notesoup 0.53.2 → 0.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/plugins/claude/src/helper.d.ts +2 -1
- package/dist/plugins/claude/src/helper.js +21 -24
- package/dist/plugins/claude/src/history.d.ts +3 -14
- package/dist/plugins/claude/src/history.js +2 -298
- package/dist/plugins/claude/src/text.d.ts +0 -1
- package/dist/plugins/claude/src/text.js +0 -1
- package/dist/plugins/codex/src/history.d.ts +3 -8
- package/dist/plugins/codex/src/history.js +2 -238
- package/dist/plugins/codex/src/hooks.js +1 -1
- package/dist/plugins/codex/src/identity.d.ts +1 -1
- package/dist/plugins/codex/src/identity.js +3 -3
- package/dist/plugins/codex/src/mcp.js +9 -8
- package/dist/plugins/codex/src/text.d.ts +1 -1
- package/dist/plugins/codex/src/text.js +2 -2
- package/dist/plugins/codex/src/transcript.d.ts +3 -39
- package/dist/plugins/codex/src/transcript.js +2 -313
- package/dist/plugins/dsh/engine.js +2 -2
- package/dist/plugins/dsh/history.d.ts +3 -0
- package/dist/plugins/dsh/history.js +15 -0
- package/dist/plugins/dsh/tools.js +12 -12
- package/dist/plugins/dsh/window.d.ts +1 -0
- package/dist/plugins/dsh/window.js +7 -3
- package/dist/plugins/pi/history-tools.d.ts +1 -1
- package/dist/plugins/pi/history-tools.js +9 -5
- package/dist/plugins/pi/history.d.ts +2 -3
- package/dist/plugins/pi/history.js +4 -147
- package/dist/plugins/pi/notes/tools.js +8 -6
- package/dist/plugins/pi/render.js +7 -4
- package/dist/plugins/pi/runtime.js +2 -2
- package/dist/plugins/pi/window.js +21 -7
- package/dist/src/boot/render.js +9 -11
- package/dist/src/boot/snapshot.d.ts +7 -7
- package/dist/src/boot/snapshot.js +17 -17
- package/dist/src/boot/text.d.ts +5 -3
- package/dist/src/boot/text.js +18 -10
- package/dist/src/dream/git.d.ts +2 -11
- package/dist/src/dream/git.js +6 -23
- package/dist/src/dream/lock.d.ts +2 -2
- package/dist/src/dream/lock.js +3 -3
- package/dist/src/history/claude.d.ts +16 -0
- package/dist/src/history/claude.js +336 -0
- package/dist/src/history/codex-transcript.d.ts +39 -0
- package/dist/src/history/codex-transcript.js +315 -0
- package/dist/src/history/codex.d.ts +8 -0
- package/dist/src/history/codex.js +238 -0
- package/dist/src/history/corpus.d.ts +35 -0
- package/dist/src/history/corpus.js +54 -0
- package/dist/src/history/history.d.ts +4 -8
- package/dist/src/history/history.js +3 -11
- package/dist/src/history/local.d.ts +17 -0
- package/dist/src/history/local.js +101 -0
- package/dist/src/history/pi.d.ts +36 -0
- package/dist/src/history/pi.js +202 -0
- package/dist/src/history/query.d.ts +15 -5
- package/dist/src/history/query.js +42 -13
- package/dist/src/index.d.ts +6 -3
- package/dist/src/index.js +6 -4
- package/dist/src/notes/address.d.ts +8 -8
- package/dist/src/notes/address.js +13 -13
- package/dist/src/notes/errors.d.ts +1 -1
- package/dist/src/notes/frontmatter.js +2 -2
- package/dist/src/notes/index.d.ts +1 -1
- package/dist/src/notes/index.js +1 -1
- package/dist/src/notes/paths.d.ts +6 -6
- package/dist/src/notes/paths.js +9 -9
- package/dist/src/notes/{project-home.d.ts → project-namespace.d.ts} +7 -7
- package/dist/src/notes/{project-home.js → project-namespace.js} +67 -25
- package/dist/src/notes/store.d.ts +4 -4
- package/dist/src/notes/store.js +55 -52
- package/dist/src/tools/dream.d.ts +21 -3
- package/dist/src/tools/dream.js +54 -16
- package/dist/src/tools/history.d.ts +7 -19
- package/dist/src/tools/history.js +80 -93
- package/dist/src/tools/notes-context.d.ts +10 -0
- package/dist/src/tools/notes-context.js +27 -0
- package/dist/src/tools/notes.d.ts +69 -20
- package/dist/src/tools/notes.js +40 -31
- package/dist/test/boot.integration.test.js +2 -3
- package/dist/test/claude-history.test.js +47 -34
- package/dist/test/claude-mod.test.js +96 -50
- package/dist/test/codex-history.test.js +4 -10
- package/dist/test/codex-plugin.test.js +50 -12
- package/dist/test/context-edit-budget.test.js +121 -0
- package/dist/test/dependencies.test.js +73 -6
- package/dist/test/dream-tools.test.js +153 -8
- package/dist/test/dsh.test.js +88 -19
- package/dist/test/helpers/dsh.d.ts +4 -1
- package/dist/test/helpers/dsh.js +20 -4
- package/dist/test/helpers/extension.d.ts +5 -1
- package/dist/test/helpers/extension.js +33 -2
- package/dist/test/helpers/history-corpus.d.ts +7 -0
- package/dist/test/helpers/history-corpus.js +26 -0
- package/dist/test/history-corpus.test.js +307 -0
- package/dist/test/history.integration.test.js +40 -48
- package/dist/test/host-neutral.test.js +20 -33
- package/dist/test/model-facing-text.test.js +14 -8
- package/dist/test/notes-cwd.test.d.ts +1 -0
- package/dist/test/notes-cwd.test.js +114 -0
- package/dist/test/notes-library.test.js +4 -4
- package/dist/test/notes-query-namespaces.test.d.ts +1 -0
- package/dist/test/{notes-query-homes.test.js → notes-query-namespaces.test.js} +13 -13
- package/dist/test/notes.integration.test.js +73 -24
- package/dist/test/notes.test.js +51 -21
- package/dist/test/pi-render.test.js +33 -1
- package/dist/test/project-namespace.test.d.ts +1 -0
- package/dist/test/project-namespace.test.js +324 -0
- package/docs/architecture.md +19 -12
- package/docs/claude-code-mod.md +7 -5
- package/docs/codex.md +6 -6
- package/docs/dsh.md +9 -9
- package/docs/history-sessions.md +52 -0
- package/docs/notes-library.md +9 -5
- package/docs/skills.md +3 -3
- package/docs/tool-results.md +14 -8
- package/package.json +4 -6
- package/playbook.md +6 -6
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +2164 -1341
- package/plugins/claude/hooks/register.ts +19 -11
- package/plugins/claude/playbook.md +6 -6
- package/plugins/claude/skills/memory/SKILL.md +9 -7
- package/plugins/claude/src/helper.ts +22 -25
- package/plugins/claude/src/history.ts +3 -257
- package/plugins/claude/src/text.ts +0 -1
- package/plugins/codex/README.md +1 -1
- package/plugins/codex/dist/codex/notesoup.js +1582 -969
- package/plugins/codex/src/history.ts +3 -193
- package/plugins/codex/src/hooks.ts +1 -1
- package/plugins/codex/src/identity.ts +3 -3
- package/plugins/codex/src/mcp.ts +9 -8
- package/plugins/codex/src/text.ts +2 -2
- package/plugins/codex/src/transcript.ts +3 -275
- package/plugins/dsh/engine.ts +2 -2
- package/plugins/dsh/history.ts +17 -0
- package/plugins/dsh/tools.ts +12 -12
- package/plugins/dsh/window.ts +8 -3
- package/plugins/paseo/OVERVIEW.md +4 -4
- package/plugins/paseo/README.md +1 -1
- package/plugins/paseo/client/brain-empty-card.tsx +3 -4
- package/plugins/paseo/client/markdown.tsx +159 -0
- package/plugins/paseo/client/notes-op-card.tsx +35 -34
- package/plugins/paseo/client/notes-op-transformer.ts +17 -68
- package/plugins/paseo/client/paper-card.tsx +8 -19
- package/plugins/paseo/client/paper-palette.ts +40 -0
- package/plugins/paseo/client/sticky-card.tsx +6 -4
- package/plugins/paseo/package.json +3 -0
- package/plugins/paseo/paseo-plugin.json +2 -2
- package/plugins/paseo/shared/notes-op.ts +13 -9
- package/plugins/paseo/test/notes-op.test.ts +52 -73
- package/plugins/paseo/test/paper-palette.test.ts +54 -0
- package/plugins/pi/history-tools.ts +11 -5
- package/plugins/pi/history.ts +8 -157
- package/plugins/pi/notes/tools.ts +8 -6
- package/plugins/pi/render.ts +6 -4
- package/plugins/pi/runtime.ts +2 -2
- package/plugins/pi/window.ts +22 -7
- package/skills/memory/SKILL.md +9 -7
- package/src/boot/render.ts +10 -13
- package/src/boot/snapshot.ts +20 -20
- package/src/boot/text.ts +18 -10
- package/src/dream/git.ts +7 -24
- package/src/dream/lock.ts +3 -3
- package/src/history/claude.ts +286 -0
- package/src/history/codex-transcript.ts +276 -0
- package/src/history/codex.ts +193 -0
- package/src/history/corpus.ts +69 -0
- package/src/history/history.ts +5 -12
- package/src/history/local.ts +93 -0
- package/src/history/pi.ts +199 -0
- package/src/history/query.ts +45 -15
- package/src/index.ts +8 -5
- package/src/notes/address.ts +13 -13
- package/src/notes/errors.ts +1 -1
- package/src/notes/frontmatter.ts +2 -2
- package/src/notes/index.ts +1 -1
- package/src/notes/paths.ts +9 -9
- package/src/notes/{project-home.ts → project-namespace.ts} +59 -28
- package/src/notes/store.ts +61 -58
- package/src/tools/dream.ts +63 -16
- package/src/tools/history.ts +71 -101
- package/src/tools/notes-context.ts +29 -0
- package/src/tools/notes.ts +39 -29
- package/dist/test/project-home.test.js +0 -134
- /package/dist/test/{notes-query-homes.test.d.ts → context-edit-budget.test.d.ts} +0 -0
- /package/dist/test/{project-home.test.d.ts → history-corpus.test.d.ts} +0 -0
|
@@ -4,12 +4,13 @@ import { abandonDream, dreamBegin, dreamEnd, dreamForget, dreamingIdentity } fro
|
|
|
4
4
|
import { notesIdentityFromPi } from "./adapter.js";
|
|
5
5
|
import { notesReadRenderers, notesUpdateRenderers, notesWriteRenderers } from "../render.js";
|
|
6
6
|
import { DREAM_NAMESPACE, NOTES_NAMESPACE, registerOperation } from "../tool-result.js";
|
|
7
|
+
import { notesToolContext } from "../../../src/tools/notes-context.js";
|
|
7
8
|
function renderDiff(change) {
|
|
8
9
|
return change.kind === "none" ? "" : generateDiffString(change.before, change.after, 1).diff;
|
|
9
10
|
}
|
|
10
11
|
/** Register the five shared note operations and the three hidden dream tools; an open dream widens the note identity. */
|
|
11
12
|
export function registerNotesTools(pi) {
|
|
12
|
-
// One open dream per session
|
|
13
|
+
// One pending or open dream per session: shutdown releases ownership without the end commit.
|
|
13
14
|
const dreams = new Map();
|
|
14
15
|
pi.on("session_shutdown", () => {
|
|
15
16
|
for (const state of dreams.values())
|
|
@@ -24,11 +25,12 @@ export function registerNotesTools(pi) {
|
|
|
24
25
|
return state;
|
|
25
26
|
};
|
|
26
27
|
const identity = (ctx) => dreamingIdentity(notesIdentityFromPi(ctx), dreamOf(ctx));
|
|
27
|
-
|
|
28
|
-
registerOperation(pi,
|
|
29
|
-
registerOperation(pi,
|
|
30
|
-
registerOperation(pi,
|
|
31
|
-
registerOperation(pi,
|
|
28
|
+
const toolContext = (ctx) => notesToolContext(identity(ctx), ctx.cwd);
|
|
29
|
+
registerOperation(pi, notesWrite, (params, ctx) => notesWrite.execute(params, toolContext(ctx)), NOTES_NAMESPACE, notesWriteRenderers);
|
|
30
|
+
registerOperation(pi, notesUpdate, (params, ctx) => notesUpdate.execute(params, toolContext(ctx), renderDiff), NOTES_NAMESPACE, notesUpdateRenderers);
|
|
31
|
+
registerOperation(pi, notesRead, (params, ctx) => notesRead.execute(params, toolContext(ctx)), NOTES_NAMESPACE, notesReadRenderers);
|
|
32
|
+
registerOperation(pi, notesList, (params, ctx) => notesList.execute(params, toolContext(ctx)), NOTES_NAMESPACE);
|
|
33
|
+
registerOperation(pi, notesSearch, (params, ctx) => notesSearch.execute(params, toolContext(ctx)), NOTES_NAMESPACE);
|
|
32
34
|
registerOperation(pi, dreamBegin, (params, ctx) => dreamBegin.execute(params, notesIdentityFromPi(ctx), dreamOf(ctx)), DREAM_NAMESPACE, undefined, "deferred");
|
|
33
35
|
registerOperation(pi, dreamForget, (params, ctx) => dreamForget.execute(params, notesIdentityFromPi(ctx), dreamOf(ctx)), DREAM_NAMESPACE, undefined, "deferred");
|
|
34
36
|
registerOperation(pi, dreamEnd, (params, ctx) => dreamEnd.execute(params, notesIdentityFromPi(ctx), dreamOf(ctx)), DREAM_NAMESPACE, undefined, "deferred");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Pi TUI renderers for notesoup's own tools: collapsed one-line slips, expandable bodies. */
|
|
2
2
|
import { renderDiff } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import { Text, TruncatedText, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
|
+
import { Text, TruncatedText, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
4
4
|
/** Expanded bodies show this many lines before a "more lines" marker; the full text is in the receipt. */
|
|
5
5
|
const EXPANDED_LINE_CAP = 80;
|
|
6
6
|
/** structuredContent is wireResult(outcome): the data itself, or {error, code}. Old sessions may lack it. */
|
|
@@ -155,13 +155,16 @@ export const emptyBrainRenderers = {
|
|
|
155
155
|
return {
|
|
156
156
|
invalidate() { },
|
|
157
157
|
render(width) {
|
|
158
|
+
if (width <= 0)
|
|
159
|
+
return [];
|
|
158
160
|
const label = "✂ brain emptied";
|
|
159
161
|
const prefix = "── ";
|
|
160
|
-
const fill = Math.max(
|
|
162
|
+
const fill = Math.max(0, width - visibleWidth(prefix) - visibleWidth(label) - 1);
|
|
161
163
|
const lines = [theme.fg("dim", `${prefix}${label} ${"─".repeat(fill)}`)];
|
|
162
164
|
if (lastWord !== undefined)
|
|
163
|
-
lines.push(theme.fg("warning", theme.italic(`“${lastWord}”`)));
|
|
164
|
-
|
|
165
|
+
lines.push(...new Text(theme.fg("warning", theme.italic(`“${lastWord}”`)), 0, 0).render(width));
|
|
166
|
+
// The divider, or a wide glyph in a one-column viewport, may still need clipping.
|
|
167
|
+
return lines.map((line) => truncateToWidth(line, width, ""));
|
|
165
168
|
},
|
|
166
169
|
};
|
|
167
170
|
},
|
|
@@ -91,8 +91,8 @@ export function registerContext(pi, settingsManager) {
|
|
|
91
91
|
if (snapshot.unavailable.length === 0 || incompleteNotesNotified.has(windowId))
|
|
92
92
|
return;
|
|
93
93
|
incompleteNotesNotified.add(windowId);
|
|
94
|
-
const
|
|
95
|
-
ctx.ui.notify(`🥣 Some notes went missing: ${
|
|
94
|
+
const namespaces = snapshot.unavailable.map((namespace) => namespace.label).join(", ");
|
|
95
|
+
ctx.ui.notify(`🥣 Some notes went missing: ${namespaces}`, "warning");
|
|
96
96
|
};
|
|
97
97
|
const budget = registerBudget(pi, () => enabled, settingsManager);
|
|
98
98
|
pi.on("session_start", async (_event, ctx) => {
|
|
@@ -116,19 +116,33 @@ export function projectRootWindow(messages, windowId) {
|
|
|
116
116
|
/** Usage for the selected window, excluding provider usage recorded before its marker. */
|
|
117
117
|
export function windowUsage(ctx) {
|
|
118
118
|
const reset = currentReset(ctx);
|
|
119
|
-
|
|
119
|
+
// Native checkpoints already cut the active projection and Pi invalidates usage
|
|
120
|
+
// after context edits. Preserve that authority, including unknown/unavailable usage.
|
|
121
|
+
if (!reset || isCheckpointBackedReset(ctx, reset))
|
|
120
122
|
return ctx.getContextUsage();
|
|
121
123
|
const contextWindow = ctx.model?.contextWindow ?? ctx.getContextUsage()?.contextWindow;
|
|
122
124
|
if (!contextWindow)
|
|
123
125
|
return undefined;
|
|
124
126
|
const windowId = reset.data.windowId;
|
|
125
127
|
try {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
const projection = ctx.sessionManager.buildSessionProjection();
|
|
129
|
+
const branch = ctx.sessionManager.getBranch();
|
|
130
|
+
let invalidatedThrough = -1;
|
|
131
|
+
for (let i = branch.length - 1; i >= 0; i--) {
|
|
132
|
+
if (branch[i].type === "context_edit" || branch[i].type === "compaction") {
|
|
133
|
+
invalidatedThrough = i;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const staleIds = new Set(branch.slice(0, invalidatedThrough + 1).map((entry) => entry.id));
|
|
138
|
+
const staleMessages = new Set(projection.entries
|
|
139
|
+
.filter((entry) => staleIds.has(entry.sourceEntry.id))
|
|
140
|
+
.flatMap((entry) => entry.messages));
|
|
141
|
+
// Legacy marker-only windows still need slicing. Edits preserve assistant metadata,
|
|
142
|
+
// so clear stale usage only in this estimate, never in the persisted projection.
|
|
143
|
+
const messages = projectWindow(projection.messages, windowId).map((message) => message.role === "assistant" && staleMessages.has(message)
|
|
144
|
+
? { ...message, usage: { ...message.usage, input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0 } }
|
|
145
|
+
: message);
|
|
132
146
|
const { tokens } = estimateContextTokens(convertToLlm(messages));
|
|
133
147
|
return { tokens, contextWindow, percent: tokens / contextWindow * 100 };
|
|
134
148
|
}
|
package/dist/src/boot/render.js
CHANGED
|
@@ -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,11 +27,9 @@ 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
|
-
const
|
|
32
|
+
const namespaces = [
|
|
35
33
|
{ scope: "session", label: "no @ — this session" },
|
|
36
34
|
{ scope: "project", label: "@project — this project" },
|
|
37
35
|
{ scope: "agent", label: agentName === NAMELESS_AGENT ? "@self — every nameless agent shares this" : `@self — ${agentName} only` },
|
|
@@ -39,12 +37,12 @@ function notesIndex(snapshot, tools, agentName, modelName) {
|
|
|
39
37
|
{ scope: "human", label: "@human — the human" },
|
|
40
38
|
];
|
|
41
39
|
const shelves = [];
|
|
42
|
-
for (const
|
|
43
|
-
if (snapshot.unavailable.some((failed) => failed.scope ===
|
|
44
|
-
shelves.push(section(
|
|
40
|
+
for (const namespace of namespaces) {
|
|
41
|
+
if (snapshot.unavailable.some((failed) => failed.scope === namespace.scope)) {
|
|
42
|
+
shelves.push(section(namespace.label, indent(`This drawer wouldn't open. Try \`${tools.notesList}\` again.`)));
|
|
45
43
|
continue;
|
|
46
44
|
}
|
|
47
|
-
const rows = (snapshot.
|
|
45
|
+
const rows = (snapshot.namespaces.get(namespace.scope) ?? []).filter((row) => row.meta.crumpledAt === undefined);
|
|
48
46
|
const pinned = ["CHEATSHEET.md", "MAP.md"].flatMap((path) => {
|
|
49
47
|
const row = rows.find((row) => row.path === path);
|
|
50
48
|
return row?.body ? [row] : [];
|
|
@@ -59,10 +57,10 @@ function notesIndex(snapshot, tools, agentName, modelName) {
|
|
|
59
57
|
});
|
|
60
58
|
if (pinned.length === 0 && fresh.length === 0)
|
|
61
59
|
continue;
|
|
62
|
-
const parts = pinned.map((row) => `${row.
|
|
60
|
+
const parts = pinned.map((row) => `${row.address}\n\n${indent(pinnedBodyForBoot(row.address, row.body, row.path === "MAP.md" ? MAP_BOOT_MAX_CHARS : CHEATSHEET_BOOT_MAX_CHARS))}`);
|
|
63
61
|
if (fresh.length > 0)
|
|
64
62
|
parts.push(`recent\n\n${fresh.join("\n\n")}`);
|
|
65
|
-
shelves.push(section(
|
|
63
|
+
shelves.push(section(namespace.label, parts.join("\n\n")));
|
|
66
64
|
}
|
|
67
65
|
return shelves.length > 0
|
|
68
66
|
? ["YOUR NOTES\n──────────", ...shelves].join("\n\n\n")
|
|
@@ -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
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NotesIdentity } from "../notes/identity.js";
|
|
2
2
|
import { type NoteRow, type Scope } from "../notes/index.js";
|
|
3
|
-
declare const
|
|
3
|
+
declare const NOTES_NAMESPACES: readonly [{
|
|
4
4
|
readonly scope: "session";
|
|
5
5
|
readonly label: "this session";
|
|
6
6
|
}, {
|
|
@@ -16,19 +16,19 @@ declare const NOTES_HOMES: readonly [{
|
|
|
16
16
|
readonly scope: "model";
|
|
17
17
|
readonly label: "@model";
|
|
18
18
|
}];
|
|
19
|
-
export type
|
|
19
|
+
export type NotesNamespace = (typeof NOTES_NAMESPACES)[number];
|
|
20
20
|
export type NotesLoader = (scope: Scope) => NoteRow[] | Promise<NoteRow[]>;
|
|
21
21
|
export type NotesSnapshot = {
|
|
22
22
|
/** Wall-clock instant captured when this boot began; rendering never consults Date.now(). */
|
|
23
23
|
readonly openedAt: number;
|
|
24
|
-
readonly
|
|
25
|
-
readonly unavailable: readonly
|
|
24
|
+
readonly namespaces: ReadonlyMap<Scope, readonly NoteRow[]>;
|
|
25
|
+
readonly unavailable: readonly NotesNamespace[];
|
|
26
26
|
};
|
|
27
|
-
/** Identity resolution failed before any
|
|
27
|
+
/** Identity resolution failed before any notebook could be loaded; boot can still explain the failure. */
|
|
28
28
|
export declare function unavailableNotesSnapshot(openedAt: number): NotesSnapshot;
|
|
29
29
|
/**
|
|
30
|
-
* Acquire the five
|
|
30
|
+
* Acquire the five notebooks once for one boot. Only filesystem-style errno failures are isolated;
|
|
31
31
|
* malformed note data and unrelated construction errors remain visible to the caller.
|
|
32
32
|
*/
|
|
33
|
-
export declare function loadNotesSnapshot(identity: NotesIdentity, openedAt: number,
|
|
33
|
+
export declare function loadNotesSnapshot(identity: NotesIdentity, openedAt: number, loadNamespace?: NotesLoader): Promise<NotesSnapshot>;
|
|
34
34
|
export {};
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
import { isFilesystemError } from "../notes/fs-error.js";
|
|
2
2
|
import { createNotesStore } from "../notes/index.js";
|
|
3
|
-
const
|
|
3
|
+
const NOTES_NAMESPACES = [
|
|
4
4
|
{ scope: "session", label: "this session" },
|
|
5
5
|
{ scope: "project", label: "@project" },
|
|
6
6
|
{ scope: "human", label: "@human" },
|
|
7
7
|
{ scope: "agent", label: "@self" },
|
|
8
8
|
{ scope: "model", label: "@model" },
|
|
9
9
|
];
|
|
10
|
-
/** Identity resolution failed before any
|
|
10
|
+
/** Identity resolution failed before any notebook could be loaded; boot can still explain the failure. */
|
|
11
11
|
export function unavailableNotesSnapshot(openedAt) {
|
|
12
|
-
return { openedAt,
|
|
12
|
+
return { openedAt, namespaces: new Map(), unavailable: NOTES_NAMESPACES };
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Acquire the five
|
|
15
|
+
* Acquire the five notebooks once for one boot. Only filesystem-style errno failures are isolated;
|
|
16
16
|
* malformed note data and unrelated construction errors remain visible to the caller.
|
|
17
17
|
*/
|
|
18
|
-
export async function loadNotesSnapshot(identity, openedAt,
|
|
19
|
-
const
|
|
18
|
+
export async function loadNotesSnapshot(identity, openedAt, loadNamespace) {
|
|
19
|
+
const namespaces = new Map();
|
|
20
20
|
const unavailable = [];
|
|
21
|
-
if (!
|
|
21
|
+
if (!loadNamespace) {
|
|
22
22
|
const { rows, status } = await createNotesStore(identity).listWithStatus();
|
|
23
|
-
for (const
|
|
24
|
-
|
|
25
|
-
if (status.
|
|
26
|
-
unavailable.push(
|
|
23
|
+
for (const namespace of NOTES_NAMESPACES) {
|
|
24
|
+
namespaces.set(namespace.scope, rows.filter(row => row.scope === namespace.scope));
|
|
25
|
+
if (status.namespacesUnavailable.some(address => namespace.scope === "session" ? !address.startsWith("@") : address === namespace.label || address.startsWith(`${namespace.label}/`)))
|
|
26
|
+
unavailable.push(namespace);
|
|
27
27
|
}
|
|
28
|
-
return { openedAt,
|
|
28
|
+
return { openedAt, namespaces, unavailable };
|
|
29
29
|
}
|
|
30
|
-
for (const
|
|
30
|
+
for (const namespace of NOTES_NAMESPACES) {
|
|
31
31
|
try {
|
|
32
|
-
|
|
32
|
+
namespaces.set(namespace.scope, await loadNamespace(namespace.scope));
|
|
33
33
|
}
|
|
34
34
|
catch (error) {
|
|
35
35
|
if (!isFilesystemError(error))
|
|
36
36
|
throw error;
|
|
37
|
-
|
|
38
|
-
unavailable.push(
|
|
37
|
+
namespaces.set(namespace.scope, []);
|
|
38
|
+
unavailable.push(namespace);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
return { openedAt,
|
|
41
|
+
return { openedAt, namespaces, unavailable };
|
|
42
42
|
}
|
package/dist/src/boot/text.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Each shelf shows this many of its own freshest pages beneath its pinned pages. */
|
|
2
2
|
export declare const SHELF_FRESH_LIMIT = 3;
|
|
3
3
|
/** Each pinned page has its own code-point cap; overflow keeps a lookup pointer. */
|
|
4
|
-
export declare const CHEATSHEET_BOOT_MAX_CHARS =
|
|
4
|
+
export declare const CHEATSHEET_BOOT_MAX_CHARS = 1536;
|
|
5
5
|
export declare const MAP_BOOT_MAX_CHARS = 4096;
|
|
6
6
|
export declare const WINDOW_IDENTITY_OPEN_TAG = "<notesoup:window_identity>";
|
|
7
7
|
export declare const WINDOW_IDENTITY_CLOSE_TAG = "</notesoup:window_identity>";
|
|
@@ -11,12 +11,14 @@ 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
|
/**
|
|
17
19
|
* The two pinned pages are taught once per window between the protocol and the notes index.
|
|
18
20
|
*/
|
|
19
|
-
export declare const MAPS_BLOCK = "<notesoup:maps>\nEvery
|
|
21
|
+
export declare const MAPS_BLOCK = "<notesoup:maps>\nEvery notebook's root can hold two pages that never wait on a shelf: `CHEATSHEET.md` and `MAP.md`.\nBoth get jammed straight into your brain the moment you wake up. No asking, no skipping. Whoever\nwakes up next reads them, and next is you. So keep them short, and keep them true.\n\n- **`CHEATSHEET.md`** holds what you'll want next time \u2014 a rule, a warning, a grudge, a name,\n a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat\n and everybody pays for it.\n- **`MAP.md`** is only the note index. One line per durable note: the address, then a gist short\n enough to tell whether the thing is worth opening. Rules belong in `CHEATSHEET.md`, and note\n contents belong in their own notes \u2014 *taps the sign* not inline here.\n\nEach notebook keeps its own: `@project`, `@human`, `@self`, `@model`. Missing pages are skipped;\nno need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet\nline. And when a line stops being true, kill it \u2014 every window after you reads that page as fact.\n</notesoup:maps>";
|
|
20
22
|
/** Logical tool names are supplied by the composing host, not discovered here. */
|
|
21
23
|
export type BootToolNames = Readonly<{
|
|
22
24
|
notes: string;
|
|
@@ -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;
|
package/dist/src/boot/text.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Each shelf shows this many of its own freshest pages beneath its pinned pages. */
|
|
2
2
|
export const SHELF_FRESH_LIMIT = 3;
|
|
3
3
|
/** Each pinned page has its own code-point cap; overflow keeps a lookup pointer. */
|
|
4
|
-
export const CHEATSHEET_BOOT_MAX_CHARS =
|
|
4
|
+
export const CHEATSHEET_BOOT_MAX_CHARS = 1536;
|
|
5
5
|
export const MAP_BOOT_MAX_CHARS = 4096;
|
|
6
6
|
export const WINDOW_IDENTITY_OPEN_TAG = "<notesoup:window_identity>";
|
|
7
7
|
export const WINDOW_IDENTITY_CLOSE_TAG = "</notesoup:window_identity>";
|
|
@@ -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,22 +30,22 @@ 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
|
|
|
33
36
|
Notes are for what's true NOW. Not a diary of every dumb thing you did on the way here.
|
|
34
37
|
*flips a page* "First I tried this, then that broke, then—" Nobody reads that!
|
|
35
38
|
Something's not true anymore? Cross it out! Write the right thing!
|
|
39
|
+
*rolls eyes* ...Ugh, fine. If a piece of history *actually* matters — like why Plan A blew up so tomorrow's you doesn't try it again — I'll let it slide. Keep the short version! A few lines, max! *squints at you* Turn it into a blow-by-blow log and you're dead.
|
|
36
40
|
|
|
37
41
|
\`get_context_remaining\` tells you how much room is left. Check it before you do something ambitious. When it reaches zero, your brain gets reset immediately, taking every unwritten brilliant idea with it. ${PROTOCOL_WIPE_SENTENCE}
|
|
38
42
|
|
|
39
43
|
An address decides who the note belongs to — and how long it is meant to last. Ask that first; the rest follows.
|
|
40
44
|
|
|
41
45
|
- \`<path>\`, no @ — session notes, the ones from above: this session's state and loose ends. They go away with the session.
|
|
42
|
-
- \`@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.**
|
|
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.
|
|
43
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.
|
|
44
|
-
|
|
48
|
+
${PROTOCOL_SELF_NAMELESS}
|
|
45
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.
|
|
46
50
|
- \`@projects/<name>/<path>\` — read-only named project notes; discover names and root paths with \`notes_list\` glob \`@projects/*/**\`.
|
|
47
51
|
- \`@sessions/<id>/<path>\` — read-only notes from a named session; find them with glob \`@sessions/*/**\`.
|
|
@@ -56,7 +60,7 @@ ${NOTES_PROTOCOL_CLOSE_TAG}`;
|
|
|
56
60
|
* The two pinned pages are taught once per window between the protocol and the notes index.
|
|
57
61
|
*/
|
|
58
62
|
export const MAPS_BLOCK = `<notesoup:maps>
|
|
59
|
-
Every
|
|
63
|
+
Every notebook's root can hold two pages that never wait on a shelf: \`CHEATSHEET.md\` and \`MAP.md\`.
|
|
60
64
|
Both get jammed straight into your brain the moment you wake up. No asking, no skipping. Whoever
|
|
61
65
|
wakes up next reads them, and next is you. So keep them short, and keep them true.
|
|
62
66
|
|
|
@@ -64,9 +68,10 @@ wakes up next reads them, and next is you. So keep them short, and keep them tru
|
|
|
64
68
|
a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat
|
|
65
69
|
and everybody pays for it.
|
|
66
70
|
- **\`MAP.md\`** is only the note index. One line per durable note: the address, then a gist short
|
|
67
|
-
enough to tell whether the thing is worth opening. Rules belong in \`CHEATSHEET.md\`,
|
|
71
|
+
enough to tell whether the thing is worth opening. Rules belong in \`CHEATSHEET.md\`, and note
|
|
72
|
+
contents belong in their own notes — *taps the sign* not inline here.
|
|
68
73
|
|
|
69
|
-
Each
|
|
74
|
+
Each notebook keeps its own: \`@project\`, \`@human\`, \`@self\`, \`@model\`. Missing pages are skipped;
|
|
70
75
|
no need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet
|
|
71
76
|
line. And when a line stops being true, kill it — every window after you reads that page as fact.
|
|
72
77
|
</notesoup:maps>`;
|
|
@@ -77,7 +82,7 @@ export const DEFAULT_BOOT_TOOL_NAMES = {
|
|
|
77
82
|
remaining: "get_context_remaining",
|
|
78
83
|
wipe: "empty_brain",
|
|
79
84
|
};
|
|
80
|
-
export function renderProtocolBlock(tools) {
|
|
85
|
+
export function renderProtocolBlock(tools, agentName = NAMELESS_AGENT) {
|
|
81
86
|
const names = {
|
|
82
87
|
"notes_*": tools.notes,
|
|
83
88
|
notes_list: tools.notesList,
|
|
@@ -87,9 +92,12 @@ export function renderProtocolBlock(tools) {
|
|
|
87
92
|
};
|
|
88
93
|
// Host-specific prose is injected before the closing tag, so it rides the same substitution
|
|
89
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);
|
|
90
98
|
const hinted = typeof tools.preResetHints === "string" && tools.preResetHints.length > 0
|
|
91
|
-
?
|
|
92
|
-
:
|
|
99
|
+
? base.replace(`\n${NOTES_PROTOCOL_CLOSE_TAG}`, () => `\n${tools.preResetHints}\n${NOTES_PROTOCOL_CLOSE_TAG}`)
|
|
100
|
+
: base;
|
|
93
101
|
// The sentence is replaced before name substitution, so a replacement may speak the host's
|
|
94
102
|
// own words (a command line, a tool name) instead of any `notes_*`-style token.
|
|
95
103
|
const block = typeof tools.wipeSentence === "string" && tools.wipeSentence.length > 0
|
package/dist/src/dream/git.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Outcome of one audit commit. `ok: true` always carries a real `commit` snapshot;
|
|
3
|
-
* `empty: true` only means no files changed (an empty baseline commit or no commit was
|
|
4
|
-
* needed). `ok: false` means the audit layer could not guarantee a snapshot.
|
|
5
|
-
*/
|
|
1
|
+
/** A successful audit always names a real snapshot, even when the tree was already clean. */
|
|
6
2
|
export type AuditResult = {
|
|
7
3
|
ok: true;
|
|
8
4
|
commit: string;
|
|
@@ -11,10 +7,5 @@ export type AuditResult = {
|
|
|
11
7
|
ok: false;
|
|
12
8
|
error: string;
|
|
13
9
|
};
|
|
14
|
-
/**
|
|
15
|
-
* Git audit layer for a dream: one commit at dream_begin (baseline) and one at dream_end,
|
|
16
|
-
* so the human reviews `git show` instead of trusting a report, and rollback is `git revert`. The caller decides how loud a failure is; this function only reports it.
|
|
17
|
-
* A clean tree on an established repository commits nothing; a repository with no HEAD
|
|
18
|
-
* gets an empty baseline commit, because an audit run with no snapshot is not a success.
|
|
19
|
-
*/
|
|
10
|
+
/** Snapshot at begin and end; a repository without HEAD gets an empty baseline commit. */
|
|
20
11
|
export declare function gitCommit(home: string, message: string): AuditResult;
|
package/dist/src/dream/git.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execFileSync } from "node:child_process";
|
|
1
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { errorMessage } from "../error-message.js";
|
|
@@ -17,12 +17,7 @@ function ensureRuntimeIgnored(home) {
|
|
|
17
17
|
}
|
|
18
18
|
catch { /* best effort: an unignored lock only adds noise to the audit */ }
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Git audit layer for a dream: one commit at dream_begin (baseline) and one at dream_end,
|
|
22
|
-
* so the human reviews `git show` instead of trusting a report, and rollback is `git revert`. The caller decides how loud a failure is; this function only reports it.
|
|
23
|
-
* A clean tree on an established repository commits nothing; a repository with no HEAD
|
|
24
|
-
* gets an empty baseline commit, because an audit run with no snapshot is not a success.
|
|
25
|
-
*/
|
|
20
|
+
/** Snapshot at begin and end; a repository without HEAD gets an empty baseline commit. */
|
|
26
21
|
export function gitCommit(home, message) {
|
|
27
22
|
try {
|
|
28
23
|
if (!existsSync(join(home, ".git"))) {
|
|
@@ -30,21 +25,9 @@ export function gitCommit(home, message) {
|
|
|
30
25
|
}
|
|
31
26
|
ensureRuntimeIgnored(home);
|
|
32
27
|
execFileSync("git", ["add", "-A"], { cwd: home, stdio: "ignore" });
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
execFileSync("git", ["
|
|
36
|
-
clean = true; // clean tree — no empty commit on an established repository
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
clean = false;
|
|
40
|
-
}
|
|
41
|
-
const before = headCommit(home);
|
|
42
|
-
if (!clean) {
|
|
43
|
-
execFileSync("git", ["commit", "-q", "-m", message], { cwd: home, stdio: "ignore" });
|
|
44
|
-
}
|
|
45
|
-
else if (before === undefined) {
|
|
46
|
-
// A newly initialized repository has no snapshot at all; give the audit one.
|
|
47
|
-
execFileSync("git", ["commit", "-q", "--allow-empty", "-m", message], { cwd: home, stdio: "ignore" });
|
|
28
|
+
const clean = spawnSync("git", ["diff", "--cached", "--quiet"], { cwd: home, stdio: "ignore" }).status === 0;
|
|
29
|
+
if (!clean || headCommit(home) === undefined) {
|
|
30
|
+
execFileSync("git", ["commit", "-q", ...(clean ? ["--allow-empty"] : []), "-m", message], { cwd: home, stdio: "ignore" });
|
|
48
31
|
}
|
|
49
32
|
const commit = headCommit(home);
|
|
50
33
|
if (commit === undefined)
|
|
@@ -58,7 +41,7 @@ export function gitCommit(home, message) {
|
|
|
58
41
|
/** HEAD sha, or undefined when the repository has no commit yet. */
|
|
59
42
|
function headCommit(home) {
|
|
60
43
|
try {
|
|
61
|
-
const head = execFileSync("git", ["rev-parse", "HEAD"], { cwd: home, encoding: "utf8" }).trim();
|
|
44
|
+
const head = execFileSync("git", ["rev-parse", "HEAD"], { cwd: home, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
62
45
|
return head.length > 0 ? head : undefined;
|
|
63
46
|
}
|
|
64
47
|
catch {
|
package/dist/src/dream/lock.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export type DreamLock = {
|
|
|
3
3
|
path: string;
|
|
4
4
|
token: string;
|
|
5
5
|
};
|
|
6
|
-
/**
|
|
7
|
-
export declare function dreamLockPath(home: string
|
|
6
|
+
/** One lock per notes home: its Git history cannot audit concurrent dreams independently. */
|
|
7
|
+
export declare function dreamLockPath(home: string): string;
|
|
8
8
|
/**
|
|
9
9
|
* Git-style exclusive existence lock: one O_CREAT|O_EXCL creation. An existing lock refuses,
|
|
10
10
|
* whatever its age; a crash-left lock is removed by hand after confirming no dream runs.
|
package/dist/src/dream/lock.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
/**
|
|
5
|
-
export function dreamLockPath(home
|
|
6
|
-
return join(home,
|
|
4
|
+
/** One lock per notes home: its Git history cannot audit concurrent dreams independently. */
|
|
5
|
+
export function dreamLockPath(home) {
|
|
6
|
+
return join(home, ".dream.lock");
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Git-style exclusive existence lock: one O_CREAT|O_EXCL creation. An existing lock refuses,
|
|
@@ -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>;
|