@benbenwu/zcf 3.6.4

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.
Files changed (94) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +193 -0
  3. package/bin/zcf.mjs +2 -0
  4. package/dist/chunks/api-providers.mjs +137 -0
  5. package/dist/chunks/claude-code-config-manager.mjs +731 -0
  6. package/dist/chunks/claude-code-incremental-manager.mjs +601 -0
  7. package/dist/chunks/codex-config-switch.mjs +394 -0
  8. package/dist/chunks/codex-provider-manager.mjs +197 -0
  9. package/dist/chunks/codex-uninstaller.mjs +422 -0
  10. package/dist/chunks/commands.mjs +118 -0
  11. package/dist/chunks/features.mjs +632 -0
  12. package/dist/chunks/simple-config.mjs +7904 -0
  13. package/dist/cli.d.mts +1 -0
  14. package/dist/cli.d.ts +1 -0
  15. package/dist/cli.mjs +2013 -0
  16. package/dist/i18n/locales/en/api.json +53 -0
  17. package/dist/i18n/locales/en/ccr.json +65 -0
  18. package/dist/i18n/locales/en/cli.json +55 -0
  19. package/dist/i18n/locales/en/codex.json +123 -0
  20. package/dist/i18n/locales/en/cometix.json +29 -0
  21. package/dist/i18n/locales/en/common.json +20 -0
  22. package/dist/i18n/locales/en/configuration.json +85 -0
  23. package/dist/i18n/locales/en/errors.json +26 -0
  24. package/dist/i18n/locales/en/installation.json +80 -0
  25. package/dist/i18n/locales/en/language.json +19 -0
  26. package/dist/i18n/locales/en/mcp.json +24 -0
  27. package/dist/i18n/locales/en/menu.json +51 -0
  28. package/dist/i18n/locales/en/multi-config.json +79 -0
  29. package/dist/i18n/locales/en/tools.json +15 -0
  30. package/dist/i18n/locales/en/uninstall.json +56 -0
  31. package/dist/i18n/locales/en/updater.json +25 -0
  32. package/dist/i18n/locales/en/workflow.json +23 -0
  33. package/dist/i18n/locales/zh-CN/api.json +53 -0
  34. package/dist/i18n/locales/zh-CN/ccr.json +65 -0
  35. package/dist/i18n/locales/zh-CN/cli.json +55 -0
  36. package/dist/i18n/locales/zh-CN/codex.json +123 -0
  37. package/dist/i18n/locales/zh-CN/cometix.json +29 -0
  38. package/dist/i18n/locales/zh-CN/common.json +20 -0
  39. package/dist/i18n/locales/zh-CN/configuration.json +85 -0
  40. package/dist/i18n/locales/zh-CN/errors.json +26 -0
  41. package/dist/i18n/locales/zh-CN/installation.json +80 -0
  42. package/dist/i18n/locales/zh-CN/language.json +19 -0
  43. package/dist/i18n/locales/zh-CN/mcp.json +24 -0
  44. package/dist/i18n/locales/zh-CN/menu.json +51 -0
  45. package/dist/i18n/locales/zh-CN/multi-config.json +79 -0
  46. package/dist/i18n/locales/zh-CN/tools.json +15 -0
  47. package/dist/i18n/locales/zh-CN/uninstall.json +56 -0
  48. package/dist/i18n/locales/zh-CN/updater.json +25 -0
  49. package/dist/i18n/locales/zh-CN/workflow.json +23 -0
  50. package/dist/index.d.mts +324 -0
  51. package/dist/index.d.ts +324 -0
  52. package/dist/index.mjs +19 -0
  53. package/dist/shared/zcf.DGjQxTq_.mjs +34 -0
  54. package/package.json +117 -0
  55. package/templates/CLAUDE.md +221 -0
  56. package/templates/claude-code/CLAUDE.md +250 -0
  57. package/templates/claude-code/common/settings.json +48 -0
  58. package/templates/claude-code/en/workflow/bmad/commands/bmad-init.md +275 -0
  59. package/templates/claude-code/en/workflow/common/agents/get-current-datetime.md +29 -0
  60. package/templates/claude-code/en/workflow/common/agents/init-architect.md +114 -0
  61. package/templates/claude-code/en/workflow/common/commands/init-project.md +53 -0
  62. package/templates/claude-code/en/workflow/plan/agents/planner.md +116 -0
  63. package/templates/claude-code/en/workflow/plan/agents/ui-ux-designer.md +91 -0
  64. package/templates/claude-code/en/workflow/plan/commands/feat.md +105 -0
  65. package/templates/claude-code/zh-CN/workflow/bmad/commands/bmad-init.md +275 -0
  66. package/templates/claude-code/zh-CN/workflow/common/agents/get-current-datetime.md +29 -0
  67. package/templates/claude-code/zh-CN/workflow/common/agents/init-architect.md +114 -0
  68. package/templates/claude-code/zh-CN/workflow/common/commands/init-project.md +53 -0
  69. package/templates/claude-code/zh-CN/workflow/plan/agents/planner.md +116 -0
  70. package/templates/claude-code/zh-CN/workflow/plan/agents/ui-ux-designer.md +91 -0
  71. package/templates/claude-code/zh-CN/workflow/plan/commands/feat.md +105 -0
  72. package/templates/codex/common/config.toml +0 -0
  73. package/templates/common/output-styles/en/engineer-professional.md +88 -0
  74. package/templates/common/output-styles/en/laowang-engineer.md +127 -0
  75. package/templates/common/output-styles/en/leibus-engineer.md +251 -0
  76. package/templates/common/output-styles/en/nekomata-engineer.md +120 -0
  77. package/templates/common/output-styles/en/ojousama-engineer.md +121 -0
  78. package/templates/common/output-styles/en/rem-engineer.md +173 -0
  79. package/templates/common/output-styles/zh-CN/engineer-professional.md +89 -0
  80. package/templates/common/output-styles/zh-CN/laowang-engineer.md +127 -0
  81. package/templates/common/output-styles/zh-CN/leibus-engineer.md +251 -0
  82. package/templates/common/output-styles/zh-CN/nekomata-engineer.md +120 -0
  83. package/templates/common/output-styles/zh-CN/ojousama-engineer.md +121 -0
  84. package/templates/common/output-styles/zh-CN/rem-engineer.md +179 -0
  85. package/templates/common/workflow/git/en/git-cleanBranches.md +102 -0
  86. package/templates/common/workflow/git/en/git-commit.md +205 -0
  87. package/templates/common/workflow/git/en/git-rollback.md +90 -0
  88. package/templates/common/workflow/git/en/git-worktree.md +276 -0
  89. package/templates/common/workflow/git/zh-CN/git-cleanBranches.md +102 -0
  90. package/templates/common/workflow/git/zh-CN/git-commit.md +205 -0
  91. package/templates/common/workflow/git/zh-CN/git-rollback.md +90 -0
  92. package/templates/common/workflow/git/zh-CN/git-worktree.md +276 -0
  93. package/templates/common/workflow/sixStep/en/workflow.md +251 -0
  94. package/templates/common/workflow/sixStep/zh-CN/workflow.md +215 -0
@@ -0,0 +1,324 @@
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 CODEX_DIR: string;
7
+ declare const CODEX_CONFIG_FILE: string;
8
+ declare const CODEX_AUTH_FILE: string;
9
+ declare const CODEX_AGENTS_FILE: string;
10
+ declare const CODEX_SKILLS_DIR: string;
11
+ declare const CODEX_PROMPTS_DIR: string;
12
+ declare const CODEX_ZCF_SKILL_NAMES: readonly ["zcf-six-step", "zcf-git-commit", "zcf-git-rollback", "zcf-git-clean-branches", "zcf-git-worktree"];
13
+ declare const CODEX_LEGACY_WORKFLOW_PROMPT_FILES: readonly ["workflow.md", "git-commit.md", "git-rollback.md", "git-cleanBranches.md", "git-worktree.md"];
14
+ declare const ZCF_CONFIG_DIR: string;
15
+ declare const ZCF_CONFIG_FILE: string;
16
+ declare const LEGACY_ZCF_CONFIG_FILES: string[];
17
+ declare const CODE_TOOL_TYPES: readonly ["claude-code", "codex"];
18
+ type CodeToolType = (typeof CODE_TOOL_TYPES)[number];
19
+ declare const DEFAULT_CODE_TOOL_TYPE: CodeToolType;
20
+ declare const CODE_TOOL_BANNERS: Record<CodeToolType, string>;
21
+ declare const CODE_TOOL_ALIASES: Record<string, CodeToolType>;
22
+ declare function isCodeToolType(value: any): value is CodeToolType;
23
+ declare const API_DEFAULT_URL = "https://api.anthropic.com";
24
+ declare const API_ENV_KEY = "ANTHROPIC_API_KEY";
25
+ declare function resolveCodeToolType(value: unknown): CodeToolType;
26
+ declare const SUPPORTED_LANGS: readonly ["zh-CN", "en"];
27
+ type SupportedLang = (typeof SUPPORTED_LANGS)[number];
28
+ declare const LANG_LABELS: {
29
+ readonly 'zh-CN': "简体中文";
30
+ readonly en: "English";
31
+ };
32
+ declare const AI_OUTPUT_LANGUAGES: {
33
+ readonly 'zh-CN': {
34
+ readonly directive: "Always respond in Chinese-simplified";
35
+ };
36
+ readonly en: {
37
+ readonly directive: "Always respond in English";
38
+ };
39
+ readonly custom: {
40
+ readonly directive: "";
41
+ };
42
+ };
43
+ type AiOutputLanguage = keyof typeof AI_OUTPUT_LANGUAGES;
44
+ declare function getAiOutputLanguageLabel(lang: AiOutputLanguage): string;
45
+
46
+ interface InitOptions {
47
+ configLang?: SupportedLang;
48
+ aiOutputLang?: AiOutputLanguage | string;
49
+ force?: boolean;
50
+ skipBanner?: boolean;
51
+ skipPrompt?: boolean;
52
+ codeType?: CodeToolType | string;
53
+ configAction?: 'new' | 'backup' | 'merge' | 'docs-only' | 'skip';
54
+ apiType?: 'auth_token' | 'api_key' | 'ccr_proxy' | 'skip';
55
+ apiKey?: string;
56
+ apiUrl?: string;
57
+ apiModel?: string;
58
+ apiHaikuModel?: string;
59
+ apiSonnetModel?: string;
60
+ apiOpusModel?: string;
61
+ provider?: string;
62
+ mcpServices?: string[] | string | boolean;
63
+ workflows?: string[] | string | boolean;
64
+ outputStyles?: string[] | string | boolean;
65
+ defaultOutputStyle?: string;
66
+ allLang?: string;
67
+ installCometixLine?: string | boolean;
68
+ apiConfigs?: string;
69
+ apiConfigsFile?: string;
70
+ }
71
+ declare function init(options?: InitOptions): Promise<void>;
72
+
73
+ declare function getPlatform(): 'windows' | 'macos' | 'linux';
74
+ declare function commandExists(command: string): Promise<boolean>;
75
+ /**
76
+ * Get recommended install methods for a code tool based on current platform
77
+ * Returns methods in priority order (most recommended first)
78
+ */
79
+ type CodeType = 'claude-code' | 'codex';
80
+ type InstallMethod$1 = 'npm' | 'homebrew' | 'curl' | 'powershell' | 'cmd' | 'npm-global' | 'native';
81
+
82
+ interface McpService {
83
+ id: string;
84
+ name: string;
85
+ description: string;
86
+ requiresApiKey: boolean;
87
+ apiKeyPrompt?: string;
88
+ apiKeyPlaceholder?: string;
89
+ apiKeyEnvVar?: string;
90
+ config: McpServerConfig;
91
+ }
92
+ interface McpServerConfig {
93
+ type: 'stdio' | 'sse';
94
+ command?: string;
95
+ args?: string[];
96
+ url?: string;
97
+ env?: Record<string, string>;
98
+ startup_timeout_ms?: number;
99
+ }
100
+ interface ClaudeConfiguration {
101
+ mcpServers: Record<string, McpServerConfig>;
102
+ hasCompletedOnboarding?: boolean;
103
+ customApiKeyResponses?: {
104
+ approved: string[];
105
+ rejected: string[];
106
+ };
107
+ env?: Record<string, string>;
108
+ primaryApiKey?: string;
109
+ installMethod?: InstallMethod$1;
110
+ }
111
+
112
+ declare function getMcpConfigPath(): string;
113
+ declare function readMcpConfig(): ClaudeConfiguration | null;
114
+ declare function writeMcpConfig(config: ClaudeConfiguration): void;
115
+ declare function backupMcpConfig(): string | null;
116
+ declare function mergeMcpServers(existing: ClaudeConfiguration | null, newServers: Record<string, McpServerConfig>): ClaudeConfiguration;
117
+ declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string, envVarName?: string): McpServerConfig;
118
+ declare function fixWindowsMcpConfig(config: ClaudeConfiguration): ClaudeConfiguration;
119
+ declare function addCompletedOnboarding(): void;
120
+ /**
121
+ * Ensures that an API key is in the approved list and not in the rejected list
122
+ * @param config - Claude configuration object
123
+ * @param apiKey - The API key to manage
124
+ * @returns Updated configuration with API key properly approved
125
+ */
126
+ declare function ensureApiKeyApproved(config: ClaudeConfiguration, apiKey: string): ClaudeConfiguration;
127
+ /**
128
+ * Removes an API key from the rejected list
129
+ * @param config - Claude configuration object
130
+ * @param apiKey - The API key to remove from rejected list
131
+ * @returns Updated configuration with API key removed from rejected list
132
+ */
133
+ declare function removeApiKeyFromRejected(config: ClaudeConfiguration, apiKey: string): ClaudeConfiguration;
134
+ /**
135
+ * Manages API key approval status by reading config, updating it, and writing it back
136
+ * @param apiKey - The API key to ensure is approved (e.g., 'sk-zcf-x-ccr')
137
+ */
138
+ declare function manageApiKeyApproval(apiKey: string): void;
139
+ /**
140
+ * Sets the primaryApiKey field in ~/.claude/config.json (VSCode extension config)
141
+ * This is required for Claude Code 2.0 to properly recognize third-party API configurations
142
+ * and prevent redirecting to official login page
143
+ */
144
+ declare function setPrimaryApiKey(): void;
145
+
146
+ /**
147
+ * API configuration for Claude Code
148
+ */
149
+ interface ApiConfig {
150
+ url: string;
151
+ key: string;
152
+ authType?: 'auth_token' | 'api_key';
153
+ }
154
+ /**
155
+ * Installation method types for code tools
156
+ */
157
+ type InstallMethod = 'npm' | 'homebrew' | 'curl' | 'powershell' | 'cmd';
158
+
159
+ declare function ensureClaudeDir(): void;
160
+ declare function backupExistingConfig(): string | null;
161
+ declare function copyConfigFiles(onlyMd?: boolean): void;
162
+ declare function configureApi(apiConfig: ApiConfig | null): ApiConfig | null;
163
+ declare function mergeConfigs(sourceFile: string, targetFile: string): void;
164
+ /**
165
+ * Update custom model configuration using environment variables
166
+ * @param primaryModel - Primary model name for general tasks
167
+ * @param haikuModel - Default Haiku model (optional)
168
+ * @param sonnetModel - Default Sonnet model (optional)
169
+ * @param opusModel - Default Opus model (optional)
170
+ */
171
+ declare function updateCustomModel(primaryModel?: string, haikuModel?: string, sonnetModel?: string, opusModel?: string): void;
172
+ /**
173
+ * Update the default model configuration in settings.json
174
+ * @param model - The model type to set: opus, sonnet, sonnet[1m], default, or custom
175
+ * Note: 'custom' model type is handled differently - it should use environment variables instead
176
+ */
177
+ declare function updateDefaultModel(model: 'opus' | 'sonnet' | 'sonnet[1m]' | 'default' | 'custom'): void;
178
+ /**
179
+ * Merge settings.json intelligently
180
+ * Preserves user's environment variables and custom configurations
181
+ */
182
+ declare function mergeSettingsFile(templatePath: string, targetPath: string): void;
183
+ /**
184
+ * Get existing model configuration from settings.json
185
+ */
186
+ declare function getExistingModelConfig(): 'opus' | 'sonnet' | 'sonnet[1m]' | 'default' | 'custom' | null;
187
+ /**
188
+ * Get existing API configuration from settings.json
189
+ */
190
+ declare function getExistingApiConfig(): ApiConfig | null;
191
+ declare function applyAiLanguageDirective(aiOutputLang: AiOutputLanguage | string): void;
192
+ /**
193
+ * Switch to official login mode - remove all third-party API configurations
194
+ * Removes: ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY from settings.json
195
+ * Removes: primaryApiKey from ~/.claude/config.json
196
+ */
197
+ declare function switchToOfficialLogin(): boolean;
198
+ /**
199
+ * Prompt user for API configuration action when existing config is found
200
+ * Returns the user's choice for how to handle existing configuration
201
+ */
202
+ declare function promptApiConfigurationAction(): Promise<'modify-partial' | 'modify-all' | 'keep-existing' | null>;
203
+
204
+ declare function isClaudeCodeInstalled(): Promise<boolean>;
205
+ /**
206
+ * Install Claude Code with method selection support
207
+ * @param skipMethodSelection - If true, use default npm installation
208
+ */
209
+ declare function installClaudeCode(skipMethodSelection?: boolean): Promise<void>;
210
+ /**
211
+ * Check if Codex is installed
212
+ */
213
+ declare function isCodexInstalled(): Promise<boolean>;
214
+ /**
215
+ * Install Codex with method selection support
216
+ * @param skipMethodSelection - If true, use default npm installation
217
+ */
218
+ declare function installCodex(skipMethodSelection?: boolean): Promise<void>;
219
+ /**
220
+ * Check if local Claude Code installation exists
221
+ */
222
+ declare function isLocalClaudeCodeInstalled(): Promise<boolean>;
223
+ /**
224
+ * Get installation status for both global and local Claude Code
225
+ */
226
+ interface InstallationStatus {
227
+ hasGlobal: boolean;
228
+ hasLocal: boolean;
229
+ localPath: string;
230
+ }
231
+ declare function getInstallationStatus(): Promise<InstallationStatus>;
232
+ /**
233
+ * Remove local Claude Code installation
234
+ */
235
+ declare function removeLocalClaudeCode(): Promise<void>;
236
+ /**
237
+ * Uninstall code tool based on install method
238
+ * @param codeType - Type of code tool to uninstall
239
+ * @returns true if uninstalled successfully
240
+ */
241
+ declare function uninstallCodeTool(codeType: CodeType): Promise<boolean>;
242
+ /**
243
+ * Set installMethod in both ~/.claude.json and zcf-config
244
+ * This ensures Claude Code knows it was installed via npm for proper auto-updates
245
+ */
246
+ declare function setInstallMethod(method: InstallMethod, codeType?: CodeType): Promise<void>;
247
+ /**
248
+ * Detect installed version of a code tool
249
+ * Returns version string or null if not installed
250
+ */
251
+ declare function detectInstalledVersion(codeType: CodeType): Promise<string | null>;
252
+ /**
253
+ * Select installation method interactively
254
+ */
255
+ declare function selectInstallMethod(codeType: CodeType, excludeMethods?: InstallMethod[]): Promise<InstallMethod | null>;
256
+ /**
257
+ * Execute installation using specified method
258
+ */
259
+ declare function executeInstallMethod(method: InstallMethod, codeType: CodeType): Promise<boolean>;
260
+ /**
261
+ * Handle installation failure with retry options
262
+ */
263
+ declare function handleInstallFailure(codeType: CodeType, failedMethods: InstallMethod[]): Promise<boolean>;
264
+ /**
265
+ * Installation verification result
266
+ */
267
+ interface VerificationResult {
268
+ success: boolean;
269
+ commandPath: string | null;
270
+ version: string | null;
271
+ needsSymlink: boolean;
272
+ symlinkCreated: boolean;
273
+ error?: string;
274
+ }
275
+ /**
276
+ * Verify installation by checking command availability and version
277
+ * If command is not in PATH but found in Homebrew paths, attempt to create symlink
278
+ */
279
+ declare function verifyInstallation(codeType: CodeType): Promise<VerificationResult>;
280
+ /**
281
+ * Symlink creation result
282
+ */
283
+ interface SymlinkResult {
284
+ success: boolean;
285
+ symlinkPath: string | null;
286
+ error?: string;
287
+ }
288
+ /**
289
+ * Create symlink in Homebrew bin directory for commands installed via npm
290
+ * This handles the case where npm global packages are installed to
291
+ * /opt/homebrew/Cellar/node/{version}/bin/ but that path is not in the user's PATH
292
+ */
293
+ declare function createHomebrewSymlink(command: string, sourcePath: string): Promise<SymlinkResult>;
294
+ /**
295
+ * Display verification result to user with appropriate messages
296
+ */
297
+ declare function displayVerificationResult(result: VerificationResult, codeType: CodeType): void;
298
+
299
+ /**
300
+ * Clean up and deduplicate permissions array
301
+ * Removes invalid and redundant permissions based on template
302
+ */
303
+ /**
304
+ * Clean up permissions array by removing invalid and redundant entries
305
+ * @param templatePermissions - Permissions from template (source of truth)
306
+ * @param userPermissions - User's existing permissions
307
+ * @returns Cleaned permissions array
308
+ */
309
+ declare function cleanupPermissions(templatePermissions: string[], userPermissions: string[]): string[];
310
+ /**
311
+ * Merge and clean permissions arrays
312
+ * Combines template and user permissions while removing invalid/redundant entries
313
+ * @param templatePermissions - Permissions from template
314
+ * @param userPermissions - User's existing permissions
315
+ * @returns Merged and cleaned permissions array
316
+ */
317
+ declare function mergeAndCleanPermissions(templatePermissions: string[] | undefined, userPermissions: string[] | undefined): string[];
318
+
319
+ declare function importRecommendedEnv(): Promise<void>;
320
+ declare function importRecommendedPermissions(): Promise<void>;
321
+ declare function openSettingsJson(): Promise<void>;
322
+
323
+ export { AI_OUTPUT_LANGUAGES, API_DEFAULT_URL, API_ENV_KEY, CLAUDE_DIR, CLAUDE_MD_FILE, CLAUDE_VSC_CONFIG_FILE, CODEX_AGENTS_FILE, CODEX_AUTH_FILE, CODEX_CONFIG_FILE, CODEX_DIR, CODEX_LEGACY_WORKFLOW_PROMPT_FILES, CODEX_PROMPTS_DIR, CODEX_SKILLS_DIR, CODEX_ZCF_SKILL_NAMES, 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, addCompletedOnboarding, applyAiLanguageDirective, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, cleanupPermissions, commandExists, configureApi, copyConfigFiles, createHomebrewSymlink, detectInstalledVersion, displayVerificationResult, ensureApiKeyApproved, ensureClaudeDir, executeInstallMethod, fixWindowsMcpConfig, getAiOutputLanguageLabel, getExistingApiConfig, getExistingModelConfig, getInstallationStatus, getMcpConfigPath, getPlatform, handleInstallFailure, importRecommendedEnv, importRecommendedPermissions, init, installClaudeCode, installCodex, isClaudeCodeInstalled, isCodeToolType, isCodexInstalled, isLocalClaudeCodeInstalled, manageApiKeyApproval, mergeAndCleanPermissions, mergeConfigs, mergeMcpServers, mergeSettingsFile, openSettingsJson, promptApiConfigurationAction, readMcpConfig, removeApiKeyFromRejected, removeLocalClaudeCode, resolveCodeToolType, selectInstallMethod, setInstallMethod, setPrimaryApiKey, switchToOfficialLogin, uninstallCodeTool, updateCustomModel, updateDefaultModel, verifyInstallation, writeMcpConfig };
324
+ export type { AiOutputLanguage, ApiConfig, ClaudeConfiguration, CodeToolType, InstallationStatus, McpServerConfig, McpService, SupportedLang, VerificationResult };
@@ -0,0 +1,324 @@
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 CODEX_DIR: string;
7
+ declare const CODEX_CONFIG_FILE: string;
8
+ declare const CODEX_AUTH_FILE: string;
9
+ declare const CODEX_AGENTS_FILE: string;
10
+ declare const CODEX_SKILLS_DIR: string;
11
+ declare const CODEX_PROMPTS_DIR: string;
12
+ declare const CODEX_ZCF_SKILL_NAMES: readonly ["zcf-six-step", "zcf-git-commit", "zcf-git-rollback", "zcf-git-clean-branches", "zcf-git-worktree"];
13
+ declare const CODEX_LEGACY_WORKFLOW_PROMPT_FILES: readonly ["workflow.md", "git-commit.md", "git-rollback.md", "git-cleanBranches.md", "git-worktree.md"];
14
+ declare const ZCF_CONFIG_DIR: string;
15
+ declare const ZCF_CONFIG_FILE: string;
16
+ declare const LEGACY_ZCF_CONFIG_FILES: string[];
17
+ declare const CODE_TOOL_TYPES: readonly ["claude-code", "codex"];
18
+ type CodeToolType = (typeof CODE_TOOL_TYPES)[number];
19
+ declare const DEFAULT_CODE_TOOL_TYPE: CodeToolType;
20
+ declare const CODE_TOOL_BANNERS: Record<CodeToolType, string>;
21
+ declare const CODE_TOOL_ALIASES: Record<string, CodeToolType>;
22
+ declare function isCodeToolType(value: any): value is CodeToolType;
23
+ declare const API_DEFAULT_URL = "https://api.anthropic.com";
24
+ declare const API_ENV_KEY = "ANTHROPIC_API_KEY";
25
+ declare function resolveCodeToolType(value: unknown): CodeToolType;
26
+ declare const SUPPORTED_LANGS: readonly ["zh-CN", "en"];
27
+ type SupportedLang = (typeof SUPPORTED_LANGS)[number];
28
+ declare const LANG_LABELS: {
29
+ readonly 'zh-CN': "简体中文";
30
+ readonly en: "English";
31
+ };
32
+ declare const AI_OUTPUT_LANGUAGES: {
33
+ readonly 'zh-CN': {
34
+ readonly directive: "Always respond in Chinese-simplified";
35
+ };
36
+ readonly en: {
37
+ readonly directive: "Always respond in English";
38
+ };
39
+ readonly custom: {
40
+ readonly directive: "";
41
+ };
42
+ };
43
+ type AiOutputLanguage = keyof typeof AI_OUTPUT_LANGUAGES;
44
+ declare function getAiOutputLanguageLabel(lang: AiOutputLanguage): string;
45
+
46
+ interface InitOptions {
47
+ configLang?: SupportedLang;
48
+ aiOutputLang?: AiOutputLanguage | string;
49
+ force?: boolean;
50
+ skipBanner?: boolean;
51
+ skipPrompt?: boolean;
52
+ codeType?: CodeToolType | string;
53
+ configAction?: 'new' | 'backup' | 'merge' | 'docs-only' | 'skip';
54
+ apiType?: 'auth_token' | 'api_key' | 'ccr_proxy' | 'skip';
55
+ apiKey?: string;
56
+ apiUrl?: string;
57
+ apiModel?: string;
58
+ apiHaikuModel?: string;
59
+ apiSonnetModel?: string;
60
+ apiOpusModel?: string;
61
+ provider?: string;
62
+ mcpServices?: string[] | string | boolean;
63
+ workflows?: string[] | string | boolean;
64
+ outputStyles?: string[] | string | boolean;
65
+ defaultOutputStyle?: string;
66
+ allLang?: string;
67
+ installCometixLine?: string | boolean;
68
+ apiConfigs?: string;
69
+ apiConfigsFile?: string;
70
+ }
71
+ declare function init(options?: InitOptions): Promise<void>;
72
+
73
+ declare function getPlatform(): 'windows' | 'macos' | 'linux';
74
+ declare function commandExists(command: string): Promise<boolean>;
75
+ /**
76
+ * Get recommended install methods for a code tool based on current platform
77
+ * Returns methods in priority order (most recommended first)
78
+ */
79
+ type CodeType = 'claude-code' | 'codex';
80
+ type InstallMethod$1 = 'npm' | 'homebrew' | 'curl' | 'powershell' | 'cmd' | 'npm-global' | 'native';
81
+
82
+ interface McpService {
83
+ id: string;
84
+ name: string;
85
+ description: string;
86
+ requiresApiKey: boolean;
87
+ apiKeyPrompt?: string;
88
+ apiKeyPlaceholder?: string;
89
+ apiKeyEnvVar?: string;
90
+ config: McpServerConfig;
91
+ }
92
+ interface McpServerConfig {
93
+ type: 'stdio' | 'sse';
94
+ command?: string;
95
+ args?: string[];
96
+ url?: string;
97
+ env?: Record<string, string>;
98
+ startup_timeout_ms?: number;
99
+ }
100
+ interface ClaudeConfiguration {
101
+ mcpServers: Record<string, McpServerConfig>;
102
+ hasCompletedOnboarding?: boolean;
103
+ customApiKeyResponses?: {
104
+ approved: string[];
105
+ rejected: string[];
106
+ };
107
+ env?: Record<string, string>;
108
+ primaryApiKey?: string;
109
+ installMethod?: InstallMethod$1;
110
+ }
111
+
112
+ declare function getMcpConfigPath(): string;
113
+ declare function readMcpConfig(): ClaudeConfiguration | null;
114
+ declare function writeMcpConfig(config: ClaudeConfiguration): void;
115
+ declare function backupMcpConfig(): string | null;
116
+ declare function mergeMcpServers(existing: ClaudeConfiguration | null, newServers: Record<string, McpServerConfig>): ClaudeConfiguration;
117
+ declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string, envVarName?: string): McpServerConfig;
118
+ declare function fixWindowsMcpConfig(config: ClaudeConfiguration): ClaudeConfiguration;
119
+ declare function addCompletedOnboarding(): void;
120
+ /**
121
+ * Ensures that an API key is in the approved list and not in the rejected list
122
+ * @param config - Claude configuration object
123
+ * @param apiKey - The API key to manage
124
+ * @returns Updated configuration with API key properly approved
125
+ */
126
+ declare function ensureApiKeyApproved(config: ClaudeConfiguration, apiKey: string): ClaudeConfiguration;
127
+ /**
128
+ * Removes an API key from the rejected list
129
+ * @param config - Claude configuration object
130
+ * @param apiKey - The API key to remove from rejected list
131
+ * @returns Updated configuration with API key removed from rejected list
132
+ */
133
+ declare function removeApiKeyFromRejected(config: ClaudeConfiguration, apiKey: string): ClaudeConfiguration;
134
+ /**
135
+ * Manages API key approval status by reading config, updating it, and writing it back
136
+ * @param apiKey - The API key to ensure is approved (e.g., 'sk-zcf-x-ccr')
137
+ */
138
+ declare function manageApiKeyApproval(apiKey: string): void;
139
+ /**
140
+ * Sets the primaryApiKey field in ~/.claude/config.json (VSCode extension config)
141
+ * This is required for Claude Code 2.0 to properly recognize third-party API configurations
142
+ * and prevent redirecting to official login page
143
+ */
144
+ declare function setPrimaryApiKey(): void;
145
+
146
+ /**
147
+ * API configuration for Claude Code
148
+ */
149
+ interface ApiConfig {
150
+ url: string;
151
+ key: string;
152
+ authType?: 'auth_token' | 'api_key';
153
+ }
154
+ /**
155
+ * Installation method types for code tools
156
+ */
157
+ type InstallMethod = 'npm' | 'homebrew' | 'curl' | 'powershell' | 'cmd';
158
+
159
+ declare function ensureClaudeDir(): void;
160
+ declare function backupExistingConfig(): string | null;
161
+ declare function copyConfigFiles(onlyMd?: boolean): void;
162
+ declare function configureApi(apiConfig: ApiConfig | null): ApiConfig | null;
163
+ declare function mergeConfigs(sourceFile: string, targetFile: string): void;
164
+ /**
165
+ * Update custom model configuration using environment variables
166
+ * @param primaryModel - Primary model name for general tasks
167
+ * @param haikuModel - Default Haiku model (optional)
168
+ * @param sonnetModel - Default Sonnet model (optional)
169
+ * @param opusModel - Default Opus model (optional)
170
+ */
171
+ declare function updateCustomModel(primaryModel?: string, haikuModel?: string, sonnetModel?: string, opusModel?: string): void;
172
+ /**
173
+ * Update the default model configuration in settings.json
174
+ * @param model - The model type to set: opus, sonnet, sonnet[1m], default, or custom
175
+ * Note: 'custom' model type is handled differently - it should use environment variables instead
176
+ */
177
+ declare function updateDefaultModel(model: 'opus' | 'sonnet' | 'sonnet[1m]' | 'default' | 'custom'): void;
178
+ /**
179
+ * Merge settings.json intelligently
180
+ * Preserves user's environment variables and custom configurations
181
+ */
182
+ declare function mergeSettingsFile(templatePath: string, targetPath: string): void;
183
+ /**
184
+ * Get existing model configuration from settings.json
185
+ */
186
+ declare function getExistingModelConfig(): 'opus' | 'sonnet' | 'sonnet[1m]' | 'default' | 'custom' | null;
187
+ /**
188
+ * Get existing API configuration from settings.json
189
+ */
190
+ declare function getExistingApiConfig(): ApiConfig | null;
191
+ declare function applyAiLanguageDirective(aiOutputLang: AiOutputLanguage | string): void;
192
+ /**
193
+ * Switch to official login mode - remove all third-party API configurations
194
+ * Removes: ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY from settings.json
195
+ * Removes: primaryApiKey from ~/.claude/config.json
196
+ */
197
+ declare function switchToOfficialLogin(): boolean;
198
+ /**
199
+ * Prompt user for API configuration action when existing config is found
200
+ * Returns the user's choice for how to handle existing configuration
201
+ */
202
+ declare function promptApiConfigurationAction(): Promise<'modify-partial' | 'modify-all' | 'keep-existing' | null>;
203
+
204
+ declare function isClaudeCodeInstalled(): Promise<boolean>;
205
+ /**
206
+ * Install Claude Code with method selection support
207
+ * @param skipMethodSelection - If true, use default npm installation
208
+ */
209
+ declare function installClaudeCode(skipMethodSelection?: boolean): Promise<void>;
210
+ /**
211
+ * Check if Codex is installed
212
+ */
213
+ declare function isCodexInstalled(): Promise<boolean>;
214
+ /**
215
+ * Install Codex with method selection support
216
+ * @param skipMethodSelection - If true, use default npm installation
217
+ */
218
+ declare function installCodex(skipMethodSelection?: boolean): Promise<void>;
219
+ /**
220
+ * Check if local Claude Code installation exists
221
+ */
222
+ declare function isLocalClaudeCodeInstalled(): Promise<boolean>;
223
+ /**
224
+ * Get installation status for both global and local Claude Code
225
+ */
226
+ interface InstallationStatus {
227
+ hasGlobal: boolean;
228
+ hasLocal: boolean;
229
+ localPath: string;
230
+ }
231
+ declare function getInstallationStatus(): Promise<InstallationStatus>;
232
+ /**
233
+ * Remove local Claude Code installation
234
+ */
235
+ declare function removeLocalClaudeCode(): Promise<void>;
236
+ /**
237
+ * Uninstall code tool based on install method
238
+ * @param codeType - Type of code tool to uninstall
239
+ * @returns true if uninstalled successfully
240
+ */
241
+ declare function uninstallCodeTool(codeType: CodeType): Promise<boolean>;
242
+ /**
243
+ * Set installMethod in both ~/.claude.json and zcf-config
244
+ * This ensures Claude Code knows it was installed via npm for proper auto-updates
245
+ */
246
+ declare function setInstallMethod(method: InstallMethod, codeType?: CodeType): Promise<void>;
247
+ /**
248
+ * Detect installed version of a code tool
249
+ * Returns version string or null if not installed
250
+ */
251
+ declare function detectInstalledVersion(codeType: CodeType): Promise<string | null>;
252
+ /**
253
+ * Select installation method interactively
254
+ */
255
+ declare function selectInstallMethod(codeType: CodeType, excludeMethods?: InstallMethod[]): Promise<InstallMethod | null>;
256
+ /**
257
+ * Execute installation using specified method
258
+ */
259
+ declare function executeInstallMethod(method: InstallMethod, codeType: CodeType): Promise<boolean>;
260
+ /**
261
+ * Handle installation failure with retry options
262
+ */
263
+ declare function handleInstallFailure(codeType: CodeType, failedMethods: InstallMethod[]): Promise<boolean>;
264
+ /**
265
+ * Installation verification result
266
+ */
267
+ interface VerificationResult {
268
+ success: boolean;
269
+ commandPath: string | null;
270
+ version: string | null;
271
+ needsSymlink: boolean;
272
+ symlinkCreated: boolean;
273
+ error?: string;
274
+ }
275
+ /**
276
+ * Verify installation by checking command availability and version
277
+ * If command is not in PATH but found in Homebrew paths, attempt to create symlink
278
+ */
279
+ declare function verifyInstallation(codeType: CodeType): Promise<VerificationResult>;
280
+ /**
281
+ * Symlink creation result
282
+ */
283
+ interface SymlinkResult {
284
+ success: boolean;
285
+ symlinkPath: string | null;
286
+ error?: string;
287
+ }
288
+ /**
289
+ * Create symlink in Homebrew bin directory for commands installed via npm
290
+ * This handles the case where npm global packages are installed to
291
+ * /opt/homebrew/Cellar/node/{version}/bin/ but that path is not in the user's PATH
292
+ */
293
+ declare function createHomebrewSymlink(command: string, sourcePath: string): Promise<SymlinkResult>;
294
+ /**
295
+ * Display verification result to user with appropriate messages
296
+ */
297
+ declare function displayVerificationResult(result: VerificationResult, codeType: CodeType): void;
298
+
299
+ /**
300
+ * Clean up and deduplicate permissions array
301
+ * Removes invalid and redundant permissions based on template
302
+ */
303
+ /**
304
+ * Clean up permissions array by removing invalid and redundant entries
305
+ * @param templatePermissions - Permissions from template (source of truth)
306
+ * @param userPermissions - User's existing permissions
307
+ * @returns Cleaned permissions array
308
+ */
309
+ declare function cleanupPermissions(templatePermissions: string[], userPermissions: string[]): string[];
310
+ /**
311
+ * Merge and clean permissions arrays
312
+ * Combines template and user permissions while removing invalid/redundant entries
313
+ * @param templatePermissions - Permissions from template
314
+ * @param userPermissions - User's existing permissions
315
+ * @returns Merged and cleaned permissions array
316
+ */
317
+ declare function mergeAndCleanPermissions(templatePermissions: string[] | undefined, userPermissions: string[] | undefined): string[];
318
+
319
+ declare function importRecommendedEnv(): Promise<void>;
320
+ declare function importRecommendedPermissions(): Promise<void>;
321
+ declare function openSettingsJson(): Promise<void>;
322
+
323
+ export { AI_OUTPUT_LANGUAGES, API_DEFAULT_URL, API_ENV_KEY, CLAUDE_DIR, CLAUDE_MD_FILE, CLAUDE_VSC_CONFIG_FILE, CODEX_AGENTS_FILE, CODEX_AUTH_FILE, CODEX_CONFIG_FILE, CODEX_DIR, CODEX_LEGACY_WORKFLOW_PROMPT_FILES, CODEX_PROMPTS_DIR, CODEX_SKILLS_DIR, CODEX_ZCF_SKILL_NAMES, 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, addCompletedOnboarding, applyAiLanguageDirective, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, cleanupPermissions, commandExists, configureApi, copyConfigFiles, createHomebrewSymlink, detectInstalledVersion, displayVerificationResult, ensureApiKeyApproved, ensureClaudeDir, executeInstallMethod, fixWindowsMcpConfig, getAiOutputLanguageLabel, getExistingApiConfig, getExistingModelConfig, getInstallationStatus, getMcpConfigPath, getPlatform, handleInstallFailure, importRecommendedEnv, importRecommendedPermissions, init, installClaudeCode, installCodex, isClaudeCodeInstalled, isCodeToolType, isCodexInstalled, isLocalClaudeCodeInstalled, manageApiKeyApproval, mergeAndCleanPermissions, mergeConfigs, mergeMcpServers, mergeSettingsFile, openSettingsJson, promptApiConfigurationAction, readMcpConfig, removeApiKeyFromRejected, removeLocalClaudeCode, resolveCodeToolType, selectInstallMethod, setInstallMethod, setPrimaryApiKey, switchToOfficialLogin, uninstallCodeTool, updateCustomModel, updateDefaultModel, verifyInstallation, writeMcpConfig };
324
+ export type { AiOutputLanguage, ApiConfig, ClaudeConfiguration, CodeToolType, InstallationStatus, McpServerConfig, McpService, SupportedLang, VerificationResult };
package/dist/index.mjs ADDED
@@ -0,0 +1,19 @@
1
+ export { F as AI_OUTPUT_LANGUAGES, A as API_DEFAULT_URL, y as API_ENV_KEY, C as CLAUDE_DIR, e as CLAUDE_MD_FILE, h as CLAUDE_VSC_CONFIG_FILE, n as CODEX_AGENTS_FILE, l as CODEX_AUTH_FILE, k as CODEX_CONFIG_FILE, j as CODEX_DIR, s as CODEX_LEGACY_WORKFLOW_PROMPT_FILES, q as CODEX_PROMPTS_DIR, p as CODEX_SKILLS_DIR, r as CODEX_ZCF_SKILL_NAMES, w as CODE_TOOL_ALIASES, v as CODE_TOOL_BANNERS, u as CODE_TOOL_TYPES, f as ClAUDE_CONFIG_FILE, D as DEFAULT_CODE_TOOL_TYPE, E as LANG_LABELS, L as LEGACY_ZCF_CONFIG_FILES, S as SETTINGS_FILE, B as SUPPORTED_LANGS, Z as ZCF_CONFIG_DIR, t as ZCF_CONFIG_FILE, P as addCompletedOnboarding, a4 as applyAiLanguageDirective, W as backupExistingConfig, K as backupMcpConfig, N as buildMcpServerConfig, c as cleanupPermissions, a as commandExists, Y as configureApi, X as copyConfigFiles, al as createHomebrewSymlink, ag as detectInstalledVersion, am as displayVerificationResult, Q as ensureApiKeyApproved, V as ensureClaudeDir, ai as executeInstallMethod, O as fixWindowsMcpConfig, G as getAiOutputLanguageLabel, a3 as getExistingApiConfig, a2 as getExistingModelConfig, ac as getInstallationStatus, H as getMcpConfigPath, g as getPlatform, aj as handleInstallFailure, b as importRecommendedEnv, d as importRecommendedPermissions, i as init, a8 as installClaudeCode, aa as installCodex, a7 as isClaudeCodeInstalled, x as isCodeToolType, a9 as isCodexInstalled, ab as isLocalClaudeCodeInstalled, T as manageApiKeyApproval, m as mergeAndCleanPermissions, _ as mergeConfigs, M as mergeMcpServers, a1 as mergeSettingsFile, o as openSettingsJson, a6 as promptApiConfigurationAction, I as readMcpConfig, R as removeApiKeyFromRejected, ad as removeLocalClaudeCode, z as resolveCodeToolType, ah as selectInstallMethod, af as setInstallMethod, U as setPrimaryApiKey, a5 as switchToOfficialLogin, ae as uninstallCodeTool, $ as updateCustomModel, a0 as updateDefaultModel, ak as verifyInstallation, J as writeMcpConfig } from './chunks/simple-config.mjs';
2
+ import 'node:fs';
3
+ import 'node:process';
4
+ import 'ansis';
5
+ import 'inquirer';
6
+ import 'node:child_process';
7
+ import 'node:os';
8
+ import 'node:util';
9
+ import 'dayjs';
10
+ import 'pathe';
11
+ import 'node:url';
12
+ import 'inquirer-toggle';
13
+ import 'ora';
14
+ import 'tinyexec';
15
+ import 'semver';
16
+ import '@rainbowatcher/toml-edit-js';
17
+ import 'node:fs/promises';
18
+ import 'i18next';
19
+ import 'i18next-fs-backend';