dsh-compact-pi 0.2.3-b2 → 0.2.3-b4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +18 -5
- package/bin/dcp-session.ts +33 -14
- package/dist/codec.mjs +45 -9
- package/dist/dcp-session.mjs +969 -436
- package/dist/index.js +12 -4
- package/docs/compatibility.md +1 -1
- package/docs/help.md +25 -4
- package/docs/publishing.md +9 -9
- package/docs/testing.md +7 -4
- package/package.json +5 -3
- package/scripts/test-resume.mjs +96 -31
- package/skills/dcp-migrate-to-dsh/SKILL.md +16 -0
- package/skills/dcp-migrate-to-dsh/references/commands.md +29 -0
- package/src/codec.ts +40 -6
- package/src/dsh/convert.ts +11 -5
- package/src/dsh/import.ts +108 -0
- package/src/dsh/migration-cli.ts +129 -0
- package/src/dsh/migration-web.ts +44 -0
- package/src/dsh/migration.ts +216 -0
- package/src/dsh/sync.ts +9 -1
- package/test/convert.test.ts +63 -1
- package/test/migration.test.ts +72 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.3-b4]
|
|
4
|
+
|
|
5
|
+
- Add `dcp-session migrate` and update the packaged skill to confirm the source, host, profile, and destination before writing. Support portable exports and direct imports for Windows Desktop, Linux desktop clients, Web, and TUI.
|
|
6
|
+
- Preview duplicate ID and mixed-log conflicts, require explicit approval before recovery or a new ID, and reject a plan when its source or destination changes.
|
|
7
|
+
- Write system messages inside their owning DSH step and preserve incomplete tool exchanges in the Pi archive. Verify imported Web sessions through both the list and history endpoints.
|
|
8
|
+
|
|
9
|
+
## [0.2.3-b3]
|
|
10
|
+
|
|
11
|
+
- Add `dcp-session pi2dsh-import` and the `dcp-migrate-to-dsh` skill. Import a selected Pi session directly into the DeepSeek Harness 0.2.3-alpha.2 store with its active summary, retained messages, images and archived Pi entries.
|
|
12
|
+
- Check the packaged extension on Pi 1.6.1. Run automatic and manual image compaction, session resume and bidirectional migration on native Windows and Ubuntu in CI.
|
|
13
|
+
- Make the CLI build and integration test runner work with Windows Node.js and preserve vendored source bytes across Git checkouts.
|
|
14
|
+
|
|
3
15
|
## [0.2.3-b2]
|
|
4
16
|
|
|
5
17
|
- Correct the lockfile integrity for `@aws/lambda-invoke-store@0.2.2` so a clean `npm ci` can install the development dependencies.
|
package/README.md
CHANGED
|
@@ -2,12 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
An installable pi extension hosting **unmodified DeepSeek Harness compaction plugins in real Cordis**. DCP adapts a defined common subset of pi and DSH; its source updater copies upstream files without rewriting imports or patching the compression algorithm.
|
|
4
4
|
|
|
5
|
-
Tested with pi 1.5.2 and 1.6.
|
|
5
|
+
Tested with pi 1.5.2 and 1.6.1. Node.js must satisfy `^24.22.3 || >=26.13.1`. DCP **0.2.3b4** uses DeepSeek Harness **0.2.3-alpha.2**. `/dcp-status` shows both versions and the upstream commit recorded in [vendor/manifest.json](vendor/manifest.json). The Git tag and npm version use the SemVer spelling `0.2.3-b4`. The source snapshot is included in the package.
|
|
6
6
|
|
|
7
7
|
## Install and use
|
|
8
8
|
|
|
9
|
+
Install from the [Pi package catalog](https://pi.dev/packages/dsh-compact-pi) via npm:
|
|
10
|
+
|
|
9
11
|
```bash
|
|
10
|
-
pi install
|
|
12
|
+
pi install npm:dsh-compact-pi@latest
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The explicit tag selects the currently published prerelease. To pin the GitHub release, use:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pi install git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b4
|
|
11
19
|
```
|
|
12
20
|
|
|
13
21
|
Restart pi or `/reload`, then `/dcp-status`. The Git tag pins this release. To follow future releases on the default branch, use `pi install git:github.com/HanqingTony/dsh-compact-pi`. Before switching from a local DCP installation, use `pi list` and `pi remove <old-source>` to remove the old package entry and avoid loading DCP twice. To install a development checkout, use `pi install /absolute/path/to/dsh-compact-pi`. For one run:
|
|
@@ -34,14 +42,14 @@ In pi 1.5.2, `pi update` alone updates **pi itself**. Use `pi update --extension
|
|
|
34
42
|
|
|
35
43
|
| Installed source | Update behavior |
|
|
36
44
|
|---|---|
|
|
37
|
-
| `git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-
|
|
45
|
+
| `git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b4` | Stays on this tag until you install a different tag |
|
|
38
46
|
| `git:github.com/HanqingTony/dsh-compact-pi` | Follows the default branch (`main`), including changes between tagged releases |
|
|
39
47
|
| Local checkout | Uses local files; pi does not fetch a new release for that path |
|
|
40
48
|
|
|
41
49
|
To upgrade a pinned 0.2.2 installation, install the new tag on the machine where pi runs.
|
|
42
50
|
|
|
43
51
|
```bash
|
|
44
|
-
pi install git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-
|
|
52
|
+
pi install git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b4
|
|
45
53
|
```
|
|
46
54
|
|
|
47
55
|
To follow `main` instead, replace the pinned source once, then update packages as needed:
|
|
@@ -140,7 +148,7 @@ npm run test:package # package, isolated install, copied-source rebuild, pi in
|
|
|
140
148
|
|
|
141
149
|
Differential tests compare the adapter with direct upstream Cordis plugin execution: summary input/budget, logical selected spans, prune/replace events, final surfaces, no-op/failure results, flush checkpoints and retry decisions. Runtime IDs/timestamps and host-specific seed offsets are excluded. Other tests cover real TypeBox tool schemas, usage pricing, durability, branches, Ctrl+O, cancellation, scope rejection and input rejection. Provider replies are deterministic stubs; paid live-model fidelity benchmarks are not implied.
|
|
142
150
|
|
|
143
|
-
The distributable is `dsh-compact-pi-0.2.3-
|
|
151
|
+
The distributable is `dsh-compact-pi-0.2.3-b4.tgz`. It can be installed with `npm install ./dsh-compact-pi-0.2.3-b4.tgz`, followed by `pi install /absolute/path/to/node_modules/dsh-compact-pi`. It contains the copied source closure and built extension.
|
|
144
152
|
|
|
145
153
|
See [testing](docs/testing.md), [publishing](docs/publishing.md), and [release notes](CHANGELOG.md).
|
|
146
154
|
|
|
@@ -148,13 +156,18 @@ See [testing](docs/testing.md), [publishing](docs/publishing.md), and [release n
|
|
|
148
156
|
|
|
149
157
|
See [usage and troubleshooting](docs/help.md) for configuration examples, migration steps and recovery checks. Run `dcp-session --help` for the CLI synopsis.
|
|
150
158
|
|
|
159
|
+
Run `dcp-session migrate` or invoke the [dcp-migrate-to-dsh skill](skills/dcp-migrate-to-dsh/SKILL.md) for a guided portable export or an import to a confirmed Windows Desktop, Linux desktop client, Web, or TUI backend. The preview shows the host, output, and attachment paths before apply.
|
|
160
|
+
|
|
151
161
|
```bash
|
|
152
162
|
dcp-session dsh2pi old.dsh.jsonl imported.pi.jsonl
|
|
153
163
|
pi --session imported.pi.jsonl
|
|
154
164
|
dcp-session pi2dsh session.pi.jsonl exported.dsh.jsonl
|
|
165
|
+
dcp-session pi2dsh-import session.pi.jsonl
|
|
155
166
|
dcp --session old.dsh.jsonl
|
|
156
167
|
```
|
|
157
168
|
|
|
169
|
+
`pi2dsh-import` adds a session to the DSH 0.2.3-alpha.2 V4 store and reports its resume ID. The packaged [dcp-migrate-to-dsh skill](skills/dcp-migrate-to-dsh/SKILL.md) can run the import from Pi or a DSH host with the converter. See [session migration help](docs/help.md#move-a-session-between-pi-and-dsh) for custom roots and skill installation.
|
|
170
|
+
|
|
158
171
|
The converter uses the DSH session format of the pinned upstream snapshot in `vendor/manifest.json`. Its pi-to-DSH export gives DSH the active branch after native context edits, compaction and DCP journal replay. The export also archives the original pi entries, including other branches and metadata, in ignorable `plugin:dcp/pi-header` and `plugin:dcp/pi-entry` records.
|
|
159
172
|
|
|
160
173
|
Importing an unchanged export restores the original pi entries. For a native DSH session, or an export whose context has since changed in DSH, the converter imports the live DSH context as a new linear pi session. Keep the source files if you want access to the original branch tree, plugin state or full event history. Pass a separate output path. Reading compressed DSH logs requires the `zstd` command.
|
package/bin/dcp-session.ts
CHANGED
|
@@ -1,36 +1,55 @@
|
|
|
1
1
|
/** CLI: convert pi and DSH session JSONL files. */
|
|
2
2
|
|
|
3
3
|
import { dshToPi, piToDsh } from '../src/dsh/convert.ts'
|
|
4
|
+
import { importPiToDsh } from '../src/dsh/import.ts'
|
|
5
|
+
import { runMigration } from '../src/dsh/migration-cli.ts'
|
|
4
6
|
|
|
5
7
|
const help = `Usage:
|
|
8
|
+
dcp-session migrate --help
|
|
6
9
|
dcp-session pi2dsh <pi-session.jsonl> <out.dsh.jsonl>
|
|
10
|
+
dcp-session pi2dsh-import <pi-session.jsonl> [dsh-session-root] [--plain]
|
|
7
11
|
dcp-session dsh2pi <dsh-session.jsonl> <out.pi.jsonl>
|
|
8
12
|
dcp-session --help
|
|
9
13
|
|
|
10
14
|
pi2dsh exports the active pi context and archives the original pi entries.
|
|
15
|
+
pi2dsh-import installs that export as a new DSH session. The default root is
|
|
16
|
+
$DSH_HOME/sessions with Zstandard encoding. Use --plain only for a DSH profile
|
|
17
|
+
configured with plaintext session storage.
|
|
11
18
|
dsh2pi restores those entries from an unchanged export. For a native or
|
|
12
19
|
continued DSH session it imports the active DSH context.
|
|
13
20
|
|
|
14
21
|
Use a separate output path. DSH input may be .jsonl or .zstd (requires zstd).
|
|
15
22
|
Image references are resolved under DSH_HOME (default ~/.dsh).`
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
if (command === '--help' || command === '-h') {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
async function main([command, input, ...args]: string[]) {
|
|
25
|
+
if (command === '--help' || command === '-h') {
|
|
26
|
+
console.log(help)
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
if (command === 'migrate') return runMigration(input === undefined ? [] : [input, ...args])
|
|
30
|
+
const importing = command === 'pi2dsh-import'
|
|
31
|
+
const plain = importing && args.at(-1) === '--plain'
|
|
32
|
+
if (plain) args.pop()
|
|
33
|
+
const [output, ...extra] = args
|
|
34
|
+
const valid = importing
|
|
35
|
+
? !output?.startsWith('--')
|
|
36
|
+
: (command === 'pi2dsh' || command === 'dsh2pi') && output
|
|
37
|
+
if (!input || !valid || extra.length) {
|
|
38
|
+
console.error(help)
|
|
39
|
+
process.exitCode = 2
|
|
40
|
+
return
|
|
41
|
+
}
|
|
26
42
|
|
|
27
|
-
try {
|
|
28
43
|
const report =
|
|
29
|
-
|
|
30
|
-
? await piToDsh(input, output)
|
|
31
|
-
: await dshToPi(input, output)
|
|
44
|
+
importing ? await importPiToDsh(input, output, plain)
|
|
45
|
+
: command === 'pi2dsh' ? await piToDsh(input, output!)
|
|
46
|
+
: await dshToPi(input, output!)
|
|
32
47
|
console.log(JSON.stringify(report, null, 2))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
await main(process.argv.slice(2))
|
|
33
52
|
} catch (error) {
|
|
34
53
|
console.error(error instanceof Error ? error.message : String(error))
|
|
35
|
-
process.
|
|
54
|
+
process.exitCode = 1
|
|
36
55
|
}
|
package/dist/codec.mjs
CHANGED
|
@@ -29581,13 +29581,14 @@ function dshMessageToPi(message, time3, toolNames, imageToPi) {
|
|
|
29581
29581
|
}
|
|
29582
29582
|
|
|
29583
29583
|
// src/dsh/sync.ts
|
|
29584
|
-
function createSyncState() {
|
|
29584
|
+
function createSyncState({ persistent = false } = {}) {
|
|
29585
29585
|
return {
|
|
29586
29586
|
turn: 1,
|
|
29587
29587
|
step: 0,
|
|
29588
29588
|
turnStarted: false,
|
|
29589
29589
|
systemSeq: void 0,
|
|
29590
29590
|
stepOpen: false,
|
|
29591
|
+
persistent,
|
|
29591
29592
|
seen: /* @__PURE__ */ new Set(),
|
|
29592
29593
|
toolCalls: /* @__PURE__ */ new Map(),
|
|
29593
29594
|
appended: 0
|
|
@@ -29610,6 +29611,11 @@ function ensureTurn(session, state) {
|
|
|
29610
29611
|
function appendSystem(session, state, entry, message, systemPrompt) {
|
|
29611
29612
|
if (state.systemSeq !== void 0) return;
|
|
29612
29613
|
ensureTurn(session, state);
|
|
29614
|
+
if (state.persistent && !state.stepOpen) {
|
|
29615
|
+
state.step += 1;
|
|
29616
|
+
append(session, "step/start", { turn: state.turn, step: state.step });
|
|
29617
|
+
state.stepOpen = true;
|
|
29618
|
+
}
|
|
29613
29619
|
let content = piContentToDsh(
|
|
29614
29620
|
systemPrompt && systemPrompt.trim().length > 0 ? systemPrompt : typeof message.content === "string" ? message.content : []
|
|
29615
29621
|
);
|
|
@@ -30183,6 +30189,36 @@ function projectPiForDsh(entries) {
|
|
|
30183
30189
|
);
|
|
30184
30190
|
return convertToLlm(system ? [system, ...conversation] : conversation).map((message, index) => ({ type: "message", id: `projected-${index}`, message }));
|
|
30185
30191
|
}
|
|
30192
|
+
function settledTools(projected) {
|
|
30193
|
+
const result = [];
|
|
30194
|
+
const pending = /* @__PURE__ */ new Set();
|
|
30195
|
+
for (const [index, entry] of projected.entries()) {
|
|
30196
|
+
const { message } = entry;
|
|
30197
|
+
if (message.role === "toolResult") {
|
|
30198
|
+
if (pending.delete(message.toolCallId)) result.push(entry);
|
|
30199
|
+
continue;
|
|
30200
|
+
}
|
|
30201
|
+
pending.clear();
|
|
30202
|
+
if (message.role !== "assistant" || message.stopReason === "error" || message.stopReason === "aborted") {
|
|
30203
|
+
result.push(entry);
|
|
30204
|
+
continue;
|
|
30205
|
+
}
|
|
30206
|
+
const followingResults = /* @__PURE__ */ new Set();
|
|
30207
|
+
for (let next = index + 1; next < projected.length; next++) {
|
|
30208
|
+
const following = projected[next].message;
|
|
30209
|
+
if (following.role !== "toolResult") break;
|
|
30210
|
+
followingResults.add(following.toolCallId);
|
|
30211
|
+
}
|
|
30212
|
+
const content = message.content.filter((block) => {
|
|
30213
|
+
if (block.type !== "toolCall") return true;
|
|
30214
|
+
if (!block.id || !followingResults.delete(block.id)) return false;
|
|
30215
|
+
pending.add(block.id);
|
|
30216
|
+
return true;
|
|
30217
|
+
});
|
|
30218
|
+
if (content.length) result.push({ ...entry, message: { ...message, content } });
|
|
30219
|
+
}
|
|
30220
|
+
return result;
|
|
30221
|
+
}
|
|
30186
30222
|
function piHeader(header) {
|
|
30187
30223
|
return {
|
|
30188
30224
|
type: "session",
|
|
@@ -30224,21 +30260,21 @@ function readDshAsPi(file2) {
|
|
|
30224
30260
|
function readPiHeader(file2) {
|
|
30225
30261
|
return readDshAsPi(file2)?.header ?? null;
|
|
30226
30262
|
}
|
|
30227
|
-
function dshRowsFromPi(pi, entries, _file2, imageToDsh, projected = projectPiForDsh(entries)) {
|
|
30263
|
+
function dshRowsFromPi(pi, entries, _file2, imageToDsh, projected = projectPiForDsh(entries), destination) {
|
|
30228
30264
|
const header = {
|
|
30229
30265
|
type: "session",
|
|
30230
30266
|
version: SESSION_FORMAT_VERSION,
|
|
30231
|
-
id: pi.id,
|
|
30267
|
+
id: destination?.id ?? pi.id,
|
|
30232
30268
|
createdAt: Date.parse(pi.timestamp),
|
|
30233
|
-
cwd: pi.cwd,
|
|
30269
|
+
cwd: destination?.cwd ?? pi.cwd,
|
|
30234
30270
|
isSeeded: false,
|
|
30235
30271
|
delegationDepth: 0,
|
|
30236
|
-
|
|
30272
|
+
...!destination && pi.parentSession ? { parentSession: pi.parentSession } : {}
|
|
30237
30273
|
};
|
|
30238
30274
|
const session = Session.create(header.id, [], headerForSession(header));
|
|
30239
30275
|
appendPluginRecord(session, PI_HEADER, JSON.parse(JSON.stringify(pi)));
|
|
30240
|
-
const state = createSyncState();
|
|
30241
|
-
syncPiEntries(session, projected, state, { imageToDsh });
|
|
30276
|
+
const state = createSyncState({ persistent: true });
|
|
30277
|
+
syncPiEntries(session, settledTools(projected), state, { imageToDsh });
|
|
30242
30278
|
closeTurn(session, state);
|
|
30243
30279
|
for (const entry of entries) {
|
|
30244
30280
|
appendPluginRecord(session, PI_ARCHIVE, JSON.parse(JSON.stringify(entry)));
|
|
@@ -30248,9 +30284,9 @@ function dshRowsFromPi(pi, entries, _file2, imageToDsh, projected = projectPiFor
|
|
|
30248
30284
|
...session.snapshotEvents().map((event) => JSON.stringify(event))
|
|
30249
30285
|
].join("\n") + "\n";
|
|
30250
30286
|
}
|
|
30251
|
-
function writeDshFromPi(file2, header, entries, imageToDsh, projected) {
|
|
30287
|
+
function writeDshFromPi(file2, header, entries, imageToDsh, projected, destination) {
|
|
30252
30288
|
mkdirSync(path.dirname(file2), { recursive: true });
|
|
30253
|
-
const body = dshRowsFromPi(header, entries, file2, imageToDsh, projected);
|
|
30289
|
+
const body = dshRowsFromPi(header, entries, file2, imageToDsh, projected, destination);
|
|
30254
30290
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
30255
30291
|
writeFileSync(tmp, body);
|
|
30256
30292
|
renameSync(tmp, file2);
|