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
@@ -25,18 +25,18 @@ type ResetState = {
25
25
  }
26
26
  const HEADLESS = "Clear-memory is off in headless (-p / SDK) sessions"
27
27
  const COMPACT_DISABLED = "Clear-memory can't run: compaction is off in this session (DISABLE_COMPACT)"
28
- const THRESHOLDS_UNAVAILABLE = "Context thresholds unavailable · automatic clear-memory skipped"
29
- const SETTINGS_UNAVAILABLE = "Notesoup settings unreadable · using the default clear-memory margins"
28
+ const THRESHOLDS_UNAVAILABLE = "Context thresholds unavailable · automatic flush skipped"
29
+ const SETTINGS_UNAVAILABLE = "Notesoup settings unreadable · using the default flush margins"
30
30
  /** Bounded retries: a transient helper failure must not disable thresholds for a whole window. */
31
31
  const MAX_LIMITS_ATTEMPTS = 3
32
32
  const RESET_INSTRUCTIONS = "notesoup: reset to a fresh notes-only context window."
33
33
  const BOOT_TOOLS = {
34
34
  notes: `${PREFIX}notes_*`, notesList: `${PREFIX}notes_list`,
35
35
  history: "history_* (unavailable in Claude)",
36
- remaining: "get_context_remaining (unavailable in Claude)", wipe: "/clear-memory (user command; no model reset tool in Claude)",
36
+ remaining: "get_context_remaining (unavailable in Claude)", wipe: "/fresh-window (user command; no model reset tool in Claude)",
37
37
  }
38
38
 
39
- /** The boot names the host's own wipe path, so the protocol block speaks about `/clear-memory`. */
39
+ /** The boot names the host's own wipe path, so the protocol block speaks about `/fresh-window`. */
40
40
  async function buildBoot($: Engine, identity: Identity, window: number, texts?: SharedTexts) {
41
41
  const tools = texts?.wipeSentence === undefined ? BOOT_TOOLS : { ...BOOT_TOOLS, wipeSentence: texts.wipeSentence }
42
42
  return run($, { op: "boot", identity, window, tools }, identity.cwd)
@@ -102,7 +102,7 @@ async function contextUsage($: Engine, state: ResetState): Promise<ContextUsage
102
102
  } catch {
103
103
  if (!state.usageFailureLogged) {
104
104
  state.usageFailureLogged = true
105
- log($, "Context usage unavailable · automatic clear-memory skipped")
105
+ log($, "Context usage unavailable · automatic flush skipped")
106
106
  }
107
107
  return undefined
108
108
  }
@@ -258,7 +258,8 @@ export function register(on: On) {
258
258
  registered.clear()
259
259
  await loadTexts($, state)
260
260
  armManual($, state, manualSignal)
261
- await $.command.register({ name: "clear-memory", description: "Reset context to a fresh notes-only window", immediate: true })
261
+ await $.command.register({ name: "neuralyze", description: "Reset context to a fresh notes-only window", immediate: true })
262
+ await $.command.register({ name: "fresh-window", description: "Reset context to a fresh notes-only window", immediate: true })
262
263
  const schemas = await run($, { op: "schemas" }, e.cwd)
263
264
  if (!schemas.ok || !Array.isArray(schemas.result)) return next(e)
264
265
  for (const row of schemas.result as SchemaRow[]) {
@@ -306,11 +307,11 @@ export function register(on: On) {
306
307
  return result
307
308
  })
308
309
  on("command.run", async ($, e, next) => {
309
- if (e.command !== "clear-memory") return next(e)
310
- if (!await refreshIdentity($, state)) return { text: "🥣 Session changed · try clear-memory again" }
310
+ if (e.command !== "neuralyze" && e.command !== "fresh-window") return next(e)
311
+ if (!await refreshIdentity($, state)) return { text: "🥣 Session changed · try /fresh-window again" }
311
312
  if (state.headless) return { text: `🥣 ${HEADLESS}` }
312
313
  if (state.compactDisabled) return { text: `🥣 ${COMPACT_DISABLED}` }
313
- if (state.resetting || state.manualPending) return { text: "🥣 Clear-memory already queued" }
314
+ if (state.resetting || state.manualPending) return { text: "🥣 Neuralyze already queued" }
314
315
  if (state.turnRunning) {
315
316
  state.manualPending = true
316
317
  return { text: "🥣 Clear-memory queued · runs after this turn" }
@@ -53,7 +53,7 @@ Before a long or risky step, or when room runs low, keep session notes named for
53
53
  - how the work was being done, and which skills are still needed
54
54
  - where to dig: seqs, note addresses, files
55
55
 
56
- `get_context_remaining` reports the room left. `clear_memory` starts a fresh window, so save the note first.
56
+ `get_context_remaining` reports the room left. `neuralyze` starts a fresh window, so save the note first.
57
57
 
58
58
  ## When a tool is missing or refuses
59
59
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.45.2",
3
+ "version": "0.46.0",
4
4
  "type": "module",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -53,7 +53,7 @@ Before a long or risky step, or when room runs low, keep session notes named for
53
53
  - how the work was being done, and which skills are still needed
54
54
  - where to dig: seqs, note addresses, files
55
55
 
56
- `get_context_remaining` reports the room left. `clear_memory` starts a fresh window, so save the note first.
56
+ `get_context_remaining` reports the room left. `neuralyze` starts a fresh window, so save the note first.
57
57
 
58
58
  ## When a tool is missing or refuses
59
59
 
package/src/boot/text.ts CHANGED
@@ -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
  /**
18
18
  * Static protocol teaching adapted from Codex's token_budget.guidance_message to
@@ -74,7 +74,7 @@ export const DEFAULT_BOOT_TOOL_NAMES = {
74
74
  notesList: "notes_list",
75
75
  history: "history_*",
76
76
  remaining: "get_context_remaining",
77
- wipe: "clear_memory",
77
+ wipe: "neuralyze",
78
78
  } as const satisfies BootToolNames;
79
79
 
80
80
  export function renderProtocolBlock(tools: BootToolNames): string {
@@ -83,12 +83,12 @@ export function renderProtocolBlock(tools: BootToolNames): string {
83
83
  notes_list: tools.notesList,
84
84
  "history_*": tools.history,
85
85
  get_context_remaining: tools.remaining,
86
- clear_memory: tools.wipe,
86
+ neuralyze: tools.wipe,
87
87
  };
88
88
  // The sentence is replaced before name substitution, so a replacement may speak the host's
89
89
  // own words (a command line, a tool name) instead of any `notes_*`-style token.
90
90
  const block = typeof tools.wipeSentence === "string" && tools.wipeSentence.length > 0
91
91
  ? PROTOCOL_BLOCK.replace(PROTOCOL_WIPE_SENTENCE, () => tools.wipeSentence!)
92
92
  : PROTOCOL_BLOCK;
93
- return block.replace(/notes_\*|notes_list|history_\*|get_context_remaining|clear_memory/g, (name) => names[name]!);
93
+ return block.replace(/notes_\*|notes_list|history_\*|get_context_remaining|(?<!\/)neuralyze/g, (name) => names[name]!);
94
94
  }
@@ -13,10 +13,10 @@ export const CONTINUATION = "WIPED! Your whole brain, poof! Who? No idea! Defini
13
13
  export const WARNING_BODY =
14
14
  "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.";
15
15
 
16
- export const WARNING_PROMPT = `${WARNING_BODY}\nWhen the notes are ready, call \`clear_memory\` to reset now instead of being cut off mid-task.`;
16
+ export const WARNING_PROMPT = `${WARNING_BODY}\nWhen the notes are ready, call \`neuralyze\` to reset now instead of being cut off mid-task.`;
17
17
 
18
- /** Pi-only nudge: pi's clear_memory persists a parting line; the dsh tool has no such parameter. */
19
- export const LAST_WORD_HINT = "If you want, pass `clear_memory` a `last_word`: one short line left visible where this window closes.";
18
+ /** Pi-only nudge: pi's neuralyze persists a parting line; the dsh tool has no such parameter. */
19
+ 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.";
20
20
 
21
21
  /** The hidden checkpoint text for pi's manual/budget-triggered requests (dsh reads WARNING_PROMPT directly). */
22
22
  export const WARNING_CONTENT = `${GUIDANCE_OPEN_TAG}\n${WARNING_PROMPT}\n${LAST_WORD_HINT}\n${GUIDANCE_CLOSE_TAG}`;
package/src/dsh/index.ts CHANGED
@@ -43,7 +43,7 @@ export function apply(ctx: Context): void {
43
43
  const state = engine.windows.get(agent.session);
44
44
  const phase = budget.remaining <= budget.warning ? "warning" : budget.remaining <= budget.reminder ? "reminder" : undefined;
45
45
  if (phase && !(phase === "warning" ? state.warned : state.reminded || state.warned)) {
46
- const text = phase === "warning" ? WARNING_PROMPT : tokenBudgetGuidance(budget.countdown, "clear_memory");
46
+ const text = phase === "warning" ? WARNING_PROMPT : tokenBudgetGuidance(budget.countdown, "neuralyze");
47
47
  agent.steer(createUserMessage({ content: [{ type: "text", text }], source: { kind: "notesoup-budget", windowId: state.snapshot.windowId, phase } }));
48
48
  if (phase === "warning") state.warned = true;
49
49
  else state.reminded = true;
package/src/dsh/tools.ts CHANGED
@@ -60,7 +60,7 @@ export function registerTools(ctx: Context, engine: NotesoupCompactionEngine): v
60
60
  ctx.on("tools/result", (exec, result) => {
61
61
  if (!exec.agent) return;
62
62
  const state = engine.windows.get(exec.agent.session);
63
- if (exec.name === "clear_memory" && !result.isError && (result.value as { window_id?: string }).window_id === state.snapshot.windowId) {
63
+ if (exec.name === "neuralyze" && !result.isError && (result.value as { window_id?: string }).window_id === state.snapshot.windowId) {
64
64
  if (!exec.parent) state.pendingReset = true;
65
65
  else {
66
66
  const roots = nestedResets.get(exec.agent) ?? new Set<string>();
@@ -80,7 +80,7 @@ export function registerTools(ctx: Context, engine: NotesoupCompactionEngine): v
80
80
  register(ctx, historyRead, async (agent) => [await historyProjection(ctx, agent.session.id)] as const);
81
81
  register(ctx, historyWindows, async (agent) => [await historyProjection(ctx, agent.session.id), agent.session.id] as const);
82
82
  ctx.tools.register(defineTool({
83
- name: "clear_memory",
83
+ name: "neuralyze",
84
84
  description: "Open a fresh context window after this tool batch. Write recovery notes first; notes and raw history stay on disk.",
85
85
  parameters: {},
86
86
  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.` }] },
@@ -7,15 +7,15 @@ import { buildBootMessage, sendBoot, type IncompleteNotesNotifier } from "../boo
7
7
 
8
8
  export type ResetTailState = { readonly boot: boolean; readonly continuation: boolean };
9
9
 
10
- /** Cap for the parting line: one visible line, not an essay. */
11
- export const MAX_LAST_WORD_CHARS = 500;
10
+ /** A sticky note, not a letter: over this, neuralyze refuses instead of truncating. */
11
+ export const MAX_LAST_WORD_CHARS = 250;
12
12
 
13
- /** Trim and cap a parting line; blank input leaves no last word. */
13
+ /** How the next window finds the note. */
14
+ export const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
15
+
16
+ /** Trim a parting line; blank input leaves no last word. Length is checked by the caller. */
14
17
  export function sanitizeLastWord(raw: string | undefined): string | undefined {
15
- const trimmed = raw?.trim();
16
- if (!trimmed) return undefined;
17
- const chars = Array.from(trimmed);
18
- return chars.length > MAX_LAST_WORD_CHARS ? `${chars.slice(0, MAX_LAST_WORD_CHARS).join("")}…` : trimmed;
18
+ return raw?.trim() || undefined;
19
19
  }
20
20
 
21
21
  /** Match the hidden continuation entry that carries the one reset message. */
@@ -58,7 +58,7 @@ export async function buildResetDrafts(
58
58
  { type: "custom", customType: RESET_MARKER_TYPE, data: { windowId } },
59
59
  { type: "custom_message", customType: BOOT_TYPE, content: boot.content, display: false, details: { windowId } },
60
60
  { type: "custom_message", customType: CONTINUATION_TYPE, content: CONTINUATION, display: false },
61
- ...(lastWord ? [{ type: "custom_message" as const, customType: RESET_LAST_WORD_TYPE, content: lastWord, display: true }] : []),
61
+ ...(lastWord ? [{ type: "custom_message" as const, customType: RESET_LAST_WORD_TYPE, content: `${LAST_WORD_PREFIX}${lastWord}`, display: true }] : []),
62
62
  ...(prompt ? [{ type: "custom_message" as const, customType: RESET_PROMPT_TYPE, content: prompt, display: true }] : []),
63
63
  ];
64
64
  }
@@ -323,7 +323,7 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
323
323
  const markerExists = currentReset(ctx) !== undefined;
324
324
  if (options.isEnabled() || markerExists) {
325
325
  if (event.reason === "manual") {
326
- ctx.ui.notify("🥣 /compact is off while notesoup is on · use /clear-memory", "warning");
326
+ ctx.ui.notify("🥣 /compact is off while notesoup is on · use /fresh-window", "warning");
327
327
  }
328
328
  return { cancel: true };
329
329
  }
package/src/pi/runtime.ts CHANGED
@@ -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, type WindowMarker } 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, type IncompleteNotesNotifier } from "./boot.js";
@@ -128,7 +128,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
128
128
  } catch (error) {
129
129
  if (missingBootNotice !== windowId) {
130
130
  missingBootNotice = windowId;
131
- ctx.ui.notify("🥣 Request cancelled · this memory window is broken, run /clear-memory", "error");
131
+ ctx.ui.notify("🥣 Request cancelled · this memory window is broken, run /fresh-window", "error");
132
132
  }
133
133
  ctx.abort();
134
134
  const safeHead = getCurrentSystemMessage(event.messages);
@@ -163,8 +163,8 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
163
163
  },
164
164
  });
165
165
 
166
- const clearMemoryCommand = {
167
- description: "Close out notes and clear memory; optionally append a prompt to continue in the fresh window",
166
+ const neuralyzeCommand = {
167
+ description: "Flush memory to notes and continue in a fresh window; optional prompt runs there",
168
168
  handler: async (args: string, cmdCtx: ExtensionCommandContext) => {
169
169
  if (!enabled) {
170
170
  cmdCtx.ui.notify("🥣 notesoup is off · run /notesoup on first", "error");
@@ -181,7 +181,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
181
181
  const prompt = args.trim() || undefined;
182
182
  const armed = resets.closeOut(requestedWindowId, "manual", prompt);
183
183
  if (armed === "already-pending") {
184
- cmdCtx.ui.notify("🥣 Clear-memory already queued · the first prompt is kept", "info");
184
+ cmdCtx.ui.notify("🥣 Neuralyze already queued · the first prompt is kept", "info");
185
185
  return;
186
186
  }
187
187
  cmdCtx.ui.notify(prompt
@@ -191,21 +191,24 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
191
191
  pi.sendMessage({ customType: MANUAL_WIPE_TYPE, content: WARNING_CONTENT, display: false }, { triggerTurn: true, deliverAs: "steer" });
192
192
  } catch (error) {
193
193
  resets.clear();
194
- cmdCtx.ui.notify(`🥣 Couldn't start clear-memory: ${errorMessage(error)}`, "error");
194
+ cmdCtx.ui.notify(`🥣 Couldn't start /fresh-window: ${errorMessage(error)}`, "error");
195
195
  }
196
196
  },
197
197
  };
198
- pi.registerCommand("clear-memory", clearMemoryCommand);
199
- pi.registerCommand("cm", clearMemoryCommand);
198
+ pi.registerCommand("neuralyze", neuralyzeCommand);
199
+ pi.registerCommand("fresh-window", neuralyzeCommand);
200
200
 
201
201
  pi.registerTool(defineTool({
202
- name: "clear_memory",
203
- label: "Clear memory",
204
- 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.",
205
- 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 }),
202
+ name: "neuralyze",
203
+ label: "Neuralyze",
204
+ 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.",
205
+ 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 }),
206
206
  async execute(_id, params, _signal, _update, ctx) {
207
207
  if (!enabled) return output({ error: "notesoup is off, so memory can't be cleared; the user can turn it on with `/notesoup on`." });
208
- return output({ status: resets.request(currentWindowId(ctx), sanitizeLastWord(params.last_word)) }, undefined, true);
208
+ const lastWord = sanitizeLastWord(params.last_word);
209
+ const length = lastWord ? Array.from(lastWord).length : 0;
210
+ if (length > MAX_LAST_WORD_CHARS) return output({ error: `last_word is ${length} characters; the sticky note holds ${MAX_LAST_WORD_CHARS}. Shorten it and call again.` });
211
+ return output({ status: resets.request(currentWindowId(ctx), lastWord) }, undefined, true);
209
212
  },
210
213
  }));
211
214