@minniexcode/codex-switch 0.0.5 → 0.0.7

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 (71) hide show
  1. package/README.AI.md +5 -2
  2. package/README.md +44 -100
  3. package/dist/app/add-provider.js +28 -4
  4. package/dist/app/edit-provider.js +47 -19
  5. package/dist/app/export-providers.js +2 -2
  6. package/dist/app/get-current-profile.js +1 -1
  7. package/dist/app/get-status.js +10 -3
  8. package/dist/app/import-providers.js +15 -7
  9. package/dist/app/init-codex.js +68 -0
  10. package/dist/app/list-backups.js +1 -1
  11. package/dist/app/list-config-profiles.js +3 -2
  12. package/dist/app/list-providers.js +2 -1
  13. package/dist/app/remove-provider.js +2 -2
  14. package/dist/app/rollback-backup.js +1 -1
  15. package/dist/app/rollback-latest.js +1 -1
  16. package/dist/app/run-doctor.js +83 -6
  17. package/dist/app/run-mutation.js +2 -2
  18. package/dist/app/setup-codex.js +21 -12
  19. package/dist/app/show-config.js +11 -3
  20. package/dist/app/show-provider.js +1 -1
  21. package/dist/app/switch-provider.js +16 -9
  22. package/dist/cli/add-interactive.js +7 -104
  23. package/dist/cli/args.js +6 -135
  24. package/dist/cli/help.js +8 -313
  25. package/dist/cli/interactive.js +17 -225
  26. package/dist/cli/output.js +21 -6
  27. package/dist/cli/prompt.js +4 -106
  28. package/dist/cli.js +10 -404
  29. package/dist/commands/args.js +132 -0
  30. package/dist/commands/dispatch.js +16 -0
  31. package/dist/commands/handlers.js +460 -0
  32. package/dist/commands/help.js +120 -0
  33. package/dist/commands/registry.js +351 -0
  34. package/dist/commands/types.js +2 -0
  35. package/dist/domain/config.js +235 -21
  36. package/dist/domain/providers.js +16 -2
  37. package/dist/domain/setup.js +1 -0
  38. package/dist/infra/backup-repo.js +9 -206
  39. package/dist/infra/codex-cli.js +9 -126
  40. package/dist/infra/codex-paths.js +6 -67
  41. package/dist/infra/config-repo.js +59 -0
  42. package/dist/infra/fs-utils.js +8 -93
  43. package/dist/infra/lock-repo.js +4 -95
  44. package/dist/infra/providers-repo.js +8 -94
  45. package/dist/interaction/add-interactive.js +99 -0
  46. package/dist/interaction/interactive.js +289 -0
  47. package/dist/interaction/prompt.js +110 -0
  48. package/dist/runtime/codex-cli.js +130 -0
  49. package/dist/runtime/codex-probe.js +57 -0
  50. package/dist/runtime/types.js +2 -0
  51. package/dist/storage/auth-repo.js +160 -0
  52. package/dist/storage/backup-repo.js +210 -0
  53. package/dist/storage/codex-paths.js +71 -0
  54. package/dist/storage/config-repo.js +266 -0
  55. package/dist/storage/fs-utils.js +97 -0
  56. package/dist/storage/lock-repo.js +99 -0
  57. package/dist/storage/providers-repo.js +98 -0
  58. package/docs/Design/codex-switch-v0.0.5-design.md +32 -22
  59. package/docs/Design/codex-switch-v0.0.6-design.md +708 -0
  60. package/docs/Design/codex-switch-v0.0.7-design.md +862 -0
  61. package/docs/PRD/codex-switch-prd-v0.0.5-to-v0.1.0.md +227 -89
  62. package/docs/PRD/codex-switch-prd-v0.1.0.md +200 -226
  63. package/docs/PRD/codex-switch-prd.md +1 -1
  64. package/docs/Reference/codex-config-reference.md +604 -0
  65. package/docs/Reference/codex-config-reference.zh-CN.md +633 -0
  66. package/docs/cli-usage.md +78 -29
  67. package/docs/codex-switch-technical-architecture.md +73 -4
  68. package/docs/test-report-0.0.5.md +163 -0
  69. package/docs/test-report-0.0.7.md +118 -0
  70. package/docs/testing.md +151 -0
  71. package/package.json +1 -1
package/docs/cli-usage.md CHANGED
@@ -89,7 +89,7 @@ CLI 的交互行为遵循以下规则:
89
89
 
90
90
  典型受影响命令包括:
91
91
 
92
- - `setup`
92
+ - `migrate`
93
93
  - `add`
94
94
  - `edit`
95
95
  - `switch`
@@ -207,40 +207,89 @@ codexs backups list --json
207
207
 
208
208
  ## 5. 变更类命令
209
209
 
210
- ### 5.1 `setup`
210
+ ### 5.1 `init`
211
211
 
212
- 从现有 Codex 目录初始化 `providers.json`。
212
+ 轻量初始化目标 Codex 目录,确保 `providers.json` 已存在。
213
213
 
214
214
  ```bash
215
- codexs setup [--json] [--codex-dir <path>] [--merge|--overwrite]
215
+ codexs init [--json] [--codex-dir <path>]
216
216
  ```
217
217
 
218
218
  示例:
219
219
 
220
220
  ```bash
221
- codexs setup
222
- codexs setup --overwrite --json
223
- codexs setup --merge --codex-dir ./.tmp-codex
221
+ codexs init
222
+ codexs init --json
223
+ codexs init --codex-dir ./.tmp-codex
224
+ ```
225
+
226
+ 行为说明:
227
+
228
+ - 不依赖 `codex` 可执行文件
229
+ - 不要求 `config.toml` 或 `auth.json` 已存在
230
+ - `providers.json` 不存在时创建空 registry:`{ "providers": {} }`
231
+ - `providers.json` 已存在时返回成功 no-op,不改写文件,也不会创建备份
232
+ - 成功 JSON 结果固定包含:`codexDir`、`createdCodexDir`、`createdProvidersFile`、`providersAlreadyExisted`、`configExists`、`authExists`
233
+
234
+ 交互模式:
235
+
236
+ - 未显式传 `--codex-dir` 时,会复用候选目录发现并允许你选择或手动输入目录
237
+ - 如果目标目录不存在,会确认是否创建目录
238
+
239
+ 非交互模式:
240
+
241
+ - `--json` 或非 TTY 下绝不会进入 prompt
242
+ - 目标目录不存在时直接返回结构化错误
243
+
244
+ ### 5.2 `migrate`
245
+
246
+ 从现有 `config.toml` adopt unmanaged profiles,并写入受管理的 `providers.json`。
247
+
248
+ ```bash
249
+ codexs migrate [--json] [--codex-dir <path>] [--merge|--overwrite]
250
+ ```
251
+
252
+ 示例:
253
+
254
+ ```bash
255
+ codexs migrate
256
+ codexs migrate --overwrite --json
257
+ codexs migrate --merge --codex-dir ./.tmp-codex
224
258
  ```
225
259
 
226
260
  行为说明:
227
261
 
228
262
  - 读取 `config.toml` 中已有 profile
263
+ - 仅 adopt 已具备 `model`、`model_provider` 且能解析到匹配 `model_providers.*.base_url` 和 `env_key` 的 unmanaged profile
229
264
  - 收集每个 profile 对应的 provider 记录
230
- - 在受管备份流程下写入 `providers.json`
231
- - 成功后会自动运行一次 `doctor`
265
+ - 保持现有受管备份、锁、`auth.json` mirror 和 post-run `doctor` 流程
232
266
 
233
267
  交互模式:
234
268
 
235
269
  - 如果 `providers.json` 已存在,会让你选择 `merge`、`overwrite` 或取消
236
- - 如果需要补全 provider 细节,会在 TTY 中询问
270
+ - profile 选择和 provider 细节收集仍然只在 TTY 中进行
237
271
 
238
272
  非交互模式:
239
273
 
240
274
  - `providers.json` 已存在时,必须显式传入 `--merge` 或 `--overwrite`
241
275
  - `--json` 模式下不会进入任何引导式输入
276
+ - 由于 adopt profile 选择和 provider secret 收集仍然是交互契约,当前版本会直接失败
277
+
278
+ ### 5.3 `setup`
279
+
280
+ `setup` 已弃用,不再执行实际初始化或迁移工作。
281
+
282
+ ```bash
283
+ codexs setup
284
+ ```
285
+
286
+ 行为说明:
242
287
 
243
- ### 5.2 `add`
288
+ - 该命令现在返回 `COMMAND_DEPRECATED`
289
+ - 错误详情中包含 `replacements: ["init", "migrate"]`
290
+ - 应改用 `codexs init` 或 `codexs migrate`
291
+
292
+ ### 5.4 `add`
244
293
 
245
294
  新增一个 provider。
246
295
 
@@ -262,7 +311,7 @@ codexs add
262
311
  - `provider`:provider 名称,也是后续 `switch/show/edit/remove` 的标识
263
312
  - `--profile`:写入到 `config.toml` 的 profile 名称
264
313
  - `--api-key`:provider API key
265
- - `--base-url`:可选的 API base URL
314
+ - `--base-url`:可选的 provider 元数据,不会写回 `[profiles.*]`
266
315
  - `--note`:备注
267
316
  - `--tag`:标签,可重复传多次
268
317
 
@@ -271,13 +320,13 @@ codexs add
271
320
  - 如果缺少 `provider`、`profile`、`apiKey`,会在 TTY 中补问
272
321
  - profile 选择会优先复用现有 `config.toml` profile
273
322
  - API key 的隐藏输入会做二次确认
274
- - tag 支持预设多选和自定义逗号分隔输入
323
+ - tag 仅支持预设选项多选
275
324
 
276
325
  非交互模式:
277
326
 
278
327
  - 必须显式传入所有必填字段
279
328
 
280
- ### 5.3 `edit`
329
+ ### 5.5 `edit`
281
330
 
282
331
  编辑单个 provider 的字段。
283
332
 
@@ -308,39 +357,35 @@ codexs edit packycode --tag daily --tag paid
308
357
 
309
358
  - 至少要提供一个需要修改的字段
310
359
 
311
- ### 5.4 `switch`
360
+ ### 5.6 `switch`
312
361
 
313
362
  切换当前使用的 provider/profile。
314
363
 
315
364
  ```bash
316
- codexs switch <provider> [--no-login] [--json] [--codex-dir <path>]
365
+ codexs switch <provider> [--json] [--codex-dir <path>]
317
366
  ```
318
367
 
319
368
  示例:
320
369
 
321
370
  ```bash
322
371
  codexs switch freemodel
323
- codexs switch freemodel --no-login
324
- codexs switch --no-login
372
+ codexs switch freemodel --json
373
+ codexs switch
325
374
  ```
326
375
 
327
376
  行为说明:
328
377
 
329
378
  - 根据 `providers.json` 找到目标 provider
330
379
  - 更新相关运行态配置
331
- - 默认会执行 Codex 登录刷新流程
380
+ - 重写当前 active provider 对应的 `auth.json` mirror
332
381
  - 会先备份 `config.toml` 和 `auth.json`
333
382
 
334
- 参数说明:
335
-
336
- - `--no-login`:切换后不执行登录刷新
337
-
338
383
  交互模式:
339
384
 
340
385
  - 如果没有传 `<provider>`,TTY 下会弹出 provider 选择器
341
386
  - 如果已经传了 `<provider>`,则直接执行,不再额外确认
342
387
 
343
- ### 5.5 `remove`
388
+ ### 5.7 `remove`
344
389
 
345
390
  删除一个 provider 记录。
346
391
 
@@ -369,7 +414,7 @@ codexs remove freemodel --force --json
369
414
 
370
415
  - 必须同时传入 `<provider>` 和 `--force`
371
416
 
372
- ### 5.6 `import`
417
+ ### 5.8 `import`
373
418
 
374
419
  从外部 JSON 文件导入 provider 配置。
375
420
 
@@ -400,7 +445,7 @@ codexs import ./providers.json --merge --json
400
445
  - 不会弹出路径向导或确认框
401
446
  - 会先验证输入文件,再执行写入
402
447
 
403
- ### 5.7 `export`
448
+ ### 5.9 `export`
404
449
 
405
450
  导出当前 `providers.json` 到指定文件。
406
451
 
@@ -498,7 +543,7 @@ codexs <command> --json
498
543
  ```bash
499
544
  codexs list --json
500
545
  codexs show packycode --json
501
- codexs switch packycode --no-login --json
546
+ codexs switch packycode --json
502
547
  codexs export ./providers.snapshot.json --force --json
503
548
  codexs rollback 20260511-221457-switch --json
504
549
  ```
@@ -508,7 +553,8 @@ codexs rollback 20260511-221457-switch --json
508
553
  ### 8.1 第一次接管现有 Codex 配置
509
554
 
510
555
  ```bash
511
- codexs setup
556
+ codexs init
557
+ codexs migrate
512
558
  codexs list
513
559
  codexs doctor
514
560
  ```
@@ -546,7 +592,8 @@ codexs rollback <backup-id>
546
592
 
547
593
  以下命令会修改本地配置或覆盖文件,使用前应明确预期:
548
594
 
549
- - `setup`
595
+ - `init`
596
+ - `migrate`
550
597
  - `add`
551
598
  - `edit`
552
599
  - `switch`
@@ -572,6 +619,8 @@ codexs --help
572
619
  也可以查看单个命令帮助:
573
620
 
574
621
  ```bash
622
+ codexs help init
623
+ codexs help migrate
575
624
  codexs help setup
576
625
  codexs help add
577
626
  codexs help switch
@@ -130,6 +130,13 @@ Infrastructure 层
130
130
 
131
131
  这意味着未来即使引入 GUI / MCP / HTTP 适配层,核心同步目标仍然是 runtime files,而不是把 runtime files 本身当成长期管理数据库。
132
132
 
133
+ `0.0.6` 的实现边界还需要区分“逻辑主层”和“兼容层”:
134
+
135
+ - 逻辑主层已经迁移到 `src/commands/`、`src/interaction/`、`src/storage/`、`src/runtime/`
136
+ - `src/cli/` 和 `src/infra/` 当前主要承担兼容 re-export 与入口收敛职责
137
+ - 这意味着 `0.0.6` 的完成标准是“边界和契约已经统一”,而不是“所有旧路径文件都物理删除”
138
+ - 后续版本可以在兼容窗口结束后继续删除旧 facade,但这不属于 `0.0.6` 的必须交付范围
139
+
133
140
  ### 3.3 模块依赖图
134
141
 
135
142
  当前代码依赖关系可以抽象为:
@@ -194,10 +201,14 @@ argv
194
201
  ```text
195
202
  src/
196
203
  cli.ts
204
+ commands/
205
+ interaction/
197
206
  app/
198
207
  cli/
199
208
  domain/
209
+ runtime/
200
210
  infra/
211
+ storage/
201
212
 
202
213
  tests/
203
214
  app.spec.js
@@ -220,7 +231,65 @@ scripts/
220
231
 
221
232
  它不直接做文件读写,不直接写业务逻辑,也不直接实现备份或校验规则。
222
233
 
223
- ### 4.2 `src/cli/`
234
+ ### 4.2 `src/commands/`
235
+
236
+ 这一层是 `0.0.6` 新增的命令表面层,负责把“公开 CLI 形态”收敛为单一 registry。
237
+
238
+ 它承担的职责是:
239
+
240
+ - 定义每个命令的公开 token 形态,例如 `config show`、`config list-profiles`、`backups list`
241
+ - 统一保存 `summary`、`usage`、`details`、`examples`
242
+ - 绑定 command handler,供 dispatch 直接执行
243
+ - 让 help、解析和 dispatch 共享同一份事实源
244
+
245
+ 它不负责:
246
+
247
+ - 具体文件读写
248
+ - prompt 交互细节
249
+ - human output 渲染
250
+
251
+ ### 4.3 `src/interaction/`
252
+
253
+ 这一层是 `0.0.6` 中显式抽出的交互层,负责所有 CLI 级 prompt 组合逻辑。
254
+
255
+ 它承担的职责是:
256
+
257
+ - 判断哪些路径允许交互
258
+ - 组合 provider 选择、确认、rollback 预览等交互动作
259
+ - 组织 add/edit/setup 中的渐进式输入收集
260
+
261
+ 它不负责:
262
+
263
+ - 业务状态变更
264
+ - 文件系统写入
265
+ - 运行时探测
266
+
267
+ `setup` 是这一层边界最强的命令之一。在 `0.0.6` 中,它的 adopt profile 选择和 provider 详情输入仍然是交互式 contract,因此非交互路径会显式失败,而不是隐式进入空输入分支。
268
+
269
+ ### 4.4 `src/storage/`
270
+
271
+ 这一层是 `0.0.6` 的文件和状态访问层,负责把以前分散在 `infra/` 的能力收口成稳定存储边界。
272
+
273
+ 它承担的职责是:
274
+
275
+ - `config.toml` / `providers.json` / backup manifest / lock file 的读写
276
+ - Codex home 目录路径展开
277
+ - 原子写入、备份、回滚、锁定
278
+
279
+ `src/infra/` 在当前版本主要保留兼容 re-export,以便逐步迁移,不再作为新的业务入口继续扩张。
280
+
281
+ ### 4.5 `src/runtime/`
282
+
283
+ 这一层是 `0.0.6` 新增的运行时边界,负责本地 Codex CLI 的外部依赖探测和登录调用。
284
+
285
+ 它承担的职责是:
286
+
287
+ - Codex 可用性检查
288
+ - Codex 版本检查
289
+ - Codex login 调用
290
+ - 未来可扩展为第三方 runtime adapter 的能力边界
291
+
292
+ ### 4.6 `src/cli/`
224
293
 
225
294
  #### `src/cli/args.ts`
226
295
 
@@ -272,7 +341,7 @@ scripts/
272
341
 
273
342
  这两个纯渲染入口的作用是让 CLI 层本身也能被测试,而不依赖真实子进程。
274
343
 
275
- ### 4.3 `src/app/`
344
+ ### 4.7 `src/app/`
276
345
 
277
346
  这一层是应用服务 / 用例编排层。每个文件基本对应一个命令或一个用例:
278
347
 
@@ -301,7 +370,7 @@ scripts/
301
370
  - `stdout` / `stderr` 怎么写
302
371
  - argv 怎么解析
303
372
 
304
- ### 4.4 `src/domain/`
373
+ ### 4.8 `src/domain/`
305
374
 
306
375
  #### `errors.ts`
307
376
 
@@ -463,7 +532,7 @@ scripts/
463
532
  - 用于 `codex login --with-api-key`
464
533
  - `baseUrl`
465
534
  - 选填
466
- - 当前版本只存储,不回写 `config.toml`
535
+ - 当前版本只存储在 `providers.json`;`config show` 中展示的 runtime `baseUrl` 由 `model_provider -> model_providers.*.base_url` 解析
467
536
  - `note`
468
537
  - 选填
469
538
  - 面向人类和 AI 的说明字段
@@ -0,0 +1,163 @@
1
+ # Test Report: 0.0.5
2
+
3
+ Date: 2026-05-13
4
+
5
+ ## Environment
6
+
7
+ - Platform: Windows (`win32`)
8
+ - Node.js: `v24.11.1`
9
+ - npm: `11.13.0`
10
+ - Workspace: `C:\Users\A200477427\Developers\Github\codex-switch`
11
+
12
+ ## Commands Run
13
+
14
+ ```bash
15
+ npm run build
16
+ npm test
17
+ ```
18
+
19
+ ## Overall Result
20
+
21
+ - Build: PASS
22
+ - Test suites: 5/5 PASS
23
+
24
+ Suite results:
25
+
26
+ - `domain`: PASS
27
+ - `app`: PASS
28
+ - `cli`: PASS
29
+ - `dev-sandbox`: PASS
30
+ - `e2e`: PASS
31
+
32
+ ## Coverage Added In This Pass
33
+
34
+ New test assets:
35
+
36
+ - `tests/dev-sandbox.spec.js`
37
+ - `tests/e2e.spec.js`
38
+ - `docs/testing.md`
39
+
40
+ Updated wiring:
41
+
42
+ - `tests/helpers.js`
43
+ - `tests/run-tests.js`
44
+
45
+ ## Detailed Results
46
+
47
+ ### 1. Domain Suite
48
+
49
+ Status: PASS
50
+
51
+ Focus:
52
+
53
+ - config patch planning
54
+ - managed profile view generation
55
+ - provider normalization and masking
56
+ - runtime drift helpers
57
+ - backup list helpers
58
+
59
+ ### 2. App Suite
60
+
61
+ Status: PASS
62
+
63
+ Focus:
64
+
65
+ - list/current/status
66
+ - add/edit/show/remove
67
+ - import/export
68
+ - switch/login/rollback
69
+ - setup
70
+ - doctor
71
+ - lock conflict and rollback behavior
72
+
73
+ ### 3. CLI Suite
74
+
75
+ Status: PASS
76
+
77
+ Focus:
78
+
79
+ - arg parsing
80
+ - help rendering
81
+ - JSON success/failure envelopes
82
+ - interactive add/edit/remove/import/export/rollback/setup flows
83
+ - config commands
84
+
85
+ ### 4. Dev Sandbox Suite
86
+
87
+ Status: PASS
88
+
89
+ Fixture:
90
+
91
+ - `dev-codex/local-sandbox`
92
+
93
+ Validated with the built CLI command dispatcher against the real development fixture:
94
+
95
+ - `list --json`
96
+ - `current --json`
97
+ - `status --json`
98
+ - `config show --json`
99
+ - `backups list --json`
100
+ - `doctor --json`
101
+
102
+ Observed state during test:
103
+
104
+ - active profile: `packycode`
105
+ - managed providers: `freemodel`, `packycode`
106
+ - status issues: `0`
107
+ - backups found: `>= 1`
108
+
109
+ ### 5. End-to-End Suite
110
+
111
+ Status: PASS
112
+
113
+ Fixture strategy:
114
+
115
+ - copy `dev-codex/local-sandbox` into a temp directory
116
+ - run write commands against the temp copy
117
+ - keep the repository fixture unchanged
118
+
119
+ Validated flows:
120
+
121
+ - `switch freemodel` updates active profile and refreshes `auth.json`
122
+ - `rollback` restores `config.toml` and `auth.json`
123
+ - `add` creates a provider in `providers.json`
124
+ - `edit` updates note and tags
125
+ - `remove --force` deletes a non-active provider
126
+ - `add --create-profile` creates a managed profile section in `config.toml` when a same-named `[model_providers.*]` runtime section already exists
127
+ - destructive removal of the active provider fails with `PROFILE_IN_USE`
128
+ - `import --merge` replaces overlapping providers and keeps merged state valid
129
+ - `export` writes a valid providers file
130
+ - `backups list` skips corrupt backup folders with warnings
131
+ - `rollback missing-backup` fails with `BACKUP_NOT_FOUND`
132
+ - corrupt `backups/latest.json` fails with `ROLLBACK_FAILED`
133
+ - `setup` adopt flow works through CLI dispatch with mocked Codex CLI availability
134
+
135
+ Validated mixed workflows:
136
+
137
+ - `add -> switch -> edit -> show -> config show -> export -> rollback`
138
+ - `import --merge -> switch --no-login -> remove -> doctor -> backups list -> rollback <backup-id>`
139
+
140
+ ## Release Confidence
141
+
142
+ Current confidence for `0.0.5`: medium-high.
143
+
144
+ Why:
145
+
146
+ - core read and write workflows now have automated coverage
147
+ - the development fixture is exercised directly by the built CLI
148
+ - backup/rollback behavior is covered by both existing and new tests
149
+
150
+ ## Residual Risks
151
+
152
+ - `setup` is not yet covered as a true subprocess end-to-end command because it depends on interactive adopt input and external `codex` availability
153
+ - `rollback-latest` still has no direct dedicated test case even though `rollback` coverage is strong
154
+ - `README.md` still shows version `0.0.4` in the documentation text and should be updated separately
155
+
156
+ ## Recommended Pre-Release Checklist
157
+
158
+ Before the next publish:
159
+
160
+ - run `npm test`
161
+ - run a manual smoke check of `node dist/cli.js --help`
162
+ - run one real local `switch --no-login` against a temp `--codex-dir`
163
+ - update user-facing docs if the package version changes
@@ -0,0 +1,118 @@
1
+ # Test Report: 0.0.7
2
+
3
+ Date: 2026-05-14
4
+
5
+ ## Environment
6
+
7
+ - Platform: Windows (`win32`)
8
+ - Workspace: `C:\Users\A200477427\Developers\Github\codex-switch`
9
+ - Node.js: `v24.11.1`
10
+ - npm: `11.13.0`
11
+
12
+ ## Scope
13
+
14
+ This report covers the current automated suite plus the new built-CLI entrypoint checks added in `tests/cli-e2e.spec.js`.
15
+
16
+ Chinese summary:
17
+
18
+ - `npm test` is not compile-only. It rebuilds `dist/` and then runs the full automated suite.
19
+ - `add` now has explicit built-CLI non-interactive regression coverage.
20
+ - `migrate` is verified in two ways: built CLI non-interactive failure contract, plus injected interactive workflow coverage.
21
+ - `setup` is verified as deprecated and must fail with `COMMAND_DEPRECATED`.
22
+
23
+ ## Commands Run
24
+
25
+ ```bash
26
+ npx tsc --noEmit
27
+ npm test
28
+ ```
29
+
30
+ ## Overall Result
31
+
32
+ - TypeScript check: PASS
33
+ - Build and suites: PASS
34
+ - Full suite total: `39 passed, 0 failed`
35
+
36
+ Suite results:
37
+
38
+ - `commands`: PASS (`10/10`)
39
+ - `cli-e2e`: PASS (`7/7`)
40
+ - `interaction`: PASS (`8/8`)
41
+ - `runtime`: PASS (`2/2`)
42
+ - `workflows`: PASS (`12/12`)
43
+
44
+ ## Built CLI Command Matrix
45
+
46
+ Read commands covered through the built CLI entrypoint:
47
+
48
+ - `--help`
49
+ - `--version`
50
+ - `list --json`
51
+ - `show --json`
52
+ - `current --json`
53
+ - `status --json`
54
+ - `config show --json`
55
+ - `config list-profiles --json`
56
+ - `backups list --json`
57
+ - `doctor --json`
58
+
59
+ Write commands covered through the built CLI entrypoint on temp copies:
60
+
61
+ - `init --json`
62
+ - `add --json`
63
+ - `add --create-profile --json`
64
+ - `edit --json`
65
+ - `switch --json`
66
+ - `remove --force --json`
67
+ - `import --json`
68
+ - `export --force --json`
69
+ - `rollback --json`
70
+
71
+ Negative contract checks through the built CLI entrypoint:
72
+
73
+ - `add` against a missing profile without `--create-profile`
74
+ - removing the active provider profile
75
+ - `rollback <missing-id>`
76
+ - `migrate --overwrite --json`
77
+ - `setup --json`
78
+
79
+ ## Key Findings
80
+
81
+ ### 1. `npm test` behavior
82
+
83
+ `npm test` rebuilds the project first and then executes the JavaScript test harness in `tests/run-tests.js`. It is not a compile-only command.
84
+
85
+ ### 2. `add`
86
+
87
+ Validated behaviors:
88
+
89
+ - succeeds non-interactively when all required flags are provided
90
+ - creates `providers.json` entries with derived `envKey`
91
+ - supports `--create-profile` to add missing profile and model provider sections
92
+ - fails with `PROFILE_NOT_FOUND` when targeting a missing profile without `--create-profile`
93
+
94
+ ### 3. `migrate`
95
+
96
+ Validated behaviors:
97
+
98
+ - built CLI non-interactive path currently fails by design with `INVALID_ARGUMENT`
99
+ - error payload includes adoptable profile metadata and a suggestion to run in an interactive TTY
100
+ - interactive adopt flow remains covered in `tests/workflows.spec.js` through runtime injection
101
+
102
+ This means the current implementation does not support a full non-interactive `migrate` workflow yet. The new tests lock that behavior in as an explicit contract instead of silently leaving it unverified.
103
+
104
+ ### 4. Repository sandbox observations
105
+
106
+ Observed from the checked-in `dev-codex/local-sandbox` fixture during this run:
107
+
108
+ - active profile: `freemodel`
109
+ - managed providers in `list --json`: `alpha`, `bestmodel`, `beta`, `freemodel`
110
+ - `doctor --json` returns `healthy: false` in this automation environment because runtime probing reports `CODEX_NOT_INSTALLED`
111
+ - the `doctor` issue is environmental, not a providers/config parse failure
112
+
113
+ ## Residual Risks
114
+
115
+ - prompt-driven subprocess automation for true interactive `migrate` is still not covered end-to-end
116
+ - Windows sandbox restrictions currently block nested `child_process` launches with `EPERM`, so automated command checks run through the built CLI entrypoint in-process instead of spawning `node dist/cli.js`
117
+ - `rollback-latest` still lacks a dedicated direct test
118
+ - backup corruption coverage is still focused on selected cases rather than an exhaustive matrix