mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-08-01 20:35:09 +00:00
Unifies the three-file OpenCode decode family — session-message.ts, sqlite-session-parser.ts, and opencode-file-parser.ts — into a single core module, packages/core/src/providers/opencode-session, exposing a two-arm tagged envelope (kind: 'sqlite' | 'file') over one shared assistant-turn builder. The SQLite driver, both WITH RECURSIVE session_tree queries, blobToText, discovery, and extractBashCommands all stay CLI-side. session-message.ts shrinks to the discovery-side sanitize helper; sqlite-session-parser.ts and opencode-file-parser.ts keep their SQL and directory walks and expose readRecords adapters. No decode logic remains CLI-side in any of the three. kilo-code is now fully converted: both arms — cline task dirs via the batch-S1 core vscode-cline module and SQLite via the new module — run through core decodes from one bridged provider, and the thin createClineParser adapter S1 retained is deleted. The CODEBURN_VERBOSE zero-yield notice is reconstructed host-side by zed-style decode wrappers, byte-identical for both the OpenCode and KiloCode labels, with parseFailCount/roleSkipCount derived from the decode's malformed-json / unknown-shape diagnostics. The session-level SQLite fallback is pre-fetched onto the envelope instead of queried lazily — output-neutral, changing only I/O volume — and keeps its distinct key shape, emitting no skills/subagentTypes keys. Validator fixes on top of the migration: - opencode's file arm emitted a spurious SQLite verbose stderr line, reporting a previous SQLite source's session id and message count, because the readRecords -> decode count handoff was never cleared when switching arms. The handoff is now reset on the file path. Pinned by a new regression test. - The S8 and F9 dedup goldens did not actually pin add-after-build: the SQLite fixture used two different message ids, and both file fixtures were degenerate (the CLI one wrote the same filename twice and silently overwrote; the core one shared a text part across both messages, so the "skipped" message built successfully). All four now fail if seenKeys.add is hoisted above the build. - Added key-presence gates to the goldens, since toEqual accepts a present-but-undefined key: the session-level fallback must omit skills/subagentTypes, a message-arm call per arm must carry them, and fallbackCostUSD must be present for cost 0 and absent for an absent cost. Goldens were captured pre-migration and re-verified against the original tree by restoring 38172892's sources in place; all 36 pass on both sides. Pre-existing issues moved verbatim and left alone: the bare-Record tool map with a truthy hit check in normalizeToolName (prototype leak on names like 'constructor'), opencode.ts's duplicated display-only tool map, and the dead inner role guard in the SQLite arm. Every new lookup introduced by the unification is a Map. |
||
|---|---|---|
| .. | ||
| cli | ||
| core | ||