@minniexcode/codex-switch 0.0.9 → 0.0.11
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 +52 -13
- package/README.CN.md +94 -39
- package/README.md +75 -33
- package/dist/app/add-provider.js +29 -26
- package/dist/app/bridge.js +15 -15
- package/dist/app/edit-provider.js +2 -18
- package/dist/app/get-status.js +35 -13
- package/dist/app/import-providers.js +1 -1
- package/dist/app/init-codex.js +13 -14
- package/dist/app/list-providers.js +0 -1
- package/dist/app/remove-provider.js +1 -1
- package/dist/app/run-doctor.js +21 -39
- package/dist/app/run-mutation.js +3 -2
- package/dist/app/setup-codex.js +30 -18
- package/dist/app/show-config.js +1 -5
- package/dist/app/switch-provider.js +16 -33
- package/dist/cli/output.js +4 -6
- package/dist/cli.js +35 -3
- package/dist/commands/args.js +2 -2
- package/dist/commands/dispatch.js +40 -0
- package/dist/commands/handlers.js +202 -84
- package/dist/commands/help.js +2 -0
- package/dist/commands/registry.js +33 -12
- package/dist/domain/backups.js +4 -4
- package/dist/domain/config.js +102 -61
- package/dist/domain/providers.js +12 -5
- package/dist/domain/runtime-state.js +81 -4
- package/dist/domain/setup.js +58 -3
- package/dist/interaction/add-interactive.js +55 -1
- package/dist/interaction/interactive.js +1 -5
- package/dist/runtime/copilot-adapter.js +56 -13
- package/dist/runtime/copilot-bridge.js +392 -44
- package/dist/runtime/copilot-cli.js +142 -0
- package/dist/runtime/copilot-installer.js +59 -11
- package/dist/runtime/copilot-sdk-loader.js +5 -5
- package/dist/storage/auth-repo.js +28 -77
- package/dist/storage/backup-repo.js +4 -4
- package/dist/storage/codex-paths.js +34 -8
- package/dist/storage/config-repo.js +1 -36
- package/dist/storage/lock-repo.js +2 -4
- package/dist/storage/runtime-state-repo.js +43 -10
- package/dist/storage/tool-config-repo.js +111 -0
- package/docs/Design/codex-switch-copilot-integration-design.md +517 -0
- package/docs/Design/codex-switch-v0.0.10-design.md +669 -0
- package/docs/Design/codex-switch-v0.0.11-design.md +824 -0
- package/docs/PRD/codex-switch-prd-v0.0.10.md +406 -0
- package/docs/PRD/codex-switch-prd-v0.0.11.md +577 -0
- package/docs/cli-usage.md +166 -271
- package/docs/codex-switch-product-overview.md +2 -2
- package/docs/codex-switch-technical-architecture.md +6 -5
- package/package.json +1 -1
package/dist/app/setup-codex.js
CHANGED
|
@@ -42,7 +42,6 @@ const codex_cli_1 = require("../runtime/codex-cli");
|
|
|
42
42
|
const config_repo_1 = require("../storage/config-repo");
|
|
43
43
|
const fs_utils_1 = require("../storage/fs-utils");
|
|
44
44
|
const providers_repo_1 = require("../storage/providers-repo");
|
|
45
|
-
const auth_repo_1 = require("../storage/auth-repo");
|
|
46
45
|
const run_doctor_1 = require("./run-doctor");
|
|
47
46
|
const run_mutation_1 = require("./run-mutation");
|
|
48
47
|
const MIN_CODEX_VERSION = "0.0.1";
|
|
@@ -70,30 +69,46 @@ async function migrateCodex(args) {
|
|
|
70
69
|
});
|
|
71
70
|
}
|
|
72
71
|
const document = (0, config_repo_1.readStructuredConfig)(args.configPath);
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
.filter((view) => view.source === "unmanaged" && view.model && view.modelProvider === view.name && view.baseUrl && view.envKey)
|
|
77
|
-
.map((view) => view.name)
|
|
78
|
-
.sort();
|
|
72
|
+
const currentProviders = (0, providers_repo_1.readProvidersFileIfExists)(args.providersPath);
|
|
73
|
+
const profileViews = (0, config_1.buildManagedProfileViews)(document, currentProviders);
|
|
74
|
+
const adoptability = (0, setup_1.collectMigrateAdoptability)(document, currentProviders);
|
|
79
75
|
if (profileViews.length === 0) {
|
|
80
76
|
throw (0, errors_1.cliError)("PROFILE_NOT_FOUND", "No profiles were found in config.toml.", {
|
|
81
77
|
file: args.configPath,
|
|
82
78
|
});
|
|
83
79
|
}
|
|
84
|
-
|
|
80
|
+
if (adoptability.adoptableProfiles.length === 0) {
|
|
81
|
+
throw (0, errors_1.cliError)("MIGRATE_NO_ADOPTABLE_PROFILES", "No adoptable profiles were found for migrate.", {
|
|
82
|
+
availableProfiles: adoptability.availableProfiles,
|
|
83
|
+
adoptableProfiles: adoptability.adoptableProfiles,
|
|
84
|
+
blockingReasonsByProfile: adoptability.blockingReasonsByProfile,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const invalidAdoptProfiles = args.adoptProfiles.filter((profile) => !adoptability.adoptableProfiles.includes(profile));
|
|
85
88
|
if (invalidAdoptProfiles.length > 0) {
|
|
86
|
-
throw (0, errors_1.cliError)("INVALID_ARGUMENT", "migrate only adopts unmanaged profiles that already contain model, model_provider, and matching model_providers base_url
|
|
89
|
+
throw (0, errors_1.cliError)("INVALID_ARGUMENT", "migrate only adopts unmanaged profiles that already contain model, model_provider, and matching model_providers base_url.", {
|
|
87
90
|
invalidProfiles: invalidAdoptProfiles.sort(),
|
|
88
|
-
|
|
91
|
+
availableProfiles: adoptability.availableProfiles,
|
|
92
|
+
adoptableProfiles: adoptability.adoptableProfiles,
|
|
93
|
+
blockingReasonsByProfile: adoptability.blockingReasonsByProfile,
|
|
89
94
|
});
|
|
90
95
|
}
|
|
91
96
|
if (args.adoptProfiles.length === 0) {
|
|
92
97
|
throw (0, errors_1.cliError)("INVALID_ARGUMENT", "migrate requires at least one explicit profile to adopt.", {
|
|
93
|
-
|
|
98
|
+
availableProfiles: adoptability.availableProfiles,
|
|
99
|
+
adoptableProfiles: adoptability.adoptableProfiles,
|
|
100
|
+
blockingReasonsByProfile: adoptability.blockingReasonsByProfile,
|
|
94
101
|
});
|
|
95
102
|
}
|
|
96
|
-
const
|
|
103
|
+
const runtimeByProfile = profileViews.reduce((accumulator, view) => {
|
|
104
|
+
if (view.source === "unmanaged") {
|
|
105
|
+
accumulator[view.name] = {
|
|
106
|
+
baseUrl: view.baseUrl ?? undefined,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return accumulator;
|
|
110
|
+
}, {});
|
|
111
|
+
const drafts = (0, setup_1.buildSetupDrafts)(args.adoptProfiles, args.providerDetailsByProfile, runtimeByProfile);
|
|
97
112
|
const incompleteProfiles = (0, setup_1.findIncompleteSetupProfiles)(drafts);
|
|
98
113
|
if (incompleteProfiles.length > 0) {
|
|
99
114
|
throw (0, errors_1.cliError)("INVALID_ARGUMENT", "migrate requires complete provider data for every selected profile.", {
|
|
@@ -101,7 +116,6 @@ async function migrateCodex(args) {
|
|
|
101
116
|
});
|
|
102
117
|
}
|
|
103
118
|
(0, fs_utils_1.ensureDir)(args.codexDir);
|
|
104
|
-
const currentProviders = (0, providers_repo_1.readProvidersFileIfExists)(args.providersPath);
|
|
105
119
|
const providersExists = fs.existsSync(args.providersPath);
|
|
106
120
|
if (providersExists && args.strategy !== "merge" && args.strategy !== "overwrite") {
|
|
107
121
|
throw (0, errors_1.cliError)("PROVIDERS_ALREADY_EXISTS", "providers.json already exists.", {
|
|
@@ -116,23 +130,19 @@ async function migrateCodex(args) {
|
|
|
116
130
|
};
|
|
117
131
|
const finalProviders = args.strategy === "merge" ? (0, providers_repo_1.mergeProviders)(currentProviders, nextProviders) : nextProviders;
|
|
118
132
|
const result = (0, run_mutation_1.runMutation)({
|
|
119
|
-
|
|
133
|
+
lockPath: args.lockPath,
|
|
120
134
|
backupsDir: args.backupsDir,
|
|
121
135
|
latestBackupPath: args.latestBackupPath,
|
|
122
136
|
operation: "migrate",
|
|
123
137
|
files: [
|
|
124
138
|
{ absolutePath: args.providersPath, relativePath: "providers.json" },
|
|
125
139
|
{ absolutePath: args.configPath, relativePath: "config.toml" },
|
|
126
|
-
{ absolutePath: args.authPath, relativePath: "auth.json" },
|
|
127
140
|
],
|
|
128
141
|
mutate: () => {
|
|
129
142
|
// migrate currently preserves config structure and only asserts that the file remains writable inside the mutation flow.
|
|
130
143
|
const configPlan = (0, config_repo_1.createConfigMutationPlan)(document, {});
|
|
131
144
|
(0, providers_repo_1.writeProvidersFile)(args.providersPath, finalProviders);
|
|
132
145
|
(0, config_repo_1.applyConfigMutation)(args.configPath, document, configPlan);
|
|
133
|
-
const activeProviderName = (0, config_repo_1.resolveActiveProviderName)(document, finalProviders);
|
|
134
|
-
const existingAuth = (0, auth_repo_1.readAuthFileIfExists)(args.authPath);
|
|
135
|
-
(0, auth_repo_1.writeAuthFile)(args.authPath, finalProviders.providers[activeProviderName], existingAuth ?? undefined);
|
|
136
146
|
return {
|
|
137
147
|
codexDir: args.codexDir,
|
|
138
148
|
strategy: args.strategy,
|
|
@@ -153,6 +163,8 @@ async function migrateCodex(args) {
|
|
|
153
163
|
configPath: args.configPath,
|
|
154
164
|
providersPath: args.providersPath,
|
|
155
165
|
authPath: args.authPath,
|
|
166
|
+
runtimeDir: args.runtimeDir,
|
|
167
|
+
runtimesDir: args.runtimesDir,
|
|
156
168
|
});
|
|
157
169
|
return {
|
|
158
170
|
data: {
|
package/dist/app/show-config.js
CHANGED
|
@@ -31,11 +31,7 @@ function showConfig(args) {
|
|
|
31
31
|
selectedProfile,
|
|
32
32
|
profiles: profiles.map((profile) => ({
|
|
33
33
|
...profile,
|
|
34
|
-
|
|
35
|
-
providerName,
|
|
36
|
-
envKey: providers.providers[providerName].envKey,
|
|
37
|
-
matchesRuntime: providers.providers[providerName].envKey === profile.envKey,
|
|
38
|
-
})),
|
|
34
|
+
linkedProviderNames: (0, providers_1.findProvidersByProfile)(providers, profile.name),
|
|
39
35
|
})),
|
|
40
36
|
},
|
|
41
37
|
};
|
|
@@ -4,14 +4,14 @@ exports.switchProvider = switchProvider;
|
|
|
4
4
|
const errors_1 = require("../domain/errors");
|
|
5
5
|
const providers_1 = require("../domain/providers");
|
|
6
6
|
const config_repo_1 = require("../storage/config-repo");
|
|
7
|
-
const providers_repo_1 = require("../storage/providers-repo");
|
|
8
7
|
const auth_repo_1 = require("../storage/auth-repo");
|
|
8
|
+
const providers_repo_1 = require("../storage/providers-repo");
|
|
9
9
|
const copilot_bridge_1 = require("../runtime/copilot-bridge");
|
|
10
10
|
const copilot_installer_1 = require("../runtime/copilot-installer");
|
|
11
11
|
const copilot_adapter_1 = require("../runtime/copilot-adapter");
|
|
12
12
|
const run_mutation_1 = require("./run-mutation");
|
|
13
13
|
/**
|
|
14
|
-
* Switches the active Codex profile
|
|
14
|
+
* Switches the active Codex profile to the target provider.
|
|
15
15
|
*/
|
|
16
16
|
async function switchProvider(args) {
|
|
17
17
|
const providers = (0, providers_repo_1.readProvidersFile)(args.providersPath);
|
|
@@ -22,25 +22,16 @@ async function switchProvider(args) {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
const document = (0, config_repo_1.ensureProfileExists)(args.configPath, provider.profile, args.providerName);
|
|
25
|
-
const envKey = (0, config_repo_1.requireRuntimeEnvKey)(document, provider.profile);
|
|
26
|
-
if (provider.envKey !== envKey) {
|
|
27
|
-
throw (0, errors_1.cliError)("PROVIDER_ENV_KEY_MISMATCH", `Provider "${args.providerName}" envKey does not match runtime env_key.`, {
|
|
28
|
-
provider: args.providerName,
|
|
29
|
-
profile: provider.profile,
|
|
30
|
-
providerEnvKey: provider.envKey,
|
|
31
|
-
runtimeEnvKey: envKey,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
25
|
if ((0, providers_1.isCopilotBridgeProvider)(provider)) {
|
|
35
|
-
const installStatus = (0, copilot_installer_1.probeCopilotSdkInstall)();
|
|
26
|
+
const installStatus = (0, copilot_installer_1.probeCopilotSdkInstall)(args.runtimesDir);
|
|
36
27
|
if (!installStatus.installed) {
|
|
37
28
|
throw (0, errors_1.cliError)("COPILOT_SDK_MISSING", "The optional Copilot SDK runtime is not installed.", {
|
|
38
29
|
installDir: installStatus.installDir,
|
|
39
30
|
packageName: installStatus.packageName,
|
|
40
31
|
});
|
|
41
32
|
}
|
|
42
|
-
await (0, copilot_adapter_1.readCopilotAuthState)();
|
|
43
|
-
const bridge = await (0, copilot_bridge_1.ensureCopilotBridge)(args.providerName, provider);
|
|
33
|
+
await (0, copilot_adapter_1.readCopilotAuthState)(args.runtimesDir);
|
|
34
|
+
const bridge = await (0, copilot_bridge_1.ensureCopilotBridge)(args.providerName, provider, args.runtimeDir);
|
|
44
35
|
const nextProvider = bridge.portChanged
|
|
45
36
|
? (0, providers_1.cleanProviderRecord)({
|
|
46
37
|
...provider,
|
|
@@ -53,25 +44,21 @@ async function switchProvider(args) {
|
|
|
53
44
|
: provider;
|
|
54
45
|
try {
|
|
55
46
|
return (0, run_mutation_1.runMutation)({
|
|
56
|
-
|
|
47
|
+
lockPath: args.lockPath,
|
|
57
48
|
backupsDir: args.backupsDir,
|
|
58
49
|
latestBackupPath: args.latestBackupPath,
|
|
59
50
|
operation: "switch",
|
|
60
51
|
files: [
|
|
61
|
-
{ absolutePath: args.configPath, relativePath: "config.toml" },
|
|
62
52
|
{ absolutePath: args.authPath, relativePath: "auth.json" },
|
|
53
|
+
{ absolutePath: args.providersPath, relativePath: "providers.json" },
|
|
54
|
+
{ absolutePath: args.configPath, relativePath: "config.toml" },
|
|
63
55
|
],
|
|
64
56
|
mutate: () => {
|
|
65
57
|
const configPlan = (0, config_repo_1.createConfigMutationPlan)(document, {
|
|
66
58
|
setActiveProfile: provider.profile,
|
|
67
|
-
upsertModelProviders:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
baseUrl: (0, providers_1.buildCopilotBridgeBaseUrl)(nextProvider.runtime),
|
|
71
|
-
envKey,
|
|
72
|
-
},
|
|
73
|
-
}
|
|
74
|
-
: undefined,
|
|
59
|
+
upsertModelProviders: {
|
|
60
|
+
[provider.profile]: (0, providers_1.buildCopilotModelProviderProjection)(nextProvider.runtime),
|
|
61
|
+
},
|
|
75
62
|
});
|
|
76
63
|
if (bridge.portChanged) {
|
|
77
64
|
(0, providers_repo_1.writeProvidersFile)(args.providersPath, {
|
|
@@ -82,12 +69,10 @@ async function switchProvider(args) {
|
|
|
82
69
|
});
|
|
83
70
|
}
|
|
84
71
|
(0, config_repo_1.applyConfigMutation)(args.configPath, document, configPlan);
|
|
85
|
-
|
|
86
|
-
(0, auth_repo_1.writeAuthFile)(args.authPath, nextProvider, existingAuth ?? undefined);
|
|
72
|
+
(0, auth_repo_1.writeOpenAiApiKeyAuth)(args.authPath, provider.apiKey);
|
|
87
73
|
return {
|
|
88
74
|
provider: args.providerName,
|
|
89
75
|
profile: nextProvider.profile,
|
|
90
|
-
envKey: nextProvider.envKey,
|
|
91
76
|
portChanged: bridge.portChanged,
|
|
92
77
|
bridgePort: bridge.port,
|
|
93
78
|
};
|
|
@@ -96,31 +81,29 @@ async function switchProvider(args) {
|
|
|
96
81
|
}
|
|
97
82
|
catch (error) {
|
|
98
83
|
if (!bridge.reused) {
|
|
99
|
-
(0, copilot_bridge_1.stopCopilotBridge)();
|
|
84
|
+
(0, copilot_bridge_1.stopCopilotBridge)(args.runtimeDir);
|
|
100
85
|
}
|
|
101
86
|
throw error;
|
|
102
87
|
}
|
|
103
88
|
}
|
|
104
89
|
return (0, run_mutation_1.runMutation)({
|
|
105
|
-
|
|
90
|
+
lockPath: args.lockPath,
|
|
106
91
|
backupsDir: args.backupsDir,
|
|
107
92
|
latestBackupPath: args.latestBackupPath,
|
|
108
93
|
operation: "switch",
|
|
109
94
|
files: [
|
|
110
|
-
{ absolutePath: args.configPath, relativePath: "config.toml" },
|
|
111
95
|
{ absolutePath: args.authPath, relativePath: "auth.json" },
|
|
96
|
+
{ absolutePath: args.configPath, relativePath: "config.toml" },
|
|
112
97
|
],
|
|
113
98
|
mutate: () => {
|
|
114
99
|
const configPlan = (0, config_repo_1.createConfigMutationPlan)(document, {
|
|
115
100
|
setActiveProfile: provider.profile,
|
|
116
101
|
});
|
|
117
102
|
(0, config_repo_1.applyConfigMutation)(args.configPath, document, configPlan);
|
|
118
|
-
|
|
119
|
-
(0, auth_repo_1.writeAuthFile)(args.authPath, provider, existingAuth ?? undefined);
|
|
103
|
+
(0, auth_repo_1.writeOpenAiApiKeyAuth)(args.authPath, provider.apiKey);
|
|
120
104
|
return {
|
|
121
105
|
provider: args.providerName,
|
|
122
106
|
profile: provider.profile,
|
|
123
|
-
envKey: provider.envKey,
|
|
124
107
|
};
|
|
125
108
|
},
|
|
126
109
|
});
|
package/dist/cli/output.js
CHANGED
|
@@ -90,8 +90,7 @@ function renderHumanSuccess(command, data, warnings) {
|
|
|
90
90
|
? ` tags=${provider.tags.join(",")}`
|
|
91
91
|
: "";
|
|
92
92
|
const note = provider.note ? ` note=${provider.note}` : "";
|
|
93
|
-
|
|
94
|
-
lines.push(`${provider.name} -> ${provider.profile}${envKey}${tags}${note}`);
|
|
93
|
+
lines.push(`${provider.name} -> ${provider.profile}${tags}${note}`);
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
break;
|
|
@@ -101,7 +100,6 @@ function renderHumanSuccess(command, data, warnings) {
|
|
|
101
100
|
lines.push(`Provider: ${String(data?.providerName ?? "")}`);
|
|
102
101
|
lines.push(`profile: ${String(provider.profile ?? "")}`);
|
|
103
102
|
lines.push(`apiKey: ${String(provider.apiKey ?? "")}`);
|
|
104
|
-
lines.push(`envKey: ${String(provider.envKey ?? "")}`);
|
|
105
103
|
if (provider.baseUrl) {
|
|
106
104
|
lines.push(`baseUrl: ${String(provider.baseUrl)}`);
|
|
107
105
|
}
|
|
@@ -125,14 +123,15 @@ function renderHumanSuccess(command, data, warnings) {
|
|
|
125
123
|
lines.push(`activeProviderResolvable: ${String(data?.activeProviderResolvable ?? false)}`);
|
|
126
124
|
const auth = data?.auth ?? {};
|
|
127
125
|
lines.push(`authExists: ${String(auth.exists ?? false)}`);
|
|
128
|
-
lines.push(`
|
|
126
|
+
lines.push(`authValid: ${String(auth.valid ?? false)}`);
|
|
127
|
+
lines.push(`authMode: ${String(auth.authMode ?? "")}`);
|
|
129
128
|
lines.push(`issues: ${Array.isArray(data?.issues) ? (data?.issues).length : 0}`);
|
|
130
129
|
break;
|
|
131
130
|
case "config-show": {
|
|
132
131
|
lines.push(`activeProfile: ${String(data?.activeProfile ?? "")}`);
|
|
133
132
|
const profiles = data?.profiles ?? [];
|
|
134
133
|
for (const profile of profiles) {
|
|
135
|
-
lines.push(`${String(profile.name)} managed=${String(profile.managed)} active=${String(profile.isActive)} source=${String(profile.source)} model=${String(profile.model ?? "")} modelProvider=${String(profile.modelProvider ?? "")} baseUrl=${String(profile.baseUrl ?? "")}
|
|
134
|
+
lines.push(`${String(profile.name)} managed=${String(profile.managed)} active=${String(profile.isActive)} source=${String(profile.source)} model=${String(profile.model ?? "")} modelProvider=${String(profile.modelProvider ?? "")} baseUrl=${String(profile.baseUrl ?? "")}`);
|
|
136
135
|
}
|
|
137
136
|
break;
|
|
138
137
|
}
|
|
@@ -145,7 +144,6 @@ function renderHumanSuccess(command, data, warnings) {
|
|
|
145
144
|
}
|
|
146
145
|
case "switch":
|
|
147
146
|
lines.push(`Switched to provider ${String(data?.provider ?? "")} using profile ${String(data?.profile ?? "")}.`);
|
|
148
|
-
lines.push(`envKey: ${String(data?.envKey ?? "")}`);
|
|
149
147
|
lines.push(`Backup: ${String(data?.backupPath ?? "")}`);
|
|
150
148
|
break;
|
|
151
149
|
case "import":
|
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,47 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
3
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
37
|
exports.printHelp = printHelp;
|
|
5
38
|
exports.printVersion = printVersion;
|
|
6
39
|
exports.main = main;
|
|
7
|
-
const dispatch_1 = require("./commands/dispatch");
|
|
8
40
|
const args_1 = require("./commands/args");
|
|
9
41
|
const help_1 = require("./commands/help");
|
|
10
42
|
const errors_1 = require("./domain/errors");
|
|
11
43
|
const output_1 = require("./cli/output");
|
|
12
|
-
const VERSION = "0.0.
|
|
44
|
+
const VERSION = require("../package.json").version ?? "0.0.0";
|
|
13
45
|
/**
|
|
14
46
|
* Prints the command help text to stdout.
|
|
15
47
|
*/
|
|
@@ -49,7 +81,7 @@ function main() {
|
|
|
49
81
|
command: parsed.command,
|
|
50
82
|
options: parsed.globalOptions,
|
|
51
83
|
};
|
|
52
|
-
(
|
|
84
|
+
Promise.resolve().then(() => __importStar(require("./commands/dispatch"))).then(({ executeCommand }) => executeCommand(ctx, parsed))
|
|
53
85
|
.then((result) => {
|
|
54
86
|
(0, output_1.outputSuccess)(ctx, result);
|
|
55
87
|
})
|
package/dist/commands/args.js
CHANGED
|
@@ -11,7 +11,7 @@ const registry_1 = require("./registry");
|
|
|
11
11
|
*/
|
|
12
12
|
function parseArgs(argv) {
|
|
13
13
|
let json = false;
|
|
14
|
-
let codexDir =
|
|
14
|
+
let codexDir = null;
|
|
15
15
|
let codexDirExplicit = false;
|
|
16
16
|
const remaining = [];
|
|
17
17
|
for (let index = 0; index < argv.length; index += 1) {
|
|
@@ -105,7 +105,7 @@ function defaultParsed(command, overrides) {
|
|
|
105
105
|
positionals: [],
|
|
106
106
|
globalOptions: {
|
|
107
107
|
json: overrides?.json ?? false,
|
|
108
|
-
codexDir: overrides?.codexDir ??
|
|
108
|
+
codexDir: overrides?.codexDir ?? null,
|
|
109
109
|
codexDirExplicit: false,
|
|
110
110
|
},
|
|
111
111
|
commandOptions: new Map(),
|
|
@@ -1,8 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.executeCommand = executeCommand;
|
|
37
|
+
const path = __importStar(require("node:path"));
|
|
4
38
|
const errors_1 = require("../domain/errors");
|
|
5
39
|
const prompt_1 = require("../interaction/prompt");
|
|
40
|
+
const codex_paths_1 = require("../storage/codex-paths");
|
|
41
|
+
const tool_config_repo_1 = require("../storage/tool-config-repo");
|
|
6
42
|
const registry_1 = require("./registry");
|
|
7
43
|
/**
|
|
8
44
|
* Resolves the shared command definition and executes its registered handler.
|
|
@@ -12,5 +48,9 @@ async function executeCommand(ctx, parsed, runtime = (0, prompt_1.createPromptRu
|
|
|
12
48
|
if (!definition) {
|
|
13
49
|
throw (0, errors_1.cliError)("UNKNOWN_COMMAND", `Unknown command: ${ctx.command}`);
|
|
14
50
|
}
|
|
51
|
+
const toolHomeDir = (0, codex_paths_1.resolveCodexSwitchHome)();
|
|
52
|
+
const toolConfigPath = path.join(toolHomeDir, "codex-switch.json");
|
|
53
|
+
const toolConfig = (0, tool_config_repo_1.readToolConfigIfExists)(toolConfigPath);
|
|
54
|
+
ctx.options.codexDir = (0, codex_paths_1.resolveCodexDir)(ctx.options.codexDir ?? undefined, toolConfig);
|
|
15
55
|
return definition.handler(ctx, parsed, runtime);
|
|
16
56
|
}
|