notesoup 0.53.2 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/plugins/claude/src/helper.js +2 -1
- 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 +2 -1
- package/dist/plugins/codex/src/text.d.ts +1 -1
- package/dist/plugins/codex/src/text.js +2 -2
- package/dist/plugins/dsh/engine.js +2 -2
- package/dist/plugins/dsh/tools.js +8 -7
- 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 +4 -4
- 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 +7 -7
- package/dist/src/boot/snapshot.d.ts +7 -7
- package/dist/src/boot/snapshot.js +17 -17
- package/dist/src/boot/text.d.ts +2 -2
- package/dist/src/boot/text.js +7 -5
- 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/index.d.ts +2 -1
- package/dist/src/index.js +3 -2
- 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/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 +1 -1
- package/dist/test/claude-mod.test.js +89 -43
- package/dist/test/codex-plugin.test.js +18 -1
- package/dist/test/context-edit-budget.test.js +121 -0
- package/dist/test/dependencies.test.js +71 -4
- package/dist/test/dream-tools.test.js +153 -8
- package/dist/test/dsh.test.js +62 -15
- 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 -0
- package/dist/test/helpers/extension.js +33 -2
- package/dist/test/host-neutral.test.js +17 -15
- package/dist/test/model-facing-text.test.js +12 -8
- 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 +72 -23
- package/dist/test/notes.test.js +50 -20
- 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 +12 -7
- package/docs/codex.md +4 -4
- package/docs/dsh.md +8 -8
- package/docs/notes-library.md +9 -5
- package/docs/skills.md +3 -3
- package/docs/tool-results.md +6 -2
- 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 +677 -615
- package/plugins/claude/hooks/register.ts +19 -11
- package/plugins/claude/playbook.md +6 -6
- package/plugins/claude/skills/memory/SKILL.md +4 -4
- package/plugins/claude/src/helper.ts +3 -2
- package/plugins/codex/README.md +1 -1
- package/plugins/codex/dist/codex/notesoup.js +877 -815
- package/plugins/codex/src/hooks.ts +1 -1
- package/plugins/codex/src/identity.ts +3 -3
- package/plugins/codex/src/mcp.ts +2 -1
- package/plugins/codex/src/text.ts +2 -2
- package/plugins/dsh/engine.ts +2 -2
- package/plugins/dsh/tools.ts +8 -7
- 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 +179 -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 +4 -4
- 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 +4 -4
- package/src/boot/render.ts +8 -8
- package/src/boot/snapshot.ts +20 -20
- package/src/boot/text.ts +7 -5
- package/src/dream/git.ts +7 -24
- package/src/dream/lock.ts +3 -3
- package/src/index.ts +4 -3
- 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/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 → notes-cwd.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ The old name is retired: `@astrosheep/pi-context` is deprecated, and the package
|
|
|
11
11
|
## Why not just compaction?
|
|
12
12
|
|
|
13
13
|
- **Reset ≠ summary.** Compaction is lossy compression you sit and wait for — and the next one summarizes the summary of the summary. A notesoup reset summarizes *nothing*: the window closes in O(1), because whatever mattered was already written to notes beforehand. Fast because there's nothing to compute; safe because the raw history never leaves disk.
|
|
14
|
-
- **Notes are files you can open.** Plain Markdown in `~/.agents/notes`, in named
|
|
14
|
+
- **Notes are files you can open.** Plain Markdown in `~/.agents/notes`, in named notebooks (`@project`, `@human`, `@self`, `@model`, plus per-session). Readable, editable, greppable, git-able. Not an encrypted blob — and not a secret the model is instructed to keep from you. (Yes, that was a real instruction. No, we didn't port it.)
|
|
15
15
|
- **History never forgets.** Every closed window — messages, tool calls, tool output — stays fully searchable through the `history_*` tools. Notes are the agent's lossy index; history is the lossless record underneath. This is the half the original experiment never shipped.
|
|
16
16
|
|
|
17
17
|
## Install
|
|
@@ -100,7 +100,7 @@ npm test # build from a clean dist, then run the suite
|
|
|
100
100
|
npm run typecheck
|
|
101
101
|
git diff --check
|
|
102
102
|
node scripts/check-notes-package.mjs # optional built /notes CRUD smoke; no install
|
|
103
|
-
npx tsx scripts/boot-smoke.mts [cwd] # optional live boot render against the real notes
|
|
103
|
+
npx tsx scripts/boot-smoke.mts [cwd] # optional live boot render against the real notes notebooks
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
The repository splits host-neutral code from host plugins:
|
|
@@ -10,6 +10,7 @@ import { selectContinuation } from "../../../src/budget/text.js";
|
|
|
10
10
|
import { claudeHistoryGapNotice, claudeHistoryUnconfirmedSeq, CLAUDE_HISTORY_UNKNOWN_PREVIOUS, CLAUDE_HISTORY_UNKNOWN_WINDOW, CLAUDE_HISTORY_UNAVAILABLE_SENTENCE, CLAUDE_WARNING_PROMPT } from "./text.js";
|
|
11
11
|
import { resolveClaudeLimits } from "./thresholds.js";
|
|
12
12
|
import { projectKey, snapshotNotesIdentity } from "../../../src/notes/index.js";
|
|
13
|
+
import { notesToolContext } from "../../../src/tools/notes-context.js";
|
|
13
14
|
const MAX_REQUEST_BYTES = 512 * 1024;
|
|
14
15
|
const MAX_RESPONSE_BYTES = 1024 * 1024;
|
|
15
16
|
function identity(input) {
|
|
@@ -115,7 +116,7 @@ export async function dispatch(request) {
|
|
|
115
116
|
: await HISTORY_OPERATIONS[tool].call(params, projection, wrapText);
|
|
116
117
|
return { ...result, text: wrapText(result.text) };
|
|
117
118
|
}
|
|
118
|
-
return OPERATIONS[value.tool].call(value.params, id);
|
|
119
|
+
return OPERATIONS[value.tool].call(value.params, notesToolContext(id, value.identity.cwd));
|
|
119
120
|
}
|
|
120
121
|
if (value.op === "history_state") {
|
|
121
122
|
const id = identity(value.identity);
|
|
@@ -27,7 +27,7 @@ export function bootWithinCap(boot) {
|
|
|
27
27
|
const bytes = Buffer.byteLength(boot, "utf8");
|
|
28
28
|
return bytes <= MAX_BOOT_BYTES
|
|
29
29
|
? undefined
|
|
30
|
-
: `notesoup: this window's boot is ${bytes} bytes, over the ${MAX_BOOT_BYTES}-byte cap. No truncated or spilled boot was injected; slim the
|
|
30
|
+
: `notesoup: this window's boot is ${bytes} bytes, over the ${MAX_BOOT_BYTES}-byte cap. No truncated or spilled boot was injected; slim the notebook MAPs and restart/resume the thread.`;
|
|
31
31
|
}
|
|
32
32
|
export async function readHookInput(stream) {
|
|
33
33
|
return await new Promise((resolveInput, reject) => {
|
|
@@ -23,7 +23,7 @@ export declare function safeThreadId(value: unknown, field?: string): string;
|
|
|
23
23
|
/** The portable server and the hook must share this root; Codex injects it into both. */
|
|
24
24
|
export declare function pluginDataRoot(env?: NodeJS.ProcessEnv): string;
|
|
25
25
|
export declare function notesHome(env?: NodeJS.ProcessEnv): string;
|
|
26
|
-
/** Native ids arrive provider-prefixed; @model is the last segment, slugged like every other
|
|
26
|
+
/** Native ids arrive provider-prefixed; @model is the last segment, slugged like every other notebook. */
|
|
27
27
|
export declare function modelSlug(value: unknown): string | undefined;
|
|
28
28
|
/** Validate every field before it becomes an identity; a corrupt binding never half-applies. */
|
|
29
29
|
export declare function readBinding(root: string, threadId: string): Promise<ThreadBinding>;
|
|
@@ -24,7 +24,7 @@ export function safeThreadId(value, field = "threadId") {
|
|
|
24
24
|
export function pluginDataRoot(env = process.env) {
|
|
25
25
|
const value = env.PLUGIN_DATA;
|
|
26
26
|
if (typeof value !== "string" || value.trim() === "" || !isAbsolute(value)) {
|
|
27
|
-
throw new CodexIdentityError("missing_plugin_data", "PLUGIN_DATA is unavailable. Install notesoup as a Codex plugin (or set PLUGIN_DATA for a standalone test) so hook bindings have one mutable
|
|
27
|
+
throw new CodexIdentityError("missing_plugin_data", "PLUGIN_DATA is unavailable. Install notesoup as a Codex plugin (or set PLUGIN_DATA for a standalone test) so hook bindings have one mutable data directory.");
|
|
28
28
|
}
|
|
29
29
|
return resolve(value);
|
|
30
30
|
}
|
|
@@ -32,7 +32,7 @@ export function notesHome(env = process.env) {
|
|
|
32
32
|
const value = env.NOTESOUP_HOME;
|
|
33
33
|
return value !== undefined && value.trim() !== "" ? resolve(value) : join(homedir(), ".agents", "notes");
|
|
34
34
|
}
|
|
35
|
-
/** Native ids arrive provider-prefixed; @model is the last segment, slugged like every other
|
|
35
|
+
/** Native ids arrive provider-prefixed; @model is the last segment, slugged like every other notebook. */
|
|
36
36
|
export function modelSlug(value) {
|
|
37
37
|
if (typeof value !== "string")
|
|
38
38
|
return undefined;
|
|
@@ -126,7 +126,7 @@ export function turnModel(meta) {
|
|
|
126
126
|
const model = typeof value === "object" && value !== null ? value.model : undefined;
|
|
127
127
|
const slug = modelSlug(model);
|
|
128
128
|
if (slug === undefined)
|
|
129
|
-
throw new CodexIdentityError("missing_model", "Codex did not supply this turn's model in MCP metadata, so notesoup cannot choose an @model
|
|
129
|
+
throw new CodexIdentityError("missing_model", "Codex did not supply this turn's model in MCP metadata, so notesoup cannot choose an @model notebook. Update Codex, or call notes from a model turn.");
|
|
130
130
|
return slug;
|
|
131
131
|
}
|
|
132
132
|
export function rootSessionIdOf(meta) {
|
|
@@ -9,6 +9,7 @@ import { wireResult } from "../../../src/tools/result.js";
|
|
|
9
9
|
import { CodexIdentityError, notesIdentityFor, pluginDataRoot, readBinding, rootSessionIdOf, safeThreadId, turnModel } from "./identity.js";
|
|
10
10
|
import { readCodexHistory } from "./history.js";
|
|
11
11
|
import { readStartState } from "./state.js";
|
|
12
|
+
import { notesToolContext } from "../../../src/tools/notes-context.js";
|
|
12
13
|
const OPERATIONS = {
|
|
13
14
|
notes_write: { operation: notesWrite, history: false },
|
|
14
15
|
notes_update: { operation: notesUpdate, history: false },
|
|
@@ -119,7 +120,7 @@ export async function callTool(name, args, meta, env = process.env) {
|
|
|
119
120
|
const { binding, rootSessionId, model } = await identityFor(meta, env);
|
|
120
121
|
const native = await readNative(binding, rootSessionId, bound.history, meta, env);
|
|
121
122
|
if (!bound.history) {
|
|
122
|
-
const outcome = await bound.operation.execute(params, notesIdentityFor(binding, model));
|
|
123
|
+
const outcome = await bound.operation.execute(params, notesToolContext(notesIdentityFor(binding, model), binding.cwd));
|
|
123
124
|
return successFor(bound, outcome);
|
|
124
125
|
}
|
|
125
126
|
const projection = native.projection;
|
|
@@ -10,5 +10,5 @@ export declare const CODEX_PRE_RESET_HINTS: string;
|
|
|
10
10
|
export declare const CODEX_SETUP_HINT = "Enable and trust the notesoup plugin in Codex, then start or resume the thread. notesoup binds identities from hooks and never from the MCP server's cwd.";
|
|
11
11
|
export declare function unsupportedChildCompaction(): string;
|
|
12
12
|
export declare function missingNativeFacts(reason: string): string;
|
|
13
|
-
/** A boot can still identify itself when the note store itself refused; it must not pretend
|
|
13
|
+
/** A boot can still identify itself when the note store itself refused; it must not pretend notebooks are empty. */
|
|
14
14
|
export declare function notesFailureBoot(reason: string): string;
|
|
@@ -19,7 +19,7 @@ export function unsupportedChildCompaction() {
|
|
|
19
19
|
export function missingNativeFacts(reason) {
|
|
20
20
|
return `notesoup: no boot injected because Codex's native window facts could not be read (${reason}). ${CODEX_SETUP_HINT} notesoup supports Codex 0.160.1 transcripts.`;
|
|
21
21
|
}
|
|
22
|
-
/** A boot can still identify itself when the note store itself refused; it must not pretend
|
|
22
|
+
/** A boot can still identify itself when the note store itself refused; it must not pretend notebooks are empty. */
|
|
23
23
|
export function notesFailureBoot(reason) {
|
|
24
|
-
return `notesoup: your notes did not load this time (${reason}). Try the notes_list tool; if it fails too, tell the human. Do not assume a
|
|
24
|
+
return `notesoup: your notes did not load this time (${reason}). Try the notes_list tool; if it fails too, tell the human. Do not assume a notebook is empty from this failure.`;
|
|
25
25
|
}
|
|
@@ -142,8 +142,8 @@ export class NotesoupCompactionEngine extends CompactionEngine {
|
|
|
142
142
|
const next = await this.windows.mint(agent, previous.window + 1, opened.time);
|
|
143
143
|
signal?.throwIfAborted();
|
|
144
144
|
if (session.surface.contentGeneration !== generation || session.surface.nodes.length !== shadowedSeqs.length + 1)
|
|
145
|
-
throw new ManualCompactionError("changed", "notesoup: the surface changed while opening the next
|
|
146
|
-
// Mint BEFORE writing the checkpoint. A rejected append restores the previous
|
|
145
|
+
throw new ManualCompactionError("changed", "notesoup: the surface changed while opening the next page; retry after current work finishes.");
|
|
146
|
+
// Mint BEFORE writing the checkpoint. A rejected append restores the previous page.
|
|
147
147
|
// One draw per reset artifact: the checkpoint text and the steered copy share it.
|
|
148
148
|
const continuation = selectContinuation(origin);
|
|
149
149
|
state.snapshot = next;
|
|
@@ -5,7 +5,8 @@ import { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "../.
|
|
|
5
5
|
import { historyList, historyRead, historyWindows } from "../../src/tools/history.js";
|
|
6
6
|
import { success } from "../../src/tools/result.js";
|
|
7
7
|
import { historyProjection } from "./history.js";
|
|
8
|
-
import { notesIdentity } from "./window.js";
|
|
8
|
+
import { notesCwd, notesIdentity } from "./window.js";
|
|
9
|
+
import { notesToolContext } from "../../src/tools/notes-context.js";
|
|
9
10
|
import { measureBudget } from "./budget.js";
|
|
10
11
|
import { preflight } from "./engine.js";
|
|
11
12
|
/** dsh enforces a small schema subset; TypeBox remains the full validator at execution. */
|
|
@@ -75,12 +76,12 @@ export function registerTools(ctx, engine) {
|
|
|
75
76
|
if (!exec.parent && nestedResets.get(exec.agent)?.delete(exec.rootCallId) && !result.isError)
|
|
76
77
|
state.pendingReset = true;
|
|
77
78
|
});
|
|
78
|
-
const
|
|
79
|
-
register(ctx, notesWrite, (agent) => [
|
|
80
|
-
register(ctx, notesUpdate, (agent) => [
|
|
81
|
-
register(ctx, notesRead, (agent) => [
|
|
82
|
-
register(ctx, notesList, (agent) => [
|
|
83
|
-
register(ctx, notesSearch, (agent) => [
|
|
79
|
+
const toolContext = (agent) => notesToolContext(notesIdentity(agent, engine.config), notesCwd(agent));
|
|
80
|
+
register(ctx, notesWrite, (agent) => [toolContext(agent)]);
|
|
81
|
+
register(ctx, notesUpdate, (agent) => [toolContext(agent)]);
|
|
82
|
+
register(ctx, notesRead, (agent) => [toolContext(agent)]);
|
|
83
|
+
register(ctx, notesList, (agent) => [toolContext(agent)]);
|
|
84
|
+
register(ctx, notesSearch, (agent) => [toolContext(agent)]);
|
|
84
85
|
register(ctx, historyList, async (agent) => [await historyProjection(ctx, agent.session.id)]);
|
|
85
86
|
register(ctx, historyRead, async (agent) => [await historyProjection(ctx, agent.session.id)]);
|
|
86
87
|
register(ctx, historyWindows, async (agent) => [await historyProjection(ctx, agent.session.id), agent.session.id]);
|
|
@@ -34,6 +34,7 @@ export declare function recordSnapshot(event: SessionEvent): WindowSnapshot | un
|
|
|
34
34
|
/** The checkpoint is authoritative when an ignorable record was lost or the transaction's close failed. */
|
|
35
35
|
export declare function checkpointSnapshot(event: SessionEvent): WindowSnapshot | undefined;
|
|
36
36
|
export declare function recoverSnapshot(events: readonly SessionEvent[]): WindowSnapshot | undefined;
|
|
37
|
+
export declare function notesCwd(agent: Pick<Agent, "session" | "options">): string;
|
|
37
38
|
/** Identity is extracted here, never in the filesystem domain. */
|
|
38
39
|
export declare function notesIdentity(agent: Pick<Agent, "session" | "options">, config: NotesConfig): NotesIdentity;
|
|
39
40
|
/** Engine-owned, per-session state; prompt reads are synchronous and never read notes again. */
|
|
@@ -79,13 +79,16 @@ export function recoverSnapshot(events) {
|
|
|
79
79
|
}
|
|
80
80
|
return latest;
|
|
81
81
|
}
|
|
82
|
+
export function notesCwd(agent) {
|
|
83
|
+
return agent.session.header.cwd ?? process.cwd();
|
|
84
|
+
}
|
|
82
85
|
/** Identity is extracted here, never in the filesystem domain. */
|
|
83
86
|
export function notesIdentity(agent, config) {
|
|
84
87
|
const home = config.notesHome ?? join(homedir(), ".agents", "notes");
|
|
85
88
|
return snapshotNotesIdentity({
|
|
86
89
|
home,
|
|
87
90
|
sessionId: agent.session.id,
|
|
88
|
-
projectKey: projectKey(agent
|
|
91
|
+
projectKey: projectKey(notesCwd(agent), home),
|
|
89
92
|
agent: slugify(config.agentName ?? "dsh"),
|
|
90
93
|
model: slugify(agent.session.requestHeader()?.config.model ?? agent.options.model ?? "unknown"),
|
|
91
94
|
});
|
|
@@ -108,9 +111,10 @@ export class Windows {
|
|
|
108
111
|
if (existing)
|
|
109
112
|
return existing;
|
|
110
113
|
const restored = recoverSnapshot(agent.session.snapshotEvents());
|
|
111
|
-
const
|
|
114
|
+
const sameSession = restored !== undefined && restored.windowId === windowId(agent.session.id, restored.window);
|
|
115
|
+
const snapshot = sameSession ? restored : await this.mint(agent, restored?.window ?? 0, agent.session.header.createdAt);
|
|
112
116
|
signal?.throwIfAborted();
|
|
113
|
-
if (!
|
|
117
|
+
if (!sameSession)
|
|
114
118
|
appendPluginRecord(agent.session, WINDOW_RECORD, snapshot);
|
|
115
119
|
const state = { snapshot, pendingReset: false, warned: false, reminded: false };
|
|
116
120
|
restoreWarnings(state, agent.session.snapshotEvents());
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
/** Register the three
|
|
2
|
+
/** Register the three deferred history operations; the adapter allocates addresses and supplies them. */
|
|
3
3
|
export declare function registerHistoryTools(pi: ExtensionAPI): void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { historyWindows, historyList, historyRead } from "../../src/tools/history.js";
|
|
2
2
|
import { historyFromSession } from "./history.js";
|
|
3
3
|
import { HISTORY_NAMESPACE, registerOperation } from "./tool-result.js";
|
|
4
|
-
/** Register the three
|
|
4
|
+
/** Register the three deferred history operations; the adapter allocates addresses and supplies them. */
|
|
5
5
|
export function registerHistoryTools(pi) {
|
|
6
|
-
registerOperation(pi, historyWindows, (params, ctx) => historyWindows.execute(params, historyFromSession(ctx), ctx.sessionManager.getSessionId()), HISTORY_NAMESPACE);
|
|
7
|
-
registerOperation(pi, historyList, (params, ctx) => historyList.execute(params, historyFromSession(ctx)), HISTORY_NAMESPACE);
|
|
8
|
-
registerOperation(pi, historyRead, (params, ctx) => historyRead.execute(params, historyFromSession(ctx)), HISTORY_NAMESPACE);
|
|
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");
|
|
9
9
|
}
|
|
@@ -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
|
@@ -31,7 +31,7 @@ function section(label, body) {
|
|
|
31
31
|
const NAMELESS_AGENT = "anonymous";
|
|
32
32
|
/** One closed boot snapshot: five tabbed shelves, current hands first, durable last; each shelf keeps its pinned pages and its own freshest pages. */
|
|
33
33
|
function notesIndex(snapshot, tools, agentName, modelName) {
|
|
34
|
-
const
|
|
34
|
+
const namespaces = [
|
|
35
35
|
{ scope: "session", label: "no @ — this session" },
|
|
36
36
|
{ scope: "project", label: "@project — this project" },
|
|
37
37
|
{ scope: "agent", label: agentName === NAMELESS_AGENT ? "@self — every nameless agent shares this" : `@self — ${agentName} only` },
|
|
@@ -39,12 +39,12 @@ function notesIndex(snapshot, tools, agentName, modelName) {
|
|
|
39
39
|
{ scope: "human", label: "@human — the human" },
|
|
40
40
|
];
|
|
41
41
|
const shelves = [];
|
|
42
|
-
for (const
|
|
43
|
-
if (snapshot.unavailable.some((failed) => failed.scope ===
|
|
44
|
-
shelves.push(section(
|
|
42
|
+
for (const namespace of namespaces) {
|
|
43
|
+
if (snapshot.unavailable.some((failed) => failed.scope === namespace.scope)) {
|
|
44
|
+
shelves.push(section(namespace.label, indent(`This drawer wouldn't open. Try \`${tools.notesList}\` again.`)));
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
47
|
-
const rows = (snapshot.
|
|
47
|
+
const rows = (snapshot.namespaces.get(namespace.scope) ?? []).filter((row) => row.meta.crumpledAt === undefined);
|
|
48
48
|
const pinned = ["CHEATSHEET.md", "MAP.md"].flatMap((path) => {
|
|
49
49
|
const row = rows.find((row) => row.path === path);
|
|
50
50
|
return row?.body ? [row] : [];
|
|
@@ -59,10 +59,10 @@ function notesIndex(snapshot, tools, agentName, modelName) {
|
|
|
59
59
|
});
|
|
60
60
|
if (pinned.length === 0 && fresh.length === 0)
|
|
61
61
|
continue;
|
|
62
|
-
const parts = pinned.map((row) => `${row.
|
|
62
|
+
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
63
|
if (fresh.length > 0)
|
|
64
64
|
parts.push(`recent\n\n${fresh.join("\n\n")}`);
|
|
65
|
-
shelves.push(section(
|
|
65
|
+
shelves.push(section(namespace.label, parts.join("\n\n")));
|
|
66
66
|
}
|
|
67
67
|
return shelves.length > 0
|
|
68
68
|
? ["YOUR NOTES\n──────────", ...shelves].join("\n\n\n")
|
|
@@ -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>";
|
|
@@ -16,7 +16,7 @@ export declare const PROTOCOL_HISTORY_SENTENCE = "History can still be dug up, p
|
|
|
16
16
|
/**
|
|
17
17
|
* The two pinned pages are taught once per window between the protocol and the notes index.
|
|
18
18
|
*/
|
|
19
|
-
export declare const MAPS_BLOCK = "<notesoup:maps>\nEvery
|
|
19
|
+
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
20
|
/** Logical tool names are supplied by the composing host, not discovered here. */
|
|
21
21
|
export type BootToolNames = Readonly<{
|
|
22
22
|
notes: 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>";
|
|
@@ -33,13 +33,14 @@ While you're doing that... thing you're doing, don't make the poor future you gu
|
|
|
33
33
|
Notes are for what's true NOW. Not a diary of every dumb thing you did on the way here.
|
|
34
34
|
*flips a page* "First I tried this, then that broke, then—" Nobody reads that!
|
|
35
35
|
Something's not true anymore? Cross it out! Write the right thing!
|
|
36
|
+
*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
37
|
|
|
37
38
|
\`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
39
|
|
|
39
40
|
An address decides who the note belongs to — and how long it is meant to last. Ask that first; the rest follows.
|
|
40
41
|
|
|
41
42
|
- \`<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.**
|
|
43
|
+
- \`@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
44
|
- \`@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
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~
|
|
45
46
|
- \`@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.
|
|
@@ -56,7 +57,7 @@ ${NOTES_PROTOCOL_CLOSE_TAG}`;
|
|
|
56
57
|
* The two pinned pages are taught once per window between the protocol and the notes index.
|
|
57
58
|
*/
|
|
58
59
|
export const MAPS_BLOCK = `<notesoup:maps>
|
|
59
|
-
Every
|
|
60
|
+
Every notebook's root can hold two pages that never wait on a shelf: \`CHEATSHEET.md\` and \`MAP.md\`.
|
|
60
61
|
Both get jammed straight into your brain the moment you wake up. No asking, no skipping. Whoever
|
|
61
62
|
wakes up next reads them, and next is you. So keep them short, and keep them true.
|
|
62
63
|
|
|
@@ -64,9 +65,10 @@ wakes up next reads them, and next is you. So keep them short, and keep them tru
|
|
|
64
65
|
a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat
|
|
65
66
|
and everybody pays for it.
|
|
66
67
|
- **\`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\`,
|
|
68
|
+
enough to tell whether the thing is worth opening. Rules belong in \`CHEATSHEET.md\`, and note
|
|
69
|
+
contents belong in their own notes — *taps the sign* not inline here.
|
|
68
70
|
|
|
69
|
-
Each
|
|
71
|
+
Each notebook keeps its own: \`@project\`, \`@human\`, \`@self\`, \`@model\`. Missing pages are skipped;
|
|
70
72
|
no need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet
|
|
71
73
|
line. And when a line stops being true, kill it — every window after you reads that page as fact.
|
|
72
74
|
</notesoup:maps>`;
|
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;
|