cxstatusline 0.1.1 → 0.4.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.
package/README.md CHANGED
@@ -37,12 +37,11 @@ Independent project; not an official OpenAI product.
37
37
 
38
38
  ## Requirements
39
39
 
40
- - **macOS 14 (Sonoma) or newer** on Apple Silicon (`darwin-arm64`) or Intel (`darwin-x64`). Clean-macOS-14 acceptance is unproven and evidenced only by build metadata (`MACOSX_DEPLOYMENT_TARGET=14.0`, `vtool` `minos`, and system-only `otool -L` linkage).
40
+ - **macOS 14 (Sonoma) or newer** (Apple Silicon or Intel).
41
41
  - **Node.js 22+**.
42
- - **Stock Codex CLI install** kept in place (`~/.codex/` and original launcher).
42
+ - **Existing Codex CLI installation** kept in place (`~/.codex/`).
43
43
  - **Git**.
44
- - **Bun 1.4+** is required only for building/linking from a git checkout.
45
- - **Rust toolchain** (1.95.0+) is required only for `cxstatusline install --compile`.
44
+ - **Rust toolchain** (1.95.0+) is required only if building from source (`--compile`).
46
45
 
47
46
  ## 🚀 Install
48
47
 
@@ -54,7 +53,7 @@ cxstatusline install
54
53
  cxstatusline doctor
55
54
  ```
56
55
 
57
- `install` downloads the release matching your exact Codex version and CPU, verifies every byte against `manifest.json`, and activates it. Nothing is signed or notarized; see [Security and trust](#security-and-trust).
56
+ `install` downloads the verified prebuilt binary matching your exact Codex version and architecture, verifies checksums against `manifest.json`, and activates it.
58
57
 
59
58
  Start Codex, accept its cxstatusline hook trust prompt, and open a new session after installation. An already-running process does not switch binaries when installation finishes.
60
59
 
@@ -102,22 +101,78 @@ cxstatusline
102
101
  The bare command opens the configuration TUI in an interactive terminal. Choose widgets, colors
103
102
  and themes, preview, then save explicitly or press Ctrl+S. Settings live at
104
103
  `~/.config/cxstatusline/settings.json` (or your XDG config location).
105
- Custom command/weather widgets and unsupported Claude-only widgets are not included.
104
+ Claude-only widgets without a Codex data source are not included; see the widget inventory in the
105
+ project notes for the full list and reasons.
106
106
 
107
107
  For scripts, `cxstatusline render` reads a versioned JSON payload on stdin and prints ANSI rows;
108
108
  it never opens the TUI.
109
109
 
110
+ ## Custom widgets
111
+
112
+ Three widgets show your own content, with the same settings fields as ccstatusline so presets import unchanged:
113
+
114
+ | Widget | Field | Shows |
115
+ |---|---|---|
116
+ | Custom Text | `customText` | A fixed label such as `[PROD]` |
117
+ | Custom Symbol | `customSymbol` | One glyph or emoji such as `⚡` |
118
+ | Custom Command | `commandPath` | The first line a shell command prints |
119
+
120
+ ### Custom Command execution and caching
121
+
122
+ Custom Command runs `commandPath` through your shell (`/bin/sh -c`) with Codex's environment, in
123
+ the session's working directory. It receives the Codex status payload as JSON on stdin plus `terminal_width`.
124
+ Only the first non-empty line is shown; stderr is discarded. Set `preserveColors` (key `p`) to keep
125
+ the command's own colour codes; other escape sequences and control characters are always removed. Configured
126
+ background colours apply in both render modes and survive resets within the command output. `maxWidth`
127
+ (key `w`) truncates with an ellipsis. The TUI preview never runs commands. Imported presets list their
128
+ commands before you confirm.
129
+
130
+ #### Synchronous execution (default)
131
+
132
+ When `refreshMs` is unset (or `0`), commands run synchronously on **every footer redraw** (up to five
133
+ times a second while Codex streams).
134
+
135
+ Codex kills the whole statusline renderer after one second and keeps the previous frame, so
136
+ cxstatusline caps each synchronous command at **300 ms by default, 600 ms maximum** (`timeout`, editor key
137
+ `t`), and all commands on a render share a 600 ms budget. Over budget shows `[Budget]`; a slow
138
+ command shows `[Timeout]`, a failing one `[Exit: N]` or `[Cmd not found]`. Commands terminated by
139
+ external signals before the deadline report `[Signal: <name>]` rather than `[Timeout]`. Keep synchronous
140
+ commands cheap and local: `git status -s | wc -l` and `date +%H:%M` are good fits; network calls are not.
141
+
142
+ #### Background caching (`refreshMs`)
143
+
144
+ For commands that take longer or should not run on every redraw, configure `refreshMs` (key `f`).
145
+
146
+ - **Background refresh:** When `refreshMs` is set, rendering reads the latest result from disk and never
147
+ blocks the statusline or consumes renderer timeout budget. When an entry is due for an update,
148
+ cxstatusline spawns a detached background process to refresh it; the refresh outlives the render.
149
+ - **Cold start:** On the very first render before the initial background run completes, the widget shows
150
+ `[Loading]`.
151
+ - **Failures and timeouts:** A failing background command caches its exit code or error token; if a
152
+ background refresh stays outstanding or fails beyond 60 seconds, the widget settles on `[Error]` and
153
+ keeps showing `[Error]` across subsequent renders until a refresh succeeds.
154
+ - **Cache location:** Cached documents live under `~/.cache/cxstatusline/commands/` (or
155
+ `$XDG_CACHE_HOME/cxstatusline/commands/`). Deleting this cache directory at any time is completely
156
+ safe; entries are re-created automatically.
157
+ - **Eviction:** Cache entries and temporary files expire and are automatically evicted after 7 days.
158
+ - **Session sharing constraint:** The cache key is derived from `(command, cwd)`, so every Codex
159
+ session running in the same working directory shares one cache entry and one payload (the payload
160
+ written by whichever session triggered the refresh). `refreshMs` is intended for commands whose
161
+ output does not depend on specific session payload details.
162
+ - **Pipeline processes:** As with synchronous mode, `shell: true` terminates `/bin/sh` on timeout,
163
+ so child processes spawned inside a shell pipeline can outlive the cap. Avoid long-running pipelines.
164
+
110
165
  ## Update
111
166
 
112
167
  ```sh
113
- codex update
114
- # or
115
168
  cxstatusline update
116
169
  ```
117
170
 
118
- `codex update` (or `cxstatusline update`) runs Codex's upstream updater, then downloads the matching prebuilt; never compiles.
171
+ `cxstatusline update` runs a pre-flight check: if upstream Codex has a new version but prebuilts have not yet been published, it warns and stops before touching your active installation.
119
172
 
120
- If no verified prebuilt release exists for the new version, cxstatusline fails closed: the working pair is left in place and the command says so. The SessionStart hook retries daily according to update policy.
173
+ Options:
174
+ - `cxstatusline update --compile`: updates upstream Codex and compiles the statusline from source for the new version.
175
+ - `cxstatusline update --force`: updates upstream Codex to stock immediately, even if prebuilt binaries are not yet published.
121
176
 
122
177
  ## Revert
123
178
 
@@ -127,43 +182,35 @@ cxstatusline revert
127
182
 
128
183
  `cxstatusline revert` restores the stock launcher, removes CX-owned executables, generations, and the hook, and keeps settings and source. Generations are kept until revert; close Codex sessions first.
129
184
 
130
- ## How it works
131
-
132
- **Renderer and settings:** The statusline is powered by a Node CLI renderer that receives session metadata from Codex, formats ANSI rows according to your `settings.json`, and writes the footer.
133
-
134
- **The additive Rust patch:** Because the Codex CLI does not yet provide an external statusline hook ([openai/codex#17827](https://github.com/openai/codex/issues/17827)), cxstatusline applies a minimal additive patch to `codex-tui` and builds synchronized binaries (`codex` and companion `codex-code-mode-host`). The patch invokes the local renderer without altering Codex's networking or command evaluation.
135
-
136
- **Generations and atomic activation:** Each verified pair installs into an immutable generation directory under `~/.local/libexec/cxstatusline/generations/<id>/`. An atomic rename switches the `~/.local/libexec/cxstatusline/current` symlink. The wrapper in `~/.local/bin/codex` resolves `current` once before execution, ensuring running sessions and their companion host stay locked to the same generation. Previous generations accumulate until explicit `cxstatusline revert`.
137
-
138
- **SessionStart hook and update policy:** A hook registered in Codex's `hooks.json` checks for upstream version drift on session start. When drift is detected, a detached child process downloads the matching prebuilt release without interrupting your active terminal session.
139
-
185
+ ## 🔍 How it works
186
+
187
+ Codex CLI does not yet provide a native statusline extension hook ([openai/codex#17827](https://github.com/openai/codex/issues/17827)). `cxstatusline` bridges this with a lightweight additive Rust patch that captures session telemetry (model, context tokens, Git branch, rate limits) and invokes a local Node/TypeScript ANSI renderer.
188
+
189
+ Updates use an immutable **generation-based layout** (`~/.local/libexec/cxstatusline/generations/`) with atomic symlink swaps, ensuring your active terminal sessions are never interrupted.
190
+
191
+ 👉 For a full architectural breakdown of how Codex is patched with Rust, check out the **[Architecture & Technical Deep Dive (wiki.md)](wiki.md)**.
192
+
140
193
  ## Supported versions
141
-
142
- cxstatusline matches exact stable releases. Supported versions in `patches/manifest.json`:
143
- - **0.152.1**
194
+
195
+ cxstatusline matches exact stable releases. Supported versions:
196
+ - **0.154.0**
197
+ - **0.153.4**
144
198
  - **0.153.0**
145
- - **0.153.4** (candidate)
146
-
199
+ - **0.152.1**
200
+
147
201
  If your Codex version is not listed, cxstatusline fails closed: it will neither download an unverified prebuilt nor attempt source compilation. New versions require a tested patch file, an entry in `patches/manifest.json`, and a release workflow run.
148
-
202
+
149
203
  ## 🩺 Troubleshooting
150
-
204
+
151
205
  - **No footer:** Run `cxstatusline doctor`, verify `which codex` points to `~/.local/bin/codex`, check your `PATH`, accept the hook prompt in Codex, and start a fresh session.
152
206
  - **Unsupported version:** Wait for an explicitly supported patch. `--force` does not bypass version compatibility. Keep a working stock Codex installation.
153
207
  - **Failed build:** Inspect `~/.local/state/cxstatusline/patch.log`, fix the prerequisite, then run `cxstatusline patch --force`. Redact personal paths, session identifiers, and secrets before sharing logs.
154
208
  - **Missing companion / interrupted install:** Run `cxstatusline doctor`. Use `cxstatusline revert` to return to stock before reinstalling if unhealthy. Do not manually replace only one binary.
155
-
156
- ## Security and trust
157
-
158
- - **Unsigned and unnotarized:** cxstatusline binaries are not signed or notarized by Apple; macOS Gatekeeper warnings are expected. Do not disable Gatekeeper globally; clear the quarantine attribute for these two files only, or build from source with `install --compile`.
159
- - **Integrity vs. identity:** Checksums and manifests prove integrity relative to the GitHub release, not publisher identity.
160
- - **Archive contents:** Each prebuilt release archive contains exactly five files: `codex`, `codex-code-mode-host`, upstream `LICENSE` (Apache-2.0), upstream `NOTICE`, and `THIRD_PARTY_NOTICES.md` (combining cxstatusline notices and generated Rust dependency notices). No extra directories, files, or telemetry.
161
- - **Security policy:** See [SECURITY.md](SECURITY.md) for full trust boundaries, file layout, and vulnerability reporting.
162
-
163
- ## Contributing and license
164
-
165
- See [CONTRIBUTING.md](CONTRIBUTING.md), [SECURITY.md](SECURITY.md), and [CHANGELOG.md](CHANGELOG.md).
166
-
167
- Inspired by [ccstatusline](https://github.com/sirmalloc/ccstatusline) for Claude Code. Its renderer and configuration UI are adapted here for Codex. Thanks to its creators and contributors!
168
-
169
- cxstatusline is [MIT licensed](LICENSE). [NOTICE](NOTICE) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) preserve upstream attribution. The build includes dependency license texts in `dist/THIRD_PARTY_LICENSES.txt`. OpenAI Codex remains separately licensed under Apache-2.0.
209
+
210
+ ## 🙏 Acknowledgments
211
+
212
+ Huge shout-out to **[ccstatusline](https://github.com/sirmalloc/ccstatusline)** by [@sirmalloc](https://github.com/sirmalloc)! The interactive configurator TUI, widget architecture, Powerline themes, and overall statusline UX in `cxstatusline` are directly adapted and inspired by `ccstatusline`'s fantastic work for Claude Code.
213
+
214
+ ## License
215
+
216
+ cxstatusline is [MIT licensed](LICENSE). See [SECURITY.md](SECURITY.md) for security boundaries and reporting. [NOTICE](NOTICE) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) preserve upstream attribution. OpenAI Codex remains separately licensed under Apache-2.0.