notesoup 0.60.1 โ 0.62.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.
- package/.agents/plugins/marketplace.json +15 -0
- package/README.md +14 -10
- package/dist/plugins/antigravity/src/cli.d.ts +1 -0
- package/dist/plugins/antigravity/src/cli.js +23 -0
- package/dist/plugins/antigravity/src/hooks.d.ts +18 -0
- package/dist/plugins/antigravity/src/hooks.js +53 -0
- package/dist/plugins/antigravity/src/identity.d.ts +26 -0
- package/dist/plugins/antigravity/src/identity.js +129 -0
- package/dist/plugins/claude/src/helper.js +2 -1
- package/dist/plugins/codex/src/hooks.js +1 -0
- package/dist/plugins/codex/src/identity.d.ts +6 -1
- package/dist/plugins/codex/src/identity.js +13 -1
- package/dist/plugins/codex/src/mcp.d.ts +35 -7
- package/dist/plugins/codex/src/mcp.js +26 -88
- package/dist/plugins/codex/src/text.js +3 -3
- package/dist/plugins/dsh/tools.js +8 -4
- package/dist/plugins/mcp/operations.d.ts +15 -0
- package/dist/plugins/mcp/operations.js +43 -0
- package/dist/plugins/mcp/server.d.ts +14 -0
- package/dist/plugins/mcp/server.js +13 -0
- package/dist/plugins/pi/budget.d.ts +1 -1
- package/dist/plugins/pi/budget.js +3 -2
- package/dist/plugins/pi/entries.d.ts +1 -0
- package/dist/plugins/pi/entries.js +1 -0
- package/dist/plugins/pi/history-tools.js +2 -1
- package/dist/plugins/pi/history.js +18 -1
- package/dist/plugins/pi/notes/tools.js +7 -3
- package/dist/plugins/pi/render.d.ts +7 -1
- package/dist/plugins/pi/render.js +2 -2
- package/dist/plugins/pi/reset/lifecycle.d.ts +1 -1
- package/dist/plugins/pi/reset/lifecycle.js +8 -9
- package/dist/plugins/pi/runtime.js +102 -61
- package/dist/plugins/pi/tool-result.js +7 -7
- package/dist/plugins/pi/window.d.ts +33 -3
- package/dist/plugins/pi/window.js +209 -9
- package/dist/src/boot/render.d.ts +5 -0
- package/dist/src/boot/render.js +60 -28
- package/dist/src/boot/text.d.ts +3 -3
- package/dist/src/boot/text.js +27 -26
- package/dist/src/budget/text.d.ts +2 -2
- package/dist/src/budget/text.js +13 -13
- package/dist/src/history/claude.d.ts +2 -0
- package/dist/src/history/claude.js +46 -0
- package/dist/src/history/codex-transcript.js +7 -5
- package/dist/src/history/codex.js +3 -0
- package/dist/src/history/corpus.d.ts +28 -1
- package/dist/src/history/corpus.js +40 -0
- package/dist/src/history/history.d.ts +37 -46
- package/dist/src/history/history.js +21 -40
- package/dist/src/history/local.js +67 -32
- package/dist/src/history/pi.d.ts +2 -1
- package/dist/src/history/pi.js +122 -48
- package/dist/src/history/prefilter.js +76 -19
- package/dist/src/history/query.d.ts +28 -49
- package/dist/src/history/query.js +83 -68
- package/dist/src/history/summary-cache.d.ts +8 -1
- package/dist/src/history/summary-cache.js +138 -12
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/notes/frontmatter.d.ts +4 -0
- package/dist/src/notes/frontmatter.js +15 -1
- package/dist/src/notes/index.d.ts +1 -1
- package/dist/src/notes/index.js +1 -1
- package/dist/src/notes/policy.d.ts +15 -1
- package/dist/src/notes/policy.js +47 -6
- package/dist/src/notes/store.d.ts +14 -0
- package/dist/src/notes/store.js +33 -12
- package/dist/src/text-match.d.ts +10 -1
- package/dist/src/text-match.js +42 -3
- package/dist/src/tools/dream.d.ts +22 -91
- package/dist/src/tools/dream.js +30 -27
- package/dist/src/tools/history.d.ts +33 -26
- package/dist/src/tools/history.js +257 -163
- package/dist/src/tools/notes.d.ts +58 -160
- package/dist/src/tools/notes.js +151 -99
- package/dist/src/tools/output.d.ts +2 -1
- package/dist/src/tools/output.js +2 -1
- package/dist/src/tools/result.d.ts +4 -7
- package/dist/src/tools/result.js +8 -9
- package/dist/src/tools/schema.d.ts +4 -1
- package/dist/src/tools/schema.js +25 -1
- package/dist/test/agent-loop.test.js +198 -16
- package/dist/test/antigravity-live.test.d.ts +1 -0
- package/dist/test/antigravity-live.test.js +142 -0
- package/dist/test/antigravity-plugin.test.d.ts +1 -0
- package/dist/test/antigravity-plugin.test.js +101 -0
- package/dist/test/boot.integration.test.js +133 -14
- package/dist/test/claude-history.test.js +14 -13
- package/dist/test/claude-mod.test.js +9 -6
- package/dist/test/codex-history.test.js +15 -3
- package/dist/test/codex-plugin.test.js +76 -38
- package/dist/test/dependencies.test.js +7 -3
- package/dist/test/dream-skill.test.js +3 -3
- package/dist/test/dream-tools.test.js +101 -56
- package/dist/test/dsh.test.js +34 -19
- package/dist/test/helpers/dependency-graph.js +2 -2
- package/dist/test/helpers/extension.d.ts +65 -2
- package/dist/test/helpers/extension.js +72 -3
- package/dist/test/history-corpus.test.js +79 -77
- package/dist/test/history-summary-cache.test.js +97 -9
- package/dist/test/history.integration.test.js +234 -168
- package/dist/test/host-neutral.test.js +69 -19
- package/dist/test/marker.test.js +1 -1
- package/dist/test/note-policy.test.js +189 -56
- package/dist/test/notes.integration.test.js +212 -94
- package/dist/test/notes.test.js +184 -113
- package/dist/test/pi-render.test.js +20 -12
- package/dist/test/project-namespace.test.js +3 -2
- package/dist/test/reset-lifecycle.test.js +2 -2
- package/docs/antigravity.md +44 -0
- package/docs/architecture.md +6 -4
- package/docs/claude-code-mod.md +2 -2
- package/docs/codex.md +36 -38
- package/docs/dsh.md +4 -4
- package/docs/history-sessions.md +28 -50
- package/docs/notes-library.md +6 -6
- package/docs/reset-lifecycle.md +1 -1
- package/docs/skills.md +3 -3
- package/docs/tool-results.md +47 -28
- package/package.json +3 -2
- package/playbook.md +3 -3
- package/plugins/antigravity/dist/antigravity/notesoup.js +26886 -0
- package/plugins/antigravity/hooks.json +7 -0
- package/plugins/antigravity/mcp_config.json +8 -0
- package/plugins/antigravity/plugin.json +6 -0
- package/plugins/antigravity/src/cli.ts +22 -0
- package/plugins/antigravity/src/hooks.ts +51 -0
- package/plugins/antigravity/src/identity.ts +127 -0
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +1129 -549
- package/plugins/claude/hooks/register.ts +2 -2
- package/plugins/claude/playbook.md +3 -3
- package/plugins/claude/skills/dream/SKILL.md +2 -2
- package/plugins/claude/skills/notesoup/SKILL.md +92 -0
- package/plugins/claude/src/helper.ts +2 -1
- package/plugins/codex/.codex-plugin/plugin.json +8 -0
- package/plugins/codex/.mcp.json +11 -0
- package/plugins/codex/README.md +5 -21
- package/plugins/codex/dist/codex/notesoup.js +18494 -17905
- package/plugins/codex/src/hooks.ts +1 -0
- package/plugins/codex/src/identity.ts +14 -1
- package/plugins/codex/src/mcp.ts +28 -98
- package/plugins/codex/src/text.ts +3 -3
- package/plugins/dsh/tools.ts +8 -4
- package/plugins/mcp/operations.ts +50 -0
- package/plugins/mcp/server.ts +23 -0
- package/plugins/paseo/README.md +5 -10
- package/plugins/paseo/client/brain-empty-card.tsx +3 -3
- package/plugins/paseo/client/markdown.tsx +50 -38
- package/plugins/paseo/client/notes-op-card.tsx +12 -9
- package/plugins/paseo/client/paper-card.tsx +6 -5
- package/plugins/paseo/client/paper-palette.ts +2 -9
- package/plugins/paseo/client/sticky-card.tsx +2 -2
- package/plugins/paseo/client/tool-result.ts +7 -14
- package/plugins/paseo/package-lock.json +3406 -0
- package/plugins/paseo/package.json +1 -0
- package/plugins/paseo/test/markdown-core.test.ts +73 -66
- package/plugins/pi/budget.ts +3 -3
- package/plugins/pi/entries.ts +1 -0
- package/plugins/pi/history-tools.ts +2 -1
- package/plugins/pi/history.ts +30 -1
- package/plugins/pi/notes/tools.ts +7 -3
- package/plugins/pi/render.ts +6 -6
- package/plugins/pi/reset/lifecycle.ts +9 -10
- package/plugins/pi/runtime.ts +96 -60
- package/plugins/pi/tool-result.ts +8 -8
- package/plugins/pi/window.ts +198 -9
- package/skills/dream/SKILL.md +2 -2
- package/skills/notesoup/SKILL.md +92 -0
- package/src/boot/render.ts +59 -25
- package/src/boot/text.ts +30 -27
- package/src/budget/text.ts +13 -13
- package/src/history/claude.ts +41 -0
- package/src/history/codex-transcript.ts +6 -4
- package/src/history/codex.ts +2 -0
- package/src/history/corpus.ts +51 -2
- package/src/history/history.ts +35 -44
- package/src/history/local.ts +67 -27
- package/src/history/pi.ts +113 -35
- package/src/history/prefilter.ts +73 -15
- package/src/history/query.ts +93 -73
- package/src/history/summary-cache.ts +142 -17
- package/src/index.ts +1 -1
- package/src/notes/frontmatter.ts +16 -1
- package/src/notes/index.ts +1 -1
- package/src/notes/policy.ts +45 -6
- package/src/notes/store.ts +30 -15
- package/src/text-match.ts +46 -4
- package/src/tools/dream.ts +29 -31
- package/src/tools/history.ts +249 -142
- package/src/tools/notes.ts +150 -112
- package/src/tools/output.ts +2 -1
- package/src/tools/result.ts +12 -11
- package/src/tools/schema.ts +24 -1
- package/plugins/claude/skills/memory/SKILL.md +0 -69
- package/plugins/codex/mcp.json +0 -10
- package/plugins/codex/plugin.json +0 -6
- package/plugins/paseo/client/markdown-core.tsx +0 -189
- package/plugins/paseo/client/typography.ts +0 -24
- package/skills/memory/SKILL.md +0 -69
|
@@ -7,12 +7,12 @@ import { Type } from "typebox";
|
|
|
7
7
|
import { Check } from "typebox/value";
|
|
8
8
|
import { loadNotesSnapshot } from "../src/boot/snapshot.js";
|
|
9
9
|
import { renderBootBlock } from "../src/boot/render.js";
|
|
10
|
-
import {
|
|
10
|
+
import { HistoryRoleSchema, ToolCallStatusSchema, projectHistory } from "../src/history/history.js";
|
|
11
11
|
import { createNotesStore } from "../src/notes/store.js";
|
|
12
12
|
import { notesWrite, notesUpdate, notesRead } from "../src/tools/notes.js";
|
|
13
13
|
import { notesToolContext } from "../src/tools/notes-context.js";
|
|
14
|
-
import { historyList, historyRead } from "../src/tools/history.js";
|
|
15
|
-
import { historyRoles } from "../src/tools/schema.js";
|
|
14
|
+
import { historyList, historySearch, historyRead } from "../src/tools/history.js";
|
|
15
|
+
import { historyRoles, paramProblem, parseIsoTimestamp, stringEnum } from "../src/tools/schema.js";
|
|
16
16
|
import { MAX_READ_WINDOW_CHARS, TOOL_OUTPUT_MAX_BYTES } from "../src/tools/output.js";
|
|
17
17
|
import { ERROR_MESSAGE_MAX_CHARS, failure, success } from "../src/result.js";
|
|
18
18
|
import { fitsResult, resultSchema, wireResult, readTextWindow, renderOutcome, renderTextWindow, structuredBytes, } from "../src/tools/result.js";
|
|
@@ -33,7 +33,7 @@ function refusal(result) {
|
|
|
33
33
|
}
|
|
34
34
|
const makeData = (window) => ({ header: "identity, metadata, cursors, and a footer".repeat(4), window });
|
|
35
35
|
const renderData = (result) => result.ok ? `${result.data.header}\n${renderTextWindow(result.data.window)}` : renderOutcome(result, () => "");
|
|
36
|
-
const read = (text, offset, limit) => readTextWindow(text, offset, limit, makeData, renderData);
|
|
36
|
+
const read = (text, offset, limit) => readTextWindow(text, offset, limit, makeData, renderData, (result) => fitsResult(result, renderData));
|
|
37
37
|
test("shared boot uses only explicit identity, loader, captured time and logical tool bindings", async (t) => {
|
|
38
38
|
const notesIdentity = identity(t);
|
|
39
39
|
const openedAt = 1_700_000_000_000;
|
|
@@ -50,19 +50,19 @@ test("shared boot uses only explicit identity, loader, captured time and logical
|
|
|
50
50
|
const block = { agentName: notesIdentity.agent, modelName: notesIdentity.model, tree: { trunk: "test", windows: [{ shortName: "root", isCurrent: false }, { shortName: "next", isCurrent: true }] }, notes: snapshot, tools };
|
|
51
51
|
const rendered = renderBootBlock(block);
|
|
52
52
|
assert.equal(renderBootBlock(block), rendered);
|
|
53
|
-
assert.ok(rendered.includes("
|
|
53
|
+
assert.ok(rendered.includes("\ncheckpoint.md ยท 1m ago โ ๐"), "an index entry is the locator plus the note's own first line, without indentation");
|
|
54
54
|
assert.ok(rendered.includes("Try `memo_list` again"));
|
|
55
55
|
assert.equal(/notes_\*|notes_list|history_\*|history_list|history_read|get_context_remaining|empty_brain/.test(rendered), false);
|
|
56
56
|
});
|
|
57
57
|
test("the shared result module bounds both surfaces and resumes by offset", () => {
|
|
58
58
|
const text = `${"a".repeat(120)}๐${"b".repeat(30)}`;
|
|
59
59
|
const chars = Array.from(text);
|
|
60
|
-
// The requested count stops the read, and the footer
|
|
60
|
+
// The requested count stops the read, and the footer states delivered/total and where to continue.
|
|
61
61
|
const first = data(read(text, 0, 10));
|
|
62
62
|
assert.equal(first.window.text, chars.slice(0, 10).join(""));
|
|
63
63
|
assert.equal(first.window.next_offset_chars, 10);
|
|
64
64
|
assert.equal(first.window.total_chars, chars.length);
|
|
65
|
-
assert.match(renderData(success(first)), /\[truncated; continue at offset_chars=10\]$/);
|
|
65
|
+
assert.match(renderData(success(first)), /\[truncated at 10\/151 chars; continue at offset_chars=10\]$/);
|
|
66
66
|
// Concatenating windows by their cursors reproduces the source, marker-free.
|
|
67
67
|
const second = data(read(text, first.window.next_offset_chars ?? 0, 10));
|
|
68
68
|
assert.equal(`${first.window.text}${second.window.text}`, chars.slice(0, 20).join(""));
|
|
@@ -81,7 +81,7 @@ test("the shared result module bounds both surfaces and resumes by offset", () =
|
|
|
81
81
|
assert.ok(Buffer.byteLength(renderData(success(capped)), "utf8") <= TOOL_OUTPUT_MAX_BYTES, "the model text fits");
|
|
82
82
|
assert.ok(Buffer.byteLength(JSON.stringify(wireResult(success(capped))), "utf8") <= TOOL_OUTPUT_MAX_BYTES, "the structured outcome fits");
|
|
83
83
|
assert.equal(capped.window.text, huge.slice(0, cappedEnd), "the delivered slice is a verbatim prefix");
|
|
84
|
-
assert.match(renderData(success(capped)), new RegExp(`\\[truncated; continue at offset_chars=${cappedEnd}\\]$`));
|
|
84
|
+
assert.match(renderData(success(capped)), new RegExp(`\\[truncated at ${cappedEnd}/${capped.window.total_chars} chars; continue at offset_chars=${cappedEnd}\\]$`));
|
|
85
85
|
// Code points, not UTF-16 units.
|
|
86
86
|
const emoji = data(read("๐๐๐", 1, 1));
|
|
87
87
|
assert.equal(emoji.window.text, "๐");
|
|
@@ -248,7 +248,7 @@ test("shared history operations read typed events through the addresses the adap
|
|
|
248
248
|
assert.match(full.text, /needle output/, "the document carries the result");
|
|
249
249
|
assert.equal(full.next_offset_chars, null);
|
|
250
250
|
// A query offset addresses that same document, so reading from it resumes inside the result.
|
|
251
|
-
const searched = data(await
|
|
251
|
+
const searched = data(await historySearch.execute({ query: "NEEDLE", roles: ["tool"] }, projection));
|
|
252
252
|
assert.equal(searched.items.length, 1);
|
|
253
253
|
const hit = searched.items[0];
|
|
254
254
|
if ("folded" in hit)
|
|
@@ -261,19 +261,69 @@ test("shared history operations read typed events through the addresses the adap
|
|
|
261
261
|
assert.match(refusal(await historyRead.execute({ seq: 9_999 }, projection)).message, /9,?999/, "an unknown address is refused by name");
|
|
262
262
|
assert.equal(data(await historyRead.execute({ seq: 3 }, projection)).seq, 2, "a paired result address resolves to its call event");
|
|
263
263
|
});
|
|
264
|
-
test("
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
assert.equal(
|
|
270
|
-
assert.
|
|
264
|
+
test("ISO 8601 parameters without an offset mean host local time", () => {
|
|
265
|
+
// Date and clock fields without an offset are read on the host clock, like the notes store does.
|
|
266
|
+
assert.equal(parseIsoTimestamp("2026-11-27"), new Date(2026, 10, 27).getTime());
|
|
267
|
+
assert.equal(parseIsoTimestamp("2026-11-27T13:40"), new Date(2026, 10, 27, 13, 40).getTime());
|
|
268
|
+
assert.equal(parseIsoTimestamp("2026-11-27T13:40:05"), new Date(2026, 10, 27, 13, 40, 5).getTime());
|
|
269
|
+
assert.equal(parseIsoTimestamp("2026-11-27T13:40:05.2509"), new Date(2026, 10, 27, 13, 40, 5, 250).getTime(), "fractional seconds truncate to milliseconds");
|
|
270
|
+
assert.equal(parseIsoTimestamp("0099-01-01"), new Date("0099-01-01T00:00:00").getTime(), "years below 100 keep their literal value");
|
|
271
|
+
// Explicit offsets fix the instant.
|
|
272
|
+
assert.equal(parseIsoTimestamp("2026-11-27T13:40:05Z"), Date.UTC(2026, 10, 27, 13, 40, 5));
|
|
273
|
+
assert.equal(parseIsoTimestamp("2026-11-27T13:40:05+08:00"), Date.UTC(2026, 10, 27, 5, 40, 5));
|
|
274
|
+
assert.equal(parseIsoTimestamp("2026-11-27T13:40:05-0530"), Date.UTC(2026, 10, 27, 19, 10, 5));
|
|
275
|
+
for (const invalid of ["2026-02-30", "2026-13-01", "2026-11-27T25:00", "2026-11-27T13:60", "2026-11-27T13:40:60", "yesterday", "2026-11-27 13:40", "2026-11-27T13", "2026-11-27T13:40:05 Z", ""]) {
|
|
276
|
+
assert.equal(parseIsoTimestamp(invalid), undefined, `${JSON.stringify(invalid)} is refused`);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
test("tool literal enums serialize as string enums and validate their values", () => {
|
|
280
|
+
const values = ["a", "b"];
|
|
281
|
+
const example = stringEnum(values, { description: "example", type: "number" });
|
|
282
|
+
const valid = "a";
|
|
283
|
+
// @ts-expect-error literal unions must not widen to arbitrary strings
|
|
284
|
+
const invalid = "c";
|
|
285
|
+
assert.equal(valid, "a");
|
|
286
|
+
assert.equal(invalid, "c");
|
|
287
|
+
const serialized = (schema) => JSON.parse(JSON.stringify(schema));
|
|
288
|
+
assert.equal(serialized(example).type, "string");
|
|
289
|
+
assert.equal(serialized(example).description, "example");
|
|
290
|
+
const origins = ["user", "self", "external"];
|
|
291
|
+
const roles = ["user", "assistant", "tool", "context"];
|
|
292
|
+
const shapes = [
|
|
293
|
+
[serialized(notesWrite.parameters).properties.origin, origins],
|
|
294
|
+
[serialized(notesUpdate.parameters).properties.origin, origins],
|
|
295
|
+
[serialized(notesRead.outputSchema).anyOf[0].properties.metadata.properties.origin, origins],
|
|
296
|
+
[serialized(historyList.parameters).properties.roles.items, roles],
|
|
297
|
+
[serialized(historySearch.parameters).properties.roles.items, roles],
|
|
298
|
+
[serialized(ToolCallStatusSchema), ["ok", "error", "unfinished"]],
|
|
299
|
+
];
|
|
300
|
+
for (const [schema, expected] of shapes) {
|
|
301
|
+
assert.equal(schema.type, "string");
|
|
302
|
+
assert.deepEqual(schema.enum, expected);
|
|
303
|
+
assert.equal(schema.anyOf, undefined);
|
|
304
|
+
}
|
|
305
|
+
for (const [schema, allowed] of [[notesWrite.parameters.properties.origin, origins], [HistoryRoleSchema, roles], [ToolCallStatusSchema, ["ok", "error", "unfinished"]]]) {
|
|
306
|
+
for (const value of allowed)
|
|
307
|
+
assert.equal(Check(schema, value), true);
|
|
308
|
+
for (const value of ["invalid", 1, true, {}, null]) {
|
|
309
|
+
assert.equal(Check(schema, value), false, `${JSON.stringify(value)} is rejected`);
|
|
310
|
+
assert.notEqual(paramProblem(schema, value), "unrecognized shape");
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
for (const [parameters, base] of [[notesWrite.parameters, { address: "a", content: "b" }], [notesUpdate.parameters, { address: "a" }]]) {
|
|
314
|
+
for (const value of ["invalid", 1, true, {}, null]) {
|
|
315
|
+
const params = { ...base, origin: value };
|
|
316
|
+
assert.equal(Check(parameters.properties.origin, value), false);
|
|
317
|
+
assert.match(paramProblem(parameters, params), /origin/);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
test("the role filter uses the four public history roles", () => {
|
|
322
|
+
assert.deepEqual(historyRoles().items, HistoryRoleSchema);
|
|
271
323
|
for (const role of ["user", "assistant", "tool", "context"]) {
|
|
272
324
|
assert.equal(Check(HistoryRoleSchema, role), true, `${role} is a public role`);
|
|
273
|
-
assert.equal(Check(historyRead.outputSchema, read(role)), true, `history_read accepts ${role}`);
|
|
274
325
|
}
|
|
275
|
-
assert.equal(Check(HistoryRoleSchema, "developer"), false
|
|
276
|
-
assert.equal(Check(historyRead.outputSchema, read("developer")), false, "history_read refuses a role outside the four");
|
|
326
|
+
assert.equal(Check(HistoryRoleSchema, "developer"), false);
|
|
277
327
|
});
|
|
278
328
|
test("history paging bounds are the schema's, and a zero limit still pages one event", async () => {
|
|
279
329
|
const items = Array.from({ length: 3 }, (_, index) => ({ seq: index + 1, windowId: "root", role: "user", text: `message-${index}` }));
|
package/dist/test/marker.test.js
CHANGED
|
@@ -10,7 +10,7 @@ test.beforeEach(env.beforeEach);
|
|
|
10
10
|
test.afterEach(env.afterEach);
|
|
11
11
|
test.after(env.dispose);
|
|
12
12
|
function beforeAgentStart(captured, ctx) {
|
|
13
|
-
return runHandlers(captured, "before_agent_start", { type: "before_agent_start", systemPromptOptions: { sections: {} } }, ctx);
|
|
13
|
+
return runHandlers(captured, "before_agent_start", { type: "before_agent_start", systemPromptOptions: { sections: {}, skills: [] } }, ctx);
|
|
14
14
|
}
|
|
15
15
|
test("marker stamps its own seq at run start once the interval is reached, never mid-turn", async () => {
|
|
16
16
|
const sessionManager = managerWithMessages(99);
|
|
@@ -22,7 +22,7 @@ function data(outcome) {
|
|
|
22
22
|
const refused = (code) => (error) => error instanceof NoteError && error.code === code;
|
|
23
23
|
async function fillPins(notes, prefix = "") {
|
|
24
24
|
for (const name of ["CHEATSHEET.md", "MAP.md", "one.md", "two.md", "three.md"]) {
|
|
25
|
-
await notes.write(`${prefix}${name}`, `body ${name}`,
|
|
25
|
+
await notes.write(`${prefix}${name}`, `body ${name}`, { pinned: true });
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
async function boot(identity) {
|
|
@@ -37,7 +37,8 @@ test("frontmatter policy round-trips without materializing defaults; arbitrary e
|
|
|
37
37
|
await notes.write("MAP", "index");
|
|
38
38
|
const defaults = (await notes.read("MAP")).meta;
|
|
39
39
|
assert.equal(defaults.pinned, undefined);
|
|
40
|
-
assert.deepEqual(effectiveNotePolicy(defaults, "MAP.md"), { pinned:
|
|
40
|
+
assert.deepEqual(effectiveNotePolicy(defaults, "MAP.md"), { pinned: false, budget: 8192, readonly: false });
|
|
41
|
+
assert.deepEqual(effectiveNotePolicy(defaults, "CHEATSHEET.md"), { pinned: true, budget: 4096, readonly: false });
|
|
41
42
|
assert.equal(effectiveNotePolicy(defaults, "nested/MAP.md").pinned, false);
|
|
42
43
|
writeFileSync(file("MAP.md"), readFileSync(file("MAP.md"), "utf8").replace("\n---\n\n", "\npinned: false\nbudget: 3000\nreadonly: true\ncustom: {\"nested\":[1,\"two\"]}\n---\n\n"));
|
|
43
44
|
const meta = (await notes.read("MAP")).meta;
|
|
@@ -50,15 +51,15 @@ test("frontmatter policy round-trips without materializing defaults; arbitrary e
|
|
|
50
51
|
assert.deepEqual(persisted.meta.custom, { nested: [1, "two"] });
|
|
51
52
|
assert.equal(persisted.body, "new index");
|
|
52
53
|
});
|
|
53
|
-
test("default budgets distinguish root
|
|
54
|
+
test("default budgets distinguish root CHEATSHEET from ordinary notes, independently of pinning", async (t) => {
|
|
54
55
|
const { context, notes } = fixture(t);
|
|
55
56
|
for (const [address, budget, pinned] of [
|
|
56
|
-
["MAP",
|
|
57
|
-
["CHEATSHEET",
|
|
58
|
-
["ordinary",
|
|
59
|
-
["custom-pin",
|
|
60
|
-
["nested/MAP",
|
|
61
|
-
["nested/CHEATSHEET",
|
|
57
|
+
["MAP", 8192, undefined],
|
|
58
|
+
["CHEATSHEET", 4096, undefined],
|
|
59
|
+
["ordinary", 8192, undefined],
|
|
60
|
+
["custom-pin", 8192, true],
|
|
61
|
+
["nested/MAP", 8192, undefined],
|
|
62
|
+
["nested/CHEATSHEET", 8192, undefined],
|
|
62
63
|
]) {
|
|
63
64
|
const written = data(await notesWrite.execute({ address, content: "body", pinned }, context));
|
|
64
65
|
assert.equal(written.budget, budget, address);
|
|
@@ -68,48 +69,49 @@ test("default budgets distinguish root index pages from ordinary notes, independ
|
|
|
68
69
|
await notes.write("ordinary", "another replacement");
|
|
69
70
|
assert.equal(data(await notesRead.execute({ address: "ordinary" }, context)).metadata.budget, 1234);
|
|
70
71
|
});
|
|
71
|
-
test("tools
|
|
72
|
+
test("tools reject budget overrides, enforce UTF-8 byte warnings, and wrap warnings in <notesoup:warning>", async (t) => {
|
|
72
73
|
const { context, notes, file } = fixture(t);
|
|
73
74
|
for (const tool of [notesWrite, notesUpdate]) {
|
|
74
75
|
const required = tool === notesWrite ? { address: "x", content: "body" } : { address: "x" };
|
|
75
|
-
assert.equal(Check(tool.parameters, { ...required, pinned: false,
|
|
76
|
-
for (const invalid of [{ pinned: "false" }, { readonly: 1 }, { budget:
|
|
76
|
+
assert.equal(Check(tool.parameters, { ...required, pinned: false, readonly: true }), true);
|
|
77
|
+
for (const invalid of [{ pinned: "false" }, { readonly: 1 }, { budget: 100 }, { budget: 0 }]) {
|
|
77
78
|
assert.equal(Check(tool.parameters, { ...required, ...invalid }), false);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
assert.equal(
|
|
84
|
-
assert.
|
|
85
|
-
|
|
86
|
-
assert.
|
|
81
|
+
// Frontmatter / store budget override still works: 2 astral chars = 8 UTF-8 bytes.
|
|
82
|
+
await notes.write("custom", "๐".repeat(2), { budget: 8, pinned: true, readonly: true });
|
|
83
|
+
const written = await notesWrite.execute({ address: "custom", content: "๐".repeat(2), pinned: true, readonly: false }, context);
|
|
84
|
+
assert.equal("outputSchema" in notesWrite, false);
|
|
85
|
+
assert.deepEqual(data(written).warnings, [], "8 UTF-8 bytes fit within budget 8");
|
|
86
|
+
assert.equal(data(written).budget, 8);
|
|
87
|
+
assert.match(notesWrite.render(written), /^overwrote custom\.md \| pinned \| budget 8$/);
|
|
88
|
+
const updated = await notesUpdate.execute({ address: "custom", edits: [{ oldText: "๐".repeat(2), newText: "๐".repeat(3) }] }, context);
|
|
89
|
+
assert.equal("outputSchema" in notesUpdate, false);
|
|
87
90
|
assert.equal(data(updated).warnings.length, 1);
|
|
88
|
-
assert.match(notesUpdate.render(updated),
|
|
91
|
+
assert.match(notesUpdate.render(updated), /<notesoup:warning>note body is 12 bytes \(budget 8\); boot truncates it to budget โ trim, split, or unpin\.<\/notesoup:warning>/);
|
|
89
92
|
assert.equal((await notes.read("custom")).body, "๐".repeat(3), "over budget saves the entire body");
|
|
90
93
|
const read = await notesRead.execute({ address: "custom", max_chars: 10 }, context);
|
|
91
94
|
assert.equal(Check(notesRead.outputSchema, wireResult(read)), true);
|
|
92
|
-
assert.deepEqual({ pinned: data(read).metadata.pinned, budget: data(read).metadata.budget, readonly: data(read).metadata.readonly }, { pinned: true, budget:
|
|
93
|
-
assert.match(notesRead.render(read), /pinned true \| budget
|
|
94
|
-
assert.match(notesRead.render(read),
|
|
95
|
+
assert.deepEqual({ pinned: data(read).metadata.pinned, budget: data(read).metadata.budget, readonly: data(read).metadata.readonly }, { pinned: true, budget: 8, readonly: false });
|
|
96
|
+
assert.match(notesRead.render(read), /pinned true \| budget 8 \| readonly false/);
|
|
97
|
+
assert.match(notesRead.render(read), /<notesoup:warning>note body is 12 bytes \(budget 8\)/);
|
|
95
98
|
const list = await notesList.execute({}, context);
|
|
96
|
-
assert.equal(
|
|
99
|
+
assert.equal("outputSchema" in notesList, false);
|
|
97
100
|
assert.equal(data(list).files[0].pinned, true);
|
|
98
|
-
assert.match(notesList.render(list), /pinned
|
|
99
|
-
assert.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
assert.equal(data(search).files[0].budget,
|
|
103
|
-
assert.match(notesList.render(search), /pinned
|
|
104
|
-
assert.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
assert.
|
|
112
|
-
assert.equal(data(larger).change_kind, "metadata");
|
|
101
|
+
assert.match(notesList.render(list), /custom\.md \| pinned \| budget 8 \| updated/);
|
|
102
|
+
assert.doesNotMatch(notesList.render(list), /readonly false/);
|
|
103
|
+
assert.match(notesList.render(list), /<notesoup:warning>note body is 12 bytes \(budget 8\)/);
|
|
104
|
+
const search = await notesList.execute({ query: "๐", max_matches_per_note: 1 }, context);
|
|
105
|
+
assert.equal(data(search).files[0].budget, 8);
|
|
106
|
+
assert.match(notesList.render(search), /custom\.md \| pinned \| budget 8 \| updated/);
|
|
107
|
+
assert.doesNotMatch(notesList.render(search), /readonly false/);
|
|
108
|
+
assert.match(notesList.render(search), /<notesoup:warning>note body is 12 bytes \(budget 8\)/);
|
|
109
|
+
await notes.write("unpinned-over", "x".repeat(8193));
|
|
110
|
+
const overflow = await notesRead.execute({ address: "unpinned-over" }, context);
|
|
111
|
+
assert.match(notesRead.render(overflow), /<notesoup:warning>note body is 8193 bytes \(budget 8192\); trim or split it\.<\/notesoup:warning>/);
|
|
112
|
+
const larger = await notes.update("custom", undefined, { budget: 16, pinned: false });
|
|
113
|
+
assert.deepEqual(larger.warnings, []);
|
|
114
|
+
assert.equal(larger.change.kind, "metadata");
|
|
113
115
|
const before = readFileSync(file("custom.md"), "utf8");
|
|
114
116
|
// Runtime JavaScript callers bypass schemas; the real store still validates before saving.
|
|
115
117
|
for (const invalid of [{ pinned: "false" }, { budget: null }, { readonly: "yes" }]) {
|
|
@@ -117,7 +119,7 @@ test("tools set policy, validate values, and visibly report effective policy and
|
|
|
117
119
|
await assert.rejects(() => notes.update("custom", undefined, invalid), refused("invalid_policy"));
|
|
118
120
|
assert.equal(readFileSync(file("custom.md"), "utf8"), before);
|
|
119
121
|
}
|
|
120
|
-
writeFileSync(file("custom.md"), before.replace("budget:
|
|
122
|
+
writeFileSync(file("custom.md"), before.replace("budget: 16", "budget: -1"));
|
|
121
123
|
const badFrontmatter = await notesRead.execute({ address: "custom" }, context);
|
|
122
124
|
assert.equal(badFrontmatter.ok, false);
|
|
123
125
|
if (!badFrontmatter.ok)
|
|
@@ -206,9 +208,9 @@ test("pin admission serializes across store instances without blocking reads or
|
|
|
206
208
|
});
|
|
207
209
|
test("moves resolve absent policy at the new path, preserving explicit false/true", async (t) => {
|
|
208
210
|
const { notes, file } = fixture(t);
|
|
209
|
-
await notes.write("
|
|
210
|
-
await notes.rename("
|
|
211
|
-
assert.deepEqual(effectiveNotePolicy((await notes.read("ordinary")).meta, "ordinary.md"), { pinned: false, budget:
|
|
211
|
+
await notes.write("CHEATSHEET", "default");
|
|
212
|
+
await notes.rename("CHEATSHEET", "ordinary");
|
|
213
|
+
assert.deepEqual(effectiveNotePolicy((await notes.read("ordinary")).meta, "ordinary.md"), { pinned: false, budget: 8192, readonly: false });
|
|
212
214
|
await notes.rename("ordinary", "CHEATSHEET");
|
|
213
215
|
assert.equal(effectiveNotePolicy((await notes.read("CHEATSHEET")).meta, "CHEATSHEET.md").pinned, true);
|
|
214
216
|
assert.equal(parseNote(readFileSync(file("CHEATSHEET.md"), "utf8")).meta.pinned, undefined);
|
|
@@ -219,32 +221,163 @@ test("moves resolve absent policy at the new path, preserving explicit false/tru
|
|
|
219
221
|
for (let n = 0; n < 4; n++)
|
|
220
222
|
await notes.write(`extra-${n}`, "pin", { pinned: true });
|
|
221
223
|
await notes.write("candidate", "candidate");
|
|
222
|
-
await assert.rejects(() => notes.rename("candidate", "
|
|
224
|
+
await assert.rejects(() => notes.rename("candidate", "CHEATSHEET"), refused("pin_limit"));
|
|
223
225
|
assert.equal((await notes.read("candidate")).body, "candidate");
|
|
224
|
-
await notes.update("candidate", undefined, { renameTo: "
|
|
225
|
-
assert.equal(effectiveNotePolicy((await notes.read("
|
|
226
|
+
await notes.update("candidate", undefined, { renameTo: "CHEATSHEET", pinned: false });
|
|
227
|
+
assert.equal(effectiveNotePolicy((await notes.read("CHEATSHEET")).meta, "CHEATSHEET.md").pinned, false);
|
|
226
228
|
});
|
|
227
|
-
test("boot uses metadata pins,
|
|
228
|
-
const { identity, notes, file } = fixture(t);
|
|
229
|
-
|
|
229
|
+
test("boot uses metadata pins, truncates over-budget pins at byte budget with outside warning, and names legacy over-cap omissions", async (t) => {
|
|
230
|
+
const { identity, notes, file, context } = fixture(t);
|
|
231
|
+
const body = "# Default rules\n\n- first rule\n - nested rule\n\n```ts\n const value = 1;\n```";
|
|
232
|
+
await notes.write("CHEATSHEET", body);
|
|
230
233
|
await notes.write("MAP", "# Unpinned map\nMAP_NOT_INJECTED", { pinned: false });
|
|
231
|
-
|
|
234
|
+
// 5 emojis (20 bytes) + 12 ASCII chars = 32 bytes; budget 10 bytes fits 2 emojis (8 bytes, 2 chars).
|
|
235
|
+
await notes.write("custom", "๐".repeat(5) + "TAIL_IS_HERE", { pinned: true, budget: 10 });
|
|
232
236
|
await notes.write("nested/MAP", "# Nested map\nNESTED_NOT_INJECTED");
|
|
233
237
|
await notes.write("roomy", "R".repeat(3000), { pinned: true, budget: 3000 });
|
|
234
238
|
let rendered = await boot(identity);
|
|
235
|
-
|
|
236
|
-
assert.ok(rendered.includes(
|
|
237
|
-
assert.
|
|
239
|
+
const pinned = `โโ CHEATSHEET.md โโ\n\n${body}\n\nโโ end of note โโ`;
|
|
240
|
+
assert.ok(rendered.includes(pinned), "the pinned note retains its exact Markdown indentation");
|
|
241
|
+
assert.ok(rendered.indexOf(pinned) < rendered.indexOf("โโ custom.md โโ"));
|
|
242
|
+
const customWarning = "<notesoup:warning>note body is 32 bytes (budget 10); boot truncates it to budget โ trim, split, or unpin.</notesoup:warning>";
|
|
243
|
+
const customBlock = `${customWarning}\nโโ custom.md โโ\n\n${"๐".repeat(2)}\n\n[truncated at 2/17; offset_chars=2]\n\nโโ end of note โโ`;
|
|
244
|
+
assert.ok(rendered.includes(customBlock), "warning sits outside the note frame and body truncates cleanly on a code-point boundary");
|
|
245
|
+
assert.equal(rendered.includes("TAIL_IS_HERE"), false, "overflow tail is truncated in boot");
|
|
246
|
+
const resumed = data(await notesRead.execute({ address: "custom", offset_chars: 2 }, context));
|
|
247
|
+
assert.equal(resumed.text, "๐".repeat(3) + "TAIL_IS_HERE", "offset_chars resumes cleanly from the exact truncated code point");
|
|
238
248
|
assert.ok(rendered.includes("R".repeat(3000)));
|
|
239
249
|
assert.equal(rendered.includes("MAP_NOT_INJECTED"), false);
|
|
240
250
|
assert.equal(rendered.includes("NESTED_NOT_INJECTED"), false);
|
|
241
251
|
assert.match(rendered, /MAP.md ยท/); // explicit false gets a normal recent seat
|
|
242
252
|
await notes.write("a", "body a", { pinned: true });
|
|
243
|
-
await notes.write("b", "
|
|
253
|
+
await notes.write("b", "๐", { pinned: true, budget: 2 }); // first char exceeds budget
|
|
244
254
|
await notes.write("z", "OMITTED_PIN_BODY");
|
|
245
255
|
writeFileSync(file("z.md"), readFileSync(file("z.md"), "utf8").replace("\n---\n\n", "\npinned: true\n---\n\n"));
|
|
246
256
|
rendered = await boot(identity);
|
|
247
|
-
assert.
|
|
257
|
+
assert.ok(rendered.includes("โโ b.md โโ\n\n[truncated at 0/1; offset_chars=0]\n\nโโ end of note โโ"), "zero-char cut emits clean marker without leading blank lines");
|
|
258
|
+
assert.match(rendered, /<notesoup:warning>only 5 pinned notes per notebook are injected; omitted pins: z.md/);
|
|
248
259
|
assert.equal(rendered.includes("OMITTED_PIN_BODY"), false);
|
|
249
|
-
|
|
260
|
+
});
|
|
261
|
+
test("MAP.md is an ordinary note by default while CHEATSHEET.md stays the one default pin", async (t) => {
|
|
262
|
+
const { notes, context } = fixture(t);
|
|
263
|
+
await notes.write("MAP", "legacy hand-written index");
|
|
264
|
+
await notes.write("CHEATSHEET", "rules");
|
|
265
|
+
const map = (await notes.read("MAP")).meta;
|
|
266
|
+
const cheatsheet = (await notes.read("CHEATSHEET")).meta;
|
|
267
|
+
assert.deepEqual(effectiveNotePolicy(map, "MAP.md"), { pinned: false, budget: 8192, readonly: false });
|
|
268
|
+
assert.deepEqual(effectiveNotePolicy(cheatsheet, "CHEATSHEET.md"), { pinned: true, budget: 4096, readonly: false });
|
|
269
|
+
await notes.rename("MAP", "moved-map");
|
|
270
|
+
assert.deepEqual(effectiveNotePolicy((await notes.read("moved-map")).meta, "moved-map.md"), { pinned: false, budget: 8192, readonly: false });
|
|
271
|
+
const listed = data(await notesList.execute({}, context));
|
|
272
|
+
assert.equal(listed.files.find(file => file.address === "CHEATSHEET.md")?.pinned, true);
|
|
273
|
+
assert.equal(listed.files.find(file => file.address === "moved-map.md")?.pinned, false, "MAP.md keeps no special role after a move");
|
|
274
|
+
});
|
|
275
|
+
test("description normalizes to one line, persists, renders in read and list, and clears on empty", async (t) => {
|
|
276
|
+
const { identity, notes, file, context } = fixture(t);
|
|
277
|
+
const written = await notesWrite.execute({ address: "described", content: "body", description: " first\n\tsecond third " }, context);
|
|
278
|
+
assert.equal(written.ok, true);
|
|
279
|
+
assert.equal((await notes.read("described")).meta.description, "first second third");
|
|
280
|
+
assert.match(readFileSync(file("described.md"), "utf8"), /^description: "first second third"$/m);
|
|
281
|
+
const read = data(await notesRead.execute({ address: "described" }, context));
|
|
282
|
+
assert.equal(read.metadata.description, "first second third");
|
|
283
|
+
assert.equal("description" in read.metadata.extra, false, "description is normalized metadata, not an extra");
|
|
284
|
+
assert.match(notesRead.render(await notesRead.execute({ address: "described" }, context)), /description first second third/);
|
|
285
|
+
const listed = data(await notesList.execute({}, context));
|
|
286
|
+
assert.equal(listed.files.find(file => file.address === "described.md")?.description, "first second third");
|
|
287
|
+
assert.match(notesList.render(await notesList.execute({}, context)), /described\.md โ first second third/);
|
|
288
|
+
// Omitting description on an edit keeps it; providing the same one is a valid no-op.
|
|
289
|
+
await notes.update("described", [{ oldText: "body", newText: "body two" }]);
|
|
290
|
+
assert.equal((await notes.read("described")).meta.description, "first second third");
|
|
291
|
+
const unchanged = data(await notesUpdate.execute({ address: "described", description: "first second third" }, context));
|
|
292
|
+
assert.equal(unchanged.change_kind, "none");
|
|
293
|
+
const changed = data(await notesUpdate.execute({ address: "described", description: "now this" }, context));
|
|
294
|
+
assert.equal(changed.change_kind, "metadata", "description alone is an operation");
|
|
295
|
+
assert.equal((await notes.read("described")).meta.description, "now this");
|
|
296
|
+
// An empty value clears the key; a whitespace-only value is empty too.
|
|
297
|
+
await notesUpdate.execute({ address: "described", description: " \n\t " }, context);
|
|
298
|
+
assert.equal((await notes.read("described")).meta.description, undefined);
|
|
299
|
+
assert.equal(/^description:/m.test(readFileSync(file("described.md"), "utf8")), false);
|
|
300
|
+
// Exactly 160 code points saves cleanly; over 160 saves with a warning and truncates in boot.
|
|
301
|
+
const exact = await notesWrite.execute({ address: "max", content: "body", description: "๐".repeat(160) }, context);
|
|
302
|
+
assert.equal(exact.ok, true);
|
|
303
|
+
assert.deepEqual(data(exact).warnings, [], "160 astral code points fit without warning");
|
|
304
|
+
assert.equal((await notes.read("max")).meta.description, "๐".repeat(160), "160 astral code points fit");
|
|
305
|
+
const tooLong = "๐".repeat(161);
|
|
306
|
+
const writtenLong = await notesWrite.execute({ address: "too-long", content: "body", description: tooLong }, context);
|
|
307
|
+
assert.equal(writtenLong.ok, true);
|
|
308
|
+
assert.equal(data(writtenLong).warnings.length, 1);
|
|
309
|
+
assert.match(notesWrite.render(writtenLong), /<notesoup:warning>description is 161 chars \(max 160\); boot index truncates it\.<\/notesoup:warning>/);
|
|
310
|
+
assert.equal((await notes.read("too-long")).meta.description, tooLong, "an oversized description still saves whole");
|
|
311
|
+
const updatedLong = await notesUpdate.execute({ address: "described", description: tooLong }, context);
|
|
312
|
+
assert.equal(updatedLong.ok, true);
|
|
313
|
+
assert.equal(data(updatedLong).warnings.length, 1);
|
|
314
|
+
assert.match(notesUpdate.render(updatedLong), /<notesoup:warning>description is 161 chars \(max 160\); boot index truncates it\.<\/notesoup:warning>/);
|
|
315
|
+
assert.equal((await notes.read("described")).meta.description, tooLong);
|
|
316
|
+
const readLong = await notesRead.execute({ address: "too-long" }, context);
|
|
317
|
+
assert.equal(data(readLong).warnings.length, 1);
|
|
318
|
+
assert.match(notesRead.render(readLong), /<notesoup:warning>description is 161 chars \(max 160\)/);
|
|
319
|
+
const listLong = await notesList.execute({ glob: "too-long.md" }, context);
|
|
320
|
+
assert.equal(data(listLong).files[0]?.warnings.length, 1);
|
|
321
|
+
assert.match(notesList.render(listLong), /<notesoup:warning>description is 161 chars \(max 160\)/);
|
|
322
|
+
const renderedLong = await boot(identity);
|
|
323
|
+
assert.ok(renderedLong.includes(`${"๐".repeat(160)}โฆ`), "boot index truncates saved over-160 descriptions");
|
|
324
|
+
assert.equal(renderedLong.includes(tooLong), false);
|
|
325
|
+
const shortened = await notesUpdate.execute({ address: "described", description: "short again" }, context);
|
|
326
|
+
assert.deepEqual(data(shortened).warnings, [], "shortening the description clears the warning");
|
|
327
|
+
});
|
|
328
|
+
test("boot auto-indexes unpinned notes newest first with description, fallback title, and pinned/crumpled omissions", async (t) => {
|
|
329
|
+
const { identity, notes } = fixture(t);
|
|
330
|
+
await notes.write("CHEATSHEET", "rules");
|
|
331
|
+
await notes.write("described", "body", { description: "when to open this" });
|
|
332
|
+
await notes.write("heading", "# Heading title\nbody");
|
|
333
|
+
await notes.write("plain", "first line only\nsecond line");
|
|
334
|
+
await notes.write("hidden", "PINNED_BODY", { pinned: true });
|
|
335
|
+
await notes.write("gone", "CRUMPLED_BODY");
|
|
336
|
+
await notes.update("gone", undefined, { crumpled: true });
|
|
337
|
+
const rendered = await boot(identity);
|
|
338
|
+
assert.equal(rendered.includes("recent"), false, "the old recent label is gone");
|
|
339
|
+
assert.match(rendered, /^โโ index โโ$/m, "the index follows pinned pages under one subheader");
|
|
340
|
+
assert.match(rendered, /^plain\.md ยท just now โ first line only$/m);
|
|
341
|
+
assert.match(rendered, /^heading\.md ยท just now โ Heading title$/m);
|
|
342
|
+
assert.match(rendered, /^described\.md ยท just now โ when to open this$/m);
|
|
343
|
+
assert.ok(rendered.indexOf("plain.md ยท") < rendered.indexOf("heading.md ยท"), "newest unpinned note leads");
|
|
344
|
+
assert.ok(rendered.indexOf("heading.md ยท") < rendered.indexOf("described.md ยท"));
|
|
345
|
+
assert.equal(rendered.includes("hidden.md ยท"), false, "pinned pages do not repeat in the index");
|
|
346
|
+
assert.equal(rendered.includes("gone.md ยท"), false, "crumpled pages do not index");
|
|
347
|
+
assert.equal(rendered.includes("PINNED_BODY"), true, "pinned pages still load whole");
|
|
348
|
+
assert.equal(rendered.includes("CRUMPLED_BODY"), false);
|
|
349
|
+
// A shelf with no pinned pages drops the redundant subheader and still indexes.
|
|
350
|
+
await notes.update("CHEATSHEET", undefined, { pinned: false, crumpled: true });
|
|
351
|
+
await notes.update("hidden", undefined, { crumpled: true });
|
|
352
|
+
const bare = await boot(identity);
|
|
353
|
+
assert.equal(/^โโ index โโ$/m.test(bare), false);
|
|
354
|
+
assert.match(bare, /^plain\.md ยท just now โ first line only$/m);
|
|
355
|
+
});
|
|
356
|
+
test("boot shelf index enforces entry and character caps with an explicit omission marker", async (t) => {
|
|
357
|
+
const { identity, notes } = fixture(t);
|
|
358
|
+
for (let index = 0; index < 26; index++)
|
|
359
|
+
await notes.write(`bulk-${index}`, "body", { description: "d" });
|
|
360
|
+
const entries = await boot(identity);
|
|
361
|
+
assert.equal(entries.split(" ยท just now โ d").length - 1, 25, "only 25 entries fit");
|
|
362
|
+
assert.match(entries, /^โฆ and 1 more \(use notes_list\)$/m);
|
|
363
|
+
assert.equal(entries.includes("bulk-0.md ยท"), false, "the oldest entry is the one left out");
|
|
364
|
+
const wide = fixture(t);
|
|
365
|
+
for (let index = 0; index < 25; index++)
|
|
366
|
+
await wide.notes.write(`big-${index}`, "body", { description: `${index}`.padStart(2, "0") + "x".repeat(158) });
|
|
367
|
+
const capped = await boot(wide.identity);
|
|
368
|
+
const shown = capped.split("big-").length - 1;
|
|
369
|
+
assert.ok(shown > 0 && shown < 25, `the character cap cuts the list (${shown} shown)`);
|
|
370
|
+
assert.match(capped, /โฆ and \d+ more \(use notes_list\)/);
|
|
371
|
+
assert.equal(capped.includes("big-00.md ยท"), false, "the oldest page falls past the character cap");
|
|
372
|
+
});
|
|
373
|
+
test("a hand-edited oversized description never breaks boot and is cut for display", async (t) => {
|
|
374
|
+
const { identity, notes, file } = fixture(t);
|
|
375
|
+
await notes.write("long", "body");
|
|
376
|
+
const oversized = "z".repeat(200);
|
|
377
|
+
writeFileSync(file("long.md"), readFileSync(file("long.md"), "utf8").replace("\n---\n\n", `\ndescription: ${oversized}\n---\n\n`));
|
|
378
|
+
const snapshot = await loadNotesSnapshot(identity, Date.now());
|
|
379
|
+
assert.equal(snapshot.namespaces.get("session")?.find(row => row.path === "long.md")?.meta.description, oversized, "reads tolerate a hand-edited oversize value");
|
|
380
|
+
const rendered = await boot(identity);
|
|
381
|
+
assert.ok(rendered.includes(`${"z".repeat(160)}โฆ`), "display truncates at 160 code points");
|
|
382
|
+
assert.equal(rendered.includes(oversized), false);
|
|
250
383
|
});
|