notesoup 0.59.1 → 0.60.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/README.md +3 -17
- package/dist/plugins/claude/src/helper.js +3 -4
- package/dist/plugins/codex/src/mcp.js +1 -2
- package/dist/plugins/dsh/tools.js +1 -2
- package/dist/plugins/pi/notes/tools.d.ts +1 -1
- package/dist/plugins/pi/notes/tools.js +2 -3
- package/dist/src/history/claude.d.ts +3 -1
- package/dist/src/history/claude.js +40 -4
- package/dist/src/history/history.d.ts +10 -11
- package/dist/src/history/history.js +8 -19
- package/dist/src/history/prefilter.d.ts +1 -1
- package/dist/src/history/prefilter.js +14 -9
- package/dist/src/history/query.d.ts +3 -14
- package/dist/src/history/query.js +73 -85
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/notes/address.js +3 -3
- package/dist/src/notes/store.d.ts +2 -4
- package/dist/src/notes/store.js +1 -2
- package/dist/src/tools/history.d.ts +4 -6
- package/dist/src/tools/history.js +69 -29
- package/dist/src/tools/notes.d.ts +18 -78
- package/dist/src/tools/notes.js +39 -50
- package/dist/src/tools/schema.d.ts +0 -1
- package/dist/src/tools/schema.js +0 -1
- package/dist/test/claude-history.test.js +27 -6
- package/dist/test/claude-mod.test.js +19 -8
- package/dist/test/codex-history.test.js +1 -1
- package/dist/test/codex-plugin.test.js +1 -2
- package/dist/test/dependencies.test.js +2 -2
- package/dist/test/dsh.test.js +2 -2
- package/dist/test/history-corpus.test.js +21 -36
- package/dist/test/history-prefilter.test.js +5 -0
- package/dist/test/history-summary-cache.test.js +3 -3
- package/dist/test/history.integration.test.js +53 -106
- package/dist/test/host-neutral.test.js +1 -1
- package/dist/test/note-policy.test.js +5 -5
- package/dist/test/notes-cwd.test.js +5 -5
- package/dist/test/notes-query-namespaces.test.js +2 -6
- package/dist/test/notes.integration.test.js +30 -35
- package/dist/test/notes.test.js +12 -14
- package/dist/test/project-namespace.test.js +3 -3
- package/docs/architecture.md +3 -3
- package/docs/claude-code-mod.md +5 -3
- package/docs/codex.md +1 -1
- package/docs/dsh.md +2 -2
- package/docs/history-sessions.md +9 -10
- package/docs/notes-library.md +3 -3
- package/docs/tool-results.md +12 -6
- package/package.json +1 -1
- package/plugins/claude/dist/claude/helper.js +214 -173
- package/plugins/claude/hooks/register.ts +8 -6
- package/plugins/claude/skills/memory/SKILL.md +6 -6
- package/plugins/claude/src/helper.ts +3 -4
- package/plugins/codex/README.md +1 -1
- package/plugins/codex/dist/codex/notesoup.js +176 -160
- package/plugins/codex/src/mcp.ts +1 -2
- package/plugins/dsh/tools.ts +1 -2
- package/plugins/paseo/README.md +16 -0
- package/plugins/paseo/client/brain-empty-card.tsx +5 -3
- package/plugins/paseo/client/markdown-core.tsx +189 -0
- package/plugins/paseo/client/markdown.tsx +38 -135
- package/plugins/paseo/client/notes-op-card.tsx +15 -12
- package/plugins/paseo/client/paper-card.tsx +1 -3
- package/plugins/paseo/client/sticky-card.tsx +2 -1
- package/plugins/paseo/client/typography.ts +24 -0
- package/plugins/paseo/test/markdown-core.test.ts +75 -0
- package/plugins/pi/notes/tools.ts +2 -3
- package/skills/memory/SKILL.md +6 -6
- package/src/history/claude.ts +31 -4
- package/src/history/history.ts +11 -16
- package/src/history/prefilter.ts +13 -9
- package/src/history/query.ts +67 -99
- package/src/index.ts +1 -1
- package/src/notes/address.ts +2 -2
- package/src/notes/store.ts +3 -6
- package/src/tools/history.ts +60 -29
- package/src/tools/notes.ts +39 -54
- package/src/tools/schema.ts +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
3
4
|
import { tmpdir } from "node:os";
|
|
4
5
|
import { join } from "node:path";
|
|
5
6
|
import test from "node:test";
|
|
@@ -50,6 +51,27 @@ test("Claude helper resolves foreign history without requiring a current append
|
|
|
50
51
|
assert.equal(invalid.ok, false);
|
|
51
52
|
assert.match(invalid.text, /invalid_session/);
|
|
52
53
|
});
|
|
54
|
+
test("Claude history tools wait for the confirmed append, never substitute a persisted sibling", async (t) => {
|
|
55
|
+
const home = mkdtempSync(join(tmpdir(), "claude-history-lag-"));
|
|
56
|
+
t.after(() => rmSync(home, { recursive: true, force: true }));
|
|
57
|
+
const transcriptPath = join(home, "transcript.jsonl");
|
|
58
|
+
const rows = [user("root", null, "start"), assistant("sibling", "root", "sibling-only text")];
|
|
59
|
+
writeFileSync(transcriptPath, jsonl(rows));
|
|
60
|
+
const identity = { home, sessionId, cwd: home, agent: "claude", model: "claude" };
|
|
61
|
+
const history = { sessionId, transcriptPath, headUuid: "active" };
|
|
62
|
+
const options = { roots: { pi: null, claude: null, codex: null }, env: {} };
|
|
63
|
+
const invoke = (tool, params) => dispatch({ op: "tool", tool, params, identity, history }, options);
|
|
64
|
+
await assert.rejects(dispatch({ op: "history_state", identity, history }), /active head is not persisted/);
|
|
65
|
+
const delayedWrite = sleep(120).then(() => writeFileSync(transcriptPath, jsonl([...rows, assistant("active", "root", "confirmed active text")])));
|
|
66
|
+
const [list, read] = await Promise.all([invoke("history_list", {}), invoke("history_read", { session: `claude:${sessionId}`, seq: 3 }), delayedWrite]);
|
|
67
|
+
for (const outcome of [list, read]) {
|
|
68
|
+
assert.ok(outcome.ok, outcome.text);
|
|
69
|
+
assert.match(outcome.text, /confirmed active text/);
|
|
70
|
+
assert.doesNotMatch(outcome.text, /sibling-only text/);
|
|
71
|
+
}
|
|
72
|
+
history.headUuid = "never-written";
|
|
73
|
+
await assert.rejects(invoke("history_list", {}), /active head is not persisted/);
|
|
74
|
+
});
|
|
53
75
|
test("Claude append and result arrival preserve call addresses and use the shared paired read", async () => {
|
|
54
76
|
const rows = [user("u", null, "run tools"), assistant("a", "u", [{ type: "thinking", thinking: "private thought" }, { type: "text", text: "working" }, call("one"), call("two")])];
|
|
55
77
|
const pending = project(rows, "a");
|
|
@@ -81,7 +103,7 @@ test("Claude dialogue paging skips tool/thinking envelopes without losing array
|
|
|
81
103
|
compact("boundary", "last"), row("boot", "boundary", "user", bootText(1))];
|
|
82
104
|
const projection = project(rows, "boot");
|
|
83
105
|
assert.equal(projection.highestSeq, 10);
|
|
84
|
-
const listed = await historyList.execute({
|
|
106
|
+
const listed = await historyList.execute({ before: 9, roles: ["user", "assistant"], limit: 3 }, projection);
|
|
85
107
|
assert.ok(listed.ok);
|
|
86
108
|
assert.deepEqual(listed.data.items.map((item) => "seq" in item ? [item.seq, item.content] : []), [[1, "human question"], [2, "assistant answer"], [8, "human followup"]]);
|
|
87
109
|
const read = await historyRead.execute({ seq: 2 }, projection);
|
|
@@ -174,7 +196,7 @@ test("Claude native compaction and reset keep pre-reset history, preserved rewri
|
|
|
174
196
|
assert.equal(allItems(projection).find((event) => event.text === "before first reset")?.windowId, `claude:${sessionId}:0`);
|
|
175
197
|
assert.equal(allItems(projection).find((event) => event.text === "after first reset")?.windowId, `claude:${sessionId}:1`);
|
|
176
198
|
assert.equal(projection.highestSeq, 8);
|
|
177
|
-
const earlier = await historyList.execute({
|
|
199
|
+
const earlier = await historyList.execute({ after: 4, before: 6, roles: ["assistant"] }, projection);
|
|
178
200
|
assert.ok(earlier.ok);
|
|
179
201
|
assert.deepEqual(earlier.data.items.map((item) => "content" in item ? item.content : ""), ["after first reset"]);
|
|
180
202
|
assert.equal(projection.windows[0]?.items[0]?.seq, 1);
|
|
@@ -188,7 +210,7 @@ test("Claude reset crosses native turn_duration graph metadata with no message c
|
|
|
188
210
|
assert.equal(projection.highestSeq, 5, "duration metadata does not allocate a message address");
|
|
189
211
|
assert.equal(projection.windows.length, 2);
|
|
190
212
|
assert.ok(allItems(projection).some((event) => event.text === "marker before reset"));
|
|
191
|
-
assert.ok((await historyList.execute({
|
|
213
|
+
assert.ok((await historyList.execute({ before: 3 }, projection)).ok);
|
|
192
214
|
assert.ok((await historyRead.execute({ seq: 2 }, projection)).ok);
|
|
193
215
|
});
|
|
194
216
|
test("Claude api_error retry metadata keeps compact ancestry without allocating seq or exposing internals", async () => {
|
|
@@ -206,7 +228,7 @@ test("Claude api_error retry metadata keeps compact ancestry without allocating
|
|
|
206
228
|
assert.deepEqual(project([...prefix, { ...rows[3], logicalParentUuid: "old" }, ...rows.slice(4)], "after"), projection, "metadata leaves all addresses and windows unchanged");
|
|
207
229
|
assert.doesNotMatch(allItems(projection).map(eventDocument).join("\n"), /PRIVATE_RETRY_PAYLOAD|ECONNRESET|request_retry/);
|
|
208
230
|
assert.ok((await historyList.execute({}, projection)).ok);
|
|
209
|
-
const earlier = await historyList.execute({
|
|
231
|
+
const earlier = await historyList.execute({ before: 3 }, projection);
|
|
210
232
|
assert.ok(earlier.ok);
|
|
211
233
|
assert.match(JSON.stringify(earlier), /before retry|finished turn/);
|
|
212
234
|
assert.ok((await historyRead.execute({ seq: 2 }, projection)).ok);
|
|
@@ -302,7 +324,6 @@ test("Claude helper reports gaps on list/read and re-anchors reset state only wi
|
|
|
302
324
|
assert.equal(excluded.ok, false);
|
|
303
325
|
assert.match(excluded.text, /outside the confirmed selected history/);
|
|
304
326
|
await assert.rejects(invoke("history_list", { window_id: "anything" }), /invalid history_list parameters:.*window_id/);
|
|
305
|
-
await assert.rejects(invoke("history_list", { before_seq: "invalid" }), /invalid history_list parameters: before_seq/);
|
|
306
327
|
await assert.rejects(invoke("history_read", { seq: "2" }), /invalid history_read parameters: seq/);
|
|
307
328
|
await assert.rejects(dispatch({ op: "history_state", identity, history }), /cannot determine the current window ordinal/);
|
|
308
329
|
// A native boundary alone cannot count the missing earlier resets. A quoted
|
|
@@ -324,7 +345,7 @@ test("Claude helper reports gaps on list/read and re-anchors reset state only wi
|
|
|
324
345
|
rows.push(compact("next", "after"), row("next-boot", "next", "user", bootText(9)), user("latest", "next-boot", "latest"));
|
|
325
346
|
writeFileSync(transcriptPath, jsonl(rows));
|
|
326
347
|
history.headUuid = "latest";
|
|
327
|
-
const earlier = await invoke("history_list", {
|
|
348
|
+
const earlier = await invoke("history_list", { after: 5, before: 7 });
|
|
328
349
|
assert.ok(earlier.ok);
|
|
329
350
|
assert.match(earlier.text, /after anchored reset/);
|
|
330
351
|
assert.doesNotMatch(earlier.text, /confirmed suffix/);
|
|
@@ -71,7 +71,7 @@ async function loadHookModule(t) {
|
|
|
71
71
|
if (typeof matcherOrHandler === "function")
|
|
72
72
|
on(event, matcherOrHandler);
|
|
73
73
|
else
|
|
74
|
-
on(event, ($, e, next) => Object.entries(matcherOrHandler).every(([key, value]) => e[key] === value) ? handler($, e, next) : next(e));
|
|
74
|
+
on(event, ($, e, next) => Object.entries(matcherOrHandler).every(([key, value]) => Array.isArray(value) ? value.includes(e[key]) : e[key] === value) ? handler($, e, next) : next(e));
|
|
75
75
|
}) };
|
|
76
76
|
}
|
|
77
77
|
/** An engine that answers the hook by running the real helper against a throwaway notes home. */
|
|
@@ -122,9 +122,9 @@ test("Claude notes survive removal of the session's worktree cwd", async (t) =>
|
|
|
122
122
|
assert.match((await call("notes_read", { address })).result, /done/);
|
|
123
123
|
}
|
|
124
124
|
});
|
|
125
|
-
test("Claude helper exposes the
|
|
125
|
+
test("Claude helper exposes the shared notes/history schemas", async () => {
|
|
126
126
|
const schemas = await dispatch({ op: "schemas" });
|
|
127
|
-
assert.deepEqual(schemas.map((schema) => schema.name), ["notes_write", "notes_update", "notes_read", "notes_list", "
|
|
127
|
+
assert.deepEqual(schemas.map((schema) => schema.name), ["notes_write", "notes_update", "notes_read", "notes_list", "history_list", "history_read"]);
|
|
128
128
|
assert.ok(schemas.every((schema) => schema.description.length > 20 && schema.inputSchema.type === "object"));
|
|
129
129
|
});
|
|
130
130
|
test("Claude helper delivers only shared rendered text and success", async () => {
|
|
@@ -328,7 +328,7 @@ test("Claude Mod helper runs from a standalone copied plugin directory", () => {
|
|
|
328
328
|
}));
|
|
329
329
|
const schemas = run('{"op":"schemas"}');
|
|
330
330
|
assert.equal(schemas.ok, true);
|
|
331
|
-
assert.equal(schemas.result?.length,
|
|
331
|
+
assert.equal(schemas.result?.length, 6);
|
|
332
332
|
assert.equal(run("not json").ok, false);
|
|
333
333
|
}
|
|
334
334
|
finally {
|
|
@@ -524,7 +524,7 @@ test("Claude Mod hook delivers the helper's shared text, and marks only a refusa
|
|
|
524
524
|
const handlers = new Map();
|
|
525
525
|
hooks.register((event, handler) => handlers.set(event, handler));
|
|
526
526
|
await handlers.get("session.start")(host, { cwd: home, isInteractive: true }, async (event) => event);
|
|
527
|
-
assert.deepEqual(registered.map((spec) => spec.name), ["empty_brain", "notes_write", "notes_update", "notes_read", "notes_list", "
|
|
527
|
+
assert.deepEqual(registered.map((spec) => spec.name), ["empty_brain", "notes_write", "notes_update", "notes_read", "notes_list", "history_list", "history_read"]);
|
|
528
528
|
for (const spec of registered) {
|
|
529
529
|
assert.equal(spec.isDeferred, false, `${spec.name} is available from the start without tool search`);
|
|
530
530
|
assert.ok(spec.description.length > 20);
|
|
@@ -586,7 +586,6 @@ test("Claude Mod clears at the shared hard point after successful settlement and
|
|
|
586
586
|
return {};
|
|
587
587
|
};
|
|
588
588
|
await invoke("session.start", { cwd: home, isInteractive: true });
|
|
589
|
-
assert.equal(registered.length, 8);
|
|
590
589
|
const initial = await handlers.get("prompt.context")(host, {}, async () => ({ blocks: [] }));
|
|
591
590
|
assert.equal(initial.blocks.length, 1, "below the warn point no warning joins the boot");
|
|
592
591
|
assert.match(initial.blocks[0].text, /Current context window id: claude:hook-session:0/);
|
|
@@ -1732,7 +1731,7 @@ test("Claude serves every registered notes tool to subagents without leaking eve
|
|
|
1732
1731
|
assert.match((await call("notes_read", { address: "child.md" })).result, /child body/);
|
|
1733
1732
|
assert.equal((await call("notes_update", { address: "child.md", edits: [{ oldText: "child body", newText: "updated body" }] })).isError, undefined);
|
|
1734
1733
|
assert.match((await call("notes_list", {})).result, /child\.md/);
|
|
1735
|
-
assert.match((await call("
|
|
1734
|
+
assert.match((await call("notes_list", { query: "updated body" })).result, /child\.md/);
|
|
1736
1735
|
assert.equal((await call("notes_read", { address: "absent.md" })).isError, true, "refusals retain the error discriminator in subagents");
|
|
1737
1736
|
});
|
|
1738
1737
|
test("Claude identity uses the documented current model and cwd, with a safe model fallback", async (t) => {
|
|
@@ -1824,6 +1823,13 @@ test("Claude history keeps classic transcript_path across startup, confirms appe
|
|
|
1824
1823
|
const handlers = new Map();
|
|
1825
1824
|
(await loadHookModule(t)).register((event, handler) => handlers.set(event, handler));
|
|
1826
1825
|
const invoke = (name, event = {}, result = {}) => handlers.get(name)(host, event, async () => result);
|
|
1826
|
+
const budgets = new Map();
|
|
1827
|
+
const run = host.process.run;
|
|
1828
|
+
host.process.run = (argv, init) => {
|
|
1829
|
+
const request = JSON.parse(init.stdin);
|
|
1830
|
+
budgets.set(request.tool ?? request.op, init?.timeoutMs);
|
|
1831
|
+
return run(argv, init);
|
|
1832
|
+
};
|
|
1827
1833
|
const transcriptPath = join(home, "transcript.jsonl");
|
|
1828
1834
|
const root = { type: "user", uuid: "root", parentUuid: null, sessionId: "hook-session", message: { role: "user", content: "old request" } };
|
|
1829
1835
|
const attachment = { type: "attachment", uuid: "startup", parentUuid: "root", sessionId: "hook-session", rendered: [{ content: [{ type: "text", text: "startup injection" }] }] };
|
|
@@ -1834,7 +1840,7 @@ test("Claude history keeps classic transcript_path across startup, confirms appe
|
|
|
1834
1840
|
// Real order: classic -> startup attachment appends -> typed session.start.
|
|
1835
1841
|
await invoke("session.append", { uuid: "startup" }, { uuid: "startup", message: {} });
|
|
1836
1842
|
await invoke("session.start", { cwd: home, isInteractive: true });
|
|
1837
|
-
assert.
|
|
1843
|
+
assert.ok(registered.some((tool) => tool.name === "history_list"));
|
|
1838
1844
|
const listed = await call("history_list", { roles: ["user", "context"] });
|
|
1839
1845
|
assert.equal(listed.isError, undefined, listed.result);
|
|
1840
1846
|
assert.match(listed.result, /old request/);
|
|
@@ -1858,6 +1864,11 @@ test("Claude history keeps classic transcript_path across startup, confirms appe
|
|
|
1858
1864
|
const switched = await call("history_list");
|
|
1859
1865
|
assert.match(switched.result, /another branch/);
|
|
1860
1866
|
assert.doesNotMatch(switched.result, /startup injection/);
|
|
1867
|
+
await call("notes_list");
|
|
1868
|
+
assert.equal(budgets.get("history_list"), 120_000);
|
|
1869
|
+
assert.equal(budgets.get("history_read"), 120_000);
|
|
1870
|
+
assert.equal(budgets.get("notes_list"), 10_000);
|
|
1871
|
+
assert.equal(budgets.get("history_state"), 10_000);
|
|
1861
1872
|
});
|
|
1862
1873
|
test("Claude history without a documented path refuses honestly and keeps notes usable", async (t) => {
|
|
1863
1874
|
const home = mkdtempSync(join(tmpdir(), "claude-no-history-path-"));
|
|
@@ -209,7 +209,7 @@ test("two native checkpoints retain old raw history; replacement_history is not
|
|
|
209
209
|
assert.deepEqual(second.projection.windows.map((w) => [w.windowId, w.items[0]?.seq, w.items.at(-1)?.seq]), [
|
|
210
210
|
[`codex:${ROOT}:${W0}`, 2, 3], [`codex:${ROOT}:${W1}`, 4, 6], [`codex:${ROOT}:${W2}`, 7, 8],
|
|
211
211
|
]);
|
|
212
|
-
const earlier = await historyList.execute({
|
|
212
|
+
const earlier = await historyList.execute({ after: 3, before: 7, roles: ["user"] }, second.projection);
|
|
213
213
|
assert.ok(earlier.ok);
|
|
214
214
|
assert.deepEqual(earlier.data.items.map((item) => [item.seq, item.role, item.content]), [[6, "user", "middle text"]]);
|
|
215
215
|
const old = await historyRead.execute({ seq: 2 }, second.projection);
|
|
@@ -149,7 +149,7 @@ test("a copied plugin without src or node_modules still initializes and lists al
|
|
|
149
149
|
const listed = await client.listTools();
|
|
150
150
|
assert.deepEqual(listed.tools.map((tool) => tool.name).sort(), [
|
|
151
151
|
"history_list", "history_read",
|
|
152
|
-
"notes_list", "notes_read", "
|
|
152
|
+
"notes_list", "notes_read", "notes_update", "notes_write",
|
|
153
153
|
]);
|
|
154
154
|
for (const tool of listed.tools) {
|
|
155
155
|
const schema = tool.outputSchema;
|
|
@@ -184,7 +184,6 @@ test("bundled Codex MCP reads another harness and wildcard results retain their
|
|
|
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
186
|
assert.equal(limited.structuredContent.items.length, 1, "the limit bounds the page to one item");
|
|
187
|
-
assert.doesNotMatch(textOf(limited), /before_seq|after_seq/);
|
|
188
187
|
const invalid = await call(client, { name: "history_read", arguments: { session: "*", seq: 1 }, _meta: metaFor(ROOT, ROOT) });
|
|
189
188
|
assert.equal(errorCode(invalid), "invalid_session");
|
|
190
189
|
});
|
|
@@ -246,7 +246,7 @@ test("AST guard sees every literal module edge, not import-like prose or comment
|
|
|
246
246
|
test("the core entry is host-neutral and the Pi plugin entry owns the extension", () => {
|
|
247
247
|
assert.deepEqual(Object.keys(core).sort(), [
|
|
248
248
|
"DEFAULT_BOOT_TOOL_NAMES", "NoteError", "createNotesStore", "deriveThresholds", "effectiveNotePolicy", "historyList", "historyRead",
|
|
249
|
-
"loadNotesSnapshot", "noteIdentity", "notesIdentityForCall", "notesList", "notesRead", "
|
|
249
|
+
"loadNotesSnapshot", "noteIdentity", "notesIdentityForCall", "notesList", "notesRead", "notesToolContext", "notesUpdate", "notesWrite", "projectHistory",
|
|
250
250
|
"projectKey", "remainingBudget", "renderBootBlock", "renderProtocolBlock", "selectContinuation", "slugify",
|
|
251
251
|
"tokenBudgetGuidance", "unavailableNotesSnapshot", "warningPrompt", "WARNING_BODY",
|
|
252
252
|
].sort(), "the core exports a curated host-neutral surface and no extension");
|
|
@@ -269,7 +269,7 @@ test("the configured extension source is the executable current entry", async ()
|
|
|
269
269
|
registerTool(tool) { tools.push(tool); },
|
|
270
270
|
registerCommand(name) { commands.push(name); },
|
|
271
271
|
});
|
|
272
|
-
assert.deepEqual(tools.map((tool) => tool.name).sort(), ["dream_begin", "dream_end", "dream_forget", "empty_brain", "get_context_remaining", "history_list", "history_read", "notes_list", "notes_read", "
|
|
272
|
+
assert.deepEqual(tools.map((tool) => tool.name).sort(), ["dream_begin", "dream_end", "dream_forget", "empty_brain", "get_context_remaining", "history_list", "history_read", "notes_list", "notes_read", "notes_update", "notes_write"]);
|
|
273
273
|
assert.deepEqual(tools.filter((tool) => tool.exposure === "deferred").map((tool) => tool.name).sort(), ["dream_begin", "dream_end", "dream_forget", "history_list", "history_read"], "dream and history tools stay hidden until searched");
|
|
274
274
|
assert.deepEqual(commands.sort(), ["empty", "fresh-window", "notesoup"]);
|
|
275
275
|
});
|
package/dist/test/dsh.test.js
CHANGED
|
@@ -8,7 +8,7 @@ import { tmpdir } from "node:os";
|
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
import { resolveProjectNamespace } from "../src/notes/project-namespace.js";
|
|
10
10
|
import { WINDOW_IDENTITY_CLOSE_TAG, WINDOW_IDENTITY_OPEN_TAG } from "../src/boot/text.js";
|
|
11
|
-
import { notesList, notesRead,
|
|
11
|
+
import { notesList, notesRead, notesUpdate, notesWrite } from "../src/tools/notes.js";
|
|
12
12
|
import { historyList, historyRead } from "../src/tools/history.js";
|
|
13
13
|
import { notesToolContext } from "../src/tools/notes-context.js";
|
|
14
14
|
import { success } from "../src/result.js";
|
|
@@ -27,7 +27,7 @@ function system(request) { return typeof request.system === "string" ? request.s
|
|
|
27
27
|
function code(expected) { return (error) => error?.code === expected; }
|
|
28
28
|
test("dsh preserves shared tool and parameter descriptions verbatim", async (t) => {
|
|
29
29
|
const { ctx } = await dshFixture(t);
|
|
30
|
-
for (const operation of [notesWrite, notesUpdate, notesRead, notesList,
|
|
30
|
+
for (const operation of [notesWrite, notesUpdate, notesRead, notesList, historyList, historyRead]) {
|
|
31
31
|
const registered = ctx.tools.get(operation.name);
|
|
32
32
|
assert.equal(registered.description, operation.description);
|
|
33
33
|
const properties = registered.parameters.properties;
|
|
@@ -112,18 +112,17 @@ test("all single-session recipes preserve the resolved identity, including folde
|
|
|
112
112
|
{ seq: 4, windowId: "w", role: "assistant", text: "last" },
|
|
113
113
|
] }], 4, new Set([1, 2, 3, 4]));
|
|
114
114
|
const ctx = context([descriptor("claude", "target-session", p)]);
|
|
115
|
-
const page = await historyList.execute({ session: "claude:target", limit: 1,
|
|
115
|
+
const page = await historyList.execute({ session: "claude:target", limit: 1, before: 5 }, ctx);
|
|
116
116
|
assert.equal(data(page).has_older, true);
|
|
117
|
-
assert.match(historyList.render(page), /→ older: \{"session":"claude:target-session","
|
|
118
|
-
const first = await historyList.execute({ session: "target",
|
|
117
|
+
assert.match(historyList.render(page), /→ older: \{"session":"claude:target-session","before":4\}/);
|
|
118
|
+
const first = await historyList.execute({ session: "target", after: 0, limit: 1 }, ctx);
|
|
119
119
|
assert.equal(data(first).has_newer, true);
|
|
120
|
-
assert.match(historyList.render(first), /→ newer: \{"session":"claude:target-session","
|
|
120
|
+
assert.match(historyList.render(first), /→ newer: \{"session":"claude:target-session","after":1\}/);
|
|
121
121
|
const foldPage = await historyList.execute({ session: "target", limit: 3 }, ctx);
|
|
122
122
|
const expand = /→ expand: (\{[^\n]+\})/.exec(historyList.render(foldPage));
|
|
123
123
|
assert.ok(expand);
|
|
124
124
|
const recipe = JSON.parse(expand[1]);
|
|
125
125
|
assert.equal(recipe.session, "claude:target-session");
|
|
126
|
-
assert.equal("from" in recipe, false);
|
|
127
126
|
assert.deepEqual(data(await historyList.execute(recipe, ctx)).items.map((item) => item.seq), [2]);
|
|
128
127
|
assert.match(historyList.render(foldPage), /session claude:target-session \| seq 1 \| user/);
|
|
129
128
|
const read = await historyRead.execute({ session: "target", seq: 3 }, ctx);
|
|
@@ -144,30 +143,21 @@ test("recipes expand a fold at seq 1 and read its neighborhood from the start",
|
|
|
144
143
|
const expand = /→ expand: (\{[^\n]+\})/.exec(historyList.render(folded));
|
|
145
144
|
assert.ok(expand);
|
|
146
145
|
const recipe = JSON.parse(expand[1]);
|
|
147
|
-
assert.equal(recipe.
|
|
146
|
+
assert.equal(recipe.after, 0);
|
|
148
147
|
assert.ok(Check(historyList.parameters, recipe));
|
|
149
148
|
assert.deepEqual(data(await historyList.execute(recipe, ctx)).items.map((item) => item.seq), [1, 2]);
|
|
150
149
|
const read = await historyRead.execute({ session: "first-fold", seq: 3 }, ctx);
|
|
151
150
|
const neighborhood = /neighborhood → `history_list`\((\{[^\n]+\})\)/.exec(historyRead.render(read));
|
|
152
151
|
assert.ok(neighborhood);
|
|
153
152
|
const nearby = JSON.parse(neighborhood[1]);
|
|
154
|
-
assert.equal(nearby.
|
|
153
|
+
assert.equal(nearby.after, 0);
|
|
155
154
|
assert.ok(Check(historyList.parameters, nearby));
|
|
156
155
|
assert.ok(data(await historyList.execute(nearby, ctx)).items.length > 0);
|
|
157
156
|
});
|
|
158
157
|
test("wildcard refusals precede discovery, and read accepts no wildcard selector", async () => {
|
|
159
158
|
const ctx = { current: () => { throw new Error("must not load current"); }, corpus: { currentHarness: "pi", sessions: async () => { throw new Error("must not discover"); } } };
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
for (const bounds of [{ before_seq: 10 }, { after_seq: 0 }, { after_seq: 1 }, { before_seq: 10, after_seq: 1 }]) {
|
|
163
|
-
refusal(await historyList.execute({ session, query, ...bounds }, ctx), "invalid_bounds");
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
for (const session of ["*", "pi:*", "cl*", "dsh:pre*suffix"]) {
|
|
168
|
-
refusal(await historyRead.execute({ session, seq: 1 }, ctx), "invalid_session");
|
|
169
|
-
}
|
|
170
|
-
refusal(await historyList.execute({ session: "*", query: "needle", since: "not-a-date" }, ctx), "invalid_time");
|
|
159
|
+
assert.match(refusal(await historyList.execute({ session: "pi:*", query: "needle", after: "3" }, ctx), "invalid_bounds"), /requires times/);
|
|
160
|
+
refusal(await historyRead.execute({ session: "*", seq: 1 }, ctx), "invalid_session");
|
|
171
161
|
});
|
|
172
162
|
test("native filesystem discovery decodes three harnesses, compressed Codex, and keeps source bytes/mtime unchanged", async (t) => {
|
|
173
163
|
const f = await fixture(t);
|
|
@@ -205,14 +195,12 @@ test("wildcard query merges every role chronologically, limits from either end,
|
|
|
205
195
|
assert.deepEqual(newest.items, page.items.slice(-2));
|
|
206
196
|
assert.equal(newest.has_older, true);
|
|
207
197
|
assert.equal(newest.has_newer, false);
|
|
208
|
-
|
|
209
|
-
const oldestResult = await historyList.execute({ session: "*", query: "needle", limit: 2, from: "oldest" }, ctx);
|
|
198
|
+
const oldestResult = await historyList.execute({ session: "*", query: "needle", limit: 2, after: "2026-10-06" }, ctx);
|
|
210
199
|
const oldest = data(oldestResult);
|
|
211
200
|
assert.deepEqual(oldest.items, page.items.slice(0, 2));
|
|
212
201
|
assert.equal(oldest.has_older, false);
|
|
213
202
|
assert.equal(oldest.has_newer, true);
|
|
214
|
-
|
|
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));
|
|
203
|
+
const filtered = data(await historyList.execute({ session: "*", query: "needle", roles: ["tool", "context"], after: "2026-10-06T01:02:04", before: "2026-10-06T01:02:07Z" }, ctx));
|
|
216
204
|
assert.deepEqual(filtered.items.map((item) => item.role), ["tool"]);
|
|
217
205
|
const harness = data(await historyList.execute({ session: "claude:*", query: "needle" }, ctx));
|
|
218
206
|
assert.ok(harness.items.every((item) => "session" in item && item.session === "claude:claude-one"));
|
|
@@ -235,12 +223,11 @@ test("bounded wildcard search scans every session and orders untimed and tied ma
|
|
|
235
223
|
}));
|
|
236
224
|
const ctx = context(sessions);
|
|
237
225
|
const ids = (page) => page.items.map((item) => "seq" in item ? [item.session, item.seq] : null);
|
|
238
|
-
assert.deepEqual(ids(data(await historyList.execute({ session: "*", query: "needle",
|
|
226
|
+
assert.deepEqual(ids(data(await historyList.execute({ session: "*", query: "needle", after: "2026-10-06", limit: 3 }, ctx))), [["pi:a", 3], ["pi:a", 4], ["pi:a", 5]]);
|
|
239
227
|
assert.deepEqual(seen, ["z", "a", "m"]);
|
|
240
228
|
seen.length = 0;
|
|
241
229
|
assert.deepEqual(ids(data(await historyList.execute({ session: "*", query: "needle", limit: 3 }, ctx))), [["pi:z", 198], ["pi:z", 199], ["pi:z", 200]]);
|
|
242
230
|
assert.deepEqual(seen, ["z", "a", "m"]);
|
|
243
|
-
assert.deepEqual(ids(data(await historyList.execute({ session: "*", query: "needle", from: "oldest", limit: 1, since: AT }, ctx))), [["pi:a", 3]]);
|
|
244
231
|
});
|
|
245
232
|
test("query-less wildcards browse recent sessions, normalize empty queries, and keep canonical IDs", async (t) => {
|
|
246
233
|
const { ctx } = await fixture(t);
|
|
@@ -278,7 +265,7 @@ test("session overviews order discovery by mtime, stop at the session limit, the
|
|
|
278
265
|
assert.deepEqual(loaded, Array.from({ length: 20 }, (_, index) => 24 - index));
|
|
279
266
|
assert.deepEqual(recent.items.map((item) => item.session), loaded.map((index) => `pi:s-${index}`));
|
|
280
267
|
loaded.length = 0;
|
|
281
|
-
const oldest = data(await historyList.execute({ session: "*",
|
|
268
|
+
const oldest = data(await historyList.execute({ session: "*", after: AT, limit: 2 }, ctx));
|
|
282
269
|
assert.equal(oldest.has_older, false);
|
|
283
270
|
assert.equal(oldest.has_newer, true);
|
|
284
271
|
assert.deepEqual(loaded, [0, 1]);
|
|
@@ -308,12 +295,11 @@ test("session representatives respect visibility, role/time filters, opening use
|
|
|
308
295
|
assert.deepEqual(await chosen({ roles: ["context", "tool"] }), [8]);
|
|
309
296
|
assert.deepEqual(await chosen({ roles: ["tool"] }), [6]);
|
|
310
297
|
assert.deepEqual(await chosen({ roles: [] }), []);
|
|
311
|
-
assert.deepEqual(await chosen({
|
|
312
|
-
assert.deepEqual(await chosen({
|
|
313
|
-
assert.deepEqual(await chosen({
|
|
314
|
-
assert.deepEqual(await chosen({
|
|
315
|
-
assert.deepEqual(await chosen({
|
|
316
|
-
assert.deepEqual(await chosen({ since: at(7) }), []);
|
|
298
|
+
assert.deepEqual(await chosen({ after: at(1), before: at(3) }), [4]);
|
|
299
|
+
assert.deepEqual(await chosen({ after: at(2) }), [5]);
|
|
300
|
+
assert.deepEqual(await chosen({ before: at(1) }), [1]);
|
|
301
|
+
assert.deepEqual(await chosen({ after: at(4) }), [8]);
|
|
302
|
+
assert.deepEqual(await chosen({ after: at(4), roles: ["user"] }), []);
|
|
317
303
|
const noUsers = { ...p, windows: p.windows.map((window) => ({ ...window, items: window.items.filter((item) => item.role !== "user") })) };
|
|
318
304
|
const fallback = data(await historyList.execute({ session: "*" }, context([descriptor("pi", "assistant-topic", noUsers)])));
|
|
319
305
|
assert.deepEqual(fallback.items.map((item) => "seq" in item ? item.seq : null), [4]);
|
|
@@ -418,13 +404,12 @@ test("oversized cross-session reads/searches obey both wire budgets and retain c
|
|
|
418
404
|
});
|
|
419
405
|
test("wildcard byte budgets report retained candidates beyond either end", async () => {
|
|
420
406
|
const ctx = context([descriptor("pi", "large", projection("needle " + "x".repeat(20_000)))]);
|
|
421
|
-
for (const
|
|
422
|
-
const result = await historyList.execute({ session: "*", query: "needle",
|
|
407
|
+
for (const after of [undefined, AT]) {
|
|
408
|
+
const result = await historyList.execute({ session: "*", query: "needle", after, limit: 5, max_chars_per_item: 50_000 }, ctx);
|
|
423
409
|
const page = data(result);
|
|
424
410
|
assert.ok(page.items.length < 5);
|
|
425
|
-
assert.equal(page.has_older,
|
|
426
|
-
assert.equal(page.has_newer,
|
|
427
|
-
assert.doesNotMatch(historyList.render(result), /before_seq|after_seq/);
|
|
411
|
+
assert.equal(page.has_older, after === undefined);
|
|
412
|
+
assert.equal(page.has_newer, after !== undefined);
|
|
428
413
|
}
|
|
429
414
|
});
|
|
430
415
|
test("qualified lookup and current-harness matches do not inspect unrelated roots", async (t) => {
|
|
@@ -35,6 +35,11 @@ test("only EOF proves a miss, while errors after tokens or a fallback still prop
|
|
|
35
35
|
}
|
|
36
36
|
assert.equal(await createHistoryPrefilter(["needle"])(late()), true);
|
|
37
37
|
assert.equal(finished, true);
|
|
38
|
+
finished = false;
|
|
39
|
+
assert.equal(await createHistoryPrefilter(["needle"])(late(), false, true), true);
|
|
40
|
+
assert.equal(finished, false, "a plain-file hit leaves the rest to the strict decoder");
|
|
41
|
+
assert.equal(await createHistoryPrefilter(["absentword"])(late(), false, true), false);
|
|
42
|
+
assert.equal(finished, true, "even the early-hit path must read to EOF to prove a miss");
|
|
38
43
|
async function* broken() { yield Buffer.from("needle"); throw new Error("read failed"); }
|
|
39
44
|
for (const queries of [["absentword"], ["needle"], ["😀"]])
|
|
40
45
|
await assert.rejects(createHistoryPrefilter(queries)(broken()), /read failed/);
|
|
@@ -138,7 +138,7 @@ test("search, roles, time filters and explicit sessions bypass the summary while
|
|
|
138
138
|
for (const query of ["", [], ["", ""]])
|
|
139
139
|
await historyList.execute({ session: "pi:*", query }, ctx);
|
|
140
140
|
assert.equal(reads.length, 1);
|
|
141
|
-
for (const filters of [{ roles: ["assistant"] }, {
|
|
141
|
+
for (const filters of [{ roles: ["assistant"] }, { after: AT }, { before: "2026-10-07" }, { query: "later" }, { session: "pi:offline" }]) {
|
|
142
142
|
const before = reads.length;
|
|
143
143
|
const params = { session: "pi:*", ...filters };
|
|
144
144
|
const result = await historyList.execute(params, ctx);
|
|
@@ -146,8 +146,8 @@ test("search, roles, time filters and explicit sessions bypass the summary while
|
|
|
146
146
|
const plain = { current: () => projection("live"), corpus: { currentHarness: "dsh", sessions: async (harness) => (await f.corpus().sessions(harness)).map(({ loadRepresentative: _cache, ...session }) => session) } };
|
|
147
147
|
assert.deepEqual(result, await historyList.execute(params, plain));
|
|
148
148
|
}
|
|
149
|
-
assert.equal(data(await historyList.execute({ session: "pi:*",
|
|
150
|
-
assert.equal(data(await historyList.execute({ session: "pi:*",
|
|
149
|
+
assert.equal(data(await historyList.execute({ session: "pi:*", after: AT }, ctx)).items.length, 1);
|
|
150
|
+
assert.equal(data(await historyList.execute({ session: "pi:*", before: AT }, ctx)).items.length, 0, "before is exclusive");
|
|
151
151
|
});
|
|
152
152
|
test("corrupt cache/schema and unwritable roots fall back; a warm cache cannot hide malformed or unsupported transcripts", async (t) => {
|
|
153
153
|
const f = await fixture(t);
|