notesoup 0.49.0 → 0.50.0
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 +1 -1
- package/dist/src/budget/text.js +1 -1
- package/dist/src/pi/runtime.js +2 -2
- package/dist/test/agent-loop.test.js +15 -15
- package/dist/test/boot.integration.test.js +4 -4
- package/dist/test/claude-mod.test.js +10 -5
- package/dist/test/dependencies.test.js +1 -1
- package/dist/test/model-facing-text.test.js +2 -2
- package/dist/test/reset-lifecycle.test.js +8 -8
- package/docs/dsh.md +1 -1
- package/docs/reset-lifecycle.md +2 -2
- package/mods/notesoup/.claude-plugin/plugin.json +1 -1
- package/mods/notesoup/hooks/register.ts +2 -2
- package/package.json +1 -1
- package/src/budget/text.ts +1 -1
- package/src/pi/runtime.ts +2 -2
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ pi -e npm:notesoup
|
|
|
28
28
|
|
|
29
29
|
## What you get
|
|
30
30
|
|
|
31
|
-
- **Durable context windows.** `/fresh-window` (alias `/empty
|
|
31
|
+
- **Durable context windows.** `/fresh-window` (alias `/empty`) clears and stops; `/fresh-window Continue reviewing the implementation` clears and continues. The model can also request a window itself with `empty_brain`, and a budget close-out fires automatically before the window runs out. Abort and ordinary errors never count as completion; the raw conversation stays in the session, just out of the next context.
|
|
32
32
|
- **A boot block at every window head.** Static once-per-window content (cache-stable) with the window identity, the recent-notes index, and a short protocol teaching the model how to recover: notes for its own bookkeeping, history tools for everything before the reset.
|
|
33
33
|
- **`get_context_remaining`** — how much room the brain has left before the hard-reserve wipe, including the warning runway.
|
|
34
34
|
- **Eight history/notes tools**, flattened from the original Codex actions:
|
package/dist/src/budget/text.js
CHANGED
|
@@ -34,7 +34,7 @@ export const WARNING_CALL = "When the notes are ready, call `empty_brain` to res
|
|
|
34
34
|
*/
|
|
35
35
|
export const WARNING_CALL_PROMPTED = "Organize the notes first, then call `empty_brain` right away — do not wait to be cut off.";
|
|
36
36
|
/**
|
|
37
|
-
* The human typed `/empty
|
|
37
|
+
* The human typed `/empty <prompt>`: the raw command line leads the close-out so the
|
|
38
38
|
* closing model sees what the next window was asked to do, verbatim. The tag names it as the
|
|
39
39
|
* next window's prompt, so no prose has to explain that.
|
|
40
40
|
*/
|
package/dist/src/pi/runtime.js
CHANGED
|
@@ -195,7 +195,7 @@ export function registerContext(pi, settingsManager) {
|
|
|
195
195
|
}
|
|
196
196
|
cmdCtx.ui.notify("🥣 Brain being emptied", "info");
|
|
197
197
|
try {
|
|
198
|
-
pi.sendMessage({ customType: MANUAL_WIPE_TYPE, content: warningContent(prompt ? `/empty
|
|
198
|
+
pi.sendMessage({ customType: MANUAL_WIPE_TYPE, content: warningContent(prompt ? `/empty ${prompt}` : undefined), display: false }, { triggerTurn: true, deliverAs: "steer" });
|
|
199
199
|
}
|
|
200
200
|
catch (error) {
|
|
201
201
|
resets.clear();
|
|
@@ -203,7 +203,7 @@ export function registerContext(pi, settingsManager) {
|
|
|
203
203
|
}
|
|
204
204
|
},
|
|
205
205
|
};
|
|
206
|
-
pi.registerCommand("empty
|
|
206
|
+
pi.registerCommand("empty", emptyBrainCommand);
|
|
207
207
|
pi.registerCommand("fresh-window", emptyBrainCommand);
|
|
208
208
|
pi.registerTool(defineTool({
|
|
209
209
|
name: "empty_brain",
|
|
@@ -464,7 +464,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
|
|
|
464
464
|
if (request === 1)
|
|
465
465
|
return assistant(fixture, [{ type: "text", text: "before manual reset" }]);
|
|
466
466
|
if (request === 2) {
|
|
467
|
-
assert.ok(text(context).includes(WARNING_JSON), "idle /empty
|
|
467
|
+
assert.ok(text(context).includes(WARNING_JSON), "idle /empty sends the shared checkpoint prompt");
|
|
468
468
|
return assistant(fixture, [{ type: "toolCall", id: "manual-note", name: "notes_write", arguments: { address: "manual-a.md", content: "MANUAL_NOTE_ALPHA" } }], "toolUse");
|
|
469
469
|
}
|
|
470
470
|
assert.equal(request, 3, "the close-out turn finishes in the old window");
|
|
@@ -475,7 +475,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
|
|
|
475
475
|
try {
|
|
476
476
|
await fixture.session.prompt("MANUAL_CLOSEOUT_OLD_SENTINEL");
|
|
477
477
|
await fixture.session.waitForIdle();
|
|
478
|
-
await fixture.session.prompt("/empty
|
|
478
|
+
await fixture.session.prompt("/empty");
|
|
479
479
|
await fixture.session.waitForIdle();
|
|
480
480
|
assert.equal(fixture.requests.length, 3, "the run stops at settlement instead of continuing in the fresh window");
|
|
481
481
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
@@ -504,7 +504,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
|
|
|
504
504
|
}
|
|
505
505
|
});
|
|
506
506
|
test("real AgentSession: a clear command keeps its prompt out of the fresh window and resumes once", { timeout: 25000 }, async () => {
|
|
507
|
-
for (const mode of ["empty
|
|
507
|
+
for (const mode of ["empty", "fresh-window", "hard-reserve", "overflow"]) {
|
|
508
508
|
let fixture;
|
|
509
509
|
const prompt = 'AFTER_CLEAR_PROMPT_SENTINEL /cm "literal text"';
|
|
510
510
|
// `text()` serializes to JSON, so a quoted argument reaches the provider in its escaped form.
|
|
@@ -532,7 +532,7 @@ test("real AgentSession: a clear command keeps its prompt out of the fresh windo
|
|
|
532
532
|
});
|
|
533
533
|
try {
|
|
534
534
|
await fixture.session.prompt("PROMPT_RESET_OLD_SENTINEL");
|
|
535
|
-
await fixture.session.prompt(`/${mode === "empty
|
|
535
|
+
await fixture.session.prompt(`/${mode === "empty" ? "empty" : "fresh-window"} ${prompt} `);
|
|
536
536
|
await fixture.session.waitForIdle();
|
|
537
537
|
assert.equal(fixture.requests.length, 3);
|
|
538
538
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
@@ -598,7 +598,7 @@ test("real AgentSession: streaming clear prompt keeps the first request", { time
|
|
|
598
598
|
const running = fixture.session.prompt("streaming old work");
|
|
599
599
|
await ready;
|
|
600
600
|
await fixture.session.prompt("/fresh-window FIRST_RESET_PROMPT", { streamingBehavior: "steer" });
|
|
601
|
-
await fixture.session.prompt("/empty
|
|
601
|
+
await fixture.session.prompt("/empty IGNORED_RESET_PROMPT", { streamingBehavior: "steer" });
|
|
602
602
|
release();
|
|
603
603
|
await running;
|
|
604
604
|
await fixture.session.waitForIdle();
|
|
@@ -630,7 +630,7 @@ test("real AgentSession: manual hard-reserve reset stops clean and mixed-tool tu
|
|
|
630
630
|
});
|
|
631
631
|
try {
|
|
632
632
|
await fixture.session.prompt("HARD_RESERVE_OLD_SENTINEL");
|
|
633
|
-
await fixture.session.prompt("/empty
|
|
633
|
+
await fixture.session.prompt("/empty");
|
|
634
634
|
await fixture.session.waitForIdle();
|
|
635
635
|
assert.equal(fixture.requests.length, 2);
|
|
636
636
|
assert.equal(resetMarkers(fixture).length, 1, "the safety wipe is not repeated at settlement");
|
|
@@ -678,7 +678,7 @@ test("real AgentSession: manual safety reset answers queued user input once befo
|
|
|
678
678
|
});
|
|
679
679
|
try {
|
|
680
680
|
await fixture.session.prompt("QUEUED_SAFETY_OLD_SENTINEL");
|
|
681
|
-
await fixture.session.prompt("/empty
|
|
681
|
+
await fixture.session.prompt("/empty");
|
|
682
682
|
await fixture.session.waitForIdle();
|
|
683
683
|
assert.equal(fixture.requests.length, 4, "queued input is answered once after Pi's tool follow-up, then the stop lands");
|
|
684
684
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
@@ -701,7 +701,7 @@ test("real AgentSession: manual overflow wipes and stops even with automatic res
|
|
|
701
701
|
});
|
|
702
702
|
try {
|
|
703
703
|
await fixture.session.prompt("MANUAL_OVERFLOW_OLD_SENTINEL");
|
|
704
|
-
await fixture.session.prompt("/empty
|
|
704
|
+
await fixture.session.prompt("/empty");
|
|
705
705
|
await fixture.session.waitForIdle();
|
|
706
706
|
assert.equal(fixture.requests.length, 2);
|
|
707
707
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
@@ -712,7 +712,7 @@ test("real AgentSession: manual overflow wipes and stops even with automatic res
|
|
|
712
712
|
fixture.close();
|
|
713
713
|
}
|
|
714
714
|
});
|
|
715
|
-
test("real AgentSession: streaming /empty
|
|
715
|
+
test("real AgentSession: streaming /empty steers a close-out and stops at settlement", { timeout: 20000 }, async () => {
|
|
716
716
|
let fixture;
|
|
717
717
|
let announceStarted;
|
|
718
718
|
let releaseResponse;
|
|
@@ -734,8 +734,8 @@ test("real AgentSession: streaming /empty-brain steers a close-out and stops at
|
|
|
734
734
|
try {
|
|
735
735
|
const running = fixture.session.prompt("STREAMING_WIPE_OLD_SENTINEL");
|
|
736
736
|
await started;
|
|
737
|
-
await fixture.session.prompt("/empty
|
|
738
|
-
await fixture.session.prompt("/empty
|
|
737
|
+
await fixture.session.prompt("/empty", { streamingBehavior: "steer" });
|
|
738
|
+
await fixture.session.prompt("/empty", { streamingBehavior: "followUp" });
|
|
739
739
|
assert.equal(fixture.notices.filter((notice) => notice.includes("Brain being emptied")).length, 1, "the user is notified once while output is ongoing");
|
|
740
740
|
assert.equal(resetMarkers(fixture).length, 0, "the ongoing turn is not interrupted");
|
|
741
741
|
releaseResponse();
|
|
@@ -769,9 +769,9 @@ test("real AgentSession: repeated manual commands share one pending window", { t
|
|
|
769
769
|
},
|
|
770
770
|
});
|
|
771
771
|
try {
|
|
772
|
-
const first = fixture.session.prompt("/empty
|
|
772
|
+
const first = fixture.session.prompt("/empty");
|
|
773
773
|
await started;
|
|
774
|
-
const second = fixture.session.prompt("/empty
|
|
774
|
+
const second = fixture.session.prompt("/empty");
|
|
775
775
|
releaseResponse();
|
|
776
776
|
await Promise.all([first, second]);
|
|
777
777
|
await fixture.session.waitForIdle();
|
|
@@ -854,7 +854,7 @@ test("real AgentSession: steering and follow-up queued during a manual reset are
|
|
|
854
854
|
},
|
|
855
855
|
});
|
|
856
856
|
try {
|
|
857
|
-
const command = fixture.session.prompt("/empty
|
|
857
|
+
const command = fixture.session.prompt("/empty");
|
|
858
858
|
await started;
|
|
859
859
|
if (delivery === "steer")
|
|
860
860
|
fixture.session.steer("QUEUED_DURING_FALLBACK");
|
|
@@ -1093,7 +1093,7 @@ test("real AgentSession: hidden or missing reset boots refuse to move the bounda
|
|
|
1093
1093
|
try {
|
|
1094
1094
|
await fixture.session.prompt("ROOT_BEFORE_HIDDEN_BOOT");
|
|
1095
1095
|
await fixture.session.waitForIdle();
|
|
1096
|
-
await fixture.session.prompt("/empty
|
|
1096
|
+
await fixture.session.prompt("/empty");
|
|
1097
1097
|
await fixture.session.waitForIdle();
|
|
1098
1098
|
await fixture.session.prompt("VALID_POST_MARKER_WORK");
|
|
1099
1099
|
await fixture.session.waitForIdle();
|
|
@@ -316,10 +316,10 @@ test("empty_brain uses one turn boundary and never calls ctx.compact", async ()
|
|
|
316
316
|
assert.equal(sessionManager.getBranch().filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE).length, 1);
|
|
317
317
|
assert.equal(sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === BOOT_TYPE && entry.details && typeof entry.details === "object" && "windowId" in entry.details).length, 1);
|
|
318
318
|
});
|
|
319
|
-
test("/empty
|
|
319
|
+
test("/empty waits out non-agent busy work before starting its single-turn request", async () => {
|
|
320
320
|
const sessionManager = manager();
|
|
321
321
|
const captured = makeExtension(sessionManager);
|
|
322
|
-
const cmd = captured.commands.get("empty
|
|
322
|
+
const cmd = captured.commands.get("empty");
|
|
323
323
|
assert.ok(cmd);
|
|
324
324
|
let waits = 0;
|
|
325
325
|
const notices = [];
|
|
@@ -334,7 +334,7 @@ test("/empty-brain waits out non-agent busy work before starting its single-turn
|
|
|
334
334
|
assert.equal(captured.sent[0]?.options?.triggerTurn, true);
|
|
335
335
|
assert.equal(notices.filter((message) => message.includes("Brain being emptied")).length, 1);
|
|
336
336
|
});
|
|
337
|
-
test("notesoup command toggles future work, /empty
|
|
337
|
+
test("notesoup command toggles future work, /empty schedules a turn-end reset, and /compact remains disabled", async () => {
|
|
338
338
|
const sessionManager = manager();
|
|
339
339
|
appendText(sessionManager, "user", "hello");
|
|
340
340
|
const captured = makeExtension(sessionManager);
|
|
@@ -353,7 +353,7 @@ test("notesoup command toggles future work, /empty-brain schedules a turn-end re
|
|
|
353
353
|
assert.match(offResult.error ?? "", /off/, "empty_brain refuses while off");
|
|
354
354
|
notices = await runCommand(captured, "notesoup", "on", low);
|
|
355
355
|
assert.match(notices[0]?.message ?? "", /on/);
|
|
356
|
-
notices = await runCommand(captured, "empty
|
|
356
|
+
notices = await runCommand(captured, "empty", "", low);
|
|
357
357
|
assert.equal(notices.length, 1, "the command acknowledges the reset request");
|
|
358
358
|
assert.match(notices[0]?.message ?? "", /Brain being emptied/);
|
|
359
359
|
assert.equal(captured.sent.length, 2, "the command persists one hidden warning after the startup boot");
|
|
@@ -463,7 +463,7 @@ test("Claude Mod headless detection skips compaction and logs once", async (t) =
|
|
|
463
463
|
await invoke("turn.complete");
|
|
464
464
|
assert.equal(attempts, 0, "headless sessions skip the unsupported capability from startup");
|
|
465
465
|
assert.deepEqual(notifications, ["🥣 No brain when headless"]);
|
|
466
|
-
const manual = await invoke("command.run", { command: "empty
|
|
466
|
+
const manual = await invoke("command.run", { command: "empty" });
|
|
467
467
|
assert.match(manual.text, /No brain when headless/);
|
|
468
468
|
assert.equal(notifications.length, 1);
|
|
469
469
|
const boot = await handlers.get("prompt.context")(host, {}, async () => ({ blocks: [] }));
|
|
@@ -522,6 +522,8 @@ test("Claude Mod manual reset uses one hidden close-out turn, then recovers its
|
|
|
522
522
|
const home = mkdtempSync(join(tmpdir(), "claude-manual-home-"));
|
|
523
523
|
t.after(() => rmSync(home, { recursive: true, force: true }));
|
|
524
524
|
const { host } = fakeEngine(home);
|
|
525
|
+
const commands = [];
|
|
526
|
+
host.command.register = async (spec) => { commands.push(spec.name); return { command: spec.name }; };
|
|
525
527
|
let handlers = new Map();
|
|
526
528
|
const invoke = (name, e = {}) => handlers.get(name)(host, e, async () => ({}));
|
|
527
529
|
const timers = [];
|
|
@@ -542,7 +544,10 @@ test("Claude Mod manual reset uses one hidden close-out turn, then recovers its
|
|
|
542
544
|
};
|
|
543
545
|
(await loadHookModule(t)).register((event, handler) => handlers.set(event, handler));
|
|
544
546
|
await invoke("session.start", { cwd: home, isInteractive: true });
|
|
545
|
-
|
|
547
|
+
assert.deepEqual(commands.sort(), ["empty", "fresh-window"], "only the new short name and the retained alias are registered");
|
|
548
|
+
assert.deepEqual(await invoke("command.run", { command: "empty-brain" }), {}, "the retired spelling passes through instead of resetting");
|
|
549
|
+
assert.equal(timers.length, 0);
|
|
550
|
+
const command = await invoke("command.run", { command: "empty" });
|
|
546
551
|
assert.match(command.text, /Brain being emptied/);
|
|
547
552
|
await Promise.resolve();
|
|
548
553
|
assert.equal(compactions, 0, "command.run must not call compact under its held turn");
|
|
@@ -560,7 +565,7 @@ test("Claude Mod manual reset uses one hidden close-out turn, then recovers its
|
|
|
560
565
|
await invoke("session.start", { cwd: home, isInteractive: true });
|
|
561
566
|
assert.deepEqual(await handlers.get("prompt.context")(host, {}, async () => ({ blocks: [] })), { blocks: [] }, "reload does not duplicate the already-retained boot");
|
|
562
567
|
await invoke("turn.start");
|
|
563
|
-
await invoke("command.run", { command: "empty
|
|
568
|
+
await invoke("command.run", { command: "empty" });
|
|
564
569
|
await invoke("turn.complete");
|
|
565
570
|
assert.equal(prompts.length, 1, "a busy manual request reuses the current turn instead of submitting another");
|
|
566
571
|
assert.match(kept[0].text, /Current context window id: claude:hook-session:2/);
|
|
@@ -631,7 +636,7 @@ test("Claude Mod stops the automatic reset and the manual command under DISABLE_
|
|
|
631
636
|
await invoke("session.start", { cwd: home, isInteractive: true });
|
|
632
637
|
assert.equal(notifications.length, 1, "one startup line");
|
|
633
638
|
assert.match(notifications[0], /DISABLE_COMPACT/);
|
|
634
|
-
const manual = await invoke("command.run", { command: "empty
|
|
639
|
+
const manual = await invoke("command.run", { command: "empty" });
|
|
635
640
|
assert.match(manual.text, /DISABLE_COMPACT/);
|
|
636
641
|
assert.equal(timers.length, 0, "no close-out turn is queued");
|
|
637
642
|
await invoke("turn.start");
|
|
@@ -794,7 +799,7 @@ test("Claude session.end gives /clear, /resume and /branch a fresh boot and iden
|
|
|
794
799
|
host.session.usage = async () => ({ context: { tokens: 142_424, window: 200_000 } });
|
|
795
800
|
assert.equal((await context()).blocks[0]?.name, "notesoup:warning", "the old window has already warned");
|
|
796
801
|
await invoke("turn.start");
|
|
797
|
-
await invoke("command.run", { command: "empty
|
|
802
|
+
await invoke("command.run", { command: "empty" });
|
|
798
803
|
const ended = { sentinel: action };
|
|
799
804
|
assert.equal(await invoke("session.end", { reason: action === "clear" ? "clear" : "resume", sessionId: "hook-session" }, ended), ended);
|
|
800
805
|
host.session.id = async () => `after-${action}`;
|
|
@@ -156,7 +156,7 @@ test("configured extension source and moved dream CLI are executable current ent
|
|
|
156
156
|
registerCommand(name) { commands.push(name); },
|
|
157
157
|
});
|
|
158
158
|
assert.deepEqual(tools.map((tool) => tool.name).sort(), ["empty_brain", "get_context_remaining", "history_list", "history_read", "history_windows", "notes_list", "notes_read", "notes_search", "notes_update", "notes_write"]);
|
|
159
|
-
assert.deepEqual(commands.sort(), ["empty
|
|
159
|
+
assert.deepEqual(commands.sort(), ["empty", "fresh-window", "notesoup"]);
|
|
160
160
|
const help = execFileSync(process.execPath, [resolve(root, manifest.bin.dream), "--help"], { cwd: root, encoding: "utf8" });
|
|
161
161
|
assert.ok(help.startsWith("dream doctor [--notes-home <dir>]"));
|
|
162
162
|
assert.ok(help.includes("Default playbook: <installed package root>/playbook.md"));
|
|
@@ -103,8 +103,8 @@ test("the countdown closes the second-tier notice only, in both hosts", () => {
|
|
|
103
103
|
assert.ok(pi.endsWith(`\n${GUIDANCE_CLOSE_TAG}`));
|
|
104
104
|
assert.ok(pi.includes(`\n${LAST_WORD_HINT}\n${COUNTDOWN_LINE}\n`), "the countdown comes after the Pi-only last-word hint");
|
|
105
105
|
assert.equal(pi.split(COUNTDOWN_LINE).length - 1, 1, "the second tier carries the countdown exactly once");
|
|
106
|
-
const prompted = warningContent("/empty
|
|
107
|
-
assert.ok(prompted.includes("<notesoup:next_window_prompt>\n/empty
|
|
106
|
+
const prompted = warningContent("/empty keep going");
|
|
107
|
+
assert.ok(prompted.includes("<notesoup:next_window_prompt>\n/empty keep going\n</notesoup:next_window_prompt>"));
|
|
108
108
|
assert.ok(prompted.endsWith(`\n${COUNTDOWN_LINE}\n${GUIDANCE_CLOSE_TAG}`), "the prompt block does not displace the countdown");
|
|
109
109
|
assert.equal(CLAUDE_WARNING_PROMPT.endsWith(`\n${COUNTDOWN_LINE}`), true, "Claude's variant ends the same way");
|
|
110
110
|
assert.equal(tokenBudgetGuidance(100, "empty_brain").includes(COUNTDOWN_LINE), false, "the first tier never counts down");
|
|
@@ -186,9 +186,9 @@ test("public reset boundary drafts one marker, one boot, and one continuation af
|
|
|
186
186
|
assert.deepEqual(branch.filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE).map((entry) => entry.type === "custom" ? entry.data : undefined), [{ windowId, origin: "normal" }], "the boundary records the model's own call");
|
|
187
187
|
assert.equal(branch.filter((entry) => entry.type === "custom_message" && entry.customType === BOOT_TYPE).length, 1);
|
|
188
188
|
});
|
|
189
|
-
test("manual /empty
|
|
189
|
+
test("manual /empty spans tool turns and commits the stop at settlement", async () => {
|
|
190
190
|
const h = harness();
|
|
191
|
-
await h.runCommand("empty
|
|
191
|
+
await h.runCommand("empty");
|
|
192
192
|
assert.ok(h.sent.some((message) => message.customType === MANUAL_WIPE_TYPE && message.triggerTurn === true), "the idle close-out warning starts a turn");
|
|
193
193
|
const toolCallMessage = {
|
|
194
194
|
role: "assistant",
|
|
@@ -228,8 +228,8 @@ test("off stops future automatic/manual reset requests while an existing marker
|
|
|
228
228
|
const afterOff = resultEntries(await h.emit("turn_end", fakeBoundaryEvent()));
|
|
229
229
|
assert.equal(afterOff.entries.length, 0, "off does not create another reset");
|
|
230
230
|
await h.runCommand("notesoup", "on");
|
|
231
|
-
await h.runCommand("empty
|
|
232
|
-
assert.equal(h.sent.length, 1, "/empty
|
|
231
|
+
await h.runCommand("empty");
|
|
232
|
+
assert.equal(h.sent.length, 1, "/empty sends one hidden close-out warning and starts a normal turn");
|
|
233
233
|
assert.equal(h.sent[0]?.triggerTurn, true);
|
|
234
234
|
assert.equal(h.sent[0]?.customType, MANUAL_WIPE_TYPE);
|
|
235
235
|
const warning = h.sessionManager.getBranch().find((entry) => entry.type === "custom_message" && entry.customType === MANUAL_WIPE_TYPE);
|
|
@@ -238,15 +238,15 @@ test("off stops future automatic/manual reset requests while an existing marker
|
|
|
238
238
|
const markers = h.sessionManager.getBranch().filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE);
|
|
239
239
|
assert.equal(markers.length, 1, "manual command waits for an agent boundary; it does not persist an immediate reset");
|
|
240
240
|
});
|
|
241
|
-
test("manual /empty
|
|
241
|
+
test("manual /empty with a prompt shows the human's command line in the close-out", async () => {
|
|
242
242
|
const h = harness();
|
|
243
243
|
// Assert on values, not on the warning's wording: the command line must survive verbatim
|
|
244
244
|
// and must precede the closing instruction, so the prompt cannot read as this window's task.
|
|
245
|
-
await h.runCommand("empty
|
|
245
|
+
await h.runCommand("empty", "Continue reviewing the implementation");
|
|
246
246
|
const warning = h.sessionManager.getBranch().find((entry) => entry.type === "custom_message" && entry.customType === MANUAL_WIPE_TYPE);
|
|
247
247
|
assert.ok(warning?.type === "custom_message", "the close-out warning is persisted");
|
|
248
248
|
const content = String(warning.content);
|
|
249
|
-
const promptLine = "/empty
|
|
249
|
+
const promptLine = "/empty Continue reviewing the implementation";
|
|
250
250
|
const promptIndex = content.indexOf(promptLine);
|
|
251
251
|
assert.ok(promptIndex >= 0, "the human's raw command line reaches the closing model");
|
|
252
252
|
const closingIndex = content.indexOf(WARNING_CALL_PROMPTED);
|
|
@@ -799,7 +799,7 @@ test("a committed reset records its origin and draws that pool exactly once", as
|
|
|
799
799
|
assert.ok(askedLine?.type === "custom_message");
|
|
800
800
|
assert.equal(askedLine.content, NORMAL_CONTINUATIONS[0]);
|
|
801
801
|
const commanded = harness();
|
|
802
|
-
await commanded.runCommand("empty
|
|
802
|
+
await commanded.runCommand("empty");
|
|
803
803
|
const commandedBoundary = resultEntries(await commanded.emit("agent_before_settle", {
|
|
804
804
|
type: "agent_before_settle",
|
|
805
805
|
entries: [],
|
package/docs/dsh.md
CHANGED
|
@@ -54,7 +54,7 @@ The reminder and close-out warning go through `agent.steer`. Close-out remains a
|
|
|
54
54
|
| Storage | Raw log remains available while the host keeps it. Notesoup does not back up session files or guarantee that an unflushed append survives a crash. |
|
|
55
55
|
| Plugin records | Best-effort across dsh migrations. Missing records recover from native checkpoints/root system text; unknown future record or checkpoint formats are not migrated by notesoup. |
|
|
56
56
|
| Tools and errors | Full shared TypeBox validation runs in the adapter because dsh supports a smaller schema subset. Expected operation errors become dsh failures with the shared code; successes use the shared bounded value and renderer. |
|
|
57
|
-
| Notifications and commands | No custom UI notifications, settings card, runtime toggle or `/fresh-window`/`/empty
|
|
57
|
+
| Notifications and commands | No custom UI notifications, settings card, runtime toggle or `/fresh-window`/`/empty` command is installed. Configure engine rows in the profile/home patch; call `empty_brain` or the host's `/compact`. |
|
|
58
58
|
| Untested host features | Real providers, reasoning/image wire behavior, cache metrics, actual context-overflow retry, HMR, migrations, ACP/Web/SDK profiles and large histories are not established by the scripted tests. |
|
|
59
59
|
| Dream | **No dsh dream backend or dream skill registration.** Use the existing supported host workflow. |
|
|
60
60
|
|
package/docs/reset-lifecycle.md
CHANGED
|
@@ -9,7 +9,7 @@ Boot acquisition/rendering is shared: `src/boot/snapshot.ts` receives explicit i
|
|
|
9
9
|
| Trigger | Behavior |
|
|
10
10
|
| --- | --- |
|
|
11
11
|
| `empty_brain` tool | Record an actual tool request for the current window, including any last word. Without command policy it commits at `turn_end` after the complete tool batch and continues. Under command policy the request remains recorded but waits for settlement. |
|
|
12
|
-
| `/fresh-window` or `/empty
|
|
12
|
+
| `/fresh-window` or `/empty` | Store command policy and send a hidden warning (start a turn when idle, steer when running). Wait for successful settlement after queued messages drain, then reset and stop for a bare command or continue for a command with text. Model tool calls remain actual requests; they do not change settlement policy. The text reaches the closing model only, never the new window directly. |
|
|
13
13
|
| Budget warning | Inject a warning at reserve plus runway when automatic reset is enabled. This creates no lifecycle state. A warning alone never authorizes a reset; a tool call or the independent hard-reserve check does. |
|
|
14
14
|
| Hard reserve | Independent safety path: if automatic resets are enabled and completed-turn usage reaches Pi's reserve, commit a boundary at `turn_end`. A pending manual stop survives in a run-scoped `stop-pending` phase; empty automatic follow-up is cancelled before provider work, while real queued user input is answered before stopping. |
|
|
15
15
|
| Abort or error | Never count as successful close-out. Abort clears lifecycle state. An ordinary close-out error is dropped without reset. Manual overflow clears and stops without retry, even with automatic reset disabled; automatic provider-overflow recovery remains separately bounded. |
|
|
@@ -31,7 +31,7 @@ The origin comes directly from the recorded tool request: with a call it is `nor
|
|
|
31
31
|
|
|
32
32
|
Each host draws once per artifact and shares that value across every representation of it: Pi persists one entry, dsh writes the same paragraph into its checkpoint text and its steered continuation, and Claude — which has no model-facing reset tool, so every Claude reset is forced — caches one line per window so a retried compaction cannot redraw it. A generic read-only text endpoint never draws.
|
|
33
33
|
|
|
34
|
-
A manual `/empty
|
|
34
|
+
A manual `/empty <prompt>` command line is not persisted after the reset: it reaches the closing window inside the warning, and the closing model records what the next window needs in notes.
|
|
35
35
|
|
|
36
36
|
The raw session branch is preserved for history. New checkpoint-backed branches use Pi's canonical retain-none projection, which preserves the empty summary wrapper and system/tool state while excluding earlier conversational context. Older marker-only sessions use marker slicing as a narrow compatibility fallback. A marker is trusted as checkpoint-backed only when it directly follows an empty native compaction whose `firstKeptEntryId` is the compaction's own ID; a generic preceding compaction is not enough.
|
|
37
37
|
|
|
@@ -339,7 +339,7 @@ export function register(on: On) {
|
|
|
339
339
|
registered.clear()
|
|
340
340
|
await loadTexts($, state)
|
|
341
341
|
armManual($, state, manualSignal)
|
|
342
|
-
await $.command.register({ name: "empty
|
|
342
|
+
await $.command.register({ name: "empty", description: "Reset context to a fresh notes-only window", immediate: true })
|
|
343
343
|
await $.command.register({ name: "fresh-window", description: "Reset context to a fresh notes-only window", immediate: true })
|
|
344
344
|
const schemas = await run($, { op: "schemas" })
|
|
345
345
|
if (!schemas.ok || !Array.isArray(schemas.result)) return next(e)
|
|
@@ -390,7 +390,7 @@ export function register(on: On) {
|
|
|
390
390
|
return result
|
|
391
391
|
})
|
|
392
392
|
on("command.run", async ($, e, next) => {
|
|
393
|
-
if (e.command !== "empty
|
|
393
|
+
if (e.command !== "empty" && e.command !== "fresh-window") return next(e)
|
|
394
394
|
if (!await refreshIdentity($, state)) return { text: "🥣 Different brain now · try /fresh-window again" }
|
|
395
395
|
if (state.headless) return { text: `🥣 ${HEADLESS}` }
|
|
396
396
|
if (state.compactDisabled) return { text: `🥣 ${COMPACT_DISABLED}` }
|
package/package.json
CHANGED
package/src/budget/text.ts
CHANGED
|
@@ -46,7 +46,7 @@ export const WARNING_CALL = "When the notes are ready, call `empty_brain` to res
|
|
|
46
46
|
export const WARNING_CALL_PROMPTED = "Organize the notes first, then call `empty_brain` right away — do not wait to be cut off.";
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* The human typed `/empty
|
|
49
|
+
* The human typed `/empty <prompt>`: the raw command line leads the close-out so the
|
|
50
50
|
* closing model sees what the next window was asked to do, verbatim. The tag names it as the
|
|
51
51
|
* next window's prompt, so no prose has to explain that.
|
|
52
52
|
*/
|
package/src/pi/runtime.ts
CHANGED
|
@@ -191,14 +191,14 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
191
191
|
}
|
|
192
192
|
cmdCtx.ui.notify("🥣 Brain being emptied", "info");
|
|
193
193
|
try {
|
|
194
|
-
pi.sendMessage({ customType: MANUAL_WIPE_TYPE, content: warningContent(prompt ? `/empty
|
|
194
|
+
pi.sendMessage({ customType: MANUAL_WIPE_TYPE, content: warningContent(prompt ? `/empty ${prompt}` : undefined), display: false }, { triggerTurn: true, deliverAs: "steer" });
|
|
195
195
|
} catch (error) {
|
|
196
196
|
resets.clear();
|
|
197
197
|
cmdCtx.ui.notify(`🥣 Brain refused to empty: ${errorMessage(error)}`, "error");
|
|
198
198
|
}
|
|
199
199
|
},
|
|
200
200
|
};
|
|
201
|
-
pi.registerCommand("empty
|
|
201
|
+
pi.registerCommand("empty", emptyBrainCommand);
|
|
202
202
|
pi.registerCommand("fresh-window", emptyBrainCommand);
|
|
203
203
|
|
|
204
204
|
pi.registerTool(defineTool({
|