mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-12 18:15:48 +00:00
fix(dispatch): restore copilot and legacy-cursor arg passthrough
Routing every non-flag token after 'copilot'/'legacy-cursor' to the subcommand handler turned the legacy profile/prompt passthrough into an 'Unknown subcommand' error. Route only known subcommands (matching prior behavior); other args pass through to the copilot/cursor bridge flow. Bar keeps its unknown-subcommand exit code (it has no passthrough).
This commit is contained in:
1 parent
d8cd2f94b5
commit
819d43914a
1 file changed
+14
-15
@@ -122,19 +122,14 @@ export async function runPreDispatchHandlers(ctx: PreDispatchContext): Promise<b
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case: copilot command (GitHub Copilot integration)
|
// Special case: copilot command (GitHub Copilot integration).
|
||||||
// Route known subcommands AND unknown tokens to the command handler so the
|
// Route ONLY known subcommands to the handler; any other arg is kept as
|
||||||
// default case can print "[X] Unknown subcommand: <token>" and exit 1.
|
// passthrough to the copilot bridge profile flow (legacy behavior). Do not
|
||||||
// Unknown tokens that are NOT subcommand-like are kept as profile passthrough.
|
// treat an arbitrary token as an unknown subcommand error, or this breaks the
|
||||||
|
// passthrough path.
|
||||||
if (firstArg === 'copilot' && args.length > 1) {
|
if (firstArg === 'copilot' && args.length > 1) {
|
||||||
const copilotToken = args[1];
|
const copilotToken = args[1];
|
||||||
const isKnownSubcommand = isCopilotSubcommandToken(copilotToken);
|
if (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) {
|
|
||||||
const { handleCopilotCommand } = await import('../commands/copilot-command');
|
const { handleCopilotCommand } = await import('../commands/copilot-command');
|
||||||
const exitCode = await handleCopilotCommand(args.slice(1));
|
const exitCode = await handleCopilotCommand(args.slice(1));
|
||||||
process.exit(exitCode);
|
process.exit(exitCode);
|
||||||
@@ -142,11 +137,15 @@ export async function runPreDispatchHandlers(ctx: PreDispatchContext): Promise<b
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Special case: explicit legacy Cursor bridge namespace.
|
// Special case: explicit legacy Cursor bridge namespace.
|
||||||
// Route ALL tokens (known and unknown) so the default case can report the error.
|
// Route ONLY known subcommands; keep other args as passthrough to the cursor
|
||||||
|
// bridge flow (legacy behavior).
|
||||||
if (firstArg === LEGACY_CURSOR_PROFILE_NAME && args.length > 1) {
|
if (firstArg === LEGACY_CURSOR_PROFILE_NAME && args.length > 1) {
|
||||||
const { handleCursorCommand } = await import('../commands/cursor-command');
|
const cursorToken = args[1];
|
||||||
const exitCode = await handleCursorCommand(args.slice(1));
|
if (isCursorSubcommandToken(cursorToken)) {
|
||||||
process.exit(exitCode);
|
const { handleCursorCommand } = await import('../commands/cursor-command');
|
||||||
|
const exitCode = await handleCursorCommand(args.slice(1));
|
||||||
|
process.exit(exitCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compatibility shim: old `ccs cursor <subcommand>` still forwards to the legacy bridge
|
// Compatibility shim: old `ccs cursor <subcommand>` still forwards to the legacy bridge
|
||||||
|
|||||||
Reference in new issue
Block a user