@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
|
@@ -1,152 +1,32 @@
|
|
|
1
|
-
# codex-switch
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
`
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
## 3. 收口矩阵
|
|
34
|
-
|
|
35
|
-
以下子系统必须完成对应收口。
|
|
36
|
-
|
|
37
|
-
| 子系统 | 必须稳定的内容 | 约束 |
|
|
38
|
-
| --- | --- | --- |
|
|
39
|
-
| 文档 | PRD、design、README、CLI usage、product overview、changelog、testing guide | 所有面向用户的文档必须与 `0.1.0` 事实一致 |
|
|
40
|
-
| 帮助 | 顶层 help、命令 help、示例顺序 | direct/Copilot 主路径优先,`migrate` 降级,`setup` 仅保留 deprecated 语义 |
|
|
41
|
-
| 输出 | `init`、`list`、`status`、`doctor`、`login` 的 human-readable 文案 | 只收口语义,不改 JSON envelope |
|
|
42
|
-
| 读路径 | tool home / runtime separation、dual-path model、ambiguous active profile 处理 | 不新增兼容层,不伪造 current 状态 |
|
|
43
|
-
| 测试 | release gate、回归测试、fixture 检查 | 回归测试必须落仓库,不能继续停留在忽略状态 |
|
|
44
|
-
|
|
45
|
-
## 4. 必须稳定的用户可见语义
|
|
46
|
-
|
|
47
|
-
### 4.1 `list`
|
|
48
|
-
|
|
49
|
-
`list` 必须能让用户直接看出:
|
|
50
|
-
|
|
51
|
-
- provider 属于 `direct` 还是 `copilot`
|
|
52
|
-
- 哪个 provider 是 current
|
|
53
|
-
- 当前 active profile 是否可唯一解析
|
|
54
|
-
|
|
55
|
-
如果当前 active profile 对应多个 provider,就必须显式表现为 ambiguous,而不是把任何一个 provider 假装成 current。
|
|
56
|
-
|
|
57
|
-
`list --json` 仍然使用既有 envelope,只允许追加字段,不允许改顶层契约。
|
|
58
|
-
|
|
59
|
-
### 4.2 `status`
|
|
60
|
-
|
|
61
|
-
`status` 必须把以下内容讲清楚:
|
|
62
|
-
|
|
63
|
-
- tool home 是什么
|
|
64
|
-
- target runtime 是什么
|
|
65
|
-
- 当前 active provider 是什么
|
|
66
|
-
- 当前路径是 direct 还是 Copilot
|
|
67
|
-
- 下一步应该做什么
|
|
68
|
-
|
|
69
|
-
`status` 是摘要,不是字段堆叠。输出顺序必须围绕“当前状态 -> 影响 -> 下一步”组织。
|
|
70
|
-
|
|
71
|
-
### 4.3 `doctor`
|
|
72
|
-
|
|
73
|
-
`doctor` 必须先给整体健康结论,再列 issue,再给修复建议。
|
|
74
|
-
|
|
75
|
-
每条 issue 至少要表达:
|
|
76
|
-
|
|
77
|
-
- 问题是什么
|
|
78
|
-
- 为什么重要
|
|
79
|
-
- 下一步怎么修
|
|
80
|
-
|
|
81
|
-
`doctor` 的目标不是罗列内部数据结构,而是把用户推到下一步修复动作。
|
|
82
|
-
|
|
83
|
-
### 4.4 provider picker
|
|
84
|
-
|
|
85
|
-
list 和 provider picker 必须一致处理 ambiguous active profile。
|
|
86
|
-
|
|
87
|
-
选择器提示至少要包含:
|
|
88
|
-
|
|
89
|
-
- `profile`
|
|
90
|
-
- `providerType`
|
|
91
|
-
- `current` 标记,仅在唯一解析时出现
|
|
92
|
-
|
|
93
|
-
### 4.5 命令定位
|
|
94
|
-
|
|
95
|
-
`0.1.0` 还必须稳定以下产品定位:
|
|
96
|
-
|
|
97
|
-
- 稳定命令面以 `init`、`login`、`list`、`show`、`current`、`status`、`doctor`、`config`、`add`、`edit`、`switch`、`remove`、`import`、`export`、`bridge`、`backups`、`rollback` 为准。
|
|
98
|
-
- `migrate` 只能被表述为高级 adopt helper。
|
|
99
|
-
- `setup` 只能被表述为 deprecated entry。
|
|
100
|
-
- `--json` 顶层 envelope 继续固定为 `ok / command / data / warnings / error`。
|
|
101
|
-
|
|
102
|
-
## 5. 文档同步要求
|
|
103
|
-
|
|
104
|
-
以下面向用户的文档必须与 `0.1.0` 事实一致:
|
|
105
|
-
|
|
106
|
-
- `README.md`
|
|
107
|
-
- `README.CN.md`
|
|
108
|
-
- `README.AI.md`
|
|
109
|
-
- `docs/cli-usage.md`
|
|
110
|
-
- `docs/codex-switch-product-overview.md`
|
|
111
|
-
- `docs/PRD/codex-switch-prd-v0.1.0.md`
|
|
112
|
-
- `docs/Design/codex-switch-v0.1.0-design.md`
|
|
113
|
-
- `CHANGELOG.md`
|
|
114
|
-
- `docs/Tests/testing.md`
|
|
115
|
-
|
|
116
|
-
历史大文档不需要在本版全文重写,但必须明确它们只是历史参考,不是当前 release contract。
|
|
117
|
-
|
|
118
|
-
## 6. 最小测试计划
|
|
119
|
-
|
|
120
|
-
`0.1.0` 的最小测试计划必须包含以下内容:
|
|
121
|
-
|
|
122
|
-
1. `npm run build`
|
|
123
|
-
2. `npm test`
|
|
124
|
-
3. `npx tsc --noEmit`
|
|
125
|
-
4. `npm pack --dry-run`
|
|
126
|
-
5. built CLI `--help`
|
|
127
|
-
6. built CLI `--version`
|
|
128
|
-
7. fresh direct provider flow
|
|
129
|
-
8. fresh Copilot provider flow
|
|
130
|
-
9. `list/status/doctor` 输出语义检查
|
|
131
|
-
10. `migrate` 高级 adopt helper 检查
|
|
132
|
-
11. `setup` deprecated entry 检查
|
|
133
|
-
|
|
134
|
-
测试结论必须落在仓库中的正式测试内容里,不能继续依赖忽略目录或口头约定。
|
|
135
|
-
|
|
136
|
-
## 7. 明确不做
|
|
137
|
-
|
|
138
|
-
本版不做以下事情:
|
|
139
|
-
|
|
140
|
-
- 新 upstream
|
|
141
|
-
- GUI / TUI
|
|
142
|
-
- daemon
|
|
143
|
-
- plugin system
|
|
144
|
-
- auto migration
|
|
145
|
-
- 兼容层
|
|
146
|
-
- dual-read / dual-write
|
|
147
|
-
- 重新设计公开 JSON envelope
|
|
148
|
-
- 重新扩张命令面
|
|
149
|
-
|
|
150
|
-
## 8. 结论
|
|
151
|
-
|
|
152
|
-
`0.1.0` 设计的核心不是“再造一个版本叙事”,而是把已存在的实现收口成稳定合同。实现只要偏离这条线,就不应被视为 `0.1.0` 的合理内容。
|
|
1
|
+
# codex-switch v0.1.0 Design
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
`0.1.0` freezes the stable CLI shape and documents the current architecture instead of introducing a new runtime model.
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
- `src/commands/` parses and dispatches public commands.
|
|
10
|
+
- `src/app/` owns use cases such as add, switch, status, doctor, bridge, and rollback.
|
|
11
|
+
- `src/domain/` owns provider, config, setup, and error contracts.
|
|
12
|
+
- `src/storage/` owns filesystem persistence for tool home and target Codex state.
|
|
13
|
+
- `src/runtime/` owns Codex CLI and optional Copilot runtime integrations.
|
|
14
|
+
|
|
15
|
+
## State Separation
|
|
16
|
+
|
|
17
|
+
The tool home stores managed state and backups. The target Codex home receives runtime projections. This keeps provider registry edits transactional and makes rollback meaningful without claiming ownership of unrelated Codex files.
|
|
18
|
+
|
|
19
|
+
## Projection
|
|
20
|
+
|
|
21
|
+
Switching a provider projects:
|
|
22
|
+
|
|
23
|
+
- top-level `model`
|
|
24
|
+
- top-level `model_provider`
|
|
25
|
+
- `[model_providers.<id>]`
|
|
26
|
+
- `auth.json` with `OPENAI_API_KEY`
|
|
27
|
+
|
|
28
|
+
Direct providers project the provider API key. Copilot providers project only the local bridge bearer secret; upstream GitHub/Copilot auth remains in the official runtime.
|
|
29
|
+
|
|
30
|
+
## Error Model
|
|
31
|
+
|
|
32
|
+
Command errors use stable CLI error codes and optional `details`. Command-specific errors may remain close to the command implementation when that keeps the public contract clearer than forcing every case into a shared diagnostic taxonomy.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# codex-switch v0.1.1 Design
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
`0.1.1` is a documentation alignment release. The design work is to make the active docs tree match the stable implementation and remove obsolete development-version transition docs from the current fact surface.
|
|
6
|
+
|
|
7
|
+
## Documentation Structure
|
|
8
|
+
|
|
9
|
+
- `README.md`, `README.CN.md`, and `README.AI.md` describe the user-facing product.
|
|
10
|
+
- `docs/cli-usage.md` is the command reference.
|
|
11
|
+
- `docs/codex-switch-product-overview.md` is the product-level summary.
|
|
12
|
+
- `docs/codex-switch-technical-architecture.md` is the implementation map.
|
|
13
|
+
- `docs/PRD/` contains active version fact sources for `0.1.0`, `0.1.1`, and planned `0.1.2`.
|
|
14
|
+
- `docs/Design/` contains matching design fact sources.
|
|
15
|
+
- `docs/Reference/` keeps Codex configuration references.
|
|
16
|
+
- `docs/Tests/testing.md` keeps the current verification contract.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
|
|
20
|
+
- Public links should not point to removed `0.0.x` development documents.
|
|
21
|
+
- The active documentation set should describe current behavior, not historical migration intent.
|
|
22
|
+
- Copilot documentation should explicitly mark the bridge as local, bearer-protected, and backed by official GitHub Copilot runtime state.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# codex-switch v0.1.2 Design
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
`0.1.2` repairs the Copilot runtime integration while keeping direct-provider support unchanged.
|
|
6
|
+
|
|
7
|
+
## SDK Runtime
|
|
8
|
+
|
|
9
|
+
- The managed installer installs `@github/copilot-sdk@1.0.2`.
|
|
10
|
+
- `loadCopilotSdk()` resolves `@github/copilot-sdk` from the managed runtime package using `createRequire()`.
|
|
11
|
+
- Copilot-specific paths call a Node gate before mutation or bridge startup. Node.js `<20` fails with `COPILOT_RUNTIME_NODE_UNSUPPORTED`.
|
|
12
|
+
- `probeCopilotSdkRuntime()` classifies missing installs, unsupported versions, and prerelease installs before runtime use.
|
|
13
|
+
- SDK API-shape validation happens later when creating the client or session.
|
|
14
|
+
|
|
15
|
+
## SDK API Contract
|
|
16
|
+
|
|
17
|
+
The supported runtime/session shape is:
|
|
18
|
+
|
|
19
|
+
- `CopilotClient`
|
|
20
|
+
- `CopilotClient.getAuthStatus()`
|
|
21
|
+
- `CopilotClient.createSession()`
|
|
22
|
+
- `CopilotSession.sendAndWait()` when present, otherwise `CopilotSession.send()`
|
|
23
|
+
- `CopilotSession.abort()`
|
|
24
|
+
- `CopilotSession.disconnect()` only as best-effort cleanup
|
|
25
|
+
- SDK `approveAll` or compatible permission handler
|
|
26
|
+
|
|
27
|
+
Auth readiness uses `getAuthStatus()` and does not create a session just to test login state. `abort()` is a required compatibility surface; `disconnect()` is not a required compatibility gate.
|
|
28
|
+
|
|
29
|
+
## Bridge Worker
|
|
30
|
+
|
|
31
|
+
The parent process passes both runtime state and SDK runtime directories into the worker. The worker creates one long-lived `CopilotClient`, starts it once, and serializes incoming requests through a promise queue. Each request gets its own session, uses `abort()` for timeout and cancellation control, and attempts `disconnect()` after completion as best-effort cleanup.
|
|
32
|
+
|
|
33
|
+
## Request Mapping
|
|
34
|
+
|
|
35
|
+
The bridge remains a minimal OpenAI-compatible adapter:
|
|
36
|
+
|
|
37
|
+
- `/v1/chat/completions` maps messages to a text prompt.
|
|
38
|
+
- `/v1/responses` accepts string input, message arrays, or typed top-level content-item arrays and maps those text-oriented shapes to the same prompt path.
|
|
39
|
+
- `model` is passed to `createSession({ model })`.
|
|
40
|
+
- Mixed top-level arrays are rejected as unsupported input.
|
|
41
|
+
- `sendAndWait()` receives `{ prompt }` and the request timeout when available; otherwise the bridge falls back to `send()`.
|
|
42
|
+
|
|
43
|
+
Non-text Responses content is represented as readable placeholders. Complex tool-call round trips are outside the `0.1.2` guarantee.
|
|
44
|
+
|
|
45
|
+
## Streaming
|
|
46
|
+
|
|
47
|
+
Streaming Responses requests emit `response.created`, `response.in_progress`, output item/content part setup events, text deltas, done events, and `response.completed`. The bridge writes initial SSE bytes before the upstream response completes and emits comment heartbeats every 15 seconds while waiting.
|
|
48
|
+
|
|
49
|
+
## Error Mapping
|
|
50
|
+
|
|
51
|
+
- Unsupported request shapes return `400`.
|
|
52
|
+
- Auth-required failures return `401`.
|
|
53
|
+
- Upstream timeouts return `504`.
|
|
54
|
+
- Other bridge runtime failures return `500`.
|
|
55
|
+
|
|
56
|
+
## Config Projection
|
|
57
|
+
|
|
58
|
+
Copilot provider projection includes:
|
|
59
|
+
|
|
60
|
+
```toml
|
|
61
|
+
wire_api = "responses"
|
|
62
|
+
stream_idle_timeout_ms = 300000
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Direct provider projection does not add `stream_idle_timeout_ms`.
|
|
@@ -1,217 +1,65 @@
|
|
|
1
|
-
# codex-switch
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
- CLI
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
##
|
|
33
|
-
|
|
34
|
-
`
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
### 3.2 `--json` envelope
|
|
67
|
-
|
|
68
|
-
`--json` 的顶层 envelope 必须保持不变:
|
|
69
|
-
|
|
70
|
-
```json
|
|
71
|
-
{
|
|
72
|
-
"ok": true,
|
|
73
|
-
"command": "list",
|
|
74
|
-
"data": {},
|
|
75
|
-
"warnings": [],
|
|
76
|
-
"error": null
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
约束如下:
|
|
81
|
-
|
|
82
|
-
- 顶层字段名不变。
|
|
83
|
-
- 顶层字段顺序和 shape 不变。
|
|
84
|
-
- 新信息只能继续追加到 `data`、`warnings` 或 `error.details`。
|
|
85
|
-
|
|
86
|
-
### 3.3 dual-path model
|
|
87
|
-
|
|
88
|
-
`0.1.0` 必须把以下分层固定为正式合同:
|
|
89
|
-
|
|
90
|
-
- tool home:
|
|
91
|
-
- `codex-switch.json`
|
|
92
|
-
- `providers.json`
|
|
93
|
-
- `backups/`
|
|
94
|
-
- `runtime/`
|
|
95
|
-
- `runtimes/`
|
|
96
|
-
- target Codex runtime:
|
|
97
|
-
- `config.toml`
|
|
98
|
-
- `auth.json`
|
|
99
|
-
|
|
100
|
-
含义必须稳定:
|
|
101
|
-
|
|
102
|
-
- `providers.json` 是管理态 SSOT。
|
|
103
|
-
- `config.toml` 是受管 runtime routing 文件。
|
|
104
|
-
- `auth.json` 是受管 auth projection 文件。
|
|
105
|
-
|
|
106
|
-
### 3.4 主工作流
|
|
107
|
-
|
|
108
|
-
Direct provider 主路径:
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
codexs init
|
|
112
|
-
codexs add <provider> --profile <name> --api-key <key>
|
|
113
|
-
codexs switch <provider>
|
|
114
|
-
codexs status
|
|
115
|
-
codexs doctor
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
Copilot provider 主路径:
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
codexs init
|
|
122
|
-
codexs login copilot
|
|
123
|
-
codexs add <provider> --copilot --profile <name>
|
|
124
|
-
codexs switch <provider>
|
|
125
|
-
codexs status
|
|
126
|
-
codexs doctor
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
`migrate` 的定位必须明确为:
|
|
130
|
-
|
|
131
|
-
- 面向已有 runtime state 的高级 adopt helper。
|
|
132
|
-
- 不应与 fresh install 主路径混淆。
|
|
133
|
-
- 不应被写成所有新用户都应先执行的默认步骤。
|
|
134
|
-
|
|
135
|
-
## 4. Release Gate
|
|
136
|
-
|
|
137
|
-
只有以下条件全部满足,才允许发布 `0.1.0`。
|
|
138
|
-
|
|
139
|
-
### 4.1 工作流
|
|
140
|
-
|
|
141
|
-
- fresh tool home 下 direct provider 主路径可稳定走通。
|
|
142
|
-
- fresh tool home 下 Copilot 主路径可稳定走通。
|
|
143
|
-
- `switch` 的成功语义仍然等于 config 和 auth projection 都正确。
|
|
144
|
-
- `rollback` 对受管写操作仍然可信。
|
|
145
|
-
|
|
146
|
-
### 4.2 输出与语义
|
|
147
|
-
|
|
148
|
-
- `--json` 读命令输出稳定。
|
|
149
|
-
- 非交互模式不会意外触发 prompt。
|
|
150
|
-
- 错误码和 issue code 对常见失败场景足够稳定。
|
|
151
|
-
- `status` 与 `doctor` 能清楚说明下一步修复动作。
|
|
152
|
-
- `list`、`status`、`doctor` 的人类可读输出和交互提示一致。
|
|
153
|
-
|
|
154
|
-
### 4.3 文档
|
|
155
|
-
|
|
156
|
-
- README、README.CN、README.AI、CLI usage、product overview、PRD、design 和 changelog 与实际行为一致。
|
|
157
|
-
- `docs/Tests/testing.md` 不能继续停留在忽略状态,测试回归必须落仓库并可版本化。
|
|
158
|
-
- 主路径在所有面向用户的文档中必须一致。
|
|
159
|
-
- `0.1.0` 的定位必须压过旧的 `0.0.12` 叙事。
|
|
160
|
-
|
|
161
|
-
### 4.4 包内容
|
|
162
|
-
|
|
163
|
-
- `npm pack --dry-run` 结果合理。
|
|
164
|
-
- tarball 中包含正确的 README、LICENSE、docs、dist。
|
|
165
|
-
- `codexs --help`、`codexs --version`、安装指引与 npm 包元数据一致。
|
|
166
|
-
|
|
167
|
-
### 4.5 结构
|
|
168
|
-
|
|
169
|
-
- 不再保留明显误导性的历史目录语义。
|
|
170
|
-
- 稳定模块的边界说明足够清楚。
|
|
171
|
-
- 新问题不再需要反复回到超大入口文件修补。
|
|
172
|
-
|
|
173
|
-
## 5. 可执行验证清单
|
|
174
|
-
|
|
175
|
-
`0.1.0` 的发布前验证必须至少覆盖以下项目:
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
npm run build
|
|
179
|
-
npm test
|
|
180
|
-
npx tsc --noEmit
|
|
181
|
-
npm pack --dry-run
|
|
182
|
-
node dist/cli.js --help
|
|
183
|
-
node dist/cli.js --version
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
同时必须做以下行为验证:
|
|
187
|
-
|
|
188
|
-
- fresh direct provider flow。
|
|
189
|
-
- fresh Copilot provider flow。
|
|
190
|
-
- `list/status/doctor` 语义检查。
|
|
191
|
-
- `--json` 输出检查。
|
|
192
|
-
- `migrate` 作为高级 adopt helper 的检查。
|
|
193
|
-
- `setup` 作为 deprecated entry 的检查。
|
|
194
|
-
|
|
195
|
-
## 6. 明确不在范围内
|
|
196
|
-
|
|
197
|
-
`0.1.0` 不要求完成以下内容:
|
|
198
|
-
|
|
199
|
-
- 新 upstream。
|
|
200
|
-
- GUI / TUI。
|
|
201
|
-
- daemon。
|
|
202
|
-
- plugin system。
|
|
203
|
-
- auto migration。
|
|
204
|
-
- 兼容层。
|
|
205
|
-
- dual-read / dual-write。
|
|
206
|
-
- `migrate` 的完整非交互产品化。
|
|
207
|
-
- 旧状态的自动升级保留逻辑。
|
|
208
|
-
|
|
209
|
-
## 7. 若 Gate 未通过
|
|
210
|
-
|
|
211
|
-
如果任何阻塞项仍然存在,就不要强行发布 `0.1.0`。
|
|
212
|
-
|
|
213
|
-
此时应继续发布 beta 或 rc 版本,而不是为了版本号好看提前进入稳定线。
|
|
214
|
-
|
|
215
|
-
## 8. 结论
|
|
216
|
-
|
|
217
|
-
`0.1.0` 的本质不是“功能更多”,而是“承诺更稳”。当命令面、输出契约、主工作流、诊断语义、包内容和文档事实完全一致时,这个版本号才成立。
|
|
1
|
+
# codex-switch v0.1.0 PRD
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
- Version line: `0.1.0`
|
|
6
|
+
- Role: first stable documentation baseline
|
|
7
|
+
- Scope: summarize the stable public contract already reached by the CLI
|
|
8
|
+
|
|
9
|
+
## Product Contract
|
|
10
|
+
|
|
11
|
+
`codex-switch` is a local-first CLI named `codexs` for managing Codex model-provider routes. It keeps tool-owned provider state separate from the target Codex runtime while projecting the selected provider into Codex-compatible `config.toml` and `auth.json` files.
|
|
12
|
+
|
|
13
|
+
Stable user workflows:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
codexs init
|
|
17
|
+
codexs add <provider> --profile <model-provider-id> --api-key <key> --base-url <url> --model <model>
|
|
18
|
+
codexs switch <provider>
|
|
19
|
+
codexs status
|
|
20
|
+
codexs doctor
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
codexs init
|
|
25
|
+
codexs login copilot
|
|
26
|
+
codexs add <provider> --copilot --profile <model-provider-id> --model <model>
|
|
27
|
+
codexs switch <provider>
|
|
28
|
+
codexs status
|
|
29
|
+
codexs doctor
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Stable Boundaries
|
|
33
|
+
|
|
34
|
+
- Tool home owns `codex-switch.json`, `providers.json`, `backups/`, `runtime/`, and `runtimes/`.
|
|
35
|
+
- Target Codex home owns the active `config.toml` and `auth.json` projection.
|
|
36
|
+
- `providers.json` is the provider registry source of truth.
|
|
37
|
+
- `config.toml` uses top-level `model` / `model_provider` plus `[model_providers.*]` sections.
|
|
38
|
+
- `auth.json` receives the active Codex-facing bearer value as `OPENAI_API_KEY`.
|
|
39
|
+
- Copilot upstream GitHub credentials are not stored in `providers.json` or target `auth.json`.
|
|
40
|
+
|
|
41
|
+
## Stable Commands
|
|
42
|
+
|
|
43
|
+
Stable command families include `init`, `login copilot`, `add`, `edit`, `switch`, `remove`, `list`, `show`, `current`, `status`, `doctor`, `config show`, `config list-profiles`, `import`, `export`, `bridge start`, `bridge status`, `bridge stop`, `backups list`, and `rollback`.
|
|
44
|
+
|
|
45
|
+
`migrate` remains an advanced adopt helper for existing Codex state. `setup` is a deprecated compatibility entry that points users to `init` and `migrate`.
|
|
46
|
+
|
|
47
|
+
## Output Contract
|
|
48
|
+
|
|
49
|
+
JSON output keeps the top-level envelope:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"ok": true,
|
|
54
|
+
"command": "status",
|
|
55
|
+
"data": {},
|
|
56
|
+
"warnings": [],
|
|
57
|
+
"error": null
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
New information should be added under `data`, `warnings`, or `error.details` without changing the envelope.
|
|
62
|
+
|
|
63
|
+
## Non-Goals
|
|
64
|
+
|
|
65
|
+
`0.1.0` does not introduce automatic migration shims, a daemon, GUI/TUI, plugin system, new upstream families, or backward-compatibility dual-read paths for old development state.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# codex-switch v0.1.1 PRD
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
- Version line: `0.1.1`
|
|
6
|
+
- Role: documentation and fact-source completion release
|
|
7
|
+
- Current package version: `0.1.1`
|
|
8
|
+
|
|
9
|
+
## Goal
|
|
10
|
+
|
|
11
|
+
`0.1.1` closes documentation gaps after the first stable line. It does not change the primary command surface. Its purpose is to make README, CLI usage, product overview, technical architecture, PRD, design, and changelog agree on the same current facts.
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
- Keep `0.1.0` as the stable product contract summary.
|
|
16
|
+
- Add explicit `0.1.1` PRD and design fact sources so links from overview and architecture resolve.
|
|
17
|
+
- Remove obsolete `0.0.x` transition docs from the active docs tree.
|
|
18
|
+
- Keep Copilot described as a managed local bridge backed by the official GitHub Copilot runtime.
|
|
19
|
+
- Clarify that direct providers remain the stable, generic path and that Copilot has additional runtime prerequisites.
|
|
20
|
+
- Keep the development-version policy: no automatic migration or backward-compatibility shims unless a later task explicitly asks for them.
|
|
21
|
+
|
|
22
|
+
## Acceptance
|
|
23
|
+
|
|
24
|
+
- Public docs link only to current `0.1.0`, `0.1.1`, or planned `0.1.2` fact sources.
|
|
25
|
+
- No public page points to removed `0.0.x` transition documents.
|
|
26
|
+
- `npm test` and `npx tsc --noEmit` continue to pass.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# codex-switch v0.1.2 PRD
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
- Version line: `0.1.2`
|
|
6
|
+
- Status: release candidate
|
|
7
|
+
- Current repository package version: `0.1.2`
|
|
8
|
+
- Role: next Copilot runtime repair line
|
|
9
|
+
- Scope: make the experimental Copilot bridge diagnosable and usable for simple text-oriented turns against the currently verified Codex runtime boundary, with `0.140.x` treated as a planning and verification target rather than a blanket compatibility guarantee
|
|
10
|
+
|
|
11
|
+
## Problem
|
|
12
|
+
|
|
13
|
+
The existing Copilot path treated `@github/copilot-sdk` as a simple chat/session SDK. The package is an official JSON-RPC control surface for GitHub Copilot CLI and has a stricter runtime contract than the previous integration assumed. It also requires Node.js `>=20`, while direct providers should continue to support Node.js `>=18`.
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
- Default the managed installer to `@github/copilot-sdk@1.0.2` instead of `latest`.
|
|
18
|
+
- Keep package-level `engines.node >=18`, but fail Copilot-only paths early under Node.js `<20` with `COPILOT_RUNTIME_NODE_UNSUPPORTED`.
|
|
19
|
+
- Load the SDK from the managed runtime install directory using `createRequire()`.
|
|
20
|
+
- Probe auth through `CopilotClient.getAuthStatus()` rather than by creating a session.
|
|
21
|
+
- Treat unsupported SDK versions and prerelease installs as explicit runtime failures before bridge use, with API-shape validation reported separately as `COPILOT_SDK_API_UNSUPPORTED` when the client or session is actually used.
|
|
22
|
+
- Start the bridge worker with the same `runtimesDir` that passed parent readiness checks.
|
|
23
|
+
- Keep one long-lived `CopilotClient` in the worker, create one session per request, require `abort()`, and attempt `disconnect()` as best-effort cleanup after the request.
|
|
24
|
+
- Serialize bridge requests to avoid session event interleaving.
|
|
25
|
+
- Normalize `/v1/chat/completions` and `/v1/responses` text-oriented turns to SDK `prompt` messages and pass the model through `createSession({ model })`.
|
|
26
|
+
- Stream Responses API events before upstream completion and emit heartbeat comments while waiting.
|
|
27
|
+
- Return explicit bridge errors for unsupported requests, auth-required failures, SDK/runtime failures, and upstream timeouts.
|
|
28
|
+
- Project Copilot model providers with `wire_api = "responses"` and `stream_idle_timeout_ms = 300000`.
|
|
29
|
+
|
|
30
|
+
## Non-Goals
|
|
31
|
+
|
|
32
|
+
`0.1.2` does not claim the Copilot bridge is a complete OpenAI Responses API backend. Complex tool-call round trips remain experimental unless verified separately.
|
|
33
|
+
|
|
34
|
+
## Acceptance
|
|
35
|
+
|
|
36
|
+
- `/v1/responses` request normalization accepts string input, message arrays, or typed top-level content-item arrays; mixed arrays are rejected; non-text items become readable placeholders.
|
|
37
|
+
- Unsupported requests map to `400`, auth-required failures map to `401`, upstream timeouts map to `504`, and other bridge runtime failures map to `500`.
|
|
38
|
+
- Streaming Responses requests emit the expected event shape, including initial lifecycle events before upstream completion, text deltas, and final completion events.
|
|
39
|
+
- Copilot config projection writes `wire_api = "responses"` and `stream_idle_timeout_ms = 300000`.
|
|
40
|
+
- Simple non-stream and stream bridge requests work against the fake SDK contract.
|
|
41
|
+
- Node `<20` Copilot commands fail before mutating provider or Codex state.
|