notesoup 0.45.2 → 0.46.1

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 (53) 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/history/query.js +18 -23
  9. package/dist/src/notes/store.js +4 -0
  10. package/dist/src/pi/reset/artifacts.d.ts +5 -3
  11. package/dist/src/pi/reset/artifacts.js +7 -9
  12. package/dist/src/pi/reset/lifecycle.js +1 -1
  13. package/dist/src/pi/runtime.js +17 -13
  14. package/dist/src/tools/history.js +1 -1
  15. package/dist/src/tools/notes.d.ts +3 -3
  16. package/dist/src/tools/notes.js +2 -2
  17. package/dist/src/tools/schema.d.ts +1 -7
  18. package/dist/src/tools/schema.js +6 -14
  19. package/dist/test/agent-loop.test.js +37 -37
  20. package/dist/test/boot.integration.test.js +11 -11
  21. package/dist/test/claude-mod.test.js +8 -8
  22. package/dist/test/dependencies.test.js +2 -2
  23. package/dist/test/dsh-cli.test.js +1 -1
  24. package/dist/test/dsh.test.js +7 -7
  25. package/dist/test/history.integration.test.js +8 -3
  26. package/dist/test/host-neutral.test.js +1 -1
  27. package/dist/test/notes.integration.test.js +22 -1
  28. package/dist/test/notes.test.js +1 -1
  29. package/dist/test/reset-lifecycle.test.js +19 -14
  30. package/docs/architecture.md +3 -3
  31. package/docs/claude-code-mod.md +3 -3
  32. package/docs/dsh.md +3 -3
  33. package/docs/notes-library.md +1 -1
  34. package/docs/reset-lifecycle.md +7 -7
  35. package/docs/tool-results.md +2 -2
  36. package/mods/notesoup/.claude-plugin/plugin.json +1 -1
  37. package/mods/notesoup/dist/claude/helper.js +16 -13
  38. package/mods/notesoup/hooks/register.ts +10 -9
  39. package/mods/notesoup/skills/memory/SKILL.md +1 -1
  40. package/package.json +1 -1
  41. package/skills/memory/SKILL.md +1 -1
  42. package/src/boot/text.ts +5 -5
  43. package/src/budget/text.ts +3 -3
  44. package/src/dsh/index.ts +1 -1
  45. package/src/dsh/tools.ts +2 -2
  46. package/src/history/query.ts +16 -20
  47. package/src/notes/store.ts +4 -0
  48. package/src/pi/reset/artifacts.ts +8 -8
  49. package/src/pi/reset/lifecycle.ts +1 -1
  50. package/src/pi/runtime.ts +16 -13
  51. package/src/tools/history.ts +1 -1
  52. package/src/tools/notes.ts +2 -2
  53. package/src/tools/schema.ts +5 -12
@@ -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,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
 
@@ -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
  }