Opencode Session Visualizer logo

Opencode Session Visualizer

Community
nigo81
opencode-session-visualizer

将 OpenCode 会话导出为可视化的 HTML 网页,复刻官方 share 页面的暗色主题样式。 从本地 SQLite 数据库提取完整对话数据(包括上下文压缩前的早期消息), 生成的 HTML 包含 Markdown 渲染、代码高亮、工具调用折叠卡片(含完整 input/output)、 思考过程折叠、左侧对话导航边栏、删除/截断对话功能。 触发词:可视化会话、导出会话、会话分享、session visualizer、share session、 导出完整对话、查看压缩前对话、生成会话网页、会话 HTML、conversation visualizer、 opencode 会话导出、完整对话记录、删除对话、清理会话。 当用户提到任何与会话导出、可视化、分享、完整记录查看相关的需求时都应使用此 skill。 即使用户只说"帮我看下之前那个对话"或"导出这个会话"也应触发。

Overview

Publishernigo81
Repositorynigo-skills
Skill nameopencode-session-visualizer
Stars
138
Forks
28
Bundled files
3
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by nigo81 on GitHub. Read the source before you install it.

Installation

Install the Opencode Session Visualizer AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/nigo81/nigo-skills/tree/main/opencode-session-visualizer
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/nigo81/nigo-skills.git /tmp/nigo-skills
mkdir -p .claude/skills
cp -r /tmp/nigo-skills/opencode-session-visualizer .claude/skills/opencode-session-visualizer
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Opencode Session Visualizer in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Opencode Session Visualizer on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Opencode Session Visualizer is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

OpenCode 会话可视化

将 OpenCode 会话从本地数据库导出,生成复刻官方 share 页面样式的单文件 HTML。

核心价值

OpenCode 的上下文压缩(compaction)是不可逆的——恢复会话时只能看到 checkpoint 之后的内容。 但数据库里完整保存了所有消息。这个 skill 直接从数据库提取完整数据,生成可分享的 HTML 网页。

跨平台说明

脚本支持 macOS、Linux 和 Windows。无需额外配置。

  • Python 命令:macOS/Linux 用 python3,Windows 用 python(下方示例统一写 python3,Windows 用户自行替换)
  • 脚本路径:脚本通过 __file__ 自动定位自身目录,无需关心 skill 安装在哪个路径。下方命令中的 SKILL_DIR 指本 skill 的安装目录(因 AI Agent 工具而异,如 ~/.claude/skills/opencode-session-visualizer/、~/.config/opencode/skills/opencode-session-visualizer/ 等)
  • 数据库路径(脚本自动搜索,无需手动指定):
    • Linux: ~/.local/share/opencode/opencode.db
    • macOS: ~/.local/share/opencode/opencode.db 或 ~/Library/Application Support/opencode/opencode.db
    • Windows: %LOCALAPPDATA%\opencode\opencode.db 或 %APPDATA%\opencode\opencode.db

工作流程

快速路径(推荐)

一行命令从数据库直接生成 HTML(SKILL_DIR = 本 skill 目录):

bash
python3 SKILL_DIR/scripts/generate_html.py --session <session_id> [output.html]

如果用户没有提供 session_id,先列出最近会话:

bash
python3 SKILL_DIR/scripts/export_session.py --list -n 15

分步路径

  1. 导出 JSON:python3 SKILL_DIR/scripts/export_session.py <session_id> session.json
  2. 生成 HTML:python3 SKILL_DIR/scripts/generate_html.py session.json [output.html]

生成后提示用户在浏览器中打开(macOS: open <path>,Windows: start <path>,Linux: xdg-open <path>)。

HTML 功能特性

生成的 HTML 是完全自包含的单文件,具备以下交互功能:

渲染

  • Markdown 渲染:助手消息支持完整 Markdown(表格、代码块、列表、标题),用 marked.js
  • 代码高亮:highlight.js 语法高亮,深色主题
  • 暗色主题:背景 #131315,代码块 #0b0b0c,链接 #89b4fa,系统字体 13px

交互

  • 左侧导航边栏:列出所有用户消息摘要,点击平滑滚动跳转,滚动时自动高亮当前消息
  • 工具调用卡片:默认折叠,显示工具名+摘要(如 read · format.ts),点击展开显示完整 Input 和 Output(代码块样式,可滚动)
  • 思考过程折叠:reasoning 内容默认折叠,点击展开查看
  • 压缩事件标记:compaction checkpoint 显示为琥珀色卡片
  • 回到顶部按钮:长页面右下角浮动按钮

编辑(浏览器内操作)

  • 删除消息 🗑:悬浮用户消息显示删除按钮,删除该消息及其后续连续的助手回复
  • 截断对话 ✂️:悬浮用户消息显示截断按钮,删除该消息之后的所有内容(批量删除尾部对话)
  • 导出清理后的 HTML:执行删除/截断操作后,导航栏出现导出按钮,点击下载清理后的单文件 HTML

数据结构

导出的 JSON 结构:

json
{
  "session": {
    "id": "ses_xxx",
    "title": "会话标题",
    "stats": { "total_messages": 222, "user_messages": 59, ... }
  },
  "messages": [
    {
      "id": "msg_xxx",
      "role": "user|assistant",
      "timestamp": "2026-07-23 16:18:45",
      "agent": "Orchestrator",
      "model": "glm-5.1",
      "parts": [
        {"type": "text", "data": {"text": "markdown内容"}},
        {"type": "tool", "data": {"type": "tool", "tool": "bash", "callID": "...", "state": {"status": "completed", "input": {"command": "..."}, "output": "...", "title": "...", "time": {"start": 123, "end": 456}}}},
        {"type": "reasoning", "data": {"text": "思考内容"}},
        {"type": "step-start", "data": {...}},
        {"type": "step-finish", "data": {...}},
        {"type": "compaction", "data": {...}},
        {"type": "patch", "data": {...}}
      ]
    }
  ]
}

Part 类型处理:

  • text:渲染为 Markdown(用户消息和助手消息的正文)
  • tool:折叠卡片,显示工具名+摘要,展开显示 Input 参数和 Output 结果
  • reasoning:折叠卡片,点击展开查看思考过程
  • step-start / step-finish:步骤分隔标记(不在页面显示)
  • compaction:琥珀色压缩事件卡片
  • patch:代码补丁卡片
  • agent:agent 切换标记

Tool 的 input 字段因工具而异:

  • read/edit/write:{filePath: "/path/to/file"}
  • bash:{command: "ls -la"}
  • grep:{pattern: "...", include: "*.ts"}
  • glob:{pattern: "**/*.py"}
  • task:{description: "...", prompt: "..."}

文件结构

opencode-session-visualizer/
├── SKILL.md                      # 本文件
├── scripts/
│   ├── export_session.py         # 数据库导出脚本(session_id → JSON)
│   └── generate_html.py          # HTML 生成脚本(JSON/DB → HTML)
└── assets/
    └── template.html             # HTML 模板(含 __SESSION_DATA__ 占位符)

脚本说明

export_session.py — 从 opencode.db 导出完整会话数据

  • python3 export_session.py <session_id> [output.json] — 导出指定会话
  • python3 export_session.py --list -n 15 — 列出最近 15 个会话
  • session_id 支持部分匹配

generate_html.py — 将会话数据注入模板生成 HTML

  • python3 generate_html.py --session <session_id> [output.html] — 直接从数据库生成(推荐)
  • python3 generate_html.py <session.json> [output.html] — 从导出的 JSON 生成
  • 模板路径自动解析为同目录下 assets/template.html

template.html — HTML 模板

  • 占位符 __SESSION_DATA__ 位于 <script id="conv-data"> 内
  • generate_html.py 将 JSON 数据注入占位符位置
  • 包含完整的 CSS/JS(暗色主题、Markdown 渲染、交互功能、删除/截断/导出)
  • CDN 依赖:marked.js、highlight.js、JetBrains Mono 字体

注意事项

  • 数据库路径由脚本自动检测(见上方「跨平台说明」),通常 5GB+,查询务必带 WHERE session_id
  • session_id 支持部分匹配(脚本会自动补全)
  • 大会话(200+ 条消息)生成的 HTML 可能 5MB+,浏览器可正常处理
  • 删除/截断功能在浏览器端操作,不影响原始数据库数据
  • 导出清理后的 HTML 时,只包含未被删除的消息

作者:nigo 微信公众号:逆行的狗

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Opencode Session Visualizer AI skill do?

将 OpenCode 会话导出为可视化的 HTML 网页,复刻官方 share 页面的暗色主题样式。 从本地 SQLite 数据库提取完整对话数据(包括上下文压缩前的早期消息), 生成的 HTML 包含 Markdown 渲染、代码高亮、工具调用折叠卡片(含完整 input/output)、 思考过程折叠、左侧对话导航边栏、删除/截断对话功能。 触发词:可视化会话、导出会话、会话分享、session visualizer、share session、 导出完整对话、查看压缩前对话、生成会话网页、会话 HTML、conversation visualizer、 opencode 会话导出、完整对话记录、删除对话、清理会话。 当用户提到任何与会话导出、可视化、分享、完整记录查看相关的需求时都应使用此 skill。 即使用户只说"帮我看下之前那个对话"或"导出这个会话"也应触发。

Why use Opencode Session Visualizer on TypingMind?

Because you install it once and use it with any model. Opencode Session Visualizer is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Opencode Session Visualizer in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/nigo81/nigo-skills/tree/main/opencode-session-visualizer. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Opencode Session Visualizer?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Opencode Session Visualizer?

As many as you like. As long as a model supports skills, you can use Opencode Session Visualizer with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Opencode Session Visualizer AI skill free?

Yes. It is published on GitHub by nigo81 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇