codex-copilot-dx 1.2.33 → 1.3.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.
Files changed (42) hide show
  1. package/README.md +64 -110
  2. package/bin/cli.mjs +38 -102
  3. package/docs/ARCHITECTURE.md +23 -7
  4. package/docs/README.md +9 -76
  5. package/docs/REFERENCE.md +137 -1936
  6. package/package.json +11 -4
  7. package/src/access-settings.mjs +2 -2
  8. package/src/adapter.mjs +1 -1
  9. package/src/auth-credentials.mjs +1 -1
  10. package/src/auto-review-model.mjs +2 -2
  11. package/src/cli-animation.mjs +2 -2
  12. package/src/cli-auth.mjs +3 -3
  13. package/src/cli-cache.mjs +2 -2
  14. package/src/cli-command-spec.mjs +260 -58
  15. package/src/cli-image.mjs +2 -2
  16. package/src/cli-limits.mjs +2 -2
  17. package/src/cli-m365.mjs +1 -1
  18. package/src/cli-management.mjs +7 -3
  19. package/src/cli-options.mjs +71 -408
  20. package/src/connection-runtime.mjs +1408 -377
  21. package/src/copilot-token-session.mjs +1 -1
  22. package/src/dashboard/connections.js +23 -4
  23. package/src/dashboard/ui.css +9 -2
  24. package/src/dashboard-api.mjs +5 -5
  25. package/src/doctor.mjs +4 -4
  26. package/src/image-mcp.mjs +2 -2
  27. package/src/native-prediction-fix.mjs +1 -1
  28. package/src/native-prediction-profile.mjs +1 -1
  29. package/src/native-prediction-windows.mjs +1 -1
  30. package/src/native-prediction.mjs +6 -6
  31. package/src/nightly-update.mjs +2 -2
  32. package/src/provider-runtime.mjs +1 -1
  33. package/src/providers/m365-accounts.mjs +1 -1
  34. package/src/release-install.mjs +11 -15
  35. package/src/startup-ui.mjs +15 -11
  36. package/src/terminal-console.mjs +5 -4
  37. package/src/terminal-state.mjs +1 -1
  38. package/src/usage.mjs +5 -5
  39. package/src/windows-command.mjs +2 -2
  40. package/bin/codex-copilot-dx.mjs +0 -11
  41. package/src/cli-models.mjs +0 -94
  42. package/src/legacy-command-warning.mjs +0 -38
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "codex-copilot-dx",
3
- "version": "1.2.33",
3
+ "version": "1.3.0",
4
4
  "description": "Local gateway for Codex and Claude with Copilot, Microsoft 365 and custom APIs",
5
5
  "author": "Dale Xiao",
6
6
  "type": "module",
7
7
  "bin": {
8
- "ccdx": "bin/cli.mjs",
9
- "codex-copilot-dx": "bin/codex-copilot-dx.mjs"
8
+ "ccdx": "bin/cli.mjs"
10
9
  },
11
10
  "files": [
12
11
  "bin/",
@@ -60,5 +59,13 @@
60
59
  },
61
60
  "optionalDependencies": {
62
61
  "@azure/msal-node-runtime": "0.20.6"
63
- }
62
+ },
63
+ "os": [
64
+ "darwin",
65
+ "win32"
66
+ ],
67
+ "cpu": [
68
+ "x64",
69
+ "arm64"
70
+ ]
64
71
  }
@@ -2,7 +2,7 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { userSettingsPath } from "./user-settings.mjs";
4
4
  import { readBoundedFileSync } from "./bounded-file.mjs";
5
- import { atomicWriteFileSync } from "./atomic-file.mjs";
5
+ import { atomicWriteFileSync, atomicWriteFileIfChangedSync } from "./atomic-file.mjs";
6
6
  import { withFileLockSync } from "./lock.mjs";
7
7
  import { isProviderId } from "./provider-metadata.mjs";
8
8
  import { CODEX_AUTO_REVIEW_MODEL } from "./models.mjs";
@@ -114,6 +114,6 @@ export function updateAccessSettings(change, options = {}) {
114
114
  const original = readBoundedFileSync(file, { maxBytes: 8 * 1024 * 1024, encoding: "utf8" });
115
115
  if (JSON.parse(original).version === 1 && !fs.existsSync(`${file}.v1-backup`)) atomicWriteFileSync(`${file}.v1-backup`, original, { mode: 0o600 });
116
116
  } catch (error) { if (error.code !== "ENOENT") throw error; }
117
- atomicWriteFileSync(file, text, { mode: 0o600 });return next;
117
+ atomicWriteFileIfChangedSync(file, text, { mode: 0o600 });return next;
118
118
  });
119
119
  }
package/src/adapter.mjs CHANGED
@@ -77,7 +77,7 @@ function sendRetiredClaudeSurface(res) {
77
77
  error: {
78
78
  type: "not_found_error",
79
79
  code: "ccdx_claude_retired",
80
- message: "The GitHub Claude endpoint was retired in ccdx 0.7.0. Microsoft 365 Claude uses the separate gateway; run ccdx m365 status.",
80
+ message: "The GitHub Claude endpoint was retired in ccdx 0.7.0. Microsoft 365 Claude uses the separate gateway; run ccdx source m365 status.",
81
81
  },
82
82
  }));
83
83
  }
@@ -35,7 +35,7 @@ export function githubTokenMetadataPath(home = os.homedir()) {
35
35
 
36
36
  export function githubReauthMessage(reason, home = os.homedir()) {
37
37
  return `${reason}
38
- Run ccdx auth reauth to sign in again.
38
+ Run ccdx source github reauth to sign in again.
39
39
  The saved sign-in is kept until verification succeeds.`;
40
40
  }
41
41
 
@@ -93,7 +93,7 @@ export async function runAutoReviewModelCommand({
93
93
  followClientLabel = "follow client (low when omitted)",
94
94
  } = {}) {
95
95
  if (!prompt && (!input.isTTY || !output.isTTY)) {
96
- throw new Error(`${commandName} auto-review-model requires an interactive terminal`);
96
+ throw new Error(`${commandName} app codex review select requires an interactive terminal`);
97
97
  }
98
98
 
99
99
  readUserSettings({ env, home, strict: true });
@@ -102,7 +102,7 @@ export async function runAutoReviewModelCommand({
102
102
  const modelIds = sortedModelIds(catalog.modelIds, current.model);
103
103
  if (!modelIds.length) throw new Error("No selectable Responses models are available");
104
104
 
105
- output.write(`${commandName} auto-review-model\n`);
105
+ output.write(`${commandName} app codex review select\n`);
106
106
  output.write(`Current: ${current.model} (${current.source})\n`);
107
107
  output.write(`Reasoning: ${current.reasoningEffort || followClientLabel}\n`);
108
108
  output.write(`Responses models from ${catalog.source}:\n`);
@@ -38,14 +38,14 @@ export async function runAnimationCommand({
38
38
  gallery = startTerminalAnimationGallery,
39
39
  } = {}) {
40
40
  if (!prompt && (!input.isTTY || !output.isTTY)) {
41
- throw new Error(`${commandName} animation requires an interactive terminal`);
41
+ throw new Error(`${commandName} config animation requires an interactive terminal`);
42
42
  }
43
43
 
44
44
  readUserSettings({ env, home, strict: true });
45
45
  const current = terminalAnimationPreference({ env, home });
46
46
  const currentIndex = TERMINAL_ANIMATION_THEMES.findIndex(({ id }) => id === current.theme);
47
47
 
48
- output.write(`${commandName} animation\n`);
48
+ output.write(`${commandName} config animation\n`);
49
49
  output.write(`Current: ${TERMINAL_ANIMATION_THEMES[currentIndex].label} (${current.source})\n\n`);
50
50
  const labels = TERMINAL_ANIMATION_THEMES.map((theme, index) => ` ${index + 1}. ${theme.label}${markers(theme, current.theme)}`);
51
51
  const prefixWidth = Math.max(...labels.map((label) => label.length)) + 2;
package/src/cli-auth.mjs CHANGED
@@ -31,7 +31,7 @@ function onlineStatusLine(profile) {
31
31
 
32
32
  function authStatusPlainLines(snapshot, { commandName }) {
33
33
  return [
34
- `${commandName} auth status`,
34
+ `${commandName} source github status`,
35
35
  status(snapshot.profiles.codex.valid ? "ok" : "warn", `Codex: ${accountLabel(snapshot.profiles.codex)} [${snapshot.profiles.codex.source === "ccdx" ? "CCDX store" : "legacy path"}]`),
36
36
  onlineStatusLine(snapshot.profiles.codex),
37
37
  status("info", `Routing: responses -> ${snapshot.routing.responses}`),
@@ -90,7 +90,7 @@ export function formatAuthStatus(snapshot = authStatus(), {
90
90
  if (format === "auto" && table.overflow) {
91
91
  return plainLines.map((line) => terminalCell(line, { fallback: "" })).join("\n");
92
92
  }
93
- const lines = [`${commandName} auth status`, "", table.output];
93
+ const lines = [`${commandName} source github status`, "", table.output];
94
94
  if (table.compact) {
95
95
  lines.push("", "Details:", ...plainLines.slice(1, -1).map((line) => terminalCell(line, { fallback: "" })));
96
96
  }
@@ -137,7 +137,7 @@ export async function runAuthCommand({
137
137
  if (result.operation?.state === "failed") throw new Error(`Sign-in failed: ${safeCell(result.operation.reason)}. Saved sign-in kept.`);
138
138
  return { action, output: result.operation?.state === "cancelled" ? "Sign-in cancelled. Saved sign-in kept."
139
139
  : result.operation?.state === "complete" ? "Signed in and verified. Use a new conversation; restart CCDX to change accounts."
140
- : "A sign-in is saved. Run ccdx auth check to verify it, or ccdx auth reauth to replace it." };
140
+ : "A sign-in is saved. Run ccdx source github check to verify it, or ccdx source github reauth to replace it." };
141
141
  } finally { process.removeListener("SIGINT", cancel);tools.dispose(); }
142
142
  }
143
143
  if (action !== "status") throw new Error(`Unsupported auth action: ${action}`);
package/src/cli-cache.mjs CHANGED
@@ -61,7 +61,7 @@ async function confirmHistoryCleanup({ input, output, prompt, yes }) {
61
61
  }
62
62
 
63
63
  function formatStatus(preference, runtime) {
64
- const lines = ["ccdx cache", `Saved buffer limit: ${mib(preference.bytes)} (${preference.source})`];
64
+ const lines = ["ccdx doctor cache", `Saved buffer limit: ${mib(preference.bytes)} (${preference.source})`];
65
65
  if (!runtime?.supported) {
66
66
  lines.push(runtime?.offline
67
67
  ? "Runtime cache: adapter is not running"
@@ -104,7 +104,7 @@ export async function runCacheCommand({
104
104
  }
105
105
  if (action === "limit") {
106
106
  if (String(env.CCDX_RESPONSE_HISTORY_MAX_BYTES || "").trim()) {
107
- throw new Error("CCDX_RESPONSE_HISTORY_MAX_BYTES overrides saved cache settings; unset it before using ccdx cache --limit");
107
+ throw new Error("CCDX_RESPONSE_HISTORY_MAX_BYTES overrides saved cache settings; unset it before using ccdx doctor cache --limit");
108
108
  }
109
109
  const targetMib = resetLimit ? RESPONSE_HISTORY_DEFAULT_MIB : Number(limitMib);
110
110
  const targetBytes = targetMib * MIB;
@@ -1,58 +1,206 @@
1
1
  import { isProviderId } from "./provider-metadata.mjs";
2
2
 
3
- export const CLI_CLIENTS = Object.freeze({ codex: "codex", "claude-app": "claude_app", "claude-code": "claude_code" });
4
- const read = { "--format": "format" }, confirm = { "--yes": "flag", "--preview": "flag" };
5
- const command = (path, description, options = {}, legacy) => ({ path: path.split(" "), description, options, legacy });
6
- // Canonical routes, their arguments and nearby help share one definition. Legacy
7
- // roots keep the old parser and output contracts rather than being reinterpreted.
3
+ export const CLI_CLIENTS = Object.freeze({
4
+ codex: "codex",
5
+ "claude-app": "claude_app",
6
+ "claude-code": "claude_code",
7
+ });
8
+ const read = { "--format": "format" },
9
+ confirm = { "--yes": "flag", "--preview": "flag" };
10
+ const command = (path, description, options = {}, dispatch) => ({
11
+ path: path.split(" "),
12
+ description,
13
+ options,
14
+ dispatch,
15
+ });
16
+ // Commands, option validation and nearby help share one public grammar.
8
17
  export const MANAGED_COMMANDS = [
18
+ command(
19
+ "start",
20
+ "Start the local gateway",
21
+ { "--show-request-id": "flag", "--no-browser": "flag", "--verbose": "flag" },
22
+ flags => ({
23
+ command: "start",
24
+ showRequestId: !!flags.show_request_id,
25
+ noBrowser: !!flags.no_browser,
26
+ verbose: !!flags.verbose,
27
+ })
28
+ ),
29
+ command("version", "Show the installed version", {}, () => ({ command: "version" })),
30
+ command("web", "Open the local Web UI", {}, () => ({ command: "web" })),
31
+ command(
32
+ "doctor",
33
+ "Check local setup",
34
+ { "--online": "flag", "--compat": "flag", "--fix": "flag", "--json": "flag" },
35
+ flags => ({
36
+ command: "doctor",
37
+ online: !!flags.online,
38
+ compat: !!flags.compat,
39
+ fix: !!flags.fix,
40
+ json: !!flags.json,
41
+ })
42
+ ),
43
+ command("doctor config", "Check client configuration without changes", {}, () => ({
44
+ command: "doctor",
45
+ configOnly: true,
46
+ })),
47
+ ...["network", "report"].map(tool =>
48
+ command(`doctor ${tool}`, "Inspect local diagnostics", {}, () => ({ command: "doctor", tool }))
49
+ ),
50
+ ...["", "github", "npm"].map(source =>
51
+ command(
52
+ `update${source ? " " + source : ""}`,
53
+ "Install an update; restart normally afterward",
54
+ { "--allow-remote": "flag" },
55
+ flags => ({ command: "update", updateSource: source || undefined, allowRemote: !!flags.allow_remote })
56
+ )
57
+ ),
9
58
  command("source list", "List registered model sources", read),
10
- command("source add", "Save an API and read its model catalog", { "--file": "value", "--key-stdin": "flag", ...confirm }),
59
+ command("source add", "Save an API and read its model catalog", {
60
+ "--file": "value",
61
+ "--key-stdin": "flag",
62
+ ...confirm,
63
+ }),
11
64
  command("source <source> status", "Show saved sign-in and catalog evidence", read),
12
- command("source <source> models", "Show the source catalog; refresh explicitly", { ...read, "--refresh": "flag" }),
65
+ command("source <source> models", "Show the source catalog; refresh explicitly", {
66
+ ...read,
67
+ "--refresh": "flag",
68
+ }),
13
69
  command("source <source> check", "Check source access without inference", read),
14
- command("source <source> edit", "Edit API configuration and model selection", { "--file": "value", "--key-stdin": "flag", ...confirm }),
15
- command("source <source> access", "Show or edit client authorization", { ...read, "--edit": "flag", "--apps": "value", ...confirm }),
70
+ command("source <source> edit", "Edit API configuration and model selection", {
71
+ "--file": "value",
72
+ "--key-stdin": "flag",
73
+ ...confirm,
74
+ }),
75
+ command("source <source> access", "Show or edit client authorization", {
76
+ ...read,
77
+ "--edit": "flag",
78
+ "--apps": "value",
79
+ ...confirm,
80
+ }),
16
81
  command("source <source> enable", "Enable a source without selecting client models", confirm),
17
- command("source <source> disable", "Review affected clients before disabling", { ...confirm, "--replacements": "value" }),
82
+ command("source <source> disable", "Review affected clients before disabling", {
83
+ ...confirm,
84
+ "--replacements": "value",
85
+ }),
18
86
  command("source <source> remove", "Remove a disabled, unbound API source", confirm),
19
- ...["login", "reauth", "logout"].map(action => command(`source github ${action}`, "Manage GitHub sign-in only", action === "logout" ? { "--yes": "flag" } : { "--login": "value" }, flags => ["auth", action, ...Object.entries(flags).flatMap(([key, value]) => value === true ? [`--${key}`] : [`--${key}`, value])])),
20
- ...["accounts", "account"].map(action => command(`source m365 ${action}`, "Read or select a shared company account", action === "account" ? { "--id": "value" } : {}, flags => ["m365", action, ...(flags.id ? ["--id", flags.id] : [])])),
87
+ ...["login", "reauth", "logout"].map(action =>
88
+ command(
89
+ `source github ${action}`,
90
+ "Manage GitHub sign-in",
91
+ action === "logout" ? { "--yes": "flag" } : { "--login": "value" },
92
+ flags => ({
93
+ command: "auth",
94
+ action,
95
+ yes: !!flags.yes,
96
+ ...(flags.login ? { expectedLogin: flags.login } : {}),
97
+ })
98
+ )
99
+ ),
100
+ ...["accounts", "account"].map(action =>
101
+ command(
102
+ `source m365 ${action}`,
103
+ "Read or select a company account",
104
+ action === "account" ? { "--id": "value" } : {},
105
+ flags => ({ command: "m365", action, ...(flags.id ? { accountId: flags.id } : {}) })
106
+ )
107
+ ),
21
108
  command("app list", "List client configuration and observed activity", read),
22
109
  command("app <app> status", "Show configuration, not process liveness", { ...read, "--details": "flag" }),
23
- command("app <app> models", "Show or edit the client's selected model plan", { ...read, "--edit": "flag", "--file": "value", ...confirm }),
110
+ command("app <app> models", "Show or edit the client's selected model plan", {
111
+ ...read,
112
+ "--edit": "flag",
113
+ "--file": "value",
114
+ ...confirm,
115
+ }),
24
116
  command("app <app> sync", "Preview or write CCDX-owned client configuration", confirm),
25
117
  command("app <app> enable", "Enable client access with its saved selection", confirm),
26
118
  command("app <app> disable", "Disable access without quitting the app", confirm),
27
- command("app codex prediction status", "Show Codex prediction setup and observation", read),
28
- ...["setup", "remove", "pause", "resume", "repair"].map(action => command(`app codex prediction ${action}`, "Manage the optional Codex prediction integration", {}, () => ["prediction", { setup: "on", remove: "off", repair: "fix" }[action] || action])),
29
- command("app codex image status", "Show Codex image setup; do not generate", read),
30
- ...["setup", "remove", "pause", "resume"].map(action => command(`app codex image ${action}`, "Manage the Codex image integration", {}, () => action === "setup" ? ["enable-image"] : action === "remove" ? ["disable-image"] : ["image", action])),
119
+ command(
120
+ "app codex prediction status",
121
+ "Show local Codex prediction setup and observation",
122
+ read,
123
+ flags => ({
124
+ command: "prediction",
125
+ action: "status",
126
+ outputFormat: flags.format,
127
+ })
128
+ ),
129
+ ...["setup", "remove", "pause", "resume", "repair"].map(action =>
130
+ command(`app codex prediction ${action}`, "Manage the optional Codex prediction integration", {}, () => ({
131
+ command: "prediction",
132
+ action: { setup: "on", remove: "off", repair: "fix" }[action] || action,
133
+ }))
134
+ ),
135
+ command("app codex image status", "Show local Codex image setup; do not generate", read, flags => ({
136
+ command: "image",
137
+ action: "status",
138
+ outputFormat: flags.format,
139
+ })),
140
+ ...["setup", "remove", "pause", "resume"].map(action =>
141
+ command(`app codex image ${action}`, "Manage the Codex image integration", {}, () => ({
142
+ command: "image",
143
+ action: { setup: "enable", remove: "disable" }[action] || action,
144
+ }))
145
+ ),
31
146
  command("app codex review status", "Show the Codex Auto-review selection", read),
32
- command("app codex review select", "Choose the Codex Auto-review model", {}, () => ["auto-review-model"]),
147
+ command("app codex review select", "Choose the Codex Auto-review model", {}, () => ({
148
+ command: "auto-review-model",
149
+ })),
33
150
  command("config show", "Show service and terminal preferences", { ...read, "--effective": "flag" }),
34
151
  command("config set <key> <value>", "Save a validated service preference", confirm),
35
152
  command("config terminal", "Choose terminal color", {}),
36
- command("config animation", "Choose terminal animation", {}, () => ["animation"]),
37
- command("config limits", "Show or set decoded-body limits", { "--decoded": "value" }, flags => ["limits", ...(flags.decoded ? ["--decoded", flags.decoded] : [])]),
153
+ command("config animation", "Choose terminal animation", {}, () => ({ command: "animation" })),
154
+ command("config limits", "Show or set decoded-body limits", { "--decoded": "value" }, flags => ({
155
+ command: "limits",
156
+ action: flags.decoded ? "set" : "status",
157
+ resetLimit: flags.decoded === "default",
158
+ limitMib: flags.decoded && flags.decoded !== "default" ? Number(flags.decoded) : undefined,
159
+ })),
38
160
  command("config reset", "Back up and restore service preferences to defaults", confirm),
39
161
  command("config restore", "Restore the current service preference backup", confirm),
40
- command("doctor cache", "Inspect or clear bounded runtime buffers", { "--limit": "value", "--clean": "flag", "--history": "flag", "--yes": "flag" }, flags => ["cache", ...Object.entries(flags).flatMap(([key, value]) => value === true ? [`--${key}`] : [`--${key}`, value])]),
41
- command("requests", "Show bounded recent model requests", { ...read, "--active": "flag", "--failed": "flag", "--app": "value", "--source": "value", "--limit": "integer" }),
162
+ command(
163
+ "doctor cache",
164
+ "Inspect or clear runtime buffers",
165
+ { "--limit": "value", "--clean": "flag", "--history": "flag", "--yes": "flag" },
166
+ flags => ({
167
+ command: "cache",
168
+ action: flags.limit ? "limit" : flags.clean ? "clean" : "status",
169
+ resetLimit: flags.limit === "default",
170
+ limitMib: flags.limit && flags.limit !== "default" ? Number(flags.limit) : undefined,
171
+ history: !!flags.history,
172
+ yes: !!flags.yes,
173
+ })
174
+ ),
175
+ command("requests", "Show bounded recent model requests", {
176
+ ...read,
177
+ "--active": "flag",
178
+ "--failed": "flag",
179
+ "--app": "value",
180
+ "--source": "value",
181
+ "--limit": "integer",
182
+ }),
42
183
  command("requests show <request>", "Show a retained request and its original diagnostic fields", read),
43
184
  command("status", "Show service state; expand diagnostics explicitly", { ...read, "--details": "flag" }),
44
- command("usage", "Show all recorded usage or this service run", { ...read, "--scope": "scope", "--provider": "value" }),
185
+ command("usage", "Show all recorded usage or this service run", {
186
+ ...read,
187
+ "--scope": "scope",
188
+ "--provider": "value",
189
+ }),
45
190
  command("update check", "Check a stable release without installing", read),
46
191
  ];
47
192
 
48
193
  function pathMatch(pattern, values, partial = false) {
49
- if ((!partial && pattern.length !== values.length) || partial && pattern.length < values.length) return null;
194
+ if ((!partial && pattern.length !== values.length) || (partial && pattern.length < values.length))
195
+ return null;
50
196
  const found = {};
51
197
  for (let index = 0; index < values.length; index++) {
52
- const token = pattern[index], value = values[index];
198
+ const token = pattern[index],
199
+ value = values[index];
53
200
  if (token.startsWith("<")) {
54
201
  const key = token.slice(1, -1);
55
- if (key === "source" && !isProviderId(value) || key === "app" && !Object.hasOwn(CLI_CLIENTS, value)) return null;
202
+ if ((key === "source" && !isProviderId(value)) || (key === "app" && !Object.hasOwn(CLI_CLIENTS, value)))
203
+ return null;
56
204
  found[key] = value;
57
205
  } else if (token !== value) return null;
58
206
  }
@@ -61,63 +209,117 @@ function pathMatch(pattern, values, partial = false) {
61
209
  function optionsFor(args, definition) {
62
210
  const values = {};
63
211
  for (let index = 0; index < args.length; index++) {
64
- const option = args[index], type = definition.options[option], key = option.replace(/^--/, "").replaceAll("-", "_");
212
+ const option = args[index],
213
+ type = definition.options[option],
214
+ key = option.replace(/^--/, "").replaceAll("-", "_");
65
215
  if (!type || Object.hasOwn(values, key)) throw new Error(`Unexpected or repeated option: ${option}`);
66
- if (type === "flag") { values[key] = true;continue; }
216
+ if (type === "flag") {
217
+ values[key] = true;
218
+ continue;
219
+ }
67
220
  const value = args[++index];
68
221
  if (!value || value.startsWith("--")) throw new Error(`Enter a value for ${option}`);
69
- if (type === "format" && !["table", "plain", "json"].includes(value)) throw new Error("Format must be table, plain or json");
222
+ if (type === "format" && !["table", "plain", "json"].includes(value))
223
+ throw new Error("Format must be table, plain or json");
70
224
  if (type === "scope" && !["run", "all"].includes(value)) throw new Error("Scope must be run or all");
71
- if (type === "integer" && (!/^\d+$/.test(value) || Number(value) < 1 || Number(value) > 100)) throw new Error("Limit must be an integer from 1 to 100");
225
+ if (type === "integer" && (!/^\d+$/.test(value) || Number(value) < 1 || Number(value) > 100))
226
+ throw new Error("Limit must be an integer from 1 to 100");
72
227
  values[key] = type === "integer" ? Number(value) : value;
73
228
  }
74
- if (values.app && !Object.hasOwn(CLI_CLIENTS, values.app)) throw new Error("Choose codex, claude-app or claude-code");
229
+ if (values.app && !Object.hasOwn(CLI_CLIENTS, values.app))
230
+ throw new Error("Choose codex, claude-app or claude-code");
75
231
  if (values.provider && !isProviderId(values.provider)) throw new Error("Enter a valid usage source ID");
76
232
  if (values.source && !isProviderId(values.source)) throw new Error("Enter a listed source ID");
77
233
  if (values.active && values.failed) throw new Error("Choose --active or --failed");
78
234
  if (values.apps !== undefined && !values.edit) throw new Error("--apps requires --edit");
79
235
  if (values.file && definition.path[0] === "app" && !values.edit) throw new Error("--file requires --edit");
80
- if ((values.active || values.failed || values.edit || values.preview) && values.format === "json" && values.edit) throw new Error("Interactive edits do not use JSON output");
236
+ if (
237
+ (values.active || values.failed || values.edit || values.preview) &&
238
+ values.format === "json" &&
239
+ values.edit
240
+ )
241
+ throw new Error("Interactive edits do not use JSON output");
81
242
  return values;
82
243
  }
83
244
  export function parseManagedCommand(args) {
84
245
  const root = args[0];
85
- const applicable = ["app", "config", "requests"].includes(root)
86
- || root === "source" && (args.length > 2 && !args[2].startsWith("-") || ["list", "add"].includes(args[1]))
87
- || root === "doctor" && args[1] === "cache"
88
- || root === "update" && args[1] === "check"
89
- || root === "status" && args.some(value => value.startsWith("--"))
90
- || root === "usage" && (args.includes("--scope") || args[args.indexOf("--format") + 1] === "json");
91
- if (!applicable) return null;
92
- const optionAt = args.findIndex(value => value.startsWith("--")), words = optionAt < 0 ? args : args.slice(0, optionAt);
246
+ const optionAt = args.findIndex(value => value.startsWith("--")),
247
+ words = optionAt < 0 ? args : args.slice(0, optionAt);
93
248
  const candidates = MANAGED_COMMANDS.filter(item => pathMatch(item.path, words));
94
- const definition = candidates.sort((a, b) => a.path.filter(token => token.startsWith("<")).length - b.path.filter(token => token.startsWith("<")).length)[0];
249
+ const definition = candidates.sort(
250
+ (a, b) =>
251
+ a.path.filter(token => token.startsWith("<")).length -
252
+ b.path.filter(token => token.startsWith("<")).length
253
+ )[0];
95
254
  if (!definition) throw new Error(`Unknown command path: ${words.join(" ")}. Use ccdx ${root} --help`);
96
- const values = optionsFor(optionAt < 0 ? [] : args.slice(optionAt), definition), ids = pathMatch(definition.path, words);
97
- if (definition.legacy) return { legacy: definition.legacy(values) };
255
+ const values = optionsFor(optionAt < 0 ? [] : args.slice(optionAt), definition),
256
+ ids = pathMatch(definition.path, words);
257
+ if (values.login && !/^[a-z\d_-]{1,39}$/i.test(values.login))
258
+ throw new Error("Enter a GitHub account name");
259
+ if (values.id && !/^[a-f0-9]{64}$/.test(values.id))
260
+ throw new Error("Use an account ID from source m365 accounts");
261
+ if (
262
+ words.join(" ") === "doctor cache" &&
263
+ ((values.limit && values.clean) || ((values.history || values.yes) && !values.clean))
264
+ )
265
+ throw new Error("Use --limit alone or --clean [--history] [--yes]");
266
+ for (const key of ["limit", "decoded"])
267
+ if (values[key] && values[key] !== "default" && !/^\d+$/.test(values[key]))
268
+ throw new Error("Enter an integer MiB value or default");
269
+ if (definition.dispatch) return { dispatch: definition.dispatch(values, ids) };
98
270
  return { command: "manage", group: root, path: words, ids, flags: values };
99
271
  }
100
272
 
101
273
  const extras = {
102
- source: "Status reads local/cached evidence. check/--refresh may contact the source; no inference.\nSource access grants do not select client models. Disable previews affected clients.\nGitHub login and company-account selection are source-specific.\nLegacy ccdx source github|m365 still switches Codex only.",
274
+ source:
275
+ "Status reads local/cached evidence. check/--refresh may contact the source; no inference.\nSource access grants do not select client models. Disable previews affected clients.\nGitHub login and company-account selection are source-specific.\nChoose visible models and defaults with app <app> models --edit.",
103
276
  app: "Configured is not App adoption or process liveness. Unknown stays unknown.\nmodels shows the selected plan; source <id> models shows the upstream catalog.\nsetup/remove changes integration setup; pause/resume retains credentials.\nsync --preview shows the model/configuration plan, not a byte-level file diff.\nNo client program is force-restarted.",
104
- config: "Only service and terminal preferences are in scope. Browser appearance stays in WebUI.\nReset keeps accounts, keys, model plans and chats and stores a pre-reset backup.\nSaved and effective values can differ; restart requirements remain explicit.",
105
- requests: "Only retained records are available. Unknown clients are not guessed from an API route.\n--failed filters failed model outcomes and structured HTTP/model errors.\nUsage records, HTTP calls and model outcomes are distinct counters.",
106
- status: "Default interactive status is brief; --details retains the complete diagnostic view.\nThe installed package version can differ from the running service.\nA listening gateway does not prove upstream model access.",
107
- usage: "Default legacy usage remains all recorded usage. --scope run reads the running service.\nUsage records are not billed request counts. Cache hit is a token-reuse estimate.",
108
- doctor: "Legacy cache flags and confirmation rules remain. --history may break chat continuation.",
109
- update: "check does not install. Existing update github/npm behavior and npm policy are retained.\nFinish tasks before changing the active installation; restart normally afterward.",
277
+ config:
278
+ "Only service and terminal preferences are in scope. Browser appearance stays in WebUI.\nReset keeps accounts, keys, model plans and chats and stores a pre-reset backup.\nSaved and effective values can differ; restart requirements remain explicit.",
279
+ requests:
280
+ "Only retained records are available. Unknown clients are not guessed from an API route.\n--failed filters failed model outcomes and structured HTTP/model errors.\nUsage records, HTTP calls and model outcomes are distinct counters.",
281
+ status:
282
+ "Default interactive status is brief; --details retains the complete diagnostic view.\nThe installed package version can differ from the running service.\nA listening gateway does not prove upstream model access.",
283
+ usage:
284
+ "Default usage includes all recorded usage. --scope run reads the running service.\nUsage records are not billed request counts. Cache hit is a token-reuse estimate.",
285
+ doctor:
286
+ "Default checks are read-only. Explicit online/compatibility checks and owned repairs have separate options.",
287
+ update:
288
+ "check does not install. Updates preserve npm policy. --allow-remote permits URL downloads for the entire dependency tree for this installation only.\nFinish tasks before changing the active installation; restart normally afterward.",
110
289
  };
111
290
  export function managedCommandHelp(parts) {
112
- if (parts[0] === "legacy") return "Compatibility entrypoints remain supported:\n auth / reauth GitHub sign-in; legacy account fields retained\n models Codex catalog; not silently replaced by selected models\n source / m365 switch Codex-only switching\n m365 on/off/remove Existing access and profile-cleanup effects\n prediction / image Codex-only features\n enable-image / disable-image / image-status\n auto-review-model Codex Auto-review\n animation / cache / limits\nRetired commands retain their existing safe cleanup/refusal behavior.\nLegacy non-TTY and machine output paths remain available.";
113
- const supported = ["source", "app", "config", "requests", "status", "usage", "update"].includes(parts[0]) || parts.join(" ") === "doctor cache" || parts.join(" ") === "update check";
114
- if (!supported) return null;
115
- const entries = MANAGED_COMMANDS.filter(item => pathMatch(item.path, parts, true)
116
- && !(parts[0] === "source" && ["github", "m365"].includes(parts[1]) && ["edit", "remove"].includes(item.path.at(-1))));
291
+ if (!MANAGED_COMMANDS.some(item => item.path[0] === parts[0])) return null;
292
+ const entries = MANAGED_COMMANDS.filter(
293
+ item =>
294
+ pathMatch(item.path, parts, true) &&
295
+ !(
296
+ parts[0] === "source" &&
297
+ ["github", "m365"].includes(parts[1]) &&
298
+ ["edit", "remove"].includes(item.path.at(-1))
299
+ )
300
+ );
117
301
  if (!entries.length) throw new Error(`Unknown help path: ${parts.join(" ")}`);
118
- return "Usage:\n" + entries.map(item => ` ccdx ${item.path.map((token, index) => parts[index] || token).join(" ")}${Object.entries(item.options).map(([name, type]) => ` [${name}${type === "flag" ? "" : type === "format" ? " table|plain|json" : " VALUE"}]`).join("")}\n ${item.description}`).join("\n")
119
- + (parts[0] === "update" && parts.length === 1 ? "\n ccdx update [npm|github] [--allow-remote]\n Install with existing policy-preserving behavior" : "") + "\n\n" + extras[parts[0]];
302
+ return (
303
+ "Usage:\n" +
304
+ entries
305
+ .map(
306
+ item =>
307
+ ` ccdx ${item.path.map((token, index) => parts[index] || token).join(" ")}${Object.entries(
308
+ item.options
309
+ )
310
+ .map(
311
+ ([name, type]) =>
312
+ ` [${name}${type === "flag" ? "" : type === "format" ? " table|plain|json" : " VALUE"}]`
313
+ )
314
+ .join("")}\n ${item.description}`
315
+ )
316
+ .join("\n") +
317
+ (extras[parts[0]] ? "\n\n" + extras[parts[0]] : "") +
318
+ (parts.join(" ") === "doctor cache"
319
+ ? "\nHistory cleanup requires confirmation or --yes. --history may break chat continuation."
320
+ : "")
321
+ );
120
322
  }
121
323
  export function rootCommandHelp() {
122
- return `Usage:\n ccdx [start] [--show-request-id] [--no-browser] [--verbose]\n\nCommon:\n status Show service state; --details expands diagnostics\n web Open local management tools\n requests Show retained model requests and failures\n usage Show recorded token usage\n doctor Check local setup; deeper checks are explicit\n\nManage:\n source Accounts, APIs, catalogs and client authorization\n app Client model plans, sync and app-specific features\n config Service and terminal preferences\n\nUpdate:\n update check Check without installing\n update github|npm Install; restart the service normally afterward\n version Show installed package version\n\nHelp:\n ccdx <command> --help\n ccdx help app codex prediction\n ccdx help legacy\n\nCompatibility:\n auth, reauth, models, m365, prediction, image, enable-image,\n disable-image, image-status, auto-review-model, animation, cache, limits\n\nStart keeps the existing configured-client setup and launch behavior.\nCLI output stays in English. Read-only commands do not start a service.`;
324
+ return `Usage:\n ccdx [start] [--show-request-id] [--no-browser] [--verbose]\n\nCommon:\n status Show service state; --details expands diagnostics\n web Open local management tools\n requests Show retained model requests and failures\n usage Show recorded token usage\n doctor Check local setup; deeper checks are explicit\n\nManage:\n source Accounts, APIs, catalogs and client authorization\n app Client model plans, sync and app-specific features\n config Service and terminal preferences\n\nUpdate:\n update check Check without installing\n update github|npm Install; restart the service normally afterward\n version Show installed package version\n\nHelp:\n ccdx <command> --help\n ccdx help app codex prediction\n\nStart keeps the existing configured-client setup and launch behavior.\nCLI output stays in English. Read-only commands do not start a service.`;
123
325
  }
package/src/cli-image.mjs CHANGED
@@ -211,13 +211,13 @@ export async function runImageCommand({
211
211
  }
212
212
  if (action !== "enable") throw new Error(`Unknown image command action: ${action}`);
213
213
  if (!prompt && (!input.isTTY || !output.isTTY)) {
214
- throw new Error(`${commandName} enable-image requires an interactive terminal`);
214
+ throw new Error(`${commandName} app codex image setup requires an interactive terminal`);
215
215
  }
216
216
 
217
217
  const current = readImageProviderConfig({ env, home });
218
218
  const ask = prompt || ((question) => visibleQuestion(input, output, question));
219
219
  const askSecret = promptSecret || ((question) => hiddenQuestion(input, output, question));
220
- output.write(`${commandName} enable-image\n`);
220
+ output.write(`${commandName} app codex image setup\n`);
221
221
  output.write("Enter an HTTPS base URL (for example, https://api.example/v1) or a full /images/generations endpoint.\n");
222
222
  const endpointAnswer = String(await ask(`Image service URL${current ? ` [${current.endpoint}]` : ""}: `) || "").trim();
223
223
  if (!endpointAnswer && !current?.endpoint) throw new Error("Image API base URL or endpoint is required");
@@ -23,7 +23,7 @@ export async function runLimitsCommand({
23
23
  } = {}) {
24
24
  if (action === "set") {
25
25
  if (String(env.CCDX_MAX_DECODED_BODY_BYTES || "").trim()) {
26
- throw new Error("CCDX_MAX_DECODED_BODY_BYTES overrides saved limits; unset it before using ccdx limits --decoded");
26
+ throw new Error("CCDX_MAX_DECODED_BODY_BYTES overrides saved limits; unset it before using ccdx config limits --decoded");
27
27
  }
28
28
  writeDecodedBodyLimitMib(resetLimit ? null : limitMib, { env, home });
29
29
  } else if (action !== "status") {
@@ -40,7 +40,7 @@ export async function runLimitsCommand({
40
40
  const activeDecoded = Number(runtime?.data?.limits?.max_decoded_body_bytes);
41
41
  const activeRaw = Number(runtime?.data?.limits?.max_body_bytes);
42
42
  const lines = [
43
- "ccdx limits",
43
+ "ccdx config limits",
44
44
  `Configured decoded request body: ${mib(preference.bytes)} (${preference.source})`,
45
45
  runtime && Number.isFinite(activeDecoded) && activeDecoded > 0
46
46
  ? `Running decoded request body: ${mib(activeDecoded)}`
package/src/cli-m365.mjs CHANGED
@@ -122,7 +122,7 @@ export async function runM365Command({ action = "status", provider, model, autoR
122
122
  return result;
123
123
  }
124
124
  if (!accountId) {
125
- if (!prompt && (!input.isTTY || !output.isTTY)) throw new Error("Use ccdx m365 account --id ID from ccdx m365 accounts.");
125
+ if (!prompt && (!input.isTTY || !output.isTTY)) throw new Error("Use ccdx source m365 account --id ID from ccdx source m365 accounts.");
126
126
  output.write(accounts.map((value, index) => ` ${index + 1}. ${terminalCell(value.login)} / ${terminalCell(value.tenant)}${value.selected ? " [selected]" : value.current_windows ? " [Windows sign-in]" : ""}`).join("\n") + "\n");
127
127
  const answer = String(await ask("Choose an account, or q to cancel: ")).trim();
128
128
  if (answer === "q") return { cancelled: true };
@@ -33,7 +33,7 @@ export function formatManagement(value, { format, output = process.stdout, colum
33
33
  }
34
34
  const scalar = value => value === null || value === undefined ? "Not observed" : value === true ? "Yes" : value === false ? "No" : terminalCell(String(value));
35
35
  const lines = (item, indent = "") => Object.entries(item).flatMap(([key, value]) => {
36
- const label = key.replaceAll("_", " ").replace(/^./, char => char.toUpperCase());
36
+ const label = terminalCell(key.replaceAll("_", " ").replace(/^./, char => char.toUpperCase()));
37
37
  if (Array.isArray(value)) {
38
38
  if (!value.length) return [`${indent}${label}: None`];
39
39
  if (value.every(row => row === null || typeof row !== "object")) return [`${indent}${label}: ${value.map(scalar).join(", ")}`];
@@ -104,7 +104,7 @@ export async function runManagementCommand(command, options = {}) {
104
104
  if (flags.format === "json") return print(result);
105
105
  const sourceNames = view.sources?.map(source => source.name).join(" · ");
106
106
  return [`CCDX ${data.version}${options.version && options.version !== data.version ? ` · installed CLI ${options.version}` : ""}`,
107
- `Listening · ${baseUrl} · up ${terminalUptime(data.uptime_ms)}`, `Enabled sources: ${view.sources?.length ?? "unknown"}`,
107
+ `Running · up ${terminalUptime(data.uptime_ms)}`, `Web UI: ${baseUrl}`, `Enabled sources: ${view.sources?.length ?? "unknown"}`,
108
108
  ...(sourceNames ? [sourceNames] : []), "", print(view.clients, [["name", "Client"], ["setup", "Setup"], ["active", "Active"]]), "",
109
109
  `Model requests: ${view.requests ?? "unknown"} total · ${view.active ?? "unknown"} active · ${view.outcomes.failed} failed`].join("\n");
110
110
  }
@@ -123,7 +123,11 @@ export async function runManagementCommand(command, options = {}) {
123
123
  if (!usage) throw new Error("Current-run usage is unavailable.");
124
124
  return print(flags.provider ? usage.by_provider?.[flags.provider] || { records: 0 } : usage);
125
125
  }
126
- const { summarizeUsageLogs } = await import("./usage-store.mjs");return print(await summarizeUsageLogs(undefined, { ...(flags.provider ? { provider: flags.provider } : {}) }));
126
+ const { summarizeUsageLogs } = await import("./usage-store.mjs");
127
+ const summary = await summarizeUsageLogs(undefined, { ...(flags.provider ? { provider: flags.provider } : {}) });
128
+ if (flags.format === "json") return print(summary);
129
+ const { formatUsageSummary } = await import("./usage.mjs");
130
+ return formatUsageSummary(summary, { format: flags.format || "auto", output });
127
131
  }
128
132
  if (group === "update") {
129
133
  const { dashboardUpdateStatus } = await import("./dashboard-updates.mjs");return print(await dashboardUpdateStatus());