notesoup 0.61.0 → 0.63.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 -11
- 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 +24 -5
- package/dist/plugins/claude/src/text.d.ts +7 -0
- package/dist/plugins/claude/src/text.js +12 -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 +4 -1
- package/dist/plugins/pi/budget.js +35 -8
- package/dist/plugins/pi/entries.d.ts +2 -0
- package/dist/plugins/pi/entries.js +2 -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/artifacts.d.ts +1 -1
- package/dist/plugins/pi/reset/artifacts.js +4 -4
- package/dist/plugins/pi/reset/lifecycle.d.ts +9 -2
- package/dist/plugins/pi/reset/lifecycle.js +109 -31
- package/dist/plugins/pi/runtime.js +104 -63
- package/dist/plugins/pi/tool-result.js +7 -7
- package/dist/plugins/pi/window.d.ts +25 -3
- package/dist/plugins/pi/window.js +219 -9
- package/dist/src/boot/render.js +18 -15
- package/dist/src/boot/text.d.ts +3 -1
- package/dist/src/boot/text.js +22 -20
- package/dist/src/budget/text.d.ts +7 -3
- package/dist/src/budget/text.js +24 -15
- 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 +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/notes/errors.d.ts +1 -1
- package/dist/src/notes/frontmatter.d.ts +0 -2
- package/dist/src/notes/frontmatter.js +0 -2
- 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 +46 -5
- package/dist/src/notes/store.d.ts +12 -0
- package/dist/src/notes/store.js +16 -20
- 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 -93
- 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 +51 -163
- package/dist/src/tools/notes.js +146 -100
- 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 +394 -56
- 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 +156 -15
- package/dist/test/budget-settings.integration.test.js +4 -4
- package/dist/test/claude-history.test.js +14 -13
- package/dist/test/claude-mod.test.js +199 -16
- package/dist/test/claude-validation.test.js +69 -2
- 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 +68 -3
- package/dist/test/helpers/extension.js +74 -5
- 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/model-facing-text.test.js +13 -3
- package/dist/test/note-policy.test.js +96 -77
- 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 +12 -2
- package/docs/antigravity.md +44 -0
- package/docs/architecture.md +6 -4
- package/docs/claude-code-mod.md +7 -7
- package/docs/codex.md +36 -38
- package/docs/dsh.md +3 -3
- package/docs/history-sessions.md +28 -50
- package/docs/notes-library.md +4 -4
- 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 +1 -1
- 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 +1108 -539
- package/plugins/claude/hooks/register.ts +202 -62
- package/plugins/claude/playbook.md +1 -1
- package/plugins/claude/skills/dream/SKILL.md +1 -1
- package/plugins/claude/skills/notesoup-guide/SKILL.md +92 -0
- package/plugins/claude/src/helper.ts +24 -5
- package/plugins/claude/src/text.ts +14 -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 +18480 -17946
- 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 +31 -8
- package/plugins/pi/entries.ts +2 -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/artifacts.ts +4 -3
- package/plugins/pi/reset/lifecycle.ts +125 -32
- package/plugins/pi/runtime.ts +98 -62
- package/plugins/pi/tool-result.ts +8 -8
- package/plugins/pi/window.ts +210 -10
- package/skills/dream/SKILL.md +1 -1
- package/skills/notesoup-guide/SKILL.md +92 -0
- package/src/boot/render.ts +18 -15
- package/src/boot/text.ts +23 -19
- package/src/budget/text.ts +27 -15
- 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 +2 -2
- package/src/notes/errors.ts +1 -1
- package/src/notes/frontmatter.ts +0 -3
- package/src/notes/index.ts +1 -1
- package/src/notes/policy.ts +44 -5
- package/src/notes/store.ts +17 -20
- 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 +145 -113
- 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);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
import { DEFAULT_BOOT_TOOL_NAMES, NOTES_PROTOCOL_CLOSE_TAG, renderProtocolBlock } from "../src/boot/text.js";
|
|
4
|
-
import { CLAUDE_WARNING_PROMPT } from "../plugins/claude/src/text.js";
|
|
4
|
+
import { CLAUDE_COMMAND_NOTICE, CLAUDE_WARNING_PROMPT, claudeCommandWarningContent } from "../plugins/claude/src/text.js";
|
|
5
5
|
import { COMMAND_NOTICE, PI_PRE_RESET_HINTS, commandWarningContent, warningContent } from "../plugins/pi/text.js";
|
|
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";
|
|
6
|
+
import { BETWEEN_TURNS_CONTINUATIONS, 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";
|
|
7
7
|
test("early guidance binds the remaining room and the host's reset tool", () => {
|
|
8
8
|
const guidance = tokenBudgetGuidance(1234, "forget_this");
|
|
9
9
|
assert.ok(guidance.startsWith(`${GUIDANCE_OPEN_TAG}\n`));
|
|
@@ -27,6 +27,12 @@ test("the countdown closes the second-tier notice only, in both hosts", () => {
|
|
|
27
27
|
assert.ok(CLAUDE_WARNING_PROMPT.endsWith(`\n${COUNTDOWN_LINE}\n${GUIDANCE_CLOSE_TAG}`));
|
|
28
28
|
assert.equal(prompted.includes(WARNING_TIMING), false, "manual requests replace the budget opening");
|
|
29
29
|
assert.equal(tokenBudgetGuidance(100, "empty_brain").includes(COUNTDOWN_LINE), false, "the first tier never counts down");
|
|
30
|
+
const claudeBare = claudeCommandWarningContent();
|
|
31
|
+
const claudePrompted = claudeCommandWarningContent("/empty keep going");
|
|
32
|
+
assert.equal(claudeBare, `${GUIDANCE_OPEN_TAG}\n${CLAUDE_COMMAND_NOTICE.bare}\n${WARNING_BODY}\n${WARNING_CALL}\n${COUNTDOWN_LINE}\n${GUIDANCE_CLOSE_TAG}`);
|
|
33
|
+
assert.equal(claudePrompted, `${GUIDANCE_OPEN_TAG}\n${CLAUDE_COMMAND_NOTICE.prompted}\n${WARNING_BODY}\n${WARNING_CALL}\n${COUNTDOWN_LINE}\n${GUIDANCE_CLOSE_TAG}\n/empty keep going`);
|
|
34
|
+
assert.equal(claudeBare.includes("erased afterward"), false, "Claude manual close-out never claims the chat view is erased");
|
|
35
|
+
assert.equal(claudeBare.includes(WARNING_TIMING), false, "Claude manual close-out omits budget timing");
|
|
30
36
|
});
|
|
31
37
|
test("only Pi's protocol explains that reset erases the human's view", () => {
|
|
32
38
|
const pi = renderProtocolBlock({ ...DEFAULT_BOOT_TOOL_NAMES, preResetHints: PI_PRE_RESET_HINTS });
|
|
@@ -42,19 +48,23 @@ test("only Pi's protocol explains that reset erases the human's view", () => {
|
|
|
42
48
|
test("continuations draw a complete entry from the pool for their reset origin", () => {
|
|
43
49
|
assert.ok(NORMAL_CONTINUATIONS.length > 0);
|
|
44
50
|
assert.ok(FORCED_CONTINUATIONS.length > 0);
|
|
51
|
+
assert.ok(BETWEEN_TURNS_CONTINUATIONS.length > 0);
|
|
45
52
|
const random = Math.random;
|
|
46
53
|
try {
|
|
47
54
|
Math.random = () => 0;
|
|
48
55
|
assert.equal(selectContinuation("normal"), NORMAL_CONTINUATIONS[0]);
|
|
49
56
|
assert.equal(selectContinuation("forced"), FORCED_CONTINUATIONS[0]);
|
|
57
|
+
assert.equal(selectContinuation("forced", { betweenTurns: true }), BETWEEN_TURNS_CONTINUATIONS[0]);
|
|
58
|
+
assert.equal(selectContinuation("normal", { betweenTurns: true }), NORMAL_CONTINUATIONS[0], "voluntary resets stay in the normal pool");
|
|
50
59
|
Math.random = () => 0.999999;
|
|
51
60
|
assert.equal(selectContinuation("normal"), NORMAL_CONTINUATIONS.at(-1), "the last entry is reachable without leaving the pool");
|
|
52
61
|
assert.equal(selectContinuation("forced"), FORCED_CONTINUATIONS.at(-1));
|
|
62
|
+
assert.equal(selectContinuation("forced", { betweenTurns: true }), BETWEEN_TURNS_CONTINUATIONS.at(-1));
|
|
53
63
|
}
|
|
54
64
|
finally {
|
|
55
65
|
Math.random = random;
|
|
56
66
|
}
|
|
57
|
-
for (const line of [...NORMAL_CONTINUATIONS, ...FORCED_CONTINUATIONS]) {
|
|
67
|
+
for (const line of [...NORMAL_CONTINUATIONS, ...FORCED_CONTINUATIONS, ...BETWEEN_TURNS_CONTINUATIONS]) {
|
|
58
68
|
assert.ok(line.length > 0);
|
|
59
69
|
assert.equal(/[\r\n]/.test(line), false, "a pool entry is one complete paragraph");
|
|
60
70
|
assert.equal(line.trim(), line, "no entry carries stray surrounding whitespace");
|
|
@@ -37,8 +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: false, budget:
|
|
41
|
-
assert.deepEqual(effectiveNotePolicy(defaults, "CHEATSHEET.md"), { pinned: true, budget:
|
|
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 });
|
|
42
42
|
assert.equal(effectiveNotePolicy(defaults, "nested/MAP.md").pinned, false);
|
|
43
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"));
|
|
44
44
|
const meta = (await notes.read("MAP")).meta;
|
|
@@ -51,15 +51,15 @@ test("frontmatter policy round-trips without materializing defaults; arbitrary e
|
|
|
51
51
|
assert.deepEqual(persisted.meta.custom, { nested: [1, "two"] });
|
|
52
52
|
assert.equal(persisted.body, "new index");
|
|
53
53
|
});
|
|
54
|
-
test("default budgets distinguish root
|
|
54
|
+
test("default budgets distinguish root CHEATSHEET from ordinary notes, independently of pinning", async (t) => {
|
|
55
55
|
const { context, notes } = fixture(t);
|
|
56
56
|
for (const [address, budget, pinned] of [
|
|
57
|
-
["MAP",
|
|
58
|
-
["CHEATSHEET",
|
|
59
|
-
["ordinary",
|
|
60
|
-
["custom-pin",
|
|
61
|
-
["nested/MAP",
|
|
62
|
-
["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],
|
|
63
63
|
]) {
|
|
64
64
|
const written = data(await notesWrite.execute({ address, content: "body", pinned }, context));
|
|
65
65
|
assert.equal(written.budget, budget, address);
|
|
@@ -69,48 +69,49 @@ test("default budgets distinguish root index pages from ordinary notes, independ
|
|
|
69
69
|
await notes.write("ordinary", "another replacement");
|
|
70
70
|
assert.equal(data(await notesRead.execute({ address: "ordinary" }, context)).metadata.budget, 1234);
|
|
71
71
|
});
|
|
72
|
-
test("tools
|
|
72
|
+
test("tools reject budget overrides, enforce UTF-8 byte warnings, and wrap warnings in <notesoup:warning>", async (t) => {
|
|
73
73
|
const { context, notes, file } = fixture(t);
|
|
74
74
|
for (const tool of [notesWrite, notesUpdate]) {
|
|
75
75
|
const required = tool === notesWrite ? { address: "x", content: "body" } : { address: "x" };
|
|
76
|
-
assert.equal(Check(tool.parameters, { ...required, pinned: false,
|
|
77
|
-
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 }]) {
|
|
78
78
|
assert.equal(Check(tool.parameters, { ...required, ...invalid }), false);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
assert.equal(
|
|
85
|
-
assert.
|
|
86
|
-
|
|
87
|
-
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);
|
|
88
90
|
assert.equal(data(updated).warnings.length, 1);
|
|
89
|
-
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>/);
|
|
90
92
|
assert.equal((await notes.read("custom")).body, "😀".repeat(3), "over budget saves the entire body");
|
|
91
93
|
const read = await notesRead.execute({ address: "custom", max_chars: 10 }, context);
|
|
92
94
|
assert.equal(Check(notesRead.outputSchema, wireResult(read)), true);
|
|
93
|
-
assert.deepEqual({ pinned: data(read).metadata.pinned, budget: data(read).metadata.budget, readonly: data(read).metadata.readonly }, { pinned: true, budget:
|
|
94
|
-
assert.match(notesRead.render(read), /pinned true \| budget
|
|
95
|
-
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\)/);
|
|
96
98
|
const list = await notesList.execute({}, context);
|
|
97
|
-
assert.equal(
|
|
99
|
+
assert.equal("outputSchema" in notesList, false);
|
|
98
100
|
assert.equal(data(list).files[0].pinned, true);
|
|
99
|
-
assert.match(notesList.render(list), /pinned
|
|
100
|
-
assert.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
assert.equal(data(search).files[0].budget,
|
|
104
|
-
assert.match(notesList.render(search), /pinned
|
|
105
|
-
assert.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
assert.
|
|
113
|
-
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");
|
|
114
115
|
const before = readFileSync(file("custom.md"), "utf8");
|
|
115
116
|
// Runtime JavaScript callers bypass schemas; the real store still validates before saving.
|
|
116
117
|
for (const invalid of [{ pinned: "false" }, { budget: null }, { readonly: "yes" }]) {
|
|
@@ -118,7 +119,7 @@ test("tools set policy, validate values, and visibly report effective policy and
|
|
|
118
119
|
await assert.rejects(() => notes.update("custom", undefined, invalid), refused("invalid_policy"));
|
|
119
120
|
assert.equal(readFileSync(file("custom.md"), "utf8"), before);
|
|
120
121
|
}
|
|
121
|
-
writeFileSync(file("custom.md"), before.replace("budget:
|
|
122
|
+
writeFileSync(file("custom.md"), before.replace("budget: 16", "budget: -1"));
|
|
122
123
|
const badFrontmatter = await notesRead.execute({ address: "custom" }, context);
|
|
123
124
|
assert.equal(badFrontmatter.ok, false);
|
|
124
125
|
if (!badFrontmatter.ok)
|
|
@@ -209,7 +210,7 @@ test("moves resolve absent policy at the new path, preserving explicit false/tru
|
|
|
209
210
|
const { notes, file } = fixture(t);
|
|
210
211
|
await notes.write("CHEATSHEET", "default");
|
|
211
212
|
await notes.rename("CHEATSHEET", "ordinary");
|
|
212
|
-
assert.deepEqual(effectiveNotePolicy((await notes.read("ordinary")).meta, "ordinary.md"), { pinned: false, budget:
|
|
213
|
+
assert.deepEqual(effectiveNotePolicy((await notes.read("ordinary")).meta, "ordinary.md"), { pinned: false, budget: 8192, readonly: false });
|
|
213
214
|
await notes.rename("ordinary", "CHEATSHEET");
|
|
214
215
|
assert.equal(effectiveNotePolicy((await notes.read("CHEATSHEET")).meta, "CHEATSHEET.md").pinned, true);
|
|
215
216
|
assert.equal(parseNote(readFileSync(file("CHEATSHEET.md"), "utf8")).meta.pinned, undefined);
|
|
@@ -225,29 +226,37 @@ test("moves resolve absent policy at the new path, preserving explicit false/tru
|
|
|
225
226
|
await notes.update("candidate", undefined, { renameTo: "CHEATSHEET", pinned: false });
|
|
226
227
|
assert.equal(effectiveNotePolicy((await notes.read("CHEATSHEET")).meta, "CHEATSHEET.md").pinned, false);
|
|
227
228
|
});
|
|
228
|
-
test("boot uses metadata pins,
|
|
229
|
-
const { identity, notes, file } = fixture(t);
|
|
230
|
-
|
|
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);
|
|
231
233
|
await notes.write("MAP", "# Unpinned map\nMAP_NOT_INJECTED", { pinned: false });
|
|
232
|
-
|
|
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 });
|
|
233
236
|
await notes.write("nested/MAP", "# Nested map\nNESTED_NOT_INJECTED");
|
|
234
237
|
await notes.write("roomy", "R".repeat(3000), { pinned: true, budget: 3000 });
|
|
235
238
|
let rendered = await boot(identity);
|
|
236
|
-
|
|
237
|
-
assert.ok(rendered.includes(
|
|
238
|
-
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");
|
|
239
248
|
assert.ok(rendered.includes("R".repeat(3000)));
|
|
240
249
|
assert.equal(rendered.includes("MAP_NOT_INJECTED"), false);
|
|
241
250
|
assert.equal(rendered.includes("NESTED_NOT_INJECTED"), false);
|
|
242
251
|
assert.match(rendered, /MAP.md ·/); // explicit false gets a normal recent seat
|
|
243
252
|
await notes.write("a", "body a", { pinned: true });
|
|
244
|
-
await notes.write("b", "
|
|
253
|
+
await notes.write("b", "😀", { pinned: true, budget: 2 }); // first char exceeds budget
|
|
245
254
|
await notes.write("z", "OMITTED_PIN_BODY");
|
|
246
255
|
writeFileSync(file("z.md"), readFileSync(file("z.md"), "utf8").replace("\n---\n\n", "\npinned: true\n---\n\n"));
|
|
247
256
|
rendered = await boot(identity);
|
|
248
|
-
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/);
|
|
249
259
|
assert.equal(rendered.includes("OMITTED_PIN_BODY"), false);
|
|
250
|
-
assert.ok(rendered.includes("TAIL_IS_HERE"));
|
|
251
260
|
});
|
|
252
261
|
test("MAP.md is an ordinary note by default while CHEATSHEET.md stays the one default pin", async (t) => {
|
|
253
262
|
const { notes, context } = fixture(t);
|
|
@@ -255,16 +264,16 @@ test("MAP.md is an ordinary note by default while CHEATSHEET.md stays the one de
|
|
|
255
264
|
await notes.write("CHEATSHEET", "rules");
|
|
256
265
|
const map = (await notes.read("MAP")).meta;
|
|
257
266
|
const cheatsheet = (await notes.read("CHEATSHEET")).meta;
|
|
258
|
-
assert.deepEqual(effectiveNotePolicy(map, "MAP.md"), { pinned: false, budget:
|
|
259
|
-
assert.deepEqual(effectiveNotePolicy(cheatsheet, "CHEATSHEET.md"), { pinned: true, budget:
|
|
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 });
|
|
260
269
|
await notes.rename("MAP", "moved-map");
|
|
261
|
-
assert.deepEqual(effectiveNotePolicy((await notes.read("moved-map")).meta, "moved-map.md"), { pinned: false, budget:
|
|
270
|
+
assert.deepEqual(effectiveNotePolicy((await notes.read("moved-map")).meta, "moved-map.md"), { pinned: false, budget: 8192, readonly: false });
|
|
262
271
|
const listed = data(await notesList.execute({}, context));
|
|
263
272
|
assert.equal(listed.files.find(file => file.address === "CHEATSHEET.md")?.pinned, true);
|
|
264
273
|
assert.equal(listed.files.find(file => file.address === "moved-map.md")?.pinned, false, "MAP.md keeps no special role after a move");
|
|
265
274
|
});
|
|
266
275
|
test("description normalizes to one line, persists, renders in read and list, and clears on empty", async (t) => {
|
|
267
|
-
const { notes, file, context } = fixture(t);
|
|
276
|
+
const { identity, notes, file, context } = fixture(t);
|
|
268
277
|
const written = await notesWrite.execute({ address: "described", content: "body", description: " first\n\tsecond third " }, context);
|
|
269
278
|
assert.equal(written.ok, true);
|
|
270
279
|
assert.equal((await notes.read("described")).meta.description, "first second third");
|
|
@@ -288,23 +297,33 @@ test("description normalizes to one line, persists, renders in read and list, an
|
|
|
288
297
|
await notesUpdate.execute({ address: "described", description: " \n\t " }, context);
|
|
289
298
|
assert.equal((await notes.read("described")).meta.description, undefined);
|
|
290
299
|
assert.equal(/^description:/m.test(readFileSync(file("described.md"), "utf8")), false);
|
|
291
|
-
// Exactly 160 code points
|
|
292
|
-
await
|
|
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");
|
|
293
304
|
assert.equal((await notes.read("max")).meta.description, "😀".repeat(160), "160 astral code points fit");
|
|
294
305
|
const tooLong = "😀".repeat(161);
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
assert.equal((
|
|
307
|
-
assert.
|
|
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");
|
|
308
327
|
});
|
|
309
328
|
test("boot auto-indexes unpinned notes newest first with description, fallback title, and pinned/crumpled omissions", async (t) => {
|
|
310
329
|
const { identity, notes } = fixture(t);
|
|
@@ -317,10 +336,10 @@ test("boot auto-indexes unpinned notes newest first with description, fallback t
|
|
|
317
336
|
await notes.update("gone", undefined, { crumpled: true });
|
|
318
337
|
const rendered = await boot(identity);
|
|
319
338
|
assert.equal(rendered.includes("recent"), false, "the old recent label is gone");
|
|
320
|
-
assert.match(rendered,
|
|
321
|
-
assert.match(rendered,
|
|
322
|
-
assert.match(rendered,
|
|
323
|
-
assert.match(rendered,
|
|
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);
|
|
324
343
|
assert.ok(rendered.indexOf("plain.md ·") < rendered.indexOf("heading.md ·"), "newest unpinned note leads");
|
|
325
344
|
assert.ok(rendered.indexOf("heading.md ·") < rendered.indexOf("described.md ·"));
|
|
326
345
|
assert.equal(rendered.includes("hidden.md ·"), false, "pinned pages do not repeat in the index");
|
|
@@ -331,8 +350,8 @@ test("boot auto-indexes unpinned notes newest first with description, fallback t
|
|
|
331
350
|
await notes.update("CHEATSHEET", undefined, { pinned: false, crumpled: true });
|
|
332
351
|
await notes.update("hidden", undefined, { crumpled: true });
|
|
333
352
|
const bare = await boot(identity);
|
|
334
|
-
assert.equal(
|
|
335
|
-
assert.match(bare,
|
|
353
|
+
assert.equal(/^── index ──$/m.test(bare), false);
|
|
354
|
+
assert.match(bare, /^plain\.md · just now — first line only$/m);
|
|
336
355
|
});
|
|
337
356
|
test("boot shelf index enforces entry and character caps with an explicit omission marker", async (t) => {
|
|
338
357
|
const { identity, notes } = fixture(t);
|
|
@@ -340,7 +359,7 @@ test("boot shelf index enforces entry and character caps with an explicit omissi
|
|
|
340
359
|
await notes.write(`bulk-${index}`, "body", { description: "d" });
|
|
341
360
|
const entries = await boot(identity);
|
|
342
361
|
assert.equal(entries.split(" · just now — d").length - 1, 25, "only 25 entries fit");
|
|
343
|
-
assert.match(entries,
|
|
362
|
+
assert.match(entries, /^… and 1 more \(use notes_list\)$/m);
|
|
344
363
|
assert.equal(entries.includes("bulk-0.md ·"), false, "the oldest entry is the one left out");
|
|
345
364
|
const wide = fixture(t);
|
|
346
365
|
for (let index = 0; index < 25; index++)
|