@minniexcode/codex-switch 0.1.3 → 0.1.5

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.
@@ -0,0 +1,18 @@
1
+ # codex-switch v0.1.4 Design
2
+
3
+ `0.1.4` is a bridge reliability and observability repair release.
4
+
5
+ ## Design Notes
6
+
7
+ - Bridge reuse probing is refactored into a structured probe helper that distinguishes transient transport failures from deterministic mismatches.
8
+ - Health and auth reuse probes use 2 attempts, a 2500 ms per-request timeout, and a 250 ms delay between attempts.
9
+ - Existing bridge workers are retried before replacement only for transient timeout and transport failures. Deterministic mismatches still replace immediately: different provider, different base URL, stale worker build, or explicit `401`/`403` auth rejection.
10
+ - Bridge worker stdout/stderr are appended to a persisted runtime log file under the managed runtime-state directory, and that log path is surfaced in bridge results and bridge-related errors.
11
+ - Parent-side lifecycle logging records probe attempts, transient failures, replacement reasons, worker start, startup timeout, startup failure, and startup success without logging secrets.
12
+ - Worker-side stderr logging records startup, shutdown, uncaught exception, and unhandled rejection.
13
+ - The shared test runner discovers `tests/*.spec.js` in sorted order, excludes helper files, and supports both suite export styles already present in the repository: `{ run }` and `{ name, tests: [...] }`.
14
+ - Interactive provider selection uses the structured config once and resolves the visible current hint in this order:
15
+ 1. unique managed mapping from top-level `model_provider`
16
+ 2. fallback to legacy top-level `profile` when top-level `model_provider` is missing or unresolved and the legacy value exactly matches one provider name
17
+ 3. ambiguous marker when multiple providers share the active `model_provider`
18
+ 4. no marker otherwise
@@ -0,0 +1,17 @@
1
+ # codex-switch v0.1.5 Design
2
+
3
+ `0.1.5` is a Copilot Bridge process-visibility and redaction patch release.
4
+
5
+ ## Design Notes
6
+
7
+ - `CopilotBridgeRuntimeEvent` is the stable internal boundary between Copilot SDK session events and the OpenAI-compatible bridge surface.
8
+ - Copilot sessions are created with `streaming: true` and register the generic `session.on("event", handler)` listener alongside the existing `data`, `message`, and `delta` text compatibility listeners.
9
+ - The adapter maps known SDK event names into bridge runtime events for assistant intent, assistant message deltas, assistant reasoning deltas, tool lifecycle, permission lifecycle, user-input requests, exit-plan-mode requests, session idle, and session errors.
10
+ - `assistant.message_delta` is also forwarded as a normal text delta so final response streaming remains compatible with existing Chat Completions and Responses text paths.
11
+ - The bridge worker forwards adapter runtime events through `onRuntimeEvent`, separate from `onTextDelta` and `onTextDone`.
12
+ - Responses streaming projects non-text runtime process events as completed assistant message items with `phase: "commentary"`.
13
+ - Reasoning deltas project as `response.reasoning_summary_part.added` followed by `response.reasoning_summary_text.delta`.
14
+ - Unknown SDK events become `session.unknown`, are omitted from the UI projection path, and are logged with bounded summaries.
15
+ - Unknown summaries redact sensitive key names and obvious token/API-key-like values before truncation.
16
+ - Chat Completions streaming only wires text deltas, so Responses-only commentary events stay out of Chat Completions streams.
17
+ - Internal Copilot tool lifecycle events remain process visibility signals only; they are not emitted as Codex/OpenAI function calls or tool calls.
@@ -0,0 +1,37 @@
1
+ # codex-switch v0.1.4 PRD
2
+
3
+ ## Version
4
+
5
+ - Version line: `0.1.4`
6
+ - Target repository package version: `0.1.4`
7
+
8
+ ## Summary
9
+
10
+ `0.1.4` is a bridge stability and observability release. It is a narrow reliability bridge between the existing Copilot bridge experiment and a stricter release gate, with no new provider families or migration behavior.
11
+
12
+ ## Required Outcome
13
+
14
+ - Copilot bridge reuse must survive one transient health or auth probe failure before the existing worker is replaced.
15
+ - Bridge failures must expose actionable evidence, including the persisted runtime log path and the restart reason when an old worker is recycled.
16
+ - `npm test` must become the widened real release gate by discovering and running the broader repository suite set already present under `tests/`.
17
+ - Interactive provider selection must restore the visible `current` hint for legacy state where only the top-level `profile` is present and `model_provider` is absent.
18
+
19
+ ## Release Scope
20
+
21
+ - Bridge reuse probe hardening for transient transport and timeout failures.
22
+ - Bridge log persistence and surfaced restart metadata across command results and diagnostics.
23
+ - Widened test-runner coverage plus any pre-existing red paths that block the widened suite from becoming the real ship gate.
24
+ - Interactive current-marker repair for legacy top-level `profile` fallback.
25
+
26
+ ## Non-Goals
27
+
28
+ - No new provider families.
29
+ - No migration or backward-compatibility shims beyond the prompt-only legacy `profile` hint fallback.
30
+ - No command-surface expansion outside the new bridge diagnostics and status fields.
31
+
32
+ ## Release Acceptance
33
+
34
+ - `switch` no longer flaps on one transient bridge probe failure.
35
+ - Bridge startup or reuse failures surface the log path and the worker replacement reason when applicable.
36
+ - `npm test` executes the widened deterministic suite set and passes.
37
+ - Interactive provider selection correctly marks the current provider from legacy top-level `profile` state when top-level `model_provider` is absent or unresolved.
@@ -0,0 +1,42 @@
1
+ # codex-switch v0.1.5 PRD
2
+
3
+ ## Version
4
+
5
+ - Version line: `0.1.5`
6
+ - Target repository package version: `0.1.5`
7
+
8
+ ## Summary
9
+
10
+ `0.1.5` is a Copilot Bridge process-visibility and redaction patch release. It surfaces assistant progress, reasoning summaries, tool lifecycle, permission, user-input, and exit-plan-mode signals through the existing bridge stream while keeping the provider command surface unchanged.
11
+
12
+ ## Required Outcome
13
+
14
+ - Copilot SDK streaming sessions must subscribe to the generic session event channel and preserve existing text-delta compatibility listeners.
15
+ - Known SDK process events must map into a stable bridge runtime-event contract instead of leaking SDK-specific shapes.
16
+ - Responses streaming must surface process/status updates as commentary items and reasoning/progress updates as reasoning summary events.
17
+ - Chat Completions streaming must continue to receive text only and must not receive Responses-only commentary events.
18
+ - Unknown SDK events must be ignored by the UI projection path while logging bounded, redacted summaries for diagnostics.
19
+ - Adapter-level tests must cover raw SDK session event normalization, not only bridge-server projection of already-normalized events.
20
+
21
+ ## Release Scope
22
+
23
+ - Copilot adapter runtime event contract and SDK event normalization.
24
+ - Bridge worker forwarding of adapter runtime events into request handlers.
25
+ - Responses streaming projection for commentary and reasoning summary events.
26
+ - Unknown-event truncation and redaction hardening.
27
+ - Focused regression coverage for raw SDK event mapping and bridge stream projection.
28
+
29
+ ## Non-Goals
30
+
31
+ - No new provider families.
32
+ - No migration or backward-compatibility shims.
33
+ - No expansion of direct-provider workflows.
34
+ - No conversion of internal Copilot tool lifecycle events into Codex/OpenAI function-call or tool-call payloads.
35
+
36
+ ## Release Acceptance
37
+
38
+ - `npm test` passes with adapter-level raw event normalization coverage.
39
+ - Responses streaming includes commentary and reasoning summary process events.
40
+ - Final assistant text still streams normally.
41
+ - Unknown events are redacted, truncated, logged for diagnostics, and ignored by the UI projection path.
42
+ - Chat Completions streaming does not emit Responses-only commentary events.
@@ -1,6 +1,8 @@
1
1
  # codex-switch Testing Guide
2
2
 
3
3
  This guide records the current `0.1.x` verification contract for release and review work.
4
+
5
+ The current repository line is `0.1.5` and remains an unreleased development line until an explicit release task says otherwise.
4
6
 
5
7
  ## Required checks
6
8
 
@@ -22,7 +24,8 @@ node dist/cli.js --version
22
24
  - Ambiguous active profile: `list`, `status`, and provider pickers must surface ambiguity instead of inventing a unique current provider
23
25
  - `--json` envelope: top-level `ok`, `command`, `data`, `warnings`, and `error` must remain stable
24
26
  - `migrate`: advanced adopt helper only
25
- - `setup`: deprecated entry only
27
+ - `setup`: deprecated entry only
28
+ - Release hygiene: `package.json`, `package-lock.json`, current-line docs, changelog top entry, and current PRD/Design fact sources must agree on the `0.1.5` development line
26
29
 
27
30
  ## Fixture guidance
28
31
 
package/docs/cli-usage.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # codex-switch CLI Usage
2
2
 
3
- This document describes the current `0.1.3` CLI contract for `@minniexcode/codex-switch`, including the Copilot login hotfix boundary.
3
+ This document describes the current `0.1.5` repository development-line CLI contract for `@minniexcode/codex-switch`, including the Copilot Bridge process-visibility boundary.
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.1.3`.
13
+ The current package version in this repository is `0.1.5`.
14
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.
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. The current `0.1.5` development line adds Copilot Bridge process visibility, defensive SDK-event normalization, and unknown-event redaction hardening without expanding the provider command surface.
16
16
 
17
17
  ## 2. Primary Workflows
18
18
 
@@ -20,7 +20,7 @@ This release line targets Codex `0.134.0+`. The public contract assumes runtime
20
20
 
21
21
  ```bash
22
22
  codexs init
23
- codexs add <provider> --model <model> --api-key <key> [--base-url <url>]
23
+ codexs add <provider> --profile <model-provider-id> --model <model> --api-key <key> [--base-url <url>]
24
24
  codexs switch <provider>
25
25
  codexs status
26
26
  codexs doctor
@@ -30,6 +30,7 @@ Intent:
30
30
 
31
31
  - `init` prepares the `codex-switch` tool home.
32
32
  - `add` creates a managed provider record with a target model and provider route identity.
33
+ - Non-interactive runs should pass `--profile` explicitly; TTY mode can prompt for missing required fields.
33
34
  - `switch` projects the selected provider into the target Codex runtime.
34
35
  - `status` summarizes tool-home, runtime, provider, and health state.
35
36
  - `doctor` gives deeper repair-oriented diagnostics.
@@ -39,7 +40,7 @@ Intent:
39
40
  ```bash
40
41
  codexs init
41
42
  codexs login copilot
42
- codexs add <provider> --copilot --model <model>
43
+ codexs add <provider> --copilot --profile <model-provider-id> --model <model>
43
44
  codexs switch <provider>
44
45
  codexs status
45
46
  codexs doctor
@@ -51,6 +52,7 @@ Important notes:
51
52
  - The current implementation prefers the bundled Copilot CLI from the managed runtime and falls back to `PATH` when needed.
52
53
  - `login copilot` succeeds only after auth readiness is rechecked.
53
54
  - `add --copilot` does not install or log in to Copilot for you.
55
+ - Non-interactive Copilot adds should also pass `--profile` explicitly; TTY mode can still collect missing required fields.
54
56
  - Copilot runtime paths require Node.js `>=20`; direct providers remain supported on Node.js `>=18`.
55
57
  - The Copilot bridge is experimental and targets simple text-oriented turns through the local OpenAI-compatible bridge.
56
58
 
@@ -82,6 +84,7 @@ Copilot bridge projection also writes:
82
84
  Compatibility notes:
83
85
 
84
86
  - `--profile` is accepted as an alias for the managed `model_provider` id.
87
+ - automation should still pass `--profile` explicitly instead of relying on prompts
85
88
  - legacy top-level `profile` and `[profiles.*]` may still appear in existing runtime state
86
89
  - `migrate`, `config show`, `config list-profiles`, and `doctor` can still inspect those legacy structures
87
90
  - new managed runtime projection should be described as route-first, not profile-first
@@ -262,6 +265,7 @@ codexs rollback [backup-id]
262
265
 
263
266
  - Create or update managed provider records rather than editing runtime files directly.
264
267
  - Treat `--profile` only as an alias for the managed `model_provider` id.
268
+ - Require explicit `--profile` in non-interactive usage; allow TTY prompts to fill it when omitted.
265
269
  - Clean old `env_key` and `env_key_instructions` fields from managed projection during subsequent switching.
266
270
 
267
271
  ### `migrate`
@@ -288,5 +292,7 @@ codexs rollback [backup-id]
288
292
  - [PRD 0.1.1](./PRD/codex-switch-prd-v0.1.1.md)
289
293
  - [PRD 0.1.2](./PRD/codex-switch-prd-v0.1.2.md)
290
294
  - [PRD 0.1.3](./PRD/codex-switch-prd-v0.1.3.md)
295
+ - [PRD 0.1.5](./PRD/codex-switch-prd-v0.1.5.md)
291
296
  - [Design 0.1.2](./Design/codex-switch-v0.1.2-design.md)
292
297
  - [Design 0.1.3](./Design/codex-switch-v0.1.3-design.md)
298
+ - [Design 0.1.5](./Design/codex-switch-v0.1.5-design.md)
@@ -4,17 +4,21 @@
4
4
 
5
5
  这份文档介绍当前活跃产品事实源下的 `codex-switch` 产品定位。
6
6
 
7
- 当前稳定 release contract 以这些文档为准:
8
-
9
- - [`cli-usage.md`](./cli-usage.md)
10
- - [`PRD/codex-switch-prd-v0.1.0.md`](./PRD/codex-switch-prd-v0.1.0.md)
11
- - [`PRD/codex-switch-prd-v0.1.1.md`](./PRD/codex-switch-prd-v0.1.1.md)
12
- - [`PRD/codex-switch-prd-v0.1.2.md`](./PRD/codex-switch-prd-v0.1.2.md)(规划中)
13
- - [`Design/codex-switch-v0.1.2-design.md`](./Design/codex-switch-v0.1.2-design.md)(规划中)
7
+ 当前仓库开发线 fact source 以这些文档为准:
8
+
9
+ - [`cli-usage.md`](./cli-usage.md)
10
+ - [`PRD/codex-switch-prd-v0.1.0.md`](./PRD/codex-switch-prd-v0.1.0.md)
11
+ - [`PRD/codex-switch-prd-v0.1.1.md`](./PRD/codex-switch-prd-v0.1.1.md)
12
+ - [`PRD/codex-switch-prd-v0.1.2.md`](./PRD/codex-switch-prd-v0.1.2.md)
13
+ - [`PRD/codex-switch-prd-v0.1.3.md`](./PRD/codex-switch-prd-v0.1.3.md)
14
+ - [`PRD/codex-switch-prd-v0.1.5.md`](./PRD/codex-switch-prd-v0.1.5.md)
15
+ - [`Design/codex-switch-v0.1.2-design.md`](./Design/codex-switch-v0.1.2-design.md)
16
+ - [`Design/codex-switch-v0.1.3-design.md`](./Design/codex-switch-v0.1.3-design.md)
17
+ - [`Design/codex-switch-v0.1.5-design.md`](./Design/codex-switch-v0.1.5-design.md)
14
18
 
15
19
  ## 产品概述
16
20
 
17
- `codex-switch` 是一个本地 provider 管理 CLI,用于管理和切换目标 Codex runtime 的 provider/model-provider 路由配置,同时把工具自己的管理态保存在独立 tool home 下。
21
+ `codex-switch` 是一个本地 provider 管理 CLI,用于管理和切换目标 Codex runtime 的 provider/model-provider 路由配置,同时把工具自己的管理态保存在独立 tool home 下。
18
22
 
19
23
  它不是旧 `setup` 小工具,也不是围绕单目录 `~/.codex` 组织全部状态的脚本集合。
20
24
 
@@ -50,11 +54,11 @@ target Codex runtime:
50
54
 
51
55
  ## 核心使用流程
52
56
 
53
- Direct 主路径:
57
+ Direct 主路径:
54
58
 
55
59
  ```bash
56
60
  codexs init
57
- codexs add <provider> --model <model> --api-key <key> [--base-url <url>]
61
+ codexs add <provider> --profile <model-provider-id> --model <model> --api-key <key> [--base-url <url>]
58
62
  codexs switch <provider>
59
63
  codexs status
60
64
  codexs doctor
@@ -65,7 +69,7 @@ Copilot 主路径:
65
69
  ```bash
66
70
  codexs init
67
71
  codexs login copilot
68
- codexs add <provider> --copilot --model <model>
72
+ codexs add <provider> --copilot --profile <model-provider-id> --model <model>
69
73
  codexs switch <provider>
70
74
  codexs status
71
75
  codexs doctor
@@ -80,12 +84,13 @@ codexs migrate
80
84
 
81
85
  ## 当前产品判断
82
86
 
83
- `0.1.1` 的重点不是再加新命令,而是让用户在 README、help 和输出第一屏就能理解:
87
+ `0.1.1` 的重点不是再加新命令,而是让用户在 README、help 和输出第一屏就能理解:
88
+
89
+ - fresh install 应先走什么
90
+ - Copilot 路径和 direct 路径有什么区别
91
+ - 非交互命令为什么应显式传 `--profile`,以及 TTY 模式下哪些缺失项可以补问
92
+ - `migrate` 何时才该使用
93
+ - `status` / `doctor` 如何帮助定位下一步
94
+ - 当前运行态是用顶层 `model` 与 `model_provider` 选择活动路由
84
95
 
85
- - fresh install 应先走什么
86
- - Copilot 路径和 direct 路径有什么区别
87
- - `migrate` 何时才该使用
88
- - `status` / `doctor` 如何帮助定位下一步
89
- - 当前运行态是用顶层 `model` 与 `model_provider` 选择活动路由
90
-
91
- `0.1.3` 是当前已发布的 Copilot login hotfix 线。当前实现边界是:Copilot 路径要求 Node.js `>=20`,受管安装默认固定到 `@github/copilot-sdk@1.0.2`,运行时会额外拒绝过旧版本和 prerelease 版本,并通过显式 `RuntimeConnection.forStdio({ path })` 把官方 SDK 连接到受管安装中的 Copilot runtime loader;本地 bridge 仍然只是面向 simple text-oriented turns 的 experimental bridge。Direct provider 路径继续支持 Node.js `>=18`。
96
+ `0.1.5` 是当前仓库开发线,重点不是扩展 provider 面,而是让已有 Copilot bridge 实验路径具备过程可见性:SDK 事件被归一化为稳定运行态事件,Responses 流可以显示 commentary/reasoning 信号,未知事件摘要会被脱敏和截断。当前实现边界仍然是:Copilot 路径要求 Node.js `>=20`,受管安装默认固定到 `@github/copilot-sdk@1.0.2`,本地 bridge 仍然只是面向 simple text-oriented turns 的 experimental bridge;Direct provider 路径继续支持 Node.js `>=18`。
@@ -7,10 +7,12 @@
7
7
  - [`PRD/codex-switch-prd-v0.1.1.md`](./PRD/codex-switch-prd-v0.1.1.md)
8
8
  - [`PRD/codex-switch-prd-v0.1.2.md`](./PRD/codex-switch-prd-v0.1.2.md)
9
9
  - [`PRD/codex-switch-prd-v0.1.3.md`](./PRD/codex-switch-prd-v0.1.3.md)
10
+ - [`PRD/codex-switch-prd-v0.1.5.md`](./PRD/codex-switch-prd-v0.1.5.md)
10
11
  - [`Design/codex-switch-v0.1.0-design.md`](./Design/codex-switch-v0.1.0-design.md)
11
12
  - [`Design/codex-switch-v0.1.1-design.md`](./Design/codex-switch-v0.1.1-design.md)
12
13
  - [`Design/codex-switch-v0.1.2-design.md`](./Design/codex-switch-v0.1.2-design.md)
13
14
  - [`Design/codex-switch-v0.1.3-design.md`](./Design/codex-switch-v0.1.3-design.md)
15
+ - [`Design/codex-switch-v0.1.5-design.md`](./Design/codex-switch-v0.1.5-design.md)
14
16
 
15
17
  ## Layers
16
18
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@minniexcode/codex-switch",
3
- "version": "0.1.3",
4
- "description": "Local-first CLI for managing and switching Codex provider/model-provider routing.",
3
+ "version": "0.1.5",
4
+ "description": "Local-first CLI for managing and switching Codex provider/model-provider routing.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
7
7
  "bin": {