dsh-session-sync
其他 活跃维护

dsh-session-sync

NB4747/dsh-session-sync

支持将Codex、Claude Code的历史AI会话自动同步至目标平台,导入后可直接续接过往对话上下文,无需重复描述需求,兼容主流AI编程工具的会话格式,操作简单无需额外配置。

0
Stars 标星
0
Forks 分支
0
Watchers 关注
1
Open Issues
TypeScript
主要语言
None
开源协议
38 KB
仓库大小
1 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:NB4747/dsh-session-sync
git clone https://github.com/NB4747/dsh-session-sync.git
git clone git@github.com:NB4747/dsh-session-sync.git
README.md main

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 / 路线图

  • [x] MVP: /sync codex incremental import
  • [x] V2 step 1: realtime auto-watch (boot-time, debounced)
  • [x] V2 step 2: Claude Code source support (/sync claude, dual-directory watch)
  • [x] V2 step 3: bidirectional sync (/sync push — DSH → Codex export)
  • [x] 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