mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-13 23:52:06 +00:00
Cleanup pass after sub-agent review.
Correctness fixes:
- WebSocket error messages no longer leak unredacted client frames or
URLs into error output. websocket.ts passes `actual` through
`safeText` (drops content with secret-pattern matches; truncates
at 300 chars) and the "no recorded interaction" die message uses
`redactUrl(request.url)`.
- WebSocket replay sendText: compare-then-advance ordering. Previous
code advanced the cursor before the assertion, so a mid-stream
mismatch left the cursor pointing past the failing frame.
- WebSocket record mode now uses `Stream.tap` (pure side-effect)
instead of `Stream.map` for capturing server frames.
API tightening:
- `Cassette.Interface.append` returns `Effect<void, UnsafeCassetteError>`
directly. The `appendOrFail` helper and `AppendResult` type are
gone — the cassette adapter owns the safety contract. Both
`fileSystem` and `memory` adapters fail with `UnsafeCassetteError`
on findings.
- `UnsafeCassetteError` moved from recorder.ts to cassette.ts.
- `ResolvedMode` type alias dropped — inlined the union.
- Mid-file `import { Schema }` in redaction.ts moved to the top.
Tests added (5):
- passthrough mode bypasses recorder + writes nothing
- auto mode records to disk when cassette is missing
- UnsafeCassetteError blocks the request when recording would write
a known secret
- Cassette.list enumerates recorded cassette names
- WebSocket replay decodes binary frames recorded as base64
Docs:
- Audit example in README compiles (was using `entry.name` after
list() shape changed to plain strings).
- Layout table no longer references the deleted `storage.ts`.
- recorder.ts row reflects current contents (resolveAutoMode +
ReplayState; appendOrFail removed).