ccman 3.0.13 → 3.0.15

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 (3) hide show
  1. package/README.md +180 -255
  2. package/dist/index.js +13803 -3480
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,371 +1,296 @@
1
1
  # ccman
2
2
 
3
- > Codex 和 Claude Code 的 API 服务商配置管理工具
3
+ > Codex 和 Claude Code 的 API 服务商配置管理工具,一键切换 Codex 和 Claude Code 的 API 服务商配置。
4
4
 
5
- ## ✨ 特性
5
+ ---
6
6
 
7
- - 🔄 **快速切换**:一键切换不同的 API 服务商
8
- - 📦 **预设模板**:内置 7 个常用服务商模板,只需填写 API Key
9
- - 🛠️ **灵活配置**:支持自定义服务商配置
10
- - 🔒 **安全存储**:API Key 只存储在本地,权限保护
7
+ ## 核心特性
8
+
9
+ - 🔄 **一键切换**:一条命令切换服务商,自动修改配置文件
10
+ - 📦 **内置预设**:7 个常用服务商模板,只需填写 API Key
11
+ - 🛠️ **自定义配置**:支持添加任意第三方服务商
12
+ - 🔐 **零破坏性**:只修改管理的字段,写入前备份,失败回滚
11
13
  - 🎯 **双工具支持**:同时管理 Codex 和 Claude Code
14
+ - 📱 **双界面**:提供 CLI(命令行)和 Desktop(图形界面)
15
+ - 🔁 **克隆功能**:快速复制配置,管理多个 API Key
16
+ - ☁️ **WebDAV 同步**(可选):同步配置到你自己的 WebDAV 服务器(iCloud/Dropbox)
17
+ - 🔒 **无第三方上传**:不会上传到我们的服务器,配置权限 `0600`
18
+ - 🎨 **交互式菜单**:无需记忆命令,跟随提示操作
12
19
 
13
- ## 📦 安装
20
+ ---
14
21
 
15
- ```bash
16
- npm install -g ccman
17
- ```
22
+ ## 也许你不需要 ccman
18
23
 
19
- **系统要求**:Node.js >= 18.0.0
24
+ ccman 的核心功能是自动化配置文件的切换:
20
25
 
21
- ## 🚀 快速开始
26
+ - **Codex**:自动修改 `~/.codex/config.toml` 和 `~/.codex/auth.json`
27
+ - **Claude Code**:自动修改 `~/.claude/settings.json`
28
+ - **备份机制**:写入前自动备份,失败时自动回滚
22
29
 
23
- ### 管理 Codex 服务商
30
+ 如果你更喜欢手动编辑配置文件,或者只使用一个服务商从不切换,可能不需要这个工具。
24
31
 
25
- ```bash
26
- # 1. 添加服务商(交互式)
27
- ccman cx add
32
+ 📖 更多信息:[GitHub 仓库](https://github.com/2ue/ccm) - 包含手动配置方式和详细对比分析
28
33
 
29
- # 2. 查看所有服务商
30
- ccman cx list
34
+ ---
31
35
 
32
- # 3. 切换服务商
33
- ccman cx use
34
-
35
- # 4. 查看当前服务商
36
- ccman cx current
37
- ```
38
-
39
- ### 管理 Claude Code 服务商
36
+ ## 安装
40
37
 
41
38
  ```bash
42
- # 1. 添加服务商(交互式)
43
- ccman cc add
39
+ npm install -g ccman
40
+ ```
44
41
 
45
- # 2. 查看所有服务商
46
- ccman cc list
42
+ **要求**:Node.js >= 18.0.0
47
43
 
48
- # 3. 切换服务商
49
- ccman cc use
44
+ **Desktop 版本**:如果你更喜欢图形界面,可以从 [GitHub Releases](https://github.com/2ue/ccm/releases) 下载 Desktop 应用(macOS/Windows/Linux)。
50
45
 
51
- # 4. 查看当前服务商
52
- ccman cc current
53
- ```
46
+ ---
54
47
 
55
- ### 交互式菜单
48
+ ## 快速开始
56
49
 
57
- 直接运行 `ccman` 进入交互式主菜单:
50
+ ### 查看帮助
58
51
 
59
52
  ```bash
60
- ccman # 主菜单(选择 Codex 或 Claude Code)
61
- ccman cx # Codex 菜单
62
- ccman cc # Claude Code 菜单
63
- ```
53
+ $ ccman --help
64
54
 
65
- ## 📚 命令详解
55
+ Usage: ccman [options] [command]
66
56
 
67
- ### Codex 命令(`ccman cx`)
57
+ Codex/Claude Code API 服务商配置管理工具
68
58
 
69
- #### `ccman cx add`
59
+ Options:
60
+ -V, --version output the version number
61
+ -h, --help display help for command
70
62
 
71
- 添加新的 Codex 服务商。
63
+ Commands:
64
+ cx 管理 Codex 服务商
65
+ cc 管理 Claude 服务商
66
+ sync WebDAV 同步配置
67
+ help [command] display help for command
68
+ ```
72
69
 
73
- **交互流程**:
70
+ ### 管理 Codex 服务商
74
71
 
75
72
  ```bash
76
- $ ccman cx add
77
-
78
- ? 选择配置方式
79
- 使用预设模板
80
- 自定义配置
81
-
82
- # 选择 "使用预设模板"
83
- ? 选择预设 ›
84
- ❯ Anthropic Official
85
- AnyRouter
86
- PackyCode
87
- CoordCode
88
- 88Code
89
- BigModel
90
- ModelScope
91
-
92
- # 填写信息
93
- ? 服务商名称 › Anthropic Official
94
- ? API Key › sk-ant-••••••••••••••••••••••
95
-
96
- ✅ 添加成功!
97
- 💡 切换到此服务商: ccman cx use "Anthropic Official"
73
+ ccman cx # 进入交互式菜单
74
+ ccman cx add # 添加服务商
75
+ ccman cx use # 切换服务商
76
+ ccman cx list # 查看所有服务商
98
77
  ```
99
78
 
100
- #### `ccman cx list`
101
-
102
- 列出所有 Codex 服务商,`●` 表示当前使用的服务商。
79
+ **示例输出**:
103
80
 
104
81
  ```bash
105
82
  $ ccman cx list
106
83
 
107
- 📋 Codex 服务商列表 (2 个)
84
+ 📋 Codex 服务商 (2 个)
108
85
 
109
- Anthropic Official
110
- https://api.anthropic.com
86
+ Anthropic Official [当前]
87
+ https://api.anthropic.com
111
88
 
112
- PackyCode
113
- https://api.packycode.com
89
+ 88Code
90
+ https://www.88code.org/api
114
91
  ```
115
92
 
116
- #### `ccman cx use [name]`
117
-
118
- 切换 Codex 服务商。如果不提供名称,会显示交互式选择器。
119
-
120
93
  ```bash
121
- # 交互式选择
122
- $ ccman cx use
123
-
124
- ? 选择要使用的服务商 ›
125
- Anthropic Official (当前)
126
- ❯ PackyCode
94
+ $ ccman cx current
127
95
 
128
- 已切换到: PackyCode
96
+ 📍 当前 Codex 服务商
129
97
 
130
- # 直接指定名称
131
- $ ccman cx use PackyCode
132
- 已切换到: PackyCode
98
+ Anthropic Official
99
+ ID: codex-1760178741529-hbgbad
100
+ URL: https://api.anthropic.com
101
+ 最后使用: 2025/10/11 18:32:25
133
102
  ```
134
103
 
135
- **说明**:切换后会自动更新 `~/.codex/` 中的配置文件,无需重启 Codex。
136
-
137
- #### `ccman cx current`
138
-
139
- 显示当前使用的 Codex 服务商。
104
+ ### 管理 Claude Code 服务商
140
105
 
141
106
  ```bash
142
- $ ccman cx current
143
-
144
- 当前 Codex 服务商
145
-
146
- 名称: PackyCode
147
- Base URL: https://api.packycode.com
148
- API Key: sk-••••••••••••••••••••••••••••••••
107
+ ccman cc # 进入交互式菜单
108
+ ccman cc add # 添加服务商
109
+ ccman cc use # 切换服务商
110
+ ccman cc list # 查看所有服务商
149
111
  ```
150
112
 
151
- #### `ccman cx edit [name]`
152
-
153
- 编辑 Codex 服务商配置。
113
+ **示例输出**:
154
114
 
155
115
  ```bash
156
- $ ccman cx edit
116
+ $ ccman cc list
157
117
 
158
- ? 选择要编辑的服务商
159
- ❯ Anthropic Official
160
- PackyCode
118
+ 📋 Claude Code 服务商 (2 个)
161
119
 
162
- # 选择后可以修改
163
- ? 服务商名称 › Anthropic Official
164
- ? Base URL › https://api.anthropic.com
165
- ? API Key › (留空保持不变)
120
+ ○ AnyRouter
121
+ https://anyrouter.top
166
122
 
167
- 编辑成功!
123
+ ● PackyCode [当前]
124
+ https://api.packycode.com
168
125
  ```
169
126
 
170
- #### `ccman cx remove [name]`
171
-
172
- 删除 Codex 服务商。
173
-
174
127
  ```bash
175
- $ ccman cx remove
176
-
177
- ? 选择要删除的服务商 ›
178
- Anthropic Official (当前使用中)
179
- ❯ PackyCode
128
+ $ ccman cc current
180
129
 
181
- ? 确认删除 "PackyCode"? (y/N)
130
+ 📍 当前 Claude Code 服务商
182
131
 
183
- ✅ 已删除: PackyCode
132
+ PackyCode
133
+ ID: claude-1760182672751-unh2bp
134
+ URL: https://api.packycode.com
135
+ 最后使用: 2025/10/11 20:14:08
184
136
  ```
185
137
 
186
- #### `ccman cx clone [source]`
138
+ ---
187
139
 
188
- 克隆 Codex 服务商配置(复制 Base URL,修改名称和 API Key)。
140
+ ## 完整命令
189
141
 
190
- ```bash
191
- $ ccman cx clone
142
+ | 命令 | 说明 |
143
+ |------|------|
144
+ | `ccman` | 主菜单(选择 Codex 或 Claude Code) |
145
+ | `ccman cx` | Codex 交互式菜单 |
146
+ | `ccman cx add` | 添加 Codex 服务商(支持预设模板和自定义) |
147
+ | `ccman cx list` | 列出所有 Codex 服务商 |
148
+ | `ccman cx use [name]` | 切换 Codex 服务商 |
149
+ | `ccman cx current` | 查看当前 Codex 服务商 |
150
+ | `ccman cx edit [name]` | 编辑 Codex 服务商 |
151
+ | `ccman cx remove [name]` | 删除 Codex 服务商 |
152
+ | `ccman cx clone [source]` | 克隆 Codex 服务商(复制配置,改名称和 Key) |
153
+ | `ccman cc` | Claude Code 交互式菜单 |
154
+ | `ccman cc add` | 添加 Claude Code 服务商 |
155
+ | `ccman cc list` | 列出所有 Claude Code 服务商 |
156
+ | `ccman cc use [name]` | 切换 Claude Code 服务商 |
157
+ | `ccman cc current` | 查看当前 Claude Code 服务商 |
158
+ | `ccman cc edit [name]` | 编辑 Claude Code 服务商 |
159
+ | `ccman cc remove [name]` | 删除 Claude Code 服务商 |
160
+ | `ccman cc clone [source]` | 克隆 Claude Code 服务商 |
161
+ | `ccman sync` | WebDAV 同步配置(备份/恢复/合并) |
192
162
 
193
- ? 选择要克隆的服务商 ›
194
- ❯ Anthropic Official
195
- PackyCode
163
+ ---
196
164
 
197
- ? 新服务商名称 › Anthropic Test
198
- ? API Key › sk-ant-test-••••••••••••••••••
165
+ ## 内置预设
199
166
 
200
- 克隆成功!
201
- 💡 切换到此服务商: ccman cx use "Anthropic Test"
202
- ```
203
-
204
- **使用场景**:
205
- - 同一服务商有多个 API Key(测试/生产环境)
206
- - 快速创建类似配置的服务商
207
-
208
- ### Claude Code 命令(`ccman cc`)
167
+ 添加服务商时可以选择"使用预设模板",只需填写 API Key:
209
168
 
210
- Claude Code 的命令与 Codex 完全相同:
169
+ | 预设名称 | Base URL |
170
+ |---------|----------|
171
+ | Anthropic Official | `https://api.anthropic.com` |
172
+ | AnyRouter | `https://anyrouter.top` |
173
+ | PackyCode | `https://api.packycode.com` |
174
+ | CoordCode | `https://api.coordcode.com/api` |
175
+ | 88Code | `https://www.88code.org/api` |
176
+ | BigModel | `https://open.bigmodel.cn/api/anthropic` |
177
+ | ModelScope | `https://api-inference.modelscope.cn/v1/chat/completions` |
211
178
 
212
- - `ccman cc add` - 添加服务商
213
- - `ccman cc list` - 列出服务商
214
- - `ccman cc use [name]` - 切换服务商
215
- - `ccman cc current` - 查看当前服务商
216
- - `ccman cc edit [name]` - 编辑服务商
217
- - `ccman cc remove [name]` - 删除服务商
218
- - `ccman cc clone [source]` - 克隆服务商
179
+ 也可以选择"自定义配置",手动填写 Base URL。
219
180
 
220
- **说明**:切换后会自动更新 `~/.claude/settings.json`,无需重启 Claude Code。
181
+ ---
221
182
 
222
- ## 🎨 内置预设模板
183
+ ## 完整使用示例
223
184
 
224
- 两个工具都支持以下预设(只需填写 API Key):
185
+ ### 场景 1:添加并切换服务商
225
186
 
226
- | 预设名称 | Base URL | 说明 |
227
- |---------|----------|------|
228
- | Anthropic Official | `https://api.anthropic.com` | Anthropic 官方 API |
229
- | AnyRouter | `https://anyrouter.top` | AnyRouter API 服务 |
230
- | PackyCode | `https://api.packycode.com` | PackyCode API 服务 |
231
- | CoordCode | `https://api.coordcode.com/api` | CoordCode API 服务 |
232
- | 88Code | `https://www.88code.org/api` | 88Code API 服务 |
233
- | BigModel | `https://open.bigmodel.cn/api/anthropic` | 智谱 BigModel API |
234
- | ModelScope | `https://api-inference.modelscope.cn/v1/chat/completions` | 阿里云 ModelScope API |
187
+ ```bash
188
+ # 1. 查看当前列表
189
+ $ ccman cx list
235
190
 
236
- ## 💡 使用示例
191
+ 📋 Codex 服务商 (1 个)
237
192
 
238
- ### 示例 1:添加并切换到新服务商
193
+ ● Anthropic Official [当前]
194
+ https://api.anthropic.com
239
195
 
240
- ```bash
241
- # 1. 添加 PackyCode
196
+ # 2. 添加 PackyCode(交互式)
242
197
  $ ccman cx add
243
- # 选择 "使用预设模板" → "PackyCode" → 输入 API Key
198
+ ? 选择配置方式 使用预设模板
199
+ ? 选择预设 › PackyCode
200
+ ? 服务商名称 › PackyCode
201
+ ? API Key › ••••••••••••••••••••
202
+ ✅ 添加成功!
203
+ 💡 切换到此服务商: ccman cx use PackyCode
244
204
 
245
- # 2. 切换到 PackyCode
205
+ # 3. 切换到 PackyCode
246
206
  $ ccman cx use PackyCode
247
207
  ✅ 已切换到: PackyCode
248
208
 
249
- # 3. 确认
209
+ # 4. 确认当前服务商
250
210
  $ ccman cx current
251
- ✅ 当前 Codex 服务商
252
- 名称: PackyCode
211
+
212
+ 📍 当前 Codex 服务商
213
+
214
+ PackyCode
215
+ ID: codex-1760178741529-abc123
216
+ URL: https://api.packycode.com
217
+ 最后使用: 2025/10/11 18:32:25
253
218
  ```
254
219
 
255
- ### 示例 2:管理多个 API Key
220
+ ### 场景 2:克隆服务商(管理多个 Key
256
221
 
257
222
  ```bash
258
- # 场景:同一服务商有测试和生产两个 API Key
259
-
260
223
  # 1. 添加生产配置
261
224
  $ ccman cc add
262
- # 名称: Claude Production
263
- # API Key: sk-ant-prod-xxx
225
+ ? 选择配置方式 自定义配置
226
+ ? 服务商名称 Claude Production
227
+ ? Base URL › https://api.anthropic.com
228
+ ? API Key › ••••••••••••••••••••
229
+ ✅ 添加成功!
264
230
 
265
231
  # 2. 克隆创建测试配置
266
232
  $ ccman cc clone
267
- # 选择 "Claude Production"
268
- # 新名称: Claude Test
269
- # API Key: sk-ant-test-xxx
233
+ ? 选择要克隆的服务商 Claude Production
234
+ ? 新服务商名称 Claude Test
235
+ ? API Key › ••••••••••••••••••••
236
+ ✅ 克隆成功!
237
+ 💡 切换到此服务商: ccman cc use "Claude Test"
270
238
 
271
239
  # 3. 查看列表
272
240
  $ ccman cc list
273
- 📋 Claude Code 服务商列表 (共 2 个)
274
- ● Claude Production (当前)
275
- ○ Claude Test
276
241
 
277
- # 4. 快速切换
278
- $ ccman cc use "Claude Test"
279
- ✅ 已切换到: Claude Test
280
- ```
242
+ 📋 Claude Code 服务商 (2 个)
281
243
 
282
- ### 示例 3:自定义服务商配置
244
+ ● Claude Production [当前]
245
+ https://api.anthropic.com
283
246
 
284
- ```bash
285
- $ ccman cx add
286
-
287
- ? 选择配置方式 › 自定义配置
288
- ? 服务商名称 › My Custom Provider
289
- ? Base URL › https://api.example.com/v1
290
- ? API Key › my-secret-key
291
-
292
- ✅ 添加成功!
293
- ```
247
+ ○ Claude Test
248
+ https://api.anthropic.com
294
249
 
295
- ## 📂 配置文件
296
-
297
- ### ccman 配置
298
-
299
- **位置**:`~/.ccman/config.json`
300
-
301
- **结构**:
302
-
303
- ```json
304
- {
305
- "providers": [
306
- {
307
- "id": "codex-1234567890-abc123",
308
- "name": "PackyCode",
309
- "type": "codex",
310
- "baseUrl": "https://api.packycode.com",
311
- "apiKey": "sk-xxx",
312
- "createdAt": 1234567890000,
313
- "lastUsedAt": 1234567900000
314
- }
315
- ],
316
- "currentCodexProvider": "codex-1234567890-abc123",
317
- "currentClaudeProvider": null
318
- }
250
+ # 4. 快速切换
251
+ $ ccman cc use "Claude Test"
252
+ 已切换到: Claude Test
319
253
  ```
320
254
 
321
- ### Codex 配置
322
-
323
- ccman 会自动修改以下文件:
324
-
325
- - `~/.codex/config.toml` - Codex 主配置
326
- - `~/.codex/auth.json` - 认证信息
327
-
328
- ### Claude Code 配置
329
-
330
- ccman 会自动修改以下文件:
331
-
332
- - `~/.claude/settings.json` - Claude Code 设置(只修改 `env.ANTHROPIC_AUTH_TOKEN` 和 `env.ANTHROPIC_BASE_URL`,不影响其他配置)
333
-
334
- ## 🔒 安全性
335
-
336
- - ✅ API Key 只存储在本地,不会联网上传
337
- - ✅ 配置文件设置为 `0600` 权限(仅当前用户可读写)
338
- - ✅ 终端输入 API Key 时自动隐藏(显示为 `••••`)
339
- - ✅ 列表显示时 API Key 自动脱敏
255
+ ---
340
256
 
341
- ## ❓ 常见问题
257
+ ## 配置文件
342
258
 
343
- ### Q: 如何切换回之前的服务商?
259
+ **ccman 配置**:`~/.ccman/config.json`
344
260
 
345
- A: 使用 `ccman cx use` 或 `ccman cc use` 选择之前的服务商即可。
261
+ **Codex 配置**(ccman 会自动修改):
262
+ - `~/.codex/config.toml`
263
+ - `~/.codex/auth.json`
346
264
 
347
- ### Q: 删除服务商后还能恢复吗?
265
+ **Claude Code 配置**(ccman 会自动修改):
266
+ - `~/.claude/settings.json`
348
267
 
349
- A: 不能。删除操作不可逆,建议删除前确认。
268
+ **零破坏性承诺**:
269
+ - 只修改管理的字段,保留其他所有配置
270
+ - 写入前备份,失败时自动回滚
271
+ - API Key 存储在本地,权限 `0600`
350
272
 
351
- ### Q: 可以同时使用 CLI 和 Desktop 吗?
273
+ ---
352
274
 
353
- A: 可以。未来会推出 Desktop 应用,CLI 和 Desktop 共享同一套配置文件(`~/.ccman/`),修改会实时同步。
275
+ ## 常见问题
354
276
 
355
- ### Q: 切换服务商后需要重启 Codex/Claude Code 吗?
277
+ **Q: 支持配置导入/导出吗?**
278
+ A: 当前版本不支持。如需备份,手动复制 `~/.ccman/` 目录。
356
279
 
357
- A: 不需要。ccman 会直接修改配置文件,工具会自动重新加载配置。
280
+ **Q: WebDAV 同步是什么?**
281
+ A: 将 ccman 配置同步到 WebDAV 服务器(如 iCloud/Dropbox),多设备共享配置。详见 `ccman sync --help`。
358
282
 
359
- ### Q: 支持导入/导出配置吗?
283
+ ---
360
284
 
361
- A: 当前版本不支持。如需备份配置,可以手动复制 `~/.ccman/` 目录。
285
+ ## 许可证
362
286
 
363
- ## 📄 许可证
287
+ MIT
364
288
 
365
- MIT © [2ue](https://github.com/2ue)
289
+ ---
366
290
 
367
- ## 🔗 相关链接
291
+ ## 相关链接
368
292
 
369
293
  - [GitHub 仓库](https://github.com/2ue/ccm)
370
294
  - [问题反馈](https://github.com/2ue/ccm/issues)
371
295
  - [更新日志](https://github.com/2ue/ccm/blob/main/CHANGELOG.md)
296
+ - [Desktop 版本](https://github.com/2ue/ccm/releases)(图形界面)