Preface¶
When developing agents in DeepSeek Harness (DSH), conversations are typically archived by working directory: a single cwd corresponds to one workspace, and historical conversations are opened and continued under that workspace. If you have also used the OpenCode desktop client for a period, your chat records will be stored in the local opencode.db, which is a separate system from DSH’s conversation storage. Manual copy-paste is time-consuming and prone to losing model information, tool calls, and token statistics.
The following introduces the community plugin dsh-opencode-session-sync (repository forwardzz/dsh-opencode-session-sync). It reads the OpenCode database in read-only mode and writes through DSH’s built-in sessionPersistence, making the imported results native DSH sessions: they are placed according to the original working directory of the session and support incremental additions after startup.
What is this?¶
dsh-opencode-session-sync is released by maintainer forwardzz and is categorized as a “memory” DSH plugin in community directories such as SkillHub. The plugin description states: import historical sessions from the OpenCode desktop client (opencode.db) as native DSH sessions according to their original working directories.
It is important to clarify two points: this is a community-maintained Harness plugin, not an official DeepSeek product; directories like SkillHub have no official affiliation with DeepSeek or Higherfly. Before installation, please review the source code and the MIT license yourself. The current package version is 0.1.0, with 0 repository stars. The README notes that it has been verified on Windows + DSH 0.2.0-rc.2.
Core Features¶
The plugin’s behavior is bounded by read-only OpenCode and write-only DSH. Its main capabilities are as follows.
Read-only on the OpenCode side. It only opens opencode.db for reading and does not modify the database or OpenCode configuration.
Writes go through DSH’s native path. Data is persisted via sessionPersistence’s create → append → flush operations. The format and event relationships are validated by DSH, and the plugin does not manually assemble log bytes.
Placement by workspace. The OpenCode session’s session_v2.directory maps to DSH’s SessionHeader.cwd; the corresponding workspace is automatically registered, and if no workspace exists for the directory, it can be automatically created when allowed by configuration.
Incremental and idempotent. After the initial import, new OpenCode sessions are added to the same DSH session; DSH session IDs are derived from OpenCode session IDs, so repeated runs do not cause duplicate imports. If a source session has been rolled back or rewritten, the plugin reports diverged instead of forcing incorrect transcript additions.
Automatic and manual coexistence. By default, a synchronization occurs approximately 4 seconds after DSH startup; simultaneously, the agent tool opencode_sync is registered to support list, import, and status.
Content preservation scope. Titles, creation times, models and providers, token usage, reasoning blocks, tool calls, and their outputs and errors are converted according to mapping rules in the README; some OpenCode event types (such as system and synthetic) have no equivalents and are skipped with a report entry.
The runtime depends only on Node built-in modules (including node:sqlite) and requires Node.js 22.5+.
Installation and Activation¶
The plugin is mounted at DSH startup; adding or removing plugins or changing configuration requires restarting DeepSeek Harness, as hot-reloading is not supported. Installation is based on the link: dependency within the profile and dsh.profile.bundles; if your environment provides the dsh CLI, the README states that dsh plugin --profile desktop add link:<absolute path> is equivalent to manual three-step installation.
macOS / Linux Example¶
First, clone the repository to a local directory (path can be customized), then create a symbolic link in node_modules, and edit the profile’s package.json:
git clone https://github.com/forwardzz/dsh-opencode-session-sync.git ~/.dsh/plugins/dsh-opencode-session-sync
ln -s ~/.dsh/plugins/dsh-opencode-session-sync ~/.dsh/profiles/desktop/node_modules/dsh-opencode-session-sync
{
"dependencies": {
"dsh-opencode-session-sync": "link:/absolute path to the cloned directory"
},
"dsh": {
"profile": {
"bundles": [
"dsh-opencode-session-sync"
]
}
}
}
Replace desktop with the actual profile name you use; running pnpm install in the profile directory can also generate links based on link:.
Verify Installation¶
Run a read-only check in the cloned directory (this does not prove the plugin is loaded, but only indicates whether DSH can find the bundle):
node tools/verify-install.mjs
After restarting DSH, you can look for log lines prefixed with [opencode-session-sync] in the output.
Configuration Points¶
The configuration file is ~/.dsh/opencode-session-sync.json, which generates default values on first run and requires a restart for changes to take effect.
Default path for the OpenCode database:
- Windows:
%USERPROFILE%\.local\share\opencode\opencode.db - macOS / Linux:
~/.local/share/opencode/opencode.db
Can be overridden via dbPath. Common fields include: enabled (default true), autoSyncOnStart (default true), autoSyncDelayMs (default 4000), importLimit (default 200), titlePrefix (default "[OC] "), includeChildren (default false, when importing child sessions as independent sessions, parent-child nesting is lost), etc. For the complete table, see the “Configuration” section in the repository’s README Chinese version.
Synchronization state is stored in:
~/.dsh/opencode-session-sync/last-run.json— per-session report of the most recent synchronization~/.dsh/opencode-session-sync/state.json— ledger of OpenCode session IDs and DSH session IDs
Typical Usage¶
Automatic Synchronization¶
Keep the default configuration: after startup, it delays approximately 4 seconds to perform import or addition without additional operations.
Calling opencode_sync in Conversation¶
| action | effect |
|---|---|
list |
read-only inventory of OpenCode sessions, corresponding workspaces, and pending sync count |
import |
perform synchronization; can use dryRun to preview without writing, or use workspace / sessionIds to limit scope |
status |
view ledger and most recent run results |
Example phrases (from README): “List sessions that exist in OpenCode but not in DSH”, “First do a dry-run to see what this will do”, “Only sync sessions related to a specific project directory”. The status column of list corresponds to import behavior: pending, new content, synced, no body.
Self-check without Starting DSH¶
Perform inventory and structural validation on the real opencode.db in the cloned directory (read-only):
node tools/selfcheck.mjs
node tools/selfcheck.mjs --limit 5
node tools/selfcheck.mjs --db <path>
Exit codes: 0 passes, 1 indicates problems found, 2 indicates environment not met (e.g., no OpenCode database on the machine).
Applicable Scenarios and Notes¶
Who it’s for: users who simultaneously use OpenCode desktop and DSH on the same machine and wish to migrate OpenCode historical conversations to DSH workspaces, and continue to incrementally sync in DSH after continuing to chat in OpenCode.
Permissions and security: the plugin runs with the current DSH process permissions, reading the OpenCode database and writing sessions and sync state under ~/.dsh. Before installation, review the GitHub repository source code to confirm paths and behavior comply with your security policy.
Direction and boundaries: import is one-way and does not write back to OpenCode; imported results are text history replay and do not re-execute tools. By default, subagent parent-child nesting is not restored; sessions containing only old tables message / part without session_message are marked as legacy-only and skipped.
Prerequisites: DSH must start normally and the host must provide tools and sessionPersistence; OpenCode desktop and its local database must exist on the same machine.
Conclusion¶
dsh-opencode-session-sync addresses the gap between “OpenCode chat is in SQLite, DSH sessions are archived by workspace”: it reads the source database in read-only mode, writes through DSH’s native persistence, and places and incrementally syncs by the original working directory. Directory page: SkillHub — forwardzz/dsh-opencode-session-sync; source code and complete configuration, FAQ: GitHub — forwardzz/dsh-opencode-session-sync.