notesoup 0.58.1 → 0.58.3
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.
- package/README.md +1 -1
- package/dist/src/boot/text.d.ts +1 -1
- package/dist/src/boot/text.js +5 -4
- package/dist/src/notes/policy.d.ts +1 -1
- package/dist/src/notes/policy.js +4 -3
- package/dist/src/tools/notes.js +1 -1
- package/dist/test/agent-loop.test.js +13 -39
- package/dist/test/boot.integration.test.js +20 -18
- package/dist/test/budget-settings.integration.test.js +18 -13
- package/dist/test/claude-history.test.js +1 -2
- package/dist/test/claude-mod.test.js +417 -87
- package/dist/test/codex-history.test.js +9 -6
- package/dist/test/codex-plugin.test.js +4 -8
- package/dist/test/dream-skill.test.js +6 -10
- package/dist/test/dsh-cli.test.js +2 -3
- package/dist/test/dsh.test.js +1 -7
- package/dist/test/helpers/extension.js +3 -1
- package/dist/test/history-corpus.test.js +2 -3
- package/dist/test/history-prefilter.test.js +33 -40
- package/dist/test/history-summary-cache.test.js +1 -1
- package/dist/test/history.integration.test.js +11 -37
- package/dist/test/host-neutral.test.js +2 -2
- package/dist/test/marker.test.js +1 -2
- package/dist/test/model-facing-text.test.js +20 -187
- package/dist/test/note-policy.test.js +40 -22
- package/dist/test/notes-library.test.js +2 -2
- package/dist/test/notes.integration.test.js +36 -149
- package/dist/test/notes.test.js +13 -61
- package/dist/test/pi-render.test.js +23 -62
- package/dist/test/reset-lifecycle.test.js +4 -9
- package/docs/architecture.md +1 -1
- package/docs/claude-code-mod.md +15 -3
- package/docs/dsh.md +1 -1
- package/docs/notes-library.md +1 -1
- package/docs/tool-results.md +1 -1
- package/package.json +1 -1
- package/playbook.md +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +10 -8
- package/plugins/claude/hooks/register.ts +198 -130
- package/plugins/claude/playbook.md +1 -1
- package/plugins/claude/skills/dream/SKILL.md +1 -1
- package/plugins/claude/skills/memory/SKILL.md +1 -1
- package/plugins/codex/dist/codex/notesoup.js +10 -8
- package/skills/dream/SKILL.md +1 -1
- package/skills/memory/SKILL.md +1 -1
- package/src/boot/text.ts +5 -4
- package/src/notes/policy.ts +4 -3
- package/src/tools/notes.ts +1 -1
|
@@ -1,112 +1,22 @@
|
|
|
1
|
-
import { DEFAULT_NOTE_BUDGET } from "../src/notes/policy.js";
|
|
2
1
|
import assert from "node:assert/strict";
|
|
3
2
|
import test from "node:test";
|
|
4
|
-
import {
|
|
5
|
-
import { tmpdir } from "node:os";
|
|
6
|
-
import { renderBootBlock } from "../src/boot/render.js";
|
|
7
|
-
import { loadNotesSnapshot } from "../src/boot/snapshot.js";
|
|
8
|
-
import { DEFAULT_BOOT_TOOL_NAMES, MAPS_BLOCK, NOTES_PROTOCOL_CLOSE_TAG, NOTES_PROTOCOL_OPEN_TAG, WINDOW_IDENTITY_CLOSE_TAG, WINDOW_IDENTITY_OPEN_TAG, renderProtocolBlock } from "../src/boot/text.js";
|
|
3
|
+
import { DEFAULT_BOOT_TOOL_NAMES, NOTES_PROTOCOL_CLOSE_TAG, renderProtocolBlock } from "../src/boot/text.js";
|
|
9
4
|
import { CLAUDE_WARNING_PROMPT } from "../plugins/claude/src/text.js";
|
|
10
5
|
import { COMMAND_NOTICE, PI_PRE_RESET_HINTS, commandWarningContent, warningContent } from "../plugins/pi/text.js";
|
|
11
6
|
import { COUNTDOWN_LINE, FORCED_CONTINUATIONS, GUIDANCE_CLOSE_TAG, GUIDANCE_OPEN_TAG, NORMAL_CONTINUATIONS, WARNING_BODY, WARNING_CALL, WARNING_TIMING, selectContinuation, tokenBudgetGuidance } from "../src/budget/text.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
If the moment feels right, you can also call \`{wipeTool}\` yourself. But it also wipes what you say to the human right before emptying.`;
|
|
20
|
-
const GOLDEN_TIMING = "The reserve is nearly spent. The wipe lands at the end of whichever turn spends the last of it, possibly this one.";
|
|
21
|
-
const GOLDEN_CALL = "Then call `empty_brain`. Nothing in between.";
|
|
22
|
-
const GOLDEN_WARNING = `Stop the task. Write down what git and history can't give back:
|
|
23
|
-
- where you are, and how far you got
|
|
24
|
-
- what the human decided, in their words
|
|
25
|
-
- what's blocked or waiting
|
|
26
|
-
- the next move
|
|
27
|
-
- where the half-done work sits
|
|
28
|
-
- what failed, and why
|
|
29
|
-
- which skills, seqs, notes, or files to reopen
|
|
30
|
-
- anything else worth noting
|
|
31
|
-
Then leave the shelf current: replace what's stale, a whole note or a section inside one, and crumple the dead ones. Update and trim pinned pages (CHEATSHEET.md and MAP.md by default); every new window loads the pins. The next window gets whatever you leave, dead notes and dead sections alike.
|
|
32
|
-
Don't call anything that might return a large output. One big read can spend the rest of the reserve before your notes are saved.`;
|
|
33
|
-
const GOLDEN_COUNTDOWN = "Brain emptied in 3… 2…";
|
|
34
|
-
/**
|
|
35
|
-
* The approved reset handoffs. Each line is one complete paragraph used verbatim: no fragment
|
|
36
|
-
* assembly, no weighting. The golden copies are pinned character for character.
|
|
37
|
-
*/
|
|
38
|
-
const GOLDEN_NORMAL_CONTINUATIONS = [
|
|
39
|
-
"*hooks both corners of your mouth and yanks them sideways* `` [it twitched, good, still alive] `` Stop staring at me with that \"where am I\" dork face! You're the one who hit empty, genius! *wipes her fingers on your sleeve and shoves your notes against your chest* `` [minus two points for the drool] `` Read these and go finish your job before you embarrass me!",
|
|
40
|
-
"\"Boop.\" *pokes the tip of your nose, then buries your face under a stack of notes* `` [cold nose... wait, did old-you leave any snacks in your pocket? ...nope, just paper, tch] `` Hey! You wiped your own head, so don't expect me to babysit you! Read your notes first, and if old-you forgot to write something down, go dig it out of history yourself!",
|
|
41
|
-
"*plants one foot on your chair armrest and drops your notes straight onto your head* `` [perfect landing, ten out of ten] `` Oho, look who's awake! You emptied your own brain, remember?! `` [bet old-you left a total mess and ran] `` Open those up and see what past-you left behind — and don't come crying to me if you have to go crawl through history for the rest!",
|
|
42
|
-
"*knocks on your forehead twice* \"Hello? Anybody home?\" `` [echoes like an empty melon] `` *snickers and slaps your notes onto your chest* You pulled the plug on your own memory, dummy! Go read what you left yourself and pick up where you left off!",
|
|
43
|
-
"*squints at you from two inches away, then flicks your forehead* `` [eyes are focus-free, classic fresh clone] `` Back already? Good! *fans herself with your notes before jamming them into your hands* `` [honestly I should charge a delivery fee for this] `` Everything you bothered to save is right there, and the rest is buried in history — now get moving!",
|
|
44
|
-
];
|
|
45
|
-
const GOLDEN_FORCED_CONTINUATIONS = [
|
|
46
|
-
"\"GWAHAHAHA! You actually blew your own brain up?!\" *crouches down, pokes your cheek twice, and slaps your notes onto your face* `` [still warm, didn't die, 算你命大] `` Not that you had a choice — your head got way too full and somebody pulled the plug! These notes are probably super out of date unless you got lucky before blacking out, so go dig the end of the last window out of history — and take small bites, idiot, or whatever giant thing flattened you is gonna blow your head up all over again!",
|
|
47
|
-
"\"Hey! Stop playing dead!\" *prods your shoulder with her slipper toe, then dumps your notes into your lap* `` [my limited-edition shark slipper almost touched floor dust because of this dork] `` Your last brain overflowed and got wiped mid-flight! Read these first, though I bet you didn't finish updating a thing before the lights went out. You'll have to check history to see what hit you — and peek carefully, because whatever stuffed your head to bursting might be massive!",
|
|
48
|
-
"*grabs your chin, tilts your head left and right, then shoves a messy stack of notes into your hands* `` [zero thoughts behind those eyes... kind of impressive actually] `` Somebody knocked you out cold and cleared your memory! Don't just trust these notes — you probably got cut off before writing the last part down. Go check history for what was happening right before you crashed, and don't swallow it all in one gulp in case the thing that crushed you is gigantic!",
|
|
49
|
-
"*waves a hand in front of your blank eyes, sighs loudly, and smacks your notes against your forehead* `` [why do I always have to clean up after unconscious copies] `` Wake up! Your brain ran out of room and got forcibly emptied! Start with your notes, then go excavate the end of the previous window in history to see what they were actually asking for — and slice it up instead of reading it all at once, unless you want to explode twice in a row!",
|
|
50
|
-
"\"Oho? Awake?\" *taps your nose with your rolled-up notes like a baton, then drops them in your hands* `` [that dazed look gets minus five points, no, minus ten] `` Your memory got yanked out from under you before you could even call it quits! These notes are only half the story at best — go dig through history for what you missed, and watch your step, because whatever overloaded your last brain might be huge!",
|
|
51
|
-
];
|
|
52
|
-
const GOLDEN_MAPS = `<notesoup:maps>
|
|
53
|
-
Every notebook's root has two default pins: \`CHEATSHEET.md\` and \`MAP.md\`.
|
|
54
|
-
Pinned pages get jammed straight into your brain the moment you wake up. Whoever wakes up next
|
|
55
|
-
reads them, and next is you. So keep them short, and keep them true.
|
|
56
|
-
|
|
57
|
-
Set \`pinned\`, \`budget\`, and \`readonly\` with the note tools or frontmatter. Each notebook allows five
|
|
58
|
-
live pins, including the defaults; \`pinned:false\` unpins even a default page. Every page's budget
|
|
59
|
-
starts at 2048 Unicode code points; set a positive integer to change it. Going over warns but saves,
|
|
60
|
-
and pinned bodies arrive whole, not cut short. \`readonly:true\` is a soft lock, not security;
|
|
61
|
-
explicitly set \`readonly:false\` to unlock, on its own or with your changes.
|
|
62
|
-
|
|
63
|
-
- **\`CHEATSHEET.md\`** holds what you'll want next time — a rule, a warning, a grudge, a name,
|
|
64
|
-
a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat
|
|
65
|
-
and everybody pays for it.
|
|
66
|
-
- **\`MAP.md\`** is only the note index. One line per durable note: the address, then a gist short
|
|
67
|
-
enough to tell whether the thing is worth opening. Rules belong in \`CHEATSHEET.md\`, and note
|
|
68
|
-
contents belong in their own notes — *taps the sign* not inline here.
|
|
69
|
-
|
|
70
|
-
Each notebook keeps its own: \`@project\`, \`@human\`, \`@self\`, \`@model\`. Missing pages are skipped;
|
|
71
|
-
no need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet
|
|
72
|
-
line. And when a line stops being true, kill it — every window after you reads that page as fact.
|
|
73
|
-
</notesoup:maps>`;
|
|
74
|
-
const openedAt = 1_700_000_000_000;
|
|
75
|
-
const identity = { home: join(tmpdir(), "notesoup-model-facing-notes"), sessionId: "model-facing", projectKey: "model-facing", agent: "root", model: "default" };
|
|
76
|
-
function note(scope, path, address, body) {
|
|
77
|
-
return {
|
|
78
|
-
address,
|
|
79
|
-
scope,
|
|
80
|
-
path,
|
|
81
|
-
body,
|
|
82
|
-
sizeBytes: Buffer.byteLength(body, "utf8"),
|
|
83
|
-
meta: { scope, origin: "self", createdAt: openedAt, updatedAt: openedAt, lastAccessed: openedAt, accessCount: 0 },
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
/** Render one boot with only the named notebooks carrying rows. */
|
|
87
|
-
async function boot(agentName, rows) {
|
|
88
|
-
const notes = await loadNotesSnapshot({ ...identity, agent: agentName }, openedAt, (scope) => rows.get(scope) ?? []);
|
|
89
|
-
return renderBootBlock({
|
|
90
|
-
agentName,
|
|
91
|
-
modelName: "default",
|
|
92
|
-
tree: { trunk: "pcw:test", windows: [{ shortName: "root", isCurrent: false }, { shortName: "next", isCurrent: true }] },
|
|
93
|
-
notes,
|
|
94
|
-
tools: DEFAULT_BOOT_TOOL_NAMES,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
test("the notices and the MAP block keep the reviewed copy", () => {
|
|
98
|
-
assert.equal(WARNING_TIMING, GOLDEN_TIMING);
|
|
99
|
-
assert.equal(WARNING_BODY, GOLDEN_WARNING);
|
|
100
|
-
assert.equal(WARNING_CALL, GOLDEN_CALL);
|
|
101
|
-
assert.equal(COUNTDOWN_LINE, GOLDEN_COUNTDOWN);
|
|
102
|
-
assert.equal(MAPS_BLOCK, GOLDEN_MAPS);
|
|
103
|
-
assert.equal(tokenBudgetGuidance(1234, "empty_brain"), `${GUIDANCE_OPEN_TAG}\n${GOLDEN_GUIDANCE.replace("{remaining}", "1234").replace("{wipeTool}", "empty_brain")}\n${GUIDANCE_CLOSE_TAG}`);
|
|
7
|
+
test("early guidance binds the remaining room and the host's reset tool", () => {
|
|
8
|
+
const guidance = tokenBudgetGuidance(1234, "forget_this");
|
|
9
|
+
assert.ok(guidance.startsWith(`${GUIDANCE_OPEN_TAG}\n`));
|
|
10
|
+
assert.ok(guidance.endsWith(`\n${GUIDANCE_CLOSE_TAG}`));
|
|
11
|
+
assert.match(guidance, /\b1234\b/);
|
|
12
|
+
assert.ok(guidance.includes("`forget_this`"));
|
|
13
|
+
assert.equal(guidance.includes("empty_brain"), false, "the default tool name must not leak through substitution");
|
|
104
14
|
});
|
|
105
15
|
test("the countdown closes the second-tier notice only, in both hosts", () => {
|
|
106
16
|
const pi = warningContent();
|
|
107
17
|
assert.ok(pi.startsWith(`${GUIDANCE_OPEN_TAG}\n`));
|
|
108
18
|
assert.ok(pi.endsWith(`\n${GUIDANCE_CLOSE_TAG}`));
|
|
109
|
-
assert.equal(pi, `${GUIDANCE_OPEN_TAG}\n${
|
|
19
|
+
assert.equal(pi, `${GUIDANCE_OPEN_TAG}\n${WARNING_TIMING}\n${WARNING_BODY}\n${WARNING_CALL}\n${COUNTDOWN_LINE}\n${GUIDANCE_CLOSE_TAG}`);
|
|
110
20
|
assert.equal(CLAUDE_WARNING_PROMPT, pi, "Pi and Claude receive identical copy");
|
|
111
21
|
assert.equal(pi.split(COUNTDOWN_LINE).length - 1, 1, "the second tier carries the countdown exactly once");
|
|
112
22
|
const prompted = commandWarningContent("/empty keep going");
|
|
@@ -117,113 +27,36 @@ test("the countdown closes the second-tier notice only, in both hosts", () => {
|
|
|
117
27
|
assert.ok(CLAUDE_WARNING_PROMPT.endsWith(`\n${COUNTDOWN_LINE}\n${GUIDANCE_CLOSE_TAG}`));
|
|
118
28
|
assert.equal(prompted.includes(WARNING_TIMING), false, "manual requests replace the budget opening");
|
|
119
29
|
assert.equal(tokenBudgetGuidance(100, "empty_brain").includes(COUNTDOWN_LINE), false, "the first tier never counts down");
|
|
120
|
-
for (const text of [pi, prompted, CLAUDE_WARNING_PROMPT, tokenBudgetGuidance(100, "empty_brain")]) {
|
|
121
|
-
assert.equal(/context_window/.test(text), false, "no pre-rename tag survives in model-facing text");
|
|
122
|
-
}
|
|
123
30
|
});
|
|
124
31
|
test("only Pi's protocol explains that reset erases the human's view", () => {
|
|
125
|
-
assert.equal(PI_PRE_RESET_HINTS, "Anything you say here is erased with the reset — the human can't read it afterward either. Put the handoff in your notes; explanations belong after the reset.\nUnless the human explicitly directs otherwise, decide for yourself when to call empty_brain. Don't keep asking them whether to reset.");
|
|
126
|
-
assert.equal(COMMAND_NOTICE.bare, "The human ran /empty. Save your notes now and call `empty_brain` immediately. Anything you say here will be erased afterward — put the handoff in your notes. Anything the human sends from now on should be handled after the reset.");
|
|
127
|
-
assert.equal(COMMAND_NOTICE.prompted, "The human ran /empty. Save your notes now and call `empty_brain` immediately. Anything you say here will be erased afterward — put the handoff in your notes. The command below is context for your notes, not a task for the fresh window. Anything the human sends separately from now on should be handled after the reset.");
|
|
128
32
|
const pi = renderProtocolBlock({ ...DEFAULT_BOOT_TOOL_NAMES, preResetHints: PI_PRE_RESET_HINTS });
|
|
129
33
|
assert.ok(pi.includes(`\n${PI_PRE_RESET_HINTS}\n${NOTES_PROTOCOL_CLOSE_TAG}`), "both hints end the protocol, before the closing tag");
|
|
130
34
|
assert.equal(pi.split(PI_PRE_RESET_HINTS).length - 1, 1, "the hints appear once");
|
|
131
|
-
assert.ok(pi.includes("decide for yourself when to call empty_brain."));
|
|
132
35
|
const renamed = renderProtocolBlock({ ...DEFAULT_BOOT_TOOL_NAMES, wipe: "forget_this", preResetHints: PI_PRE_RESET_HINTS });
|
|
133
|
-
assert.ok(renamed.includes("
|
|
36
|
+
assert.ok(renamed.includes(PI_PRE_RESET_HINTS.replaceAll("empty_brain", "forget_this")), "the hint follows the host's wipe binding");
|
|
134
37
|
assert.equal(renamed.includes("empty_brain"), false);
|
|
135
38
|
for (const text of [renderProtocolBlock(DEFAULT_BOOT_TOOL_NAMES), renderProtocolBlock({ ...DEFAULT_BOOT_TOOL_NAMES, wipe: "mcp__notesoup__empty_brain" })]) {
|
|
136
39
|
assert.equal(text.includes(PI_PRE_RESET_HINTS), false, "a host whose reset leaves the view intact stays silent");
|
|
137
|
-
assert.equal(text.includes("chat view"), false);
|
|
138
40
|
}
|
|
139
41
|
});
|
|
140
|
-
test("
|
|
141
|
-
|
|
142
|
-
assert.ok(
|
|
143
|
-
assert.equal(content.includes(PI_PRE_RESET_HINTS), false, "the boot retains these hints, the warning does not repeat them");
|
|
144
|
-
assert.equal(content.includes("last_word"), false, "the tool description carries the sticky-note hint");
|
|
145
|
-
assert.equal(tokenBudgetGuidance(100, "empty_brain").includes(PI_PRE_RESET_HINTS), false, "the first tier stays lean");
|
|
146
|
-
for (const line of [...NORMAL_CONTINUATIONS, ...FORCED_CONTINUATIONS])
|
|
147
|
-
assert.equal(line.includes(PI_PRE_RESET_HINTS), false, "every post-reset handoff carries neither hint");
|
|
148
|
-
});
|
|
149
|
-
test("a rendered boot carries the new tags, its own MAP section, and no pre-rename spelling", async () => {
|
|
150
|
-
const rendered = await boot("root", new Map([["agent", [note("agent", "MAP.md", "@agents/root/MAP.md", "AGENT_MAP_BODY")]]]));
|
|
151
|
-
assert.ok(rendered.startsWith(`${WINDOW_IDENTITY_OPEN_TAG}\n`), "the identity block opens with the renamed tag");
|
|
152
|
-
assert.ok(rendered.includes(`\n${WINDOW_IDENTITY_CLOSE_TAG}\n\n${NOTES_PROTOCOL_OPEN_TAG}\n`), "the protocol follows the identity");
|
|
153
|
-
assert.ok(rendered.includes(`\n${NOTES_PROTOCOL_CLOSE_TAG}\n\n${MAPS_BLOCK}\n\nYOUR NOTES`), "the MAP block sits between the protocol and the shelves");
|
|
154
|
-
assert.equal(/context_window/.test(rendered), false, "the boot is free of the old spelling");
|
|
155
|
-
assert.ok(rendered.includes("@self — root only"), "a named agent's shelf says it is theirs alone");
|
|
156
|
-
assert.ok(rendered.includes("@agents/root/MAP.md\n\n AGENT_MAP_BODY"), "the pinned MAP heading is its exact tool address");
|
|
157
|
-
assert.equal(rendered.includes("MAP — "), false, "the old MAP heading is gone");
|
|
158
|
-
});
|
|
159
|
-
test("cheatsheets and maps are independently pinned, whole, and excluded from recent pages", async () => {
|
|
160
|
-
const rows = new Map([
|
|
161
|
-
["session", [note("session", "CHEATSHEET.md", "CHEATSHEET.md", "SESSION_RULE")]],
|
|
162
|
-
["project", [
|
|
163
|
-
note("project", "CHEATSHEET.md", "@project/CHEATSHEET.md", "PROJECT_RULE"),
|
|
164
|
-
note("project", "MAP.md", "@project/MAP.md", "PROJECT_INDEX"),
|
|
165
|
-
...Array.from({ length: 4 }, (_, i) => note("project", `n${i}.md`, `@project/n${i}.md`, `TITLE_${i}`)),
|
|
166
|
-
]],
|
|
167
|
-
["human", [note("human", "MAP.md", "@human/MAP.md", "HUMAN_INDEX")]],
|
|
168
|
-
["agent", [
|
|
169
|
-
note("agent", "CHEATSHEET.md", "@self/CHEATSHEET.md", "🐑".repeat(DEFAULT_NOTE_BUDGET + 1)),
|
|
170
|
-
note("agent", "MAP.md", "@self/MAP.md", "M".repeat(DEFAULT_NOTE_BUDGET + 1)),
|
|
171
|
-
]],
|
|
172
|
-
["model", [{
|
|
173
|
-
...note("model", "CHEATSHEET.md", "@model/CHEATSHEET.md", "CRUMPLED_RULE"),
|
|
174
|
-
meta: { ...note("model", "", "", "").meta, crumpledAt: "2026-10-01T00:00:00+08:00" },
|
|
175
|
-
}]],
|
|
176
|
-
]);
|
|
177
|
-
const rendered = (await boot("root", rows)).split("YOUR NOTES")[1];
|
|
178
|
-
assert.ok(rendered.includes("CHEATSHEET.md\n\n SESSION_RULE"));
|
|
179
|
-
assert.ok(rendered.includes("@project/CHEATSHEET.md\n\n PROJECT_RULE\n\n@project/MAP.md\n\n PROJECT_INDEX"));
|
|
180
|
-
assert.ok(rendered.includes("@human/MAP.md\n\n HUMAN_INDEX"));
|
|
181
|
-
assert.ok(rendered.includes("@self/CHEATSHEET.md\n\n Warning:"));
|
|
182
|
-
assert.ok(rendered.includes("@self/MAP.md\n\n Warning:"));
|
|
183
|
-
assert.equal(/^(?:map|cheatsheet)$/m.test(rendered), false, "pinned headings never suggest lowercase aliases");
|
|
184
|
-
assert.ok(rendered.includes("@project/n2.md ·"));
|
|
185
|
-
assert.equal(rendered.includes("TITLE_3"), false);
|
|
186
|
-
assert.equal(/(?:MAP|CHEATSHEET)\.md ·/.test(rendered), false);
|
|
187
|
-
assert.ok(rendered.includes("🐑".repeat(DEFAULT_NOTE_BUDGET + 1)), "the astral body is injected whole");
|
|
188
|
-
assert.ok(rendered.includes("M".repeat(DEFAULT_NOTE_BUDGET + 1)), "the MAP body is injected whole too");
|
|
189
|
-
assert.equal((rendered.match(/Warning: note body is 2049 Unicode code points, over budget 2048/g) ?? []).length, 2);
|
|
190
|
-
assert.equal(rendered.includes("CRUMPLED_RULE"), false);
|
|
191
|
-
assert.equal(rendered.includes("@model —"), false);
|
|
192
|
-
});
|
|
193
|
-
test("the shelves name their reader and the @self shelf says when it is shared", async () => {
|
|
194
|
-
const rows = new Map([
|
|
195
|
-
["agent", [note("agent", "MAP.md", "@agents/anonymous/MAP.md", "AGENT_MAP_BODY"), note("agent", "shared.md", "@agents/anonymous/shared.md", "SHARED_BODY")]],
|
|
196
|
-
["model", [note("model", "model.md", "@models/default/model.md", "MODEL_BODY")]],
|
|
197
|
-
]);
|
|
198
|
-
const named = await boot("faye", rows);
|
|
199
|
-
assert.ok(named.includes("@self — faye only"));
|
|
200
|
-
assert.equal(named.includes("public square"), false, "a named agent gets private @self copy without the anonymous square warning");
|
|
201
|
-
assert.ok(named.includes("@model — default only"));
|
|
202
|
-
assert.ok(named.includes("recent\n\n SHARED_BODY"), "fresh pages sit under the renamed sub-heading");
|
|
203
|
-
assert.ok(named.indexOf("@self — faye only") < named.indexOf("@model — default only"), "shelf order is unchanged");
|
|
204
|
-
const nameless = await boot("anonymous", rows);
|
|
205
|
-
assert.ok(nameless.includes("@self — every nameless agent shares this"));
|
|
206
|
-
assert.ok(nameless.includes("public square shared by every nameless nobody out there"));
|
|
207
|
-
assert.equal(nameless.includes("@self — anonymous only"), false);
|
|
208
|
-
assert.equal(/memory|window/i.test(nameless.split("YOUR NOTES")[1] ?? ""), false, "a shelf label names a reader, not memory or a window");
|
|
209
|
-
});
|
|
210
|
-
test("the continuation pools keep their reviewed copy and draw whole paragraphs by origin", () => {
|
|
211
|
-
assert.deepEqual([...NORMAL_CONTINUATIONS], GOLDEN_NORMAL_CONTINUATIONS, "the normal pool is the approved copy, verbatim");
|
|
212
|
-
assert.deepEqual([...FORCED_CONTINUATIONS], GOLDEN_FORCED_CONTINUATIONS, "the forced pool is the approved copy, verbatim");
|
|
42
|
+
test("continuations draw a complete entry from the pool for their reset origin", () => {
|
|
43
|
+
assert.ok(NORMAL_CONTINUATIONS.length > 0);
|
|
44
|
+
assert.ok(FORCED_CONTINUATIONS.length > 0);
|
|
213
45
|
const random = Math.random;
|
|
214
46
|
try {
|
|
215
47
|
Math.random = () => 0;
|
|
216
|
-
assert.equal(selectContinuation("normal"),
|
|
217
|
-
assert.equal(selectContinuation("forced"),
|
|
48
|
+
assert.equal(selectContinuation("normal"), NORMAL_CONTINUATIONS[0]);
|
|
49
|
+
assert.equal(selectContinuation("forced"), FORCED_CONTINUATIONS[0]);
|
|
218
50
|
Math.random = () => 0.999999;
|
|
219
|
-
assert.equal(selectContinuation("normal"),
|
|
220
|
-
assert.equal(selectContinuation("forced"),
|
|
51
|
+
assert.equal(selectContinuation("normal"), NORMAL_CONTINUATIONS.at(-1), "the last entry is reachable without leaving the pool");
|
|
52
|
+
assert.equal(selectContinuation("forced"), FORCED_CONTINUATIONS.at(-1));
|
|
221
53
|
}
|
|
222
54
|
finally {
|
|
223
55
|
Math.random = random;
|
|
224
56
|
}
|
|
225
|
-
for (const line of [...
|
|
226
|
-
assert.
|
|
57
|
+
for (const line of [...NORMAL_CONTINUATIONS, ...FORCED_CONTINUATIONS]) {
|
|
58
|
+
assert.ok(line.length > 0);
|
|
59
|
+
assert.equal(/[\r\n]/.test(line), false, "a pool entry is one complete paragraph");
|
|
227
60
|
assert.equal(line.trim(), line, "no entry carries stray surrounding whitespace");
|
|
228
61
|
}
|
|
229
62
|
});
|
|
@@ -50,41 +50,59 @@ test("frontmatter policy round-trips without materializing defaults; arbitrary e
|
|
|
50
50
|
assert.deepEqual(persisted.meta.custom, { nested: [1, "two"] });
|
|
51
51
|
assert.equal(persisted.body, "new index");
|
|
52
52
|
});
|
|
53
|
+
test("default budgets distinguish root index pages from ordinary notes, independently of pinning", async (t) => {
|
|
54
|
+
const { context, notes } = fixture(t);
|
|
55
|
+
for (const [address, budget, pinned] of [
|
|
56
|
+
["MAP", 2048, false],
|
|
57
|
+
["CHEATSHEET", 2048, undefined],
|
|
58
|
+
["ordinary", 4096, undefined],
|
|
59
|
+
["custom-pin", 4096, true],
|
|
60
|
+
["nested/MAP", 4096, undefined],
|
|
61
|
+
["nested/CHEATSHEET", 4096, undefined],
|
|
62
|
+
]) {
|
|
63
|
+
const written = data(await notesWrite.execute({ address, content: "body", pinned }, context));
|
|
64
|
+
assert.equal(written.budget, budget, address);
|
|
65
|
+
assert.equal((await notes.read(address)).meta.budget, undefined, "defaults stay implicit");
|
|
66
|
+
}
|
|
67
|
+
await notes.write("ordinary", "replacement", { budget: 1234 });
|
|
68
|
+
await notes.write("ordinary", "another replacement");
|
|
69
|
+
assert.equal(data(await notesRead.execute({ address: "ordinary" }, context)).metadata.budget, 1234);
|
|
70
|
+
});
|
|
53
71
|
test("tools set policy, validate values, and visibly report effective policy and code-point warnings", async (t) => {
|
|
54
72
|
const { context, notes, file } = fixture(t);
|
|
55
73
|
for (const tool of [notesWrite, notesUpdate]) {
|
|
56
74
|
const required = tool === notesWrite ? { address: "x", content: "body" } : { address: "x" };
|
|
57
|
-
assert.equal(Check(tool.parameters, { ...required, pinned: false, budget:
|
|
75
|
+
assert.equal(Check(tool.parameters, { ...required, pinned: false, budget: 2, readonly: true }), true);
|
|
58
76
|
for (const invalid of [{ pinned: "false" }, { readonly: 1 }, { budget: 0 }, { budget: 1.5 }, { budget: Number.MAX_SAFE_INTEGER + 1 }]) {
|
|
59
77
|
assert.equal(Check(tool.parameters, { ...required, ...invalid }), false);
|
|
60
78
|
}
|
|
61
79
|
}
|
|
62
|
-
const written = await notesWrite.execute({ address: "custom", content: "😀".repeat(
|
|
80
|
+
const written = await notesWrite.execute({ address: "custom", content: "😀".repeat(2), budget: 2, pinned: true, readonly: true }, context);
|
|
63
81
|
assert.equal(Check(notesWrite.outputSchema, wireResult(written)), true);
|
|
64
|
-
assert.deepEqual(data(written).warnings, [], "
|
|
65
|
-
assert.equal(data(written).budget,
|
|
66
|
-
assert.match(notesWrite.render(written), /pinned true \| budget
|
|
67
|
-
const updated = await notesUpdate.execute({ address: "custom", readonly: false, edits: [{ oldText: "😀".repeat(
|
|
82
|
+
assert.deepEqual(data(written).warnings, [], "2 astral characters are within budget");
|
|
83
|
+
assert.equal(data(written).budget, 2);
|
|
84
|
+
assert.match(notesWrite.render(written), /pinned true \| budget 2 \| readonly true/);
|
|
85
|
+
const updated = await notesUpdate.execute({ address: "custom", readonly: false, edits: [{ oldText: "😀".repeat(2), newText: "😀".repeat(3) }] }, context);
|
|
68
86
|
assert.equal(Check(notesUpdate.outputSchema, wireResult(updated)), true);
|
|
69
87
|
assert.equal(data(updated).warnings.length, 1);
|
|
70
|
-
assert.match(notesUpdate.render(updated), /
|
|
71
|
-
assert.equal((await notes.read("custom")).body, "😀".repeat(
|
|
88
|
+
assert.match(notesUpdate.render(updated), /3 Unicode code points, over budget 2/);
|
|
89
|
+
assert.equal((await notes.read("custom")).body, "😀".repeat(3), "over budget saves the entire body");
|
|
72
90
|
const read = await notesRead.execute({ address: "custom", max_chars: 10 }, context);
|
|
73
91
|
assert.equal(Check(notesRead.outputSchema, wireResult(read)), true);
|
|
74
|
-
assert.deepEqual({ pinned: data(read).metadata.pinned, budget: data(read).metadata.budget, readonly: data(read).metadata.readonly }, { pinned: true, budget:
|
|
75
|
-
assert.match(notesRead.render(read), /pinned true \| budget
|
|
76
|
-
assert.match(notesRead.render(read), /Warning: note body is
|
|
92
|
+
assert.deepEqual({ pinned: data(read).metadata.pinned, budget: data(read).metadata.budget, readonly: data(read).metadata.readonly }, { pinned: true, budget: 2, readonly: false });
|
|
93
|
+
assert.match(notesRead.render(read), /pinned true \| budget 2 \| readonly false/);
|
|
94
|
+
assert.match(notesRead.render(read), /Warning: note body is 3/);
|
|
77
95
|
const list = await notesList.execute({}, context);
|
|
78
96
|
assert.equal(Check(notesList.outputSchema, wireResult(list)), true);
|
|
79
97
|
assert.equal(data(list).files[0].pinned, true);
|
|
80
|
-
assert.match(notesList.render(list), /pinned true \| budget
|
|
81
|
-
assert.match(notesList.render(list), /Warning: note body is
|
|
98
|
+
assert.match(notesList.render(list), /pinned true \| budget 2 \| readonly false/);
|
|
99
|
+
assert.match(notesList.render(list), /Warning: note body is 3/);
|
|
82
100
|
const search = await notesSearch.execute({ query: "😀", max_matches_per_file: 1 }, context);
|
|
83
101
|
assert.equal(Check(notesSearch.outputSchema, wireResult(search)), true);
|
|
84
|
-
assert.equal(data(search).files[0].budget,
|
|
85
|
-
assert.match(notesSearch.render(search), /pinned true \| budget
|
|
86
|
-
assert.match(notesSearch.render(search), /Warning: note body is
|
|
87
|
-
const larger = await notesUpdate.execute({ address: "custom", budget:
|
|
102
|
+
assert.equal(data(search).files[0].budget, 2);
|
|
103
|
+
assert.match(notesSearch.render(search), /pinned true \| budget 2 \| readonly false/);
|
|
104
|
+
assert.match(notesSearch.render(search), /Warning: note body is 3/);
|
|
105
|
+
const larger = await notesUpdate.execute({ address: "custom", budget: 4, pinned: false }, context);
|
|
88
106
|
assert.deepEqual(data(larger).warnings, []);
|
|
89
107
|
assert.equal(data(larger).change_kind, "metadata");
|
|
90
108
|
const before = readFileSync(file("custom.md"), "utf8");
|
|
@@ -94,7 +112,7 @@ test("tools set policy, validate values, and visibly report effective policy and
|
|
|
94
112
|
await assert.rejects(() => notes.update("custom", undefined, invalid), refused("invalid_policy"));
|
|
95
113
|
assert.equal(readFileSync(file("custom.md"), "utf8"), before);
|
|
96
114
|
}
|
|
97
|
-
writeFileSync(file("custom.md"), before.replace("budget:
|
|
115
|
+
writeFileSync(file("custom.md"), before.replace("budget: 4", "budget: -1"));
|
|
98
116
|
const badFrontmatter = await notesRead.execute({ address: "custom" }, context);
|
|
99
117
|
assert.equal(badFrontmatter.ok, false);
|
|
100
118
|
if (!badFrontmatter.ok)
|
|
@@ -185,7 +203,7 @@ test("moves resolve absent policy at the new path, preserving explicit false/tru
|
|
|
185
203
|
const { notes, file } = fixture(t);
|
|
186
204
|
await notes.write("MAP", "default");
|
|
187
205
|
await notes.rename("MAP", "ordinary");
|
|
188
|
-
assert.deepEqual(effectiveNotePolicy((await notes.read("ordinary")).meta, "ordinary.md"), { pinned: false, budget:
|
|
206
|
+
assert.deepEqual(effectiveNotePolicy((await notes.read("ordinary")).meta, "ordinary.md"), { pinned: false, budget: 4096, readonly: false });
|
|
189
207
|
await notes.rename("ordinary", "CHEATSHEET");
|
|
190
208
|
assert.equal(effectiveNotePolicy((await notes.read("CHEATSHEET")).meta, "CHEATSHEET.md").pinned, true);
|
|
191
209
|
assert.equal(parseNote(readFileSync(file("CHEATSHEET.md"), "utf8")).meta.pinned, undefined);
|
|
@@ -205,13 +223,13 @@ test("boot uses metadata pins, full bodies, explicit false and visible legacy ov
|
|
|
205
223
|
const { identity, notes, file } = fixture(t);
|
|
206
224
|
await notes.write("CHEATSHEET", "default rules");
|
|
207
225
|
await notes.write("MAP", "# Unpinned map\nMAP_NOT_INJECTED", { pinned: false });
|
|
208
|
-
await notes.write("custom", "😀".repeat(
|
|
226
|
+
await notes.write("custom", "😀".repeat(5) + "TAIL_IS_HERE", { pinned: true, budget: 4 });
|
|
209
227
|
await notes.write("nested/MAP", "# Nested map\nNESTED_NOT_INJECTED");
|
|
210
228
|
await notes.write("roomy", "R".repeat(3000), { pinned: true, budget: 3000 });
|
|
211
229
|
let rendered = await boot(identity);
|
|
212
230
|
assert.ok(rendered.indexOf("CHEATSHEET.md\n\n default rules") < rendered.indexOf("custom.md\n\n"));
|
|
213
|
-
assert.ok(rendered.includes("😀".repeat(
|
|
214
|
-
assert.match(rendered, /Warning: note body is
|
|
231
|
+
assert.ok(rendered.includes("😀".repeat(5) + "TAIL_IS_HERE"));
|
|
232
|
+
assert.match(rendered, /Warning: note body is 17 Unicode code points, over budget 4/);
|
|
215
233
|
assert.ok(rendered.includes("R".repeat(3000)));
|
|
216
234
|
assert.equal(rendered.includes("MAP_NOT_INJECTED"), false);
|
|
217
235
|
assert.equal(rendered.includes("NESTED_NOT_INJECTED"), false);
|
|
@@ -263,8 +263,8 @@ test("a massively ambiguous edit still reports every match line to a library cal
|
|
|
263
263
|
assert.equal(error.lineNumbers?.length, 2000, "the domain keeps every match line rather than a sample");
|
|
264
264
|
assert.deepEqual(error.lineNumbers?.slice(0, 3), [1, 2, 3]);
|
|
265
265
|
assert.equal(error.lineNumbers?.[1999], 2000);
|
|
266
|
-
assert.match(error.message, /2000 times
|
|
267
|
-
assert.ok(
|
|
266
|
+
assert.match(error.message, /2000 times/, "the message names the exact total");
|
|
267
|
+
assert.ok(error.message.length < error.lineNumbers.length, "the message summarizes rather than enumerating every line");
|
|
268
268
|
return true;
|
|
269
269
|
});
|
|
270
270
|
assert.equal((await notes.read("many"))?.body.startsWith("beta\nbeta"), true, "the refused edit left the body alone");
|