@minniexcode/codex-switch 0.0.11 → 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.
package/README.AI.md CHANGED
@@ -1,152 +1,110 @@
1
- # AI README
2
-
3
- This file is for AI agents, automation scripts, and contributors who need a compact operational summary of the repository.
4
-
5
- ## Repository Purpose
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.
8
-
9
- Primary goals:
10
-
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
17
-
18
- ## Main Command Surface
19
-
20
- ```bash
21
- 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>
31
- 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
40
- codexs doctor
41
- codexs rollback [backup-id]
42
- ```
43
-
44
- Shared flags:
45
-
46
- ```bash
47
- --json
48
- --codex-dir <path>
49
- ```
50
-
51
- Relevant environment variables:
52
-
53
- ```bash
54
- CODEXS_HOME
55
- CODEXS_CODEX_DIR
56
- ```
57
-
58
- ## Important Files
59
-
60
- Tool home:
61
-
62
- ```text
63
- ~/.config/codex-switch/
64
- codex-switch.json
65
- providers.json
66
- backups/
67
- runtime/
68
- runtimes/
69
- ```
70
-
71
- Target Codex runtime:
72
-
73
- ```text
74
- ~/.codex/
75
- config.toml
76
- auth.json
77
- ```
78
-
79
- Operational model:
80
-
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
88
-
89
- ## Project Structure
90
-
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
114
-
115
- ## Command Entry Point
116
-
117
- Use `codexs` directly for runtime interaction:
118
-
119
- ```bash
120
- codexs --help
121
- codexs list --json
122
- codexs status --json
123
- codexs config list-profiles --json
124
- ```
125
-
126
- ## Current Version Context
127
-
128
- Current package version in this repository:
129
-
130
- ```text
131
- 0.0.11
132
- ```
133
-
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
1
+ # AI README
2
+
3
+ This file summarizes the current operational contract for AI agents, automation scripts, and contributors.
4
+
5
+ ## Package Context
6
+
7
+ - Package: `@minniexcode/codex-switch`
8
+ - CLI name: `codexs`
9
+ - Current repository version: `0.1.0`
10
+ - Version status: stable release line
11
+
12
+ ## Product Role
13
+
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.
15
+
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:
21
+
22
+ ```bash
23
+ codexs init
24
+ codexs add <provider> --profile <name> --api-key <key>
25
+ codexs switch <provider>
26
+ codexs status
27
+ codexs doctor
28
+ ```
29
+
30
+ GitHub Copilot workflow:
31
+
32
+ ```bash
33
+ codexs init
34
+ codexs login copilot
35
+ codexs add <provider> --copilot --profile <name>
36
+ codexs switch <provider>
37
+ codexs status
38
+ codexs doctor
39
+ ```
40
+
41
+ Advanced adopt workflow:
42
+
43
+ ```bash
44
+ codexs init
45
+ codexs migrate
46
+ ```
47
+
48
+ `migrate` is not a fresh-install default. It is an advanced adopt helper for existing runtime state.
49
+
50
+ ## Important Paths
51
+
52
+ Tool home:
53
+
54
+ ```text
55
+ ~/.config/codex-switch/
56
+ codex-switch.json
57
+ providers.json
58
+ backups/
59
+ runtime/
60
+ runtimes/
61
+ ```
62
+
63
+ Target Codex runtime:
64
+
65
+ ```text
66
+ ~/.codex/
67
+ config.toml
68
+ auth.json
69
+ ```
70
+
71
+ Operational meaning:
72
+
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.
77
+
78
+ ## Command Notes
79
+
80
+ Shared flags:
81
+
82
+ ```bash
83
+ --json
84
+ --codex-dir <path>
85
+ --help
86
+ --version
87
+ ```
88
+
89
+ Relevant environment variables:
90
+
91
+ ```bash
92
+ CODEXS_HOME
93
+ CODEXS_CODEX_DIR
94
+ ```
95
+
96
+ Important behavioral constraints:
97
+
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` remains interactive when provider adoption requires human input.
103
+ - `status` is the main dual-path summary command.
104
+ - `doctor` is the deeper repair-oriented diagnostic command.
105
+
106
+ ## Safety Notes
107
+
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,215 +1,179 @@
1
- # @minniexcode/codex-switch
2
-
3
- `@minniexcode/codex-switch` 是一个本地优先的 CLI,用来安全地管理和切换 Codex 的 provider/profile 配置。
4
-
5
- `0.0.11` 开始,它不再把整个管理态都塞进 `~/.codex/`,而是把工具自己的状态拆到独立的 tool home 里,同时继续对目标 Codex runtime 做受控写入。
6
-
7
- ## 这个仓库是做什么的
8
-
9
- 这个仓库包含 `codex-switch` 的 CLI 实现、npm 包配置,以及相关产品和技术文档。
10
-
11
- 项目目标:
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
- 全局安装:
64
-
65
- ```bash
66
- npm install -g @minniexcode/codex-switch
67
- ```
68
-
69
- 或者直接执行:
70
-
71
- ```bash
72
- npx @minniexcode/codex-switch --help
73
- ```
74
-
75
- 检查 CLI 是否可用:
76
-
77
- ```bash
78
- codexs --help
79
- ```
80
-
81
- 典型使用方式:
82
-
83
- ```bash
84
- codexs init
85
- codexs migrate
86
- codexs list
87
- codexs config show
88
- codexs add my-provider --profile my-provider --api-key sk-xxx
89
- codexs switch my-provider
90
- codexs status
91
- ```
92
-
93
- GitHub Copilot 路径:
94
-
95
- ```bash
96
- codexs login copilot
97
- codexs add copilot-main --copilot --profile copilot-main
98
- codexs bridge start copilot-main
99
- ```
100
-
101
- 给脚本或 AI 使用时建议加上:
102
-
103
- ```bash
104
- codexs list --json
105
- codexs status --json
106
- codexs config list-profiles --json
107
- ```
108
-
109
- 通用参数:
110
-
111
- ```bash
112
- --json
113
- --codex-dir <path>
114
- ```
115
-
116
- 环境变量:
117
-
118
- ```bash
119
- CODEXS_HOME
120
- CODEXS_CODEX_DIR
121
- ```
122
-
123
- ## 交互式体验
124
-
125
- 这个 CLI 同时支持显式命令和交互式终端流程。
126
-
127
- - `codexs add` TTY 里会补问缺失的必填项
128
- - `codexs switch` 在未传 provider 时可以弹出选择列表
129
- - `codexs remove` 支持交互式选择和确认删除
130
- - `import`、`export`、`rollback` 在交互模式下会要求确认
131
- - `login copilot` 必须在真实 TTY 中执行
132
- - `migrate` 当前仍保留交互式 adopt 语义
133
- - `--json` 模式保持非交互,适合自动化
134
-
135
- ## 管理哪些文件
136
-
137
- 从 `0.0.11` 开始,`codex-switch` 使用双路径模型。
138
-
139
- tool home:
140
-
141
- ```text
142
- ~/.config/codex-switch/
143
- codex-switch.json
144
- providers.json
145
- backups/
146
- runtime/
147
- runtimes/
148
- ```
149
-
150
- 目标 Codex runtime:
151
-
152
- ```text
153
- ~/.codex/
154
- config.toml
155
- auth.json
156
- ```
157
-
158
- 存储模型:
159
-
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
167
-
168
- 注意:`providers.json` 可能包含 API key,本地使用时应视为敏感文件。
169
-
170
- ## 最近版本更新
171
-
172
- ### 0.0.11
173
-
174
- - 引入独立 tool home,正式把管理态从 `~/.codex` 中拆出
175
- - 新增 `login copilot`,把 GitHub Copilot 上游登录从 `add --copilot` 中解耦
176
- - 新增 `bridge start/status/stop` 与 `config show/list-profiles`
177
- - README、CLI usage 和发布元数据统一按新命令契约更新
178
-
179
- ### 0.0.10
180
-
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` 的拆分
190
-
191
- ## 相关文档
192
-
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)
202
-
203
- ## 本地开发
204
-
205
- ```bash
206
- npm install
207
- npm run build
208
- npm test
209
- npx tsc --noEmit
210
- node dist/cli.js --help
211
- ```
212
-
213
- ## License
214
-
215
- MIT
1
+ # @minniexcode/codex-switch
2
+
3
+ `@minniexcode/codex-switch` 是一个本地优先的 CLI,用来安全地管理和切换 Codex 的 providerprofile 配置。
4
+
5
+ 它把 `codex-switch` 自己的工具状态和目标 Codex runtime 明确分开,让 provider 管理、备份与 runtime 投影有一套受管流程,而不是依赖手工改文件。
6
+
7
+ ## 版本定位
8
+
9
+ 当前包版本:`0.1.0`
10
+
11
+ 这是第一条稳定发布线。这个版本的重点不是继续扩命令面,而是把主工作流、帮助文案、实际行为和发布文档统一到同一套契约上。
12
+
13
+ ## 安装
14
+
15
+ ```bash
16
+ npm install -g @minniexcode/codex-switch
17
+ ```
18
+
19
+ 不全局安装时也可以直接运行:
20
+
21
+ ```bash
22
+ npx @minniexcode/codex-switch --help
23
+ ```
24
+
25
+ CLI 命令名:
26
+
27
+ ```bash
28
+ codexs --help
29
+ ```
30
+
31
+ ## 主工作流
32
+
33
+ Direct provider 主路径:
34
+
35
+ ```bash
36
+ codexs init
37
+ codexs add my-provider --profile my-provider --api-key sk-xxx
38
+ codexs switch my-provider
39
+ codexs status
40
+ codexs doctor
41
+ ```
42
+
43
+ GitHub Copilot 主路径:
44
+
45
+ ```bash
46
+ codexs init
47
+ codexs login copilot
48
+ codexs add copilot-main --copilot --profile copilot-main
49
+ codexs switch copilot-main
50
+ codexs status
51
+ codexs doctor
52
+ ```
53
+
54
+ 说明:
55
+
56
+ - `init` 负责初始化 `codex-switch` 的 tool home 与受管状态文件。
57
+ - `login copilot` 负责上游 Copilot onboarding 和登录可用性检查。
58
+ - `add --copilot` 不负责替你登录,它假设上游 Copilot 已经 ready。
59
+ - `status` 是切换后的主读取命令。
60
+ - `doctor` 是主诊断命令,用于解释问题和下一步修复动作。
61
+
62
+ ## Advanced Adopt 路径
63
+
64
+ 如果你已经有现成的 Codex runtime 状态,希望把它 adopt 到受管 `providers.json`,再使用:
65
+
66
+ ```bash
67
+ codexs init
68
+ codexs migrate
69
+ ```
70
+
71
+ `migrate` 是高级 adopt helper,不是 fresh install 的默认第一步。
72
+
73
+ ## 命令面
74
+
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
+ ```
99
+
100
+ `setup` 仍然存在,但只作为已弃用兼容入口,用来提示调用方改用 `init` 或 `migrate`。
101
+
102
+ ## 双路径模型
103
+
104
+ tool home:
105
+
106
+ ```text
107
+ ~/.config/codex-switch/
108
+ codex-switch.json
109
+ providers.json
110
+ backups/
111
+ runtime/
112
+ runtimes/
113
+ ```
114
+
115
+ 目标 Codex runtime:
116
+
117
+ ```text
118
+ ~/.codex/
119
+ config.toml
120
+ auth.json
121
+ ```
122
+
123
+ 关键边界:
124
+
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 状态与路由。
131
+
132
+ 路径控制:
133
+
134
+ - `--codex-dir <path>` 显式指定目标 Codex runtime 目录。
135
+ - `CODEXS_CODEX_DIR` 在未传 `--codex-dir` 时提供默认目标目录。
136
+ - `CODEXS_HOME` 用于覆盖 tool home 位置。
137
+
138
+ ## 自动化说明
139
+
140
+ 这个 CLI 同时支持人类终端使用和非交互自动化。
141
+
142
+ 全局参数:
143
+
144
+ ```bash
145
+ --json
146
+ --codex-dir <path>
147
+ --help
148
+ --version
149
+ ```
150
+
151
+ 当前实现边界:
152
+
153
+ - `login copilot` 必须运行在真实 TTY 下,不支持 `--json`。
154
+ - `migrate` 在需要人工补齐 adopt 信息时仍然保持交互式语义。
155
+ - 自动化调用应尽量显式传参,并优先使用 `--json`。
156
+
157
+ ## 本地开发
158
+
159
+ ```bash
160
+ npm run build
161
+ npm test
162
+ npx tsc --noEmit
163
+ node dist/cli.js --help
164
+ npm pack --dry-run
165
+ ```
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
+ - [Release PRD 0.1.0](./docs/PRD/codex-switch-prd-v0.1.0.md)
175
+ - [Release Gate PRD 0.1.0](./docs/PRD/codex-switch-prd-v0.1.0.md)
176
+
177
+ ## License
178
+
179
+ MIT