Documentation
¶
Overview ¶
Package opencodev2 converts an OpenCode 2 session export to the OpenCode 1 shape every reader of OpenCode sessions takes: the transcript library's Convert and OpenCode adapter, and the CLI's OpenCode agent. It imports only the standard library (the library's dependency guard).
Index ¶
Constants ¶
const NativeKey = "opencode2"
NativeKey is the message info key that keeps the OpenCode 2 messages a converted message came from, verbatim. Every reader ignores it; the CLI's OpenCode resume uses it to give OpenCode 2 back the exact session it exported, which the 1.x shape alone cannot reproduce.
Variables ¶
This section is empty.
Functions ¶
func IsExport ¶
IsExport reports whether data is an OpenCode 2 export: its messages carry a top-level "type" rather than an "info" object. An export is written by one OpenCode version, so the first message decides; it is read with a streaming decoder, so a 1.x export (every stored transcript) costs one message's decode, not the whole file's. An export with no messages is the same in both versions.
func Normalize ¶
Normalize converts an OpenCode 2 export to the OpenCode 1 shape and returns other payloads unchanged. The conversion is deterministic, so re-exporting the same session yields the same message indices; transcript offsets stored between turns depend on that.
Each converted message carries its source messages under info[NativeKey]: the 2.x message itself, plus any that convert to nothing (idle markers, kinds this version does not know) after it. Both messages of a converted compaction carry the key, the summary with none.
Types ¶
This section is empty.