mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-02 12:19:35 +00:00
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:
+2
-3
@@ -55,6 +55,7 @@ import {
|
|||||||
resolveOfficialChannelsLaunchPlan,
|
resolveOfficialChannelsLaunchPlan,
|
||||||
} from './channels/official-channels-runtime';
|
} from './channels/official-channels-runtime';
|
||||||
import { getOfficialChannelReadiness } from './channels/official-channels-store';
|
import { getOfficialChannelReadiness } from './channels/official-channels-store';
|
||||||
|
import { isCursorSubcommandToken } from './cursor/constants';
|
||||||
|
|
||||||
// Import centralized error handling
|
// Import centralized error handling
|
||||||
import { handleError, runCleanup } from './errors';
|
import { handleError, runCleanup } from './errors';
|
||||||
@@ -467,9 +468,7 @@ async function main(): Promise<void> {
|
|||||||
// Special case: cursor command (Cursor local proxy integration)
|
// Special case: cursor command (Cursor local proxy integration)
|
||||||
// Route known admin subcommands to the command handler, keep all other args as profile passthrough.
|
// Route known admin subcommands to the command handler, keep all other args as profile passthrough.
|
||||||
if (firstArg === 'cursor' && args.length > 1) {
|
if (firstArg === 'cursor' && args.length > 1) {
|
||||||
const { isCursorSubcommandToken, handleCursorCommand } = await import(
|
const { handleCursorCommand } = await import('./commands/cursor-command');
|
||||||
'./commands/cursor-command'
|
|
||||||
);
|
|
||||||
const cursorToken = args[1];
|
const cursorToken = args[1];
|
||||||
|
|
||||||
if (isCursorSubcommandToken(cursorToken)) {
|
if (isCursorSubcommandToken(cursorToken)) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { COPILOT_SUBCOMMANDS } from '../copilot/constants';
|
import { COPILOT_SUBCOMMANDS } from '../copilot/constants';
|
||||||
|
import { CURSOR_SUBCOMMANDS } from '../cursor/constants';
|
||||||
import { CLIPROXY_PROVIDER_IDS } from '../cliproxy/provider-capabilities';
|
import { CLIPROXY_PROVIDER_IDS } from '../cliproxy/provider-capabilities';
|
||||||
import { CURSOR_SUBCOMMANDS } from './cursor-command';
|
|
||||||
|
|
||||||
export type HelpTopicName = 'profiles' | 'providers' | 'completion' | 'targets';
|
export type HelpTopicName = 'profiles' | 'providers' | 'completion' | 'targets';
|
||||||
|
|
||||||
@@ -310,9 +310,7 @@ export function getPublicRootCommands(): readonly RootCommandEntry[] {
|
|||||||
|
|
||||||
export function getAllRootCommandTokens(): string[] {
|
export function getAllRootCommandTokens(): string[] {
|
||||||
return uniqueStrings(
|
return uniqueStrings(
|
||||||
ROOT_COMMAND_CATALOG.flatMap((entry) => [entry.name, ...(entry.aliases || [])]).concat(
|
ROOT_COMMAND_CATALOG.flatMap((entry) => [entry.name, ...(entry.aliases || [])])
|
||||||
'copilot'
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,26 +20,6 @@ import { DEFAULT_CURSOR_CONFIG } from '../config/unified-config-types';
|
|||||||
import { renderCursorHelp, renderCursorModels, renderCursorStatus } from './cursor-command-display';
|
import { renderCursorHelp, renderCursorModels, renderCursorStatus } from './cursor-command-display';
|
||||||
import { ok, fail, info } from '../utils/ui';
|
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.
|
* Handle cursor subcommand.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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])
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user