@minniexcode/codex-switch 0.0.5 → 0.0.6
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.md +35 -97
- package/dist/app/add-provider.js +10 -4
- package/dist/app/edit-provider.js +9 -9
- package/dist/app/export-providers.js +2 -2
- package/dist/app/get-current-profile.js +1 -1
- package/dist/app/get-status.js +2 -2
- package/dist/app/import-providers.js +15 -7
- package/dist/app/list-backups.js +1 -1
- package/dist/app/list-config-profiles.js +3 -2
- package/dist/app/list-providers.js +1 -1
- package/dist/app/remove-provider.js +2 -2
- package/dist/app/rollback-backup.js +1 -1
- package/dist/app/rollback-latest.js +1 -1
- package/dist/app/run-doctor.js +23 -6
- package/dist/app/run-mutation.js +2 -2
- package/dist/app/setup-codex.js +6 -6
- package/dist/app/show-config.js +2 -2
- package/dist/app/show-provider.js +1 -1
- package/dist/app/switch-provider.js +3 -3
- package/dist/cli/add-interactive.js +7 -106
- package/dist/cli/args.js +5 -137
- package/dist/cli/help.js +5 -313
- package/dist/cli/interactive.js +16 -227
- package/dist/cli/output.js +2 -2
- package/dist/cli/prompt.js +3 -108
- package/dist/cli.js +10 -404
- package/dist/commands/args.js +132 -0
- package/dist/commands/dispatch.js +16 -0
- package/dist/commands/handlers.js +391 -0
- package/dist/commands/help.js +119 -0
- package/dist/commands/registry.js +291 -0
- package/dist/commands/types.js +2 -0
- package/dist/domain/config.js +100 -23
- package/dist/infra/backup-repo.js +8 -208
- package/dist/infra/codex-cli.js +8 -128
- package/dist/infra/codex-paths.js +5 -69
- package/dist/infra/config-repo.js +59 -0
- package/dist/infra/fs-utils.js +7 -95
- package/dist/infra/lock-repo.js +3 -97
- package/dist/infra/providers-repo.js +7 -96
- package/dist/interaction/add-interactive.js +108 -0
- package/dist/interaction/interactive.js +216 -0
- package/dist/interaction/prompt.js +110 -0
- package/dist/runtime/codex-cli.js +130 -0
- package/dist/runtime/codex-probe.js +50 -0
- package/dist/runtime/types.js +2 -0
- package/dist/storage/backup-repo.js +210 -0
- package/dist/storage/codex-paths.js +71 -0
- package/dist/storage/config-repo.js +208 -0
- package/dist/storage/fs-utils.js +97 -0
- package/dist/storage/lock-repo.js +99 -0
- package/dist/storage/providers-repo.js +98 -0
- package/docs/Design/codex-switch-v0.0.5-design.md +32 -22
- package/docs/Design/codex-switch-v0.0.6-design.md +708 -0
- package/docs/PRD/codex-switch-prd-v0.0.5-to-v0.1.0.md +125 -93
- package/docs/PRD/codex-switch-prd-v0.1.0.md +200 -226
- package/docs/PRD/codex-switch-prd.md +1 -1
- package/docs/cli-usage.md +2 -1
- package/docs/codex-switch-technical-architecture.md +73 -4
- package/docs/test-report-0.0.5.md +163 -0
- package/docs/testing.md +131 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
## @minniexcode/codex-switch
|
|
2
2
|
|
|
3
3
|
`codex-switch` is a local-first CLI for managing and switching Codex provider/profile configuration safely.
|
|
4
4
|
|
|
5
|
-
`codex-switch` 是一个本地优先的 CLI,用来安全地管理和切换 Codex 的 provider/profile 配置。
|
|
6
|
-
|
|
7
5
|
It is designed for users who work with multiple Codex providers, API keys, or profiles and want a repeatable, backup-first workflow instead of manually editing files under `~/.codex/`.
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
中文版: [README.CN.md](./README.CN.md)
|
|
10
8
|
|
|
11
|
-
## Overview
|
|
9
|
+
## Overview
|
|
12
10
|
|
|
13
11
|
What it does:
|
|
14
12
|
|
|
@@ -17,22 +15,11 @@ What it does:
|
|
|
17
15
|
- Switch the active provider/profile safely
|
|
18
16
|
- Import and export provider definitions
|
|
19
17
|
- Run diagnostics and detect local drift
|
|
20
|
-
- List backups and
|
|
21
|
-
|
|
22
|
-
它可以完成的事情:
|
|
23
|
-
|
|
24
|
-
- 从现有 Codex 目录初始化 `providers.json`
|
|
25
|
-
- 查看、新增、编辑、删除 provider 记录
|
|
26
|
-
- 安全切换当前激活的 provider/profile
|
|
27
|
-
- 导入和导出 provider 配置
|
|
28
|
-
- 运行诊断并识别本地配置漂移
|
|
29
|
-
- 查看备份并回滚到之前的受管状态
|
|
30
|
-
|
|
31
|
-
Current version: `0.0.4`
|
|
18
|
+
- List backups and roll back to a previous managed state
|
|
32
19
|
|
|
33
|
-
|
|
20
|
+
Current version: `0.0.6`
|
|
34
21
|
|
|
35
|
-
## Install
|
|
22
|
+
## Install
|
|
36
23
|
|
|
37
24
|
Install globally:
|
|
38
25
|
|
|
@@ -46,31 +33,13 @@ Or run directly:
|
|
|
46
33
|
npx @minniexcode/codex-switch --help
|
|
47
34
|
```
|
|
48
35
|
|
|
49
|
-
全局安装:
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npm install -g @minniexcode/codex-switch
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
或者直接运行:
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
npx @minniexcode/codex-switch --help
|
|
59
|
-
```
|
|
60
|
-
|
|
61
36
|
CLI entry:
|
|
62
37
|
|
|
63
38
|
```bash
|
|
64
39
|
codexs --help
|
|
65
40
|
```
|
|
66
41
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
codexs --help
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Quick Start | 快速开始
|
|
42
|
+
## Quick Start
|
|
74
43
|
|
|
75
44
|
Take over an existing Codex directory:
|
|
76
45
|
|
|
@@ -78,12 +47,6 @@ Take over an existing Codex directory:
|
|
|
78
47
|
codexs setup
|
|
79
48
|
```
|
|
80
49
|
|
|
81
|
-
接管当前已有的 Codex 目录:
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
codexs setup
|
|
85
|
-
```
|
|
86
|
-
|
|
87
50
|
Inspect managed providers:
|
|
88
51
|
|
|
89
52
|
```bash
|
|
@@ -91,13 +54,6 @@ codexs list
|
|
|
91
54
|
codexs show my-provider
|
|
92
55
|
```
|
|
93
56
|
|
|
94
|
-
查看已管理的 provider:
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
codexs list
|
|
98
|
-
codexs show my-provider
|
|
99
|
-
```
|
|
100
|
-
|
|
101
57
|
Add and switch:
|
|
102
58
|
|
|
103
59
|
```bash
|
|
@@ -105,13 +61,6 @@ codexs add my-provider --profile my-provider --api-key sk-xxx
|
|
|
105
61
|
codexs switch my-provider
|
|
106
62
|
```
|
|
107
63
|
|
|
108
|
-
新增并切换:
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
codexs add my-provider --profile my-provider --api-key sk-xxx
|
|
112
|
-
codexs switch my-provider
|
|
113
|
-
```
|
|
114
|
-
|
|
115
64
|
Check runtime state:
|
|
116
65
|
|
|
117
66
|
```bash
|
|
@@ -120,15 +69,7 @@ codexs status
|
|
|
120
69
|
codexs doctor
|
|
121
70
|
```
|
|
122
71
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
codexs current
|
|
127
|
-
codexs status
|
|
128
|
-
codexs doctor
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Common Commands | 常用命令
|
|
72
|
+
## Common Commands
|
|
132
73
|
|
|
133
74
|
```bash
|
|
134
75
|
codexs setup
|
|
@@ -154,19 +95,10 @@ codexs help switch
|
|
|
154
95
|
codexs help setup
|
|
155
96
|
```
|
|
156
97
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
codexs help switch
|
|
161
|
-
codexs help setup
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
## How It Works | 工作方式
|
|
98
|
+
## How It Works
|
|
165
99
|
|
|
166
100
|
By default, `codex-switch` operates on `~/.codex/`, and you can override the target with `--codex-dir`.
|
|
167
101
|
|
|
168
|
-
`codex-switch` 默认围绕 `~/.codex/` 工作,也可以通过 `--codex-dir` 指向其他目录。
|
|
169
|
-
|
|
170
102
|
Managed files:
|
|
171
103
|
|
|
172
104
|
```text
|
|
@@ -177,23 +109,19 @@ Managed files:
|
|
|
177
109
|
backups/
|
|
178
110
|
```
|
|
179
111
|
|
|
180
|
-
|
|
112
|
+
Notes:
|
|
181
113
|
|
|
182
114
|
- `providers.json` is the managed provider registry
|
|
183
115
|
- `config.toml` and `auth.json` represent runtime state
|
|
184
116
|
- mutating commands back up before writing
|
|
185
117
|
- rollback is available after failed or undesired changes
|
|
186
118
|
|
|
187
|
-
|
|
188
|
-
- `config.toml` 和 `auth.json` 代表当前运行态
|
|
189
|
-
- 所有写操作都会先备份再写入
|
|
190
|
-
- 变更失败或结果不符合预期时可以回滚
|
|
191
|
-
|
|
192
|
-
## Automation | 自动化
|
|
119
|
+
## Automation
|
|
193
120
|
|
|
194
121
|
This CLI supports both human TTY use and non-interactive automation.
|
|
195
122
|
|
|
196
|
-
|
|
123
|
+
Current exception:
|
|
124
|
+
- `setup` in `0.0.6` is intentionally TTY-only for adopt initialization. It requires interactive profile selection and provider detail collection, and non-interactive/`--json` runs fail fast with a structured error.
|
|
197
125
|
|
|
198
126
|
Recommended global flags:
|
|
199
127
|
|
|
@@ -204,28 +132,38 @@ Recommended global flags:
|
|
|
204
132
|
--version
|
|
205
133
|
```
|
|
206
134
|
|
|
207
|
-
|
|
135
|
+
Recommendations:
|
|
208
136
|
|
|
209
137
|
- use `--json` for stable machine-readable output
|
|
210
138
|
- pass all required arguments explicitly in scripts or CI
|
|
211
139
|
- use `--codex-dir <path>` for sandbox or test environments
|
|
212
140
|
|
|
213
|
-
|
|
214
|
-
- 在非交互环境中显式传入所有必需参数
|
|
215
|
-
- 在测试环境中优先配合 `--codex-dir <path>` 使用
|
|
141
|
+
## Testing
|
|
216
142
|
|
|
217
|
-
|
|
143
|
+
Build and test locally:
|
|
218
144
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
145
|
+
```bash
|
|
146
|
+
npm run build
|
|
147
|
+
npm test
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The repository includes a development fixture under `dev-codex/local-sandbox` plus dedicated test docs:
|
|
151
|
+
|
|
152
|
+
- [Testing Guide](./docs/testing.md)
|
|
153
|
+
- [Test Report for 0.0.5](./docs/test-report-0.0.5.md)
|
|
154
|
+
|
|
155
|
+
## Documentation
|
|
156
|
+
|
|
157
|
+
- [Chinese README](./README.CN.md)
|
|
223
158
|
- [AI README](./README.AI.md)
|
|
224
|
-
- [
|
|
159
|
+
- [Detailed CLI Usage](./docs/cli-usage.md)
|
|
160
|
+
- [Testing Guide](./docs/testing.md)
|
|
161
|
+
- [Test Report for 0.0.5](./docs/test-report-0.0.5.md)
|
|
225
162
|
- [Product Overview](./docs/codex-switch-product-overview.md)
|
|
226
163
|
- [Technical Architecture](./docs/codex-switch-technical-architecture.md)
|
|
227
|
-
- [0.0.
|
|
164
|
+
- [Design Doc 0.0.5](./docs/Design/codex-switch-v0.0.5-design.md)
|
|
165
|
+
- [Design Doc 0.0.4](./docs/Design/codex-switch-v0.0.4-design.md)
|
|
228
166
|
|
|
229
|
-
## License
|
|
167
|
+
## License
|
|
230
168
|
|
|
231
169
|
MIT
|
package/dist/app/add-provider.js
CHANGED
|
@@ -4,9 +4,9 @@ exports.addProvider = addProvider;
|
|
|
4
4
|
const config_1 = require("../domain/config");
|
|
5
5
|
const providers_1 = require("../domain/providers");
|
|
6
6
|
const errors_1 = require("../domain/errors");
|
|
7
|
-
const config_repo_1 = require("../
|
|
8
|
-
const fs_utils_1 = require("../
|
|
9
|
-
const providers_repo_1 = require("../
|
|
7
|
+
const config_repo_1 = require("../storage/config-repo");
|
|
8
|
+
const fs_utils_1 = require("../storage/fs-utils");
|
|
9
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
10
10
|
const run_mutation_1 = require("./run-mutation");
|
|
11
11
|
/**
|
|
12
12
|
* Adds a new provider record to the managed providers registry.
|
|
@@ -29,10 +29,16 @@ function addProvider(args) {
|
|
|
29
29
|
? {
|
|
30
30
|
[args.profile]: (0, config_1.validateManagedProfileCreation)(args.profile, {
|
|
31
31
|
model: args.model ?? undefined,
|
|
32
|
-
|
|
32
|
+
modelProvider: args.profile,
|
|
33
33
|
}),
|
|
34
34
|
}
|
|
35
35
|
: undefined;
|
|
36
|
+
if (!existingProfile && args.createProfile) {
|
|
37
|
+
(0, config_repo_1.requireModelProviderRuntimeSection)(document, args.profile);
|
|
38
|
+
}
|
|
39
|
+
if (existingProfile) {
|
|
40
|
+
(0, config_repo_1.requireManagedProfileRuntime)(document, providers, args.profile);
|
|
41
|
+
}
|
|
36
42
|
const next = {
|
|
37
43
|
providers: {
|
|
38
44
|
...providers.providers,
|
|
@@ -4,9 +4,9 @@ exports.editProvider = editProvider;
|
|
|
4
4
|
const errors_1 = require("../domain/errors");
|
|
5
5
|
const config_1 = require("../domain/config");
|
|
6
6
|
const providers_1 = require("../domain/providers");
|
|
7
|
-
const config_repo_1 = require("../
|
|
8
|
-
const fs_utils_1 = require("../
|
|
9
|
-
const providers_repo_1 = require("../
|
|
7
|
+
const config_repo_1 = require("../storage/config-repo");
|
|
8
|
+
const fs_utils_1 = require("../storage/fs-utils");
|
|
9
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
10
10
|
const run_mutation_1 = require("./run-mutation");
|
|
11
11
|
/**
|
|
12
12
|
* Updates selected fields on a single managed provider.
|
|
@@ -60,23 +60,23 @@ function editProvider(args) {
|
|
|
60
60
|
upsertProfiles = {
|
|
61
61
|
[newProfile]: (0, config_1.validateManagedProfileCreation)(newProfile, {
|
|
62
62
|
model: args.model ?? undefined,
|
|
63
|
-
|
|
63
|
+
modelProvider: newProfile,
|
|
64
64
|
}),
|
|
65
65
|
};
|
|
66
|
+
(0, config_repo_1.requireModelProviderRuntimeSection)(document, newProfile);
|
|
66
67
|
}
|
|
67
|
-
else
|
|
68
|
+
else {
|
|
69
|
+
(0, config_repo_1.requireManagedProfileRuntime)(document, providers, newProfile);
|
|
70
|
+
}
|
|
71
|
+
if (targetProfileExists && args.model !== undefined) {
|
|
68
72
|
upsertProfiles = {
|
|
69
73
|
[newProfile]: {
|
|
70
74
|
...(args.model !== undefined && args.model !== null ? { model: args.model } : {}),
|
|
71
|
-
...(args.baseUrl !== undefined && args.baseUrl !== null ? { baseUrl: args.baseUrl } : {}),
|
|
72
75
|
},
|
|
73
76
|
};
|
|
74
77
|
if (args.model !== undefined && (targetSection?.model !== args.model) && !updatedFields.includes("model")) {
|
|
75
78
|
updatedFields.push("model");
|
|
76
79
|
}
|
|
77
|
-
if (args.baseUrl !== undefined && targetSection?.baseUrl !== args.baseUrl && !updatedFields.includes("baseUrl")) {
|
|
78
|
-
updatedFields.push("baseUrl");
|
|
79
|
-
}
|
|
80
80
|
}
|
|
81
81
|
const remainingLinksByProfile = new Map();
|
|
82
82
|
for (const [name, provider] of Object.entries(providers.providers)) {
|
|
@@ -37,8 +37,8 @@ exports.exportProviders = exportProviders;
|
|
|
37
37
|
const fs = __importStar(require("node:fs"));
|
|
38
38
|
const path = __importStar(require("node:path"));
|
|
39
39
|
const errors_1 = require("../domain/errors");
|
|
40
|
-
const fs_utils_1 = require("../
|
|
41
|
-
const providers_repo_1 = require("../
|
|
40
|
+
const fs_utils_1 = require("../storage/fs-utils");
|
|
41
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
42
42
|
/**
|
|
43
43
|
* Exports the current providers registry to a user-specified file.
|
|
44
44
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCurrentProfile = getCurrentProfile;
|
|
4
|
-
const config_repo_1 = require("../
|
|
4
|
+
const config_repo_1 = require("../storage/config-repo");
|
|
5
5
|
/**
|
|
6
6
|
* Returns the currently active top-level Codex profile.
|
|
7
7
|
*/
|
package/dist/app/get-status.js
CHANGED
|
@@ -37,8 +37,8 @@ exports.getStatus = getStatus;
|
|
|
37
37
|
const fs = __importStar(require("node:fs"));
|
|
38
38
|
const config_1 = require("../domain/config");
|
|
39
39
|
const runtime_state_1 = require("../domain/runtime-state");
|
|
40
|
-
const config_repo_1 = require("../
|
|
41
|
-
const providers_repo_1 = require("../
|
|
40
|
+
const config_repo_1 = require("../storage/config-repo");
|
|
41
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
42
42
|
/**
|
|
43
43
|
* Reports the current on-disk runtime state and how it maps back to managed providers.
|
|
44
44
|
*/
|
|
@@ -39,9 +39,9 @@ const path = __importStar(require("node:path"));
|
|
|
39
39
|
const config_1 = require("../domain/config");
|
|
40
40
|
const providers_1 = require("../domain/providers");
|
|
41
41
|
const errors_1 = require("../domain/errors");
|
|
42
|
-
const config_repo_1 = require("../
|
|
43
|
-
const fs_utils_1 = require("../
|
|
44
|
-
const providers_repo_1 = require("../
|
|
42
|
+
const config_repo_1 = require("../storage/config-repo");
|
|
43
|
+
const fs_utils_1 = require("../storage/fs-utils");
|
|
44
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
45
45
|
const run_mutation_1 = require("./run-mutation");
|
|
46
46
|
/**
|
|
47
47
|
* Imports provider definitions from an external JSON file into the managed registry.
|
|
@@ -83,13 +83,21 @@ function importProviders(args) {
|
|
|
83
83
|
const missingViews = nextViews.filter((view) => view.source === "orphaned-reference");
|
|
84
84
|
const repairedProfiles = [];
|
|
85
85
|
const upsertProfiles = missingViews.reduce((accumulator, view) => {
|
|
86
|
-
const
|
|
87
|
-
if (!
|
|
88
|
-
throw (0, errors_1.cliError)("MANAGED_PROFILE_FIELDS_MISSING", "Import would create provider references to missing config profiles that need model and
|
|
86
|
+
const sourceView = currentViews.find((entry) => entry.name === view.name) ?? null;
|
|
87
|
+
if (!sourceView?.model) {
|
|
88
|
+
throw (0, errors_1.cliError)("MANAGED_PROFILE_FIELDS_MISSING", "Import would create provider references to missing config profiles that need model and matching model_provider sections.", {
|
|
89
89
|
profilesNeedingRepair: missingViews.map((entry) => entry.name).sort(),
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
if (sourceView.modelProvider !== view.name || !sourceView.baseUrl) {
|
|
93
|
+
throw (0, errors_1.cliError)("MANAGED_PROFILE_FIELDS_MISSING", "Import would create provider references to missing config profiles without matching model_provider runtime sections.", {
|
|
94
|
+
profilesNeedingRepair: missingViews.map((entry) => entry.name).sort(),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
accumulator[view.name] = (0, config_1.validateManagedProfileCreation)(view.name, {
|
|
98
|
+
model: sourceView.model,
|
|
99
|
+
modelProvider: view.name,
|
|
100
|
+
});
|
|
93
101
|
repairedProfiles.push(view.name);
|
|
94
102
|
return accumulator;
|
|
95
103
|
}, {});
|
package/dist/app/list-backups.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listBackupEntries = listBackupEntries;
|
|
4
|
-
const backup_repo_1 = require("../
|
|
4
|
+
const backup_repo_1 = require("../storage/backup-repo");
|
|
5
5
|
/**
|
|
6
6
|
* Lists backup manifests available under the managed Codex backups directory.
|
|
7
7
|
*/
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listConfigProfilesView = listConfigProfilesView;
|
|
4
4
|
const config_1 = require("../domain/config");
|
|
5
|
-
const config_repo_1 = require("../
|
|
6
|
-
const providers_repo_1 = require("../
|
|
5
|
+
const config_repo_1 = require("../storage/config-repo");
|
|
6
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
7
7
|
/**
|
|
8
8
|
* Returns the lightweight config profile listing.
|
|
9
9
|
*/
|
|
@@ -16,6 +16,7 @@ function listConfigProfilesView(args) {
|
|
|
16
16
|
isActive: profile.isActive,
|
|
17
17
|
linkedProviders: profile.linkedProviders,
|
|
18
18
|
model: profile.model,
|
|
19
|
+
modelProvider: profile.modelProvider,
|
|
19
20
|
baseUrl: profile.baseUrl,
|
|
20
21
|
source: profile.source,
|
|
21
22
|
}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listProviders = listProviders;
|
|
4
|
-
const providers_repo_1 = require("../
|
|
4
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
5
5
|
/**
|
|
6
6
|
* Returns the sorted list of configured providers for display.
|
|
7
7
|
*/
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.removeProvider = removeProvider;
|
|
4
4
|
const errors_1 = require("../domain/errors");
|
|
5
5
|
const config_1 = require("../domain/config");
|
|
6
|
-
const config_repo_1 = require("../
|
|
7
|
-
const providers_repo_1 = require("../
|
|
6
|
+
const config_repo_1 = require("../storage/config-repo");
|
|
7
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
8
8
|
const run_mutation_1 = require("./run-mutation");
|
|
9
9
|
/**
|
|
10
10
|
* Removes a provider from the managed providers registry.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rollbackBackup = rollbackBackup;
|
|
4
4
|
const errors_1 = require("../domain/errors");
|
|
5
|
-
const backup_repo_1 = require("../
|
|
5
|
+
const backup_repo_1 = require("../storage/backup-repo");
|
|
6
6
|
/**
|
|
7
7
|
* Restores either the latest backup or a specific historical backup by id.
|
|
8
8
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rollbackLatest = rollbackLatest;
|
|
4
4
|
const errors_1 = require("../domain/errors");
|
|
5
|
-
const backup_repo_1 = require("../
|
|
5
|
+
const backup_repo_1 = require("../storage/backup-repo");
|
|
6
6
|
/**
|
|
7
7
|
* Restores the most recent mutation backup recorded by codex-switch.
|
|
8
8
|
*/
|
package/dist/app/run-doctor.js
CHANGED
|
@@ -37,10 +37,10 @@ exports.runDoctor = runDoctor;
|
|
|
37
37
|
const fs = __importStar(require("node:fs"));
|
|
38
38
|
const config_1 = require("../domain/config");
|
|
39
39
|
const runtime_state_1 = require("../domain/runtime-state");
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const providers_repo_1 = require("../infra/providers-repo");
|
|
40
|
+
const config_repo_1 = require("../storage/config-repo");
|
|
41
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
43
42
|
const errors_1 = require("../domain/errors");
|
|
43
|
+
const codex_probe_1 = require("../runtime/codex-probe");
|
|
44
44
|
/**
|
|
45
45
|
* Performs consistency checks across config.toml, providers.json, and the local Codex CLI.
|
|
46
46
|
*/
|
|
@@ -96,11 +96,20 @@ function runDoctor(args) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
const drift = (0, runtime_state_1.inspectLiveStateDrift)(currentProfile, providers);
|
|
99
|
-
const codexCheck = (0,
|
|
99
|
+
const codexCheck = (0, codex_probe_1.probeCodexRuntime)();
|
|
100
100
|
if (!codexCheck.ok) {
|
|
101
|
+
const message = codexCheck.reason === "missing"
|
|
102
|
+
? "codex CLI is not available on PATH."
|
|
103
|
+
: codexCheck.reason === "unsupported"
|
|
104
|
+
? "codex CLI version is below the supported minimum."
|
|
105
|
+
: "codex CLI probe failed.";
|
|
101
106
|
issues.push({
|
|
102
|
-
code: "
|
|
103
|
-
|
|
107
|
+
code: codexCheck.reason === "unsupported"
|
|
108
|
+
? "CODEX_VERSION_UNSUPPORTED"
|
|
109
|
+
: codexCheck.reason === "missing"
|
|
110
|
+
? "CODEX_NOT_INSTALLED"
|
|
111
|
+
: "CODEX_LOGIN_FAILED",
|
|
112
|
+
message,
|
|
104
113
|
cause: codexCheck.cause,
|
|
105
114
|
});
|
|
106
115
|
}
|
|
@@ -125,6 +134,14 @@ function renderConfigIssueMessage(issue) {
|
|
|
125
134
|
return `Profile "${issue.profile}" is shared by multiple providers.`;
|
|
126
135
|
case "ORPHANED_PROFILE_SECTION":
|
|
127
136
|
return `Profile section "${issue.profile}" is not linked to any provider.`;
|
|
137
|
+
case "MODEL_PROVIDER_MISSING":
|
|
138
|
+
return `Profile "${issue.profile}" is missing model_provider.`;
|
|
139
|
+
case "MODEL_PROVIDER_NAME_MISMATCH":
|
|
140
|
+
return `Profile "${issue.profile}" must use matching model_provider name "${issue.profile}", found "${issue.modelProvider}".`;
|
|
141
|
+
case "MODEL_PROVIDER_SECTION_MISSING":
|
|
142
|
+
return `Model provider section "${issue.modelProvider}" for profile "${issue.profile}" is missing from config.toml.`;
|
|
143
|
+
case "MODEL_PROVIDER_BASE_URL_MISSING":
|
|
144
|
+
return `Model provider section "${issue.modelProvider}" for profile "${issue.profile}" is missing base_url.`;
|
|
128
145
|
case "DESTRUCTIVE_REMOVE_BLOCKED":
|
|
129
146
|
return `Provider "${issue.provider}" cannot be removed while "${issue.activeProfile}" remains active.`;
|
|
130
147
|
}
|
package/dist/app/run-mutation.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runMutation = runMutation;
|
|
4
4
|
const errors_1 = require("../domain/errors");
|
|
5
|
-
const backup_repo_1 = require("../
|
|
6
|
-
const lock_repo_1 = require("../
|
|
5
|
+
const backup_repo_1 = require("../storage/backup-repo");
|
|
6
|
+
const lock_repo_1 = require("../storage/lock-repo");
|
|
7
7
|
/**
|
|
8
8
|
* Runs a write operation under a lock with automatic backup and rollback handling.
|
|
9
9
|
*/
|
package/dist/app/setup-codex.js
CHANGED
|
@@ -38,10 +38,10 @@ const fs = __importStar(require("node:fs"));
|
|
|
38
38
|
const setup_1 = require("../domain/setup");
|
|
39
39
|
const errors_1 = require("../domain/errors");
|
|
40
40
|
const config_1 = require("../domain/config");
|
|
41
|
-
const codex_cli_1 = require("../
|
|
42
|
-
const config_repo_1 = require("../
|
|
43
|
-
const fs_utils_1 = require("../
|
|
44
|
-
const providers_repo_1 = require("../
|
|
41
|
+
const codex_cli_1 = require("../runtime/codex-cli");
|
|
42
|
+
const config_repo_1 = require("../storage/config-repo");
|
|
43
|
+
const fs_utils_1 = require("../storage/fs-utils");
|
|
44
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
45
45
|
const run_doctor_1 = require("./run-doctor");
|
|
46
46
|
const run_mutation_1 = require("./run-mutation");
|
|
47
47
|
const MIN_CODEX_VERSION = "0.0.1";
|
|
@@ -71,7 +71,7 @@ function setupCodex(args) {
|
|
|
71
71
|
const document = (0, config_repo_1.readStructuredConfig)(args.configPath);
|
|
72
72
|
const profileViews = (0, config_1.buildManagedProfileViews)(document, null);
|
|
73
73
|
const adoptableProfiles = profileViews
|
|
74
|
-
.filter((view) => view.source === "unmanaged" && view.model && view.baseUrl)
|
|
74
|
+
.filter((view) => view.source === "unmanaged" && view.model && view.modelProvider === view.name && view.baseUrl)
|
|
75
75
|
.map((view) => view.name)
|
|
76
76
|
.sort();
|
|
77
77
|
if (profileViews.length === 0) {
|
|
@@ -81,7 +81,7 @@ function setupCodex(args) {
|
|
|
81
81
|
}
|
|
82
82
|
const invalidAdoptProfiles = args.adoptProfiles.filter((profile) => !adoptableProfiles.includes(profile));
|
|
83
83
|
if (invalidAdoptProfiles.length > 0) {
|
|
84
|
-
throw (0, errors_1.cliError)("INVALID_ARGUMENT", "setup only adopts unmanaged profiles that already contain model and base_url.", {
|
|
84
|
+
throw (0, errors_1.cliError)("INVALID_ARGUMENT", "setup only adopts unmanaged profiles that already contain model, model_provider, and a matching model_providers base_url.", {
|
|
85
85
|
invalidProfiles: invalidAdoptProfiles.sort(),
|
|
86
86
|
adoptableProfiles,
|
|
87
87
|
});
|
package/dist/app/show-config.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.showConfig = showConfig;
|
|
4
4
|
const config_1 = require("../domain/config");
|
|
5
5
|
const errors_1 = require("../domain/errors");
|
|
6
|
-
const config_repo_1 = require("../
|
|
7
|
-
const providers_repo_1 = require("../
|
|
6
|
+
const config_repo_1 = require("../storage/config-repo");
|
|
7
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
8
8
|
/**
|
|
9
9
|
* Returns the structured config view, optionally filtered to one profile.
|
|
10
10
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.showProvider = showProvider;
|
|
4
4
|
const providers_1 = require("../domain/providers");
|
|
5
|
-
const providers_repo_1 = require("../
|
|
5
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
6
6
|
/**
|
|
7
7
|
* Returns a single provider record, with text-mode callers able to use a masked preview.
|
|
8
8
|
*/
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.switchProvider = switchProvider;
|
|
4
4
|
const errors_1 = require("../domain/errors");
|
|
5
|
-
const config_repo_1 = require("../
|
|
6
|
-
const
|
|
7
|
-
const providers_repo_1 = require("../infra/providers-repo");
|
|
5
|
+
const config_repo_1 = require("../storage/config-repo");
|
|
6
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
8
7
|
const run_mutation_1 = require("./run-mutation");
|
|
8
|
+
const codex_cli_1 = require("../runtime/codex-cli");
|
|
9
9
|
/**
|
|
10
10
|
* Switches the active Codex profile and optionally refreshes the CLI login session.
|
|
11
11
|
*/
|