notesoup 0.47.0 → 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/dist/src/pi/budget.js +1 -1
- package/dist/src/pi/reset/lifecycle.js +2 -2
- package/dist/src/pi/runtime.js +13 -12
- package/dist/test/agent-loop.test.js +13 -13
- package/dist/test/boot.integration.test.js +5 -5
- package/dist/test/budget-settings.integration.test.js +1 -1
- package/dist/test/claude-mod.test.js +7 -7
- package/dist/test/reset-lifecycle.test.js +2 -2
- package/mods/notesoup/.claude-plugin/plugin.json +1 -1
- package/mods/notesoup/hooks/register.ts +14 -14
- package/package.json +1 -1
- package/src/pi/budget.ts +1 -1
- package/src/pi/reset/lifecycle.ts +2 -2
- package/src/pi/runtime.ts +13 -12
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.
|
|
@@ -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);
|
|
@@ -170,7 +173,7 @@ export function registerContext(pi, settingsManager) {
|
|
|
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,18 +188,16 @@ 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
|
};
|
|
@@ -124,13 +124,13 @@ async function openFixture(options) {
|
|
|
124
124
|
await session.bindExtensions({
|
|
125
125
|
uiContext: {
|
|
126
126
|
notify(message, type) {
|
|
127
|
-
if (message === "🥣
|
|
127
|
+
if (message === "🥣 Brain emptied") {
|
|
128
128
|
const marker = sessionManager.getBranch().filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE).at(-1);
|
|
129
129
|
const windowId = marker?.data?.windowId;
|
|
130
130
|
assert.ok(sessionManager.getBranch().some((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE && entry.data?.windowId === windowId), "notification follows the reset marker commit");
|
|
131
131
|
assert.ok(sessionManager.getBranch().some((entry) => entry.type === "custom_message" && entry.customType === BOOT_TYPE && entry.details?.windowId === windowId), "notification follows the reset boot commit");
|
|
132
132
|
}
|
|
133
|
-
if (type === "warning" && /^🥣
|
|
133
|
+
if (type === "warning" && /^🥣 Brain almost full/.test(message))
|
|
134
134
|
budgetNotices++;
|
|
135
135
|
notices.push(message);
|
|
136
136
|
},
|
|
@@ -400,12 +400,12 @@ test("real AgentSession: final warning survives its reset boundary and notifies
|
|
|
400
400
|
assert.equal(fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === WARNING_TYPE).length, 1);
|
|
401
401
|
assert.equal(resetMarkers(fixture).length, 1, "the reset commits in the same boundary as the final warning");
|
|
402
402
|
assert.equal(fixture.budgetNotices(), 1, "the old-window committed warning reaches the UI after reset");
|
|
403
|
-
assert.equal(fixture.notices.filter((notice) => notice === "🥣
|
|
403
|
+
assert.equal(fixture.notices.filter((notice) => notice === "🥣 Brain emptied").length, 1, "reset notification remains intact");
|
|
404
404
|
assert.equal(fixture.notices.some((notice) => notice.includes("Context running low")), false, "early guidance stays silent");
|
|
405
405
|
await fixture.session.prompt("Continue after reset.");
|
|
406
406
|
await fixture.session.waitForIdle();
|
|
407
407
|
assert.equal(fixture.budgetNotices(), 1, "later turns cannot repeat the consumed final warning");
|
|
408
|
-
assert.equal(fixture.notices.filter((notice) => notice === "🥣
|
|
408
|
+
assert.equal(fixture.notices.filter((notice) => notice === "🥣 Brain emptied").length, 1, "the prior reset notification is also deduplicated");
|
|
409
409
|
}
|
|
410
410
|
finally {
|
|
411
411
|
fixture.close();
|
|
@@ -417,7 +417,7 @@ test("real AgentSession: explicit tiny-session wipe ignores keepRecentTokens and
|
|
|
417
417
|
compactionEnabled: false,
|
|
418
418
|
keepRecentTokens: 1_000_000,
|
|
419
419
|
script: (request, context) => request === 1
|
|
420
|
-
? assistant(fixture, [{ type: "toolCall", id: "wipe-1", name: "empty_brain", arguments: {} }], "toolUse")
|
|
420
|
+
? assistant(fixture, [{ type: "toolCall", id: "wipe-1", name: "empty_brain", arguments: { last_word: "shoe" } }], "toolUse")
|
|
421
421
|
: assistant(fixture, [{ type: "text", text: "resumed in a new window" }]),
|
|
422
422
|
});
|
|
423
423
|
try {
|
|
@@ -425,7 +425,7 @@ test("real AgentSession: explicit tiny-session wipe ignores keepRecentTokens and
|
|
|
425
425
|
assert.equal(fixture.notices.length, 0, "startup boot is silent");
|
|
426
426
|
await fixture.session.prompt("OLD_CONTEXT_SENTINEL: retain this only in durable history.");
|
|
427
427
|
await fixture.session.waitForIdle();
|
|
428
|
-
assert.
|
|
428
|
+
assert.deepEqual(fixture.notices.filter((message) => message.includes("Brain emptied")), ["🥣 Brain emptied · last word: “shoe”"], "the reset notifies once, carrying the last word");
|
|
429
429
|
assert.equal(fixture.requests.length, 2, "the tool starts exactly one continuation");
|
|
430
430
|
assert.ok(text(fixture.requests[0]).includes("OLD_CONTEXT_SENTINEL"));
|
|
431
431
|
assertFreshRequest(fixture, 1, "OLD_CONTEXT_SENTINEL");
|
|
@@ -531,7 +531,7 @@ test("real AgentSession: clear commands append a prompt after continuation and r
|
|
|
531
531
|
assert.equal(appended.customType, "notesoup/reset-prompt");
|
|
532
532
|
assert.equal(appended.content, prompt);
|
|
533
533
|
assert.equal(appended.display, true);
|
|
534
|
-
assert.ok(fixture.notices.some((notice) => notice.includes("
|
|
534
|
+
assert.ok(fixture.notices.some((notice) => notice.includes("Brain emptied")));
|
|
535
535
|
}
|
|
536
536
|
finally {
|
|
537
537
|
fixture.close();
|
|
@@ -590,7 +590,7 @@ test("real AgentSession: streaming clear prompt keeps the first request", { time
|
|
|
590
590
|
await fixture.session.waitForIdle();
|
|
591
591
|
assert.equal(fixture.requests.length, 3);
|
|
592
592
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
593
|
-
assert.ok(fixture.notices.some((notice) => notice.includes("already
|
|
593
|
+
assert.ok(fixture.notices.some((notice) => notice.includes("Brain already being emptied")));
|
|
594
594
|
}
|
|
595
595
|
finally {
|
|
596
596
|
release();
|
|
@@ -621,7 +621,7 @@ test("real AgentSession: manual hard-reserve reset stops clean and mixed-tool tu
|
|
|
621
621
|
assert.equal(fixture.requests.length, 2);
|
|
622
622
|
assert.equal(resetMarkers(fixture).length, 1, "the safety wipe is not repeated at settlement");
|
|
623
623
|
assert.equal(JSON.stringify(fixture.sessionManager.buildSessionProjection().messages).includes("HARD_RESERVE_OLD_SENTINEL"), false);
|
|
624
|
-
assert.ok(fixture.notices.some((notice) => notice.includes("
|
|
624
|
+
assert.ok(fixture.notices.some((notice) => notice.includes("Brain emptied")));
|
|
625
625
|
if (mixed) {
|
|
626
626
|
assert.ok(existsSync(join(fixture.notesRoot, "pi", "session", fixture.sessionManager.getSessionId(), "pressure.md")), "the whole tool batch completes before the cut");
|
|
627
627
|
assert.equal(fixture.streamSignals.at(-1), true, "Pi's unavoidable tool follow-up is cancelled before provider work");
|
|
@@ -692,7 +692,7 @@ test("real AgentSession: manual overflow wipes and stops even with automatic res
|
|
|
692
692
|
assert.equal(fixture.requests.length, 2);
|
|
693
693
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
694
694
|
assert.equal(JSON.stringify(fixture.sessionManager.buildSessionProjection().messages).includes("MANUAL_OVERFLOW_OLD_SENTINEL"), false);
|
|
695
|
-
assert.ok(fixture.notices.some((notice) => notice.includes("
|
|
695
|
+
assert.ok(fixture.notices.some((notice) => notice.includes("Brain emptied")));
|
|
696
696
|
}
|
|
697
697
|
finally {
|
|
698
698
|
fixture.close();
|
|
@@ -722,7 +722,7 @@ test("real AgentSession: streaming /empty-brain steers a close-out and stops at
|
|
|
722
722
|
await started;
|
|
723
723
|
await fixture.session.prompt("/empty-brain", { streamingBehavior: "steer" });
|
|
724
724
|
await fixture.session.prompt("/empty-brain", { streamingBehavior: "followUp" });
|
|
725
|
-
assert.equal(fixture.notices.filter((notice) => notice.includes("
|
|
725
|
+
assert.equal(fixture.notices.filter((notice) => notice.includes("Brain being emptied")).length, 1, "the user is notified once while output is ongoing");
|
|
726
726
|
assert.equal(resetMarkers(fixture).length, 0, "the ongoing turn is not interrupted");
|
|
727
727
|
releaseResponse();
|
|
728
728
|
await running;
|
|
@@ -731,7 +731,7 @@ test("real AgentSession: streaming /empty-brain steers a close-out and stops at
|
|
|
731
731
|
assert.equal(fixture.requests.length, 2, "the warning closes out and the run stops — no continuation in the fresh window");
|
|
732
732
|
assert.equal(fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === MANUAL_WIPE_TYPE).length, 1, "the busy warning is persisted once");
|
|
733
733
|
assert.equal(JSON.stringify(fixture.sessionManager.buildSessionProjection().messages).includes("STREAMING_WIPE_OLD_SENTINEL"), false);
|
|
734
|
-
assert.ok(fixture.notices.some((notice) => notice.includes("
|
|
734
|
+
assert.ok(fixture.notices.some((notice) => notice.includes("Brain emptied")), "the committed boundary has a separate success notice");
|
|
735
735
|
}
|
|
736
736
|
finally {
|
|
737
737
|
releaseResponse();
|
|
@@ -796,7 +796,7 @@ test("real AgentSession: user abort, synthetic aborted response, and generic err
|
|
|
796
796
|
await fixture.session.waitForIdle();
|
|
797
797
|
assert.equal(resetMarkers(fixture).length, 0, `${mode} does not force a reset`);
|
|
798
798
|
assert.equal(fixture.sessionManager.getBranch().filter((entry) => entry.type === "compaction").length, 0);
|
|
799
|
-
assert.equal(fixture.notices.some((notice) => notice.includes("
|
|
799
|
+
assert.equal(fixture.notices.some((notice) => notice.includes("Brain emptied")), false);
|
|
800
800
|
if (mode === "ctx-abort")
|
|
801
801
|
assert.equal(fixture.streamSignals.at(-1), true, "this case aborts the real Pi operation signal");
|
|
802
802
|
else
|
|
@@ -86,7 +86,7 @@ test("the root boot and reset boot carry durable window identity", async () => {
|
|
|
86
86
|
assert.equal(boundary.continue, true);
|
|
87
87
|
await runHandlers(captured, "turn_start", {}, ctx);
|
|
88
88
|
await runHandlers(captured, "agent_settled", {}, ctx);
|
|
89
|
-
assert.equal(noticesOf(ctx).filter((notice) => notice.message.includes("
|
|
89
|
+
assert.equal(noticesOf(ctx).filter((notice) => notice.message.includes("Brain emptied")).length, 1, "the committed reset is announced once");
|
|
90
90
|
const entries = sessionManager.getBranch();
|
|
91
91
|
const marker = entries.find((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE);
|
|
92
92
|
assert.ok(marker && marker.type === "custom");
|
|
@@ -115,7 +115,7 @@ test("an aborted async boot repair emits no boot, continuation, or incomplete-no
|
|
|
115
115
|
controller.abort();
|
|
116
116
|
await pending;
|
|
117
117
|
assert.equal(captured.sent.length, 0, "aborted snapshot work cannot append the reset boot or continuation");
|
|
118
|
-
assert.equal(noticesOf(ctx).some((notice) => notice.message.includes("
|
|
118
|
+
assert.equal(noticesOf(ctx).some((notice) => notice.message.includes("went missing")), false, "aborted snapshot work cannot notify about missing homes");
|
|
119
119
|
assert.equal(sessionManager.getBranch().some((entry) => entry.type === "custom_message" && [BOOT_TYPE, CONTINUATION_TYPE].includes(entry.customType)), false);
|
|
120
120
|
});
|
|
121
121
|
test("a marker tail with only metadata repairs its missing boot and continuation without moving the boundary", async () => {
|
|
@@ -229,7 +229,7 @@ test("/empty-brain waits out non-agent busy work before starting its single-turn
|
|
|
229
229
|
assert.equal(waits, 1);
|
|
230
230
|
assert.equal(captured.sent.length, 1);
|
|
231
231
|
assert.equal(captured.sent[0]?.options?.triggerTurn, true);
|
|
232
|
-
assert.equal(notices.filter((message) => message.includes("
|
|
232
|
+
assert.equal(notices.filter((message) => message.includes("Brain being emptied")).length, 1);
|
|
233
233
|
});
|
|
234
234
|
test("notesoup command toggles future work, /empty-brain schedules a turn-end reset, and /compact remains disabled", async () => {
|
|
235
235
|
const sessionManager = manager();
|
|
@@ -252,7 +252,7 @@ test("notesoup command toggles future work, /empty-brain schedules a turn-end re
|
|
|
252
252
|
assert.match(notices[0]?.message ?? "", /on/);
|
|
253
253
|
notices = await runCommand(captured, "empty-brain", "", low);
|
|
254
254
|
assert.equal(notices.length, 1, "the command acknowledges the reset request");
|
|
255
|
-
assert.match(notices[0]?.message ?? "", /
|
|
255
|
+
assert.match(notices[0]?.message ?? "", /Brain being emptied/);
|
|
256
256
|
assert.equal(captured.sent.length, 2, "the command persists one hidden warning after the startup boot");
|
|
257
257
|
assert.equal(captured.sent[1]?.options?.triggerTurn, true, "the manual checkpoint prompt starts an ordinary agent turn");
|
|
258
258
|
assert.equal(captured.sent[1]?.message.customType, MANUAL_WIPE_TYPE);
|
|
@@ -283,7 +283,7 @@ test("committed reset confirmation survives later work while repair refuses that
|
|
|
283
283
|
assert.equal(resetBoundaryCommitted(ctx, marker.id, windowId), true, "later work does not undo a committed native boundary");
|
|
284
284
|
await runHandlers(captured, "agent_settled", {}, ctx);
|
|
285
285
|
await runHandlers(captured, "turn_start", {}, ctx);
|
|
286
|
-
assert.equal(noticesOf(ctx).filter((notice) => notice.message.includes("
|
|
286
|
+
assert.equal(noticesOf(ctx).filter((notice) => notice.message.includes("Brain emptied")).length, 1);
|
|
287
287
|
assert.equal(resetBoundaryCommitted(ctx, marker.id, "wrong-window"), false);
|
|
288
288
|
const partial = manager();
|
|
289
289
|
const partialCtx = context(partial);
|
|
@@ -40,7 +40,7 @@ test("early guidance stays silent and the committed final warning notifies once"
|
|
|
40
40
|
await commitTurnEndBoundary(captured, sm, final);
|
|
41
41
|
await runHandlers(captured, "turn_start", {}, final);
|
|
42
42
|
await runHandlers(captured, "agent_settled", {}, final);
|
|
43
|
-
assert.equal(noticesOf(final).filter((notice) => notice.message === "🥣
|
|
43
|
+
assert.equal(noticesOf(final).filter((notice) => notice.message === "🥣 Brain almost full · taking notes").length, 1, "only the committed final warning notifies, exactly once");
|
|
44
44
|
});
|
|
45
45
|
test("the visible countdown ends at the warning line, clamps at zero, and preserves unknown usage", async () => {
|
|
46
46
|
const fixture = settingsFixture({
|
|
@@ -116,7 +116,7 @@ test("Claude helper boot uses actual Claude note tool bindings and a fresh snaps
|
|
|
116
116
|
} });
|
|
117
117
|
assert.match(boot, /mcp__notesoup__notes_\*/);
|
|
118
118
|
assert.match(boot, /claude:session/);
|
|
119
|
-
assert.doesNotMatch(boot, /
|
|
119
|
+
assert.doesNotMatch(boot, /brain empty|continuation/);
|
|
120
120
|
});
|
|
121
121
|
test("Claude helper serves the shared reset prose and the host's wipe sentence", async () => {
|
|
122
122
|
const texts = await dispatch({ op: "texts" });
|
|
@@ -303,7 +303,7 @@ test("Claude Mod boot failure preserves fallback with available, absent, or fail
|
|
|
303
303
|
...upstream,
|
|
304
304
|
blocks: [...upstream.blocks, { name: "notesoup:boot", text: "# notesoup\nYour notes didn't load this time (helper exited unsuccessfully). Try `mcp__notesoup__notes_list`; if it fails too, tell the human." }],
|
|
305
305
|
}, "boot failure keeps the original fallback and upstream fields even if notify is absent or fails");
|
|
306
|
-
const expectedNotifications = mode === "no ui" || mode === "no toast" ? [] : ["🥣 Notes
|
|
306
|
+
const expectedNotifications = mode === "no ui" || mode === "no toast" ? [] : ["🥣 Notes went missing"];
|
|
307
307
|
assert.deepEqual(notifications, expectedNotifications, "one user-facing notification reports the notes boot failure");
|
|
308
308
|
assert.equal(bootRequests, 1);
|
|
309
309
|
assert.equal(nextCalls, 1);
|
|
@@ -371,7 +371,7 @@ test("Claude Mod resets at Claude's resolved point after the turn, retains one f
|
|
|
371
371
|
host.session.usage = async () => { throw new Error("usage unavailable"); };
|
|
372
372
|
await invoke("session.measure");
|
|
373
373
|
await invoke("turn.complete");
|
|
374
|
-
assert.equal(notifications.filter((text) => text.includes("
|
|
374
|
+
assert.equal(notifications.filter((text) => text.includes("Brain fullness unknown")).length, 1, "usage failure logs once per session");
|
|
375
375
|
host.session.usage = async () => measured();
|
|
376
376
|
await dispatch({ op: "tool", tool: "notes_write", identity: { ...identity, home, cwd: home, sessionId: "hook-session" }, params: { address: "@human/MAP.md", content: "FRESH_NOTES_AT_RESET" } });
|
|
377
377
|
await invoke("turn.start");
|
|
@@ -418,9 +418,9 @@ test("Claude Mod headless detection skips compaction and logs once", async (t) =
|
|
|
418
418
|
await invoke("session.measure");
|
|
419
419
|
await invoke("turn.complete");
|
|
420
420
|
assert.equal(attempts, 0, "headless sessions skip the unsupported capability from startup");
|
|
421
|
-
assert.deepEqual(notifications, ["🥣
|
|
421
|
+
assert.deepEqual(notifications, ["🥣 No brain when headless"]);
|
|
422
422
|
const manual = await invoke("command.run", { command: "empty-brain" });
|
|
423
|
-
assert.match(manual.text, /
|
|
423
|
+
assert.match(manual.text, /No brain when headless/);
|
|
424
424
|
assert.equal(notifications.length, 1);
|
|
425
425
|
const boot = await handlers.get("prompt.context")(host, {}, async () => ({ blocks: [] }));
|
|
426
426
|
assert.match(boot.blocks[0].text, /Current context window id: claude:hook-session:0/);
|
|
@@ -480,7 +480,7 @@ test("Claude Mod manual reset uses one hidden close-out turn, then recovers its
|
|
|
480
480
|
(await loadHookModule(t)).register((event, handler) => handlers.set(event, handler));
|
|
481
481
|
await invoke("session.start", { cwd: home, isInteractive: true });
|
|
482
482
|
const command = await invoke("command.run", { command: "empty-brain" });
|
|
483
|
-
assert.match(command.text, /
|
|
483
|
+
assert.match(command.text, /Brain being emptied/);
|
|
484
484
|
await Promise.resolve();
|
|
485
485
|
assert.equal(compactions, 0, "command.run must not call compact under its held turn");
|
|
486
486
|
assert.equal(timers.length, 1);
|
|
@@ -595,7 +595,7 @@ test("Claude Mod skips the automatic reset when thresholds cannot be resolved",
|
|
|
595
595
|
await invoke("turn.complete");
|
|
596
596
|
await invoke("session.measure");
|
|
597
597
|
assert.equal(compactions, 0, "an unresolvable point never resets");
|
|
598
|
-
assert.equal(notifications.filter((text) => text.includes("
|
|
598
|
+
assert.equal(notifications.filter((text) => text.includes("Brain size unknown")).length, 1, "one line, not one per turn");
|
|
599
599
|
});
|
|
600
600
|
test("Claude skill projections stay byte-identical to canonical shared files", () => {
|
|
601
601
|
assert.deepEqual(readFileSync(join(process.cwd(), "mods/notesoup/skills/memory/SKILL.md")), readFileSync(join(process.cwd(), "skills/memory/SKILL.md")));
|
|
@@ -272,8 +272,8 @@ test("reset construction failure preserves incoming and budget drafts without co
|
|
|
272
272
|
assert.deepEqual(result.entries, [incoming, budgetDraft], "already-built drafts survive reset construction failure");
|
|
273
273
|
assert.equal(result.continue, false, "a failed reset does not request continuation");
|
|
274
274
|
assert.equal(notices.at(-1)?.type, "warning");
|
|
275
|
-
assert.match(notices.at(-1)?.message ?? "", /
|
|
276
|
-
assert.match(notices.at(-1)?.message ?? "", /
|
|
275
|
+
assert.match(notices.at(-1)?.message ?? "", /Brain still full/);
|
|
276
|
+
assert.match(notices.at(-1)?.message ?? "", /prompt not sent/);
|
|
277
277
|
});
|
|
278
278
|
test("a stale async reset is discarded after a lifecycle switch without staging a notice", async () => {
|
|
279
279
|
const sessionManager = Manager.inMemory("/private/tmp/notesoup-stale-reset-test");
|
|
@@ -23,9 +23,9 @@ type ResetState = {
|
|
|
23
23
|
compactDisabled: boolean; limitsFailureLogged: boolean; limitsAttempts: number; limitsWindow: number
|
|
24
24
|
limits?: ClaudeLimits; warnedWindow?: number; texts?: SharedTexts; settingsFailureLogged: boolean
|
|
25
25
|
}
|
|
26
|
-
const HEADLESS = "
|
|
27
|
-
const COMPACT_DISABLED = "
|
|
28
|
-
const THRESHOLDS_UNAVAILABLE = "
|
|
26
|
+
const HEADLESS = "No brain when headless"
|
|
27
|
+
const COMPACT_DISABLED = "Brain can't be emptied with DISABLE_COMPACT"
|
|
28
|
+
const THRESHOLDS_UNAVAILABLE = "Brain size unknown · no automatic emptying"
|
|
29
29
|
const SETTINGS_UNAVAILABLE = "Notesoup settings unreadable · using the default flush margins"
|
|
30
30
|
/** Bounded retries: a transient helper failure must not disable thresholds for a whole window. */
|
|
31
31
|
const MAX_LIMITS_ATTEMPTS = 3
|
|
@@ -102,7 +102,7 @@ async function contextUsage($: Engine, state: ResetState): Promise<ContextUsage
|
|
|
102
102
|
} catch {
|
|
103
103
|
if (!state.usageFailureLogged) {
|
|
104
104
|
state.usageFailureLogged = true
|
|
105
|
-
log($, "
|
|
105
|
+
log($, "Brain fullness unknown · no automatic emptying")
|
|
106
106
|
}
|
|
107
107
|
return undefined
|
|
108
108
|
}
|
|
@@ -308,19 +308,19 @@ export function register(on: On) {
|
|
|
308
308
|
})
|
|
309
309
|
on("command.run", async ($, e, next) => {
|
|
310
310
|
if (e.command !== "empty-brain" && e.command !== "fresh-window") return next(e)
|
|
311
|
-
if (!await refreshIdentity($, state)) return { text: "🥣
|
|
311
|
+
if (!await refreshIdentity($, state)) return { text: "🥣 Different brain now · try /fresh-window again" }
|
|
312
312
|
if (state.headless) return { text: `🥣 ${HEADLESS}` }
|
|
313
313
|
if (state.compactDisabled) return { text: `🥣 ${COMPACT_DISABLED}` }
|
|
314
|
-
if (state.resetting || state.manualPending) return { text: "🥣
|
|
314
|
+
if (state.resetting || state.manualPending) return { text: "🥣 Brain already being emptied" }
|
|
315
315
|
if (state.turnRunning) {
|
|
316
316
|
state.manualPending = true
|
|
317
|
-
return { text: "🥣
|
|
317
|
+
return { text: "🥣 Brain being emptied" }
|
|
318
318
|
}
|
|
319
319
|
// command.run holds a turn even when idle. Start one hidden close-out
|
|
320
320
|
// turn after it returns; turn.complete is the verified self-hook path.
|
|
321
321
|
state.manualPending = true
|
|
322
322
|
manualSignal.wake?.()
|
|
323
|
-
return { text: "🥣
|
|
323
|
+
return { text: "🥣 Brain being emptied" }
|
|
324
324
|
})
|
|
325
325
|
on("session.compact", async ($, e, next) => {
|
|
326
326
|
if (e.agentId !== undefined) return next(e)
|
|
@@ -363,7 +363,7 @@ export function register(on: On) {
|
|
|
363
363
|
if (generation !== state.generation) return result
|
|
364
364
|
if (!boot.ok) {
|
|
365
365
|
try {
|
|
366
|
-
await $.ui.toast("🥣 Notes
|
|
366
|
+
await $.ui.toast("🥣 Notes went missing")
|
|
367
367
|
} catch { /* Notification failure must not suppress the fallback block. */ }
|
|
368
368
|
}
|
|
369
369
|
blocks = [...blocks, { name: "notesoup:boot", text: boot.ok ? String(boot.result) : `# notesoup\nYour notes didn't load this time (${boot.error}). Try \`${PREFIX}notes_list\`; if it fails too, tell the human.` }]
|
|
@@ -427,7 +427,7 @@ async function finishManual($: Engine, state: ResetState, signal: { wake?: () =>
|
|
|
427
427
|
if (generation !== state.generation) return
|
|
428
428
|
if (texts?.warning === undefined) {
|
|
429
429
|
state.manualPending = false
|
|
430
|
-
log($, "
|
|
430
|
+
log($, "Brain still full: the close-out prompt didn't load")
|
|
431
431
|
return
|
|
432
432
|
}
|
|
433
433
|
await $.prompt.submit({ text: texts.warning })
|
|
@@ -435,7 +435,7 @@ async function finishManual($: Engine, state: ResetState, signal: { wake?: () =>
|
|
|
435
435
|
} catch {
|
|
436
436
|
if (generation === state.generation) {
|
|
437
437
|
state.manualPending = false
|
|
438
|
-
log($, "
|
|
438
|
+
log($, "Brain still full: the close-out turn didn't start")
|
|
439
439
|
}
|
|
440
440
|
} finally { armManual($, state, signal) }
|
|
441
441
|
}
|
|
@@ -467,12 +467,12 @@ async function reset($: Engine, state: ResetState): Promise<void> {
|
|
|
467
467
|
const result = await $.session.compact({ instructions: RESET_INSTRUCTIONS })
|
|
468
468
|
if (generation !== state.generation) return
|
|
469
469
|
if (result.skip !== undefined || state.preparedBoot === undefined) {
|
|
470
|
-
log($, `
|
|
470
|
+
log($, `Brain not emptied · ${result.skip ?? "notes boot was not retained"}`)
|
|
471
471
|
return
|
|
472
472
|
}
|
|
473
473
|
state.retainedBoot = state.preparedBoot
|
|
474
474
|
state.window++
|
|
475
|
-
log($, "
|
|
475
|
+
log($, "Brain emptied")
|
|
476
476
|
} catch (error) {
|
|
477
477
|
if (generation !== state.generation) return
|
|
478
478
|
const text = String(error)
|
|
@@ -482,7 +482,7 @@ async function reset($: Engine, state: ResetState): Promise<void> {
|
|
|
482
482
|
} else if (/a turn is (running|in flight)/.test(text)) {
|
|
483
483
|
state.manualPending = true
|
|
484
484
|
} else {
|
|
485
|
-
log($, `
|
|
485
|
+
log($, `Brain still full: ${text.replace(/[\r\n].*$/s, "")}`)
|
|
486
486
|
}
|
|
487
487
|
} finally {
|
|
488
488
|
if (generation === state.generation) {
|
package/package.json
CHANGED
package/src/pi/budget.ts
CHANGED
|
@@ -64,7 +64,7 @@ export function registerBudget(
|
|
|
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
|
} else if (settled) {
|
|
69
69
|
// An uncommitted draft must not be matched to a later manual warning.
|
|
70
70
|
pendingNotices.delete(key);
|
|
@@ -250,7 +250,7 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
|
|
|
250
250
|
try {
|
|
251
251
|
resetDrafts = await options.buildReset(ctx, isCurrent, prompt, lastWord);
|
|
252
252
|
} catch (error) {
|
|
253
|
-
if (isCurrent()) ctx.ui.notify(`🥣
|
|
253
|
+
if (isCurrent()) ctx.ui.notify(`🥣 Brain still full: ${errorMessage(error)}${prompt ? " · prompt not sent" : ""}`, "warning");
|
|
254
254
|
return entries.length > 0 ? { entries } : undefined;
|
|
255
255
|
}
|
|
256
256
|
if (!isCurrent()) return entries.length > 0 ? { entries } : undefined;
|
|
@@ -323,7 +323,7 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
|
|
|
323
323
|
const markerExists = currentReset(ctx) !== undefined;
|
|
324
324
|
if (options.isEnabled() || markerExists) {
|
|
325
325
|
if (event.reason === "manual") {
|
|
326
|
-
ctx.ui.notify("🥣
|
|
326
|
+
ctx.ui.notify("🥣 No compacting brains here · use /fresh-window", "warning");
|
|
327
327
|
}
|
|
328
328
|
return { cancel: true };
|
|
329
329
|
}
|
package/src/pi/runtime.ts
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, type WindowMarker } 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, type IncompleteNotesNotifier } from "./boot.js";
|
|
13
13
|
import { errorMessage } from "../error-message.js";
|
|
@@ -71,7 +71,10 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
71
71
|
const marker = branch.find((entry): entry is WindowMarker => isWindowMarker(entry) && entry.data.windowId === windowId);
|
|
72
72
|
if (!marker || !isCheckpointBackedReset(ctx, marker) || !resetBoundaryCommitted(ctx, marker.id, windowId)) continue;
|
|
73
73
|
pendingResetNotices.delete(windowId);
|
|
74
|
-
|
|
74
|
+
const tail = branch.slice(branch.indexOf(marker) + 1);
|
|
75
|
+
const lastWordEntry = tail.find((entry) => (entry as { customType?: string }).customType === RESET_LAST_WORD_TYPE) as { content?: string } | undefined;
|
|
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));
|
|
@@ -83,7 +86,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
83
86
|
if (snapshot.unavailable.length === 0 || incompleteNotesNotified.has(windowId)) return;
|
|
84
87
|
incompleteNotesNotified.add(windowId);
|
|
85
88
|
const homes = snapshot.unavailable.map((home) => home.label).join(", ");
|
|
86
|
-
ctx.ui.notify(`🥣 Some notes
|
|
89
|
+
ctx.ui.notify(`🥣 Some notes went missing: ${homes}`, "warning");
|
|
87
90
|
};
|
|
88
91
|
const budget = registerBudget(pi, () => enabled, settingsManager);
|
|
89
92
|
|
|
@@ -110,7 +113,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
110
113
|
pi.on("session_before_tree", (event, ctx) => {
|
|
111
114
|
if (!event.preparation.userWantsSummary) return undefined;
|
|
112
115
|
if (!branchHasWindowMarker(ctx) && !branchHasWindowMarker(ctx, event.preparation.targetId)) return undefined;
|
|
113
|
-
ctx.ui.notify("🥣 Branch summary skipped · it
|
|
116
|
+
ctx.ui.notify("🥣 Branch summary skipped · it remembers too much", "info");
|
|
114
117
|
return { summary: { summary: "" } };
|
|
115
118
|
});
|
|
116
119
|
|
|
@@ -128,7 +131,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
128
131
|
} catch (error) {
|
|
129
132
|
if (missingBootNotice !== windowId) {
|
|
130
133
|
missingBootNotice = windowId;
|
|
131
|
-
ctx.ui.notify("🥣 Request cancelled ·
|
|
134
|
+
ctx.ui.notify("🥣 Request cancelled · brain is broken, run /fresh-window", "error");
|
|
132
135
|
}
|
|
133
136
|
ctx.abort();
|
|
134
137
|
const safeHead = getCurrentSystemMessage(event.messages);
|
|
@@ -167,7 +170,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
167
170
|
description: "Flush memory to notes and continue in a fresh window; optional prompt runs there",
|
|
168
171
|
handler: async (args: string, cmdCtx: ExtensionCommandContext) => {
|
|
169
172
|
if (!enabled) {
|
|
170
|
-
cmdCtx.ui.notify("🥣 notesoup is off ·
|
|
173
|
+
cmdCtx.ui.notify("🥣 notesoup is off · no brain to empty", "error");
|
|
171
174
|
return;
|
|
172
175
|
}
|
|
173
176
|
const requestedWindowId = currentWindowId(cmdCtx);
|
|
@@ -181,17 +184,15 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
181
184
|
const prompt = args.trim() || undefined;
|
|
182
185
|
const armed = resets.closeOut(requestedWindowId, "manual", prompt);
|
|
183
186
|
if (armed === "already-pending") {
|
|
184
|
-
cmdCtx.ui.notify("🥣
|
|
187
|
+
cmdCtx.ui.notify("🥣 Brain already being emptied", "info");
|
|
185
188
|
return;
|
|
186
189
|
}
|
|
187
|
-
cmdCtx.ui.notify(
|
|
188
|
-
? "🥣 Clearing memory · notes first, then your prompt runs"
|
|
189
|
-
: "🥣 Clearing memory · notes first, then it stops", "info");
|
|
190
|
+
cmdCtx.ui.notify("🥣 Brain being emptied", "info");
|
|
190
191
|
try {
|
|
191
192
|
pi.sendMessage({ customType: MANUAL_WIPE_TYPE, content: WARNING_CONTENT, display: false }, { triggerTurn: true, deliverAs: "steer" });
|
|
192
193
|
} catch (error) {
|
|
193
194
|
resets.clear();
|
|
194
|
-
cmdCtx.ui.notify(`🥣
|
|
195
|
+
cmdCtx.ui.notify(`🥣 Brain refused to empty: ${errorMessage(error)}`, "error");
|
|
195
196
|
}
|
|
196
197
|
},
|
|
197
198
|
};
|