Module opencode

Module opencode 

Source
Expand description

OpenCode CLI session parser for multi-file JSON storage. OpenCode CLI session parser.

Parses session files from the OpenCode CLI tool (opencode.ai). OpenCode uses a multi-file structure with separate directories for sessions, messages, and parts.

Storage layout:

  • Sessions: ~/.local/share/opencode/storage/session/<project-hash>/<session-id>.json
  • Messages: ~/.local/share/opencode/storage/message/<session-id>/msg_<id>.json
  • Parts: ~/.local/share/opencode/storage/part/msg_<id>/prt_<id>.json

Each session file contains metadata including project directory and timestamps. Message files contain role and timing information. Part files contain the actual text content or tool call information.

Structs§

OpenCodeWatcher
Watcher for OpenCode CLI sessions.
ParsedOpenCodeMessage
Intermediate representation of a parsed OpenCode message.
ParsedOpenCodeSession
Intermediate representation of a parsed OpenCode session.

Functions§

find_opencode_session_files
Discovers all OpenCode session files.
parse_opencode_session
Parses an OpenCode session from its session file.