notesoup 0.52.1 → 0.52.2
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/dist/plugins/claude/src/history.js +6 -5
- package/dist/src/history/query.js +2 -1
- package/dist/src/tools/history.js +1 -1
- package/dist/test/claude-history.test.js +31 -0
- package/dist/test/claude-mod.test.js +21 -0
- package/docs/claude-code-mod.md +2 -2
- package/package.json +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +6 -7
- package/plugins/claude/hooks/register.ts +19 -14
- package/plugins/claude/src/history.ts +6 -5
- package/src/history/query.ts +2 -1
- package/src/tools/history.ts +1 -1
|
@@ -113,15 +113,16 @@ const BOOT_IDENTITY = /^<(?:notesoup:window_identity|context_window)>\nAgent nam
|
|
|
113
113
|
const BOOT_PROTOCOL_OPEN = /\n<(?:notesoup:notes_protocol|context_window_protocol)>\n/;
|
|
114
114
|
const BOOT_PROTOCOL_CLOSE = /\n<\/(?:notesoup:notes_protocol|context_window_protocol)>/;
|
|
115
115
|
/** Match the complete retained notesoup boot, not a casually quoted window-id line. */
|
|
116
|
-
function bootOrdinal(row,
|
|
116
|
+
function bootOrdinal(row, retained) {
|
|
117
117
|
if (!retained || row.type !== "user" || !object(row.message))
|
|
118
118
|
return undefined;
|
|
119
119
|
const text = contentText(row.message.content);
|
|
120
120
|
if (!BOOT_IDENTITY.test(text) || !BOOT_PROTOCOL_OPEN.test(text) || !BOOT_PROTOCOL_CLOSE.test(text))
|
|
121
121
|
return undefined;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
// A fork copies the retained boot verbatim. Its ordinal survives, while
|
|
123
|
+
// public window ids below always belong to the current transcript session.
|
|
124
|
+
const suffix = /^Current context window id: claude:[^\n]+:(\d+)$/m.exec(text)?.[1];
|
|
125
|
+
if (suffix === undefined)
|
|
125
126
|
return undefined;
|
|
126
127
|
const ordinal = Number(suffix);
|
|
127
128
|
return Number.isSafeInteger(ordinal) ? ordinal : undefined;
|
|
@@ -180,7 +181,7 @@ export function claudeHistoryFromJsonl(text, source) {
|
|
|
180
181
|
let before = cursor.ordinal ?? 0;
|
|
181
182
|
for (const current of chain.reverse()) {
|
|
182
183
|
const retained = current.row.isCompactSummary === true || (current.ancestor !== undefined && boundary(current.ancestor.row));
|
|
183
|
-
const marked = bootOrdinal(current.row,
|
|
184
|
+
const marked = bootOrdinal(current.row, retained);
|
|
184
185
|
current.ordinal = marked === undefined ? before + (boundary(current.row) ? 1 : 0) : Math.max(before, marked);
|
|
185
186
|
before = current.ordinal;
|
|
186
187
|
}
|
|
@@ -85,7 +85,8 @@ function prepareSelection(projection, params) {
|
|
|
85
85
|
run.push(event);
|
|
86
86
|
continue;
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
// Tool/thinking-only envelopes are not dialogue, even with explicit roles.
|
|
89
|
+
if ((event.role === "user" || event.role === "assistant") && eventDocument(event) === "")
|
|
89
90
|
continue;
|
|
90
91
|
const matchOffset = params.query === undefined ? undefined : earliestMatchOffsetChars(eventDocument(event), params.query);
|
|
91
92
|
if (matchOffset !== undefined && matchOffset < 0)
|
|
@@ -68,7 +68,7 @@ function renderRead(data) {
|
|
|
68
68
|
const tool = toolHeader(data);
|
|
69
69
|
const afterSeq = data.seq - 10;
|
|
70
70
|
const neighborhood = `neighborhood → \`history_list\`(${JSON.stringify({ ...(afterSeq >= 1 ? { after_seq: afterSeq } : {}), before_seq: data.seq + 10 })})`;
|
|
71
|
-
return [header(data), ...(tool ? [tool] : []), neighborhood, "", renderTextWindow(data)].join("\n");
|
|
71
|
+
return [header(data), ...(tool ? [tool] : []), neighborhood, "", data.total_chars === 0 ? "No visible text recorded for this event." : renderTextWindow(data)].join("\n");
|
|
72
72
|
}
|
|
73
73
|
/* ------------------------------------------------------------------ shared bounding */
|
|
74
74
|
/** Include rendering and cursors in the budget, not just row contents. */
|
|
@@ -52,6 +52,30 @@ test("Claude append and result arrival preserve call addresses and use the share
|
|
|
52
52
|
assert.ok(search.ok);
|
|
53
53
|
assert.deepEqual(search.data.items.map((item) => "seq" in item ? item.seq : -1), [3]);
|
|
54
54
|
});
|
|
55
|
+
test("Claude dialogue paging skips tool/thinking envelopes without losing array text or changing addresses", async () => {
|
|
56
|
+
const rows = [row("u", null, "user", [{ type: "text", text: "human question" }]),
|
|
57
|
+
assistant("reply", "u", [{ type: "text", text: "assistant answer" }]),
|
|
58
|
+
assistant("thinking", "reply", [{ type: "thinking", thinking: "private thought" }]),
|
|
59
|
+
assistant("call", "thinking", [call("one")]), row("result", "call", "user", [result("one", "tool output")]),
|
|
60
|
+
row("last", "result", "user", [{ type: "text", text: "human followup" }]),
|
|
61
|
+
compact("boundary", "last"), row("boot", "boundary", "user", bootText(1))];
|
|
62
|
+
const projection = project(rows, "boot");
|
|
63
|
+
assert.equal(projection.highestSeq, 10);
|
|
64
|
+
const listed = await historyList.execute({ window_id: "@previous", roles: ["user", "assistant"], limit: 3 }, projection);
|
|
65
|
+
assert.ok(listed.ok);
|
|
66
|
+
assert.deepEqual(listed.data.items.map((item) => "seq" in item ? [item.seq, item.content] : []), [[1, "human question"], [2, "assistant answer"], [8, "human followup"]]);
|
|
67
|
+
const read = await historyRead.execute({ seq: 2 }, projection);
|
|
68
|
+
assert.ok(read.ok);
|
|
69
|
+
assert.equal(read.data.text, "assistant answer");
|
|
70
|
+
const envelope = await historyRead.execute({ seq: 6 }, projection);
|
|
71
|
+
assert.ok(envelope.ok);
|
|
72
|
+
assert.equal(envelope.data.text, "", "a tool-result envelope has no dialogue text to invent");
|
|
73
|
+
assert.match(historyRead.render(envelope), /No visible text recorded/);
|
|
74
|
+
const tool = await historyRead.execute({ seq: 5 }, projection);
|
|
75
|
+
assert.ok(tool.ok);
|
|
76
|
+
assert.match(tool.data.text, /tool output/);
|
|
77
|
+
assert.doesNotMatch(historyList.render(listed), /private thought|tool output/);
|
|
78
|
+
});
|
|
55
79
|
test("Claude file-history deltas do not become events or change history addresses", () => {
|
|
56
80
|
const rows = [user("u", null, "hello"), assistant("a", "u", [{ type: "text", text: "reply" }])];
|
|
57
81
|
const delta = { type: "file-history-delta", messageId: "u", snapshotMessageId: "u", trackingPath: "private-file.txt",
|
|
@@ -107,6 +131,13 @@ test("a persisted boot yields its ordinal under both tag spellings", () => {
|
|
|
107
131
|
const partial = `<notesoup:window_identity>\nAgent name: claude (brain: claude)\n\nclaude:${sessionId}\n</notesoup:window_identity>\nCurrent context window id: claude:${sessionId}:3`;
|
|
108
132
|
assert.equal(allItems(project(rowsFor(partial), "after")).find((event) => event.text === "after reset")?.windowId, `claude:${sessionId}:1`, "an identity line without the protocol block is not a trusted boot");
|
|
109
133
|
});
|
|
134
|
+
test("Claude forked transcripts retain copied boot ordinals but use the new session's window ids", () => {
|
|
135
|
+
const rows = [user("u", null, "old request"), compact("boundary", "u"), row("boot", "boundary", "user", bootText(3)), user("after", "boot", "after fork")];
|
|
136
|
+
const forkId = "forked-session";
|
|
137
|
+
const projection = claudeHistoryFromJsonl(jsonl(rows.map((row) => ({ ...row, sessionId: forkId }))), { sessionId: forkId, headUuid: "after" });
|
|
138
|
+
assert.equal(allItems(projection).find((event) => event.text === "after fork")?.windowId, `claude:${forkId}:3`);
|
|
139
|
+
assert.ok(projection.windows.every((window) => window.windowId.startsWith(`claude:${forkId}:`)));
|
|
140
|
+
});
|
|
110
141
|
test("Claude native compaction and reset keep pre-reset history, preserved rewrites and matching boot windows", async () => {
|
|
111
142
|
const old = assistant("old", "u", [{ type: "text", text: "before first reset" }]);
|
|
112
143
|
const reset = row("boot", "boundary", "user", bootText(1));
|
|
@@ -307,6 +307,27 @@ test("Claude Mod appends boot once and reuses persisted blocks after re-registra
|
|
|
307
307
|
assert.equal(nextCalls, 2, "the upstream chain still runs exactly once per prompt");
|
|
308
308
|
assert.deepEqual(notifications, [], "successful boot never notifies");
|
|
309
309
|
});
|
|
310
|
+
test("Claude fork replaces a copied boot with the current identity without resetting the window ordinal", async (t) => {
|
|
311
|
+
const home = mkdtempSync(join(tmpdir(), "claude-fork-boot-"));
|
|
312
|
+
t.after(() => rmSync(home, { recursive: true, force: true }));
|
|
313
|
+
const { host } = fakeEngine(home);
|
|
314
|
+
const copied = "<notesoup:window_identity>\nAgent name: claude (brain: claude)\n\nclaude:parent-session\n</notesoup:window_identity>\n\n<notesoup:notes_protocol>\nParent protocol\n</notesoup:notes_protocol>\nCurrent context window id: claude:parent-session:3";
|
|
315
|
+
host.session.messages = async () => [{ role: "user", text: copied }];
|
|
316
|
+
const handlers = new Map();
|
|
317
|
+
(await loadHookModule(t)).register((event, handler) => handlers.set(event, handler));
|
|
318
|
+
const invoke = (name, event = {}, result = {}) => handlers.get(name)(host, event, async () => result);
|
|
319
|
+
await invoke("session.start", { cwd: home, isInteractive: true });
|
|
320
|
+
const upstream = { blocks: [{ name: "other", text: "keep me" }, { name: "notesoup:boot", text: copied }], sentinel: "kept" };
|
|
321
|
+
const current = await invoke("prompt.context", {}, upstream);
|
|
322
|
+
assert.equal(current.sentinel, "kept");
|
|
323
|
+
assert.deepEqual(current.blocks[0], upstream.blocks[0]);
|
|
324
|
+
assert.equal(current.blocks.length, 2, "replace the copied context block rather than adding another");
|
|
325
|
+
assert.match(current.blocks[1].text, /Current context window id: claude:hook-session:3/);
|
|
326
|
+
assert.doesNotMatch(current.blocks[1].text, /claude:parent-session/);
|
|
327
|
+
assert.deepEqual(await invoke("prompt.context", {}, current), current, "reuse the now-current block on reload");
|
|
328
|
+
const compacted = await invoke("session.compact", { trigger: "auto", messages: [] });
|
|
329
|
+
assert.match(compacted.messages[0].text, /Current context window id: claude:hook-session:4/);
|
|
330
|
+
});
|
|
310
331
|
test("Claude Mod with NOTESOUP_DISABLED registers nothing and passes every event through", async (t) => {
|
|
311
332
|
const home = mkdtempSync(join(tmpdir(), "claude-hook-disabled-"));
|
|
312
333
|
t.after(() => rmSync(home, { recursive: true, force: true }));
|
package/docs/claude-code-mod.md
CHANGED
|
@@ -22,9 +22,9 @@ The notes tools also serve subagent calls, using the same session identity and s
|
|
|
22
22
|
|
|
23
23
|
The active head comes from the main loop's successful `session.append` result UUID, including attachments and notices. On startup/resume, before such an append, the public API supplies no authoritative selected leaf: history explicitly refuses instead of assuming the last file row or `last-prompt.leafUuid` is current. The append result means the engine kept a row, but its disk write may lag; a head missing on disk is a retryable refusal, not permission to switch branches. Session end clears the binding; a new classic start rebinds it.
|
|
24
24
|
|
|
25
|
-
Seqs are allocated over first-occurrence persisted append order, before active-branch filtering: one address per logical message/attachment/notice and additional addresses for each tool use/result. Repeated UUID records do not allocate again. Results pair by `tool_use_id`; pending calls remain unfinished, and a paired result's seq redirects to its call. Only text blocks and recorded attachment renderings become visible text; thinking and raw, unrendered attachment payloads are never exposed. Record types other than user, assistant, system and attachment are ignored, including future metadata, without allocating addresses or exposing payloads. If the selected branch requires a skipped record as an ancestor, history refuses with the missing ancestor UUID. Invalid supported message/block schemas and malformed committed JSONL lines still refuse explicitly. An incomplete final unterminated write is tolerated. Valid forward parent references are resolved after reading the snapshot, without reallocating addresses.
|
|
25
|
+
Seqs are allocated over first-occurrence persisted append order, before active-branch filtering: one address per logical message/attachment/notice and additional addresses for each tool use/result. Repeated UUID records do not allocate again. List pages skip empty user/assistant envelopes even with explicit roles, so tool-only and thinking-only rows do not crowd out dialogue; direct reads preserve those addresses and explicitly say when no visible text was recorded. Results pair by `tool_use_id`; pending calls remain unfinished, and a paired result's seq redirects to its call. Only text blocks and recorded attachment renderings become visible text; thinking and raw, unrendered attachment payloads are never exposed. Record types other than user, assistant, system and attachment are ignored, including future metadata, without allocating addresses or exposing payloads. If the selected branch requires a skipped record as an ancestor, history refuses with the missing ancestor UUID. Invalid supported message/block schemas and malformed committed JSONL lines still refuse explicitly. An incomplete final unterminated write is tolerated. Valid forward parent references are resolved after reading the snapshot, without reallocating addresses.
|
|
26
26
|
|
|
27
|
-
The selected tree follows the latest native `parentUuid` links. Compact boundaries also join their `logicalParentUuid` and recorded preserved segments through original ancestry, retaining old events instead of presenting only retained inference context. Auxiliary preservation UUIDs that were never persisted are skipped. Windows use `claude:<sessionId>:<ordinal>`, matching the boot: native compact boundaries advance the ordinal, and retained notesoup boot markers name that same ordinal rather than advancing it again. Preserved duplicate rows keep their original window; new children of their rewritten versions inherit the new window. `@previous` resolves through this oldest-first window list. A missing required ancestor is an explicit refusal.
|
|
27
|
+
The selected tree follows the latest native `parentUuid` links. Compact boundaries also join their `logicalParentUuid` and recorded preserved segments through original ancestry, retaining old events instead of presenting only retained inference context. Auxiliary preservation UUIDs that were never persisted are skipped. Windows use `claude:<sessionId>:<ordinal>`, matching the current boot: native compact boundaries advance the ordinal, and retained notesoup boot markers name that same ordinal rather than advancing it again. A fork preserves the copied boot's ordinal but uses its own session id for public window ids. Copied prompt-context boot blocks are rebuilt with a fresh notes snapshot and the current session identity; historical boot messages in the transcript remain unchanged. Preserved duplicate rows keep their original window; new children of their rewritten versions inherit the new window. `@previous` resolves through this oldest-first window list. A missing required ancestor is an explicit refusal.
|
|
28
28
|
|
|
29
29
|
## Validation
|
|
30
30
|
|
package/package.json
CHANGED
|
@@ -9412,7 +9412,7 @@ function prepareSelection(projection, params) {
|
|
|
9412
9412
|
run.push(event);
|
|
9413
9413
|
continue;
|
|
9414
9414
|
}
|
|
9415
|
-
if (
|
|
9415
|
+
if ((event.role === "user" || event.role === "assistant") && eventDocument(event) === "") continue;
|
|
9416
9416
|
const matchOffset = params.query === void 0 ? void 0 : earliestMatchOffsetChars(eventDocument(event), params.query);
|
|
9417
9417
|
if (matchOffset !== void 0 && matchOffset < 0) continue;
|
|
9418
9418
|
candidates.push({ event, matchOffset, before: foldedRun(run) });
|
|
@@ -9535,7 +9535,7 @@ function renderRead(data) {
|
|
|
9535
9535
|
const tool = toolHeader(data);
|
|
9536
9536
|
const afterSeq = data.seq - 10;
|
|
9537
9537
|
const neighborhood = `neighborhood \u2192 \`history_list\`(${JSON.stringify({ ...afterSeq >= 1 ? { after_seq: afterSeq } : {}, before_seq: data.seq + 10 })})`;
|
|
9538
|
-
return [header(data), ...tool ? [tool] : [], neighborhood, "", renderTextWindow(data)].join("\n");
|
|
9538
|
+
return [header(data), ...tool ? [tool] : [], neighborhood, "", data.total_chars === 0 ? "No visible text recorded for this event." : renderTextWindow(data)].join("\n");
|
|
9539
9539
|
}
|
|
9540
9540
|
function pageFits(page) {
|
|
9541
9541
|
return fitsResult(success(page), (result) => renderOutcome(result, renderPage));
|
|
@@ -9747,13 +9747,12 @@ function decode(row, seq) {
|
|
|
9747
9747
|
var BOOT_IDENTITY = /^<(?:notesoup:window_identity|context_window)>\nAgent name: claude \(/;
|
|
9748
9748
|
var BOOT_PROTOCOL_OPEN = /\n<(?:notesoup:notes_protocol|context_window_protocol)>\n/;
|
|
9749
9749
|
var BOOT_PROTOCOL_CLOSE = /\n<\/(?:notesoup:notes_protocol|context_window_protocol)>/;
|
|
9750
|
-
function bootOrdinal(row,
|
|
9750
|
+
function bootOrdinal(row, retained) {
|
|
9751
9751
|
if (!retained || row.type !== "user" || !object(row.message)) return void 0;
|
|
9752
9752
|
const text = contentText(row.message.content);
|
|
9753
9753
|
if (!BOOT_IDENTITY.test(text) || !BOOT_PROTOCOL_OPEN.test(text) || !BOOT_PROTOCOL_CLOSE.test(text)) return void 0;
|
|
9754
|
-
const
|
|
9755
|
-
|
|
9756
|
-
if (suffix === void 0 || !/^\d+$/.test(suffix)) return void 0;
|
|
9754
|
+
const suffix = /^Current context window id: claude:[^\n]+:(\d+)$/m.exec(text)?.[1];
|
|
9755
|
+
if (suffix === void 0) return void 0;
|
|
9757
9756
|
const ordinal = Number(suffix);
|
|
9758
9757
|
return Number.isSafeInteger(ordinal) ? ordinal : void 0;
|
|
9759
9758
|
}
|
|
@@ -9795,7 +9794,7 @@ function claudeHistoryFromJsonl(text, source) {
|
|
|
9795
9794
|
let before = cursor.ordinal ?? 0;
|
|
9796
9795
|
for (const current of chain.reverse()) {
|
|
9797
9796
|
const retained = current.row.isCompactSummary === true || current.ancestor !== void 0 && boundary(current.ancestor.row);
|
|
9798
|
-
const marked = bootOrdinal(current.row,
|
|
9797
|
+
const marked = bootOrdinal(current.row, retained);
|
|
9799
9798
|
current.ordinal = marked === void 0 ? before + (boundary(current.row) ? 1 : 0) : Math.max(before, marked);
|
|
9800
9799
|
before = current.ordinal;
|
|
9801
9800
|
}
|
|
@@ -469,7 +469,11 @@ export function register(on: On) {
|
|
|
469
469
|
// The reset already retained its boot as the sole conversation message.
|
|
470
470
|
// Prompt context still recomputes, but must not inject a duplicate snapshot.
|
|
471
471
|
const retained = state.retainedBoot !== undefined
|
|
472
|
-
let blocks =
|
|
472
|
+
let blocks = result.blocks.filter((block) => {
|
|
473
|
+
if (block.name !== "notesoup:boot" || !identity) return true
|
|
474
|
+
const marker = bootWindow(block.text)
|
|
475
|
+
return !retained && (!marker || (marker.sessionId === identity.sessionId && marker.window === state.window))
|
|
476
|
+
})
|
|
473
477
|
if (!retained && !blocks.some((block) => block.name === "notesoup:boot") && identity) {
|
|
474
478
|
const texts = await loadTexts($, state)
|
|
475
479
|
const boot = await buildBoot($, identity, state.window, texts, state.history)
|
|
@@ -532,22 +536,23 @@ async function withWarning<T extends { context?: readonly string[]; drop?: strin
|
|
|
532
536
|
/** The boot's identity line; `context_window` is the pre-rename tag still in old transcripts. */
|
|
533
537
|
const BOOT_IDENTITY = /<(?:notesoup:window_identity|context_window)>\nAgent name: claude /
|
|
534
538
|
|
|
535
|
-
/**
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
+
/** Old and new tag spellings, including a boot copied into a fork. */
|
|
540
|
+
function bootWindow(text: string): { sessionId: string; window: number } | undefined {
|
|
541
|
+
if (!BOOT_IDENTITY.test(text)) return undefined
|
|
542
|
+
const marker = /^Current context window id: claude:([^\n]+):(\d+)$/m.exec(text)
|
|
543
|
+
if (!marker) return undefined
|
|
544
|
+
const window = Number(marker[2])
|
|
545
|
+
return Number.isSafeInteger(window) ? { sessionId: marker[1]!, window } : undefined
|
|
546
|
+
}
|
|
547
|
+
/** Keep the copied boot ordinal, but rebuild its snapshot and identity for the new session. */
|
|
539
548
|
function restoreWindow(state: ResetState, messages: readonly { role: string; text: string }[]) {
|
|
540
549
|
if (!state.identity) return
|
|
541
|
-
const prefix = `Current context window id: claude:${state.identity.sessionId}:`
|
|
542
550
|
for (const message of messages) {
|
|
543
|
-
if (message.role !== "user"
|
|
544
|
-
const
|
|
545
|
-
if (!
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
if (!/^\d+$/.test(suffix) || !Number.isSafeInteger(window) || window <= state.window) continue
|
|
549
|
-
state.window = window
|
|
550
|
-
state.retainedBoot = message.text
|
|
551
|
+
if (message.role !== "user") continue
|
|
552
|
+
const marker = bootWindow(message.text)
|
|
553
|
+
if (!marker || marker.window <= state.window) continue
|
|
554
|
+
state.window = marker.window
|
|
555
|
+
state.retainedBoot = marker.sessionId === state.identity.sessionId ? message.text : undefined
|
|
551
556
|
}
|
|
552
557
|
}
|
|
553
558
|
|
|
@@ -99,13 +99,14 @@ const BOOT_PROTOCOL_OPEN = /\n<(?:notesoup:notes_protocol|context_window_protoco
|
|
|
99
99
|
const BOOT_PROTOCOL_CLOSE = /\n<\/(?:notesoup:notes_protocol|context_window_protocol)>/;
|
|
100
100
|
|
|
101
101
|
/** Match the complete retained notesoup boot, not a casually quoted window-id line. */
|
|
102
|
-
function bootOrdinal(row: Row,
|
|
102
|
+
function bootOrdinal(row: Row, retained: boolean): number | undefined {
|
|
103
103
|
if (!retained || row.type !== "user" || !object(row.message)) return undefined;
|
|
104
104
|
const text = contentText(row.message.content);
|
|
105
105
|
if (!BOOT_IDENTITY.test(text) || !BOOT_PROTOCOL_OPEN.test(text) || !BOOT_PROTOCOL_CLOSE.test(text)) return undefined;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
// A fork copies the retained boot verbatim. Its ordinal survives, while
|
|
107
|
+
// public window ids below always belong to the current transcript session.
|
|
108
|
+
const suffix = /^Current context window id: claude:[^\n]+:(\d+)$/m.exec(text)?.[1];
|
|
109
|
+
if (suffix === undefined) return undefined;
|
|
109
110
|
const ordinal = Number(suffix);
|
|
110
111
|
return Number.isSafeInteger(ordinal) ? ordinal : undefined;
|
|
111
112
|
}
|
|
@@ -158,7 +159,7 @@ export function claudeHistoryFromJsonl(text: string, source: Omit<ClaudeHistoryS
|
|
|
158
159
|
let before = cursor.ordinal ?? 0;
|
|
159
160
|
for (const current of chain.reverse()) {
|
|
160
161
|
const retained = current.row.isCompactSummary === true || (current.ancestor !== undefined && boundary(current.ancestor.row));
|
|
161
|
-
const marked = bootOrdinal(current.row,
|
|
162
|
+
const marked = bootOrdinal(current.row, retained);
|
|
162
163
|
current.ordinal = marked === undefined ? before + (boundary(current.row) ? 1 : 0) : Math.max(before, marked);
|
|
163
164
|
before = current.ordinal;
|
|
164
165
|
}
|
package/src/history/query.ts
CHANGED
|
@@ -108,7 +108,8 @@ function prepareSelection(projection: HistoryProjection, params: HistorySelectio
|
|
|
108
108
|
run.push(event);
|
|
109
109
|
continue;
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
// Tool/thinking-only envelopes are not dialogue, even with explicit roles.
|
|
112
|
+
if ((event.role === "user" || event.role === "assistant") && eventDocument(event) === "") continue;
|
|
112
113
|
const matchOffset = params.query === undefined ? undefined : earliestMatchOffsetChars(eventDocument(event), params.query as string[]);
|
|
113
114
|
if (matchOffset !== undefined && matchOffset < 0) continue;
|
|
114
115
|
candidates.push({ event, matchOffset, before: foldedRun(run) });
|
package/src/tools/history.ts
CHANGED
|
@@ -75,7 +75,7 @@ function renderRead(data: HistoryReadData): string {
|
|
|
75
75
|
const tool = toolHeader(data);
|
|
76
76
|
const afterSeq = data.seq - 10;
|
|
77
77
|
const neighborhood = `neighborhood → \`history_list\`(${JSON.stringify({ ...(afterSeq >= 1 ? { after_seq: afterSeq } : {}), before_seq: data.seq + 10 })})`;
|
|
78
|
-
return [header(data), ...(tool ? [tool] : []), neighborhood, "", renderTextWindow(data)].join("\n");
|
|
78
|
+
return [header(data), ...(tool ? [tool] : []), neighborhood, "", data.total_chars === 0 ? "No visible text recorded for this event." : renderTextWindow(data)].join("\n");
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/* ------------------------------------------------------------------ shared bounding */
|