nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Feature] Rename ACP extension methods to the reserved `_` prefix and advertise them under `_meta` in `agentCapabilities`

Open addyCooks opened this issue 1 month ago • 0 comments

Description

ACP reserves method names that start with _ for custom methods, and says extensions should advertise themselves under _meta in capability objects. Nanocoder's ACP agent has four custom request methods with bare names (renameSession, timeline/list, timeline/revert, retryTurn), and it advertises none of its extensions.

I'd like to:

  1. Add _-prefixed names for these methods, following the _nanocoder/... style Nanocoder already uses for _nanocoder/sessionTitleChanged.
  2. Keep the bare names working as deprecated aliases for a while.
  3. Advertise the extensions under _meta in agentCapabilities, listing the exact method names, so clients can detect support and use the advertised names without guessing from the Nanocoder version.

Tracked from Nano-Collective/nanocoder-desktop#12 (item 7). The gap was first noted as finding 2 ("extension methods are not declared as capabilities") in Nano-Collective/docs#122. Related: #1889, #1891 and #1892, which add more extension methods and should follow whatever naming this settles.

Use Case

  • Protocol compliance. ACP's extensibility rules say custom methods start with _, so they can't collide with methods added to the protocol later. A bare timeline/list could clash with a future standard method.
  • Capability detection. A client such as Nanocoder Desktop has to guess from the version whether timeline/list or renameSession exists, or call it and interpret the error. Today an unknown method fails with a generic error, so a client can't reliably tell "unknown method" from a real failure. Advertised capabilities let a client check first, which is what the ACP docs recommend.
  • Consistency. Nanocoder already uses _nanocoder/sessionTitleChanged for a notification and nanocoder/... keys in _meta. The four request methods are the exception.

This is a nice-to-have for the desktop, which can work around it with an adapter that tries the prefixed name first and the bare name second. It is not blocking.

Proposed Solution

  1. New names. For example:
    • _nanocoder/renameSession
    • _nanocoder/timeline/list
    • _nanocoder/timeline/revert
    • _nanocoder/retryTurn
  2. Deprecated aliases. Keep the bare names working for at least one release, log a one-time deprecation notice when one is used, and remove them in a later release that is announced in the changelog.
  3. Advertise the exact names. In getAgentCapabilities(), add _meta with a Nanocoder entry listing the supported extension requests and notifications, for example _meta: {nanocoder: {extMethods: [...], extNotifications: ['_nanocoder/sessionTitleChanged']}}. Clients should take the method names from this list as they are, and never build them by adding a prefix.
  4. Unknown methods. Return the standard "Method not found" (-32601) for an unrecognized custom request, as ACP says, so a client can tell "not supported" from "failed". Today it throws a plain Error.
  5. Update the VS Code extension to call the new names when they are advertised and fall back to the bare names otherwise.
  6. Docs. Update docs/features/acp.md, which mentions renameSession, to list the new names, the aliases and the advertised capabilities.

Alternatives Considered

  • Do nothing. Clients keep guessing from the Nanocoder version, and bare names stay at risk of colliding with future protocol methods.
  • Rename without aliases. Simpler, but it breaks every existing client, including older versions of the VS Code extension.
  • Advertise without renaming. Fixes detection but leaves the reserved-name problem.
  • A different namespace, such as _nanocoder.dev/... like the ACP example _zed.dev/.... A domain-style name is more collision-proof, but Nanocoder already uses _nanocoder/... for sessionTitleChanged, so I'd keep that.

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] This feature aligns with the project's goals (local-first AI assistance)

Current behavior, checked against main at fc01e23:

  • source/acp/acp-agent.ts (~L712-829): extMethod handles renameSession, timeline/list, timeline/revert and retryTurn by bare name. Any other method throws Error('Unknown extension method: ...').
  • @agentclientprotocol/sdk 1.4.0 (the version in pnpm-lock.yaml) sends and routes custom method names exactly as given. extMethod(method) calls request(method), and incoming requests reach extMethod(message.method, ...) unchanged. Nothing adds or strips a _, so these names are on the wire as bare names.
  • source/acp/acp-agent.ts (~L490): the agent already sends _nanocoder/sessionTitleChanged, and responses use _meta keys such as nanocoder/artifacts, nanocoder/usage and nanocoder/artifact.
  • source/acp/acp-capabilities.ts (~L25): getAgentCapabilities() returns loadSession, providers and sessionCapabilities, with no _meta.
  • plugins/vscode/src/acp-client.ts (~L513, L562): the VS Code extension calls extMethod('renameSession', ...) and extMethod('retryTurn', ...).
  • source/acp/acp-agent.spec.ts references these methods in about 46 places.
  • docs/features/acp.md documents renameSession.
  • ACP's extensibility page: custom methods use the _ prefix, an unrecognized custom request should return "Method not found", and extensions should be advertised under _meta in capability objects. The root level of spec-defined types is reserved.

Implementation Notes (optional)

In extMethod, normalize the incoming name first: strip a leading _nanocoder/ if present, then dispatch on the existing branches, and log a deprecation notice when a bare name is used. The advertised list can be built from the same table that dispatches, so the two never drift.

Open questions for maintainers:

  1. Exact names. _nanocoder/timeline/list or _nanocoder/timelineList? Another option is a plain _renameSession. Whatever is chosen, the advertisement states it, so clients don't have to guess.
  2. Shape of the advertisement. One nanocoder object under agentCapabilities._meta with the method lists, or one flag per feature?
  3. Alias lifetime. One minor release, or longer to give the VS Code extension and third-party clients time?
  4. Should notifications be listed too? _nanocoder/sessionTitleChanged is already prefixed. Listing it in the advertisement lets clients know whether to expect it.
  5. Should the advertisement carry a version, so later additions (for example the method proposed in #1892) are discoverable?

Acceptance criteria:

  • [ ] The four methods respond to their _nanocoder/... names with the same results as before.
  • [ ] The bare names still work and log a one-time deprecation notice.
  • [ ] initialize returns agentCapabilities._meta listing the exact supported extension methods and notifications.
  • [ ] An unknown custom request returns "Method not found" (-32601).
  • [ ] The VS Code extension uses the new names when advertised and falls back to the bare names otherwise.
  • [ ] docs/features/acp.md lists the new names, the aliases, and the advertised capabilities.
  • [ ] _nanocoder/sessionTitleChanged and the existing nanocoder/... _meta keys are unchanged.

Test plan:

  • ACP spec: each method answers on the new name and on the bare alias, with identical results.
  • ACP spec: the deprecation notice is logged once per bare name.
  • ACP spec: initialize advertises the expected _meta entry, and every advertised name is handled.
  • ACP spec: an unknown _-prefixed request returns -32601.
  • VS Code extension: renaming a session and retrying a turn work against an agent that advertises the new names and against one that does not.

Out of scope: adding new extension methods (#1889, #1891, #1892), changing what any method does, and renaming _meta keys on responses or the existing notification.

addyCooks avatar Oct 26 '26 16:10 addyCooks