Start with the best source available.
Priority order:
- User-provided export: inspect the provided JSON or markdown first.
- CLI JSON export: if no export was provided, create JSON and use it as the canonical investigation artifact.
- TUI markdown export: create markdown only when a readable transcript/report artifact is useful.
If the available artifact is JSON, proceed from it directly. Use JSON as the source of truth for message IDs, timestamps, parentID, sessionID, finish, tool states, token metadata, and errors.
If no export was provided, create JSON:
opencode export <session_id> > session-<short-id>.json
If the available artifact is markdown, use it for narrative review and quoting. When exact metadata is needed, run the JSON export command above too.
During an investigation, OpenCode runtime logs are available at:
/home/airtonp/.local/share/opencode/log
Search them by session ID, timestamp, error text, or tool name when exports do not explain runtime behavior:
rg -n "<session_id|timestamp|error|tool_name>" /home/airtonp/.local/share/opencode/log
Treat logs as supporting runtime evidence; use session exports as the canonical source for conversation structure and agent actions.
To create markdown, launch the TUI from the directory where the .md should be saved:
opencode -s <session_id>
Then use the export flow:
- Press
ctrl+x x to open Export Options. If the shortcut is unreliable, press ctrl+p, search export, and select Export session transcript.
- Leave the default filename such as
session-ses_abcd.md, unless the user requested another name.
- Press
return to confirm. A success toast should say Session exported to <filename>.
- Exit with
ctrl+d, then verify the file exists in the directory where opencode -s was launched.