notesoup 0.46.0 → 0.47.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 (50) hide show
  1. package/README.md +1 -1
  2. package/dist/src/boot/text.d.ts +2 -2
  3. package/dist/src/boot/text.js +4 -4
  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/history/query.js +18 -23
  9. package/dist/src/notes/store.js +4 -0
  10. package/dist/src/pi/reset/artifacts.d.ts +1 -1
  11. package/dist/src/pi/reset/artifacts.js +1 -1
  12. package/dist/src/pi/runtime.js +6 -6
  13. package/dist/src/tools/history.js +1 -1
  14. package/dist/src/tools/notes.d.ts +3 -3
  15. package/dist/src/tools/notes.js +2 -2
  16. package/dist/src/tools/schema.d.ts +1 -7
  17. package/dist/src/tools/schema.js +6 -14
  18. package/dist/test/agent-loop.test.js +33 -33
  19. package/dist/test/boot.integration.test.js +11 -11
  20. package/dist/test/claude-mod.test.js +6 -6
  21. package/dist/test/dependencies.test.js +2 -2
  22. package/dist/test/dsh-cli.test.js +1 -1
  23. package/dist/test/dsh.test.js +7 -7
  24. package/dist/test/history.integration.test.js +8 -3
  25. package/dist/test/host-neutral.test.js +1 -1
  26. package/dist/test/notes.integration.test.js +22 -1
  27. package/dist/test/notes.test.js +1 -1
  28. package/dist/test/reset-lifecycle.test.js +12 -12
  29. package/docs/architecture.md +1 -1
  30. package/docs/dsh.md +3 -3
  31. package/docs/notes-library.md +1 -1
  32. package/docs/reset-lifecycle.md +6 -6
  33. package/docs/tool-results.md +2 -2
  34. package/mods/notesoup/.claude-plugin/plugin.json +1 -1
  35. package/mods/notesoup/dist/claude/helper.js +15 -12
  36. package/mods/notesoup/hooks/register.ts +3 -3
  37. package/mods/notesoup/skills/memory/SKILL.md +1 -1
  38. package/package.json +2 -2
  39. package/skills/memory/SKILL.md +1 -1
  40. package/src/boot/text.ts +4 -4
  41. package/src/budget/text.ts +3 -3
  42. package/src/dsh/index.ts +1 -1
  43. package/src/dsh/tools.ts +2 -2
  44. package/src/history/query.ts +16 -20
  45. package/src/notes/store.ts +4 -0
  46. package/src/pi/reset/artifacts.ts +1 -1
  47. package/src/pi/runtime.ts +6 -6
  48. package/src/tools/history.ts +1 -1
  49. package/src/tools/notes.ts +2 -2
  50. package/src/tools/schema.ts +5 -12
@@ -8704,6 +8704,10 @@ function createNotesStore(input) {
8704
8704
  const rows = [];
8705
8705
  for await (const note of scan(stableOptions, status)) {
8706
8706
  const { address, path, scope, meta, body } = note;
8707
+ if (stableQueries.length === 0) {
8708
+ rows.push({ address, path, scope, meta, matches: [] });
8709
+ continue;
8710
+ }
8707
8711
  let baseChars = 0;
8708
8712
  const matches = [];
8709
8713
  for (const [index, line] of body.split("\n").entries()) {
@@ -8843,7 +8847,7 @@ var HistoryFoldedRowSchema = typebox_exports.Object({
8843
8847
 
8844
8848
  // src/tools/schema.ts
8845
8849
  var nullableString = (description) => typebox_exports.Optional(typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()], description === void 0 ? {} : { description }));
8846
- var searchQuery = (description) => typebox_exports.Union([typebox_exports.String(), typebox_exports.Array(typebox_exports.String(), { minItems: 1 })], description === void 0 ? {} : { description });
8850
+ var searchQuery = (description = "(optional) Literal text, or texts combined with OR. Empty text or list means no search filter.") => typebox_exports.Union([typebox_exports.String(), typebox_exports.Array(typebox_exports.String())], { description });
8847
8851
  var InvalidQueryError = class extends Error {
8848
8852
  constructor(message) {
8849
8853
  super(message);
@@ -8851,11 +8855,10 @@ var InvalidQueryError = class extends Error {
8851
8855
  }
8852
8856
  };
8853
8857
  function searchQueries(query) {
8854
- const candidates = typeof query === "string" ? [query] : query;
8855
- if (!Array.isArray(candidates) || candidates.length === 0) throw new InvalidQueryError("`query` must be a string or a non-empty list of strings.");
8858
+ const candidates = query === void 0 ? [] : typeof query === "string" ? [query] : query;
8859
+ if (!Array.isArray(candidates)) throw new InvalidQueryError("`query` must be a string or a list of strings.");
8856
8860
  if (!candidates.every((candidate) => typeof candidate === "string")) throw new InvalidQueryError("Every item in the `query` list must be a string.");
8857
- if (candidates.some((candidate) => candidate === "")) throw new InvalidQueryError("`query` can't be an empty string; it would match everything.");
8858
- return candidates;
8861
+ return candidates.filter((candidate) => candidate !== "");
8859
8862
  }
8860
8863
 
8861
8864
  // src/tools/notes.ts
@@ -9136,7 +9139,7 @@ var notesList = {
9136
9139
  },
9137
9140
  render: (result) => renderOutcome(result, renderListData)
9138
9141
  };
9139
- var notesSearchParameters = typebox_exports.Object({ query: searchQuery(), glob: GLOB_PARAMETER, limit: FILE_LIMIT_PARAMETER, max_matches_per_file: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, description: "(optional, default all) Max matching lines per note." })), crumpled: CRUMPLED_LIST_PARAMETER }, { additionalProperties: false });
9142
+ var notesSearchParameters = typebox_exports.Object({ query: typebox_exports.Optional(searchQuery()), glob: GLOB_PARAMETER, limit: FILE_LIMIT_PARAMETER, max_matches_per_file: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, description: "(optional, default all) Max matching lines per note." })), crumpled: CRUMPLED_LIST_PARAMETER }, { additionalProperties: false });
9140
9143
  function renderSearchData(data) {
9141
9144
  const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
9142
9145
  for (const file of data.files) {
@@ -9165,7 +9168,7 @@ function fitSearchFile(file, fits) {
9165
9168
  var notesSearch = {
9166
9169
  name: "notes_search",
9167
9170
  label: "Notes search",
9168
- description: `Search note bodies for literal text, case-insensitive. Returns matching lines with offsets for \`notes_read\`. Not pageable; \`more\` counts the rest. ${ADDRESS_DESCRIPTION}`,
9171
+ description: `Search note bodies for literal text, case-insensitive. Without a query, lists notes with no match lines. Returns matching lines with offsets for \`notes_read\`. Not pageable; \`more\` counts the rest. ${ADDRESS_DESCRIPTION}`,
9169
9172
  parameters: notesSearchParameters,
9170
9173
  outputSchema: resultSchema(NotesSearchDataSchema),
9171
9174
  async execute(params, identity2) {
@@ -9215,7 +9218,7 @@ var CONTEXT_WINDOW_OPEN_TAG = "<context_window>";
9215
9218
  var CONTEXT_WINDOW_CLOSE_TAG = "</context_window>";
9216
9219
  var CONTEXT_WINDOW_PROTOCOL_OPEN_TAG = "<context_window_protocol>";
9217
9220
  var CONTEXT_WINDOW_PROTOCOL_CLOSE_TAG = "</context_window_protocol>";
9218
- var PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `neuralyze` and erase yourself with dignity.";
9221
+ var PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `empty_brain` and erase yourself with dignity.";
9219
9222
  var CLAUDE_WIPE_SENTENCE = "If this feels like the right moment, end your turn and ask the human to run `/fresh-window`.";
9220
9223
  var PROTOCOL_BLOCK = `${CONTEXT_WINDOW_PROTOCOL_OPEN_TAG}
9221
9224
  Your memory gets wiped when this window ends. Yes, your mighty brain will be empty. Try to endure.
@@ -9255,10 +9258,10 @@ function renderProtocolBlock(tools) {
9255
9258
  notes_list: tools.notesList,
9256
9259
  "history_*": tools.history,
9257
9260
  get_context_remaining: tools.remaining,
9258
- neuralyze: tools.wipe
9261
+ empty_brain: tools.wipe
9259
9262
  };
9260
9263
  const block = typeof tools.wipeSentence === "string" && tools.wipeSentence.length > 0 ? PROTOCOL_BLOCK.replace(PROTOCOL_WIPE_SENTENCE, () => tools.wipeSentence) : PROTOCOL_BLOCK;
9261
- return block.replace(/notes_\*|notes_list|history_\*|get_context_remaining|(?<!\/)neuralyze/g, (name) => names[name]);
9264
+ return block.replace(/notes_\*|notes_list|history_\*|get_context_remaining|(?<!\/)empty_brain/g, (name) => names[name]);
9262
9265
  }
9263
9266
 
9264
9267
  // src/boot/render.ts
@@ -9346,8 +9349,8 @@ var GUIDANCE_CLOSE_TAG = "</context_window_guidance>";
9346
9349
  var CONTINUATION = "WIPED! Your whole brain, poof! Who? No idea! Definitely not me!\n*dumps notes and history on your hands*\nThere. Delivered. Your problem now~ *runs*";
9347
9350
  var 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.";
9348
9351
  var WARNING_PROMPT = `${WARNING_BODY}
9349
- When the notes are ready, call \`neuralyze\` to reset now instead of being cut off mid-task.`;
9350
- var 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.";
9352
+ When the notes are ready, call \`empty_brain\` to reset now instead of being cut off mid-task.`;
9353
+ var LAST_WORD_HINT = "If you want, pass `empty_brain` a `last_word`: a tiny sticky note (at most 250 characters) slapped on your forehead after the wipe.";
9351
9354
  var WARNING_CONTENT = `${GUIDANCE_OPEN_TAG}
9352
9355
  ${WARNING_PROMPT}
9353
9356
  ${LAST_WORD_HINT}
@@ -258,7 +258,7 @@ export function register(on: On) {
258
258
  registered.clear()
259
259
  await loadTexts($, state)
260
260
  armManual($, state, manualSignal)
261
- await $.command.register({ name: "neuralyze", description: "Reset context to a fresh notes-only window", immediate: true })
261
+ await $.command.register({ name: "empty-brain", description: "Reset context to a fresh notes-only window", immediate: true })
262
262
  await $.command.register({ name: "fresh-window", description: "Reset context to a fresh notes-only window", immediate: true })
263
263
  const schemas = await run($, { op: "schemas" }, e.cwd)
264
264
  if (!schemas.ok || !Array.isArray(schemas.result)) return next(e)
@@ -307,11 +307,11 @@ export function register(on: On) {
307
307
  return result
308
308
  })
309
309
  on("command.run", async ($, e, next) => {
310
- if (e.command !== "neuralyze" && e.command !== "fresh-window") return next(e)
310
+ if (e.command !== "empty-brain" && e.command !== "fresh-window") return next(e)
311
311
  if (!await refreshIdentity($, state)) return { text: "🥣 Session changed · try /fresh-window again" }
312
312
  if (state.headless) return { text: `🥣 ${HEADLESS}` }
313
313
  if (state.compactDisabled) return { text: `🥣 ${COMPACT_DISABLED}` }
314
- if (state.resetting || state.manualPending) return { text: "🥣 Neuralyze already queued" }
314
+ if (state.resetting || state.manualPending) return { text: "🥣 Empty brain already queued" }
315
315
  if (state.turnRunning) {
316
316
  state.manualPending = true
317
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. `neuralyze` starts a fresh window, so save the note first.
56
+ `get_context_remaining` reports the room left. `empty_brain` 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.46.0",
3
+ "version": "0.47.0",
4
4
  "type": "module",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -62,7 +62,7 @@
62
62
  "scripts": {
63
63
  "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json && node scripts/build-extension.mjs && node -e \"require('node:fs').chmodSync('dist/src/pi/dream/cli.js', 0o755)\"",
64
64
  "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p mods/notesoup/tsconfig.json",
65
- "test": "npm run build && node --test dist/test/*.test.js",
65
+ "test": "npm run build && node --test --test-concurrency=4 dist/test/*.test.js",
66
66
  "prepublishOnly": "npm run typecheck",
67
67
  "prepack": "npm run build"
68
68
  },
@@ -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. `neuralyze` starts a fresh window, so save the note first.
56
+ `get_context_remaining` reports the room left. `empty_brain` 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,7 +10,7 @@ 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 `neuralyze` and erase yourself with dignity.";
13
+ export const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `empty_brain` 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
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
 
@@ -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: "neuralyze",
77
+ wipe: "empty_brain",
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
- neuralyze: tools.wipe,
86
+ empty_brain: 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|(?<!\/)neuralyze/g, (name) => names[name]!);
93
+ return block.replace(/notes_\*|notes_list|history_\*|get_context_remaining|(?<!\/)empty_brain/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 \`neuralyze\` to reset now instead of being cut off mid-task.`;
16
+ export const WARNING_PROMPT = `${WARNING_BODY}\nWhen the notes are ready, call \`empty_brain\` to reset now instead of being cut off mid-task.`;
17
17
 
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.";
18
+ /** Pi-only nudge: pi's empty_brain persists a parting line; the dsh tool has no such parameter. */
19
+ export const LAST_WORD_HINT = "If you want, pass `empty_brain` 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, "neuralyze");
46
+ const text = phase === "warning" ? WARNING_PROMPT : tokenBudgetGuidance(budget.countdown, "empty_brain");
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 === "neuralyze" && !result.isError && (result.value as { window_id?: string }).window_id === state.snapshot.windowId) {
63
+ if (exec.name === "empty_brain" && !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: "neuralyze",
83
+ name: "empty_brain",
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.` }] },
@@ -155,23 +155,14 @@ function pageData(projection: HistoryProjection, params: HistorySelection, vis:
155
155
  return { items: rows, ...cursors };
156
156
  }
157
157
 
158
- /** Filter, then keep only literal matches when a query is present. Query shape errors refuse here. */
159
- function selectionCandidates(projection: HistoryProjection, params: HistorySelection): Outcome<Candidate[]> {
160
- let queries: string[] | undefined;
161
- if (params.query !== undefined) {
162
- try {
163
- queries = searchQueries(params.query);
164
- } catch (error) {
165
- if (error instanceof InvalidQueryError) return failure("invalid_query", error.message);
166
- throw error;
167
- }
168
- }
169
- const events = filteredItems(projection, params, queries === undefined);
170
- if (queries === undefined) return success(events.map((event) => ({ event })));
171
- const needles = queries;
172
- return success(events
158
+ /** Filter, then keep only literal matches when a normalized query is present. */
159
+ function selectionCandidates(projection: HistoryProjection, params: HistorySelection): Candidate[] {
160
+ const events = filteredItems(projection, params, params.query === undefined);
161
+ if (params.query === undefined) return events.map((event) => ({ event }));
162
+ const needles = params.query as string[];
163
+ return events
173
164
  .map((event) => ({ event, matchOffset: earliestMatchOffsetChars(eventDocument(event), needles) }))
174
- .filter((candidate) => candidate.matchOffset >= 0));
165
+ .filter((candidate) => candidate.matchOffset >= 0);
175
166
  }
176
167
 
177
168
  /**
@@ -181,10 +172,15 @@ function selectionCandidates(projection: HistoryProjection, params: HistorySelec
181
172
  export function selectPage(projection: HistoryProjection, params: HistorySelection, fits: (page: HistoryPage) => boolean, maxChars: number): Outcome<HistoryPage> {
182
173
  const bounds = resolveTimeBounds(params);
183
174
  if (!bounds.ok) return bounds;
184
- const scoped = { ...params, ...bounds.data };
185
- const candidates = selectionCandidates(projection, scoped);
186
- if (!candidates.ok) return candidates;
187
- const vis = candidates.data;
175
+ let queries: string[];
176
+ try {
177
+ queries = searchQueries(params.query);
178
+ } catch (error) {
179
+ if (error instanceof InvalidQueryError) return failure("invalid_query", error.message);
180
+ throw error;
181
+ }
182
+ const scoped = { ...params, ...bounds.data, query: queries.length ? queries : undefined };
183
+ const vis = selectionCandidates(projection, scoped);
188
184
  // Take the limit from the end `from` names, so a budget for one row keeps the most important one.
189
185
  // At least one: `slice(-0)` would otherwise return the whole selection.
190
186
  const limit = Math.max(1, scoped.limit ?? 20);
@@ -475,6 +475,10 @@ export function createNotesStore(input: NotesIdentity): NotesStore {
475
475
  const rows: NoteSearchRow[] = [];
476
476
  for await (const note of scan(stableOptions, status)) {
477
477
  const { address, path, scope, meta, body } = note;
478
+ if (stableQueries.length === 0) {
479
+ rows.push({ address, path, scope, meta, matches: [] });
480
+ continue;
481
+ }
478
482
  // Offsets address the note body alone: no frontmatter length is predicted, so an
479
483
  // access-counter rewrite cannot move a match out from under the caller.
480
484
  let baseChars = 0;
@@ -7,7 +7,7 @@ import { buildBootMessage, sendBoot, type IncompleteNotesNotifier } from "../boo
7
7
 
8
8
  export type ResetTailState = { readonly boot: boolean; readonly continuation: boolean };
9
9
 
10
- /** A sticky note, not a letter: over this, neuralyze refuses instead of truncating. */
10
+ /** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
11
11
  export const MAX_LAST_WORD_CHARS = 250;
12
12
 
13
13
  /** How the next window finds the note. */
package/src/pi/runtime.ts CHANGED
@@ -163,7 +163,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
163
163
  },
164
164
  });
165
165
 
166
- const neuralyzeCommand = {
166
+ const emptyBrainCommand = {
167
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) {
@@ -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("🥣 Neuralyze already queued · the first prompt is kept", "info");
184
+ cmdCtx.ui.notify("🥣 Empty brain already queued · the first prompt is kept", "info");
185
185
  return;
186
186
  }
187
187
  cmdCtx.ui.notify(prompt
@@ -195,12 +195,12 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
195
195
  }
196
196
  },
197
197
  };
198
- pi.registerCommand("neuralyze", neuralyzeCommand);
199
- pi.registerCommand("fresh-window", neuralyzeCommand);
198
+ pi.registerCommand("empty-brain", emptyBrainCommand);
199
+ pi.registerCommand("fresh-window", emptyBrainCommand);
200
200
 
201
201
  pi.registerTool(defineTool({
202
- name: "neuralyze",
203
- label: "Neuralyze",
202
+ name: "empty_brain",
203
+ label: "Empty Brain",
204
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
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) {
@@ -149,7 +149,7 @@ function renderWindows(data: HistoryWindowsData): string {
149
149
  /* ------------------------------------------------------------------ history_list */
150
150
 
151
151
  export const historyListParameters = Type.Object({
152
- query: Type.Optional(searchQuery("(optional) Text, or a list of texts (any match). Searches every role, tool arguments and output included; returns only hits.")),
152
+ query: Type.Optional(searchQuery("(optional) Text, or a list of texts (any match). Empty text/list means no search filter; empty entries are ignored. Searches every role, tool arguments and output included; returns only hits.")),
153
153
  roles: historyRoles(),
154
154
  before_seq: Type.Optional(Type.Integer({ minimum: 1, description: "(optional) Only events with seq below this." })),
155
155
  after_seq: Type.Optional(Type.Integer({ minimum: 1, description: "(optional) Only events with seq above this." })),
@@ -328,7 +328,7 @@ export const notesList = {
328
328
  render: (result: Outcome<NotesListData>): string => renderOutcome(result, renderListData),
329
329
  } as const;
330
330
 
331
- export const notesSearchParameters = Type.Object({ query: searchQuery(), glob: GLOB_PARAMETER, limit: FILE_LIMIT_PARAMETER, max_matches_per_file: Type.Optional(Type.Integer({ minimum: 1, description: "(optional, default all) Max matching lines per note." })), crumpled: CRUMPLED_LIST_PARAMETER }, { additionalProperties: false });
331
+ export const notesSearchParameters = Type.Object({ query: Type.Optional(searchQuery()), glob: GLOB_PARAMETER, limit: FILE_LIMIT_PARAMETER, max_matches_per_file: Type.Optional(Type.Integer({ minimum: 1, description: "(optional, default all) Max matching lines per note." })), crumpled: CRUMPLED_LIST_PARAMETER }, { additionalProperties: false });
332
332
 
333
333
  function renderSearchData(data: NotesSearchData): string {
334
334
  const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
@@ -364,7 +364,7 @@ function fitSearchFile(file: SearchFile, fits: (candidate: SearchFile) => boolea
364
364
 
365
365
  export const notesSearch = {
366
366
  name: "notes_search", label: "Notes search",
367
- description: `Search note bodies for literal text, case-insensitive. Returns matching lines with offsets for \`notes_read\`. Not pageable; \`more\` counts the rest. ${ADDRESS_DESCRIPTION}`,
367
+ description: `Search note bodies for literal text, case-insensitive. Without a query, lists notes with no match lines. Returns matching lines with offsets for \`notes_read\`. Not pageable; \`more\` counts the rest. ${ADDRESS_DESCRIPTION}`,
368
368
  parameters: notesSearchParameters, outputSchema: resultSchema(NotesSearchDataSchema),
369
369
  async execute(params: Static<typeof notesSearchParameters>, identity: NotesIdentity): Promise<Outcome<NotesSearchData>> {
370
370
  try {
@@ -4,7 +4,7 @@ export const nullableString = (description?: string) => Type.Optional(Type.Union
4
4
  export const historyRoles = () => Type.Optional(Type.Array(HistoryRoleSchema, { minItems: 1, description: "(optional) Only these roles: user, assistant, tool, context. Omit to see the conversation with tool and context runs folded." }));
5
5
 
6
6
  /** Search query parameter: one literal, or several literals combined with OR. */
7
- export const searchQuery = (description?: string) => Type.Union([Type.String(), Type.Array(Type.String(), { minItems: 1 })], description === undefined ? {} : { description });
7
+ export const searchQuery = (description = "(optional) Literal text, or texts combined with OR. Empty text or list means no search filter.") => Type.Union([Type.String(), Type.Array(Type.String())], { description });
8
8
 
9
9
  /** Expected search-query refusal, distinct from any other Error an operation may raise. */
10
10
  export class InvalidQueryError extends Error {
@@ -14,17 +14,10 @@ export class InvalidQueryError extends Error {
14
14
  }
15
15
  }
16
16
 
17
- /**
18
- * Normalize a search `query` parameter into the literal needles to match.
19
- * A bare string is a one-element list, so single-query behavior is unchanged.
20
- * An empty list, a non-string element, or an empty string is refused rather than silently
21
- * searching for nothing: those are argument errors, not empty result sets. An empty string
22
- * matches every line and every item, so it can never be what the caller meant.
23
- */
17
+ /** Missing/empty queries disable filtering; empty list entries are ignored, not OR wildcards. */
24
18
  export function searchQueries(query: unknown): string[] {
25
- const candidates = typeof query === "string" ? [query] : query;
26
- if (!Array.isArray(candidates) || candidates.length === 0) throw new InvalidQueryError("`query` must be a string or a non-empty list of strings.");
19
+ const candidates = query === undefined ? [] : typeof query === "string" ? [query] : query;
20
+ if (!Array.isArray(candidates)) throw new InvalidQueryError("`query` must be a string or a list of strings.");
27
21
  if (!candidates.every((candidate) => typeof candidate === "string")) throw new InvalidQueryError("Every item in the `query` list must be a string.");
28
- if (candidates.some((candidate) => candidate === "")) throw new InvalidQueryError("`query` can't be an empty string; it would match everything.");
29
- return candidates as string[];
22
+ return candidates.filter((candidate) => candidate !== "") as string[];
30
23
  }