@jiawang1209/codex-hud 0.1.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/.codex-plugin/plugin.json +41 -0
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +342 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +206 -0
- package/dist/cli.js.map +1 -0
- package/dist/codex-statusline.d.ts +9 -0
- package/dist/codex-statusline.js +96 -0
- package/dist/codex-statusline.js.map +1 -0
- package/dist/config.d.ts +62 -0
- package/dist/config.js +199 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/installer.d.ts +17 -0
- package/dist/installer.js +125 -0
- package/dist/installer.js.map +1 -0
- package/dist/native-runner.d.ts +28 -0
- package/dist/native-runner.js +122 -0
- package/dist/native-runner.js.map +1 -0
- package/dist/render.d.ts +11 -0
- package/dist/render.js +149 -0
- package/dist/render.js.map +1 -0
- package/dist/snapshot.d.ts +12 -0
- package/dist/snapshot.js +32 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/sources/codex.d.ts +50 -0
- package/dist/sources/codex.js +182 -0
- package/dist/sources/codex.js.map +1 -0
- package/dist/sources/git.d.ts +2 -0
- package/dist/sources/git.js +37 -0
- package/dist/sources/git.js.map +1 -0
- package/dist/sources/session.d.ts +14 -0
- package/dist/sources/session.js +278 -0
- package/dist/sources/session.js.map +1 -0
- package/dist/tmux-runner.d.ts +26 -0
- package/dist/tmux-runner.js +203 -0
- package/dist/tmux-runner.js.map +1 -0
- package/dist/types.d.ts +42 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/docs/installation.md +42 -0
- package/docs/native-codex-cli-patch.md +55 -0
- package/docs/plugin-marketplace.md +42 -0
- package/docs/release.md +35 -0
- package/docs/superpowers/plans/2026-05-23-codex-hud-mvp.md +234 -0
- package/docs/superpowers/plans/2026-05-23-productized-native-bundle.md +431 -0
- package/docs/superpowers/specs/2026-05-23-codex-hud-design.md +197 -0
- package/docs/upstream/codex-command-backed-statusline.md +101 -0
- package/package.json +49 -0
- package/patches/codex-cli-command-statusline.patch +459 -0
- package/plugins/codex-hud/.codex-plugin/plugin.json +41 -0
- package/plugins/codex-hud/skills/codex-hud/SKILL.md +153 -0
- package/skills/codex-hud/SKILL.md +153 -0
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
# Productized Native Bundle Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** Package Codex HUD as a complete product that can install the HUD CLI, prepare a patched Codex native adapter, install a reversible `codex` shim, and expose the same workflow through a Codex plugin marketplace.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Keep `codex-hud` as the product entrypoint. Add a native adapter manager that can find/build/use a patched Codex checkout, then wire it through `codex-hud install`, `codex-hud doctor`, and the existing shim/native commands. Keep the patched Codex source separate from the npm package, but make its installation automatic and invisible to users.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** TypeScript ESM CLI, Node.js child process/file APIs, npm package scripts, Codex plugin manifest/marketplace JSON, patched OpenAI Codex Rust source in a sibling checkout.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
### Task 1: Add Product Install Command
|
|
14
|
+
|
|
15
|
+
**Files:**
|
|
16
|
+
- Modify: `src/cli.ts`
|
|
17
|
+
- Create: `src/installer.ts`
|
|
18
|
+
- Test: `tests/installer.test.js`
|
|
19
|
+
- Modify: `tests/cli.test.js`
|
|
20
|
+
|
|
21
|
+
- [ ] **Step 1: Write failing installer tests**
|
|
22
|
+
|
|
23
|
+
Add tests that assert `parseInstallArgs`, `buildInstallPlan`, and `installProduct` support dry-run and explicit paths.
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import { test } from "node:test";
|
|
27
|
+
import assert from "node:assert/strict";
|
|
28
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
29
|
+
import path from "node:path";
|
|
30
|
+
import { tmpdir } from "node:os";
|
|
31
|
+
import {
|
|
32
|
+
buildInstallPlan,
|
|
33
|
+
parseInstallArgs,
|
|
34
|
+
} from "../dist/installer.js";
|
|
35
|
+
|
|
36
|
+
test("parseInstallArgs supports dry-run and explicit native source", () => {
|
|
37
|
+
const parsed = parseInstallArgs([
|
|
38
|
+
"--dry-run",
|
|
39
|
+
"--codex-source",
|
|
40
|
+
"/tmp/openai-codex",
|
|
41
|
+
"--bin-dir",
|
|
42
|
+
"/tmp/bin",
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
assert.equal(parsed.dryRun, true);
|
|
46
|
+
assert.equal(parsed.codexSource, "/tmp/openai-codex");
|
|
47
|
+
assert.equal(parsed.binDir, "/tmp/bin");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("buildInstallPlan points at patched Codex binary and shim destination", () => {
|
|
51
|
+
const plan = buildInstallPlan({
|
|
52
|
+
codexSource: "/tmp/openai-codex",
|
|
53
|
+
binDir: "/tmp/bin",
|
|
54
|
+
dryRun: true,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
assert.equal(plan.codexSource, "/tmp/openai-codex");
|
|
58
|
+
assert.equal(plan.codexBinary, "/tmp/openai-codex/codex-rs/target/debug/codex");
|
|
59
|
+
assert.equal(plan.shimPath, "/tmp/bin/codex");
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- [ ] **Step 2: Run test and verify it fails**
|
|
64
|
+
|
|
65
|
+
Run:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm test
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Expected: FAIL because `dist/installer.js` does not exist.
|
|
72
|
+
|
|
73
|
+
- [ ] **Step 3: Implement minimal installer module**
|
|
74
|
+
|
|
75
|
+
Create `src/installer.ts` with these exports:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
import os from "node:os";
|
|
79
|
+
import path from "node:path";
|
|
80
|
+
import { spawn } from "node:child_process";
|
|
81
|
+
import { installCodexShim, defaultShimBinDir } from "./native-runner.js";
|
|
82
|
+
|
|
83
|
+
export interface ProductInstallOptions {
|
|
84
|
+
dryRun: boolean;
|
|
85
|
+
codexSource?: string;
|
|
86
|
+
binDir?: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ProductInstallPlan {
|
|
90
|
+
codexSource: string;
|
|
91
|
+
codexBinary: string;
|
|
92
|
+
shimPath: string;
|
|
93
|
+
commands: string[][];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function parseInstallArgs(args: string[]): ProductInstallOptions {
|
|
97
|
+
let dryRun = false;
|
|
98
|
+
let codexSource: string | undefined;
|
|
99
|
+
let binDir: string | undefined;
|
|
100
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
101
|
+
const arg = args[index];
|
|
102
|
+
if (arg === "--dry-run") dryRun = true;
|
|
103
|
+
if (arg === "--codex-source" && args[index + 1]) codexSource = args[++index];
|
|
104
|
+
if (arg === "--bin-dir" && args[index + 1]) binDir = args[++index];
|
|
105
|
+
}
|
|
106
|
+
return { dryRun, codexSource, binDir };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function defaultCodexSource(): string {
|
|
110
|
+
return path.join(os.homedir(), ".codex-hud", "native", "openai-codex");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function buildInstallPlan(options: ProductInstallOptions): ProductInstallPlan {
|
|
114
|
+
const codexSource = options.codexSource ?? defaultCodexSource();
|
|
115
|
+
const codexBinary = path.join(codexSource, "codex-rs", "target", "debug", "codex");
|
|
116
|
+
const binDir = options.binDir ?? defaultShimBinDir();
|
|
117
|
+
return {
|
|
118
|
+
codexSource,
|
|
119
|
+
codexBinary,
|
|
120
|
+
shimPath: path.join(binDir, "codex"),
|
|
121
|
+
commands: [
|
|
122
|
+
["git", "clone", "--depth", "1", "--branch", "rust-v0.131.0", "https://github.com/openai/codex.git", codexSource],
|
|
123
|
+
["cargo", "build", "-p", "codex-cli"],
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- [ ] **Step 4: Wire `codex-hud install` into CLI**
|
|
130
|
+
|
|
131
|
+
Modify `src/cli.ts`:
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
import { installProduct, parseInstallArgs } from "./installer.js";
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Add help text:
|
|
138
|
+
|
|
139
|
+
```text
|
|
140
|
+
codex-hud install Prepare native Codex HUD integration
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Add command branch:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
if (command === "install") {
|
|
147
|
+
return await installProduct(parseInstallArgs(argv.slice(1)));
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
- [ ] **Step 5: Run tests**
|
|
152
|
+
|
|
153
|
+
Run:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
npm test
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Expected: PASS for new installer tests and existing suite.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
### Task 2: Make Native Adapter Patch Reproducible
|
|
164
|
+
|
|
165
|
+
**Files:**
|
|
166
|
+
- Create: `patches/codex-cli-command-statusline.patch`
|
|
167
|
+
- Modify: `src/installer.ts`
|
|
168
|
+
- Test: `tests/installer.test.js`
|
|
169
|
+
- Modify: `docs/native-codex-cli-patch.md`
|
|
170
|
+
|
|
171
|
+
- [ ] **Step 1: Write failing test for patch command sequence**
|
|
172
|
+
|
|
173
|
+
Add:
|
|
174
|
+
|
|
175
|
+
```js
|
|
176
|
+
test("buildInstallPlan applies bundled Codex patch before building", () => {
|
|
177
|
+
const plan = buildInstallPlan({
|
|
178
|
+
codexSource: "/tmp/openai-codex",
|
|
179
|
+
dryRun: true,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
assert.deepEqual(plan.commands[1], ["git", "apply", "patches/codex-cli-command-statusline.patch"]);
|
|
183
|
+
assert.deepEqual(plan.commands[2], ["cargo", "build", "-p", "codex-cli"]);
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
- [ ] **Step 2: Run test and verify it fails**
|
|
188
|
+
|
|
189
|
+
Run:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
npm test
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Expected: FAIL because patch command is not in the plan.
|
|
196
|
+
|
|
197
|
+
- [ ] **Step 3: Export current Codex patch**
|
|
198
|
+
|
|
199
|
+
From `/Users/liuyue/Desktop/Github_repos/openai-codex` run:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
git diff -- codex-rs/tui/src/bottom_pane/chat_composer.rs \
|
|
203
|
+
codex-rs/tui/src/bottom_pane/chat_composer/footer_state.rs \
|
|
204
|
+
codex-rs/tui/src/bottom_pane/footer.rs \
|
|
205
|
+
codex-rs/tui/src/bottom_pane/mod.rs \
|
|
206
|
+
codex-rs/tui/src/chatwidget/status_controls.rs \
|
|
207
|
+
codex-rs/tui/src/chatwidget/status_surfaces.rs \
|
|
208
|
+
> /Users/liuyue/Desktop/Github_repos/codex-hud/patches/codex-cli-command-statusline.patch
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
- [ ] **Step 4: Update install plan to apply patch**
|
|
212
|
+
|
|
213
|
+
Modify `buildInstallPlan()` command list:
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
commands: [
|
|
217
|
+
["git", "clone", "--depth", "1", "--branch", "rust-v0.131.0", "https://github.com/openai/codex.git", codexSource],
|
|
218
|
+
["git", "apply", "patches/codex-cli-command-statusline.patch"],
|
|
219
|
+
["cargo", "build", "-p", "codex-cli"],
|
|
220
|
+
],
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
- [ ] **Step 5: Run tests**
|
|
224
|
+
|
|
225
|
+
Run:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
npm test
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Expected: PASS.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
### Task 3: Product Doctor Checks
|
|
236
|
+
|
|
237
|
+
**Files:**
|
|
238
|
+
- Modify: `src/sources/codex.ts`
|
|
239
|
+
- Modify: `src/cli.ts`
|
|
240
|
+
- Test: `tests/doctor.test.js`
|
|
241
|
+
|
|
242
|
+
- [ ] **Step 1: Write failing doctor tests**
|
|
243
|
+
|
|
244
|
+
Add tests that expect doctor output to mention:
|
|
245
|
+
|
|
246
|
+
```text
|
|
247
|
+
codex-hud binary
|
|
248
|
+
codex shim
|
|
249
|
+
patched Codex
|
|
250
|
+
native status command
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
- [ ] **Step 2: Run test and verify it fails**
|
|
254
|
+
|
|
255
|
+
Run:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
npm test
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Expected: FAIL because doctor only checks Codex/Node readiness today.
|
|
262
|
+
|
|
263
|
+
- [ ] **Step 3: Extend doctor report**
|
|
264
|
+
|
|
265
|
+
Add checks for:
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
which codex-hud
|
|
269
|
+
which codex
|
|
270
|
+
~/.local/bin/codex contains "codex-hud shim"
|
|
271
|
+
resolved patched Codex path exists
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Doctor should emit actionable lines:
|
|
275
|
+
|
|
276
|
+
```text
|
|
277
|
+
✓ codex-hud binary found
|
|
278
|
+
✓ codex shim installed at ~/.local/bin/codex
|
|
279
|
+
✓ patched Codex found at ...
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
- [ ] **Step 4: Run tests**
|
|
283
|
+
|
|
284
|
+
Run:
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
npm test
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Expected: PASS.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
### Task 4: Marketplace Packaging
|
|
295
|
+
|
|
296
|
+
**Files:**
|
|
297
|
+
- Create/modify: `plugins/codex-hud/.codex-plugin/plugin.json`
|
|
298
|
+
- Create/modify: `plugins/codex-hud/skills/codex-hud/SKILL.md`
|
|
299
|
+
- Modify: `.agents/plugins/marketplace.json`
|
|
300
|
+
- Test: plugin validation command
|
|
301
|
+
|
|
302
|
+
- [ ] **Step 1: Create distributable plugin folder**
|
|
303
|
+
|
|
304
|
+
Copy the plugin wrapper into `plugins/codex-hud` so the marketplace source path is real:
|
|
305
|
+
|
|
306
|
+
```text
|
|
307
|
+
plugins/codex-hud/.codex-plugin/plugin.json
|
|
308
|
+
plugins/codex-hud/skills/codex-hud/SKILL.md
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
- [ ] **Step 2: Update marketplace source**
|
|
312
|
+
|
|
313
|
+
Ensure `.agents/plugins/marketplace.json` points to:
|
|
314
|
+
|
|
315
|
+
```json
|
|
316
|
+
{
|
|
317
|
+
"name": "codex-hud",
|
|
318
|
+
"source": {
|
|
319
|
+
"source": "local",
|
|
320
|
+
"path": "./plugins/codex-hud"
|
|
321
|
+
},
|
|
322
|
+
"policy": {
|
|
323
|
+
"installation": "AVAILABLE",
|
|
324
|
+
"authentication": "ON_INSTALL"
|
|
325
|
+
},
|
|
326
|
+
"category": "Engineering"
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
- [ ] **Step 3: Validate plugin**
|
|
331
|
+
|
|
332
|
+
Run:
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
python3 /Users/liuyue/.codex/skills/.system/plugin-creator/scripts/validate_plugin.py plugins/codex-hud
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Expected: validation succeeds.
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
### Task 5: Release Readiness
|
|
343
|
+
|
|
344
|
+
**Files:**
|
|
345
|
+
- Modify: `package.json`
|
|
346
|
+
- Create: `docs/installation.md`
|
|
347
|
+
- Create: `docs/plugin-marketplace.md`
|
|
348
|
+
- Create: `docs/release.md`
|
|
349
|
+
- Create: `CHANGELOG.md`
|
|
350
|
+
- Create: `LICENSE` if missing
|
|
351
|
+
|
|
352
|
+
- [ ] **Step 1: Add package scripts**
|
|
353
|
+
|
|
354
|
+
Modify `package.json`:
|
|
355
|
+
|
|
356
|
+
```json
|
|
357
|
+
{
|
|
358
|
+
"scripts": {
|
|
359
|
+
"build": "tsc",
|
|
360
|
+
"test": "npm run build && node --test",
|
|
361
|
+
"prepack": "npm run build",
|
|
362
|
+
"pack:check": "npm test && npm pack --dry-run"
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
- [ ] **Step 2: Add installation docs**
|
|
368
|
+
|
|
369
|
+
Create `docs/installation.md` with:
|
|
370
|
+
|
|
371
|
+
```markdown
|
|
372
|
+
# Installation
|
|
373
|
+
|
|
374
|
+
## Recommended
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
npm install -g codex-hud
|
|
378
|
+
codex-hud install
|
|
379
|
+
codex
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
## Fallback without native adapter
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
codex-hud run
|
|
386
|
+
```
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
- [ ] **Step 3: Add plugin marketplace docs**
|
|
390
|
+
|
|
391
|
+
Create `docs/plugin-marketplace.md` with:
|
|
392
|
+
|
|
393
|
+
```markdown
|
|
394
|
+
# Codex Plugin Marketplace
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
codex plugin marketplace add owner/codex-hud --ref main
|
|
398
|
+
codex plugin add codex-hud@codex-hud-marketplace
|
|
399
|
+
```
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
- [ ] **Step 4: Add release docs**
|
|
403
|
+
|
|
404
|
+
Create `docs/release.md` with:
|
|
405
|
+
|
|
406
|
+
```markdown
|
|
407
|
+
# Release
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
npm run pack:check
|
|
411
|
+
npm publish --access public
|
|
412
|
+
```
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
- [ ] **Step 5: Run release checks**
|
|
416
|
+
|
|
417
|
+
Run:
|
|
418
|
+
|
|
419
|
+
```bash
|
|
420
|
+
npm run pack:check
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
Expected: tests pass and npm dry-run includes `dist/`, docs, plugin files, and patches.
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
### Self-Review
|
|
428
|
+
|
|
429
|
+
- Spec coverage: The plan covers unified install, native adapter patch reproduction, shim, plugin marketplace, docs, and release checks.
|
|
430
|
+
- Placeholder scan: No unresolved placeholders are present in command behavior. Repository owner in marketplace docs must be replaced with the final GitHub owner before publishing.
|
|
431
|
+
- Type consistency: Installer uses `ProductInstallOptions`, `ProductInstallPlan`, `installCodexShim`, and `defaultShimBinDir` consistently.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Codex HUD Design
|
|
2
|
+
|
|
3
|
+
Date: 2026-05-23
|
|
4
|
+
Status: Draft approved for implementation planning
|
|
5
|
+
|
|
6
|
+
## Goal
|
|
7
|
+
|
|
8
|
+
Codex HUD is a Codex CLI-first terminal telemetry layer inspired by Claude HUD. It should give users an at-a-glance view of the current Codex working session: model, reasoning effort, project path, git state, context usage, usage windows when available, task progress, tool activity, and session signals.
|
|
9
|
+
|
|
10
|
+
The first version will use a standalone CLI as the core runtime and a Codex plugin wrapper for packaging, setup guidance, and future integration. This avoids blocking the project on a Claude-style command-backed statusline API that Codex CLI does not currently expose as a stable public surface.
|
|
11
|
+
|
|
12
|
+
## Non-Goals
|
|
13
|
+
|
|
14
|
+
- Do not patch or fork Codex CLI.
|
|
15
|
+
- Do not assume Codex has the same `statusLine.command` stdin/stdout contract as Claude Code.
|
|
16
|
+
- Do not require tmux, shell prompt integration, or Codex Desktop for the MVP.
|
|
17
|
+
- Do not collect or upload session content.
|
|
18
|
+
- Do not parse private message bodies beyond the metadata needed for HUD signals.
|
|
19
|
+
|
|
20
|
+
## Product Shape
|
|
21
|
+
|
|
22
|
+
The core package exposes a command named `codex-hud`.
|
|
23
|
+
|
|
24
|
+
Initial commands:
|
|
25
|
+
|
|
26
|
+
- `codex-hud status`: render one HUD snapshot and exit.
|
|
27
|
+
- `codex-hud watch`: continuously render HUD snapshots on an interval.
|
|
28
|
+
- `codex-hud doctor`: inspect runtime readiness and print actionable diagnostics.
|
|
29
|
+
- `codex-hud config`: show or initialize user configuration.
|
|
30
|
+
|
|
31
|
+
The Codex plugin wrapper provides:
|
|
32
|
+
|
|
33
|
+
- `.codex-plugin/plugin.json` with project metadata.
|
|
34
|
+
- A skill or command-oriented instructions for setup and diagnostics.
|
|
35
|
+
- Documentation for using the CLI directly today.
|
|
36
|
+
- A future path to native Codex statusline integration if Codex adds a command-backed statusline provider.
|
|
37
|
+
|
|
38
|
+
## MVP Display
|
|
39
|
+
|
|
40
|
+
Default compact output:
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
[gpt-5.5 medium] | codex-hud git:(main*) | Context 42% | 5h 68% | Todos 2/5 | Bash/Edit active
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Expanded output may split details across semantic lines:
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
[gpt-5.5 medium] | codex-hud git:(main*)
|
|
50
|
+
Context ████░░░░░░ 42% | Usage ██████░░░░ 68%
|
|
51
|
+
Tools Bash active | Edit x2 | Read x4
|
|
52
|
+
Todos 2/5 | Build CLI scaffold
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
When a signal is unavailable, the renderer should omit it or show a clear low-noise fallback. The HUD should not imply precision where Codex does not expose reliable data.
|
|
56
|
+
|
|
57
|
+
## Data Sources
|
|
58
|
+
|
|
59
|
+
The data layer normalizes signals from multiple sources into one internal `HudSnapshot`.
|
|
60
|
+
|
|
61
|
+
Primary sources for the MVP:
|
|
62
|
+
|
|
63
|
+
- Current working directory passed by process cwd.
|
|
64
|
+
- Git state from local `git` commands.
|
|
65
|
+
- Codex config from `$CODEX_HOME/config.toml` or `~/.codex/config.toml`.
|
|
66
|
+
- Codex version from `codex --version`.
|
|
67
|
+
- Feature flags from `codex features list` when available.
|
|
68
|
+
- Session files under `$CODEX_HOME/sessions` or `~/.codex/sessions` when discoverable.
|
|
69
|
+
|
|
70
|
+
Optional and best-effort sources:
|
|
71
|
+
|
|
72
|
+
- Recent session JSONL metadata for tool activity, tasks, model, reasoning effort, and context signals.
|
|
73
|
+
- Local usage or limit data if Codex exposes it in config, session logs, or a future statusline payload.
|
|
74
|
+
- Stdin JSON adapter for future Codex statusline support.
|
|
75
|
+
|
|
76
|
+
The reader modules should be defensive. Missing files, unknown schemas, malformed JSONL lines, or unavailable Codex commands must degrade gracefully.
|
|
77
|
+
|
|
78
|
+
## Architecture
|
|
79
|
+
|
|
80
|
+
The CLI is organized into small units:
|
|
81
|
+
|
|
82
|
+
- `cli`: argument parsing, command dispatch, exit codes.
|
|
83
|
+
- `sources`: filesystem, Codex config, Codex sessions, git, Codex command probes.
|
|
84
|
+
- `adapters`: convert raw data into normalized HUD state.
|
|
85
|
+
- `render`: compact and expanded terminal output, colors, width handling.
|
|
86
|
+
- `config`: user config loading, defaults, validation.
|
|
87
|
+
- `doctor`: environment checks and actionable diagnostics.
|
|
88
|
+
|
|
89
|
+
The normalized state is the main boundary:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
interface HudSnapshot {
|
|
93
|
+
model?: string;
|
|
94
|
+
reasoningEffort?: string;
|
|
95
|
+
cwd: string;
|
|
96
|
+
projectName: string;
|
|
97
|
+
git?: GitSnapshot;
|
|
98
|
+
context?: ProgressSnapshot;
|
|
99
|
+
usage?: UsageSnapshot;
|
|
100
|
+
tools: ToolActivity[];
|
|
101
|
+
todos: TodoSnapshot;
|
|
102
|
+
session?: SessionSnapshot;
|
|
103
|
+
warnings: HudWarning[];
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Renderers must depend on `HudSnapshot`, not on raw Codex files. This keeps future statusline stdin support local to a new adapter.
|
|
108
|
+
|
|
109
|
+
## Configuration
|
|
110
|
+
|
|
111
|
+
Default config location:
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
~/.codex-hud/config.json
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The first version supports:
|
|
118
|
+
|
|
119
|
+
- `layout`: `compact` or `expanded`.
|
|
120
|
+
- `refreshIntervalMs`: watch interval.
|
|
121
|
+
- `pathLevels`: number of cwd path segments to show.
|
|
122
|
+
- `display`: booleans for model, git, context, usage, tools, todos, session.
|
|
123
|
+
- `colors`: simple named colors and bar characters.
|
|
124
|
+
- `codexHome`: optional override for `$CODEX_HOME`.
|
|
125
|
+
|
|
126
|
+
Advanced config should be validated and merged with defaults, not trusted directly.
|
|
127
|
+
|
|
128
|
+
## Error Handling
|
|
129
|
+
|
|
130
|
+
The HUD should never crash the user terminal for ordinary missing data. It should:
|
|
131
|
+
|
|
132
|
+
- Exit non-zero only for invalid CLI arguments or explicit `doctor` failures.
|
|
133
|
+
- Print a minimal fallback status if optional sources fail.
|
|
134
|
+
- Keep debug details behind an environment flag such as `CODEX_HUD_DEBUG=1`.
|
|
135
|
+
- Avoid leaking full transcript content in errors.
|
|
136
|
+
|
|
137
|
+
## Testing
|
|
138
|
+
|
|
139
|
+
Core tests should use fixtures and not require live Codex sessions.
|
|
140
|
+
|
|
141
|
+
Initial test coverage:
|
|
142
|
+
|
|
143
|
+
- Config loading and validation.
|
|
144
|
+
- Git parser behavior for clean, dirty, detached, and non-git directories.
|
|
145
|
+
- JSONL session parsing with malformed-line tolerance.
|
|
146
|
+
- Renderer output for compact and expanded layouts.
|
|
147
|
+
- Doctor checks with mocked command availability.
|
|
148
|
+
|
|
149
|
+
Manual verification:
|
|
150
|
+
|
|
151
|
+
- `codex-hud doctor` in this repository.
|
|
152
|
+
- `codex-hud status` in a git repo and a non-git directory.
|
|
153
|
+
- `codex-hud watch` with a short interval and interrupt handling.
|
|
154
|
+
|
|
155
|
+
## Implementation Phases
|
|
156
|
+
|
|
157
|
+
Phase 1: CLI skeleton and config.
|
|
158
|
+
|
|
159
|
+
- Create TypeScript package.
|
|
160
|
+
- Add command parser.
|
|
161
|
+
- Add config defaults and validation.
|
|
162
|
+
- Add compact renderer with static and cwd/git data.
|
|
163
|
+
|
|
164
|
+
Phase 2: Codex-aware sources.
|
|
165
|
+
|
|
166
|
+
- Add Codex CLI detection.
|
|
167
|
+
- Read Codex config and version.
|
|
168
|
+
- Discover recent session files.
|
|
169
|
+
- Parse safe metadata from session JSONL fixtures.
|
|
170
|
+
|
|
171
|
+
Phase 3: Plugin wrapper.
|
|
172
|
+
|
|
173
|
+
- Add `.codex-plugin/plugin.json`.
|
|
174
|
+
- Add setup and diagnostic instructions.
|
|
175
|
+
- Document direct CLI, watch mode, and future statusline integration.
|
|
176
|
+
|
|
177
|
+
Phase 4: polish and packaging.
|
|
178
|
+
|
|
179
|
+
- Add tests, CI-ready scripts, README, examples, and release notes.
|
|
180
|
+
- Revisit native statusline integration if Codex exposes a stable command-backed API.
|
|
181
|
+
|
|
182
|
+
## Open Risks
|
|
183
|
+
|
|
184
|
+
- Codex session JSONL schema may change and may differ across CLI, Desktop, and cloud-backed flows.
|
|
185
|
+
- Codex CLI currently appears to lack a stable public command-backed statusline API like Claude Code.
|
|
186
|
+
- Usage limits and precise context percentages may not be available from stable local sources.
|
|
187
|
+
- Plugin-scoped lifecycle hooks and UI customization may be limited by Codex plugin runtime behavior.
|
|
188
|
+
|
|
189
|
+
## Acceptance Criteria
|
|
190
|
+
|
|
191
|
+
The MVP is acceptable when:
|
|
192
|
+
|
|
193
|
+
- `codex-hud status` prints a useful one-shot HUD in this repository.
|
|
194
|
+
- `codex-hud watch` refreshes without corrupting the terminal and exits cleanly on Ctrl-C.
|
|
195
|
+
- `codex-hud doctor` explains missing optional capabilities clearly.
|
|
196
|
+
- The package includes a Codex plugin manifest and user-facing setup docs.
|
|
197
|
+
- Tests cover config, rendering, git state, and session parsing fixtures.
|