dsh-compact-pi 0.2.3-b3 → 0.2.3-b5

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.3-b5]
4
+
5
+ - Guide session migration one decision at a time. Confirm the target, resolve conflicts individually, and approve the exact output path before writing.
6
+ - Show a short destination preview in the terminal wizard. Scripted plans still return JSON.
7
+ - Record the compaction scope observation and provide an opt-in comparison harness. The default summary prompt remains the upstream prompt.
8
+
9
+ ## [0.2.3-b4]
10
+
11
+ - 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.
12
+ - 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.
13
+ - 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.
14
+
3
15
  ## [0.2.3-b3]
4
16
 
5
17
  - 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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
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.1. Node.js must satisfy `^24.22.3 || >=26.13.1`. DCP **0.2.3b3** 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-b3`. The source snapshot is included in the package.
5
+ Tested with pi 1.5.2 and 1.6.1. Node.js must satisfy `^24.22.3 || >=26.13.1`. DCP **0.2.3b5** 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-b5`. The source snapshot is included in the package.
6
6
 
7
7
  ## Install and use
8
8
 
@@ -15,7 +15,7 @@ pi install npm:dsh-compact-pi@latest
15
15
  The explicit tag selects the currently published prerelease. To pin the GitHub release, use:
16
16
 
17
17
  ```bash
18
- pi install git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b3
18
+ pi install git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b5
19
19
  ```
20
20
 
21
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:
@@ -42,14 +42,14 @@ In pi 1.5.2, `pi update` alone updates **pi itself**. Use `pi update --extension
42
42
 
43
43
  | Installed source | Update behavior |
44
44
  |---|---|
45
- | `git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b3` | Stays on this tag until you install a different tag |
45
+ | `git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b5` | Stays on this tag until you install a different tag |
46
46
  | `git:github.com/HanqingTony/dsh-compact-pi` | Follows the default branch (`main`), including changes between tagged releases |
47
47
  | Local checkout | Uses local files; pi does not fetch a new release for that path |
48
48
 
49
49
  To upgrade a pinned 0.2.2 installation, install the new tag on the machine where pi runs.
50
50
 
51
51
  ```bash
52
- pi install git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b3
52
+ pi install git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b5
53
53
  ```
54
54
 
55
55
  To follow `main` instead, replace the pinned source once, then update packages as needed:
@@ -148,7 +148,7 @@ npm run test:package # package, isolated install, copied-source rebuild, pi in
148
148
 
149
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.
150
150
 
151
- The distributable is `dsh-compact-pi-0.2.3-b3.tgz`. It can be installed with `npm install ./dsh-compact-pi-0.2.3-b3.tgz`, followed by `pi install /absolute/path/to/node_modules/dsh-compact-pi`. It contains the copied source closure and built extension.
151
+ The distributable is `dsh-compact-pi-0.2.3-b5.tgz`. It can be installed with `npm install ./dsh-compact-pi-0.2.3-b5.tgz`, followed by `pi install /absolute/path/to/node_modules/dsh-compact-pi`. It contains the copied source closure and built extension.
152
152
 
153
153
  See [testing](docs/testing.md), [publishing](docs/publishing.md), and [release notes](CHANGELOG.md).
154
154
 
@@ -156,6 +156,8 @@ See [testing](docs/testing.md), [publishing](docs/publishing.md), and [release n
156
156
 
157
157
  See [usage and troubleshooting](docs/help.md) for configuration examples, migration steps and recovery checks. Run `dcp-session --help` for the CLI synopsis.
158
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
+
159
161
  ```bash
160
162
  dcp-session dsh2pi old.dsh.jsonl imported.pi.jsonl
161
163
  pi --session imported.pi.jsonl
@@ -2,8 +2,10 @@
2
2
 
3
3
  import { dshToPi, piToDsh } from '../src/dsh/convert.ts'
4
4
  import { importPiToDsh } from '../src/dsh/import.ts'
5
+ import { runMigration } from '../src/dsh/migration-cli.ts'
5
6
 
6
7
  const help = `Usage:
8
+ dcp-session migrate --help
7
9
  dcp-session pi2dsh <pi-session.jsonl> <out.dsh.jsonl>
8
10
  dcp-session pi2dsh-import <pi-session.jsonl> [dsh-session-root] [--plain]
9
11
  dcp-session dsh2pi <dsh-session.jsonl> <out.pi.jsonl>
@@ -19,30 +21,35 @@ continued DSH session it imports the active DSH context.
19
21
  Use a separate output path. DSH input may be .jsonl or .zstd (requires zstd).
20
22
  Image references are resolved under DSH_HOME (default ~/.dsh).`
21
23
 
22
- const [command, input, ...args] = process.argv.slice(2)
23
- if (command === '--help' || command === '-h') {
24
- console.log(help)
25
- process.exit(0)
26
- }
27
- const importing = command === 'pi2dsh-import'
28
- const plain = importing && args.at(-1) === '--plain'
29
- if (plain) args.pop()
30
- const [output, ...extra] = args
31
- const valid = importing
32
- ? !output?.startsWith('--')
33
- : (command === 'pi2dsh' || command === 'dsh2pi') && output && extra.length === 0
34
- if (!input || !valid || extra.length) {
35
- console.error(help)
36
- process.exit(2)
37
- }
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
+ }
38
42
 
39
- try {
40
43
  const report =
41
44
  importing ? await importPiToDsh(input, output, plain)
42
45
  : command === 'pi2dsh' ? await piToDsh(input, output!)
43
46
  : await dshToPi(input, output!)
44
47
  console.log(JSON.stringify(report, null, 2))
48
+ }
49
+
50
+ try {
51
+ await main(process.argv.slice(2))
45
52
  } catch (error) {
46
53
  console.error(error instanceof Error ? error.message : String(error))
47
- process.exit(1)
54
+ process.exitCode = 1
48
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
- ...pi.parentSession ? { parentSession: pi.parentSession } : {}
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);