codex-copilot-dx 1.2.32 → 1.2.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,44 +11,42 @@ npm install -g codex-copilot-dx@latest
11
11
  ccdx
12
12
  ```
13
13
 
14
- No Node or Git? Download [install.sh](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.32/install.sh) (macOS/Linux) or [install.ps1](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.32/install.ps1) (Windows), then run `sh install.sh` or `./install.ps1` under your current shell policy. The bootstrap reuses compatible Node/npm or installs verified official Node 24.22.0 privately for CCDX. It adds no Git, compiler or system package manager. It keeps registry/proxy/certificate policy, verifies the Release package and installed runtime, and restores the prior CCDX package if installation fails. Manifest-listed complete packages install their bundled dependencies offline; older source-only releases need the configured registry. See [installation limits and private command paths](docs/REFERENCE.md#install-without-node-or-git).
14
+ No Node or Git? Download [install.sh](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.33/install.sh) (macOS/Linux) or [install.ps1](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.33/install.ps1) (Windows), then run `sh install.sh` or `./install.ps1` under your current shell policy. The bootstrap reuses compatible Node/npm or installs verified official Node 24.22.0 privately for CCDX. It adds no Git, compiler or system package manager. It keeps registry/proxy/certificate policy, verifies the Release package and installed runtime, and restores the prior CCDX package if installation fails. Manifest-listed complete packages install their bundled dependencies offline; older source-only releases need the configured registry. See [installation limits and private command paths](docs/REFERENCE.md#install-without-node-or-git).
15
15
 
16
16
  CCDX reuses a compatible local credential or starts GitHub Device Flow, listens on `127.0.0.1:2026`, configures Codex, and opens the App. Interactive desktop starts also open the local WebUI once; use `ccdx --no-browser` or disable this in WebUI settings. No client binary patch is needed. On Windows, open the App manually unless native prediction setup is enabled. In restricted Windows PowerShell, use `npm.cmd` to install and `ccdx.cmd` for the first launch, or run `ccdx.cmd doctor --fix`. Startup, updates and explicit repair remove only CCDX's exact npm-generated `.ps1` launchers so later calls can use `ccdx`. The npm package adds no install hook or policy change; custom launchers are preserved. npm's own script is untouched. The configured `dummy` API key is a placeholder, not a credential.
17
17
 
18
- The [local control console](http://127.0.0.1:2026/) separates Overview, Codex/Claude, Model sources, Usage, Requests, Checks & repairs and Settings, with a stable sticky header. Model sources owns API accounts, keys and model capabilities; application pages own visible models and defaults. Settings owns independent web/terminal colors (classic green, Klein blue or Soft pink), plus a WebUI-only Pure white palette with an inverted black night mode, startup and updates. Accounts and model catalogs stay with Model sources; client-specific tools stay with their application. CLI remains English; WebUI supports English/Chinese. Codex shows evidenced memory-model dependencies and warns before closing them; native memory settings remain yours. An interactive terminal shows bounded startup checks, source/client state, a usage table with approximate cache hit rate, notices and animation. Plain/NO_COLOR/narrow output remains supported; `--verbose` retains request detail.
18
+ The [local control console](http://127.0.0.1:2026/) separates Overview, Codex/Claude, Model sources, Usage, Requests, Checks & repairs and Settings, with a stable sticky header. Model sources owns API accounts, keys and model capabilities; application pages own visible models and defaults. Settings owns independent web/terminal colors (classic green, Klein blue or Soft pink), plus a WebUI-only Pure white palette with an inverted black night mode, startup and updates. Accounts and model catalogs stay with Model sources; client-specific tools stay with their application. CLI remains English; WebUI supports English/Chinese. Codex shows evidenced memory-model dependencies and warns before closing them; native memory settings remain yours. An interactive terminal replaces ordinary startup checks with one live view: the listener, enabled sources, client setup/activity, usage and scoped notices. Source names start left-aligned below `Enabled sources: N`. Saved credentials do not imply access; configured clients do not imply running Apps. Motion uses observed inference and actual image generation, not MCP discovery traffic. Plain/NO_COLOR/narrow output remains supported; `--verbose` retains request detail.
19
19
 
20
20
  The WebUI keeps English monospace text with explicit Chinese sans-serif system-font fallbacks, including Microsoft YaHei on Windows. Requests aligns applications to a shared right edge and models to a shared left edge. It shows live app/source/model flow above existing summaries and finished records; a thin theme-colored ring rotates around its atom while requests are active. Usage offers animated bars or curves; reduced motion stays static. Hidden pages stop scheduled reads; status refreshes about every two seconds and source/settings evidence about every 16 seconds. Catalogs and retained usage load on demand or every 30 minutes while open. Disclosures use down/up chevrons with brief rotation and content transitions; reduced-motion mode remains immediate. Saved model selection and configuration-write results are shown separately; writing does not prove that the App has loaded the change. The UI does not add inference calls. Ready means local service availability, not verified model access. First output uses ms, speed token/s, and partial/unknown usage remains explicit. Images/predictions stay opt-in; their first setup uses CLI. 1.2.18 preserves Codex sign-in and unavailable model selections after saving bindings. See the [control reference](docs/REFERENCE.md#control-console-and-online-settings), [1.2.18 fixes and verification](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/RELEASE_1.2.18.md) and [copy inventory](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/UX_COPY.md).
21
21
 
22
22
  ## Commands
23
+
23
24
  | Command | Purpose |
24
25
  | --- | --- |
25
- | `ccdx help` | Command help; use `ccdx help <command>` for details |
26
- | `ccdx start` | Start/reuse the adapter, open Codex when enabled, and open WebUI on interactive desktop starts |
27
- | `ccdx --no-browser` / `ccdx --verbose` | Skip WebUI opening once / retain detailed terminal logs |
28
- | `ccdx status` | Runtime, limits and bounded request diagnostics |
29
- | `ccdx doctor` | Configuration, adapter and read-only App/catalog diagnostics |
30
- | `ccdx doctor --fix` | Repair owned launchers/config, recover existing auth and enabled prediction routing once |
31
- | `ccdx doctor --json` | Redacted structured diagnostics; combines with `--fix` |
32
- | `ccdx doctor config` | Read-only configuration check |
33
- | `ccdx doctor --compat` | Online inference/continuation compatibility probes |
34
- | `ccdx auth status` / `login` / `reauth` / `check` / `logout` | Inspect, verify or safely replace CCDX sign-in; other apps stay signed in |
35
- | `ccdx models` | Current source models; manual APIs show configured models without an online probe |
36
- | `ccdx usage` | Recorded tokens and upstream prompt-cache hit rate |
37
- | `ccdx usage --provider ID` | Filter current or historical source-specific usage |
38
- | `ccdx m365 status` / `models` | M365 authorization, Claude gateway and Claude models |
39
- | `ccdx m365 accounts` / `account` | List local company accounts or select one; `account --id ID` supports scripts |
40
- | `ccdx m365 switch` | Choose the Codex source; default remains GitHub |
41
- | `ccdx m365 on` / `off` / `remove` | Enable discovery, restore owned client settings, or remove owned M365 state |
42
- | `ccdx auto-review-model` | Select model, then reasoning effort; `0` follows client |
43
- | `ccdx animation` | Preview and select terminal animation |
44
- | `ccdx prediction fix` | Recheck system routing and repair enabled predictions; report required restarts |
45
- | `ccdx cache --limit 128` | Set the history-cache budget in MiB |
46
- | `ccdx cache --clean` | Clear the rebuildable image-transform cache |
47
- | `ccdx limits --decoded 256` | Set the decoded request-body budget; restart to apply |
48
- | `ccdx enable-image` | Opt in to image generation/editing with your own API |
49
- | `ccdx image-status` / `ccdx disable-image` | Check or disable optional images |
50
- | `ccdx prediction on` / `off` / `status` | Opt in to native predictions (macOS and Windows) |
51
- | `ccdx update` | Update the global package |
26
+ | `ccdx` / `ccdx start` | Start/reuse the foreground gateway; keep existing client setup/launch behavior |
27
+ | `ccdx status` / `status --details` | Brief interactive state / complete diagnostic view |
28
+ | `ccdx web` | Open local management tools |
29
+ | `ccdx source list` | List registered sources |
30
+ | `ccdx source github status` / `check` / `reauth` | Saved GitHub evidence / online access check / safe sign-in replacement |
31
+ | `ccdx source m365 models --refresh` | Explicitly read the online company catalog; no inference |
32
+ | `ccdx source add` | Save an API, read models and choose their declared interfaces |
33
+ | `ccdx app list` | List client configuration and observed request activity |
34
+ | `ccdx app claude-app models --edit` | Choose client models separately from source authorization |
35
+ | `ccdx app claude-app sync --preview` | Review the model/configuration plan without writing |
36
+ | `ccdx app codex prediction status` | Inspect the optional Codex-only prediction integration |
37
+ | `ccdx app codex image setup` | Configure optional Codex images with a private key prompt |
38
+ | `ccdx requests --failed --app claude-app` | Inspect retained failures; no full-history promise |
39
+ | `ccdx usage` / `usage --scope run` | Legacy all-recorded usage / current service run |
40
+ | `ccdx config show --effective` | Separate saved service preferences from effective state |
41
+ | `ccdx config reset --preview` | Review default service/terminal preferences; browser appearance stays separate |
42
+ | `ccdx doctor` / `doctor --fix` | Local checks / existing bounded owned repairs |
43
+ | `ccdx update check` / `update github` | Check without installation / install a verified GitHub release |
44
+
45
+ Use `ccdx help app codex prediction` or nearby `--help` for complete options.
46
+ New read-only commands support `--format table|plain|json`. New connection writes require the compatible updated service and use the protected loopback API. Finish active work before restarting an older service. `--verbose` and `--show-request-id` keep detailed startup/request output.
47
+
48
+ Existing `ccdx auth`, `ccdx reauth`, `ccdx models`, `ccdx source github|m365`, `ccdx m365 switch`, `ccdx prediction`, `ccdx image`, `ccdx enable-image`, `ccdx disable-image`, `ccdx image-status`, `ccdx auto-review-model`, `ccdx animation`, `ccdx cache`, `ccdx limits` and flag aliases remain supported. Legacy `source` switching stays Codex-only; legacy `models` stays a catalog. Non-TTY legacy status output is retained.
49
+ See [command groups and compatibility](docs/REFERENCE.md#command-groups-1233).
52
50
 
53
51
  ## Add your own API
54
52
 
package/bin/cli.mjs CHANGED
@@ -22,7 +22,7 @@ import { createProfileModelRuntime } from "../src/profile-model-runtime.mjs";
22
22
  import { createCodexModelCatalog } from "../src/codex-model-catalog.mjs";
23
23
  import { createProviderRuntime } from "../src/provider-runtime.mjs";
24
24
  import { setResponseHistoryMaxBytes } from "../src/response-history.mjs";
25
- import { startupBanner, startupCheck, startupReady, startupLogger, predictionStartupCheck, providerStartupChecks } from "../src/startup-ui.mjs";
25
+ import { startupBanner, startupCheck, startupReady, startupLogger, predictionStartupCheck, providerStartupChecks, createStartupPresentation } from "../src/startup-ui.mjs";
26
26
  import { createTerminalConsole } from "../src/terminal-console.mjs";
27
27
  import { createServiceControl } from "../src/service-control.mjs";
28
28
  import { openDashboard } from "../src/browser-launch.mjs";
@@ -48,6 +48,19 @@ if (CLI.command === "version") {
48
48
  console.log(CLI_BANNER);
49
49
  process.exit(0);
50
50
  }
51
+ if (CLI.command === "manage") {
52
+ try {
53
+ const { runManagementCommand } = await import("../src/cli-management.mjs");
54
+ const address = parseAdapterAddressOptions(process.env);
55
+ const result = await runManagementCommand(CLI, { host: address.adapterHost, port: address.adapterPort, version: LOCAL_VERSION });
56
+ if (result) console.log(result);
57
+ process.exit(0);
58
+ } catch (error) {
59
+ if (CLI.flags?.format === "json") console.log(JSON.stringify({ error: { code: error.code || "ccdx_command_failed", message: error.message } }));
60
+ else console.error(status("err", `${error.code ? `${error.code}: ` : ""}${error.message}`));
61
+ process.exit(1);
62
+ }
63
+ }
51
64
  if (CLI.command === "web") {
52
65
  try {
53
66
  const { runWebCommand } = await import("../src/cli-web.mjs");
@@ -235,7 +248,10 @@ if (CLI.command === "status") {
235
248
  port: probe.adapterPort,
236
249
  timeoutMs: probe.existingAdapterTimeoutMs,
237
250
  });
238
- console.log(formatAdapterStatus(snapshot, { commandName: CLI_NAME, cliVersion: LOCAL_VERSION }));
251
+ if (process.stdout.isTTY) {
252
+ const { runManagementCommand } = await import("../src/cli-management.mjs");
253
+ console.log(await runManagementCommand({ group: "status", path: ["status"], flags: {} }, { version: LOCAL_VERSION, readStatus: async () => snapshot }));
254
+ } else console.log(formatAdapterStatus(snapshot, { commandName: CLI_NAME, cliVersion: LOCAL_VERSION }));
239
255
  process.exit(0);
240
256
  } catch (e) {
241
257
  console.error(status("err", e.message));
@@ -440,6 +456,8 @@ if (CLI.command === "doctor") {
440
456
  }
441
457
 
442
458
  console.log(`\n${startupBanner({ commandName: CLI_NAME, version: LOCAL_VERSION })}\n`);
459
+ const startupPresentation = createStartupPresentation({ verbose: CLI.verbose === true || CLI.showRequestId === true || LOGGING.level === "debug" || serviceWorker?.warming });
460
+ if (startupPresentation.enabled) LOGGING.setTerminalSink((method, args) => startupPresentation.log(method, args));
443
461
 
444
462
  async function printUpdateNotice() {
445
463
  try {
@@ -466,7 +484,7 @@ try {
466
484
  // Ready is already displayed; finish the bounded check before this short-lived CLI exits.
467
485
  await updateNotice;
468
486
  serviceWorker?.reused();
469
- await LOGGING.cleanup();
487
+ startupPresentation.finish();await LOGGING.cleanup();
470
488
  process.exit(0);
471
489
  }
472
490
 
@@ -579,9 +597,13 @@ try {
579
597
  }
580
598
 
581
599
  startupComplete = true;
582
- console.log(startupReady({ baseUrl: adapterBaseUrl(ADAPTER_HOST, ADAPTER_PORT), commandName: CLI_NAME }));
600
+ if (!startupPresentation.enabled) console.log(startupReady({ baseUrl: adapterBaseUrl(ADAPTER_HOST, ADAPTER_PORT), commandName: CLI_NAME }));
583
601
  await launchDashboard();
584
- if (!serviceWorker?.warming) { terminalConsole.start();LOGGING.setTerminalSink((method, args) => terminalConsole.log(method, args)); }
602
+ if (!serviceWorker?.warming) {
603
+ startupPresentation.finish();for (const [method, args] of startupPresentation.warnings) terminalConsole.log(method, args);
604
+ terminalConsole.start();if (!terminalConsole.enabled && startupPresentation.enabled) process.stdout.write(startupReady({ baseUrl: adapterBaseUrl(ADAPTER_HOST, ADAPTER_PORT), commandName: CLI_NAME }));
605
+ LOGGING.setTerminalSink((method, args) => terminalConsole.log(method, args));
606
+ }
585
607
 
586
608
  const shutdown = async (signal) => {
587
609
  if (shuttingDown) return;
@@ -646,7 +668,7 @@ try {
646
668
  });
647
669
  }
648
670
  } catch (e) {
649
- LOGGING.setTerminalSink(null);terminalConsole?.cleanup();
671
+ startupPresentation.finish();LOGGING.setTerminalSink(null);terminalConsole?.cleanup();
650
672
  console.error(status("err", e.message));
651
673
  await clientIntegration?.close().catch(() => {});
652
674
  await providerRuntime?.close().catch(() => {});
@@ -940,3 +940,35 @@ service settings. Chinese font fallback is shared through the page's font-stack
940
940
  CSS variable, without remote font I/O. Flow layout aligns application node right
941
941
  edges and model node left edges; existing ResizeObserver/geometry caching and
942
942
  visibility-gated dash animation retain their ownership.
943
+
944
+
945
+ ### CLI state and management (1.2.33)
946
+
947
+ `terminal-state.mjs` projects existing request/source/client evidence for the live
948
+ terminal and canonical CLI views. It does not own model selection, credentials,
949
+ provider health, files or requests. TUI snapshots stay on the one-second cadence;
950
+ animation updates only its final row. `model_activity` provides actual inference
951
+ and generation activity; tool discovery is not work. The core Codex startup writer
952
+ returns observed configured/preserved metadata, which the integration snapshot
953
+ exposes only as last-checked setup evidence. Managed binding setup keeps priority.
954
+
955
+ `cli-command-spec.mjs` defines canonical paths, validated options, nearby/deep help
956
+ and explicit legacy translations. `cli-management.mjs` formats bounded public
957
+ snapshots and orchestrates existing loopback actions with normal prompt/private-key
958
+ input. The CLI entry exits before service startup for these commands. Existing
959
+ legacy parsing/handlers retain their effects and non-TTY/machine paths.
960
+
961
+ The full connection snapshot exposes a management capability and per-client
962
+ binding revision. CLI connection mutations require this capability; older running
963
+ services are not silently upgraded or mutated. Source authorization uses the same
964
+ source-impact revision as closing previews. A client access-only action retains
965
+ legacy source and deployment representation; it does not migrate a GitHub-only
966
+ binding or change Codex auth mode. Explicit one-shot client sync reuses serialized,
967
+ targeted ownership writers while retaining `auto_sync=false`. Shared Claude settings
968
+ retain existing peer/manual-support protections. Disabled, unbound APIs can be
969
+ removed; in-flight credential retirement uses the existing secret lifecycle.
970
+
971
+ CLI service-preference backups use the existing bounded validator, file lock and
972
+ atomic backup/config pair with a separate backup filename. WebUI's appearance-paired
973
+ backup and version-one format are unchanged. No new history store, daemon, client
974
+ restart controller, transport policy or production dependency is introduced.
package/docs/REFERENCE.md CHANGED
@@ -1010,22 +1010,29 @@ The upgrade intentionally does not delete or rewrite retired Claude or PM Studio
1010
1010
 
1011
1011
  ## Commands
1012
1012
 
1013
- Run `ccdx <command> --help` for command-specific behavior and side-effect details.
1014
- Startup uses aligned status/project/result columns and a left-aligned Ready footer
1015
- with the Web UI URL and `ccdx help`. Ctrl+C is shown only for the foreground-owned
1016
- service, never a short-lived command reusing another service. A static, favicon-style
1017
- atom uses the saved terminal color (green by default) and half-block characters only on interactive color terminals
1018
- at least 72 columns wide; narrow terminals, `NO_COLOR`, `TERM=dumb` and redirected
1019
- output keep a plain title. No new graphics/font/runtime dependency is installed.
1020
- Credentials found are not labeled online-authorized, cached model lists are not
1021
- labeled fresh upstream data, and image configuration is not a provider test.
1022
- Ready reports core readiness independently of optional prediction/image warnings.
1023
- Model refresh logs show counts; `ccdx models` retains the complete live list.
1024
- After Ready, the default foreground display becomes a fixed status region;
1025
- request and background-refresh detail is available with `--verbose` or explicit file logging. Status messages remove terminal controls and collapse newlines;
1026
- the static banner and multiline interactive prompts retain their own presentation.
1027
- VS Code compatibility-version details remain available in debug logging. Startup
1028
- does not wait for optional update/compression work or add online doctor/model probes.
1013
+ Run `ccdx <command> --help` or `ccdx help <path>` for command behavior and
1014
+ side effects. On supported interactive terminals ordinary startup checks use one
1015
+ transient row. Device authorization instructions and warnings remain visible.
1016
+ The foreground live region then owns one listener/uptime line, enabled sources,
1017
+ peer client setup/activity, returned usage, notices and a separate animation line.
1018
+ Source names start in column one immediately below `Enabled sources: N`.
1019
+ Small terminals compact summaries without changing metric meaning. The atom,
1020
+ colors, plain/NO_COLOR/dumb output and verbose paths remain.
1021
+
1022
+ Enabled sources are not inferred online-authorized. Configured client settings
1023
+ are not App process liveness or proof that all visible models were adopted.
1024
+ Codex legacy startup writes expose only their observed configured/preserved state;
1025
+ managed model-plan state keeps priority. No new App probe is started by rendering.
1026
+ The live region uses existing model activity, including actual image generation,
1027
+ not image MCP tool-listing traffic. The model-request table retains its three
1028
+ text-inference routes; HTTP/capability counters stay in detailed diagnostics.
1029
+ Unknown outcomes appear when nonzero. Failed reads keep timestamped prior usage
1030
+ and mark current activity unknown rather than clearing counters or showing Idle.
1031
+
1032
+ Supported TTY output replaces redundant Ready/Web/Claude summaries. Non-TTY,
1033
+ verbose and short-lived existing-service paths retain their compatible startup
1034
+ output. `Ctrl+C` stops only the foreground-owned service. Logs remain available
1035
+ through explicit file logging or verbose mode, without growing the live region.
1029
1036
 
1030
1037
  ### Live models
1031
1038
 
@@ -1350,7 +1357,7 @@ Unknown support prevents an explicitly requested exception from starting.
1350
1357
  For an older updater that still requires Git, install the Release tarball directly:
1351
1358
 
1352
1359
  ```sh
1353
- npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.32/codex-copilot-dx-1.2.32.tgz
1360
+ npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.33/codex-copilot-dx-1.2.33.tgz
1354
1361
  # Windows PowerShell: use npm.cmd instead of npm.
1355
1362
  ```
1356
1363
 
@@ -2384,3 +2391,105 @@ Pure white uses the existing independent light/dark toggle, browser persistence,
2384
2391
  cross-tab updates, automatic/manual saving, and pre-reset backup/restore. It does
2385
2392
  not change the default green palette or the terminal palette and does not change
2386
2393
  Codex/Claude routing, credentials or model selections.
2394
+
2395
+
2396
+ ### Command groups (1.2.33)
2397
+
2398
+ Canonical groups separate source identity/catalogs, client model plans and service
2399
+ preferences. The compact route definition drives parsing, nearby/deep help and
2400
+ explicit legacy mappings. Existing legacy handlers continue to own their original
2401
+ arguments, output and effects. New CLI handlers use the loopback management API;
2402
+ read-only commands do not start a service or launch an App.
2403
+
2404
+ ```text
2405
+ ccdx source list
2406
+ ccdx source add [--file FILE] [--key-stdin] [--preview] [--yes]
2407
+ ccdx source ID status [--format table|plain|json]
2408
+ ccdx source ID models [--refresh] [--format table|plain|json]
2409
+ ccdx source ID check [--format table|plain|json]
2410
+ ccdx source ID edit [--file FILE] [--key-stdin] [--preview] [--yes]
2411
+ ccdx source ID access [--edit] [--apps codex,claude-app,claude-code|none]
2412
+ ccdx source ID enable|disable|remove [--preview] [--yes]
2413
+ ccdx source github login|reauth [--login ACCOUNT]
2414
+ ccdx source github logout [--yes]
2415
+ ccdx source m365 accounts
2416
+ ccdx source m365 account [--id ID]
2417
+
2418
+ ccdx app list
2419
+ ccdx app ID status [--details] [--format table|plain|json]
2420
+ ccdx app ID models [--edit] [--file FILE] [--preview] [--yes]
2421
+ ccdx app ID sync [--preview] [--yes]
2422
+ ccdx app ID enable|disable [--preview] [--yes]
2423
+ ccdx app codex prediction status|setup|remove|pause|resume|repair
2424
+ ccdx app codex image status|setup|remove|pause|resume
2425
+ ccdx app codex review status|select
2426
+
2427
+ ccdx requests [--active|--failed] [--app ID] [--source ID] [--limit 1..100]
2428
+ ccdx requests show REQUEST_ID
2429
+ ccdx status [--details] [--format table|plain|json]
2430
+ ccdx usage --scope run|all [--provider ID] [--format table|plain|json]
2431
+ ccdx config show [--effective] [--format table|plain|json]
2432
+ ccdx config set KEY VALUE [--preview] [--yes]
2433
+ ccdx config terminal
2434
+ ccdx config animation
2435
+ ccdx config limits [--decoded MiB|default]
2436
+ ccdx config reset|restore [--preview] [--yes]
2437
+ ccdx doctor cache [existing cache options]
2438
+ ccdx update check [--format table|plain|json]
2439
+ ```
2440
+
2441
+ Client IDs are `codex`, `claude-app`, `claude-code`; backend binding IDs are unchanged.
2442
+ Only APIs support generic edit/remove. Removal requires a disabled source with no
2443
+ retained client binding, including disabled clients. Built-in M365 profile cleanup
2444
+ remains the explicit legacy `m365 remove`, with its existing effects. Source
2445
+ `check`/model `--refresh` contact a source only when requested and never send inference.
2446
+ Cached built-in catalogs are read directly from the source, without filtering
2447
+ through client selection. API default catalogs describe saved model configuration;
2448
+ explicit refresh returns discovery results. Neither proves inference access.
2449
+ Source grants do not choose visible client models. Disable uses the existing
2450
+ source-impact revision and replacement/pause review; scripts must give explicit
2451
+ `--replacements` JSON for affected clients. It never silently chooses another source.
2452
+
2453
+ Client models describe the saved selected plan, not the upstream directory.
2454
+ Unavailable selections remain explicit and are not silently dropped; a changed
2455
+ plan containing unavailable selections is refused until the catalog returns or
2456
+ the user explicitly removes them. Removing an observed Codex memory dependency
2457
+ shows its existing warning before confirmation; no model name is guessed. New access toggles retain legacy source/model
2458
+ bindings and do not materialize deployments. `sync --preview` reports the model
2459
+ and managed-configuration plan, not a byte-level file diff. Explicit sync can write
2460
+ once while `auto_sync` is false; the preference stays false. Writers retain current
2461
+ ownership checks and do not restart client programs or imply App adoption.
2462
+
2463
+ Source and client writes carry the current revision. Old running services without
2464
+ the new management capability are refused before new connection mutations. This
2465
+ is not an automatic restart or a package/process hot handoff. New JSON output
2466
+ contains no ANSI or startup chatter; failures exit nonzero. Existing 0/1/2 exit
2467
+ conventions and legacy non-TTY/machine paths remain.
2468
+
2469
+ For scripts, API files contain only `config` and `allowed` (backend client IDs).
2470
+ Configuration includes name/base_url/endpoints/auth_header/models and optionally
2471
+ key_env. A key uses a bounded private stdin stream with `--key-stdin` or an existing
2472
+ environment reference; it is not a command argument or echoed in output. App model
2473
+ files require an explicit deployments array (empty pauses access) and allow
2474
+ default_model/auto_sync. Both forms use the same
2475
+ backend validation and authorization as WebUI. Interactive creation retains a saved
2476
+ source after discovery failure, reports partial failure, and allows explicit retry;
2477
+ model interfaces missing upstream must be chosen explicitly.
2478
+
2479
+ `config` only manages the settings-preference allowlist. It does not reset browser
2480
+ local storage, accounts, API credentials, model plans, chats or image/prediction
2481
+ access. CLI reset/restore reuse the existing atomic backup writer with a separate
2482
+ `service-settings-preferences-backup.json` in the same CCDX config directory.
2483
+ The original WebUI backup file and version-one format are retained. The CLI uses
2484
+ `config restore`; WebUI keeps its own appearance-paired backup. Invalid or stale
2485
+ files are not overwritten. Overnight-update risk needs explicit confirmation;
2486
+ `--yes` is an explicit script choice. Saved/effective state and normal restart
2487
+ requirements remain distinct. No new background service, stop or restart command
2488
+ is introduced.
2489
+
2490
+ Requests use existing bounded active/recent performance and structured error
2491
+ snapshots. They retain original request IDs, source, route, codes and attempts;
2492
+ missing records return Not retained. Notices are not treated as failed request
2493
+ counts, and no new transcript/history database is added. Only observed application
2494
+ identity is used. Codex App/CLI observations share the Codex binding; unidentified
2495
+ clients stay separate.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-copilot-dx",
3
- "version": "1.2.32",
3
+ "version": "1.2.33",
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",
@@ -0,0 +1,123 @@
1
+ import { isProviderId } from "./provider-metadata.mjs";
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.
8
+ export const MANAGED_COMMANDS = [
9
+ 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 }),
11
+ 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" }),
13
+ 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 }),
16
+ 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" }),
18
+ 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] : [])])),
21
+ command("app list", "List client configuration and observed activity", read),
22
+ 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 }),
24
+ command("app <app> sync", "Preview or write CCDX-owned client configuration", confirm),
25
+ command("app <app> enable", "Enable client access with its saved selection", confirm),
26
+ 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])),
31
+ 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"]),
33
+ command("config show", "Show service and terminal preferences", { ...read, "--effective": "flag" }),
34
+ command("config set <key> <value>", "Save a validated service preference", confirm),
35
+ 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] : [])]),
38
+ command("config reset", "Back up and restore service preferences to defaults", confirm),
39
+ 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" }),
42
+ command("requests show <request>", "Show a retained request and its original diagnostic fields", read),
43
+ 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" }),
45
+ command("update check", "Check a stable release without installing", read),
46
+ ];
47
+
48
+ function pathMatch(pattern, values, partial = false) {
49
+ if ((!partial && pattern.length !== values.length) || partial && pattern.length < values.length) return null;
50
+ const found = {};
51
+ for (let index = 0; index < values.length; index++) {
52
+ const token = pattern[index], value = values[index];
53
+ if (token.startsWith("<")) {
54
+ const key = token.slice(1, -1);
55
+ if (key === "source" && !isProviderId(value) || key === "app" && !Object.hasOwn(CLI_CLIENTS, value)) return null;
56
+ found[key] = value;
57
+ } else if (token !== value) return null;
58
+ }
59
+ return found;
60
+ }
61
+ function optionsFor(args, definition) {
62
+ const values = {};
63
+ for (let index = 0; index < args.length; index++) {
64
+ const option = args[index], type = definition.options[option], key = option.replace(/^--/, "").replaceAll("-", "_");
65
+ if (!type || Object.hasOwn(values, key)) throw new Error(`Unexpected or repeated option: ${option}`);
66
+ if (type === "flag") { values[key] = true;continue; }
67
+ const value = args[++index];
68
+ 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");
70
+ 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");
72
+ values[key] = type === "integer" ? Number(value) : value;
73
+ }
74
+ if (values.app && !Object.hasOwn(CLI_CLIENTS, values.app)) throw new Error("Choose codex, claude-app or claude-code");
75
+ if (values.provider && !isProviderId(values.provider)) throw new Error("Enter a valid usage source ID");
76
+ if (values.source && !isProviderId(values.source)) throw new Error("Enter a listed source ID");
77
+ if (values.active && values.failed) throw new Error("Choose --active or --failed");
78
+ if (values.apps !== undefined && !values.edit) throw new Error("--apps requires --edit");
79
+ 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");
81
+ return values;
82
+ }
83
+ export function parseManagedCommand(args) {
84
+ 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);
93
+ 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];
95
+ 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) };
98
+ return { command: "manage", group: root, path: words, ids, flags: values };
99
+ }
100
+
101
+ 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.",
103
+ 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.",
110
+ };
111
+ 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))));
117
+ 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]];
120
+ }
121
+ 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.`;
123
+ }
package/src/cli-image.mjs CHANGED
@@ -23,7 +23,7 @@ async function visibleQuestion(input, output, question) {
23
23
  finally { prompt.close(); }
24
24
  }
25
25
 
26
- export function hiddenQuestion(input, output, question) {
26
+ export function hiddenQuestion(input, output, question, { cancelMessage = "Image provider setup cancelled" } = {}) {
27
27
  if (!input?.isTTY || !output?.isTTY || typeof input.setRawMode !== "function") {
28
28
  return Promise.reject(new Error("Hidden API key input requires an interactive terminal"));
29
29
  }
@@ -43,7 +43,7 @@ export function hiddenQuestion(input, output, question) {
43
43
  const onKeypress = (text, key = {}) => {
44
44
  if (key.ctrl && key.name === "c") {
45
45
  cleanup();
46
- reject(new Error("Image provider setup cancelled"));
46
+ reject(new Error(cancelMessage));
47
47
  return;
48
48
  }
49
49
  if (key.name === "return" || key.name === "enter") {