@minniexcode/codex-switch 0.0.12 → 0.1.1

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 (36) hide show
  1. package/README.AI.md +37 -6
  2. package/README.CN.md +45 -11
  3. package/README.md +45 -13
  4. package/dist/app/add-provider.js +22 -24
  5. package/dist/app/edit-provider.js +34 -55
  6. package/dist/app/get-current-profile.js +15 -3
  7. package/dist/app/get-status.js +11 -8
  8. package/dist/app/list-config-profiles.js +3 -1
  9. package/dist/app/list-providers.js +10 -4
  10. package/dist/app/remove-provider.js +52 -19
  11. package/dist/app/run-doctor.js +29 -28
  12. package/dist/app/setup-codex.js +3 -3
  13. package/dist/app/show-config.js +3 -1
  14. package/dist/app/switch-provider.js +36 -5
  15. package/dist/cli/output.js +36 -18
  16. package/dist/commands/handlers.js +2 -2
  17. package/dist/commands/help.js +3 -3
  18. package/dist/commands/registry.js +35 -30
  19. package/dist/domain/config.js +250 -185
  20. package/dist/domain/providers.js +23 -0
  21. package/dist/domain/runtime-state.js +15 -15
  22. package/dist/domain/setup.js +3 -1
  23. package/dist/interaction/interactive.js +2 -2
  24. package/dist/runtime/codex-version.js +7 -0
  25. package/dist/storage/config-repo.js +6 -14
  26. package/docs/Design/codex-switch-v0.1.0-design.md +152 -0
  27. package/docs/Design/codex-switch-v0.1.1-design.md +33 -0
  28. package/docs/PRD/codex-switch-prd-v0.1.0.md +217 -205
  29. package/docs/Reference/codex-config-reference.md +41 -0
  30. package/docs/Reference/codex-config-reference.zh-CN.md +41 -0
  31. package/docs/Tests/testing.md +31 -78
  32. package/docs/cli-usage.md +86 -27
  33. package/docs/codex-switch-command-design.md +649 -649
  34. package/docs/codex-switch-product-overview.md +81 -80
  35. package/docs/codex-switch-technical-architecture.md +1115 -1115
  36. package/package.json +51 -51
package/docs/cli-usage.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # codex-switch CLI Usage
2
2
 
3
- This document describes the current CLI contract for `@minniexcode/codex-switch` at version `0.0.12`.
3
+ This document describes the current CLI contract for `@minniexcode/codex-switch` at version `0.1.1`.
4
4
 
5
5
  Executable command name:
6
6
 
@@ -10,9 +10,9 @@ codexs
10
10
 
11
11
  ## 1. Version Context
12
12
 
13
- The current package version in this repository is `0.0.12`.
13
+ The current package version in this repository is `0.1.1`.
14
14
 
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.
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
16
 
17
17
  ## 2. Primary Workflows
18
18
 
@@ -20,7 +20,7 @@ This is still a development-version release. The command surface already exists,
20
20
 
21
21
  ```bash
22
22
  codexs init
23
- codexs add <provider> --profile <name> --api-key <key>
23
+ codexs add <provider> --model <model> --api-key <key> [--base-url <url>]
24
24
  codexs switch <provider>
25
25
  codexs status
26
26
  codexs doctor
@@ -29,7 +29,7 @@ codexs doctor
29
29
  Intent:
30
30
 
31
31
  - `init` prepares the `codex-switch` tool home.
32
- - `add` creates a managed provider record.
32
+ - `add` creates a managed provider record with a target model and provider route identity.
33
33
  - `switch` projects the selected provider into the target Codex runtime.
34
34
  - `status` summarizes tool-home, runtime, provider, and health state.
35
35
  - `doctor` gives deeper repair-oriented diagnostics.
@@ -39,7 +39,7 @@ Intent:
39
39
  ```bash
40
40
  codexs init
41
41
  codexs login copilot
42
- codexs add <provider> --copilot --profile <name>
42
+ codexs add <provider> --copilot --model <model>
43
43
  codexs switch <provider>
44
44
  codexs status
45
45
  codexs doctor
@@ -52,7 +52,56 @@ Important notes:
52
52
  - `login copilot` succeeds only after auth readiness is rechecked.
53
53
  - `add --copilot` does not install or log in to Copilot for you.
54
54
 
55
- ## 3. Advanced Adopt Workflow
55
+ ## 3. Runtime Route Contract
56
+
57
+ For Codex `0.134.0+`, the active runtime route is selected through top-level `model` and `model_provider` in `config.toml`.
58
+
59
+ `codex-switch` writes that route as its primary runtime projection:
60
+
61
+ - top-level `model`
62
+ - top-level `model_provider`
63
+ - `[model_providers.<id>]`
64
+ - `auth.json` when direct auth projection is required
65
+
66
+ Managed provider projection intentionally avoids these legacy fields:
67
+
68
+ - `model_providers.<id>.env_key`
69
+ - `model_providers.<id>.env_key_instructions`
70
+
71
+ Managed provider projection fixes these fields for OpenAI-compatible direct routes:
72
+
73
+ - `wire_api = "responses"`
74
+ - `requires_openai_auth = true`
75
+
76
+ Compatibility notes:
77
+
78
+ - `--profile` is accepted as an alias for the managed `model_provider` id.
79
+ - legacy top-level `profile` and `[profiles.*]` may still appear in existing runtime state
80
+ - `migrate`, `config show`, `config list-profiles`, and `doctor` can still inspect those legacy structures
81
+ - new managed runtime projection should be described as route-first, not profile-first
82
+
83
+ Example managed direct-provider projection:
84
+
85
+ ```toml
86
+ model = "gpt-5.5"
87
+ model_provider = "proxy"
88
+
89
+ [model_providers.proxy]
90
+ name = "proxy"
91
+ base_url = "https://proxy.example.com/v1"
92
+ wire_api = "responses"
93
+ requires_openai_auth = true
94
+ ```
95
+
96
+ Authentication projection for the direct path remains:
97
+
98
+ ```json
99
+ {
100
+ "OPENAI_API_KEY": "sk-xxx"
101
+ }
102
+ ```
103
+
104
+ ## 4. Advanced Adopt Workflow
56
105
 
57
106
  Use `migrate` only when you already have Codex runtime state that should be adopted into managed `providers.json` state.
58
107
 
@@ -65,12 +114,12 @@ codexs migrate
65
114
 
66
115
  Current behavior:
67
116
 
68
- - It reads `config.toml` profiles from the target Codex runtime.
117
+ - It can inspect legacy runtime `profile` and `[profiles.*]` state from the target Codex runtime.
69
118
  - It can collect missing provider details in TTY mode.
70
119
  - It can merge into or overwrite existing managed provider state.
71
120
  - It still fails fast in non-TTY and `--json` runs when interactive input would be required.
72
121
 
73
- ## 4. Deprecated Entry
122
+ ## 5. Deprecated Entry
74
123
 
75
124
  ```bash
76
125
  codexs setup
@@ -78,9 +127,9 @@ codexs setup
78
127
 
79
128
  `setup` is deprecated. It is kept only to direct callers toward `init` or `migrate`, and it no longer performs initialization or migration work.
80
129
 
81
- ## 5. Global Contract
130
+ ## 6. Global Contract
82
131
 
83
- ### 5.1 Global Flags
132
+ ### 6.1 Global Flags
84
133
 
85
134
  ```bash
86
135
  --json
@@ -89,14 +138,14 @@ codexs setup
89
138
  --version
90
139
  ```
91
140
 
92
- ### 5.2 Environment Variables
141
+ ### 6.2 Environment Variables
93
142
 
94
143
  ```bash
95
144
  CODEXS_HOME
96
145
  CODEXS_CODEX_DIR
97
146
  ```
98
147
 
99
- ### 5.3 Runtime Model
148
+ ### 6.3 Runtime Model
100
149
 
101
150
  Tool home:
102
151
 
@@ -124,7 +173,7 @@ Meaning:
124
173
  - `config.toml` remains the active runtime routing file.
125
174
  - `auth.json` remains the active auth projection file.
126
175
 
127
- ## 6. Command Categories
176
+ ## 7. Command Categories
128
177
 
129
178
  Read commands:
130
179
 
@@ -157,7 +206,7 @@ codexs bridge stop [provider]
157
206
  codexs rollback [backup-id]
158
207
  ```
159
208
 
160
- ## 7. Selected Command Semantics
209
+ ## 8. Selected Command Semantics
161
210
 
162
211
  ### `init`
163
212
 
@@ -175,38 +224,47 @@ codexs rollback [backup-id]
175
224
  ### `status`
176
225
 
177
226
  - Reports the target Codex runtime and the tool-home root.
178
- - Reports the current profile and whether it maps to a managed provider.
227
+ - Reports the active model and active `model_provider` route.
228
+ - Can still surface legacy profile-derived observations when inspecting older runtime state.
179
229
  - Adds bridge, Copilot SDK, and upstream auth signals when the active provider uses a local runtime bridge.
180
230
  - Does not mutate any files.
181
231
 
182
232
  ### `list`
183
233
 
184
- - Lists managed providers together with their linked profile.
234
+ - Lists managed providers together with their linked route identity.
185
235
  - Distinguishes provider type using the public values `direct` and `copilot`.
186
236
  - 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.
237
+ - When the active route is shared by multiple providers, it does not invent a single current provider and should instead surface the ambiguity.
238
+ - TTY provider pickers used by commands such as `switch` and `show` follow the same visibility rules for route, provider type, and current-state hints.
189
239
 
190
240
  ### `doctor`
191
241
 
192
- - Checks expected config files, provider/profile consistency, and Codex CLI availability.
242
+ - Checks expected config files, managed-provider consistency, and Codex CLI availability.
243
+ - Inspects both route-first runtime state and legacy profile state when needed.
193
244
  - Adds bridge and Copilot dependency diagnostics for Copilot-backed providers.
194
245
  - Returns repair-oriented issues intended for both human users and AI agents.
195
246
 
196
247
  ### `switch`
197
248
 
198
- - Direct providers rewrite `auth.json` as an API-key projection and update the active runtime profile.
249
+ - Projects direct providers by rewriting top-level `model`, top-level `model_provider`, the managed `[model_providers.<id>]` block, and `auth.json`.
250
+ - Cleans legacy projected `env_key` and `env_key_instructions` fields before writing the managed provider route.
199
251
  - Copilot bridge providers also project the local bridge secret into the runtime while managing bridge routing.
200
252
  - 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`.
253
+ - 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`.
254
+
255
+ ### `add` and `edit`
256
+
257
+ - Create or update managed provider records rather than editing runtime files directly.
258
+ - Treat `--profile` only as an alias for the managed `model_provider` id.
259
+ - Clean old `env_key` and `env_key_instructions` fields from managed projection during subsequent switching.
202
260
 
203
261
  ### `migrate`
204
262
 
205
- - Adopts unmanaged runtime profiles into managed `providers.json` state.
206
- - Still relies on interactive profile selection and provider-detail collection in this release.
263
+ - Adopts unmanaged runtime route or legacy profile state into managed `providers.json` state.
264
+ - Still relies on interactive route/profile selection and provider-detail collection in this release.
207
265
  - Should be treated as an advanced adopt tool, not as the normal onboarding path.
208
266
 
209
- ## 8. Automation Boundaries
267
+ ## 9. Automation Boundaries
210
268
 
211
269
  - Progressive prompts run only in a real TTY and never under `--json`.
212
270
  - Human write commands may prompt for missing inputs or dangerous-action confirmation.
@@ -214,10 +272,11 @@ codexs rollback [backup-id]
214
272
  - `login copilot` is TTY-only.
215
273
  - `migrate` is not yet a complete non-interactive workflow.
216
274
 
217
- ## 9. Related Docs
275
+ ## 10. Related Docs
218
276
 
219
277
  - [README](../README.md)
220
278
  - [Chinese README](../README.CN.md)
221
279
  - [AI README](../README.AI.md)
222
280
  - [Product Overview](./codex-switch-product-overview.md)
223
- - [PRD 0.0.12](./PRD/codex-switch-prd-v0.0.12.md)
281
+ - [Release PRD 0.1.1](./PRD/codex-switch-prd-v0.1.1.md)
282
+ - [Release Design 0.1.1](./Design/codex-switch-v0.1.1-design.md)