Token导航 LogoToken导航TokenDH.com
研究检索执行命令clawhub未标认证来源可访问clear审计提醒

opencode-session-toolkitOpencode 会话工具包

Agent Skill

opencode-session-toolkit 用于查找、检索和筛选相关信息,适合在 OpenClaw 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

2,564

周安装

109

GitHub Stars

公开资料未说明

下载量

898
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:opencode-session-toolkit(Opencode 会话工具包)
来源仓库:https://github.com/wufei-png/opencode-session-toolkit
安装命令:
openclaw skills install opencode-session-toolkit
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install opencode-session-toolkit

简介

读取本地 OpenCode SQLite 数据库,运行跨目录会话查询,并将会话导出到 Markdown 文件。

SKILL.md

name
opencode-session-toolkit
description
Read the local OpenCode SQLite database, run cross-directory session queries, and export sessions to Markdown files.

OpenCode Session Toolkit

Read the local OpenCode SQLite database and query or export sessions, messages, parts, and projects across directories.

All commands below assume the workdir is this skill directory. For Markdown export, run the bundled script directly:

./scripts/export_opencode_sessions.py --help

When to use

  • List recent sessions, filter by directory, or search by title
  • Read message JSON for a specific session
  • Export matched sessions into one-Markdown-per-session archives
  • Inspect database schema and indexes (load references/schema.md only when needed)

Workflow

  1. Resolve the database path with opencode db path.
  2. Run all queries in read-only mode.
  3. Load references/schema.md only when field-level details are required.

1. Resolve the database path

if ! command -v opencode >/dev/null 2>&1; then
  echo "opencode command not found in PATH" >&2
  exit 1
fi

if ! DB_PATH="$(opencode db path 2>/dev/null)"; then
  echo "Failed to resolve OpenCode DB path via: opencode db path" >&2
  exit 1
fi

if [ -z "${DB_PATH:-}" ] || [ ! -f "$DB_PATH" ]; then
  echo "OpenCode DB not found: $DB_PATH" >&2
  exit 1
fi

echo "Using DB: $DB_PATH"

List existing DB files (no error when there is no match):

find "${XDG_DATA_HOME:-$HOME/.local/share}/opencode" -maxdepth 1 -name '*.db' -print 2>/dev/null

2. Time conversion and output formatting

Time conversion: all time fields are Unix timestamps in milliseconds. Convert them directly in SQL with datetime().

# Convert in SQL (recommended, no external command needed)
datetime(time_updated/1000, 'unixepoch', 'localtime')

# Shell helpers for time windows
NOW_MS=$(date +%s000)
LAST_7D=$((NOW_MS - 7*86400*1000))
LAST_30D=$((NOW_MS - 30*86400*1000))

Table alignment: for normal fields, pipe SQLite output to column -t -s '|' (| is SQLite's default delimiter). For long JSON fields such as message.data, prefer -json output.

sqlite3 -readonly "$DB_PATH" "SELECT id, title, time_updated FROM session LIMIT 5;" | column -t -s '|'

3. Common read-only queries

Tip: For queries without large JSON fields, append | column -t -s '|' for aligned table output.

List the latest 20 sessions (most recently updated first)

sqlite3 -readonly "$DB_PATH" \
  "SELECT id, title, directory,
          datetime(time_updated/1000,'unixepoch','localtime') as updated
   FROM session
   ORDER BY time_updated DESC
   LIMIT 20;" | column -t -s '|'

Filter sessions by directory

sqlite3 -readonly "$DB_PATH" \
  "SELECT id, title, datetime(time_updated/1000,'unixepoch','localtime') as updated
   FROM session
   WHERE directory LIKE '/path/to/project%'
   ORDER BY time_updated DESC
   LIMIT 20;" | column -t -s '|'

Filter sessions by project_id (most precise project linkage)

sqlite3 -readonly "$DB_PATH" \
  "SELECT s.id, s.title, s.directory,
          datetime(s.time_updated/1000,'unixepoch','localtime') as updated
   FROM session s
   WHERE s.project_id = 'your-project-id'
   ORDER BY s.time_updated DESC
   LIMIT 20;" | column -t -s '|'

project_id maps to project.id. List projects with:

sqlite3 -readonly "$DB_PATH" "SELECT id, worktree, name FROM project;" | column -t -s '|'

List sessions across all directories (with project info)

sqlite3 -readonly "$DB_PATH" \
  "SELECT s.id, s.title, s.directory, p.worktree,
          datetime(s.time_updated/1000,'unixepoch','localtime') as updated
   FROM session s
   LEFT JOIN project p ON s.project_id = p.id
   ORDER BY s.time_updated DESC
   LIMIT 50;" | column -t -s '|'

Filter by time range

# Sessions active in the last 7 days
sqlite3 -readonly "$DB_PATH" \
  "SELECT id, title, datetime(time_updated/1000,'unixepoch','localtime') as updated
   FROM session
   WHERE time_updated > $(( $(date +%s000) - 7*86400*1000 ))
   ORDER BY time_updated DESC
   LIMIT 20;" | column -t -s '|'

# Sessions created today (local time)
sqlite3 -readonly "$DB_PATH" \
  "SELECT id, title, datetime(time_created/1000,'unixepoch','localtime') as created
   FROM session
   WHERE date(time_created/1000,'unixepoch','localtime') = date('now','localtime')
   ORDER BY time_created DESC
   LIMIT 20;" | column -t -s '|'

Read message content for one session

sqlite3 -readonly -json "$DB_PATH" \
  "SELECT m.id, datetime(m.time_created/1000,'unixepoch','localtime') as created, m.data
   FROM message m
   WHERE m.session_id = 'your-session-id'
   ORDER BY m.time_created ASC;"

Extract fields from message.data JSON

# Extract key fields such as role and modelID
sqlite3 -readonly "$DB_PATH" \
  "SELECT id,
          json_extract(data, '$.role') as role,
          json_extract(data, '$.modelID') as model,
          datetime(time_created/1000,'unixepoch','localtime') as created
   FROM message
   WHERE session_id = 'your-session-id'
   ORDER BY time_created ASC;" | column -t -s '|'

# Search message payload text with LIKE
sqlite3 -readonly "$DB_PATH" \
  "SELECT id, json_extract(data, '$.role') as role, time_created
   FROM message
   WHERE data LIKE '%keyword%'
   ORDER BY time_created DESC
   LIMIT 20;" | column -t -s '|'

Search session titles

sqlite3 -readonly "$DB_PATH" \
  "SELECT id, title, directory, datetime(time_updated/1000,'unixepoch','localtime') as updated
   FROM session
   WHERE title LIKE '%keyword%'
   ORDER BY time_updated DESC
   LIMIT 20;" | column -t -s '|'

View session summary stats

sqlite3 -readonly "$DB_PATH" \
  "SELECT title, summary_additions, summary_deletions, summary_files,
          datetime(time_created/1000,'unixepoch','localtime') as created
   FROM session
   ORDER BY time_updated DESC
   LIMIT 20;" | column -t -s '|'

4. Export sessions to Markdown

The export script writes one session per Markdown file. By default:

  • filename = session title + created time
  • time filtering uses time_updated unless --time-field created is passed
  • step-start / step-finish parts are skipped to reduce noise
  • when project.name is empty, project folder names fall back to the worktree basename, or global

Export sessions for one project

./scripts/export_opencode_sessions.py \
  --project opencode-session-toolkit \
  --output-dir ./exports/opencode-session-toolkit

--project matches by substring against project_id, project.name, project.worktree, and session.directory.

Export sessions in a time range

./scripts/export_opencode_sessions.py \
  --start 2026-03-01 \
  --end 2026-03-24T23:59:59 \
  --time-field updated \
  --output-dir ./exports/march

Accepted time formats:

  • ISO date: 2026-03-24
  • ISO datetime: 2026-03-24T22:35:37
  • Unix seconds / milliseconds

Full export grouped by project

./scripts/export_opencode_sessions.py \
  --all \
  --group-by-project \
  --output-dir ./exports/all

Output example:

exports/all/
  OrchAI/
    Migration work planning with subagent discussion_2026-03-23_23-48-07.md
  global/
    opencode-session-toolkit 命令验证与优化_2026-03-24_22-35-37.md

Useful extra filters

  • --session-id ses_xxx: exact session export
  • --title-contains keyword: match session titles
  • --directory-contains keyword: match session directories
  • --archived include|exclude|only: filter archived sessions
  • --filename-time-field created|updated: choose which session time goes into the filename
  • --include-part-type text --include-part-type tool: export only certain part types
  • --exclude-part-type reasoning: drop noisy part types
  • --overwrite: overwrite existing files instead of appending the session id to avoid collisions

If no filters are provided, the script requires --all to avoid accidental full-database exports.

5. Inspect schema

sqlite3 -readonly "$DB_PATH" ".schema session"
sqlite3 -readonly "$DB_PATH" ".schema message"
sqlite3 -readonly "$DB_PATH" ".schema part"
sqlite3 -readonly "$DB_PATH" ".schema project"

For complete field and index notes, see references/schema.md.

6. List all tables

sqlite3 -readonly "$DB_PATH" ".tables"

7. Example output

id          title                     directory                   updated
----------  -----------------------  --------------------------  -------------------
ses_abc123  My Session - 2026-03-24  /home/user/project         2026-03-24 10:00:00
ses_def456  Another Session          /home/user/other           2026-03-23 15:30:00

(Aligned with | column -t -s '|'.)

8. Notes

  • OpenCode uses SQLite WAL mode, so .db-wal and .db-shm files are expected.
  • Time fields are Unix timestamps in milliseconds. Convert with datetime(ts/1000,'unixepoch','localtime').
  • data fields are JSON. Use json_extract(data, '$.field') for structured extraction, and prefer sqlite3 -json for raw message inspection.
  • Session isolation is anchored by project_id; for cross-directory queries, joining project.worktree is recommended.
  • Direct writes can corrupt data. Back up before any non-read-only operation.
  • account and control_account tables may contain sensitive credentials. Redact outputs when sharing.

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

79.45%
按下载量换算713

安全审计

VirusTotal

通过

ClawScan

可疑

Static analysis

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 openclaw skills install opencode-session-toolkit 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills