Repository navigation
Description
What happened?
OpenCode 2.1 changed its storage layout, its transcript shape and the CLI command that imports a transcript. With OpenCode 2.1.4 the opencode harness no longer reads or writes anything:
-
Discovery finds nothing.
txcript list --from opencodeprintsno local opencode sessions foundagainst a 2.1.4opencode.dbthat holds hundreds of sessions. 2.1 keeps sessions insession_v2and every message as one flat record insession_message (id, session_id, type, seq, time_created, time_updated, data); thesession,messageandparttables txcript queries are gone. -
continue --with opencodefails. The top-levelopencode importcommand no longer exists; it isopencode session import <file> [--directory <dir>]now. txcript'ssaverunsopencode import <staged file>and gets:error: cannot convert to opencode: `opencode import` failed: ERROR Unexpected positional argument: "…\opencode-import-20033d02-ce35-4d65-a630-10f98d7f9be4.json" -
The staged export is rejected by the new importer. Feeding the file txcript left behind to
opencode session importreturns400 Bad Request. The server log shows why:schema rejection … reason="Missing key\n at [\"info\"][\"projectID\"]"and, after adding the header fields the 2.1 schema requires (
projectID,cost,tokens,location.directory):schema rejection … reason="Expected Session.Message.Info\n at [\"messages\"][0]"The 2.1 transfer is
{ info, messages: [ <flat records> ] }: a message is{ id, type: "user" | "assistant" | "shell" | "compaction" | …, time: { created }, … }with an assistant's text, reasoning and tool calls in itscontentarray, and a tool's result inside the call'sstate. There is no{ info, parts }pair any more. The importer's legacy decoder (session-legacy.ts) only renames native-data keys (state/providerState→native); it does not accept the 2.0 layout.
I expected txcript list --from opencode to show the sessions, and txcript continue ./run.json --with opencode to create a session in OpenCode 2.1.
How to reproduce
run.json (Simple document):
{
"cwd": "D:\\demo",
"title": "Import probe",
"messages": [
{ "role": "user", "content": "List the files in the project." },
{ "role": "assistant", "content": [
{ "type": "tool_use", "id": "call_1", "name": "Bash", "input": { "command": "ls" } } ] },
{ "role": "user", "content": [
{ "type": "tool_result", "tool_use_id": "call_1", "content": "README.md\nsrc" } ] },
{ "role": "assistant", "content": "Two entries: README.md and src." }
]
}opencode --version # opencode v2.1.4
txcript list --from opencode # no local opencode sessions found (DB has sessions)
txcript continue .\run.json --with opencode --no-resume
# error: cannot convert to opencode: `opencode import` failed: … Unexpected positional argument …
# the staged file is left in %TEMP%; hand it to the 2.1 command directly:
opencode session import $env:TEMP\opencode-import-<uuid>.json --directory D:\demo --print-logs --log-level warn
# schema rejection … Missing key at ["info"]["projectID"] → Error: Failed to import session: Bad RequestA minimal transcript that 2.1.4 accepts is the fixture in OpenCode's own CLI test (packages/cli/test/import-export.test.ts): info with id, projectID, cost, tokens, time { created, updated }, title, location { directory }, and messages as flat { id, type: "user", text, time { created } } records.
Versions
- txcript: 0.14.4 (release binary,
x86_64-pc-windows-msvc).mainat 851a257 still runsopencode import(src/harness/opencode.rs). - Agents and their versions: OpenCode 2.1.4 (
opencode --version). - Operating system: Windows 11.
Upstream references (OpenCode v2.1.4)
- CLI:
session import/session exportare the only transcript commands —packages/cli/src/commands/commands.tsL431–485; handlerpackages/cli/src/commands/handlers/session/import.ts(POSTs the file to/api/experimental/session/import, printsImported session: <id>). The docs pagecli.mdxstill showsopencode import <file>, which is out of date. - Wire schema:
packages/protocol/src/groups/session.tsL72–84 and L179; message records:packages/schema/src/session-message.ts; legacy upgrade:packages/schema/src/session-legacy.ts. - Storage:
packages/core/src/session/sql.ts(session_v2,session_message); importer:packages/core/src/session/transfer.ts.
I am preparing a PR: detect the 2.1 layout in the store (read session_v2 + session_message, keep the 2.0 tables working), and on save pick the CLI command and transcript shape from opencode --version.
Activity
fix(opencode): write OpenCode 2.1 tool names and input keys
fix(opencode): read and write OpenCode 2.1 sessions
fix(opencode): write OpenCode 2.1 tool names and input keys