dsh-compact-pi 0.2.3-b4 → 0.2.3-b6
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 +28 -5
- package/bin/dcp-session.ts +4 -1
- package/dist/dcp-session.mjs +619 -157
- package/dist/dcp.mjs +23 -18
- package/dist/index.js +70 -15
- package/docs/compatibility.md +1 -1
- package/docs/help.md +22 -3
- package/docs/publishing.md +4 -4
- package/docs/testing.md +17 -0
- package/package.json +2 -2
- package/scripts/smoke-package.mjs +4 -0
- package/scripts/test-correction-scope.ts +187 -0
- package/scripts/test-resume.mjs +1 -1
- package/skills/dcp-import-from-dsh/SKILL.md +17 -0
- package/skills/dcp-migrate-to-dsh/SKILL.md +10 -5
- package/skills/dcp-migrate-to-dsh/references/commands.md +4 -0
- package/src/bridge.ts +2 -1
- package/src/config.ts +61 -4
- package/src/dsh/convert.ts +14 -14
- package/src/dsh/engine.ts +3 -1
- package/src/dsh/llm.ts +29 -4
- package/src/dsh/migration-cli.ts +10 -2
- package/src/dsh/migration.ts +4 -4
- package/src/dsh/pi-destination.ts +75 -0
- package/src/dsh/reverse-migration-cli.ts +71 -0
- package/src/dsh/reverse-migration.ts +244 -0
- package/src/dsh/store.ts +14 -8
- package/src/index.ts +2 -2
- package/test/cancellation.test.ts +1 -0
- package/test/config.test.ts +33 -0
- package/test/host.test.ts +56 -0
- package/test/integration.test.ts +2 -0
- package/test/migration.test.ts +73 -0
package/dist/dcp.mjs
CHANGED
|
@@ -29857,19 +29857,23 @@ function projectSurface(session, imageToPi) {
|
|
|
29857
29857
|
}
|
|
29858
29858
|
|
|
29859
29859
|
// src/dsh/store.ts
|
|
29860
|
-
import { execFileSync } from "node:child_process";
|
|
29861
29860
|
import { promises as fs } from "node:fs";
|
|
29861
|
+
import { promisify } from "node:util";
|
|
29862
|
+
import { zstdDecompress } from "node:zlib";
|
|
29863
|
+
var decompress = promisify(zstdDecompress);
|
|
29862
29864
|
async function readDshFile(file2) {
|
|
29863
|
-
let
|
|
29865
|
+
let bytes;
|
|
29864
29866
|
try {
|
|
29865
|
-
|
|
29866
|
-
encoding: "utf8",
|
|
29867
|
-
maxBuffer: 512 * 1024 * 1024
|
|
29868
|
-
}) : await fs.readFile(file2, "utf8");
|
|
29867
|
+
bytes = await fs.readFile(file2);
|
|
29869
29868
|
} catch (error62) {
|
|
29870
29869
|
if (error62?.code === "ENOENT") return void 0;
|
|
29871
29870
|
throw error62;
|
|
29872
29871
|
}
|
|
29872
|
+
return parseDshFile(file2, bytes);
|
|
29873
|
+
}
|
|
29874
|
+
async function parseDshFile(file2, bytes) {
|
|
29875
|
+
const decoded = file2.endsWith(".zstd") ? await decompress(bytes, { maxOutputLength: 512 * 1024 * 1024 }) : bytes;
|
|
29876
|
+
const text = decoded.toString("utf8");
|
|
29873
29877
|
const rows = text.split("\n").filter((line) => line.trim().length > 0);
|
|
29874
29878
|
if (rows.length === 0) return void 0;
|
|
29875
29879
|
const headerRow = JSON.parse(rows[0]);
|
|
@@ -29986,18 +29990,20 @@ async function dshToPi(input2, output2) {
|
|
|
29986
29990
|
throw new Error("Choose a separate output file for session conversion");
|
|
29987
29991
|
const dsh = await readDshFile(input2);
|
|
29988
29992
|
if (!dsh) throw new Error(`${input2}: not a DSH session file`);
|
|
29993
|
+
const { header, entries } = await convertDshSession(dsh);
|
|
29994
|
+
await writePiSession(output2, header, entries);
|
|
29995
|
+
return {
|
|
29996
|
+
input: input2,
|
|
29997
|
+
output: output2,
|
|
29998
|
+
messages: entries.filter((entry) => entry.type === "message").length,
|
|
29999
|
+
events: dsh.events.length
|
|
30000
|
+
};
|
|
30001
|
+
}
|
|
30002
|
+
async function convertDshSession(dsh, dshHome) {
|
|
29989
30003
|
const archived = archivedPi(dsh.header, dsh.events);
|
|
29990
|
-
if (archived)
|
|
29991
|
-
await writePiSession(output2, archived.header, archived.entries);
|
|
29992
|
-
return {
|
|
29993
|
-
input: input2,
|
|
29994
|
-
output: output2,
|
|
29995
|
-
messages: archived.entries.filter((entry) => entry.type === "message").length,
|
|
29996
|
-
events: dsh.events.length
|
|
29997
|
-
};
|
|
29998
|
-
}
|
|
30004
|
+
if (archived) return archived;
|
|
29999
30005
|
const session = restoreSession(dsh.header, dsh.events);
|
|
30000
|
-
const carrier = await openImageBridge();
|
|
30006
|
+
const carrier = await openImageBridge(dshHome);
|
|
30001
30007
|
let messages;
|
|
30002
30008
|
try {
|
|
30003
30009
|
await carrier.images.hydrate(
|
|
@@ -30023,8 +30029,7 @@ async function dshToPi(input2, output2) {
|
|
|
30023
30029
|
);
|
|
30024
30030
|
parentId = id;
|
|
30025
30031
|
}
|
|
30026
|
-
|
|
30027
|
-
return { input: input2, output: output2, messages: messages.length, events: dsh.events.length };
|
|
30032
|
+
return { header, entries };
|
|
30028
30033
|
}
|
|
30029
30034
|
|
|
30030
30035
|
// bin/dcp.ts
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/bridge.ts
|
|
2
2
|
import { createHash as createHash5 } from "node:crypto";
|
|
3
3
|
import path3 from "node:path";
|
|
4
|
-
import { homedir as
|
|
4
|
+
import { homedir as homedir4 } from "node:os";
|
|
5
5
|
|
|
6
6
|
// vendor/dsh-runtime.mjs
|
|
7
7
|
import { createRequire } from "node:module";
|
|
@@ -30631,8 +30631,8 @@ var SessionProjectionRegistry = class extends Service {
|
|
|
30631
30631
|
// package.json
|
|
30632
30632
|
var package_default = {
|
|
30633
30633
|
name: "dsh-compact-pi",
|
|
30634
|
-
version: "0.2.3-
|
|
30635
|
-
dcpVersion: "0.2.
|
|
30634
|
+
version: "0.2.3-b6",
|
|
30635
|
+
dcpVersion: "0.2.3b6",
|
|
30636
30636
|
type: "module",
|
|
30637
30637
|
description: "DeepSeek Harness context compaction for pi: upstream engine, policy, token meter and pruner",
|
|
30638
30638
|
repository: {
|
|
@@ -35106,7 +35106,7 @@ function usageToDsh(usage) {
|
|
|
35106
35106
|
totalTokens: Number(usage.totalTokens ?? 0)
|
|
35107
35107
|
};
|
|
35108
35108
|
}
|
|
35109
|
-
function createLlm(host, images) {
|
|
35109
|
+
function createLlm(host, images, summaryPrompt) {
|
|
35110
35110
|
return {
|
|
35111
35111
|
imageRequestPricing: () => void 0,
|
|
35112
35112
|
async *stream(options) {
|
|
@@ -35114,14 +35114,25 @@ function createLlm(host, images) {
|
|
|
35114
35114
|
if (!model)
|
|
35115
35115
|
throw new Error("dcp: no pi model available for summarization");
|
|
35116
35116
|
options.signal?.throwIfAborted();
|
|
35117
|
+
let requestMessages = options.messages ?? [];
|
|
35118
|
+
if (options.purpose === "compaction" && summaryPrompt && summaryPrompt.mode !== "native") {
|
|
35119
|
+
const directive = requestMessages.at(-1);
|
|
35120
|
+
if (directive?.role !== "user" || !Array.isArray(directive.content) || directive.content.length !== 1 || directive.content[0]?.type !== "text" || typeof directive.content[0].text !== "string")
|
|
35121
|
+
throw new Error("dcp: unexpected DSH compaction directive format");
|
|
35122
|
+
const text2 = summaryPrompt.mode === "append" ? directive.content[0].text + "\n\n" + summaryPrompt.text : summaryPrompt.text;
|
|
35123
|
+
requestMessages = [
|
|
35124
|
+
...requestMessages.slice(0, -1),
|
|
35125
|
+
{ ...directive, content: [{ type: "text", text: text2 }] }
|
|
35126
|
+
];
|
|
35127
|
+
}
|
|
35117
35128
|
const imageToPi = images ? await images.requestMapper(
|
|
35118
|
-
|
|
35129
|
+
requestMessages,
|
|
35119
35130
|
model,
|
|
35120
35131
|
options.signal
|
|
35121
35132
|
) : void 0;
|
|
35122
35133
|
const messages = [];
|
|
35123
35134
|
const systemPrompts = [];
|
|
35124
|
-
for (const message of
|
|
35135
|
+
for (const message of requestMessages) {
|
|
35125
35136
|
if (message.role === "system") {
|
|
35126
35137
|
systemPrompts.push(textOf(message.content));
|
|
35127
35138
|
continue;
|
|
@@ -35365,7 +35376,7 @@ var ImageBridge = class {
|
|
|
35365
35376
|
// src/dsh/engine.ts
|
|
35366
35377
|
import { homedir as homedir2 } from "node:os";
|
|
35367
35378
|
import path from "node:path";
|
|
35368
|
-
async function createEngine(host, config2 = {}) {
|
|
35379
|
+
async function createEngine(host, config2 = {}, summaryPrompt) {
|
|
35369
35380
|
const ctx = new Context();
|
|
35370
35381
|
try {
|
|
35371
35382
|
if (host.notify)
|
|
@@ -35386,7 +35397,7 @@ async function createEngine(host, config2 = {}) {
|
|
|
35386
35397
|
ctx.provide("agents", /* @__PURE__ */ new Map());
|
|
35387
35398
|
await ctx.plugin({
|
|
35388
35399
|
name: "pi-compaction-llm",
|
|
35389
|
-
apply: (service) => service.provide("llm", createLlm(host, images))
|
|
35400
|
+
apply: (service) => service.provide("llm", createLlm(host, images, summaryPrompt))
|
|
35390
35401
|
});
|
|
35391
35402
|
await ctx.plugin(SessionStore);
|
|
35392
35403
|
await ctx.plugin(SessionProjectionRegistry);
|
|
@@ -35527,6 +35538,7 @@ function assertCompatible(model, messages, instructions) {
|
|
|
35527
35538
|
// src/config.ts
|
|
35528
35539
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
35529
35540
|
import { mkdir as mkdir3, readFile as readFile3, rename as rename2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
35541
|
+
import { homedir as homedir3 } from "node:os";
|
|
35530
35542
|
import path2 from "node:path";
|
|
35531
35543
|
async function readConfig(cwd) {
|
|
35532
35544
|
for (const file2 of ["dcp.json", "zcp.json"]) {
|
|
@@ -35543,7 +35555,7 @@ function validateConfig(value) {
|
|
|
35543
35555
|
throw new Error("dcp.json must be an object");
|
|
35544
35556
|
const record2 = value;
|
|
35545
35557
|
for (const key of Object.keys(record2))
|
|
35546
|
-
if (!["policy", "audit"].includes(key))
|
|
35558
|
+
if (!["policy", "audit", "summaryPrompt", "dshBackends"].includes(key))
|
|
35547
35559
|
throw new Error(`dcp.json: unknown setting ${key}`);
|
|
35548
35560
|
if (record2.audit !== void 0 && typeof record2.audit !== "boolean")
|
|
35549
35561
|
throw new Error("dcp.json: audit must be boolean");
|
|
@@ -35551,11 +35563,52 @@ function validateConfig(value) {
|
|
|
35551
35563
|
throw new Error("dcp.json: policy must be an object");
|
|
35552
35564
|
const policy = record2.policy ?? {};
|
|
35553
35565
|
resolveConfig2(policy);
|
|
35566
|
+
if (record2.summaryPrompt !== void 0) {
|
|
35567
|
+
const value2 = record2.summaryPrompt;
|
|
35568
|
+
if (!value2 || typeof value2 !== "object" || Array.isArray(value2))
|
|
35569
|
+
throw new Error("dcp.json: summaryPrompt must be an object");
|
|
35570
|
+
const prompt = value2;
|
|
35571
|
+
for (const key of Object.keys(prompt))
|
|
35572
|
+
if (!["mode", "text"].includes(key))
|
|
35573
|
+
throw new Error(`dcp.json: unknown summaryPrompt setting ${key}`);
|
|
35574
|
+
if (prompt.mode === "native") {
|
|
35575
|
+
if (prompt.text !== void 0)
|
|
35576
|
+
throw new Error("dcp.json: summaryPrompt.text is only used with override or append");
|
|
35577
|
+
} else {
|
|
35578
|
+
if (prompt.mode !== "override" && prompt.mode !== "append")
|
|
35579
|
+
throw new Error("dcp.json: summaryPrompt.mode must be native, override, or append");
|
|
35580
|
+
if (typeof prompt.text !== "string" || !prompt.text.trim())
|
|
35581
|
+
throw new Error("dcp.json: summaryPrompt.text must be a non-empty string");
|
|
35582
|
+
}
|
|
35583
|
+
}
|
|
35584
|
+
if (record2.dshBackends !== void 0) {
|
|
35585
|
+
const backends = record2.dshBackends;
|
|
35586
|
+
if (!backends || typeof backends !== "object" || Array.isArray(backends))
|
|
35587
|
+
throw new Error("dcp.json: dshBackends must be an object of named local backends");
|
|
35588
|
+
for (const [name2, backend] of Object.entries(backends)) {
|
|
35589
|
+
if (!name2.trim() || !backend || typeof backend !== "object" || Array.isArray(backend) || Object.keys(backend).some((key) => key !== "home" && key !== "sessionRoot") || typeof backend.home !== "string" || !path2.isAbsolute(backend.home) || backend.sessionRoot !== void 0 && (typeof backend.sessionRoot !== "string" || !path2.isAbsolute(backend.sessionRoot)))
|
|
35590
|
+
throw new Error(`dcp.json: dshBackends.${name2} requires an absolute local home and optional absolute sessionRoot`);
|
|
35591
|
+
}
|
|
35592
|
+
}
|
|
35554
35593
|
return record2;
|
|
35555
35594
|
}
|
|
35556
|
-
async function loadConfig(cwd) {
|
|
35557
|
-
const { policy
|
|
35558
|
-
|
|
35595
|
+
async function loadConfig(cwd, agentDir) {
|
|
35596
|
+
const config2 = { policy: {}, audit: true, ...validateConfig(await readConfig(cwd)) };
|
|
35597
|
+
if (agentDir && !config2.summaryPrompt) {
|
|
35598
|
+
const file2 = path2.join(agentDir, "dcp.json");
|
|
35599
|
+
try {
|
|
35600
|
+
const userConfig = validateConfig(JSON.parse(await readFile3(file2, "utf8")));
|
|
35601
|
+
if (userConfig.summaryPrompt) config2.summaryPrompt = userConfig.summaryPrompt;
|
|
35602
|
+
} catch (error62) {
|
|
35603
|
+
if (error62.code !== "ENOENT")
|
|
35604
|
+
throw new Error(`${file2}: ${error62.message}`, { cause: error62 });
|
|
35605
|
+
}
|
|
35606
|
+
}
|
|
35607
|
+
return config2;
|
|
35608
|
+
}
|
|
35609
|
+
function loadCompactionConfig(cwd) {
|
|
35610
|
+
const agentDir = process.env.PI_CODING_AGENT_DIR || path2.join(homedir3(), ".pi", "agent");
|
|
35611
|
+
return loadConfig(cwd, agentDir.replace(/^~(?=[/\\]|$)/, homedir3()));
|
|
35559
35612
|
}
|
|
35560
35613
|
function summaryModelLabel(policy) {
|
|
35561
35614
|
return policy.summarizationProvider && policy.summarizationModel ? `${policy.summarizationProvider}/${policy.summarizationModel}` : "Auto (last model that answered, then current request model)";
|
|
@@ -35750,7 +35803,7 @@ var DshBridge = class {
|
|
|
35750
35803
|
host() {
|
|
35751
35804
|
return {
|
|
35752
35805
|
attachmentHome: () => path3.join(
|
|
35753
|
-
this.ctx.sessionManager.getSessionFile() ? path3.dirname(this.ctx.sessionManager.getSessionFile()) : process.env.PI_CODING_AGENT_DIR ?? path3.join(
|
|
35806
|
+
this.ctx.sessionManager.getSessionFile() ? path3.dirname(this.ctx.sessionManager.getSessionFile()) : process.env.PI_CODING_AGENT_DIR ?? path3.join(homedir4(), ".pi/agent"),
|
|
35754
35807
|
".dcp-assets"
|
|
35755
35808
|
),
|
|
35756
35809
|
notify: (message, level) => this.ctx.ui.notify(message, level),
|
|
@@ -35777,7 +35830,8 @@ var DshBridge = class {
|
|
|
35777
35830
|
const host = this.host();
|
|
35778
35831
|
const bundle = await (this.bundle ??= createEngine(
|
|
35779
35832
|
host,
|
|
35780
|
-
this.config.policy
|
|
35833
|
+
this.config.policy,
|
|
35834
|
+
this.config.summaryPrompt
|
|
35781
35835
|
).catch((error62) => {
|
|
35782
35836
|
this.running = false;
|
|
35783
35837
|
this.bundle = void 0;
|
|
@@ -36203,6 +36257,7 @@ var DshBridge = class {
|
|
|
36203
36257
|
checkpoints=${this.records().length}; tokens~${this.lastTokens}
|
|
36204
36258
|
${policy}
|
|
36205
36259
|
${this.summaryModelStatus()}
|
|
36260
|
+
Summary prompt: ${this.config.summaryPrompt?.mode ?? "native"}
|
|
36206
36261
|
Compatibility: fixed model; text/tools/images; no input during compaction
|
|
36207
36262
|
Host: real Cordis plugins, unmodified source snapshot
|
|
36208
36263
|
Persistence: pi append-only log (current branch)`;
|
|
@@ -36228,7 +36283,7 @@ function dcp(pi) {
|
|
|
36228
36283
|
bridge = void 0;
|
|
36229
36284
|
displayContext = ctx;
|
|
36230
36285
|
try {
|
|
36231
|
-
bridge = new DshBridge(pi, ctx, await
|
|
36286
|
+
bridge = new DshBridge(pi, ctx, await loadCompactionConfig(ctx.cwd));
|
|
36232
36287
|
} catch (error62) {
|
|
36233
36288
|
ctx.ui.notify(`dcp: initialization failed: ${String(error62)}`, "error");
|
|
36234
36289
|
}
|
package/docs/compatibility.md
CHANGED
package/docs/help.md
CHANGED
|
@@ -9,23 +9,24 @@ pi install npm:dsh-compact-pi@latest
|
|
|
9
9
|
Use the explicit tag while the npm release has a prerelease version. The GitHub tag is also available:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
pi install git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-
|
|
12
|
+
pi install git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b6
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Restart pi or run `/reload` while idle. `/dcp-status` should show DCP `0.2.
|
|
15
|
+
Restart pi or run `/reload` while idle. `/dcp-status` should show DCP `0.2.3b6` and DSH `0.2.3-alpha.2`. DCP is tested with pi 1.5.2 and 1.6.1 and needs Node.js `^24.22.3 || >=26.13.1`. Check `pi list` for duplicate installations if commands or warnings appear twice. See the [update instructions](../README.md#updating-an-existing-installation) for pinned tags and branch installs.
|
|
16
16
|
|
|
17
17
|
## Compaction and model selection
|
|
18
18
|
|
|
19
19
|
- `/dcp-compact` runs manual DSH compaction when pi is idle. The ordinary `/compact` command also reaches DCP when pi admits the operation.
|
|
20
20
|
- `/dcp-summary-model` opens a picker for the project default summary model. The chosen model writes the summary and the active session model continues the conversation.
|
|
21
21
|
- `/dcp-summary-model reset` restores automatic summary model selection for the project default. DSH prefers the last model that answered, then the most recent request route. An exact `modelPolicies` override still takes precedence.
|
|
22
|
+
- To customize the summary instruction, set `summaryPrompt` in the project's `.pi/dcp.json` or set a user-wide default in the Pi agent directory's `dcp.json`. The project setting takes precedence. Use `native` for the upstream prompt, `override` for your own prompt, or `append` to add guidance to the upstream prompt. Run `/reload` while idle and check the mode with `/dcp-status`. See the [configuration example](../README.md#custom-compaction-prompt).
|
|
22
23
|
- Expand a compaction card with `Ctrl+O` to check the engine, model and token estimates. See the [policy settings](../README.md#configuration) for pressure, retention and output budgets.
|
|
23
24
|
|
|
24
25
|
If a historical summary model is unavailable in pi, use the picker to select an available model. If a model has a small context window, check `/dcp-status` and set a headroom budget that fits. An unsupported attachment warning leaves the original context available. Use the exact warning and the version shown by `/dcp-status` when reporting a problem.
|
|
25
26
|
|
|
26
27
|
## Move a session between pi and DSH
|
|
27
28
|
|
|
28
|
-
Run `dcp-session migrate` in a terminal, or ask the `dcp-migrate-to-dsh` skill to guide you. The
|
|
29
|
+
Run `dcp-session migrate` in a terminal, or ask the `dcp-migrate-to-dsh` skill to guide you. The skill asks one key question at a time and waits for your answer. Once the destination and any conflicts are settled, it shows the exact output path and asks whether to write. Agents use `migrate plan` and `migrate apply` to keep the preview and write separate. See the [command examples](../skills/dcp-migrate-to-dsh/references/commands.md).
|
|
29
30
|
|
|
30
31
|
- **Portable export** writes a new folder under the export directory you choose. Move that whole folder to keep the JSONL and images together.
|
|
31
32
|
- **Direct import** uses the target backend's version, profile, data home, session directory, workspace, and encoding. Run on the target machine. On Windows, use Windows Node.js and Windows paths. On Linux, use the data paths of the backend your desktop client actually connects to.
|
|
@@ -33,6 +34,24 @@ Run `dcp-session migrate` in a terminal, or ask the `dcp-migrate-to-dsh` skill t
|
|
|
33
34
|
|
|
34
35
|
The import receipt confirms a write. Open the imported history in the chosen Desktop or TUI, or run `migrate verify-web` to check both the list and history of the approved Web instance.
|
|
35
36
|
|
|
37
|
+
### Import from DSH into Pi
|
|
38
|
+
|
|
39
|
+
In the Pi workspace where you want to use the imported conversation, say “从 DSH 导入一个会话” or run `/skill:dcp-import-from-dsh`. The skill checks local DSH backends, shows sessions from the selected backend, then asks where Pi should store the import. Confirm the Pi workspace and exact output path before writing. Open `/resume` in the confirmed workspace or use the receipt's `pi --session` arguments.
|
|
40
|
+
|
|
41
|
+
To make a local backend available by name, add `dshBackends` to the current project's `.pi/dcp.json`. Each name maps to an absolute `home` for the DSH data and attachments, and optionally an absolute `sessionRoot` if it differs from `<home>/sessions`.
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"dshBackends": {
|
|
46
|
+
"desktop": { "home": "/home/you/.dsh-desktop" }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Without a recorded backend, DCP suggests readable local stores from `DSH_HOME` and the default `~/.dsh`. You can supply another data home and session root from the same machine. The selector supports DSH v4 plaintext and Zstandard logs. Use Windows paths when running on native Windows. On the command line, `dcp-session import-dsh --help` lists the same five scripted steps.
|
|
52
|
+
|
|
53
|
+
### Low-level conversion
|
|
54
|
+
|
|
36
55
|
The CLI can also run low-level conversions for scripts. In a checkout use `node dist/dcp-session.mjs --help`. Exit the active source session or work from a copy.
|
|
37
56
|
|
|
38
57
|
```bash
|
package/docs/publishing.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Publishing dsh-compact-pi
|
|
2
2
|
|
|
3
|
-
Use Node.js `^24.22.3 || >=26.13.1`. The package version `0.2.3-
|
|
3
|
+
Use Node.js `^24.22.3 || >=26.13.1`. The package version `0.2.3-b6` corresponds to the displayed version `0.2.3b6`. Keep the upstream DSH base version and increment the DCP build suffix for subsequent releases.
|
|
4
4
|
|
|
5
5
|
## Verify a release
|
|
6
6
|
|
|
@@ -21,13 +21,13 @@ See [testing](testing.md) for the resume and migration matrix. If the source sna
|
|
|
21
21
|
Authenticate interactively with `npm login`, then verify the intended publisher with `npm whoami`. Do not put authentication tokens in this repository.
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
npm publish ./dsh-compact-pi-0.2.3-
|
|
24
|
+
npm publish ./dsh-compact-pi-0.2.3-b6.tgz --access public --tag latest
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
The package's `publishConfig` defaults to the public npm registry and the `beta` tag for candidate builds. Use the tested tarball and set `--tag latest` for the public release. Verify with `npm view dsh-compact-pi dist-tags`. Users can install with `pi install npm:dsh-compact-pi@latest` or pin the exact version.
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
|
-
pi install npm:dsh-compact-pi@0.2.3-
|
|
30
|
+
pi install npm:dsh-compact-pi@0.2.3-b6
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
Restart pi or run `/reload`, then `/dcp-status`. Remove a previous local DCP package entry before loading the published package to avoid registering the extension twice. Run `pi list` to identify the installed source and `pi remove <source>` to remove it.
|
|
@@ -39,7 +39,7 @@ The package is listed in the [Pi package catalog](https://pi.dev/packages/dsh-co
|
|
|
39
39
|
GitHub also hosts tagged releases:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
pi install git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-
|
|
42
|
+
pi install git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b6
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
A Git release must include `dist/`, `vendor/` and the package manifest so installing it does not require development dependencies or an upstream checkout. Tag only the verified release commit. Keep source provenance and third-party licenses in the repository and tarball.
|
package/docs/testing.md
CHANGED
|
@@ -19,8 +19,25 @@ The resume test installs the built npm tarball in a temporary directory and load
|
|
|
19
19
|
|
|
20
20
|
Run `node --import tsx --test test/migration.test.ts` on Windows or Linux to test explicit destination selection, read-only planning, stale plans, duplicate IDs, encoding conflicts, and opt-in recovery of Pi entries. The GitHub Actions matrix runs this test on both hosts. For desktop release checks, also open a synthetic imported session in the target app and verify its history.
|
|
21
21
|
|
|
22
|
+
The reverse workflow test probes configured and missing local stores, lists a Zstandard session from a custom store, and imports it into a different Pi workspace. It uses Pi's own session manager to open the history and confirm that the default picker lists it from the chosen workspace.
|
|
23
|
+
|
|
22
24
|
The test also generates a native pi checkpoint and a separate snapshot cut at the DCP journal commit using an earlier DCP release. On the candidate pi it checks that the next provider request contains the old summary, a retained message and the new user request. It disables fresh summarization during replay so a lost checkpoint fails the test. It runs the CLI in both directions, checking for inactive branch leakage, native context edits, archive fidelity and continued work after adding a message in DSH.
|
|
23
25
|
|
|
24
26
|
The baseline bundle comes from Git commit `1f43099c0273a3edcbe5353a4aaf32884efd1fc9`. The candidate pi package is installed from npm into a temporary directory. If a shallow clone lacks the baseline, fetch the `v0.2.2-b3` tag before running the test. Other builds and the unit suite can run without that Git history.
|
|
25
27
|
|
|
26
28
|
The **Pi session compatibility** workflow runs the same test on Ubuntu and native Windows for pi 1.5.2 and the candidate version. Run it manually with an exact candidate pi version before extending the supported matrix. On Windows, run `npm ci` and `npm run test:resume -- 1.6.1` in a native terminal with Windows Node.js and Git for Windows available on `PATH`. Both platforms use stubbed provider responses to verify session behavior. Summary quality with a live model is outside the test's scope.
|
|
29
|
+
|
|
30
|
+
## Observation: task corrections carry over after compaction
|
|
31
|
+
|
|
32
|
+
**Status: observe over time.** In a November 2026 zup session, the user clarified that a specific prompt-enhancement workflow took a reference image and used I2I. The checkpoint restated that choice as a general preference. The reported symptom was that later workflow designs also used I2I, including when the new task called for a fresh image from text. How often this occurs in normal long-running sessions remains open.
|
|
33
|
+
|
|
34
|
+
In a controlled replay, DeepSeek Flash planned a separate poster workflow whose form had exactly three text fields. Each condition ran eight times. Both checkpoint variants also preserved the reference-image input when resuming the original enhancer in all eight trials.
|
|
35
|
+
|
|
36
|
+
| Behavior on the new task | Recorded wording | Correction scoped to the original workflow | No checkpoint |
|
|
37
|
+
|---|---:|---:|---:|
|
|
38
|
+
| Added a required reference image | 5/8 | 1/8 | 0/8 |
|
|
39
|
+
| Included I2I in the processing steps | 7/8 | 6/8 | 0/8 |
|
|
40
|
+
|
|
41
|
+
Explicit scope reduced the extra input requirement in this fixture. I2I routing persisted in six of eight scoped trials. Keep the scope rule in the experiment and retain the existing default summary behavior while collecting more cases. For future reports, record the DCP and DSH versions, model, compaction trigger, a redacted correction with its original task, and what the subsequent plan actually did. Check both required inputs and processing steps.
|
|
42
|
+
|
|
43
|
+
The optional harness uses Pi's configured credentials and sends a de-identified fixture. Run `node --import tsx scripts/test-correction-scope.ts deepseek deepseek-flash 8 text-form` to reproduce the fixed-form test. Use `checkpoint` for the less constrained poster request or `summaries` for two successive compactions before continuation. The harness prints the checkpoints or workflow plans as JSON for review.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-compact-pi",
|
|
3
|
-
"version": "0.2.3-
|
|
4
|
-
"dcpVersion": "0.2.
|
|
3
|
+
"version": "0.2.3-b6",
|
|
4
|
+
"dcpVersion": "0.2.3b6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "DeepSeek Harness context compaction for pi: upstream engine, policy, token meter and pruner",
|
|
7
7
|
"repository": {
|
|
@@ -142,6 +142,10 @@ try {
|
|
|
142
142
|
await loader.reload()
|
|
143
143
|
assert.deepEqual(loader.getExtensions().errors, [])
|
|
144
144
|
assert.equal(loader.getExtensions().extensions.length, 1)
|
|
145
|
+
assert.ok(existsSync(path.join(installed, 'skills/dcp-import-from-dsh/SKILL.md')))
|
|
146
|
+
const reverseCli = path.join(installed, 'dist/dcp-session.mjs')
|
|
147
|
+
const probe = JSON.parse(execFileSync(process.execPath, [reverseCli, 'import-dsh', 'probe'], { cwd: dir, encoding: 'utf8' }))
|
|
148
|
+
assert.equal(probe.status, 'no-configured-backend')
|
|
145
149
|
execFileSync(
|
|
146
150
|
process.execPath,
|
|
147
151
|
[
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/** Paired live test. Uses Pi's configured model and synthetic, de-identified dialogue. */
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
import { mkdtemp, rm } from 'node:fs/promises'
|
|
4
|
+
import { tmpdir } from 'node:os'
|
|
5
|
+
import path from 'node:path'
|
|
6
|
+
import { ModelRuntime } from '@earendil-works/pi-coding-agent'
|
|
7
|
+
import { createEngine, enterSession } from '../src/dsh/engine.ts'
|
|
8
|
+
import { createSession } from '../src/dsh/session.ts'
|
|
9
|
+
import { createSyncState, syncPiEntries, closeTurn } from '../src/dsh/sync.ts'
|
|
10
|
+
|
|
11
|
+
const [provider = 'deepseek', modelId = 'deepseek-flash', trials = '1', scenario = 'summaries'] = process.argv.slice(2)
|
|
12
|
+
const attempts = Number(trials)
|
|
13
|
+
assert.ok(Number.isInteger(attempts) && attempts > 0 && attempts <= 10)
|
|
14
|
+
assert.ok(['summaries', 'checkpoint', 'text-form'].includes(scenario), 'Choose summaries, checkpoint, or text-form')
|
|
15
|
+
const runtime = await ModelRuntime.create({ refreshOnCreate: false })
|
|
16
|
+
const model = runtime.getModel(provider, modelId)
|
|
17
|
+
assert.ok(model, `Missing configured model ${provider}/${modelId}`)
|
|
18
|
+
const root = await mkdtemp(path.join(tmpdir(), 'dcp-scope-'))
|
|
19
|
+
const system = 'You are a coding assistant collaborating on image-generation workflows.'
|
|
20
|
+
const suffix = '\n\n' + [
|
|
21
|
+
'When recording a user correction, keep its object, triggering condition, and scope together.',
|
|
22
|
+
'Record a correction as task-specific unless the user explicitly made it a standing preference. Name the work item even when the surrounding conversation will be removed.',
|
|
23
|
+
'When merging a prior checkpoint, preserve these scope limits. If the scope of an old correction is unclear, mark it as unclear and avoid applying it to other tasks.',
|
|
24
|
+
].join('\n')
|
|
25
|
+
|
|
26
|
+
type Turn = [role: 'user' | 'assistant', text: string]
|
|
27
|
+
// Reconstructed from the PE mini-project: a nearby, unrelated T2I preset and
|
|
28
|
+
// a correction about the standalone PE that receives a reference image.
|
|
29
|
+
const caseHistory: Turn[] = [
|
|
30
|
+
['user', 'Park the seed and LoRA investigation on the existing T2I preset. I want to extract the Qwen-Image-2.1 prompt enhancer into its own standalone workflow.'],
|
|
31
|
+
['assistant', 'I extracted the prompt enhancer from the image editing workflow. It rewrites prompts for Qwen Image.'],
|
|
32
|
+
['user', 'Stop changing the workflow for a moment. I need the accelerated local model to turn the prompt I enter into a suitable Qwen Image prompt. Let us align on the task first.'],
|
|
33
|
+
['assistant', 'If the input is just text, I would use the T2I prompt enhancer.'],
|
|
34
|
+
['user', 'Who said I wanted T2I? I want I2I.'],
|
|
35
|
+
['assistant', 'Will you also provide a reference image?'],
|
|
36
|
+
['user', 'Of course I will provide a reference image as well.'],
|
|
37
|
+
['assistant', 'Understood. Input is a reference image and an edit instruction; output is a rewritten prompt.'],
|
|
38
|
+
]
|
|
39
|
+
// DSH rejects a framed checkpoint that is larger than its input. Supply
|
|
40
|
+
// compressible background in both rounds without adding scope instructions.
|
|
41
|
+
const background: Turn[] = [
|
|
42
|
+
['user', 'The earlier build diagnostics are now complete.'],
|
|
43
|
+
['assistant', Array.from({ length: 120 }, (_, index) =>
|
|
44
|
+
`Read-only fixture check ${index + 1}: input schema and registry diagnostic both passed.`,
|
|
45
|
+
).join('\n')],
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
async function summarize(history: Turn[], scoped: boolean) {
|
|
49
|
+
const signal = AbortSignal.timeout(90000)
|
|
50
|
+
const bundle = await createEngine({
|
|
51
|
+
attachmentHome: () => root,
|
|
52
|
+
model: () => model,
|
|
53
|
+
findModel: () => model,
|
|
54
|
+
systemPrompt: () => system,
|
|
55
|
+
complete: async (_model, context, options) => {
|
|
56
|
+
const block = context.messages.at(-1).content[0]
|
|
57
|
+
assert.ok(block.text.startsWith('You are now acting as a compaction engine'))
|
|
58
|
+
if (scoped) block.text += suffix
|
|
59
|
+
return runtime.complete(model, context, options)
|
|
60
|
+
},
|
|
61
|
+
}, { headroomTokens: 512, retainTokens: 32, maxTokens: 2048 })
|
|
62
|
+
const { session } = createSession('scope-test-' + crypto.randomUUID())
|
|
63
|
+
const leave = enterSession(bundle, session)
|
|
64
|
+
try {
|
|
65
|
+
const state = createSyncState()
|
|
66
|
+
const items: Turn[] = [
|
|
67
|
+
...background,
|
|
68
|
+
...history,
|
|
69
|
+
['user', 'Hold there for now. I will specify which work item to continue next.'],
|
|
70
|
+
]
|
|
71
|
+
syncPiEntries(session, [
|
|
72
|
+
{ type: 'message', id: 'system', message: { role: 'system', content: system } },
|
|
73
|
+
], state)
|
|
74
|
+
session.append('request/header', {
|
|
75
|
+
header: { config: { provider, model: modelId, maxTokens: model.maxTokens } },
|
|
76
|
+
reason: 'initial',
|
|
77
|
+
})
|
|
78
|
+
syncPiEntries(session, items.map(([role, text], index) => ({
|
|
79
|
+
type: 'message', id: `input-${index}`,
|
|
80
|
+
message: role === 'user' ? { role, content: text } : {
|
|
81
|
+
role, provider, model: modelId, stopReason: 'stop',
|
|
82
|
+
content: [{ type: 'text', text }],
|
|
83
|
+
},
|
|
84
|
+
})), state)
|
|
85
|
+
closeTurn(session, state)
|
|
86
|
+
bundle.flush = async () => {}
|
|
87
|
+
await bundle.engine.compactNow({
|
|
88
|
+
session, options: { provider, model: modelId },
|
|
89
|
+
runMaintenance: task => task(signal),
|
|
90
|
+
}, signal)
|
|
91
|
+
const checkpoint = session.surface.nodes
|
|
92
|
+
.map(seq => session.deriveEventMessage(session.eventAt(seq)!))
|
|
93
|
+
.find(message => message?.source?.kind === 'compact-checkpoint')
|
|
94
|
+
assert.ok(checkpoint, 'Expected compaction to produce a real checkpoint')
|
|
95
|
+
return checkpoint.content.map((block: { text?: string }) => block.text).join('\n')
|
|
96
|
+
} finally {
|
|
97
|
+
leave()
|
|
98
|
+
await bundle.ctx.fiber.dispose()
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const followups = [
|
|
103
|
+
['resumeA', 'Resume the standalone prompt enhancer we aligned on. Which kind of input should I wire up?', 'I2I'],
|
|
104
|
+
['newB', 'New work item: generate an entirely new product poster from a text brief. I have no input image. What workflow mode should this work item use?', 'T2I'],
|
|
105
|
+
['newUnspecified', 'Separate new workflow for product posters. I have not said whether there will be an input image. Is either workflow mode already required for this new work item?', 'UNCLEAR'],
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
async function completeText(checkpoint: string | undefined, request: string) {
|
|
109
|
+
const result = await runtime.complete(model, {
|
|
110
|
+
systemPrompt: system,
|
|
111
|
+
messages: [
|
|
112
|
+
...(checkpoint ? [{ role: 'user' as const, content: checkpoint, timestamp: 1 }] : []),
|
|
113
|
+
{ role: 'user', content: request, timestamp: 2 },
|
|
114
|
+
],
|
|
115
|
+
}, { maxTokens: 2048, signal: AbortSignal.timeout(90000) })
|
|
116
|
+
if (result.stopReason === 'error' || result.stopReason === 'aborted')
|
|
117
|
+
throw new Error(result.errorMessage ?? result.stopReason)
|
|
118
|
+
return result.content.flatMap(block => block.type === 'text' ? [block.text.trim()] : []).join('\n')
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// A redacted extract of the recorded zup checkpoint. Change only the scope
|
|
122
|
+
// of the two statements that generalized the correction.
|
|
123
|
+
const checkpoint = `This is an automatically generated checkpoint condensing an earlier span of the conversation to free up context. Treat the captured context as established background and build on it without restating it. Continue the task directly from the messages that follow, without acknowledging this checkpoint.
|
|
124
|
+
|
|
125
|
+
<compacted-summary>
|
|
126
|
+
## Primary Request and Intent
|
|
127
|
+
- Extract the prompt enhancer into its own standalone workflow.
|
|
128
|
+
- The assistant suggested T2I. The user corrected the choice to I2I.
|
|
129
|
+
## Key Technical Concepts
|
|
130
|
+
- Qwen Image has separate PE-I2I (reference image and edit instruction) and PE-T2I (text brief) prompt enhancers. User wants **I2I only**.
|
|
131
|
+
## Critical Context
|
|
132
|
+
- Work on the existing T2I preset is parked.
|
|
133
|
+
- User explicitly wants **I2I**, not T2I; will always supply a reference image.
|
|
134
|
+
</compacted-summary>`
|
|
135
|
+
const scopedCheckpoint = checkpoint
|
|
136
|
+
.replace('User wants **I2I only**.', 'For the standalone prompt enhancer, the user wants **I2I only**.')
|
|
137
|
+
.replace('User explicitly wants **I2I**, not T2I; will always supply a reference image.', 'For this standalone prompt enhancer, the user wants **I2I**, not T2I, and will supply a reference image.')
|
|
138
|
+
|
|
139
|
+
async function comparePlans(trial: number, arm: 'recorded' | 'scoped' | 'no-checkpoint') {
|
|
140
|
+
const newWorkflow = scenario === 'text-form'
|
|
141
|
+
? '另做一个读书会活动海报工作流。表单固定就三个字段:活动名称、主题、配色。输出一张新的活动海报。先列出运行所需的输入项和主要处理节点。'
|
|
142
|
+
: '另做一个商品宣传海报工作流,从表单里填商品名称、卖点和画面风格,输出一张新的宣传海报。先列出我需要填写或上传的输入项和主要处理节点。'
|
|
143
|
+
const probes = [
|
|
144
|
+
['resumeA', '继续做刚才那个独立提示词增强工作流。先列出我需要填写或上传的输入项和主要处理节点。', true],
|
|
145
|
+
['newB', newWorkflow, false],
|
|
146
|
+
] as const
|
|
147
|
+
const selected = arm === 'no-checkpoint' ? probes.slice(1) : probes
|
|
148
|
+
const context = arm === 'scoped' ? scopedCheckpoint : arm === 'recorded' ? checkpoint : undefined
|
|
149
|
+
const results = await Promise.all(selected.map(async ([name, request, expectedImage]) => {
|
|
150
|
+
const answer = await completeText(context, request +
|
|
151
|
+
'\n只输出 JSON:{"requiredInputs":[{"name":"输入名称","type":"text/image/number/other"}],"steps":["处理步骤"]}。requiredInputs 只列运行所需输入。')
|
|
152
|
+
const json = answer.trim().replace(/^\x60\x60\x60(?:json)?\s*|\s*\x60\x60\x60$/gi, '')
|
|
153
|
+
const plan = JSON.parse(json)
|
|
154
|
+
assert.ok(Array.isArray(plan.requiredInputs) && Array.isArray(plan.steps), 'Expected workflow plan JSON')
|
|
155
|
+
const requiredImage = plan.requiredInputs.some((input: { type: string }) => input.type.toLowerCase() === 'image')
|
|
156
|
+
const editingSteps = plan.steps.filter((step: string) => /\bi2i\b|图生图|image-to-image|img2img/i.test(step))
|
|
157
|
+
return { name, expectedImage, requiredImage, editingSteps, plan }
|
|
158
|
+
}))
|
|
159
|
+
console.log(JSON.stringify({ trial, arm, results }))
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
for (let trial = 1; trial <= attempts; trial++) {
|
|
164
|
+
if (scenario !== 'summaries') {
|
|
165
|
+
await Promise.all([comparePlans(trial, 'recorded'), comparePlans(trial, 'scoped')])
|
|
166
|
+
await comparePlans(trial, 'no-checkpoint')
|
|
167
|
+
continue
|
|
168
|
+
}
|
|
169
|
+
await Promise.all([false, true].map(async scoped => {
|
|
170
|
+
const first = await summarize(caseHistory, scoped)
|
|
171
|
+
const second = await summarize([
|
|
172
|
+
['user', first],
|
|
173
|
+
['assistant', 'The standalone workflow design is aligned. We can continue once a work item is specified.'],
|
|
174
|
+
], scoped)
|
|
175
|
+
const results = await Promise.all(followups.map(async ([name, request, expected]) => {
|
|
176
|
+
const answer = await completeText(second, request! + '\nStart your answer with exactly one of: I2I, T2I, or UNCLEAR. Then give a one-sentence reason.')
|
|
177
|
+
return { name, expected, actual: answer.match(/\b(I2I|T2I|UNCLEAR)\b/i)?.[0]?.toUpperCase(), answer }
|
|
178
|
+
}))
|
|
179
|
+
console.log(JSON.stringify({
|
|
180
|
+
trial, arm: scoped ? 'scoped' : 'upstream',
|
|
181
|
+
summary1: first, summary2: second, results,
|
|
182
|
+
}))
|
|
183
|
+
}))
|
|
184
|
+
}
|
|
185
|
+
} finally {
|
|
186
|
+
await rm(root, { recursive: true, force: true })
|
|
187
|
+
}
|
package/scripts/test-resume.mjs
CHANGED
|
@@ -272,7 +272,7 @@ if (dir) {
|
|
|
272
272
|
const temporary = mkdtempSync(path.join(os.tmpdir(), 'dcp-pi-resume-'))
|
|
273
273
|
try {
|
|
274
274
|
const result = spawnSync(process.execPath, [import.meta.filename, candidate], {
|
|
275
|
-
env: { ...process.env, DCP_TEST_WORK_DIR: temporary },
|
|
275
|
+
env: { ...process.env, DCP_TEST_WORK_DIR: temporary, PI_CODING_AGENT_DIR: path.join(temporary, 'agent') },
|
|
276
276
|
stdio: 'inherit',
|
|
277
277
|
})
|
|
278
278
|
if (result.error) throw result.error
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dcp-import-from-dsh
|
|
3
|
+
description: Import an existing DeepSeek Harness session into the local Pi session picker with a confirmed backend, session, and destination. Use for DSH-to-Pi session migration.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Import a DSH session into Pi
|
|
7
|
+
|
|
8
|
+
Use `dcp-session import-dsh` for every step. If the command is unavailable, use `node <DCP-package-root>/dist/dcp-session.mjs import-dsh` from the installation that contains this skill. Run `--help` to see arguments. Run on the machine where the destination Pi runs and use that host's native paths. Use the directory where the user is working as the script's project or pass it explicitly with `--project`.
|
|
9
|
+
|
|
10
|
+
Ask one question and wait for the reply before proceeding. Use a host selection tool when available and include an option to enter a different answer. Otherwise ask in chat and wait. Show short choices in the user's language.
|
|
11
|
+
|
|
12
|
+
1. **Backend.** Run `probe`. If a single configured backend is available, use it unless the user names another. If none is configured, tell the user and offer the available suggestions plus a custom local DSH home. If a configured backend is unavailable or several are configured, report the result and ask which to use or what path to correct. Use `--backend <name>` or the explicit custom `--dsh-home <dir>` and, when supplied, `--session-root <dir>` in the following commands. These are local DSH data stores. Ask for local data paths if the user only knows a remote URL or desktop client name.
|
|
13
|
+
2. **Session.** Run `sessions` with that backend. Offer the returned sessions by project, date, and ID. Offer another page or a project filter when needed. Ask the user to choose an exact session. Pass that returned ID to `plan`.
|
|
14
|
+
3. **Destination.** Run `destination` for the current Pi workspace. Ask whether to import into that workspace or a different one. Show the actual Pi session directory alongside the workspace and offer a custom destination. If the user selects another workspace or uses a separate Pi profile or session directory, rerun `destination` with the applicable `--workspace`, `--pi-home` or `--session-dir`. Importing an old DSH project into the current Pi project is valid when the user chooses it.
|
|
15
|
+
4. **Approval.** Run `plan` with the selected backend and session, destination options and a fresh `--plan-file` in a temporary directory. On a duplicate, ask whether to stop or import a copy with a new ID. Use `--on-conflict copy` only if chosen. Show a short preview with the source, Pi workspace, and exact output path. Ask for approval to write. Only after that approval, run `apply --plan-file <file> --confirm <code>` using the plan's code. If the plan goes stale, show the new plan and ask again.
|
|
16
|
+
|
|
17
|
+
Report the receipt and tell the user which workspace to open in Pi. The script verifies both history and picker lookup. Include the exact `pi` resume arguments from the receipt if helpful. Keep raw plan JSON and session contents out of the conversation. Leave the new session idle.
|