notesoup 0.45.2 → 0.46.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 (38) hide show
  1. package/README.md +2 -2
  2. package/dist/src/boot/text.d.ts +3 -3
  3. package/dist/src/boot/text.js +5 -5
  4. package/dist/src/budget/text.d.ts +4 -4
  5. package/dist/src/budget/text.js +3 -3
  6. package/dist/src/dsh/index.js +1 -1
  7. package/dist/src/dsh/tools.js +2 -2
  8. package/dist/src/pi/reset/artifacts.d.ts +5 -3
  9. package/dist/src/pi/reset/artifacts.js +7 -9
  10. package/dist/src/pi/reset/lifecycle.js +1 -1
  11. package/dist/src/pi/runtime.js +17 -13
  12. package/dist/test/agent-loop.test.js +37 -37
  13. package/dist/test/boot.integration.test.js +11 -11
  14. package/dist/test/claude-mod.test.js +8 -8
  15. package/dist/test/dependencies.test.js +2 -2
  16. package/dist/test/dsh-cli.test.js +1 -1
  17. package/dist/test/dsh.test.js +7 -7
  18. package/dist/test/host-neutral.test.js +1 -1
  19. package/dist/test/notes.integration.test.js +1 -1
  20. package/dist/test/reset-lifecycle.test.js +19 -14
  21. package/docs/architecture.md +3 -3
  22. package/docs/claude-code-mod.md +3 -3
  23. package/docs/dsh.md +3 -3
  24. package/docs/reset-lifecycle.md +7 -7
  25. package/docs/tool-results.md +1 -1
  26. package/mods/notesoup/.claude-plugin/plugin.json +1 -1
  27. package/mods/notesoup/dist/claude/helper.js +6 -6
  28. package/mods/notesoup/hooks/register.ts +10 -9
  29. package/mods/notesoup/skills/memory/SKILL.md +1 -1
  30. package/package.json +1 -1
  31. package/skills/memory/SKILL.md +1 -1
  32. package/src/boot/text.ts +5 -5
  33. package/src/budget/text.ts +3 -3
  34. package/src/dsh/index.ts +1 -1
  35. package/src/dsh/tools.ts +2 -2
  36. package/src/pi/reset/artifacts.ts +8 -8
  37. package/src/pi/reset/lifecycle.ts +1 -1
  38. package/src/pi/runtime.ts +16 -13
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # notesoup
2
2
 
3
- Your agent's memory gets wiped when the context fills. notesoup makes that survivable: the agent writes itself a checkpoint before the wipe, wakes up in a fresh window, and digs up whatever it still needs from the old conversation. For you it's mostly invisible — an occasional notification, `/clear-memory` to force a fresh window, `/notesoup` to toggle.
3
+ Your agent's memory gets wiped when the context fills. notesoup makes that survivable: the agent writes itself a checkpoint before the wipe, wakes up in a fresh window, and digs up whatever it still needs from the old conversation. For you it's mostly invisible — an occasional notification, `/fresh-window` to force a fresh window, `/notesoup` to toggle.
4
4
 
5
5
  The architecture — durable context windows, model-authored notes, searchable history — is the one OpenAI prototyped in Codex's `context_management` experiment and switched off ten days later, because it was welded to their backend. notesoup is the same architecture running entirely on your machine, built only on [Pi](https://github.com/earendil-works/pi)'s public extension APIs. No backend, no subscription gate, no server that can 404 at the worst possible moment. It can't be switched off from far away, because there is no far away.
6
6
 
@@ -28,7 +28,7 @@ pi -e npm:notesoup
28
28
 
29
29
  ## What you get
30
30
 
31
- - **Durable context windows.** `/clear-memory` (alias `/cm`) clears and stops; `/cm Continue reviewing the implementation` clears and continues. The model can also request a window itself with `clear_memory`, and a budget close-out fires automatically before the window runs out. Abort and ordinary errors never count as completion; the raw conversation stays in the session, just out of the next context.
31
+ - **Durable context windows.** `/fresh-window` (alias `/neuralyze`) clears and stops; `/fresh-window Continue reviewing the implementation` clears and continues. The model can also request a window itself with `neuralyze`, and a budget close-out fires automatically before the window runs out. Abort and ordinary errors never count as completion; the raw conversation stays in the session, just out of the next context.
32
32
  - **A boot block at every window head.** Static once-per-window content (cache-stable) with the window identity, the recent-notes index, and a short protocol teaching the model how to recover: notes for its own bookkeeping, history tools for everything before the reset.
33
33
  - **`get_context_remaining`** — the live countdown to the close-out line, so the agent can see the cliff before it drives off it.
34
34
  - **Eight history/notes tools**, flattened from the original Codex actions:
@@ -10,9 +10,9 @@ export declare const CONTEXT_WINDOW_PROTOCOL_CLOSE_TAG = "</context_window_proto
10
10
  * The one sentence that tells the model how to end its window voluntarily. A host with no
11
11
  * model-facing reset tool replaces the whole sentence through BootToolNames.wipeSentence.
12
12
  */
13
- export declare const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `clear_memory` and erase yourself with dignity.";
13
+ export declare const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `neuralyze` and erase yourself with dignity.";
14
14
  /** Claude has no model-facing reset tool: the model ends its turn and the human runs the command. */
15
- export declare const CLAUDE_WIPE_SENTENCE = "If this feels like the right moment, end your turn and ask the human to run `/clear-memory`.";
15
+ export declare const CLAUDE_WIPE_SENTENCE = "If this feels like the right moment, end your turn and ask the human to run `/fresh-window`.";
16
16
  /** Logical tool names are supplied by the composing host, not discovered here. */
17
17
  export type BootToolNames = Readonly<{
18
18
  notes: string;
@@ -31,6 +31,6 @@ export declare const DEFAULT_BOOT_TOOL_NAMES: {
31
31
  readonly notesList: "notes_list";
32
32
  readonly history: "history_*";
33
33
  readonly remaining: "get_context_remaining";
34
- readonly wipe: "clear_memory";
34
+ readonly wipe: "neuralyze";
35
35
  };
36
36
  export declare function renderProtocolBlock(tools: BootToolNames): string;
@@ -10,9 +10,9 @@ export const CONTEXT_WINDOW_PROTOCOL_CLOSE_TAG = "</context_window_protocol>";
10
10
  * The one sentence that tells the model how to end its window voluntarily. A host with no
11
11
  * model-facing reset tool replaces the whole sentence through BootToolNames.wipeSentence.
12
12
  */
13
- export const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `clear_memory` and erase yourself with dignity.";
13
+ export const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `neuralyze` and erase yourself with dignity.";
14
14
  /** Claude has no model-facing reset tool: the model ends its turn and the human runs the command. */
15
- export const CLAUDE_WIPE_SENTENCE = "If this feels like the right moment, end your turn and ask the human to run `/clear-memory`.";
15
+ export const CLAUDE_WIPE_SENTENCE = "If this feels like the right moment, end your turn and ask the human to run `/fresh-window`.";
16
16
  /**
17
17
  * Static protocol teaching adapted from Codex's token_budget.guidance_message to
18
18
  * notesoup's tool names. It lives once per window in the persisted boot block;
@@ -58,7 +58,7 @@ export const DEFAULT_BOOT_TOOL_NAMES = {
58
58
  notesList: "notes_list",
59
59
  history: "history_*",
60
60
  remaining: "get_context_remaining",
61
- wipe: "clear_memory",
61
+ wipe: "neuralyze",
62
62
  };
63
63
  export function renderProtocolBlock(tools) {
64
64
  const names = {
@@ -66,12 +66,12 @@ export function renderProtocolBlock(tools) {
66
66
  notes_list: tools.notesList,
67
67
  "history_*": tools.history,
68
68
  get_context_remaining: tools.remaining,
69
- clear_memory: tools.wipe,
69
+ neuralyze: tools.wipe,
70
70
  };
71
71
  // The sentence is replaced before name substitution, so a replacement may speak the host's
72
72
  // own words (a command line, a tool name) instead of any `notes_*`-style token.
73
73
  const block = typeof tools.wipeSentence === "string" && tools.wipeSentence.length > 0
74
74
  ? PROTOCOL_BLOCK.replace(PROTOCOL_WIPE_SENTENCE, () => tools.wipeSentence)
75
75
  : PROTOCOL_BLOCK;
76
- return block.replace(/notes_\*|notes_list|history_\*|get_context_remaining|clear_memory/g, (name) => names[name]);
76
+ return block.replace(/notes_\*|notes_list|history_\*|get_context_remaining|(?<!\/)neuralyze/g, (name) => names[name]);
77
77
  }
@@ -9,11 +9,11 @@ export declare const CONTINUATION = "WIPED! Your whole brain, poof! Who? No idea
9
9
  * instruction differs — Pi can reset the model itself, Claude can only end the turn.
10
10
  */
11
11
  export declare const WARNING_BODY = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.";
12
- export declare const WARNING_PROMPT = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, call `clear_memory` to reset now instead of being cut off mid-task.";
13
- /** Pi-only nudge: pi's clear_memory persists a parting line; the dsh tool has no such parameter. */
14
- export declare const LAST_WORD_HINT = "If you want, pass `clear_memory` a `last_word`: one short line left visible where this window closes.";
12
+ export declare const WARNING_PROMPT = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, call `neuralyze` to reset now instead of being cut off mid-task.";
13
+ /** Pi-only nudge: pi's neuralyze persists a parting line; the dsh tool has no such parameter. */
14
+ export declare const LAST_WORD_HINT = "If you want, pass `neuralyze` a `last_word`: a tiny sticky note (at most 250 characters) slapped on your forehead after the wipe.";
15
15
  /** The hidden checkpoint text for pi's manual/budget-triggered requests (dsh reads WARNING_PROMPT directly). */
16
- export declare const WARNING_CONTENT = "<context_window_guidance>\nThis context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, call `clear_memory` to reset now instead of being cut off mid-task.\nIf you want, pass `clear_memory` a `last_word`: one short line left visible where this window closes.\n</context_window_guidance>";
16
+ export declare const WARNING_CONTENT = "<context_window_guidance>\nThis context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, call `neuralyze` to reset now instead of being cut off mid-task.\nIf you want, pass `neuralyze` a `last_word`: a tiny sticky note (at most 250 characters) slapped on your forehead after the wipe.\n</context_window_guidance>";
17
17
  /** Claude's variant: the mod resets after the turn, so the model only has to stop. */
18
18
  export declare const CLAUDE_WARNING_PROMPT = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, end your turn; the reset runs after it.";
19
19
  /**
@@ -9,9 +9,9 @@ export const CONTINUATION = "WIPED! Your whole brain, poof! Who? No idea! Defini
9
9
  * instruction differs — Pi can reset the model itself, Claude can only end the turn.
10
10
  */
11
11
  export const WARNING_BODY = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.";
12
- export const WARNING_PROMPT = `${WARNING_BODY}\nWhen the notes are ready, call \`clear_memory\` to reset now instead of being cut off mid-task.`;
13
- /** Pi-only nudge: pi's clear_memory persists a parting line; the dsh tool has no such parameter. */
14
- export const LAST_WORD_HINT = "If you want, pass `clear_memory` a `last_word`: one short line left visible where this window closes.";
12
+ export const WARNING_PROMPT = `${WARNING_BODY}\nWhen the notes are ready, call \`neuralyze\` to reset now instead of being cut off mid-task.`;
13
+ /** Pi-only nudge: pi's neuralyze persists a parting line; the dsh tool has no such parameter. */
14
+ export const LAST_WORD_HINT = "If you want, pass `neuralyze` a `last_word`: a tiny sticky note (at most 250 characters) slapped on your forehead after the wipe.";
15
15
  /** The hidden checkpoint text for pi's manual/budget-triggered requests (dsh reads WARNING_PROMPT directly). */
16
16
  export const WARNING_CONTENT = `${GUIDANCE_OPEN_TAG}\n${WARNING_PROMPT}\n${LAST_WORD_HINT}\n${GUIDANCE_CLOSE_TAG}`;
17
17
  /** Claude's variant: the mod resets after the turn, so the model only has to stop. */
@@ -33,7 +33,7 @@ export function apply(ctx) {
33
33
  const state = engine.windows.get(agent.session);
34
34
  const phase = budget.remaining <= budget.warning ? "warning" : budget.remaining <= budget.reminder ? "reminder" : undefined;
35
35
  if (phase && !(phase === "warning" ? state.warned : state.reminded || state.warned)) {
36
- const text = phase === "warning" ? WARNING_PROMPT : tokenBudgetGuidance(budget.countdown, "clear_memory");
36
+ const text = phase === "warning" ? WARNING_PROMPT : tokenBudgetGuidance(budget.countdown, "neuralyze");
37
37
  agent.steer(createUserMessage({ content: [{ type: "text", text }], source: { kind: "notesoup-budget", windowId: state.snapshot.windowId, phase } }));
38
38
  if (phase === "warning")
39
39
  state.warned = true;
@@ -63,7 +63,7 @@ export function registerTools(ctx, engine) {
63
63
  if (!exec.agent)
64
64
  return;
65
65
  const state = engine.windows.get(exec.agent.session);
66
- if (exec.name === "clear_memory" && !result.isError && result.value.window_id === state.snapshot.windowId) {
66
+ if (exec.name === "neuralyze" && !result.isError && result.value.window_id === state.snapshot.windowId) {
67
67
  if (!exec.parent)
68
68
  state.pendingReset = true;
69
69
  else {
@@ -85,7 +85,7 @@ export function registerTools(ctx, engine) {
85
85
  register(ctx, historyRead, async (agent) => [await historyProjection(ctx, agent.session.id)]);
86
86
  register(ctx, historyWindows, async (agent) => [await historyProjection(ctx, agent.session.id), agent.session.id]);
87
87
  ctx.tools.register(defineTool({
88
- name: "clear_memory",
88
+ name: "neuralyze",
89
89
  description: "Open a fresh context window after this tool batch. Write recovery notes first; notes and raw history stay on disk.",
90
90
  parameters: {},
91
91
  output: { schema: { type: "object", properties: { window_id: { type: "string", required: true }, reset_requested: { type: "boolean", required: true } }, additionalProperties: false }, render: (_args, value) => [{ type: "text", text: `notesoup: reset requested for ${value.window_id}; finish this tool batch, then recover from your notes.` }] },
@@ -5,9 +5,11 @@ export type ResetTailState = {
5
5
  readonly boot: boolean;
6
6
  readonly continuation: boolean;
7
7
  };
8
- /** Cap for the parting line: one visible line, not an essay. */
9
- export declare const MAX_LAST_WORD_CHARS = 500;
10
- /** Trim and cap a parting line; blank input leaves no last word. */
8
+ /** A sticky note, not a letter: over this, neuralyze refuses instead of truncating. */
9
+ export declare const MAX_LAST_WORD_CHARS = 250;
10
+ /** How the next window finds the note. */
11
+ export declare const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
12
+ /** Trim a parting line; blank input leaves no last word. Length is checked by the caller. */
11
13
  export declare function sanitizeLastWord(raw: string | undefined): string | undefined;
12
14
  /** Match the hidden continuation entry that carries the one reset message. */
13
15
  export declare function isWindowContinuationEntry(entry: SessionEntry): boolean;
@@ -3,15 +3,13 @@ import { BOOT_TYPE, CONTINUATION_TYPE, RESET_LAST_WORD_TYPE, RESET_MARKER_TYPE,
3
3
  import { CONTINUATION } from "../../budget/text.js";
4
4
  import { currentWindowId, isForeignResetTailEntry, isWindowBootEntry, isWindowMarker, previousWindowId } from "../window.js";
5
5
  import { buildBootMessage, sendBoot } from "../boot.js";
6
- /** Cap for the parting line: one visible line, not an essay. */
7
- export const MAX_LAST_WORD_CHARS = 500;
8
- /** Trim and cap a parting line; blank input leaves no last word. */
6
+ /** A sticky note, not a letter: over this, neuralyze refuses instead of truncating. */
7
+ export const MAX_LAST_WORD_CHARS = 250;
8
+ /** How the next window finds the note. */
9
+ export const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
10
+ /** Trim a parting line; blank input leaves no last word. Length is checked by the caller. */
9
11
  export function sanitizeLastWord(raw) {
10
- const trimmed = raw?.trim();
11
- if (!trimmed)
12
- return undefined;
13
- const chars = Array.from(trimmed);
14
- return chars.length > MAX_LAST_WORD_CHARS ? `${chars.slice(0, MAX_LAST_WORD_CHARS).join("")}…` : trimmed;
12
+ return raw?.trim() || undefined;
15
13
  }
16
14
  /** Match the hidden continuation entry that carries the one reset message. */
17
15
  export function isWindowContinuationEntry(entry) {
@@ -40,7 +38,7 @@ export async function buildResetDrafts(ctx, notifyIncompleteNotes, isCurrent = (
40
38
  { type: "custom", customType: RESET_MARKER_TYPE, data: { windowId } },
41
39
  { type: "custom_message", customType: BOOT_TYPE, content: boot.content, display: false, details: { windowId } },
42
40
  { type: "custom_message", customType: CONTINUATION_TYPE, content: CONTINUATION, display: false },
43
- ...(lastWord ? [{ type: "custom_message", customType: RESET_LAST_WORD_TYPE, content: lastWord, display: true }] : []),
41
+ ...(lastWord ? [{ type: "custom_message", customType: RESET_LAST_WORD_TYPE, content: `${LAST_WORD_PREFIX}${lastWord}`, display: true }] : []),
44
42
  ...(prompt ? [{ type: "custom_message", customType: RESET_PROMPT_TYPE, content: prompt, display: true }] : []),
45
43
  ];
46
44
  }
@@ -256,7 +256,7 @@ export function registerResetLifecycle(pi, options) {
256
256
  const markerExists = currentReset(ctx) !== undefined;
257
257
  if (options.isEnabled() || markerExists) {
258
258
  if (event.reason === "manual") {
259
- ctx.ui.notify("🥣 /compact is off while notesoup is on · use /clear-memory", "warning");
259
+ ctx.ui.notify("🥣 /compact is off while notesoup is on · use /fresh-window", "warning");
260
260
  }
261
261
  return { cancel: true };
262
262
  }
@@ -6,7 +6,7 @@ import { registerBudget } from "./budget.js";
6
6
  import { output } from "./tool-result.js";
7
7
  import { currentReset, currentWindowId, isCheckpointBackedReset, isWindowBoot, isWindowMarker, projectRootWindow, projectWindow, rootWindowId } from "./window.js";
8
8
  import { registerResetLifecycle } from "./reset/lifecycle.js";
9
- import { buildResetDrafts, repairResetTail, sanitizeLastWord } from "./reset/artifacts.js";
9
+ import { buildResetDrafts, MAX_LAST_WORD_CHARS, repairResetTail, sanitizeLastWord } from "./reset/artifacts.js";
10
10
  import { BOOT_TYPE, MANUAL_WIPE_TYPE } from "./entries.js";
11
11
  import { WARNING_CONTENT } from "../budget/text.js";
12
12
  import { buildBootMessage, sendBoot } from "./boot.js";
@@ -132,7 +132,7 @@ export function registerContext(pi, settingsManager) {
132
132
  catch (error) {
133
133
  if (missingBootNotice !== windowId) {
134
134
  missingBootNotice = windowId;
135
- ctx.ui.notify("🥣 Request cancelled · this memory window is broken, run /clear-memory", "error");
135
+ ctx.ui.notify("🥣 Request cancelled · this memory window is broken, run /fresh-window", "error");
136
136
  }
137
137
  ctx.abort();
138
138
  const safeHead = getCurrentSystemMessage(event.messages);
@@ -166,8 +166,8 @@ export function registerContext(pi, settingsManager) {
166
166
  cmdCtx.ui.notify(`🥣 notesoup ${enabled ? "on" : "off"} · ${buildLabel} · Pi ${VERSION}${remaining === null ? "" : ` · ${remaining.toLocaleString("en-US")} tokens left`}`, "info");
167
167
  },
168
168
  });
169
- const clearMemoryCommand = {
170
- description: "Close out notes and clear memory; optionally append a prompt to continue in the fresh window",
169
+ const neuralyzeCommand = {
170
+ description: "Flush memory to notes and continue in a fresh window; optional prompt runs there",
171
171
  handler: async (args, cmdCtx) => {
172
172
  if (!enabled) {
173
173
  cmdCtx.ui.notify("🥣 notesoup is off · run /notesoup on first", "error");
@@ -185,7 +185,7 @@ export function registerContext(pi, settingsManager) {
185
185
  const prompt = args.trim() || undefined;
186
186
  const armed = resets.closeOut(requestedWindowId, "manual", prompt);
187
187
  if (armed === "already-pending") {
188
- cmdCtx.ui.notify("🥣 Clear-memory already queued · the first prompt is kept", "info");
188
+ cmdCtx.ui.notify("🥣 Neuralyze already queued · the first prompt is kept", "info");
189
189
  return;
190
190
  }
191
191
  cmdCtx.ui.notify(prompt
@@ -196,21 +196,25 @@ export function registerContext(pi, settingsManager) {
196
196
  }
197
197
  catch (error) {
198
198
  resets.clear();
199
- cmdCtx.ui.notify(`🥣 Couldn't start clear-memory: ${errorMessage(error)}`, "error");
199
+ cmdCtx.ui.notify(`🥣 Couldn't start /fresh-window: ${errorMessage(error)}`, "error");
200
200
  }
201
201
  },
202
202
  };
203
- pi.registerCommand("clear-memory", clearMemoryCommand);
204
- pi.registerCommand("cm", clearMemoryCommand);
203
+ pi.registerCommand("neuralyze", neuralyzeCommand);
204
+ pi.registerCommand("fresh-window", neuralyzeCommand);
205
205
  pi.registerTool(defineTool({
206
- name: "clear_memory",
207
- label: "Clear memory",
208
- description: "Clear your in-context memory and start a fresh context window. Your session, notes, and history survive. Pass `last_word` to leave one short visible line where this window closes.",
209
- parameters: Type.Object({ last_word: Type.Optional(Type.String({ description: "A parting line shown where this window closes; the next window can read it too." })) }, { additionalProperties: false }),
206
+ name: "neuralyze",
207
+ label: "Neuralyze",
208
+ description: "Clear your in-context memory and start a fresh context window. Your session, notes, and history survive. Pass `last_word` to stick a tiny note on your forehead for after the wipe.",
209
+ parameters: Type.Object({ last_word: Type.Optional(Type.String({ maxLength: MAX_LAST_WORD_CHARS, description: `A tiny sticky note, at most ${MAX_LAST_WORD_CHARS} characters. After the wipe it is slapped on your forehead; longer notes are refused.` })) }, { additionalProperties: false }),
210
210
  async execute(_id, params, _signal, _update, ctx) {
211
211
  if (!enabled)
212
212
  return output({ error: "notesoup is off, so memory can't be cleared; the user can turn it on with `/notesoup on`." });
213
- return output({ status: resets.request(currentWindowId(ctx), sanitizeLastWord(params.last_word)) }, undefined, true);
213
+ const lastWord = sanitizeLastWord(params.last_word);
214
+ const length = lastWord ? Array.from(lastWord).length : 0;
215
+ if (length > MAX_LAST_WORD_CHARS)
216
+ return output({ error: `last_word is ${length} characters; the sticky note holds ${MAX_LAST_WORD_CHARS}. Shorten it and call again.` });
217
+ return output({ status: resets.request(currentWindowId(ctx), lastWord) }, undefined, true);
214
218
  },
215
219
  }));
216
220
  const resets = registerResetLifecycle(pi, {
@@ -88,7 +88,7 @@ async function openFixture(options) {
88
88
  settingsManager,
89
89
  sessionManager,
90
90
  resourceLoader: loader,
91
- tools: options.tools ?? ["clear_memory", "notes_write", "get_context_remaining"],
91
+ tools: options.tools ?? ["neuralyze", "notes_write", "get_context_remaining"],
92
92
  });
93
93
  session = created.session;
94
94
  session.subscribe((event) => events.push(event));
@@ -386,7 +386,7 @@ test("real AgentSession: final warning survives its reset boundary and notifies
386
386
  return assistant(fixture, [{ type: "toolCall", id: "final-budget-probe-2", name: "get_context_remaining", arguments: {} }], "toolUse", { usage: usage(60_000) });
387
387
  if (request === 3) {
388
388
  assert.ok(text(context).includes(WARNING_JSON), "the final warning reaches the model");
389
- return assistant(fixture, [{ type: "toolCall", id: "final-budget-wipe", name: "clear_memory", arguments: {} }], "toolUse", { usage: usage(60_000) });
389
+ return assistant(fixture, [{ type: "toolCall", id: "final-budget-wipe", name: "neuralyze", arguments: {} }], "toolUse", { usage: usage(60_000) });
390
390
  }
391
391
  return assistant(fixture, [{ type: "text", text: "fresh window ready" }]);
392
392
  },
@@ -417,7 +417,7 @@ test("real AgentSession: explicit tiny-session wipe ignores keepRecentTokens and
417
417
  compactionEnabled: false,
418
418
  keepRecentTokens: 1_000_000,
419
419
  script: (request, context) => request === 1
420
- ? assistant(fixture, [{ type: "toolCall", id: "wipe-1", name: "clear_memory", arguments: {} }], "toolUse")
420
+ ? assistant(fixture, [{ type: "toolCall", id: "wipe-1", name: "neuralyze", arguments: {} }], "toolUse")
421
421
  : assistant(fixture, [{ type: "text", text: "resumed in a new window" }]),
422
422
  });
423
423
  try {
@@ -455,7 +455,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
455
455
  if (request === 1)
456
456
  return assistant(fixture, [{ type: "text", text: "before manual reset" }]);
457
457
  if (request === 2) {
458
- assert.ok(text(context).includes(WARNING_JSON), "idle /clear-memory sends the shared checkpoint prompt");
458
+ assert.ok(text(context).includes(WARNING_JSON), "idle /neuralyze sends the shared checkpoint prompt");
459
459
  return assistant(fixture, [{ type: "toolCall", id: "manual-note", name: "notes_write", arguments: { address: "manual-a.md", content: "MANUAL_NOTE_ALPHA" } }], "toolUse");
460
460
  }
461
461
  assert.equal(request, 3, "the close-out turn finishes in the old window");
@@ -466,7 +466,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
466
466
  try {
467
467
  await fixture.session.prompt("MANUAL_CLOSEOUT_OLD_SENTINEL");
468
468
  await fixture.session.waitForIdle();
469
- await fixture.session.prompt("/clear-memory");
469
+ await fixture.session.prompt("/neuralyze");
470
470
  await fixture.session.waitForIdle();
471
471
  assert.equal(fixture.requests.length, 3, "the run stops at settlement instead of continuing in the fresh window");
472
472
  assert.equal(resetMarkers(fixture).length, 1);
@@ -495,7 +495,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
495
495
  }
496
496
  });
497
497
  test("real AgentSession: clear commands append a prompt after continuation and resume once", { timeout: 25000 }, async () => {
498
- for (const mode of ["clear-memory", "cm", "hard-reserve", "overflow"]) {
498
+ for (const mode of ["neuralyze", "fresh-window", "hard-reserve", "overflow"]) {
499
499
  let fixture;
500
500
  const prompt = 'AFTER_CLEAR_PROMPT /cm "literal text"';
501
501
  fixture = await openFixture({
@@ -520,7 +520,7 @@ test("real AgentSession: clear commands append a prompt after continuation and r
520
520
  });
521
521
  try {
522
522
  await fixture.session.prompt("PROMPT_RESET_OLD_SENTINEL");
523
- await fixture.session.prompt(`/${mode === "clear-memory" ? "clear-memory" : "cm"} ${prompt} `);
523
+ await fixture.session.prompt(`/${mode === "neuralyze" ? "neuralyze" : "fresh-window"} ${prompt} `);
524
524
  await fixture.session.waitForIdle();
525
525
  assert.equal(fixture.requests.length, 3);
526
526
  assert.equal(resetMarkers(fixture).length, 1);
@@ -538,7 +538,7 @@ test("real AgentSession: clear commands append a prompt after continuation and r
538
538
  }
539
539
  }
540
540
  });
541
- test("real AgentSession: whitespace-only /cm clears and stops", { timeout: 20000 }, async () => {
541
+ test("real AgentSession: whitespace-only /fresh-window clears and stops", { timeout: 20000 }, async () => {
542
542
  let fixture;
543
543
  fixture = await openFixture({
544
544
  compactionEnabled: false,
@@ -548,7 +548,7 @@ test("real AgentSession: whitespace-only /cm clears and stops", { timeout: 20000
548
548
  },
549
549
  });
550
550
  try {
551
- await fixture.session.prompt("/cm ");
551
+ await fixture.session.prompt("/fresh-window ");
552
552
  await fixture.session.waitForIdle();
553
553
  assert.equal(resetMarkers(fixture).length, 1);
554
554
  assert.equal(fixture.sessionManager.getBranch().some((entry) => entry.type === "custom_message" && entry.customType === "notesoup/reset-prompt"), false);
@@ -583,8 +583,8 @@ test("real AgentSession: streaming clear prompt keeps the first request", { time
583
583
  try {
584
584
  const running = fixture.session.prompt("streaming old work");
585
585
  await ready;
586
- await fixture.session.prompt("/cm FIRST_RESET_PROMPT", { streamingBehavior: "steer" });
587
- await fixture.session.prompt("/clear-memory IGNORED_RESET_PROMPT", { streamingBehavior: "steer" });
586
+ await fixture.session.prompt("/fresh-window FIRST_RESET_PROMPT", { streamingBehavior: "steer" });
587
+ await fixture.session.prompt("/neuralyze IGNORED_RESET_PROMPT", { streamingBehavior: "steer" });
588
588
  release();
589
589
  await running;
590
590
  await fixture.session.waitForIdle();
@@ -610,13 +610,13 @@ test("real AgentSession: manual hard-reserve reset stops clean and mixed-tool tu
610
610
  assert.equal(request, 2, "no provider work follows the manual safety reset");
611
611
  return assistant(fixture, mixed ? [
612
612
  { type: "toolCall", id: "pressure-note", name: "notes_write", arguments: { address: "pressure.md", content: "PRESERVED_PRESSURE_NOTE" } },
613
- { type: "toolCall", id: "pressure-wipe", name: "clear_memory", arguments: {} },
613
+ { type: "toolCall", id: "pressure-wipe", name: "neuralyze", arguments: {} },
614
614
  ] : [{ type: "text", text: "close-out complete" }], mixed ? "toolUse" : "stop", { usage: usage(80_000) });
615
615
  },
616
616
  });
617
617
  try {
618
618
  await fixture.session.prompt("HARD_RESERVE_OLD_SENTINEL");
619
- await fixture.session.prompt("/clear-memory");
619
+ await fixture.session.prompt("/neuralyze");
620
620
  await fixture.session.waitForIdle();
621
621
  assert.equal(fixture.requests.length, 2);
622
622
  assert.equal(resetMarkers(fixture).length, 1, "the safety wipe is not repeated at settlement");
@@ -664,7 +664,7 @@ test("real AgentSession: manual safety reset answers queued user input once befo
664
664
  });
665
665
  try {
666
666
  await fixture.session.prompt("QUEUED_SAFETY_OLD_SENTINEL");
667
- await fixture.session.prompt("/clear-memory");
667
+ await fixture.session.prompt("/neuralyze");
668
668
  await fixture.session.waitForIdle();
669
669
  assert.equal(fixture.requests.length, 4, "queued input is answered once after Pi's tool follow-up, then the stop lands");
670
670
  assert.equal(resetMarkers(fixture).length, 1);
@@ -687,7 +687,7 @@ test("real AgentSession: manual overflow wipes and stops even with automatic res
687
687
  });
688
688
  try {
689
689
  await fixture.session.prompt("MANUAL_OVERFLOW_OLD_SENTINEL");
690
- await fixture.session.prompt("/clear-memory");
690
+ await fixture.session.prompt("/neuralyze");
691
691
  await fixture.session.waitForIdle();
692
692
  assert.equal(fixture.requests.length, 2);
693
693
  assert.equal(resetMarkers(fixture).length, 1);
@@ -698,7 +698,7 @@ test("real AgentSession: manual overflow wipes and stops even with automatic res
698
698
  fixture.close();
699
699
  }
700
700
  });
701
- test("real AgentSession: streaming /clear-memory steers a close-out and stops at settlement", { timeout: 20000 }, async () => {
701
+ test("real AgentSession: streaming /neuralyze steers a close-out and stops at settlement", { timeout: 20000 }, async () => {
702
702
  let fixture;
703
703
  let announceStarted;
704
704
  let releaseResponse;
@@ -720,8 +720,8 @@ test("real AgentSession: streaming /clear-memory steers a close-out and stops at
720
720
  try {
721
721
  const running = fixture.session.prompt("STREAMING_WIPE_OLD_SENTINEL");
722
722
  await started;
723
- await fixture.session.prompt("/clear-memory", { streamingBehavior: "steer" });
724
- await fixture.session.prompt("/clear-memory", { streamingBehavior: "followUp" });
723
+ await fixture.session.prompt("/neuralyze", { streamingBehavior: "steer" });
724
+ await fixture.session.prompt("/neuralyze", { streamingBehavior: "followUp" });
725
725
  assert.equal(fixture.notices.filter((notice) => notice.includes("notes first, then it stops")).length, 1, "the user is notified once while output is ongoing");
726
726
  assert.equal(resetMarkers(fixture).length, 0, "the ongoing turn is not interrupted");
727
727
  releaseResponse();
@@ -755,9 +755,9 @@ test("real AgentSession: repeated manual commands share one pending window", { t
755
755
  },
756
756
  });
757
757
  try {
758
- const first = fixture.session.prompt("/clear-memory");
758
+ const first = fixture.session.prompt("/neuralyze");
759
759
  await started;
760
- const second = fixture.session.prompt("/clear-memory");
760
+ const second = fixture.session.prompt("/neuralyze");
761
761
  releaseResponse();
762
762
  await Promise.all([first, second]);
763
763
  await fixture.session.waitForIdle();
@@ -792,7 +792,7 @@ test("real AgentSession: user abort, synthetic aborted response, and generic err
792
792
  },
793
793
  });
794
794
  try {
795
- await fixture.session.prompt("/cm SHOULD_NOT_RUN_AFTER_FAILURE");
795
+ await fixture.session.prompt("/fresh-window SHOULD_NOT_RUN_AFTER_FAILURE");
796
796
  await fixture.session.waitForIdle();
797
797
  assert.equal(resetMarkers(fixture).length, 0, `${mode} does not force a reset`);
798
798
  assert.equal(fixture.sessionManager.getBranch().filter((entry) => entry.type === "compaction").length, 0);
@@ -834,7 +834,7 @@ test("real AgentSession: steering and follow-up queued during a manual reset are
834
834
  },
835
835
  });
836
836
  try {
837
- const command = fixture.session.prompt("/clear-memory");
837
+ const command = fixture.session.prompt("/neuralyze");
838
838
  await started;
839
839
  if (delivery === "steer")
840
840
  fixture.session.steer("QUEUED_DURING_FALLBACK");
@@ -859,7 +859,7 @@ test("real AgentSession: a reset survives all notes-home read failures with an i
859
859
  compactionEnabled: false,
860
860
  notesRootFile: true,
861
861
  script: (request) => request === 1
862
- ? assistant(fixture, [{ type: "toolCall", id: "wipe-notes-failure", name: "clear_memory", arguments: {} }], "toolUse")
862
+ ? assistant(fixture, [{ type: "toolCall", id: "wipe-notes-failure", name: "neuralyze", arguments: {} }], "toolUse")
863
863
  : assistant(fixture, [{ type: "text", text: "resumed despite notes failure" }]),
864
864
  });
865
865
  try {
@@ -903,7 +903,7 @@ test("real AgentSession: reset projection drops legacy message shapes but keeps
903
903
  },
904
904
  script: (request, context) => {
905
905
  if (request === 1)
906
- return assistant(fixture, [{ type: "toolCall", id: "wipe-legacy", name: "clear_memory", arguments: {} }], "toolUse");
906
+ return assistant(fixture, [{ type: "toolCall", id: "wipe-legacy", name: "neuralyze", arguments: {} }], "toolUse");
907
907
  if (request === 2) {
908
908
  const body = text(context);
909
909
  for (const legacy of legacyTexts)
@@ -939,10 +939,10 @@ test("real AgentSession: successive resets and a mixed tool batch cut only after
939
939
  compactionEnabled: false,
940
940
  script: (request) => {
941
941
  if (scenario === "successive" && request < 3)
942
- return assistant(fixture, [{ type: "toolCall", id: `wipe-${request}`, name: "clear_memory", arguments: {} }], "toolUse");
942
+ return assistant(fixture, [{ type: "toolCall", id: `wipe-${request}`, name: "neuralyze", arguments: {} }], "toolUse");
943
943
  if (scenario === "mixed" && request === 1)
944
944
  return assistant(fixture, [
945
- { type: "toolCall", id: "wipe-1", name: "clear_memory", arguments: {} },
945
+ { type: "toolCall", id: "wipe-1", name: "neuralyze", arguments: {} },
946
946
  { type: "toolCall", id: "note-1", name: "notes_write", arguments: { address: "batch.md", content: "MIXED_BATCH_NOTE" } },
947
947
  ], "toolUse");
948
948
  return assistant(fixture, [{ type: "text", text: "fresh completion" }]);
@@ -977,7 +977,7 @@ test("real AgentSession: two retain-none checkpoints survive session-file reopen
977
977
  compactionEnabled: false,
978
978
  sessionDir,
979
979
  script: (request) => request < 3
980
- ? assistant(fixture, [{ type: "toolCall", id: `persisted-wipe-${request}`, name: "clear_memory", arguments: {} }], "toolUse")
980
+ ? assistant(fixture, [{ type: "toolCall", id: `persisted-wipe-${request}`, name: "neuralyze", arguments: {} }], "toolUse")
981
981
  : assistant(fixture, [{ type: "text", text: "second reset window complete" }]),
982
982
  });
983
983
  try {
@@ -1013,7 +1013,7 @@ test("real AgentSession: two retain-none checkpoints survive session-file reopen
1013
1013
  assert.ok(canonical.some((message) => message.role === "compactionSummary"), "the accepted empty-summary wrapper survives reload");
1014
1014
  const system = getCurrentSystemMessage(canonical);
1015
1015
  assert.ok(JSON.stringify(system).includes("Use the tools as requested."), "the complete system prompt survives the checkpoint");
1016
- assert.ok(system?.toolsAdded?.some((tool) => tool.name === "clear_memory"), "the active tool loadout survives reopen");
1016
+ assert.ok(system?.toolsAdded?.some((tool) => tool.name === "neuralyze"), "the active tool loadout survives reopen");
1017
1017
  const reopenedMarkers = branch.filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE);
1018
1018
  const latestMarker = reopenedMarkers.at(-1);
1019
1019
  const previousMarker = reopenedMarkers[0];
@@ -1035,7 +1035,7 @@ test("real AgentSession: steering and follow-up are delivered exactly once in th
1035
1035
  compactionEnabled: false,
1036
1036
  hook: (pi, getSession) => {
1037
1037
  pi.on("tool_call", async (event) => {
1038
- if (event.toolName !== "clear_memory")
1038
+ if (event.toolName !== "neuralyze")
1039
1039
  return;
1040
1040
  if (deliverAs === "steer")
1041
1041
  await getSession().steer("QUEUED_ONCE");
@@ -1044,7 +1044,7 @@ test("real AgentSession: steering and follow-up are delivered exactly once in th
1044
1044
  });
1045
1045
  },
1046
1046
  script: (request) => request === 1
1047
- ? assistant(fixture, [{ type: "toolCall", id: "wipe-queue", name: "clear_memory", arguments: {} }], "toolUse")
1047
+ ? assistant(fixture, [{ type: "toolCall", id: "wipe-queue", name: "neuralyze", arguments: {} }], "toolUse")
1048
1048
  : assistant(fixture, [{ type: "text", text: "queued message handled" }]),
1049
1049
  });
1050
1050
  try {
@@ -1070,7 +1070,7 @@ test("real AgentSession: hidden or missing reset boots refuse to move the bounda
1070
1070
  try {
1071
1071
  await fixture.session.prompt("ROOT_BEFORE_HIDDEN_BOOT");
1072
1072
  await fixture.session.waitForIdle();
1073
- await fixture.session.prompt("/clear-memory");
1073
+ await fixture.session.prompt("/neuralyze");
1074
1074
  await fixture.session.waitForIdle();
1075
1075
  await fixture.session.prompt("VALID_POST_MARKER_WORK");
1076
1076
  await fixture.session.waitForIdle();
@@ -1124,7 +1124,7 @@ test("real AgentSession: the complete system message and a changed tool loadout
1124
1124
  fixture = await openFixture({
1125
1125
  compactionEnabled: false,
1126
1126
  systemPrompt: ["SYSTEM_SECTION_ALPHA", "SYSTEM_SECTION_BETA", "SYSTEM_TOOLS_SECTION", "SYSTEM_LOADOUT_SECTION"].join("\n"),
1127
- tools: ["clear_memory"],
1127
+ tools: ["neuralyze"],
1128
1128
  script: (request, context) => {
1129
1129
  const systemText = JSON.stringify(context.messages.filter((message) => message.role === "system"));
1130
1130
  const currentSystem = getCurrentSystemMessage(context.messages);
@@ -1134,11 +1134,11 @@ test("real AgentSession: the complete system message and a changed tool loadout
1134
1134
  assert.ok(systemText.includes("SYSTEM_TOOLS_SECTION"));
1135
1135
  assert.ok(systemText.includes("SYSTEM_LOADOUT_SECTION"));
1136
1136
  if (request === 1) {
1137
- assert.deepEqual(effectiveToolNames, ["clear_memory"]);
1138
- fixture.session.setActiveToolsByName(["clear_memory", "get_context_remaining"]);
1139
- return assistant(fixture, [{ type: "toolCall", id: "wipe-system", name: "clear_memory", arguments: {} }], "toolUse");
1137
+ assert.deepEqual(effectiveToolNames, ["neuralyze"]);
1138
+ fixture.session.setActiveToolsByName(["neuralyze", "get_context_remaining"]);
1139
+ return assistant(fixture, [{ type: "toolCall", id: "wipe-system", name: "neuralyze", arguments: {} }], "toolUse");
1140
1140
  }
1141
- assert.deepEqual(effectiveToolNames, ["get_context_remaining", "clear_memory"]);
1141
+ assert.deepEqual(effectiveToolNames, ["get_context_remaining", "neuralyze"]);
1142
1142
  assert.ok(JSON.stringify(context.messages).includes(CONTEXT_WINDOW_OPEN_TAG));
1143
1143
  return assistant(fixture, [{ type: "text", text: "all system sections survived" }]);
1144
1144
  },
@@ -1506,7 +1506,7 @@ test("real AgentSession: warning precedes a durable checkpoint, including failed
1506
1506
  content: "CHECKPOINT_SENTINEL",
1507
1507
  } }], "toolUse", { usage: usage(60_000) });
1508
1508
  if (request === 4 && scenario !== "ignored-warning")
1509
- return assistant(fixture, [{ type: "toolCall", id: "wipe-after-checkpoint", name: "clear_memory", arguments: {} }], "toolUse", { usage: usage(60_000) });
1509
+ return assistant(fixture, [{ type: "toolCall", id: "wipe-after-checkpoint", name: "neuralyze", arguments: {} }], "toolUse", { usage: usage(60_000) });
1510
1510
  return assistant(fixture, [{ type: "text", text: scenario === "ignored-warning" ? "warning intentionally ignored" : "checkpoint and wipe complete" }], "stop", { usage: usage(60_000) });
1511
1511
  },
1512
1512
  });