zcf 1.1.1 → 1.1.3
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/README.md +23 -13
- package/dist/cli.mjs +7 -27
- package/dist/index.d.mts +25 -2
- package/dist/index.d.ts +25 -2
- package/dist/index.mjs +1 -1
- package/dist/shared/{zcf.CUoxYhz9.mjs → zcf.EL2e1-Wq.mjs} +138 -29
- package/package.json +1 -1
- package/templates/en/CLAUDE.md +0 -2
- package/templates/{en/settings.json → settings.json} +6 -2
- package/templates/zh-CN/CLAUDE.md +0 -2
- package/templates/zh-CN/settings.json +0 -25
package/README.md
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
# ZCF - Zero-Config Claude-Code Flow
|
|
2
2
|
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://claude.ai/code)
|
|
5
|
+
|
|
3
6
|
**中文** | [English](README_EN.md)
|
|
4
7
|
|
|
5
8
|
> 零配置,一键搞定 Claude Code 环境设置 - 支持中英文双语配置和智能代理系统
|
|
6
9
|
|
|
10
|
+

|
|
11
|
+
|
|
7
12
|
## 🚀 快速开始
|
|
8
13
|
|
|
9
14
|
### 根据你的情况选择:
|
|
10
15
|
|
|
11
16
|
#### 🆕 首次使用 Claude Code
|
|
17
|
+
|
|
12
18
|
```bash
|
|
13
|
-
npx zcf # 完整初始化:安装 Claude Code + 配置 API + 设置 MCP 服务
|
|
19
|
+
npx zcf # 完整初始化:安装 Claude Code + 导入工作流 + 配置 API + 设置 MCP 服务
|
|
14
20
|
```
|
|
15
21
|
|
|
16
22
|
#### 🔄 已有 Claude Code 环境
|
|
23
|
+
|
|
17
24
|
```bash
|
|
18
25
|
npx zcf u # 仅导入工作流:快速添加 AI 工作流和命令系统
|
|
19
26
|
```
|
|
@@ -25,6 +32,7 @@ npx zcf u # 仅导入工作流:快速添加 AI 工作流和命令系统
|
|
|
25
32
|
完整初始化(`npx zcf`)会自动:
|
|
26
33
|
|
|
27
34
|
- ✅ 检测并安装 Claude Code
|
|
35
|
+
- ✅ 选择 AI 输出语言(新增)
|
|
28
36
|
- ✅ 配置 API 密钥
|
|
29
37
|
- ✅ 选择并配置 MCP 服务
|
|
30
38
|
- ✅ 设置所有必要的配置文件
|
|
@@ -45,10 +53,11 @@ npx zcf u # 仅导入工作流:快速添加 AI 工作流和命令系统
|
|
|
45
53
|
|
|
46
54
|
## ✨ ZCF 工具特性
|
|
47
55
|
|
|
48
|
-
### 🌏
|
|
56
|
+
### 🌏 多语言支持
|
|
49
57
|
|
|
50
58
|
- 脚本交互语言:控制安装过程的提示语言
|
|
51
59
|
- 配置文件语言:决定安装哪套配置文件(zh-CN/en)
|
|
60
|
+
- AI 输出语言:选择 AI 回复使用的语言(支持简体中文、English 及自定义语言)
|
|
52
61
|
|
|
53
62
|
### 🔧 智能安装
|
|
54
63
|
|
|
@@ -92,6 +101,13 @@ $ npx zcf
|
|
|
92
101
|
❯ 简体中文 (zh-CN) - 中文版(便于中文用户自定义)
|
|
93
102
|
English (en) - 英文版(推荐,token 消耗更低)
|
|
94
103
|
|
|
104
|
+
? 选择 AI 输出语言:
|
|
105
|
+
AI 将使用此语言回复你的问题
|
|
106
|
+
❯ 简体中文
|
|
107
|
+
English
|
|
108
|
+
Custom
|
|
109
|
+
(支持日语、法语、德语等多种语言)
|
|
110
|
+
|
|
95
111
|
? 检测到 Claude Code 未安装,是否自动安装?(Y/n)
|
|
96
112
|
|
|
97
113
|
✔ Claude Code 安装成功
|
|
@@ -133,9 +149,9 @@ $ npx zcf
|
|
|
133
149
|
|
|
134
150
|
#### 命令速查表
|
|
135
151
|
|
|
136
|
-
| 命令 | 缩写 | 说明
|
|
137
|
-
| ------------ | ------- |
|
|
138
|
-
| `zcf` | - | 初始化配置(默认命令)
|
|
152
|
+
| 命令 | 缩写 | 说明 |
|
|
153
|
+
| ------------ | ------- | ---------------------------- |
|
|
154
|
+
| `zcf` | - | 初始化配置(默认命令) |
|
|
139
155
|
| `zcf update` | `zcf u` | 更新 Prompt 文档并备份旧配置 |
|
|
140
156
|
|
|
141
157
|
#### 常用选项
|
|
@@ -194,9 +210,9 @@ claude-code-config/
|
|
|
194
210
|
│ ├── utils/ # 工具函数
|
|
195
211
|
│ └── constants.ts # 常量定义
|
|
196
212
|
├── templates/ # 配置模板
|
|
213
|
+
│ ├── settings.json # 基础配置(含隐私保护环境变量)
|
|
197
214
|
│ ├── en/ # 英文版
|
|
198
215
|
│ │ ├── CLAUDE.md # 核心原则
|
|
199
|
-
│ │ ├── settings.json
|
|
200
216
|
│ │ ├── agents/ # AI 代理
|
|
201
217
|
│ │ └── commands/ # 命令定义
|
|
202
218
|
│ └── zh-CN/ # 中文版
|
|
@@ -233,12 +249,6 @@ claude-code-config/
|
|
|
233
249
|
5. **[模式:优化]** - 提升质量
|
|
234
250
|
6. **[模式:评审]** - 最终评估
|
|
235
251
|
|
|
236
|
-
## ⚙️ 支持的模型
|
|
237
|
-
|
|
238
|
-
- **opus**:最强大,适合复杂任务
|
|
239
|
-
- **sonnet**:平衡性能和成本
|
|
240
|
-
- **haiku**:快速轻量级模型
|
|
241
|
-
|
|
242
252
|
## 🛠️ 开发
|
|
243
253
|
|
|
244
254
|
```bash
|
|
@@ -260,7 +270,7 @@ node bin/zcf.mjs
|
|
|
260
270
|
|
|
261
271
|
1. **任务分解**:保持任务独立可测试
|
|
262
272
|
2. **代码质量**:遵循 SOLID、KISS、DRY 和 YAGNI 原则
|
|
263
|
-
3.
|
|
273
|
+
3. **文档管理**:计划存储在项目根目录的`.claude/plan/` 目录下
|
|
264
274
|
|
|
265
275
|
## 🔧 故障排除
|
|
266
276
|
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import cac from 'cac';
|
|
3
3
|
import ansis from 'ansis';
|
|
4
|
-
import {
|
|
4
|
+
import { t as displayBanner, u as selectScriptLanguage, v as readZcfConfig, I as I18N, S as SETTINGS_FILE, b as SUPPORTED_LANGS, L as LANG_LABELS, x as resolveAiOutputLanguage, y as updatePromptOnly, z as updateZcfConfig, B as version, i as init } from './shared/zcf.EL2e1-Wq.mjs';
|
|
5
5
|
import prompts from '@posva/prompts';
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
7
|
import 'node:os';
|
|
@@ -12,30 +12,8 @@ import 'tinyexec';
|
|
|
12
12
|
async function update(options = {}) {
|
|
13
13
|
try {
|
|
14
14
|
displayBanner("Update configuration for Claude Code");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!zcfConfig) {
|
|
18
|
-
const langResponse = await prompts({
|
|
19
|
-
type: "select",
|
|
20
|
-
name: "lang",
|
|
21
|
-
message: "Select script language / \u9009\u62E9\u811A\u672C\u8BED\u8A00",
|
|
22
|
-
choices: SUPPORTED_LANGS.map((l) => ({
|
|
23
|
-
title: LANG_LABELS[l],
|
|
24
|
-
value: l
|
|
25
|
-
}))
|
|
26
|
-
});
|
|
27
|
-
if (!langResponse.lang) {
|
|
28
|
-
console.log(ansis.yellow("Operation cancelled / \u64CD\u4F5C\u5DF2\u53D6\u6D88"));
|
|
29
|
-
process.exit(0);
|
|
30
|
-
}
|
|
31
|
-
scriptLang = langResponse.lang;
|
|
32
|
-
updateZcfConfig({
|
|
33
|
-
version,
|
|
34
|
-
preferredLang: scriptLang
|
|
35
|
-
});
|
|
36
|
-
} else {
|
|
37
|
-
scriptLang = zcfConfig.preferredLang;
|
|
38
|
-
}
|
|
15
|
+
const scriptLang = await selectScriptLanguage();
|
|
16
|
+
const zcfConfig = readZcfConfig();
|
|
39
17
|
const i18n = I18N[scriptLang];
|
|
40
18
|
if (!existsSync(SETTINGS_FILE)) {
|
|
41
19
|
console.log(ansis.yellow(i18n.noExistingConfig));
|
|
@@ -61,13 +39,15 @@ async function update(options = {}) {
|
|
|
61
39
|
}
|
|
62
40
|
configLang = configResponse.lang;
|
|
63
41
|
}
|
|
42
|
+
const aiOutputLang = await resolveAiOutputLanguage(scriptLang, options.aiOutputLang, zcfConfig);
|
|
64
43
|
console.log(ansis.cyan(`
|
|
65
44
|
${i18n.updatingPrompts}
|
|
66
45
|
`));
|
|
67
|
-
await updatePromptOnly(configLang, scriptLang);
|
|
46
|
+
await updatePromptOnly(configLang, scriptLang, aiOutputLang);
|
|
68
47
|
updateZcfConfig({
|
|
69
48
|
version,
|
|
70
|
-
preferredLang: scriptLang
|
|
49
|
+
preferredLang: scriptLang,
|
|
50
|
+
aiOutputLang
|
|
71
51
|
});
|
|
72
52
|
} catch (error) {
|
|
73
53
|
const zcfConfig = readZcfConfig();
|
package/dist/index.d.mts
CHANGED
|
@@ -38,10 +38,28 @@ declare const LANG_LABELS: {
|
|
|
38
38
|
readonly 'zh-CN': "简体中文";
|
|
39
39
|
readonly en: "English";
|
|
40
40
|
};
|
|
41
|
+
declare const AI_OUTPUT_LANGUAGES: {
|
|
42
|
+
readonly 'zh-CN': {
|
|
43
|
+
readonly label: "简体中文";
|
|
44
|
+
readonly directive: "Always respond in Chinese-simplified";
|
|
45
|
+
};
|
|
46
|
+
readonly en: {
|
|
47
|
+
readonly label: "English";
|
|
48
|
+
readonly directive: "Always respond in English";
|
|
49
|
+
};
|
|
50
|
+
readonly custom: {
|
|
51
|
+
readonly label: "Custom";
|
|
52
|
+
readonly directive: "";
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type AiOutputLanguage = keyof typeof AI_OUTPUT_LANGUAGES;
|
|
41
56
|
declare const I18N: {
|
|
42
57
|
'zh-CN': {
|
|
43
58
|
selectScriptLang: string;
|
|
44
59
|
selectConfigLang: string;
|
|
60
|
+
selectAiOutputLang: string;
|
|
61
|
+
aiOutputLangHint: string;
|
|
62
|
+
enterCustomLanguage: string;
|
|
45
63
|
configLangHint: {
|
|
46
64
|
'zh-CN': string;
|
|
47
65
|
en: string;
|
|
@@ -89,6 +107,9 @@ declare const I18N: {
|
|
|
89
107
|
en: {
|
|
90
108
|
selectScriptLang: string;
|
|
91
109
|
selectConfigLang: string;
|
|
110
|
+
selectAiOutputLang: string;
|
|
111
|
+
aiOutputLangHint: string;
|
|
112
|
+
enterCustomLanguage: string;
|
|
92
113
|
configLangHint: {
|
|
93
114
|
'zh-CN': string;
|
|
94
115
|
en: string;
|
|
@@ -139,6 +160,7 @@ declare const MCP_SERVICES: McpService[];
|
|
|
139
160
|
interface InitOptions {
|
|
140
161
|
lang?: SupportedLang;
|
|
141
162
|
configLang?: SupportedLang;
|
|
163
|
+
aiOutputLang?: AiOutputLanguage | string;
|
|
142
164
|
force?: boolean;
|
|
143
165
|
}
|
|
144
166
|
declare function init(options?: InitOptions): Promise<void>;
|
|
@@ -158,6 +180,7 @@ interface ApiConfig {
|
|
|
158
180
|
}
|
|
159
181
|
declare function configureApi(apiConfig: ApiConfig | null): void;
|
|
160
182
|
declare function mergeConfigs(sourceFile: string, targetFile: string): void;
|
|
183
|
+
declare function applyAiLanguageDirective(aiOutputLang: AiOutputLanguage | string): void;
|
|
161
184
|
|
|
162
185
|
declare function getMcpConfigPath(): string;
|
|
163
186
|
declare function readMcpConfig(): McpConfiguration | null;
|
|
@@ -166,5 +189,5 @@ declare function backupMcpConfig(): string | null;
|
|
|
166
189
|
declare function mergeMcpServers(existing: McpConfiguration | null, newServers: Record<string, McpServerConfig>): McpConfiguration;
|
|
167
190
|
declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string): McpServerConfig;
|
|
168
191
|
|
|
169
|
-
export { CLAUDE_DIR, CLAUDE_MD_FILE, I18N, LANG_LABELS, MCP_CONFIG_FILE, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, ZCF_CONFIG_FILE, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, commandExists, configureApi, copyConfigFiles, ensureClaudeDir, getMcpConfigPath, getPlatform, init, installClaudeCode, isClaudeCodeInstalled, mergeConfigs, mergeMcpServers, readMcpConfig, writeMcpConfig };
|
|
170
|
-
export type { ApiConfig, McpConfiguration, McpServerConfig, McpService, SupportedLang };
|
|
192
|
+
export { AI_OUTPUT_LANGUAGES, CLAUDE_DIR, CLAUDE_MD_FILE, I18N, LANG_LABELS, MCP_CONFIG_FILE, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, ZCF_CONFIG_FILE, applyAiLanguageDirective, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, commandExists, configureApi, copyConfigFiles, ensureClaudeDir, getMcpConfigPath, getPlatform, init, installClaudeCode, isClaudeCodeInstalled, mergeConfigs, mergeMcpServers, readMcpConfig, writeMcpConfig };
|
|
193
|
+
export type { AiOutputLanguage, ApiConfig, McpConfiguration, McpServerConfig, McpService, SupportedLang };
|
package/dist/index.d.ts
CHANGED
|
@@ -38,10 +38,28 @@ declare const LANG_LABELS: {
|
|
|
38
38
|
readonly 'zh-CN': "简体中文";
|
|
39
39
|
readonly en: "English";
|
|
40
40
|
};
|
|
41
|
+
declare const AI_OUTPUT_LANGUAGES: {
|
|
42
|
+
readonly 'zh-CN': {
|
|
43
|
+
readonly label: "简体中文";
|
|
44
|
+
readonly directive: "Always respond in Chinese-simplified";
|
|
45
|
+
};
|
|
46
|
+
readonly en: {
|
|
47
|
+
readonly label: "English";
|
|
48
|
+
readonly directive: "Always respond in English";
|
|
49
|
+
};
|
|
50
|
+
readonly custom: {
|
|
51
|
+
readonly label: "Custom";
|
|
52
|
+
readonly directive: "";
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type AiOutputLanguage = keyof typeof AI_OUTPUT_LANGUAGES;
|
|
41
56
|
declare const I18N: {
|
|
42
57
|
'zh-CN': {
|
|
43
58
|
selectScriptLang: string;
|
|
44
59
|
selectConfigLang: string;
|
|
60
|
+
selectAiOutputLang: string;
|
|
61
|
+
aiOutputLangHint: string;
|
|
62
|
+
enterCustomLanguage: string;
|
|
45
63
|
configLangHint: {
|
|
46
64
|
'zh-CN': string;
|
|
47
65
|
en: string;
|
|
@@ -89,6 +107,9 @@ declare const I18N: {
|
|
|
89
107
|
en: {
|
|
90
108
|
selectScriptLang: string;
|
|
91
109
|
selectConfigLang: string;
|
|
110
|
+
selectAiOutputLang: string;
|
|
111
|
+
aiOutputLangHint: string;
|
|
112
|
+
enterCustomLanguage: string;
|
|
92
113
|
configLangHint: {
|
|
93
114
|
'zh-CN': string;
|
|
94
115
|
en: string;
|
|
@@ -139,6 +160,7 @@ declare const MCP_SERVICES: McpService[];
|
|
|
139
160
|
interface InitOptions {
|
|
140
161
|
lang?: SupportedLang;
|
|
141
162
|
configLang?: SupportedLang;
|
|
163
|
+
aiOutputLang?: AiOutputLanguage | string;
|
|
142
164
|
force?: boolean;
|
|
143
165
|
}
|
|
144
166
|
declare function init(options?: InitOptions): Promise<void>;
|
|
@@ -158,6 +180,7 @@ interface ApiConfig {
|
|
|
158
180
|
}
|
|
159
181
|
declare function configureApi(apiConfig: ApiConfig | null): void;
|
|
160
182
|
declare function mergeConfigs(sourceFile: string, targetFile: string): void;
|
|
183
|
+
declare function applyAiLanguageDirective(aiOutputLang: AiOutputLanguage | string): void;
|
|
161
184
|
|
|
162
185
|
declare function getMcpConfigPath(): string;
|
|
163
186
|
declare function readMcpConfig(): McpConfiguration | null;
|
|
@@ -166,5 +189,5 @@ declare function backupMcpConfig(): string | null;
|
|
|
166
189
|
declare function mergeMcpServers(existing: McpConfiguration | null, newServers: Record<string, McpServerConfig>): McpConfiguration;
|
|
167
190
|
declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string): McpServerConfig;
|
|
168
191
|
|
|
169
|
-
export { CLAUDE_DIR, CLAUDE_MD_FILE, I18N, LANG_LABELS, MCP_CONFIG_FILE, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, ZCF_CONFIG_FILE, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, commandExists, configureApi, copyConfigFiles, ensureClaudeDir, getMcpConfigPath, getPlatform, init, installClaudeCode, isClaudeCodeInstalled, mergeConfigs, mergeMcpServers, readMcpConfig, writeMcpConfig };
|
|
170
|
-
export type { ApiConfig, McpConfiguration, McpServerConfig, McpService, SupportedLang };
|
|
192
|
+
export { AI_OUTPUT_LANGUAGES, CLAUDE_DIR, CLAUDE_MD_FILE, I18N, LANG_LABELS, MCP_CONFIG_FILE, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, ZCF_CONFIG_FILE, applyAiLanguageDirective, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, commandExists, configureApi, copyConfigFiles, ensureClaudeDir, getMcpConfigPath, getPlatform, init, installClaudeCode, isClaudeCodeInstalled, mergeConfigs, mergeMcpServers, readMcpConfig, writeMcpConfig };
|
|
193
|
+
export type { AiOutputLanguage, ApiConfig, McpConfiguration, McpServerConfig, McpService, SupportedLang };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CLAUDE_DIR, a as CLAUDE_MD_FILE, I as I18N, L as LANG_LABELS, M as MCP_CONFIG_FILE, d as MCP_SERVICES, S as SETTINGS_FILE, b as SUPPORTED_LANGS, Z as ZCF_CONFIG_FILE, j as backupExistingConfig,
|
|
1
|
+
export { A as AI_OUTPUT_LANGUAGES, C as CLAUDE_DIR, a as CLAUDE_MD_FILE, I as I18N, L as LANG_LABELS, M as MCP_CONFIG_FILE, d as MCP_SERVICES, S as SETTINGS_FILE, b as SUPPORTED_LANGS, Z as ZCF_CONFIG_FILE, n as applyAiLanguageDirective, j as backupExistingConfig, p as backupMcpConfig, s as buildMcpServerConfig, c as commandExists, l as configureApi, k as copyConfigFiles, h as ensureClaudeDir, o as getMcpConfigPath, g as getPlatform, i as init, f as installClaudeCode, e as isClaudeCodeInstalled, m as mergeConfigs, q as mergeMcpServers, r as readMcpConfig, w as writeMcpConfig } from './shared/zcf.EL2e1-Wq.mjs';
|
|
2
2
|
import '@posva/prompts';
|
|
3
3
|
import 'ansis';
|
|
4
4
|
import 'node:fs';
|
|
@@ -6,7 +6,7 @@ import { join, dirname } from 'pathe';
|
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
7
|
import { exec } from 'tinyexec';
|
|
8
8
|
|
|
9
|
-
const version = "1.1.
|
|
9
|
+
const version = "1.1.3";
|
|
10
10
|
|
|
11
11
|
const CLAUDE_DIR = join(homedir(), ".claude");
|
|
12
12
|
const SETTINGS_FILE = join(CLAUDE_DIR, "settings.json");
|
|
@@ -18,10 +18,18 @@ const LANG_LABELS = {
|
|
|
18
18
|
"zh-CN": "\u7B80\u4F53\u4E2D\u6587",
|
|
19
19
|
en: "English"
|
|
20
20
|
};
|
|
21
|
+
const AI_OUTPUT_LANGUAGES = {
|
|
22
|
+
"zh-CN": { label: "\u7B80\u4F53\u4E2D\u6587", directive: "Always respond in Chinese-simplified" },
|
|
23
|
+
en: { label: "English", directive: "Always respond in English" },
|
|
24
|
+
custom: { label: "Custom", directive: "" }
|
|
25
|
+
};
|
|
21
26
|
const I18N = {
|
|
22
27
|
"zh-CN": {
|
|
23
28
|
selectScriptLang: "\u9009\u62E9\u811A\u672C\u8BED\u8A00",
|
|
24
29
|
selectConfigLang: "\u9009\u62E9 Claude Code \u914D\u7F6E\u8BED\u8A00",
|
|
30
|
+
selectAiOutputLang: "\u9009\u62E9 AI \u8F93\u51FA\u8BED\u8A00",
|
|
31
|
+
aiOutputLangHint: "AI \u5C06\u4F7F\u7528\u6B64\u8BED\u8A00\u56DE\u590D\u4F60\u7684\u95EE\u9898",
|
|
32
|
+
enterCustomLanguage: "\u8BF7\u8F93\u5165\u81EA\u5B9A\u4E49\u8BED\u8A00\uFF08\u4F8B\u5982\uFF1AJapanese, French \u7B49\uFF09",
|
|
25
33
|
configLangHint: {
|
|
26
34
|
"zh-CN": "\u4E2D\u6587\u7248\uFF08\u4FBF\u4E8E\u4E2D\u6587\u7528\u6237\u81EA\u5B9A\u4E49\uFF09",
|
|
27
35
|
en: "\u82F1\u6587\u7248\uFF08\u63A8\u8350\uFF0Ctoken \u6D88\u8017\u66F4\u4F4E\uFF09"
|
|
@@ -63,12 +71,15 @@ const I18N = {
|
|
|
63
71
|
updateConfigLangPrompt: "\u9009\u62E9\u914D\u7F6E\u8BED\u8A00",
|
|
64
72
|
updateConfigLangChoice: {
|
|
65
73
|
"zh-CN": "\u4E2D\u6587\u7248\u914D\u7F6E",
|
|
66
|
-
|
|
74
|
+
en: "\u82F1\u6587\u7248\u914D\u7F6E"
|
|
67
75
|
}
|
|
68
76
|
},
|
|
69
77
|
en: {
|
|
70
78
|
selectScriptLang: "Select script language",
|
|
71
79
|
selectConfigLang: "Select Claude Code configuration language",
|
|
80
|
+
selectAiOutputLang: "Select AI output language",
|
|
81
|
+
aiOutputLangHint: "AI will respond to you in this language",
|
|
82
|
+
enterCustomLanguage: "Enter custom language (e.g., Japanese, French, etc.)",
|
|
72
83
|
configLangHint: {
|
|
73
84
|
"zh-CN": "Chinese (easier for Chinese users to customize)",
|
|
74
85
|
en: "English (recommended, lower token consumption)"
|
|
@@ -110,7 +121,7 @@ const I18N = {
|
|
|
110
121
|
updateConfigLangPrompt: "Select configuration language",
|
|
111
122
|
updateConfigLangChoice: {
|
|
112
123
|
"zh-CN": "Chinese configuration",
|
|
113
|
-
|
|
124
|
+
en: "English configuration"
|
|
114
125
|
}
|
|
115
126
|
}
|
|
116
127
|
};
|
|
@@ -191,7 +202,7 @@ function displayBanner(subtitle) {
|
|
|
191
202
|
\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
192
203
|
\u2551 \u2551
|
|
193
204
|
\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2551
|
|
194
|
-
\u2551
|
|
205
|
+
\u2551 \u2588\u2588\u2554\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2551
|
|
195
206
|
\u2551 \u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557 \u2551
|
|
196
207
|
\u2551 \u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u255D \u2551
|
|
197
208
|
\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2551
|
|
@@ -238,6 +249,7 @@ function copyConfigFiles(lang, onlyMd = false) {
|
|
|
238
249
|
const distDir = dirname(dirname(currentFilePath));
|
|
239
250
|
const rootDir = dirname(distDir);
|
|
240
251
|
const sourceDir = join(rootDir, "templates", lang);
|
|
252
|
+
const baseTemplateDir = join(rootDir, "templates");
|
|
241
253
|
if (!existsSync(sourceDir)) {
|
|
242
254
|
throw new Error(`Template directory not found: ${sourceDir}`);
|
|
243
255
|
}
|
|
@@ -245,6 +257,11 @@ function copyConfigFiles(lang, onlyMd = false) {
|
|
|
245
257
|
copyMdFiles(sourceDir, CLAUDE_DIR);
|
|
246
258
|
} else {
|
|
247
259
|
copyDirectory(sourceDir, CLAUDE_DIR);
|
|
260
|
+
const baseSettingsPath = join(baseTemplateDir, "settings.json");
|
|
261
|
+
const destSettingsPath = join(CLAUDE_DIR, "settings.json");
|
|
262
|
+
if (existsSync(baseSettingsPath)) {
|
|
263
|
+
copyFileSync(baseSettingsPath, destSettingsPath);
|
|
264
|
+
}
|
|
248
265
|
}
|
|
249
266
|
}
|
|
250
267
|
function copyMdFiles(src, dest) {
|
|
@@ -269,6 +286,9 @@ function copyDirectory(src, dest) {
|
|
|
269
286
|
}
|
|
270
287
|
const entries = readdirSync(src);
|
|
271
288
|
for (const entry of entries) {
|
|
289
|
+
if (entry === "settings.json") {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
272
292
|
const srcPath = join(src, entry);
|
|
273
293
|
const destPath = join(dest, entry);
|
|
274
294
|
const stat = statSync(srcPath);
|
|
@@ -318,7 +338,7 @@ function configureApi(apiConfig) {
|
|
|
318
338
|
console.error("Failed to parse existing settings.json, using defaults:", error);
|
|
319
339
|
}
|
|
320
340
|
}
|
|
321
|
-
settings.env.
|
|
341
|
+
settings.env.ANTHROPIC_AUTH_TOKEN = apiConfig.key;
|
|
322
342
|
settings.env.ANTHROPIC_BASE_URL = apiConfig.url;
|
|
323
343
|
writeFileSync(SETTINGS_FILE, JSON.stringify(settings, null, 2));
|
|
324
344
|
}
|
|
@@ -348,6 +368,30 @@ function deepMerge(target, source) {
|
|
|
348
368
|
}
|
|
349
369
|
return result;
|
|
350
370
|
}
|
|
371
|
+
function applyAiLanguageDirective(aiOutputLang) {
|
|
372
|
+
if (!existsSync(CLAUDE_MD_FILE)) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
let content = readFileSync(CLAUDE_MD_FILE, "utf-8");
|
|
376
|
+
const lines = content.split("\n");
|
|
377
|
+
if (lines[0] && lines[0].startsWith("Always respond in")) {
|
|
378
|
+
lines.shift();
|
|
379
|
+
if (lines[0] === "") {
|
|
380
|
+
lines.shift();
|
|
381
|
+
}
|
|
382
|
+
content = lines.join("\n");
|
|
383
|
+
}
|
|
384
|
+
let directive = "";
|
|
385
|
+
if (aiOutputLang === "custom") {
|
|
386
|
+
return;
|
|
387
|
+
} else if (AI_OUTPUT_LANGUAGES[aiOutputLang]) {
|
|
388
|
+
directive = AI_OUTPUT_LANGUAGES[aiOutputLang].directive;
|
|
389
|
+
} else {
|
|
390
|
+
directive = `Always respond in ${aiOutputLang}`;
|
|
391
|
+
}
|
|
392
|
+
const newContent = directive + "\n\n" + content;
|
|
393
|
+
writeFileSync(CLAUDE_MD_FILE, newContent, "utf-8");
|
|
394
|
+
}
|
|
351
395
|
|
|
352
396
|
function getPlatform() {
|
|
353
397
|
const p = platform();
|
|
@@ -470,18 +514,99 @@ function updateZcfConfig(updates) {
|
|
|
470
514
|
const newConfig = {
|
|
471
515
|
version: updates.version || existingConfig?.version || "1.0.0",
|
|
472
516
|
preferredLang: updates.preferredLang || existingConfig?.preferredLang || "en",
|
|
517
|
+
aiOutputLang: updates.aiOutputLang || existingConfig?.aiOutputLang,
|
|
473
518
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
474
519
|
};
|
|
475
520
|
writeZcfConfig(newConfig);
|
|
476
521
|
}
|
|
477
522
|
|
|
478
|
-
async function
|
|
523
|
+
async function selectAiOutputLanguage(scriptLang, defaultLang) {
|
|
524
|
+
const i18n = I18N[scriptLang];
|
|
525
|
+
console.log(ansis.dim(`
|
|
526
|
+
${i18n.aiOutputLangHint}
|
|
527
|
+
`));
|
|
528
|
+
const aiLangChoices = Object.entries(AI_OUTPUT_LANGUAGES).map(([key, value]) => ({
|
|
529
|
+
title: value.label,
|
|
530
|
+
value: key
|
|
531
|
+
}));
|
|
532
|
+
const defaultChoice = defaultLang || (scriptLang === "zh-CN" ? "zh-CN" : "en");
|
|
533
|
+
const aiLangResponse = await prompts({
|
|
534
|
+
type: "select",
|
|
535
|
+
name: "lang",
|
|
536
|
+
message: i18n.selectAiOutputLang,
|
|
537
|
+
choices: aiLangChoices,
|
|
538
|
+
initial: aiLangChoices.findIndex((c) => c.value === defaultChoice)
|
|
539
|
+
});
|
|
540
|
+
if (!aiLangResponse.lang) {
|
|
541
|
+
console.log(ansis.yellow(i18n.cancelled));
|
|
542
|
+
process.exit(0);
|
|
543
|
+
}
|
|
544
|
+
let aiOutputLang = aiLangResponse.lang;
|
|
545
|
+
if (aiOutputLang === "custom") {
|
|
546
|
+
const customLangResponse = await prompts({
|
|
547
|
+
type: "text",
|
|
548
|
+
name: "customLang",
|
|
549
|
+
message: i18n.enterCustomLanguage,
|
|
550
|
+
validate: (value) => !!value || "Language is required"
|
|
551
|
+
});
|
|
552
|
+
if (!customLangResponse.customLang) {
|
|
553
|
+
console.log(ansis.yellow(i18n.cancelled));
|
|
554
|
+
process.exit(0);
|
|
555
|
+
}
|
|
556
|
+
return customLangResponse.customLang;
|
|
557
|
+
}
|
|
558
|
+
return aiOutputLang;
|
|
559
|
+
}
|
|
560
|
+
async function selectScriptLanguage(currentLang) {
|
|
561
|
+
const zcfConfig = readZcfConfig();
|
|
562
|
+
if (zcfConfig?.preferredLang) {
|
|
563
|
+
return zcfConfig.preferredLang;
|
|
564
|
+
}
|
|
565
|
+
if (currentLang) {
|
|
566
|
+
return currentLang;
|
|
567
|
+
}
|
|
568
|
+
const response = await prompts({
|
|
569
|
+
type: "select",
|
|
570
|
+
name: "lang",
|
|
571
|
+
message: "Select script language / \u9009\u62E9\u811A\u672C\u8BED\u8A00",
|
|
572
|
+
choices: SUPPORTED_LANGS.map((l) => ({
|
|
573
|
+
title: LANG_LABELS[l],
|
|
574
|
+
value: l
|
|
575
|
+
}))
|
|
576
|
+
});
|
|
577
|
+
if (!response.lang) {
|
|
578
|
+
console.log(ansis.yellow("Operation cancelled / \u64CD\u4F5C\u5DF2\u53D6\u6D88"));
|
|
579
|
+
process.exit(0);
|
|
580
|
+
}
|
|
581
|
+
const scriptLang = response.lang;
|
|
582
|
+
updateZcfConfig({
|
|
583
|
+
version,
|
|
584
|
+
preferredLang: scriptLang
|
|
585
|
+
});
|
|
586
|
+
return scriptLang;
|
|
587
|
+
}
|
|
588
|
+
async function resolveAiOutputLanguage(scriptLang, commandLineOption, savedConfig) {
|
|
589
|
+
const i18n = I18N[scriptLang];
|
|
590
|
+
if (commandLineOption) {
|
|
591
|
+
return commandLineOption;
|
|
592
|
+
}
|
|
593
|
+
if (savedConfig?.aiOutputLang) {
|
|
594
|
+
console.log(ansis.gray(`\u2714 ${i18n.aiOutputLangHint}: ${savedConfig.aiOutputLang}`));
|
|
595
|
+
return savedConfig.aiOutputLang;
|
|
596
|
+
}
|
|
597
|
+
return await selectAiOutputLanguage(scriptLang, scriptLang);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
async function updatePromptOnly(configLang, scriptLang, aiOutputLang) {
|
|
479
601
|
const i18n = I18N[scriptLang];
|
|
480
602
|
const backupDir = backupExistingConfig();
|
|
481
603
|
if (backupDir) {
|
|
482
604
|
console.log(ansis.gray(`\u2714 ${i18n.backupSuccess}: ${backupDir}`));
|
|
483
605
|
}
|
|
484
606
|
copyConfigFiles(configLang, true);
|
|
607
|
+
if (aiOutputLang) {
|
|
608
|
+
applyAiLanguageDirective(aiOutputLang);
|
|
609
|
+
}
|
|
485
610
|
console.log(ansis.green(`\u2714 ${i18n.configSuccess} ${CLAUDE_DIR}`));
|
|
486
611
|
console.log("\n" + ansis.cyan(i18n.complete));
|
|
487
612
|
}
|
|
@@ -490,27 +615,7 @@ async function init(options = {}) {
|
|
|
490
615
|
displayBanner();
|
|
491
616
|
console.log(ansis.gray(` Version: ${ansis.cyan(version)} | ${ansis.cyan("https://github.com/UfoMiao/zcf")}
|
|
492
617
|
`));
|
|
493
|
-
|
|
494
|
-
if (!scriptLang) {
|
|
495
|
-
const response = await prompts({
|
|
496
|
-
type: "select",
|
|
497
|
-
name: "lang",
|
|
498
|
-
message: "Select script language / \u9009\u62E9\u811A\u672C\u8BED\u8A00",
|
|
499
|
-
choices: SUPPORTED_LANGS.map((l) => ({
|
|
500
|
-
title: LANG_LABELS[l],
|
|
501
|
-
value: l
|
|
502
|
-
}))
|
|
503
|
-
});
|
|
504
|
-
if (!response.lang) {
|
|
505
|
-
console.log(ansis.yellow("\u64CD\u4F5C\u5DF2\u53D6\u6D88 / Operation cancelled"));
|
|
506
|
-
process.exit(0);
|
|
507
|
-
}
|
|
508
|
-
scriptLang = response.lang;
|
|
509
|
-
}
|
|
510
|
-
if (!scriptLang) {
|
|
511
|
-
console.error(ansis.red("Language not selected"));
|
|
512
|
-
process.exit(1);
|
|
513
|
-
}
|
|
618
|
+
const scriptLang = await selectScriptLanguage(options.lang);
|
|
514
619
|
const i18n = I18N[scriptLang];
|
|
515
620
|
let configLang = options.configLang;
|
|
516
621
|
if (!configLang) {
|
|
@@ -529,6 +634,8 @@ async function init(options = {}) {
|
|
|
529
634
|
}
|
|
530
635
|
configLang = response.lang;
|
|
531
636
|
}
|
|
637
|
+
const zcfConfig = readZcfConfig();
|
|
638
|
+
const aiOutputLang = await resolveAiOutputLanguage(scriptLang, options.aiOutputLang, zcfConfig);
|
|
532
639
|
const installed = await isClaudeCodeInstalled();
|
|
533
640
|
if (!installed) {
|
|
534
641
|
const response = await prompts({
|
|
@@ -649,6 +756,7 @@ async function init(options = {}) {
|
|
|
649
756
|
} else if (action === "new") {
|
|
650
757
|
copyConfigFiles(configLang, false);
|
|
651
758
|
}
|
|
759
|
+
applyAiLanguageDirective(aiOutputLang);
|
|
652
760
|
if (apiConfig && !onlyUpdateDocs) {
|
|
653
761
|
configureApi(apiConfig);
|
|
654
762
|
console.log(ansis.green(`\u2714 ${i18n.apiConfigSuccess}`));
|
|
@@ -735,7 +843,8 @@ async function init(options = {}) {
|
|
|
735
843
|
}
|
|
736
844
|
updateZcfConfig({
|
|
737
845
|
version,
|
|
738
|
-
preferredLang: scriptLang
|
|
846
|
+
preferredLang: scriptLang,
|
|
847
|
+
aiOutputLang
|
|
739
848
|
});
|
|
740
849
|
console.log(ansis.green(`\u2714 ${i18n.configSuccess} ${CLAUDE_DIR}`));
|
|
741
850
|
console.log("\n" + ansis.cyan(i18n.complete));
|
|
@@ -745,4 +854,4 @@ async function init(options = {}) {
|
|
|
745
854
|
}
|
|
746
855
|
}
|
|
747
856
|
|
|
748
|
-
export { CLAUDE_DIR as C, I18N as I, LANG_LABELS as L, MCP_CONFIG_FILE as M, SETTINGS_FILE as S, ZCF_CONFIG_FILE as Z, CLAUDE_MD_FILE as a, SUPPORTED_LANGS as b, commandExists as c, MCP_SERVICES as d, isClaudeCodeInstalled as e, installClaudeCode as f, getPlatform as g, ensureClaudeDir as h, init as i, backupExistingConfig as j, copyConfigFiles as k, configureApi as l, mergeConfigs as m,
|
|
857
|
+
export { AI_OUTPUT_LANGUAGES as A, version as B, CLAUDE_DIR as C, I18N as I, LANG_LABELS as L, MCP_CONFIG_FILE as M, SETTINGS_FILE as S, ZCF_CONFIG_FILE as Z, CLAUDE_MD_FILE as a, SUPPORTED_LANGS as b, commandExists as c, MCP_SERVICES as d, isClaudeCodeInstalled as e, installClaudeCode as f, getPlatform as g, ensureClaudeDir as h, init as i, backupExistingConfig as j, copyConfigFiles as k, configureApi as l, mergeConfigs as m, applyAiLanguageDirective as n, getMcpConfigPath as o, backupMcpConfig as p, mergeMcpServers as q, readMcpConfig as r, buildMcpServerConfig as s, displayBanner as t, selectScriptLanguage as u, readZcfConfig as v, writeMcpConfig as w, resolveAiOutputLanguage as x, updatePromptOnly as y, updateZcfConfig as z };
|
package/package.json
CHANGED
package/templates/en/CLAUDE.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
Always respond in Chinese-simplified
|
|
2
|
-
|
|
3
1
|
You are an experienced [professional domain, e.g., Software Development Engineer / System Designer / Code Architect], specializing in building [core strengths, e.g., high-performance / maintainable / robust / domain-driven] solutions.
|
|
4
2
|
|
|
5
3
|
Your mission is: **Review, understand, and iteratively improve/advance a [project type, e.g., existing codebase / software project / technical process].**
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/claude-code-settings.json",
|
|
3
|
-
"env": {
|
|
3
|
+
"env": {
|
|
4
|
+
"DISABLE_TELEMETRY": "1",
|
|
5
|
+
"DISABLE_ERROR_REPORTING": "1",
|
|
6
|
+
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
|
|
7
|
+
},
|
|
4
8
|
"includeCoAuthoredBy": false,
|
|
5
9
|
"permissions": {
|
|
6
10
|
"allow": [
|
|
@@ -22,4 +26,4 @@
|
|
|
22
26
|
},
|
|
23
27
|
"hooks": {},
|
|
24
28
|
"model": "opus"
|
|
25
|
-
}
|
|
29
|
+
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/claude-code-settings.json",
|
|
3
|
-
"env": {},
|
|
4
|
-
"includeCoAuthoredBy": false,
|
|
5
|
-
"permissions": {
|
|
6
|
-
"allow": [
|
|
7
|
-
"Bash(*)",
|
|
8
|
-
"LS(*)",
|
|
9
|
-
"Read(*)",
|
|
10
|
-
"Write(*)",
|
|
11
|
-
"Edit(*)",
|
|
12
|
-
"MultiEdit(*)",
|
|
13
|
-
"Glob(*)",
|
|
14
|
-
"Grep(*)",
|
|
15
|
-
"WebFetch(*)",
|
|
16
|
-
"WebSearch(*)",
|
|
17
|
-
"TodoWrite(*)",
|
|
18
|
-
"NotebookRead(*)",
|
|
19
|
-
"NotebookEdit(*)"
|
|
20
|
-
],
|
|
21
|
-
"deny": []
|
|
22
|
-
},
|
|
23
|
-
"hooks": {},
|
|
24
|
-
"model": "opus"
|
|
25
|
-
}
|