Skip to main content

Module opencode

Module opencode 

Source
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 $HOME see the override. Mirrors the TS sibling’s path.join(homedir(), '.local', 'share', 'opencode', 'storage', 'session') exactly.
  • ingest_sessions — opens a fresh ledger handle and runs relayburn_sdk::ingest_opencode_sessions (the opencode-only ingest pass). The TS sibling calls ingestOpencodeSessions() 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 HarnessAdapter for the opencode adapter. The registry calls this once at lazy-init time. See pending_stamp::adapter_static for the leak semantics — opencode is one of two callers and the leaked footprint is bytes, not megabytes.
config
Build the PendingStampAdapter config for opencode. Exposed as a constructor function (rather than a static) because the closure captures and the Arc<dyn Fn>s inside don’t fit a const initializer. The registry calls this once and feeds the result to pending_stamp::adapter_static.