zcf 1.0.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/README.md ADDED
@@ -0,0 +1,238 @@
1
+ # ZCF - Zero-Config Claude-Code Flow
2
+
3
+ **中文** | [English](README_EN.md)
4
+
5
+ > 零配置,一键搞定 Claude Code 环境设置 - 支持中英文双语配置和智能代理系统
6
+
7
+ ## 🚀 快速开始
8
+
9
+ ```bash
10
+ npx zcf
11
+ ```
12
+
13
+ 运行后会自动:
14
+ - 检测并安装 Claude Code
15
+ - 配置 API 密钥
16
+ - 选择并配置 MCP 服务
17
+ - 设置所有必要的配置文件
18
+
19
+ ### 使用方式
20
+
21
+ 配置完成后:
22
+
23
+ - **项目第一次使用强烈建议先运行 `/init` 进行初始化,生成 CLAUDE.md 便于 AI 理解项目架构**
24
+ - `<任务描述>` - 不使用任何工作流直接执行,会遵循 SOLID、KISS、DRY 和 YAGNI 原则,适合修复 Bug 等小任务
25
+ - `/feat <任务描述>` - 开始新功能开发,分为 plan 和 ui 两个阶段
26
+ - `/workflow <任务描述>` - 执行完整开发工作流,不是自动化,开始会给出多套方案,每一步会询问用户意见,可随时修改方案,掌控力 MAX
27
+
28
+ > **PS**:
29
+ >
30
+ > - feat 和 workflow 这两套各有优势,可以都试试比较一下
31
+ > - 生成的文档位置默认都是项目根目录下的 `.claude/xxx.md`,可以把 `.claude/` 加入项目的 `.gitignore` 里
32
+
33
+ ## ✨ ZCF 工具特性
34
+
35
+ ### 🌏 双语支持
36
+ - 脚本交互语言:控制安装过程的提示语言
37
+ - 配置文件语言:决定安装哪套配置文件(zh-CN/en)
38
+
39
+ ### 🔧 智能安装
40
+ - 自动检测 Claude Code 安装状态
41
+ - 支持 npm/yarn/pnpm 包管理器
42
+ - 跨平台支持(Windows/macOS/Linux)
43
+ - 自动配置 MCP 服务(新增)
44
+
45
+ ### 📦 完整配置
46
+ - CLAUDE.md 系统指令
47
+ - settings.json 设置文件
48
+ - commands 自定义命令
49
+ - agents AI 代理配置
50
+
51
+ ### 🔐 API 配置
52
+ - 自定义 API 支持
53
+ - API Key 自动配置
54
+ - 支持稍后在 claude 命令中配置(如 OAuth)
55
+
56
+ ### 💾 配置管理
57
+ - 智能备份现有配置(所有备份保存在 ~/.claude/backup/)
58
+ - 配置合并选项
59
+ - 安全的覆盖机制
60
+ - MCP 配置修改前自动备份
61
+
62
+ ## 📖 使用说明
63
+
64
+ ### 交互式配置流程
65
+
66
+ ```bash
67
+ $ npx zcf
68
+
69
+ ? Select script language / 选择脚本语言:
70
+ ❯ 简体中文
71
+ English
72
+
73
+ ? 选择 Claude Code 配置语言:
74
+ ❯ 简体中文 (zh-CN) - 中文版(便于中文用户自定义)
75
+ English (en) - 英文版(推荐,token 消耗更低)
76
+
77
+ ? 检测到 Claude Code 未安装,是否自动安装?(Y/n)
78
+
79
+ ✔ Claude Code 安装成功
80
+
81
+ ? 是否配置 API?
82
+ ❯ 配置 API
83
+ 跳过(稍后在 claude 命令中自行配置,如 OAuth)
84
+
85
+ ? 请输入 API URL: https://api.anthropic.com
86
+ ? 请输入 API Key: sk-xxx
87
+
88
+ ? 检测到已有配置文件,如何处理?
89
+ ❯ 备份并覆盖全部
90
+ 仅更新 Prompt 文档并备份旧配置
91
+ 合并配置
92
+ 跳过
93
+
94
+ ✔ 已备份所有配置文件到 ~/.claude/backup/xxx
95
+ ✔ 配置文件已复制到 ~/.claude
96
+ ✔ API 配置完成
97
+
98
+ ? 是否配置 MCP 服务?(Y/n)
99
+
100
+ ? 选择要安装的 MCP 服务(空格选择,回车确认)
101
+ ❯ ◯ 全部安装
102
+ ◯ Context7 文档查询 - 查询最新的库文档和代码示例
103
+ ◯ DeepWiki - 查询 GitHub 仓库文档和示例
104
+ ◯ Playwright 浏览器控制 - 直接控制浏览器进行自动化操作
105
+ ◯ Exa AI 搜索 - 使用 Exa AI 进行网页搜索
106
+
107
+ ? 请输入 Exa API Key(可从 https://dashboard.exa.ai/api-keys 获取)
108
+
109
+ ✔ MCP 服务已配置
110
+
111
+ 🎉 配置完成!使用 'claude' 命令开始体验。
112
+ ```
113
+
114
+ ### 命令行参数
115
+
116
+ ```bash
117
+ # 指定配置语言
118
+ npx zcf --config-lang zh-CN
119
+
120
+ # 强制覆盖现有配置
121
+ npx zcf --force
122
+
123
+ # 跳过 Claude Code 安装检测
124
+ npx zcf --skip-install
125
+
126
+ # 帮助信息
127
+ npx zcf --help
128
+ ```
129
+
130
+ ## 📁 项目结构
131
+
132
+ ```
133
+ claude-code-config/
134
+ ├── README.md # 说明文档
135
+ ├── package.json # npm 包配置
136
+ ├── bin/
137
+ │ └── zcf.mjs # CLI 入口
138
+ ├── src/ # 源代码
139
+ │ ├── cli.ts # CLI 主逻辑
140
+ │ ├── commands/ # 命令实现
141
+ │ ├── utils/ # 工具函数
142
+ │ └── constants.ts # 常量定义
143
+ ├── templates/ # 配置模板
144
+ │ ├── en/ # 英文版
145
+ │ │ ├── CLAUDE.md # 核心原则
146
+ │ │ ├── settings.json
147
+ │ │ ├── agents/ # AI 代理
148
+ │ │ └── commands/ # 命令定义
149
+ │ └── zh-CN/ # 中文版
150
+ │ └── ... (相同结构)
151
+ └── dist/ # 构建输出
152
+ ```
153
+
154
+ ## ✨ 核心特性
155
+
156
+ ### 🤖 专业代理
157
+
158
+ - **任务规划师**:将复杂任务拆解为可执行步骤
159
+ - **UI/UX 设计师**:提供专业界面设计指导
160
+
161
+ ### ⚡ 命令系统
162
+
163
+ - **功能开发** (`/feat`):结构化新功能开发
164
+ - **工作流** (`/workflow`):完整的六阶段开发流程
165
+
166
+ ### 🔧 智能配置
167
+
168
+ - API 密钥管理
169
+ - 细粒度权限控制
170
+ - 多种 Claude 模型支持
171
+
172
+ ## 🎯 开发工作流
173
+
174
+ ### 六阶段工作流
175
+
176
+ 1. **[模式:研究]** - 理解需求
177
+ 2. **[模式:构思]** - 设计方案
178
+ 3. **[模式:计划]** - 制定详细计划
179
+ 4. **[模式:执行]** - 实施开发
180
+ 5. **[模式:优化]** - 提升质量
181
+ 6. **[模式:评审]** - 最终评估
182
+
183
+ ## ⚙️ 支持的模型
184
+
185
+ - **opus**:最强大,适合复杂任务
186
+ - **sonnet**:平衡性能和成本
187
+ - **haiku**:快速轻量级模型
188
+
189
+ ## 🛠️ 开发
190
+
191
+ ```bash
192
+ # 克隆项目
193
+ git clone https://github.com/UfoMiao/claude-code-config.git
194
+ cd claude-code-config
195
+
196
+ # 安装依赖(使用 pnpm)
197
+ pnpm install
198
+
199
+ # 构建项目
200
+ pnpm build
201
+
202
+ # 本地测试
203
+ node bin/zcf.mjs
204
+ ```
205
+
206
+ ## 💡 最佳实践
207
+
208
+ 1. **任务分解**:保持任务独立可测试
209
+ 2. **代码质量**:遵循 SOLID、KISS、DRY 和 YAGNI 原则
210
+ 3. **文档管理**:计划存储在 `.claude/` 目录
211
+
212
+ ## 🔧 故障排除
213
+
214
+ 如果遇到问题,可以:
215
+
216
+ 1. 重新运行 `npx zcf` 重新配置
217
+ 2. 检查 `~/.claude/` 目录下的配置文件
218
+ 3. 确保 Claude Code 已正确安装
219
+
220
+ ## 🙏 鸣谢
221
+
222
+ 本项目的部分 Prompt 参考了以下优秀作品:
223
+
224
+ - [Linux.do - 分享一个让 AI 只生成必要的代码的通用 Prompt,欢迎一起调优~](https://linux.do/t/topic/830802)
225
+ - [Linux.do - claude code 降智不怕,使用 agent 与 command 结合将任务做详细的拆分大概可以帮助到你](https://linux.do/t/topic/815230)
226
+ - [Linux.do - cursor 快速开发规则](https://linux.do/t/topic/697566)
227
+
228
+ 感谢这些社区贡献者的分享!
229
+
230
+ ## 📄 许可证
231
+
232
+ MIT 许可证
233
+
234
+ ---
235
+
236
+ 如果这个项目对你有帮助,请给我一个 ⭐️ Star!
237
+
238
+ [![Star History Chart](https://api.star-history.com/svg?repos=UfoMiao/claude-code-config&type=Date)](https://star-history.com/#UfoMiao/claude-code-config&Date)
package/bin/zcf.mjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/cli.mjs'
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+
package/dist/cli.mjs ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ import cac from 'cac';
3
+ import { i as init } from './shared/zcf.DMG6psxU.mjs';
4
+ import '@posva/prompts';
5
+ import 'ansis';
6
+ import 'node:fs';
7
+ import 'node:os';
8
+ import 'pathe';
9
+ import 'dayjs';
10
+ import 'tinyexec';
11
+
12
+ const version = "1.0.0";
13
+
14
+ const cli = cac("zcf");
15
+ cli.command("[lang]", "Initialize Claude Code configuration").option("--config-lang <lang>", "Configuration language (zh-CN, en)").option("--force", "Force overwrite existing configuration").option("--skip-install", "Skip Claude Code installation check").action(async (lang, options) => {
16
+ await init({
17
+ lang: lang || options.lang,
18
+ configLang: options.configLang,
19
+ force: options.force,
20
+ skipInstall: options.skipInstall
21
+ });
22
+ });
23
+ cli.help();
24
+ cli.version(version);
25
+ cli.parse();
@@ -0,0 +1,154 @@
1
+ interface McpService {
2
+ id: string;
3
+ name: {
4
+ en: string;
5
+ 'zh-CN': string;
6
+ };
7
+ description: {
8
+ en: string;
9
+ 'zh-CN': string;
10
+ };
11
+ requiresApiKey: boolean;
12
+ apiKeyPrompt?: {
13
+ en: string;
14
+ 'zh-CN': string;
15
+ };
16
+ apiKeyPlaceholder?: string;
17
+ config: McpServerConfig;
18
+ }
19
+ interface McpServerConfig {
20
+ type: 'stdio' | 'sse';
21
+ command?: string;
22
+ args?: string[];
23
+ url?: string;
24
+ env?: Record<string, string>;
25
+ }
26
+ interface McpConfiguration {
27
+ mcpServers: Record<string, McpServerConfig>;
28
+ }
29
+
30
+ declare const CLAUDE_DIR: string;
31
+ declare const SETTINGS_FILE: string;
32
+ declare const CLAUDE_MD_FILE: string;
33
+ declare const MCP_CONFIG_FILE: string;
34
+ declare const SUPPORTED_LANGS: readonly ["zh-CN", "en"];
35
+ type SupportedLang = typeof SUPPORTED_LANGS[number];
36
+ declare const LANG_LABELS: {
37
+ readonly 'zh-CN': "简体中文";
38
+ readonly en: "English";
39
+ };
40
+ declare const I18N: {
41
+ 'zh-CN': {
42
+ selectScriptLang: string;
43
+ selectConfigLang: string;
44
+ configLangHint: {
45
+ 'zh-CN': string;
46
+ en: string;
47
+ };
48
+ installPrompt: string;
49
+ installing: string;
50
+ installSuccess: string;
51
+ installFailed: string;
52
+ npmNotFound: string;
53
+ configureApi: string;
54
+ customApi: string;
55
+ skipApi: string;
56
+ enterApiUrl: string;
57
+ enterApiKey: string;
58
+ existingConfig: string;
59
+ backupAndOverwrite: string;
60
+ updateDocsOnly: string;
61
+ mergeConfig: string;
62
+ skip: string;
63
+ backupSuccess: string;
64
+ copying: string;
65
+ configSuccess: string;
66
+ apiConfigSuccess: string;
67
+ mcpConfigSuccess: string;
68
+ selectMcpServices: string;
69
+ allServices: string;
70
+ mcpServiceInstalled: string;
71
+ enterExaApiKey: string;
72
+ skipMcp: string;
73
+ configureMcp: string;
74
+ mcpBackupSuccess: string;
75
+ complete: string;
76
+ error: string;
77
+ yes: string;
78
+ no: string;
79
+ };
80
+ en: {
81
+ selectScriptLang: string;
82
+ selectConfigLang: string;
83
+ configLangHint: {
84
+ 'zh-CN': string;
85
+ en: string;
86
+ };
87
+ installPrompt: string;
88
+ installing: string;
89
+ installSuccess: string;
90
+ installFailed: string;
91
+ npmNotFound: string;
92
+ configureApi: string;
93
+ customApi: string;
94
+ skipApi: string;
95
+ enterApiUrl: string;
96
+ enterApiKey: string;
97
+ existingConfig: string;
98
+ backupAndOverwrite: string;
99
+ updateDocsOnly: string;
100
+ mergeConfig: string;
101
+ skip: string;
102
+ backupSuccess: string;
103
+ copying: string;
104
+ configSuccess: string;
105
+ apiConfigSuccess: string;
106
+ mcpConfigSuccess: string;
107
+ selectMcpServices: string;
108
+ allServices: string;
109
+ mcpServiceInstalled: string;
110
+ enterExaApiKey: string;
111
+ skipMcp: string;
112
+ configureMcp: string;
113
+ mcpBackupSuccess: string;
114
+ complete: string;
115
+ error: string;
116
+ yes: string;
117
+ no: string;
118
+ };
119
+ };
120
+ declare const MCP_SERVICES: McpService[];
121
+
122
+ interface InitOptions {
123
+ lang?: SupportedLang;
124
+ configLang?: SupportedLang;
125
+ force?: boolean;
126
+ skipInstall?: boolean;
127
+ }
128
+ declare function init(options?: InitOptions): Promise<void>;
129
+
130
+ declare function getPlatform(): "windows" | "macos" | "linux";
131
+ declare function commandExists(command: string): Promise<boolean>;
132
+
133
+ declare function isClaudeCodeInstalled(): Promise<boolean>;
134
+ declare function installClaudeCode(lang: SupportedLang): Promise<void>;
135
+
136
+ declare function ensureClaudeDir(): void;
137
+ declare function backupExistingConfig(): string | null;
138
+ declare function copyConfigFiles(lang: SupportedLang, onlyMd?: boolean): void;
139
+ interface ApiConfig {
140
+ url: string;
141
+ key: string;
142
+ }
143
+ declare function configureApi(apiConfig: ApiConfig | null): void;
144
+ declare function mergeConfigs(sourceFile: string, targetFile: string): void;
145
+
146
+ declare function getMcpConfigPath(): string;
147
+ declare function readMcpConfig(): McpConfiguration | null;
148
+ declare function writeMcpConfig(config: McpConfiguration): void;
149
+ declare function backupMcpConfig(): string | null;
150
+ declare function mergeMcpServers(existing: McpConfiguration | null, newServers: Record<string, McpServerConfig>): McpConfiguration;
151
+ declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string): McpServerConfig;
152
+
153
+ export { CLAUDE_DIR, CLAUDE_MD_FILE, I18N, LANG_LABELS, MCP_CONFIG_FILE, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, commandExists, configureApi, copyConfigFiles, ensureClaudeDir, getMcpConfigPath, getPlatform, init, installClaudeCode, isClaudeCodeInstalled, mergeConfigs, mergeMcpServers, readMcpConfig, writeMcpConfig };
154
+ export type { ApiConfig, McpConfiguration, McpServerConfig, McpService, SupportedLang };
@@ -0,0 +1,154 @@
1
+ interface McpService {
2
+ id: string;
3
+ name: {
4
+ en: string;
5
+ 'zh-CN': string;
6
+ };
7
+ description: {
8
+ en: string;
9
+ 'zh-CN': string;
10
+ };
11
+ requiresApiKey: boolean;
12
+ apiKeyPrompt?: {
13
+ en: string;
14
+ 'zh-CN': string;
15
+ };
16
+ apiKeyPlaceholder?: string;
17
+ config: McpServerConfig;
18
+ }
19
+ interface McpServerConfig {
20
+ type: 'stdio' | 'sse';
21
+ command?: string;
22
+ args?: string[];
23
+ url?: string;
24
+ env?: Record<string, string>;
25
+ }
26
+ interface McpConfiguration {
27
+ mcpServers: Record<string, McpServerConfig>;
28
+ }
29
+
30
+ declare const CLAUDE_DIR: string;
31
+ declare const SETTINGS_FILE: string;
32
+ declare const CLAUDE_MD_FILE: string;
33
+ declare const MCP_CONFIG_FILE: string;
34
+ declare const SUPPORTED_LANGS: readonly ["zh-CN", "en"];
35
+ type SupportedLang = typeof SUPPORTED_LANGS[number];
36
+ declare const LANG_LABELS: {
37
+ readonly 'zh-CN': "简体中文";
38
+ readonly en: "English";
39
+ };
40
+ declare const I18N: {
41
+ 'zh-CN': {
42
+ selectScriptLang: string;
43
+ selectConfigLang: string;
44
+ configLangHint: {
45
+ 'zh-CN': string;
46
+ en: string;
47
+ };
48
+ installPrompt: string;
49
+ installing: string;
50
+ installSuccess: string;
51
+ installFailed: string;
52
+ npmNotFound: string;
53
+ configureApi: string;
54
+ customApi: string;
55
+ skipApi: string;
56
+ enterApiUrl: string;
57
+ enterApiKey: string;
58
+ existingConfig: string;
59
+ backupAndOverwrite: string;
60
+ updateDocsOnly: string;
61
+ mergeConfig: string;
62
+ skip: string;
63
+ backupSuccess: string;
64
+ copying: string;
65
+ configSuccess: string;
66
+ apiConfigSuccess: string;
67
+ mcpConfigSuccess: string;
68
+ selectMcpServices: string;
69
+ allServices: string;
70
+ mcpServiceInstalled: string;
71
+ enterExaApiKey: string;
72
+ skipMcp: string;
73
+ configureMcp: string;
74
+ mcpBackupSuccess: string;
75
+ complete: string;
76
+ error: string;
77
+ yes: string;
78
+ no: string;
79
+ };
80
+ en: {
81
+ selectScriptLang: string;
82
+ selectConfigLang: string;
83
+ configLangHint: {
84
+ 'zh-CN': string;
85
+ en: string;
86
+ };
87
+ installPrompt: string;
88
+ installing: string;
89
+ installSuccess: string;
90
+ installFailed: string;
91
+ npmNotFound: string;
92
+ configureApi: string;
93
+ customApi: string;
94
+ skipApi: string;
95
+ enterApiUrl: string;
96
+ enterApiKey: string;
97
+ existingConfig: string;
98
+ backupAndOverwrite: string;
99
+ updateDocsOnly: string;
100
+ mergeConfig: string;
101
+ skip: string;
102
+ backupSuccess: string;
103
+ copying: string;
104
+ configSuccess: string;
105
+ apiConfigSuccess: string;
106
+ mcpConfigSuccess: string;
107
+ selectMcpServices: string;
108
+ allServices: string;
109
+ mcpServiceInstalled: string;
110
+ enterExaApiKey: string;
111
+ skipMcp: string;
112
+ configureMcp: string;
113
+ mcpBackupSuccess: string;
114
+ complete: string;
115
+ error: string;
116
+ yes: string;
117
+ no: string;
118
+ };
119
+ };
120
+ declare const MCP_SERVICES: McpService[];
121
+
122
+ interface InitOptions {
123
+ lang?: SupportedLang;
124
+ configLang?: SupportedLang;
125
+ force?: boolean;
126
+ skipInstall?: boolean;
127
+ }
128
+ declare function init(options?: InitOptions): Promise<void>;
129
+
130
+ declare function getPlatform(): "windows" | "macos" | "linux";
131
+ declare function commandExists(command: string): Promise<boolean>;
132
+
133
+ declare function isClaudeCodeInstalled(): Promise<boolean>;
134
+ declare function installClaudeCode(lang: SupportedLang): Promise<void>;
135
+
136
+ declare function ensureClaudeDir(): void;
137
+ declare function backupExistingConfig(): string | null;
138
+ declare function copyConfigFiles(lang: SupportedLang, onlyMd?: boolean): void;
139
+ interface ApiConfig {
140
+ url: string;
141
+ key: string;
142
+ }
143
+ declare function configureApi(apiConfig: ApiConfig | null): void;
144
+ declare function mergeConfigs(sourceFile: string, targetFile: string): void;
145
+
146
+ declare function getMcpConfigPath(): string;
147
+ declare function readMcpConfig(): McpConfiguration | null;
148
+ declare function writeMcpConfig(config: McpConfiguration): void;
149
+ declare function backupMcpConfig(): string | null;
150
+ declare function mergeMcpServers(existing: McpConfiguration | null, newServers: Record<string, McpServerConfig>): McpConfiguration;
151
+ declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string): McpServerConfig;
152
+
153
+ export { CLAUDE_DIR, CLAUDE_MD_FILE, I18N, LANG_LABELS, MCP_CONFIG_FILE, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, commandExists, configureApi, copyConfigFiles, ensureClaudeDir, getMcpConfigPath, getPlatform, init, installClaudeCode, isClaudeCodeInstalled, mergeConfigs, mergeMcpServers, readMcpConfig, writeMcpConfig };
154
+ export type { ApiConfig, McpConfiguration, McpServerConfig, McpService, SupportedLang };
package/dist/index.mjs ADDED
@@ -0,0 +1,8 @@
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, j as backupExistingConfig, o as backupMcpConfig, q as buildMcpServerConfig, c as commandExists, l as configureApi, k as copyConfigFiles, h as ensureClaudeDir, n as getMcpConfigPath, g as getPlatform, i as init, f as installClaudeCode, e as isClaudeCodeInstalled, m as mergeConfigs, p as mergeMcpServers, r as readMcpConfig, w as writeMcpConfig } from './shared/zcf.DMG6psxU.mjs';
2
+ import '@posva/prompts';
3
+ import 'ansis';
4
+ import 'node:fs';
5
+ import 'node:os';
6
+ import 'pathe';
7
+ import 'dayjs';
8
+ import 'tinyexec';