Expand description
OpenCode HarnessAdapter — Rust port of packages/cli/src/harnesses/opencode.ts.
OpenCode shares the pending-stamp + watch-loop shape with codex, so the
adapter is constructed via super::pending_stamp::adapter_static
instead of re-implementing the trait. The only opencode-specific bits are:
name = "opencode"— the dispatch key and log-line label.session_root—$HOME/.local/share/opencode/storage/session, resolved lazily so tests that override$HOMEsee the override. Mirrors the TS sibling’spath.join(homedir(), '.local', 'share', 'opencode', 'storage', 'session')exactly.ingest_sessions— opens a fresh ledger handle and runsrelayburn_sdk::ingest_opencode_sessions(the opencode-only ingest pass). The TS sibling callsingestOpencodeSessions()directly here; the Rust SDK function takes&mut Ledger, so the closure opens a handle each call. That mirrors the TS lock-then-write-then-close shape, and the per-tick open is cheap (SQLite WAL, no DDL after first open).
The factory’s super::pending_stamp::adapter_static does the
Box::leak so the registry can store the result as
&'static dyn HarnessAdapter. See the factory module for the leak
rationale (codex/opencode are the only two callers; runtime cost is
a few dozen bytes per process).
Functions§
- adapter
- Convenience: hand out a
&'static dyn HarnessAdapterfor the opencode adapter. The registry calls this once at lazy-init time. Seepending_stamp::adapter_staticfor the leak semantics — opencode is one of two callers and the leaked footprint is bytes, not megabytes. - config
- Build the
PendingStampAdapterconfig for opencode. Exposed as a constructor function (rather than astatic) because the closure captures and theArc<dyn Fn>s inside don’t fit a const initializer. The registry calls this once and feeds the result topending_stamp::adapter_static.