glassbox-trace 0.3.0 → 0.4.1
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 +32 -13
- package/dist/glassbox.html +380 -25
- package/package.json +5 -2
- package/src/cli.mjs +83 -15
- package/src/tail.mjs +141 -0
- package/src/trace-core.js +217 -9
- package/src/viewer.html +163 -16
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/aldohushi1-stack/glassbox/actions/workflows/ci.yml)
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**Other tools show you what happened in a Claude Code session. Glassbox tells you what went wrong.**
|
|
6
6
|
|
|
7
|
-
Drop a session `.jsonl` onto one HTML file. Get a timeline of every model call and tool call, where the tokens and money went, and a list of things a reviewer would flag — retry loops, failing tools, oversized results, context bloat, stalls. Nothing leaves your
|
|
7
|
+
Drop a session `.jsonl` onto one HTML file. Get a timeline of every model call and tool call, where the tokens and money went, and a list of things a reviewer would flag — retry loops, failing tools, oversized results, context bloat, stalls — each with the evidence and one line on what to do differently. Compare two sessions side by side. Watch one live while Claude Code writes it. Hand the findings back to the agent. Nothing leaves your machine.
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
@@ -27,12 +27,24 @@ glassbox list --grep "npm test" only sessions containing the text
|
|
|
27
27
|
glassbox open 81c4 open a session by id prefix (or a .jsonl path)
|
|
28
28
|
glassbox open 81c4 --out trace.html write a self-contained HTML you can send to someone
|
|
29
29
|
glassbox check print findings; exit 1 on any error-level finding
|
|
30
|
-
glassbox check --
|
|
30
|
+
glassbox check --format md the findings as Markdown written for the agent: evidence + what to do next time
|
|
31
|
+
glassbox check --fail-on warn --format json stricter, machine-readable (CI, hooks, agents); add --redact before sharing
|
|
32
|
+
glassbox compare 81c4 9f0a same task, two sessions: time, tokens, cost, tools and findings side by side
|
|
33
|
+
glassbox compare 81c4 9f0a --out cmp.html …as one HTML with both sessions in it
|
|
34
|
+
glassbox watch live tail: the viewer follows the newest session as Claude Code writes it
|
|
31
35
|
```
|
|
32
36
|
|
|
33
37
|
The npm package is `glassbox-trace` (plain `glassbox` was already taken); the command it installs is `glassbox`. Subagent transcripts next to the session are included automatically. `GLASSBOX_HOME` overrides `~/.claude`; `GLASSBOX_BROWSER` names the command used to open HTML.
|
|
34
38
|
|
|
35
|
-
**
|
|
39
|
+
**In CI:** exit 0 clean, 1 on findings at/above `--fail-on`, 2 on a usage error; `--format json` carries `glassbox` (version) and `schema`; `--redact` blanks prompt text, tool inputs and quoted output. A GitHub Actions example for Agent SDK runs is in [docs/CI.md](docs/CI.md).
|
|
40
|
+
|
|
41
|
+
**Feed it back to Claude.** `glassbox check --format md` prints the findings the way an agent needs them: each one with the concrete tool calls and request numbers it is about, and a fixed "next time" line per rule. Paste it into the next session ("here's what went wrong last time"), pipe it into a file, or let the Stop hook below deliver it automatically.
|
|
42
|
+
|
|
43
|
+
**Compare two sessions.** `glassbox compare A B` (or **Compare…** in the viewer) lines up the same task done twice: wall and active time, requests, tool calls and errors, context served, peak prompt, cache hit, output, cost, findings — each with the change and who did better — plus tool use side by side and the findings that appear in only one of them. Handy for "did the new CLAUDE.md help?", "Sonnet vs Opus on this job", or "before and after I fixed that hook".
|
|
44
|
+
|
|
45
|
+
**Watch a session live.** `glassbox watch` serves the viewer from `127.0.0.1` and streams the transcript to it as it grows — new tool calls land on the timeline within a second, tiles and findings update, **Follow** keeps the right edge on now (pan or zoom and it lets go). Loopback only; nothing leaves the machine.
|
|
46
|
+
|
|
47
|
+
**Let the agent read its own recorder.** `glassbox hook install` adds a Claude Code Stop hook: every session ends with a one-screen Glassbox summary (turns, tool calls, context peak, cost, top findings). Add `--feedback` and the findings — with their evidence and the "next time" advice — are handed back to the agent once; it reads them and says, in a sentence, what it would do differently. It never loops (`stop_hook_active` is respected), never blocks a clean session, and `glassbox hook uninstall` removes it, with a `.glassbox-backup` of `settings.json` kept.
|
|
36
48
|
|
|
37
49
|
```
|
|
38
50
|
glassbox hook install --feedback --fail-on warn # summary + one-shot feedback to the agent
|
|
@@ -40,13 +52,13 @@ glassbox hook install # summary only
|
|
|
40
52
|
glassbox hook uninstall
|
|
41
53
|
```
|
|
42
54
|
|
|
43
|
-
**In the browser:** open `dist/glassbox.html` (double-click, no server). It shows the demo session at rest. Then either drop your `.jsonl` (or the whole `<session-id>` folder for subagent lanes), or in Chrome/Edge click **Open folder…**, pick `~/.claude/projects`, and choose a session from the list — the folder is remembered, so next time it's **Recent**. Finding the file by hand: `ls -t ~/.claude/projects/*/*.jsonl | head` on macOS/Linux, `%USERPROFILE%\.claude\projects\` on Windows.
|
|
55
|
+
**In the browser:** the viewer is one HTML file — open `dist/glassbox.html` (double-click, no server; the CLI, compare-from-terminal and live tail need Node 18+). It shows the demo session at rest. Then either drop your `.jsonl` (or the whole `<session-id>` folder for subagent lanes), or in Chrome/Edge click **Open folder…**, pick `~/.claude/projects`, and choose a session from the list — the folder is remembered, so next time it's **Recent**. Finding the file by hand: `ls -t ~/.claude/projects/*/*.jsonl | head` on macOS/Linux, `%USERPROFILE%\.claude\projects\` on Windows.
|
|
44
56
|
|
|
45
57
|
Read top to bottom: stats → timeline (with minimap, search, fit-to-turn) → context & cost → findings → tools → turns. Click anything for detail. Every selection is a permalink (`#req=17`, `#tool=…`, `#find=3`, `#turn=2`).
|
|
46
58
|
|
|
47
59
|
**Keyboard:** `Tab` into the timeline, `←`/`→` previous/next call, `↑`/`↓` change lane, `Enter` opens detail, `Esc` closes it; `+` `−` `0` zoom, `Shift+←/→` pan, `/` search, `?` help. Touch: drag to pan, pinch to zoom.
|
|
48
60
|
|
|
49
|
-
**Findings → Copy / Copy all / Export report** give you Markdown to paste into an issue or back into the agent
|
|
61
|
+
**Findings → Copy / Copy all / Export report** give you Markdown to paste into an issue or back into the agent — the exported report is the same agent-ready format as `check --format md`. **Compare…** loads a second session next to this one; **Swap** puts it on the timeline.
|
|
50
62
|
|
|
51
63
|
**Share mode** blanks every prompt, tool input, result and assistant text in the view; **Export redacted** downloads a structure-only `.jsonl` that keeps timestamps, usage and tool names — safe to post publicly.
|
|
52
64
|
|
|
@@ -70,7 +82,7 @@ Read top to bottom: stats → timeline (with minimap, search, fit-to-turn) → c
|
|
|
70
82
|
| `slow-tool` | a tool call ≥ 60 s (warn at 5 min) |
|
|
71
83
|
| `max-tokens`, `api-error`, `hook-error`, `compaction`, `thinking-heavy`, `subagent-share`, `long-turn` | what they say |
|
|
72
84
|
|
|
73
|
-
All mechanical, no AI. Thresholds are in `TraceCore.DEFAULTS` and can be overridden when calling `diagnose(trace, opts)`.
|
|
85
|
+
All mechanical, no AI. Thresholds are in `TraceCore.DEFAULTS` and can be overridden when calling `diagnose(trace, opts)`. Every rule has a one-line "next time" in `TraceCore.ADVICE`, which is what the Markdown report and the Stop hook hand back to the agent.
|
|
74
86
|
|
|
75
87
|
## Token and cost accounting
|
|
76
88
|
|
|
@@ -86,9 +98,9 @@ Claude Code transcripts (main + subagents + `meta.json`), Agent SDK / `claude -p
|
|
|
86
98
|
## Develop
|
|
87
99
|
|
|
88
100
|
```
|
|
89
|
-
npm test # unit tests (node:test) — parser, every diagnostic rule, cost, redaction, CLI, real fixtures
|
|
101
|
+
npm test # unit tests (node:test) — parser, every diagnostic rule, cost, redaction, report, compare, tailer + SSE server, CLI, real fixtures
|
|
90
102
|
npm run build # dist/glassbox.html (standalone) + dist/glassbox.artifact.html (fragment)
|
|
91
|
-
npm run e2e # Playwright: demo in light+dark, tiles vs core, keyboard nav, drawer focus, search, clipboard, permalinks
|
|
103
|
+
npm run e2e # Playwright: demo in light+dark, tiles vs core, keyboard nav, drawer focus, search, clipboard, permalinks, compare, live tail
|
|
92
104
|
npm run audit # axe-core + contrast + keyboard reachability + responsive + 16 MB stress run; fails on regressions
|
|
93
105
|
```
|
|
94
106
|
|
|
@@ -97,24 +109,31 @@ Layout:
|
|
|
97
109
|
```
|
|
98
110
|
src/trace-core.js pure engine: parseTrace · diagnose · estimateCost · redact (no DOM, no deps)
|
|
99
111
|
src/viewer.html the UI; the build inlines trace-core and the demo
|
|
100
|
-
src/cli.mjs CLI library (session discovery, embed, check); bin/glassbox.mjs is the entry point
|
|
112
|
+
src/cli.mjs CLI library (session discovery, embed, check, compare, hook); bin/glassbox.mjs is the entry point
|
|
113
|
+
src/tail.mjs live tail: byte-offset tailer + loopback SSE server for `glassbox watch`
|
|
101
114
|
scripts/build.mjs build
|
|
102
115
|
scripts/sanitize.mjs turn a real transcript into a shareable fixture (demo or structure mode)
|
|
103
116
|
test/ unit, e2e and audit harnesses, fixtures
|
|
104
117
|
DESIGN.md design doc — data model, rules, thresholds, UI, privacy
|
|
105
118
|
STUDY.md accessibility & ease-of-use study that drove v0.2
|
|
119
|
+
STUDY-IMPLEMENTATION.md adoption study (solo dev, Cowork/SDK, CI, feedback loop) that drove v0.4.1
|
|
120
|
+
docs/ CI recipe, feedback-loop study protocol, Community Extensions PR, post copy
|
|
121
|
+
scripts/feedback-study.mjs measures with/without --feedback session groups
|
|
106
122
|
```
|
|
107
123
|
|
|
108
124
|
Use the engine on its own:
|
|
109
125
|
|
|
110
126
|
```js
|
|
111
|
-
const { parseTrace, diagnose, estimateCost } = require('./src/trace-core.js');
|
|
127
|
+
const { parseTrace, diagnose, estimateCost, reportMarkdown, compare } = require('./src/trace-core.js');
|
|
112
128
|
const trace = parseTrace([{ name: 'session.jsonl', text: fs.readFileSync(p, 'utf8') }]);
|
|
113
|
-
|
|
129
|
+
const findings = diagnose(trace), cost = estimateCost(trace);
|
|
130
|
+
console.log(trace.totals, findings, cost.total);
|
|
131
|
+
console.log(reportMarkdown(trace, findings, cost)); // the agent-ready report
|
|
132
|
+
console.log(compare({ trace, findings, cost }, other)); // other = the same three for a second session
|
|
114
133
|
```
|
|
115
134
|
|
|
116
135
|
## Privacy
|
|
117
136
|
|
|
118
|
-
The page makes no network requests except the Google Fonts stylesheet (it falls back to system fonts if that's blocked). Transcripts contain everything the agent saw; that's why share mode exists.
|
|
137
|
+
The page makes no network requests except the Google Fonts stylesheet (it falls back to system fonts if that's blocked). `glassbox watch` binds to `127.0.0.1` only and stops with the command. Transcripts contain everything the agent saw; that's why share mode exists.
|
|
119
138
|
|
|
120
139
|
Source: [github.com/aldohushi1-stack/glassbox](https://github.com/aldohushi1-stack/glassbox) · MIT © Aldo Hushi
|