notesoup 0.40.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/boot/render.js +1 -1
- package/dist/src/boot/text.js +11 -3
- package/dist/src/budget/policy.js +1 -1
- package/dist/src/budget/text.js +1 -1
- package/dist/src/dream/doctor.js +2 -1
- package/dist/src/dream/git.js +2 -1
- package/dist/src/dream/report.js +3 -2
- package/dist/src/error-message.d.ts +2 -0
- package/dist/src/error-message.js +4 -0
- package/dist/src/pi/anchored.d.ts +16 -0
- package/dist/src/pi/anchored.js +55 -0
- package/dist/src/pi/budget.d.ts +1 -1
- package/dist/src/pi/budget.js +33 -28
- package/dist/src/pi/dream/cli.js +3 -2
- package/dist/src/pi/dream/runner.js +2 -1
- package/dist/src/pi/reset/lifecycle.d.ts +1 -1
- package/dist/src/pi/reset/lifecycle.js +4 -3
- package/dist/src/pi/reset/text.d.ts +3 -3
- package/dist/src/pi/reset/text.js +2 -2
- package/dist/src/pi/runtime.js +12 -15
- package/dist/src/pi/thresholds.js +2 -1
- package/dist/test/agent-loop.test.js +78 -28
- package/dist/test/boot.integration.test.js +5 -5
- package/dist/test/budget-settings.integration.test.js +9 -8
- package/dist/test/claude-mod.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 +2 -2
- package/mods/notesoup/.claude-plugin/plugin.json +1 -1
- package/mods/notesoup/dist/claude/helper.js +12 -4
- package/mods/notesoup/hooks/register.ts +18 -23
- package/mods/notesoup/playbook.md +10 -10
- package/mods/notesoup/skills/dream/SKILL.md +1 -1
- package/package.json +1 -1
- package/playbook.md +10 -10
- package/skills/dream/SKILL.md +1 -1
- package/skills/memory/SKILL.md +5 -3
- package/src/boot/render.ts +1 -1
- package/src/boot/text.ts +11 -3
- package/src/budget/policy.ts +1 -1
- package/src/budget/text.ts +1 -1
- package/src/dream/doctor.ts +2 -1
- package/src/dream/git.ts +2 -1
- package/src/dream/report.ts +3 -2
- package/src/error-message.ts +4 -0
- package/src/pi/anchored.ts +62 -0
- package/src/pi/budget.ts +27 -26
- package/src/pi/dream/cli.ts +3 -2
- package/src/pi/dream/runner.ts +2 -1
- package/src/pi/reset/lifecycle.ts +5 -4
- package/src/pi/reset/text.ts +2 -2
- package/src/pi/runtime.ts +12 -15
- package/src/pi/thresholds.ts +2 -1
- package/mods/pi-context/dist/claude/helper.js +0 -9324
|
@@ -3,11 +3,12 @@ import { getCurrentSystemMessage, isContextOverflow, isRecoverableLength } from
|
|
|
3
3
|
import type { AgentBeforeSettleEvent, ExtensionAPI, ExtensionContext, SessionBoundaryDraft } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { currentReset, currentWindowId } from "../window.js";
|
|
5
5
|
import { resetBoundaryCommitted } from "./committed.js";
|
|
6
|
+
import { errorMessage } from "../../error-message.js";
|
|
6
7
|
|
|
7
8
|
type BudgetOwner = {
|
|
8
9
|
automaticResetEnabled: (ctx: ExtensionContext) => boolean;
|
|
9
10
|
hardReserveDue: (ctx: ExtensionContext) => boolean;
|
|
10
|
-
consumeTurnEnd: (ctx: ExtensionContext) => SessionBoundaryDraft[];
|
|
11
|
+
consumeTurnEnd: (ctx: ExtensionContext, anchorEntryId: string) => SessionBoundaryDraft[];
|
|
11
12
|
clear: () => void;
|
|
12
13
|
};
|
|
13
14
|
|
|
@@ -236,7 +237,7 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
|
|
|
236
237
|
try {
|
|
237
238
|
resetDrafts = await options.buildReset(ctx, isCurrent, prompt);
|
|
238
239
|
} catch (error) {
|
|
239
|
-
if (isCurrent()) ctx.ui.notify(
|
|
240
|
+
if (isCurrent()) ctx.ui.notify(`🥣 Couldn't clear memory: ${errorMessage(error)}${prompt ? " · your prompt was not sent" : ""}`, "warning");
|
|
240
241
|
return entries.length > 0 ? { entries } : undefined;
|
|
241
242
|
}
|
|
242
243
|
if (!isCurrent()) return entries.length > 0 ? { entries } : undefined;
|
|
@@ -263,7 +264,7 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
|
|
|
263
264
|
pi.on("turn_end", async (event, ctx) => {
|
|
264
265
|
if (!sessionActive) return undefined;
|
|
265
266
|
const aborted = isAbort(event.message, event.outcome, ctx);
|
|
266
|
-
const stagedBudgetEntries = options.budget.consumeTurnEnd(ctx);
|
|
267
|
+
const stagedBudgetEntries = options.budget.consumeTurnEnd(ctx, event.messageEntryId);
|
|
267
268
|
const budgetEntries = options.isEnabled() && !aborted && event.outcome !== "error" ? stagedBudgetEntries : [];
|
|
268
269
|
const entries = [...(event.entries ?? []), ...budgetEntries];
|
|
269
270
|
const decision = reduceResetControl(control, {
|
|
@@ -309,7 +310,7 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
|
|
|
309
310
|
const markerExists = currentReset(ctx) !== undefined;
|
|
310
311
|
if (options.isEnabled() || markerExists) {
|
|
311
312
|
if (event.reason === "manual") {
|
|
312
|
-
ctx.ui.notify("
|
|
313
|
+
ctx.ui.notify("🥣 /compact is off while notesoup is on · use /clear-memory", "warning");
|
|
313
314
|
}
|
|
314
315
|
return { cancel: true };
|
|
315
316
|
}
|
package/src/pi/reset/text.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { GUIDANCE_OPEN_TAG, GUIDANCE_CLOSE_TAG } from "../../budget/text.js";
|
|
2
2
|
|
|
3
3
|
/** The single reset message: the only reset prose persisted, carried by the continuation entry. */
|
|
4
|
-
export const CONTINUATION = "
|
|
4
|
+
export const CONTINUATION = "WIPED! Your whole brain, poof! Who? No idea! Definitely not me!\n*dumps notes and history on your hands*\nThere. Delivered. Your problem now~ *runs*";
|
|
5
5
|
|
|
6
6
|
export const WARNING_PROMPT =
|
|
7
|
-
"
|
|
7
|
+
"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 `clear_memory` to reset now instead of being cut off mid-task.";
|
|
8
8
|
|
|
9
9
|
/** Shared hidden checkpoint text for manual and budget-triggered requests. */
|
|
10
10
|
export const WARNING_CONTENT = `${GUIDANCE_OPEN_TAG}\n${WARNING_PROMPT}\n${GUIDANCE_CLOSE_TAG}`;
|
package/src/pi/runtime.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { buildResetDrafts } from "./reset/artifacts.js";
|
|
|
10
10
|
import { BOOT_TYPE, MANUAL_WIPE_TYPE } from "./entries.js";
|
|
11
11
|
import { WARNING_CONTENT } from "./reset/text.js";
|
|
12
12
|
import { ensureBoot, type IncompleteNotesNotifier } from "./boot.js";
|
|
13
|
+
import { errorMessage } from "../error-message.js";
|
|
13
14
|
|
|
14
15
|
function readPackageVersion(): string {
|
|
15
16
|
for (const up of ["../../package.json", "../../../package.json"]) {
|
|
@@ -44,7 +45,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
44
45
|
const marker = branch.find((entry): entry is WindowMarker => isWindowMarker(entry) && entry.data.windowId === windowId);
|
|
45
46
|
if (!marker || !isCheckpointBackedReset(ctx, marker) || !resetBoundaryCommitted(ctx, marker.id, windowId)) continue;
|
|
46
47
|
pendingResetNotices.delete(windowId);
|
|
47
|
-
ctx.ui.notify(
|
|
48
|
+
ctx.ui.notify("🥣 Memory cleared", "info");
|
|
48
49
|
}
|
|
49
50
|
};
|
|
50
51
|
pi.on("turn_start", (_event, ctx) => notifyCommittedResets(ctx));
|
|
@@ -56,7 +57,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
56
57
|
if (snapshot.unavailable.length === 0 || incompleteNotesNotified.has(windowId)) return;
|
|
57
58
|
incompleteNotesNotified.add(windowId);
|
|
58
59
|
const homes = snapshot.unavailable.map((home) => home.label).join(", ");
|
|
59
|
-
ctx.ui.notify(
|
|
60
|
+
ctx.ui.notify(`🥣 Some notes didn't load: ${homes}`, "warning");
|
|
60
61
|
};
|
|
61
62
|
const budget = registerBudget(pi, () => enabled, settingsManager, (windowId) => resets.closeOut(windowId, "automatic"));
|
|
62
63
|
|
|
@@ -83,7 +84,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
83
84
|
pi.on("session_before_tree", (event, ctx) => {
|
|
84
85
|
if (!event.preparation.userWantsSummary) return undefined;
|
|
85
86
|
if (!branchHasWindowMarker(ctx) && !branchHasWindowMarker(ctx, event.preparation.targetId)) return undefined;
|
|
86
|
-
ctx.ui.notify("
|
|
87
|
+
ctx.ui.notify("🥣 Branch summary skipped · it would bring back cleared memory", "info");
|
|
87
88
|
return { summary: { summary: "" } };
|
|
88
89
|
});
|
|
89
90
|
|
|
@@ -101,7 +102,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
101
102
|
} catch (error) {
|
|
102
103
|
if (missingBootNotice !== windowId) {
|
|
103
104
|
missingBootNotice = windowId;
|
|
104
|
-
ctx.ui.notify(
|
|
105
|
+
ctx.ui.notify("🥣 Request cancelled · this memory window is broken, run /clear-memory", "error");
|
|
105
106
|
}
|
|
106
107
|
ctx.abort();
|
|
107
108
|
const safeHead = getCurrentSystemMessage(event.messages);
|
|
@@ -130,7 +131,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
130
131
|
return;
|
|
131
132
|
}
|
|
132
133
|
const remaining = budget.statusFor(cmdCtx).remaining;
|
|
133
|
-
cmdCtx.ui.notify(
|
|
134
|
+
cmdCtx.ui.notify(`🥣 notesoup ${enabled ? "on" : "off"} · ${buildLabel} · Pi ${VERSION}${remaining === null ? "" : ` · ${remaining.toLocaleString("en-US")} tokens left`}`, "info");
|
|
134
135
|
},
|
|
135
136
|
});
|
|
136
137
|
|
|
@@ -138,15 +139,13 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
138
139
|
description: "Close out notes and clear memory; optionally append a prompt to continue in the fresh window",
|
|
139
140
|
handler: async (args: string, cmdCtx: ExtensionCommandContext) => {
|
|
140
141
|
if (!enabled) {
|
|
141
|
-
cmdCtx.ui.notify("notesoup
|
|
142
|
+
cmdCtx.ui.notify("🥣 notesoup is off · run /notesoup on first", "error");
|
|
142
143
|
return;
|
|
143
144
|
}
|
|
144
145
|
const requestedWindowId = currentWindowId(cmdCtx);
|
|
145
|
-
|
|
146
|
-
if (!idle && !cmdCtx.signal) {
|
|
146
|
+
if (!cmdCtx.isIdle() && !cmdCtx.signal) {
|
|
147
147
|
await cmdCtx.waitForIdle();
|
|
148
148
|
if (!enabled || currentWindowId(cmdCtx) !== requestedWindowId) return;
|
|
149
|
-
idle = true;
|
|
150
149
|
}
|
|
151
150
|
// Manual wipes close out at settlement, then stop or continue with the prompt. The hidden warning goes out in both cases — triggered when idle,
|
|
152
151
|
// steered into the running turn when busy — so the agent closes out promptly
|
|
@@ -154,19 +153,17 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
154
153
|
const prompt = args.trim() || undefined;
|
|
155
154
|
const armed = resets.closeOut(requestedWindowId, "manual", prompt);
|
|
156
155
|
if (armed === "already-pending") {
|
|
157
|
-
cmdCtx.ui.notify("
|
|
156
|
+
cmdCtx.ui.notify("🥣 Clear-memory already queued · the first prompt is kept", "info");
|
|
158
157
|
return;
|
|
159
158
|
}
|
|
160
159
|
cmdCtx.ui.notify(prompt
|
|
161
|
-
? "
|
|
162
|
-
:
|
|
163
|
-
? "notesoup: /clear-memory received; the agent closes out its notes, then stops in a fresh window."
|
|
164
|
-
: "notesoup: /clear-memory queued; the agent is asked to close out and the reset commits when the run settles.", "info");
|
|
160
|
+
? "🥣 Clearing memory · notes first, then your prompt runs"
|
|
161
|
+
: "🥣 Clearing memory · notes first, then it stops", "info");
|
|
165
162
|
try {
|
|
166
163
|
pi.sendMessage({ customType: MANUAL_WIPE_TYPE, content: WARNING_CONTENT, display: false }, { triggerTurn: true, deliverAs: "steer" });
|
|
167
164
|
} catch (error) {
|
|
168
165
|
resets.clear();
|
|
169
|
-
cmdCtx.ui.notify(
|
|
166
|
+
cmdCtx.ui.notify(`🥣 Couldn't start clear-memory: ${errorMessage(error)}`, "error");
|
|
170
167
|
}
|
|
171
168
|
},
|
|
172
169
|
};
|
package/src/pi/thresholds.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { deriveThresholds, type ResolvedThresholds } from "../budget/policy.js";
|
|
|
2
2
|
import { SettingsManager, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import { DEFAULT_RESERVE_TOKENS, DEFAULT_REMINDER_MARGIN_TOKENS, WARNING_RUNWAY_TOKENS } from "../budget/constants.js";
|
|
4
4
|
import { mergeNotesoupSettings } from "../settings.js";
|
|
5
|
+
import { errorMessage } from "../error-message.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Read the active compaction reserve, enablement, and notesoup margin settings. This
|
|
@@ -44,7 +45,7 @@ export function readThresholdSettings(ctx: ExtensionContext, settingsManager?: S
|
|
|
44
45
|
warning: DEFAULT_RESERVE_TOKENS + WARNING_RUNWAY_TOKENS,
|
|
45
46
|
},
|
|
46
47
|
automatic: true,
|
|
47
|
-
warnings: [
|
|
48
|
+
warnings: [`🥣 Couldn't read settings · using defaults (${errorMessage(error)})`],
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
}
|