Skip to content

OpenCode

OpenCode CLI, desktop, and local web sessions use one physical core store. Hansard therefore exposes one canonical import source, opencode, regardless of which OpenCode surface created or displayed a conversation.

Source Use it for
opencode All sessions in the canonical OpenCode data root or an explicit override.

The legacy selectors opencode-cli, opencode-desktop, and opencode-web forward to opencode for command compatibility. They do not identify separate physical stores and cannot narrow an import to one application surface.

Archive provenance records the detected physical source type: opencode-history for the historical JSON store or opencode-sqlite-history for the SQLite store.

Hansard discovers OpenCode beneath its canonical XDG data root, normally $XDG_DATA_HOME/opencode, or beneath an explicitly configured Hansard data or database override. It does not infer extra transcript stores from desktop app state. The importer recognizes nine audited stable format cohorts: four JSON cohorts covering combined messages, embedded v2 parts, project-scoped separate parts, and global separate parts; plus five SQLite cohorts covering the two Go schemas, the TypeScript legacy message/part schema, and both full-message schemas. Each detected cohort is validated before its records are normalized.

JSON imports publish the accepted session, message, part, todo, and session-diff components as one per-session source snapshot. Todo and diff lists are retained under bounded summaries with full-list digests and counts; private session/share and session_share components are bounded but never published, and legacy embedded share secrets are removed before conversion and raw publication. SQLite imports first capture a coherent snapshot that includes committed WAL state, then create a fresh history-only projection that omits credential, account, and share-secret tables. The projection is inspected, converted, and archived for every session found in the database, with the privacy profile recorded in raw provenance. Raw replay reads those archived components or the archived SQLite object without consulting or resnapshotting the live OpenCode store. Text, reasoning, tool calls and results, validated attachments, model routes, usage, workspace metadata, current todos, and linked child-agent relationships remain tied to the physical source that was parsed.

Terminal window
hansard import --source opencode --since all
hansard index rebuild

After the import finishes, open Conversations and selectFilter & sort. Set Source toOpenCode, choose the backfill window underTime, and use Folder when the same harness appears in several projects. Select a result to inspect its messages, tool calls and results, files, commits, model and usage fields, and source provenance in one conversation view.

For a local source that should stay current, open Settings → Indexing & Imports. Automatic follows detected local harnesses; Custom lets Sources scannedselect an explicit set. Explicit cloud and account-export sources do not turn into background network jobs here. If the expected result is absent after resetting the conversation filters, return to the terminal import in this guide and add --explain-skips where supported.

  • Sessions, messages, parts, tool calls and results, model routes, usage, workspace metadata, bounded current todo and file-diff snapshots, and linked agent runs.
  • The privacy-filtered per-session JSON component set or coherent SQLite history projection used for conversion, with enough provenance for offline raw replay.
  • Committed SQLite WAL state captured in the coherent database snapshot.
  • The exact provider route used for each model, including OpenCode Zen, OpenRouter, and custom routes.
  • Route-specific pricing applies only when the source recorded an exact route. OpenRouter and custom routes do not inherit OpenCode Zen pricing.
  • An unknown or malformed record fails the claimed format instead of being silently omitted or interpreted as another cohort.
  • The legacy surface aliases cannot select separate CLI, desktop, or web history because those surfaces share the same physical store.
Terminal window
hansard import --source opencode --since all
hansard index rebuild