notesoup 0.58.2 → 0.59.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 (62) hide show
  1. package/README.md +2 -1
  2. package/dist/plugins/claude/src/helper.js +13 -0
  3. package/dist/plugins/claude/src/thresholds.js +17 -12
  4. package/dist/plugins/pi/budget.d.ts +3 -0
  5. package/dist/plugins/pi/budget.js +22 -11
  6. package/dist/plugins/pi/runtime.js +22 -6
  7. package/dist/src/boot/text.d.ts +1 -1
  8. package/dist/src/boot/text.js +5 -4
  9. package/dist/src/budget/cap.d.ts +2 -0
  10. package/dist/src/budget/cap.js +11 -0
  11. package/dist/src/notes/policy.d.ts +1 -1
  12. package/dist/src/notes/policy.js +4 -3
  13. package/dist/src/tools/notes.js +1 -1
  14. package/dist/test/agent-loop.test.js +13 -39
  15. package/dist/test/boot.integration.test.js +20 -18
  16. package/dist/test/budget-settings.integration.test.js +63 -14
  17. package/dist/test/claude-history.test.js +1 -2
  18. package/dist/test/claude-mod.test.js +96 -29
  19. package/dist/test/codex-history.test.js +9 -6
  20. package/dist/test/codex-plugin.test.js +4 -8
  21. package/dist/test/dream-skill.test.js +6 -10
  22. package/dist/test/dsh-cli.test.js +2 -3
  23. package/dist/test/dsh.test.js +1 -7
  24. package/dist/test/helpers/extension.js +3 -1
  25. package/dist/test/history-corpus.test.js +2 -3
  26. package/dist/test/history-prefilter.test.js +33 -40
  27. package/dist/test/history-summary-cache.test.js +1 -1
  28. package/dist/test/history.integration.test.js +11 -37
  29. package/dist/test/host-neutral.test.js +2 -2
  30. package/dist/test/marker.test.js +1 -2
  31. package/dist/test/model-facing-text.test.js +20 -187
  32. package/dist/test/note-policy.test.js +40 -22
  33. package/dist/test/notes-library.test.js +2 -2
  34. package/dist/test/notes.integration.test.js +36 -149
  35. package/dist/test/notes.test.js +13 -61
  36. package/dist/test/pi-render.test.js +23 -62
  37. package/dist/test/reset-lifecycle.test.js +4 -9
  38. package/docs/architecture.md +1 -1
  39. package/docs/claude-code-mod.md +5 -3
  40. package/docs/dsh.md +1 -1
  41. package/docs/notes-library.md +1 -1
  42. package/docs/reset-lifecycle.md +3 -1
  43. package/docs/tool-results.md +1 -1
  44. package/package.json +1 -1
  45. package/playbook.md +1 -1
  46. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  47. package/plugins/claude/dist/claude/helper.js +47 -17
  48. package/plugins/claude/hooks/register.ts +51 -5
  49. package/plugins/claude/playbook.md +1 -1
  50. package/plugins/claude/skills/dream/SKILL.md +1 -1
  51. package/plugins/claude/skills/memory/SKILL.md +1 -1
  52. package/plugins/claude/src/helper.ts +11 -0
  53. package/plugins/claude/src/thresholds.ts +18 -11
  54. package/plugins/codex/dist/codex/notesoup.js +10 -8
  55. package/plugins/pi/budget.ts +21 -11
  56. package/plugins/pi/runtime.ts +18 -6
  57. package/skills/dream/SKILL.md +1 -1
  58. package/skills/memory/SKILL.md +1 -1
  59. package/src/boot/text.ts +5 -4
  60. package/src/budget/cap.ts +9 -0
  61. package/src/notes/policy.ts +4 -3
  62. package/src/tools/notes.ts +1 -1
@@ -17,6 +17,7 @@ import { buildBootMessage, sendBoot, type IncompleteNotesNotifier } from "./boot
17
17
  import { maybeSendMarker } from "./marker.js";
18
18
  import { nextHistorySeq } from "./history.js";
19
19
  import { errorMessage } from "../../src/error-message.js";
20
+ import { parseContextCap } from "../../src/budget/cap.js";
20
21
 
21
22
  function readPackageVersion(): string {
22
23
  for (const up of ["../../package.json", "../../../package.json"]) {
@@ -152,12 +153,23 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
152
153
  });
153
154
 
154
155
  pi.registerCommand("notesoup", {
155
- description: "Show loaded version/build and toggle notesoup context windows",
156
+ description: "Show notesoup status, toggle context windows, or cap their capacity",
156
157
  getArgumentCompletions: (prefix) =>
157
- ["on", "off"].filter((a) => a.startsWith(prefix)).map((a) => ({ value: a, label: a })),
158
+ ["on", "off", "cap", "cap off"].filter((a) => a.startsWith(prefix)).map((a) => ({ value: a, label: a })),
158
159
  handler: async (args, cmdCtx) => {
159
160
  const arg = args.trim().toLowerCase();
160
- if (arg === "on") {
161
+ const parts = arg.split(/\s+/);
162
+ if (parts[0] === "cap") {
163
+ if (parts.length > 1) {
164
+ const value = parts.length === 2 ? parseContextCap(parts[1]!) : undefined;
165
+ if (value === undefined) {
166
+ cmdCtx.ui.notify("Usage: /notesoup cap [100k|1m|tokens|off]", "error");
167
+ return;
168
+ }
169
+ const error = budget.setCap(value ?? undefined, cmdCtx);
170
+ if (error) { cmdCtx.ui.notify(`🥣 ${error}`, "error"); return; }
171
+ }
172
+ } else if (arg === "on") {
161
173
  enabled = true;
162
174
  const generation = ++lifecycleGeneration;
163
175
  await ensureBoot(pi, cmdCtx, notifyIncompleteNotes, () => generation === lifecycleGeneration && enabled);
@@ -170,11 +182,11 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
170
182
  budget.clear();
171
183
  resets.clear();
172
184
  } else if (arg !== "") {
173
- cmdCtx.ui.notify("Usage: /notesoup [on|off]", "error");
185
+ cmdCtx.ui.notify("Usage: /notesoup [on|off|cap [100k|1m|tokens|off]]", "error");
174
186
  return;
175
187
  }
176
- const remaining = budget.statusFor(cmdCtx).remaining;
177
- cmdCtx.ui.notify(`🥣 notesoup ${enabled ? "on" : "off"} · ${buildLabel} · Pi ${VERSION}${remaining === null ? "" : ` · ${remaining.toLocaleString("en-US")} tokens left`}`, "info");
188
+ const { remaining, cap } = budget.statusFor(cmdCtx);
189
+ cmdCtx.ui.notify(`🥣 notesoup ${enabled ? "on" : "off"} · ${buildLabel} · Pi ${VERSION} · cap ${cap === undefined ? "off" : cap.toLocaleString("en-US")}${remaining === null ? "" : ` · ${remaining.toLocaleString("en-US")} tokens left`}`, "info");
178
190
  },
179
191
  });
180
192
 
@@ -5,7 +5,7 @@ description: Review and consolidate durable notes using notesoup's shared dream
5
5
 
6
6
  # Dream
7
7
 
8
- Read `../../playbook.md` completely, resolving the path from this skill's directory. It is the shared guide to reviewing and organizing notes. Standing reminders belong in a separate `CHEATSHEET.md` (five lines); `MAP.md` holds only the note index. Both default to pinned and load every window when live unless explicitly unpinned. Every note defaults to a 2048-code-point advisory budget, adjustable per note; pinned bodies load whole with overflow warnings. Respect soft readonly locks; explicitly unlock with `readonly:false` before changing a locked note.
8
+ Read `../../playbook.md` completely, resolving the path from this skill's directory. It is the shared guide to reviewing and organizing notes. Standing reminders belong in a separate `CHEATSHEET.md` (five lines); `MAP.md` holds only the note index. Both default to pinned and load every window when live unless explicitly unpinned. Ordinary notes default to a 4096-code-point advisory budget (2048 for root `CHEATSHEET.md` and `MAP.md`), adjustable per note; pinned bodies load whole with overflow warnings. Respect soft readonly locks; explicitly unlock with `readonly:false` before changing a locked note.
9
9
 
10
10
  Dream in this agent's current session. Do not start another agent or model unless the human asks.
11
11
 
@@ -32,7 +32,7 @@ Any other `@` prefix is refused. A path is relative and `/`-separated, with no e
32
32
 
33
33
  `@` addresses are not file paths: never pass them to file tools like `read`, `write`, `edit`, or `bash`. That creates a stray directory instead of a note.
34
34
 
35
- `CHEATSHEET.md` and `MAP.md` at each notebook's root are separate default-pinned pages you wake up with; absent or crumpled pages are skipped. Set `pinned`, `budget`, and `readonly` through `notes_write`/`notes_update` or frontmatter. Explicit `pinned:false` unpins even a default page. Each notebook allows five live pins; every page defaults to a 2048-code-point advisory budget, adjustable per note. Overflow warns but saves, and pinned bodies load whole. `readonly:true` is a soft lock, not security; explicitly set `readonly:false` to unlock, alone or alongside your changes. Keep standing reminders in `CHEATSHEET.md`, to five lines. `MAP.md` holds only the note index: each durable note's address and gist, for lookup. Update it whenever you add, move or crumple a durable note. Do not create empty pages.
35
+ `CHEATSHEET.md` and `MAP.md` at each notebook's root are separate default-pinned pages you wake up with; absent or crumpled pages are skipped. Set `pinned`, `budget`, and `readonly` through `notes_write`/`notes_update` or frontmatter. Explicit `pinned:false` unpins even a default page. Each notebook allows five live pins; ordinary pages default to a 4096-code-point advisory budget (2048 for root `CHEATSHEET.md` and `MAP.md`), adjustable per note. Overflow warns but saves, and pinned bodies load whole. `readonly:true` is a soft lock, not security; explicitly set `readonly:false` to unlock, alone or alongside your changes. Keep standing reminders in `CHEATSHEET.md`, to five lines. `MAP.md` holds only the note index: each durable note's address and gist, for lookup. Update it whenever you add, move or crumple a durable note. Do not create empty pages.
36
36
 
37
37
  Keep notes focused on what is true now; if a piece of past context still matters (such as why an approach was ruled out), keep only a brief summary rather than a blow-by-blow log. Crumple notes that are no longer true; a stale note is worse than none.
38
38
 
package/src/boot/text.ts CHANGED
@@ -64,10 +64,11 @@ Pinned pages get jammed straight into your brain the moment you wake up. Whoever
64
64
  reads them, and next is you. So keep them short, and keep them true.
65
65
 
66
66
  Set \`pinned\`, \`budget\`, and \`readonly\` with the note tools or frontmatter. Each notebook allows five
67
- live pins, including the defaults; \`pinned:false\` unpins even a default page. Every page's budget
68
- starts at 2048 Unicode code points; set a positive integer to change it. Going over warns but saves,
69
- and pinned bodies arrive whole, not cut short. \`readonly:true\` is a soft lock, not security;
70
- explicitly set \`readonly:false\` to unlock, on its own or with your changes.
67
+ live pins, including the defaults; \`pinned:false\` unpins even a default page. Budgets start at 4096
68
+ Unicode code points, or 2048 for root \`CHEATSHEET.md\` and \`MAP.md\`; set a positive integer to
69
+ change one. Going over warns but saves, and pinned bodies arrive whole, not cut short.
70
+ \`readonly:true\` is a soft lock, not security; explicitly set \`readonly:false\` to unlock,
71
+ on its own or with your changes.
71
72
 
72
73
  - **\`CHEATSHEET.md\`** holds what you'll want next time — a rule, a warning, a grudge, a name,
73
74
  a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat
@@ -0,0 +1,9 @@
1
+ /** Parse a slash-command cap: decimal k/m suffixes, whole tokens, or off. */
2
+ export function parseContextCap(value: string): number | null | undefined {
3
+ const text = value.trim().toLowerCase();
4
+ if (text === "off") return null;
5
+ const match = /^(\d+(?:\.\d+)?)([km]?)$/.exec(text);
6
+ if (!match) return undefined;
7
+ const tokens = Number(match[1]) * (match[2] === "m" ? 1_000_000 : match[2] === "k" ? 1_000 : 1);
8
+ return Number.isSafeInteger(tokens) && tokens > 0 ? tokens : undefined;
9
+ }
@@ -2,7 +2,7 @@ import { NoteError } from "./errors.js";
2
2
 
3
3
  export type NotePolicyFields = { pinned?: boolean; budget?: number; readonly?: boolean };
4
4
  export type NotePolicy = Required<NotePolicyFields>;
5
- export const DEFAULT_NOTE_BUDGET = 2048;
5
+ export const DEFAULT_NOTE_BUDGET = 4096;
6
6
  export const MAX_PINNED_NOTES = 5;
7
7
  /** Defaults and ordering live here; no other layer assigns behavior by page name. */
8
8
  const DEFAULT_PINNED_PAGES = ["CHEATSHEET.md", "MAP.md"] as const;
@@ -19,9 +19,10 @@ export function validateNotePolicy(fields: NotePolicyFields): void {
19
19
  /** Only root default pages are pinned implicitly; an explicit false always wins. */
20
20
  export function effectiveNotePolicy(fields: NotePolicyFields, path: string): NotePolicy {
21
21
  validateNotePolicy(fields);
22
+ const defaultPage = DEFAULT_PINNED_PAGES.some(page => page === path);
22
23
  return {
23
- pinned: fields.pinned ?? DEFAULT_PINNED_PAGES.some(page => page === path),
24
- budget: fields.budget ?? DEFAULT_NOTE_BUDGET,
24
+ pinned: fields.pinned ?? defaultPage,
25
+ budget: fields.budget ?? (defaultPage ? 2048 : DEFAULT_NOTE_BUDGET),
25
26
  readonly: fields.readonly ?? false,
26
27
  };
27
28
  }
@@ -19,7 +19,7 @@ const ORIGIN = Type.Optional(Type.Union([...ORIGIN_VALUES], {
19
19
  }));
20
20
  const POLICY_PARAMETERS = {
21
21
  pinned: Type.Optional(Type.Boolean({ description: "Inject the full body at boot. At most 5 live pins per notebook; root CHEATSHEET.md/MAP.md default true, all others false. Explicit false overrides the default." })),
22
- budget: Type.Optional(Type.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER, description: "Body budget in Unicode code points (default 2048 for every note). Over budget warns but saves; boot does not truncate." })),
22
+ budget: Type.Optional(Type.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER, description: "Body budget in Unicode code points (default 4096; root CHEATSHEET.md and MAP.md default 2048). Over budget warns but saves; boot does not truncate." })),
23
23
  readonly: Type.Optional(Type.Boolean({ description: "Soft lock, not a security boundary. true locks changes; explicitly pass false to unlock, including in the same call as edits or overwrite." })),
24
24
  };
25
25
  const PolicySchema = {