codex-copilot-dx 1.2.32 → 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 (48) hide show
  1. package/README.md +65 -113
  2. package/bin/cli.mjs +61 -103
  3. package/docs/ARCHITECTURE.md +51 -3
  4. package/docs/README.md +9 -76
  5. package/docs/REFERENCE.md +137 -1827
  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 +325 -0
  15. package/src/cli-image.mjs +4 -4
  16. package/src/cli-limits.mjs +2 -2
  17. package/src/cli-m365.mjs +1 -1
  18. package/src/cli-management.mjs +344 -0
  19. package/src/cli-options.mjs +73 -443
  20. package/src/cli-status.mjs +7 -7
  21. package/src/cli-tools.mjs +3 -2
  22. package/src/client-integration.mjs +7 -3
  23. package/src/config.mjs +4 -3
  24. package/src/connection-runtime.mjs +1414 -350
  25. package/src/copilot-token-session.mjs +1 -1
  26. package/src/dashboard/connections.js +23 -4
  27. package/src/dashboard/ui.css +9 -2
  28. package/src/dashboard-api.mjs +5 -5
  29. package/src/doctor.mjs +4 -4
  30. package/src/image-mcp.mjs +2 -2
  31. package/src/native-prediction-fix.mjs +1 -1
  32. package/src/native-prediction-profile.mjs +1 -1
  33. package/src/native-prediction-windows.mjs +1 -1
  34. package/src/native-prediction.mjs +6 -6
  35. package/src/nightly-update.mjs +2 -2
  36. package/src/provider-runtime.mjs +1 -1
  37. package/src/providers/m365-accounts.mjs +1 -1
  38. package/src/release-install.mjs +11 -15
  39. package/src/service-control.mjs +1 -1
  40. package/src/settings-preferences.mjs +6 -4
  41. package/src/startup-ui.mjs +34 -2
  42. package/src/terminal-console.mjs +32 -30
  43. package/src/terminal-state.mjs +69 -0
  44. package/src/usage.mjs +5 -5
  45. package/src/windows-command.mjs +2 -2
  46. package/bin/codex-copilot-dx.mjs +0 -11
  47. package/src/cli-models.mjs +0 -94
  48. package/src/legacy-command-warning.mjs +0 -38
package/README.md CHANGED
@@ -1,130 +1,82 @@
1
- # codex-copilot-dx
1
+ # CCDX
2
2
 
3
- CCDX connects Codex App to GitHub Copilot by default: discovery, adapted model catalogs, Responses streaming, tool calls and conversation history. Eligible Microsoft 365 environments can also use a protocol-isolated Claude gateway on the main listener and manually select M365 as a Codex backup. Default Auto-review: **GPT-6.1 Sol / low**. Image generation is **off by default**. Native predictions and nightly software updates are also **off by default**.
3
+ Use your model services in **Codex App, Claude App and Claude Code** through one local gateway.
4
4
 
5
- ## Install and run
5
+ Connect GitHub Copilot, Microsoft 365 or your own API. Choose which apps can use each source, then select their models. CCDX supports **macOS and Windows**, on Apple Silicon/ARM64 and x64.
6
6
 
7
- For Codex App, use macOS or Windows and a GitHub account with access to the desired Copilot models. With Node.js **22.15+** and npm already available:
7
+ ## Install and start
8
8
 
9
- ```bash
9
+ With Node.js **22.15+** and npm:
10
+
11
+ ```sh
10
12
  npm install -g codex-copilot-dx@latest
11
13
  ccdx
12
14
  ```
13
15
 
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).
16
+ Without Node.js, download and run the installer for your system:
17
+
18
+ - macOS: [install.sh](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.3.0/install.sh), then `sh install.sh`.
19
+ - Windows: [install.ps1](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.3.0/install.ps1), then `./install.ps1` under your current shell policy.
20
+
21
+ The installer reuses a compatible Node.js or installs a private, verified copy. Git and a compiler are not required. Complete platform packages include their dependencies. Company registry, proxy, certificate and shell policies are kept.
22
+
23
+ On Windows, use `npm.cmd` or `ccdx.cmd` if PowerShell blocks npm-generated scripts. See [installation and updates](docs/REFERENCE.md#installation-and-updates).
24
+
25
+ ## Choose sources and models
15
26
 
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.
27
+ The Web UI opens at [http://127.0.0.1:2026](http://127.0.0.1:2026/). Run `ccdx web` to open it again, including before signing in.
17
28
 
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.
29
+ 1. **Model sources:** connect an account or API, read its models and choose allowed apps.
30
+ 2. **Codex / Claude:** choose visible models, set a default and save. Preview and synchronize client settings when needed.
31
+ 3. **Overview / Requests:** check configuration, activity and errors.
19
32
 
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).
33
+ For a custom API, enter its HTTPS address and key, then choose **Save & read models**. Select the models and interfaces it provides. Codex uses Responses; Claude uses Messages. Both share port 2026.
34
+
35
+ Model availability depends on your account and service. Microsoft 365 also requires a supported company environment. Existing account, model and client settings are retained during upgrades. No repeat setup or model selection is needed for an unchanged working configuration.
21
36
 
22
37
  ## Commands
23
- | Command | Purpose |
38
+
39
+ | Task | Command |
24
40
  | --- | --- |
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 |
52
-
53
- ## Add your own API
54
-
55
- Run `ccdx web` without GitHub sign-in. In **Model sources → Add API**, enter the HTTPS address/key, read the catalog, select models and declare their real interfaces. Then open **Codex** or **Claude**, choose visible models across sources, set a default and save. Claude App/Code use Messages; Codex uses Responses, all on port 2026. GitHub-only Codex selections retain native OpenAI mode and readable model names. Token counting is separate from message generation. For manual APIs, an observed count-endpoint 404 is remembered for one minute per model/API-header scope; CCDX returns a clear 404 without inventing a token count. Unknown count capabilities share their first admitted request; a 404 prevents distinct waiting inputs from fanning out. A supported endpoint still counts each distinct input separately. Identical small count requests share bounded work. A request stays on its selected deployment; there is no automatic cross-source retry or model replacement. Reopen clients after configuration changes. Claude App can continue an existing conversation on a different selected, authorized source when complete Messages history is available; unfinished tool turns, unavailable attachments and company-account isolation still apply. Codex and Claude Code retain their existing history rules. Stop management before normal `ccdx` startup for the live terminal.
56
-
57
- Keys use system credential protection or an explicit environment reference; clients receive separate local credentials. Saving reads model metadata automatically, without inference. Startup and the existing model refresh cycle also refresh enabled APIs when the 30-minute cache expires; failed reads retain saved configuration. Selecting no models pauses access; enable a source and select models to resume. Closed sources can be restored on Model sources; closed apps remain reachable for restoration on their app pages. Pinned streams finish on their original source. The version-two graph preserves old single-source visibility and saves a byte-for-byte v1 backup before migration. User and managed client settings remain protected. Refreshing GitHub models also updates Codex candidates without changing saved selections or native sign-in.
58
-
59
- Model lists/details preserve the upstream maker declaration separately from your API source name. Missing maker metadata shows Not provided; model names are never used to guess a maker. Maker and display-name evidence use a rebuildable cache and do not change the strict connection schema or routing identity. Names follow upstream display name, upstream name, then model ID. Claude compatibility aliases remain internal; mixed sources retain their original visible names regardless of the default source. Closing a source previews all selected consumers, including nondefault models. First-time API setup uses **Save & read models** and keeps the model editor open, including after a failed lookup. Model details show upstream capabilities per API, with optional manual overrides collapsed below. Context, input/output limits, reasoning levels, thinking modes, input types, tools and native search are deployment-specific. Structured Anthropic declarations are mapped to Messages; they do not grant the same capabilities to a gateway's other interfaces. Missing and unrecognized metadata are distinguished, without guessing from model names. Manual overrides, including false, take priority. Claude synchronization projects compatible routes, supported host controls and per-model budgets. Unknown or out-of-range windows and unverified client versions are reported as limited; they are not promoted to 1M. Output requests are bounded by declared limits. Compatibility routes do not prove that every model supports every App tool, search or reasoning mode. See the [capability and synchronization limits](docs/REFERENCE.md#model-capabilities-and-claude-synchronization). [1.2.31 changes and verification](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/RELEASE_1.2.31.md) cover model display, source impact, error evidence and scoped WebUI improvements. Shared GitHub catalogs and the policy-preserving complete-package update fallback remain included. Existing native Codex sign-in/model protections and the 1.2.27 context-preference fix remain included.
60
-
61
- ## Microsoft 365 access
62
-
63
- Eligible macOS/Windows machines attempt silent Microsoft authorization at startup, without Copilot CLI or a browser login. MDM alone is insufficient: account, tenant, device policy and Loki entitlement must permit access. Optional failure does not block GitHub. Saved bindings stay selected; unresolved company accounts can be chosen under **Model sources → Microsoft 365** or `ccdx m365 account` in the updated running service. Listing is local; changing accounts validates only the selected account, affects M365 in Codex/Claude and requires new conversations. See the reference for identity and history limits. Microsoft 365 uses the fixed `loki.delve.office.com` service origin. Account/origin-bound model discovery is separate from inference; old environment caches are not advertised as current. This does not enable a paused source or change existing application routing.
64
-
65
- In **Model sources → Microsoft 365 → Allowed apps**, choose consuming apps; discovery alone does not configure them all. Existing grants are retained, and changing access preserves other sources. Claude clients use `http://127.0.0.1:2026/anthropic` (or the configured main port), a private local gateway key and a Claude-only catalog. No second Claude listener is opened. Existing unchanged CCDX-owned 2027 addresses migrate automatically; hand-written or managed addresses are preserved and need explicit migration. The optional prediction CONNECT/PAC bridge remains a separate transport.
66
- Existing custom/managed settings are preserved; already-running clients may need a normal restart.
67
- Canonical Claude IDs and advertised effort caps refresh only in unchanged CCDX-owned settings. User and managed choices are preserved; supported App versions can update model knowledge through Anthropic's signed catalog. New protocol semantics may require a client or CCDX update. See the [model reference](docs/REFERENCE.md#claude-gateway-and-client-ownership).
68
- `ccdx m365 off` restores unchanged owned fields; `remove` also clears owned M365 state. With managed client connections, off pauses affected bindings instead of selecting another source; removal retains shared client-ownership records needed by manual APIs.
69
-
70
- Codex stays on GitHub until `ccdx m365 switch`. Select available GPT/review models;
71
- there is no automatic failover or missing-model substitution. Use **Standard** on M365:
72
- Fast is unverified. Tokens, accounts and review choices are isolated; prediction and images remain independent.
73
-
74
- The optional native broker adds a **14.6 MB download**, with no install hook. Linux retains core support without M365.
75
- See the [M365 reference](docs/REFERENCE.md#microsoft-365-provider) for ownership, cache/experimental-feature limits and cleanup.
76
-
77
- ## Compatibility and safety
78
-
79
- - Standard/Fast follow the exact variants advertised by Copilot; CCDX does not
80
- invent Fast availability. Auto-review is separate from the foreground model.
81
- - Model discovery does not prove inference access. If a new model is absent in
82
- Codex, run `ccdx doctor`; fully quit the App (**Command-Q** on macOS) before reopening.
83
- CCDX does not claim it can verify the App's internal model cache externally.
84
- - After a package upgrade, restart the running CCDX adapter. Choosing a model or
85
- effort on a current adapter takes effect on its next Auto-review request. Native prediction ports persist on macOS/Windows; an older random route may need one full App quit. A busy saved port disables only predictions.
86
- - `0.9.28` adds verified local plaintext recovery after connection-owned compaction rejection; see the reference for strict source and safety limits. Request-body bytes, local-history bytes and the model's token window are
87
- different limits. Request-context figures are observed metadata, not exact
88
- live session occupancy. Prompts and images are not retained by that panel.
89
- - `ccdx cache --clean --history` also clears active response history and can
90
- break continuations. Generated images and Codex transcripts are not deleted.
91
- - Optional image setup/maintenance never blocks the primary service. Disabled
92
- users get no CCDX image skill or MCP installation.
93
- - Missing-token discovery includes legacy OpenCode Copilot OAuth and GitHub CLI. Reads are bounded and account-matched; incomplete/network-failed or HTTP-403-blocked discovery does not start another login. The default saved credential is preserved; Copilot 401/403 alone is not proof that it expired. Other apps' credentials stay read-only.
94
- - `doctor --fix` does not start login, enable optional features, change company policy or force-restart Apps. It backs up changed config; missing-token repair can contact GitHub. Partial repairs exit 1. See the reference for exact scope.
95
- - Native predictions are a separate, opt-in compatibility feature. Quit Codex,
96
- run `ccdx prediction on`, then restart CCDX. This adds App-profile certificate
97
- trust and an App-only route for `chatgpt.com` and `ab.chatgpt.com`; HTTPS on those
98
- hosts is decrypted locally, but only prediction configuration is changed.
99
- Other domains and the CCDX model endpoint stay on their existing routes.
100
- No program files or OS trust are changed. Static HTTP/HTTPS/SOCKS5 proxies and bypass rules are retained.
101
- Windows supports company PAC/WPAD; macOS dynamic routing remains unsupported. Windows setup needs the official MSIX App, Windows PowerShell and .NET Framework 4.7.2+—not Git/OpenSSL. See the reference for limits.
102
- Bridge checks allow three same-port recovery attempts per process. The revised PAC adds a loopback retry endpoint after the unchanged primary, preserving company fallback. Quit Codex once to load this route revision; later CCDX upgrades retain it. App prediction failures can remain cached for five minutes, so network recovery is not proof of an immediate suggestion. Only closed, initialized Apps in direct environments receive an owned persistent route; missing routes in running Apps are not hot-attached.
103
- - CCDX adds experimental local history compression only when installed App
104
- runtimes support it and report it off. Existing choices are preserved; an
105
- already-enabled default, unavailable runtime or failed check is skipped.
106
- - Image API redirects must stay on the same HTTPS origin. Returned images must
107
- use public HTTPS URLs; well-known NAT64 mappings follow IPv4 address rules.
108
- - Keep the adapter on loopback. LAN mode is only for trusted networks; do not
109
- expose it to the public internet. The dashboard is not an authentication wall
110
- for the API. Inference rejects browser Origin headers; native clients remain supported. Diagnostic errors may contain sensitive upstream text.
111
-
112
- Open `ccdx web` for source-specific account tools and Checks & repairs without signing in first. It starts a management-only service when needed; stop it before normal app startup. Safe reauth, config preview/backup, local reports, feature pause/resume and matching circle SVG status icons are described in the [account tools reference](docs/REFERENCE.md#account-and-repair-tools). Existing themes, layout and bilingual support are preserved. Startup checks GitHub's latest-release web redirect, not npm or the anonymous REST quota, and suggests `ccdx update github`. Settings → Version & updates shows the running version, release dates and newer releases, with copyable update and macOS/Windows recovery commands. This separate, cached GitHub metadata check never installs; failed checks remain unknown. The separate **Update overnight** switch defaults off and requires a normal CCDX restart after enabling. Its foreground supervisor checks during 00:00–04:00 local time after ten observed idle minutes, selects same-series stable patches at least 24 hours old, stages verified packages and attempts rollback on failure. Ctrl+C stops it; no OS service is installed. Review the displayed risk and [handoff limits](docs/REFERENCE.md#nightly-updates-opt-in) before enabling. See the [reference](docs/REFERENCE.md#version-and-update-information).
113
- Settings → **Save & restore**, immediately after Version & updates, defaults to automatic saving of this page’s preferences. Turn it off to save or discard drafts manually. Restore defaults backs up the saved preferences first and offers Restore backup; it preserves accounts, keys, model/source selections, native sign-in, client connections, image/prediction access, chats and usage. Browser appearance stays browser-local; failed or conflicting saves retain the draft and show the actual result. See the [scope and recovery rules](docs/REFERENCE.md#settings-saving-and-restore).
114
- GitHub updates verify the exact Release without Git. Source packages use the configured npm registry; a confirmed EALLOWREMOTE restores the old package and permits one same-version complete platform package attempt offline. Nightly preparation shares this fallback. A blocked old updater can use the current verified bootstrap once. Lookup errors identify HTTP refusal, timeout, network failure or invalid redirects. For npm `EALLOWREMOTE`, only if policy permits and the update is trusted, use `ccdx update github --allow-remote`: explicit URL-download permission for that installation's whole dependency tree, not a hostname allowlist. Persistent npm settings stay unchanged.
115
- Updates back up the discovered CCDX package and commands, restore them on install/runtime-check failure, and verify the installed version (exact for GitHub). Mismatched npm targets warn without changing PATH/prefix. Manual updates require a separate adapter restart. Full `ccdx doctor` reports this target and readonly credential permissions; it never changes ACLs.
116
- Recent errors separate HTTP and model failures. By default HTTP metadata retains status, source and IDs, not error bodies or prompts; original errors still reach Codex unchanged. Explicit, bounded error-excerpt collection is described in the [reference](docs/REFERENCE.md#http-error-diagnostics).
117
-
118
- See [architecture boundaries](docs/ARCHITECTURE.md) and the [complete reference](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/REFERENCE.md) for authentication, configuration, limits, logging, images and compatibility. It is also included as `docs/REFERENCE.md` in the npm package.
119
-
120
- ## Development
121
-
122
- ```bash
123
- npm ci
124
- npm run verify
125
- node scripts/config-startup-replay.mjs
41
+ | Start the gateway | `ccdx` |
42
+ | Open the Web UI | `ccdx web` |
43
+ | Check service and apps | `ccdx status` / `ccdx app list` |
44
+ | Manage sources | `ccdx source list` / `ccdx source add` |
45
+ | Sign in again | `ccdx source github reauth` |
46
+ | Choose client models | `ccdx app codex models --edit` |
47
+ | Preview client setup | `ccdx app claude-app sync --preview` |
48
+ | Inspect failures | `ccdx requests --failed` |
49
+ | Read usage | `ccdx usage` / `ccdx usage --scope run` |
50
+ | Inspect preferences | `ccdx config show --effective` |
51
+ | Check local setup | `ccdx doctor` |
52
+
53
+ Use `ccdx help` or `ccdx <command> --help` for options. The CLI uses English; the Web UI supports English and Chinese.
54
+
55
+ **1.3 uses one command tree.** Old command names and the `codex-copilot-dx` executable have been removed. This changes command entrypoints, not saved accounts, model selections or chats. See the [command reference](docs/REFERENCE.md#commands).
56
+
57
+ ## Optional features
58
+
59
+ Images, native input suggestions and overnight updates are **off by default**. Existing enabled settings are retained.
60
+
61
+ - **Images:** `ccdx app codex image setup`. [Image guide](docs/REFERENCE.md#optional-image-generation).
62
+ - **Input suggestions:** `ccdx app codex prediction setup`. Setup adds trust within the Codex profile and locally decrypts traffic for the configured prediction hosts. Read the [setup and removal guide](docs/REFERENCE.md#optional-native-predictions) first.
63
+ - **Appearance and updates:** open Settings. Web and terminal colors are independent.
64
+
65
+ ## Update and troubleshoot
66
+
67
+ Finish active tasks before updating the active installation. Install the update, then restart CCDX normally:
68
+
69
+ ```sh
70
+ ccdx update github
71
+ ccdx version
126
72
  ```
127
73
 
128
- Verification covers unit tests, isolated HTTP/idle-stream replay, performance/resource gates and package contents—not an upstream service SLA. CI also tests Node 22.15/24 on Linux, Windows and macOS, temporary-prefix installation/upgrade and installed image processing.
74
+ The foreground terminal stops with **Ctrl+C**. Client configuration marked **Unchanged** means CCDX kept the existing settings. Configuration and successful model access are separate checks.
75
+
76
+ If models are missing, check the selected source and app models first. After a client update or configuration change, fully quit and reopen that app. Use **Checks & repairs** or `ccdx doctor` for local diagnostics.
77
+
78
+ Keep the gateway on loopback. Account keys stay separate from the local credentials given to clients. Prompts are not included in routine diagnostics. See the [reference](docs/REFERENCE.md) for access, history, troubleshooting and settings, and [architecture](docs/ARCHITECTURE.md) for engineering boundaries.
79
+
80
+ ## License
129
81
 
130
- License: MIT.
82
+ MIT
package/bin/cli.mjs CHANGED
@@ -1,31 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { ensureAuth, openCodex } from "../src/launcher.mjs";
4
- import { startAdapter } from "../src/adapter.mjs";
5
- import { defaultCopilotClient, refreshVSCodeVersion } from "../src/copilot.mjs";
6
3
  import { status } from "../src/status.mjs";
7
- import { configureLogging } from "../src/log.mjs";
8
- import { flushUsageWrites, printUsageSummary } from "../src/usage.mjs";
9
4
  import { checkForUpdate, localPackageVersion } from "../src/version.mjs";
10
- import { runDoctor } from "../src/doctor.mjs";
11
- import { adapterBaseUrl, checkRunningAdapter } from "../src/running-adapter.mjs";
12
- import { assertSafeAdapterHost, isLoopbackHost } from "../src/security.mjs";
13
- import { runInBackground } from "../src/startup.mjs";
14
5
  import { cliCommandName, cliHelp, parseAdapterAddressOptions, parseAdapterProbeOptions, parseCliArgs, parseRuntimeOptions } from "../src/cli-options.mjs";
15
- import { formatAdapterStatus, readAdapterStatus } from "../src/cli-status.mjs";
16
- import { closeHttpServer } from "../src/shutdown.mjs";
17
- import { autoReviewModelPreference, autoReviewPreference, responseHistoryLimitPreference, terminalAnimationPreference, servicePreferences, serviceSettingsSnapshot, nightlyUpdatePreference } from "../src/user-settings.mjs";
18
- import { formatLiveCopilotModels } from "../src/cli-models.mjs";
19
- import { runAuthCommand } from "../src/cli-auth.mjs";
20
- import { createProfileRuntime } from "../src/profile-runtime.mjs";
21
- import { createProfileModelRuntime } from "../src/profile-model-runtime.mjs";
22
- import { createCodexModelCatalog } from "../src/codex-model-catalog.mjs";
23
- import { createProviderRuntime } from "../src/provider-runtime.mjs";
24
- import { setResponseHistoryMaxBytes } from "../src/response-history.mjs";
25
- import { startupBanner, startupCheck, startupReady, startupLogger, predictionStartupCheck, providerStartupChecks } from "../src/startup-ui.mjs";
26
- import { createTerminalConsole } from "../src/terminal-console.mjs";
27
- import { createServiceControl } from "../src/service-control.mjs";
28
- import { openDashboard } from "../src/browser-launch.mjs";
29
6
 
30
7
  const LOCAL_VERSION = localPackageVersion();
31
8
  const CLI_NAME = cliCommandName();
@@ -48,6 +25,19 @@ if (CLI.command === "version") {
48
25
  console.log(CLI_BANNER);
49
26
  process.exit(0);
50
27
  }
28
+ if (CLI.command === "manage") {
29
+ try {
30
+ const { runManagementCommand } = await import("../src/cli-management.mjs");
31
+ const address = parseAdapterAddressOptions(process.env);
32
+ const result = await runManagementCommand(CLI, { host: address.adapterHost, port: address.adapterPort, version: LOCAL_VERSION });
33
+ if (result) console.log(result);
34
+ process.exit(0);
35
+ } catch (error) {
36
+ if (CLI.flags?.format === "json") console.log(JSON.stringify({ error: { code: error.code || "ccdx_command_failed", message: error.message } }));
37
+ else console.error(status("err", `${error.code ? `${error.code}: ` : ""}${error.message}`));
38
+ process.exit(1);
39
+ }
40
+ }
51
41
  if (CLI.command === "web") {
52
42
  try {
53
43
  const { runWebCommand } = await import("../src/cli-web.mjs");
@@ -87,28 +77,19 @@ if (CLI.command === "image") {
87
77
  ? parseAdapterAddressOptions(process.env)
88
78
  : { adapterPort: 2026, adapterHost: "127.0.0.1" };
89
79
  const { runImageCommand } = await import("../src/cli-image.mjs");
90
- await runImageCommand({
80
+ const lines = [], structured = CLI.outputFormat === "json";
81
+ const result = await runImageCommand({
91
82
  action: CLI.action,
92
83
  commandName: CLI_NAME,
93
84
  adapterPort: address.adapterPort,
94
85
  adapterHost: address.adapterHost,
86
+ ...(structured ? { output: { write: text => lines.push(String(text)) } } : {}),
95
87
  });
88
+ if (structured) console.log(JSON.stringify({ client: "codex", feature: "image", configured: result.enabled === true, details: lines.join("").trim() }));
96
89
  process.exit(0);
97
90
  } catch (e) {
98
- console.error(status("err", e.message));
99
- process.exit(1);
100
- }
101
- }
102
- if (CLI.command === "suggestion") {
103
- try {
104
- const { retirePredictionIntegration } = await import("../src/prediction-retirement.mjs");
105
- const result = retirePredictionIntegration({ dryRun: CLI.action === "status" });
106
- console.log("The old suggestion panel is no longer supported.");
107
- if (CLI.action === "status" && result.changed) console.log(`Legacy settings remain; run ${CLI_NAME} suggestion off to clean them up.`);
108
- if (result.preserved) console.warn("Your edited suggestion settings were kept.");
109
- process.exit(0);
110
- } catch (error) {
111
- console.error(status("err", error.message));
91
+ if (CLI.outputFormat === "json") console.log(JSON.stringify({ error: { code: e.code || "ccdx_image_status_failed", message: e.message } }));
92
+ else console.error(status("err", e.message));
112
93
  process.exit(1);
113
94
  }
114
95
  }
@@ -120,8 +101,10 @@ if (CLI.command === "prediction") {
120
101
  console.log(await pauseServiceFeature({ feature: "prediction", action: CLI.action, host: address.adapterHost, port: address.adapterPort }));
121
102
  process.exit(0);
122
103
  }
104
+ const { readAdapterStatus } = await import("../src/cli-status.mjs");
123
105
  const { runPredictionCommand } = await import("../src/native-prediction.mjs");
124
- const result = await runPredictionCommand({ action: CLI.action, repairRuntime: async () => {
106
+ const lines = [], structured = CLI.outputFormat === "json";
107
+ const result = await runPredictionCommand({ action: CLI.action, ...(structured ? { output: text => lines.push(String(text)) } : {}), repairRuntime: async () => {
125
108
  const { requestPredictionFix } = await import("../src/native-prediction-fix.mjs");
126
109
  const probe = parseAdapterProbeOptions(process.env);
127
110
  return requestPredictionFix({ host: probe.adapterHost, port: probe.adapterPort });
@@ -129,22 +112,11 @@ if (CLI.command === "prediction") {
129
112
  const probe = parseAdapterProbeOptions(process.env);
130
113
  return readAdapterStatus({ host: probe.adapterHost, port: probe.adapterPort, timeoutMs: probe.existingAdapterTimeoutMs }).then(({ data }) => data);
131
114
  } });
115
+ if (structured) console.log(JSON.stringify({ client: "codex", feature: "prediction", configured: result.enabled === true, details: lines.join("\n") }));
132
116
  process.exit(CLI.action === "fix" ? result.exitCode : 0);
133
117
  } catch (error) {
134
- console.error(status("err", error.message));
135
- process.exit(1);
136
- }
137
- }
138
- if (CLI.command === "usage") {
139
- try {
140
- await printUsageSummary({
141
- format: CLI.outputFormat || "auto",
142
- provider: CLI.provider || "",
143
- output: process.stdout,
144
- });
145
- process.exit(0);
146
- } catch (e) {
147
- console.error(status("err", e.message));
118
+ if (CLI.outputFormat === "json") console.log(JSON.stringify({ error: { code: error.code || "ccdx_prediction_status_failed", message: error.message } }));
119
+ else console.error(status("err", error.message));
148
120
  process.exit(1);
149
121
  }
150
122
  }
@@ -186,17 +158,9 @@ if (CLI.command === "limits") {
186
158
  process.exit(1);
187
159
  }
188
160
  }
189
- if (CLI.command === "retired") {
190
- console.error(status("err", `${CLI.integration} integration was retired in ccdx 0.7.0.`));
191
- if (CLI.integration === "PM Studio") {
192
- console.error(status("info", "Update or reinstall PM Studio to remove an older CCDX app patch."));
193
- } else {
194
- console.error(status("info", "Remove any old CCDX endpoint from the client before using a different provider."));
195
- }
196
- process.exit(1);
197
- }
198
161
  if (CLI.command === "auth") {
199
162
  try {
163
+ const { runAuthCommand } = await import("../src/cli-auth.mjs");
200
164
  const result = await runAuthCommand({
201
165
  action: CLI.action,
202
166
  profile: CLI.profile,
@@ -221,42 +185,6 @@ if (CLI.command === "auth") {
221
185
  process.exit(1);
222
186
  }
223
187
  }
224
- if (CLI.command === "status") {
225
- let probe;
226
- try {
227
- probe = parseAdapterProbeOptions(process.env);
228
- } catch (e) {
229
- console.error(e.message);
230
- process.exit(2);
231
- }
232
- try {
233
- const snapshot = await readAdapterStatus({
234
- host: probe.adapterHost,
235
- port: probe.adapterPort,
236
- timeoutMs: probe.existingAdapterTimeoutMs,
237
- });
238
- console.log(formatAdapterStatus(snapshot, { commandName: CLI_NAME, cliVersion: LOCAL_VERSION }));
239
- process.exit(0);
240
- } catch (e) {
241
- console.error(status("err", e.message));
242
- process.exit(1);
243
- }
244
- }
245
- if (CLI.command === "models") {
246
- try {
247
- const { fetchActiveProviderModels } = await import("../src/cli-m365.mjs");
248
- const catalog = await fetchActiveProviderModels();
249
- console.log(formatLiveCopilotModels(catalog, {
250
- commandName: CLI_NAME,
251
- format: CLI.outputFormat || "auto",
252
- output: process.stdout,
253
- }));
254
- process.exit(0);
255
- } catch (e) {
256
- console.error(status("err", e.message));
257
- process.exit(1);
258
- }
259
- }
260
188
  if (CLI.command === "auto-review-model") {
261
189
  try {
262
190
  const { runProviderAutoReviewCommand } = await import("../src/cli-m365.mjs");
@@ -289,6 +217,7 @@ if (CLI.command === "doctor" && CLI.tool) {
289
217
  } catch (error) { console.error(status("err", error.message));process.exit(1); }
290
218
  }
291
219
  if (CLI.command === "doctor" && CLI.configOnly) {
220
+ const { runDoctor } = await import("../src/doctor.mjs");
292
221
  let probe;
293
222
  try {
294
223
  probe = parseAdapterAddressOptions(process.env);
@@ -305,6 +234,29 @@ if (CLI.command === "doctor" && CLI.configOnly) {
305
234
  process.exit(checks.some((check) => check.kind === "err") ? 1 : 0);
306
235
  }
307
236
 
237
+ // Startup components are loaded only after read-only and local tool commands exit.
238
+ const { ensureAuth, openCodex } = await import("../src/launcher.mjs");
239
+ const { startAdapter } = await import("../src/adapter.mjs");
240
+ const { defaultCopilotClient, refreshVSCodeVersion } = await import("../src/copilot.mjs");
241
+ const { configureLogging } = await import("../src/log.mjs");
242
+ const { flushUsageWrites } = await import("../src/usage.mjs");
243
+ const { runDoctor } = await import("../src/doctor.mjs");
244
+ const { adapterBaseUrl, checkRunningAdapter } = await import("../src/running-adapter.mjs");
245
+ const { assertSafeAdapterHost, isLoopbackHost } = await import("../src/security.mjs");
246
+ const { runInBackground } = await import("../src/startup.mjs");
247
+ const { readAdapterStatus } = await import("../src/cli-status.mjs");
248
+ const { closeHttpServer } = await import("../src/shutdown.mjs");
249
+ const { autoReviewModelPreference, autoReviewPreference, responseHistoryLimitPreference, terminalAnimationPreference, servicePreferences, serviceSettingsSnapshot, nightlyUpdatePreference } = await import("../src/user-settings.mjs");
250
+ const { createProfileRuntime } = await import("../src/profile-runtime.mjs");
251
+ const { createProfileModelRuntime } = await import("../src/profile-model-runtime.mjs");
252
+ const { createCodexModelCatalog } = await import("../src/codex-model-catalog.mjs");
253
+ const { createProviderRuntime } = await import("../src/provider-runtime.mjs");
254
+ const { setResponseHistoryMaxBytes } = await import("../src/response-history.mjs");
255
+ const { startupBanner, startupCheck, startupReady, startupLogger, predictionStartupCheck, providerStartupChecks, createStartupPresentation } = await import("../src/startup-ui.mjs");
256
+ const { createTerminalConsole } = await import("../src/terminal-console.mjs");
257
+ const { createServiceControl } = await import("../src/service-control.mjs");
258
+ const { openDashboard } = await import("../src/browser-launch.mjs");
259
+
308
260
  let serviceWorker = null;
309
261
  if (CLI.command === "start") {
310
262
  if (process.send && process.env.CCDX_SUPERVISED_SERVICE === "1") {
@@ -440,6 +392,8 @@ if (CLI.command === "doctor") {
440
392
  }
441
393
 
442
394
  console.log(`\n${startupBanner({ commandName: CLI_NAME, version: LOCAL_VERSION })}\n`);
395
+ const startupPresentation = createStartupPresentation({ verbose: CLI.verbose === true || CLI.showRequestId === true || LOGGING.level === "debug" || serviceWorker?.warming });
396
+ if (startupPresentation.enabled) LOGGING.setTerminalSink((method, args) => startupPresentation.log(method, args));
443
397
 
444
398
  async function printUpdateNotice() {
445
399
  try {
@@ -466,7 +420,7 @@ try {
466
420
  // Ready is already displayed; finish the bounded check before this short-lived CLI exits.
467
421
  await updateNotice;
468
422
  serviceWorker?.reused();
469
- await LOGGING.cleanup();
423
+ startupPresentation.finish();await LOGGING.cleanup();
470
424
  process.exit(0);
471
425
  }
472
426
 
@@ -495,7 +449,7 @@ try {
495
449
  const m365Setup = runInBackground(() => providerRuntime.start());
496
450
  if (providerRuntime.selection().codex === "github") {
497
451
  try { await ensureAuth({ log: startupLogger("Sign-in"), interactive: serviceWorker?.preserving !== true }); }
498
- catch (error) { if (serviceWorker?.preserving) throw error;console.warn(startupCheck("warn", "Sign-in", "Sign-in unavailable. Use the dashboard or ccdx auth login; saved credentials kept.")); }
452
+ catch (error) { if (serviceWorker?.preserving) throw error;console.warn(startupCheck("warn", "Sign-in", "Sign-in unavailable. Use the dashboard or ccdx source github login; saved credentials kept.")); }
499
453
  } else {
500
454
  if (providerRuntime.selection().codex === "m365") await m365Setup;
501
455
  const source = providerRuntime.connections().providers.find(source => source.id === providerRuntime.selection().codex);
@@ -579,9 +533,13 @@ try {
579
533
  }
580
534
 
581
535
  startupComplete = true;
582
- console.log(startupReady({ baseUrl: adapterBaseUrl(ADAPTER_HOST, ADAPTER_PORT), commandName: CLI_NAME }));
536
+ if (!startupPresentation.enabled) console.log(startupReady({ baseUrl: adapterBaseUrl(ADAPTER_HOST, ADAPTER_PORT), commandName: CLI_NAME }));
583
537
  await launchDashboard();
584
- if (!serviceWorker?.warming) { terminalConsole.start();LOGGING.setTerminalSink((method, args) => terminalConsole.log(method, args)); }
538
+ if (!serviceWorker?.warming) {
539
+ startupPresentation.finish();for (const [method, args] of startupPresentation.warnings) terminalConsole.log(method, args);
540
+ terminalConsole.start();if (!terminalConsole.enabled && startupPresentation.enabled) process.stdout.write(startupReady({ baseUrl: adapterBaseUrl(ADAPTER_HOST, ADAPTER_PORT), commandName: CLI_NAME }));
541
+ LOGGING.setTerminalSink((method, args) => terminalConsole.log(method, args));
542
+ }
585
543
 
586
544
  const shutdown = async (signal) => {
587
545
  if (shuttingDown) return;
@@ -646,7 +604,7 @@ try {
646
604
  });
647
605
  }
648
606
  } catch (e) {
649
- LOGGING.setTerminalSink(null);terminalConsole?.cleanup();
607
+ startupPresentation.finish();LOGGING.setTerminalSink(null);terminalConsole?.cleanup();
650
608
  console.error(status("err", e.message));
651
609
  await clientIntegration?.close().catch(() => {});
652
610
  await providerRuntime?.close().catch(() => {});
@@ -269,7 +269,7 @@ before body admission, credential use or provider dispatch; native LAN opt-in is
269
269
  Manual package installation is an explicit management operation in `package-update.mjs`,
270
270
  not part of inference or optional client integration. Windows uses the system
271
271
  command interpreter only for the fixed `npm.cmd` installer command; stable-tag
272
- validation remains upstream of launch. macOS/Linux use direct npm argv. There
272
+ validation remains upstream of launch. macOS uses direct npm argv. There
273
273
  is no generic shell runner or package-manager framework, and npm's configured
274
274
  registry/proxy environment remains owned by the user.
275
275
  Readonly npm policy discovery is update-only and uses the same global context as
@@ -605,8 +605,8 @@ and cancellation propagation for both native Responses and Chat translation.
605
605
  Empty-stream diagnostics are additive scalar metadata, not a new retry policy.
606
606
  Release reports describe a specific environment, not an SLA or a guarantee of
607
607
  compatibility with every future client or corporate network policy.
608
- CI runs Node 22.15 and 24 on Linux, Windows and macOS. The owned temporary-prefix
609
- package smoke installs its 0.9.41 baseline (or an explicit local artifact), upgrades to the packed candidate and exercises
608
+ CI runs Node 22.15 and 24 on Windows and macOS. The owned temporary-prefix
609
+ package smoke installs its 1.2.33 baseline (or an explicit local artifact), upgrades to the packed candidate and exercises
610
610
  installed sharp without provider calls. It does not claim a live Codex UI test
611
611
  or the GitHub updater's network installation; the Windows command chain has a
612
612
  separate actual-process fixture. Direct runtime dependencies are exact versions;
@@ -940,3 +940,51 @@ 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
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 handler dispatch. `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. The single
959
+ public grammar rejects removed command roots before startup. Shared feature
960
+ handlers keep their existing behavior. Saved configuration remains readable.
961
+
962
+ The full connection snapshot exposes a management capability and per-client
963
+ binding revision. CLI connection mutations require this capability; older running
964
+ services are not silently upgraded or mutated. Source authorization uses the same
965
+ source-impact revision as closing previews. A client access-only action retains
966
+ legacy source and deployment representation; it does not migrate a GitHub-only
967
+ binding or change Codex auth mode. Explicit one-shot client sync reuses serialized,
968
+ targeted ownership writers while retaining `auto_sync=false`. Shared Claude settings
969
+ retain existing peer/manual-support protections. Disabled, unbound APIs can be
970
+ removed; in-flight credential retirement uses the existing secret lifecycle.
971
+
972
+ CLI service-preference backups use the existing bounded validator, file lock and
973
+ atomic backup/config pair with a separate backup filename. WebUI's appearance-paired
974
+ backup and version-one format are unchanged. No new history store, daemon, client
975
+ restart controller, transport policy or production dependency is introduced.
976
+
977
+
978
+ ### 1.3 scope and state orchestration
979
+
980
+ CCDX ships only for macOS and Windows (x64/ARM64). CI and complete-package builders use those four targets. The macOS bootstrap rejects unsupported systems before downloads. `ccdx` is the only package command; old CLI roots and aliases are removed without resetting accounts, keys, selected models or client-owned files.
981
+
982
+ Startup presentation classifies each formatted line independently. Normal checks are transient; mixed-message warnings and sign-in instructions remain visible. The live region labels the Web UI address and renders enabled sources once. `preserved` remains an internal configuration result and is displayed as `Unchanged`.
983
+
984
+ Source-catalog tables keep fixed column geometry while native disclosures expand, preventing metadata width from moving the disclosure control. The API editor places its capability panel below the selected model row. Neither path adds network reads or inference.
985
+
986
+ `connection-runtime.mjs` retains one serial mutation queue and its existing synchronization coalescer. Named preparation/selection handlers separate branch-specific validation/mutation from the shared credential-write, client-sync and retirement sequence. Codex sync, Claude preparation/writing and shared App/Code capability reconciliation have local boundaries. Desktop inspection remains at the existing await point; clients are not synchronized in parallel.
987
+
988
+ A full snapshot keeps a local map of compiled client plans, including reuse during source-impact projection. Public data remains cloned and contains the same revisions/route identifiers. No persistent or global cache is added. `updateAccessSettings` retains strict validation, the lock and original-byte v1 backup, then skips an atomic rewrite only when serialized bytes already match. Skipping a file write does not skip an explicit control action or client sync.
989
+
990
+ The CLI keeps only command/version/status fundamentals before its early command dispatch. Existing tool implementations are imported in their branches; startup composition loads afterward in its previous dependency order. Native account stores, source/key identity, model projections and image/prediction behavior are unchanged. The repository-only `docs/STATE_REFACTOR_PLAN.md` records included boundaries, local measurements and deferred work.