notesoup 0.57.4 → 0.58.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 +15 -1
- package/dist/plugins/claude/src/helper.js +2 -11
- package/dist/plugins/claude/src/thresholds.js +23 -43
- package/dist/plugins/codex/src/mcp.js +3 -11
- package/dist/plugins/codex/src/state.d.ts +1 -1
- package/dist/plugins/codex/src/state.js +1 -1
- package/dist/plugins/dsh/tools.js +1 -1
- package/dist/plugins/pi/boot.d.ts +1 -1
- package/dist/plugins/pi/boot.js +2 -3
- package/dist/plugins/pi/budget.d.ts +1 -1
- package/dist/plugins/pi/budget.js +1 -1
- package/dist/plugins/pi/render.d.ts +1 -1
- package/dist/plugins/pi/render.js +20 -11
- package/dist/plugins/pi/runtime.js +6 -2
- package/dist/plugins/pi/tool-result.d.ts +2 -1
- package/dist/plugins/pi/window.js +24 -1
- package/dist/src/boot/render.d.ts +3 -4
- package/dist/src/boot/render.js +23 -21
- package/dist/src/boot/text.d.ts +2 -5
- package/dist/src/boot/text.js +12 -9
- package/dist/src/budget/text.d.ts +1 -1
- package/dist/src/budget/text.js +1 -1
- package/dist/src/history/corpus.d.ts +1 -1
- package/dist/src/history/corpus.js +1 -1
- package/dist/src/history/history.d.ts +2 -2
- package/dist/src/history/history.js +5 -8
- package/dist/src/history/query.d.ts +11 -3
- package/dist/src/history/query.js +7 -11
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.js +1 -1
- package/dist/src/notes/constants.d.ts +1 -1
- package/dist/src/notes/constants.js +1 -1
- package/dist/src/notes/errors.d.ts +1 -1
- package/dist/src/notes/frontmatter.d.ts +2 -1
- package/dist/src/notes/frontmatter.js +3 -1
- package/dist/src/notes/index.d.ts +1 -0
- package/dist/src/notes/index.js +1 -0
- package/dist/src/notes/policy.d.ts +16 -0
- package/dist/src/notes/policy.js +43 -0
- package/dist/src/notes/store.d.ts +7 -2
- package/dist/src/notes/store.js +61 -19
- package/dist/src/result.d.ts +21 -0
- package/dist/src/result.js +18 -0
- package/dist/src/text-match.d.ts +8 -0
- package/dist/src/text-match.js +34 -0
- package/dist/src/tools/dream.d.ts +9 -1
- package/dist/src/tools/dream.js +2 -1
- package/dist/src/tools/history.js +14 -5
- package/dist/src/tools/notes.d.ts +75 -13
- package/dist/src/tools/notes.js +58 -19
- package/dist/src/tools/output.d.ts +1 -3
- package/dist/src/tools/output.js +1 -19
- package/dist/src/tools/result.d.ts +2 -20
- package/dist/src/tools/result.js +4 -18
- package/dist/src/tools/schema.d.ts +3 -7
- package/dist/src/tools/schema.js +10 -16
- package/dist/test/agent-loop.test.js +78 -6
- package/dist/test/boot.integration.test.js +30 -3
- package/dist/test/claude-mod.test.js +101 -16
- package/dist/test/codex-history.test.js +2 -2
- package/dist/test/codex-plugin.test.js +2 -0
- package/dist/test/dependencies.test.js +38 -3
- package/dist/test/dsh.test.js +1 -1
- package/dist/test/helpers/dependency-graph.js +12 -6
- package/dist/test/helpers/extension.d.ts +2 -1
- package/dist/test/history.integration.test.js +47 -1
- package/dist/test/host-neutral.test.js +4 -3
- package/dist/test/model-facing-text.test.js +20 -16
- package/dist/test/note-policy.test.d.ts +1 -0
- package/dist/test/note-policy.test.js +227 -0
- package/dist/test/notes.integration.test.js +9 -9
- package/dist/test/notes.test.js +4 -4
- package/dist/test/pi-render.test.js +28 -1
- package/dist/test/project-namespace.test.js +1 -1
- package/docs/architecture.md +10 -7
- package/docs/claude-code-mod.md +3 -3
- package/docs/dsh.md +1 -1
- package/docs/notes-library.md +19 -6
- package/docs/reset-lifecycle.md +2 -2
- package/docs/tool-results.md +3 -1
- package/package.json +12 -12
- package/playbook.md +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +535 -439
- package/plugins/claude/hooks/register.ts +26 -36
- package/plugins/claude/playbook.md +1 -1
- package/plugins/claude/skills/dream/SKILL.md +1 -1
- package/plugins/claude/skills/memory/SKILL.md +1 -1
- package/plugins/claude/src/helper.ts +2 -11
- package/plugins/claude/src/thresholds.ts +22 -42
- package/plugins/codex/dist/codex/notesoup.js +519 -403
- package/plugins/codex/src/mcp.ts +5 -12
- package/plugins/codex/src/state.ts +1 -1
- package/plugins/dsh/tools.ts +2 -1
- package/plugins/pi/boot.ts +3 -4
- package/plugins/pi/budget.ts +1 -1
- package/plugins/pi/render.ts +20 -8
- package/plugins/pi/runtime.ts +6 -2
- package/plugins/pi/tool-result.ts +2 -1
- package/plugins/pi/window.ts +20 -1
- package/skills/dream/SKILL.md +1 -1
- package/skills/memory/SKILL.md +1 -1
- package/src/boot/render.ts +24 -21
- package/src/boot/text.ts +12 -9
- package/src/budget/text.ts +1 -1
- package/src/history/corpus.ts +1 -1
- package/src/history/history.ts +5 -6
- package/src/history/query.ts +11 -14
- package/src/index.ts +5 -2
- package/src/notes/constants.ts +1 -1
- package/src/notes/errors.ts +1 -1
- package/src/notes/frontmatter.ts +4 -2
- package/src/notes/index.ts +1 -0
- package/src/notes/policy.ts +49 -0
- package/src/notes/store.ts +63 -24
- package/src/result.ts +26 -0
- package/src/text-match.ts +32 -0
- package/src/tools/dream.ts +2 -1
- package/src/tools/history.ts +15 -6
- package/src/tools/notes.ts +60 -20
- package/src/tools/output.ts +1 -17
- package/src/tools/result.ts +4 -26
- package/src/tools/schema.ts +11 -17
- package/dist/plugins/codex/src/history.d.ts +0 -3
- package/dist/plugins/codex/src/history.js +0 -2
- package/dist/plugins/codex/src/transcript.d.ts +0 -3
- package/dist/plugins/codex/src/transcript.js +0 -2
- package/plugins/codex/src/history.ts +0 -3
- package/plugins/codex/src/transcript.ts +0 -3
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ pi -e npm:notesoup
|
|
|
29
29
|
## What you get
|
|
30
30
|
|
|
31
31
|
- **Durable context windows.** `/fresh-window` (alias `/empty`) clears and stops, with any command text available for close-out notes. Separate human input received during emptying continues in the fresh window. The model can also request a window itself with `empty_brain`, and a budget close-out fires automatically before the window runs out. Abort and ordinary errors never count as completion; the raw conversation stays in the session, just out of the next context.
|
|
32
|
-
- **A boot block at every window head.**
|
|
32
|
+
- **A boot block at every window head.** Pi keeps the window identity and notes snapshot in a hidden user-role boot; its fixed recovery protocol and pinned-page teaching live in a named system section. Every note body, including `@human` pins, stays user-role data. Claude, Codex and dsh keep their existing combined boot injection.
|
|
33
33
|
- **`get_context_remaining`** — how much room the brain has left before the hard-reserve wipe, including the warning runway.
|
|
34
34
|
- **Seven history/notes tools**, flattened from the original Codex actions:
|
|
35
35
|
|
|
@@ -51,6 +51,20 @@ pi -e npm:notesoup
|
|
|
51
51
|
|
|
52
52
|
- **Runtime toggle** — `/notesoup off` stops new automatic resets; `/notesoup on` re-enables them; bare `/notesoup` reports the state.
|
|
53
53
|
|
|
54
|
+
## Per-note policy
|
|
55
|
+
|
|
56
|
+
Notes have optional `pinned`, `budget`, and `readonly` frontmatter fields, also settable through `notes_write` and `notes_update`:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{ "address": "@project/decisions.md", "pinned": true, "budget": 3000, "readonly": false }
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- **Pinned** notes are injected **in full** at boot. Root `CHEATSHEET.md` and `MAP.md` default to pinned; every other page defaults to unpinned. Explicit `pinned: false` overrides even a default page. Each notebook allows **five live pins**, including its existing default pages; crumpled notes do not count. A sixth pin, restore or move that exceeds the cap refuses without changing either note. Manually over-cap notebooks get a boot warning naming the omitted pins, with default pages shown first.
|
|
63
|
+
- **Budget** defaults to **2048 Unicode code points for every page**, including CHEATSHEET and MAP. Any positive safe integer is allowed. Over-budget writes and updates succeed with a visible warning; pinned bodies are never truncated to their budget. This advisory budget is separate from the existing hard serialized-file byte limit. Tool results/read metadata/list/search expose effective policy and budget warnings.
|
|
64
|
+
- **Readonly** defaults to false. `readonly: true` is a **soft lock**, not security: mutations refuse until explicitly unlocked with `readonly: false`, either by itself or in the same call as the requested changes. A write can create and lock a note together. Reads still record access metadata; direct filesystem edits can bypass the lock.
|
|
65
|
+
|
|
66
|
+
Absent fields stay absent on disk. On move/rename, implicit pin defaults follow the new root path; explicit true/false values travel with the note. The original origin, other metadata, and unknown frontmatter are preserved. See the [library API](docs/notes-library.md#per-note-policy) for details.
|
|
67
|
+
|
|
54
68
|
## Configuration
|
|
55
69
|
|
|
56
70
|
Pi budget settings live under the top-level `notesoup` key in `~/.pi/agent/settings.json` or `<cwd>/.pi/settings.json`. Trusted project values win **per key**: a project override of `reserveTokens` still inherits a global `warningRunwayTokens`. Each value must be a positive safe integer (numeric strings are also accepted). An absent value uses its fallback; an invalid value emits a warning and uses that same fallback, not a lower-precedence global value.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { realpathSync } from "node:fs";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
|
-
import { Check
|
|
3
|
+
import { Check } from "typebox/value";
|
|
4
|
+
import { paramProblem } from "../../../src/tools/schema.js";
|
|
4
5
|
import { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "../../../src/tools/notes.js";
|
|
5
6
|
import { historyList, historyRead } from "../../../src/tools/history.js";
|
|
6
7
|
import { localHistoryCorpus } from "../../../src/history/local.js";
|
|
@@ -19,16 +20,6 @@ function identity(input) {
|
|
|
19
20
|
throw new Error("invalid identity");
|
|
20
21
|
return snapshotNotesIdentity({ home: input.home, sessionId: input.sessionId, projectKey: projectKey(input.cwd, input.home), agent: input.agent, model: input.model });
|
|
21
22
|
}
|
|
22
|
-
/** The first schema violation, named by parameter so the model can fix that one field. */
|
|
23
|
-
function paramProblem(schema, params) {
|
|
24
|
-
// A false subschema reports "schema is false"; its parent's additionalProperties error names the field instead.
|
|
25
|
-
const first = Errors(schema, params).find((error) => error.keyword !== "boolean");
|
|
26
|
-
if (!first)
|
|
27
|
-
return "unrecognized shape";
|
|
28
|
-
const extra = first.keyword === "additionalProperties" ? `: ${first.params.additionalProperties.join(", ")}` : "";
|
|
29
|
-
const field = first.instancePath.replace(/^\//, "").replaceAll("/", ".");
|
|
30
|
-
return `${field ? `${field} ` : ""}${first.message}${extra}`;
|
|
31
|
-
}
|
|
32
23
|
/** Bind shared execution/rendering to a host context; dispatch validates parameters before calling. */
|
|
33
24
|
function boundOperation(operation) {
|
|
34
25
|
return {
|
|
@@ -43,24 +43,11 @@ function settingFlag(settings) {
|
|
|
43
43
|
* smallest present value keeps notesoup's reset ahead of whichever one Claude would use.
|
|
44
44
|
*/
|
|
45
45
|
function configuredWindow(settings, env, model) {
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const modelSettings = isPlainObject(settings.modelSettings) ? settings.modelSettings : {};
|
|
52
|
-
const perModel = modelSettings[model];
|
|
53
|
-
if (isPlainObject(perModel)) {
|
|
54
|
-
const value = positiveNumber(perModel.autoCompactWindow);
|
|
55
|
-
if (value !== undefined)
|
|
56
|
-
windows.push(value);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (isPlainObject(settings)) {
|
|
60
|
-
const value = positiveNumber(settings.autoCompactWindow);
|
|
61
|
-
if (value !== undefined)
|
|
62
|
-
windows.push(value);
|
|
63
|
-
}
|
|
46
|
+
const root = isPlainObject(settings) ? settings : {};
|
|
47
|
+
const models = isPlainObject(root.modelSettings) ? root.modelSettings : {};
|
|
48
|
+
const perModel = typeof model === "string" && model.length > 0 ? models[model] : undefined;
|
|
49
|
+
const windows = [env.autoCompactWindow, isPlainObject(perModel) ? perModel.autoCompactWindow : undefined, root.autoCompactWindow]
|
|
50
|
+
.map(positiveNumber).filter((value) => value !== undefined);
|
|
64
51
|
return windows.length === 0 ? undefined : Math.min(...windows);
|
|
65
52
|
}
|
|
66
53
|
function tokenLimits(source, autoCompact, native, resetMargin, warningRunway) {
|
|
@@ -71,16 +58,6 @@ function tokenLimits(source, autoCompact, native, resetMargin, warningRunway) {
|
|
|
71
58
|
native: tokens, reset, warn: Math.max(MIN_POINT_TOKENS, reset - warningRunway), resetMargin, warningRunway,
|
|
72
59
|
};
|
|
73
60
|
}
|
|
74
|
-
/** The percent fallback: the same reserves expressed as points of ASSUMED_WINDOW_TOKENS. */
|
|
75
|
-
function percentLimits(autoCompact, pct, resetMargin, warningRunway) {
|
|
76
|
-
const base = 100 * (1 - (CLAUDE_OUTPUT_RESERVE_TOKENS + CLAUDE_AUTOCOMPACT_BUFFER_TOKENS) / ASSUMED_WINDOW_TOKENS);
|
|
77
|
-
const native = pct === undefined ? base : Math.min(pct, base);
|
|
78
|
-
const reset = Math.max(MIN_POINT_PERCENT, native - (resetMargin / ASSUMED_WINDOW_TOKENS) * 100);
|
|
79
|
-
return {
|
|
80
|
-
source: "percent", autoCompact, unit: "percent",
|
|
81
|
-
native, reset, warn: Math.max(MIN_POINT_PERCENT, reset - (warningRunway / ASSUMED_WINDOW_TOKENS) * 100), resetMargin, warningRunway,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
61
|
/**
|
|
85
62
|
* Resolve the points from whatever the host could read. Every field is undocumented-adjacent,
|
|
86
63
|
* so a missing or malformed one degrades to the next source and finally to the percent
|
|
@@ -111,20 +88,23 @@ export function resolveClaudeLimits(facts) {
|
|
|
111
88
|
if (native > 0)
|
|
112
89
|
return tokenLimits("auto-compact", true, native, resetMargin, warningRunway);
|
|
113
90
|
}
|
|
114
|
-
// (b)
|
|
115
|
-
// window always answers here: falling through to the percent fallback would express the
|
|
116
|
-
// points on an assumed 200K window, which is later than the window notesoup can see.
|
|
91
|
+
// (b/c) Compute once, using the classic 200K capacity only when the host reports none.
|
|
117
92
|
const window = positiveNumber(usage.window);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return
|
|
93
|
+
const capacity = window ?? ASSUMED_WINDOW_TOKENS;
|
|
94
|
+
const configured = configuredWindow(settings, env, breakdown.model);
|
|
95
|
+
const effective = Math.min(configured ?? capacity, capacity);
|
|
96
|
+
const available = effective - CLAUDE_OUTPUT_RESERVE_TOKENS;
|
|
97
|
+
const thresholdFromWindow = available - CLAUDE_AUTOCOMPACT_BUFFER_TOKENS;
|
|
98
|
+
const native = autoCompact
|
|
99
|
+
? pct === undefined ? thresholdFromWindow : Math.min(Math.floor(available * (pct / 100)), thresholdFromWindow)
|
|
100
|
+
: available;
|
|
101
|
+
const limits = tokenLimits(window === undefined ? "percent" : "window", autoCompact, native, resetMargin, warningRunway);
|
|
102
|
+
if (window !== undefined)
|
|
103
|
+
return limits;
|
|
104
|
+
return {
|
|
105
|
+
...limits, unit: "percent",
|
|
106
|
+
native: limits.native / capacity * 100,
|
|
107
|
+
reset: Math.max(MIN_POINT_PERCENT, limits.reset / capacity * 100),
|
|
108
|
+
warn: Math.max(MIN_POINT_PERCENT, limits.warn / capacity * 100),
|
|
109
|
+
};
|
|
130
110
|
}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
-
import { Check
|
|
5
|
+
import { Check } from "typebox/value";
|
|
6
|
+
import { paramProblem } from "../../../src/tools/schema.js";
|
|
6
7
|
import { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "../../../src/tools/notes.js";
|
|
7
8
|
import { historyList, historyRead } from "../../../src/tools/history.js";
|
|
8
9
|
import { wireResult } from "../../../src/tools/result.js";
|
|
9
10
|
import { CodexIdentityError, notesIdentityFor, pluginDataRoot, readBinding, rootSessionIdOf, safeThreadId, turnModel } from "./identity.js";
|
|
10
|
-
import { readCodexHistory } from "
|
|
11
|
+
import { readCodexHistory } from "../../../src/history/codex.js";
|
|
11
12
|
import { localHistoryCorpus } from "../../../src/history/local.js";
|
|
12
13
|
import { readStartState } from "./state.js";
|
|
13
14
|
import { notesToolContext } from "../../../src/tools/notes-context.js";
|
|
@@ -40,15 +41,6 @@ function successFor(bound, outcome) {
|
|
|
40
41
|
...(outcome.ok ? {} : { isError: true }),
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
|
-
/** The first schema violation, named by parameter so the model can fix that one field. */
|
|
44
|
-
function paramProblem(schema, params) {
|
|
45
|
-
const first = Errors(schema, params).find((error) => error.keyword !== "boolean");
|
|
46
|
-
if (!first)
|
|
47
|
-
return "unrecognized shape";
|
|
48
|
-
const extra = first.keyword === "additionalProperties" ? `: ${first.params.additionalProperties.join(", ")}` : "";
|
|
49
|
-
const field = first.instancePath.replace(/^\//, "").replaceAll("/", ".");
|
|
50
|
-
return `${field ? `${field} ` : ""}${first.message}${extra}`;
|
|
51
|
-
}
|
|
52
44
|
/** MCP metadata is the caller's claim; it must agree with the hook binding before any read. */
|
|
53
45
|
function metaFacts(meta, binding) {
|
|
54
46
|
const rootSessionId = rootSessionIdOf(meta);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NotesSnapshot } from "../../../src/boot/snapshot.js";
|
|
2
|
-
import { type CodexRecord, type CodexTranscriptSource, type CodexTranscriptState } from "
|
|
2
|
+
import { type CodexRecord, type CodexTranscriptSource, type CodexTranscriptState } from "../../../src/history/codex-transcript.js";
|
|
3
3
|
export type CodexSource = CodexTranscriptSource;
|
|
4
4
|
/** The one marker that makes a persisted notesoup boot verifiable in a native window. */
|
|
5
5
|
export declare function bootMarker(threadId: string, windowId: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Native Codex facts shared by hook boot and MCP history; no second parser and no invented window. */
|
|
2
2
|
import { DEFAULT_BOOT_TOOL_NAMES } from "../../../src/boot/text.js";
|
|
3
3
|
import { renderBootBlock } from "../../../src/boot/render.js";
|
|
4
|
-
import { readCodexTranscript } from "
|
|
4
|
+
import { readCodexTranscript } from "../../../src/history/codex-transcript.js";
|
|
5
5
|
import { CODEX_PRE_RESET_HINTS, CODEX_WIPE_SENTENCE } from "./text.js";
|
|
6
6
|
/** The one marker that makes a persisted notesoup boot verifiable in a native window. */
|
|
7
7
|
export function bootMarker(threadId, windowId) {
|
|
@@ -3,7 +3,7 @@ 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
5
|
import { historyList, historyRead } from "../../src/tools/history.js";
|
|
6
|
-
import { success } from "../../src/
|
|
6
|
+
import { success } from "../../src/result.js";
|
|
7
7
|
import { historyContext } from "./history.js";
|
|
8
8
|
import { notesCwd, notesIdentity } from "./window.js";
|
|
9
9
|
import { notesToolContext } from "../../src/tools/notes-context.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { type NotesSnapshot } from "../../src/boot/snapshot.js";
|
|
3
3
|
export type IncompleteNotesNotifier = (ctx: ExtensionContext, windowId: string, snapshot: NotesSnapshot) => void;
|
|
4
|
-
/** The
|
|
4
|
+
/** The hidden user boot: window identity and notes snapshot; teaching belongs to system sections. */
|
|
5
5
|
export type BootMessage = {
|
|
6
6
|
readonly customType: string;
|
|
7
7
|
readonly content: string;
|
package/dist/plugins/pi/boot.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { DEFAULT_BOOT_TOOL_NAMES } from "../../src/boot/text.js";
|
|
2
|
-
import { PI_PRE_RESET_HINTS } from "./text.js";
|
|
3
2
|
import { agentSlug, modelSlug, notesIdentityFromPi } from "./notes/adapter.js";
|
|
4
3
|
import { loadNotesSnapshot, unavailableNotesSnapshot } from "../../src/boot/snapshot.js";
|
|
5
4
|
import { isFilesystemError } from "../../src/notes/index.js";
|
|
6
5
|
import { BOOT_TYPE } from "./entries.js";
|
|
7
|
-
import {
|
|
6
|
+
import { renderBootContext } from "../../src/boot/render.js";
|
|
8
7
|
import { historyFromSession, nextHistorySeq } from "./history.js";
|
|
9
8
|
/**
|
|
10
9
|
* Acquire one notes snapshot and build the boot custom message for a window. All identity
|
|
@@ -51,7 +50,7 @@ export async function buildBootMessage(ctx, windowId, firstSeq, notifyIncomplete
|
|
|
51
50
|
notifyIncompleteNotes?.(ctx, windowId, notes);
|
|
52
51
|
return {
|
|
53
52
|
customType: BOOT_TYPE,
|
|
54
|
-
content:
|
|
53
|
+
content: renderBootContext({ agentName, modelName, tree, notes, tools: DEFAULT_BOOT_TOOL_NAMES }),
|
|
55
54
|
display: false,
|
|
56
55
|
details: { windowId },
|
|
57
56
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentMessage } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import { Type } from "
|
|
2
|
+
import { Type } from "typebox";
|
|
3
3
|
import { type ExtensionAPI, type ExtensionContext, type SessionBoundaryDraft, type SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
export declare const ContextRemainingOutputSchema: Type.TObject<{
|
|
5
5
|
remaining_tokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_BOOT_TOOL_NAMES } from "../../src/boot/text.js";
|
|
2
2
|
import { remainingBudget } from "../../src/budget/policy.js";
|
|
3
|
-
import { Type } from "
|
|
3
|
+
import { Type } from "typebox";
|
|
4
4
|
import { convertToLlm, defineTool } from "@earendil-works/pi-coding-agent";
|
|
5
5
|
import { GUIDANCE_TYPE, WARNING_TYPE } from "./entries.js";
|
|
6
6
|
import { estimateContextTokens } from "./estimate.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Pi TUI renderers
|
|
1
|
+
/** Pi TUI renderers: compact slips with visible policy/warnings, expandable bodies. */
|
|
2
2
|
import { type AgentToolResult, type Theme } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import { type Component } from "@earendil-works/pi-tui";
|
|
4
4
|
import type { Static } from "typebox";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/** Pi TUI renderers
|
|
1
|
+
/** Pi TUI renderers: compact slips with visible policy/warnings, expandable bodies. */
|
|
2
2
|
import { renderDiff } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import { Text, TruncatedText, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
|
+
import { Container, 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. */
|
|
@@ -50,6 +50,21 @@ function boundedLines(text, theme) {
|
|
|
50
50
|
return text;
|
|
51
51
|
return `${lines.slice(0, EXPANDED_LINE_CAP).join("\n")}\n${theme.fg("dim", `… ${lines.length - EXPANDED_LINE_CAP} more lines`)}`;
|
|
52
52
|
}
|
|
53
|
+
/** Keep policy and warnings outside the clipped summary and expandable body, even when collapsed.
|
|
54
|
+
* Older persisted receipts may have neither; don't invent policy for those results.
|
|
55
|
+
*/
|
|
56
|
+
function noteResult(head, policy, warnings, expanded, body, theme) {
|
|
57
|
+
const result = new Container();
|
|
58
|
+
result.addChild(expanded ? new Text(head, 0, 0) : new TruncatedText(head, 0, 0));
|
|
59
|
+
if (policy?.pinned !== undefined && policy.budget !== undefined && policy.readonly !== undefined) {
|
|
60
|
+
result.addChild(new Text(theme.fg("dim", `pinned ${policy.pinned} | budget ${policy.budget} | readonly ${policy.readonly}`), 0, 0));
|
|
61
|
+
}
|
|
62
|
+
for (const warning of warnings ?? [])
|
|
63
|
+
result.addChild(new Text(theme.fg("warning", warning), 0, 0));
|
|
64
|
+
if (expanded && body)
|
|
65
|
+
result.addChild(new Text(`\n${body}`, 0, 0));
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
53
68
|
export const notesWriteRenderers = {
|
|
54
69
|
renderCall: (args, theme) => callLine(theme, "notes_write", args.address),
|
|
55
70
|
renderResult(result, options, theme, context) {
|
|
@@ -61,9 +76,7 @@ export const notesWriteRenderers = {
|
|
|
61
76
|
const content = typeof context.args?.content === "string" ? context.args.content : "";
|
|
62
77
|
const qualifier = data.outcome === "created" ? "" : theme.fg("dim", ` · ${data.outcome}`);
|
|
63
78
|
const head = `wrote ${addressText(theme, data.address)}${qualifier}${theme.fg("dim", ` · ${Array.from(content).length} chars`)}`;
|
|
64
|
-
|
|
65
|
-
return new TruncatedText(head, 0, 0);
|
|
66
|
-
return new Text(`${head}\n\n${boundedLines(content, theme)}`, 0, 0);
|
|
79
|
+
return noteResult(head, data, data.warnings, options.expanded, options.expanded ? boundedLines(content, theme) : undefined, theme);
|
|
67
80
|
},
|
|
68
81
|
};
|
|
69
82
|
export const notesUpdateRenderers = {
|
|
@@ -103,9 +116,7 @@ export const notesUpdateRenderers = {
|
|
|
103
116
|
if (peek !== undefined && peek !== "")
|
|
104
117
|
head += theme.fg("dim", " · ") + theme.fg("toolDiffAdded", `+ ${peek}`);
|
|
105
118
|
}
|
|
106
|
-
|
|
107
|
-
return new TruncatedText(head, 0, 0);
|
|
108
|
-
return new Text(diff !== "" ? `${head}\n\n${renderDiff(diff)}` : head, 0, 0);
|
|
119
|
+
return noteResult(head, data, data.warnings, options.expanded, options.expanded && diff !== "" ? renderDiff(diff) : undefined, theme);
|
|
109
120
|
},
|
|
110
121
|
};
|
|
111
122
|
export const notesReadRenderers = {
|
|
@@ -121,10 +132,8 @@ export const notesReadRenderers = {
|
|
|
121
132
|
const peek = data.text.split("\n").find((line) => line.trim() !== "");
|
|
122
133
|
if (peek !== undefined)
|
|
123
134
|
head += theme.fg("dim", ` — ${peek.trim()}`);
|
|
124
|
-
if (!options.expanded)
|
|
125
|
-
return new TruncatedText(head, 0, 0);
|
|
126
135
|
const tail = truncated ? `\n${theme.fg("dim", `… continue at offset_chars=${data.next_offset_chars}`)}` : "";
|
|
127
|
-
return
|
|
136
|
+
return noteResult(head, data.metadata, data.warnings, options.expanded, options.expanded ? `${boundedLines(data.text, theme)}${tail}` : undefined, theme);
|
|
128
137
|
},
|
|
129
138
|
};
|
|
130
139
|
/** The empty_brain result is the JSON receipt text; there is no structured payload. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { resetBoundaryCommitted } from "./reset/committed.js";
|
|
3
|
-
import { getCurrentSystemMessage
|
|
3
|
+
import { getCurrentSystemMessage } from "@earendil-works/pi-ai";
|
|
4
|
+
import { Type } from "typebox";
|
|
4
5
|
import { VERSION, defineTool } from "@earendil-works/pi-coding-agent";
|
|
5
6
|
import { registerBudget } from "./budget.js";
|
|
6
7
|
import { DREAM_NAMESPACE, HISTORY_NAMESPACE, NOTES_NAMESPACE, output } from "./tool-result.js";
|
|
@@ -9,7 +10,9 @@ import { currentReset, currentWindowId, isCheckpointBackedReset, isWindowBoot, i
|
|
|
9
10
|
import { registerResetLifecycle } from "./reset/lifecycle.js";
|
|
10
11
|
import { buildResetDrafts, LAST_WORD_ADVERTISED_CHARS, MAX_LAST_WORD_CHARS, repairResetTail, sanitizeLastWord } from "./reset/artifacts.js";
|
|
11
12
|
import { BOOT_TYPE, MANUAL_WIPE_TYPE } from "./entries.js";
|
|
12
|
-
import { commandWarningContent } from "./text.js";
|
|
13
|
+
import { commandWarningContent, PI_PRE_RESET_HINTS } from "./text.js";
|
|
14
|
+
import { DEFAULT_BOOT_TOOL_NAMES, MAPS_BLOCK, renderProtocolBlock } from "../../src/boot/text.js";
|
|
15
|
+
import { agentSlug } from "./notes/adapter.js";
|
|
13
16
|
import { buildBootMessage, sendBoot } from "./boot.js";
|
|
14
17
|
import { maybeSendMarker } from "./marker.js";
|
|
15
18
|
import { nextHistorySeq } from "./history.js";
|
|
@@ -83,6 +86,7 @@ export function registerContext(pi, settingsManager) {
|
|
|
83
86
|
};
|
|
84
87
|
pi.on("before_agent_start", (event, ctx) => {
|
|
85
88
|
event.systemPromptOptions.sections.notesoup_tools = notesoupTools;
|
|
89
|
+
event.systemPromptOptions.sections.notesoup_protocol = `${renderProtocolBlock({ ...DEFAULT_BOOT_TOOL_NAMES, preResetHints: PI_PRE_RESET_HINTS }, agentSlug())}\n\n${MAPS_BLOCK}`;
|
|
86
90
|
if (enabled)
|
|
87
91
|
maybeSendMarker(pi, ctx);
|
|
88
92
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** Pi transport for host-neutral operations. */
|
|
2
2
|
import { type ExtensionAPI, type ExtensionToolContext, type ToolDefinition, type ToolExposure } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import type { Static, TSchema } from "typebox";
|
|
4
|
-
import
|
|
4
|
+
import type { Outcome } from "../../src/result.js";
|
|
5
|
+
import { type Operation } from "../../src/tools/result.js";
|
|
5
6
|
/** Pi's JSON envelope for reset and budget tools; details carry only log/UI metadata. */
|
|
6
7
|
export declare function output(value: unknown, details?: unknown, terminate?: boolean): {
|
|
7
8
|
isError?: boolean | undefined;
|
|
@@ -2,6 +2,7 @@ import { getCurrentSystemMessage } from "@earendil-works/pi-ai";
|
|
|
2
2
|
import { estimateContextTokens } from "./estimate.js";
|
|
3
3
|
import { convertToLlm } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { BOOT_TYPE, RESET_MARKER_TYPE } from "./entries.js";
|
|
5
|
+
import { NOTES_PROTOCOL_OPEN_TAG, NOTES_PROTOCOL_CLOSE_TAG, WINDOW_IDENTITY_OPEN_TAG, WINDOW_IDENTITY_CLOSE_TAG } from "../../src/boot/text.js";
|
|
5
6
|
export function isWindowMarker(entry) {
|
|
6
7
|
return entry.type === "custom" && entry.customType === RESET_MARKER_TYPE &&
|
|
7
8
|
typeof entry.data === "object" && entry.data !== null &&
|
|
@@ -86,6 +87,27 @@ export function isWindowBoot(message, windowId) {
|
|
|
86
87
|
export function isWindowBootEntry(entry, windowId) {
|
|
87
88
|
return entry.type === "custom_message" && entry.customType === BOOT_TYPE && hasWindowId(entry.details, windowId);
|
|
88
89
|
}
|
|
90
|
+
/** Strip only the old boot's leading teaching blocks, never tags quoted inside its notes. */
|
|
91
|
+
function withoutBootTeaching(message) {
|
|
92
|
+
if (message.role !== "custom" || typeof message.content !== "string" || !message.content.startsWith(`${WINDOW_IDENTITY_OPEN_TAG}\n`))
|
|
93
|
+
return message;
|
|
94
|
+
const identityEnd = message.content.indexOf(`\n${WINDOW_IDENTITY_CLOSE_TAG}\n\n`);
|
|
95
|
+
if (identityEnd < 0)
|
|
96
|
+
return message;
|
|
97
|
+
const start = identityEnd + `\n${WINDOW_IDENTITY_CLOSE_TAG}\n\n`.length;
|
|
98
|
+
let rest = message.content.slice(start);
|
|
99
|
+
for (const [open, close] of [[NOTES_PROTOCOL_OPEN_TAG, NOTES_PROTOCOL_CLOSE_TAG], ["<notesoup:maps>", "</notesoup:maps>"]]) {
|
|
100
|
+
if (!rest.startsWith(`${open}\n`))
|
|
101
|
+
return message;
|
|
102
|
+
const end = rest.indexOf(`\n${close}\n\n`);
|
|
103
|
+
if (end < 0)
|
|
104
|
+
return message;
|
|
105
|
+
rest = rest.slice(end + `\n${close}\n\n`.length);
|
|
106
|
+
}
|
|
107
|
+
if (!rest.startsWith("YOUR NOTES\n──────────\n"))
|
|
108
|
+
return message;
|
|
109
|
+
return { ...message, content: message.content.slice(0, start) + rest };
|
|
110
|
+
}
|
|
89
111
|
/**
|
|
90
112
|
* The durable marker selects a boot message by identity, never by wall-clock time.
|
|
91
113
|
* The boot is the first conversation message of the window. Folding only its prefix
|
|
@@ -97,6 +119,7 @@ export function projectWindow(messages, windowId) {
|
|
|
97
119
|
throw new Error(`Missing boot for context window ${windowId}`);
|
|
98
120
|
const head = getCurrentSystemMessage(messages.slice(0, cut));
|
|
99
121
|
const suffix = messages.slice(cut);
|
|
122
|
+
suffix[0] = withoutBootTeaching(suffix[0]);
|
|
100
123
|
return head ? [head, ...suffix] : suffix;
|
|
101
124
|
}
|
|
102
125
|
/**
|
|
@@ -108,7 +131,7 @@ export function projectRootWindow(messages, windowId) {
|
|
|
108
131
|
const matching = messages.filter((message) => isWindowBoot(message, windowId));
|
|
109
132
|
if (matching.length === 0)
|
|
110
133
|
return messages;
|
|
111
|
-
const activeBoot = matching[matching.length - 1];
|
|
134
|
+
const activeBoot = withoutBootTeaching(matching[matching.length - 1]);
|
|
112
135
|
const firstBoot = messages.findIndex((message) => isWindowBoot(message));
|
|
113
136
|
const withoutBoots = messages.filter((message) => !isWindowBoot(message));
|
|
114
137
|
return [...withoutBoots.slice(0, firstBoot), activeBoot, ...withoutBoots.slice(firstBoot)];
|
|
@@ -16,8 +16,7 @@ export type BootRenderData = {
|
|
|
16
16
|
readonly notes: NotesSnapshot;
|
|
17
17
|
readonly tools: BootToolNames;
|
|
18
18
|
};
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
19
|
+
/** Window data only: identity and the closed notes snapshot, never protocol teaching. */
|
|
20
|
+
export declare function renderBootContext(data: BootRenderData): string;
|
|
21
|
+
/** Full boot for hosts that keep protocol teaching alongside their window data. */
|
|
23
22
|
export declare function renderBootBlock(data: BootRenderData): string;
|
package/dist/src/boot/render.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { effectiveNotePolicy, MAX_PINNED_NOTES, noteBudgetWarnings, pinnedPageOrder } from "../notes/policy.js";
|
|
2
|
+
import { WINDOW_IDENTITY_OPEN_TAG, WINDOW_IDENTITY_CLOSE_TAG, MAPS_BLOCK, NAMELESS_AGENT, SHELF_FRESH_LIMIT, renderProtocolBlock } from "./text.js";
|
|
2
3
|
function relativeTime(timestamp, now) {
|
|
3
4
|
const seconds = Math.trunc((timestamp - now) / 1000);
|
|
4
5
|
if (seconds === 0)
|
|
@@ -43,12 +44,11 @@ function notesIndex(snapshot, tools, agentName, modelName) {
|
|
|
43
44
|
continue;
|
|
44
45
|
}
|
|
45
46
|
const rows = (snapshot.namespaces.get(namespace.scope) ?? []).filter((row) => row.meta.crumpledAt === undefined);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
47
|
+
const pins = rows.filter(row => effectiveNotePolicy(row.meta, row.path).pinned)
|
|
48
|
+
.sort((a, b) => pinnedPageOrder(a.path) - pinnedPageOrder(b.path) || a.path.localeCompare(b.path));
|
|
49
|
+
const pinned = pins.slice(0, MAX_PINNED_NOTES);
|
|
50
50
|
const fresh = rows
|
|
51
|
-
.filter(
|
|
51
|
+
.filter(row => !effectiveNotePolicy(row.meta, row.path).pinned)
|
|
52
52
|
.slice(0, SHELF_FRESH_LIMIT)
|
|
53
53
|
.map((row) => {
|
|
54
54
|
const locator = `${row.address} · ${relativeTime(row.meta.updatedAt, snapshot.openedAt)}`;
|
|
@@ -57,7 +57,12 @@ function notesIndex(snapshot, tools, agentName, modelName) {
|
|
|
57
57
|
});
|
|
58
58
|
if (pinned.length === 0 && fresh.length === 0)
|
|
59
59
|
continue;
|
|
60
|
-
const parts = pinned.map(
|
|
60
|
+
const parts = pinned.map(row => {
|
|
61
|
+
const warnings = noteBudgetWarnings(row.body, effectiveNotePolicy(row.meta, row.path));
|
|
62
|
+
return `${row.address}\n\n${indent([...warnings, row.body].join("\n"))}`;
|
|
63
|
+
});
|
|
64
|
+
if (pins.length > MAX_PINNED_NOTES)
|
|
65
|
+
parts.push(indent(`Warning: only ${MAX_PINNED_NOTES} pinned notes per notebook are injected; omitted pins: ${pins.slice(MAX_PINNED_NOTES).map(row => row.address).join(", ")}. Unpin some notes or read the omitted pages with ${tools.notes}.`));
|
|
61
66
|
if (fresh.length > 0)
|
|
62
67
|
parts.push(`recent\n\n${fresh.join("\n\n")}`);
|
|
63
68
|
shelves.push(section(namespace.label, parts.join("\n\n")));
|
|
@@ -66,18 +71,8 @@ function notesIndex(snapshot, tools, agentName, modelName) {
|
|
|
66
71
|
? ["YOUR NOTES\n──────────", ...shelves].join("\n\n\n")
|
|
67
72
|
: "YOUR NOTES\n──────────\n\nNone yet. A blank slate is a fine place to start — just don't finish there.";
|
|
68
73
|
}
|
|
69
|
-
/**
|
|
70
|
-
function
|
|
71
|
-
const chars = Array.from(body);
|
|
72
|
-
if (chars.length <= maxChars)
|
|
73
|
-
return body;
|
|
74
|
-
return `${chars.slice(0, maxChars).join("")}\n[truncated at ${maxChars} chars; slim this page down, full body at \`${address}\`]`;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Render a static, once-per-window boot block from explicit data. This function does not read
|
|
78
|
-
* notes or call runtime UI APIs; acquisition belongs to loadNotesSnapshot and its caller.
|
|
79
|
-
*/
|
|
80
|
-
export function renderBootBlock(data) {
|
|
74
|
+
/** Render the window identity without reading notes or consulting the host. */
|
|
75
|
+
function renderIdentity(data) {
|
|
81
76
|
// Root, the window before this one, and this one: the block is rewritten every window, so an
|
|
82
77
|
// unbounded list would repeat the whole history once per window for no new information.
|
|
83
78
|
const shown = new Set([0, data.tree.windows.length - 2, data.tree.windows.length - 1]);
|
|
@@ -93,6 +88,13 @@ export function renderBootBlock(data) {
|
|
|
93
88
|
return `${window.isCurrent ? "└─" : "├─"} ${name}${range}${window.isCurrent ? " ← you are here" : ""}`;
|
|
94
89
|
}),
|
|
95
90
|
];
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
return `${WINDOW_IDENTITY_OPEN_TAG}\n${lines.join("\n")}\n${WINDOW_IDENTITY_CLOSE_TAG}`;
|
|
92
|
+
}
|
|
93
|
+
/** Window data only: identity and the closed notes snapshot, never protocol teaching. */
|
|
94
|
+
export function renderBootContext(data) {
|
|
95
|
+
return [renderIdentity(data), notesIndex(data.notes, data.tools, data.agentName, data.modelName)].join("\n\n");
|
|
96
|
+
}
|
|
97
|
+
/** Full boot for hosts that keep protocol teaching alongside their window data. */
|
|
98
|
+
export function renderBootBlock(data) {
|
|
99
|
+
return [renderIdentity(data), renderProtocolBlock(data.tools, data.agentName), MAPS_BLOCK, notesIndex(data.notes, data.tools, data.agentName, data.modelName)].join("\n\n");
|
|
98
100
|
}
|
package/dist/src/boot/text.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
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
|
-
/** Each pinned page has its own code-point cap; overflow keeps a lookup pointer. */
|
|
4
|
-
export declare const CHEATSHEET_BOOT_MAX_CHARS = 1536;
|
|
5
|
-
export declare const MAP_BOOT_MAX_CHARS = 4096;
|
|
6
3
|
export declare const WINDOW_IDENTITY_OPEN_TAG = "<notesoup:window_identity>";
|
|
7
4
|
export declare const WINDOW_IDENTITY_CLOSE_TAG = "</notesoup:window_identity>";
|
|
8
5
|
export declare const NOTES_PROTOCOL_OPEN_TAG = "<notesoup:notes_protocol>";
|
|
@@ -16,9 +13,9 @@ export declare const NAMELESS_AGENT = "anonymous";
|
|
|
16
13
|
export declare const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `empty_brain` and erase yourself with dignity.";
|
|
17
14
|
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.";
|
|
18
15
|
/**
|
|
19
|
-
*
|
|
16
|
+
* Default pinned pages and per-note policy are taught between the protocol and the notes index.
|
|
20
17
|
*/
|
|
21
|
-
export declare const MAPS_BLOCK = "<notesoup:maps>\nEvery notebook's root
|
|
18
|
+
export declare const MAPS_BLOCK = "<notesoup:maps>\nEvery notebook's root has two default pins: `CHEATSHEET.md` and `MAP.md`.\nPinned pages get jammed straight into your brain the moment you wake up. Whoever wakes up next\nreads them, and next is you. So keep them short, and keep them true.\n\nSet `pinned`, `budget`, and `readonly` with the note tools or frontmatter. Each notebook allows five\nlive pins, including the defaults; `pinned:false` unpins even a default page. Every page's budget\nstarts at 2048 Unicode code points; set a positive integer to change it. Going over warns but saves,\nand pinned bodies arrive whole, not cut short. `readonly:true` is a soft lock, not security;\nexplicitly set `readonly:false` to unlock, on its own or with your changes.\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>";
|
|
22
19
|
/** Logical tool names are supplied by the composing host, not discovered here. */
|
|
23
20
|
export type BootToolNames = Readonly<{
|
|
24
21
|
notes: string;
|
package/dist/src/boot/text.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
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
|
-
/** Each pinned page has its own code-point cap; overflow keeps a lookup pointer. */
|
|
4
|
-
export const CHEATSHEET_BOOT_MAX_CHARS = 1536;
|
|
5
|
-
export const MAP_BOOT_MAX_CHARS = 4096;
|
|
6
3
|
export const WINDOW_IDENTITY_OPEN_TAG = "<notesoup:window_identity>";
|
|
7
4
|
export const WINDOW_IDENTITY_CLOSE_TAG = "</notesoup:window_identity>";
|
|
8
5
|
export const NOTES_PROTOCOL_OPEN_TAG = "<notesoup:notes_protocol>";
|
|
@@ -19,8 +16,8 @@ const PROTOCOL_SELF_NAMED = "- `@self/<path>` — yours. It follows you, not the
|
|
|
19
16
|
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~`;
|
|
20
17
|
/**
|
|
21
18
|
* Static protocol teaching adapted from Codex's token_budget.guidance_message to
|
|
22
|
-
* notesoup's tool names.
|
|
23
|
-
* it
|
|
19
|
+
* notesoup's tool names. Pi supplies it as a named system section; other hosts
|
|
20
|
+
* retain it in their persisted boot block. Neither path reads note content.
|
|
24
21
|
*
|
|
25
22
|
* The reported room reaches zero at the hard-reserve wipe line.
|
|
26
23
|
*/
|
|
@@ -57,12 +54,18 @@ Still a tie? *shrugs* You've got a brain. Use it.
|
|
|
57
54
|
Any other @ address is fake. End of discussion. @ addresses are not file paths: never pass them to file tools like \`read\`, \`write\`, \`edit\`, or \`bash\`.
|
|
58
55
|
${NOTES_PROTOCOL_CLOSE_TAG}`;
|
|
59
56
|
/**
|
|
60
|
-
*
|
|
57
|
+
* Default pinned pages and per-note policy are taught between the protocol and the notes index.
|
|
61
58
|
*/
|
|
62
59
|
export const MAPS_BLOCK = `<notesoup:maps>
|
|
63
|
-
Every notebook's root
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
Every notebook's root has two default pins: \`CHEATSHEET.md\` and \`MAP.md\`.
|
|
61
|
+
Pinned pages get jammed straight into your brain the moment you wake up. Whoever wakes up next
|
|
62
|
+
reads them, and next is you. So keep them short, and keep them true.
|
|
63
|
+
|
|
64
|
+
Set \`pinned\`, \`budget\`, and \`readonly\` with the note tools or frontmatter. Each notebook allows five
|
|
65
|
+
live pins, including the defaults; \`pinned:false\` unpins even a default page. Every page's budget
|
|
66
|
+
starts at 2048 Unicode code points; set a positive integer to change it. Going over warns but saves,
|
|
67
|
+
and pinned bodies arrive whole, not cut short. \`readonly:true\` is a soft lock, not security;
|
|
68
|
+
explicitly set \`readonly:false\` to unlock, on its own or with your changes.
|
|
66
69
|
|
|
67
70
|
- **\`CHEATSHEET.md\`** holds what you'll want next time — a rule, a warning, a grudge, a name,
|
|
68
71
|
a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat
|
|
@@ -12,7 +12,7 @@ export declare function selectContinuation(origin: ResetOrigin): string;
|
|
|
12
12
|
/** Budget timing stays out of manual close-outs, which may have plenty of room. */
|
|
13
13
|
export declare const WARNING_TIMING = "The reserve is nearly spent. The wipe lands at the end of whichever turn spends the last of it, possibly this one.";
|
|
14
14
|
/** The shared handoff instructions, used for both budget and manual close-outs. */
|
|
15
|
-
export declare const WARNING_BODY = "Stop the task. Write down what git and history can't give back:\n- where you are, and how far you got\n- what the human decided, in their words\n- what's blocked or waiting\n- the next move\n- where the half-done work sits\n- what failed, and why\n- which skills, seqs, notes, or files to reopen\n- anything else worth noting\nThen leave the shelf current: replace what's stale, a whole note or a section inside one, and crumple the dead ones. Update and trim CHEATSHEET.md and MAP.md; every new window loads
|
|
15
|
+
export declare const WARNING_BODY = "Stop the task. Write down what git and history can't give back:\n- where you are, and how far you got\n- what the human decided, in their words\n- what's blocked or waiting\n- the next move\n- where the half-done work sits\n- what failed, and why\n- which skills, seqs, notes, or files to reopen\n- anything else worth noting\nThen leave the shelf current: replace what's stale, a whole note or a section inside one, and crumple the dead ones. Update and trim pinned pages (CHEATSHEET.md and MAP.md by default); every new window loads the pins. The next window gets whatever you leave, dead notes and dead sections alike.\nDon't call anything that might return a large output. One big read can spend the rest of the reserve before your notes are saved.";
|
|
16
16
|
export declare const WARNING_CALL = "Then call `empty_brain`. Nothing in between.";
|
|
17
17
|
export declare function warningPrompt(): string;
|
|
18
18
|
/** Pi and Claude deliver exactly the same second-tier notice. */
|
package/dist/src/budget/text.js
CHANGED
|
@@ -25,7 +25,7 @@ export function selectContinuation(origin) {
|
|
|
25
25
|
/** Budget timing stays out of manual close-outs, which may have plenty of room. */
|
|
26
26
|
export const WARNING_TIMING = "The reserve is nearly spent. The wipe lands at the end of whichever turn spends the last of it, possibly this one.";
|
|
27
27
|
/** The shared handoff instructions, used for both budget and manual close-outs. */
|
|
28
|
-
export const WARNING_BODY = "Stop the task. Write down what git and history can't give back:\n- where you are, and how far you got\n- what the human decided, in their words\n- what's blocked or waiting\n- the next move\n- where the half-done work sits\n- what failed, and why\n- which skills, seqs, notes, or files to reopen\n- anything else worth noting\nThen leave the shelf current: replace what's stale, a whole note or a section inside one, and crumple the dead ones. Update and trim CHEATSHEET.md and MAP.md; every new window loads
|
|
28
|
+
export const WARNING_BODY = "Stop the task. Write down what git and history can't give back:\n- where you are, and how far you got\n- what the human decided, in their words\n- what's blocked or waiting\n- the next move\n- where the half-done work sits\n- what failed, and why\n- which skills, seqs, notes, or files to reopen\n- anything else worth noting\nThen leave the shelf current: replace what's stale, a whole note or a section inside one, and crumple the dead ones. Update and trim pinned pages (CHEATSHEET.md and MAP.md by default); every new window loads the pins. The next window gets whatever you leave, dead notes and dead sections alike.\nDon't call anything that might return a large output. One big read can spend the rest of the reserve before your notes are saved.";
|
|
29
29
|
export const WARNING_CALL = "Then call `empty_brain`. Nothing in between.";
|
|
30
30
|
export function warningPrompt() {
|
|
31
31
|
return `${WARNING_TIMING}\n${WARNING_BODY}\n${WARNING_CALL}`;
|