@minniexcode/codex-switch 0.1.0 → 0.1.2
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 +141 -110
- package/README.CN.md +215 -179
- package/README.md +224 -183
- package/dist/app/add-provider.js +16 -23
- package/dist/app/bridge.js +2 -1
- package/dist/app/edit-provider.js +30 -65
- package/dist/app/get-current-profile.js +15 -3
- package/dist/app/get-status.js +11 -8
- package/dist/app/list-config-profiles.js +3 -1
- package/dist/app/list-providers.js +10 -4
- package/dist/app/remove-provider.js +52 -19
- package/dist/app/run-doctor.js +26 -29
- package/dist/app/setup-codex.js +3 -3
- package/dist/app/show-config.js +3 -1
- package/dist/app/switch-provider.js +38 -6
- package/dist/cli/output.js +29 -19
- package/dist/commands/handlers.js +3 -2
- package/dist/commands/help.js +3 -3
- package/dist/commands/registry.js +29 -29
- package/dist/domain/config.js +293 -209
- package/dist/domain/providers.js +8 -0
- package/dist/domain/runtime-state.js +15 -15
- package/dist/domain/setup.js +3 -1
- package/dist/interaction/interactive.js +2 -2
- package/dist/runtime/codex-version.js +7 -0
- package/dist/runtime/copilot-adapter.js +326 -70
- package/dist/runtime/copilot-bridge-worker.js +27 -2
- package/dist/runtime/copilot-bridge.js +192 -10
- package/dist/runtime/copilot-cli.js +7 -0
- package/dist/runtime/copilot-installer.js +59 -1
- package/dist/runtime/copilot-sdk-loader.js +4 -1
- package/dist/storage/config-repo.js +6 -14
- package/docs/Design/codex-switch-v0.1.0-design.md +32 -152
- package/docs/Design/codex-switch-v0.1.1-design.md +22 -0
- package/docs/Design/codex-switch-v0.1.2-design.md +65 -0
- package/docs/PRD/codex-switch-prd-v0.1.0.md +65 -217
- package/docs/PRD/codex-switch-prd-v0.1.1.md +26 -0
- package/docs/PRD/codex-switch-prd-v0.1.2.md +41 -0
- package/docs/Reference/codex-config-reference.md +41 -0
- package/docs/Reference/codex-config-reference.zh-CN.md +41 -0
- package/docs/Tests/testing.md +1 -1
- package/docs/cli-usage.md +290 -223
- package/docs/codex-switch-command-design.md +2 -2
- package/docs/codex-switch-product-overview.md +18 -13
- package/docs/codex-switch-product-research.md +2 -2
- package/docs/codex-switch-technical-architecture.md +84 -1115
- package/package.json +2 -2
- package/docs/Design/codex-switch-copilot-integration-design.md +0 -517
- package/docs/Design/codex-switch-v0.0.10-design.md +0 -669
- package/docs/Design/codex-switch-v0.0.11-design.md +0 -824
- package/docs/Design/codex-switch-v0.0.12-design.md +0 -343
- package/docs/Design/codex-switch-v0.0.4-design.md +0 -874
- package/docs/Design/codex-switch-v0.0.5-design.md +0 -932
- package/docs/Design/codex-switch-v0.0.6-design.md +0 -708
- package/docs/Design/codex-switch-v0.0.7-design.md +0 -862
- package/docs/Design/codex-switch-v0.0.8-design.md +0 -132
- package/docs/Design/codex-switch-v0.0.9-design.md +0 -182
- package/docs/Design/codex-switch-v0.0.9-to-v0.0.12-roadmap.md +0 -413
- package/docs/PRD/codex-switch-prd-v0.0.10.md +0 -406
- package/docs/PRD/codex-switch-prd-v0.0.11.md +0 -577
- package/docs/PRD/codex-switch-prd-v0.0.12.md +0 -279
- package/docs/PRD/codex-switch-prd-v0.0.5-to-v0.1.0.md +0 -446
- package/docs/PRD/codex-switch-prd-v0.0.8.md +0 -62
- package/docs/PRD/codex-switch-prd-v0.0.9.md +0 -166
- package/docs/PRD/codex-switch-prd.md +0 -650
- package/docs/Tests/test-report-0.0.5.md +0 -163
- package/docs/Tests/test-report-0.0.7.md +0 -118
- package/docs/Tests/testing-bridge-v0.0.9.md +0 -367
|
@@ -137,6 +137,12 @@ model_reasoning_effort = "high"
|
|
|
137
137
|
approval_policy = "never"
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
+
Important `codex-switch` note:
|
|
141
|
+
|
|
142
|
+
- official Codex still supports profiles
|
|
143
|
+
- `codex-switch` `0.1.1` does not treat top-level `profile` as the recommended managed runtime selector
|
|
144
|
+
- in `codex-switch`, legacy `profile` and `[profiles.*]` are mainly inspect-and-adopt inputs for `migrate`, `doctor`, and `config` inspection flows
|
|
145
|
+
|
|
140
146
|
## 4. `config.toml` by topic
|
|
141
147
|
|
|
142
148
|
### 4.1 Model, reasoning, and response style
|
|
@@ -194,6 +200,8 @@ Core keys:
|
|
|
194
200
|
- `model_providers.<id>.env_http_headers`
|
|
195
201
|
- `model_providers.<id>.query_params`
|
|
196
202
|
- `model_providers.<id>.request_max_retries`
|
|
203
|
+
- `model_providers.<id>.wire_api`
|
|
204
|
+
- `model_providers.<id>.requires_openai_auth`
|
|
197
205
|
|
|
198
206
|
Authentication options for custom providers include:
|
|
199
207
|
|
|
@@ -214,6 +222,22 @@ Related Bedrock keys:
|
|
|
214
222
|
- `model_providers.amazon-bedrock.aws.profile`
|
|
215
223
|
- `model_providers.amazon-bedrock.aws.region`
|
|
216
224
|
|
|
225
|
+
#### `codex-switch` 0.1.1 managed projection
|
|
226
|
+
|
|
227
|
+
When `codex-switch` manages a direct OpenAI-compatible route for Codex `0.134.0+`, it intentionally projects a narrower runtime shape than the full official provider schema:
|
|
228
|
+
|
|
229
|
+
- top-level `model` is the active model selector
|
|
230
|
+
- top-level `model_provider` is the active route selector
|
|
231
|
+
- projected `[model_providers.<id>]` keeps `base_url`
|
|
232
|
+
- projected `[model_providers.<id>]` fixes `wire_api = "responses"`
|
|
233
|
+
- projected `[model_providers.<id>]` fixes `requires_openai_auth = true`
|
|
234
|
+
- projected runtime config does not keep `env_key`
|
|
235
|
+
- projected runtime config does not keep `env_key_instructions`
|
|
236
|
+
|
|
237
|
+
Authentication is projected through `auth.json` with `OPENAI_API_KEY`, not through `env_key` in the managed runtime config.
|
|
238
|
+
|
|
239
|
+
That is a `codex-switch` product decision, not a limitation of Codex itself. If you hand-write or independently manage Codex config, `env_key` remains a valid official mechanism.
|
|
240
|
+
|
|
217
241
|
### 4.3.1 `openai_base_url` vs custom providers
|
|
218
242
|
|
|
219
243
|
If you only want to point the built-in OpenAI provider to a proxy, router, or residency-specific endpoint, use:
|
|
@@ -539,6 +563,23 @@ env_key = "OPENAI_API_KEY"
|
|
|
539
563
|
http_headers = { "X-Team" = "platform" }
|
|
540
564
|
```
|
|
541
565
|
|
|
566
|
+
This is an official Codex-style custom provider example.
|
|
567
|
+
|
|
568
|
+
If you are using `codex-switch` managed direct-provider projection instead, the runtime projection is intentionally narrower:
|
|
569
|
+
|
|
570
|
+
```toml
|
|
571
|
+
model = "gpt-5.4"
|
|
572
|
+
model_provider = "proxy"
|
|
573
|
+
|
|
574
|
+
[model_providers.proxy]
|
|
575
|
+
name = "proxy"
|
|
576
|
+
base_url = "https://proxy.example.com/v1"
|
|
577
|
+
wire_api = "responses"
|
|
578
|
+
requires_openai_auth = true
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
In that managed projection, `OPENAI_API_KEY` is expected in `auth.json` rather than through `env_key` in `config.toml`.
|
|
582
|
+
|
|
542
583
|
### 6.4 Locked-down shell environment
|
|
543
584
|
|
|
544
585
|
```toml
|
|
@@ -149,6 +149,12 @@ model_reasoning_effort = "high"
|
|
|
149
149
|
approval_policy = "never"
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
+
对 `codex-switch` 0.1.1 的补充说明:
|
|
153
|
+
|
|
154
|
+
- 官方 Codex 仍然支持 profiles
|
|
155
|
+
- `codex-switch` 不再把顶层 `profile` 视为推荐的受管 runtime selector
|
|
156
|
+
- 在 `codex-switch` 里,legacy `profile` 和 `[profiles.*]` 主要用于 `migrate`、`doctor` 和 `config` 检视的 adopt / inspect 场景
|
|
157
|
+
|
|
152
158
|
## 4. `config.toml` 主题整理
|
|
153
159
|
|
|
154
160
|
### 4.1 模型、推理强度与输出风格
|
|
@@ -206,6 +212,8 @@ Codex 把“当前使用哪个 provider”和“provider 怎么定义”拆开
|
|
|
206
212
|
- `model_providers.<id>.env_http_headers`
|
|
207
213
|
- `model_providers.<id>.query_params`
|
|
208
214
|
- `model_providers.<id>.request_max_retries`
|
|
215
|
+
- `model_providers.<id>.wire_api`
|
|
216
|
+
- `model_providers.<id>.requires_openai_auth`
|
|
209
217
|
|
|
210
218
|
自定义 provider 的认证方式包括:
|
|
211
219
|
|
|
@@ -229,6 +237,22 @@ Bedrock 相关 key:
|
|
|
229
237
|
- `model_providers.amazon-bedrock.aws.profile`
|
|
230
238
|
- `model_providers.amazon-bedrock.aws.region`
|
|
231
239
|
|
|
240
|
+
#### `codex-switch` 0.1.1 的受管投影
|
|
241
|
+
|
|
242
|
+
当 `codex-switch` 为 Codex `0.134.0+` 管理一个 direct OpenAI-compatible route 时,它会有意把运行态投影限制在一组更窄的字段上:
|
|
243
|
+
|
|
244
|
+
- 顶层 `model` 是活动模型选择器
|
|
245
|
+
- 顶层 `model_provider` 是活动路由选择器
|
|
246
|
+
- 投影后的 `[model_providers.<id>]` 保留 `base_url`
|
|
247
|
+
- 投影后的 `[model_providers.<id>]` 固定写 `wire_api = "responses"`
|
|
248
|
+
- 投影后的 `[model_providers.<id>]` 固定写 `requires_openai_auth = true`
|
|
249
|
+
- 受管运行态投影不会保留 `env_key`
|
|
250
|
+
- 受管运行态投影不会保留 `env_key_instructions`
|
|
251
|
+
|
|
252
|
+
认证信息会通过 `auth.json` 里的 `OPENAI_API_KEY` 投影,而不是通过运行态 `config.toml` 中的 `env_key`。
|
|
253
|
+
|
|
254
|
+
这属于 `codex-switch` 的产品约束,不是 Codex 官方能力限制。如果你是手工维护或独立维护 Codex config,`env_key` 仍然是官方支持的方式。
|
|
255
|
+
|
|
232
256
|
### 4.3.1 `openai_base_url` 和自定义 provider 的区别
|
|
233
257
|
|
|
234
258
|
如果你只是想把内置 `openai` provider 指向公司网关、路由层或者某个数据驻留 endpoint,官方建议直接用:
|
|
@@ -568,6 +592,23 @@ env_key = "OPENAI_API_KEY"
|
|
|
568
592
|
http_headers = { "X-Team" = "platform" }
|
|
569
593
|
```
|
|
570
594
|
|
|
595
|
+
这段是官方 Codex 风格的自定义 provider 示例。
|
|
596
|
+
|
|
597
|
+
如果你走的是 `codex-switch` 的受管 direct-provider 投影,运行态会被有意收窄为:
|
|
598
|
+
|
|
599
|
+
```toml
|
|
600
|
+
model = "gpt-5.4"
|
|
601
|
+
model_provider = "proxy"
|
|
602
|
+
|
|
603
|
+
[model_providers.proxy]
|
|
604
|
+
name = "proxy"
|
|
605
|
+
base_url = "https://proxy.example.com/v1"
|
|
606
|
+
wire_api = "responses"
|
|
607
|
+
requires_openai_auth = true
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
在这种受管投影下,`OPENAI_API_KEY` 预期写在 `auth.json`,而不是通过 `config.toml` 里的 `env_key` 暴露。
|
|
611
|
+
|
|
571
612
|
### 6.4 最小暴露的 shell 环境策略
|
|
572
613
|
|
|
573
614
|
```toml
|
package/docs/Tests/testing.md
CHANGED
package/docs/cli-usage.md
CHANGED
|
@@ -1,223 +1,290 @@
|
|
|
1
|
-
# codex-switch CLI Usage
|
|
2
|
-
|
|
3
|
-
This document describes the current CLI contract for `@minniexcode/codex-switch
|
|
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.
|
|
14
|
-
|
|
15
|
-
This
|
|
16
|
-
|
|
17
|
-
## 2. Primary Workflows
|
|
18
|
-
|
|
19
|
-
### 2.1 Direct Providers
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
codexs init
|
|
23
|
-
codexs add <provider> --
|
|
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 --
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
# codex-switch CLI Usage
|
|
2
|
+
|
|
3
|
+
This document describes the current `0.1.2` CLI contract for `@minniexcode/codex-switch`, including the Copilot runtime repair boundary.
|
|
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.2`.
|
|
14
|
+
|
|
15
|
+
This release line targets Codex `0.134.0+`. The public contract assumes runtime routing is selected by top-level `model` plus `model_provider`, while legacy `profile` and `[profiles.*]` remain inspect-and-adopt inputs instead of the recommended runtime path.
|
|
16
|
+
|
|
17
|
+
## 2. Primary Workflows
|
|
18
|
+
|
|
19
|
+
### 2.1 Direct Providers
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
codexs init
|
|
23
|
+
codexs add <provider> --model <model> --api-key <key> [--base-url <url>]
|
|
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 with a target model and provider route identity.
|
|
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 --model <model>
|
|
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
|
+
- Copilot runtime paths require Node.js `>=20`; direct providers remain supported on Node.js `>=18`.
|
|
55
|
+
- The Copilot bridge is experimental and targets simple text-oriented turns through the local OpenAI-compatible bridge.
|
|
56
|
+
|
|
57
|
+
## 3. Runtime Route Contract
|
|
58
|
+
|
|
59
|
+
For Codex `0.134.0+`, the active runtime route is selected through top-level `model` and `model_provider` in `config.toml`.
|
|
60
|
+
|
|
61
|
+
`codex-switch` writes that route as its primary runtime projection:
|
|
62
|
+
|
|
63
|
+
- top-level `model`
|
|
64
|
+
- top-level `model_provider`
|
|
65
|
+
- `[model_providers.<id>]`
|
|
66
|
+
- `auth.json` when direct auth projection is required
|
|
67
|
+
|
|
68
|
+
Managed provider projection intentionally avoids these legacy fields:
|
|
69
|
+
|
|
70
|
+
- `model_providers.<id>.env_key`
|
|
71
|
+
- `model_providers.<id>.env_key_instructions`
|
|
72
|
+
|
|
73
|
+
Managed provider projection fixes these fields for OpenAI-compatible direct routes:
|
|
74
|
+
|
|
75
|
+
- `wire_api = "responses"`
|
|
76
|
+
- `requires_openai_auth = true`
|
|
77
|
+
|
|
78
|
+
Copilot bridge projection also writes:
|
|
79
|
+
|
|
80
|
+
- `stream_idle_timeout_ms = 300000`
|
|
81
|
+
|
|
82
|
+
Compatibility notes:
|
|
83
|
+
|
|
84
|
+
- `--profile` is accepted as an alias for the managed `model_provider` id.
|
|
85
|
+
- legacy top-level `profile` and `[profiles.*]` may still appear in existing runtime state
|
|
86
|
+
- `migrate`, `config show`, `config list-profiles`, and `doctor` can still inspect those legacy structures
|
|
87
|
+
- new managed runtime projection should be described as route-first, not profile-first
|
|
88
|
+
|
|
89
|
+
Example managed direct-provider projection:
|
|
90
|
+
|
|
91
|
+
```toml
|
|
92
|
+
model = "gpt-5.5"
|
|
93
|
+
model_provider = "proxy"
|
|
94
|
+
|
|
95
|
+
[model_providers.proxy]
|
|
96
|
+
name = "proxy"
|
|
97
|
+
base_url = "https://proxy.example.com/v1"
|
|
98
|
+
wire_api = "responses"
|
|
99
|
+
requires_openai_auth = true
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Authentication projection for the direct path remains:
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"OPENAI_API_KEY": "sk-xxx"
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 4. Advanced Adopt Workflow
|
|
111
|
+
|
|
112
|
+
Use `migrate` only when you already have Codex runtime state that should be adopted into managed `providers.json` state.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
codexs init
|
|
116
|
+
codexs migrate
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`migrate` is an advanced adopt helper. It is not the default first step for fresh installs.
|
|
120
|
+
|
|
121
|
+
Current behavior:
|
|
122
|
+
|
|
123
|
+
- It can inspect legacy runtime `profile` and `[profiles.*]` state from the target Codex runtime.
|
|
124
|
+
- It can collect missing provider details in TTY mode.
|
|
125
|
+
- It can merge into or overwrite existing managed provider state.
|
|
126
|
+
- It still fails fast in non-TTY and `--json` runs when interactive input would be required.
|
|
127
|
+
|
|
128
|
+
## 5. Deprecated Entry
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
codexs setup
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`setup` is deprecated. It is kept only to direct callers toward `init` or `migrate`, and it no longer performs initialization or migration work.
|
|
135
|
+
|
|
136
|
+
## 6. Global Contract
|
|
137
|
+
|
|
138
|
+
### 6.1 Global Flags
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
--json
|
|
142
|
+
--codex-dir <path>
|
|
143
|
+
--help
|
|
144
|
+
--version
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 6.2 Environment Variables
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
CODEXS_HOME
|
|
151
|
+
CODEXS_CODEX_DIR
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 6.3 Runtime Model
|
|
155
|
+
|
|
156
|
+
Tool home:
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
~/.config/codex-switch/
|
|
160
|
+
codex-switch.json
|
|
161
|
+
providers.json
|
|
162
|
+
backups/
|
|
163
|
+
runtime/
|
|
164
|
+
runtimes/
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Target Codex runtime:
|
|
168
|
+
|
|
169
|
+
```text
|
|
170
|
+
~/.codex/
|
|
171
|
+
config.toml
|
|
172
|
+
auth.json
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Meaning:
|
|
176
|
+
|
|
177
|
+
- `providers.json` is the managed provider registry.
|
|
178
|
+
- `codex-switch.json` stores tool-level metadata such as `defaultCodexDir`.
|
|
179
|
+
- `config.toml` remains the active runtime routing file.
|
|
180
|
+
- `auth.json` remains the active auth projection file.
|
|
181
|
+
|
|
182
|
+
## 7. Command Categories
|
|
183
|
+
|
|
184
|
+
Read commands:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
codexs list
|
|
188
|
+
codexs show <provider>
|
|
189
|
+
codexs current
|
|
190
|
+
codexs status
|
|
191
|
+
codexs config show [profile]
|
|
192
|
+
codexs config list-profiles
|
|
193
|
+
codexs bridge status [provider]
|
|
194
|
+
codexs backups list
|
|
195
|
+
codexs doctor
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Change commands:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
codexs init
|
|
202
|
+
codexs login copilot
|
|
203
|
+
codexs migrate
|
|
204
|
+
codexs add <provider>
|
|
205
|
+
codexs edit <provider>
|
|
206
|
+
codexs switch <provider>
|
|
207
|
+
codexs remove <provider>
|
|
208
|
+
codexs import <file>
|
|
209
|
+
codexs export <file>
|
|
210
|
+
codexs bridge start [provider]
|
|
211
|
+
codexs bridge stop [provider]
|
|
212
|
+
codexs rollback [backup-id]
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## 8. Selected Command Semantics
|
|
216
|
+
|
|
217
|
+
### `init`
|
|
218
|
+
|
|
219
|
+
- Creates `codex-switch.json` and `providers.json` under the tool home when they do not exist yet.
|
|
220
|
+
- Does not create or validate `config.toml`, `auth.json`, or the target Codex directory.
|
|
221
|
+
- When `--codex-dir` is passed explicitly during first-time initialization, it can persist `defaultCodexDir`.
|
|
222
|
+
|
|
223
|
+
### `login copilot`
|
|
224
|
+
|
|
225
|
+
- Supports `copilot` and `github-copilot` as the current upstream name.
|
|
226
|
+
- Installs the local Copilot SDK under the tool home when needed.
|
|
227
|
+
- Invokes the official Copilot CLI for login when readiness is not already present.
|
|
228
|
+
- Requires a real TTY and does not support `--json`.
|
|
229
|
+
|
|
230
|
+
### `status`
|
|
231
|
+
|
|
232
|
+
- Reports the target Codex runtime and the tool-home root.
|
|
233
|
+
- Reports the active model and active `model_provider` route.
|
|
234
|
+
- Can still surface legacy profile-derived observations when inspecting older runtime state.
|
|
235
|
+
- Adds bridge, Copilot SDK, and upstream auth signals when the active provider uses a local runtime bridge.
|
|
236
|
+
- Does not mutate any files.
|
|
237
|
+
|
|
238
|
+
### `list`
|
|
239
|
+
|
|
240
|
+
- Lists managed providers together with their linked route identity.
|
|
241
|
+
- Distinguishes provider type using the public values `direct` and `copilot`.
|
|
242
|
+
- Marks the current provider only when the active runtime can be mapped back to one unique managed provider.
|
|
243
|
+
- When the active route is shared by multiple providers, it does not invent a single current provider and should instead surface the ambiguity.
|
|
244
|
+
- TTY provider pickers used by commands such as `switch` and `show` follow the same visibility rules for route, provider type, and current-state hints.
|
|
245
|
+
|
|
246
|
+
### `doctor`
|
|
247
|
+
|
|
248
|
+
- Checks expected config files, managed-provider consistency, and Codex CLI availability.
|
|
249
|
+
- Inspects both route-first runtime state and legacy profile state when needed.
|
|
250
|
+
- Adds bridge and Copilot dependency diagnostics for Copilot-backed providers.
|
|
251
|
+
- Returns repair-oriented issues intended for both human users and AI agents.
|
|
252
|
+
|
|
253
|
+
### `switch`
|
|
254
|
+
|
|
255
|
+
- Projects direct providers by rewriting top-level `model`, top-level `model_provider`, the managed `[model_providers.<id>]` block, and `auth.json`.
|
|
256
|
+
- Cleans legacy projected `env_key` and `env_key_instructions` fields before writing the managed provider route.
|
|
257
|
+
- Copilot bridge providers also project the local bridge secret into the runtime while managing bridge routing.
|
|
258
|
+
- Managed writes are backed up and rolled back on failure.
|
|
259
|
+
- When `<provider>` is omitted in a TTY, the interactive provider selector should show route, provider type, and current-state hints using the same rules as `list`.
|
|
260
|
+
|
|
261
|
+
### `add` and `edit`
|
|
262
|
+
|
|
263
|
+
- Create or update managed provider records rather than editing runtime files directly.
|
|
264
|
+
- Treat `--profile` only as an alias for the managed `model_provider` id.
|
|
265
|
+
- Clean old `env_key` and `env_key_instructions` fields from managed projection during subsequent switching.
|
|
266
|
+
|
|
267
|
+
### `migrate`
|
|
268
|
+
|
|
269
|
+
- Adopts unmanaged runtime route or legacy profile state into managed `providers.json` state.
|
|
270
|
+
- Still relies on interactive route/profile selection and provider-detail collection in this release.
|
|
271
|
+
- Should be treated as an advanced adopt tool, not as the normal onboarding path.
|
|
272
|
+
|
|
273
|
+
## 9. Automation Boundaries
|
|
274
|
+
|
|
275
|
+
- Progressive prompts run only in a real TTY and never under `--json`.
|
|
276
|
+
- Human write commands may prompt for missing inputs or dangerous-action confirmation.
|
|
277
|
+
- Automation should pass explicit arguments and prefer `--json`.
|
|
278
|
+
- `login copilot` is TTY-only.
|
|
279
|
+
- `migrate` is not yet a complete non-interactive workflow.
|
|
280
|
+
|
|
281
|
+
## 10. Related Docs
|
|
282
|
+
|
|
283
|
+
- [README](../README.md)
|
|
284
|
+
- [Chinese README](../README.CN.md)
|
|
285
|
+
- [AI README](../README.AI.md)
|
|
286
|
+
- [Product Overview](./codex-switch-product-overview.md)
|
|
287
|
+
- [PRD 0.1.0](./PRD/codex-switch-prd-v0.1.0.md)
|
|
288
|
+
- [PRD 0.1.1](./PRD/codex-switch-prd-v0.1.1.md)
|
|
289
|
+
- [PRD 0.1.2](./PRD/codex-switch-prd-v0.1.2.md)
|
|
290
|
+
- [Design 0.1.2](./Design/codex-switch-v0.1.2-design.md)
|