notesoup 0.46.1 → 0.47.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 +1 -1
- package/dist/src/boot/text.d.ts +2 -2
- package/dist/src/boot/text.js +4 -4
- package/dist/src/budget/text.d.ts +4 -4
- package/dist/src/budget/text.js +3 -3
- package/dist/src/dsh/index.js +1 -1
- package/dist/src/dsh/tools.js +2 -2
- package/dist/src/pi/budget.js +1 -1
- package/dist/src/pi/reset/artifacts.d.ts +1 -1
- package/dist/src/pi/reset/artifacts.js +1 -1
- package/dist/src/pi/reset/lifecycle.js +2 -2
- package/dist/src/pi/runtime.js +18 -17
- package/dist/test/agent-loop.test.js +45 -45
- package/dist/test/boot.integration.test.js +16 -16
- package/dist/test/budget-settings.integration.test.js +1 -1
- package/dist/test/claude-mod.test.js +13 -13
- package/dist/test/dependencies.test.js +2 -2
- package/dist/test/dsh-cli.test.js +1 -1
- package/dist/test/dsh.test.js +7 -7
- package/dist/test/host-neutral.test.js +1 -1
- package/dist/test/notes.integration.test.js +1 -1
- package/dist/test/reset-lifecycle.test.js +14 -14
- package/docs/architecture.md +1 -1
- package/docs/dsh.md +3 -3
- package/docs/reset-lifecycle.md +6 -6
- package/docs/tool-results.md +1 -1
- package/mods/notesoup/.claude-plugin/plugin.json +1 -1
- package/mods/notesoup/dist/claude/helper.js +5 -5
- package/mods/notesoup/hooks/register.ts +16 -16
- package/mods/notesoup/skills/memory/SKILL.md +1 -1
- package/package.json +2 -2
- package/skills/memory/SKILL.md +1 -1
- package/src/boot/text.ts +4 -4
- package/src/budget/text.ts +3 -3
- package/src/dsh/index.ts +1 -1
- package/src/dsh/tools.ts +2 -2
- package/src/pi/budget.ts +1 -1
- package/src/pi/reset/artifacts.ts +1 -1
- package/src/pi/reset/lifecycle.ts +2 -2
- package/src/pi/runtime.ts +18 -17
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ pi -e npm:notesoup
|
|
|
28
28
|
|
|
29
29
|
## What you get
|
|
30
30
|
|
|
31
|
-
- **Durable context windows.** `/fresh-window` (alias `/
|
|
31
|
+
- **Durable context windows.** `/fresh-window` (alias `/empty-brain`) clears and stops; `/fresh-window Continue reviewing the implementation` clears and continues. 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
32
|
- **A boot block at every window head.** Static once-per-window content (cache-stable) with the window identity, the recent-notes index, and a short protocol teaching the model how to recover: notes for its own bookkeeping, history tools for everything before the reset.
|
|
33
33
|
- **`get_context_remaining`** — the live countdown to the close-out line, so the agent can see the cliff before it drives off it.
|
|
34
34
|
- **Eight history/notes tools**, flattened from the original Codex actions:
|
package/dist/src/boot/text.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const CONTEXT_WINDOW_PROTOCOL_CLOSE_TAG = "</context_window_proto
|
|
|
10
10
|
* The one sentence that tells the model how to end its window voluntarily. A host with no
|
|
11
11
|
* model-facing reset tool replaces the whole sentence through BootToolNames.wipeSentence.
|
|
12
12
|
*/
|
|
13
|
-
export declare const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `
|
|
13
|
+
export declare const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `empty_brain` and erase yourself with dignity.";
|
|
14
14
|
/** Claude has no model-facing reset tool: the model ends its turn and the human runs the command. */
|
|
15
15
|
export declare const CLAUDE_WIPE_SENTENCE = "If this feels like the right moment, end your turn and ask the human to run `/fresh-window`.";
|
|
16
16
|
/** Logical tool names are supplied by the composing host, not discovered here. */
|
|
@@ -31,6 +31,6 @@ export declare const DEFAULT_BOOT_TOOL_NAMES: {
|
|
|
31
31
|
readonly notesList: "notes_list";
|
|
32
32
|
readonly history: "history_*";
|
|
33
33
|
readonly remaining: "get_context_remaining";
|
|
34
|
-
readonly wipe: "
|
|
34
|
+
readonly wipe: "empty_brain";
|
|
35
35
|
};
|
|
36
36
|
export declare function renderProtocolBlock(tools: BootToolNames): string;
|
package/dist/src/boot/text.js
CHANGED
|
@@ -10,7 +10,7 @@ export const CONTEXT_WINDOW_PROTOCOL_CLOSE_TAG = "</context_window_protocol>";
|
|
|
10
10
|
* The one sentence that tells the model how to end its window voluntarily. A host with no
|
|
11
11
|
* model-facing reset tool replaces the whole sentence through BootToolNames.wipeSentence.
|
|
12
12
|
*/
|
|
13
|
-
export const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `
|
|
13
|
+
export const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `empty_brain` and erase yourself with dignity.";
|
|
14
14
|
/** Claude has no model-facing reset tool: the model ends its turn and the human runs the command. */
|
|
15
15
|
export const CLAUDE_WIPE_SENTENCE = "If this feels like the right moment, end your turn and ask the human to run `/fresh-window`.";
|
|
16
16
|
/**
|
|
@@ -58,7 +58,7 @@ export const DEFAULT_BOOT_TOOL_NAMES = {
|
|
|
58
58
|
notesList: "notes_list",
|
|
59
59
|
history: "history_*",
|
|
60
60
|
remaining: "get_context_remaining",
|
|
61
|
-
wipe: "
|
|
61
|
+
wipe: "empty_brain",
|
|
62
62
|
};
|
|
63
63
|
export function renderProtocolBlock(tools) {
|
|
64
64
|
const names = {
|
|
@@ -66,12 +66,12 @@ export function renderProtocolBlock(tools) {
|
|
|
66
66
|
notes_list: tools.notesList,
|
|
67
67
|
"history_*": tools.history,
|
|
68
68
|
get_context_remaining: tools.remaining,
|
|
69
|
-
|
|
69
|
+
empty_brain: tools.wipe,
|
|
70
70
|
};
|
|
71
71
|
// The sentence is replaced before name substitution, so a replacement may speak the host's
|
|
72
72
|
// own words (a command line, a tool name) instead of any `notes_*`-style token.
|
|
73
73
|
const block = typeof tools.wipeSentence === "string" && tools.wipeSentence.length > 0
|
|
74
74
|
? PROTOCOL_BLOCK.replace(PROTOCOL_WIPE_SENTENCE, () => tools.wipeSentence)
|
|
75
75
|
: PROTOCOL_BLOCK;
|
|
76
|
-
return block.replace(/notes_\*|notes_list|history_\*|get_context_remaining|(?<!\/)
|
|
76
|
+
return block.replace(/notes_\*|notes_list|history_\*|get_context_remaining|(?<!\/)empty_brain/g, (name) => names[name]);
|
|
77
77
|
}
|
|
@@ -9,11 +9,11 @@ export declare const CONTINUATION = "WIPED! Your whole brain, poof! Who? No idea
|
|
|
9
9
|
* instruction differs — Pi can reset the model itself, Claude can only end the turn.
|
|
10
10
|
*/
|
|
11
11
|
export declare const WARNING_BODY = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.";
|
|
12
|
-
export declare const WARNING_PROMPT = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, call `
|
|
13
|
-
/** Pi-only nudge: pi's
|
|
14
|
-
export declare const LAST_WORD_HINT = "If you want, pass `
|
|
12
|
+
export declare const WARNING_PROMPT = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, call `empty_brain` to reset now instead of being cut off mid-task.";
|
|
13
|
+
/** Pi-only nudge: pi's empty_brain persists a parting line; the dsh tool has no such parameter. */
|
|
14
|
+
export declare const LAST_WORD_HINT = "If you want, pass `empty_brain` a `last_word`: a tiny sticky note (at most 250 characters) slapped on your forehead after the wipe.";
|
|
15
15
|
/** The hidden checkpoint text for pi's manual/budget-triggered requests (dsh reads WARNING_PROMPT directly). */
|
|
16
|
-
export declare const WARNING_CONTENT = "<context_window_guidance>\nThis context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, call `
|
|
16
|
+
export declare const WARNING_CONTENT = "<context_window_guidance>\nThis context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, call `empty_brain` to reset now instead of being cut off mid-task.\nIf you want, pass `empty_brain` a `last_word`: a tiny sticky note (at most 250 characters) slapped on your forehead after the wipe.\n</context_window_guidance>";
|
|
17
17
|
/** Claude's variant: the mod resets after the turn, so the model only has to stop. */
|
|
18
18
|
export declare const CLAUDE_WARNING_PROMPT = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, end your turn; the reset runs after it.";
|
|
19
19
|
/**
|
package/dist/src/budget/text.js
CHANGED
|
@@ -9,9 +9,9 @@ export const CONTINUATION = "WIPED! Your whole brain, poof! Who? No idea! Defini
|
|
|
9
9
|
* instruction differs — Pi can reset the model itself, Claude can only end the turn.
|
|
10
10
|
*/
|
|
11
11
|
export const WARNING_BODY = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.";
|
|
12
|
-
export const WARNING_PROMPT = `${WARNING_BODY}\nWhen the notes are ready, call \`
|
|
13
|
-
/** Pi-only nudge: pi's
|
|
14
|
-
export const LAST_WORD_HINT = "If you want, pass `
|
|
12
|
+
export const WARNING_PROMPT = `${WARNING_BODY}\nWhen the notes are ready, call \`empty_brain\` to reset now instead of being cut off mid-task.`;
|
|
13
|
+
/** Pi-only nudge: pi's empty_brain persists a parting line; the dsh tool has no such parameter. */
|
|
14
|
+
export const LAST_WORD_HINT = "If you want, pass `empty_brain` a `last_word`: a tiny sticky note (at most 250 characters) slapped on your forehead after the wipe.";
|
|
15
15
|
/** The hidden checkpoint text for pi's manual/budget-triggered requests (dsh reads WARNING_PROMPT directly). */
|
|
16
16
|
export const WARNING_CONTENT = `${GUIDANCE_OPEN_TAG}\n${WARNING_PROMPT}\n${LAST_WORD_HINT}\n${GUIDANCE_CLOSE_TAG}`;
|
|
17
17
|
/** Claude's variant: the mod resets after the turn, so the model only has to stop. */
|
package/dist/src/dsh/index.js
CHANGED
|
@@ -33,7 +33,7 @@ export function apply(ctx) {
|
|
|
33
33
|
const state = engine.windows.get(agent.session);
|
|
34
34
|
const phase = budget.remaining <= budget.warning ? "warning" : budget.remaining <= budget.reminder ? "reminder" : undefined;
|
|
35
35
|
if (phase && !(phase === "warning" ? state.warned : state.reminded || state.warned)) {
|
|
36
|
-
const text = phase === "warning" ? WARNING_PROMPT : tokenBudgetGuidance(budget.countdown, "
|
|
36
|
+
const text = phase === "warning" ? WARNING_PROMPT : tokenBudgetGuidance(budget.countdown, "empty_brain");
|
|
37
37
|
agent.steer(createUserMessage({ content: [{ type: "text", text }], source: { kind: "notesoup-budget", windowId: state.snapshot.windowId, phase } }));
|
|
38
38
|
if (phase === "warning")
|
|
39
39
|
state.warned = true;
|
package/dist/src/dsh/tools.js
CHANGED
|
@@ -63,7 +63,7 @@ export function registerTools(ctx, engine) {
|
|
|
63
63
|
if (!exec.agent)
|
|
64
64
|
return;
|
|
65
65
|
const state = engine.windows.get(exec.agent.session);
|
|
66
|
-
if (exec.name === "
|
|
66
|
+
if (exec.name === "empty_brain" && !result.isError && result.value.window_id === state.snapshot.windowId) {
|
|
67
67
|
if (!exec.parent)
|
|
68
68
|
state.pendingReset = true;
|
|
69
69
|
else {
|
|
@@ -85,7 +85,7 @@ export function registerTools(ctx, engine) {
|
|
|
85
85
|
register(ctx, historyRead, async (agent) => [await historyProjection(ctx, agent.session.id)]);
|
|
86
86
|
register(ctx, historyWindows, async (agent) => [await historyProjection(ctx, agent.session.id), agent.session.id]);
|
|
87
87
|
ctx.tools.register(defineTool({
|
|
88
|
-
name: "
|
|
88
|
+
name: "empty_brain",
|
|
89
89
|
description: "Open a fresh context window after this tool batch. Write recovery notes first; notes and raw history stay on disk.",
|
|
90
90
|
parameters: {},
|
|
91
91
|
output: { schema: { type: "object", properties: { window_id: { type: "string", required: true }, reset_requested: { type: "boolean", required: true } }, additionalProperties: false }, render: (_args, value) => [{ type: "text", text: `notesoup: reset requested for ${value.window_id}; finish this tool batch, then recover from your notes.` }] },
|
package/dist/src/pi/budget.js
CHANGED
|
@@ -64,7 +64,7 @@ export function registerBudget(pi, isEnabled, settingsManager) {
|
|
|
64
64
|
for (const [key, notice] of pendingNotices) {
|
|
65
65
|
if (warningCommittedInWindow(ctx, notice)) {
|
|
66
66
|
pendingNotices.delete(key);
|
|
67
|
-
ctx.ui.notify("🥣
|
|
67
|
+
ctx.ui.notify("🥣 Brain almost full · taking notes", "warning");
|
|
68
68
|
}
|
|
69
69
|
else if (settled) {
|
|
70
70
|
// An uncommitted draft must not be matched to a later manual warning.
|
|
@@ -5,7 +5,7 @@ export type ResetTailState = {
|
|
|
5
5
|
readonly boot: boolean;
|
|
6
6
|
readonly continuation: boolean;
|
|
7
7
|
};
|
|
8
|
-
/** A sticky note, not a letter: over this,
|
|
8
|
+
/** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
|
|
9
9
|
export declare const MAX_LAST_WORD_CHARS = 250;
|
|
10
10
|
/** How the next window finds the note. */
|
|
11
11
|
export declare const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
|
|
@@ -3,7 +3,7 @@ import { BOOT_TYPE, CONTINUATION_TYPE, RESET_LAST_WORD_TYPE, RESET_MARKER_TYPE,
|
|
|
3
3
|
import { CONTINUATION } from "../../budget/text.js";
|
|
4
4
|
import { currentWindowId, isForeignResetTailEntry, isWindowBootEntry, isWindowMarker, previousWindowId } from "../window.js";
|
|
5
5
|
import { buildBootMessage, sendBoot } from "../boot.js";
|
|
6
|
-
/** A sticky note, not a letter: over this,
|
|
6
|
+
/** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
|
|
7
7
|
export const MAX_LAST_WORD_CHARS = 250;
|
|
8
8
|
/** How the next window finds the note. */
|
|
9
9
|
export const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
|
|
@@ -176,7 +176,7 @@ export function registerResetLifecycle(pi, options) {
|
|
|
176
176
|
}
|
|
177
177
|
catch (error) {
|
|
178
178
|
if (isCurrent())
|
|
179
|
-
ctx.ui.notify(`🥣
|
|
179
|
+
ctx.ui.notify(`🥣 Brain still full: ${errorMessage(error)}${prompt ? " · prompt not sent" : ""}`, "warning");
|
|
180
180
|
return entries.length > 0 ? { entries } : undefined;
|
|
181
181
|
}
|
|
182
182
|
if (!isCurrent())
|
|
@@ -256,7 +256,7 @@ export function registerResetLifecycle(pi, options) {
|
|
|
256
256
|
const markerExists = currentReset(ctx) !== undefined;
|
|
257
257
|
if (options.isEnabled() || markerExists) {
|
|
258
258
|
if (event.reason === "manual") {
|
|
259
|
-
ctx.ui.notify("🥣
|
|
259
|
+
ctx.ui.notify("🥣 No compacting brains here · use /fresh-window", "warning");
|
|
260
260
|
}
|
|
261
261
|
return { cancel: true };
|
|
262
262
|
}
|
package/dist/src/pi/runtime.js
CHANGED
|
@@ -6,8 +6,8 @@ import { registerBudget } from "./budget.js";
|
|
|
6
6
|
import { output } from "./tool-result.js";
|
|
7
7
|
import { currentReset, currentWindowId, isCheckpointBackedReset, isWindowBoot, isWindowMarker, projectRootWindow, projectWindow, rootWindowId } from "./window.js";
|
|
8
8
|
import { registerResetLifecycle } from "./reset/lifecycle.js";
|
|
9
|
-
import { buildResetDrafts, MAX_LAST_WORD_CHARS, repairResetTail, sanitizeLastWord } from "./reset/artifacts.js";
|
|
10
|
-
import { BOOT_TYPE, MANUAL_WIPE_TYPE } from "./entries.js";
|
|
9
|
+
import { buildResetDrafts, LAST_WORD_PREFIX, MAX_LAST_WORD_CHARS, repairResetTail, sanitizeLastWord } from "./reset/artifacts.js";
|
|
10
|
+
import { BOOT_TYPE, MANUAL_WIPE_TYPE, RESET_LAST_WORD_TYPE } from "./entries.js";
|
|
11
11
|
import { WARNING_CONTENT } from "../budget/text.js";
|
|
12
12
|
import { buildBootMessage, sendBoot } from "./boot.js";
|
|
13
13
|
import { errorMessage } from "../error-message.js";
|
|
@@ -71,7 +71,10 @@ export function registerContext(pi, settingsManager) {
|
|
|
71
71
|
if (!marker || !isCheckpointBackedReset(ctx, marker) || !resetBoundaryCommitted(ctx, marker.id, windowId))
|
|
72
72
|
continue;
|
|
73
73
|
pendingResetNotices.delete(windowId);
|
|
74
|
-
|
|
74
|
+
const tail = branch.slice(branch.indexOf(marker) + 1);
|
|
75
|
+
const lastWordEntry = tail.find((entry) => entry.customType === RESET_LAST_WORD_TYPE);
|
|
76
|
+
const lastWord = lastWordEntry?.content?.startsWith(LAST_WORD_PREFIX) ? lastWordEntry.content.slice(LAST_WORD_PREFIX.length) : undefined;
|
|
77
|
+
ctx.ui.notify(`🥣 Brain emptied${lastWord ? ` · last word: “${lastWord}”` : ""}`, "info");
|
|
75
78
|
}
|
|
76
79
|
};
|
|
77
80
|
pi.on("turn_start", (_event, ctx) => notifyCommittedResets(ctx));
|
|
@@ -84,7 +87,7 @@ export function registerContext(pi, settingsManager) {
|
|
|
84
87
|
return;
|
|
85
88
|
incompleteNotesNotified.add(windowId);
|
|
86
89
|
const homes = snapshot.unavailable.map((home) => home.label).join(", ");
|
|
87
|
-
ctx.ui.notify(`🥣 Some notes
|
|
90
|
+
ctx.ui.notify(`🥣 Some notes went missing: ${homes}`, "warning");
|
|
88
91
|
};
|
|
89
92
|
const budget = registerBudget(pi, () => enabled, settingsManager);
|
|
90
93
|
pi.on("session_start", async (_event, ctx) => {
|
|
@@ -113,7 +116,7 @@ export function registerContext(pi, settingsManager) {
|
|
|
113
116
|
return undefined;
|
|
114
117
|
if (!branchHasWindowMarker(ctx) && !branchHasWindowMarker(ctx, event.preparation.targetId))
|
|
115
118
|
return undefined;
|
|
116
|
-
ctx.ui.notify("🥣 Branch summary skipped · it
|
|
119
|
+
ctx.ui.notify("🥣 Branch summary skipped · it remembers too much", "info");
|
|
117
120
|
return { summary: { summary: "" } };
|
|
118
121
|
});
|
|
119
122
|
// This is the final provider-facing projection. Reset windows cut at their matching boot;
|
|
@@ -132,7 +135,7 @@ export function registerContext(pi, settingsManager) {
|
|
|
132
135
|
catch (error) {
|
|
133
136
|
if (missingBootNotice !== windowId) {
|
|
134
137
|
missingBootNotice = windowId;
|
|
135
|
-
ctx.ui.notify("🥣 Request cancelled ·
|
|
138
|
+
ctx.ui.notify("🥣 Request cancelled · brain is broken, run /fresh-window", "error");
|
|
136
139
|
}
|
|
137
140
|
ctx.abort();
|
|
138
141
|
const safeHead = getCurrentSystemMessage(event.messages);
|
|
@@ -166,11 +169,11 @@ export function registerContext(pi, settingsManager) {
|
|
|
166
169
|
cmdCtx.ui.notify(`🥣 notesoup ${enabled ? "on" : "off"} · ${buildLabel} · Pi ${VERSION}${remaining === null ? "" : ` · ${remaining.toLocaleString("en-US")} tokens left`}`, "info");
|
|
167
170
|
},
|
|
168
171
|
});
|
|
169
|
-
const
|
|
172
|
+
const emptyBrainCommand = {
|
|
170
173
|
description: "Flush memory to notes and continue in a fresh window; optional prompt runs there",
|
|
171
174
|
handler: async (args, cmdCtx) => {
|
|
172
175
|
if (!enabled) {
|
|
173
|
-
cmdCtx.ui.notify("🥣 notesoup is off ·
|
|
176
|
+
cmdCtx.ui.notify("🥣 notesoup is off · no brain to empty", "error");
|
|
174
177
|
return;
|
|
175
178
|
}
|
|
176
179
|
const requestedWindowId = currentWindowId(cmdCtx);
|
|
@@ -185,26 +188,24 @@ export function registerContext(pi, settingsManager) {
|
|
|
185
188
|
const prompt = args.trim() || undefined;
|
|
186
189
|
const armed = resets.closeOut(requestedWindowId, "manual", prompt);
|
|
187
190
|
if (armed === "already-pending") {
|
|
188
|
-
cmdCtx.ui.notify("🥣
|
|
191
|
+
cmdCtx.ui.notify("🥣 Brain already being emptied", "info");
|
|
189
192
|
return;
|
|
190
193
|
}
|
|
191
|
-
cmdCtx.ui.notify(
|
|
192
|
-
? "🥣 Clearing memory · notes first, then your prompt runs"
|
|
193
|
-
: "🥣 Clearing memory · notes first, then it stops", "info");
|
|
194
|
+
cmdCtx.ui.notify("🥣 Brain being emptied", "info");
|
|
194
195
|
try {
|
|
195
196
|
pi.sendMessage({ customType: MANUAL_WIPE_TYPE, content: WARNING_CONTENT, display: false }, { triggerTurn: true, deliverAs: "steer" });
|
|
196
197
|
}
|
|
197
198
|
catch (error) {
|
|
198
199
|
resets.clear();
|
|
199
|
-
cmdCtx.ui.notify(`🥣
|
|
200
|
+
cmdCtx.ui.notify(`🥣 Brain refused to empty: ${errorMessage(error)}`, "error");
|
|
200
201
|
}
|
|
201
202
|
},
|
|
202
203
|
};
|
|
203
|
-
pi.registerCommand("
|
|
204
|
-
pi.registerCommand("fresh-window",
|
|
204
|
+
pi.registerCommand("empty-brain", emptyBrainCommand);
|
|
205
|
+
pi.registerCommand("fresh-window", emptyBrainCommand);
|
|
205
206
|
pi.registerTool(defineTool({
|
|
206
|
-
name: "
|
|
207
|
-
label: "
|
|
207
|
+
name: "empty_brain",
|
|
208
|
+
label: "Empty Brain",
|
|
208
209
|
description: "Clear your in-context memory and start a fresh context window. Your session, notes, and history survive. Pass `last_word` to stick a tiny note on your forehead for after the wipe.",
|
|
209
210
|
parameters: Type.Object({ last_word: Type.Optional(Type.String({ maxLength: MAX_LAST_WORD_CHARS, description: `A tiny sticky note, at most ${MAX_LAST_WORD_CHARS} characters. After the wipe it is slapped on your forehead; longer notes are refused.` })) }, { additionalProperties: false }),
|
|
210
211
|
async execute(_id, params, _signal, _update, ctx) {
|