ccman 3.0.7 → 3.0.9
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 +291 -90
- package/dist/index.js +115 -186
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,170 +1,371 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ccman
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Codex 和 Claude Code 的 API 服务商配置管理工具
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## ✨ 特性
|
|
6
|
+
|
|
7
|
+
- 🔄 **快速切换**:一键切换不同的 API 服务商
|
|
8
|
+
- 📦 **预设模板**:内置 7 个常用服务商模板,只需填写 API Key
|
|
9
|
+
- 🛠️ **灵活配置**:支持自定义服务商配置
|
|
10
|
+
- 🔒 **安全存储**:API Key 只存储在本地,权限保护
|
|
11
|
+
- 🎯 **双工具支持**:同时管理 Codex 和 Claude Code
|
|
12
|
+
|
|
13
|
+
## 📦 安装
|
|
6
14
|
|
|
7
15
|
```bash
|
|
8
|
-
|
|
9
|
-
|
|
16
|
+
npm install -g ccman
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**系统要求**:Node.js >= 18.0.0
|
|
20
|
+
|
|
21
|
+
## 🚀 快速开始
|
|
22
|
+
|
|
23
|
+
### 管理 Codex 服务商
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# 1. 添加服务商(交互式)
|
|
27
|
+
ccman cx add
|
|
28
|
+
|
|
29
|
+
# 2. 查看所有服务商
|
|
30
|
+
ccman cx list
|
|
10
31
|
|
|
11
|
-
#
|
|
12
|
-
|
|
32
|
+
# 3. 切换服务商
|
|
33
|
+
ccman cx use
|
|
34
|
+
|
|
35
|
+
# 4. 查看当前服务商
|
|
36
|
+
ccman cx current
|
|
13
37
|
```
|
|
14
38
|
|
|
15
|
-
|
|
39
|
+
### 管理 Claude Code 服务商
|
|
16
40
|
|
|
17
41
|
```bash
|
|
18
|
-
# 1.
|
|
19
|
-
ccman
|
|
42
|
+
# 1. 添加服务商(交互式)
|
|
43
|
+
ccman cc add
|
|
44
|
+
|
|
45
|
+
# 2. 查看所有服务商
|
|
46
|
+
ccman cc list
|
|
20
47
|
|
|
21
|
-
#
|
|
22
|
-
ccman
|
|
48
|
+
# 3. 切换服务商
|
|
49
|
+
ccman cc use
|
|
50
|
+
|
|
51
|
+
# 4. 查看当前服务商
|
|
52
|
+
ccman cc current
|
|
53
|
+
```
|
|
23
54
|
|
|
24
|
-
|
|
25
|
-
ccman list
|
|
55
|
+
### 交互式菜单
|
|
26
56
|
|
|
27
|
-
|
|
28
|
-
ccman use "Provider Name"
|
|
57
|
+
直接运行 `ccman` 进入交互式主菜单:
|
|
29
58
|
|
|
30
|
-
|
|
31
|
-
ccman
|
|
59
|
+
```bash
|
|
60
|
+
ccman # 主菜单(选择 Codex 或 Claude Code)
|
|
61
|
+
ccman cx # Codex 菜单
|
|
62
|
+
ccman cc # Claude Code 菜单
|
|
32
63
|
```
|
|
33
64
|
|
|
34
|
-
##
|
|
65
|
+
## 📚 命令详解
|
|
66
|
+
|
|
67
|
+
### Codex 命令(`ccman cx`)
|
|
35
68
|
|
|
36
|
-
|
|
69
|
+
#### `ccman cx add`
|
|
37
70
|
|
|
38
|
-
|
|
71
|
+
添加新的 Codex 服务商。
|
|
72
|
+
|
|
73
|
+
**交互流程**:
|
|
39
74
|
|
|
40
75
|
```bash
|
|
41
|
-
ccman
|
|
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"
|
|
42
98
|
```
|
|
43
99
|
|
|
44
|
-
|
|
100
|
+
#### `ccman cx list`
|
|
45
101
|
|
|
46
|
-
|
|
102
|
+
列出所有 Codex 服务商,`●` 表示当前使用的服务商。
|
|
47
103
|
|
|
48
104
|
```bash
|
|
49
|
-
ccman
|
|
50
|
-
```
|
|
105
|
+
$ ccman cx list
|
|
51
106
|
|
|
52
|
-
|
|
53
|
-
1. Choose preset template or custom configuration
|
|
54
|
-
2. If preset: Select from available presets (Anthropic Official, PackyCode)
|
|
55
|
-
3. If custom: Enter provider details manually
|
|
56
|
-
4. Enter API key (masked input)
|
|
107
|
+
📋 Codex 服务商列表 (共 2 个)
|
|
57
108
|
|
|
58
|
-
|
|
109
|
+
● Anthropic Official
|
|
110
|
+
https://api.anthropic.com
|
|
59
111
|
|
|
60
|
-
|
|
112
|
+
○ PackyCode
|
|
113
|
+
https://api.packycode.com
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### `ccman cx use [name]`
|
|
117
|
+
|
|
118
|
+
切换 Codex 服务商。如果不提供名称,会显示交互式选择器。
|
|
61
119
|
|
|
62
120
|
```bash
|
|
63
|
-
|
|
64
|
-
ccman
|
|
121
|
+
# 交互式选择
|
|
122
|
+
$ ccman cx use
|
|
123
|
+
|
|
124
|
+
? 选择要使用的服务商 ›
|
|
125
|
+
Anthropic Official (当前)
|
|
126
|
+
❯ PackyCode
|
|
127
|
+
|
|
128
|
+
✅ 已切换到: PackyCode
|
|
129
|
+
|
|
130
|
+
# 直接指定名称
|
|
131
|
+
$ ccman cx use PackyCode
|
|
132
|
+
✅ 已切换到: PackyCode
|
|
65
133
|
```
|
|
66
134
|
|
|
67
|
-
|
|
135
|
+
**说明**:切换后会自动更新 `~/.codex/` 中的配置文件,无需重启 Codex。
|
|
68
136
|
|
|
69
|
-
|
|
137
|
+
#### `ccman cx current`
|
|
138
|
+
|
|
139
|
+
显示当前使用的 Codex 服务商。
|
|
70
140
|
|
|
71
141
|
```bash
|
|
72
|
-
ccman
|
|
142
|
+
$ ccman cx current
|
|
143
|
+
|
|
144
|
+
✅ 当前 Codex 服务商
|
|
145
|
+
|
|
146
|
+
名称: PackyCode
|
|
147
|
+
Base URL: https://api.packycode.com
|
|
148
|
+
API Key: sk-••••••••••••••••••••••••••••••••
|
|
73
149
|
```
|
|
74
150
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
151
|
+
#### `ccman cx edit [name]`
|
|
152
|
+
|
|
153
|
+
编辑 Codex 服务商配置。
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
$ ccman cx edit
|
|
157
|
+
|
|
158
|
+
? 选择要编辑的服务商 ›
|
|
159
|
+
❯ Anthropic Official
|
|
160
|
+
PackyCode
|
|
161
|
+
|
|
162
|
+
# 选择后可以修改
|
|
163
|
+
? 服务商名称 › Anthropic Official
|
|
164
|
+
? Base URL › https://api.anthropic.com
|
|
165
|
+
? API Key › (留空保持不变)
|
|
166
|
+
|
|
167
|
+
✅ 编辑成功!
|
|
168
|
+
```
|
|
78
169
|
|
|
79
|
-
|
|
170
|
+
#### `ccman cx remove [name]`
|
|
80
171
|
|
|
81
|
-
|
|
172
|
+
删除 Codex 服务商。
|
|
82
173
|
|
|
83
174
|
```bash
|
|
84
|
-
ccman
|
|
175
|
+
$ ccman cx remove
|
|
176
|
+
|
|
177
|
+
? 选择要删除的服务商 ›
|
|
178
|
+
Anthropic Official (当前使用中)
|
|
179
|
+
❯ PackyCode
|
|
180
|
+
|
|
181
|
+
? 确认删除 "PackyCode"? › (y/N)
|
|
182
|
+
|
|
183
|
+
✅ 已删除: PackyCode
|
|
85
184
|
```
|
|
86
185
|
|
|
87
|
-
|
|
186
|
+
#### `ccman cx clone [source]`
|
|
88
187
|
|
|
89
|
-
|
|
188
|
+
克隆 Codex 服务商配置(复制 Base URL,修改名称和 API Key)。
|
|
90
189
|
|
|
91
190
|
```bash
|
|
92
|
-
ccman
|
|
93
|
-
|
|
191
|
+
$ ccman cx clone
|
|
192
|
+
|
|
193
|
+
? 选择要克隆的服务商 ›
|
|
194
|
+
❯ Anthropic Official
|
|
195
|
+
PackyCode
|
|
196
|
+
|
|
197
|
+
? 新服务商名称 › Anthropic Test
|
|
198
|
+
? API Key › sk-ant-test-••••••••••••••••••
|
|
199
|
+
|
|
200
|
+
✅ 克隆成功!
|
|
201
|
+
💡 切换到此服务商: ccman cx use "Anthropic Test"
|
|
94
202
|
```
|
|
95
203
|
|
|
96
|
-
|
|
204
|
+
**使用场景**:
|
|
205
|
+
- 同一服务商有多个 API Key(测试/生产环境)
|
|
206
|
+
- 快速创建类似配置的服务商
|
|
207
|
+
|
|
208
|
+
### Claude Code 命令(`ccman cc`)
|
|
209
|
+
|
|
210
|
+
Claude Code 的命令与 Codex 完全相同:
|
|
211
|
+
|
|
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]` - 克隆服务商
|
|
97
219
|
|
|
98
|
-
|
|
220
|
+
**说明**:切换后会自动更新 `~/.claude/settings.json`,无需重启 Claude Code。
|
|
221
|
+
|
|
222
|
+
## 🎨 内置预设模板
|
|
223
|
+
|
|
224
|
+
两个工具都支持以下预设(只需填写 API Key):
|
|
225
|
+
|
|
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 |
|
|
235
|
+
|
|
236
|
+
## 💡 使用示例
|
|
237
|
+
|
|
238
|
+
### 示例 1:添加并切换到新服务商
|
|
99
239
|
|
|
100
240
|
```bash
|
|
101
|
-
|
|
241
|
+
# 1. 添加 PackyCode
|
|
242
|
+
$ ccman cx add
|
|
243
|
+
# 选择 "使用预设模板" → "PackyCode" → 输入 API Key
|
|
244
|
+
|
|
245
|
+
# 2. 切换到 PackyCode
|
|
246
|
+
$ ccman cx use PackyCode
|
|
247
|
+
✅ 已切换到: PackyCode
|
|
248
|
+
|
|
249
|
+
# 3. 确认
|
|
250
|
+
$ ccman cx current
|
|
251
|
+
✅ 当前 Codex 服务商
|
|
252
|
+
名称: PackyCode
|
|
102
253
|
```
|
|
103
254
|
|
|
104
|
-
|
|
105
|
-
- Provider name
|
|
106
|
-
- Provider type (Codex/Claude Code)
|
|
107
|
-
- Base URL
|
|
108
|
-
- API Key (optional)
|
|
255
|
+
### 示例 2:管理多个 API Key
|
|
109
256
|
|
|
110
|
-
|
|
257
|
+
```bash
|
|
258
|
+
# 场景:同一服务商有测试和生产两个 API Key
|
|
259
|
+
|
|
260
|
+
# 1. 添加生产配置
|
|
261
|
+
$ ccman cc add
|
|
262
|
+
# 名称: Claude Production
|
|
263
|
+
# API Key: sk-ant-prod-xxx
|
|
264
|
+
|
|
265
|
+
# 2. 克隆创建测试配置
|
|
266
|
+
$ ccman cc clone
|
|
267
|
+
# 选择 "Claude Production"
|
|
268
|
+
# 新名称: Claude Test
|
|
269
|
+
# API Key: sk-ant-test-xxx
|
|
270
|
+
|
|
271
|
+
# 3. 查看列表
|
|
272
|
+
$ ccman cc list
|
|
273
|
+
📋 Claude Code 服务商列表 (共 2 个)
|
|
274
|
+
● Claude Production (当前)
|
|
275
|
+
○ Claude Test
|
|
276
|
+
|
|
277
|
+
# 4. 快速切换
|
|
278
|
+
$ ccman cc use "Claude Test"
|
|
279
|
+
✅ 已切换到: Claude Test
|
|
280
|
+
```
|
|
111
281
|
|
|
112
|
-
|
|
282
|
+
### 示例 3:自定义服务商配置
|
|
113
283
|
|
|
114
284
|
```bash
|
|
115
|
-
ccman
|
|
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
|
+
✅ 添加成功!
|
|
116
293
|
```
|
|
117
294
|
|
|
118
|
-
##
|
|
295
|
+
## 📂 配置文件
|
|
296
|
+
|
|
297
|
+
### ccman 配置
|
|
119
298
|
|
|
120
|
-
|
|
299
|
+
**位置**:`~/.ccman/config.json`
|
|
300
|
+
|
|
301
|
+
**结构**:
|
|
121
302
|
|
|
122
303
|
```json
|
|
123
304
|
{
|
|
124
305
|
"providers": [
|
|
125
306
|
{
|
|
126
|
-
"id": "
|
|
127
|
-
"name": "
|
|
128
|
-
"type": "
|
|
129
|
-
"baseUrl": "https://api.
|
|
130
|
-
"apiKey": "sk-
|
|
131
|
-
"createdAt":
|
|
132
|
-
"lastUsedAt":
|
|
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
|
|
133
314
|
}
|
|
134
315
|
],
|
|
135
|
-
"
|
|
316
|
+
"currentCodexProvider": "codex-1234567890-abc123",
|
|
317
|
+
"currentClaudeProvider": null
|
|
136
318
|
}
|
|
137
319
|
```
|
|
138
320
|
|
|
139
|
-
|
|
321
|
+
### Codex 配置
|
|
140
322
|
|
|
141
|
-
|
|
323
|
+
ccman 会自动修改以下文件:
|
|
142
324
|
|
|
143
|
-
-
|
|
144
|
-
-
|
|
325
|
+
- `~/.codex/config.toml` - Codex 主配置
|
|
326
|
+
- `~/.codex/auth.json` - 认证信息
|
|
145
327
|
|
|
146
|
-
|
|
328
|
+
### Claude Code 配置
|
|
147
329
|
|
|
148
|
-
|
|
330
|
+
ccman 会自动修改以下文件:
|
|
149
331
|
|
|
150
|
-
-
|
|
151
|
-
- **Provider not found**: Check available providers with `ccman list`
|
|
152
|
-
- **Invalid configuration**: Detailed validation errors with fix suggestions
|
|
332
|
+
- `~/.claude/settings.json` - Claude Code 设置(只修改 `env.ANTHROPIC_AUTH_TOKEN` 和 `env.ANTHROPIC_BASE_URL`,不影响其他配置)
|
|
153
333
|
|
|
154
|
-
##
|
|
334
|
+
## 🔒 安全性
|
|
155
335
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
336
|
+
- ✅ API Key 只存储在本地,不会联网上传
|
|
337
|
+
- ✅ 配置文件设置为 `0600` 权限(仅当前用户可读写)
|
|
338
|
+
- ✅ 终端输入 API Key 时自动隐藏(显示为 `••••`)
|
|
339
|
+
- ✅ 列表显示时 API Key 自动脱敏
|
|
159
340
|
|
|
160
|
-
|
|
161
|
-
pnpm dev <command>
|
|
341
|
+
## ❓ 常见问题
|
|
162
342
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
343
|
+
### Q: 如何切换回之前的服务商?
|
|
344
|
+
|
|
345
|
+
A: 使用 `ccman cx use` 或 `ccman cc use` 选择之前的服务商即可。
|
|
346
|
+
|
|
347
|
+
### Q: 删除服务商后还能恢复吗?
|
|
348
|
+
|
|
349
|
+
A: 不能。删除操作不可逆,建议删除前确认。
|
|
350
|
+
|
|
351
|
+
### Q: 可以同时使用 CLI 和 Desktop 吗?
|
|
352
|
+
|
|
353
|
+
A: 可以。未来会推出 Desktop 应用,CLI 和 Desktop 共享同一套配置文件(`~/.ccman/`),修改会实时同步。
|
|
354
|
+
|
|
355
|
+
### Q: 切换服务商后需要重启 Codex/Claude Code 吗?
|
|
356
|
+
|
|
357
|
+
A: 不需要。ccman 会直接修改配置文件,工具会自动重新加载配置。
|
|
358
|
+
|
|
359
|
+
### Q: 支持导入/导出配置吗?
|
|
360
|
+
|
|
361
|
+
A: 当前版本不支持。如需备份配置,可以手动复制 `~/.ccman/` 目录。
|
|
362
|
+
|
|
363
|
+
## 📄 许可证
|
|
364
|
+
|
|
365
|
+
MIT © [2ue](https://github.com/2ue)
|
|
167
366
|
|
|
168
|
-
##
|
|
367
|
+
## 🔗 相关链接
|
|
169
368
|
|
|
170
|
-
|
|
369
|
+
- [GitHub 仓库](https://github.com/2ue/ccm)
|
|
370
|
+
- [问题反馈](https://github.com/2ue/ccm/issues)
|
|
371
|
+
- [更新日志](https://github.com/2ue/ccm/blob/main/CHANGELOG.md)
|
package/dist/index.js
CHANGED
|
@@ -2031,12 +2031,12 @@ function printLogo() {
|
|
|
2031
2031
|
console.log(
|
|
2032
2032
|
import_chalk.default.bold(
|
|
2033
2033
|
`
|
|
2034
|
-
\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\
|
|
2035
|
-
\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\
|
|
2036
|
-
\u2588\u2588\u2551 \u2588\u2588\u2551
|
|
2037
|
-
\u2588\u2588\u2551 \u2588\u2588\u2551
|
|
2038
|
-
\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\
|
|
2039
|
-
\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D
|
|
2034
|
+
\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2557
|
|
2035
|
+
\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551
|
|
2036
|
+
\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551
|
|
2037
|
+
\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551
|
|
2038
|
+
\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551
|
|
2039
|
+
\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D
|
|
2040
2040
|
`
|
|
2041
2041
|
)
|
|
2042
2042
|
);
|
|
@@ -2047,54 +2047,8 @@ function printLogo() {
|
|
|
2047
2047
|
var import_chalk3 = __toESM(require("chalk"));
|
|
2048
2048
|
var import_inquirer2 = __toESM(require("inquirer"));
|
|
2049
2049
|
|
|
2050
|
-
// ../core/
|
|
2051
|
-
var
|
|
2052
|
-
name: "@ccman/core",
|
|
2053
|
-
version: "3.0.7",
|
|
2054
|
-
type: "module",
|
|
2055
|
-
description: "Core business logic for ccman",
|
|
2056
|
-
main: "./dist/index.js",
|
|
2057
|
-
types: "./dist/index.d.ts",
|
|
2058
|
-
files: [
|
|
2059
|
-
"dist"
|
|
2060
|
-
],
|
|
2061
|
-
scripts: {
|
|
2062
|
-
build: "tsc",
|
|
2063
|
-
test: "vitest run",
|
|
2064
|
-
"test:watch": "vitest",
|
|
2065
|
-
clean: "rm -rf dist"
|
|
2066
|
-
},
|
|
2067
|
-
keywords: [
|
|
2068
|
-
"codex",
|
|
2069
|
-
"claude",
|
|
2070
|
-
"claude-code",
|
|
2071
|
-
"ai",
|
|
2072
|
-
"api",
|
|
2073
|
-
"config",
|
|
2074
|
-
"manager"
|
|
2075
|
-
],
|
|
2076
|
-
author: "2ue",
|
|
2077
|
-
license: "MIT",
|
|
2078
|
-
repository: {
|
|
2079
|
-
type: "git",
|
|
2080
|
-
url: "https://github.com/2ue/ccm.git",
|
|
2081
|
-
directory: "packages/core"
|
|
2082
|
-
},
|
|
2083
|
-
homepage: "https://github.com/2ue/ccm#readme",
|
|
2084
|
-
bugs: {
|
|
2085
|
-
url: "https://github.com/2ue/ccm/issues"
|
|
2086
|
-
},
|
|
2087
|
-
dependencies: {
|
|
2088
|
-
"@iarna/toml": "^2.2.5",
|
|
2089
|
-
"proper-lockfile": "^4.1.2"
|
|
2090
|
-
},
|
|
2091
|
-
devDependencies: {
|
|
2092
|
-
vitest: "^1.0.0"
|
|
2093
|
-
},
|
|
2094
|
-
engines: {
|
|
2095
|
-
node: ">=18.0.0"
|
|
2096
|
-
}
|
|
2097
|
-
};
|
|
2050
|
+
// ../core/dist/index.js
|
|
2051
|
+
var import_module = require("module");
|
|
2098
2052
|
|
|
2099
2053
|
// ../core/dist/tool-manager.js
|
|
2100
2054
|
var path3 = __toESM(require("path"), 1);
|
|
@@ -2212,9 +2166,9 @@ function writeCodexConfig(provider) {
|
|
|
2212
2166
|
fs2.writeFileSync(authPath, JSON.stringify(auth, null, 2), { mode: 384 });
|
|
2213
2167
|
}
|
|
2214
2168
|
|
|
2215
|
-
// ../core/dist/writers/
|
|
2169
|
+
// ../core/dist/writers/claude.js
|
|
2216
2170
|
var fs3 = __toESM(require("fs"), 1);
|
|
2217
|
-
function
|
|
2171
|
+
function writeClaudeConfig(provider) {
|
|
2218
2172
|
ensureDir(getClaudeDir());
|
|
2219
2173
|
const configPath = getClaudeConfigPath();
|
|
2220
2174
|
let settings;
|
|
@@ -2249,45 +2203,20 @@ function writeClaudeCodeConfig(provider) {
|
|
|
2249
2203
|
|
|
2250
2204
|
// ../core/dist/presets/codex.js
|
|
2251
2205
|
var CODEX_PRESETS = [
|
|
2252
|
-
{
|
|
2253
|
-
name: "Anthropic Official",
|
|
2254
|
-
baseUrl: "https://api.anthropic.com",
|
|
2255
|
-
description: "Anthropic \u5B98\u65B9 API"
|
|
2256
|
-
},
|
|
2257
|
-
{
|
|
2258
|
-
name: "AnyRouter",
|
|
2259
|
-
baseUrl: "https://anyrouter.top",
|
|
2260
|
-
description: "AnyRouter API \u670D\u52A1"
|
|
2261
|
-
},
|
|
2262
2206
|
{
|
|
2263
2207
|
name: "PackyCode",
|
|
2264
2208
|
baseUrl: "https://api.packycode.com",
|
|
2265
2209
|
description: "PackyCode API \u670D\u52A1"
|
|
2266
2210
|
},
|
|
2267
|
-
{
|
|
2268
|
-
name: "CoordCode",
|
|
2269
|
-
baseUrl: "https://api.coordcode.com/api",
|
|
2270
|
-
description: "CoordCode API \u670D\u52A1"
|
|
2271
|
-
},
|
|
2272
2211
|
{
|
|
2273
2212
|
name: "88Code",
|
|
2274
2213
|
baseUrl: "https://www.88code.org/api",
|
|
2275
2214
|
description: "88Code API \u670D\u52A1"
|
|
2276
|
-
},
|
|
2277
|
-
{
|
|
2278
|
-
name: "BigModel",
|
|
2279
|
-
baseUrl: "https://open.bigmodel.cn/api/anthropic",
|
|
2280
|
-
description: "\u667A\u8C31 BigModel API"
|
|
2281
|
-
},
|
|
2282
|
-
{
|
|
2283
|
-
name: "ModelScope",
|
|
2284
|
-
baseUrl: "https://api-inference.modelscope.cn/v1/chat/completions",
|
|
2285
|
-
description: "\u963F\u91CC\u4E91 ModelScope API"
|
|
2286
2215
|
}
|
|
2287
2216
|
];
|
|
2288
2217
|
|
|
2289
|
-
// ../core/dist/presets/
|
|
2290
|
-
var
|
|
2218
|
+
// ../core/dist/presets/claude.js
|
|
2219
|
+
var CC_PRESETS = [
|
|
2291
2220
|
{
|
|
2292
2221
|
name: "Anthropic Official",
|
|
2293
2222
|
baseUrl: "https://api.anthropic.com",
|
|
@@ -2328,19 +2257,19 @@ var CLAUDECODE_PRESETS = [
|
|
|
2328
2257
|
// ../core/dist/tool-manager.js
|
|
2329
2258
|
var ProviderNotFoundError = class extends Error {
|
|
2330
2259
|
constructor(id) {
|
|
2331
|
-
super(
|
|
2260
|
+
super(`\u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${id}`);
|
|
2332
2261
|
this.name = "ProviderNotFoundError";
|
|
2333
2262
|
}
|
|
2334
2263
|
};
|
|
2335
2264
|
var ProviderNameConflictError = class extends Error {
|
|
2336
2265
|
constructor(name) {
|
|
2337
|
-
super(
|
|
2266
|
+
super(`\u670D\u52A1\u5546\u540D\u79F0\u5DF2\u5B58\u5728: ${name}`);
|
|
2338
2267
|
this.name = "ProviderNameConflictError";
|
|
2339
2268
|
}
|
|
2340
2269
|
};
|
|
2341
2270
|
var PresetNameConflictError = class extends Error {
|
|
2342
2271
|
constructor(name) {
|
|
2343
|
-
super(
|
|
2272
|
+
super(`\u9884\u7F6E\u540D\u79F0\u5DF2\u5B58\u5728: ${name}`);
|
|
2344
2273
|
this.name = "PresetNameConflictError";
|
|
2345
2274
|
}
|
|
2346
2275
|
};
|
|
@@ -2354,11 +2283,13 @@ function createCodexManager() {
|
|
|
2354
2283
|
function loadConfig() {
|
|
2355
2284
|
if (!fileExists(configPath)) {
|
|
2356
2285
|
ensureDir(getCcmanDir());
|
|
2357
|
-
const
|
|
2358
|
-
providers: []
|
|
2286
|
+
const initialConfig = {
|
|
2287
|
+
providers: [],
|
|
2288
|
+
presets: [...CODEX_PRESETS]
|
|
2289
|
+
// 初始化内置预置到配置文件
|
|
2359
2290
|
};
|
|
2360
|
-
writeJSON(configPath,
|
|
2361
|
-
return
|
|
2291
|
+
writeJSON(configPath, initialConfig);
|
|
2292
|
+
return initialConfig;
|
|
2362
2293
|
}
|
|
2363
2294
|
return readJSON(configPath);
|
|
2364
2295
|
}
|
|
@@ -2405,17 +2336,17 @@ function createCodexManager() {
|
|
|
2405
2336
|
if (!provider) {
|
|
2406
2337
|
throw new ProviderNotFoundError(id);
|
|
2407
2338
|
}
|
|
2408
|
-
config.
|
|
2339
|
+
config.currentProviderId = id;
|
|
2409
2340
|
provider.lastUsedAt = Date.now();
|
|
2410
2341
|
saveConfig(config);
|
|
2411
2342
|
writeCodexConfig(provider);
|
|
2412
2343
|
},
|
|
2413
2344
|
getCurrent() {
|
|
2414
2345
|
const config = loadConfig();
|
|
2415
|
-
if (!config.
|
|
2346
|
+
if (!config.currentProviderId) {
|
|
2416
2347
|
return null;
|
|
2417
2348
|
}
|
|
2418
|
-
const provider = config.providers.find((p) => p.id === config.
|
|
2349
|
+
const provider = config.providers.find((p) => p.id === config.currentProviderId);
|
|
2419
2350
|
return provider || null;
|
|
2420
2351
|
},
|
|
2421
2352
|
edit(id, updates) {
|
|
@@ -2437,7 +2368,7 @@ function createCodexManager() {
|
|
|
2437
2368
|
if (updates.apiKey !== void 0)
|
|
2438
2369
|
provider.apiKey = updates.apiKey;
|
|
2439
2370
|
saveConfig(config);
|
|
2440
|
-
if (config.
|
|
2371
|
+
if (config.currentProviderId === id) {
|
|
2441
2372
|
writeCodexConfig(provider);
|
|
2442
2373
|
}
|
|
2443
2374
|
return provider;
|
|
@@ -2448,8 +2379,8 @@ function createCodexManager() {
|
|
|
2448
2379
|
if (index === -1) {
|
|
2449
2380
|
throw new ProviderNotFoundError(id);
|
|
2450
2381
|
}
|
|
2451
|
-
if (config.
|
|
2452
|
-
config.
|
|
2382
|
+
if (config.currentProviderId === id) {
|
|
2383
|
+
config.currentProviderId = void 0;
|
|
2453
2384
|
}
|
|
2454
2385
|
config.providers.splice(index, 1);
|
|
2455
2386
|
saveConfig(config);
|
|
@@ -2503,7 +2434,7 @@ function createCodexManager() {
|
|
|
2503
2434
|
}
|
|
2504
2435
|
const preset = config.presets.find((p) => p.name === name);
|
|
2505
2436
|
if (!preset) {
|
|
2506
|
-
throw new Error(
|
|
2437
|
+
throw new Error(`\u9884\u7F6E\u4E0D\u5B58\u5728: ${name}`);
|
|
2507
2438
|
}
|
|
2508
2439
|
if (updates.name !== void 0 && updates.name !== preset.name) {
|
|
2509
2440
|
const allPresets = [...CODEX_PRESETS, ...config.presets];
|
|
@@ -2535,16 +2466,18 @@ function createCodexManager() {
|
|
|
2535
2466
|
}
|
|
2536
2467
|
};
|
|
2537
2468
|
}
|
|
2538
|
-
function
|
|
2539
|
-
const configPath = path3.join(getCcmanDir(), "
|
|
2469
|
+
function createClaudeManager() {
|
|
2470
|
+
const configPath = path3.join(getCcmanDir(), "claude.json");
|
|
2540
2471
|
function loadConfig() {
|
|
2541
2472
|
if (!fileExists(configPath)) {
|
|
2542
2473
|
ensureDir(getCcmanDir());
|
|
2543
|
-
const
|
|
2544
|
-
providers: []
|
|
2474
|
+
const initialConfig = {
|
|
2475
|
+
providers: [],
|
|
2476
|
+
presets: [...CC_PRESETS]
|
|
2477
|
+
// 初始化内置预置到配置文件
|
|
2545
2478
|
};
|
|
2546
|
-
writeJSON(configPath,
|
|
2547
|
-
return
|
|
2479
|
+
writeJSON(configPath, initialConfig);
|
|
2480
|
+
return initialConfig;
|
|
2548
2481
|
}
|
|
2549
2482
|
return readJSON(configPath);
|
|
2550
2483
|
}
|
|
@@ -2559,7 +2492,7 @@ function createClaudeCodeManager() {
|
|
|
2559
2492
|
throw new ProviderNameConflictError(input.name);
|
|
2560
2493
|
}
|
|
2561
2494
|
const provider = {
|
|
2562
|
-
id: generateId("
|
|
2495
|
+
id: generateId("claude"),
|
|
2563
2496
|
name: input.name,
|
|
2564
2497
|
baseUrl: input.baseUrl,
|
|
2565
2498
|
apiKey: input.apiKey,
|
|
@@ -2591,17 +2524,17 @@ function createClaudeCodeManager() {
|
|
|
2591
2524
|
if (!provider) {
|
|
2592
2525
|
throw new ProviderNotFoundError(id);
|
|
2593
2526
|
}
|
|
2594
|
-
config.
|
|
2527
|
+
config.currentProviderId = id;
|
|
2595
2528
|
provider.lastUsedAt = Date.now();
|
|
2596
2529
|
saveConfig(config);
|
|
2597
|
-
|
|
2530
|
+
writeClaudeConfig(provider);
|
|
2598
2531
|
},
|
|
2599
2532
|
getCurrent() {
|
|
2600
2533
|
const config = loadConfig();
|
|
2601
|
-
if (!config.
|
|
2534
|
+
if (!config.currentProviderId) {
|
|
2602
2535
|
return null;
|
|
2603
2536
|
}
|
|
2604
|
-
const provider = config.providers.find((p) => p.id === config.
|
|
2537
|
+
const provider = config.providers.find((p) => p.id === config.currentProviderId);
|
|
2605
2538
|
return provider || null;
|
|
2606
2539
|
},
|
|
2607
2540
|
edit(id, updates) {
|
|
@@ -2623,8 +2556,8 @@ function createClaudeCodeManager() {
|
|
|
2623
2556
|
if (updates.apiKey !== void 0)
|
|
2624
2557
|
provider.apiKey = updates.apiKey;
|
|
2625
2558
|
saveConfig(config);
|
|
2626
|
-
if (config.
|
|
2627
|
-
|
|
2559
|
+
if (config.currentProviderId === id) {
|
|
2560
|
+
writeClaudeConfig(provider);
|
|
2628
2561
|
}
|
|
2629
2562
|
return provider;
|
|
2630
2563
|
},
|
|
@@ -2634,8 +2567,8 @@ function createClaudeCodeManager() {
|
|
|
2634
2567
|
if (index === -1) {
|
|
2635
2568
|
throw new ProviderNotFoundError(id);
|
|
2636
2569
|
}
|
|
2637
|
-
if (config.
|
|
2638
|
-
config.
|
|
2570
|
+
if (config.currentProviderId === id) {
|
|
2571
|
+
config.currentProviderId = void 0;
|
|
2639
2572
|
}
|
|
2640
2573
|
config.providers.splice(index, 1);
|
|
2641
2574
|
saveConfig(config);
|
|
@@ -2649,7 +2582,7 @@ function createClaudeCodeManager() {
|
|
|
2649
2582
|
}
|
|
2650
2583
|
const newProvider = {
|
|
2651
2584
|
...source,
|
|
2652
|
-
id: generateId("
|
|
2585
|
+
id: generateId("claude"),
|
|
2653
2586
|
name: newName,
|
|
2654
2587
|
createdAt: Date.now(),
|
|
2655
2588
|
lastUsedAt: void 0
|
|
@@ -2663,7 +2596,7 @@ function createClaudeCodeManager() {
|
|
|
2663
2596
|
if (!config.presets) {
|
|
2664
2597
|
config.presets = [];
|
|
2665
2598
|
}
|
|
2666
|
-
const allPresets = [...
|
|
2599
|
+
const allPresets = [...CC_PRESETS, ...config.presets];
|
|
2667
2600
|
const nameExists = allPresets.some((p) => p.name === input.name);
|
|
2668
2601
|
if (nameExists) {
|
|
2669
2602
|
throw new PresetNameConflictError(input.name);
|
|
@@ -2680,7 +2613,7 @@ function createClaudeCodeManager() {
|
|
|
2680
2613
|
listPresets() {
|
|
2681
2614
|
const config = loadConfig();
|
|
2682
2615
|
const userPresets = config.presets || [];
|
|
2683
|
-
return [...
|
|
2616
|
+
return [...CC_PRESETS, ...userPresets];
|
|
2684
2617
|
},
|
|
2685
2618
|
editPreset(name, updates) {
|
|
2686
2619
|
const config = loadConfig();
|
|
@@ -2689,10 +2622,10 @@ function createClaudeCodeManager() {
|
|
|
2689
2622
|
}
|
|
2690
2623
|
const preset = config.presets.find((p) => p.name === name);
|
|
2691
2624
|
if (!preset) {
|
|
2692
|
-
throw new Error(
|
|
2625
|
+
throw new Error(`\u9884\u7F6E\u4E0D\u5B58\u5728: ${name}`);
|
|
2693
2626
|
}
|
|
2694
2627
|
if (updates.name !== void 0 && updates.name !== preset.name) {
|
|
2695
|
-
const allPresets = [...
|
|
2628
|
+
const allPresets = [...CC_PRESETS, ...config.presets];
|
|
2696
2629
|
const nameConflict = allPresets.some((p) => p.name !== name && p.name === updates.name);
|
|
2697
2630
|
if (nameConflict) {
|
|
2698
2631
|
throw new PresetNameConflictError(updates.name);
|
|
@@ -2723,7 +2656,10 @@ function createClaudeCodeManager() {
|
|
|
2723
2656
|
}
|
|
2724
2657
|
|
|
2725
2658
|
// ../core/dist/index.js
|
|
2726
|
-
var
|
|
2659
|
+
var import_meta = {};
|
|
2660
|
+
var require2 = (0, import_module.createRequire)(import_meta.url);
|
|
2661
|
+
var pkg = require2("../package.json");
|
|
2662
|
+
var VERSION = pkg.version;
|
|
2727
2663
|
|
|
2728
2664
|
// src/interactive.ts
|
|
2729
2665
|
var import_inquirer = __toESM(require("inquirer"));
|
|
@@ -2780,7 +2716,7 @@ async function startMainMenu() {
|
|
|
2780
2716
|
name: "choice",
|
|
2781
2717
|
message: "\u8BF7\u9009\u62E9\u64CD\u4F5C:",
|
|
2782
2718
|
choices: [
|
|
2783
|
-
{ name: "\u{1F537} Claude
|
|
2719
|
+
{ name: "\u{1F537} Claude \u7BA1\u7406", value: "claude" },
|
|
2784
2720
|
{ name: "\u{1F536} Codex \u7BA1\u7406", value: "codex" },
|
|
2785
2721
|
{ name: "\u{1F4E6} \u9884\u7F6E\u670D\u52A1\u5546\u7BA1\u7406", value: "presets" },
|
|
2786
2722
|
{ name: "\u274C \u9000\u51FA", value: "exit" }
|
|
@@ -2791,8 +2727,8 @@ async function startMainMenu() {
|
|
|
2791
2727
|
console.log(import_chalk2.default.gray("\n\u{1F44B} \u518D\u89C1!\n"));
|
|
2792
2728
|
break;
|
|
2793
2729
|
}
|
|
2794
|
-
if (choice === "
|
|
2795
|
-
await
|
|
2730
|
+
if (choice === "claude") {
|
|
2731
|
+
await startClaudeMenu();
|
|
2796
2732
|
} else if (choice === "codex") {
|
|
2797
2733
|
await startCodexMenu();
|
|
2798
2734
|
} else if (choice === "presets") {
|
|
@@ -2800,15 +2736,15 @@ async function startMainMenu() {
|
|
|
2800
2736
|
}
|
|
2801
2737
|
}
|
|
2802
2738
|
}
|
|
2803
|
-
async function
|
|
2804
|
-
await showToolMenu("
|
|
2739
|
+
async function startClaudeMenu() {
|
|
2740
|
+
await showToolMenu("claude");
|
|
2805
2741
|
}
|
|
2806
2742
|
async function startCodexMenu() {
|
|
2807
2743
|
await showToolMenu("codex");
|
|
2808
2744
|
}
|
|
2809
2745
|
async function showToolMenu(tool) {
|
|
2810
|
-
const toolName = tool === "
|
|
2811
|
-
const toolEmoji = tool === "
|
|
2746
|
+
const toolName = tool === "claude" ? "Claude" : "Codex";
|
|
2747
|
+
const toolEmoji = tool === "claude" ? "\u{1F537}" : "\u{1F536}";
|
|
2812
2748
|
while (true) {
|
|
2813
2749
|
console.log();
|
|
2814
2750
|
const { action } = await import_inquirer.default.prompt([
|
|
@@ -2873,8 +2809,8 @@ async function showPresetsMenu() {
|
|
|
2873
2809
|
console.log(import_chalk2.default.yellow("\n\u26A0\uFE0F \u9884\u7F6E\u670D\u52A1\u5546\u7BA1\u7406\u529F\u80FD\u5373\u5C06\u63A8\u51FA\n"));
|
|
2874
2810
|
}
|
|
2875
2811
|
async function handleAdd(tool) {
|
|
2876
|
-
const manager = tool === "codex" ? createCodexManager() :
|
|
2877
|
-
const toolName = tool === "
|
|
2812
|
+
const manager = tool === "codex" ? createCodexManager() : createClaudeManager();
|
|
2813
|
+
const toolName = tool === "claude" ? "Claude" : "Codex";
|
|
2878
2814
|
const presets = manager.listPresets();
|
|
2879
2815
|
console.log(import_chalk2.default.bold(`
|
|
2880
2816
|
\u{1F4DD} \u6DFB\u52A0 ${toolName} \u670D\u52A1\u5546
|
|
@@ -2906,18 +2842,17 @@ async function handleAdd(tool) {
|
|
|
2906
2842
|
}
|
|
2907
2843
|
]);
|
|
2908
2844
|
const preset = presets.find((p) => p.name === presetName);
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
apiKey = inputApiKey;
|
|
2845
|
+
console.log(import_chalk2.default.blue(`
|
|
2846
|
+
\u4F7F\u7528\u9884\u8BBE: ${preset.name} - ${preset.description}
|
|
2847
|
+
`));
|
|
2848
|
+
const input = await promptProviderForm({
|
|
2849
|
+
name: preset.name,
|
|
2850
|
+
baseUrl: preset.baseUrl,
|
|
2851
|
+
apiKey: ""
|
|
2852
|
+
});
|
|
2853
|
+
name = input.name;
|
|
2854
|
+
baseUrl = input.baseUrl;
|
|
2855
|
+
apiKey = input.apiKey;
|
|
2921
2856
|
} else {
|
|
2922
2857
|
const answers = await import_inquirer.default.prompt([
|
|
2923
2858
|
{
|
|
@@ -2955,8 +2890,7 @@ async function handleAdd(tool) {
|
|
|
2955
2890
|
console.log(import_chalk2.default.green("\u2705 \u6DFB\u52A0\u6210\u529F"));
|
|
2956
2891
|
console.log();
|
|
2957
2892
|
console.log(` ${import_chalk2.default.bold(provider.name)} ${import_chalk2.default.blue(`[${toolName}]`)}`);
|
|
2958
|
-
console.log(` ${import_chalk2.default.gray(
|
|
2959
|
-
console.log(` ${import_chalk2.default.gray(`URL: ${provider.baseUrl}`)}`);
|
|
2893
|
+
console.log(` ${import_chalk2.default.gray(provider.baseUrl)}`);
|
|
2960
2894
|
console.log();
|
|
2961
2895
|
const { switchNow } = await import_inquirer.default.prompt([
|
|
2962
2896
|
{
|
|
@@ -2975,7 +2909,7 @@ async function handleAdd(tool) {
|
|
|
2975
2909
|
}
|
|
2976
2910
|
}
|
|
2977
2911
|
async function handleSwitch(tool) {
|
|
2978
|
-
const manager = tool === "codex" ? createCodexManager() :
|
|
2912
|
+
const manager = tool === "codex" ? createCodexManager() : createClaudeManager();
|
|
2979
2913
|
const providers = manager.list();
|
|
2980
2914
|
const current = manager.getCurrent();
|
|
2981
2915
|
if (providers.length === 0) {
|
|
@@ -3000,10 +2934,10 @@ async function handleSwitch(tool) {
|
|
|
3000
2934
|
`));
|
|
3001
2935
|
}
|
|
3002
2936
|
async function handleList(tool) {
|
|
3003
|
-
const manager = tool === "codex" ? createCodexManager() :
|
|
2937
|
+
const manager = tool === "codex" ? createCodexManager() : createClaudeManager();
|
|
3004
2938
|
const providers = manager.list();
|
|
3005
2939
|
const current = manager.getCurrent();
|
|
3006
|
-
const toolName = tool === "
|
|
2940
|
+
const toolName = tool === "claude" ? "Claude" : "Codex";
|
|
3007
2941
|
if (providers.length === 0) {
|
|
3008
2942
|
console.log(import_chalk2.default.yellow(`
|
|
3009
2943
|
\u26A0\uFE0F \u6682\u65E0 ${toolName} \u670D\u52A1\u5546
|
|
@@ -3018,8 +2952,7 @@ async function handleList(tool) {
|
|
|
3018
2952
|
const marker = isCurrent ? import_chalk2.default.green("\u25CF") : import_chalk2.default.gray("\u25CB");
|
|
3019
2953
|
const nameStyle = isCurrent ? import_chalk2.default.green.bold : import_chalk2.default.white;
|
|
3020
2954
|
console.log(`${marker} ${nameStyle(p.name)}`);
|
|
3021
|
-
console.log(` ${import_chalk2.default.gray(
|
|
3022
|
-
console.log(` ${import_chalk2.default.gray(`URL: ${p.baseUrl}`)}`);
|
|
2955
|
+
console.log(` ${import_chalk2.default.gray(p.baseUrl)}`);
|
|
3023
2956
|
if (p.lastUsedAt) {
|
|
3024
2957
|
const date = new Date(p.lastUsedAt).toLocaleString("zh-CN");
|
|
3025
2958
|
console.log(` ${import_chalk2.default.gray(`\u6700\u540E\u4F7F\u7528: ${date}`)}`);
|
|
@@ -3034,9 +2967,9 @@ async function handleList(tool) {
|
|
|
3034
2967
|
}
|
|
3035
2968
|
}
|
|
3036
2969
|
async function handleCurrent(tool) {
|
|
3037
|
-
const manager = tool === "codex" ? createCodexManager() :
|
|
2970
|
+
const manager = tool === "codex" ? createCodexManager() : createClaudeManager();
|
|
3038
2971
|
const current = manager.getCurrent();
|
|
3039
|
-
const toolName = tool === "
|
|
2972
|
+
const toolName = tool === "claude" ? "Claude" : "Codex";
|
|
3040
2973
|
if (!current) {
|
|
3041
2974
|
console.log(import_chalk2.default.yellow(`
|
|
3042
2975
|
\u26A0\uFE0F \u672A\u9009\u62E9\u4EFB\u4F55 ${toolName} \u670D\u52A1\u5546
|
|
@@ -3047,8 +2980,7 @@ async function handleCurrent(tool) {
|
|
|
3047
2980
|
\u{1F441}\uFE0F \u5F53\u524D ${toolName} \u670D\u52A1\u5546
|
|
3048
2981
|
`));
|
|
3049
2982
|
console.log(` ${import_chalk2.default.green.bold(current.name)}`);
|
|
3050
|
-
console.log(` ${import_chalk2.default.gray(
|
|
3051
|
-
console.log(` ${import_chalk2.default.gray(`URL: ${current.baseUrl}`)}`);
|
|
2983
|
+
console.log(` ${import_chalk2.default.gray(current.baseUrl)}`);
|
|
3052
2984
|
if (current.lastUsedAt) {
|
|
3053
2985
|
const date = new Date(current.lastUsedAt).toLocaleString("zh-CN");
|
|
3054
2986
|
console.log(` ${import_chalk2.default.gray(`\u6700\u540E\u4F7F\u7528: ${date}`)}`);
|
|
@@ -3056,7 +2988,7 @@ async function handleCurrent(tool) {
|
|
|
3056
2988
|
console.log();
|
|
3057
2989
|
}
|
|
3058
2990
|
async function handleEdit(tool) {
|
|
3059
|
-
const manager = tool === "codex" ? createCodexManager() :
|
|
2991
|
+
const manager = tool === "codex" ? createCodexManager() : createClaudeManager();
|
|
3060
2992
|
const providers = manager.list();
|
|
3061
2993
|
if (providers.length === 0) {
|
|
3062
2994
|
console.log(import_chalk2.default.yellow("\n\u26A0\uFE0F \u6682\u65E0\u670D\u52A1\u5546\n"));
|
|
@@ -3110,7 +3042,7 @@ async function handleEdit(tool) {
|
|
|
3110
3042
|
console.log(import_chalk2.default.green("\n\u2705 \u7F16\u8F91\u6210\u529F\n"));
|
|
3111
3043
|
}
|
|
3112
3044
|
async function handleClone(tool) {
|
|
3113
|
-
const manager = tool === "codex" ? createCodexManager() :
|
|
3045
|
+
const manager = tool === "codex" ? createCodexManager() : createClaudeManager();
|
|
3114
3046
|
const providers = manager.list();
|
|
3115
3047
|
if (providers.length === 0) {
|
|
3116
3048
|
console.log(import_chalk2.default.yellow("\n\u26A0\uFE0F \u6682\u65E0\u670D\u52A1\u5546\n"));
|
|
@@ -3151,11 +3083,11 @@ async function handleClone(tool) {
|
|
|
3151
3083
|
});
|
|
3152
3084
|
console.log(import_chalk2.default.green("\n\u2705 \u514B\u9686\u6210\u529F\n"));
|
|
3153
3085
|
console.log(` ${import_chalk2.default.bold(newProvider.name)}`);
|
|
3154
|
-
console.log(` ${import_chalk2.default.gray(
|
|
3086
|
+
console.log(` ${import_chalk2.default.gray(newProvider.baseUrl)}`);
|
|
3155
3087
|
console.log();
|
|
3156
3088
|
}
|
|
3157
3089
|
async function handleRemove(tool) {
|
|
3158
|
-
const manager = tool === "codex" ? createCodexManager() :
|
|
3090
|
+
const manager = tool === "codex" ? createCodexManager() : createClaudeManager();
|
|
3159
3091
|
const providers = manager.list();
|
|
3160
3092
|
if (providers.length === 0) {
|
|
3161
3093
|
console.log(import_chalk2.default.yellow("\n\u26A0\uFE0F \u6682\u65E0\u670D\u52A1\u5546\n"));
|
|
@@ -3278,8 +3210,7 @@ function addCommand(program2) {
|
|
|
3278
3210
|
console.log(import_chalk3.default.green("\u2705 \u6DFB\u52A0\u6210\u529F"));
|
|
3279
3211
|
console.log();
|
|
3280
3212
|
console.log(` ${import_chalk3.default.bold(provider.name)} ${import_chalk3.default.blue("[Codex]")}`);
|
|
3281
|
-
console.log(` ${import_chalk3.default.gray(
|
|
3282
|
-
console.log(` ${import_chalk3.default.gray(`URL: ${provider.baseUrl}`)}`);
|
|
3213
|
+
console.log(` ${import_chalk3.default.gray(provider.baseUrl)}`);
|
|
3283
3214
|
console.log();
|
|
3284
3215
|
const { switchNow } = await import_inquirer2.default.prompt([
|
|
3285
3216
|
{
|
|
@@ -3294,8 +3225,8 @@ function addCommand(program2) {
|
|
|
3294
3225
|
console.log(import_chalk3.default.green("\u2705 \u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546"));
|
|
3295
3226
|
console.log();
|
|
3296
3227
|
console.log(import_chalk3.default.gray("\u914D\u7F6E\u5DF2\u66F4\u65B0:"));
|
|
3297
|
-
console.log(import_chalk3.default.gray(
|
|
3298
|
-
console.log(import_chalk3.default.gray(
|
|
3228
|
+
console.log(import_chalk3.default.gray(` - ${getCodexConfigPath()}`));
|
|
3229
|
+
console.log(import_chalk3.default.gray(` - ${getCodexAuthPath()}`));
|
|
3299
3230
|
} else {
|
|
3300
3231
|
console.log(import_chalk3.default.blue("\u{1F4A1} \u7A0D\u540E\u5207\u6362:") + import_chalk3.default.white(` ccman cx use "${provider.name}"`));
|
|
3301
3232
|
}
|
|
@@ -3394,8 +3325,8 @@ function useCommand(program2) {
|
|
|
3394
3325
|
console.log(` ${import_chalk5.default.gray(`URL: ${provider.baseUrl}`)}`);
|
|
3395
3326
|
console.log();
|
|
3396
3327
|
console.log(import_chalk5.default.gray("\u914D\u7F6E\u5DF2\u66F4\u65B0:"));
|
|
3397
|
-
console.log(import_chalk5.default.gray(
|
|
3398
|
-
console.log(import_chalk5.default.gray(
|
|
3328
|
+
console.log(import_chalk5.default.gray(` - ${getCodexConfigPath()}`));
|
|
3329
|
+
console.log(import_chalk5.default.gray(` - ${getCodexAuthPath()}`));
|
|
3399
3330
|
console.log();
|
|
3400
3331
|
} catch (error) {
|
|
3401
3332
|
if (error instanceof ProviderNotFoundError) {
|
|
@@ -3674,13 +3605,13 @@ function createCodexCommands(program2) {
|
|
|
3674
3605
|
cloneCommand(program2);
|
|
3675
3606
|
}
|
|
3676
3607
|
|
|
3677
|
-
// src/commands/
|
|
3608
|
+
// src/commands/claude/add.ts
|
|
3678
3609
|
var import_chalk10 = __toESM(require("chalk"));
|
|
3679
3610
|
var import_inquirer7 = __toESM(require("inquirer"));
|
|
3680
3611
|
function addCommand2(program2) {
|
|
3681
3612
|
program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 Claude Code \u670D\u52A1\u5546(\u4EA4\u4E92\u5F0F)").action(async () => {
|
|
3682
3613
|
try {
|
|
3683
|
-
const manager =
|
|
3614
|
+
const manager = createClaudeManager();
|
|
3684
3615
|
console.log(import_chalk10.default.bold("\n\u{1F4DD} \u6DFB\u52A0 Claude Code \u670D\u52A1\u5546\n"));
|
|
3685
3616
|
const { usePreset } = await import_inquirer7.default.prompt([
|
|
3686
3617
|
{
|
|
@@ -3702,13 +3633,13 @@ function addCommand2(program2) {
|
|
|
3702
3633
|
type: "list",
|
|
3703
3634
|
name: "presetName",
|
|
3704
3635
|
message: "\u9009\u62E9\u9884\u7F6E\u670D\u52A1\u5546:",
|
|
3705
|
-
choices:
|
|
3636
|
+
choices: CC_PRESETS.map((p) => ({
|
|
3706
3637
|
name: `${p.name} - ${p.description}`,
|
|
3707
3638
|
value: p.name
|
|
3708
3639
|
}))
|
|
3709
3640
|
}
|
|
3710
3641
|
]);
|
|
3711
|
-
const preset =
|
|
3642
|
+
const preset = CC_PRESETS.find((p) => p.name === presetName);
|
|
3712
3643
|
console.log(import_chalk10.default.blue(`
|
|
3713
3644
|
\u4F7F\u7528\u9884\u8BBE: ${preset.name} - ${preset.description}
|
|
3714
3645
|
`));
|
|
@@ -3763,8 +3694,7 @@ function addCommand2(program2) {
|
|
|
3763
3694
|
console.log(import_chalk10.default.green("\u2705 \u6DFB\u52A0\u6210\u529F"));
|
|
3764
3695
|
console.log();
|
|
3765
3696
|
console.log(` ${import_chalk10.default.bold(provider.name)} ${import_chalk10.default.blue("[Claude Code]")}`);
|
|
3766
|
-
console.log(` ${import_chalk10.default.gray(
|
|
3767
|
-
console.log(` ${import_chalk10.default.gray(`URL: ${provider.baseUrl}`)}`);
|
|
3697
|
+
console.log(` ${import_chalk10.default.gray(provider.baseUrl)}`);
|
|
3768
3698
|
console.log();
|
|
3769
3699
|
const { switchNow } = await import_inquirer7.default.prompt([
|
|
3770
3700
|
{
|
|
@@ -3779,7 +3709,7 @@ function addCommand2(program2) {
|
|
|
3779
3709
|
console.log(import_chalk10.default.green("\u2705 \u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546"));
|
|
3780
3710
|
console.log();
|
|
3781
3711
|
console.log(import_chalk10.default.gray("\u914D\u7F6E\u5DF2\u66F4\u65B0:"));
|
|
3782
|
-
console.log(import_chalk10.default.gray(
|
|
3712
|
+
console.log(import_chalk10.default.gray(` - ${getClaudeConfigPath()}`));
|
|
3783
3713
|
} else {
|
|
3784
3714
|
console.log(import_chalk10.default.blue("\u{1F4A1} \u7A0D\u540E\u5207\u6362:") + import_chalk10.default.white(` ccman cc use "${provider.name}"`));
|
|
3785
3715
|
}
|
|
@@ -3792,12 +3722,12 @@ function addCommand2(program2) {
|
|
|
3792
3722
|
});
|
|
3793
3723
|
}
|
|
3794
3724
|
|
|
3795
|
-
// src/commands/
|
|
3725
|
+
// src/commands/claude/list.ts
|
|
3796
3726
|
var import_chalk11 = __toESM(require("chalk"));
|
|
3797
3727
|
function listCommand2(program2) {
|
|
3798
3728
|
program2.command("list").alias("ls").description("\u5217\u51FA\u6240\u6709 Claude Code \u670D\u52A1\u5546").action(async () => {
|
|
3799
3729
|
try {
|
|
3800
|
-
const manager =
|
|
3730
|
+
const manager = createClaudeManager();
|
|
3801
3731
|
const providers = manager.list();
|
|
3802
3732
|
const current = manager.getCurrent();
|
|
3803
3733
|
if (providers.length === 0) {
|
|
@@ -3835,13 +3765,13 @@ function listCommand2(program2) {
|
|
|
3835
3765
|
});
|
|
3836
3766
|
}
|
|
3837
3767
|
|
|
3838
|
-
// src/commands/
|
|
3768
|
+
// src/commands/claude/use.ts
|
|
3839
3769
|
var import_chalk12 = __toESM(require("chalk"));
|
|
3840
3770
|
var import_inquirer8 = __toESM(require("inquirer"));
|
|
3841
3771
|
function useCommand2(program2) {
|
|
3842
3772
|
program2.command("use [name]").description("\u5207\u6362 Claude Code \u670D\u52A1\u5546").action(async (name) => {
|
|
3843
3773
|
try {
|
|
3844
|
-
const manager =
|
|
3774
|
+
const manager = createClaudeManager();
|
|
3845
3775
|
const providers = manager.list();
|
|
3846
3776
|
if (providers.length === 0) {
|
|
3847
3777
|
console.log(import_chalk12.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Claude Code \u670D\u52A1\u5546\n"));
|
|
@@ -3878,8 +3808,7 @@ function useCommand2(program2) {
|
|
|
3878
3808
|
console.log(` ${import_chalk12.default.gray(`URL: ${provider.baseUrl}`)}`);
|
|
3879
3809
|
console.log();
|
|
3880
3810
|
console.log(import_chalk12.default.gray("\u914D\u7F6E\u5DF2\u66F4\u65B0:"));
|
|
3881
|
-
console.log(import_chalk12.default.gray(
|
|
3882
|
-
console.log(import_chalk12.default.gray(" - ~/.claude/auth.json"));
|
|
3811
|
+
console.log(import_chalk12.default.gray(` - ${getClaudeConfigPath()}`));
|
|
3883
3812
|
console.log();
|
|
3884
3813
|
} catch (error) {
|
|
3885
3814
|
if (error instanceof ProviderNotFoundError) {
|
|
@@ -3897,12 +3826,12 @@ function useCommand2(program2) {
|
|
|
3897
3826
|
});
|
|
3898
3827
|
}
|
|
3899
3828
|
|
|
3900
|
-
// src/commands/
|
|
3829
|
+
// src/commands/claude/current.ts
|
|
3901
3830
|
var import_chalk13 = __toESM(require("chalk"));
|
|
3902
3831
|
function currentCommand2(program2) {
|
|
3903
3832
|
program2.command("current").description("\u663E\u793A\u5F53\u524D\u4F7F\u7528\u7684 Claude Code \u670D\u52A1\u5546").action(async () => {
|
|
3904
3833
|
try {
|
|
3905
|
-
const manager =
|
|
3834
|
+
const manager = createClaudeManager();
|
|
3906
3835
|
const current = manager.getCurrent();
|
|
3907
3836
|
if (!current) {
|
|
3908
3837
|
console.log(import_chalk13.default.yellow("\n\u26A0\uFE0F \u672A\u9009\u62E9\u4EFB\u4F55 Claude Code \u670D\u52A1\u5546\n"));
|
|
@@ -3927,13 +3856,13 @@ function currentCommand2(program2) {
|
|
|
3927
3856
|
});
|
|
3928
3857
|
}
|
|
3929
3858
|
|
|
3930
|
-
// src/commands/
|
|
3859
|
+
// src/commands/claude/remove.ts
|
|
3931
3860
|
var import_chalk14 = __toESM(require("chalk"));
|
|
3932
3861
|
var import_inquirer9 = __toESM(require("inquirer"));
|
|
3933
3862
|
function removeCommand2(program2) {
|
|
3934
3863
|
program2.command("remove [name]").alias("rm").description("\u5220\u9664 Claude Code \u670D\u52A1\u5546").action(async (name) => {
|
|
3935
3864
|
try {
|
|
3936
|
-
const manager =
|
|
3865
|
+
const manager = createClaudeManager();
|
|
3937
3866
|
const providers = manager.list();
|
|
3938
3867
|
if (providers.length === 0) {
|
|
3939
3868
|
console.log(import_chalk14.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Claude Code \u670D\u52A1\u5546\n"));
|
|
@@ -3996,13 +3925,13 @@ function removeCommand2(program2) {
|
|
|
3996
3925
|
});
|
|
3997
3926
|
}
|
|
3998
3927
|
|
|
3999
|
-
// src/commands/
|
|
3928
|
+
// src/commands/claude/edit.ts
|
|
4000
3929
|
var import_chalk15 = __toESM(require("chalk"));
|
|
4001
3930
|
var import_inquirer10 = __toESM(require("inquirer"));
|
|
4002
3931
|
function editCommand2(program2) {
|
|
4003
3932
|
program2.command("edit [name]").description("\u7F16\u8F91 Claude Code \u670D\u52A1\u5546").action(async (name) => {
|
|
4004
3933
|
try {
|
|
4005
|
-
const manager =
|
|
3934
|
+
const manager = createClaudeManager();
|
|
4006
3935
|
const providers = manager.list();
|
|
4007
3936
|
if (providers.length === 0) {
|
|
4008
3937
|
console.log(import_chalk15.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Claude Code \u670D\u52A1\u5546\n"));
|
|
@@ -4083,13 +4012,13 @@ function editCommand2(program2) {
|
|
|
4083
4012
|
});
|
|
4084
4013
|
}
|
|
4085
4014
|
|
|
4086
|
-
// src/commands/
|
|
4015
|
+
// src/commands/claude/clone.ts
|
|
4087
4016
|
var import_chalk16 = __toESM(require("chalk"));
|
|
4088
4017
|
var import_inquirer11 = __toESM(require("inquirer"));
|
|
4089
4018
|
function cloneCommand2(program2) {
|
|
4090
4019
|
program2.command("clone [source-name] [new-name]").description("\u514B\u9686 Claude Code \u670D\u52A1\u5546").action(async (sourceName, newName) => {
|
|
4091
4020
|
try {
|
|
4092
|
-
const manager =
|
|
4021
|
+
const manager = createClaudeManager();
|
|
4093
4022
|
const providers = manager.list();
|
|
4094
4023
|
if (providers.length === 0) {
|
|
4095
4024
|
console.log(import_chalk16.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Claude Code \u670D\u52A1\u5546\n"));
|
|
@@ -4147,8 +4076,8 @@ function cloneCommand2(program2) {
|
|
|
4147
4076
|
});
|
|
4148
4077
|
}
|
|
4149
4078
|
|
|
4150
|
-
// src/commands/
|
|
4151
|
-
function
|
|
4079
|
+
// src/commands/claude/index.ts
|
|
4080
|
+
function createClaudeCommands(program2) {
|
|
4152
4081
|
addCommand2(program2);
|
|
4153
4082
|
listCommand2(program2);
|
|
4154
4083
|
useCommand2(program2);
|
|
@@ -4179,11 +4108,11 @@ cx.action(async () => {
|
|
|
4179
4108
|
printLogo();
|
|
4180
4109
|
await startCodexMenu();
|
|
4181
4110
|
});
|
|
4182
|
-
var cc = program.command("cc").description("\u7BA1\u7406 Claude
|
|
4183
|
-
|
|
4111
|
+
var cc = program.command("cc").description("\u7BA1\u7406 Claude \u670D\u52A1\u5546");
|
|
4112
|
+
createClaudeCommands(cc);
|
|
4184
4113
|
cc.action(async () => {
|
|
4185
4114
|
printLogo();
|
|
4186
|
-
await
|
|
4115
|
+
await startClaudeMenu();
|
|
4187
4116
|
});
|
|
4188
4117
|
(async () => {
|
|
4189
4118
|
if (!process.argv.slice(2).length) {
|