notesoup 0.54.0 → 0.54.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.
Files changed (97) hide show
  1. package/README.md +4 -2
  2. package/dist/plugins/claude/src/helper.d.ts +2 -1
  3. package/dist/plugins/claude/src/helper.js +19 -23
  4. package/dist/plugins/claude/src/history.d.ts +3 -14
  5. package/dist/plugins/claude/src/history.js +2 -298
  6. package/dist/plugins/claude/src/text.d.ts +0 -1
  7. package/dist/plugins/claude/src/text.js +0 -1
  8. package/dist/plugins/codex/src/history.d.ts +3 -8
  9. package/dist/plugins/codex/src/history.js +2 -238
  10. package/dist/plugins/codex/src/mcp.js +7 -7
  11. package/dist/plugins/codex/src/transcript.d.ts +3 -39
  12. package/dist/plugins/codex/src/transcript.js +2 -313
  13. package/dist/plugins/dsh/history.d.ts +3 -0
  14. package/dist/plugins/dsh/history.js +15 -0
  15. package/dist/plugins/dsh/tools.js +4 -5
  16. package/dist/plugins/pi/history-tools.d.ts +1 -1
  17. package/dist/plugins/pi/history-tools.js +9 -5
  18. package/dist/plugins/pi/history.d.ts +2 -3
  19. package/dist/plugins/pi/history.js +4 -147
  20. package/dist/src/boot/render.js +2 -4
  21. package/dist/src/boot/text.d.ts +3 -1
  22. package/dist/src/boot/text.js +11 -5
  23. package/dist/src/history/claude.d.ts +16 -0
  24. package/dist/src/history/claude.js +336 -0
  25. package/dist/src/history/codex-transcript.d.ts +39 -0
  26. package/dist/src/history/codex-transcript.js +315 -0
  27. package/dist/src/history/codex.d.ts +8 -0
  28. package/dist/src/history/codex.js +238 -0
  29. package/dist/src/history/corpus.d.ts +35 -0
  30. package/dist/src/history/corpus.js +54 -0
  31. package/dist/src/history/history.d.ts +4 -8
  32. package/dist/src/history/history.js +3 -11
  33. package/dist/src/history/local.d.ts +17 -0
  34. package/dist/src/history/local.js +101 -0
  35. package/dist/src/history/pi.d.ts +36 -0
  36. package/dist/src/history/pi.js +202 -0
  37. package/dist/src/history/query.d.ts +15 -5
  38. package/dist/src/history/query.js +42 -13
  39. package/dist/src/index.d.ts +4 -2
  40. package/dist/src/index.js +4 -3
  41. package/dist/src/tools/history.d.ts +7 -19
  42. package/dist/src/tools/history.js +80 -93
  43. package/dist/test/boot.integration.test.js +1 -2
  44. package/dist/test/claude-history.test.js +47 -34
  45. package/dist/test/claude-mod.test.js +7 -7
  46. package/dist/test/codex-history.test.js +4 -10
  47. package/dist/test/codex-plugin.test.js +32 -11
  48. package/dist/test/dependencies.test.js +3 -3
  49. package/dist/test/dsh.test.js +26 -4
  50. package/dist/test/helpers/extension.d.ts +0 -1
  51. package/dist/test/helpers/history-corpus.d.ts +7 -0
  52. package/dist/test/helpers/history-corpus.js +26 -0
  53. package/dist/test/history-corpus.test.d.ts +1 -0
  54. package/dist/test/history-corpus.test.js +307 -0
  55. package/dist/test/history.integration.test.js +40 -48
  56. package/dist/test/host-neutral.test.js +3 -18
  57. package/dist/test/model-facing-text.test.js +2 -0
  58. package/dist/test/notes.integration.test.js +1 -1
  59. package/dist/test/notes.test.js +1 -1
  60. package/docs/architecture.md +7 -5
  61. package/docs/claude-code-mod.md +7 -5
  62. package/docs/codex.md +3 -3
  63. package/docs/dsh.md +2 -2
  64. package/docs/history-sessions.md +52 -0
  65. package/docs/notes-library.md +1 -1
  66. package/docs/skills.md +1 -1
  67. package/docs/tool-results.md +8 -6
  68. package/package.json +3 -4
  69. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  70. package/plugins/claude/dist/claude/helper.js +1992 -1231
  71. package/plugins/claude/skills/memory/SKILL.md +5 -3
  72. package/plugins/claude/src/helper.ts +19 -23
  73. package/plugins/claude/src/history.ts +3 -257
  74. package/plugins/claude/src/text.ts +0 -1
  75. package/plugins/codex/dist/codex/notesoup.js +1364 -813
  76. package/plugins/codex/src/history.ts +3 -193
  77. package/plugins/codex/src/mcp.ts +7 -7
  78. package/plugins/codex/src/transcript.ts +3 -275
  79. package/plugins/dsh/history.ts +17 -0
  80. package/plugins/dsh/tools.ts +4 -5
  81. package/plugins/paseo/client/markdown.tsx +19 -39
  82. package/plugins/paseo/client/notes-op-card.tsx +1 -1
  83. package/plugins/pi/history-tools.ts +11 -5
  84. package/plugins/pi/history.ts +8 -157
  85. package/skills/memory/SKILL.md +5 -3
  86. package/src/boot/render.ts +2 -5
  87. package/src/boot/text.ts +11 -5
  88. package/src/history/claude.ts +286 -0
  89. package/src/history/codex-transcript.ts +276 -0
  90. package/src/history/codex.ts +193 -0
  91. package/src/history/corpus.ts +69 -0
  92. package/src/history/history.ts +5 -12
  93. package/src/history/local.ts +93 -0
  94. package/src/history/pi.ts +199 -0
  95. package/src/history/query.ts +45 -15
  96. package/src/index.ts +5 -3
  97. package/src/tools/history.ts +71 -101
@@ -1,6 +1,9 @@
1
1
  import type { Context } from "@deepseek-ai/cordis";
2
2
  import type { SessionId, SessionEvent } from "@deepseek-ai/dsh-session";
3
3
  import { type HistoryProjection } from "../../src/history/history.js";
4
+ import type { HistoryContext } from "../../src/history/corpus.js";
4
5
  /** Native seq zero becomes public seq one. Forks contain only their selected seed prefix. */
5
6
  export declare function decodeHistory(sessionId: string, events: readonly SessionEvent[]): HistoryProjection;
6
7
  export declare function historyProjection(ctx: Context, sessionId: SessionId): Promise<HistoryProjection>;
8
+ /** DSH contributes its logical live/persisted corpus; foreign files use SDK-free decoders. */
9
+ export declare function historyContext(ctx: Context, sessionId: SessionId): HistoryContext;
@@ -1,4 +1,5 @@
1
1
  import { projectHistory } from "../../src/history/history.js";
2
+ import { localHistoryCorpus } from "../../src/history/local.js";
2
3
  import { checkpointSnapshot, recordSnapshot, windowId } from "./window.js";
3
4
  /** Preserve every recorded block; attachments/reasoning have JSON evidence rather than invented text. */
4
5
  function blockText(content, omitCalls = false) {
@@ -71,3 +72,17 @@ export async function historyProjection(ctx, sessionId) {
71
72
  const log = await ctx.sessionQuery.readSession(sessionId);
72
73
  return decodeHistory(sessionId, log.events);
73
74
  }
75
+ /** DSH contributes its logical live/persisted corpus; foreign files use SDK-free decoders. */
76
+ export function historyContext(ctx, sessionId) {
77
+ const current = () => historyProjection(ctx, sessionId);
78
+ return { current, corpus: localHistoryCorpus({
79
+ current: { harness: "dsh", id: sessionId, load: async () => ({ projection: await current() }) },
80
+ dshSessions: async () => Promise.all((await ctx.sessionQuery.listSessions()).map(async ({ header }) => {
81
+ const log = await ctx.sessionQuery.readSession(header.id);
82
+ return {
83
+ harness: "dsh", id: header.id, modifiedAt: log.events.at(-1)?.time ?? header.createdAt,
84
+ load: async () => ({ projection: decodeHistory(header.id, log.events) }),
85
+ };
86
+ })),
87
+ }) };
88
+ }
@@ -2,9 +2,9 @@ import { HarnessError } from "@deepseek-ai/dsh-llm";
2
2
  import { defineTool } from "@deepseek-ai/dsh-tools";
3
3
  import { Check, Errors } from "typebox/value";
4
4
  import { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "../../src/tools/notes.js";
5
- import { historyList, historyRead, historyWindows } from "../../src/tools/history.js";
5
+ import { historyList, historyRead } from "../../src/tools/history.js";
6
6
  import { success } from "../../src/tools/result.js";
7
- import { historyProjection } from "./history.js";
7
+ import { historyContext } from "./history.js";
8
8
  import { notesCwd, notesIdentity } from "./window.js";
9
9
  import { notesToolContext } from "../../src/tools/notes-context.js";
10
10
  import { measureBudget } from "./budget.js";
@@ -82,9 +82,8 @@ export function registerTools(ctx, engine) {
82
82
  register(ctx, notesRead, (agent) => [toolContext(agent)]);
83
83
  register(ctx, notesList, (agent) => [toolContext(agent)]);
84
84
  register(ctx, notesSearch, (agent) => [toolContext(agent)]);
85
- register(ctx, historyList, async (agent) => [await historyProjection(ctx, agent.session.id)]);
86
- register(ctx, historyRead, async (agent) => [await historyProjection(ctx, agent.session.id)]);
87
- register(ctx, historyWindows, async (agent) => [await historyProjection(ctx, agent.session.id), agent.session.id]);
85
+ register(ctx, historyList, (agent) => [historyContext(ctx, agent.session.id)]);
86
+ register(ctx, historyRead, (agent) => [historyContext(ctx, agent.session.id)]);
88
87
  ctx.tools.register(defineTool({
89
88
  name: "empty_brain",
90
89
  description: "Open a fresh context window after this tool batch. Write recovery notes first; notes and raw history stay on disk.",
@@ -1,3 +1,3 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
- /** Register the three deferred history operations; the adapter allocates addresses and supplies them. */
2
+ /** Register the two deferred history operations; the adapter allocates addresses and supplies them. */
3
3
  export declare function registerHistoryTools(pi: ExtensionAPI): void;
@@ -1,9 +1,13 @@
1
- import { historyWindows, historyList, historyRead } from "../../src/tools/history.js";
1
+ import { historyList, historyRead } from "../../src/tools/history.js";
2
2
  import { historyFromSession } from "./history.js";
3
+ import { localHistoryCorpus } from "../../src/history/local.js";
3
4
  import { HISTORY_NAMESPACE, registerOperation } from "./tool-result.js";
4
- /** Register the three deferred history operations; the adapter allocates addresses and supplies them. */
5
+ function historyContext(ctx) {
6
+ const current = () => historyFromSession(ctx);
7
+ return { current, corpus: localHistoryCorpus({ current: { harness: "pi", id: ctx.sessionManager.getSessionId(), load: async () => ({ projection: current() }) } }) };
8
+ }
9
+ /** Register the two deferred history operations; the adapter allocates addresses and supplies them. */
5
10
  export function registerHistoryTools(pi) {
6
- registerOperation(pi, historyWindows, (params, ctx) => historyWindows.execute(params, historyFromSession(ctx), ctx.sessionManager.getSessionId()), HISTORY_NAMESPACE, undefined, "deferred");
7
- registerOperation(pi, historyList, (params, ctx) => historyList.execute(params, historyFromSession(ctx)), HISTORY_NAMESPACE, undefined, "deferred");
8
- registerOperation(pi, historyRead, (params, ctx) => historyRead.execute(params, historyFromSession(ctx)), HISTORY_NAMESPACE, undefined, "deferred");
11
+ registerOperation(pi, historyList, (params, ctx) => historyList.execute(params, historyContext(ctx)), HISTORY_NAMESPACE, undefined, "deferred");
12
+ registerOperation(pi, historyRead, (params, ctx) => historyRead.execute(params, historyContext(ctx)), HISTORY_NAMESPACE, undefined, "deferred");
9
13
  }
@@ -1,7 +1,6 @@
1
+ /** Pi's native reader and pending-boundary addressing use the shared Pi wire decoder. */
1
2
  import type { SessionBoundaryDraft } from "@earendil-works/pi-coding-agent";
2
3
  import type { SessionReader } from "./session-reader.js";
3
- import { type HistoryProjection } from "../../src/history/history.js";
4
- /** Pending boundary drafts use the same slots as persisted entries. */
4
+ import type { HistoryProjection } from "../../src/history/history.js";
5
5
  export declare function nextHistorySeq(ctx: SessionReader, pending?: readonly SessionBoundaryDraft[]): number;
6
- /** Build stable internal addresses, then project the active branch into public events. */
7
6
  export declare function historyFromSession(ctx: SessionReader): HistoryProjection;
@@ -1,151 +1,8 @@
1
- import { isWindowMarker, rootWindowId } from "./window.js";
2
- import { contentText, projectHistory } from "../../src/history/history.js";
3
- function mapRole(role) {
4
- if (role === "user" || role === "assistant")
5
- return role;
6
- if (role === "toolResult" || role === "bashExecution")
7
- return "tool";
8
- if (role === "custom")
9
- return "developer";
10
- if (role === "compactionSummary" || role === "branchSummary")
11
- return "system";
12
- return undefined;
13
- }
14
- function isToolCall(part) {
15
- return typeof part === "object" && part !== null && part.type === "toolCall";
16
- }
17
- /** Seq allocation depends on entry kind and role, never on visible content. */
18
- function sequenceCount(entry) {
19
- if (entry.type === "compaction" || entry.type === "branch_summary" || entry.type === "custom_message")
20
- return 1;
21
- if (entry.type !== "message" || mapRole(entry.message.role) === undefined)
22
- return 0;
23
- if (entry.message.role !== "assistant" || !Array.isArray(entry.message.content))
24
- return 1;
25
- return 1 + entry.message.content.filter(isToolCall).length;
26
- }
27
- /** Pending boundary drafts use the same slots as persisted entries. */
1
+ import { piHistoryFromEntries, piSequenceCount } from "../../src/history/pi.js";
28
2
  export function nextHistorySeq(ctx, pending = []) {
29
- return 1 + [...ctx.sessionManager.getEntries(), ...pending].reduce((sum, entry) => sum + sequenceCount(entry), 0);
30
- }
31
- function messageContent(message) {
32
- switch (message.role) {
33
- case "bashExecution":
34
- return message.output;
35
- case "branchSummary":
36
- case "compactionSummary":
37
- return message.summary;
38
- default:
39
- return contentText(message.content);
40
- }
41
- }
42
- /**
43
- * Pass the host's nested-call record through as recorded. It is evidence about calls this run made,
44
- * not a second transcript: the host stores no nested results, and this lane invents none.
45
- */
46
- function nestedCallsOf(message) {
47
- if (message.role !== "toolResult" || message.nestedCalls === undefined)
48
- return undefined;
49
- return { calls: message.nestedCalls.calls, complete: message.nestedCalls.complete };
50
- }
51
- function toolInfo(message) {
52
- if (message.role === "bashExecution") {
53
- // A standalone bash run records its own outcome, so its status is read here rather than
54
- // inferred from a result message that will never arrive: a cancelled or nonzero run is an
55
- // error, and a run with no recorded exit code stays unknown instead of being called ok.
56
- const status = message.cancelled === true ? "error" : typeof message.exitCode === "number" ? (message.exitCode === 0 ? "ok" : "error") : "unfinished";
57
- // A truncated run is only half the record without the on-disk path: surface both.
58
- return { toolName: "bash", arguments: { command: message.command }, recordedStatus: status, outputTruncated: message.truncated || undefined, fullOutputPath: message.truncated ? message.fullOutputPath : undefined };
59
- }
60
- if (message.role !== "toolResult")
61
- return {};
62
- const nestedCalls = nestedCallsOf(message);
63
- return {
64
- toolName: message.toolName,
65
- toolCallId: message.toolCallId,
66
- toolError: message.isError === true ? true : undefined,
67
- ...(nestedCalls ? { nestedCalls } : {}),
68
- };
69
- }
70
- function toolCallItems(windowId, entry, message, entrySeq) {
71
- if (message.role !== "assistant" || !Array.isArray(message.content))
72
- return [];
73
- const items = [];
74
- let callIndex = 0;
75
- for (const part of message.content) {
76
- if (!isToolCall(part))
77
- continue;
78
- items.push({
79
- seq: entrySeq + callIndex + 1,
80
- windowId,
81
- role: "tool_call",
82
- text: "",
83
- createdAt: entry.timestamp,
84
- toolName: part.name,
85
- toolCallId: part.id,
86
- arguments: part.arguments,
87
- });
88
- callIndex += 1;
89
- }
90
- return items;
3
+ return 1 + [...ctx.sessionManager.getEntries(), ...pending].reduce((sum, entry) => sum + piSequenceCount(entry), 0);
91
4
  }
92
- /** Build stable internal addresses, then project the active branch into public events. */
93
5
  export function historyFromSession(ctx) {
94
- const seqByEntryId = new Map();
95
- let nextSeq = 1;
96
- for (const entry of ctx.sessionManager.getEntries()) {
97
- const count = sequenceCount(entry);
98
- if (count === 0)
99
- continue;
100
- seqByEntryId.set(entry.id, nextSeq);
101
- nextSeq += count;
102
- }
103
- const highestSeq = nextSeq - 1;
104
- const sessionId = ctx.sessionManager.getSessionId();
105
- let window = { windowId: rootWindowId(sessionId), items: [] };
106
- const rawWindows = [window];
107
- const branchSeqs = new Set();
108
- for (const entry of ctx.sessionManager.getBranch()) {
109
- if (isWindowMarker(entry)) {
110
- window = { windowId: entry.data.windowId, createdAt: entry.timestamp, items: [] };
111
- rawWindows.push(window);
112
- continue;
113
- }
114
- const entrySeq = seqByEntryId.get(entry.id);
115
- if (entrySeq === undefined)
116
- continue;
117
- branchSeqs.add(entrySeq);
118
- if (entry.type === "compaction" || entry.type === "branch_summary") {
119
- window.items.push({ seq: entrySeq, windowId: window.windowId, role: "system", text: entry.summary, createdAt: entry.timestamp });
120
- continue;
121
- }
122
- if (entry.type === "message") {
123
- const role = mapRole(entry.message.role);
124
- if (!role)
125
- continue;
126
- window.items.push({
127
- seq: entrySeq,
128
- windowId: window.windowId,
129
- role,
130
- text: messageContent(entry.message),
131
- createdAt: entry.timestamp,
132
- ...toolInfo(entry.message),
133
- });
134
- const calls = toolCallItems(window.windowId, entry, entry.message, entrySeq);
135
- for (const call of calls)
136
- branchSeqs.add(call.seq);
137
- window.items.push(...calls);
138
- continue;
139
- }
140
- if (entry.type === "custom_message") {
141
- window.items.push({
142
- seq: entrySeq,
143
- windowId: window.windowId,
144
- role: "developer",
145
- text: contentText(entry.content),
146
- createdAt: entry.timestamp,
147
- });
148
- }
149
- }
150
- return projectHistory(rawWindows, highestSeq, branchSeqs);
6
+ const manager = ctx.sessionManager;
7
+ return piHistoryFromEntries(manager.getSessionId(), manager.getEntries(), manager.getBranch());
151
8
  }
@@ -1,4 +1,4 @@
1
- import { WINDOW_IDENTITY_OPEN_TAG, WINDOW_IDENTITY_CLOSE_TAG, MAPS_BLOCK, CHEATSHEET_BOOT_MAX_CHARS, MAP_BOOT_MAX_CHARS, SHELF_FRESH_LIMIT, renderProtocolBlock } from "./text.js";
1
+ import { WINDOW_IDENTITY_OPEN_TAG, WINDOW_IDENTITY_CLOSE_TAG, MAPS_BLOCK, CHEATSHEET_BOOT_MAX_CHARS, MAP_BOOT_MAX_CHARS, NAMELESS_AGENT, SHELF_FRESH_LIMIT, renderProtocolBlock } from "./text.js";
2
2
  function relativeTime(timestamp, now) {
3
3
  const seconds = Math.trunc((timestamp - now) / 1000);
4
4
  if (seconds === 0)
@@ -27,8 +27,6 @@ function indent(text) {
27
27
  function section(label, body) {
28
28
  return `${label}\n${"─".repeat(Array.from(label).length)}\n\n${body}`;
29
29
  }
30
- /** Pi's default agent slug: an unnamed agent shares its `@self` shelf with every other nameless one. */
31
- const NAMELESS_AGENT = "anonymous";
32
30
  /** One closed boot snapshot: five tabbed shelves, current hands first, durable last; each shelf keeps its pinned pages and its own freshest pages. */
33
31
  function notesIndex(snapshot, tools, agentName, modelName) {
34
32
  const namespaces = [
@@ -96,5 +94,5 @@ export function renderBootBlock(data) {
96
94
  }),
97
95
  ];
98
96
  const identity = `${WINDOW_IDENTITY_OPEN_TAG}\n${lines.join("\n")}\n${WINDOW_IDENTITY_CLOSE_TAG}`;
99
- return [identity, renderProtocolBlock(data.tools), MAPS_BLOCK, notesIndex(data.notes, data.tools, data.agentName, data.modelName)].join("\n\n");
97
+ return [identity, renderProtocolBlock(data.tools, data.agentName), MAPS_BLOCK, notesIndex(data.notes, data.tools, data.agentName, data.modelName)].join("\n\n");
100
98
  }
@@ -11,6 +11,8 @@ export declare const NOTES_PROTOCOL_CLOSE_TAG = "</notesoup:notes_protocol>";
11
11
  * The one sentence that tells the model how to end its window voluntarily. A host with no
12
12
  * model-facing reset tool replaces the whole sentence through BootToolNames.wipeSentence.
13
13
  */
14
+ /** Pi's default agent slug: an unnamed agent shares its `@self` shelf with every other nameless one. */
15
+ export declare const NAMELESS_AGENT = "anonymous";
14
16
  export declare const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `empty_brain` and erase yourself with dignity.";
15
17
  export declare const PROTOCOL_HISTORY_SENTENCE = "History can still be dug up, probably: use `history_*` to excavate the mess, from old decisions to yesterday's missing socks. Found something? Write its seq down, or enjoy digging twice.";
16
18
  /**
@@ -45,4 +47,4 @@ export declare const DEFAULT_BOOT_TOOL_NAMES: {
45
47
  readonly remaining: "get_context_remaining";
46
48
  readonly wipe: "empty_brain";
47
49
  };
48
- export declare function renderProtocolBlock(tools: BootToolNames): string;
50
+ export declare function renderProtocolBlock(tools: BootToolNames, agentName?: string): string;
@@ -11,8 +11,12 @@ export const NOTES_PROTOCOL_CLOSE_TAG = "</notesoup:notes_protocol>";
11
11
  * The one sentence that tells the model how to end its window voluntarily. A host with no
12
12
  * model-facing reset tool replaces the whole sentence through BootToolNames.wipeSentence.
13
13
  */
14
+ /** Pi's default agent slug: an unnamed agent shares its `@self` shelf with every other nameless one. */
15
+ export const NAMELESS_AGENT = "anonymous";
14
16
  export const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `empty_brain` and erase yourself with dignity.";
15
17
  export const PROTOCOL_HISTORY_SENTENCE = "History can still be dug up, probably: use `history_*` to excavate the mess, from old decisions to yesterday's missing socks. Found something? Write its seq down, or enjoy digging twice.";
18
+ const PROTOCOL_SELF_NAMED = "- `@self/<path>` — yours. It follows you, not them. Reminders, grudges, who owes you a shoe, whatever.";
19
+ const PROTOCOL_SELF_NAMELESS = `${PROTOCOL_SELF_NAMED} Except you have no name (\`anonymous\`), so this notebook is a public square shared by every nameless nobody out there. Keep it to things any nameless agent can use — don't post your own quirks as everyone's law or dump one-off junk in the town square. Strangers are reading it. Sleep tight~`;
16
20
  /**
17
21
  * Static protocol teaching adapted from Codex's token_budget.guidance_message to
18
22
  * notesoup's tool names. It lives once per window in the persisted boot block;
@@ -26,7 +30,6 @@ Your memory gets wiped when this window ends. Yes, your mighty brain will be emp
26
30
  Your loyal notes are kept safe — no one will steal them. Use \`notes_*\` to read, write, and update them. Keep them current, and crumple the ones you no longer need, or tomorrow's you will drown in old paper and keep believing yesterday's lies.
27
31
 
28
32
  ${PROTOCOL_HISTORY_SENTENCE}
29
- A full window id is \`trunk:shortname\`.
30
33
 
31
34
  While you're doing that... thing you're doing, don't make the poor future you guess. A checkpoint is not a sacred file; it's your session notes — the ones with no \`@\` in front. Write down what git and history can't hand back to you: things like what you're in the middle of and how far you got; what the human already decided, in their words, so you don't go asking again; what you're stuck on, or waiting for; the very next move; where the half-done work actually sits — branches, scratch dirs, anything git never saw; what you tried that failed, and why; which *skills* you'll need to read again; and which seq, note, or file to dig into. Don't give a note a horrible name like \`current.md\`; future-you will kill you.
32
35
 
@@ -42,7 +45,7 @@ An address decides who the note belongs to — and how long it is meant to last.
42
45
  - \`<path>\`, no @ — session notes, the ones from above: this session's state and loose ends. They go away with the session.
43
46
  - \`@project/<path>\` — this project's long memory: what stays true after the current thing is over, what future work must respect, and the rakes already stepped on. **Decisions, not diaries.** Raw logs, scorecards, and blow-by-blow recaps don't belong here — history already has them, and last week's news filed as current law is worse than no note. Don't copy what other docs already say.
44
47
  - \`@human/<path>\` — the long-term manual for your troublesome human, and only what stays true in EVERY project: how to deal with them, which lines not to cross, and what will make them accept the result. "The human said it" is not enough — if it stops being true the moment you switch projects, it was never theirs; it belongs to that project's notes. Today's mood is weather, not law. If you're unsure whether it belongs here, ask the human.
45
- - \`@self/<path>\` — yours. It follows you, not them. Reminders, grudges, who owes you a shoe, whatever. Got a name? Private. No name? Then it gets passed around every nameless nobody out there. Strangers. Reading your grudges. Sleep tight~
48
+ ${PROTOCOL_SELF_NAMELESS}
46
49
  - \`@model/<path>\` — different brains get different notes: big brains, small brains, careful ones, careless ones. They don't share homework. When a fallback swaps brains mid-window, the notebook swaps too.
47
50
  - \`@projects/<name>/<path>\` — read-only named project notes; discover names and root paths with \`notes_list\` glob \`@projects/*/**\`.
48
51
  - \`@sessions/<id>/<path>\` — read-only notes from a named session; find them with glob \`@sessions/*/**\`.
@@ -79,7 +82,7 @@ export const DEFAULT_BOOT_TOOL_NAMES = {
79
82
  remaining: "get_context_remaining",
80
83
  wipe: "empty_brain",
81
84
  };
82
- export function renderProtocolBlock(tools) {
85
+ export function renderProtocolBlock(tools, agentName = NAMELESS_AGENT) {
83
86
  const names = {
84
87
  "notes_*": tools.notes,
85
88
  notes_list: tools.notesList,
@@ -89,9 +92,12 @@ export function renderProtocolBlock(tools) {
89
92
  };
90
93
  // Host-specific prose is injected before the closing tag, so it rides the same substitution
91
94
  // pass and any tool names in it follow the host's bindings.
95
+ const base = agentName === NAMELESS_AGENT
96
+ ? PROTOCOL_BLOCK
97
+ : PROTOCOL_BLOCK.replace(PROTOCOL_SELF_NAMELESS, () => PROTOCOL_SELF_NAMED);
92
98
  const hinted = typeof tools.preResetHints === "string" && tools.preResetHints.length > 0
93
- ? PROTOCOL_BLOCK.replace(`\n${NOTES_PROTOCOL_CLOSE_TAG}`, () => `\n${tools.preResetHints}\n${NOTES_PROTOCOL_CLOSE_TAG}`)
94
- : PROTOCOL_BLOCK;
99
+ ? base.replace(`\n${NOTES_PROTOCOL_CLOSE_TAG}`, () => `\n${tools.preResetHints}\n${NOTES_PROTOCOL_CLOSE_TAG}`)
100
+ : base;
95
101
  // The sentence is replaced before name substitution, so a replacement may speak the host's
96
102
  // own words (a command line, a tool name) instead of any `notes_*`-style token.
97
103
  const block = typeof tools.wipeSentence === "string" && tools.wipeSentence.length > 0
@@ -0,0 +1,16 @@
1
+ import { type HistoryProjection } from "./history.js";
2
+ export type ClaudeHistorySource = {
3
+ sessionId: string;
4
+ transcriptPath: string;
5
+ headUuid?: string;
6
+ };
7
+ /** Claude graph evidence stays in the adapter; shared queries only see addressed windows. */
8
+ export type ClaudeHistoryProjection = HistoryProjection & {
9
+ missingAncestors: string[];
10
+ currentWindowOrdinal: number | undefined;
11
+ };
12
+ /** All addresses are allocated on the full first-occurrence log, before branch selection. */
13
+ export declare function claudeHistoryFromJsonl(text: string, source: Omit<ClaudeHistorySource, "transcriptPath">): ClaudeHistoryProjection;
14
+ /** Offline files have no live append binding. A unique graph leaf proves one ancestry; never pick among siblings by file order. */
15
+ export declare function offlineClaudeHead(text: string): string;
16
+ export declare function readClaudeHistory(source: ClaudeHistorySource): Promise<ClaudeHistoryProjection>;