Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
19ec646
fix: open step/start before first surface event so imported sessions …
altruistOS Sep 21, 2026
a316c31
fix: write imported sessions as format v3 so DSH 0.9.0 import works
altruistOS Sep 21, 2026
4f4c757
fix: normalize delegationDepth on the migrate source header
altruistOS Sep 21, 2026
c1b3eed
fix: heal pre-v3 imported sessions so DSH 0.9.x can open them
altruistOS Sep 21, 2026
fe84f34
fix: repair-sessions --fix must not rewrite working v3 sessions
altruistOS Sep 21, 2026
9d6a838
feat: adapt import/export to DSH 0.9.0 handle-based persistence API
altruistOS Sep 21, 2026
cdac3b8
fix: write imported sessions in the installed current format (DSH 0.1…
altruistOS Oct 5, 2026
70e430e
fix: heal stale-format store logs and merge paginated rollout segments
altruistOS Oct 5, 2026
c29b88f
fix: migrate stored artifacts from their actual version; normalize us…
altruistOS Oct 5, 2026
b71c86b
fix: continue per-turn step numbering when inserting step markers in …
altruistOS Oct 5, 2026
8a8c8e5
fix: renormalize turn/step regions in repair; skip compaction logs ho…
altruistOS Oct 5, 2026
de5e5b0
fix: address review round 2 — continuation repacking, full restore va…
altruistOS Oct 5, 2026
33f1964
fix: store the reply to a question imported while still pending
altruistOS Oct 5, 2026
0818f91
fix: preserve standard function call arguments
Walvez Oct 5, 2026
360c17a
fix: declare verified DSH 0.2.0-rc.2 compatibility
Walvez Oct 5, 2026
d17b494
fix: run session codec and isolated tests on Node 20
Walvez Oct 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,28 @@ on:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
node: [20, 22]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: npm
- name: Install Zstandard CLI for Node 20 compression and codec checks
run: sudo apt-get update && sudo apt-get install -y zstd
- name: Install deps (cordis/react/react-dom for the host+client suites)
run: npm ci
- name: Test suite (reader + host smoke + client render; hermetic, no dsh install needed)
Expand All @@ -32,6 +41,9 @@ jobs:
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 22
Expand All @@ -40,10 +52,19 @@ jobs:
- name: pack plugin and add to a scratch web profile
run: |
export DSH_HOME="$RUNNER_TEMP/dsh-home"
npm pack --silent
pnpm dlx @deepseek-ai/dsh plugin --profile web add "$PWD"/dsh-codex-sync-*.tgz
npm pack --json > pack.json
TGZ="$(node -p 'JSON.parse(require("fs").readFileSync("pack.json"))[0].filename')"
mkdir "$RUNNER_TEMP/packed-plugin"
tar -xzf "$TGZ" -C "$RUNNER_TEMP/packed-plugin"
cmp lib/codex-reader.mjs "$RUNNER_TEMP/packed-plugin/package/lib/codex-reader.mjs"
cmp package.json "$RUNNER_TEMP/packed-plugin/package/package.json"
cmp lib/zstd-frame.mjs "$RUNNER_TEMP/packed-plugin/package/lib/zstd-frame.mjs"
cmp docs/COMPATIBILITY.md "$RUNNER_TEMP/packed-plugin/package/docs/COMPATIBILITY.md"
git rev-parse HEAD
sha256sum "$TGZ"
pnpm dlx @deepseek-ai/dsh@0.2.0-rc.2 plugin --profile web add "$PWD/$TGZ"
echo "DSH_HOME=$DSH_HOME" >> "$GITHUB_ENV"
- name: composed config mentions this plugin
run: |
pnpm dlx @deepseek-ai/dsh --profile web --dump-config > composed.txt
pnpm dlx @deepseek-ai/dsh@0.2.0-rc.2 --profile web --dump-config > composed.txt
grep -E "dsh-codex-sync|codex-sync" composed.txt
19 changes: 19 additions & 0 deletions docs/COMPATIBILITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Verified DSH runtime compatibility

The PR #3 local follow-up was tested with the official npm/CLI
`@deepseek-ai/dsh@0.2.0-rc.2`, its `@deepseek-ai/dsh-session@0.2.0-rc.2`
and session-format catalog v4. Desktop version numbers are independent and
are not substitutes for npm package versions.

The optional MCP client peer admits `0.2.0-rc.2` explicitly, alongside the
existing `^0.0.1-rc.1` range. This does not claim compatibility with every
future 0.2 release or prove full MCP mirroring acceptance. Session import
requires the host's production migration/catalog packages; development-only
migration packages must not be installed into a production profile as a fix.

Use a profile dependency plus the bundle patch insert, as in
`examples/web-profile.cordis.patch.yml`. Do not also add the same bundle to
`dsh.profile.bundles`. Verify installation and actual activation without
`plugin allow-version`; a composed configuration alone is insufficient.

Node 20 requires the `zstd` executable for checksummed compression; newer Node runtimes with native Zstandard use the native API. The repair CLI already requires `zstd` for decompression. CI checks both compression paths.
5 changes: 5 additions & 0 deletions docs/compat.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ DSH sessions can be exported back to Codex as rollout JSONL files and indexed in
- **Selectable rules**: Only DSH-updated Codex-origin chats (`dshUpdated=true`, tagged "Updated in DSH" / "DSH 已续聊") are selectable. Unchanged or source-missing Codex chats remain grayed out and locked. Native DSH sessions are selectable.
- **Independent copy**: Every export creates a brand-new Codex rollout (new uuid) and thread entry. It never overwrites the original Codex thread.
- **Sub-agents**: Hidden by default (`hideSub`, default on) and nested under their parent sessions for organization. Selecting a child sub-agent exports it as a separate standalone Codex thread (no merge with parent).


Runtime package versions and default activation checks are described in [COMPATIBILITY.md](COMPATIBILITY.md).

Reverse export preserves user and assistant text; it does not reconstruct tool traces or the original thread id. Use the native DSH archive export to retain the stored event log.
3 changes: 3 additions & 0 deletions lib/attach-workspaces.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* 服务不存在(headless 等未加载 workspace 插件的组合)时静默跳过。
*/

import { normalizePersistence } from './persistence-facade.mjs'

/** 路径显示:home 用 `~` 前缀;超过 3 级只保留最后 3 级(保证同名可区分又简洁)。 */
export function displayPath(cwd) {
const home = process.env.HOME ?? ''
Expand Down Expand Up @@ -117,6 +119,7 @@ export async function unifyWorkspaceTitles(ctx) {
* @returns [{id, cwd}],按持久化 header 读取。
*/
export async function listImportedSessions(persistence) {
persistence = normalizePersistence(persistence)
const headers = await persistence.list()
const imported = []
for (const header of headers) {
Expand Down
2 changes: 1 addition & 1 deletion lib/codex-reader.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export function parseCodexSession(file) {
if (type === 'custom_tool_call' || type === 'function_call') {
if (pending.length === 0) pendingTime = at
const id = typeof payload.call_id === 'string' ? payload.call_id : `codex-call-${crypto.randomUUID()}`
const input = payload.input
const input = type === 'function_call' ? (payload.arguments ?? payload.input) : payload.input
const args = typeof input === 'string' ? input : input === undefined ? '' : JSON.stringify(input)
pending.push({ type: 'tool-call', id, name: String(payload.name ?? 'tool'), arguments: args })
continue
Expand Down
42 changes: 33 additions & 9 deletions lib/convert.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function buildDshEvents(messages, options = {}) {
const events = []
let turn = 0
let step = 0
let stepHasAssistant = false
let openTurn = false
let lastTime = 0
let firstUserSeq
Expand Down Expand Up @@ -77,9 +78,18 @@ export function buildDshEvents(messages, options = {}) {
openTurn = false
}
turn += 1
step = 0
step = 1
stepHasAssistant = false
openTurn = true
push('turn/start', message.time, { turn })
// 每个 turn 必须先开一个 step 区,才能承接后面的 surface 事件
// (user/message / assistant/message / tool/result)。dsl 持久化读入时的
// format v2→v3 迁移要求:任何 surface 事件出现在第一个 step/start 之前,
// 会因“无法在不改变时间顺序的情况下获取 system head”而拒绝导入。
// 原生 agent-loop 是先 step/start 再写 surface;导入器必须复用同样的
// “step/start 前置于首条 surface 事件”的序列,否则 DSH 0.9.0 已导入会话
// 无法打开(issue #2)。
openStepFor(turn, step, message.time)
if (message.blocks.length > 0) {
push('user/message', message.time, {
role: 'user',
Expand All @@ -92,9 +102,13 @@ export function buildDshEvents(messages, options = {}) {
} else {
if (!openTurn) {
turn += 1
step = 0
step = 1
stepHasAssistant = false
openTurn = true
push('turn/start', message.time, { turn })
// 首个消息是 assistant(无前置用户消息)时也要先开 step 区,
// 才能承接其后的 surface 事件。
openStepFor(turn, step, message.time)
}
// Paired tool-result blocks (from codex custom_tool_call_output) are
// consumed by the tool/result surface event, never written into the
Expand All @@ -118,8 +132,16 @@ export function buildDshEvents(messages, options = {}) {
}
}
if (contentBlocks.length === 0) continue
step += 1
openStepFor(turn, step, message.time)
// 若当前 turn 已有 open step 区且尚未被任何 assistant 占用(即刚由用户
// 消息开启的 step 1),则首个 assistant 复用该 step——与原生 agent-loop
// 行为一致(首条 user/message 与 assistant/message 共享 step 1)。否则
// 递增开启新 step,保证同一 turn 内多条 assistant 各自成步。
const regionMatches = openStep !== null && openStep.turn === turn && openStep.step === step
if (!regionMatches || stepHasAssistant) {
step += 1
openStepFor(turn, step, message.time)
}
stepHasAssistant = true
push('assistant/message', message.time, {
turn,
step,
Expand Down Expand Up @@ -171,12 +193,14 @@ export function buildDshEvents(messages, options = {}) {
// 继承源会话标题:latest-wins 的 session/title 事件。默认 fallback 源
// (继续对话后 LLM 标题生成器接管更新);`titlePinned` 时用 user 源
// 固定标题(自动生成停止调度,来源标识与标题持久保留)。
// V4 relationship rule:user 源标题是独立文本,messageSeqs 必须为空;
// fallback 源标题必须引用一条更早的 user/message 事件。
if (options.title !== undefined && options.title.length > 0) {
push('session/title', lastTime, {
title: options.title,
messageSeqs: firstUserSeq !== undefined ? [firstUserSeq] : [],
source: options.titlePinned === true ? { kind: 'user' } : { kind: 'fallback' },
})
const source = options.titlePinned === true ? { kind: 'user' } : { kind: 'fallback' }
const messageSeqs = options.titlePinned === true ? [] : (firstUserSeq !== undefined ? [firstUserSeq] : [])
if (messageSeqs.length > 0 || options.titlePinned === true) {
push('session/title', lastTime, { title: options.title, messageSeqs, source })
}
}
return events
}
Expand Down
6 changes: 2 additions & 4 deletions lib/dsh-writer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* verify the decompressed SHA-256 is unchanged.
*/

import { constants, zstdCompressSync } from 'node:zlib'
import { compressChecksummedFrame } from './zstd-frame.mjs'
import { existsSync, mkdirSync, readdirSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'

Expand Down Expand Up @@ -63,9 +63,7 @@ export function projectKey(cwd) {

/** One zstd-compressed frame with the backend's checksum flag. */
function zstdFrame(text) {
return zstdCompressSync(Buffer.from(text, 'utf8'), {
params: { [constants.ZSTD_c_checksumFlag]: 1 },
})
return compressChecksummedFrame(Buffer.from(text, 'utf8'))
}

/**
Expand Down
3 changes: 3 additions & 0 deletions lib/export-codex.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { execFileSync } from 'node:child_process'
import { dirname, join } from 'node:path'
import { randomFillSync } from 'node:crypto'
import { listCodexSessions, parseCodexSession } from './codex-reader.mjs'
import { normalizePersistence } from './persistence-facade.mjs'

function uuidv7() {
const b = Buffer.alloc(16)
Expand Down Expand Up @@ -405,6 +406,7 @@ export function indexCodexThread(codexHome, { uuid, path, cwd, createdAt, title,
* List DSH sessions as an export catalog (grouped by cwd).
*/
export async function listExportCatalog(persistence, options = {}, codexHome = join(process.env.HOME ?? '', '.codex')) {
persistence = normalizePersistence(persistence)
const includeCodex = options.includeCodex === true
const includeSubagents = options.includeSubagents === true

Expand Down Expand Up @@ -538,6 +540,7 @@ export async function listExportCatalog(persistence, options = {}, codexHome = j
* Export selected DSH sessions to new Codex rollouts + thread index.
*/
export async function exportToCodex(persistence, options = {}, codexHome = join(process.env.HOME ?? '', '.codex')) {
persistence = normalizePersistence(persistence)
const dryRun = options.dryRun === true
const want = Array.isArray(options.ids) && options.ids.length > 0 ? new Set(options.ids) : null
const metas = (await persistence.list()) || []
Expand Down
Loading
Loading