notesoup 0.51.0 → 0.51.2

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.
Files changed (41) hide show
  1. package/README.md +0 -1
  2. package/dist/plugins/pi/entries.d.ts +2 -0
  3. package/dist/plugins/pi/entries.js +2 -0
  4. package/dist/plugins/pi/reset/artifacts.d.ts +10 -2
  5. package/dist/plugins/pi/reset/artifacts.js +24 -5
  6. package/dist/plugins/pi/reset/lifecycle.d.ts +9 -8
  7. package/dist/plugins/pi/reset/lifecycle.js +109 -31
  8. package/dist/plugins/pi/runtime.js +9 -10
  9. package/dist/plugins/pi/text.d.ts +11 -14
  10. package/dist/plugins/pi/text.js +15 -16
  11. package/dist/src/index.d.ts +1 -1
  12. package/dist/src/index.js +1 -1
  13. package/dist/test/agent-loop.test.js +316 -163
  14. package/dist/test/boot.integration.test.js +3 -3
  15. package/dist/test/claude-validation.test.js +4 -2
  16. package/dist/test/dsh-cli.test.js +7 -6
  17. package/dist/test/helpers/dsh-messages.js +3 -0
  18. package/dist/test/model-facing-text.test.js +10 -4
  19. package/dist/test/reset-lifecycle.test.js +105 -15
  20. package/docs/notes-library.md +1 -1
  21. package/docs/reset-lifecycle.md +42 -58
  22. package/package.json +2 -6
  23. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  24. package/plugins/claude/dist/claude/helper.js +485 -485
  25. package/plugins/paseo/OVERVIEW.md +7 -0
  26. package/plugins/paseo/README.md +12 -0
  27. package/plugins/paseo/client/source-row.ts +14 -0
  28. package/plugins/paseo/client/sticky-card.tsx +21 -0
  29. package/plugins/paseo/index.client.tsx +10 -0
  30. package/plugins/paseo/package.json +19 -0
  31. package/plugins/paseo/paseo-plugin.json +4 -0
  32. package/plugins/paseo/shared/last-word.ts +6 -0
  33. package/plugins/paseo/test/source-row.test.ts +19 -0
  34. package/plugins/paseo/tsconfig.json +16 -0
  35. package/plugins/pi/entries.ts +2 -0
  36. package/plugins/pi/reset/artifacts.ts +26 -5
  37. package/plugins/pi/reset/lifecycle.ts +101 -34
  38. package/plugins/pi/runtime.ts +9 -10
  39. package/plugins/pi/text.ts +17 -17
  40. package/src/index.ts +1 -1
  41. package/docs/sdk-integration.md +0 -39
@@ -85,7 +85,7 @@ test("the root boot and reset boot carry durable window identity", async () => {
85
85
  assert.equal(boundary.continue, true);
86
86
  await runHandlers(captured, "turn_start", {}, ctx);
87
87
  await runHandlers(captured, "agent_settled", {}, ctx);
88
- assert.deepEqual(noticesOf(ctx).filter((notice) => notice.message.includes("Brain emptied")), [{ message: "🥣 Brain emptied", type: "info" }], "the committed reset is announced once");
88
+ assert.deepEqual(noticesOf(ctx).filter((notice) => notice.message.includes("Fresh brain")), [{ message: "🥣 Fresh brain", type: "info" }], "the committed reset is announced once");
89
89
  const entries = sessionManager.getBranch();
90
90
  const marker = entries.find((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE);
91
91
  assert.ok(marker && marker.type === "custom");
@@ -377,7 +377,7 @@ test("forced reset confirmation warns about overflow", async () => {
377
377
  const ctx = context(sessionManager, undefined, { tokens: 199_000, contextWindow: 200_000, percent: 99.5 });
378
378
  await commitTurnEndBoundary(captured, sessionManager, ctx);
379
379
  await runHandlers(captured, "agent_settled", {}, ctx);
380
- assert.deepEqual(noticesOf(ctx).filter((notice) => notice.message.includes("Brain emptied")), [{ message: "🥣 Brain emptied forcibly: overflow", type: "warning" }]);
380
+ assert.deepEqual(noticesOf(ctx).filter((notice) => notice.message.includes("forcibly emptied")), [{ message: "🥣 Brain forcibly emptied: overflow", type: "warning" }]);
381
381
  });
382
382
  test("committed reset confirmation survives later work while repair refuses that suffix", async () => {
383
383
  const sessionManager = manager();
@@ -394,7 +394,7 @@ test("committed reset confirmation survives later work while repair refuses that
394
394
  assert.equal(resetBoundaryCommitted(ctx, marker.id, windowId), true, "later work does not undo a committed native boundary");
395
395
  await runHandlers(captured, "agent_settled", {}, ctx);
396
396
  await runHandlers(captured, "turn_start", {}, ctx);
397
- assert.equal(noticesOf(ctx).filter((notice) => notice.message.includes("Brain emptied")).length, 1);
397
+ assert.equal(noticesOf(ctx).filter((notice) => notice.message.includes("Fresh brain")).length, 1);
398
398
  assert.equal(resetBoundaryCommitted(ctx, marker.id, "wrong-window"), false);
399
399
  const partial = manager();
400
400
  const partialCtx = context(partial);
@@ -5,10 +5,12 @@ import { tmpdir } from "node:os";
5
5
  import { join } from "node:path";
6
6
  import test from "node:test";
7
7
  const plugin = join(process.cwd(), "plugins/claude");
8
+ const CLAUDE_VALIDATE_TIMEOUT_MS = 60_000;
8
9
  /** Only an absent executable may skip the real loader gate; other failures fail the suite. */
9
10
  function validate(t, dir) {
10
11
  const result = spawnSync("claude", ["plugin", "validate", dir, "--strict", "--json"], {
11
- encoding: "utf8", timeout: 30_000,
12
+ encoding: "utf8",
13
+ timeout: CLAUDE_VALIDATE_TIMEOUT_MS,
12
14
  });
13
15
  if (result.error?.code === "ENOENT") {
14
16
  t.skip("Claude mod validation skipped: claude is not installed (not found on PATH)");
@@ -29,7 +31,7 @@ test("Claude mod passes the installed engine's strict loader validation", (t) =>
29
31
  });
30
32
  test("Claude mod typechecks against the vendored engine contract without Node globals", () => {
31
33
  const result = spawnSync(process.execPath, ["node_modules/typescript/bin/tsc", "-p", "plugins/claude/tsconfig.json"], {
32
- encoding: "utf8", timeout: 30_000,
34
+ encoding: "utf8",
33
35
  });
34
36
  assert.ifError(result.error);
35
37
  assert.equal(result.status, 0, result.stdout + result.stderr);
@@ -10,7 +10,7 @@ import { messagesServer } from "./helpers/dsh-messages.js";
10
10
  const exec = promisify(execFile);
11
11
  const repository = fileURLToPath(new URL("../../", import.meta.url));
12
12
  const system = (request) => typeof request.system === "string" ? request.system : request.system?.map((block) => block.text).join("\n") ?? "";
13
- test("dsh profile loads our rows and a second process restores the on-disk window", { timeout: 45000 }, async (t) => {
13
+ test("dsh profile loads our rows and a second process restores the on-disk window", async (t) => {
14
14
  const directory = await mkdtemp(join(tmpdir(), "notesoup-dsh-cli-"));
15
15
  const mock = await messagesServer();
16
16
  t.after(async () => { await mock.close(); await rm(directory, { recursive: true, force: true }); });
@@ -26,19 +26,20 @@ test("dsh profile loads our rows and a second process restores the on-disk windo
26
26
  .replace("'notesoup/dsh'", `'${pathToFileURL(join(repository, "dist/plugins/dsh/index.js")).href}'`)
27
27
  .replace("# notesHome: /absolute/path/to/notes", `notesHome: ${join(directory, "notes")}`);
28
28
  await writeFile(join(profile, "cordis.patch.yml"), patch + "\n- id: session-title-llm\n disabled: true\n");
29
- const env = { ...process.env, DSH_HOME: home, DEEPSEEK_API_KEY: "mock-key", DEEPSEEK_BASE_URL: mock.url, DSH_TOOLS_MODE: "native" };
29
+ // A broken ambient proxy must not intercept the local Messages server.
30
+ const env = { ...process.env, NODE_USE_ENV_PROXY: "1", HTTP_PROXY: "http://127.0.0.1:1", http_proxy: "http://127.0.0.1:1", DSH_HOME: home, DEEPSEEK_API_KEY: "mock-key", DEEPSEEK_BASE_URL: mock.url, DSH_TOOLS_MODE: "native" };
30
31
  const cli = resolve(repository, "node_modules/@deepseek-ai/dsh/lib/bin.js");
31
32
  mock.script.push({ tool: "empty_brain", input: {} }, { text: "after reset" });
32
- const first = await exec(process.execPath, [cli, "--profile", "notesoup-test", "old conversation"], { cwd: directory, env, timeout: 20000 });
33
- assert.equal(mock.requests.length, 2, first.stderr);
33
+ const first = await exec(process.execPath, [cli, "--profile", "notesoup-test", "old conversation"], { cwd: directory, env, signal: t.signal, killSignal: "SIGKILL" });
34
+ assert.equal(mock.requests.length, 2, JSON.stringify(first));
34
35
  assert.equal(mock.requests[1].messages.length, 1);
35
36
  assert.notEqual(system(mock.requests[0]), system(mock.requests[1]));
36
37
  const sessionPaths = await readdir(join(home, "sessions"), { recursive: true });
37
38
  const sessionId = sessionPaths.map((entry) => entry.split("/").at(-1)).find((entry) => entry.startsWith("session-"));
38
39
  assert.ok(sessionId, JSON.stringify(sessionPaths));
39
40
  mock.script.push({ text: "reloaded" });
40
- const second = await exec(process.execPath, [cli, "--profile", "notesoup-test", "--session-id", sessionId, "resume"], { cwd: directory, env, timeout: 20000 });
41
- assert.equal(mock.requests.length, 3, second.stderr);
41
+ const second = await exec(process.execPath, [cli, "--profile", "notesoup-test", "--session-id", sessionId, "resume"], { cwd: directory, env, signal: t.signal, killSignal: "SIGKILL" });
42
+ assert.equal(mock.requests.length, 3, JSON.stringify(second));
42
43
  assert.equal(system(mock.requests[2]), system(mock.requests[1]));
43
44
  assert.equal(JSON.stringify(mock.requests[2].messages).includes("old conversation"), false);
44
45
  });
@@ -1,4 +1,7 @@
1
1
  import { createServer } from "node:http";
2
+ // Keep local fixtures off inherited proxies, including in the DSH CLI child processes.
3
+ // Lowercase wins in Node's proxy settings; preserve that effective exclusion list.
4
+ process.env.no_proxy = process.env.NO_PROXY = [process.env.no_proxy || process.env.NO_PROXY, "127.0.0.1"].filter(Boolean).join(",");
2
5
  /** Same Messages/SSE approach as /tmp/dsh-spike/mock/llm-server.mjs; no credentials or external traffic. */
3
6
  export async function messagesServer() {
4
7
  const requests = [];
@@ -6,7 +6,7 @@ import { renderBootBlock } from "../src/boot/render.js";
6
6
  import { loadNotesSnapshot } from "../src/boot/snapshot.js";
7
7
  import { DEFAULT_BOOT_TOOL_NAMES, MAPS_BLOCK, NOTES_PROTOCOL_CLOSE_TAG, NOTES_PROTOCOL_OPEN_TAG, WINDOW_IDENTITY_CLOSE_TAG, WINDOW_IDENTITY_OPEN_TAG, renderProtocolBlock } from "../src/boot/text.js";
8
8
  import { CLAUDE_WARNING_PROMPT, CLAUDE_WIPE_SENTENCE } from "../plugins/claude/src/text.js";
9
- import { PI_PRE_RESET_HINTS, LAST_WORD_HINT, warningContent } from "../plugins/pi/text.js";
9
+ import { COMMAND_NOTICE, PI_PRE_RESET_HINTS, LAST_WORD_HINT, commandWarningContent, warningContent } from "../plugins/pi/text.js";
10
10
  import { COUNTDOWN_LINE, FORCED_CONTINUATIONS, GUIDANCE_CLOSE_TAG, GUIDANCE_OPEN_TAG, NORMAL_CONTINUATIONS, WARNING_BODY, selectContinuation, tokenBudgetGuidance } from "../src/budget/text.js";
11
11
  /**
12
12
  * The reviewed Design text is what the model actually reads, so the golden copies below pin it
@@ -105,16 +105,22 @@ test("the countdown closes the second-tier notice only, in both hosts", () => {
105
105
  assert.ok(pi.endsWith(`\n${GUIDANCE_CLOSE_TAG}`));
106
106
  assert.ok(pi.includes(`\n${LAST_WORD_HINT}\n${COUNTDOWN_LINE}\n`), "the countdown comes after the Pi-only last-word hint");
107
107
  assert.equal(pi.split(COUNTDOWN_LINE).length - 1, 1, "the second tier carries the countdown exactly once");
108
- const prompted = warningContent("/empty keep going");
108
+ const prompted = commandWarningContent("/empty keep going");
109
109
  assert.ok(prompted.includes("<notesoup:next_window_prompt>\n/empty keep going\n</notesoup:next_window_prompt>"));
110
- assert.ok(prompted.endsWith(`\n${COUNTDOWN_LINE}\n${GUIDANCE_CLOSE_TAG}`), "the prompt block does not displace the countdown");
110
+ assert.ok(prompted.includes(`\n${COUNTDOWN_LINE}\n${GUIDANCE_CLOSE_TAG}\n<notesoup:next_window_prompt>`), "the prompt block follows the closed notice");
111
+ assert.equal(commandWarningContent(), `${GUIDANCE_OPEN_TAG}\n${COMMAND_NOTICE.bare}\n${WARNING_BODY}\n${LAST_WORD_HINT}\n${COUNTDOWN_LINE}\n${GUIDANCE_CLOSE_TAG}`);
112
+ assert.equal(prompted, `${GUIDANCE_OPEN_TAG}\n${COMMAND_NOTICE.prompted}\n${WARNING_BODY}\n${LAST_WORD_HINT}\n${COUNTDOWN_LINE}\n${GUIDANCE_CLOSE_TAG}\n<notesoup:next_window_prompt>\n/empty keep going\n</notesoup:next_window_prompt>`);
113
+ assert.equal(prompted.includes(PI_PRE_RESET_HINTS), false, "manual commands own reset timing");
111
114
  assert.equal(CLAUDE_WARNING_PROMPT.endsWith(`\n${COUNTDOWN_LINE}`), true, "Claude's variant ends the same way");
112
115
  assert.equal(tokenBudgetGuidance(100, "empty_brain").includes(COUNTDOWN_LINE), false, "the first tier never counts down");
113
116
  for (const text of [pi, prompted, CLAUDE_WARNING_PROMPT, tokenBudgetGuidance(100, "empty_brain")]) {
114
117
  assert.equal(/context_window/.test(text), false, "no pre-rename tag survives in model-facing text");
115
118
  }
116
119
  });
117
- test("only Pi's protocol claims the reset clears the human's chat view", () => {
120
+ test("only Pi's protocol explains that reset erases the human's view", () => {
121
+ assert.equal(PI_PRE_RESET_HINTS, "Anything you say here is erased with the reset — the human can't read it afterward either. Put the handoff in your notes; explanations belong after the reset.\nUnless the human explicitly directs otherwise, decide for yourself when to call empty_brain. Don't keep asking them whether to reset.");
122
+ assert.equal(COMMAND_NOTICE.bare, "The human ran /empty. Save your notes now and call `empty_brain` immediately. Anything you say here will be erased afterward — put the handoff in your notes. Anything the human sends from now on should be handled after the reset.");
123
+ assert.equal(COMMAND_NOTICE.prompted, "The human ran /empty. Save your notes now and call `empty_brain` immediately. Anything you say here will be erased afterward — put the handoff in your notes. The prompt below, and anything the human sends from now on, should be handled after the reset.");
118
124
  const pi = renderProtocolBlock({ ...DEFAULT_BOOT_TOOL_NAMES, preResetHints: PI_PRE_RESET_HINTS });
119
125
  assert.ok(pi.includes(`\n${PI_PRE_RESET_HINTS}\n${NOTES_PROTOCOL_CLOSE_TAG}`), "both hints end the protocol, before the closing tag");
120
126
  assert.equal(pi.split(PI_PRE_RESET_HINTS).length - 1, 1, "the hints appear once");
@@ -6,13 +6,14 @@ import test from "node:test";
6
6
  import { Check } from "typebox/value";
7
7
  import { SessionManager as Manager } from "@earendil-works/pi-coding-agent";
8
8
  import notesoup from "../plugins/pi/extension.js";
9
- import { BOOT_TYPE, CONTINUATION_TYPE, GUIDANCE_TYPE, RESET_LAST_WORD_TYPE, RESET_MARKER_TYPE } from "../plugins/pi/entries.js";
9
+ import { BOOT_TYPE, CARRIED_INPUT_TYPE, CONTINUATION_TYPE, GUIDANCE_TYPE, RESET_LAST_WORD_TYPE, RESET_MARKER_TYPE } from "../plugins/pi/entries.js";
10
10
  import { MANUAL_WIPE_TYPE } from "../plugins/pi/entries.js";
11
11
  import { assertBootHistory, toolContext } from "./helpers/extension.js";
12
12
  import { COUNTDOWN_LINE, FORCED_CONTINUATIONS, NORMAL_CONTINUATIONS } from "../src/budget/text.js";
13
- import { LAST_WORD_HINT, WARNING_CALL_PROMPTED, warningContent } from "../plugins/pi/text.js";
13
+ import { LAST_WORD_HINT, commandWarningContent } from "../plugins/pi/text.js";
14
14
  import { historyFromSession, nextHistorySeq } from "../plugins/pi/history.js";
15
- import { buildResetDrafts, LAST_WORD_PREFIX, MAX_LAST_WORD_CHARS, sanitizeLastWord } from "../plugins/pi/reset/artifacts.js";
15
+ import { buildResetDrafts, inspectResetTail, LAST_WORD_PREFIX, MAX_LAST_WORD_CHARS, repairResetTail, sanitizeLastWord } from "../plugins/pi/reset/artifacts.js";
16
+ import { resetBoundaryCommitted } from "../plugins/pi/reset/committed.js";
16
17
  import { initialResetControl, reduceResetControl, registerResetLifecycle, } from "../plugins/pi/reset/lifecycle.js";
17
18
  const previousNotesHome = process.env.PI_NOTES_HOME;
18
19
  const testNotesHome = mkdtempSync(join(tmpdir(), "notesoup-lifecycle-notes-"));
@@ -235,14 +236,13 @@ test("off stops future automatic/manual reset requests while an existing marker
235
236
  assert.equal(h.sent[0]?.customType, MANUAL_WIPE_TYPE);
236
237
  const warning = h.sessionManager.getBranch().find((entry) => entry.type === "custom_message" && entry.customType === MANUAL_WIPE_TYPE);
237
238
  assert.ok(warning && warning.type === "custom_message");
238
- assert.equal(warning.content, warningContent());
239
+ assert.equal(warning.content, commandWarningContent());
239
240
  const markers = h.sessionManager.getBranch().filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE);
240
241
  assert.equal(markers.length, 1, "manual command waits for an agent boundary; it does not persist an immediate reset");
241
242
  });
242
243
  test("manual /empty with a prompt shows the human's command line in the close-out", async () => {
243
244
  const h = harness();
244
- // Assert on values, not on the warning's wording: the command line must survive verbatim
245
- // and must precede the closing instruction, so the prompt cannot read as this window's task.
245
+ // Structure and carried values are checked here; exact copy lives in model-facing-text tests.
246
246
  await h.runCommand("empty", "Continue reviewing the implementation");
247
247
  const warning = h.sessionManager.getBranch().find((entry) => entry.type === "custom_message" && entry.customType === MANUAL_WIPE_TYPE);
248
248
  assert.ok(warning?.type === "custom_message", "the close-out warning is persisted");
@@ -250,11 +250,10 @@ test("manual /empty with a prompt shows the human's command line in the close-ou
250
250
  const promptLine = "/empty Continue reviewing the implementation";
251
251
  const promptIndex = content.indexOf(promptLine);
252
252
  assert.ok(promptIndex >= 0, "the human's raw command line reaches the closing model");
253
- const closingIndex = content.indexOf(WARNING_CALL_PROMPTED);
254
- assert.ok(closingIndex > promptIndex, "the closing instruction follows the prompt, so the order stays prompt then act");
253
+ assert.ok(promptIndex > content.indexOf("</notesoup:budget_notice>"), "deferred work is outside the notice");
255
254
  assert.ok(content.indexOf(COUNTDOWN_LINE) > content.indexOf(LAST_WORD_HINT), "the countdown follows the Pi-only last-word hint");
256
255
  assert.equal(content.split(COUNTDOWN_LINE).length - 1, 1, "the notice carries the countdown once");
257
- // The prompt was a note-to-self for the closing window: it never becomes the next window's task.
256
+ // The same original text becomes the new window's task, not a notes-only hint.
258
257
  const settle = resultEntries(await h.emit("agent_before_settle", {
259
258
  type: "agent_before_settle",
260
259
  entries: [],
@@ -267,7 +266,92 @@ test("manual /empty with a prompt shows the human's command line in the close-ou
267
266
  RESET_MARKER_TYPE,
268
267
  BOOT_TYPE,
269
268
  CONTINUATION_TYPE,
270
- ], "the reset tail is one boot, one continuation, and no persisted prompt");
269
+ CARRIED_INPUT_TYPE,
270
+ ], "the reset tail ends with the carried human input");
271
+ assert.deepEqual(settle.entries.at(-1), { type: "custom_message", customType: CARRIED_INPUT_TYPE, content: "Continue reviewing the implementation", display: true });
272
+ });
273
+ test("input arriving during reset construction survives even when the hidden steer is never delivered", async () => {
274
+ const sessionManager = Manager.inMemory("/private/tmp/notesoup-late-input-test");
275
+ const handlers = new Map();
276
+ const steers = [];
277
+ const api = {
278
+ on(name, handler) { handlers.set(name, handler); },
279
+ sendMessage(message, options) { steers.push({ message, options }); },
280
+ };
281
+ const ctx = {
282
+ cwd: "/private/tmp", sessionManager, model: undefined, hasPendingMessages: () => false,
283
+ isProjectTrusted: () => true, ui: { notify() { } },
284
+ };
285
+ let release;
286
+ const gate = new Promise((resolve) => { release = resolve; });
287
+ const lifecycle = registerResetLifecycle(api, {
288
+ isEnabled: () => true,
289
+ budget: { automaticResetEnabled: () => true, hardReserveDue: () => false, consumeTurnEnd: () => [], clear() { } },
290
+ async buildReset(ctx, isCurrent, lastWord, firstSeq, origin) {
291
+ await gate;
292
+ return buildResetDrafts(ctx, undefined, isCurrent, lastWord, firstSeq, origin);
293
+ },
294
+ });
295
+ lifecycle.command(`pcw:${sessionManager.getSessionId().slice(0, 8)}:root`, false);
296
+ lifecycle.request(`pcw:${sessionManager.getSessionId().slice(0, 8)}:root`, "handoff");
297
+ const pending = handlers.get("agent_before_settle")({ ...fakeBoundaryEvent(), type: "agent_before_settle" }, ctx);
298
+ assert.equal(await handlers.get("input")({ source: "extension", text: "not intercepted" }, ctx), undefined);
299
+ assert.deepEqual(await handlers.get("input")({ source: "rpc", text: " first\ninput " }, ctx), { action: "handled" });
300
+ assert.deepEqual(await handlers.get("input")({ source: "interactive", text: "second" }, ctx), { action: "handled" });
301
+ release();
302
+ const boundary = resultEntries([await pending]);
303
+ assert.equal(boundary.continue, true, "late input overrides the bare command's stop");
304
+ assert.deepEqual(boundary.entries.slice(-2).map((entry) => entry.type === "custom_message" ? entry.content : null), [" first\ninput ", "second"]);
305
+ assert.equal(steers.length, 2, "steers were queued but never delivered by this host");
306
+ appendDrafts(sessionManager, boundary.entries);
307
+ const marker = sessionManager.getBranch().find((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE);
308
+ const windowId = marker.data.windowId;
309
+ assert.equal(resetBoundaryCommitted(ctx, marker.id, windowId), true);
310
+ assert.deepEqual(inspectResetTail(ctx, marker.id, windowId), { boot: true, continuation: true }, "last word and trailing inputs form a complete ordered boundary");
311
+ await repairResetTail(api, ctx, marker);
312
+ assert.equal(steers.length, 2, "repair never duplicates a complete boundary with carried inputs");
313
+ sessionManager.appendCustomMessageEntry(BOOT_TYPE, "late boot", false, { windowId });
314
+ assert.equal(inspectResetTail(ctx, marker.id, windowId), undefined, "artifacts cannot restart after carried input");
315
+ assert.equal(resetBoundaryCommitted(ctx, marker.id, windowId), true, "later malformed work does not undo a committed prefix");
316
+ sessionManager.appendCompaction("", null, 0);
317
+ const partialMarker = sessionManager.appendCustomEntry(RESET_MARKER_TYPE, { windowId: "partial" });
318
+ sessionManager.appendCustomMessageEntry(BOOT_TYPE, "boot", false, { windowId: "partial" });
319
+ sessionManager.appendCustomMessageEntry(CARRIED_INPUT_TYPE, "too early", true);
320
+ assert.equal(inspectResetTail(ctx, partialMarker, "partial"), undefined, "repair cannot append a continuation after human content");
321
+ assert.equal(resetBoundaryCommitted(ctx, partialMarker, "partial"), false);
322
+ });
323
+ test("abort during reset construction restores handled input at settlement, once", async () => {
324
+ const sessionManager = Manager.inMemory("/private/tmp/notesoup-cancelled-build-test");
325
+ const handlers = new Map();
326
+ const sent = [];
327
+ const api = {
328
+ on(name, handler) { handlers.set(name, handler); },
329
+ sendMessage(message, options) { sent.push({ message, options }); },
330
+ };
331
+ const controller = new AbortController();
332
+ const ctx = { sessionManager, signal: controller.signal, hasPendingMessages: () => false, ui: { notify() { } } };
333
+ let release;
334
+ const gate = new Promise((resolve) => { release = resolve; });
335
+ const lifecycle = registerResetLifecycle(api, {
336
+ isEnabled: () => true,
337
+ budget: { automaticResetEnabled: () => false, hardReserveDue: () => false, consumeTurnEnd: () => [], clear() { } },
338
+ async buildReset() { await gate; return []; },
339
+ });
340
+ const windowId = `pcw:${sessionManager.getSessionId().slice(0, 8)}:root`;
341
+ lifecycle.command(windowId, false);
342
+ const building = handlers.get("agent_before_settle")({ ...fakeBoundaryEvent(), type: "agent_before_settle" }, ctx);
343
+ assert.deepEqual(await handlers.get("input")({ source: "rpc", text: "cancelled during construction" }, ctx), { action: "handled" });
344
+ controller.abort();
345
+ release();
346
+ assert.equal(await building, undefined, "aborted construction must not commit a reset");
347
+ await handlers.get("agent_settled")({}, ctx);
348
+ await handlers.get("agent_settled")({}, ctx);
349
+ const restored = sent.filter((item) => item.message.customType === CARRIED_INPUT_TYPE);
350
+ assert.deepEqual(restored, [{ message: { type: "custom_message", customType: CARRIED_INPUT_TYPE, content: "cancelled during construction", display: true }, options: { triggerTurn: false } }]);
351
+ // A later command in the same window must not revive the cancelled command's steer.
352
+ lifecycle.command(windowId, false);
353
+ const stale = { role: "custom", ...sent[0].message };
354
+ assert.deepEqual(await handlers.get("context_with_system")({ messages: [stale] }, ctx), { messages: [] });
271
355
  });
272
356
  test("reset construction failure preserves incoming and budget drafts without continuation", async () => {
273
357
  const sessionManager = Manager.inMemory("/private/tmp/notesoup-reset-failure-test");
@@ -519,7 +603,6 @@ test("reset-control: fallback is normal-stop only; hard reserve remains safety",
519
603
  assert.equal(notNormalStop.effect, "none");
520
604
  assert.deepEqual(notNormalStop.state, initialResetControl());
521
605
  }
522
- assert.deepEqual(reduceResetControl(manual, { type: "settled" }).state, initialResetControl());
523
606
  });
524
607
  test("reset-control: manual stop survives a hard-reserve reset across windows without a second wipe", () => {
525
608
  const windowId = "pcw:test:window";
@@ -538,7 +621,7 @@ test("reset-control: manual stop survives a hard-reserve reset across windows wi
538
621
  assert.equal(stop.effect, "stop", "the safety boundary already wiped; settlement must only stop");
539
622
  assert.deepEqual(stop.state, initialResetControl());
540
623
  assert.equal(reduceResetControl(safety.state, { type: "before_settle", facts: beforeSettleFacts() }).effect, "commit-boundary-stop", "a failed safety construction may be retried before settlement");
541
- assert.deepEqual(reduceResetControl(safety.state, { type: "abort" }).state, initialResetControl());
624
+ assert.deepEqual(reduceResetControl(safety.state, { type: "before_settle", facts: beforeSettleFacts({ windowId: freshWindowId, aborted: true }) }).state, initialResetControl());
542
625
  });
543
626
  test("reset-control: manual overflow keeps stop intent while queued work supersedes the failure", () => {
544
627
  const windowId = "pcw:test:window";
@@ -552,15 +635,22 @@ test("reset-control: manual overflow keeps stop intent while queued work superse
552
635
  assert.deepEqual(success.state.request, manual.request, "a successful queued turn clears only the overflow, not the manual wipe");
553
636
  assert.equal(success.state.overflow, "idle");
554
637
  assert.equal(reduceResetControl(success.state, { type: "before_settle", facts: beforeSettleFacts() }).effect, "commit-boundary-stop");
638
+ const prompted = reduceResetControl(manual, { type: "input", windowId, input: "answer after reset" }).state;
639
+ const called = reduceResetControl(prompted, { type: "tool_request", windowId, lastWord: "saved" }).state;
640
+ const failed = reduceResetControl(called, { type: "turn_end", facts: turnEndFacts({ overflow: true, failed: true, automaticResetEnabled: false }) }).state;
641
+ const retry = reduceResetControl(failed, { type: "before_settle", facts: beforeSettleFacts({ failed: true, automaticResetEnabled: false }) });
642
+ assert.equal(retry.effect, "commit-boundary", "manual input continues even when automatic reset is disabled");
643
+ assert.equal(retry.origin, "forced", "an overflowing close-out is forced even after a tool request");
644
+ assert.equal(retry.lastWord, "saved");
645
+ assert.equal(retry.state.overflow, "spent", "manual recovery spends the same bounded attempt");
555
646
  });
556
- test("reset-control: abort and lifecycle transitions clear every pending phase", () => {
647
+ test("reset-control: explicit abort clears a pending request at turn end or settlement", () => {
557
648
  const windowId = "pcw:test:window";
558
649
  const pending = reduceResetControl(initialResetControl(), { type: "command", windowId, continueAfterReset: false }).state;
559
650
  const aborted = reduceResetControl(pending, { type: "turn_end", facts: turnEndFacts({ aborted: true }) });
560
651
  assert.equal(aborted.effect, "none");
561
652
  assert.deepEqual(aborted.state, initialResetControl());
562
- assert.deepEqual(reduceResetControl(pending, { type: "clear" }).state, initialResetControl());
563
- assert.deepEqual(reduceResetControl(pending, { type: "settled" }).state, initialResetControl());
653
+ assert.deepEqual(reduceResetControl(pending, { type: "before_settle", facts: beforeSettleFacts({ aborted: true }) }).state, initialResetControl());
564
654
  });
565
655
  test("reset-control: overflow recovery is armed at turn_end and spent exactly once at settle", () => {
566
656
  const armed = reduceResetControl(initialResetControl(), { type: "turn_end", facts: turnEndFacts({ overflow: true, failed: true }) });
@@ -26,7 +26,7 @@ const files = await notes.list({ glob: "@project/**" });
26
26
  const matches = await notes.search(["library"]);
27
27
  ```
28
28
 
29
- `/notes` ships JavaScript and TypeScript declarations. It does not import Pi or read `PI_*` environment variables. Pi packages are optional peers: a notes-only installation does not install them. Using the Pi plugin (`notesoup/pi`), the dsh rows (`notesoup/dsh`), or the `dream` CLI still requires its host. This is a filesystem library for Node, not a browser storage API.
29
+ `/notes` ships JavaScript and TypeScript declarations. It does not import Pi or read `PI_*` environment variables. Pi packages are optional peers: a notes-only installation does not install them. Using the Pi plugin, the dsh rows (`notesoup/dsh`), or the `dream` CLI still requires its host. This is a filesystem library for Node, not a browser storage API.
30
30
 
31
31
  ## API and identity
32
32
 
@@ -1,87 +1,71 @@
1
1
  # Reset lifecycle
2
2
 
3
- All lifecycle control flow is native Pi integration. `plugins/pi/reset/lifecycle.ts` owns actual tool requests, command settlement policy, bounded overflow recovery and scheduling. `plugins/pi/budget.ts` reads usage/settings and stages reminders; `src/budget/policy.ts` derives thresholds. `plugins/pi/reset/artifacts.ts` constructs ordered drafts and repairs incomplete suffixes; `plugins/pi/reset/committed.ts` confirms durable boundaries. `plugins/pi/window.ts` owns markers and provider projection. `plugins/pi/runtime.ts` wires commands, tools and public Pi hooks.
4
-
5
- Boot acquisition/rendering is shared: `src/boot/snapshot.ts` receives explicit identity, a captured time and an optional scope loader; `src/boot/render.ts` receives the snapshot and logical tool bindings. Pi supplies its existing names. Shared history is an addressed query projection, never an inference transcript or reset scheduler. There is no generic HostEvent or Harness reducer, and no second commit database.
3
+ Pi reset control lives in `plugins/pi/reset/lifecycle.ts`: the pure `reduceResetControl` selects effects; `registerResetLifecycle` adapts public Pi events and constructs boundaries. `budget.ts` stages reminders and checks settings; `reset/artifacts.ts` builds and repairs ordered artifacts; `reset/committed.ts` confirms durable boundaries. `window.ts` owns identities and provider projection; `runtime.ts` wires commands and tools. No Pi source patches, native summarization requests, or second commit database are used.
6
4
 
7
5
  ## Lifecycle at a glance
8
6
 
7
+ **Human input not yet answered must survive a reset and be answered afterward. Only a bare `/empty` with no later human input stops after resetting.**
8
+
9
9
  | Trigger | Behavior |
10
10
  | --- | --- |
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` | 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
- | 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
- | 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
- | 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. |
16
- | `/compact` while active | Cancel native compaction, which could otherwise summarize pre-reset history back into the active window. A manual attempt receives an actionable `/fresh-window` notice. |
11
+ | `empty_brain` tool | Record the actual call and optional last word. Without command policy, reset after the whole tool batch at `turn_end` and continue. Under command policy, wait for settlement. |
12
+ | `/empty <text>` or `/fresh-window <text>` | Send a hidden close-out warning (trigger when idle, steer when busy), then reset and continue. Carry the argument text verbatim as the next window's human message; it is not merely a notes hint. |
13
+ | Bare `/empty` or `/fresh-window` | Close out, reset, and stop, unless more human input arrives while close-out is pending. |
14
+ | Human input during command close-out | Intercept public `input` events except source `extension`, return `handled`, and stash text/images in command state. Also hidden-steer the bare `<notesoup:next_window_prompt>` block plus original images to the closing model. The originals are carried even if that steer never arrives; any carried input makes the reset continue. |
15
+ | Passive provider overflow / recoverable length | With automatic reset enabled, force a retain-none reset and continue once. Carry the failed logical run's human messages: starting prompt and delivered steering/follow-ups. A run started by our own continuation has no human input to carry. |
16
+ | Command close-out overflow | Force a reset even if automatic reset is disabled. Apply command policy: continue with text/carried input, otherwise stop. The recovery attempt is spent, so an oversized carried prompt cannot loop. |
17
+ | Budget warning | Stage reminders when automatic reset is enabled. Warnings alone never authorize reset. |
18
+ | Hard reserve | Independently reset at `turn_end` when automatic reset is enabled. A bare-command stop latch cancels empty tool follow-ups, but never real queued or carried human input. |
19
+ | Abort / ordinary error | Restore stashed originals as visible user-content custom messages before clearing command state. Explicit abort stays stopped; ordinary close-out errors do not force reset. |
20
+ | `/compact` while active | Cancel native compaction; manual attempts receive a `/fresh-window` notice. |
17
21
 
18
- A new boundary is ordered as:
22
+ Switching to a smaller model does not proactively reset or select another model. If its request overflows, the same bounded automatic recovery carries the unanswered prompt into a fresh window on the selected model. Disabling automatic reset disables passive overflow recovery.
19
23
 
20
- 1. A native `compaction` entry with `summary: ""` and `firstKeptEntryId` set to its own ID. This is Pi's retain-none canonical checkpoint; it is not a generated summary request.
21
- 2. A `notesoup/reset-marker` custom entry with `{ windowId, origin }`.
22
- 3. A hidden `notesoup/boot` custom message with matching `details.windowId`.
23
- 4. A hidden continuation message carrying the paragraph drawn for that boundary.
24
- 5. If the closing window passed a `last_word`, a visible `notesoup/reset-last-word` message carrying it. Pi boundary drafts do not support ordinary user entries, so the parting line is committed with the reset instead of queued separately.
24
+ ## Boundary order and handoff
25
25
 
26
- ## Handoff origin and the continuation pools
26
+ One public boundary draft contains, in order:
27
27
 
28
- The continuation is one randomly selected, complete paragraph from an approved pool, drawn when a new boundary artifact is created and persisted verbatim in the continuation entry; the marker's `origin` field records which pool was used. Rendering, history reads, and reloads never draw again, so a window keeps the handoff it was opened with.
29
-
30
- The origin comes directly from the recorded tool request: with a call it is `normal`, without one it is `forced`. Command policy affects timing and continuation, never origin. A hard-reserve stop latch retains the tool request for construction retry. No separate acknowledgement flag or warning-source inference is needed. Legacy markers without a valid origin default to normal.
31
-
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.
28
+ 1. A native `compaction` with `summary: ""` and `firstKeptEntryId: null` (Pi materializes its own ID: retain none).
29
+ 2. A `notesoup/reset-marker` custom entry with `{ windowId, origin }`.
30
+ 3. A hidden `notesoup/boot` custom message with matching `details.windowId`.
31
+ 4. One hidden continuation paragraph, selected once when the artifact is built.
32
+ 5. An optional visible `notesoup/reset-last-word` sticky note.
33
+ 6. One visible `notesoup/carried-input` custom message per carried human input, preserving original text/image content and order.
33
34
 
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
+ Boundary drafts cannot contain ordinary user entries. Pi's public custom-message conversion supplies role `user` to the provider, including text/image arrays. Carried inputs are appended atomically with the reset artifacts, not queued as separate prompts; any carried input returns `continue: true`.
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
+ The origin is `normal` for an actual tool request, otherwise `forced`; overflow recovery is always forced. Each origin has an approved complete-paragraph pool. Construction draws once and persists the paragraph verbatim; rendering, reads, reloads and repair never redraw an existing continuation. Legacy markers without a valid origin default to normal. Other hosts retain their own scheduling: dsh shares one draw across checkpoint and continuation; Claude caches its forced handoff per window.
37
38
 
38
- `turn_end` preserves incoming entries, consumes budget drafts and appends a reset only for a tool-only request or hard reserve. `agent_before_settle` executes command policy after queued work drains, or performs bounded overflow recovery. Pi owns ensuing continuation and scheduling. Async reset construction captures session/window generations and rechecks them, enabled state and abort status before returning drafts. Stale results are discarded without losing incoming/budget entries; construction failures notify only while current and do not claim a continuation.
39
+ Raw session history remains available. The retain-none checkpoint excludes old conversational context while preserving Pi's empty summary wrapper and system/tool state. Marker-only legacy sessions use boot slicing as a compatibility fallback. A marker is checkpoint-backed only if it directly follows a self-retaining, empty native compaction.
39
40
 
40
- ## Reducer state
41
+ ## Reducer and run state
41
42
 
42
- `reduceResetControl` is pure: the adapter supplies all lifecycle facts, and the reducer returns the next state plus a named effect. Its state combines a request phase with a bounded overflow phase:
43
+ `ResetControlState` combines a request and a bounded overflow phase:
43
44
 
44
- | State | Meaning |
45
+ | Request | Meaning |
45
46
  | --- | --- |
46
- | `{ phase: "none" }` | No request or command policy is pending. |
47
- | `{ phase: "pending", windowId, command?, tool? }` | `command: { continueAfterReset }` is settlement policy. `tool: { lastWord? }` records an actual model call, even without a last word. Either or both may exist; neither overwrites the other. No warning source or raw prompt is stored. |
48
- | `{ phase: "stop-pending", windowId, tool? }` | A manual hard-reserve reset was proposed for the given old window. The stop survives a committed window change; settlement stops without a second wipe (or retries construction if the old window is still active). New wipe requests only acknowledge it. |
49
-
50
- | `overflow: "idle"` | No overflow recovery is pending. |
51
- | `overflow: "pending"` | An overflow failure may recover once at pre-settlement. |
52
- | `overflow: "pending-spent"` | Recovery was already spent in this failure chain. |
53
- | `overflow: "spent"` | The one recovery has been used until the chain settles. |
54
-
55
- ### Transition rules
56
-
57
- - `command(windowId, continueAfterReset)` stores settlement policy. Duplicate same-window commands retain the first policy; a pending tool request is retained.
58
- - `tool_request(windowId, lastWord?)` records an actual call without changing command policy. Tool-only duplicates keep the first request; under command policy, repeated calls may supply the first nonempty last word.
59
- - `turn_end` clears on abort. Overflow preserves command policy and its tool request; otherwise automatic recovery is armed only when enabled and unqueued. Other errors drop pending requests. Success commits a tool-only request or hard-reserve reset. Hard reserve under a bare command retains the cross-window `stop-pending` latch; a continuing command needs no stop latch.
60
- - `agent_before_settle` waits for queued work. Command overflow resets even with automatic recovery disabled, honoring command continuation policy. Other overflow recovery gets one attempt. A committed stop latch stops without a second wipe; an uncommitted one can retry construction. Otherwise a successful command settles and resets. No command means no ordinary settle reset.
61
- - `agent_settled`, session start/tree navigation/shutdown, `/notesoup off`, and abort clear transient request state. Durable checkpoint/marker history remains authoritative after transient state is gone.
62
-
63
- After a manual safety reset, `context_with_system` verifies the committed checkpoint/marker/boot/continuation before using public `ctx.abort()` to cancel Pi's otherwise unavoidable tool-batch follow-up, returning a system-only safe context. Pending messages or a real user message after the reset marker bypass cancellation so queued work is not swallowed. A follow-up queue may require Pi's ordinary tool follow-up to finish before delivery; the stop intent remains armed until that work settles. Abort/settlement clears the run-scoped latch, so later user prompts work normally.
64
-
65
- Budget warnings need no rearming or consumption in the lifecycle. Direct tool calls remain valid without a warning. Actual abort, synthetic assistant abort and generic provider failure keep their existing cleanup semantics.
47
+ | `none` | No command or tool request. |
48
+ | `pending` | Current `windowId`, optional `tool: { lastWord? }`, and optional `command: { continueAfterReset, inputs? }`. Command inputs retain originals, not prompt-block wrappers. Duplicate commands retain the first policy/text; tool calls do not overwrite command policy. |
49
+ | `stop-pending` | A bare-command hard-reserve reset's stop intent survives the window change. It retains the tool request for construction retry, but stops without a second wipe after commit. |
66
50
 
67
- ## Budget staging and notifications
51
+ Overflow phases are `idle`, `pending`, `spent`, and `pending-spent`. `turn_end` arms enabled recovery; `agent_before_settle` waits for queued work and spends at most one attempt. A successful queued turn supersedes the failure. Command overflow also spends the attempt before continuing. Abort, final settlement, session start/tree/shutdown and `/notesoup off` clear transient state.
68
52
 
69
- The early reminder is staged once per window at `reserve + reminderMarginTokens`; the final warning at `reserve + WARNING_RUNWAY_TOKENS`, only when automatic compaction is enabled. Hard reserve remains independent. Budget and command warnings have distinct message types, so an aborted command cannot suppress a later budget warning. Durable warning deduplication concerns only injection; no transient automatic close-out is armed or rearmed.
53
+ The adapter collects actual user `message_end` content until settlement or a successful reset boundary. Low-level `agent_start` events do not clear it: Pi can start additional loops while draining follow-ups/recovering. Custom boot/warning/continuation messages are never mistaken for human input. Successful boundary construction clears this run collection, so an automatic continuation does not replay old input.
70
54
 
71
- Pi's boot protocol and second-tier warning include pre-reset hints: the reset clears the human's chat view, so long explanations belong after it; the model manages reset timing unless directed otherwise. Those hints are Pi-only. Dsh's second-tier notice ends with the same countdown as Pi and Claude.
55
+ Command state remains live during asynchronous notes acquisition. Inputs arriving during construction join that same boundary and override a proposed stop. Hidden steers carry window/command identity; provider projection excludes them once that command ends, including steers Pi delivers only after the reset. Originals remain available exactly once as carried input. Construction captures session/window generations and rechecks identity, enabled state and abort status before returning drafts. Stale work preserves incoming/budget entries but discards reset drafts; construction failures notify only while current and do not claim continuation. If close-out cannot commit, stashed originals are restored with public `sendMessage(..., { triggerTurn: false })`, including cancellation during construction; clearing command state must not erase input already reported as handled.
72
56
 
73
- Budget drafts are instance-local and are consumed at turn end. They are discarded on abort, failed turn, transition, or window mismatch. The final warning notifies the UI when first injected into a model request, before the response or tool execution, rather than waiting for durability. Aborting the request does not retract the notice or repeat it on retry in the same window; early guidance remains UI-silent. Active-window usage and the exact `SettingsManager` authority drive threshold checks; default file-backed policy is cached per extension instance, while injected managers are read through their public API.
57
+ After a manual safety reset, `context_with_system` checks the committed boundary before using public `ctx.abort()` to cancel an unavoidable empty tool follow-up with system-only context. Pending messages, ordinary user entries or carried inputs after the marker bypass cancellation. Later user prompts are not affected by the run-scoped stop latch.
74
58
 
75
- ## Projection, repair, and history
59
+ ## Warnings, projection and repair
76
60
 
77
- `context_with_system` selects the active boot by durable `details.windowId`. For a verified native checkpoint, Pi's canonical projection is used directly; for a legacy marker-only reset, the compatibility projection slices at the matching boot. The projection preserves system/tool state and later prompt patches. If the boot is absent, the runtime aborts safely instead of sending raw history. Usage estimation uses the same checkpoint-aware projection decision.
61
+ Budget reminders are staged once per window at reserve plus reminder margin, then reserve plus warning runway. Hard reserve remains independent. Budget and command warnings use different types. The final budget warning notifies at first provider injection, not durability; early guidance stays UI-silent. Budget drafts are instance-local and discarded on abort, failed turn, transition or window mismatch. Active-window usage and the exact public `SettingsManager` authority determine thresholds.
78
62
 
79
- Commit confirmation and repair are different native facts. `resetBoundaryCommitted` validates a checkpoint-backed marker followed by its matching hidden boot and hidden continuation; later conversation does not undo that commit. `inspectResetTail` instead asks whether the entire suffix remains safe to repair, refusing later conversation, foreign messages, later markers or misordered/duplicate artifacts. UI success notices use confirmation, not the repair predicate, and remain committed-only.
63
+ Manual warnings begin with the `/empty` notice inside `<notesoup:budget_notice>`, followed by `WARNING_BODY`, the last-word hint and countdown. Optional command text sits after the closing tag in `<notesoup:next_window_prompt>`. They omit budget timing hints. Pi's boot protocol and budget warnings explain that reset erases the human's view and leave timing to the model unless directed otherwise; other hosts do not inherit that Pi-only claim.
80
64
 
81
- Startup/tree repair is narrow: it may complete a repairable marker tail when later conversation does not make the missing metadata ambiguous. It awaits the notes snapshot and rechecks lifecycle/window identity before sending a repaired boot or continuation. A missing continuation is drawn from the pool its marker's `origin` names; an existing continuation is never replaced, never redrawn, and its marker is never rewritten. Legacy marker-only tails remain supported; repair never moves a boundary or promotes an arbitrary compaction to a retain-none checkpoint. `/tree` summary generation is suppressed with an empty summary when either branch crosses a reset, because the raw summary generator bypasses the provider projection.
65
+ `context_with_system` selects the boot by durable window identity, using Pi's canonical checkpoint projection or legacy slicing. Missing boot aborts safely instead of exposing raw history. Usage estimates use the same projection decision. `/tree` summaries are suppressed when crossing reset branches because native branch summarization bypasses this projection.
82
66
 
83
- ## Validation and known limits
67
+ `resetBoundaryCommitted` validates checkpoint -> marker -> matching hidden boot -> hidden continuation; trailing last words, carried input or later conversation cannot undo that committed prefix. `inspectResetTail` checks the entire repairable suffix: optional last word and carried inputs must follow the continuation, with no duplicate/misordered artifacts or later conversation. A carried input before boot/continuation blocks repair rather than allowing metadata to be appended after human content. Startup/tree repair only fills missing boot/continuation when safe, rechecking lifecycle identity after notes acquisition. UI success notices use committed confirmation, not repairability.
84
68
 
85
- The test suite combines isolated reducer tests with scripted SDK tests executing Pi's real agent loop without model/network calls. The retained scripted AgentSession tests cover idle and streaming manual commands whose close-outs commit at settlement and stop without a fresh-window continuation, direct wipe without warning, budget close-out, same-window concurrent command deduplication, actual and synthetic abort/error cleanup, queued steering/follow-up delivery before the stop, hard-reserve and bounded-overflow recovery, successive resets, and real SessionManager file reopen after two retain-none checkpoints. It also checks raw-history preservation, canonical projection, empty-summary retention, system/tool state, warning/marker order, and fresh-window continuation.
69
+ ## Validation
86
70
 
87
- Focused regression tests distinguish committed-boundary confirmation from safe suffix repair even after later work. Resolved-AST dependency tests reject shared imports of native adapters and SDKs, including indirect type/re-export/dynamic paths. Retained behavioral cases are representative rather than exhaustive. Tree-summary suppression has no dedicated retained test, and external-provider behavior, every malformed persisted shape, and every filesystem failure mode are not established by this suite.
71
+ Scripted SDK tests run Pi's real agent loop without network calls: smaller-model overflow and prompt replay, command text, bare stop, intercepted text/images, hard-reserve handling, overflowing close-out and bounded retry. They also cover passive tool-loop steering/follow-ups and input-free automatic continuations. Focused tests check late input during asynchronous construction, stale queued steer exclusion, abort/error restoration, ordered carry artifacts, commit confirmation, safe repair, canonical projection and persisted history. External-provider behavior and every malformed persisted/filesystem case are not established by this suite.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.51.0",
3
+ "version": "0.51.2",
4
4
  "type": "module",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -13,10 +13,6 @@
13
13
  "types": "./dist/src/notes/index.d.ts",
14
14
  "import": "./dist/src/notes/index.js"
15
15
  },
16
- "./pi": {
17
- "types": "./dist/plugins/pi/index.d.ts",
18
- "import": "./dist/plugins/pi/index.js"
19
- },
20
16
  "./package.json": "./package.json",
21
17
  "./dsh": {
22
18
  "types": "./dist/plugins/dsh/index.d.ts",
@@ -66,7 +62,7 @@
66
62
  "scripts": {
67
63
  "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json && node scripts/build-extension.mjs && node -e \"require('node:fs').chmodSync('dist/plugins/pi/dream/cli.js', 0o755)\"",
68
64
  "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p plugins/claude/tsconfig.json",
69
- "test": "npm run build && node --test --test-concurrency=4 dist/test/*.test.js",
65
+ "test": "npm run build && node --test --test-concurrency=4 $(ls dist/test/*.test.js | grep -v dist/test/claude-validation.test.js) && node --test dist/test/claude-validation.test.js",
70
66
  "prepublishOnly": "npm run typecheck",
71
67
  "prepack": "npm run build"
72
68
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.51.0",
3
+ "version": "0.51.2",
4
4
  "description": "Durable notes and a host-scoped notes boot section for Claude Code.",
5
5
  "author": {
6
6
  "name": "AstroSheep"