mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-15 16:19:12 +00:00
Implements 6-phase CLI UX improvement plan with comprehensive error handling, interactive features, and cross-platform consistency. ### Added - Shell auto-completion (bash, zsh, PowerShell, Fish) - Error codes (E101-E901) with documentation URLs - Fuzzy matching "Did you mean?" suggestions (Levenshtein distance) - Progress indicators (doctor [n/9] counter, GLMT proxy spinner) - Interactive confirmation prompts with --yes/-y automation flag - JSON output format (--json) for auth commands - Impact display (session count, paths) before destructive operations - Comprehensive test suite (15 tests, 100% pass rate) - Complete error documentation in docs/errors/ - Cross-platform `--shell-completion` command ### Changed - Error boxes: Unicode (╔═╗) → ASCII (===) for compatibility - JSON output uses CCS version instead of schema version - Help text includes EXAMPLES section across platforms - Test suite properly counts test cases (not assertions) ### Fixed - --yes flag bug (returned false instead of true) - Help text consistency (added Uninstall section to bash) - Test pass rate calculation (excludes skipped tests) - Help section comparison (locale-specific sort) ### Testing - 13/13 tests passing (2 legitimately skipped) - Cross-platform verified (Node.js, bash, PowerShell) - All error codes documented and tested
60 lines
1.7 KiB
JavaScript
60 lines
1.7 KiB
JavaScript
// CCS Error Codes
|
|
// Documentation: ../../docs/errors/README.md
|
|
|
|
const ERROR_CODES = {
|
|
// Configuration Errors (E100-E199)
|
|
CONFIG_MISSING: 'E101',
|
|
CONFIG_INVALID_JSON: 'E102',
|
|
CONFIG_INVALID_PROFILE: 'E103',
|
|
|
|
// Profile Management Errors (E200-E299)
|
|
PROFILE_NOT_FOUND: 'E104',
|
|
PROFILE_ALREADY_EXISTS: 'E105',
|
|
PROFILE_CANNOT_DELETE_DEFAULT: 'E106',
|
|
PROFILE_INVALID_NAME: 'E107',
|
|
|
|
// Claude CLI Detection Errors (E300-E399)
|
|
CLAUDE_NOT_FOUND: 'E301',
|
|
CLAUDE_VERSION_INCOMPATIBLE: 'E302',
|
|
CLAUDE_EXECUTION_FAILED: 'E303',
|
|
|
|
// Network/API Errors (E400-E499)
|
|
GLMT_PROXY_TIMEOUT: 'E401',
|
|
API_KEY_MISSING: 'E402',
|
|
API_AUTH_FAILED: 'E403',
|
|
API_RATE_LIMIT: 'E404',
|
|
|
|
// File System Errors (E500-E599)
|
|
FS_CANNOT_CREATE_DIR: 'E501',
|
|
FS_CANNOT_WRITE_FILE: 'E502',
|
|
FS_CANNOT_READ_FILE: 'E503',
|
|
FS_INSTANCE_NOT_FOUND: 'E504',
|
|
|
|
// Internal Errors (E900-E999)
|
|
INTERNAL_ERROR: 'E900',
|
|
INVALID_STATE: 'E901'
|
|
};
|
|
|
|
// Error code documentation URL generator
|
|
function getErrorDocUrl(errorCode) {
|
|
return `https://github.com/kaitranntt/ccs/blob/main/docs/errors/README.md#${errorCode.toLowerCase()}`;
|
|
}
|
|
|
|
// Get error category from code
|
|
function getErrorCategory(errorCode) {
|
|
const code = parseInt(errorCode.substring(1));
|
|
if (code >= 100 && code < 200) return 'Configuration';
|
|
if (code >= 200 && code < 300) return 'Profile Management';
|
|
if (code >= 300 && code < 400) return 'Claude CLI Detection';
|
|
if (code >= 400 && code < 500) return 'Network/API';
|
|
if (code >= 500 && code < 600) return 'File System';
|
|
if (code >= 900 && code < 1000) return 'Internal';
|
|
return 'Unknown';
|
|
}
|
|
|
|
module.exports = {
|
|
ERROR_CODES,
|
|
getErrorDocUrl,
|
|
getErrorCategory
|
|
};
|