@minniexcode/codex-switch 0.0.5 → 0.0.7
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 +5 -2
- package/README.md +44 -100
- package/dist/app/add-provider.js +28 -4
- package/dist/app/edit-provider.js +47 -19
- package/dist/app/export-providers.js +2 -2
- package/dist/app/get-current-profile.js +1 -1
- package/dist/app/get-status.js +10 -3
- package/dist/app/import-providers.js +15 -7
- package/dist/app/init-codex.js +68 -0
- package/dist/app/list-backups.js +1 -1
- package/dist/app/list-config-profiles.js +3 -2
- package/dist/app/list-providers.js +2 -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 +83 -6
- package/dist/app/run-mutation.js +2 -2
- package/dist/app/setup-codex.js +21 -12
- package/dist/app/show-config.js +11 -3
- package/dist/app/show-provider.js +1 -1
- package/dist/app/switch-provider.js +16 -9
- package/dist/cli/add-interactive.js +7 -104
- package/dist/cli/args.js +6 -135
- package/dist/cli/help.js +8 -313
- package/dist/cli/interactive.js +17 -225
- package/dist/cli/output.js +21 -6
- package/dist/cli/prompt.js +4 -106
- 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 +460 -0
- package/dist/commands/help.js +120 -0
- package/dist/commands/registry.js +351 -0
- package/dist/commands/types.js +2 -0
- package/dist/domain/config.js +235 -21
- package/dist/domain/providers.js +16 -2
- package/dist/domain/setup.js +1 -0
- package/dist/infra/backup-repo.js +9 -206
- package/dist/infra/codex-cli.js +9 -126
- package/dist/infra/codex-paths.js +6 -67
- package/dist/infra/config-repo.js +59 -0
- package/dist/infra/fs-utils.js +8 -93
- package/dist/infra/lock-repo.js +4 -95
- package/dist/infra/providers-repo.js +8 -94
- package/dist/interaction/add-interactive.js +99 -0
- package/dist/interaction/interactive.js +289 -0
- package/dist/interaction/prompt.js +110 -0
- package/dist/runtime/codex-cli.js +130 -0
- package/dist/runtime/codex-probe.js +57 -0
- package/dist/runtime/types.js +2 -0
- package/dist/storage/auth-repo.js +160 -0
- package/dist/storage/backup-repo.js +210 -0
- package/dist/storage/codex-paths.js +71 -0
- package/dist/storage/config-repo.js +266 -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/Design/codex-switch-v0.0.7-design.md +862 -0
- package/docs/PRD/codex-switch-prd-v0.0.5-to-v0.1.0.md +227 -89
- package/docs/PRD/codex-switch-prd-v0.1.0.md +200 -226
- package/docs/PRD/codex-switch-prd.md +1 -1
- package/docs/Reference/codex-config-reference.md +604 -0
- package/docs/Reference/codex-config-reference.zh-CN.md +633 -0
- package/docs/cli-usage.md +78 -29
- package/docs/codex-switch-technical-architecture.md +73 -4
- package/docs/test-report-0.0.5.md +163 -0
- package/docs/test-report-0.0.7.md +118 -0
- package/docs/testing.md +151 -0
- package/package.json +1 -1
package/dist/cli/args.js
CHANGED
|
@@ -1,139 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseArgs =
|
|
4
|
-
exports.hasFlag = hasFlag;
|
|
5
|
-
exports.getSingleOption = getSingleOption;
|
|
6
|
-
const errors_1 = require("../domain/errors");
|
|
7
|
-
const codex_paths_1 = require("../infra/codex-paths");
|
|
3
|
+
exports.parseArgs = exports.hasFlag = exports.getSingleOption = void 0;
|
|
8
4
|
/**
|
|
9
|
-
*
|
|
5
|
+
* Compatibility facade that re-exports shared CLI argument parsing helpers.
|
|
10
6
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const remaining = [];
|
|
16
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
17
|
-
const value = argv[index];
|
|
18
|
-
if (value === "--json") {
|
|
19
|
-
json = true;
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
if (value === "--codex-dir") {
|
|
23
|
-
const next = argv[index + 1];
|
|
24
|
-
if (!next) {
|
|
25
|
-
throw (0, errors_1.cliError)("INVALID_ARGUMENT", "--codex-dir requires a path value.");
|
|
26
|
-
}
|
|
27
|
-
codexDir = (0, codex_paths_1.resolveCodexDir)(next);
|
|
28
|
-
codexDirExplicit = true;
|
|
29
|
-
index += 1;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
remaining.push(value);
|
|
33
|
-
}
|
|
34
|
-
if (remaining[0] === "help") {
|
|
35
|
-
const helpTarget = remaining[1] === "backups" && remaining[2] === "list" ? "backups" : remaining[1] ?? null;
|
|
36
|
-
return {
|
|
37
|
-
command: null,
|
|
38
|
-
positionals: [],
|
|
39
|
-
globalOptions: {
|
|
40
|
-
json,
|
|
41
|
-
codexDir,
|
|
42
|
-
codexDirExplicit,
|
|
43
|
-
},
|
|
44
|
-
commandOptions: new Map(),
|
|
45
|
-
helpRequested: true,
|
|
46
|
-
helpTarget,
|
|
47
|
-
versionRequested: false,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const versionRequested = remaining.includes("--version") || remaining.includes("-v");
|
|
51
|
-
if (versionRequested) {
|
|
52
|
-
return defaultParsed(null, {
|
|
53
|
-
json,
|
|
54
|
-
codexDir,
|
|
55
|
-
versionRequested: true,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
const commandToken = remaining[0] ?? null;
|
|
59
|
-
const command = commandToken === "backups" && remaining[1] === "list"
|
|
60
|
-
? "backups-list"
|
|
61
|
-
: commandToken === "config" && remaining[1] === "show"
|
|
62
|
-
? "config-show"
|
|
63
|
-
: commandToken === "config" && remaining[1] === "list-profiles"
|
|
64
|
-
? "config-list-profiles"
|
|
65
|
-
: commandToken;
|
|
66
|
-
const positionals = [];
|
|
67
|
-
const commandOptions = new Map();
|
|
68
|
-
let helpRequested = false;
|
|
69
|
-
const startIndex = command === "backups-list" || command === "config-show" || command === "config-list-profiles" ? 2 : 1;
|
|
70
|
-
for (let index = startIndex; index < remaining.length; index += 1) {
|
|
71
|
-
const value = remaining[index];
|
|
72
|
-
if (value === "--help" || value === "-h") {
|
|
73
|
-
helpRequested = true;
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
if (value.startsWith("--")) {
|
|
77
|
-
const optionName = value;
|
|
78
|
-
const next = remaining[index + 1];
|
|
79
|
-
if (!next || next.startsWith("--")) {
|
|
80
|
-
// Boolean flags are stored as "true" so later access uses one uniform map shape.
|
|
81
|
-
commandOptions.set(optionName, ["true"]);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
const existing = commandOptions.get(optionName) ?? [];
|
|
85
|
-
existing.push(next);
|
|
86
|
-
commandOptions.set(optionName, existing);
|
|
87
|
-
index += 1;
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
positionals.push(value);
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
command,
|
|
94
|
-
positionals,
|
|
95
|
-
globalOptions: {
|
|
96
|
-
json,
|
|
97
|
-
codexDir,
|
|
98
|
-
codexDirExplicit,
|
|
99
|
-
},
|
|
100
|
-
commandOptions,
|
|
101
|
-
helpRequested,
|
|
102
|
-
helpTarget: helpRequested ? (command === "backups-list" ? "backups" : command) : null,
|
|
103
|
-
versionRequested: false,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Creates a parsed result for built-in synthetic commands such as help/version.
|
|
108
|
-
*/
|
|
109
|
-
function defaultParsed(command, overrides) {
|
|
110
|
-
return {
|
|
111
|
-
command,
|
|
112
|
-
positionals: [],
|
|
113
|
-
globalOptions: {
|
|
114
|
-
json: overrides?.json ?? false,
|
|
115
|
-
codexDir: overrides?.codexDir ?? (0, codex_paths_1.resolveCodexDir)(),
|
|
116
|
-
codexDirExplicit: false,
|
|
117
|
-
},
|
|
118
|
-
commandOptions: new Map(),
|
|
119
|
-
helpRequested: overrides?.helpRequested ?? false,
|
|
120
|
-
helpTarget: overrides?.helpTarget ?? null,
|
|
121
|
-
versionRequested: overrides?.versionRequested ?? false,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Checks whether a boolean-style option was supplied.
|
|
126
|
-
*/
|
|
127
|
-
function hasFlag(options, name) {
|
|
128
|
-
return options.has(name);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Returns the last supplied value for a single-valued command option.
|
|
132
|
-
*/
|
|
133
|
-
function getSingleOption(options, name, required = true) {
|
|
134
|
-
const values = options.get(name) ?? [];
|
|
135
|
-
if (values.length === 0) {
|
|
136
|
-
return required ? null : null;
|
|
137
|
-
}
|
|
138
|
-
return values[values.length - 1];
|
|
139
|
-
}
|
|
7
|
+
var args_1 = require("../commands/args");
|
|
8
|
+
Object.defineProperty(exports, "getSingleOption", { enumerable: true, get: function () { return args_1.getSingleOption; } });
|
|
9
|
+
Object.defineProperty(exports, "hasFlag", { enumerable: true, get: function () { return args_1.hasFlag; } });
|
|
10
|
+
Object.defineProperty(exports, "parseArgs", { enumerable: true, get: function () { return args_1.parseArgs; } });
|
package/dist/cli/help.js
CHANGED
|
@@ -1,315 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getKnownCommandNames =
|
|
4
|
-
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
const COMMANDS = [
|
|
12
|
-
{
|
|
13
|
-
name: "config-show",
|
|
14
|
-
group: "read",
|
|
15
|
-
summary: "Show the structured config profile view.",
|
|
16
|
-
usage: ["codexs config show [profile] [--json] [--codex-dir <path>]"],
|
|
17
|
-
details: [
|
|
18
|
-
"Returns all recognizable config profiles by default, including unmanaged and orphaned references.",
|
|
19
|
-
"Passing [profile] narrows the response to one profile while preserving the same shape.",
|
|
20
|
-
],
|
|
21
|
-
examples: ["codexs config show", "codexs config show packycode --json"],
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: "config-list-profiles",
|
|
25
|
-
group: "read",
|
|
26
|
-
summary: "List recognizable config profiles with managed-state hints.",
|
|
27
|
-
usage: ["codexs config list-profiles [--json] [--codex-dir <path>]"],
|
|
28
|
-
details: [
|
|
29
|
-
"Lists managed, unmanaged, and orphaned config profiles in one stable view.",
|
|
30
|
-
"Use config show for richer single-profile details.",
|
|
31
|
-
],
|
|
32
|
-
examples: ["codexs config list-profiles", "codexs config list-profiles --json"],
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: "setup",
|
|
36
|
-
group: "write",
|
|
37
|
-
summary: "Initialize providers.json from an existing Codex directory.",
|
|
38
|
-
usage: ["codexs setup [--json] [--codex-dir <path>] [--merge|--overwrite]"],
|
|
39
|
-
details: [
|
|
40
|
-
"Reads config.toml profiles, collects complete provider records, then writes providers.json under managed backup flow.",
|
|
41
|
-
"TTY mode can collect missing provider details and choose merge or overwrite when providers.json already exists.",
|
|
42
|
-
"Non-TTY and --json runs stay non-interactive and require explicit strategy when providers.json already exists.",
|
|
43
|
-
],
|
|
44
|
-
examples: ["codexs setup", "codexs setup --overwrite --json --codex-dir ~/.codex"],
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: "list",
|
|
48
|
-
group: "read",
|
|
49
|
-
summary: "List configured providers from providers.json.",
|
|
50
|
-
usage: ["codexs list [--json] [--codex-dir <path>]"],
|
|
51
|
-
details: [
|
|
52
|
-
"Reads providers.json and prints provider-to-profile mappings.",
|
|
53
|
-
"Use --json for machine-readable automation output.",
|
|
54
|
-
],
|
|
55
|
-
examples: ["codexs list", "codexs list --json"],
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: "show",
|
|
59
|
-
group: "read",
|
|
60
|
-
summary: "Show one provider record from providers.json.",
|
|
61
|
-
usage: ["codexs show <provider> [--json] [--codex-dir <path>]"],
|
|
62
|
-
details: [
|
|
63
|
-
"Human-readable output masks apiKey by default.",
|
|
64
|
-
"TTY mode can select a missing provider interactively before showing its record.",
|
|
65
|
-
"JSON mode returns the full provider payload for local automation.",
|
|
66
|
-
],
|
|
67
|
-
examples: ["codexs show packycode", "codexs show packycode --json"],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: "current",
|
|
71
|
-
group: "read",
|
|
72
|
-
summary: "Show the active top-level profile from config.toml.",
|
|
73
|
-
usage: ["codexs current [--json] [--codex-dir <path>]"],
|
|
74
|
-
details: [
|
|
75
|
-
"Reads the currently active top-level profile.",
|
|
76
|
-
"Fails when config.toml is missing or has no top-level profile.",
|
|
77
|
-
],
|
|
78
|
-
examples: ["codexs current", "codexs current --json"],
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: "status",
|
|
82
|
-
group: "read",
|
|
83
|
-
summary: "Show a quick status summary for the local Codex directory.",
|
|
84
|
-
usage: ["codexs status [--json] [--codex-dir <path>]"],
|
|
85
|
-
details: [
|
|
86
|
-
"Reports file presence, current profile, and whether the live profile is mapped.",
|
|
87
|
-
"Surfaces config consistency signals without mutating any files.",
|
|
88
|
-
"Use doctor for deeper diagnostics.",
|
|
89
|
-
],
|
|
90
|
-
examples: ["codexs status", "codexs status --json --codex-dir ./.tmp-codex"],
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: "edit",
|
|
94
|
-
group: "write",
|
|
95
|
-
summary: "Update fields on a single provider record.",
|
|
96
|
-
usage: [
|
|
97
|
-
"codexs edit <provider> [--profile <name>] [--api-key <key>] [--base-url <url>] [--note <text>] [--tag <tag> ...] [--json] [--codex-dir <path>]",
|
|
98
|
-
"codexs edit <provider> --profile <name> --create-profile --model <name> --base-url <url>",
|
|
99
|
-
],
|
|
100
|
-
details: [
|
|
101
|
-
"Passed flags replace only the selected fields and keep the rest unchanged.",
|
|
102
|
-
"TTY mode can first select a provider, then prompt for fields when no editable options were provided.",
|
|
103
|
-
"Interactive tags use preset multi-select plus optional custom comma-separated input.",
|
|
104
|
-
"When rebinding to a missing profile, --create-profile requires both --model and --base-url.",
|
|
105
|
-
"Backs up providers.json and config.toml before writing.",
|
|
106
|
-
],
|
|
107
|
-
examples: ["codexs edit packycode --note primary", "codexs edit packycode --tag daily --tag paid --json"],
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: "add",
|
|
111
|
-
group: "write",
|
|
112
|
-
summary: "Add a provider with explicit flags or progressive TTY prompts.",
|
|
113
|
-
usage: [
|
|
114
|
-
"codexs add <provider> --profile <name> --api-key <key> [--base-url <url>] [--note <text>] [--tag <tag> ...]",
|
|
115
|
-
"codexs add <provider> --profile <name> --api-key <key> --create-profile --model <name> --base-url <url>",
|
|
116
|
-
"codexs add [--profile <name>] [--api-key <key>] [--base-url <url>] [--note <text>] [--tag <tag> ...]",
|
|
117
|
-
],
|
|
118
|
-
details: [
|
|
119
|
-
"Prompts only for missing required values when stdin/stdout are TTYs and --json is not set.",
|
|
120
|
-
"Interactive add collects provider name, profile, and apiKey progressively as plain text inputs.",
|
|
121
|
-
"Confirm API key when prompted interactively because the hidden prompt asks twice before writing.",
|
|
122
|
-
"Interactive tags use preset multi-select plus optional custom comma-separated input.",
|
|
123
|
-
"Automation and non-TTY environments must pass all required values explicitly.",
|
|
124
|
-
"Creating a missing profile section requires --create-profile together with --model and --base-url.",
|
|
125
|
-
],
|
|
126
|
-
examples: [
|
|
127
|
-
"codexs add packycode --profile packycode --api-key sk-xxx",
|
|
128
|
-
"codexs add packycode --profile packycode",
|
|
129
|
-
"codexs add",
|
|
130
|
-
],
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: "switch",
|
|
134
|
-
group: "write",
|
|
135
|
-
summary: "Switch to a provider and optionally refresh Codex login.",
|
|
136
|
-
usage: ["codexs switch <provider> [--no-login] [--json] [--codex-dir <path>]"],
|
|
137
|
-
details: [
|
|
138
|
-
"When <provider> is omitted in a TTY, an interactive provider selector is shown.",
|
|
139
|
-
"When <provider> is passed explicitly, switch proceeds directly without extra confirmation.",
|
|
140
|
-
"--no-login remains explicit and is never prompted interactively.",
|
|
141
|
-
"Backs up config.toml and auth.json, then rolls back on failure.",
|
|
142
|
-
],
|
|
143
|
-
examples: ["codexs switch freemodel", "codexs switch --no-login", "codexs switch freemodel --no-login --json"],
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
name: "remove",
|
|
147
|
-
group: "write",
|
|
148
|
-
summary: "Remove a provider from providers.json.",
|
|
149
|
-
usage: ["codexs remove <provider> [--force] [--switch-to <profile>] [--json] [--codex-dir <path>]"],
|
|
150
|
-
details: [
|
|
151
|
-
"TTY mode can select a missing provider interactively and always asks for deletion confirmation.",
|
|
152
|
-
"Non-TTY and --json automation still require both <provider> and --force.",
|
|
153
|
-
"The confirmation prompt includes the provider name and cancels without writing when declined.",
|
|
154
|
-
"When removing the last provider linked to the active profile, pass --switch-to first.",
|
|
155
|
-
"Backs up providers.json and config.toml before removing the record.",
|
|
156
|
-
],
|
|
157
|
-
examples: ["codexs remove freemodel", "codexs remove freemodel --force --json"],
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
name: "import",
|
|
161
|
-
group: "write",
|
|
162
|
-
summary: "Replace providers.json with an external JSON file.",
|
|
163
|
-
usage: ["codexs import <file> [--json] [--codex-dir <path>]"],
|
|
164
|
-
details: [
|
|
165
|
-
"The file path is always explicit; there is no path wizard in this release.",
|
|
166
|
-
"TTY mode asks for confirmation before replacing or merging into the current providers registry.",
|
|
167
|
-
"Non-TTY and --json runs stay non-interactive and validate the file before writing.",
|
|
168
|
-
],
|
|
169
|
-
examples: ["codexs import ./providers.json", "codexs import ./providers.json --merge --json"],
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
name: "export",
|
|
173
|
-
group: "write",
|
|
174
|
-
summary: "Export the current providers.json to another file.",
|
|
175
|
-
usage: ["codexs export <file> [--force] [--json] [--codex-dir <path>]"],
|
|
176
|
-
details: [
|
|
177
|
-
"The file path is always explicit; there is no path wizard in this release.",
|
|
178
|
-
"TTY mode asks before overwriting an existing target when --force is not supplied.",
|
|
179
|
-
"Non-TTY and --json automation require --force to overwrite an existing file.",
|
|
180
|
-
],
|
|
181
|
-
examples: ["codexs export ./providers-backup.json", "codexs export ./providers-backup.json --force"],
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
name: "backups",
|
|
185
|
-
group: "recovery",
|
|
186
|
-
summary: "List historical backup entries.",
|
|
187
|
-
usage: ["codexs backups list [--json] [--codex-dir <path>]"],
|
|
188
|
-
details: [
|
|
189
|
-
"Enumerates backups/ manifests and returns them newest first.",
|
|
190
|
-
"Corrupt backup manifests are skipped with warnings instead of failing the whole command.",
|
|
191
|
-
],
|
|
192
|
-
examples: ["codexs backups list", "codexs backups list --json"],
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
name: "doctor",
|
|
196
|
-
group: "recovery",
|
|
197
|
-
summary: "Run configuration and environment diagnostics.",
|
|
198
|
-
usage: ["codexs doctor [--json] [--codex-dir <path>]"],
|
|
199
|
-
details: [
|
|
200
|
-
"Checks the expected config files, provider/profile consistency, and Codex CLI availability.",
|
|
201
|
-
"Returns structured issues so users and AI agents can act on them.",
|
|
202
|
-
],
|
|
203
|
-
examples: ["codexs doctor", "codexs doctor --json"],
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
name: "rollback",
|
|
207
|
-
group: "recovery",
|
|
208
|
-
summary: "Restore the latest managed backup or a specific backup id.",
|
|
209
|
-
usage: ["codexs rollback [<backup-id>] [--json] [--codex-dir <path>]"],
|
|
210
|
-
details: [
|
|
211
|
-
"TTY mode previews the target backup path and affected files, then asks for confirmation.",
|
|
212
|
-
"Non-TTY and --json runs stay non-interactive and execute immediately.",
|
|
213
|
-
"Use after a failed or undesired managed mutation.",
|
|
214
|
-
],
|
|
215
|
-
examples: ["codexs rollback", "codexs rollback 20260511-221457-switch --json"],
|
|
216
|
-
},
|
|
217
|
-
];
|
|
218
|
-
const COMMAND_NAME_SET = new Set(COMMANDS.map((command) => command.name));
|
|
219
|
-
function getKnownCommandNames() {
|
|
220
|
-
return COMMANDS.map((command) => command.name);
|
|
221
|
-
}
|
|
222
|
-
function isKnownCommandName(commandName) {
|
|
223
|
-
return COMMAND_NAME_SET.has(commandName) || commandName === "backups-list";
|
|
224
|
-
}
|
|
225
|
-
function buildHelpText(commandName) {
|
|
226
|
-
const normalizedCommandName = commandName === "backups-list"
|
|
227
|
-
? "backups"
|
|
228
|
-
: commandName === "config-show"
|
|
229
|
-
? "config-show"
|
|
230
|
-
: commandName === "config-list-profiles"
|
|
231
|
-
? "config-list-profiles"
|
|
232
|
-
: commandName === "config"
|
|
233
|
-
? "config-show"
|
|
234
|
-
: commandName;
|
|
235
|
-
if (!commandName) {
|
|
236
|
-
return [
|
|
237
|
-
"codex-switch",
|
|
238
|
-
"",
|
|
239
|
-
"Manage and switch local Codex provider/profile configuration safely.",
|
|
240
|
-
"",
|
|
241
|
-
"Usage:",
|
|
242
|
-
" codexs <command> [options]",
|
|
243
|
-
" codexs help <command>",
|
|
244
|
-
"",
|
|
245
|
-
...renderGroupedCommands(),
|
|
246
|
-
"",
|
|
247
|
-
"Global options:",
|
|
248
|
-
" --json Output the standard JSON envelope and disable all prompts.",
|
|
249
|
-
" --codex-dir <path> Target a specific Codex directory instead of ~/.codex.",
|
|
250
|
-
" --help Show top-level or command-specific help.",
|
|
251
|
-
" --version Print the current CLI version.",
|
|
252
|
-
"",
|
|
253
|
-
"Environment:",
|
|
254
|
-
" CODEXS_CODEX_DIR Default Codex directory when --codex-dir is not passed.",
|
|
255
|
-
" NODE_ENV=development defaults to ./dev-codex/local-sandbox when no override is set.",
|
|
256
|
-
"",
|
|
257
|
-
"Interactive rules:",
|
|
258
|
-
" Progressive prompts only run in a real TTY and never run under --json.",
|
|
259
|
-
" Human write commands may guide missing inputs or ask for dangerous-action confirmation.",
|
|
260
|
-
" Automation should pass explicit arguments and prefer --json for stable parsing.",
|
|
261
|
-
"",
|
|
262
|
-
"Dangerous commands:",
|
|
263
|
-
" remove deletes provider records.",
|
|
264
|
-
" import replaces or merges providers.json.",
|
|
265
|
-
" export may overwrite a target file.",
|
|
266
|
-
" rollback restores files from a managed backup.",
|
|
267
|
-
"",
|
|
268
|
-
"Examples:",
|
|
269
|
-
" codexs setup",
|
|
270
|
-
" codexs list",
|
|
271
|
-
" codexs switch",
|
|
272
|
-
" codexs add packycode --profile packycode --api-key sk-xxx",
|
|
273
|
-
" codexs config show",
|
|
274
|
-
" codexs remove freemodel",
|
|
275
|
-
" codexs backups list",
|
|
276
|
-
" codexs rollback",
|
|
277
|
-
" codexs help add",
|
|
278
|
-
].join("\n");
|
|
279
|
-
}
|
|
280
|
-
const command = COMMANDS.find((candidate) => candidate.name === normalizedCommandName);
|
|
281
|
-
if (!command) {
|
|
282
|
-
return [
|
|
283
|
-
`Unknown help topic: ${normalizedCommandName}`,
|
|
284
|
-
"",
|
|
285
|
-
"Available commands:",
|
|
286
|
-
...getKnownCommandNames().map((name) => ` ${name}`),
|
|
287
|
-
].join("\n");
|
|
288
|
-
}
|
|
289
|
-
return [
|
|
290
|
-
`codexs ${command.name}`,
|
|
291
|
-
"",
|
|
292
|
-
command.summary,
|
|
293
|
-
"",
|
|
294
|
-
"Usage:",
|
|
295
|
-
...command.usage.map((usage) => ` ${usage}`),
|
|
296
|
-
"",
|
|
297
|
-
"Details:",
|
|
298
|
-
...command.details.map((detail) => ` ${detail}`),
|
|
299
|
-
"",
|
|
300
|
-
"Examples:",
|
|
301
|
-
...command.examples.map((example) => ` ${example}`),
|
|
302
|
-
].join("\n");
|
|
303
|
-
}
|
|
304
|
-
function renderGroupedCommands() {
|
|
305
|
-
const lines = [];
|
|
306
|
-
for (const group of ["read", "write", "recovery"]) {
|
|
307
|
-
lines.push(`${GROUP_TITLES[group]}:`);
|
|
308
|
-
for (const command of COMMANDS.filter((candidate) => candidate.group === group)) {
|
|
309
|
-
lines.push(` ${command.name.padEnd(8, " ")} ${command.summary}`);
|
|
310
|
-
}
|
|
311
|
-
lines.push("");
|
|
312
|
-
}
|
|
313
|
-
lines.pop();
|
|
314
|
-
return lines;
|
|
315
|
-
}
|
|
3
|
+
exports.isKnownCommandName = exports.getKnownCommandNames = exports.buildHelpText = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Compatibility facade that re-exports CLI help helpers from the commands layer.
|
|
6
|
+
*/
|
|
7
|
+
var help_1 = require("../commands/help");
|
|
8
|
+
Object.defineProperty(exports, "buildHelpText", { enumerable: true, get: function () { return help_1.buildHelpText; } });
|
|
9
|
+
Object.defineProperty(exports, "getKnownCommandNames", { enumerable: true, get: function () { return help_1.getKnownCommandNames; } });
|
|
10
|
+
Object.defineProperty(exports, "isKnownCommandName", { enumerable: true, get: function () { return help_1.isKnownCommandNameForHelp; } });
|