@minniexcode/codex-switch 0.0.11 → 0.1.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.AI.md +110 -152
- package/README.CN.md +179 -215
- package/README.md +183 -217
- package/dist/app/add-provider.js +9 -3
- package/dist/app/edit-provider.js +17 -3
- package/dist/app/get-status.js +8 -3
- package/dist/app/list-providers.js +48 -1
- package/dist/app/run-doctor.js +4 -0
- package/dist/cli/output.js +153 -18
- package/dist/commands/handlers.js +10 -6
- package/dist/commands/help.js +9 -5
- package/dist/commands/registry.js +22 -14
- package/dist/domain/config.js +26 -1
- package/dist/domain/providers.js +16 -0
- package/dist/domain/runtime-state.js +30 -8
- package/dist/infra/config-repo.js +16 -206
- package/dist/interaction/interactive.js +16 -6
- package/dist/runtime/copilot-bridge.js +2 -1
- package/dist/storage/config-repo.js +0 -23
- package/docs/Design/codex-switch-v0.0.12-design.md +343 -0
- package/docs/Design/codex-switch-v0.1.0-design.md +152 -0
- package/docs/PRD/codex-switch-prd-v0.0.12.md +279 -0
- package/docs/PRD/codex-switch-prd-v0.1.0.md +217 -317
- package/docs/Tests/testing.md +31 -151
- package/docs/cli-usage.md +223 -524
- package/docs/codex-switch-command-design.md +649 -646
- package/docs/codex-switch-product-overview.md +86 -241
- package/docs/codex-switch-technical-architecture.md +1115 -1112
- package/package.json +51 -51
- package/dist/app/rollback-latest.js +0 -26
package/docs/cli-usage.md
CHANGED
|
@@ -1,524 +1,223 @@
|
|
|
1
|
-
# codex-switch CLI Usage
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
codexs
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## 1.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
codexs
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
- `
|
|
123
|
-
- `
|
|
124
|
-
- `
|
|
125
|
-
- `
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
codexs
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
-
|
|
178
|
-
-
|
|
179
|
-
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
-
|
|
221
|
-
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
### 5.1 `init`
|
|
226
|
-
|
|
227
|
-
初始化 codex-switch tool home 和 registry 文件。
|
|
228
|
-
|
|
229
|
-
```bash
|
|
230
|
-
codexs init [--json] [--codex-dir <path>]
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
行为说明:
|
|
234
|
-
|
|
235
|
-
- 不依赖 `codex` 可执行文件
|
|
236
|
-
- 不要求目标 `config.toml` 或 `auth.json` 已存在
|
|
237
|
-
- `codex-switch.json` 不存在时创建
|
|
238
|
-
- `providers.json` 不存在时创建空 registry:`{ "providers": {} }`
|
|
239
|
-
- 若显式传入 `--codex-dir` 且 `codex-switch.json` 尚不存在,`init` 会把它持久化为 `defaultCodexDir`
|
|
240
|
-
- 成功结果围绕 tool home 返回,不再承诺旧的 `createdCodexDir`、`configExists`、`authExists` 等字段
|
|
241
|
-
|
|
242
|
-
### 5.2 `login copilot`
|
|
243
|
-
|
|
244
|
-
完成 GitHub Copilot 上游安装与登录就绪检查。
|
|
245
|
-
|
|
246
|
-
```bash
|
|
247
|
-
codexs login copilot
|
|
248
|
-
codexs login github-copilot
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
行为说明:
|
|
252
|
-
|
|
253
|
-
- 当前支持 `copilot` 与 `github-copilot` 两种拼写
|
|
254
|
-
- 若本地 Copilot SDK runtime 未安装,会先确认是否安装
|
|
255
|
-
- 若登录尚未就绪,会调用官方 `copilot login`,完成后做一次 recheck
|
|
256
|
-
- 该命令要求真实 TTY,不支持 `--json`
|
|
257
|
-
- 登录状态是共享的;切换 GitHub 账号会影响所有 Copilot provider
|
|
258
|
-
|
|
259
|
-
### 5.3 `migrate`
|
|
260
|
-
|
|
261
|
-
从现有 `config.toml` adopt unmanaged profiles,并写入受管理的 `providers.json`。
|
|
262
|
-
|
|
263
|
-
```bash
|
|
264
|
-
codexs migrate [--json] [--codex-dir <path>] [--merge|--overwrite]
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
行为说明:
|
|
268
|
-
|
|
269
|
-
- 读取 `config.toml` 中已有 profile
|
|
270
|
-
- 仅 adopt 已具备 `model`、`model_provider` 且能解析到匹配 `base_url` 的 unmanaged profile
|
|
271
|
-
- 收集每个 profile 对应的 provider 记录
|
|
272
|
-
- 保持受管备份、锁和 post-run `doctor` 流程
|
|
273
|
-
- 非交互模式下,profile 选择和 provider 细节收集仍不会自动化展开
|
|
274
|
-
|
|
275
|
-
### 5.4 `setup`
|
|
276
|
-
|
|
277
|
-
`setup` 已弃用,不再执行实际初始化或迁移工作。
|
|
278
|
-
|
|
279
|
-
```bash
|
|
280
|
-
codexs setup
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
### 5.5 `add`
|
|
284
|
-
|
|
285
|
-
新增一个 provider。`add` 同时支持 direct provider 和 Copilot bridge provider。
|
|
286
|
-
|
|
287
|
-
```bash
|
|
288
|
-
codexs add <provider> --profile <name> --api-key <key> [--base-url <url>] [--note <text>] [--tag <tag> ...]
|
|
289
|
-
codexs add <provider> --copilot --profile <name> [--bridge-host <host>] [--bridge-port <port>] [--bridge-api-key <secret>]
|
|
290
|
-
codexs add <provider> --profile <name> --api-key <key> --create-profile --model <name> --base-url <url>
|
|
291
|
-
codexs add
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
说明:
|
|
295
|
-
|
|
296
|
-
- direct provider 必须提供 `provider`、`profile`、`apiKey`
|
|
297
|
-
- `--create-profile` 可在 profile 缺失时一并创建目标 profile
|
|
298
|
-
- direct provider 创建新 profile 时需要同时给出 `--model` 与 `--base-url`
|
|
299
|
-
- Copilot provider 创建新 profile 时需要 `--create-profile` 与 `--model`
|
|
300
|
-
- `--copilot` 下禁止 `--api-key`,应使用 `--bridge-api-key`
|
|
301
|
-
- `add --copilot` 不再负责安装 SDK 或触发登录,应先执行 `codexs login copilot`
|
|
302
|
-
- `--install-copilot-sdk` 现在只保留为 rejected compatibility flag
|
|
303
|
-
|
|
304
|
-
交互模式:
|
|
305
|
-
|
|
306
|
-
- direct provider 缺少必填项时会在 TTY 中补问
|
|
307
|
-
- Copilot provider 的交互流不会要求 direct API key
|
|
308
|
-
- tags 交互使用 preset multi-select
|
|
309
|
-
|
|
310
|
-
### 5.6 `edit`
|
|
311
|
-
|
|
312
|
-
编辑单个 provider 的字段。
|
|
313
|
-
|
|
314
|
-
```bash
|
|
315
|
-
codexs edit <provider> [--profile <name>] [--api-key <key>] [--base-url <url>] [--note <text>] [--tag <tag> ...] [--json] [--codex-dir <path>]
|
|
316
|
-
codexs edit <provider> --profile <name> --create-profile --model <name> --base-url <url>
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
说明:
|
|
320
|
-
|
|
321
|
-
- 只更新显式传入的字段
|
|
322
|
-
- `--tag` 会替换整组标签,而不是追加单个 tag
|
|
323
|
-
- 当目标 profile 不存在时,可配合 `--create-profile`、`--model`、`--base-url` 完成重绑定
|
|
324
|
-
|
|
325
|
-
### 5.7 `switch`
|
|
326
|
-
|
|
327
|
-
切换当前使用的 provider/profile。
|
|
328
|
-
|
|
329
|
-
```bash
|
|
330
|
-
codexs switch <provider> [--json] [--codex-dir <path>]
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
行为说明:
|
|
334
|
-
|
|
335
|
-
- 根据 `providers.json` 找到目标 provider
|
|
336
|
-
- direct provider 会切换 active profile,并将 `auth.json` 重写为 `auth_mode=apikey` 与 `OPENAI_API_KEY=<provider.apiKey>`
|
|
337
|
-
- Copilot bridge provider 会维护本地 bridge 路由,并将认证投影写到本地 bridge secret
|
|
338
|
-
- Copilot bridge provider 会在切换前检查 SDK 和上游登录状态
|
|
339
|
-
- 切换前会备份 `config.toml` 与 `auth.json`
|
|
340
|
-
|
|
341
|
-
### 5.8 `bridge start`
|
|
342
|
-
|
|
343
|
-
启动或复用受管 Copilot bridge。
|
|
344
|
-
|
|
345
|
-
```bash
|
|
346
|
-
codexs bridge start [provider] [--json] [--codex-dir <path>]
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
说明:
|
|
350
|
-
|
|
351
|
-
- 可通过显式 provider、当前 active provider、唯一 provider 或 TTY 选择来解析目标
|
|
352
|
-
- 如果预期端口被占用,会自动寻找新的 5 位端口并持久化
|
|
353
|
-
|
|
354
|
-
### 5.9 `bridge stop`
|
|
355
|
-
|
|
356
|
-
停止受管 Copilot bridge。
|
|
357
|
-
|
|
358
|
-
```bash
|
|
359
|
-
codexs bridge stop [provider] [--json] [--codex-dir <path>]
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
说明:
|
|
363
|
-
|
|
364
|
-
- 不修改 `providers.json`
|
|
365
|
-
- 在没有运行中的受管 bridge 时保持幂等
|
|
366
|
-
|
|
367
|
-
### 5.10 `remove`
|
|
368
|
-
|
|
369
|
-
删除一个 provider 记录。
|
|
370
|
-
|
|
371
|
-
```bash
|
|
372
|
-
codexs remove <provider> [--force] [--switch-to <profile>] [--json] [--codex-dir <path>]
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
说明:
|
|
376
|
-
|
|
377
|
-
- 删除的是 `providers.json` 中的记录
|
|
378
|
-
- 如果删除的 provider 是当前 active profile 的最后一个绑定项,可先传 `--switch-to`
|
|
379
|
-
- 非交互模式下必须同时传入 `<provider>` 和 `--force`
|
|
380
|
-
|
|
381
|
-
### 5.11 `import`
|
|
382
|
-
|
|
383
|
-
从外部 JSON 文件导入 provider 配置。
|
|
384
|
-
|
|
385
|
-
```bash
|
|
386
|
-
codexs import <file> [--merge] [--json] [--codex-dir <path>]
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
### 5.12 `export`
|
|
390
|
-
|
|
391
|
-
导出当前 `providers.json` 到指定文件。
|
|
392
|
-
|
|
393
|
-
```bash
|
|
394
|
-
codexs export <file> [--force] [--json] [--codex-dir <path>]
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
说明:
|
|
398
|
-
|
|
399
|
-
- 目标文件已存在时,非交互模式下必须显式传 `--force`
|
|
400
|
-
|
|
401
|
-
## 6. 诊断与恢复
|
|
402
|
-
|
|
403
|
-
### 6.1 `doctor`
|
|
404
|
-
|
|
405
|
-
运行本地配置与环境诊断。
|
|
406
|
-
|
|
407
|
-
```bash
|
|
408
|
-
codexs doctor [--json] [--codex-dir <path>]
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
通常会检查:
|
|
412
|
-
|
|
413
|
-
- 必要文件是否存在
|
|
414
|
-
- provider/profile 映射是否一致
|
|
415
|
-
- 当前运行态是否有漂移
|
|
416
|
-
- Codex CLI 是否可用
|
|
417
|
-
- Copilot SDK、登录状态和 bridge runtime 是否健康
|
|
418
|
-
|
|
419
|
-
### 6.2 `rollback`
|
|
420
|
-
|
|
421
|
-
回滚到最近一次备份,或者指定备份 ID。
|
|
422
|
-
|
|
423
|
-
```bash
|
|
424
|
-
codexs rollback [<backup-id>] [--json] [--codex-dir <path>]
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
## 7. JSON 输出与自动化建议
|
|
428
|
-
|
|
429
|
-
如果你是在脚本、CI 或 Agent 环境中调用,建议遵循以下约束:
|
|
430
|
-
|
|
431
|
-
```bash
|
|
432
|
-
codexs <command> --json
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
推荐实践:
|
|
436
|
-
|
|
437
|
-
- 始终显式传入必需参数,不依赖交互输入
|
|
438
|
-
- 使用 `--json` 获取稳定输出
|
|
439
|
-
- 对危险命令显式传入控制参数,例如 `--force`、`--merge`、`--overwrite`
|
|
440
|
-
- 对多环境调试使用 `--codex-dir <path>` 和 `CODEXS_HOME`
|
|
441
|
-
- 不要在自动化环境中调用 `login copilot`
|
|
442
|
-
|
|
443
|
-
## 8. 典型使用流程
|
|
444
|
-
|
|
445
|
-
### 8.1 第一次接管现有 Codex 配置
|
|
446
|
-
|
|
447
|
-
```bash
|
|
448
|
-
codexs init
|
|
449
|
-
codexs migrate
|
|
450
|
-
codexs list
|
|
451
|
-
codexs doctor
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
### 8.2 新增并切换到一个 direct provider
|
|
455
|
-
|
|
456
|
-
```bash
|
|
457
|
-
codexs add my-provider --profile my-provider --api-key sk-xxx
|
|
458
|
-
codexs switch my-provider
|
|
459
|
-
codexs current
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
### 8.3 接入 GitHub Copilot provider
|
|
463
|
-
|
|
464
|
-
```bash
|
|
465
|
-
codexs login copilot
|
|
466
|
-
codexs add copilot-main --copilot --profile copilot-main
|
|
467
|
-
codexs switch copilot-main
|
|
468
|
-
codexs bridge status copilot-main
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
### 8.4 检查 config profile 与受管态映射
|
|
472
|
-
|
|
473
|
-
```bash
|
|
474
|
-
codexs config list-profiles
|
|
475
|
-
codexs config show
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
### 8.5 出现错误后恢复
|
|
479
|
-
|
|
480
|
-
```bash
|
|
481
|
-
codexs backups list
|
|
482
|
-
codexs rollback
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
## 9. 危险命令说明
|
|
486
|
-
|
|
487
|
-
以下命令会修改本地配置或覆盖文件,使用前应明确预期:
|
|
488
|
-
|
|
489
|
-
- `init`
|
|
490
|
-
- `migrate`
|
|
491
|
-
- `add`
|
|
492
|
-
- `edit`
|
|
493
|
-
- `switch`
|
|
494
|
-
- `bridge start`
|
|
495
|
-
- `remove`
|
|
496
|
-
- `import`
|
|
497
|
-
- `export`(目标文件已存在时)
|
|
498
|
-
- `rollback`
|
|
499
|
-
|
|
500
|
-
建议:
|
|
501
|
-
|
|
502
|
-
- 人工操作先执行 `backups list`
|
|
503
|
-
- 自动化操作统一加 `--json`
|
|
504
|
-
- 在测试目录中先用 `--codex-dir <path>` 与 `CODEXS_HOME` 验证流程
|
|
505
|
-
|
|
506
|
-
## 10. 查看命令帮助
|
|
507
|
-
|
|
508
|
-
可以查看总帮助:
|
|
509
|
-
|
|
510
|
-
```bash
|
|
511
|
-
codexs --help
|
|
512
|
-
```
|
|
513
|
-
|
|
514
|
-
也可以查看单个命令帮助:
|
|
515
|
-
|
|
516
|
-
```bash
|
|
517
|
-
codexs help init
|
|
518
|
-
codexs help login
|
|
519
|
-
codexs help bridge
|
|
520
|
-
codexs help config
|
|
521
|
-
codexs help add
|
|
522
|
-
codexs help switch
|
|
523
|
-
codexs help rollback
|
|
524
|
-
```
|
|
1
|
+
# codex-switch CLI Usage
|
|
2
|
+
|
|
3
|
+
This document describes the current CLI contract for `@minniexcode/codex-switch` at version `0.1.0`.
|
|
4
|
+
|
|
5
|
+
Executable command name:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
codexs
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 1. Version Context
|
|
12
|
+
|
|
13
|
+
The current package version in this repository is `0.1.0`.
|
|
14
|
+
|
|
15
|
+
This is the first stable release line. The command surface already exists, and this version focuses on keeping workflow guidance, help text, and implementation behavior aligned.
|
|
16
|
+
|
|
17
|
+
## 2. Primary Workflows
|
|
18
|
+
|
|
19
|
+
### 2.1 Direct Providers
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
codexs init
|
|
23
|
+
codexs add <provider> --profile <name> --api-key <key>
|
|
24
|
+
codexs switch <provider>
|
|
25
|
+
codexs status
|
|
26
|
+
codexs doctor
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Intent:
|
|
30
|
+
|
|
31
|
+
- `init` prepares the `codex-switch` tool home.
|
|
32
|
+
- `add` creates a managed provider record.
|
|
33
|
+
- `switch` projects the selected provider into the target Codex runtime.
|
|
34
|
+
- `status` summarizes tool-home, runtime, provider, and health state.
|
|
35
|
+
- `doctor` gives deeper repair-oriented diagnostics.
|
|
36
|
+
|
|
37
|
+
### 2.2 GitHub Copilot
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
codexs init
|
|
41
|
+
codexs login copilot
|
|
42
|
+
codexs add <provider> --copilot --profile <name>
|
|
43
|
+
codexs switch <provider>
|
|
44
|
+
codexs status
|
|
45
|
+
codexs doctor
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Important notes:
|
|
49
|
+
|
|
50
|
+
- `login copilot` is the upstream onboarding command.
|
|
51
|
+
- The current implementation prefers the bundled Copilot CLI from the managed runtime and falls back to `PATH` when needed.
|
|
52
|
+
- `login copilot` succeeds only after auth readiness is rechecked.
|
|
53
|
+
- `add --copilot` does not install or log in to Copilot for you.
|
|
54
|
+
|
|
55
|
+
## 3. Advanced Adopt Workflow
|
|
56
|
+
|
|
57
|
+
Use `migrate` only when you already have Codex runtime state that should be adopted into managed `providers.json` state.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
codexs init
|
|
61
|
+
codexs migrate
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`migrate` is an advanced adopt helper. It is not the default first step for fresh installs.
|
|
65
|
+
|
|
66
|
+
Current behavior:
|
|
67
|
+
|
|
68
|
+
- It reads `config.toml` profiles from the target Codex runtime.
|
|
69
|
+
- It can collect missing provider details in TTY mode.
|
|
70
|
+
- It can merge into or overwrite existing managed provider state.
|
|
71
|
+
- It still fails fast in non-TTY and `--json` runs when interactive input would be required.
|
|
72
|
+
|
|
73
|
+
## 4. Deprecated Entry
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
codexs setup
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`setup` is deprecated. It is kept only to direct callers toward `init` or `migrate`, and it no longer performs initialization or migration work.
|
|
80
|
+
|
|
81
|
+
## 5. Global Contract
|
|
82
|
+
|
|
83
|
+
### 5.1 Global Flags
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
--json
|
|
87
|
+
--codex-dir <path>
|
|
88
|
+
--help
|
|
89
|
+
--version
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 5.2 Environment Variables
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
CODEXS_HOME
|
|
96
|
+
CODEXS_CODEX_DIR
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 5.3 Runtime Model
|
|
100
|
+
|
|
101
|
+
Tool home:
|
|
102
|
+
|
|
103
|
+
```text
|
|
104
|
+
~/.config/codex-switch/
|
|
105
|
+
codex-switch.json
|
|
106
|
+
providers.json
|
|
107
|
+
backups/
|
|
108
|
+
runtime/
|
|
109
|
+
runtimes/
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Target Codex runtime:
|
|
113
|
+
|
|
114
|
+
```text
|
|
115
|
+
~/.codex/
|
|
116
|
+
config.toml
|
|
117
|
+
auth.json
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Meaning:
|
|
121
|
+
|
|
122
|
+
- `providers.json` is the managed provider registry.
|
|
123
|
+
- `codex-switch.json` stores tool-level metadata such as `defaultCodexDir`.
|
|
124
|
+
- `config.toml` remains the active runtime routing file.
|
|
125
|
+
- `auth.json` remains the active auth projection file.
|
|
126
|
+
|
|
127
|
+
## 6. Command Categories
|
|
128
|
+
|
|
129
|
+
Read commands:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
codexs list
|
|
133
|
+
codexs show <provider>
|
|
134
|
+
codexs current
|
|
135
|
+
codexs status
|
|
136
|
+
codexs config show [profile]
|
|
137
|
+
codexs config list-profiles
|
|
138
|
+
codexs bridge status [provider]
|
|
139
|
+
codexs backups list
|
|
140
|
+
codexs doctor
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Change commands:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
codexs init
|
|
147
|
+
codexs login copilot
|
|
148
|
+
codexs migrate
|
|
149
|
+
codexs add <provider>
|
|
150
|
+
codexs edit <provider>
|
|
151
|
+
codexs switch <provider>
|
|
152
|
+
codexs remove <provider>
|
|
153
|
+
codexs import <file>
|
|
154
|
+
codexs export <file>
|
|
155
|
+
codexs bridge start [provider]
|
|
156
|
+
codexs bridge stop [provider]
|
|
157
|
+
codexs rollback [backup-id]
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## 7. Selected Command Semantics
|
|
161
|
+
|
|
162
|
+
### `init`
|
|
163
|
+
|
|
164
|
+
- Creates `codex-switch.json` and `providers.json` under the tool home when they do not exist yet.
|
|
165
|
+
- Does not create or validate `config.toml`, `auth.json`, or the target Codex directory.
|
|
166
|
+
- When `--codex-dir` is passed explicitly during first-time initialization, it can persist `defaultCodexDir`.
|
|
167
|
+
|
|
168
|
+
### `login copilot`
|
|
169
|
+
|
|
170
|
+
- Supports `copilot` and `github-copilot` as the current upstream name.
|
|
171
|
+
- Installs the local Copilot SDK under the tool home when needed.
|
|
172
|
+
- Invokes the official Copilot CLI for login when readiness is not already present.
|
|
173
|
+
- Requires a real TTY and does not support `--json`.
|
|
174
|
+
|
|
175
|
+
### `status`
|
|
176
|
+
|
|
177
|
+
- Reports the target Codex runtime and the tool-home root.
|
|
178
|
+
- Reports the current profile and whether it maps to a managed provider.
|
|
179
|
+
- Adds bridge, Copilot SDK, and upstream auth signals when the active provider uses a local runtime bridge.
|
|
180
|
+
- Does not mutate any files.
|
|
181
|
+
|
|
182
|
+
### `list`
|
|
183
|
+
|
|
184
|
+
- Lists managed providers together with their linked profile.
|
|
185
|
+
- Distinguishes provider type using the public values `direct` and `copilot`.
|
|
186
|
+
- Marks the current provider only when the active runtime can be mapped back to one unique managed provider.
|
|
187
|
+
- When the active profile is shared by multiple providers, it does not invent a single current provider and should instead surface the ambiguity.
|
|
188
|
+
- TTY provider pickers used by commands such as `switch` and `show` follow the same visibility rules for profile, provider type, and current-state hints.
|
|
189
|
+
|
|
190
|
+
### `doctor`
|
|
191
|
+
|
|
192
|
+
- Checks expected config files, provider/profile consistency, and Codex CLI availability.
|
|
193
|
+
- Adds bridge and Copilot dependency diagnostics for Copilot-backed providers.
|
|
194
|
+
- Returns repair-oriented issues intended for both human users and AI agents.
|
|
195
|
+
|
|
196
|
+
### `switch`
|
|
197
|
+
|
|
198
|
+
- Direct providers rewrite `auth.json` as an API-key projection and update the active runtime profile.
|
|
199
|
+
- Copilot bridge providers also project the local bridge secret into the runtime while managing bridge routing.
|
|
200
|
+
- Managed writes are backed up and rolled back on failure.
|
|
201
|
+
- When `<provider>` is omitted in a TTY, the interactive provider selector should show profile, provider type, and current-state hints using the same rules as `list`.
|
|
202
|
+
|
|
203
|
+
### `migrate`
|
|
204
|
+
|
|
205
|
+
- Adopts unmanaged runtime profiles into managed `providers.json` state.
|
|
206
|
+
- Still relies on interactive profile selection and provider-detail collection in this release.
|
|
207
|
+
- Should be treated as an advanced adopt tool, not as the normal onboarding path.
|
|
208
|
+
|
|
209
|
+
## 8. Automation Boundaries
|
|
210
|
+
|
|
211
|
+
- Progressive prompts run only in a real TTY and never under `--json`.
|
|
212
|
+
- Human write commands may prompt for missing inputs or dangerous-action confirmation.
|
|
213
|
+
- Automation should pass explicit arguments and prefer `--json`.
|
|
214
|
+
- `login copilot` is TTY-only.
|
|
215
|
+
- `migrate` is not yet a complete non-interactive workflow.
|
|
216
|
+
|
|
217
|
+
## 9. Related Docs
|
|
218
|
+
|
|
219
|
+
- [README](../README.md)
|
|
220
|
+
- [Chinese README](../README.CN.md)
|
|
221
|
+
- [AI README](../README.AI.md)
|
|
222
|
+
- [Product Overview](./codex-switch-product-overview.md)
|
|
223
|
+
- [Release PRD 0.1.0](./PRD/codex-switch-prd-v0.1.0.md)
|