Skip to content

Latest commit

 

History

History
66 lines (48 loc) · 2.69 KB

File metadata and controls

66 lines (48 loc) · 2.69 KB
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
author requires_mcp
zelinzhou
opencode-export

What I do

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.

When to use me

  • 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"

How to use me

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 files
  • session_ids (optional) — specific sessions, or omit for auto-select by config rules
  • formats (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.

Example workflow

User: "导出我最近的项目会话给 TA 看"

  1. list_sessions(project_directory="my-project") → see what exists
  2. Tell user: "找到 N 个会话,最近的是 [title] 于 [date],要导出哪些?"
  3. User confirms → export_sessions(output_dir="...", session_ids=[...])
  4. Report: "已导出 X 个会话到 [path],打开 index.html 即可浏览"

Notes

  • 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.json over HTML parsing.
  • Large exports (>20 sessions) may take 30+ seconds; the tool blocks until complete.