forwardzz/dsh-opencode-session-sync ↗★ 0
dsh-opencode-session-sync
DeepSeek Harness 插件:把 OpenCode 桌面端(opencode.db)的历史会话按各自原本的工作目录导入为 DSH 原生会话 适合需要将OpenCode桌面端历史记录无缝迁移至DSH的用户。
설치
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:forwardzz/dsh-opencode-session-syncUsage
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:
| File | Contents |
|---|---|
~/.dsh/opencode-session-sync/last-run.json | Full report of the most recent sync, per session, with reasons |
~/.dsh/opencode-session-sync/state.json | Ledger: 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:
action | What it does | Main parameters |
|---|---|---|
list | Read-only inventory: which OpenCode sessions exist, what workspace each maps to, and how many rows are still pending | workspace, limit, includeChildren |
import | Syncs: new sessions are imported, existing ones get their new turns appended | dryRun, workspace, sessionIds, limit, includeChildren |
status | Ledger 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.
| Field | Default | Meaning |
|---|---|---|
enabled | true | When false the plugin does nothing at all: no tool, no sync |
dbPath | empty (default location) | OpenCode database path |
autoSyncOnStart | true | Sync once after startup |
autoSyncDelayMs | 4000 | Delay before that first sync, to stay out of the startup path |
includeChildren | false | Also import subagent child sessions |
importLimit | 200 | At 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 |
includeReasoning | true | Keep reasoning blocks |
includeToolCalls | true | Keep tool calls |
maxToolResultChars | 200000 | Per-block character cap; longer blocks are truncated and marked |
createMissingWorkspaces | true | Create a workspace when the target directory has none |
onlyExistingDirectories | false | Skip 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