notesoup 0.58.2 → 0.58.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/boot/text.d.ts +1 -1
- package/dist/src/boot/text.js +5 -4
- package/dist/src/notes/policy.d.ts +1 -1
- package/dist/src/notes/policy.js +4 -3
- package/dist/src/tools/notes.js +1 -1
- package/dist/test/agent-loop.test.js +13 -39
- package/dist/test/boot.integration.test.js +20 -18
- package/dist/test/budget-settings.integration.test.js +18 -13
- package/dist/test/claude-history.test.js +1 -2
- package/dist/test/claude-mod.test.js +16 -8
- package/dist/test/codex-history.test.js +9 -6
- package/dist/test/codex-plugin.test.js +4 -8
- package/dist/test/dream-skill.test.js +6 -10
- package/dist/test/dsh-cli.test.js +2 -3
- package/dist/test/dsh.test.js +1 -7
- package/dist/test/helpers/extension.js +3 -1
- package/dist/test/history-corpus.test.js +2 -3
- package/dist/test/history-prefilter.test.js +33 -40
- package/dist/test/history-summary-cache.test.js +1 -1
- package/dist/test/history.integration.test.js +11 -37
- package/dist/test/host-neutral.test.js +2 -2
- package/dist/test/marker.test.js +1 -2
- package/dist/test/model-facing-text.test.js +20 -187
- package/dist/test/note-policy.test.js +40 -22
- package/dist/test/notes-library.test.js +2 -2
- package/dist/test/notes.integration.test.js +36 -149
- package/dist/test/notes.test.js +13 -61
- package/dist/test/pi-render.test.js +23 -62
- package/dist/test/reset-lifecycle.test.js +4 -9
- package/docs/architecture.md +1 -1
- package/docs/dsh.md +1 -1
- package/docs/notes-library.md +1 -1
- package/docs/tool-results.md +1 -1
- package/package.json +1 -1
- package/playbook.md +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +10 -8
- package/plugins/claude/playbook.md +1 -1
- package/plugins/claude/skills/dream/SKILL.md +1 -1
- package/plugins/claude/skills/memory/SKILL.md +1 -1
- package/plugins/codex/dist/codex/notesoup.js +10 -8
- package/skills/dream/SKILL.md +1 -1
- package/skills/memory/SKILL.md +1 -1
- package/src/boot/text.ts +5 -4
- package/src/notes/policy.ts +4 -3
- package/src/tools/notes.ts +1 -1
|
@@ -169,8 +169,8 @@ test("root: raw messages, top-level envelope metadata, native tool pairing and n
|
|
|
169
169
|
assert.ok(tool.ok);
|
|
170
170
|
assert.equal(tool.data.tool, "exec_command");
|
|
171
171
|
assert.equal(tool.data.tool_status, "error");
|
|
172
|
-
assert.match(
|
|
173
|
-
assert.match(
|
|
172
|
+
assert.match(tool.data.text, /printf output/);
|
|
173
|
+
assert.match(tool.data.text, /partial\nerror/);
|
|
174
174
|
assert.equal(tool.data.output_truncated, undefined);
|
|
175
175
|
assert.equal(tool.data.nested_calls, undefined);
|
|
176
176
|
const paired = await historyRead.execute({ seq: 9 }, projection);
|
|
@@ -178,11 +178,12 @@ test("root: raw messages, top-level envelope metadata, native tool pairing and n
|
|
|
178
178
|
if (paired.ok)
|
|
179
179
|
assert.equal(paired.data.seq, 7);
|
|
180
180
|
const omitted = await historyRead.execute({ seq: 6 }, projection);
|
|
181
|
-
assert.
|
|
181
|
+
assert.ok(!omitted.ok);
|
|
182
|
+
assert.equal(omitted.error.code, "unknown_seq");
|
|
182
183
|
const page = await historyList.execute({ query: "printf output" }, projection);
|
|
183
184
|
assert.ok(page.ok);
|
|
184
185
|
assert.equal(page.data.items.length, 1);
|
|
185
|
-
assert.
|
|
186
|
+
assert.equal(page.data.items[0]?.seq, 7);
|
|
186
187
|
assert.deepEqual(await readFile(f.path), before);
|
|
187
188
|
assert.equal((await stat(f.path)).mtimeMs, info.mtimeMs);
|
|
188
189
|
});
|
|
@@ -209,9 +210,11 @@ test("two native checkpoints retain old raw history; replacement_history is not
|
|
|
209
210
|
[`codex:${ROOT}:${W0}`, 2, 3], [`codex:${ROOT}:${W1}`, 4, 6], [`codex:${ROOT}:${W2}`, 7, 8],
|
|
210
211
|
]);
|
|
211
212
|
const earlier = await historyList.execute({ after_seq: 3, before_seq: 7, roles: ["user"] }, second.projection);
|
|
212
|
-
assert.
|
|
213
|
+
assert.ok(earlier.ok);
|
|
214
|
+
assert.deepEqual(earlier.data.items.map((item) => [item.seq, item.role, item.content]), [[6, "user", "middle text"]]);
|
|
213
215
|
const old = await historyRead.execute({ seq: 2 }, second.projection);
|
|
214
|
-
assert.
|
|
216
|
+
assert.ok(old.ok);
|
|
217
|
+
assert.match(old.data.text, /old raw text/);
|
|
215
218
|
const { projection: _projection, dependencies: _dependencies, lineageSources: _lineageSources, ...facts } = second;
|
|
216
219
|
assert.deepEqual(await readCodexTranscriptState({ transcriptPath: f.path, threadId: ROOT }), facts);
|
|
217
220
|
assert.deepEqual(await readCodexHistory({ transcriptPath: f.path, threadId: ROOT }), second);
|
|
@@ -183,7 +183,7 @@ test("bundled Codex MCP reads another harness and wildcard results retain their
|
|
|
183
183
|
assert.equal(page.has_newer, false);
|
|
184
184
|
const limited = await call(client, { name: "history_list", arguments: { session: "*", query: "needle", limit: 1 }, _meta: metaFor(ROOT, ROOT) });
|
|
185
185
|
assert.equal(limited.structuredContent.has_older, true);
|
|
186
|
-
assert.
|
|
186
|
+
assert.equal(limited.structuredContent.items.length, 1, "the limit bounds the page to one item");
|
|
187
187
|
assert.doesNotMatch(textOf(limited), /before_seq|after_seq/);
|
|
188
188
|
const invalid = await call(client, { name: "history_read", arguments: { session: "*", seq: 1 }, _meta: metaFor(ROOT, ROOT) });
|
|
189
189
|
assert.equal(errorCode(invalid), "invalid_session");
|
|
@@ -294,7 +294,7 @@ test("history tools serve root and child native ancestry, and refuse stale nativ
|
|
|
294
294
|
row("response_item", message("user", "child task")),
|
|
295
295
|
]));
|
|
296
296
|
await bind(f.data, { threadId: CHILD, rootSessionId: ROOT, home: f.home, cwd: f.cwd, transcriptPath: childPath, agent: "worker", agentType: "worker" });
|
|
297
|
-
const invalidFilter = await call(client, { name: "history_list", arguments: {
|
|
297
|
+
const invalidFilter = await call(client, { name: "history_list", arguments: { limit: 0 }, _meta: meta });
|
|
298
298
|
assert.equal(errorCode(invalidFilter), "invalid_params");
|
|
299
299
|
const childHistory = await call(client, { name: "history_list", arguments: {}, _meta: metaFor(CHILD, ROOT) });
|
|
300
300
|
assert.equal(childHistory.isError, undefined);
|
|
@@ -321,18 +321,14 @@ test("a root boot carries the native window, native reset names, and is deduped
|
|
|
321
321
|
const env = { ...process.env, PLUGIN_DATA: f.data, NOTESOUP_HOME: f.home };
|
|
322
322
|
const first = await runHook("SessionStart", startPayload(f), env);
|
|
323
323
|
const boot = bootOf(first);
|
|
324
|
-
assert.match(boot, /YOUR NOTES/);
|
|
325
324
|
assert.ok(boot.includes(NOTES_PROTOCOL_OPEN_TAG) && boot.includes(MAPS_BLOCK), "Codex keeps teaching in its native boot hook");
|
|
326
325
|
assert.match(boot, new RegExp(`Agent name: anonymous \\(brain: gpt-5-4\\)`));
|
|
327
326
|
assert.match(boot, new RegExp(`codex:${ROOT}`));
|
|
328
327
|
assert.match(boot, new RegExp(`<notesoup:codex_window>\\nthread: ${ROOT}\\nwindow: ${W0}`));
|
|
329
|
-
|
|
330
|
-
assert.match(boot, new RegExp(`${W0} {4}← you are here`));
|
|
331
|
-
assert.match(boot, /native `new_context`/);
|
|
328
|
+
assert.ok(boot.includes("`new_context`"), "the protocol speaks Codex's own reset tool");
|
|
332
329
|
assert.match(boot, /get_context_remaining/);
|
|
333
330
|
assert.match(boot, /notes_\*/);
|
|
334
331
|
assert.doesNotMatch(boot, /empty_brain/);
|
|
335
|
-
assert.match(boot, /Child limitation/);
|
|
336
332
|
const binding = JSON.parse(readFileSync(join(f.data, "bindings", `${ROOT}.json`), "utf8"));
|
|
337
333
|
assert.equal(binding.rootSessionId, ROOT);
|
|
338
334
|
assert.equal(binding.home, f.home);
|
|
@@ -377,7 +373,7 @@ test("a fork gets its own boot instead of inheriting the parent's recorded ident
|
|
|
377
373
|
const boot = parsed.hookSpecificOutput?.additionalContext ?? "";
|
|
378
374
|
assert.match(boot, new RegExp(`thread: ${FORK}`));
|
|
379
375
|
assert.match(boot, new RegExp(`Agent name: worker \\(brain: gpt-5-4\\)`));
|
|
380
|
-
assert.
|
|
376
|
+
assert.ok(boot.includes("worker map"), "the subagent reads its own library, not the parent's");
|
|
381
377
|
assert.equal(JSON.parse(readFileSync(join(f.data, "bindings", `${FORK}.json`), "utf8")).rootSessionId, ROOT);
|
|
382
378
|
});
|
|
383
379
|
test("child PreCompact stops before native history is cut; root PreCompact is transparent", async (t) => {
|
|
@@ -28,21 +28,16 @@ test("dream skill is publicly discoverable and resolves the shared playbook", ()
|
|
|
28
28
|
const root = packageRoot();
|
|
29
29
|
const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
30
30
|
assert.deepEqual(manifest.pi.skills, ["./skills"]);
|
|
31
|
-
assert.deepEqual(manifest.pi.extensions, ["./plugins/pi/index.ts"]);
|
|
32
|
-
assert.equal(manifest.bin, undefined, "the dream CLI is gone; dreams run through the dream_* tools");
|
|
33
31
|
assert.ok(manifest.files.includes("skills"));
|
|
34
32
|
discoverSkill(join(root, "skills"), "memory");
|
|
35
33
|
const skill = discoverSkill(join(root, "skills"), "dream");
|
|
36
|
-
const
|
|
34
|
+
const reference = readFileSync(join(skill.baseDir, "SKILL.md"), "utf8").match(/`([^`]+playbook\.md)`/)?.[1];
|
|
35
|
+
assert.ok(reference, "the skill links its playbook");
|
|
36
|
+
const skillPlaybook = resolve(skill.baseDir, reference);
|
|
37
37
|
const packagePlaybook = resolve(root, "playbook.md");
|
|
38
38
|
assert.equal(skillPlaybook, packagePlaybook);
|
|
39
39
|
const playbook = readFileSync(packagePlaybook, "utf8");
|
|
40
40
|
assert.equal(readFileSync(skillPlaybook, "utf8"), playbook);
|
|
41
|
-
const instructions = readFileSync(join(skill.baseDir, "SKILL.md"), "utf8");
|
|
42
|
-
for (const name of ["dream_begin", "dream_forget", "dream_end"])
|
|
43
|
-
assert.ok(instructions.includes(name));
|
|
44
|
-
assert.match(instructions, /missing from the current tool list, search for them/);
|
|
45
|
-
assert.doesNotMatch(instructions, /tool_search|searchTools|codemode/);
|
|
46
41
|
});
|
|
47
42
|
test("npm tarball keeps the skill's relative playbook path portable after extraction", () => {
|
|
48
43
|
const root = packageRoot();
|
|
@@ -57,14 +52,15 @@ test("npm tarball keeps the skill's relative playbook path portable after extrac
|
|
|
57
52
|
assert.ok(packedPaths.includes("skills/dream/SKILL.md"));
|
|
58
53
|
assert.ok(packedPaths.includes("skills/memory/SKILL.md"));
|
|
59
54
|
assert.ok(packedPaths.includes("playbook.md"));
|
|
60
|
-
assert.ok(packedPaths.includes("plugins/pi/index.ts"));
|
|
61
55
|
const extracted = join(fixture, "extracted");
|
|
62
56
|
execFileSync("mkdir", ["-p", extracted]);
|
|
63
57
|
execFileSync("tar", ["-xzf", join(fixture, packed.filename), "-C", extracted]);
|
|
64
58
|
const installedRoot = join(extracted, "package");
|
|
65
59
|
discoverSkill(join(installedRoot, "skills"), "memory");
|
|
66
60
|
const installedSkill = discoverSkill(join(installedRoot, "skills"), "dream");
|
|
67
|
-
const
|
|
61
|
+
const reference = readFileSync(join(installedSkill.baseDir, "SKILL.md"), "utf8").match(/`([^`]+playbook\.md)`/)?.[1];
|
|
62
|
+
assert.ok(reference, "the installed skill links its playbook");
|
|
63
|
+
const referencedPlaybook = resolve(installedSkill.baseDir, reference);
|
|
68
64
|
assert.equal(referencedPlaybook, resolve(installedRoot, "playbook.md"));
|
|
69
65
|
assert.equal(readFileSync(referencedPlaybook, "utf8"), readFileSync(join(root, "playbook.md"), "utf8"));
|
|
70
66
|
}
|
|
@@ -23,9 +23,8 @@ test("dsh profile loads our rows and a second process restores the on-disk windo
|
|
|
23
23
|
const example = await readFile(join(repository, "docs/dsh.profile.patch.yml"), "utf8");
|
|
24
24
|
const patch = example
|
|
25
25
|
.replace("'notesoup/dsh/engine'", `'${pathToFileURL(join(repository, "dist/plugins/dsh/engine.js")).href}'`)
|
|
26
|
-
.replace("'notesoup/dsh'", `'${pathToFileURL(join(repository, "dist/plugins/dsh/index.js")).href}'`)
|
|
27
|
-
|
|
28
|
-
await writeFile(join(profile, "cordis.patch.yml"), patch + "\n- id: session-title-llm\n disabled: true\n");
|
|
26
|
+
.replace("'notesoup/dsh'", `'${pathToFileURL(join(repository, "dist/plugins/dsh/index.js")).href}'`);
|
|
27
|
+
await writeFile(join(profile, "cordis.patch.yml"), patch + `\n- id: notesoup-engine\n config:\n notesHome: ${JSON.stringify(join(directory, "notes"))}\n- id: session-title-llm\n disabled: true\n`);
|
|
29
28
|
// A broken ambient proxy must not intercept the local Messages server.
|
|
30
29
|
const env = { ...process.env, NODE_USE_ENV_PROXY: "1", HTTP_PROXY: "http://127.0.0.1:1", http_proxy: "http://127.0.0.1:1", DSH_HOME: home, DEEPSEEK_API_KEY: "mock-key", DEEPSEEK_BASE_URL: mock.url, DSH_TOOLS_MODE: "native" };
|
|
31
30
|
const cli = resolve(repository, "node_modules/@deepseek-ai/dsh/lib/bin.js");
|
package/dist/test/dsh.test.js
CHANGED
|
@@ -7,8 +7,6 @@ import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
import { resolveProjectNamespace } from "../src/notes/project-namespace.js";
|
|
10
|
-
import { renderBootBlock } from "../src/boot/render.js";
|
|
11
|
-
import { loadNotesSnapshot } from "../src/boot/snapshot.js";
|
|
12
10
|
import { WINDOW_IDENTITY_CLOSE_TAG, WINDOW_IDENTITY_OPEN_TAG } from "../src/boot/text.js";
|
|
13
11
|
import { notesRead } from "../src/tools/notes.js";
|
|
14
12
|
import { notesToolContext } from "../src/tools/notes-context.js";
|
|
@@ -365,7 +363,7 @@ test("dsh explicit resets survive auto:false; shared tool reads and expected err
|
|
|
365
363
|
if (!read.isError)
|
|
366
364
|
assert.equal(read.value.text, "raw");
|
|
367
365
|
}
|
|
368
|
-
const invalidHistory = await call("history_list", {
|
|
366
|
+
const invalidHistory = await call("history_list", { limit: 0 });
|
|
369
367
|
assert.equal(invalidHistory.isError, true);
|
|
370
368
|
if (invalidHistory.isError)
|
|
371
369
|
assert.equal(invalidHistory.error.info?.code, "INVALID_PARAMS");
|
|
@@ -408,10 +406,6 @@ test("dsh explicit resets survive auto:false; shared tool reads and expected err
|
|
|
408
406
|
assert.equal(refused.isError, true);
|
|
409
407
|
if (refused.isError)
|
|
410
408
|
assert.equal(refused.error.info?.code, "invalid_scope");
|
|
411
|
-
const snapshot = engine.windows.get(agent.session).snapshot;
|
|
412
|
-
const sharedBoot = renderBootBlock({ agentName: identity.agent, modelName: identity.model, tree: { trunk: `dsh:${agent.session.id}`, windows: [{ shortName: "0", isCurrent: false }, { shortName: "1", isCurrent: true }] }, notes: await loadNotesSnapshot(identity, snapshot.openedAt), tools: { notes: "notes_*", notesList: "notes_list", history: "history_*", remaining: "get_context_remaining", wipe: "empty_brain" } });
|
|
413
|
-
// The shared protocol, including the pinned-page instructions, is used verbatim inside host framing.
|
|
414
|
-
assert.ok(snapshot.boot.includes(sharedBoot.split("YOUR NOTES")[0]));
|
|
415
409
|
const blocked = ctx.on("tools/post-execute", async (exec, _result, next) => exec.name === "empty_brain" ? { kind: "block", feedback: [{ type: "text", text: "blocked" }] } : next());
|
|
416
410
|
mock.script.push({ tool: "empty_brain", input: {} }, { text: "request refused" });
|
|
417
411
|
await run(agent, "refused clear");
|
|
@@ -92,7 +92,9 @@ export function settingsFixture(options = {}) {
|
|
|
92
92
|
registerTempPath?.(agentDir);
|
|
93
93
|
const fixtureManager = SettingsManager.create(cwd, agentDir, { projectTrusted: true });
|
|
94
94
|
const projectReserve = options.project?.compaction?.reserveTokens;
|
|
95
|
-
|
|
95
|
+
const expectedReserve = projectReserve ?? options.reserveTokens;
|
|
96
|
+
if (expectedReserve !== undefined)
|
|
97
|
+
assert.equal(fixtureManager.getCompactionSettings().reserveTokens, expectedReserve, "fixture reserve reads back");
|
|
96
98
|
return { cwd, agentDir };
|
|
97
99
|
}
|
|
98
100
|
/** TypeBox's TSchema does not expose `type`/`required` statically; read them structurally. */
|
|
@@ -205,14 +205,12 @@ test("wildcard query merges every role chronologically, limits from either end,
|
|
|
205
205
|
assert.deepEqual(newest.items, page.items.slice(-2));
|
|
206
206
|
assert.equal(newest.has_older, true);
|
|
207
207
|
assert.equal(newest.has_newer, false);
|
|
208
|
-
assert.match(historyList.render(newestResult), /→ more older results: narrow with since\/until, query, roles or the session pattern/);
|
|
209
208
|
assert.doesNotMatch(historyList.render(newestResult), /before_seq|after_seq/);
|
|
210
209
|
const oldestResult = await historyList.execute({ session: "*", query: "needle", limit: 2, from: "oldest" }, ctx);
|
|
211
210
|
const oldest = data(oldestResult);
|
|
212
211
|
assert.deepEqual(oldest.items, page.items.slice(0, 2));
|
|
213
212
|
assert.equal(oldest.has_older, false);
|
|
214
213
|
assert.equal(oldest.has_newer, true);
|
|
215
|
-
assert.match(historyList.render(oldestResult), /→ more newer results:/);
|
|
216
214
|
assert.doesNotMatch(historyList.render(oldestResult), /before_seq|after_seq/);
|
|
217
215
|
const filtered = data(await historyList.execute({ session: "*", query: "needle", roles: ["tool", "context"], since: "2026-10-06T01:02:05", until: "2026-10-06T01:02:07Z" }, ctx));
|
|
218
216
|
assert.deepEqual(filtered.items.map((item) => item.role), ["tool"]);
|
|
@@ -445,7 +443,8 @@ test("cross-session Claude gaps are visible even on an empty page, budgeted, and
|
|
|
445
443
|
const empty = await historyList.execute({ session: "claude:claude-one", query: "absent" }, f.ctx);
|
|
446
444
|
assert.equal(data(empty).items.length, 0);
|
|
447
445
|
assert.match(data(empty).notice, /missing ancestor.*"missing"/);
|
|
448
|
-
|
|
446
|
+
const emptyText = historyList.render(empty);
|
|
447
|
+
assert.ok(emptyText.includes(data(empty).notice), "the gap notice survives an empty page");
|
|
449
448
|
const list = await historyList.execute({ session: "claude:*", query: "needle", max_chars_per_item: 50_000 }, f.ctx);
|
|
450
449
|
assert.ok(Buffer.byteLength(JSON.stringify(data(list))) <= TOOL_OUTPUT_MAX_BYTES);
|
|
451
450
|
assert.ok(Buffer.byteLength(historyList.render(list)) <= TOOL_OUTPUT_MAX_BYTES);
|
|
@@ -39,48 +39,41 @@ test("only EOF proves a miss, while errors after tokens or a fallback still prop
|
|
|
39
39
|
for (const queries of [["absentword"], ["needle"], ["😀"]])
|
|
40
40
|
await assert.rejects(createHistoryPrefilter(queries)(broken()), /read failed/);
|
|
41
41
|
});
|
|
42
|
-
test("
|
|
43
|
-
|
|
44
|
-
copied subagent inference prefix omitted child-local history starts at native ordinal copied model context
|
|
45
|
-
does not prove original parent event addresses compaction boundary replacement_history is an inference checkpoint
|
|
46
|
-
not new conversation events opaque content omitted not recovered plaintext MCP completion without a recorded raw call
|
|
47
|
-
FunctionCallOutput display without raw output encrypted content unavailable world_state snapshot patch omitted from
|
|
48
|
-
the text projection not a newly spoken message native structured retained context not newly spoken dialogue`;
|
|
49
|
-
const prior = (text, queries) => {
|
|
50
|
-
const normalized = text.replace(/\\+u([0-9a-fA-F]{4})/g, (_, hex) => String.fromCharCode(Number.parseInt(hex, 16)));
|
|
51
|
-
return queries.some((query) => (query.match(/[\p{L}\p{N}_-]+/gu) ?? []).every((token) => {
|
|
52
|
-
const parts = /^\d+ms$/iu.test(token) ? [token.slice(0, -2), "ms"] : [token];
|
|
53
|
-
return parts.every((part) => {
|
|
54
|
-
const literal = new RegExp(part, "iu");
|
|
55
|
-
return literal.test(text) || literal.test(normalized) || literal.test(presentation);
|
|
56
|
-
});
|
|
57
|
-
}));
|
|
58
|
-
};
|
|
42
|
+
test("raw and one-pass Unicode-unescaped matching agree across every byte split", async () => {
|
|
43
|
+
// true is a conservative "may match" (the strict decoder still decides); false is a proven miss.
|
|
59
44
|
const cases = [
|
|
60
|
-
|
|
61
|
-
[String.raw `{"text":"\u006eeedle"}`, ["
|
|
62
|
-
[String.raw `{"text":"\u006eeedle"}`, ["
|
|
63
|
-
[String.raw `{"text":"\u006eeedle"}`, ["
|
|
64
|
-
|
|
65
|
-
[String.raw `
|
|
66
|
-
[String.raw
|
|
67
|
-
|
|
68
|
-
[String.raw
|
|
69
|
-
[String.raw `\
|
|
70
|
-
[String.raw
|
|
71
|
-
|
|
72
|
-
[String.raw
|
|
73
|
-
[String.raw `\
|
|
74
|
-
|
|
75
|
-
[String.raw
|
|
76
|
-
[String.raw `\u006e
|
|
77
|
-
[String.raw
|
|
78
|
-
|
|
79
|
-
[String.raw `\
|
|
80
|
-
[
|
|
45
|
+
// `\u006e` decodes to n; the raw escape text is searchable too.
|
|
46
|
+
[String.raw `{"text":"\u006eeedle"}`, ["needle"], true],
|
|
47
|
+
[String.raw `{"text":"\u006eeedle"}`, ["u006eeedle"], true],
|
|
48
|
+
[String.raw `{"text":"\u006eeedle"}`, ["needle u006eeedle"], true],
|
|
49
|
+
// Queries are OR; every token in one query is required.
|
|
50
|
+
[String.raw `{"text":"\u006eeedle"}`, ["absentword", "needle"], true],
|
|
51
|
+
[String.raw `{"text":"\u006eeedle"}`, ["needle absentword"], false],
|
|
52
|
+
// Case folding applies to raw and decoded text alike.
|
|
53
|
+
[String.raw `NEE\u0044LE LONG\u017f CASE\u03a3`, ["needle longs caseς"], true],
|
|
54
|
+
[String.raw `\uD801\uDC00needle`, ["𐐨needle"], true],
|
|
55
|
+
[String.raw `\uD801\uDC00needle`, ["ud801 𐐨needle"], true],
|
|
56
|
+
// Decoding is one pass: producing a backslash does not re-open the following escape.
|
|
57
|
+
[String.raw `\u005cu006eeedle`, ["needle"], false],
|
|
58
|
+
[String.raw `\u005c\u0075\u0030\u0030\u0036\u0065eedle`, ["needle"], false],
|
|
59
|
+
// Two raw backslashes plus an escape decode to one character.
|
|
60
|
+
[String.raw `prefix\\u006eeedle`, ["prefixneedle"], true],
|
|
61
|
+
[String.raw `\u006e\\u0065edle`, ["needle"], true],
|
|
62
|
+
[String.raw `{"arguments":"{\"path\":\"\\u006eeedle\"}"}`, ["needle"], true],
|
|
63
|
+
// Incomplete escapes stay literal; raw hex remains a possible literal hit.
|
|
64
|
+
[String.raw `\u00xz needle\u00`, ["needle u00"], true],
|
|
65
|
+
[String.raw `need\u00xzle`, ["needle"], false],
|
|
66
|
+
[String.raw `\u006e\u00xz`, ["nu00xz"], false],
|
|
67
|
+
[String.raw `\u006e\u00xz`, ["u00xz"], true],
|
|
68
|
+
[String.raw `\u006e\u00`, ["u00"], true],
|
|
69
|
+
// A trailing backslash is flushed as a literal, never merged into a query token.
|
|
70
|
+
[String.raw `\u006e` + "\\", ["absentword"], false],
|
|
71
|
+
// Uppercase `U` is not an escape marker.
|
|
72
|
+
[String.raw `\U006eeedle`, ["needle"], false],
|
|
73
|
+
["LONGſ CASEΣ 你好", ["longs caseς 你好"], true],
|
|
81
74
|
];
|
|
82
|
-
for (const [text, queries] of cases) {
|
|
83
|
-
const bytes = Buffer.from(text), plan = createHistoryPrefilter(queries)
|
|
75
|
+
for (const [text, queries, expected] of cases) {
|
|
76
|
+
const bytes = Buffer.from(text), plan = createHistoryPrefilter(queries);
|
|
84
77
|
for (let cut = 1; cut < bytes.length; cut++) {
|
|
85
78
|
async function* split() { yield bytes.subarray(0, cut); yield bytes.subarray(cut); }
|
|
86
79
|
assert.equal(await plan(split()), expected, `${JSON.stringify({ text, queries })} split ${cut}`);
|
|
@@ -289,7 +289,7 @@ test("Codex cache fingerprints actual archived compressed ancestors and revalida
|
|
|
289
289
|
assert.equal(data(await historyList.execute(params, f.context())).items.length, 0, "new ambiguous discovery must invalidate a warm child summary");
|
|
290
290
|
const explicit = await historyList.execute({ session: `codex:${CHILD}` }, f.context());
|
|
291
291
|
assert.ok(!explicit.ok);
|
|
292
|
-
assert.
|
|
292
|
+
assert.equal(explicit.error.code, "history_unavailable");
|
|
293
293
|
await fs.unlink(duplicatePath);
|
|
294
294
|
assert.match(historyList.render(await historyList.execute(params, f.context())), /edited topic/);
|
|
295
295
|
await fs.unlink(ancestorPath);
|
|
@@ -49,14 +49,12 @@ test("Pi registered tools resolve another persisted session and propagate its id
|
|
|
49
49
|
const current = resultData(await call(captured, "history_read", { session: `pi:${session.getSessionId()}`, seq: 1 }, ctx));
|
|
50
50
|
assert.equal(current.session, `pi:${session.getSessionId()}`);
|
|
51
51
|
});
|
|
52
|
-
test("history_list exposes bounded paging, `from` and a literal query
|
|
52
|
+
test("history_list exposes bounded paging, `from` and a literal query", () => {
|
|
53
53
|
const captured = makeExtension(manager());
|
|
54
54
|
const readSchema = captured.tools.get("history_read")?.parameters;
|
|
55
|
-
const legacyItemKey = ["item", "id"].join("_");
|
|
56
55
|
assert.ok(readSchema.properties?.seq);
|
|
57
56
|
assert.deepEqual(readSchema.required, ["seq"]);
|
|
58
|
-
assert.equal(readSchema.properties?.
|
|
59
|
-
assert.equal(readSchema.properties?.window_id, undefined);
|
|
57
|
+
assert.equal(readSchema.properties?.window_id, undefined, "history_read accepts no window selector");
|
|
60
58
|
const listSchema = captured.tools.get("history_list").parameters;
|
|
61
59
|
const properties = listSchema.properties;
|
|
62
60
|
assert.equal(properties.before_seq?.minimum, 1, "bounds are positive seqs");
|
|
@@ -66,10 +64,6 @@ test("history_list exposes bounded paging, `from` and a literal query, while not
|
|
|
66
64
|
assert.equal(Check(listSchema, { after_seq: -1 }), false);
|
|
67
65
|
assert.deepEqual(properties.from?.anyOf?.map((item) => item.const), ["newest", "oldest"]);
|
|
68
66
|
assert.ok(properties.query);
|
|
69
|
-
assert.equal(properties.around, undefined);
|
|
70
|
-
assert.equal(properties.tool_name, undefined);
|
|
71
|
-
assert.equal(properties.custom_type, undefined);
|
|
72
|
-
assert.equal(properties.cursor, undefined);
|
|
73
67
|
assert.deepEqual(properties.roles?.items?.anyOf?.map((item) => item.const), ["user", "assistant", "tool", "context"], "the role filter carries the four public roles");
|
|
74
68
|
assert.ok(properties.since, "the time filter has a since param");
|
|
75
69
|
assert.ok(properties.until, "the time filter has an until param");
|
|
@@ -77,22 +71,12 @@ test("history_list exposes bounded paging, `from` and a literal query, while not
|
|
|
77
71
|
assert.equal(Check(listSchema, { since: "" }), false, "an empty time value is refused by the schema");
|
|
78
72
|
assert.equal(Check(listSchema, { query: "needle", from: "oldest", roles: ["tool"] }), true);
|
|
79
73
|
assert.equal(Check(listSchema, { from: "recent" }), false);
|
|
80
|
-
// The retired names are unknown parameters, refused like any other: `additionalProperties: false`.
|
|
81
|
-
for (const retired of [{ before: 5 }, { after: 5 }, { order: "oldest" }, { limit_chars: 10 }]) {
|
|
82
|
-
assert.equal(Check(listSchema, retired), false, `${Object.keys(retired)[0]} is refused as an unknown parameter`);
|
|
83
|
-
}
|
|
84
74
|
assert.equal(Check(listSchema, { query: "" }), true, "an empty literal is equivalent to an omitted query");
|
|
85
|
-
for (const invalid of [{ roles: ["tool_call"] }, { roles: ["system"] }, {
|
|
75
|
+
for (const invalid of [{ roles: ["tool_call"] }, { roles: ["system"] }, { roles: [] }]) {
|
|
86
76
|
assert.equal(Check(listSchema, invalid), false, JSON.stringify(invalid));
|
|
87
77
|
}
|
|
88
78
|
assert.deepEqual(Object.keys(properties).sort(), ["session", "query", "roles", "before_seq", "after_seq", "since", "until", "from", "limit", "max_chars_per_item"].sort());
|
|
89
|
-
assert.equal(Check(listSchema, { window_id: "anything" }), false, "
|
|
90
|
-
const notesSchema = captured.tools.get("notes_list")?.parameters;
|
|
91
|
-
assert.equal(notesSchema.properties?.cursor, undefined);
|
|
92
|
-
assert.ok(notesSchema.properties?.limit);
|
|
93
|
-
const notesSearchSchema = captured.tools.get("notes_search")?.parameters;
|
|
94
|
-
assert.equal(notesSearchSchema.properties?.cursor, undefined);
|
|
95
|
-
assert.ok(notesSearchSchema.properties?.limit);
|
|
79
|
+
assert.equal(Check(listSchema, { window_id: "anything" }), false, "removed filters are refused as unknown parameters");
|
|
96
80
|
});
|
|
97
81
|
test("every history operation declares a result schema its own payload satisfies", async () => {
|
|
98
82
|
const session = manager();
|
|
@@ -107,7 +91,6 @@ test("every history operation declares a result schema its own payload satisfies
|
|
|
107
91
|
const structured = result.structuredContent;
|
|
108
92
|
assert.ok(structured !== undefined, `${toolName} carries a structured outcome`);
|
|
109
93
|
assert.equal(Check(operation.outputSchema, structured), true, `${toolName} payload satisfies its own outputSchema`);
|
|
110
|
-
assert.equal(rendered(result).split("\n")[0], "seq 1 | user");
|
|
111
94
|
if (toolName === "history_list") {
|
|
112
95
|
assert.deepEqual(page(result).items, [{ seq: 1, role: "user", created_at: page(result).items[0].created_at, content: "hello", truncated: false, offset_chars: 0 }]);
|
|
113
96
|
}
|
|
@@ -238,7 +221,7 @@ test("a one-row page budget admits the newest candidate first", () => {
|
|
|
238
221
|
assert.deepEqual(keptSeqs(2), [2, 3], "a truncated prefix is the newest rows, delivered in chronological order");
|
|
239
222
|
assert.deepEqual(keptSeqs(1, "oldest"), [1], "from oldest keeps the other end when the budget is short");
|
|
240
223
|
});
|
|
241
|
-
test("query
|
|
224
|
+
test("query reports budget failures while tools refuse the page", async () => {
|
|
242
225
|
const projection = projectHistory([{ windowId: "w1", items: [{ seq: 1, windowId: "w1", role: "user", text: "message" }] }], 1, new Set([1]));
|
|
243
226
|
assert.deepEqual(selectPage(projection, {}, () => false, 100), { ok: false, pageTooLarge: { count: 1, multi: false } });
|
|
244
227
|
const collector = new CorpusCollector({});
|
|
@@ -253,11 +236,8 @@ test("query returns budget-failure facts while tools preserve single-session and
|
|
|
253
236
|
const wrap = (text) => "x".repeat(TOOL_OUTPUT_MAX_BYTES + 1) + text;
|
|
254
237
|
for (const session of [undefined, "pi:budget", "*"]) {
|
|
255
238
|
const result = await historyList.execute({ session }, context, wrap);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const message = `Even trimmed to their shortest, these 1 rows${multi ? "" : " and their folded runs"} fill the 32 KB a call can carry; ${narrow}.`;
|
|
259
|
-
assert.deepEqual(result, { ok: false, error: { code: "page_too_large", message } });
|
|
260
|
-
assert.equal(historyList.render(result), `error: page_too_large: ${message}`);
|
|
239
|
+
assert.ok(!result.ok);
|
|
240
|
+
assert.equal(result.error.code, "page_too_large");
|
|
261
241
|
}
|
|
262
242
|
});
|
|
263
243
|
test("history page selection still charges host wrapping and session notices before delivering previews", async () => {
|
|
@@ -425,13 +405,11 @@ test("conversation view folds tools and injected messages, while explicit roles
|
|
|
425
405
|
session.appendCustomMessageEntry("square", "injected event", false);
|
|
426
406
|
append(session, { role: "assistant", content: [], stopReason: "toolUse", timestamp: Date.now() });
|
|
427
407
|
const conversation = page(await call(captured, "history_list", {}, ctx));
|
|
428
|
-
const legacyItemKey = ["item", "id"].join("_");
|
|
429
408
|
assert.ok(conversation.folded_after);
|
|
430
409
|
assert.ok(conversation.items.every((item) => "seq" in item && !("folded" in item)));
|
|
431
410
|
assert.equal(conversation.items.some((item) => item.role === "developer"), false);
|
|
432
411
|
assert.equal(conversation.items.some((item) => item.role === "tool"), false);
|
|
433
412
|
assert.equal(conversation.items.some((item) => item.role === "assistant" && item.content === ""), false);
|
|
434
|
-
assert.equal(conversation.items.every((item) => legacyItemKey in item === false), true);
|
|
435
413
|
const folded = conversation.folded_after;
|
|
436
414
|
assert.equal(folded.count, 3, "two tool events and one injected context are folded, not the empty assistant message");
|
|
437
415
|
assert.deepEqual(folded.tools, { bash: 1, read: 1 });
|
|
@@ -441,7 +419,6 @@ test("conversation view folds tools and injected messages, while explicit roles
|
|
|
441
419
|
const hiddenOnly = page(await call(captured, "history_list", { after_seq: 2, before_seq: 6 }, ctx));
|
|
442
420
|
assert.deepEqual(hiddenOnly.items, []);
|
|
443
421
|
assert.deepEqual(hiddenOnly.folded_after, { first_seq: 3, last_seq: 4, count: 2, tools: { bash: 1, read: 1 } });
|
|
444
|
-
assert.match(rendered(await call(captured, "history_list", { after_seq: 2, before_seq: 6 }, ctx)), /seqs 3-4 \| folded 2 events/);
|
|
445
422
|
const expanded = page(await call(captured, "history_list", { roles: ["tool"] }, ctx));
|
|
446
423
|
assert.deepEqual(expanded.items.map((item) => [item.seq, item.role, item.tool, item.tool_status]), [[3, "tool", "bash", "ok"], [4, "tool", "read", "ok"]]);
|
|
447
424
|
assert.equal(expanded.items[0].content, 'bash {"command":"pwd"}\n--- output ---\nok');
|
|
@@ -576,7 +553,6 @@ test("standalone bash execution retains command, output, and truncation path", a
|
|
|
576
553
|
truncated: false,
|
|
577
554
|
content: 'bash {"command":"echo needle"}\n--- output ---\nneedle output',
|
|
578
555
|
});
|
|
579
|
-
assert.match(rendered(raw), /output truncated, full text at \/tmp\/bash-output\.txt/, "a truncation with a path names both");
|
|
580
556
|
const query = page(await call(captured, "history_list", { roles: ["tool"], query: "NEEDLE OUTPUT" }, ctx));
|
|
581
557
|
assert.deepEqual(query.items.map((item) => item.seq), [1]);
|
|
582
558
|
const read = resultRead(await call(captured, "history_read", { seq: 1, offset_chars: query.items[0].offset_chars }, ctx));
|
|
@@ -594,8 +570,6 @@ test("a truncated tool run without a recorded path still reports output_truncate
|
|
|
594
570
|
const item = found.items[0];
|
|
595
571
|
assert.equal(item.output_truncated, true, "the truncation is reported even with no path");
|
|
596
572
|
assert.equal("full_output_path" in item, false, "no path is invented");
|
|
597
|
-
assert.match(rendered(raw), /output truncated/, "the header still says the output was truncated");
|
|
598
|
-
assert.equal(rendered(raw).includes("full text at"), false, "the header claims no path");
|
|
599
573
|
const read = resultRead(await call(captured, "history_read", { seq: 1 }, ctx));
|
|
600
574
|
assert.equal(read.output_truncated, true, "the read reports the same truncation");
|
|
601
575
|
assert.equal("full_output_path" in read, false);
|
|
@@ -612,10 +586,10 @@ test("list renders paging and fold recipes across resets, and read renders a nei
|
|
|
612
586
|
assert.match(rendered(listed), /→ older: \{"before_seq":\d+\}/, "the footer prints the exact call to page older");
|
|
613
587
|
const earlier = page(await call(captured, "history_list", { before_seq: 31, from: "oldest", limit: 30 }, ctx));
|
|
614
588
|
assert.deepEqual(earlier.items.map((item) => item.seq), Array.from({ length: 30 }, (_, index) => index + 1));
|
|
615
|
-
const earlierQuery = page(await call(captured, "history_list", { query: "older window", before_seq: 31 }, ctx));
|
|
616
|
-
assert.equal(earlierQuery.items.length,
|
|
617
|
-
const current = await call(captured, "history_list", { after_seq: 30 }, ctx);
|
|
618
|
-
assert.
|
|
589
|
+
const earlierQuery = page(await call(captured, "history_list", { query: "older window", before_seq: 31, limit: 30 }, ctx));
|
|
590
|
+
assert.equal(earlierQuery.items.length, 30, "queries and seq bounds recover earlier windows without a separate address");
|
|
591
|
+
const current = page(await call(captured, "history_list", { after_seq: 30 }, ctx));
|
|
592
|
+
assert.deepEqual(current.items.map((item) => [item.seq, item.content]), [[31, "current window"]], "the reset marker consumes no address");
|
|
619
593
|
toolCall(session, "t1", "bash", { command: "ls" });
|
|
620
594
|
toolResult(session, "t1", "bash", "done");
|
|
621
595
|
appendText(session, "user", "after tools");
|
|
@@ -194,7 +194,7 @@ test("shared note operations return canonical outcomes with a body-only read win
|
|
|
194
194
|
}));
|
|
195
195
|
assert.equal(observedKind, "body");
|
|
196
196
|
assert.equal(updated.change_kind, "body");
|
|
197
|
-
assert.
|
|
197
|
+
assert.ok(notesUpdate.render(success(updated)).startsWith(`updated @project/test.md (project ${notesIdentity.projectKey})`));
|
|
198
198
|
await notesWrite.execute({ address: "owned.md", content: "first", origin: "user" }, toolContext);
|
|
199
199
|
await notesWrite.execute({ address: "owned.md", content: "rewritten" }, toolContext);
|
|
200
200
|
assert.equal(data(await notesRead.execute({ address: "owned.md" }, toolContext)).metadata.origin, "user", "tool overwrites preserve an omitted origin");
|
|
@@ -203,7 +203,7 @@ test("shared note operations return canonical outcomes with a body-only read win
|
|
|
203
203
|
const moved = data(await notesUpdate.execute({ address: "owned.md", rename_to: "@project/renamed.md", edits: [{ oldText: "rewritten", newText: "final" }], origin: "external" }, toolContext));
|
|
204
204
|
assert.equal(moved.change_kind, "moved");
|
|
205
205
|
assert.equal(moved.rename_from, "owned.md");
|
|
206
|
-
assert.
|
|
206
|
+
assert.ok(notesUpdate.render(success(moved)).startsWith("moved owned.md -> @project/renamed.md"));
|
|
207
207
|
const renamed = data(await notesRead.execute({ address: moved.address }, toolContext));
|
|
208
208
|
assert.equal(renamed.text, "final");
|
|
209
209
|
assert.equal(renamed.metadata.origin, "external");
|
package/dist/test/marker.test.js
CHANGED
|
@@ -3,7 +3,7 @@ import test from "node:test";
|
|
|
3
3
|
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { BOOT_TYPE, CONTINUATION_TYPE, MARKER_TYPE, RESET_MARKER_TYPE } from "../plugins/pi/entries.js";
|
|
5
5
|
import { nextHistorySeq } from "../plugins/pi/history.js";
|
|
6
|
-
import { buildMarkerDraft
|
|
6
|
+
import { buildMarkerDraft } from "../plugins/pi/marker.js";
|
|
7
7
|
import { appendText, call, commitTurnEndBoundary, context, installExtensionTestEnvironment, makeExtension, runCommand, runHandlers, sentOf } from "./helpers/extension.js";
|
|
8
8
|
const env = installExtensionTestEnvironment("notesoup-marker-test");
|
|
9
9
|
test.beforeEach(env.beforeEach);
|
|
@@ -73,7 +73,6 @@ test("no marker before the interval", async () => {
|
|
|
73
73
|
const captured = makeExtension(sessionManager);
|
|
74
74
|
await beforeAgentStart(captured, context(sessionManager));
|
|
75
75
|
assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
|
|
76
|
-
assert.equal(MARKER_INTERVAL, 100);
|
|
77
76
|
});
|
|
78
77
|
test("a reset tail awaiting repair blocks markers, and boot anchors the new window's interval", async () => {
|
|
79
78
|
const sessionManager = managerWithMessages(99);
|