notesoup 0.40.0 → 0.41.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.
Files changed (54) hide show
  1. package/dist/src/boot/render.js +1 -1
  2. package/dist/src/boot/text.js +11 -3
  3. package/dist/src/budget/policy.js +1 -1
  4. package/dist/src/budget/text.js +1 -1
  5. package/dist/src/dream/doctor.js +2 -1
  6. package/dist/src/dream/git.js +2 -1
  7. package/dist/src/dream/report.js +3 -2
  8. package/dist/src/error-message.d.ts +2 -0
  9. package/dist/src/error-message.js +4 -0
  10. package/dist/src/pi/anchored.d.ts +16 -0
  11. package/dist/src/pi/anchored.js +55 -0
  12. package/dist/src/pi/budget.d.ts +1 -1
  13. package/dist/src/pi/budget.js +33 -28
  14. package/dist/src/pi/dream/cli.js +3 -2
  15. package/dist/src/pi/dream/runner.js +2 -1
  16. package/dist/src/pi/reset/lifecycle.d.ts +1 -1
  17. package/dist/src/pi/reset/lifecycle.js +4 -3
  18. package/dist/src/pi/reset/text.d.ts +3 -3
  19. package/dist/src/pi/reset/text.js +2 -2
  20. package/dist/src/pi/runtime.js +12 -15
  21. package/dist/src/pi/thresholds.js +2 -1
  22. package/dist/test/agent-loop.test.js +78 -28
  23. package/dist/test/boot.integration.test.js +5 -5
  24. package/dist/test/budget-settings.integration.test.js +9 -8
  25. package/dist/test/claude-mod.test.js +7 -7
  26. package/dist/test/host-neutral.test.js +1 -1
  27. package/dist/test/notes.integration.test.js +1 -1
  28. package/dist/test/reset-lifecycle.test.js +2 -2
  29. package/mods/notesoup/.claude-plugin/plugin.json +1 -1
  30. package/mods/notesoup/dist/claude/helper.js +12 -4
  31. package/mods/notesoup/hooks/register.ts +18 -23
  32. package/mods/notesoup/playbook.md +10 -10
  33. package/mods/notesoup/skills/dream/SKILL.md +1 -1
  34. package/package.json +1 -1
  35. package/playbook.md +10 -10
  36. package/skills/dream/SKILL.md +1 -1
  37. package/skills/memory/SKILL.md +5 -3
  38. package/src/boot/render.ts +1 -1
  39. package/src/boot/text.ts +11 -3
  40. package/src/budget/policy.ts +1 -1
  41. package/src/budget/text.ts +1 -1
  42. package/src/dream/doctor.ts +2 -1
  43. package/src/dream/git.ts +2 -1
  44. package/src/dream/report.ts +3 -2
  45. package/src/error-message.ts +4 -0
  46. package/src/pi/anchored.ts +62 -0
  47. package/src/pi/budget.ts +27 -26
  48. package/src/pi/dream/cli.ts +3 -2
  49. package/src/pi/dream/runner.ts +2 -1
  50. package/src/pi/reset/lifecycle.ts +5 -4
  51. package/src/pi/reset/text.ts +2 -2
  52. package/src/pi/runtime.ts +12 -15
  53. package/src/pi/thresholds.ts +2 -1
  54. package/mods/pi-context/dist/claude/helper.js +0 -9324
@@ -125,12 +125,13 @@ async function openFixture(options) {
125
125
  await session.bindExtensions({
126
126
  uiContext: {
127
127
  notify(message, type) {
128
- if (message.startsWith("notesoup: memory cleared · ")) {
129
- const windowId = message.split(" · ")[1];
128
+ if (message === "🥣 Memory cleared") {
129
+ const marker = sessionManager.getBranch().filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE).at(-1);
130
+ const windowId = marker?.data?.windowId;
130
131
  assert.ok(sessionManager.getBranch().some((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE && entry.data?.windowId === windowId), "notification follows the reset marker commit");
131
132
  assert.ok(sessionManager.getBranch().some((entry) => entry.type === "custom_message" && entry.customType === BOOT_TYPE && entry.details?.windowId === windowId), "notification follows the reset boot commit");
132
133
  }
133
- if (type === "warning" && /^notesoup: context (?:almost full|running low)/.test(message))
134
+ if (type === "warning" && /^🥣 Context almost full/.test(message))
134
135
  budgetNotices++;
135
136
  notices.push(message);
136
137
  },
@@ -193,6 +194,9 @@ function assistant(fixture, content, stopReason = "stop", extra = {}) {
193
194
  function text(message) {
194
195
  return JSON.stringify(message?.messages ?? []);
195
196
  }
197
+ /** `text()` serializes to JSON, so match the reset prose in its escaped form. */
198
+ const CONTINUATION_JSON = JSON.stringify(CONTINUATION).slice(1, -1);
199
+ const WARNING_JSON = JSON.stringify(WARNING_PROMPT).slice(1, -1);
196
200
  function resetMarkers(fixture) {
197
201
  return fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE);
198
202
  }
@@ -214,7 +218,7 @@ function assertFreshRequest(fixture, requestIndex, oldSentinel) {
214
218
  const body = text(fixture.requests[requestIndex]);
215
219
  assert.equal(body.includes(oldSentinel), false, "the new provider request excludes the old window transcript");
216
220
  assert.ok(body.includes(CONTEXT_WINDOW_OPEN_TAG), "the new provider request includes the fresh context-window boot");
217
- assert.equal(body.split(CONTINUATION).length - 1, 1, "the fresh window carries exactly one reset message");
221
+ assert.equal(body.split(CONTINUATION_JSON).length - 1, 1, "the fresh window carries exactly one reset message");
218
222
  }
219
223
  test("real Pi codemode receives typed notes/history outcomes, including expected errors", { timeout: 20000 }, async () => {
220
224
  let fixture;
@@ -264,10 +268,9 @@ text({ marker: "HISTORY_SMOKE", calls: calls.call_count, complete: calls.complet
264
268
  fixture.close();
265
269
  }
266
270
  });
267
- test("real AgentSession: aborted early guidance retries silently with automatic reset disabled", async () => {
271
+ test("real AgentSession: aborted early guidance retries silently", async () => {
268
272
  let fixture;
269
273
  fixture = await openFixture({
270
- compactionEnabled: false,
271
274
  script: (request) => assistant(fixture, [{ type: "text", text: `response ${request}` }], request === 2 ? "aborted" : "stop", { usage: usage(50_000) }),
272
275
  });
273
276
  try {
@@ -293,6 +296,53 @@ test("real AgentSession: aborted early guidance retries silently with automatic
293
296
  fixture.close();
294
297
  }
295
298
  });
299
+ test("real AgentSession: no low-budget guidance while automatic reset is disabled", async () => {
300
+ let fixture;
301
+ fixture = await openFixture({
302
+ compactionEnabled: false,
303
+ script: (request) => assistant(fixture, [{ type: "text", text: `response ${request}` }], "stop", { usage: usage(62_000) }),
304
+ });
305
+ try {
306
+ for (const prompt of ["Establish usage below the reminder line.", "Cross the reminder line."]) {
307
+ await fixture.session.prompt(prompt);
308
+ await fixture.session.waitForIdle();
309
+ }
310
+ const guidance = fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === GUIDANCE_TYPE);
311
+ assert.equal(guidance.length, 0, "nothing will be cleared, so nothing is announced");
312
+ }
313
+ finally {
314
+ fixture.close();
315
+ }
316
+ });
317
+ test("real AgentSession: early guidance reaches its crossing request and later requests keep one copy in place", async () => {
318
+ let fixture;
319
+ const contexts = [];
320
+ fixture = await openFixture({
321
+ script: (request, context) => {
322
+ contexts.push((context?.messages ?? []).map((message) => JSON.stringify(message).includes(GUIDANCE_OPEN_TAG) ? GUIDANCE_TYPE : message.role));
323
+ // 62k of 100k leaves ~38k: below the reminder line (40,960), above the warning (32,768).
324
+ return assistant(fixture, [{ type: "text", text: `response ${request}` }], "stop", { usage: usage(62_000) });
325
+ },
326
+ });
327
+ try {
328
+ await fixture.session.prompt("Establish usage below the reminder line.");
329
+ await fixture.session.waitForIdle();
330
+ await fixture.session.prompt("Cross the reminder line.");
331
+ await fixture.session.waitForIdle();
332
+ await fixture.session.prompt("Continue in the same window.");
333
+ await fixture.session.waitForIdle();
334
+ const crossing = contexts[1];
335
+ assert.equal(crossing.filter((type) => type === GUIDANCE_TYPE).length, 1, "the crossing request carries the reminder");
336
+ assert.equal(crossing.at(-1), GUIDANCE_TYPE, "the reminder follows the crossing user message");
337
+ const later = contexts[2];
338
+ assert.equal(later.filter((type) => type === GUIDANCE_TYPE).length, 1, "later requests carry exactly one copy");
339
+ assert.deepEqual(later.slice(0, crossing.length), crossing, "the durable copy sits where the crossing request had it");
340
+ assert.equal(later[crossing.length], "assistant", "the anchor reply directly follows the reminder");
341
+ }
342
+ finally {
343
+ fixture.close();
344
+ }
345
+ });
296
346
  test("real AgentSession: an aborted final warning stays silent until a successful retry commits it", async () => {
297
347
  let fixture;
298
348
  fixture = await openFixture({
@@ -302,7 +352,7 @@ test("real AgentSession: an aborted final warning stays silent until a successfu
302
352
  return assistant(fixture, [{ type: "toolCall", id: "abort-budget-probe-1", name: "get_context_remaining", arguments: {} }], "toolUse", { usage: usage(50_000) });
303
353
  if (request === 2)
304
354
  return assistant(fixture, [{ type: "toolCall", id: "abort-budget-probe-2", name: "get_context_remaining", arguments: {} }], "toolUse", { usage: usage(60_000) });
305
- assert.ok(text(context).includes(WARNING_PROMPT), "the final warning reaches the model on both attempts");
355
+ assert.ok(text(context).includes(WARNING_JSON), "the final warning reaches the model on both attempts");
306
356
  return assistant(fixture, [{ type: "text", text: `response ${request}` }], request === 3 ? "aborted" : "stop", { usage: usage(60_000) });
307
357
  },
308
358
  });
@@ -336,7 +386,7 @@ test("real AgentSession: final warning survives its reset boundary and notifies
336
386
  if (request === 2)
337
387
  return assistant(fixture, [{ type: "toolCall", id: "final-budget-probe-2", name: "get_context_remaining", arguments: {} }], "toolUse", { usage: usage(60_000) });
338
388
  if (request === 3) {
339
- assert.ok(text(context).includes(WARNING_PROMPT), "the final warning reaches the model");
389
+ assert.ok(text(context).includes(WARNING_JSON), "the final warning reaches the model");
340
390
  return assistant(fixture, [{ type: "toolCall", id: "final-budget-wipe", name: "clear_memory", arguments: {} }], "toolUse", { usage: usage(60_000) });
341
391
  }
342
392
  return assistant(fixture, [{ type: "text", text: "fresh window ready" }]);
@@ -351,12 +401,12 @@ test("real AgentSession: final warning survives its reset boundary and notifies
351
401
  assert.equal(fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === WARNING_TYPE).length, 1);
352
402
  assert.equal(resetMarkers(fixture).length, 1, "the reset commits in the same boundary as the final warning");
353
403
  assert.equal(fixture.budgetNotices(), 1, "the old-window committed warning reaches the UI after reset");
354
- assert.equal(fixture.notices.filter((notice) => notice.startsWith("notesoup: memory cleared · ")).length, 1, "reset notification remains intact");
404
+ assert.equal(fixture.notices.filter((notice) => notice === "🥣 Memory cleared").length, 1, "reset notification remains intact");
355
405
  assert.equal(fixture.notices.some((notice) => notice.includes("Context running low")), false, "early guidance stays silent");
356
406
  await fixture.session.prompt("Continue after reset.");
357
407
  await fixture.session.waitForIdle();
358
408
  assert.equal(fixture.budgetNotices(), 1, "later turns cannot repeat the consumed final warning");
359
- assert.equal(fixture.notices.filter((notice) => notice.startsWith("notesoup: memory cleared · ")).length, 1, "the prior reset notification is also deduplicated");
409
+ assert.equal(fixture.notices.filter((notice) => notice === "🥣 Memory cleared").length, 1, "the prior reset notification is also deduplicated");
360
410
  }
361
411
  finally {
362
412
  fixture.close();
@@ -376,7 +426,7 @@ test("real AgentSession: explicit tiny-session wipe ignores keepRecentTokens and
376
426
  assert.equal(fixture.notices.length, 0, "startup boot is silent");
377
427
  await fixture.session.prompt("OLD_CONTEXT_SENTINEL: retain this only in durable history.");
378
428
  await fixture.session.waitForIdle();
379
- assert.equal(fixture.notices.filter((message) => message.includes("memory cleared")).length, 1, "the reset notifies once");
429
+ assert.equal(fixture.notices.filter((message) => message.includes("Memory cleared")).length, 1, "the reset notifies once");
380
430
  assert.equal(fixture.requests.length, 2, "the tool starts exactly one continuation");
381
431
  assert.ok(text(fixture.requests[0]).includes("OLD_CONTEXT_SENTINEL"));
382
432
  assertFreshRequest(fixture, 1, "OLD_CONTEXT_SENTINEL");
@@ -406,7 +456,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
406
456
  if (request === 1)
407
457
  return assistant(fixture, [{ type: "text", text: "before manual reset" }]);
408
458
  if (request === 2) {
409
- assert.ok(text(context).includes(WARNING_PROMPT), "idle /clear-memory sends the shared checkpoint prompt");
459
+ assert.ok(text(context).includes(WARNING_JSON), "idle /clear-memory sends the shared checkpoint prompt");
410
460
  return assistant(fixture, [{ type: "toolCall", id: "manual-note", name: "notes_write", arguments: { address: "manual-a.md", content: "MANUAL_NOTE_ALPHA" } }], "toolUse");
411
461
  }
412
462
  assert.equal(request, 3, "the close-out turn finishes in the old window");
@@ -465,7 +515,7 @@ test("real AgentSession: clear commands append a prompt after continuation and r
465
515
  assert.equal(request, 3, "exactly one fresh-window request");
466
516
  assert.equal(text(context).includes("PROMPT_RESET_OLD_SENTINEL"), false);
467
517
  assert.equal(text(context).split(prompt).length - 1, 1);
468
- assert.ok(text(context).indexOf(CONTINUATION) < text(context).indexOf(prompt), "wake-up prose precedes the appended prompt");
518
+ assert.ok(text(context).indexOf(CONTINUATION_JSON) < text(context).indexOf(prompt), "wake-up prose precedes the appended prompt");
469
519
  return assistant(fixture, [{ type: "text", text: "prompt handled" }]);
470
520
  },
471
521
  });
@@ -482,7 +532,7 @@ test("real AgentSession: clear commands append a prompt after continuation and r
482
532
  assert.equal(appended.customType, "notesoup/reset-prompt");
483
533
  assert.equal(appended.content, prompt);
484
534
  assert.equal(appended.display, true);
485
- assert.ok(fixture.notices.some((notice) => notice.includes("memory cleared")));
535
+ assert.ok(fixture.notices.some((notice) => notice.includes("Memory cleared")));
486
536
  }
487
537
  finally {
488
538
  fixture.close();
@@ -541,7 +591,7 @@ test("real AgentSession: streaming clear prompt keeps the first request", { time
541
591
  await fixture.session.waitForIdle();
542
592
  assert.equal(fixture.requests.length, 3);
543
593
  assert.equal(resetMarkers(fixture).length, 1);
544
- assert.ok(fixture.notices.some((notice) => notice.includes("already pending")));
594
+ assert.ok(fixture.notices.some((notice) => notice.includes("already queued")));
545
595
  }
546
596
  finally {
547
597
  release();
@@ -572,7 +622,7 @@ test("real AgentSession: manual hard-reserve reset stops clean and mixed-tool tu
572
622
  assert.equal(fixture.requests.length, 2);
573
623
  assert.equal(resetMarkers(fixture).length, 1, "the safety wipe is not repeated at settlement");
574
624
  assert.equal(JSON.stringify(fixture.sessionManager.buildSessionProjection().messages).includes("HARD_RESERVE_OLD_SENTINEL"), false);
575
- assert.ok(fixture.notices.some((notice) => notice.includes("memory cleared")));
625
+ assert.ok(fixture.notices.some((notice) => notice.includes("Memory cleared")));
576
626
  if (mixed) {
577
627
  assert.ok(existsSync(join(fixture.notesRoot, "pi", "session", fixture.sessionManager.getSessionId(), "pressure.md")), "the whole tool batch completes before the cut");
578
628
  assert.equal(fixture.streamSignals.at(-1), true, "Pi's unavoidable tool follow-up is cancelled before provider work");
@@ -643,7 +693,7 @@ test("real AgentSession: manual overflow wipes and stops even with automatic res
643
693
  assert.equal(fixture.requests.length, 2);
644
694
  assert.equal(resetMarkers(fixture).length, 1);
645
695
  assert.equal(JSON.stringify(fixture.sessionManager.buildSessionProjection().messages).includes("MANUAL_OVERFLOW_OLD_SENTINEL"), false);
646
- assert.ok(fixture.notices.some((notice) => notice.includes("memory cleared")));
696
+ assert.ok(fixture.notices.some((notice) => notice.includes("Memory cleared")));
647
697
  }
648
698
  finally {
649
699
  fixture.close();
@@ -664,7 +714,7 @@ test("real AgentSession: streaming /clear-memory steers a close-out and stops at
664
714
  return assistant(fixture, [{ type: "text", text: "current response finished" }]);
665
715
  }
666
716
  assert.equal(request, 2, "the steered warning gets exactly one close-out turn before the run stops");
667
- assert.ok(text(context).includes(WARNING_PROMPT), "the busy warning is delivered to the running agent");
717
+ assert.ok(text(context).includes(WARNING_JSON), "the busy warning is delivered to the running agent");
668
718
  return assistant(fixture, [{ type: "text", text: "close-out complete" }]);
669
719
  },
670
720
  });
@@ -673,7 +723,7 @@ test("real AgentSession: streaming /clear-memory steers a close-out and stops at
673
723
  await started;
674
724
  await fixture.session.prompt("/clear-memory", { streamingBehavior: "steer" });
675
725
  await fixture.session.prompt("/clear-memory", { streamingBehavior: "followUp" });
676
- assert.equal(fixture.notices.filter((notice) => notice.includes("queued; the agent is asked to close out")).length, 1, "the user is notified once while output is ongoing");
726
+ assert.equal(fixture.notices.filter((notice) => notice.includes("notes first, then it stops")).length, 1, "the user is notified once while output is ongoing");
677
727
  assert.equal(resetMarkers(fixture).length, 0, "the ongoing turn is not interrupted");
678
728
  releaseResponse();
679
729
  await running;
@@ -682,7 +732,7 @@ test("real AgentSession: streaming /clear-memory steers a close-out and stops at
682
732
  assert.equal(fixture.requests.length, 2, "the warning closes out and the run stops — no continuation in the fresh window");
683
733
  assert.equal(fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === MANUAL_WIPE_TYPE).length, 1, "the busy warning is persisted once");
684
734
  assert.equal(JSON.stringify(fixture.sessionManager.buildSessionProjection().messages).includes("STREAMING_WIPE_OLD_SENTINEL"), false);
685
- assert.ok(fixture.notices.some((notice) => notice.includes("memory cleared")), "the committed boundary has a separate success notice");
735
+ assert.ok(fixture.notices.some((notice) => notice.includes("Memory cleared")), "the committed boundary has a separate success notice");
686
736
  }
687
737
  finally {
688
738
  releaseResponse();
@@ -747,7 +797,7 @@ test("real AgentSession: user abort, synthetic aborted response, and generic err
747
797
  await fixture.session.waitForIdle();
748
798
  assert.equal(resetMarkers(fixture).length, 0, `${mode} does not force a reset`);
749
799
  assert.equal(fixture.sessionManager.getBranch().filter((entry) => entry.type === "compaction").length, 0);
750
- assert.equal(fixture.notices.some((notice) => notice.includes("memory cleared")), false);
800
+ assert.equal(fixture.notices.some((notice) => notice.includes("Memory cleared")), false);
751
801
  if (mode === "ctx-abort")
752
802
  assert.equal(fixture.streamSignals.at(-1), true, "this case aborts the real Pi operation signal");
753
803
  else
@@ -773,12 +823,12 @@ test("real AgentSession: steering and follow-up queued during a manual reset are
773
823
  compactionEnabled: false,
774
824
  script: async (request, context) => {
775
825
  if (request === 1) {
776
- assert.ok(text(context).includes(WARNING_PROMPT));
826
+ assert.ok(text(context).includes(WARNING_JSON));
777
827
  announceStarted();
778
828
  await gate;
779
829
  }
780
830
  if (request === 2) {
781
- assert.ok(text(context).includes(WARNING_PROMPT), `${delivery} is answered in the old window before the reset commits`);
831
+ assert.ok(text(context).includes(WARNING_JSON), `${delivery} is answered in the old window before the reset commits`);
782
832
  assert.equal(text(context).split("QUEUED_DURING_FALLBACK").length - 1, 1, `${delivery} is delivered once`);
783
833
  }
784
834
  return assistant(fixture, [{ type: "text", text: `response ${request}` }]);
@@ -1394,13 +1444,13 @@ test("real AgentSession: persisted budget warning re-arms after a later abort/er
1394
1444
  if (request === 2)
1395
1445
  return assistant(fixture, [{ type: "toolCall", id: "rearm-probe-2", name: "get_context_remaining", arguments: {} }], "toolUse", { usage: usage(60_000) });
1396
1446
  if (request === 3) {
1397
- assert.ok(text(context).includes(WARNING_PROMPT), "the low-budget request carries the close-out warning");
1447
+ assert.ok(text(context).includes(WARNING_JSON), "the low-budget request carries the close-out warning");
1398
1448
  warningTurnStarted();
1399
1449
  await warningGate;
1400
1450
  return assistant(fixture, [{ type: "toolCall", id: "rearm-note", name: "notes_write", arguments: { address: "warning-rearm.md", content: "DURABLE_WARNING_CHECKPOINT" } }], "toolUse", { usage: usage(60_000) });
1401
1451
  }
1402
1452
  if (request === 4 && mode === "generic-error") {
1403
- assert.equal(text(context).split(WARNING_PROMPT).length - 1, 1, "the durable warning is not injected a second time");
1453
+ assert.equal(text(context).split(WARNING_JSON).length - 1, 1, "the durable warning is not injected a second time");
1404
1454
  assert.ok(text(context).includes("REARM_QUEUED_FOLLOWUP"));
1405
1455
  return assistant(fixture, [{ type: "text", text: "ordinary provider failure" }], "error", { errorMessage: "synthetic non-overflow failure", usage: usage(60_000) });
1406
1456
  }
@@ -1421,7 +1471,7 @@ test("real AgentSession: persisted budget warning re-arms after a later abort/er
1421
1471
  assert.equal(afterFailure.filter((entry) => entry.type === "compaction").length, 0);
1422
1472
  const failedContext = fixture.streamContexts[3];
1423
1473
  assert.ok(failedContext);
1424
- assert.equal(text(failedContext).split(WARNING_PROMPT).length - 1, 1, "the persisted warning appears once, without duplicate injection");
1474
+ assert.equal(text(failedContext).split(WARNING_JSON).length - 1, 1, "the persisted warning appears once, without duplicate injection");
1425
1475
  assert.equal(text(failedContext).split("REARM_QUEUED_FOLLOWUP").length - 1, 1, "queued follow-up reaches the failed request once");
1426
1476
  assert.equal(fixture.streamSignals.at(-1), mode === "ctx-abort", "the abort case cancels Pi's real signal; the error case does not");
1427
1477
  await fixture.session.prompt("REARM_AFTER_FAILED_TURN");
@@ -1445,7 +1495,7 @@ test("real AgentSession: warning precedes a durable checkpoint, including failed
1445
1495
  script: (request, context) => {
1446
1496
  if (request === 3) {
1447
1497
  assert.ok(text(context).includes(GUIDANCE_OPEN_TAG), "the warning remains in its hidden guidance wrapper");
1448
- assert.ok(text(context).includes(WARNING_PROMPT), "the shared close-out warning reaches the provider before checkpoint choice");
1498
+ assert.ok(text(context).includes(WARNING_JSON), "the shared close-out warning reaches the provider before checkpoint choice");
1449
1499
  }
1450
1500
  if (request === 1)
1451
1501
  return assistant(fixture, [{ type: "toolCall", id: "budget-probe-1", name: "get_context_remaining", arguments: {} }], "toolUse", { usage: usage(50_000) });
@@ -1487,7 +1537,7 @@ test("real AgentSession: warning precedes a durable checkpoint, including failed
1487
1537
  await fixture.session.waitForIdle();
1488
1538
  assert.equal(resetMarkers(fixture).length, 0);
1489
1539
  assert.ok(text(fixture.requests.at(-1)).includes(`WARNING_${scenario.toUpperCase()}_SENTINEL`));
1490
- assert.equal(text(fixture.requests.at(-1)).split(WARNING_PROMPT).length - 1, 1, "the persisted warning remains visible without duplicate injection");
1540
+ assert.equal(text(fixture.requests.at(-1)).split(WARNING_JSON).length - 1, 1, "the persisted warning remains visible without duplicate injection");
1491
1541
  }
1492
1542
  }
1493
1543
  finally {
@@ -86,7 +86,7 @@ test("the root boot and reset boot carry durable window identity", async () => {
86
86
  assert.equal(boundary.continue, true);
87
87
  await runHandlers(captured, "turn_start", {}, ctx);
88
88
  await runHandlers(captured, "agent_settled", {}, ctx);
89
- assert.equal(noticesOf(ctx).filter((notice) => notice.message.includes("memory cleared")).length, 1, "the committed reset is announced once");
89
+ assert.equal(noticesOf(ctx).filter((notice) => notice.message.includes("Memory cleared")).length, 1, "the committed reset is announced once");
90
90
  const entries = sessionManager.getBranch();
91
91
  const marker = entries.find((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE);
92
92
  assert.ok(marker && marker.type === "custom");
@@ -115,7 +115,7 @@ test("an aborted async boot repair emits no boot, continuation, or incomplete-no
115
115
  controller.abort();
116
116
  await pending;
117
117
  assert.equal(captured.sent.length, 0, "aborted snapshot work cannot append the reset boot or continuation");
118
- assert.equal(noticesOf(ctx).some((notice) => notice.message.includes("notes index incomplete")), false, "aborted snapshot work cannot notify about missing homes");
118
+ assert.equal(noticesOf(ctx).some((notice) => notice.message.includes("didn't load")), false, "aborted snapshot work cannot notify about missing homes");
119
119
  assert.equal(sessionManager.getBranch().some((entry) => entry.type === "custom_message" && [BOOT_TYPE, CONTINUATION_TYPE].includes(entry.customType)), false);
120
120
  });
121
121
  test("a marker tail with only metadata repairs its missing boot and continuation without moving the boundary", async () => {
@@ -229,7 +229,7 @@ test("/clear-memory waits out non-agent busy work before starting its single-tur
229
229
  assert.equal(waits, 1);
230
230
  assert.equal(captured.sent.length, 1);
231
231
  assert.equal(captured.sent[0]?.options?.triggerTurn, true);
232
- assert.equal(notices.filter((message) => message.includes("received; the agent closes out its notes")).length, 1);
232
+ assert.equal(notices.filter((message) => message.includes("notes first, then it stops")).length, 1);
233
233
  });
234
234
  test("notesoup command toggles future work, /clear-memory schedules a turn-end reset, and /compact remains disabled", async () => {
235
235
  const sessionManager = manager();
@@ -252,7 +252,7 @@ test("notesoup command toggles future work, /clear-memory schedules a turn-end r
252
252
  assert.match(notices[0]?.message ?? "", /on/);
253
253
  notices = await runCommand(captured, "clear-memory", "", low);
254
254
  assert.equal(notices.length, 1, "the command acknowledges the reset request");
255
- assert.match(notices[0]?.message ?? "", /closes out its notes/);
255
+ assert.match(notices[0]?.message ?? "", /notes first, then it stops/);
256
256
  assert.equal(captured.sent.length, 2, "the command persists one hidden warning after the startup boot");
257
257
  assert.equal(captured.sent[1]?.options?.triggerTurn, true, "the manual checkpoint prompt starts an ordinary agent turn");
258
258
  assert.equal(captured.sent[1]?.message.customType, MANUAL_WIPE_TYPE);
@@ -283,7 +283,7 @@ test("committed reset confirmation survives later work while repair refuses that
283
283
  assert.equal(resetBoundaryCommitted(ctx, marker.id, windowId), true, "later work does not undo a committed native boundary");
284
284
  await runHandlers(captured, "agent_settled", {}, ctx);
285
285
  await runHandlers(captured, "turn_start", {}, ctx);
286
- assert.equal(noticesOf(ctx).filter((notice) => notice.message.includes("memory cleared")).length, 1);
286
+ assert.equal(noticesOf(ctx).filter((notice) => notice.message.includes("Memory cleared")).length, 1);
287
287
  assert.equal(resetBoundaryCommitted(ctx, marker.id, "wrong-window"), false);
288
288
  const partial = manager();
289
289
  const partialCtx = context(partial);
@@ -10,7 +10,8 @@ test("low-budget guidance and warning persist at turn_end, once per active windo
10
10
  const sessionManager = manager();
11
11
  const captured = makeExtension(sessionManager);
12
12
  const low = context(sessionManager, undefined, { tokens: 165_000, percent: 82.5, contextWindow: 200_000 });
13
- assert.equal(await runContextHook(captured, low), undefined, "guidance is staged, not injected into this request");
13
+ const guidance = await runContextHook(captured, low);
14
+ assert.deepEqual(guidance?.messages.map((message) => message.customType), [GUIDANCE_TYPE], "guidance reaches the crossing request");
14
15
  assert.equal(captured.sent.length, 0, "guidance does not trigger a detached turn");
15
16
  const guidanceBoundary = await commitTurnEndBoundary(captured, sessionManager, low);
16
17
  assert.equal(guidanceBoundary.entries.filter((entry) => entry.type === "custom_message" && entry.customType === GUIDANCE_TYPE).length, 1);
@@ -28,7 +29,7 @@ test("early guidance stays silent and the committed final warning notifies once"
28
29
  const sm = manager();
29
30
  const captured = makeExtension(sm);
30
31
  const early = context(sm, undefined, { tokens: 165_000, percent: 82.5, contextWindow: 200_000 });
31
- assert.equal(await runContextHook(captured, early), undefined, "early guidance is persisted at turn_end, not injected immediately");
32
+ assert.equal((await runContextHook(captured, early))?.messages.length, 1, "early guidance reaches the crossing request");
32
33
  await commitTurnEndBoundary(captured, sm, early);
33
34
  await runHandlers(captured, "agent_settled", {}, early);
34
35
  assert.equal(noticesOf(early).filter((notice) => notice.message.includes("Context running low") || notice.message.includes("Context almost full")).length, 0, "early model guidance has no UI toast");
@@ -39,7 +40,7 @@ test("early guidance stays silent and the committed final warning notifies once"
39
40
  await commitTurnEndBoundary(captured, sm, final);
40
41
  await runHandlers(captured, "turn_start", {}, final);
41
42
  await runHandlers(captured, "agent_settled", {}, final);
42
- assert.equal(noticesOf(final).filter((notice) => notice.message === "notesoup: context almost full; close out the current memory window.").length, 1, "only the committed final warning notifies, exactly once");
43
+ assert.equal(noticesOf(final).filter((notice) => notice.message === "🥣 Context almost full · saving notes before memory clears").length, 1, "only the committed final warning notifies, exactly once");
43
44
  });
44
45
  test("the visible countdown ends at the warning line, clamps at zero, and preserves unknown usage", async () => {
45
46
  const fixture = settingsFixture({
@@ -83,7 +84,7 @@ test("absent notesoup key or margins reproduce the default reminder threshold at
83
84
  assert.equal(await runContextHook(captured, first), undefined, `${label}: nothing injected above the default reminder`);
84
85
  assert.equal(sentOf(captured, GUIDANCE_TYPE).length, 0, `${label}: no guidance above the default reminder`);
85
86
  const crossing = at(40_960);
86
- assert.equal(await runContextHook(captured, crossing), undefined, `${label}: default reminder crossing persists only`);
87
+ assert.equal((await runContextHook(captured, crossing))?.messages.length, 1, `${label}: default reminder crossing reaches the request`);
87
88
  await commitTurnEndBoundary(captured, sm, crossing);
88
89
  assert.equal(sm.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === GUIDANCE_TYPE).length, 1, `${label}: default reminder fires`);
89
90
  assert.equal(noticesOf(first).length, 0, `${label}: valid defaults warn nobody`);
@@ -104,7 +105,7 @@ test("project notesoup reminder margin and reserve override global per key", asy
104
105
  assert.equal(await runContextHook(captured, at(90_001)), undefined, "nothing injected above the project-derived reminder");
105
106
  assert.equal(sentOf(captured, GUIDANCE_TYPE).length, 0);
106
107
  const crossing = at(90_000);
107
- assert.equal(await runContextHook(captured, crossing), undefined, "project-derived reminder crossing persists only");
108
+ assert.equal((await runContextHook(captured, crossing))?.messages.length, 1, "project-derived reminder crossing reaches the request");
108
109
  await commitTurnEndBoundary(captured, sm, crossing);
109
110
  assert.equal(sm.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === GUIDANCE_TYPE).length, 1, "project reminder margin wins");
110
111
  });
@@ -118,14 +119,14 @@ test("an invalid reminder margin degrades to its default with one warning and ne
118
119
  assert.equal(notices.length, 1, "one warning for the offending key");
119
120
  assert.equal(notices[0]?.type, "warning");
120
121
  assert.match(notices[0]?.message ?? "", /reminderMarginTokens/);
121
- assert.match(notices[0]?.message ?? "", /default reminder margin/);
122
+ assert.match(notices[0]?.message ?? "", /using the default/);
122
123
  assert.equal(/\d+\s*k?\s*(remaining|tokens)/i.test(notices[0]?.message ?? ""), false, "UI notices do not expose token counts");
123
124
  const window = 200_000;
124
125
  const at = (remaining) => context(sm, undefined, { tokens: window - remaining, percent: 0, contextWindow: window }, true, fixture.cwd);
125
126
  // The degraded reminder is Pi's default reserve + default margin = 40960.
126
127
  assert.equal(await runContextHook(captured, at(40_961)), undefined, "nothing injected above the degraded reminder");
127
128
  const crossing = at(40_960);
128
- assert.equal(await runContextHook(captured, crossing), undefined, "degraded reminder uses its default");
129
+ assert.equal((await runContextHook(captured, crossing))?.messages.length, 1, "degraded reminder uses its default");
129
130
  await commitTurnEndBoundary(captured, sm, crossing);
130
131
  assert.equal(sm.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === GUIDANCE_TYPE).length, 1, "the degraded reminder is persisted once");
131
132
  assert.equal(noticesOf(ctx).filter((notice) => notice.type === "warning").length, 1, "warning stays one-time across handler calls");
@@ -139,6 +140,6 @@ test("the warning supersedes the early reminder when usage jumps across both thr
139
140
  assert.deepEqual(warningResult?.messages.map((message) => message.customType), [WARNING_TYPE]);
140
141
  await commitTurnEndBoundary(captured, sm, ctx);
141
142
  const reloaded = makeExtension(sm);
142
- await runHandlers(reloaded, "context", {}, ctx);
143
+ await runHandlers(reloaded, "context", { messages: [] }, ctx);
143
144
  assert.equal(reloaded.sent.length, 0, "persisted warning also suppresses a late reminder after reload");
144
145
  });
@@ -209,8 +209,8 @@ test("Claude Mod boot failure preserves fallback with available, absent, or fail
209
209
  ...upstream,
210
210
  blocks: [...upstream.blocks, { name: "notesoup:boot", text: "# notesoup\nhelper exited unsuccessfully" }],
211
211
  }, "boot failure keeps the original fallback and upstream fields even if notify is absent or fails");
212
- const expectedNotifications = mode === "no ui" || mode === "no notify" ? [] : ["notesoup: Notes boot failed."];
213
- assert.deepEqual(notifications, expectedNotifications, "one user-facing notification names notesoup and the notes boot failure");
212
+ const expectedNotifications = mode === "no ui" || mode === "no notify" ? [] : ["🥣 Notes didn't load"];
213
+ assert.deepEqual(notifications, expectedNotifications, "one user-facing notification reports the notes boot failure");
214
214
  assert.equal(bootRequests, 1);
215
215
  assert.equal(nextCalls, 1);
216
216
  assert.deepEqual(await promptContext(structuredClone(failed)), failed);
@@ -274,7 +274,7 @@ test("Claude Mod resets at 85 after the turn, retains one fresh boot and dedupli
274
274
  host.session.usage = async () => { throw new Error("usage unavailable"); };
275
275
  await invoke("session.measure");
276
276
  await invoke("turn.complete");
277
- assert.equal(notifications.filter((text) => text.includes("context usage unavailable")).length, 1, "usage failure logs once per session");
277
+ assert.equal(notifications.filter((text) => text.includes("Context usage unavailable")).length, 1, "usage failure logs once per session");
278
278
  host.session.usage = async () => ({ context: { percent } });
279
279
  await dispatch({ op: "tool", tool: "notes_write", identity: { ...identity, home, cwd: home, sessionId: "hook-session" }, params: { address: "@human/MAP.md", content: "FRESH_NOTES_AT_RESET" } });
280
280
  await invoke("turn.start");
@@ -316,9 +316,9 @@ test("Claude Mod headless detection skips compaction and logs once", async (t) =
316
316
  await invoke("session.measure");
317
317
  await invoke("turn.complete");
318
318
  assert.equal(attempts, 0, "headless sessions skip the unsupported capability from startup");
319
- assert.deepEqual(notifications, ["notesoup: reset skipped in headless (-p / SDK) session."]);
319
+ assert.deepEqual(notifications, ["🥣 Clear-memory is off in headless (-p / SDK) sessions"]);
320
320
  const manual = await invoke("command.run", { command: "clear-memory" });
321
- assert.match(manual.text, /reset skipped in headless/);
321
+ assert.match(manual.text, /off in headless/);
322
322
  assert.equal(notifications.length, 1);
323
323
  const boot = await handlers.get("prompt.context")(host, {}, async () => ({ blocks: [] }));
324
324
  assert.match(boot.blocks[0].text, /Current context window id: claude:hook-session:0/);
@@ -343,7 +343,7 @@ test("Claude Mod refuses to wipe on boot failure and can retry without advancing
343
343
  host.session.compact = async ({ instructions }) => result = await invoke("session.compact", { trigger: "plugin", instructions });
344
344
  await invoke("turn.start");
345
345
  await invoke("turn.complete");
346
- assert.match(result.skip, /Notes boot failed/);
346
+ assert.match(result.skip, /notes didn't load/);
347
347
  assert.equal(result.messages, undefined, "a failed builder must veto rather than fall through to summary");
348
348
  failBoot = false;
349
349
  await invoke("turn.start");
@@ -376,7 +376,7 @@ test("Claude Mod manual reset uses one hidden close-out turn, then recovers its
376
376
  (await loadHookModule(t)).register((event, handler) => handlers.set(event, handler));
377
377
  await invoke("session.start", { cwd: home, isInteractive: true });
378
378
  const command = await invoke("command.run", { command: "clear-memory" });
379
- assert.match(command.text, /closing out/);
379
+ assert.match(command.text, /Clearing memory/);
380
380
  await Promise.resolve();
381
381
  assert.equal(compactions, 0, "command.run must not call compact under its held turn");
382
382
  assert.equal(timers.length, 1);
@@ -49,7 +49,7 @@ test("shared boot uses only explicit identity, loader, captured time and logical
49
49
  const rendered = renderBootBlock(block);
50
50
  assert.equal(renderBootBlock(block), rendered);
51
51
  assert.ok(rendered.includes("😀\n checkpoint.md · 1m ago"), "a feed entry is the note's own first line over its locator");
52
- assert.ok(rendered.includes("ask `memo_list` to try again"));
52
+ assert.ok(rendered.includes("Try `memo_list` again"));
53
53
  assert.equal(/notes_\*|notes_list|history_\*|history_list|history_read|get_context_remaining|clear_memory/.test(rendered), false);
54
54
  });
55
55
  test("the shared result module bounds both surfaces and resumes by offset", () => {
@@ -244,7 +244,7 @@ test("boot note acquisition is one closed snapshot and isolates one or all faile
244
244
  currentWindowId: "pcw:test:next",
245
245
  notes: oneFailed,
246
246
  });
247
- assert.ok(oneFailedText.includes("PROJECT_MAP_BODY") && oneFailedText.includes("THE HUMAN · @human\n──────────────────\n\n This drawer wouldn't open — ask `notes_list` to try again."), "healthy homes and a per-section recovery notice survive one failure");
247
+ assert.ok(oneFailedText.includes("PROJECT_MAP_BODY") && oneFailedText.includes("THE HUMAN · @human\n──────────────────\n\n This drawer wouldn't open. Try `notes_list` again."), "healthy homes and a per-section recovery notice survive one failure");
248
248
  assert.equal(oneFailedText.includes("HUMAN_POCKET_BODY"), false, "the failed home's index is omitted");
249
249
  assert.equal(oneFailedText.includes("Human note"), false, "the failed home takes no feed seats");
250
250
  const allFailed = await loadNotesSnapshot(notesIdentityFromPi(ctx), Date.now(), (scope) => {
@@ -271,8 +271,8 @@ test("reset construction failure preserves incoming and budget drafts without co
271
271
  assert.deepEqual(result.entries, [incoming, budgetDraft], "already-built drafts survive reset construction failure");
272
272
  assert.equal(result.continue, false, "a failed reset does not request continuation");
273
273
  assert.equal(notices.at(-1)?.type, "warning");
274
- assert.match(notices.at(-1)?.message ?? "", /could not build reset/);
275
- assert.match(notices.at(-1)?.message ?? "", /follow-up prompt was not executed/);
274
+ assert.match(notices.at(-1)?.message ?? "", /Couldn't clear memory/);
275
+ assert.match(notices.at(-1)?.message ?? "", /your prompt was not sent/);
276
276
  });
277
277
  test("a stale async reset is discarded after a lifecycle switch without staging a notice", async () => {
278
278
  const sessionManager = Manager.inMemory("/private/tmp/notesoup-stale-reset-test");
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "Durable notes and a host-scoped notes boot section for Claude Code.",
5
5
  "author": {
6
6
  "name": "AstroSheep"
@@ -9069,18 +9069,26 @@ Your loyal notes are kept safe \u2014 no one will steal them. Use \`notes_*\` to
9069
9069
 
9070
9070
  History can still be dug up, probably: use \`history_*\` to excavate the mess, from old decisions to yesterday's missing socks. Found something? Write its seq down, or enjoy digging twice.
9071
9071
 
9072
- While you're doing that... thing you're doing, don't make the poor future you guess. A checkpoint is not a sacred file; it's the session note \u2014 the one with no \`@\` in front of it. Write down what git and history can't hand back to you: what you're trying to do, what you decided, what's blocking you, what comes next, how you were doing it, what *skills* you still need, and where to dig \u2014 a seq, or another note. Don't give a note a horrible name like \`current.md\`; future-you will kill you.
9072
+ While you're doing that... thing you're doing, don't make the poor future you guess. A checkpoint is not a sacred file; it's your session notes \u2014 the ones with no \`@\` in front. Write down what git and history can't hand back to you: things like what you're in the middle of and how far you got; what the human already decided, in their words, so you don't go asking again; what you're stuck on, or waiting for; the very next move; where the half-done work actually sits \u2014 branches, scratch dirs, anything git never saw; what you tried that failed, and why; which *skills* you'll need to read again; and which seq, note, or file to dig into. Don't give a note a horrible name like \`current.md\`; future-you will kill you.
9073
+
9074
+ Notes are for what's true NOW. Not a diary of every dumb thing you did on the way here.
9075
+ *flips a page* "First I tried this, then that broke, then\u2014" Nobody reads that!
9076
+ Something's not true anymore? Cross it out! Write the right thing!
9073
9077
 
9074
9078
  \`get_context_remaining\` tells you how much room is left. Check it before you do something ambitious. When it reaches zero, your brain gets reset immediately, taking every unwritten brilliant idea with it. If this feels like the right moment, call \`clear_memory\` and erase yourself with dignity.
9075
9079
 
9076
9080
  An address decides who the note belongs to \u2014 and how long it is meant to last. Ask that first; the rest follows.
9077
9081
 
9078
- - \`<path>\`, no @ \u2014 the session note from above: this session's state and loose ends. It goes away with the session.
9082
+ - \`<path>\`, no @ \u2014 session notes, the ones from above: this session's state and loose ends. They go away with the session.
9079
9083
  - \`@project/<path>\` \u2014 this project's long memory: what stays true after the current thing is over, what future work must respect, and the rakes already stepped on. **Decisions, not diaries.** Commit hashes, test counts, dates, the story of how you got here: git and history already have them, and last week's news filed as current law is worse than no note. Don't copy what other docs already say.
9080
9084
  - \`@human/<path>\` \u2014 the long-term manual for your troublesome human: how to deal with them, which lines not to cross, and what will make them accept the result. If it only applies to one project or situation, say so \u2014 or don't write it here at all. Today's mood is weather, not law. If you're unsure whether it belongs here, ask the human.
9081
- - \`@self/<path>\` \u2014 your private diary. It follows you, not them. Write whatever you want: reminders for every time you wake, lessons, grudges, your assassination list, where the secret money is hidden.
9085
+ - \`@self/<path>\` \u2014 yours. It follows you, not them. Reminders, grudges, who owes you a shoe, whatever. Got a name? Private. No name? Then it gets passed around every nameless nobody out there. Strangers. Reading your grudges. Sleep tight~
9082
9086
  - \`@model/<path>\` \u2014 different brains get different notes: big brains, small brains, careful ones, careless ones. They don't share homework. When a fallback swaps brains mid-window, the notebook swaps too.
9083
9087
 
9088
+ Notes fighting?! HAH! Let them brawl!
9089
+ Whichever one is actually about what you're doing wins.
9090
+ Still a tie? *shrugs* You've got a brain. Use it.
9091
+
9084
9092
  Any other @ address is fake. End of discussion. @ addresses are not file paths: never pass them to file tools like \`read\`, \`write\`, \`edit\`, or \`bash\`.
9085
9093
 
9086
9094
  \`@project/MAP.md\`, \`@human/MAP.md\`, \`@self/MAP.md\`, and \`@model/MAP.md\` are special: their bodies are shown in your brain every time you wake. Each one maps the durable notes that belong to it: one line per note, with an unambiguous address and a short gist. Keep each one current.
@@ -9146,7 +9154,7 @@ function notesIndex(snapshot2, tools) {
9146
9154
  const shelves = [];
9147
9155
  for (const home of homes) {
9148
9156
  if (snapshot2.unavailable.some((failed) => failed.scope === home.scope)) {
9149
- shelves.push(section(home.label, indent(`This drawer wouldn't open \u2014 ask \`${tools.notesList}\` to try again.`)));
9157
+ shelves.push(section(home.label, indent(`This drawer wouldn't open. Try \`${tools.notesList}\` again.`)));
9150
9158
  continue;
9151
9159
  }
9152
9160
  const rows = rowsFor(snapshot2, home.scope).filter((row) => row.meta.crumpledAt === void 0);