@xwm111/ccs 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +65 -0
- package/bin/ccs.mjs +2 -0
- package/dist/chunks/auto-updater.mjs +1708 -0
- package/dist/chunks/claude-code-incremental-manager.mjs +576 -0
- package/dist/chunks/installer.mjs +610 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +2407 -0
- package/dist/i18n/locales/en/api.json +51 -0
- package/dist/i18n/locales/en/cli.json +58 -0
- package/dist/i18n/locales/en/common.json +19 -0
- package/dist/i18n/locales/en/configuration.json +81 -0
- package/dist/i18n/locales/en/errors.json +26 -0
- package/dist/i18n/locales/en/installation.json +80 -0
- package/dist/i18n/locales/en/language.json +19 -0
- package/dist/i18n/locales/en/menu.json +31 -0
- package/dist/i18n/locales/en/multi-config.json +79 -0
- package/dist/i18n/locales/en/uninstall.json +56 -0
- package/dist/i18n/locales/en/updater.json +26 -0
- package/dist/i18n/locales/zh-CN/api.json +51 -0
- package/dist/i18n/locales/zh-CN/cli.json +58 -0
- package/dist/i18n/locales/zh-CN/common.json +19 -0
- package/dist/i18n/locales/zh-CN/configuration.json +81 -0
- package/dist/i18n/locales/zh-CN/errors.json +26 -0
- package/dist/i18n/locales/zh-CN/installation.json +80 -0
- package/dist/i18n/locales/zh-CN/language.json +19 -0
- package/dist/i18n/locales/zh-CN/menu.json +31 -0
- package/dist/i18n/locales/zh-CN/multi-config.json +79 -0
- package/dist/i18n/locales/zh-CN/uninstall.json +56 -0
- package/dist/i18n/locales/zh-CN/updater.json +26 -0
- package/dist/index.d.mts +222 -0
- package/dist/index.d.ts +222 -0
- package/dist/index.mjs +18 -0
- package/package.json +109 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
declare const CLAUDE_DIR: string;
|
|
2
|
+
declare const SETTINGS_FILE: string;
|
|
3
|
+
declare const CLAUDE_MD_FILE: string;
|
|
4
|
+
declare const ClAUDE_CONFIG_FILE: string;
|
|
5
|
+
declare const CLAUDE_VSC_CONFIG_FILE: string;
|
|
6
|
+
declare const ZCF_CONFIG_DIR: string;
|
|
7
|
+
declare const ZCF_CONFIG_FILE: string;
|
|
8
|
+
declare const LEGACY_ZCF_CONFIG_FILES: string[];
|
|
9
|
+
declare const CODE_TOOL_TYPES: readonly ["claude-code"];
|
|
10
|
+
type CodeToolType = (typeof CODE_TOOL_TYPES)[number];
|
|
11
|
+
declare const DEFAULT_CODE_TOOL_TYPE: CodeToolType;
|
|
12
|
+
declare const CODE_TOOL_BANNERS: Record<CodeToolType, string>;
|
|
13
|
+
declare const CODE_TOOL_ALIASES: Record<string, CodeToolType>;
|
|
14
|
+
declare function isCodeToolType(value: any): value is CodeToolType;
|
|
15
|
+
declare const API_DEFAULT_URL = "https://api.anthropic.com";
|
|
16
|
+
declare const API_ENV_KEY = "ANTHROPIC_API_KEY";
|
|
17
|
+
declare function resolveCodeToolType(value: unknown): CodeToolType;
|
|
18
|
+
declare const SUPPORTED_LANGS: readonly ["zh-CN", "en"];
|
|
19
|
+
type SupportedLang = (typeof SUPPORTED_LANGS)[number];
|
|
20
|
+
declare const LANG_LABELS: {
|
|
21
|
+
readonly 'zh-CN': "简体中文";
|
|
22
|
+
readonly en: "English";
|
|
23
|
+
};
|
|
24
|
+
declare const AI_OUTPUT_LANGUAGES: {
|
|
25
|
+
readonly 'zh-CN': {
|
|
26
|
+
readonly directive: "Always respond in Chinese-simplified";
|
|
27
|
+
};
|
|
28
|
+
readonly en: {
|
|
29
|
+
readonly directive: "Always respond in English";
|
|
30
|
+
};
|
|
31
|
+
readonly custom: {
|
|
32
|
+
readonly directive: "";
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
type AiOutputLanguage = keyof typeof AI_OUTPUT_LANGUAGES;
|
|
36
|
+
declare function getAiOutputLanguageLabel(lang: AiOutputLanguage): string;
|
|
37
|
+
|
|
38
|
+
declare function getPlatform(): 'windows' | 'macos' | 'linux';
|
|
39
|
+
declare function commandExists(command: string): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Get recommended install methods for a code tool based on current platform
|
|
42
|
+
* Returns methods in priority order (most recommended first)
|
|
43
|
+
*/
|
|
44
|
+
type CodeType = 'claude-code' | 'codex';
|
|
45
|
+
type InstallMethod$1 = 'npm' | 'homebrew' | 'curl' | 'powershell' | 'cmd' | 'npm-global' | 'native';
|
|
46
|
+
|
|
47
|
+
interface McpService {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
description: string;
|
|
51
|
+
requiresApiKey: boolean;
|
|
52
|
+
apiKeyPrompt?: string;
|
|
53
|
+
apiKeyPlaceholder?: string;
|
|
54
|
+
apiKeyEnvVar?: string;
|
|
55
|
+
config: McpServerConfig;
|
|
56
|
+
}
|
|
57
|
+
interface McpServerConfig {
|
|
58
|
+
type: 'stdio' | 'sse';
|
|
59
|
+
command?: string;
|
|
60
|
+
args?: string[];
|
|
61
|
+
url?: string;
|
|
62
|
+
env?: Record<string, string>;
|
|
63
|
+
startup_timeout_ms?: number;
|
|
64
|
+
}
|
|
65
|
+
interface ClaudeConfiguration {
|
|
66
|
+
mcpServers: Record<string, McpServerConfig>;
|
|
67
|
+
hasCompletedOnboarding?: boolean;
|
|
68
|
+
customApiKeyResponses?: {
|
|
69
|
+
approved: string[];
|
|
70
|
+
rejected: string[];
|
|
71
|
+
};
|
|
72
|
+
env?: Record<string, string>;
|
|
73
|
+
primaryApiKey?: string;
|
|
74
|
+
installMethod?: InstallMethod$1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* API configuration for Claude Code
|
|
79
|
+
*/
|
|
80
|
+
interface ApiConfig {
|
|
81
|
+
url: string;
|
|
82
|
+
key: string;
|
|
83
|
+
authType?: 'auth_token' | 'api_key';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Installation method types for code tools
|
|
87
|
+
*/
|
|
88
|
+
type InstallMethod = 'npm' | 'homebrew' | 'curl' | 'powershell' | 'cmd';
|
|
89
|
+
|
|
90
|
+
declare function ensureClaudeDir(): void;
|
|
91
|
+
declare function backupExistingConfig(): string | null;
|
|
92
|
+
declare function copyConfigFiles(onlyMd?: boolean): void;
|
|
93
|
+
declare function configureApi(apiConfig: ApiConfig | null): ApiConfig | null;
|
|
94
|
+
declare function mergeConfigs(sourceFile: string, targetFile: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* Update custom model configuration using environment variables
|
|
97
|
+
* @param primaryModel - Primary model name for general tasks
|
|
98
|
+
* @param haikuModel - Default Haiku model (optional)
|
|
99
|
+
* @param sonnetModel - Default Sonnet model (optional)
|
|
100
|
+
* @param opusModel - Default Opus model (optional)
|
|
101
|
+
*/
|
|
102
|
+
declare function updateCustomModel(primaryModel?: string, haikuModel?: string, sonnetModel?: string, opusModel?: string): void;
|
|
103
|
+
/**
|
|
104
|
+
* Update the default model configuration in settings.json
|
|
105
|
+
* @param model - The model type to set: opus, sonnet, sonnet[1m], default, or custom
|
|
106
|
+
* Note: 'custom' model type is handled differently - it should use environment variables instead
|
|
107
|
+
*/
|
|
108
|
+
declare function updateDefaultModel(model: 'opus' | 'sonnet' | 'sonnet[1m]' | 'default' | 'custom'): void;
|
|
109
|
+
/**
|
|
110
|
+
* Merge settings.json intelligently
|
|
111
|
+
* Preserves user's environment variables and custom configurations
|
|
112
|
+
*/
|
|
113
|
+
declare function mergeSettingsFile(templatePath: string, targetPath: string): void;
|
|
114
|
+
/**
|
|
115
|
+
* Get existing model configuration from settings.json
|
|
116
|
+
*/
|
|
117
|
+
declare function getExistingModelConfig(): 'opus' | 'sonnet' | 'sonnet[1m]' | 'default' | 'custom' | null;
|
|
118
|
+
/**
|
|
119
|
+
* Get existing API configuration from settings.json
|
|
120
|
+
*/
|
|
121
|
+
declare function getExistingApiConfig(): ApiConfig | null;
|
|
122
|
+
declare function applyAiLanguageDirective(aiOutputLang: AiOutputLanguage | string): void;
|
|
123
|
+
/**
|
|
124
|
+
* Switch to official login mode - remove all third-party API configurations
|
|
125
|
+
* Removes: ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY from settings.json
|
|
126
|
+
* Removes: primaryApiKey from ~/.claude/config.json
|
|
127
|
+
*/
|
|
128
|
+
declare function switchToOfficialLogin(): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Prompt user for API configuration action when existing config is found
|
|
131
|
+
* Returns the user's choice for how to handle existing configuration
|
|
132
|
+
*/
|
|
133
|
+
declare function promptApiConfigurationAction(): Promise<'modify-partial' | 'modify-all' | 'keep-existing' | null>;
|
|
134
|
+
|
|
135
|
+
declare function isClaudeCodeInstalled(): Promise<boolean>;
|
|
136
|
+
/**
|
|
137
|
+
* Install Claude Code with method selection support
|
|
138
|
+
* @param skipMethodSelection - If true, use default npm installation
|
|
139
|
+
*/
|
|
140
|
+
declare function installClaudeCode(skipMethodSelection?: boolean): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Check if local Claude Code installation exists
|
|
143
|
+
*/
|
|
144
|
+
declare function isLocalClaudeCodeInstalled(): Promise<boolean>;
|
|
145
|
+
/**
|
|
146
|
+
* Get installation status for both global and local Claude Code
|
|
147
|
+
*/
|
|
148
|
+
interface InstallationStatus {
|
|
149
|
+
hasGlobal: boolean;
|
|
150
|
+
hasLocal: boolean;
|
|
151
|
+
localPath: string;
|
|
152
|
+
}
|
|
153
|
+
declare function getInstallationStatus(): Promise<InstallationStatus>;
|
|
154
|
+
/**
|
|
155
|
+
* Remove local Claude Code installation
|
|
156
|
+
*/
|
|
157
|
+
declare function removeLocalClaudeCode(): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Uninstall code tool based on install method
|
|
160
|
+
* @param codeType - Type of code tool to uninstall
|
|
161
|
+
* @returns true if uninstalled successfully
|
|
162
|
+
*/
|
|
163
|
+
declare function uninstallCodeTool(codeType: CodeType): Promise<boolean>;
|
|
164
|
+
/**
|
|
165
|
+
* Set installMethod in both ~/.claude.json and zcf-config
|
|
166
|
+
* This ensures Claude Code knows it was installed via npm for proper auto-updates
|
|
167
|
+
*/
|
|
168
|
+
declare function setInstallMethod(method: InstallMethod, codeType?: CodeType): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Detect installed version of a code tool
|
|
171
|
+
* Returns version string or null if not installed
|
|
172
|
+
*/
|
|
173
|
+
declare function detectInstalledVersion(codeType: CodeType): Promise<string | null>;
|
|
174
|
+
/**
|
|
175
|
+
* Select installation method interactively
|
|
176
|
+
*/
|
|
177
|
+
declare function selectInstallMethod(codeType: CodeType, excludeMethods?: InstallMethod[]): Promise<InstallMethod | null>;
|
|
178
|
+
/**
|
|
179
|
+
* Execute installation using specified method
|
|
180
|
+
*/
|
|
181
|
+
declare function executeInstallMethod(method: InstallMethod, codeType: CodeType): Promise<boolean>;
|
|
182
|
+
/**
|
|
183
|
+
* Handle installation failure with retry options
|
|
184
|
+
*/
|
|
185
|
+
declare function handleInstallFailure(codeType: CodeType, failedMethods: InstallMethod[]): Promise<boolean>;
|
|
186
|
+
/**
|
|
187
|
+
* Installation verification result
|
|
188
|
+
*/
|
|
189
|
+
interface VerificationResult {
|
|
190
|
+
success: boolean;
|
|
191
|
+
commandPath: string | null;
|
|
192
|
+
version: string | null;
|
|
193
|
+
needsSymlink: boolean;
|
|
194
|
+
symlinkCreated: boolean;
|
|
195
|
+
error?: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Verify installation by checking command availability and version
|
|
199
|
+
* If command is not in PATH but found in Homebrew paths, attempt to create symlink
|
|
200
|
+
*/
|
|
201
|
+
declare function verifyInstallation(codeType: CodeType): Promise<VerificationResult>;
|
|
202
|
+
/**
|
|
203
|
+
* Symlink creation result
|
|
204
|
+
*/
|
|
205
|
+
interface SymlinkResult {
|
|
206
|
+
success: boolean;
|
|
207
|
+
symlinkPath: string | null;
|
|
208
|
+
error?: string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Create symlink in Homebrew bin directory for commands installed via npm
|
|
212
|
+
* This handles the case where npm global packages are installed to
|
|
213
|
+
* /opt/homebrew/Cellar/node/{version}/bin/ but that path is not in the user's PATH
|
|
214
|
+
*/
|
|
215
|
+
declare function createHomebrewSymlink(command: string, sourcePath: string): Promise<SymlinkResult>;
|
|
216
|
+
/**
|
|
217
|
+
* Display verification result to user with appropriate messages
|
|
218
|
+
*/
|
|
219
|
+
declare function displayVerificationResult(result: VerificationResult, _codeType: CodeType): void;
|
|
220
|
+
|
|
221
|
+
export { AI_OUTPUT_LANGUAGES, API_DEFAULT_URL, API_ENV_KEY, CLAUDE_DIR, CLAUDE_MD_FILE, CLAUDE_VSC_CONFIG_FILE, CODE_TOOL_ALIASES, CODE_TOOL_BANNERS, CODE_TOOL_TYPES, ClAUDE_CONFIG_FILE, DEFAULT_CODE_TOOL_TYPE, LANG_LABELS, LEGACY_ZCF_CONFIG_FILES, SETTINGS_FILE, SUPPORTED_LANGS, ZCF_CONFIG_DIR, ZCF_CONFIG_FILE, applyAiLanguageDirective, backupExistingConfig, commandExists, configureApi, copyConfigFiles, createHomebrewSymlink, detectInstalledVersion, displayVerificationResult, ensureClaudeDir, executeInstallMethod, getAiOutputLanguageLabel, getExistingApiConfig, getExistingModelConfig, getInstallationStatus, getPlatform, handleInstallFailure, installClaudeCode, isClaudeCodeInstalled, isCodeToolType, isLocalClaudeCodeInstalled, mergeConfigs, mergeSettingsFile, promptApiConfigurationAction, removeLocalClaudeCode, resolveCodeToolType, selectInstallMethod, setInstallMethod, switchToOfficialLogin, uninstallCodeTool, updateCustomModel, updateDefaultModel, verifyInstallation };
|
|
222
|
+
export type { AiOutputLanguage, ApiConfig, ClaudeConfiguration, CodeToolType, InstallationStatus, McpServerConfig, McpService, SupportedLang, VerificationResult };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
declare const CLAUDE_DIR: string;
|
|
2
|
+
declare const SETTINGS_FILE: string;
|
|
3
|
+
declare const CLAUDE_MD_FILE: string;
|
|
4
|
+
declare const ClAUDE_CONFIG_FILE: string;
|
|
5
|
+
declare const CLAUDE_VSC_CONFIG_FILE: string;
|
|
6
|
+
declare const ZCF_CONFIG_DIR: string;
|
|
7
|
+
declare const ZCF_CONFIG_FILE: string;
|
|
8
|
+
declare const LEGACY_ZCF_CONFIG_FILES: string[];
|
|
9
|
+
declare const CODE_TOOL_TYPES: readonly ["claude-code"];
|
|
10
|
+
type CodeToolType = (typeof CODE_TOOL_TYPES)[number];
|
|
11
|
+
declare const DEFAULT_CODE_TOOL_TYPE: CodeToolType;
|
|
12
|
+
declare const CODE_TOOL_BANNERS: Record<CodeToolType, string>;
|
|
13
|
+
declare const CODE_TOOL_ALIASES: Record<string, CodeToolType>;
|
|
14
|
+
declare function isCodeToolType(value: any): value is CodeToolType;
|
|
15
|
+
declare const API_DEFAULT_URL = "https://api.anthropic.com";
|
|
16
|
+
declare const API_ENV_KEY = "ANTHROPIC_API_KEY";
|
|
17
|
+
declare function resolveCodeToolType(value: unknown): CodeToolType;
|
|
18
|
+
declare const SUPPORTED_LANGS: readonly ["zh-CN", "en"];
|
|
19
|
+
type SupportedLang = (typeof SUPPORTED_LANGS)[number];
|
|
20
|
+
declare const LANG_LABELS: {
|
|
21
|
+
readonly 'zh-CN': "简体中文";
|
|
22
|
+
readonly en: "English";
|
|
23
|
+
};
|
|
24
|
+
declare const AI_OUTPUT_LANGUAGES: {
|
|
25
|
+
readonly 'zh-CN': {
|
|
26
|
+
readonly directive: "Always respond in Chinese-simplified";
|
|
27
|
+
};
|
|
28
|
+
readonly en: {
|
|
29
|
+
readonly directive: "Always respond in English";
|
|
30
|
+
};
|
|
31
|
+
readonly custom: {
|
|
32
|
+
readonly directive: "";
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
type AiOutputLanguage = keyof typeof AI_OUTPUT_LANGUAGES;
|
|
36
|
+
declare function getAiOutputLanguageLabel(lang: AiOutputLanguage): string;
|
|
37
|
+
|
|
38
|
+
declare function getPlatform(): 'windows' | 'macos' | 'linux';
|
|
39
|
+
declare function commandExists(command: string): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Get recommended install methods for a code tool based on current platform
|
|
42
|
+
* Returns methods in priority order (most recommended first)
|
|
43
|
+
*/
|
|
44
|
+
type CodeType = 'claude-code' | 'codex';
|
|
45
|
+
type InstallMethod$1 = 'npm' | 'homebrew' | 'curl' | 'powershell' | 'cmd' | 'npm-global' | 'native';
|
|
46
|
+
|
|
47
|
+
interface McpService {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
description: string;
|
|
51
|
+
requiresApiKey: boolean;
|
|
52
|
+
apiKeyPrompt?: string;
|
|
53
|
+
apiKeyPlaceholder?: string;
|
|
54
|
+
apiKeyEnvVar?: string;
|
|
55
|
+
config: McpServerConfig;
|
|
56
|
+
}
|
|
57
|
+
interface McpServerConfig {
|
|
58
|
+
type: 'stdio' | 'sse';
|
|
59
|
+
command?: string;
|
|
60
|
+
args?: string[];
|
|
61
|
+
url?: string;
|
|
62
|
+
env?: Record<string, string>;
|
|
63
|
+
startup_timeout_ms?: number;
|
|
64
|
+
}
|
|
65
|
+
interface ClaudeConfiguration {
|
|
66
|
+
mcpServers: Record<string, McpServerConfig>;
|
|
67
|
+
hasCompletedOnboarding?: boolean;
|
|
68
|
+
customApiKeyResponses?: {
|
|
69
|
+
approved: string[];
|
|
70
|
+
rejected: string[];
|
|
71
|
+
};
|
|
72
|
+
env?: Record<string, string>;
|
|
73
|
+
primaryApiKey?: string;
|
|
74
|
+
installMethod?: InstallMethod$1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* API configuration for Claude Code
|
|
79
|
+
*/
|
|
80
|
+
interface ApiConfig {
|
|
81
|
+
url: string;
|
|
82
|
+
key: string;
|
|
83
|
+
authType?: 'auth_token' | 'api_key';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Installation method types for code tools
|
|
87
|
+
*/
|
|
88
|
+
type InstallMethod = 'npm' | 'homebrew' | 'curl' | 'powershell' | 'cmd';
|
|
89
|
+
|
|
90
|
+
declare function ensureClaudeDir(): void;
|
|
91
|
+
declare function backupExistingConfig(): string | null;
|
|
92
|
+
declare function copyConfigFiles(onlyMd?: boolean): void;
|
|
93
|
+
declare function configureApi(apiConfig: ApiConfig | null): ApiConfig | null;
|
|
94
|
+
declare function mergeConfigs(sourceFile: string, targetFile: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* Update custom model configuration using environment variables
|
|
97
|
+
* @param primaryModel - Primary model name for general tasks
|
|
98
|
+
* @param haikuModel - Default Haiku model (optional)
|
|
99
|
+
* @param sonnetModel - Default Sonnet model (optional)
|
|
100
|
+
* @param opusModel - Default Opus model (optional)
|
|
101
|
+
*/
|
|
102
|
+
declare function updateCustomModel(primaryModel?: string, haikuModel?: string, sonnetModel?: string, opusModel?: string): void;
|
|
103
|
+
/**
|
|
104
|
+
* Update the default model configuration in settings.json
|
|
105
|
+
* @param model - The model type to set: opus, sonnet, sonnet[1m], default, or custom
|
|
106
|
+
* Note: 'custom' model type is handled differently - it should use environment variables instead
|
|
107
|
+
*/
|
|
108
|
+
declare function updateDefaultModel(model: 'opus' | 'sonnet' | 'sonnet[1m]' | 'default' | 'custom'): void;
|
|
109
|
+
/**
|
|
110
|
+
* Merge settings.json intelligently
|
|
111
|
+
* Preserves user's environment variables and custom configurations
|
|
112
|
+
*/
|
|
113
|
+
declare function mergeSettingsFile(templatePath: string, targetPath: string): void;
|
|
114
|
+
/**
|
|
115
|
+
* Get existing model configuration from settings.json
|
|
116
|
+
*/
|
|
117
|
+
declare function getExistingModelConfig(): 'opus' | 'sonnet' | 'sonnet[1m]' | 'default' | 'custom' | null;
|
|
118
|
+
/**
|
|
119
|
+
* Get existing API configuration from settings.json
|
|
120
|
+
*/
|
|
121
|
+
declare function getExistingApiConfig(): ApiConfig | null;
|
|
122
|
+
declare function applyAiLanguageDirective(aiOutputLang: AiOutputLanguage | string): void;
|
|
123
|
+
/**
|
|
124
|
+
* Switch to official login mode - remove all third-party API configurations
|
|
125
|
+
* Removes: ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY from settings.json
|
|
126
|
+
* Removes: primaryApiKey from ~/.claude/config.json
|
|
127
|
+
*/
|
|
128
|
+
declare function switchToOfficialLogin(): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Prompt user for API configuration action when existing config is found
|
|
131
|
+
* Returns the user's choice for how to handle existing configuration
|
|
132
|
+
*/
|
|
133
|
+
declare function promptApiConfigurationAction(): Promise<'modify-partial' | 'modify-all' | 'keep-existing' | null>;
|
|
134
|
+
|
|
135
|
+
declare function isClaudeCodeInstalled(): Promise<boolean>;
|
|
136
|
+
/**
|
|
137
|
+
* Install Claude Code with method selection support
|
|
138
|
+
* @param skipMethodSelection - If true, use default npm installation
|
|
139
|
+
*/
|
|
140
|
+
declare function installClaudeCode(skipMethodSelection?: boolean): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Check if local Claude Code installation exists
|
|
143
|
+
*/
|
|
144
|
+
declare function isLocalClaudeCodeInstalled(): Promise<boolean>;
|
|
145
|
+
/**
|
|
146
|
+
* Get installation status for both global and local Claude Code
|
|
147
|
+
*/
|
|
148
|
+
interface InstallationStatus {
|
|
149
|
+
hasGlobal: boolean;
|
|
150
|
+
hasLocal: boolean;
|
|
151
|
+
localPath: string;
|
|
152
|
+
}
|
|
153
|
+
declare function getInstallationStatus(): Promise<InstallationStatus>;
|
|
154
|
+
/**
|
|
155
|
+
* Remove local Claude Code installation
|
|
156
|
+
*/
|
|
157
|
+
declare function removeLocalClaudeCode(): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Uninstall code tool based on install method
|
|
160
|
+
* @param codeType - Type of code tool to uninstall
|
|
161
|
+
* @returns true if uninstalled successfully
|
|
162
|
+
*/
|
|
163
|
+
declare function uninstallCodeTool(codeType: CodeType): Promise<boolean>;
|
|
164
|
+
/**
|
|
165
|
+
* Set installMethod in both ~/.claude.json and zcf-config
|
|
166
|
+
* This ensures Claude Code knows it was installed via npm for proper auto-updates
|
|
167
|
+
*/
|
|
168
|
+
declare function setInstallMethod(method: InstallMethod, codeType?: CodeType): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Detect installed version of a code tool
|
|
171
|
+
* Returns version string or null if not installed
|
|
172
|
+
*/
|
|
173
|
+
declare function detectInstalledVersion(codeType: CodeType): Promise<string | null>;
|
|
174
|
+
/**
|
|
175
|
+
* Select installation method interactively
|
|
176
|
+
*/
|
|
177
|
+
declare function selectInstallMethod(codeType: CodeType, excludeMethods?: InstallMethod[]): Promise<InstallMethod | null>;
|
|
178
|
+
/**
|
|
179
|
+
* Execute installation using specified method
|
|
180
|
+
*/
|
|
181
|
+
declare function executeInstallMethod(method: InstallMethod, codeType: CodeType): Promise<boolean>;
|
|
182
|
+
/**
|
|
183
|
+
* Handle installation failure with retry options
|
|
184
|
+
*/
|
|
185
|
+
declare function handleInstallFailure(codeType: CodeType, failedMethods: InstallMethod[]): Promise<boolean>;
|
|
186
|
+
/**
|
|
187
|
+
* Installation verification result
|
|
188
|
+
*/
|
|
189
|
+
interface VerificationResult {
|
|
190
|
+
success: boolean;
|
|
191
|
+
commandPath: string | null;
|
|
192
|
+
version: string | null;
|
|
193
|
+
needsSymlink: boolean;
|
|
194
|
+
symlinkCreated: boolean;
|
|
195
|
+
error?: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Verify installation by checking command availability and version
|
|
199
|
+
* If command is not in PATH but found in Homebrew paths, attempt to create symlink
|
|
200
|
+
*/
|
|
201
|
+
declare function verifyInstallation(codeType: CodeType): Promise<VerificationResult>;
|
|
202
|
+
/**
|
|
203
|
+
* Symlink creation result
|
|
204
|
+
*/
|
|
205
|
+
interface SymlinkResult {
|
|
206
|
+
success: boolean;
|
|
207
|
+
symlinkPath: string | null;
|
|
208
|
+
error?: string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Create symlink in Homebrew bin directory for commands installed via npm
|
|
212
|
+
* This handles the case where npm global packages are installed to
|
|
213
|
+
* /opt/homebrew/Cellar/node/{version}/bin/ but that path is not in the user's PATH
|
|
214
|
+
*/
|
|
215
|
+
declare function createHomebrewSymlink(command: string, sourcePath: string): Promise<SymlinkResult>;
|
|
216
|
+
/**
|
|
217
|
+
* Display verification result to user with appropriate messages
|
|
218
|
+
*/
|
|
219
|
+
declare function displayVerificationResult(result: VerificationResult, _codeType: CodeType): void;
|
|
220
|
+
|
|
221
|
+
export { AI_OUTPUT_LANGUAGES, API_DEFAULT_URL, API_ENV_KEY, CLAUDE_DIR, CLAUDE_MD_FILE, CLAUDE_VSC_CONFIG_FILE, CODE_TOOL_ALIASES, CODE_TOOL_BANNERS, CODE_TOOL_TYPES, ClAUDE_CONFIG_FILE, DEFAULT_CODE_TOOL_TYPE, LANG_LABELS, LEGACY_ZCF_CONFIG_FILES, SETTINGS_FILE, SUPPORTED_LANGS, ZCF_CONFIG_DIR, ZCF_CONFIG_FILE, applyAiLanguageDirective, backupExistingConfig, commandExists, configureApi, copyConfigFiles, createHomebrewSymlink, detectInstalledVersion, displayVerificationResult, ensureClaudeDir, executeInstallMethod, getAiOutputLanguageLabel, getExistingApiConfig, getExistingModelConfig, getInstallationStatus, getPlatform, handleInstallFailure, installClaudeCode, isClaudeCodeInstalled, isCodeToolType, isLocalClaudeCodeInstalled, mergeConfigs, mergeSettingsFile, promptApiConfigurationAction, removeLocalClaudeCode, resolveCodeToolType, selectInstallMethod, setInstallMethod, switchToOfficialLogin, uninstallCodeTool, updateCustomModel, updateDefaultModel, verifyInstallation };
|
|
222
|
+
export type { AiOutputLanguage, ApiConfig, ClaudeConfiguration, CodeToolType, InstallationStatus, McpServerConfig, McpService, SupportedLang, VerificationResult };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { n as AI_OUTPUT_LANGUAGES, A as API_DEFAULT_URL, k as API_ENV_KEY, C as CLAUDE_DIR, a as CLAUDE_MD_FILE, d as CLAUDE_VSC_CONFIG_FILE, i as CODE_TOOL_ALIASES, h as CODE_TOOL_BANNERS, f as CODE_TOOL_TYPES, b as ClAUDE_CONFIG_FILE, D as DEFAULT_CODE_TOOL_TYPE, m as LANG_LABELS, L as LEGACY_ZCF_CONFIG_FILES, S as SETTINGS_FILE, l as SUPPORTED_LANGS, Z as ZCF_CONFIG_DIR, e as ZCF_CONFIG_FILE, B as applyAiLanguageDirective, q as backupExistingConfig, c as commandExists, t as configureApi, s as copyConfigFiles, p as ensureClaudeDir, o as getAiOutputLanguageLabel, z as getExistingApiConfig, y as getExistingModelConfig, g as getPlatform, j as isCodeToolType, u as mergeConfigs, x as mergeSettingsFile, F as promptApiConfigurationAction, r as resolveCodeToolType, E as switchToOfficialLogin, v as updateCustomModel, w as updateDefaultModel } from './chunks/auto-updater.mjs';
|
|
2
|
+
export { createHomebrewSymlink, detectInstalledVersion, displayVerificationResult, executeInstallMethod, getInstallationStatus, handleInstallFailure, installClaudeCode, isClaudeCodeInstalled, isLocalClaudeCodeInstalled, removeLocalClaudeCode, selectInstallMethod, setInstallMethod, uninstallCodeTool, verifyInstallation } from './chunks/installer.mjs';
|
|
3
|
+
import 'node:url';
|
|
4
|
+
import 'ansis';
|
|
5
|
+
import 'dayjs';
|
|
6
|
+
import 'inquirer';
|
|
7
|
+
import 'pathe';
|
|
8
|
+
import 'node:os';
|
|
9
|
+
import 'node:fs';
|
|
10
|
+
import 'node:process';
|
|
11
|
+
import 'tinyexec';
|
|
12
|
+
import 'ora';
|
|
13
|
+
import 'semver';
|
|
14
|
+
import 'i18next';
|
|
15
|
+
import 'i18next-fs-backend';
|
|
16
|
+
import 'inquirer-toggle';
|
|
17
|
+
import 'node:child_process';
|
|
18
|
+
import 'node:util';
|
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xwm111/ccs",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"packageManager": "pnpm@10.17.1",
|
|
6
|
+
"description": "Claude Code Switch - manage and quickly switch between multiple Claude Code API endpoints",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "xwm111",
|
|
9
|
+
"url": "https://github.com/xwm111"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"homepage": "https://github.com/xwm111/ccs",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/xwm111/ccs.git"
|
|
16
|
+
},
|
|
17
|
+
"bugs": "https://github.com/xwm111/ccs/issues",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"claude",
|
|
20
|
+
"claude-code",
|
|
21
|
+
"api",
|
|
22
|
+
"endpoint",
|
|
23
|
+
"switch",
|
|
24
|
+
"config",
|
|
25
|
+
"cli",
|
|
26
|
+
"anthropic"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"main": "dist/index.mjs",
|
|
32
|
+
"module": "dist/index.mjs",
|
|
33
|
+
"types": "dist/index.d.mts",
|
|
34
|
+
"bin": {
|
|
35
|
+
"ccs": "bin/ccs.mjs"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"bin",
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"dev": "tsx ./src/cli.ts",
|
|
43
|
+
"build": "unbuild",
|
|
44
|
+
"start": "node bin/ccs.mjs",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"prepublishOnly": "pnpm build",
|
|
47
|
+
"lint": "eslint",
|
|
48
|
+
"lint:fix": "eslint --fix",
|
|
49
|
+
"test": "vitest",
|
|
50
|
+
"test:ui": "vitest --ui",
|
|
51
|
+
"test:coverage": "vitest run --coverage",
|
|
52
|
+
"test:run": "vitest run",
|
|
53
|
+
"test:watch": "vitest watch",
|
|
54
|
+
"changeset": "changeset",
|
|
55
|
+
"version": "changeset version",
|
|
56
|
+
"update:deps": "pnpx taze major -r -w",
|
|
57
|
+
"release": "pnpm build && changeset publish",
|
|
58
|
+
"prepare": "husky",
|
|
59
|
+
"commitlint": "commitlint",
|
|
60
|
+
"commitlint:check": "commitlint --from HEAD~1 --to HEAD --verbose",
|
|
61
|
+
"docs:dev": "pnpm -F @zcf/docs dev",
|
|
62
|
+
"docs:build": "pnpm -F @zcf/docs build",
|
|
63
|
+
"docs:preview": "pnpm -F @zcf/docs preview"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"@rainbowatcher/toml-edit-js": "catalog:runtime",
|
|
67
|
+
"@types/semver": "catalog:types",
|
|
68
|
+
"ansis": "catalog:cli",
|
|
69
|
+
"cac": "catalog:cli",
|
|
70
|
+
"dayjs": "catalog:runtime",
|
|
71
|
+
"find-up-simple": "catalog:runtime",
|
|
72
|
+
"fs-extra": "catalog:runtime",
|
|
73
|
+
"i18next": "catalog:runtime",
|
|
74
|
+
"i18next-fs-backend": "catalog:runtime",
|
|
75
|
+
"inquirer": "catalog:cli",
|
|
76
|
+
"inquirer-toggle": "catalog:cli",
|
|
77
|
+
"ora": "catalog:cli",
|
|
78
|
+
"pathe": "catalog:runtime",
|
|
79
|
+
"semver": "catalog:runtime",
|
|
80
|
+
"tinyexec": "catalog:runtime",
|
|
81
|
+
"trash": "catalog:runtime"
|
|
82
|
+
},
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@antfu/eslint-config": "catalog:build",
|
|
85
|
+
"@changesets/cli": "catalog:tooling",
|
|
86
|
+
"@commitlint/cli": "catalog:tooling",
|
|
87
|
+
"@commitlint/config-conventional": "catalog:tooling",
|
|
88
|
+
"@commitlint/types": "catalog:tooling",
|
|
89
|
+
"@types/fs-extra": "catalog:types",
|
|
90
|
+
"@types/inquirer": "catalog:types",
|
|
91
|
+
"@types/node": "catalog:types",
|
|
92
|
+
"@vitest/coverage-v8": "catalog:testing",
|
|
93
|
+
"@vitest/ui": "catalog:testing",
|
|
94
|
+
"eslint": "catalog:build",
|
|
95
|
+
"eslint-plugin-format": "catalog:build",
|
|
96
|
+
"glob": "catalog:testing",
|
|
97
|
+
"husky": "catalog:tooling",
|
|
98
|
+
"lint-staged": "catalog:tooling",
|
|
99
|
+
"tsx": "catalog:build",
|
|
100
|
+
"typescript": "catalog:build",
|
|
101
|
+
"unbuild": "catalog:build",
|
|
102
|
+
"vitest": "catalog:testing"
|
|
103
|
+
},
|
|
104
|
+
"lint-staged": {
|
|
105
|
+
"*": [
|
|
106
|
+
"pnpm lint"
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
}
|