You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR #72 landed strategy D only. Strategy C is explicitly deferred and intentionally lower-priority — it is the only path to per-tool-call grain on OpenCode but is only worth pursuing if a concrete attribution question needs that resolution.
Strategy C — OpenCode server event-stream intercept. Per the issue, only worth pursuing if a concrete attribution question needs finer-than-file grain.
OpenCode has a server mode with an event stream. Subscribing to that would give real per-event parity (tool-call grain, not file grain). Codex has no equivalent surface I'm aware of — the rollout JSONL is the only observation point, and (B) is the ceiling there.
Worth pursuing only if a concrete attribution question (per-tool-call cost, mid-turn retry detection) needs finer grain than (B) provides.
Relevant call sites:
packages/cli/src/commands/opencode.ts — current ingest is post-exit, file-grain only.
The ~/.local/share/opencode/storage/{session,message}/ JSON files are derivative of the live event stream; the stream itself is the higher-fidelity source.
This issue exists primarily as a decision-point tracker: do not implement until at least one of the trigger questions below has a real backlog item attached.
Proposal
When triggered, build a thin client that subscribes to OpenCode's server event stream and feeds events through the same normalized TurnRecord / ContentRecord / appendTurns path the file-grain reader uses, with per-tool-call grain instead of per-message rollups.
Trigger questions (file an explicit dependent issue if any of these become active work):
Per-tool-call cost attribution for OpenCode (e.g. "which Bash invocation in turn N consumed the most input tokens?")
Real-time waste signaling on OpenCode (file-grain doesn't expose it within the same turn)
Sketch (do not build until triggered):
New module packages/reader/src/opencode-stream.ts with a subscribe(opts) function that yields normalized events.
New CLI subcommand burn opencode --stream (or fold into burn watch --opencode-stream) that connects to the local OpenCode server, subscribes, and pipes events to appendTurns / appendContent.
Cursor model needs an event-id high-watermark (not byte offset) since the stream is not file-backed.
Cross-check stream-derived turns against file-derived turns (after wrapper exits) to detect drift; one is canonical, the other is the validator.
Context
PR #72 landed strategy D only. Strategy C is explicitly deferred and intentionally lower-priority — it is the only path to per-tool-call grain on OpenCode but is only worth pursuing if a concrete attribution question needs that resolution.
From PR #72:
From #63:
Relevant call sites:
packages/cli/src/commands/opencode.ts— current ingest is post-exit, file-grain only.packages/reader/src/opencode.ts— file-grain reader; already populatesparentID -> isSidechain.~/.local/share/opencode/storage/{session,message}/JSON files are derivative of the live event stream; the stream itself is the higher-fidelity source.This issue exists primarily as a decision-point tracker: do not implement until at least one of the trigger questions below has a real backlog item attached.
Proposal
When triggered, build a thin client that subscribes to OpenCode's server event stream and feeds events through the same normalized
TurnRecord/ContentRecord/appendTurnspath the file-grain reader uses, with per-tool-call grain instead of per-message rollups.Trigger questions (file an explicit dependent issue if any of these become active work):
Sketch (do not build until triggered):
packages/reader/src/opencode-stream.tswith asubscribe(opts)function that yields normalized events.burn opencode --stream(or fold intoburn watch --opencode-stream) that connects to the local OpenCode server, subscribes, and pipes events toappendTurns/appendContent.Tests (when implemented):
appendTurnsdedup is the safety net).Acceptance criteria
(Apply only when this issue is activated by a triggering question.)
burn opencode --stream(or equivalent) ingests at per-tool-call grain.Out of scope
Refs
burn watch(file-grain incremental ingest, the cheaper baseline)