opencodev2

package
v0.13.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func IsExport(data []byte) bool

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

func Normalize(data []byte) ([]byte, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL