@minniexcode/codex-switch 0.0.12 → 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.
@@ -1,78 +1,31 @@
1
- # Testing Guide
2
-
3
- Version under test: `0.0.12`
4
-
5
- 这份文档同时是测试说明和 beta release checklist。
6
-
7
- ## Active Suites
8
-
9
- - `tests/commands.spec.js`: argument parsing, help rendering, and command registry contract
10
- - `tests/cli-e2e.spec.js`: built CLI help/version plus human-readable and JSON output behavior
11
- - `tests/interaction.spec.js`: prompt boundaries
12
- - `tests/runtime.spec.js`: runtime probing behavior
13
- - `tests/workflows.spec.js`: file-backed mutation and rollback behavior
14
-
15
- ## Required Commands
16
-
17
- ```bash
18
- npm run build
19
- npm test
20
- npx tsc --noEmit
21
- npm pack --dry-run
22
- ```
23
-
24
- ## Release Checklist
25
-
26
- Read checks:
27
-
28
- - built CLI `--help`
29
- - built CLI `--version`
30
- - `list --json`
31
- - `status --json`
32
- - `doctor --json`
33
-
34
- Primary workflow checks:
35
-
36
- - fresh tool home direct path
37
- - fresh tool home Copilot path
38
- - read commands in `--json`
39
- - write commands in sandbox
40
-
41
- Specific `0.0.12` checks:
42
-
43
- - top-level help shows direct primary workflow before `migrate`
44
- - `migrate` is clearly presented as advanced adopt
45
- - `setup` remains deprecation-only
46
- - human-readable `init` output shows tool home, tool config, and providers registry
47
- - human-readable `status` output shows tool home and target runtime
48
- - human-readable `doctor` output is repair-oriented
49
- - `--version` matches `package.json.version`
50
-
51
- ## Test Limits
52
-
53
- - `login copilot` depends on SDK install, official CLI invocation, and auth recheck. Automation should distinguish mocked coverage from real-environment validation.
54
- - `migrate` remains intentionally interactive for adopt detail collection. Non-interactive tests should verify the current failure contract rather than force a fake full automation path.
55
-
56
- ## Reporting Template
57
-
58
- ```text
59
- Version under test: 0.0.12
60
- Build: PASS/FAIL
61
- Suite results:
62
- - commands: PASS/FAIL
63
- - cli-e2e: PASS/FAIL
64
- - interaction: PASS/FAIL
65
- - runtime: PASS/FAIL
66
- - workflows: PASS/FAIL
67
-
68
- Release checks:
69
- - help/version: PASS/FAIL
70
- - direct path: PASS/FAIL
71
- - copilot path: PASS/FAIL
72
- - json reads: PASS/FAIL
73
- - sandbox writes: PASS/FAIL
74
-
75
- Open risks:
76
- - <risk 1>
77
- - <risk 2>
78
- ```
1
+ # codex-switch Testing Guide
2
+
3
+ This guide records the release gate for `0.1.0`.
4
+
5
+ ## Required checks
6
+
7
+ Run these commands before publishing or reviewing release changes:
8
+
9
+ ```bash
10
+ npm run build
11
+ npm test
12
+ npx tsc --noEmit
13
+ npm pack --dry-run
14
+ node dist/cli.js --help
15
+ node dist/cli.js --version
16
+ ```
17
+
18
+ ## Release scenarios
19
+
20
+ - Fresh direct-provider flow: `init -> add -> switch -> status -> doctor`
21
+ - Fresh Copilot flow: `init -> login copilot -> add --copilot -> switch -> status -> doctor`
22
+ - Ambiguous active profile: `list`, `status`, and provider pickers must surface ambiguity instead of inventing a unique current provider
23
+ - `--json` envelope: top-level `ok`, `command`, `data`, `warnings`, and `error` must remain stable
24
+ - `migrate`: advanced adopt helper only
25
+ - `setup`: deprecated entry only
26
+
27
+ ## Fixture guidance
28
+
29
+ - Prefer isolated temp directories for mutating tests.
30
+ - Keep fixtures small and realistic.
31
+ - Use `dev-codex/local-sandbox` only when a test needs a representative Codex directory layout.
package/docs/cli-usage.md CHANGED
@@ -1,223 +1,223 @@
1
- # codex-switch CLI Usage
2
-
3
- This document describes the current CLI contract for `@minniexcode/codex-switch` at version `0.0.12`.
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.0.12`.
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.
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
- - [PRD 0.0.12](./PRD/codex-switch-prd-v0.0.12.md)
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)