Back to home@NB4747

dsh-session-sync

No description

Stars
0
Language
TypeScript
Created
Aug 18, 2026
Updated
Aug 18, 2026
GitHub repo

Introduction

dsh-session-sync

Sync Codex / Claude Code sessions into DeepSeek Harness as resumable sessions. 把 Codex / Claude Code 的历史会话同步到 DeepSeek Harness(DSH),导入后可直接续聊。

Features / 功能

  • One-command import/sync codex 自动扫描 ~/.codex/sessions,导入最新会话
  • Auto-watch (realtime):启动时自动监听 ~/.codex/sessions,Codex 会话一有变化就增量导入,无需手动操作
  • Incremental:manifest 按 mtime 去重,只导入新增/更新的 rollout,不重复创建
  • Full fidelity:用户消息、助手回复(含工具调用文本)完整保留,导入后可续聊
  • Auto workspace grouping:按源项目目录(cwd)自动归入 DSH 工作区,与 Codex 项目视图一致
  • Validated:写入走 DSH 官方 SessionPersistence 接口,通过全部 load 校验

Install / 安装

# install the plugin into your DSH web profile
cd ~/.dsh/profiles/web
pnpm add @z47_rose_1/dsh-session-sync

Or install directly from GitHub:

pnpm add github:NB4747/dsh-session-sync

Then add to cordis.patch.yml:

- insert:
    - id: session-sync
      name: 'dsh-session-sync'

Restart DSH (dsh web).

Usage / 使用

In the DSH Web UI, run:

/sync codex     # manual incremental import
/sync claude    # import Claude Code sessions (~/.claude/projects)
/sync watch     # start realtime watcher (enabled automatically on boot)
/sync unwatch   # stop the watcher
/sync push <sessionId>  # export new DSH turns back to the source Codex rollout (bidirectional)

Or with an explicit path (file or directory):

/sync codex C:\Users\you\.codex\sessions

Imported sessions appear under their source project workspace. Refresh the session list to see them.

Realtime syncing is enabled by default when the plugin loads — every new or changed Codex rollout / Claude Code session is auto-imported after a 3-second debounce. Set autoWatch: false in the plugin config to disable.

Development / 开发

pnpm install
pnpm run build

How it works / 原理

  1. Parse a Codex rollout JSONL (~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl) — read-only
  2. Map user turns + assistant replies into DSH SessionEvents
  3. Write through DSH's sessionPersistence.create / append (zstd frames, contiguous seq, balanced turns)
  4. DSH workspace bootstrap groups sessions by their source cwd

Roadmap / 路线图

  • MVP: /sync codex incremental import
  • V2 step 1: realtime auto-watch (boot-time, debounced)
  • V2 step 2: Claude Code source support (/sync claude, dual-directory watch)
  • V2 step 3: bidirectional sync (/sync push — DSH → Codex export)
  • V2 step 4: conflict handling (external-change detection, push→watch loop guard)
  • GUI desktop app

Conflict handling / 冲突处理

  • Push → watch loop guard: after /sync push, the manifest records the post-push mtime so the watcher skips the lines we just wrote — no duplicate sessions.
  • External change detection: if the source rollout gained new turns on the Codex side since import, /sync push warns you and appends your DSH turns after them (chronological order preserved).

License

MIT