diff --git a/src/dispatcher/pre-dispatch.ts b/src/dispatcher/pre-dispatch.ts index e5c0d4eb..32b4c897 100644 --- a/src/dispatcher/pre-dispatch.ts +++ b/src/dispatcher/pre-dispatch.ts @@ -122,19 +122,14 @@ export async function runPreDispatchHandlers(ctx: PreDispatchContext): Promise" and exit 1. - // Unknown tokens that are NOT subcommand-like are kept as profile passthrough. + // Special case: copilot command (GitHub Copilot integration). + // Route ONLY known subcommands to the handler; any other arg is kept as + // passthrough to the copilot bridge profile flow (legacy behavior). Do not + // treat an arbitrary token as an unknown subcommand error, or this breaks the + // passthrough path. if (firstArg === 'copilot' && args.length > 1) { const copilotToken = args[1]; - const isKnownSubcommand = isCopilotSubcommandToken(copilotToken); - // Route any non-flag, non-profile-looking second token to the handler so - // the default branch fires with the correct error message. - const looksLikeCopilotSubcmd = - isKnownSubcommand || (typeof copilotToken === 'string' && !copilotToken.startsWith('-')); - - if (looksLikeCopilotSubcmd) { + if (isCopilotSubcommandToken(copilotToken)) { const { handleCopilotCommand } = await import('../commands/copilot-command'); const exitCode = await handleCopilotCommand(args.slice(1)); process.exit(exitCode); @@ -142,11 +137,15 @@ export async function runPreDispatchHandlers(ctx: PreDispatchContext): Promise 1) { - const { handleCursorCommand } = await import('../commands/cursor-command'); - const exitCode = await handleCursorCommand(args.slice(1)); - process.exit(exitCode); + const cursorToken = args[1]; + if (isCursorSubcommandToken(cursorToken)) { + const { handleCursorCommand } = await import('../commands/cursor-command'); + const exitCode = await handleCursorCommand(args.slice(1)); + process.exit(exitCode); + } } // Compatibility shim: old `ccs cursor ` still forwards to the legacy bridge