From 341fe98727cfc2a46e0827a7df6615f855dae7e7 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 20 Nov 2026 17:26:27 +0800 Subject: [PATCH 1/3] fix(acp-registry): match registry-id basenames for copilot, kimi, and claude --- .../Adapters/AcpRegistryAdapterV2.test.ts | 15 +++++++++++++++ .../provider-acp-registry/src/server/adapter.ts | 13 +++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts index 35c0ec29d1148..e3f20f73d4e69 100644 --- a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts @@ -1400,6 +1400,14 @@ describe("AcpRegistryAdapterV2", () => { ), "1", ); + // A local install can be named after the registry package id too. + assert.equal( + yield* launchSwitch( + { source: "local", commandPath: "/opt/bin/claude-acp" }, + { PATH: "/opt/bin" }, + ), + "1", + ); assert.equal( yield* launchSwitch({ agentId: "claude-acp" }, { CLAUDE_AGENT_ACP_EXPERIMENTAL_V2: "0" }), "0", @@ -1472,6 +1480,13 @@ describe("AcpRegistryAdapterV2", () => { yield* steering({ source: "local", commandPath: "C:\\tools\\copilot.cmd" }), copilot, ); + assert.deepEqual( + yield* steering({ + source: "local", + commandPath: "C:\\tools\\github-copilot-cli.exe", + }), + copilot, + ); assert.deepEqual(yield* steering({ agentId: "gemini" }), { ...copilot, supportsSteeringByInterruptRestart: true, diff --git a/packages/provider-acp-registry/src/server/adapter.ts b/packages/provider-acp-registry/src/server/adapter.ts index ce5a2b94531c4..321b578c31c67 100644 --- a/packages/provider-acp-registry/src/server/adapter.ts +++ b/packages/provider-acp-registry/src/server/adapter.ts @@ -210,19 +210,24 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu /^opencode(?:-v2)?(\.exe|\.cmd)?$/i.test( options.settings.commandPath.split(/[\\/]/).pop() ?? "", )); - // Local installs launch the `copilot` binary directly with no registry id. + // Local installs launch each binary directly with no registry id; a command may + // also be named after the published package id. const isCopilot = registryAgentId === "github-copilot-cli" || (options.settings.source === "local" && - /^copilot(\.exe|\.cmd)?$/i.test(options.settings.commandPath.split(/[\\/]/).pop() ?? "")); + /^(?:github-)?copilot(?:-cli)?(\.exe|\.cmd)?$/i.test( + options.settings.commandPath.split(/[\\/]/).pop() ?? "", + )); const isKimi = registryAgentId === "kimi-code" || (options.settings.source === "local" && - /^kimi(\.exe|\.cmd)?$/i.test(options.settings.commandPath.split(/[\\/]/).pop() ?? "")); + /^kimi(?:-code)?(\.exe|\.cmd)?$/i.test( + options.settings.commandPath.split(/[\\/]/).pop() ?? "", + )); const isClaude = registryAgentId === "claude-acp" || (options.settings.source === "local" && - /^claude-agent-acp(\.exe|\.cmd)?$/i.test( + /^claude(?:-agent)?-acp(\.exe|\.cmd)?$/i.test( options.settings.commandPath.split(/[\\/]/).pop() ?? "", )); const runtimeOptions = isClaude From c64345c6eee8cf34d4156966d2fad9c6fd7e3115 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 20 Nov 2026 09:43:29 +0000 Subject: [PATCH 2/3] fix(acp-registry): keep Claude basename narrow and pin Copilot to its two names Claude has a dedicated driver, so claude-acp stays out of the registry and needs no local-basename widening. Copilot matches only copilot or github-copilot-cli rather than every combination of the optional parts. Co-Authored-By: Claude Opus 5.5 --- .../Adapters/AcpRegistryAdapterV2.test.ts | 8 -------- packages/provider-acp-registry/src/server/adapter.ts | 8 ++++---- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts index e3f20f73d4e69..4e36f74e3c510 100644 --- a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts @@ -1400,14 +1400,6 @@ describe("AcpRegistryAdapterV2", () => { ), "1", ); - // A local install can be named after the registry package id too. - assert.equal( - yield* launchSwitch( - { source: "local", commandPath: "/opt/bin/claude-acp" }, - { PATH: "/opt/bin" }, - ), - "1", - ); assert.equal( yield* launchSwitch({ agentId: "claude-acp" }, { CLAUDE_AGENT_ACP_EXPERIMENTAL_V2: "0" }), "0", diff --git a/packages/provider-acp-registry/src/server/adapter.ts b/packages/provider-acp-registry/src/server/adapter.ts index 321b578c31c67..9656a6042d935 100644 --- a/packages/provider-acp-registry/src/server/adapter.ts +++ b/packages/provider-acp-registry/src/server/adapter.ts @@ -210,12 +210,12 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu /^opencode(?:-v2)?(\.exe|\.cmd)?$/i.test( options.settings.commandPath.split(/[\\/]/).pop() ?? "", )); - // Local installs launch each binary directly with no registry id; a command may - // also be named after the published package id. + // Local installs launch the binary directly with no registry id, named either + // for the CLI or for its registry id. const isCopilot = registryAgentId === "github-copilot-cli" || (options.settings.source === "local" && - /^(?:github-)?copilot(?:-cli)?(\.exe|\.cmd)?$/i.test( + /^(?:copilot|github-copilot-cli)(\.exe|\.cmd)?$/i.test( options.settings.commandPath.split(/[\\/]/).pop() ?? "", )); const isKimi = @@ -227,7 +227,7 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu const isClaude = registryAgentId === "claude-acp" || (options.settings.source === "local" && - /^claude(?:-agent)?-acp(\.exe|\.cmd)?$/i.test( + /^claude-agent-acp(\.exe|\.cmd)?$/i.test( options.settings.commandPath.split(/[\\/]/).pop() ?? "", )); const runtimeOptions = isClaude From ba97ed88f7b7546b6a0649516772f079d016b789 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 20 Nov 2026 19:14:08 +0800 Subject: [PATCH 3/3] extract local command matcher and cover kimi-code regression --- .../src/server/adapter.localCommands.test.ts | 41 +++++++++++++++++++ .../src/server/adapter.ts | 36 ++++++++++------ 2 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 packages/provider-acp-registry/src/server/adapter.localCommands.test.ts diff --git a/packages/provider-acp-registry/src/server/adapter.localCommands.test.ts b/packages/provider-acp-registry/src/server/adapter.localCommands.test.ts new file mode 100644 index 0000000000000..02684c22fdce7 --- /dev/null +++ b/packages/provider-acp-registry/src/server/adapter.localCommands.test.ts @@ -0,0 +1,41 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { matchesLocalAgentCommand } from "./adapter.ts"; + +const KIMI = /^kimi(?:-code)?(\.exe|\.cmd)?$/i; +const COPILOT = /^(?:github-)?copilot(?:-cli)?(\.exe|\.cmd)?$/i; +const CLAUDE = /^claude(?:-agent)?-acp(\.exe|\.cmd)?$/i; + +describe("matchesLocalAgentCommand", () => { + it.each([ + ["kimi-code", true], + ["kimi", true], + ["kimi-code.exe", true], + ["kimi.cmd", true], + ["kimicode", false], + ])("local command %s enables Kimi handling: %s", (command, expected) => { + expect(matchesLocalAgentCommand(`/usr/local/bin/${command}`, "local", KIMI)).toBe(expected); + }); + + it.each([ + ["copilot", true], + ["github-copilot-cli.exe", true], + ["copilot-cli.CMD", true], + ["copilotx", false], + ])("local command %s enables Copilot handling: %s", (command, expected) => { + expect(matchesLocalAgentCommand(`C:\\Tools\\${command}`, "local", COPILOT)).toBe(expected); + }); + + it.each([ + ["claude-acp", true], + ["claude-agent-acp.exe", true], + ["claude", false], + ])("local command %s enables Claude handling: %s", (command, expected) => { + expect(matchesLocalAgentCommand(`/opt/bin/${command}`, "local", CLAUDE)).toBe(expected); + }); + + it("never matches non-local sources", () => { + expect(matchesLocalAgentCommand("/usr/bin/kimi-code", "registry", KIMI)).toBe(false); + expect(matchesLocalAgentCommand("/usr/bin/kimi-code", "npx", KIMI)).toBe(false); + }); +}); diff --git a/packages/provider-acp-registry/src/server/adapter.ts b/packages/provider-acp-registry/src/server/adapter.ts index 321b578c31c67..fab72788a8501 100644 --- a/packages/provider-acp-registry/src/server/adapter.ts +++ b/packages/provider-acp-registry/src/server/adapter.ts @@ -186,6 +186,15 @@ const isHermes = ( initializeResult: AcpSessionRuntime.AcpSessionRuntimeStartResult["initializeResult"], ) => initializeResult.agentInfo?.name === "hermes-agent"; +/** A local install launches the binary directly with no registry id, so detect it by basename. */ +export function matchesLocalAgentCommand( + commandPath: string, + source: string, + pattern: RegExp, +): boolean { + return source === "local" && pattern.test(commandPath.split(/[\\/]/).pop() ?? ""); +} + export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(function* ( options: AcpRegistryAdapterV2Options, ) { @@ -214,22 +223,25 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu // also be named after the published package id. const isCopilot = registryAgentId === "github-copilot-cli" || - (options.settings.source === "local" && - /^(?:github-)?copilot(?:-cli)?(\.exe|\.cmd)?$/i.test( - options.settings.commandPath.split(/[\\/]/).pop() ?? "", - )); + matchesLocalAgentCommand( + options.settings.commandPath, + options.settings.source, + /^(?:github-)?copilot(?:-cli)?(\.exe|\.cmd)?$/i, + ); const isKimi = registryAgentId === "kimi-code" || - (options.settings.source === "local" && - /^kimi(?:-code)?(\.exe|\.cmd)?$/i.test( - options.settings.commandPath.split(/[\\/]/).pop() ?? "", - )); + matchesLocalAgentCommand( + options.settings.commandPath, + options.settings.source, + /^kimi(?:-code)?(\.exe|\.cmd)?$/i, + ); const isClaude = registryAgentId === "claude-acp" || - (options.settings.source === "local" && - /^claude(?:-agent)?-acp(\.exe|\.cmd)?$/i.test( - options.settings.commandPath.split(/[\\/]/).pop() ?? "", - )); + matchesLocalAgentCommand( + options.settings.commandPath, + options.settings.source, + /^claude(?:-agent)?-acp(\.exe|\.cmd)?$/i, + ); const runtimeOptions = isClaude ? { ...options,