mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-17 04:17:11 +00:00
86 lines
2.9 KiB
TypeScript
86 lines
2.9 KiB
TypeScript
/**
|
|
* Version Command Handler
|
|
*
|
|
* Handle --version command for CCS.
|
|
*/
|
|
|
|
import * as path from 'path';
|
|
import * as fs from 'fs';
|
|
import * as os from 'os';
|
|
import { colored } from '../utils/helpers';
|
|
import { getConfigPath } from '../utils/config-manager';
|
|
import { getVersion } from '../utils/version';
|
|
|
|
/**
|
|
* Handle version command
|
|
*/
|
|
export function handleVersionCommand(): void {
|
|
console.log(colored(`CCS (Claude Code Switch) v${getVersion()}`, 'bold'));
|
|
console.log('');
|
|
|
|
console.log(colored('Installation:', 'cyan'));
|
|
const installLocation = process.argv[1] || '(not found)';
|
|
console.log(` ${colored('Location:'.padEnd(17), 'cyan')} ${installLocation}`);
|
|
|
|
const ccsDir = path.join(os.homedir(), '.ccs');
|
|
console.log(` ${colored('CCS Directory:'.padEnd(17), 'cyan')} ${ccsDir}`);
|
|
|
|
const configPath = getConfigPath();
|
|
console.log(` ${colored('Config:'.padEnd(17), 'cyan')} ${configPath}`);
|
|
|
|
const profilesJson = path.join(os.homedir(), '.ccs', 'profiles.json');
|
|
console.log(` ${colored('Profiles:'.padEnd(17), 'cyan')} ${profilesJson}`);
|
|
|
|
// Delegation status
|
|
const delegationSessionsPath = path.join(os.homedir(), '.ccs', 'delegation-sessions.json');
|
|
const delegationConfigured = fs.existsSync(delegationSessionsPath);
|
|
|
|
const readyProfiles: string[] = [];
|
|
|
|
// Check for profiles with valid API keys
|
|
for (const profile of ['glm', 'kimi']) {
|
|
const settingsPath = path.join(os.homedir(), '.ccs', `${profile}.settings.json`);
|
|
if (fs.existsSync(settingsPath)) {
|
|
try {
|
|
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
const apiKey = settings.env?.ANTHROPIC_AUTH_TOKEN;
|
|
if (apiKey && !apiKey.match(/YOUR_.*_API_KEY_HERE/) && !apiKey.match(/sk-test.*/)) {
|
|
readyProfiles.push(profile);
|
|
}
|
|
} catch (_error) {
|
|
// Invalid JSON, skip
|
|
}
|
|
}
|
|
}
|
|
|
|
const hasValidApiKeys = readyProfiles.length > 0;
|
|
const delegationEnabled = delegationConfigured || hasValidApiKeys;
|
|
|
|
if (delegationEnabled) {
|
|
console.log(` ${colored('Delegation:'.padEnd(17), 'cyan')} Enabled`);
|
|
} else {
|
|
console.log(` ${colored('Delegation:'.padEnd(17), 'cyan')} Not configured`);
|
|
}
|
|
|
|
console.log('');
|
|
|
|
if (readyProfiles.length > 0) {
|
|
console.log(colored('Delegation Ready:', 'cyan'));
|
|
console.log(
|
|
` ${colored('[OK]', 'yellow')} ${readyProfiles.join(', ')} profiles are ready for delegation`
|
|
);
|
|
console.log('');
|
|
} else if (delegationEnabled) {
|
|
console.log(colored('Delegation Ready:', 'cyan'));
|
|
console.log(` ${colored('[!]', 'yellow')} Delegation configured but no valid API keys found`);
|
|
console.log('');
|
|
}
|
|
|
|
console.log(`${colored('Documentation:', 'cyan')} https://github.com/kaitranntt/ccs`);
|
|
console.log(`${colored('License:', 'cyan')} MIT`);
|
|
console.log('');
|
|
console.log(colored("Run 'ccs --help' for usage information", 'yellow'));
|
|
|
|
process.exit(0);
|
|
}
|