| name | opencode-export | ||||
|---|---|---|---|---|---|
| description | Export opencode sessions to self-contained HTML + JSON archives for sharing, review, or backup. Use when the user wants to save, archive, or share their AI coding session history. | ||||
| license | MIT | ||||
| compatibility | opencode | ||||
| metadata |
|
Export opencode session history to portable HTML + JSON archives:
- list_sessions — discover what sessions exist (by project, time, size)
- show_session — preview a session's metadata + recent messages
- export_sessions — generate self-contained HTML (with offline vendor assets) + structured JSON
Output HTML includes: sticky header with session metadata, collapsible tool/reasoning blocks, subagent inlining, lazy syntax highlighting, TOC drawer of user prompts. JSON preserves full content for programmatic analysis.
- User asks to "save / archive / export / back up" their sessions
- User needs to share AI interaction history (e.g., for TA review, portfolio, audit)
- User wants to generate a browsable record of a project's development
- User asks "what sessions do I have" or "show me my session history"
Step 1 — Discover what's available:
Call list_sessions with the project directory (omit to auto-detect from CWD).
Returns recent root sessions with id/title/date/message_count/tokens.
Step 2 — Preview if user is unsure:
Call show_session with a specific session_id to peek at metadata + recent
messages without committing to a full export.
Step 3 — Export when user confirms:
Call export_sessions with:
output_dir(required) — where to write filessession_ids(optional) — specific sessions, or omit for auto-select by config rulesformats(optional) —["html","json"](default) or["html"]only
Returns a summary with file paths. Tell the user where to find index.html
to open in a browser.
User: "导出我最近的项目会话给 TA 看"
list_sessions(project_directory="my-project")→ see what exists- Tell user: "找到 N 个会话,最近的是 [title] 于 [date],要导出哪些?"
- User confirms →
export_sessions(output_dir="...", session_ids=[...]) - Report: "已导出 X 个会话到 [path],打开 index.html 即可浏览"
- Tokens for older sessions are backfilled from step-finish parts; values may be approximate.
- Secret redaction is automatic (API keys, tokens, passwords masked).
- Vendor assets (highlight.js, mermaid, katex) are bundled for offline viewing.
- For programmatic analysis, prefer
data/sessions.jsonover HTML parsing. - Large exports (>20 sessions) may take 30+ seconds; the tool blocks until complete.