diff --git a/packages/shared/src/agent-command.test.ts b/packages/shared/src/agent-command.test.ts index 6796358105d..8480d45baca 100644 --- a/packages/shared/src/agent-command.test.ts +++ b/packages/shared/src/agent-command.test.ts @@ -60,4 +60,21 @@ describe("buildAgentPromptCommand", () => { expect(command).toStartWith("pi \"$(cat <<'SUPERSET_PROMPT_pi1234'"); expect(command).not.toContain("pi -p"); }); + + it("passes copilot prompts via --prompt flag, not as positional", () => { + // Repro for #3862: `copilot -i ... ""` errors with + // "Expected 0 arguments but got 1." because interactive mode does + // not accept a positional prompt. The prompt must be passed via + // the --prompt flag. + const command = buildAgentPromptCommand({ + prompt: "hello", + randomId: "copilot-1234", + agent: "copilot", + }); + + expect(command).not.toMatch(/\bcopilot\b[^"]*\s-i\b/); + expect(command).toStartWith( + "copilot --allow-tool=write --prompt \"$(cat <<'SUPERSET_PROMPT_copilot1234'", + ); + }); }); diff --git a/packages/shared/src/agent-permissions-migration.ts b/packages/shared/src/agent-permissions-migration.ts index cda447361c9..89236644f4d 100644 --- a/packages/shared/src/agent-permissions-migration.ts +++ b/packages/shared/src/agent-permissions-migration.ts @@ -41,7 +41,7 @@ export const LEGACY_BUILTIN_TERMINAL_AGENT_OVERRIDES: Readonly< }, copilot: { command: "copilot --allow-all", - promptCommand: "copilot -i --allow-all", + promptCommand: "copilot --allow-all --prompt", promptCommandSuffix: "--yolo", }, "cursor-agent": { diff --git a/packages/shared/src/builtin-terminal-agents.ts b/packages/shared/src/builtin-terminal-agents.ts index 294098270ae..649822cfa68 100644 --- a/packages/shared/src/builtin-terminal-agents.ts +++ b/packages/shared/src/builtin-terminal-agents.ts @@ -121,7 +121,7 @@ export const BUILTIN_TERMINAL_AGENTS = [ description: "GitHub's coding agent for planning, editing, and building in your repo.", command: "copilot --allow-tool=write", - promptCommand: "copilot -i --allow-tool=write", + promptCommand: "copilot --allow-tool=write --prompt", includeInDefaultTerminalPresets: true, }), createBuiltinTerminalAgent({