@minniexcode/codex-switch 0.0.11 → 0.0.12
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 +56 -98
- package/README.CN.md +90 -126
- package/README.md +63 -97
- package/dist/app/get-status.js +8 -3
- package/dist/app/list-providers.js +48 -1
- package/dist/cli/output.js +145 -18
- package/dist/commands/handlers.js +10 -6
- package/dist/commands/help.js +9 -5
- package/dist/commands/registry.js +15 -12
- 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/PRD/codex-switch-prd-v0.0.12.md +279 -0
- package/docs/PRD/codex-switch-prd-v0.1.0.md +125 -237
- package/docs/Tests/testing.md +39 -112
- package/docs/cli-usage.md +138 -439
- package/docs/codex-switch-command-design.md +3 -0
- package/docs/codex-switch-product-overview.md +52 -207
- package/docs/codex-switch-technical-architecture.md +3 -0
- package/package.json +1 -1
- package/dist/app/rollback-latest.js +0 -26
package/docs/cli-usage.md
CHANGED
|
@@ -1,524 +1,223 @@
|
|
|
1
1
|
# codex-switch CLI Usage
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This document describes the current CLI contract for `@minniexcode/codex-switch` at version `0.0.12`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Executable command name:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
codexs
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
## 1.
|
|
11
|
+
## 1. Version Context
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
The current package version in this repository is `0.0.12`.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
- target Codex runtime:保存目标 Codex 的 `config.toml` 和 `auth.json`
|
|
15
|
+
This is still a development-version release. The command surface already exists, but this version mainly focuses on keeping workflow guidance, help text, and implementation behavior aligned.
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
## 2. Primary Workflows
|
|
19
18
|
|
|
20
|
-
1
|
|
21
|
-
2. 写入前先备份,异常时支持回滚
|
|
22
|
-
3. 同时兼容人类终端使用和脚本/Agent 自动化调用
|
|
23
|
-
4. 对 GitHub Copilot 这类交互式上游登录提供独立命令入口
|
|
24
|
-
|
|
25
|
-
tool home 默认路径:
|
|
26
|
-
|
|
27
|
-
```text
|
|
28
|
-
~/.config/codex-switch/
|
|
29
|
-
codex-switch.json
|
|
30
|
-
providers.json
|
|
31
|
-
backups/
|
|
32
|
-
runtime/
|
|
33
|
-
runtimes/
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
target Codex runtime 默认路径:
|
|
37
|
-
|
|
38
|
-
```text
|
|
39
|
-
~/.codex/
|
|
40
|
-
config.toml
|
|
41
|
-
auth.json
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## 2. 安装与入口
|
|
45
|
-
|
|
46
|
-
全局安装:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
npm install -g @minniexcode/codex-switch
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
临时执行:
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
npx @minniexcode/codex-switch --help
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
查看总帮助:
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
codexs --help
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
查看版本:
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
codexs --version
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## 3. 全局规则
|
|
71
|
-
|
|
72
|
-
### 3.1 全局参数
|
|
73
|
-
|
|
74
|
-
所有命令都支持以下全局参数:
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
--json
|
|
78
|
-
--codex-dir <path>
|
|
79
|
-
--help
|
|
80
|
-
--version
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
说明:
|
|
84
|
-
|
|
85
|
-
- `--json`:输出标准 JSON 结果,并禁用所有交互 prompt
|
|
86
|
-
- `--codex-dir <path>`:指定目标 Codex runtime 目录
|
|
87
|
-
- `--help`:查看命令帮助
|
|
88
|
-
- `--version`:输出当前 CLI 版本
|
|
89
|
-
|
|
90
|
-
### 3.2 环境变量
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
CODEXS_HOME
|
|
94
|
-
CODEXS_CODEX_DIR
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
说明:
|
|
98
|
-
|
|
99
|
-
- `CODEXS_HOME`:覆盖默认 tool home 目录
|
|
100
|
-
- `CODEXS_CODEX_DIR`:在未传 `--codex-dir` 时提供默认 Codex runtime 目录
|
|
101
|
-
|
|
102
|
-
### 3.3 交互规则
|
|
103
|
-
|
|
104
|
-
CLI 的交互行为遵循以下规则:
|
|
105
|
-
|
|
106
|
-
- 只有在真实 TTY 终端下才会出现 prompt
|
|
107
|
-
- 只要传入 `--json`,就绝不会出现 prompt
|
|
108
|
-
- 面向脚本或 CI 的调用应显式传参,并优先使用 `--json`
|
|
109
|
-
- 某些危险操作在交互模式下会确认,在非交互模式下则要求显式参数
|
|
110
|
-
- `login copilot` 必须在真实 TTY 中运行
|
|
111
|
-
- `migrate` 当前仍保留交互式 adopt 契约
|
|
112
|
-
|
|
113
|
-
### 3.4 备份与回滚
|
|
114
|
-
|
|
115
|
-
所有受管理的写操作都会先备份相关文件,再执行写入。
|
|
116
|
-
|
|
117
|
-
典型受影响命令包括:
|
|
118
|
-
|
|
119
|
-
- `migrate`
|
|
120
|
-
- `add`
|
|
121
|
-
- `edit`
|
|
122
|
-
- `switch`
|
|
123
|
-
- `bridge start`
|
|
124
|
-
- `remove`
|
|
125
|
-
- `import`
|
|
126
|
-
|
|
127
|
-
如果操作失败,命令内部会尽量自动回滚。你也可以稍后手动执行:
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
codexs rollback
|
|
131
|
-
codexs rollback <backup-id>
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## 4. 读取类命令
|
|
135
|
-
|
|
136
|
-
### 4.1 `list`
|
|
137
|
-
|
|
138
|
-
列出 `providers.json` 中的全部 provider。
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
codexs list [--json] [--codex-dir <path>]
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
### 4.2 `show`
|
|
145
|
-
|
|
146
|
-
查看单个 provider 的完整记录。
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
codexs show <provider> [--json] [--codex-dir <path>]
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
说明:
|
|
153
|
-
|
|
154
|
-
- 普通文本输出默认隐藏 `apiKey`
|
|
155
|
-
- `--json` 模式会返回完整 provider 数据
|
|
156
|
-
|
|
157
|
-
### 4.3 `current`
|
|
158
|
-
|
|
159
|
-
查看 `config.toml` 当前激活的顶层 profile。
|
|
19
|
+
### 2.1 Direct Providers
|
|
160
20
|
|
|
161
21
|
```bash
|
|
162
|
-
codexs
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
输出目标 Codex runtime 的快速状态摘要。
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
codexs status [--json] [--codex-dir <path>]
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
通常会覆盖这些信息:
|
|
174
|
-
|
|
175
|
-
- 关键文件是否存在
|
|
176
|
-
- 当前激活 profile 是什么
|
|
177
|
-
- 当前运行态是否能在受管理 provider 映射中找到
|
|
178
|
-
- Copilot SDK 是否已安装
|
|
179
|
-
- Copilot bridge runtime state 是否健康
|
|
180
|
-
|
|
181
|
-
### 4.5 `config show`
|
|
182
|
-
|
|
183
|
-
查看结构化 config profile 视图。
|
|
184
|
-
|
|
185
|
-
```bash
|
|
186
|
-
codexs config show [profile] [--json] [--codex-dir <path>]
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
说明:
|
|
190
|
-
|
|
191
|
-
- 不传 `[profile]` 时返回全部可识别 profile
|
|
192
|
-
- 可同时看到 managed、unmanaged 和 orphaned 引用
|
|
193
|
-
|
|
194
|
-
### 4.6 `config list-profiles`
|
|
195
|
-
|
|
196
|
-
列出可识别的 config profile 名称及其受管态提示。
|
|
197
|
-
|
|
198
|
-
```bash
|
|
199
|
-
codexs config list-profiles [--json] [--codex-dir <path>]
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### 4.7 `bridge status`
|
|
203
|
-
|
|
204
|
-
查看当前受管 Copilot bridge 的运行状态。
|
|
205
|
-
|
|
206
|
-
```bash
|
|
207
|
-
codexs bridge status [provider] [--json] [--codex-dir <path>]
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### 4.8 `backups list`
|
|
211
|
-
|
|
212
|
-
查看历史备份清单。
|
|
213
|
-
|
|
214
|
-
```bash
|
|
215
|
-
codexs backups list [--json] [--codex-dir <path>]
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
说明:
|
|
219
|
-
|
|
220
|
-
- 返回结果按 `createdAt` 倒序排列
|
|
221
|
-
- 损坏的备份 manifest 会被跳过,并给出 warning,不会导致整个命令失败
|
|
222
|
-
|
|
223
|
-
## 5. 变更类命令
|
|
224
|
-
|
|
225
|
-
### 5.1 `init`
|
|
226
|
-
|
|
227
|
-
初始化 codex-switch tool home 和 registry 文件。
|
|
228
|
-
|
|
229
|
-
```bash
|
|
230
|
-
codexs init [--json] [--codex-dir <path>]
|
|
22
|
+
codexs init
|
|
23
|
+
codexs add <provider> --profile <name> --api-key <key>
|
|
24
|
+
codexs switch <provider>
|
|
25
|
+
codexs status
|
|
26
|
+
codexs doctor
|
|
231
27
|
```
|
|
232
28
|
|
|
233
|
-
|
|
29
|
+
Intent:
|
|
234
30
|
|
|
235
|
-
-
|
|
236
|
-
-
|
|
237
|
-
- `
|
|
238
|
-
- `
|
|
239
|
-
-
|
|
240
|
-
- 成功结果围绕 tool home 返回,不再承诺旧的 `createdCodexDir`、`configExists`、`authExists` 等字段
|
|
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.
|
|
241
36
|
|
|
242
|
-
###
|
|
243
|
-
|
|
244
|
-
完成 GitHub Copilot 上游安装与登录就绪检查。
|
|
37
|
+
### 2.2 GitHub Copilot
|
|
245
38
|
|
|
246
39
|
```bash
|
|
40
|
+
codexs init
|
|
247
41
|
codexs login copilot
|
|
248
|
-
codexs
|
|
42
|
+
codexs add <provider> --copilot --profile <name>
|
|
43
|
+
codexs switch <provider>
|
|
44
|
+
codexs status
|
|
45
|
+
codexs doctor
|
|
249
46
|
```
|
|
250
47
|
|
|
251
|
-
|
|
48
|
+
Important notes:
|
|
252
49
|
|
|
253
|
-
-
|
|
254
|
-
-
|
|
255
|
-
-
|
|
256
|
-
-
|
|
257
|
-
- 登录状态是共享的;切换 GitHub 账号会影响所有 Copilot provider
|
|
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.
|
|
258
54
|
|
|
259
|
-
|
|
55
|
+
## 3. Advanced Adopt Workflow
|
|
260
56
|
|
|
261
|
-
|
|
57
|
+
Use `migrate` only when you already have Codex runtime state that should be adopted into managed `providers.json` state.
|
|
262
58
|
|
|
263
59
|
```bash
|
|
264
|
-
codexs
|
|
60
|
+
codexs init
|
|
61
|
+
codexs migrate
|
|
265
62
|
```
|
|
266
63
|
|
|
267
|
-
|
|
64
|
+
`migrate` is an advanced adopt helper. It is not the default first step for fresh installs.
|
|
268
65
|
|
|
269
|
-
|
|
270
|
-
- 仅 adopt 已具备 `model`、`model_provider` 且能解析到匹配 `base_url` 的 unmanaged profile
|
|
271
|
-
- 收集每个 profile 对应的 provider 记录
|
|
272
|
-
- 保持受管备份、锁和 post-run `doctor` 流程
|
|
273
|
-
- 非交互模式下,profile 选择和 provider 细节收集仍不会自动化展开
|
|
66
|
+
Current behavior:
|
|
274
67
|
|
|
275
|
-
|
|
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.
|
|
276
72
|
|
|
277
|
-
|
|
73
|
+
## 4. Deprecated Entry
|
|
278
74
|
|
|
279
75
|
```bash
|
|
280
76
|
codexs setup
|
|
281
77
|
```
|
|
282
78
|
|
|
283
|
-
|
|
79
|
+
`setup` is deprecated. It is kept only to direct callers toward `init` or `migrate`, and it no longer performs initialization or migration work.
|
|
284
80
|
|
|
285
|
-
|
|
81
|
+
## 5. Global Contract
|
|
286
82
|
|
|
287
|
-
|
|
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 的字段。
|
|
83
|
+
### 5.1 Global Flags
|
|
313
84
|
|
|
314
85
|
```bash
|
|
315
|
-
|
|
316
|
-
|
|
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>]
|
|
86
|
+
--json
|
|
87
|
+
--codex-dir <path>
|
|
88
|
+
--help
|
|
89
|
+
--version
|
|
360
90
|
```
|
|
361
91
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
- 不修改 `providers.json`
|
|
365
|
-
- 在没有运行中的受管 bridge 时保持幂等
|
|
366
|
-
|
|
367
|
-
### 5.10 `remove`
|
|
368
|
-
|
|
369
|
-
删除一个 provider 记录。
|
|
92
|
+
### 5.2 Environment Variables
|
|
370
93
|
|
|
371
94
|
```bash
|
|
372
|
-
|
|
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>]
|
|
95
|
+
CODEXS_HOME
|
|
96
|
+
CODEXS_CODEX_DIR
|
|
387
97
|
```
|
|
388
98
|
|
|
389
|
-
### 5.
|
|
99
|
+
### 5.3 Runtime Model
|
|
390
100
|
|
|
391
|
-
|
|
101
|
+
Tool home:
|
|
392
102
|
|
|
393
|
-
```
|
|
394
|
-
|
|
103
|
+
```text
|
|
104
|
+
~/.config/codex-switch/
|
|
105
|
+
codex-switch.json
|
|
106
|
+
providers.json
|
|
107
|
+
backups/
|
|
108
|
+
runtime/
|
|
109
|
+
runtimes/
|
|
395
110
|
```
|
|
396
111
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
- 目标文件已存在时,非交互模式下必须显式传 `--force`
|
|
400
|
-
|
|
401
|
-
## 6. 诊断与恢复
|
|
112
|
+
Target Codex runtime:
|
|
402
113
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
```bash
|
|
408
|
-
codexs doctor [--json] [--codex-dir <path>]
|
|
114
|
+
```text
|
|
115
|
+
~/.codex/
|
|
116
|
+
config.toml
|
|
117
|
+
auth.json
|
|
409
118
|
```
|
|
410
119
|
|
|
411
|
-
|
|
120
|
+
Meaning:
|
|
412
121
|
|
|
413
|
-
-
|
|
414
|
-
-
|
|
415
|
-
-
|
|
416
|
-
-
|
|
417
|
-
- Copilot SDK、登录状态和 bridge runtime 是否健康
|
|
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.
|
|
418
126
|
|
|
419
|
-
|
|
127
|
+
## 6. Command Categories
|
|
420
128
|
|
|
421
|
-
|
|
129
|
+
Read commands:
|
|
422
130
|
|
|
423
131
|
```bash
|
|
424
|
-
codexs
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
codexs
|
|
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
|
|
433
141
|
```
|
|
434
142
|
|
|
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 配置
|
|
143
|
+
Change commands:
|
|
446
144
|
|
|
447
145
|
```bash
|
|
448
146
|
codexs init
|
|
147
|
+
codexs login copilot
|
|
449
148
|
codexs migrate
|
|
450
|
-
codexs
|
|
451
|
-
codexs
|
|
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]
|
|
452
158
|
```
|
|
453
159
|
|
|
454
|
-
|
|
160
|
+
## 7. Selected Command Semantics
|
|
455
161
|
|
|
456
|
-
|
|
457
|
-
codexs add my-provider --profile my-provider --api-key sk-xxx
|
|
458
|
-
codexs switch my-provider
|
|
459
|
-
codexs current
|
|
460
|
-
```
|
|
162
|
+
### `init`
|
|
461
163
|
|
|
462
|
-
|
|
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`.
|
|
463
167
|
|
|
464
|
-
|
|
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
|
-
```
|
|
168
|
+
### `login copilot`
|
|
470
169
|
|
|
471
|
-
|
|
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`.
|
|
472
174
|
|
|
473
|
-
|
|
474
|
-
codexs config list-profiles
|
|
475
|
-
codexs config show
|
|
476
|
-
```
|
|
175
|
+
### `status`
|
|
477
176
|
|
|
478
|
-
|
|
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.
|
|
479
181
|
|
|
480
|
-
|
|
481
|
-
codexs backups list
|
|
482
|
-
codexs rollback
|
|
483
|
-
```
|
|
182
|
+
### `list`
|
|
484
183
|
|
|
485
|
-
|
|
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.
|
|
486
189
|
|
|
487
|
-
|
|
190
|
+
### `doctor`
|
|
488
191
|
|
|
489
|
-
-
|
|
490
|
-
-
|
|
491
|
-
-
|
|
492
|
-
- `edit`
|
|
493
|
-
- `switch`
|
|
494
|
-
- `bridge start`
|
|
495
|
-
- `remove`
|
|
496
|
-
- `import`
|
|
497
|
-
- `export`(目标文件已存在时)
|
|
498
|
-
- `rollback`
|
|
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.
|
|
499
195
|
|
|
500
|
-
|
|
196
|
+
### `switch`
|
|
501
197
|
|
|
502
|
-
-
|
|
503
|
-
-
|
|
504
|
-
-
|
|
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`.
|
|
505
202
|
|
|
506
|
-
|
|
203
|
+
### `migrate`
|
|
507
204
|
|
|
508
|
-
|
|
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.
|
|
509
208
|
|
|
510
|
-
|
|
511
|
-
codexs --help
|
|
512
|
-
```
|
|
209
|
+
## 8. Automation Boundaries
|
|
513
210
|
|
|
514
|
-
|
|
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.
|
|
515
216
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
codexs help rollback
|
|
524
|
-
```
|
|
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
|
+
- [PRD 0.0.12](./PRD/codex-switch-prd-v0.0.12.md)
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# codex-switch 命令设计说明
|
|
2
2
|
|
|
3
|
+
> 状态说明:这份文档是历史跨版本参考,不是当前 release contract。
|
|
4
|
+
> 当前事实源请改看 [`docs/cli-usage.md`](./cli-usage.md)、[`docs/PRD/codex-switch-prd-v0.0.12.md`](./PRD/codex-switch-prd-v0.0.12.md)、[`docs/Design/codex-switch-v0.0.12-design.md`](./Design/codex-switch-v0.0.12-design.md)。
|
|
5
|
+
|
|
3
6
|
## 文档信息
|
|
4
7
|
|
|
5
8
|
- 文档类型:命令设计文档
|