notesoup 0.60.1 → 0.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +15 -0
- package/README.md +14 -10
- package/dist/plugins/antigravity/src/cli.d.ts +1 -0
- package/dist/plugins/antigravity/src/cli.js +23 -0
- package/dist/plugins/antigravity/src/hooks.d.ts +18 -0
- package/dist/plugins/antigravity/src/hooks.js +53 -0
- package/dist/plugins/antigravity/src/identity.d.ts +26 -0
- package/dist/plugins/antigravity/src/identity.js +129 -0
- package/dist/plugins/claude/src/helper.js +2 -1
- package/dist/plugins/codex/src/hooks.js +1 -0
- package/dist/plugins/codex/src/identity.d.ts +6 -1
- package/dist/plugins/codex/src/identity.js +13 -1
- package/dist/plugins/codex/src/mcp.d.ts +35 -7
- package/dist/plugins/codex/src/mcp.js +26 -88
- package/dist/plugins/codex/src/text.js +3 -3
- package/dist/plugins/dsh/tools.js +8 -4
- package/dist/plugins/mcp/operations.d.ts +15 -0
- package/dist/plugins/mcp/operations.js +43 -0
- package/dist/plugins/mcp/server.d.ts +14 -0
- package/dist/plugins/mcp/server.js +13 -0
- package/dist/plugins/pi/budget.d.ts +1 -1
- package/dist/plugins/pi/budget.js +3 -2
- package/dist/plugins/pi/entries.d.ts +1 -0
- package/dist/plugins/pi/entries.js +1 -0
- package/dist/plugins/pi/history-tools.js +2 -1
- package/dist/plugins/pi/history.js +18 -1
- package/dist/plugins/pi/notes/tools.js +7 -3
- package/dist/plugins/pi/render.d.ts +7 -1
- package/dist/plugins/pi/render.js +2 -2
- package/dist/plugins/pi/reset/lifecycle.d.ts +1 -1
- package/dist/plugins/pi/reset/lifecycle.js +8 -9
- package/dist/plugins/pi/runtime.js +102 -61
- package/dist/plugins/pi/tool-result.js +7 -7
- package/dist/plugins/pi/window.d.ts +33 -3
- package/dist/plugins/pi/window.js +209 -9
- package/dist/src/boot/render.d.ts +5 -0
- package/dist/src/boot/render.js +60 -28
- package/dist/src/boot/text.d.ts +3 -3
- package/dist/src/boot/text.js +27 -26
- package/dist/src/budget/text.d.ts +2 -2
- package/dist/src/budget/text.js +13 -13
- package/dist/src/history/claude.d.ts +2 -0
- package/dist/src/history/claude.js +46 -0
- package/dist/src/history/codex-transcript.js +7 -5
- package/dist/src/history/codex.js +3 -0
- package/dist/src/history/corpus.d.ts +28 -1
- package/dist/src/history/corpus.js +40 -0
- package/dist/src/history/history.d.ts +37 -46
- package/dist/src/history/history.js +21 -40
- package/dist/src/history/local.js +67 -32
- package/dist/src/history/pi.d.ts +2 -1
- package/dist/src/history/pi.js +122 -48
- package/dist/src/history/prefilter.js +76 -19
- package/dist/src/history/query.d.ts +28 -49
- package/dist/src/history/query.js +83 -68
- package/dist/src/history/summary-cache.d.ts +8 -1
- package/dist/src/history/summary-cache.js +138 -12
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/notes/frontmatter.d.ts +4 -0
- package/dist/src/notes/frontmatter.js +15 -1
- package/dist/src/notes/index.d.ts +1 -1
- package/dist/src/notes/index.js +1 -1
- package/dist/src/notes/policy.d.ts +15 -1
- package/dist/src/notes/policy.js +47 -6
- package/dist/src/notes/store.d.ts +14 -0
- package/dist/src/notes/store.js +33 -12
- package/dist/src/text-match.d.ts +10 -1
- package/dist/src/text-match.js +42 -3
- package/dist/src/tools/dream.d.ts +22 -91
- package/dist/src/tools/dream.js +30 -27
- package/dist/src/tools/history.d.ts +33 -26
- package/dist/src/tools/history.js +257 -163
- package/dist/src/tools/notes.d.ts +58 -160
- package/dist/src/tools/notes.js +151 -99
- package/dist/src/tools/output.d.ts +2 -1
- package/dist/src/tools/output.js +2 -1
- package/dist/src/tools/result.d.ts +4 -7
- package/dist/src/tools/result.js +8 -9
- package/dist/src/tools/schema.d.ts +4 -1
- package/dist/src/tools/schema.js +25 -1
- package/dist/test/agent-loop.test.js +198 -16
- package/dist/test/antigravity-live.test.d.ts +1 -0
- package/dist/test/antigravity-live.test.js +142 -0
- package/dist/test/antigravity-plugin.test.d.ts +1 -0
- package/dist/test/antigravity-plugin.test.js +101 -0
- package/dist/test/boot.integration.test.js +133 -14
- package/dist/test/claude-history.test.js +14 -13
- package/dist/test/claude-mod.test.js +9 -6
- package/dist/test/codex-history.test.js +15 -3
- package/dist/test/codex-plugin.test.js +76 -38
- package/dist/test/dependencies.test.js +7 -3
- package/dist/test/dream-skill.test.js +3 -3
- package/dist/test/dream-tools.test.js +101 -56
- package/dist/test/dsh.test.js +34 -19
- package/dist/test/helpers/dependency-graph.js +2 -2
- package/dist/test/helpers/extension.d.ts +65 -2
- package/dist/test/helpers/extension.js +72 -3
- package/dist/test/history-corpus.test.js +79 -77
- package/dist/test/history-summary-cache.test.js +97 -9
- package/dist/test/history.integration.test.js +234 -168
- package/dist/test/host-neutral.test.js +69 -19
- package/dist/test/marker.test.js +1 -1
- package/dist/test/note-policy.test.js +189 -56
- package/dist/test/notes.integration.test.js +212 -94
- package/dist/test/notes.test.js +184 -113
- package/dist/test/pi-render.test.js +20 -12
- package/dist/test/project-namespace.test.js +3 -2
- package/dist/test/reset-lifecycle.test.js +2 -2
- package/docs/antigravity.md +44 -0
- package/docs/architecture.md +6 -4
- package/docs/claude-code-mod.md +2 -2
- package/docs/codex.md +36 -38
- package/docs/dsh.md +4 -4
- package/docs/history-sessions.md +28 -50
- package/docs/notes-library.md +6 -6
- package/docs/reset-lifecycle.md +1 -1
- package/docs/skills.md +3 -3
- package/docs/tool-results.md +47 -28
- package/package.json +3 -2
- package/playbook.md +3 -3
- package/plugins/antigravity/dist/antigravity/notesoup.js +26886 -0
- package/plugins/antigravity/hooks.json +7 -0
- package/plugins/antigravity/mcp_config.json +8 -0
- package/plugins/antigravity/plugin.json +6 -0
- package/plugins/antigravity/src/cli.ts +22 -0
- package/plugins/antigravity/src/hooks.ts +51 -0
- package/plugins/antigravity/src/identity.ts +127 -0
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +1129 -549
- package/plugins/claude/hooks/register.ts +2 -2
- package/plugins/claude/playbook.md +3 -3
- package/plugins/claude/skills/dream/SKILL.md +2 -2
- package/plugins/claude/skills/notesoup/SKILL.md +92 -0
- package/plugins/claude/src/helper.ts +2 -1
- package/plugins/codex/.codex-plugin/plugin.json +8 -0
- package/plugins/codex/.mcp.json +11 -0
- package/plugins/codex/README.md +5 -21
- package/plugins/codex/dist/codex/notesoup.js +18494 -17905
- package/plugins/codex/src/hooks.ts +1 -0
- package/plugins/codex/src/identity.ts +14 -1
- package/plugins/codex/src/mcp.ts +28 -98
- package/plugins/codex/src/text.ts +3 -3
- package/plugins/dsh/tools.ts +8 -4
- package/plugins/mcp/operations.ts +50 -0
- package/plugins/mcp/server.ts +23 -0
- package/plugins/paseo/README.md +5 -10
- package/plugins/paseo/client/brain-empty-card.tsx +3 -3
- package/plugins/paseo/client/markdown.tsx +50 -38
- package/plugins/paseo/client/notes-op-card.tsx +12 -9
- package/plugins/paseo/client/paper-card.tsx +6 -5
- package/plugins/paseo/client/paper-palette.ts +2 -9
- package/plugins/paseo/client/sticky-card.tsx +2 -2
- package/plugins/paseo/client/tool-result.ts +7 -14
- package/plugins/paseo/package-lock.json +3406 -0
- package/plugins/paseo/package.json +1 -0
- package/plugins/paseo/test/markdown-core.test.ts +73 -66
- package/plugins/pi/budget.ts +3 -3
- package/plugins/pi/entries.ts +1 -0
- package/plugins/pi/history-tools.ts +2 -1
- package/plugins/pi/history.ts +30 -1
- package/plugins/pi/notes/tools.ts +7 -3
- package/plugins/pi/render.ts +6 -6
- package/plugins/pi/reset/lifecycle.ts +9 -10
- package/plugins/pi/runtime.ts +96 -60
- package/plugins/pi/tool-result.ts +8 -8
- package/plugins/pi/window.ts +198 -9
- package/skills/dream/SKILL.md +2 -2
- package/skills/notesoup/SKILL.md +92 -0
- package/src/boot/render.ts +59 -25
- package/src/boot/text.ts +30 -27
- package/src/budget/text.ts +13 -13
- package/src/history/claude.ts +41 -0
- package/src/history/codex-transcript.ts +6 -4
- package/src/history/codex.ts +2 -0
- package/src/history/corpus.ts +51 -2
- package/src/history/history.ts +35 -44
- package/src/history/local.ts +67 -27
- package/src/history/pi.ts +113 -35
- package/src/history/prefilter.ts +73 -15
- package/src/history/query.ts +93 -73
- package/src/history/summary-cache.ts +142 -17
- package/src/index.ts +1 -1
- package/src/notes/frontmatter.ts +16 -1
- package/src/notes/index.ts +1 -1
- package/src/notes/policy.ts +45 -6
- package/src/notes/store.ts +30 -15
- package/src/text-match.ts +46 -4
- package/src/tools/dream.ts +29 -31
- package/src/tools/history.ts +249 -142
- package/src/tools/notes.ts +150 -112
- package/src/tools/output.ts +2 -1
- package/src/tools/result.ts +12 -11
- package/src/tools/schema.ts +24 -1
- package/plugins/claude/skills/memory/SKILL.md +0 -69
- package/plugins/codex/mcp.json +0 -10
- package/plugins/codex/plugin.json +0 -6
- package/plugins/paseo/client/markdown-core.tsx +0 -189
- package/plugins/paseo/client/typography.ts +0 -24
- package/skills/memory/SKILL.md +0 -69
|
@@ -107,12 +107,31 @@ export function manager(persisted = false) {
|
|
|
107
107
|
const dir = mkdtempSync(join(tmpdir(), "notesoup-session-"));
|
|
108
108
|
return SessionManager.create("/private/tmp/notesoup-test", dir);
|
|
109
109
|
}
|
|
110
|
-
export function makeExtension(sessionManager, settingsManager) {
|
|
111
|
-
const
|
|
110
|
+
export function makeExtension(sessionManager, settingsManager, options = {}) {
|
|
111
|
+
const listeners = new Map();
|
|
112
|
+
const events = {
|
|
113
|
+
on(channel, handler) {
|
|
114
|
+
const handlers = listeners.get(channel) ?? new Set();
|
|
115
|
+
handlers.add(handler);
|
|
116
|
+
listeners.set(channel, handlers);
|
|
117
|
+
return () => { handlers.delete(handler); };
|
|
118
|
+
},
|
|
119
|
+
emit(channel, data) {
|
|
120
|
+
for (const handler of listeners.get(channel) ?? [])
|
|
121
|
+
handler(data);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
const captured = {
|
|
125
|
+
tools: new Map(), handlers: new Map(), commands: new Map(), sent: [],
|
|
126
|
+
contextMessages: [], flags: [], flagValues: new Map(Object.entries(options.flags ?? {})), events,
|
|
127
|
+
};
|
|
112
128
|
const api = {
|
|
113
129
|
registerFlag(name) {
|
|
114
130
|
captured.flags.push(name);
|
|
115
131
|
},
|
|
132
|
+
getFlag(name) {
|
|
133
|
+
return captured.flagValues.get(name);
|
|
134
|
+
},
|
|
116
135
|
registerTool(tool) {
|
|
117
136
|
captured.tools.set(tool.name, tool);
|
|
118
137
|
},
|
|
@@ -127,6 +146,7 @@ export function makeExtension(sessionManager, settingsManager) {
|
|
|
127
146
|
appendEntry(customType, data) {
|
|
128
147
|
sessionManager.appendCustomEntry(customType, data);
|
|
129
148
|
},
|
|
149
|
+
events,
|
|
130
150
|
sendMessage(message, options) {
|
|
131
151
|
captured.sent.push({ message, options });
|
|
132
152
|
sessionManager.appendCustomMessageEntry(message.customType, message.content, message.display, message.details);
|
|
@@ -271,7 +291,25 @@ function isTextWindow(value) {
|
|
|
271
291
|
return typeof candidate.text === "string" && typeof candidate.total_chars === "number" &&
|
|
272
292
|
(candidate.next_offset_chars === null || typeof candidate.next_offset_chars === "number");
|
|
273
293
|
}
|
|
274
|
-
/**
|
|
294
|
+
/** Plain-text operation success, with no structured wire payload. */
|
|
295
|
+
export function resultText(result) {
|
|
296
|
+
assert.ok(!result.isError, "expected a successful result");
|
|
297
|
+
assert.equal(result.structuredContent, undefined, "plain-text result has no structured payload");
|
|
298
|
+
const first = result.content[0];
|
|
299
|
+
assert.ok(first && first.type === "text", "tool result carries text");
|
|
300
|
+
return first.text;
|
|
301
|
+
}
|
|
302
|
+
/** Plain-text operation refusal, preserving its error code and message. */
|
|
303
|
+
export function resultTextError(result) {
|
|
304
|
+
assert.equal(result.isError, true, "expected a refusal");
|
|
305
|
+
assert.equal(result.structuredContent, undefined, "plain-text refusal has no structured payload");
|
|
306
|
+
const first = result.content[0];
|
|
307
|
+
assert.ok(first && first.type === "text", "tool result carries text");
|
|
308
|
+
const match = /^error: ([^:]+): ([\s\S]*)$/.exec(first.text);
|
|
309
|
+
assert.ok(match, "refusal carries a code and message");
|
|
310
|
+
return { code: match[1], message: match[2] };
|
|
311
|
+
}
|
|
312
|
+
/** Data of a successful notes_read outcome, asserting both the structured success and the non-error result. */
|
|
275
313
|
export function resultData(result) {
|
|
276
314
|
const outcome = outcomeOf(result);
|
|
277
315
|
assert.equal("error" in outcome, false, `expected success, got refusal ${JSON.stringify(outcome)}`);
|
|
@@ -334,6 +372,37 @@ export async function runHandlers(captured, name, event, ctx) {
|
|
|
334
372
|
ctx.isIdle = isIdle;
|
|
335
373
|
}
|
|
336
374
|
}
|
|
375
|
+
/** Run every registered input handler in order, as Pi does before appending the prompt. */
|
|
376
|
+
export async function runInput(captured, ctx, event = { type: "input", text: "hello", source: "interactive" }) {
|
|
377
|
+
for (const handler of captured.handlers.get("input") ?? [])
|
|
378
|
+
await handler(event, ctx);
|
|
379
|
+
}
|
|
380
|
+
/** Run before_agent_start with an event shaped like Pi's, returning the handler's result and the mutated event. */
|
|
381
|
+
export async function runBeforeAgentStart(captured, ctx, options = {}) {
|
|
382
|
+
const skills = (options.skills ?? []).map((skill) => ({
|
|
383
|
+
name: skill.name,
|
|
384
|
+
description: `${skill.name} skill`,
|
|
385
|
+
filePath: skill.filePath,
|
|
386
|
+
baseDir: dirname(skill.filePath),
|
|
387
|
+
sourceInfo: {},
|
|
388
|
+
disableModelInvocation: false,
|
|
389
|
+
}));
|
|
390
|
+
const event = {
|
|
391
|
+
type: "before_agent_start",
|
|
392
|
+
messageType: options.messageType ?? "user",
|
|
393
|
+
prompt: "hello",
|
|
394
|
+
...(options.message ? { message: { role: "custom", content: "custom", display: false, timestamp: 0, ...options.message } } : {}),
|
|
395
|
+
systemPrompt: "",
|
|
396
|
+
systemPromptOptions: { sections: {}, skills },
|
|
397
|
+
};
|
|
398
|
+
let result;
|
|
399
|
+
for (const handler of captured.handlers.get("before_agent_start") ?? []) {
|
|
400
|
+
const returned = (await handler(event, ctx));
|
|
401
|
+
if (returned)
|
|
402
|
+
result = returned;
|
|
403
|
+
}
|
|
404
|
+
return { event, result };
|
|
405
|
+
}
|
|
337
406
|
export async function runCommand(captured, name, args, ctx) {
|
|
338
407
|
const command = captured.commands.get(name);
|
|
339
408
|
assert.ok(command, `${name} command registered`);
|
|
@@ -11,7 +11,7 @@ import { parseSessionSelector } from "../src/history/corpus.js";
|
|
|
11
11
|
import { allItems, projectHistory } from "../src/history/history.js";
|
|
12
12
|
import { claudeHistoryFromJsonl, offlineClaudeHead, offlineClaudeHistoryFromJsonl } from "../src/history/claude.js";
|
|
13
13
|
import { piHistoryFromJsonl } from "../src/history/pi.js";
|
|
14
|
-
import { historyList, historyRead } from "../src/tools/history.js";
|
|
14
|
+
import { historyList, historySearch, historyRead } from "../src/tools/history.js";
|
|
15
15
|
import { TOOL_OUTPUT_MAX_BYTES } from "../src/tools/output.js";
|
|
16
16
|
const AT = "2026-10-06T01:02:03.000Z";
|
|
17
17
|
const CODEX = "019a0000-0000-7000-8000-000000000001";
|
|
@@ -60,15 +60,14 @@ async function fixture(t) {
|
|
|
60
60
|
return { home, roots, put, ctx, corpus, piPath, claudePath, codexPath, codexText };
|
|
61
61
|
}
|
|
62
62
|
test("session schemas are optional and non-empty, while the current projection keeps its exact wire shape", async () => {
|
|
63
|
-
for (const operation of [historyList, historyRead]) {
|
|
64
|
-
const params = operation === historyRead ? { seq: 1 } : {};
|
|
63
|
+
for (const operation of [historyList, historySearch, historyRead]) {
|
|
64
|
+
const params = operation === historyRead ? { seq: 1 } : operation === historySearch ? { query: "needle" } : {};
|
|
65
65
|
assert.equal(Check(operation.parameters, params), true);
|
|
66
66
|
assert.equal(Check(operation.parameters, { ...params, session: "" }), false);
|
|
67
67
|
assert.equal(Check(operation.parameters, { ...params, session: "claude:a" }), true);
|
|
68
68
|
}
|
|
69
69
|
const p = projection();
|
|
70
70
|
const page = await historyList.execute({ limit: 1 }, p);
|
|
71
|
-
assert.ok(Check(historyList.outputSchema, page.ok ? page.data : page));
|
|
72
71
|
assert.equal("session" in data(page).items[0], false);
|
|
73
72
|
assert.equal(data(page).has_older, true);
|
|
74
73
|
assert.match(historyList.render(page), /^seq 5 \| user/);
|
|
@@ -112,25 +111,24 @@ test("all single-session recipes preserve the resolved identity, including folde
|
|
|
112
111
|
{ seq: 4, windowId: "w", role: "assistant", text: "last" },
|
|
113
112
|
] }], 4, new Set([1, 2, 3, 4]));
|
|
114
113
|
const ctx = context([descriptor("claude", "target-session", p)]);
|
|
115
|
-
const
|
|
114
|
+
const filters = { roles: ["user", "assistant"], limit: 1, max_chars_per_item: 3 };
|
|
115
|
+
const page = await historyList.execute({ session: "claude:target", before: 5, ...filters }, ctx);
|
|
116
116
|
assert.equal(data(page).has_older, true);
|
|
117
|
-
assert.
|
|
118
|
-
const first = await historyList.execute({ session: "target", after: 0,
|
|
117
|
+
assert.deepEqual(JSON.parse(/→ older: (\{[^}]+\})/.exec(historyList.render(page))[1]), { session: "claude:target-session", ...filters, before: 4 });
|
|
118
|
+
const first = await historyList.execute({ session: "target", after: 0, before: 5, ...filters }, ctx);
|
|
119
119
|
assert.equal(data(first).has_newer, true);
|
|
120
|
-
assert.
|
|
120
|
+
assert.deepEqual(JSON.parse(/→ newer: (\{[^}]+\})/.exec(historyList.render(first))[1]), { session: "claude:target-session", ...filters, 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
126
|
assert.deepEqual(data(await historyList.execute(recipe, ctx)).items.map((item) => item.seq), [2]);
|
|
127
|
-
assert.match(historyList.render(foldPage),
|
|
127
|
+
assert.match(historyList.render(foldPage), /=== session claude:target-session ===\nseq 1 \| user/);
|
|
128
128
|
const read = await historyRead.execute({ session: "target", seq: 3 }, ctx);
|
|
129
129
|
assert.equal(data(read).session, "claude:target-session");
|
|
130
130
|
assert.match(historyRead.render(read), /^session claude:target-session \| seq 3 \| user/);
|
|
131
|
-
assert.match(historyRead.render(read),
|
|
132
|
-
assert.ok(Check(historyRead.outputSchema, data(read)));
|
|
133
|
-
assert.ok(Check(historyList.outputSchema, data(foldPage)));
|
|
131
|
+
assert.match(historyRead.render(read), /→ history_list: .*"session":"claude:target-session"/);
|
|
134
132
|
});
|
|
135
133
|
test("recipes expand a fold at seq 1 and read its neighborhood from the start", async () => {
|
|
136
134
|
const p = projectHistory([{ windowId: "w", items: [
|
|
@@ -139,7 +137,8 @@ test("recipes expand a fold at seq 1 and read its neighborhood from the start",
|
|
|
139
137
|
{ seq: 3, windowId: "w", role: "user", text: "hello" },
|
|
140
138
|
] }], 3, new Set([1, 2, 3]));
|
|
141
139
|
const ctx = context([descriptor("claude", "first-fold", p)]);
|
|
142
|
-
const folded = await historyList.execute({ session: "first-fold" }, ctx);
|
|
140
|
+
const folded = await historyList.execute({ session: "first-fold", before: 3 }, ctx);
|
|
141
|
+
assert.match(historyList.render(folded), /^=== session claude:first-fold ===\nseqs 1-2/);
|
|
143
142
|
const expand = /→ expand: (\{[^\n]+\})/.exec(historyList.render(folded));
|
|
144
143
|
assert.ok(expand);
|
|
145
144
|
const recipe = JSON.parse(expand[1]);
|
|
@@ -147,17 +146,21 @@ test("recipes expand a fold at seq 1 and read its neighborhood from the start",
|
|
|
147
146
|
assert.ok(Check(historyList.parameters, recipe));
|
|
148
147
|
assert.deepEqual(data(await historyList.execute(recipe, ctx)).items.map((item) => item.seq), [1, 2]);
|
|
149
148
|
const read = await historyRead.execute({ session: "first-fold", seq: 3 }, ctx);
|
|
150
|
-
const neighborhood =
|
|
149
|
+
const neighborhood = /→ history_list: (\{[^\n]+\})/.exec(historyRead.render(read));
|
|
151
150
|
assert.ok(neighborhood);
|
|
152
151
|
const nearby = JSON.parse(neighborhood[1]);
|
|
153
152
|
assert.equal(nearby.after, 0);
|
|
154
153
|
assert.ok(Check(historyList.parameters, nearby));
|
|
155
154
|
assert.ok(data(await historyList.execute(nearby, ctx)).items.length > 0);
|
|
156
155
|
});
|
|
157
|
-
test("wildcard refusals precede discovery, and read accepts no wildcard selector", async () => {
|
|
156
|
+
test("bounds and wildcard refusals precede discovery, and read accepts no wildcard selector", async () => {
|
|
158
157
|
const ctx = { current: () => { throw new Error("must not load current"); }, corpus: { currentHarness: "pi", sessions: async () => { throw new Error("must not discover"); } } };
|
|
159
|
-
|
|
158
|
+
refusal(await historyList.execute({ session: "pi:*", after: 1 }, ctx), "invalid_bounds");
|
|
159
|
+
refusal(await historyList.execute({ session: "pi:*", before: 5 }, ctx), "invalid_bounds");
|
|
160
|
+
refusal(await historyList.execute({ session: "pi:*", since: "3" }, ctx), "invalid_bounds");
|
|
160
161
|
refusal(await historyRead.execute({ session: "*", seq: 1 }, ctx), "invalid_session");
|
|
162
|
+
refusal(await historySearch.execute({ session: "*", query: "needle", since: "3" }, ctx), "invalid_bounds");
|
|
163
|
+
assert.deepEqual(data(await historySearch.execute({ session: "*", query: "" }, ctx)), { items: [], has_older: false, has_newer: false });
|
|
161
164
|
});
|
|
162
165
|
test("native filesystem discovery decodes three harnesses, compressed Codex, and keeps source bytes/mtime unchanged", async (t) => {
|
|
163
166
|
const f = await fixture(t);
|
|
@@ -183,30 +186,31 @@ test("native filesystem discovery decodes three harnesses, compressed Codex, and
|
|
|
183
186
|
});
|
|
184
187
|
test("wildcard query merges every role chronologically, limits from either end, and returns no folds/cursors", async (t) => {
|
|
185
188
|
const { ctx } = await fixture(t);
|
|
186
|
-
const result = await
|
|
189
|
+
const result = await historySearch.execute({ session: "*", query: ["", "nEeDlE"], limit: 20 }, ctx);
|
|
187
190
|
const page = data(result);
|
|
188
191
|
assert.deepEqual(page.items.map((item) => "role" in item ? [item.session, item.seq, item.role] : null), [
|
|
189
192
|
["pi:pi-one", 1, "user"], ["claude:claude-one", 1, "user"], ["pi:pi-one", 3, "tool"], ["claude:claude-one", 2, "context"], [`codex:${CODEX}`, 2, "assistant"],
|
|
190
193
|
]);
|
|
191
194
|
assert.equal(page.has_older, false);
|
|
192
195
|
assert.equal(page.has_newer, false);
|
|
193
|
-
const newestResult = await
|
|
196
|
+
const newestResult = await historySearch.execute({ session: "*", query: "needle", limit: 2 }, ctx);
|
|
194
197
|
const newest = data(newestResult);
|
|
195
198
|
assert.deepEqual(newest.items, page.items.slice(-2));
|
|
196
199
|
assert.equal(newest.has_older, true);
|
|
197
200
|
assert.equal(newest.has_newer, false);
|
|
198
|
-
const oldestResult = await
|
|
201
|
+
const oldestResult = await historySearch.execute({ session: "*", query: "needle", limit: 2, since: "2026-10-06" }, ctx);
|
|
199
202
|
const oldest = data(oldestResult);
|
|
200
203
|
assert.deepEqual(oldest.items, page.items.slice(0, 2));
|
|
201
204
|
assert.equal(oldest.has_older, false);
|
|
202
205
|
assert.equal(oldest.has_newer, true);
|
|
203
|
-
const filtered = data(await
|
|
206
|
+
const filtered = data(await historySearch.execute({ session: "*", query: "needle", roles: ["tool", "context"], since: "2026-10-06T01:02:04", until: "2026-10-06T01:02:07Z" }, ctx));
|
|
204
207
|
assert.deepEqual(filtered.items.map((item) => item.role), ["tool"]);
|
|
205
|
-
const harness = data(await
|
|
208
|
+
const harness = data(await historySearch.execute({ session: "claude:*", query: "needle" }, ctx));
|
|
206
209
|
assert.ok(harness.items.every((item) => "session" in item && item.session === "claude:claude-one"));
|
|
207
|
-
assert.equal(data(await
|
|
208
|
-
|
|
209
|
-
assert.
|
|
210
|
+
assert.equal(data(await historySearch.execute({ session: "pi:absent*", query: "needle" }, ctx)).items.length, 0);
|
|
211
|
+
const text = historySearch.render(result);
|
|
212
|
+
assert.deepEqual([...text.matchAll(/^=== session (.+) ===$/gm)].map(match => match[1]), ["pi:pi-one", "claude:claude-one", `codex:${CODEX}`]);
|
|
213
|
+
assert.match(text, /=== session pi:pi-one ===\nseq 1 \| user[\s\S]*?\nseq 3 \| tool[\s\S]*?\n=== session claude:claude-one ===/);
|
|
210
214
|
});
|
|
211
215
|
test("bounded wildcard search scans every session and orders untimed and tied matches", async () => {
|
|
212
216
|
const seen = [];
|
|
@@ -223,23 +227,23 @@ test("bounded wildcard search scans every session and orders untimed and tied ma
|
|
|
223
227
|
}));
|
|
224
228
|
const ctx = context(sessions);
|
|
225
229
|
const ids = (page) => page.items.map((item) => "seq" in item ? [item.session, item.seq] : null);
|
|
226
|
-
assert.deepEqual(ids(data(await
|
|
230
|
+
assert.deepEqual(ids(data(await historySearch.execute({ session: "*", query: "needle", since: "2026-10-06", limit: 3 }, ctx))), [["pi:a", 3], ["pi:a", 4], ["pi:a", 5]]);
|
|
227
231
|
assert.deepEqual(seen, ["z", "a", "m"]);
|
|
228
232
|
seen.length = 0;
|
|
229
|
-
assert.deepEqual(ids(data(await
|
|
233
|
+
assert.deepEqual(ids(data(await historySearch.execute({ session: "*", query: "needle", limit: 3 }, ctx))), [["pi:z", 198], ["pi:z", 199], ["pi:z", 200]]);
|
|
230
234
|
assert.deepEqual(seen, ["z", "a", "m"]);
|
|
231
235
|
});
|
|
232
|
-
test("
|
|
236
|
+
test("wildcard history_list browses recent sessions, keeps canonical IDs, and history_search returns empty for empty queries", async (t) => {
|
|
233
237
|
const { ctx } = await fixture(t);
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
assert.
|
|
238
|
+
const result = await historyList.execute({ session: "*" }, ctx);
|
|
239
|
+
const page = data(result);
|
|
240
|
+
assert.deepEqual(page.items.map((item) => "seq" in item ? [item.session, item.seq, item.role] : null), [
|
|
241
|
+
["pi:pi-one", 1, "user"], ["claude:claude-one", 1, "user"], ["pi:current", 1, "user"], [`codex:${CODEX}`, 2, "assistant"],
|
|
242
|
+
]);
|
|
243
|
+
assert.equal(page.has_older, false);
|
|
244
|
+
assert.equal(page.has_newer, false);
|
|
245
|
+
for (const query of ["", [], ["", ""]]) {
|
|
246
|
+
assert.deepEqual(data(await historySearch.execute({ session: "*", query }, ctx)), { items: [], has_older: false, has_newer: false });
|
|
243
247
|
}
|
|
244
248
|
const harness = data(await historyList.execute({ session: "claude:*" }, ctx));
|
|
245
249
|
assert.deepEqual(harness.items.map((item) => item.session), ["claude:claude-one"]);
|
|
@@ -265,7 +269,7 @@ test("session overviews order discovery by mtime, stop at the session limit, the
|
|
|
265
269
|
assert.deepEqual(loaded, Array.from({ length: 20 }, (_, index) => 24 - index));
|
|
266
270
|
assert.deepEqual(recent.items.map((item) => item.session), loaded.map((index) => `pi:s-${index}`));
|
|
267
271
|
loaded.length = 0;
|
|
268
|
-
const oldest = data(await historyList.execute({ session: "*",
|
|
272
|
+
const oldest = data(await historyList.execute({ session: "*", since: AT, limit: 2 }, ctx));
|
|
269
273
|
assert.equal(oldest.has_older, false);
|
|
270
274
|
assert.equal(oldest.has_newer, true);
|
|
271
275
|
assert.deepEqual(loaded, [0, 1]);
|
|
@@ -295,11 +299,11 @@ test("session representatives respect visibility, role/time filters, opening use
|
|
|
295
299
|
assert.deepEqual(await chosen({ roles: ["context", "tool"] }), [8]);
|
|
296
300
|
assert.deepEqual(await chosen({ roles: ["tool"] }), [6]);
|
|
297
301
|
assert.deepEqual(await chosen({ roles: [] }), []);
|
|
298
|
-
assert.deepEqual(await chosen({
|
|
299
|
-
assert.deepEqual(await chosen({
|
|
300
|
-
assert.deepEqual(await chosen({
|
|
301
|
-
assert.deepEqual(await chosen({
|
|
302
|
-
assert.deepEqual(await chosen({
|
|
302
|
+
assert.deepEqual(await chosen({ since: at(1), until: at(3) }), [4]);
|
|
303
|
+
assert.deepEqual(await chosen({ since: at(2) }), [5]);
|
|
304
|
+
assert.deepEqual(await chosen({ until: at(1) }), [1]);
|
|
305
|
+
assert.deepEqual(await chosen({ since: at(4) }), [8]);
|
|
306
|
+
assert.deepEqual(await chosen({ since: at(4), roles: ["user"] }), []);
|
|
303
307
|
const noUsers = { ...p, windows: p.windows.map((window) => ({ ...window, items: window.items.filter((item) => item.role !== "user") })) };
|
|
304
308
|
const fallback = data(await historyList.execute({ session: "*" }, context([descriptor("pi", "assistant-topic", noUsers)])));
|
|
305
309
|
assert.deepEqual(fallback.items.map((item) => "seq" in item ? item.seq : null), [4]);
|
|
@@ -325,7 +329,7 @@ test("wildcard queries reach lazy loaders and pre-filtered misses are not errors
|
|
|
325
329
|
{ ...descriptor("pi", "broken"), async load(queries) { seen.push(queries); throw new Error("unsupported"); } },
|
|
326
330
|
{ ...descriptor("claude", "hit"), async load(queries) { seen.push(queries); return { projection: projection("other") }; } },
|
|
327
331
|
]);
|
|
328
|
-
const page = data(await
|
|
332
|
+
const page = data(await historySearch.execute({ session: "*", query: ["", "needle", "other"] }, ctx));
|
|
329
333
|
assert.equal(page.items.length, 5);
|
|
330
334
|
assert.ok(page.items.every((item) => item.session === "claude:hit"));
|
|
331
335
|
assert.deepEqual(seen, [["needle", "other"], ["needle", "other"], ["needle", "other"]]);
|
|
@@ -334,7 +338,9 @@ test("wildcard queries reach lazy loaders and pre-filtered misses are not errors
|
|
|
334
338
|
});
|
|
335
339
|
test("query offsets and text continuation retain cross-session identity and Unicode coordinates", async (t) => {
|
|
336
340
|
const { ctx } = await fixture(t);
|
|
337
|
-
const
|
|
341
|
+
const result = await historySearch.execute({ session: "pi:pi-one", query: "NEEDLE", roles: ["user"], max_chars_per_item: 3 }, ctx);
|
|
342
|
+
assert.match(historySearch.render(result), /^=== session pi:pi-one ===\nseq 1 \| user \| [^|\n]+ \| offset_chars 5\nNEE \[truncated\]/);
|
|
343
|
+
const page = data(result);
|
|
338
344
|
const hit = page.items[0];
|
|
339
345
|
assert.ok("seq" in hit);
|
|
340
346
|
assert.equal(hit.offset_chars, 5);
|
|
@@ -348,7 +354,7 @@ test("query offsets and text continuation retain cross-session identity and Unic
|
|
|
348
354
|
});
|
|
349
355
|
test("wildcard glob metacharacters other than * stay literal, with deterministic timestamp ties", async () => {
|
|
350
356
|
const ctx = context([descriptor("pi", "a.b"), descriptor("pi", "axb"), descriptor("claude", "a.b")]);
|
|
351
|
-
const page = data(await
|
|
357
|
+
const page = data(await historySearch.execute({ session: "a.*", query: "needle", limit: 500 }, ctx));
|
|
352
358
|
assert.ok(page.items.every((item) => "session" in item && ["pi:a.b", "claude:a.b"].includes(item.session)));
|
|
353
359
|
assert.deepEqual(page.items.slice(0, 2).map((item) => "session" in item ? item.session : ""), ["claude:a.b", "pi:a.b"]);
|
|
354
360
|
});
|
|
@@ -358,7 +364,7 @@ test("root overrides/env homes are hermetic, missing roots are empty, and foreig
|
|
|
358
364
|
const current = { harness: "dsh", id: "unreadable", load: async () => { throw new Error("current unavailable"); } };
|
|
359
365
|
const ctx = { current: () => { throw new Error("must not read current"); }, corpus: localHistoryCorpus({ roots, env: {}, summaryCacheRoot: join(f.home, "history-cache"), home: join(f.home, "absent"), current }) };
|
|
360
366
|
assert.equal(data(await historyRead.execute({ session: "pi:pi-one", seq: 1 }, ctx)).session, "pi:pi-one");
|
|
361
|
-
assert.equal(data(await
|
|
367
|
+
assert.equal(data(await historySearch.execute({ session: "pi:*", query: "needle" }, ctx)).items.length, 2);
|
|
362
368
|
const env = { PI_CODING_AGENT_DIR: dirname(f.roots.pi), CLAUDE_CONFIG_DIR: dirname(f.roots.claude), CODEX_HOME: dirname(f.roots.codex) };
|
|
363
369
|
const configured = localHistoryCorpus({ current, summaryCacheRoot: join(f.home, "history-cache"), home: join(f.home, "absent"), env });
|
|
364
370
|
assert.equal((await configured.sessions()).length, 4);
|
|
@@ -372,18 +378,17 @@ test("DSH service descriptors participate in resolution/search only when supplie
|
|
|
372
378
|
const ctx = { current: () => projection(), corpus };
|
|
373
379
|
assert.equal(data(await historyRead.execute({ session: "dsh:dsh", seq: 1 }, ctx)).session, "dsh:dsh-one");
|
|
374
380
|
assert.equal(data(await historyRead.execute({ session: "pi-one", seq: 1 }, ctx)).text, "live needle 1");
|
|
375
|
-
const page = data(await
|
|
381
|
+
const page = data(await historySearch.execute({ session: "dsh:*", query: "needle" }, ctx));
|
|
376
382
|
assert.equal(page.items.length, 5);
|
|
377
383
|
assert.ok(page.items.every((item) => "role" in item && item.role === "context"));
|
|
378
384
|
assert.equal((await corpus.sessions()).filter((session) => session.harness === "pi" && session.id === "pi-one").length, 1);
|
|
379
385
|
});
|
|
380
|
-
test("oversized cross-session reads/searches obey
|
|
386
|
+
test("oversized cross-session reads/searches obey the rendered text budget and retain canonical identities", async () => {
|
|
381
387
|
const p = projection("😀".repeat(40_000));
|
|
382
388
|
const ctx = context([descriptor("codex", "long-id", p)]);
|
|
383
|
-
const list = await
|
|
389
|
+
const list = await historySearch.execute({ session: "*", query: "😀", max_chars_per_item: 50_000, limit: 500 }, ctx);
|
|
384
390
|
const page = data(list);
|
|
385
|
-
assert.ok(Buffer.byteLength(
|
|
386
|
-
assert.ok(Buffer.byteLength(historyList.render(list)) <= TOOL_OUTPUT_MAX_BYTES);
|
|
391
|
+
assert.ok(Buffer.byteLength(historySearch.render(list)) <= TOOL_OUTPUT_MAX_BYTES);
|
|
387
392
|
assert.equal(page.items.length, 1);
|
|
388
393
|
assert.equal(page.has_older, true);
|
|
389
394
|
assert.equal(page.has_newer, false);
|
|
@@ -391,12 +396,10 @@ test("oversized cross-session reads/searches obey both wire budgets and retain c
|
|
|
391
396
|
assert.ok("seq" in item && item.truncated);
|
|
392
397
|
assert.equal(item.session, "codex:long-id");
|
|
393
398
|
const read = await historyRead.execute({ session: item.session, seq: item.seq, max_chars: 50_000 }, ctx);
|
|
394
|
-
assert.ok(Buffer.byteLength(JSON.stringify(data(read))) <= TOOL_OUTPUT_MAX_BYTES);
|
|
395
399
|
assert.ok(Buffer.byteLength(historyRead.render(read)) <= TOOL_OUTPUT_MAX_BYTES);
|
|
396
400
|
assert.equal(data(read).session, "codex:long-id");
|
|
397
401
|
assert.ok(data(read).next_offset_chars > 0);
|
|
398
402
|
const overview = await historyList.execute({ session: "*", max_chars_per_item: 50_000 }, ctx);
|
|
399
|
-
assert.ok(Buffer.byteLength(JSON.stringify(data(overview))) <= TOOL_OUTPUT_MAX_BYTES);
|
|
400
403
|
assert.ok(Buffer.byteLength(historyList.render(overview)) <= TOOL_OUTPUT_MAX_BYTES);
|
|
401
404
|
assert.equal(data(overview).items.length, 1);
|
|
402
405
|
assert.equal(data(overview).has_older, false);
|
|
@@ -404,12 +407,12 @@ test("oversized cross-session reads/searches obey both wire budgets and retain c
|
|
|
404
407
|
});
|
|
405
408
|
test("wildcard byte budgets report retained candidates beyond either end", async () => {
|
|
406
409
|
const ctx = context([descriptor("pi", "large", projection("needle " + "x".repeat(20_000)))]);
|
|
407
|
-
for (const
|
|
408
|
-
const result = await
|
|
410
|
+
for (const since of [undefined, AT]) {
|
|
411
|
+
const result = await historySearch.execute({ session: "*", query: "needle", since, limit: 5, max_chars_per_item: 50_000 }, ctx);
|
|
409
412
|
const page = data(result);
|
|
410
413
|
assert.ok(page.items.length < 5);
|
|
411
|
-
assert.equal(page.has_older,
|
|
412
|
-
assert.equal(page.has_newer,
|
|
414
|
+
assert.equal(page.has_older, since === undefined);
|
|
415
|
+
assert.equal(page.has_newer, since !== undefined);
|
|
413
416
|
}
|
|
414
417
|
});
|
|
415
418
|
test("qualified lookup and current-harness matches do not inspect unrelated roots", async (t) => {
|
|
@@ -420,19 +423,19 @@ test("qualified lookup and current-harness matches do not inspect unrelated root
|
|
|
420
423
|
const ctx = { current: () => projection(), corpus: localHistoryCorpus({ current, summaryCacheRoot: join(f.home, "history-cache"), roots: { pi: f.roots.pi, claude: notDirectory, codex: null }, env: {} }) };
|
|
421
424
|
assert.equal(data(await historyRead.execute({ session: "pi-one", seq: 1 }, ctx)).session, "pi:pi-one");
|
|
422
425
|
assert.equal(data(await historyRead.execute({ session: "pi:pi-one", seq: 1 }, ctx)).session, "pi:pi-one");
|
|
423
|
-
assert.equal(data(await
|
|
426
|
+
assert.equal(data(await historySearch.execute({ session: "pi:*", query: "needle" }, ctx)).items.length, 7);
|
|
424
427
|
});
|
|
425
428
|
test("cross-session Claude gaps are visible even on an empty page, budgeted, and outside document offsets", async (t) => {
|
|
426
429
|
const f = await fixture(t);
|
|
427
430
|
await f.put(f.claudePath, rows([{ type: "assistant", uuid: "head", parentUuid: "missing", sessionId: "claude-one", timestamp: AT, message: { role: "assistant", content: "😀needle" + "x".repeat(50_000) } }]));
|
|
428
|
-
const empty = await
|
|
431
|
+
const empty = await historySearch.execute({ session: "claude:claude-one", query: "absent" }, f.ctx);
|
|
429
432
|
assert.equal(data(empty).items.length, 0);
|
|
430
433
|
assert.match(data(empty).notice, /missing ancestor.*"missing"/);
|
|
431
|
-
const emptyText =
|
|
434
|
+
const emptyText = historySearch.render(empty);
|
|
435
|
+
assert.match(emptyText, /=== session claude:claude-one ===\nNo events match/);
|
|
432
436
|
assert.ok(emptyText.includes(data(empty).notice), "the gap notice survives an empty page");
|
|
433
|
-
const list = await
|
|
434
|
-
assert.ok(Buffer.byteLength(
|
|
435
|
-
assert.ok(Buffer.byteLength(historyList.render(list)) <= TOOL_OUTPUT_MAX_BYTES);
|
|
437
|
+
const list = await historySearch.execute({ session: "claude:*", query: "needle", max_chars_per_item: 50_000 }, f.ctx);
|
|
438
|
+
assert.ok(Buffer.byteLength(historySearch.render(list)) <= TOOL_OUTPUT_MAX_BYTES);
|
|
436
439
|
const hit = data(list).items[0];
|
|
437
440
|
assert.ok("seq" in hit);
|
|
438
441
|
assert.equal(hit.offset_chars, 1);
|
|
@@ -440,7 +443,6 @@ test("cross-session Claude gaps are visible even on an empty page, budgeted, and
|
|
|
440
443
|
assert.match(data(read).notice, /history is incomplete/);
|
|
441
444
|
assert.ok(data(read).text.startsWith("needle"));
|
|
442
445
|
assert.ok(!data(read).text.includes("missing ancestor"));
|
|
443
|
-
assert.ok(Buffer.byteLength(JSON.stringify(data(read))) <= TOOL_OUTPUT_MAX_BYTES);
|
|
444
446
|
assert.ok(Buffer.byteLength(historyRead.render(read)) <= TOOL_OUTPUT_MAX_BYTES);
|
|
445
447
|
});
|
|
446
448
|
test("wildcards skip corrupt and unreadable sessions, while single-session lists and reads still refuse", async (t) => {
|
|
@@ -449,13 +451,13 @@ test("wildcards skip corrupt and unreadable sessions, while single-session lists
|
|
|
449
451
|
const sessions = await f.corpus.sessions();
|
|
450
452
|
await rm(f.claudePath);
|
|
451
453
|
const ctx = { current: () => projection(), corpus: { currentHarness: "pi", sessions: async () => sessions } };
|
|
452
|
-
for (const
|
|
453
|
-
const page = data(
|
|
454
|
+
for (const result of [await historyList.execute({ session: "*" }, ctx), await historySearch.execute({ session: "*", query: "needle" }, ctx)]) {
|
|
455
|
+
const page = data(result);
|
|
454
456
|
assert.ok(page.items.length > 0);
|
|
455
457
|
assert.ok(page.items.every((item) => item.session !== "pi:broken" && item.session !== "claude:claude-one"));
|
|
456
458
|
}
|
|
457
459
|
for (const session of ["pi:broken", "claude:claude-one"]) {
|
|
458
|
-
assert.ok(refusal(await
|
|
460
|
+
assert.ok(refusal(await historySearch.execute({ session, query: "absent" }, ctx), "history_unavailable").includes(session));
|
|
459
461
|
refusal(await historyRead.execute({ session, seq: 1 }, ctx), "history_unavailable");
|
|
460
462
|
}
|
|
461
463
|
});
|
|
@@ -551,10 +553,10 @@ test("streaming filtering never loses escaped JSON, Unicode or OR-query matches"
|
|
|
551
553
|
const codexText = escapeText(f.codexText.replace("Codex needle", JSON.stringify(content).slice(1, -1)));
|
|
552
554
|
await f.put(f.codexPath, zstdCompressSync(Buffer.from(codexText)));
|
|
553
555
|
for (const query of ["needle", "你好", "😀", 'quote"slash\\', "line\nbreak", "İ", "longs", "caseς", ["absentword", "needle"]]) {
|
|
554
|
-
const page = data(await
|
|
556
|
+
const page = data(await historySearch.execute({ session: "*", query }, f.ctx));
|
|
555
557
|
assert.deepEqual(page.items.map((item) => item.session), ["claude:claude-one", "pi:pi-one", `codex:${CODEX}`], JSON.stringify(query));
|
|
556
558
|
}
|
|
557
|
-
assert.deepEqual(data(await
|
|
559
|
+
assert.deepEqual(data(await historySearch.execute({ session: "*", query: "absentword" }, f.ctx)).items, []);
|
|
558
560
|
});
|
|
559
561
|
test("streaming filtering preserves generated tool documents, compact arguments and nested JSON escapes", async (t) => {
|
|
560
562
|
const f = await fixture(t);
|
|
@@ -563,19 +565,19 @@ test("streaming filtering preserves generated tool documents, compact arguments
|
|
|
563
565
|
{ type: "message", id: "t", parentId: null, timestamp: AT, message: { role: "toolResult", content: [{ type: "text", text: "done" }] } },
|
|
564
566
|
]));
|
|
565
567
|
for (const query of ["unknown", "arguments", "output"]) {
|
|
566
|
-
const page = data(await
|
|
568
|
+
const page = data(await historySearch.execute({ session: "pi:pi-*", query }, f.ctx));
|
|
567
569
|
assert.equal(page.items.length, 1, query);
|
|
568
570
|
}
|
|
569
571
|
await f.put(f.piPath, rows([
|
|
570
572
|
{ type: "session", id: "pi-one" },
|
|
571
573
|
{ type: "message", id: "t", parentId: null, timestamp: AT, message: { role: "assistant", content: [{ type: "toolCall", id: "c", name: "read", arguments: { value: "\ud800" } }] } },
|
|
572
574
|
]));
|
|
573
|
-
assert.equal(data(await
|
|
575
|
+
assert.equal(data(await historySearch.execute({ session: "pi:pi-*", query: "ud" }, f.ctx)).items.length, 1);
|
|
574
576
|
const codexRows = f.codexText.split("\n").filter(Boolean).map((line) => JSON.parse(line));
|
|
575
577
|
codexRows[1].payload = { type: "function_call", call_id: "t", name: "read", arguments: '{ "path" : "\\u006eeedle" }' };
|
|
576
578
|
await f.put(f.codexPath, zstdCompressSync(Buffer.from(rows(codexRows))));
|
|
577
579
|
for (const query of ["needle", '"path":"needle"']) {
|
|
578
|
-
const page = data(await
|
|
580
|
+
const page = data(await historySearch.execute({ session: "codex:*", query }, f.ctx));
|
|
579
581
|
assert.equal(page.items.length, 1, query);
|
|
580
582
|
}
|
|
581
583
|
});
|
|
@@ -593,7 +595,7 @@ test("Codex streaming prefilter preserves query hits inherited through a split h
|
|
|
593
595
|
]);
|
|
594
596
|
// Put the inheritance sentinel across the filesystem stream's 64KiB boundary.
|
|
595
597
|
await f.put(join(dirname(f.codexPath), `rollout-2026-10-06T01-02-03-${child}.jsonl`), " ".repeat(65535 - childText.indexOf('"history_base"')) + childText);
|
|
596
|
-
const page = data(await
|
|
598
|
+
const page = data(await historySearch.execute({ session: `codex:${child}*`, query: "ancestralneedle" }, f.ctx));
|
|
597
599
|
assert.deepEqual(page.items.map((item) => "seq" in item ? [item.session, item.seq] : null), [[`codex:${child}`, 2]]);
|
|
598
600
|
});
|
|
599
601
|
test("streaming search agrees with strict decoding across chunk and event-time boundaries", async (t) => {
|
|
@@ -621,7 +623,7 @@ test("streaming search agrees with strict decoding across chunk and event-time b
|
|
|
621
623
|
for (const query of ["needle", "longs", "caseς", "k", "𐐨", "你好", "😀", "absentword", ["absentword", "needle"]]) {
|
|
622
624
|
for (const bounds of [{}, { since: AT, until: "2026-10-06T01:02:08Z" }, { since: "2026-10-06T01:02:08Z" }, { until: AT }]) {
|
|
623
625
|
const args = { session: "*", query, limit: 20, ...bounds };
|
|
624
|
-
assert.deepEqual(await
|
|
626
|
+
assert.deepEqual(await historySearch.execute(args, f.ctx), await historySearch.execute(args, strict), JSON.stringify({ compressed, ...args }));
|
|
625
627
|
}
|
|
626
628
|
}
|
|
627
629
|
}
|
|
@@ -629,8 +631,8 @@ test("streaming search agrees with strict decoding across chunk and event-time b
|
|
|
629
631
|
test("stream failures skip wildcard sessions but explicit selections still refuse", async (t) => {
|
|
630
632
|
const f = await fixture(t);
|
|
631
633
|
await f.put(f.codexPath, "not-zstd");
|
|
632
|
-
assert.deepEqual(data(await
|
|
633
|
-
refusal(await
|
|
634
|
+
assert.deepEqual(data(await historySearch.execute({ session: "codex:*", query: "absentword" }, f.ctx)).items, []);
|
|
635
|
+
refusal(await historySearch.execute({ session: `codex:${CODEX}`, query: "absentword" }, f.ctx), "history_unavailable");
|
|
634
636
|
});
|
|
635
637
|
test("offline Claude attachments and retry branches are readable and searchable through session selectors", async (t) => {
|
|
636
638
|
const f = await fixture(t);
|
|
@@ -643,7 +645,7 @@ test("offline Claude attachments and retry branches are readable and searchable
|
|
|
643
645
|
assert.equal(data(await historyRead.execute({ session: "claude:claude-one", seq: 3 }, f.ctx)).text, "rightneedle");
|
|
644
646
|
refusal(await historyRead.execute({ session: "claude:claude-one", seq: 2 }, f.ctx), "not_on_branch");
|
|
645
647
|
for (const session of ["claude:claude-one", "claude:*"]) {
|
|
646
|
-
const page = data(await
|
|
648
|
+
const page = data(await historySearch.execute({ session, query: "needle" }, f.ctx));
|
|
647
649
|
assert.deepEqual(page.items.map((item) => "seq" in item ? item.seq : null), [3]);
|
|
648
650
|
}
|
|
649
651
|
assert.deepEqual(data(await historyList.execute({ session: "claude:*" }, f.ctx)).items.map((item) => "seq" in item ? item.seq : null), [1]);
|