refactor(cli): slim cursor completion imports

- extract cursor subcommand constants into a lightweight module

- remove redundant copilot token concatenation from the command catalog
This commit is contained in:
Tam Nhu Tran
2026-04-03 00:53:10 -04:00
parent 86b30eb9f5
commit 3dcf879c9f
4 changed files with 22 additions and 27 deletions
+2 -3
View File
@@ -55,6 +55,7 @@ import {
resolveOfficialChannelsLaunchPlan,
} from './channels/official-channels-runtime';
import { getOfficialChannelReadiness } from './channels/official-channels-store';
import { isCursorSubcommandToken } from './cursor/constants';
// Import centralized error handling
import { handleError, runCleanup } from './errors';
@@ -467,9 +468,7 @@ async function main(): Promise<void> {
// Special case: cursor command (Cursor local proxy integration)
// Route known admin subcommands to the command handler, keep all other args as profile passthrough.
if (firstArg === 'cursor' && args.length > 1) {
const { isCursorSubcommandToken, handleCursorCommand } = await import(
'./commands/cursor-command'
);
const { handleCursorCommand } = await import('./commands/cursor-command');
const cursorToken = args[1];
if (isCursorSubcommandToken(cursorToken)) {
+2 -4
View File
@@ -1,6 +1,6 @@
import { COPILOT_SUBCOMMANDS } from '../copilot/constants';
import { CURSOR_SUBCOMMANDS } from '../cursor/constants';
import { CLIPROXY_PROVIDER_IDS } from '../cliproxy/provider-capabilities';
import { CURSOR_SUBCOMMANDS } from './cursor-command';
export type HelpTopicName = 'profiles' | 'providers' | 'completion' | 'targets';
@@ -310,9 +310,7 @@ export function getPublicRootCommands(): readonly RootCommandEntry[] {
export function getAllRootCommandTokens(): string[] {
return uniqueStrings(
ROOT_COMMAND_CATALOG.flatMap((entry) => [entry.name, ...(entry.aliases || [])]).concat(
'copilot'
)
ROOT_COMMAND_CATALOG.flatMap((entry) => [entry.name, ...(entry.aliases || [])])
);
}
-20
View File
@@ -20,26 +20,6 @@ import { DEFAULT_CURSOR_CONFIG } from '../config/unified-config-types';
import { renderCursorHelp, renderCursorModels, renderCursorStatus } from './cursor-command-display';
import { ok, fail, info } from '../utils/ui';
/** Valid cursor subcommands — imported by ccs.ts for routing */
export const CURSOR_SUBCOMMANDS = [
'auth',
'status',
'models',
'start',
'stop',
'enable',
'disable',
'help',
'--help',
'-h',
] as const;
export function isCursorSubcommandToken(token?: string): boolean {
return (
Boolean(token) && CURSOR_SUBCOMMANDS.includes(token as (typeof CURSOR_SUBCOMMANDS)[number])
);
}
/**
* Handle cursor subcommand.
*/
+18
View File
@@ -0,0 +1,18 @@
export const CURSOR_SUBCOMMANDS = [
'auth',
'status',
'models',
'start',
'stop',
'enable',
'disable',
'help',
'--help',
'-h',
] as const;
export function isCursorSubcommandToken(token?: string): boolean {
return (
Boolean(token) && CURSOR_SUBCOMMANDS.includes(token as (typeof CURSOR_SUBCOMMANDS)[number])
);
}