forwardzz/dsh-opencode-session-sync ↗★ 0

dsh-opencode-session-sync

将OpenCode历史会话导入为DSH会话 适合需要将OpenCode桌面端历史记录无缝迁移至DSH的用户。

套件
dsh-opencode-session-sync
相容性
待驗證
版本
0.1.0
授權
MIT
最近更新
2026年10月6日

安裝

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:forwardzz/dsh-opencode-session-sync

Usage

Automatic sync (default)

About 4 seconds after startup the plugin imports once, then appends anything new on each later start. No action needed.

Two files record what happened:

FileContents
~/.dsh/opencode-session-sync/last-run.jsonFull report of the most recent sync, per session, with reasons
~/.dsh/opencode-session-sync/state.jsonLedger: OpenCode session id → DSH session id, plus the last source row imported

Manual sync: the opencode_sync tool

The plugin registers one agent tool. Ask in conversation, or call it directly:

actionWhat it doesMain parameters
listRead-only inventory: which OpenCode sessions exist, what workspace each maps to, and how many rows are still pendingworkspace, limit, includeChildren
importSyncs: new sessions are imported, existing ones get their new turns appendeddryRun, workspace, sessionIds, limit, includeChildren
statusLedger and the last run—

Things you can say:

  • "List the OpenCode sessions that are not in DSH yet."
  • "Dry-run a sync and show me what it would do."
  • "Sync only the sessions from my-project."

list reads both sides, so its status column tells you exactly what an import would do: 待导入 (will be created), 有新内容 with a pending count (will be appended), 已同步, or 无正文.

Command line self-check

Convert and validate without starting DSH (read-only, writes nothing):

node tools/selfcheck.mjs              # inventory + convert + structural checks
node tools/selfcheck.mjs --limit 5    # only the 5 most recently updated
node tools/selfcheck.mjs --all        # include subagent child sessions
node tools/selfcheck.mjs --db 
  # point at a specific OpenCode database

Exit codes: 0 passed, 1 problems found (listed individually), 2 environment not satisfied (for example, no OpenCode database on this machine).

Configuration

Configuration lives in ~/.dsh/opencode-session-sync.json. Defaults are written on first run; changes take effect after a restart.

FieldDefaultMeaning
enabledtrueWhen false the plugin does nothing at all: no tool, no sync
dbPathempty (default location)OpenCode database path
autoSyncOnStarttrueSync once after startup
autoSyncDelayMs4000Delay before that first sync, to stay out of the startup path
includeChildrenfalseAlso import subagent child sessions
importLimit200At most this many sessions per run, newest first
titlePrefix"[OC] "Prefix added to imported titles; set "" for none
agentPreset"standard"Agent preset recorded on imported sessions
includeReasoningtrueKeep reasoning blocks
includeToolCallstrueKeep tool calls
maxToolResultChars200000Per-block character cap; longer blocks are truncated and marked
createMissingWorkspacestrueCreate a workspace when the target directory has none
onlyExistingDirectoriesfalseSkip sessions whose directory does not exist on this machine

Default OpenCode database location:

  • Windows: %USERPROFILE%\.local\share\opencode\opencode.db
  • macOS / Linux: ~/.local/share/opencode/opencode.db