pi-deltabox 0.1.6 → 0.1.7
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/README.md +16 -13
- package/dist/client.js +17 -2
- package/dist/commands.js +58 -11
- package/dist/config.js +2 -0
- package/dist/extension.js +25 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -50,9 +50,9 @@ for low-latency byte I/O. Linux and macOS also reuse an isolated Bash worker.
|
|
|
50
50
|
as compatibility fallbacks.
|
|
51
51
|
- **Three review modes** — review everything at the end of a task, after every
|
|
52
52
|
tool call, or only after risky calls.
|
|
53
|
-
- **Slash commands** — `/
|
|
54
|
-
`/
|
|
55
|
-
`/
|
|
53
|
+
- **Slash commands** — `/deltabox-status`, `/deltabox-review`,
|
|
54
|
+
`/deltabox-commit`, `/deltabox-abort`, `/deltabox-sync`, `/deltabox-skip`,
|
|
55
|
+
`/deltabox-diff`, `/deltabox-mode`, `/deltabox-exit`.
|
|
56
56
|
- **End-of-task nudge** — when a task finishes with pending changes, Pi tells
|
|
57
57
|
you to review, commit, or abort them.
|
|
58
58
|
|
|
@@ -122,6 +122,7 @@ or both. Project values are merged over user-wide values, including nested
|
|
|
122
122
|
"durability": "fast",
|
|
123
123
|
"groupCommitMs": null
|
|
124
124
|
},
|
|
125
|
+
"exit": "abort",
|
|
125
126
|
"review": {
|
|
126
127
|
"mode": "task"
|
|
127
128
|
}
|
|
@@ -144,7 +145,7 @@ provider supports it.
|
|
|
144
145
|
|
|
145
146
|
The extension reports the requested mode, resolved mode, provider, visibility,
|
|
146
147
|
durability, rollback guarantee, fallback reason, and taint state through
|
|
147
|
-
`/
|
|
148
|
+
`/deltabox-status`. Fallback and unsafe rollback conditions are also shown as Pi
|
|
148
149
|
notifications.
|
|
149
150
|
|
|
150
151
|
### Review modes
|
|
@@ -167,13 +168,15 @@ reached.
|
|
|
167
168
|
|
|
168
169
|
| Command | Description |
|
|
169
170
|
|---|---|
|
|
170
|
-
| `/
|
|
171
|
-
| `/
|
|
172
|
-
| `/
|
|
173
|
-
| `/
|
|
174
|
-
| `/
|
|
175
|
-
| `/
|
|
176
|
-
| `/
|
|
171
|
+
| `/deltabox-status` | Show session status, exit policy, and pending change count |
|
|
172
|
+
| `/deltabox-review` | Show the pending diff |
|
|
173
|
+
| `/deltabox-commit` | Apply pending changes to the real project |
|
|
174
|
+
| `/deltabox-abort` | Discard changes back to the active review scope |
|
|
175
|
+
| `/deltabox-sync` | Sync sibling commits and list stale paths or conflict copies in a private session |
|
|
176
|
+
| `/deltabox-skip` | Keep changes pending and preserve the current rollback point |
|
|
177
|
+
| `/deltabox-diff [from] [to]` | Diff between checkpoints |
|
|
178
|
+
| `/deltabox-mode [task\|tool\|risky]` | Show or switch review mode at runtime |
|
|
179
|
+
| `/deltabox-exit [abort\|commit]` | Show or set the session exit policy for uncommitted changes |
|
|
177
180
|
|
|
178
181
|
## How it works
|
|
179
182
|
|
|
@@ -185,7 +188,7 @@ reached.
|
|
|
185
188
|
client rather than creating another backend session.
|
|
186
189
|
3. `none`-isolation project reads and writes use the controlled mount directly; native
|
|
187
190
|
Buffer methods handle fallback paths without JSON or Base64.
|
|
188
|
-
4. `/
|
|
191
|
+
4. `/deltabox-commit` accepts the current view; `/deltabox-abort` restores the
|
|
189
192
|
active review scope. In through mode, host visibility is immediate. In
|
|
190
193
|
private modes, publication happens at commit.
|
|
191
194
|
5. Set `"transport": "serve"` or `"cli"` only when native loading is not
|
|
@@ -193,7 +196,7 @@ reached.
|
|
|
193
196
|
6. If Pi is killed or crashes without stopping its session, the next start
|
|
194
197
|
**recovers** it instead of starting fresh: the session keeps its pending
|
|
195
198
|
changes and its open review, and a notice tells you to settle them with
|
|
196
|
-
`/
|
|
199
|
+
`/deltabox-review`, then `/deltabox-commit` or `/deltabox-abort`. Nothing is
|
|
197
200
|
committed or reverted on your behalf. This needs a deltabox-lite addon with
|
|
198
201
|
session ownership (native transport). If a session start fails, the next
|
|
199
202
|
turn, tool call, or command retries it.
|
package/dist/client.js
CHANGED
|
@@ -86,8 +86,8 @@ export function recoveryNotices(recovery, project) {
|
|
|
86
86
|
const next = recovery.pendingChanges === 0
|
|
87
87
|
? "It has no pending changes."
|
|
88
88
|
: recovery.reviewActive
|
|
89
|
-
? `It has ${recovery.pendingChanges} pending change(s); use /
|
|
90
|
-
: `It has ${recovery.pendingChanges} pending change(s); use /
|
|
89
|
+
? `It has ${recovery.pendingChanges} pending change(s); use /deltabox-review, then /deltabox-commit or /deltabox-abort.`
|
|
90
|
+
: `It has ${recovery.pendingChanges} pending change(s); use /deltabox-diff to inspect them.`;
|
|
91
91
|
notices.push({
|
|
92
92
|
code: "recovered",
|
|
93
93
|
level: "warning",
|
|
@@ -598,6 +598,21 @@ export class DeltaboxClient {
|
|
|
598
598
|
args.push("--to", to);
|
|
599
599
|
return this.parse(await this.cli(args));
|
|
600
600
|
}
|
|
601
|
+
async sync() {
|
|
602
|
+
if (this.transport === "native") {
|
|
603
|
+
const native = this.nativeRequired();
|
|
604
|
+
if (!native.sync) {
|
|
605
|
+
throw new Error("Upgrade the Deltabox native addon to a build with session sync support.");
|
|
606
|
+
}
|
|
607
|
+
return native.sync(this.id());
|
|
608
|
+
}
|
|
609
|
+
if (this.transport === "serve") {
|
|
610
|
+
return (await this.request("session.sync", {
|
|
611
|
+
session_id: this.id(),
|
|
612
|
+
}));
|
|
613
|
+
}
|
|
614
|
+
return this.parse(await this.cli(["sync", this.id(), ...this.projectArgs()]));
|
|
615
|
+
}
|
|
601
616
|
async commit(checkpoint) {
|
|
602
617
|
if (this.transport === "native") {
|
|
603
618
|
return this.nativeRequired().commit(this.id(), checkpoint);
|
package/dist/commands.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { renderDiff } from "./format.js";
|
|
2
2
|
export function registerCommands(pi,
|
|
3
3
|
/** Resolves the started client; `ctx` receives any start notices. */
|
|
4
|
-
getClient, getConfig, setMode) {
|
|
5
|
-
pi.registerCommand("
|
|
4
|
+
getClient, getConfig, setMode, setExitPolicy = () => undefined) {
|
|
5
|
+
pi.registerCommand("deltabox-status", {
|
|
6
6
|
description: "Show deltabox-lite session status and pending change count",
|
|
7
7
|
handler: async (_args, ctx) => {
|
|
8
8
|
const client = await getClient(ctx);
|
|
@@ -18,6 +18,7 @@ getClient, getConfig, setMode) {
|
|
|
18
18
|
`Visibility: ${status.host_visibility}`,
|
|
19
19
|
`Durability: ${status.durability}`,
|
|
20
20
|
`Rollback: ${status.rollback_guarantee}${status.tainted ? " (tainted)" : ""}`,
|
|
21
|
+
`Exit policy: ${getConfig().exit}`,
|
|
21
22
|
...(status.fallback_reason ? [`Fallback: ${status.fallback_reason}`] : []),
|
|
22
23
|
].join("\n"), "info");
|
|
23
24
|
}
|
|
@@ -26,7 +27,7 @@ getClient, getConfig, setMode) {
|
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
});
|
|
29
|
-
pi.registerCommand("
|
|
30
|
+
pi.registerCommand("deltabox-review", {
|
|
30
31
|
description: "Show the pending diff",
|
|
31
32
|
handler: async (_args, ctx) => {
|
|
32
33
|
const client = await getClient(ctx);
|
|
@@ -40,7 +41,7 @@ getClient, getConfig, setMode) {
|
|
|
40
41
|
}
|
|
41
42
|
},
|
|
42
43
|
});
|
|
43
|
-
pi.registerCommand("
|
|
44
|
+
pi.registerCommand("deltabox-commit", {
|
|
44
45
|
description: "Commit pending changes to the real project",
|
|
45
46
|
handler: async (_args, ctx) => {
|
|
46
47
|
const client = await getClient(ctx);
|
|
@@ -53,7 +54,7 @@ getClient, getConfig, setMode) {
|
|
|
53
54
|
}
|
|
54
55
|
},
|
|
55
56
|
});
|
|
56
|
-
pi.registerCommand("
|
|
57
|
+
pi.registerCommand("deltabox-abort", {
|
|
57
58
|
description: "Abort pending changes back to the head checkpoint",
|
|
58
59
|
handler: async (_args, ctx) => {
|
|
59
60
|
const client = await getClient(ctx);
|
|
@@ -66,7 +67,32 @@ getClient, getConfig, setMode) {
|
|
|
66
67
|
}
|
|
67
68
|
},
|
|
68
69
|
});
|
|
69
|
-
pi.registerCommand("
|
|
70
|
+
pi.registerCommand("deltabox-sync", {
|
|
71
|
+
description: "Sync sibling commits and list paths to reconcile in a private session",
|
|
72
|
+
handler: async (args, ctx) => {
|
|
73
|
+
if (String(args ?? "").trim()) {
|
|
74
|
+
ctx.ui.notify("usage: /deltabox-sync", "warning");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const client = await getClient(ctx);
|
|
79
|
+
const result = await client.sync();
|
|
80
|
+
ctx.ui.notify([
|
|
81
|
+
`Folded ${result.folded_publications} sibling publication(s).`,
|
|
82
|
+
...result.stale_paths.map((path) => `Stale path: ${path}`),
|
|
83
|
+
...result.conflicts.map((conflict) => `Conflict: ${conflict.path} (host: ${conflict.host_kind})` +
|
|
84
|
+
(conflict.theirs ? ` — compare with ${conflict.theirs}` : "")),
|
|
85
|
+
...(result.conflicts.length
|
|
86
|
+
? ["Resolve each conflict at its original path before running /deltabox-commit."]
|
|
87
|
+
: []),
|
|
88
|
+
].join("\n"), "info");
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
ctx.ui.notify(`deltabox error: ${String(error)}`, "error");
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
pi.registerCommand("deltabox-skip", {
|
|
70
96
|
description: "Keep pending changes and preserve the current rollback point",
|
|
71
97
|
handler: async (_args, ctx) => {
|
|
72
98
|
try {
|
|
@@ -78,7 +104,7 @@ getClient, getConfig, setMode) {
|
|
|
78
104
|
}
|
|
79
105
|
},
|
|
80
106
|
});
|
|
81
|
-
pi.registerCommand("
|
|
107
|
+
pi.registerCommand("deltabox-diff", {
|
|
82
108
|
description: "Show the diff between two checkpoints (or base and head)",
|
|
83
109
|
handler: async (args, ctx) => {
|
|
84
110
|
const client = await getClient(ctx);
|
|
@@ -95,16 +121,37 @@ getClient, getConfig, setMode) {
|
|
|
95
121
|
}
|
|
96
122
|
},
|
|
97
123
|
});
|
|
98
|
-
pi.registerCommand("
|
|
99
|
-
description: "
|
|
124
|
+
pi.registerCommand("deltabox-mode", {
|
|
125
|
+
description: "Show or set review mode: task, tool, or risky",
|
|
100
126
|
handler: async (args, ctx) => {
|
|
101
|
-
const
|
|
127
|
+
const trimmed = String(args ?? "").trim();
|
|
128
|
+
if (!trimmed) {
|
|
129
|
+
ctx.ui.notify(`review mode: ${getConfig().review.mode}. usage: /deltabox-mode task|tool|risky`, "info");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const mode = trimmed;
|
|
102
133
|
if (mode !== "task" && mode !== "tool" && mode !== "risky") {
|
|
103
|
-
ctx.ui.notify("usage: /
|
|
134
|
+
ctx.ui.notify("usage: /deltabox-mode task|tool|risky", "warning");
|
|
104
135
|
return;
|
|
105
136
|
}
|
|
106
137
|
setMode(mode);
|
|
107
138
|
ctx.ui.notify(`review mode set to ${mode}`, "info");
|
|
108
139
|
},
|
|
109
140
|
});
|
|
141
|
+
pi.registerCommand("deltabox-exit", {
|
|
142
|
+
description: "Show or set session exit policy: abort|commit",
|
|
143
|
+
handler: async (args, ctx) => {
|
|
144
|
+
const trimmed = String(args ?? "").trim();
|
|
145
|
+
if (!trimmed) {
|
|
146
|
+
ctx.ui.notify(`Exit policy: ${getConfig().exit}. Usage: /deltabox-exit [abort|commit]`, "info");
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (trimmed !== "abort" && trimmed !== "commit") {
|
|
150
|
+
ctx.ui.notify("Usage: /deltabox-exit [abort|commit]", "warning");
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
setExitPolicy(trimmed);
|
|
154
|
+
ctx.ui.notify(`Exit policy set to ${trimmed}.`, "info");
|
|
155
|
+
},
|
|
156
|
+
});
|
|
110
157
|
}
|
package/dist/config.js
CHANGED
|
@@ -16,6 +16,7 @@ export const DEFAULT_CONFIG = {
|
|
|
16
16
|
durability: "fast",
|
|
17
17
|
groupCommitMs: null,
|
|
18
18
|
},
|
|
19
|
+
exit: "abort",
|
|
19
20
|
review: {
|
|
20
21
|
mode: "task",
|
|
21
22
|
},
|
|
@@ -80,6 +81,7 @@ export function mergeConfig(base, raw) {
|
|
|
80
81
|
? null
|
|
81
82
|
: base.filesystem.groupCommitMs,
|
|
82
83
|
},
|
|
84
|
+
exit: value.exit === "abort" || value.exit === "commit" ? value.exit : base.exit,
|
|
83
85
|
review: {
|
|
84
86
|
mode: review.mode === "task" || review.mode === "tool" || review.mode === "risky"
|
|
85
87
|
? review.mode
|
package/dist/extension.js
CHANGED
|
@@ -20,7 +20,12 @@ export function registerExtension(pi, dependencies = defaultDependencies) {
|
|
|
20
20
|
let client = null;
|
|
21
21
|
let config = dependencies.loadConfig(dependencies.cwd());
|
|
22
22
|
let mode = config.review.mode;
|
|
23
|
-
|
|
23
|
+
let exitPolicy = config.exit;
|
|
24
|
+
const getConfig = () => ({
|
|
25
|
+
...config,
|
|
26
|
+
exit: exitPolicy,
|
|
27
|
+
review: { ...config.review, mode },
|
|
28
|
+
});
|
|
24
29
|
const getClient = () => {
|
|
25
30
|
if (!client) {
|
|
26
31
|
client = dependencies.createClient(dependencies.cwd(), config);
|
|
@@ -62,6 +67,7 @@ export function registerExtension(pi, dependencies = defaultDependencies) {
|
|
|
62
67
|
pi.on("session_start", async (_event, ctx) => {
|
|
63
68
|
config = dependencies.loadConfig(dependencies.cwd());
|
|
64
69
|
mode = config.review.mode;
|
|
70
|
+
exitPolicy = config.exit;
|
|
65
71
|
try {
|
|
66
72
|
await ensureClient(ctx);
|
|
67
73
|
}
|
|
@@ -72,6 +78,21 @@ export function registerExtension(pi, dependencies = defaultDependencies) {
|
|
|
72
78
|
pi.on("session_shutdown", async (_event, ctx) => {
|
|
73
79
|
if (client) {
|
|
74
80
|
try {
|
|
81
|
+
if (await client.reviewStatus()) {
|
|
82
|
+
if (exitPolicy === "commit") {
|
|
83
|
+
const result = await client.reviewCommit();
|
|
84
|
+
if (result.applied > 0) {
|
|
85
|
+
ctx.ui.notify(`Deltabox: committed ${result.applied} pending change(s) on exit.`, "info");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const result = await client.reviewAbort();
|
|
90
|
+
if (result.restored > 0) {
|
|
91
|
+
ctx.ui.notify(`Deltabox: rolled back ${result.restored} uncommitted change(s) on exit. ` +
|
|
92
|
+
'Run /deltabox-commit or /deltabox-exit commit before exiting, or set "exit": "commit" in deltabox.json to keep them.', "warning");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
75
96
|
await client.stop();
|
|
76
97
|
}
|
|
77
98
|
catch (error) {
|
|
@@ -102,7 +123,7 @@ export function registerExtension(pi, dependencies = defaultDependencies) {
|
|
|
102
123
|
const diff = await client.reviewDiff();
|
|
103
124
|
if (diff.pending_changes > 0) {
|
|
104
125
|
const note = `Task finished with ${diff.pending_changes} pending change(s). ` +
|
|
105
|
-
"Use /
|
|
126
|
+
"Use /deltabox-review, /deltabox-commit, or /deltabox-abort.";
|
|
106
127
|
ctx.ui.notify(note, "info");
|
|
107
128
|
}
|
|
108
129
|
}
|
|
@@ -115,6 +136,8 @@ export function registerExtension(pi, dependencies = defaultDependencies) {
|
|
|
115
136
|
}
|
|
116
137
|
registerCommands(pi, ensureClient, getConfig, (next) => {
|
|
117
138
|
mode = next;
|
|
139
|
+
}, (next) => {
|
|
140
|
+
exitPolicy = next;
|
|
118
141
|
});
|
|
119
142
|
}
|
|
120
143
|
export default registerExtension;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-deltabox",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Pi extension: agent-native sandbox sessions with diff/commit/abort, powered by deltabox-lite",
|
|
6
6
|
"type": "module",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"typebox": "^1.3.10"
|
|
29
29
|
},
|
|
30
30
|
"optionalDependencies": {
|
|
31
|
-
"deltabox-lite-darwin-arm64": "0.
|
|
32
|
-
"deltabox-lite-darwin-x64": "0.
|
|
33
|
-
"deltabox-lite-linux-arm64": "0.
|
|
34
|
-
"deltabox-lite-linux-x64": "0.
|
|
35
|
-
"deltabox-lite-windows-x64": "0.
|
|
31
|
+
"deltabox-lite-darwin-arm64": "0.5.0",
|
|
32
|
+
"deltabox-lite-darwin-x64": "0.5.0",
|
|
33
|
+
"deltabox-lite-linux-arm64": "0.5.0",
|
|
34
|
+
"deltabox-lite-linux-x64": "0.5.0",
|
|
35
|
+
"deltabox-lite-windows-x64": "0.5.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@earendil-works/pi-coding-agent": "^0.79.3",
|