@minniexcode/codex-switch 0.0.11 → 0.0.12

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 CHANGED
@@ -1,61 +1,53 @@
1
1
  # AI README
2
2
 
3
- This file is for AI agents, automation scripts, and contributors who need a compact operational summary of the repository.
3
+ This file summarizes the current operational contract for AI agents, automation scripts, and contributors.
4
4
 
5
- ## Repository Purpose
5
+ ## Package Context
6
6
 
7
- `@minniexcode/codex-switch` is a local-first TypeScript CLI for managing provider/profile state for Codex while keeping codex-switch tool state separate from the target Codex runtime.
7
+ - Package: `@minniexcode/codex-switch`
8
+ - CLI name: `codexs`
9
+ - Current repository version: `0.0.12`
10
+ - Version status: development-version software, not a stable `0.1.0` release yet
8
11
 
9
- Primary goals:
12
+ ## Product Role
10
13
 
11
- - safe local profile switching
12
- - backup-before-write mutation flows
13
- - rollback on failure
14
- - stable machine-readable CLI output
15
- - support for both human TTY usage and agent automation
16
- - explicit onboarding for interactive upstreams such as GitHub Copilot
14
+ `codex-switch` is a local-first TypeScript CLI that manages provider and profile state for Codex while keeping tool-managed state separate from the target Codex runtime.
17
15
 
18
- ## Main Command Surface
16
+ The managed source of truth is the tool home. Runtime files under the target Codex directory are projected outputs, not the main registry.
17
+
18
+ ## Primary Workflows
19
+
20
+ Direct provider workflow:
19
21
 
20
22
  ```bash
21
23
  codexs init
22
- codexs login copilot
23
- codexs migrate
24
- codexs list
25
- codexs show <provider>
26
- codexs current
27
- codexs status
28
- codexs config show [profile]
29
- codexs config list-profiles
30
- codexs edit <provider>
24
+ codexs add <provider> --profile <name> --api-key <key>
31
25
  codexs switch <provider>
32
- codexs import <file>
33
- codexs export <file>
34
- codexs add <provider>
35
- codexs remove <provider>
36
- codexs bridge start [provider]
37
- codexs bridge status [provider]
38
- codexs bridge stop [provider]
39
- codexs backups list
26
+ codexs status
40
27
  codexs doctor
41
- codexs rollback [backup-id]
42
28
  ```
43
29
 
44
- Shared flags:
30
+ GitHub Copilot workflow:
45
31
 
46
32
  ```bash
47
- --json
48
- --codex-dir <path>
33
+ codexs init
34
+ codexs login copilot
35
+ codexs add <provider> --copilot --profile <name>
36
+ codexs switch <provider>
37
+ codexs status
38
+ codexs doctor
49
39
  ```
50
40
 
51
- Relevant environment variables:
41
+ Advanced adopt workflow:
52
42
 
53
43
  ```bash
54
- CODEXS_HOME
55
- CODEXS_CODEX_DIR
44
+ codexs init
45
+ codexs migrate
56
46
  ```
57
47
 
58
- ## Important Files
48
+ `migrate` is not a fresh-install default. It is an advanced adopt helper for existing runtime state.
49
+
50
+ ## Important Paths
59
51
 
60
52
  Tool home:
61
53
 
@@ -76,77 +68,43 @@ Target Codex runtime:
76
68
  auth.json
77
69
  ```
78
70
 
79
- Operational model:
71
+ Operational meaning:
80
72
 
81
- - `providers.json` is the management-state source of truth
82
- - `codex-switch.json` stores tool-level metadata such as `defaultCodexDir`
83
- - `config.toml` remains the managed runtime-routing file in the target Codex directory
84
- - `auth.json` remains the active auth projection file
85
- - `runtime/` stores managed bridge runtime state
86
- - `runtimes/` stores optional local runtimes such as the Copilot SDK install
87
- - mutating commands back up first and run under a lightweight file lock in the tool home
73
+ - `providers.json` is the managed provider registry.
74
+ - `codex-switch.json` stores tool-level metadata such as the default target Codex directory.
75
+ - `config.toml` is the active runtime routing file.
76
+ - `auth.json` is the active auth projection file.
88
77
 
89
- ## Project Structure
78
+ ## Command Notes
90
79
 
91
- ```text
92
- src/
93
- app/
94
- cli/
95
- commands/
96
- domain/
97
- interaction/
98
- runtime/
99
- storage/
100
- tests/
101
- docs/
102
- dist/
103
- ```
104
-
105
- Layer intent:
106
-
107
- - `cli`: output shaping and thin CLI-facing utilities
108
- - `commands`: argument parsing, help rendering, and command dispatch
109
- - `app`: command orchestration and use-case logic
110
- - `domain`: pure domain rules and shared models
111
- - `interaction`: TTY-only prompt flows
112
- - `runtime`: Codex/Copilot runtime probing and local bridge management
113
- - `storage`: filesystem-backed repositories and path resolution
80
+ Shared flags:
114
81
 
115
- ## Command Entry Point
82
+ ```bash
83
+ --json
84
+ --codex-dir <path>
85
+ --help
86
+ --version
87
+ ```
116
88
 
117
- Use `codexs` directly for runtime interaction:
89
+ Relevant environment variables:
118
90
 
119
91
  ```bash
120
- codexs --help
121
- codexs list --json
122
- codexs status --json
123
- codexs config list-profiles --json
92
+ CODEXS_HOME
93
+ CODEXS_CODEX_DIR
124
94
  ```
125
95
 
126
- ## Current Version Context
96
+ Important behavioral constraints:
127
97
 
128
- Current package version in this repository:
98
+ - Prefer `--json` for programmatic invocation whenever the command supports it.
99
+ - `login copilot` requires a real TTY and does not support `--json`.
100
+ - `login copilot` currently installs the local Copilot SDK when needed, tries the bundled runtime CLI first, falls back to `PATH` when necessary, and rechecks auth readiness before reporting success.
101
+ - `add --copilot` assumes SDK install and upstream Copilot auth are already ready.
102
+ - `migrate` still depends on interactive profile selection and provider-detail collection in this release.
103
+ - `status` is the main dual-path summary command.
104
+ - `doctor` is the deeper repair-oriented diagnostic command.
129
105
 
130
- ```text
131
- 0.0.11
132
- ```
106
+ ## Safety Notes
133
107
 
134
- Recent version summary:
135
-
136
- - `0.0.11`: tool-home split, `login copilot`, managed bridge commands, and config inspection commands
137
- - `0.0.10`: `init` / `migrate` command split finalized and `setup` deprecated
138
- - `0.0.7`: command-surface refactor and setup split groundwork
139
- - `0.0.4`: setup/show/edit/backups list/specific rollback/import merge and clearer CLI semantics
140
- - `0.0.3`: interactive TTY flows and improved help
141
- - `0.0.2`: mutation orchestration, backups, rollback, locks, drift detection improvements
142
- - `0.0.1`: initial TypeScript CLI and baseline docs
143
-
144
- ## Notes For Agents
145
-
146
- - Prefer `--json` when invoking commands programmatically
147
- - Treat `providers.json` as sensitive because it may contain API keys
148
- - Do not assume silent write-back from runtime files into `providers.json`
149
- - Prefer `init` for repeatable tool-home setup and `migrate` for human-led adopt flows
150
- - `login copilot` requires a real TTY and should not be used under `--json`
151
- - `add --copilot` assumes SDK install and upstream auth readiness are already satisfied
152
- - Use `docs/` for deeper product and architecture context
108
+ - Treat `providers.json` as sensitive because it may contain API keys.
109
+ - Human-readable output may mask secrets, but JSON output can expose full provider payloads.
110
+ - Managed write operations rely on backup and rollback flow; do not describe manual file edits as the primary workflow.
package/README.CN.md CHANGED
@@ -1,140 +1,105 @@
1
1
  # @minniexcode/codex-switch
2
2
 
3
- `@minniexcode/codex-switch` 是一个本地优先的 CLI,用来安全地管理和切换 Codex 的 provider/profile 配置。
3
+ `@minniexcode/codex-switch` 是一个本地优先的 CLI,用来安全地管理和切换 Codex 的 providerprofile 配置。
4
4
 
5
- `0.0.11` 开始,它不再把整个管理态都塞进 `~/.codex/`,而是把工具自己的状态拆到独立的 tool home 里,同时继续对目标 Codex runtime 做受控写入。
5
+ 它把 `codex-switch` 自己的工具状态和目标 Codex runtime 明确分开,让 provider 管理、备份与 runtime 投影有一套受管流程,而不是依赖手工改文件。
6
6
 
7
- ## 这个仓库是做什么的
7
+ ## 版本定位
8
8
 
9
- 这个仓库包含 `codex-switch` 的 CLI 实现、npm 包配置,以及相关产品和技术文档。
9
+ 当前包版本:`0.0.12`
10
10
 
11
- 项目目标:
11
+ 当前仍处于开发版本阶段。这个版本的重点不是继续扩命令面,而是把主工作流、帮助文案和实际行为统一到同一套契约上。
12
12
 
13
- - 在本地完成 provider/profile 管理与切换
14
- - 写入前先备份
15
- - 出错时可回滚
16
- - 同时兼顾终端用户和 AI/自动化调用
17
- - 为 GitHub Copilot 这类交互式上游登录提供独立入口
18
-
19
- ## 现在可以做什么
20
-
21
- 当前公开命令面如下:
22
-
23
- ```bash
24
- codexs init
25
- codexs login copilot
26
- codexs migrate
27
- codexs list
28
- codexs show <provider>
29
- codexs current
30
- codexs status
31
- codexs config show [profile]
32
- codexs config list-profiles
33
- codexs edit <provider>
34
- codexs switch <provider>
35
- codexs import <file>
36
- codexs export <file>
37
- codexs add <provider>
38
- codexs remove <provider>
39
- codexs bridge start [provider]
40
- codexs bridge status [provider]
41
- codexs bridge stop [provider]
42
- codexs backups list
43
- codexs doctor
44
- codexs rollback [backup-id]
45
- codexs setup
46
- ```
47
-
48
- 对应能力包括:
49
-
50
- - 初始化独立的 tool home 与空的受管 `providers.json`
51
- - 从已有 `config.toml` adopt 可管理的 runtime profile
52
- - 查看本地已管理 provider
53
- - 查看结构化 config profile 视图
54
- - 编辑、切换、导入、导出、删除 provider
55
- - 为 GitHub Copilot 完成上游 SDK 安装与登录检查
56
- - 显式启动、查看和停止本地 Copilot bridge
57
- - 检查配置漂移和常见本地问题
58
- - 在变更前自动备份,并在失败时回滚
59
- - 保留 `setup` 作为弃用入口,并引导到 `init` / `migrate`
60
-
61
- ## 简单用法
62
-
63
- 全局安装:
13
+ ## 安装
64
14
 
65
15
  ```bash
66
16
  npm install -g @minniexcode/codex-switch
67
17
  ```
68
18
 
69
- 或者直接执行:
19
+ 不全局安装时也可以直接运行:
70
20
 
71
21
  ```bash
72
22
  npx @minniexcode/codex-switch --help
73
23
  ```
74
24
 
75
- 检查 CLI 是否可用:
25
+ CLI 命令名:
76
26
 
77
27
  ```bash
78
28
  codexs --help
79
29
  ```
80
30
 
81
- 典型使用方式:
31
+ ## 主工作流
32
+
33
+ Direct provider 主路径:
82
34
 
83
35
  ```bash
84
36
  codexs init
85
- codexs migrate
86
- codexs list
87
- codexs config show
88
37
  codexs add my-provider --profile my-provider --api-key sk-xxx
89
38
  codexs switch my-provider
90
39
  codexs status
40
+ codexs doctor
91
41
  ```
92
42
 
93
- GitHub Copilot 路径:
43
+ GitHub Copilot 主路径:
94
44
 
95
45
  ```bash
46
+ codexs init
96
47
  codexs login copilot
97
48
  codexs add copilot-main --copilot --profile copilot-main
98
- codexs bridge start copilot-main
49
+ codexs switch copilot-main
50
+ codexs status
51
+ codexs doctor
99
52
  ```
100
53
 
101
- 给脚本或 AI 使用时建议加上:
102
-
103
- ```bash
104
- codexs list --json
105
- codexs status --json
106
- codexs config list-profiles --json
107
- ```
54
+ 说明:
108
55
 
109
- 通用参数:
56
+ - `init` 负责初始化 `codex-switch` 的 tool home 与受管状态文件。
57
+ - `login copilot` 负责上游 Copilot onboarding 和登录可用性检查。
58
+ - `add --copilot` 不负责替你登录,它假设上游 Copilot 已经 ready。
59
+ - `status` 是切换后的主读取命令。
60
+ - `doctor` 是主诊断命令,用于解释问题和下一步修复动作。
110
61
 
111
- ```bash
112
- --json
113
- --codex-dir <path>
114
- ```
62
+ ## Advanced Adopt 路径
115
63
 
116
- 环境变量:
64
+ 如果你已经有现成的 Codex runtime 状态,希望把它 adopt 到受管 `providers.json`,再使用:
117
65
 
118
66
  ```bash
119
- CODEXS_HOME
120
- CODEXS_CODEX_DIR
67
+ codexs init
68
+ codexs migrate
121
69
  ```
122
70
 
123
- ## 交互式体验
71
+ `migrate` 是高级 adopt helper,不是 fresh install 的默认第一步。
124
72
 
125
- 这个 CLI 同时支持显式命令和交互式终端流程。
73
+ ## 命令面
126
74
 
127
- - `codexs add` 在 TTY 里会补问缺失的必填项
128
- - `codexs switch` 在未传 provider 时可以弹出选择列表
129
- - `codexs remove` 支持交互式选择和确认删除
130
- - `import`、`export`、`rollback` 在交互模式下会要求确认
131
- - `login copilot` 必须在真实 TTY 中执行
132
- - `migrate` 当前仍保留交互式 adopt 语义
133
- - `--json` 模式保持非交互,适合自动化
75
+ ```bash
76
+ codexs init
77
+ codexs login copilot
78
+ codexs migrate
79
+ codexs list
80
+ codexs show <provider>
81
+ codexs current
82
+ codexs status
83
+ codexs config show [profile]
84
+ codexs config list-profiles
85
+ codexs add <provider> --profile <name> --api-key <key>
86
+ codexs add <provider> --copilot --profile <name>
87
+ codexs edit <provider>
88
+ codexs switch <provider>
89
+ codexs remove <provider> [--force] [--switch-to <profile>]
90
+ codexs import <file>
91
+ codexs export <file> [--force]
92
+ codexs bridge start [provider]
93
+ codexs bridge status [provider]
94
+ codexs bridge stop [provider]
95
+ codexs backups list
96
+ codexs rollback [backup-id]
97
+ codexs doctor
98
+ ```
134
99
 
135
- ## 管理哪些文件
100
+ `setup` 仍然存在,但只作为已弃用兼容入口,用来提示调用方改用 `init` 或 `migrate`。
136
101
 
137
- `0.0.11` 开始,`codex-switch` 使用双路径模型。
102
+ ## 双路径模型
138
103
 
139
104
  tool home:
140
105
 
@@ -155,61 +120,60 @@ tool home:
155
120
  auth.json
156
121
  ```
157
122
 
158
- 存储模型:
123
+ 关键边界:
159
124
 
160
- - `providers.json` 是管理态的单一事实来源,位于 tool home
161
- - `codex-switch.json` 存放工具级配置,例如 `defaultCodexDir`
162
- - `config.toml` 是目标 Codex runtime 的受管路由文件
163
- - `auth.json` 是当前认证投影文件
164
- - `backups/latest.json` 记录最近一次可回滚窗口
165
- - `runtime/` 保存受管 bridge runtime state
166
- - `runtimes/` 用于存放可选本地 runtime,例如 Copilot SDK
125
+ - `providers.json` 是受管 provider 注册表,位于 tool home
126
+ - `codex-switch.json` 保存工具级元数据,例如 `defaultCodexDir`。
127
+ - `config.toml` 仍然是目标 runtime 里的活动路由文件。
128
+ - `auth.json` 仍然是目标 runtime 里的活动认证投影文件。
129
+ - Direct provider 切换会改写活动 runtime 中的 `OPENAI_API_KEY`。
130
+ - Copilot provider 保持上游 GitHub 登录留在官方 Copilot runtime 中,`codex-switch` 只管理本地 bridge 状态与路由。
167
131
 
168
- 注意:`providers.json` 可能包含 API key,本地使用时应视为敏感文件。
132
+ 路径控制:
169
133
 
170
- ## 最近版本更新
134
+ - `--codex-dir <path>` 显式指定目标 Codex runtime 目录。
135
+ - `CODEXS_CODEX_DIR` 在未传 `--codex-dir` 时提供默认目标目录。
136
+ - `CODEXS_HOME` 用于覆盖 tool home 位置。
171
137
 
172
- ### 0.0.11
138
+ ## 自动化说明
173
139
 
174
- - 引入独立 tool home,正式把管理态从 `~/.codex` 中拆出
175
- - 新增 `login copilot`,把 GitHub Copilot 上游登录从 `add --copilot` 中解耦
176
- - 新增 `bridge start/status/stop` 与 `config show/list-profiles`
177
- - README、CLI usage 和发布元数据统一按新命令契约更新
140
+ 这个 CLI 同时支持人类终端使用和非交互自动化。
178
141
 
179
- ### 0.0.10
142
+ 全局参数:
180
143
 
181
- - 正式拆分 `setup`:新增 `init` 和 `migrate`,`setup` 变为弃用命令
182
- - 收紧迁移、诊断、回滚和发布正确性边界
183
- - 清理 provider/runtime 管理语义,CLI 聚焦静态 profile 与 `base_url` 层配置
184
-
185
- ### 0.0.7
186
-
187
- - 完成 command-surface 重构
188
- - 校正 env key / auth mirror 相关模型
189
- - 推进 `setup` 向 `init` + `migrate` 的拆分
144
+ ```bash
145
+ --json
146
+ --codex-dir <path>
147
+ --help
148
+ --version
149
+ ```
190
150
 
191
- ## 相关文档
151
+ 当前实现边界:
192
152
 
193
- - [English README](./README.md)
194
- - [AI README](./README.AI.md)
195
- - [详细 CLI 文档](./docs/cli-usage.md)
196
- - [产品概览](./docs/codex-switch-product-overview.md)
197
- - [产品调研](./docs/codex-switch-product-research.md)
198
- - [PRD 0.0.11](./docs/PRD/codex-switch-prd-v0.0.11.md)
199
- - [技术架构](./docs/codex-switch-technical-architecture.md)
200
- - [0.0.11 设计文档](./docs/Design/codex-switch-v0.0.11-design.md)
201
- - [测试说明](./docs/Tests/testing.md)
153
+ - `login copilot` 必须运行在真实 TTY 下,不支持 `--json`。
154
+ - `migrate` 在当前版本仍然依赖交互式 profile 选择和 provider 细节补全。
155
+ - 自动化调用应尽量显式传参,并优先使用 `--json`。
202
156
 
203
157
  ## 本地开发
204
158
 
205
159
  ```bash
206
- npm install
207
160
  npm run build
208
161
  npm test
209
162
  npx tsc --noEmit
210
163
  node dist/cli.js --help
164
+ npm pack --dry-run
211
165
  ```
212
166
 
167
+ ## 相关文档
168
+
169
+ - [English README](./README.md)
170
+ - [AI README](./README.AI.md)
171
+ - [详细 CLI 文档](./docs/cli-usage.md)
172
+ - [产品概览](./docs/codex-switch-product-overview.md)
173
+ - [测试说明](./docs/Tests/testing.md)
174
+ - [PRD 0.0.12](./docs/PRD/codex-switch-prd-v0.0.12.md)
175
+ - [Release Gate PRD 0.1.0](./docs/PRD/codex-switch-prd-v0.1.0.md)
176
+
213
177
  ## License
214
178
 
215
179
  MIT