notesoup 0.40.0 → 0.42.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 (93) hide show
  1. package/dist/src/boot/render.js +1 -1
  2. package/dist/src/boot/text.d.ts +12 -0
  3. package/dist/src/boot/text.js +25 -5
  4. package/dist/src/budget/policy.js +1 -1
  5. package/dist/src/budget/text.d.ts +12 -0
  6. package/dist/src/budget/text.js +13 -1
  7. package/dist/src/claude/helper.js +23 -2
  8. package/dist/src/claude/thresholds.d.ts +39 -0
  9. package/dist/src/claude/thresholds.js +149 -0
  10. package/dist/src/dream/doctor.js +3 -2
  11. package/dist/src/dream/git.js +2 -1
  12. package/dist/src/dream/jail.js +10 -10
  13. package/dist/src/dream/report.js +3 -2
  14. package/dist/src/error-message.d.ts +2 -0
  15. package/dist/src/error-message.js +4 -0
  16. package/dist/src/history/history.js +1 -1
  17. package/dist/src/history/query.js +6 -6
  18. package/dist/src/notes/address.d.ts +1 -1
  19. package/dist/src/notes/address.js +12 -12
  20. package/dist/src/notes/store.js +16 -12
  21. package/dist/src/pi/anchored.d.ts +16 -0
  22. package/dist/src/pi/anchored.js +55 -0
  23. package/dist/src/pi/budget.d.ts +1 -1
  24. package/dist/src/pi/budget.js +33 -28
  25. package/dist/src/pi/dream/cli.js +3 -2
  26. package/dist/src/pi/dream/runner.js +2 -1
  27. package/dist/src/pi/reset/lifecycle.d.ts +1 -1
  28. package/dist/src/pi/reset/lifecycle.js +4 -3
  29. package/dist/src/pi/reset/text.d.ts +3 -4
  30. package/dist/src/pi/reset/text.js +5 -4
  31. package/dist/src/pi/runtime.js +13 -16
  32. package/dist/src/pi/thresholds.js +2 -1
  33. package/dist/src/pi/tool-result.js +2 -2
  34. package/dist/src/settings.d.ts +8 -0
  35. package/dist/src/settings.js +6 -1
  36. package/dist/src/tools/history.js +12 -12
  37. package/dist/src/tools/notes.d.ts +3 -3
  38. package/dist/src/tools/notes.js +12 -11
  39. package/dist/src/tools/output.d.ts +2 -0
  40. package/dist/src/tools/output.js +2 -0
  41. package/dist/src/tools/result.js +2 -2
  42. package/dist/src/tools/schema.js +3 -3
  43. package/dist/test/agent-loop.test.js +78 -28
  44. package/dist/test/boot.integration.test.js +5 -5
  45. package/dist/test/budget-settings.integration.test.js +9 -8
  46. package/dist/test/claude-mod.test.js +213 -23
  47. package/dist/test/dream.test.js +3 -3
  48. package/dist/test/history.integration.test.js +7 -8
  49. package/dist/test/host-neutral.test.js +2 -2
  50. package/dist/test/notes-library.test.js +1 -1
  51. package/dist/test/notes.integration.test.js +5 -5
  52. package/dist/test/notes.test.js +16 -16
  53. package/dist/test/reset-lifecycle.test.js +2 -2
  54. package/docs/claude-code-mod.md +10 -2
  55. package/mods/notesoup/.claude-plugin/plugin.json +1 -1
  56. package/mods/notesoup/dist/claude/helper.js +212 -45
  57. package/mods/notesoup/hooks/register.ts +209 -48
  58. package/mods/notesoup/playbook.md +10 -10
  59. package/mods/notesoup/skills/dream/SKILL.md +1 -1
  60. package/package.json +1 -1
  61. package/playbook.md +10 -10
  62. package/skills/dream/SKILL.md +1 -1
  63. package/skills/memory/SKILL.md +5 -3
  64. package/src/boot/render.ts +1 -1
  65. package/src/boot/text.ts +31 -5
  66. package/src/budget/policy.ts +1 -1
  67. package/src/budget/text.ts +18 -1
  68. package/src/claude/helper.ts +20 -3
  69. package/src/claude/thresholds.ts +170 -0
  70. package/src/dream/doctor.ts +3 -2
  71. package/src/dream/git.ts +2 -1
  72. package/src/dream/jail.ts +10 -10
  73. package/src/dream/report.ts +3 -2
  74. package/src/error-message.ts +4 -0
  75. package/src/history/history.ts +1 -1
  76. package/src/history/query.ts +6 -6
  77. package/src/notes/address.ts +12 -12
  78. package/src/notes/store.ts +17 -12
  79. package/src/pi/anchored.ts +62 -0
  80. package/src/pi/budget.ts +27 -26
  81. package/src/pi/dream/cli.ts +3 -2
  82. package/src/pi/dream/runner.ts +2 -1
  83. package/src/pi/reset/lifecycle.ts +5 -4
  84. package/src/pi/reset/text.ts +6 -7
  85. package/src/pi/runtime.ts +13 -16
  86. package/src/pi/thresholds.ts +2 -1
  87. package/src/pi/tool-result.ts +2 -2
  88. package/src/settings.ts +18 -2
  89. package/src/tools/history.ts +12 -12
  90. package/src/tools/notes.ts +14 -12
  91. package/src/tools/output.ts +2 -0
  92. package/src/tools/result.ts +2 -2
  93. package/src/tools/schema.ts +3 -3
@@ -1,8 +1,16 @@
1
1
  export declare const NOTESOUP_SETTINGS_KEY = "notesoup";
2
2
  /** Nested under "notesoup": the default dreamer model pattern, overridden by CLI --dreamer. */
3
3
  export declare const NOTESOUP_DREAMER_KEY = "dreamer";
4
+ /**
5
+ * The one notesoup settings shape both hosts read. `reminderMarginTokens` is Pi's early
6
+ * reminder margin; `resetMarginTokens` and `warningRunwayTokens` are the Claude mod's
7
+ * margins against Claude's own auto-compact point (see src/claude/thresholds.ts). A host
8
+ * ignores the keys it does not use; every value is validated where it is consumed.
9
+ */
4
10
  export type NotesoupSettings = {
5
11
  reminderMarginTokens?: unknown;
12
+ resetMarginTokens?: unknown;
13
+ warningRunwayTokens?: unknown;
6
14
  dreamer?: unknown;
7
15
  };
8
16
  /** Merge the global and project "notesoup" objects per key; project wins, mirroring Pi's deep merge. */
@@ -14,5 +14,10 @@ function notesoupSettings(settings) {
14
14
  /** Merge the global and project "notesoup" objects per key; project wins, mirroring Pi's deep merge. */
15
15
  export function mergeNotesoupSettings(globalSettings, projectSettings) {
16
16
  const merged = { ...notesoupSettings(globalSettings), ...notesoupSettings(projectSettings) };
17
- return { reminderMarginTokens: merged.reminderMarginTokens, dreamer: merged.dreamer };
17
+ return {
18
+ reminderMarginTokens: merged.reminderMarginTokens,
19
+ resetMarginTokens: merged.resetMarginTokens,
20
+ warningRunwayTokens: merged.warningRunwayTokens,
21
+ dreamer: merged.dreamer,
22
+ };
18
23
  }
@@ -1,6 +1,6 @@
1
1
  /** Host-neutral history operations: one bounded payload for text and structured results. */
2
2
  import { Type } from "typebox";
3
- import { HISTORY_PREVIEW_CHARS } from "./output.js";
3
+ import { HISTORY_PREVIEW_CHARS, TOOL_OUTPUT_LIMIT } from "./output.js";
4
4
  import { failure, fitsResult, resultSchema, readTextWindow, renderOutcome, renderTextWindow, success, TextWindowRequestSchema, TextWindowSchema } from "./result.js";
5
5
  import { historyRoles, searchQuery } from "./schema.js";
6
6
  import { HistoryPageSchema, selectPage } from "../history/query.js";
@@ -59,7 +59,7 @@ function renderFoldedRow(row) {
59
59
  function renderPage(page) {
60
60
  // An empty selection has no anchors either, so it would otherwise render as nothing at all.
61
61
  if (page.items.length === 0)
62
- return "no events match this selection";
62
+ return "No events match these filters.";
63
63
  const body = page.items.map((item) => (isFoldedRow(item) ? renderFoldedRow(item) : renderPageItem(item))).join("\n\n");
64
64
  const cursors = [
65
65
  page.page_older === null ? "" : `→ older: ${JSON.stringify(page.page_older)}`,
@@ -82,7 +82,7 @@ function pageFits(page) {
82
82
  const MAX_REPORTED_WINDOWS = 5;
83
83
  /** At most `MAX_REPORTED_WINDOWS` known ids, appended to an unknown_window_id message. */
84
84
  function knownWindowSuffix(known) {
85
- return known.length === 0 ? "" : `; known: ${known.slice(0, MAX_REPORTED_WINDOWS).join(", ")}`;
85
+ return known.length === 0 ? "" : `; its windows: ${known.slice(0, MAX_REPORTED_WINDOWS).join(", ")}`;
86
86
  }
87
87
  export const PREVIOUS_WINDOW = "@previous";
88
88
  /** Resolve "@previous" against oldest-first windows; every other value passes through. */
@@ -93,13 +93,13 @@ function resolveWindowId(projection, windowId) {
93
93
  if (previous !== undefined)
94
94
  return { ok: true, window_id: previous.windowId };
95
95
  const known = projection.windows.map((current) => current.windowId);
96
- return { ok: false, outcome: failure("unknown_window_id", `unknown window_id "${PREVIOUS_WINDOW}": this session has no window before the current one${knownWindowSuffix(known)}`) };
96
+ return { ok: false, outcome: failure("unknown_window_id", `"${PREVIOUS_WINDOW}" has nothing to point at: this session has no window before the current one${knownWindowSuffix(known)}.`) };
97
97
  }
98
98
  function badWindowId(projection, params) {
99
99
  const badWindow = unknownWindowId(projection, params);
100
100
  if (!badWindow)
101
101
  return undefined;
102
- return failure("unknown_window_id", `${badWindow.message}${knownWindowSuffix(badWindow.known)}`);
102
+ return failure("unknown_window_id", `${badWindow.message}${knownWindowSuffix(badWindow.known)}.`);
103
103
  }
104
104
  /* ------------------------------------------------------------------ history_windows */
105
105
  export const historyWindowsParameters = Type.Object({}, { additionalProperties: false });
@@ -125,14 +125,14 @@ export const historyWindows = {
125
125
  data.windows.push(row);
126
126
  data.more--;
127
127
  }
128
- return fits(data) ? success(data) : failure("output_too_large", "The session identity does not fit one `history_windows` response.");
128
+ return fits(data) ? success(data) : failure("output_too_large", `The session id alone fills the ${TOOL_OUTPUT_LIMIT} a call can carry.`);
129
129
  },
130
130
  render: (result) => renderOutcome(result, renderWindows),
131
131
  };
132
132
  function renderWindows(data) {
133
133
  const lines = [`session ${data.session_id}`, ...data.windows.map((window) => `window ${window.window_id} | seqs ${window.first_seq ?? "-"}-${window.last_seq ?? "-"}`)];
134
134
  if (data.more > 0)
135
- lines.push(`${data.more} more windows not shown; \`history_list\` also reports window ids on events`);
135
+ lines.push(`${data.more} more windows not shown; every \`history_list\` event also names its window.`);
136
136
  return lines.join("\n");
137
137
  }
138
138
  /* ------------------------------------------------------------------ history_list */
@@ -179,22 +179,22 @@ export const historyRead = {
179
179
  // Address checks run in one order: past the end of the file, off this branch, then
180
180
  // consumed by a pairing. Only the last two can mention what is at the address.
181
181
  if (item === undefined && params.seq > projection.highestSeq) {
182
- return failure("unknown_seq", `unknown seq ${params.seq}: this session's items run 1..${projection.highestSeq}`);
182
+ return failure("unknown_seq", `There is no seq ${params.seq}; this session runs from seq 1 to ${projection.highestSeq}.`);
183
183
  }
184
184
  if (!projection.branchSeqs.has(params.seq)) {
185
- return failure("not_on_branch", `seq ${params.seq} is on another branch and is not readable here`);
185
+ return failure("not_on_branch", `Seq ${params.seq} is on another branch of this session; it can't be read from here.`);
186
186
  }
187
187
  if (item === undefined) {
188
188
  const callSeq = projection.pairedResults.get(params.seq);
189
189
  if (callSeq !== undefined) {
190
- return failure("not_an_event", `seq ${params.seq} is a tool result already shown inside the call at seq ${callSeq}; read that seq instead`);
190
+ return failure("not_an_event", `Seq ${params.seq} is a tool result, shown together with its call; read seq ${callSeq} instead.`);
191
191
  }
192
- return failure("unknown_seq", `seq ${params.seq} is on this branch but carries no readable event`);
192
+ return failure("unknown_seq", `Seq ${params.seq} holds nothing to read.`);
193
193
  }
194
194
  const document = eventDocument(item);
195
195
  const totalChars = Array.from(document).length;
196
196
  if (typeof params.offset_chars === "number" && params.offset_chars > totalChars) {
197
- return failure("invalid_offset", `offset_chars ${params.offset_chars} is past the end: the item has ${totalChars} chars; the largest legal offset is ${totalChars} (an empty end-read)`);
197
+ return failure("invalid_offset", `This event ends at char ${totalChars}; offset_chars ${params.offset_chars} is past the last word.`);
198
198
  }
199
199
  return readTextWindow(document, params.offset_chars, params.max_chars, (window) => ({
200
200
  seq: item.seq,
@@ -80,7 +80,7 @@ export declare const notesWriteParameters: Type.TObject<{
80
80
  export declare const notesWrite: {
81
81
  readonly name: "notes_write";
82
82
  readonly label: "Notes write";
83
- readonly description: "Create or replace a note's body, keeping metadata; uncrumples a crumpled note. Name it for what it holds and when to use it. Store what git and history can't recover. Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes. Not file paths: never pass them to file tools.";
83
+ readonly description: "Create or replace a note. Name it for what it holds and when to use it. Store what git and history can't recover. Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes. Not file paths: never pass them to file tools.";
84
84
  readonly parameters: Type.TObject<{
85
85
  address: Type.TString;
86
86
  content: Type.TString;
@@ -115,7 +115,7 @@ export declare const DIFF_SHORTENED_MARKER = "[diff truncated; update applied]";
115
115
  export declare const notesUpdate: {
116
116
  readonly name: "notes_update";
117
117
  readonly label: "Notes update";
118
- readonly description: "Edit a note's body, change its origin or crumpled state, or move it. Each `oldText` must match exactly once unless `replace_all` is true; frontmatter can't be edited. Returns a diff. Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes. Not file paths: never pass them to file tools.";
118
+ readonly description: "Edit a note, change its origin or crumpled state, or move it. Each `oldText` must match exactly once unless `replace_all` is true. Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes. Not file paths: never pass them to file tools.";
119
119
  readonly parameters: Type.TObject<{
120
120
  address: Type.TString;
121
121
  edits: Type.TOptional<Type.TArray<Type.TObject<{
@@ -149,7 +149,7 @@ export declare const notesReadParameters: Type.TObject<{
149
149
  export declare const notesRead: {
150
150
  readonly name: "notes_read";
151
151
  readonly label: "Notes read";
152
- readonly description: "Read a note's metadata and body, without frontmatter. Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes. Not file paths: never pass them to file tools.";
152
+ readonly description: "Read a note. Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes. Not file paths: never pass them to file tools.";
153
153
  readonly parameters: Type.TObject<{
154
154
  offset_chars: Type.TOptional<Type.TInteger>;
155
155
  max_chars: Type.TOptional<Type.TInteger>;
@@ -2,7 +2,7 @@ import { Type } from "typebox";
2
2
  import { localIso } from "../notes/frontmatter.js";
3
3
  import { isFilesystemError } from "../notes/fs-error.js";
4
4
  import { createNotesStore, NoteError, noteIdentity } from "../notes/index.js";
5
- import { prefixFit } from "./output.js";
5
+ import { prefixFit, TOOL_OUTPUT_LIMIT } from "./output.js";
6
6
  import { failure, fitsResult, resultSchema, readTextWindow, renderOutcome, renderTextWindow, structuredBytes, success, TextWindowRequestSchema, TextWindowSchema } from "./result.js";
7
7
  import { nullableString, InvalidQueryError, searchQueries, searchQuery } from "./schema.js";
8
8
  const ORIGIN_VALUES = [Type.Literal("user"), Type.Literal("self"), Type.Literal("external")];
@@ -164,11 +164,11 @@ function snapshot(rows, limit, status, renderData, shrink) {
164
164
  files.push(reduced);
165
165
  }
166
166
  if (files.length === 0)
167
- return failure("output_too_large", "The first matching note cannot fit in a response without losing its identity.");
167
+ return failure("output_too_large", `\`${item.address}\` won't fit on the list (${TOOL_OUTPUT_LIMIT} per call); narrow \`glob\` to leave it out.`);
168
168
  break;
169
169
  }
170
170
  const outcome = success(data(files));
171
- return fitsResult(outcome, render) ? outcome : failure("output_too_large", "The notes snapshot metadata exceeds the response budget.");
171
+ return fitsResult(outcome, render) ? outcome : failure("output_too_large", `The list of unreachable homes is itself over ${TOOL_OUTPUT_LIMIT}; narrow \`glob\` to fewer homes.`);
172
172
  }
173
173
  function listedFile(row, identity) {
174
174
  return { address: row.address, ...projectKeyField(row.scope, identity.projectKey), updated_at: localIso(row.meta.updatedAt), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }) };
@@ -179,7 +179,7 @@ function renderWriteData(data) {
179
179
  }
180
180
  export const notesWrite = {
181
181
  name: "notes_write", label: "Notes write",
182
- description: `Create or replace a note's body, keeping metadata; uncrumples a crumpled note. Name it for what it holds and when to use it. Store what git and history can't recover. ${ADDRESS_DESCRIPTION}`,
182
+ description: `Create or replace a note. Name it for what it holds and when to use it. Store what git and history can't recover. ${ADDRESS_DESCRIPTION}`,
183
183
  parameters: notesWriteParameters, outputSchema: resultSchema(NotesWriteDataSchema), executionMode: "sequential",
184
184
  async execute(params, identity) {
185
185
  try {
@@ -214,19 +214,20 @@ function renderUpdate(result) {
214
214
  }
215
215
  /** A shortened diff still says so in the receipt's own text, on both surfaces. */
216
216
  export const DIFF_SHORTENED_MARKER = "[diff truncated; update applied]";
217
+ const RECEIPT_TOO_LONG = `Saved, but the receipt is too long to hand back (${TOOL_OUTPUT_LIMIT} per call). Check the note with \`notes_read\`.`;
217
218
  /** Bound a mutation receipt on both surfaces; a huge diff is cut to the longest fitting prefix and marked. */
218
219
  function boundedUpdate(data) {
219
220
  if (fitsResult(success(data), renderUpdate))
220
221
  return success(data);
221
222
  if (data.diff === "")
222
- return failure("output_too_large", "The update was applied, but its receipt metadata exceeds the response budget.");
223
+ return failure("output_too_large", RECEIPT_TOO_LONG);
223
224
  const diff = prefixFit(data.diff, (candidate) => fitsResult(success({ ...data, diff: `${candidate}\n${DIFF_SHORTENED_MARKER}` }), renderUpdate));
224
225
  const result = success({ ...data, diff: `${diff}\n${DIFF_SHORTENED_MARKER}` });
225
- return fitsResult(result, renderUpdate) ? result : failure("output_too_large", "The update was applied, but its receipt metadata exceeds the response budget.");
226
+ return fitsResult(result, renderUpdate) ? result : failure("output_too_large", RECEIPT_TOO_LONG);
226
227
  }
227
228
  export const notesUpdate = {
228
229
  name: "notes_update", label: "Notes update",
229
- description: `Edit a note's body, change its origin or crumpled state, or move it. Each \`oldText\` must match exactly once unless \`replace_all\` is true; frontmatter can't be edited. Returns a diff. ${ADDRESS_DESCRIPTION}`,
230
+ description: `Edit a note, change its origin or crumpled state, or move it. Each \`oldText\` must match exactly once unless \`replace_all\` is true. ${ADDRESS_DESCRIPTION}`,
230
231
  parameters: notesUpdateParameters, outputSchema: resultSchema(NotesUpdateDataSchema), executionMode: "sequential",
231
232
  async execute(params, identity, renderDiff) {
232
233
  try {
@@ -257,17 +258,17 @@ function renderReadData(data) {
257
258
  }
258
259
  export const notesRead = {
259
260
  name: "notes_read", label: "Notes read",
260
- description: `Read a note's metadata and body, without frontmatter. ${ADDRESS_DESCRIPTION}`,
261
+ description: `Read a note. ${ADDRESS_DESCRIPTION}`,
261
262
  parameters: notesReadParameters, outputSchema: resultSchema(NotesReadDataSchema),
262
263
  async execute(params, identity) {
263
264
  try {
264
265
  const note = await createNotesStore(identity).read(params.address);
266
+ const resolved = noteIdentity(identity, params.address);
265
267
  if (!note)
266
- return failure("not_found", "note not found");
268
+ return failure("not_found", `No note at ${resolved.address}.`);
267
269
  const totalChars = Array.from(note.body).length;
268
270
  if (params.offset_chars !== undefined && params.offset_chars > totalChars)
269
- return failure("invalid_offset", `offset_chars ${params.offset_chars} is past the end of the body: the note has ${totalChars} body chars; the largest legal offset is ${totalChars} (an empty end-read)`);
270
- const resolved = noteIdentity(identity, params.address);
271
+ return failure("invalid_offset", `This note ends at char ${totalChars}; offset_chars ${params.offset_chars} is past the last word.`);
271
272
  const metadata = noteMetadata(note.meta);
272
273
  return readTextWindow(note.body, params.offset_chars, params.max_chars, (window) => ({ ...resolved, metadata, ...window }), (result) => renderOutcome(result, renderReadData));
273
274
  }
@@ -1,6 +1,8 @@
1
1
  /** Budget primitives. Notes/history use result.ts; reset/budget tools retain output(). */
2
2
  export { earliestMatchOffsetChars } from "../text-match.js";
3
3
  export declare const TOOL_OUTPUT_MAX_BYTES: number;
4
+ /** The per-call limit as the model reads it in refusals. */
5
+ export declare const TOOL_OUTPUT_LIMIT = "32 KB";
4
6
  export declare const DEFAULT_READ_WINDOW_CHARS = 12000;
5
7
  export declare const MAX_READ_WINDOW_CHARS = 50000;
6
8
  export declare const HISTORY_PREVIEW_CHARS = 1200;
@@ -1,6 +1,8 @@
1
1
  /** Budget primitives. Notes/history use result.ts; reset/budget tools retain output(). */
2
2
  export { earliestMatchOffsetChars } from "../text-match.js";
3
3
  export const TOOL_OUTPUT_MAX_BYTES = 32 * 1024;
4
+ /** The per-call limit as the model reads it in refusals. */
5
+ export const TOOL_OUTPUT_LIMIT = `${TOOL_OUTPUT_MAX_BYTES / 1024} KB`;
4
6
  export const DEFAULT_READ_WINDOW_CHARS = 12000;
5
7
  export const MAX_READ_WINDOW_CHARS = 50000;
6
8
  export const HISTORY_PREVIEW_CHARS = 1200;
@@ -1,6 +1,6 @@
1
1
  /** Internal outcomes, compact wire results, and bounded read windows. */
2
2
  import { Type } from "typebox";
3
- import { DEFAULT_READ_WINDOW_CHARS, MAX_READ_WINDOW_CHARS, TOOL_OUTPUT_MAX_BYTES, withinTextBudget } from "./output.js";
3
+ import { DEFAULT_READ_WINDOW_CHARS, MAX_READ_WINDOW_CHARS, TOOL_OUTPUT_LIMIT, TOOL_OUTPUT_MAX_BYTES, withinTextBudget } from "./output.js";
4
4
  /** The one refusal shape: `code` is a stable internal identifier, `message` the bounded reading. */
5
5
  export const OperationErrorSchema = Type.Object({
6
6
  code: Type.String(),
@@ -94,7 +94,7 @@ export function readTextWindow(text, offset, limit, makeData, render) {
94
94
  high = mid - 1;
95
95
  }
96
96
  if (low === 0)
97
- return failure("output_too_large", "The response metadata leaves no room for a progressing read window.");
97
+ return failure("output_too_large", `Its header alone fills the ${TOOL_OUTPUT_LIMIT} a call can carry; no room left for the text.`);
98
98
  return success(makeData(window(low)));
99
99
  }
100
100
  /** The continuation line never becomes part of `window.text`, and a complete window has none. */
@@ -22,10 +22,10 @@ export class InvalidQueryError extends Error {
22
22
  export function searchQueries(query) {
23
23
  const candidates = typeof query === "string" ? [query] : query;
24
24
  if (!Array.isArray(candidates) || candidates.length === 0)
25
- throw new InvalidQueryError("query must be a string or a non-empty array of strings");
25
+ throw new InvalidQueryError("`query` must be a string or a non-empty list of strings.");
26
26
  if (!candidates.every((candidate) => typeof candidate === "string"))
27
- throw new InvalidQueryError("query array elements must be strings");
27
+ throw new InvalidQueryError("Every item in the `query` list must be a string.");
28
28
  if (candidates.some((candidate) => candidate === ""))
29
- throw new InvalidQueryError("query strings must be non-empty: an empty query matches everything");
29
+ throw new InvalidQueryError("`query` can't be an empty string; it would match everything.");
30
30
  return candidates;
31
31
  }
@@ -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);