notesoup 0.48.1 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/boot/snapshot.js +10 -3
- package/dist/src/budget/text.js +1 -1
- package/dist/src/notes/address.js +0 -2
- package/dist/src/notes/errors.d.ts +1 -1
- package/dist/src/notes/store.d.ts +4 -10
- package/dist/src/notes/store.js +42 -72
- package/dist/src/pi/runtime.js +3 -3
- package/dist/src/tools/notes.js +8 -14
- package/dist/test/agent-loop.test.js +15 -15
- package/dist/test/boot.integration.test.js +5 -5
- package/dist/test/claude-mod.test.js +10 -5
- package/dist/test/dependencies.test.js +1 -1
- package/dist/test/host-neutral.test.js +12 -0
- package/dist/test/model-facing-text.test.js +2 -2
- package/dist/test/notes-library.test.js +67 -10
- package/dist/test/notes.integration.test.js +9 -9
- package/dist/test/notes.test.js +46 -13
- package/dist/test/reset-lifecycle.test.js +31 -9
- package/docs/dsh.md +1 -1
- package/docs/notes-library.md +7 -7
- package/docs/reset-lifecycle.md +2 -2
- package/mods/notesoup/.claude-plugin/plugin.json +1 -1
- package/mods/notesoup/dist/claude/helper.js +51 -76
- package/mods/notesoup/hooks/register.ts +2 -2
- package/package.json +1 -1
- package/src/boot/snapshot.ts +9 -3
- package/src/budget/text.ts +1 -1
- package/src/notes/address.ts +0 -1
- package/src/notes/errors.ts +1 -1
- package/src/notes/store.ts +41 -73
- package/src/pi/runtime.ts +3 -3
- package/src/tools/notes.ts +8 -14
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 `/empty
|
|
31
|
+
- **Durable context windows.** `/fresh-window` (alias `/empty`) 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`** — how much room the brain has left before the hard-reserve wipe, including the warning runway.
|
|
34
34
|
- **Eight history/notes tools**, flattened from the original Codex actions:
|
|
@@ -16,13 +16,20 @@ export function unavailableNotesSnapshot(openedAt) {
|
|
|
16
16
|
* malformed note data and unrelated construction errors remain visible to the caller.
|
|
17
17
|
*/
|
|
18
18
|
export async function loadNotesSnapshot(identity, openedAt, loadHome) {
|
|
19
|
-
const store = createNotesStore(identity);
|
|
20
|
-
const load = loadHome ?? ((scope) => store.list({ scope }));
|
|
21
19
|
const homes = new Map();
|
|
22
20
|
const unavailable = [];
|
|
21
|
+
if (!loadHome) {
|
|
22
|
+
const { rows, status } = await createNotesStore(identity).listWithStatus();
|
|
23
|
+
for (const home of NOTES_HOMES) {
|
|
24
|
+
homes.set(home.scope, rows.filter(row => row.scope === home.scope));
|
|
25
|
+
if (status.homesUnavailable.some(address => home.scope === "session" ? !address.startsWith("@") : address === home.label || address.startsWith(`${home.label}/`)))
|
|
26
|
+
unavailable.push(home);
|
|
27
|
+
}
|
|
28
|
+
return { openedAt, homes, unavailable };
|
|
29
|
+
}
|
|
23
30
|
for (const home of NOTES_HOMES) {
|
|
24
31
|
try {
|
|
25
|
-
homes.set(home.scope, await
|
|
32
|
+
homes.set(home.scope, await loadHome(home.scope));
|
|
26
33
|
}
|
|
27
34
|
catch (error) {
|
|
28
35
|
if (!isFilesystemError(error))
|
package/dist/src/budget/text.js
CHANGED
|
@@ -34,7 +34,7 @@ export const WARNING_CALL = "When the notes are ready, call `empty_brain` to res
|
|
|
34
34
|
*/
|
|
35
35
|
export const WARNING_CALL_PROMPTED = "Organize the notes first, then call `empty_brain` right away — do not wait to be cut off.";
|
|
36
36
|
/**
|
|
37
|
-
* The human typed `/empty
|
|
37
|
+
* The human typed `/empty <prompt>`: the raw command line leads the close-out so the
|
|
38
38
|
* closing model sees what the next window was asked to do, verbatim. The tag names it as the
|
|
39
39
|
* next window's prompt, so no prose has to explain that.
|
|
40
40
|
*/
|
|
@@ -80,8 +80,6 @@ export function assertAddress(value) {
|
|
|
80
80
|
if (path === "" && who === undefined)
|
|
81
81
|
throw new NoteError("invalid_address", `${shown(value)} isn't a note address. ${ADDRESS_FORMS}`);
|
|
82
82
|
}
|
|
83
|
-
if (path.includes("@"))
|
|
84
|
-
throw new NoteError("invalid_address", `${shown(value)} isn't a note address. ${ADDRESS_FORMS}`);
|
|
85
83
|
assertVirtualPath(path);
|
|
86
84
|
return { scope, path, who };
|
|
87
85
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type NoteErrorCode = "not_found" | "already_exists" | "ambiguous_edit" | "no_match" | "nothing_to_do" | "too_large" | "invalid_scope" | "invalid_origin" | "invalid_address" | "invalid_pattern" | "invalid_query" | "invalid_offset" | "io_error" | "internal_error";
|
|
1
|
+
export type NoteErrorCode = "not_found" | "already_exists" | "ambiguous_edit" | "no_match" | "invalid_edit" | "nothing_to_do" | "too_large" | "invalid_scope" | "invalid_origin" | "invalid_address" | "invalid_pattern" | "invalid_query" | "invalid_offset" | "io_error" | "internal_error";
|
|
2
2
|
/** Typed store refusal. Edit locations are exposed in camelCase. */
|
|
3
3
|
export declare class NoteError extends Error {
|
|
4
4
|
readonly code: NoteErrorCode;
|
|
@@ -34,17 +34,9 @@ export type EditOptions = {
|
|
|
34
34
|
origin?: Origin;
|
|
35
35
|
crumpled?: boolean;
|
|
36
36
|
replaceAll?: boolean;
|
|
37
|
+
renameTo?: string;
|
|
37
38
|
};
|
|
38
|
-
export type NotesQuery =
|
|
39
|
-
scope?: undefined;
|
|
40
|
-
who?: never;
|
|
41
|
-
} | {
|
|
42
|
-
scope: "session" | "project" | "human";
|
|
43
|
-
who?: never;
|
|
44
|
-
} | {
|
|
45
|
-
scope: "agent" | "model";
|
|
46
|
-
who?: string;
|
|
47
|
-
}) & {
|
|
39
|
+
export type NotesQuery = {
|
|
48
40
|
glob?: string;
|
|
49
41
|
crumpled?: boolean;
|
|
50
42
|
};
|
|
@@ -72,6 +64,8 @@ export type NoteEditResult = {
|
|
|
72
64
|
applied: number;
|
|
73
65
|
resolvedScope: Scope;
|
|
74
66
|
change: NoteChange;
|
|
67
|
+
moved: boolean;
|
|
68
|
+
replacedCrumpledTarget: boolean;
|
|
75
69
|
};
|
|
76
70
|
export type NoteRenameResult = {
|
|
77
71
|
meta: NoteMeta;
|
package/dist/src/notes/store.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { mkdir, readdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { mkdir, readdir, readFile, realpath, rename, rm, writeFile } from "node:fs/promises";
|
|
3
3
|
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { earliestMatchOffsetChars } from "../text-match.js";
|
|
5
5
|
import { assertAddress, assertGlobPattern, addressFor, canonicalAddressFor, globToRegExp, HOME_HEADS } from "./address.js";
|
|
@@ -7,7 +7,7 @@ import { isFilesystemError } from "./fs-error.js";
|
|
|
7
7
|
import { snapshotNotesIdentity } from "./identity.js";
|
|
8
8
|
import { NoteError } from "./errors.js";
|
|
9
9
|
import { MAX_NOTE_BYTES, MAX_NOTE_PATH_BYTES } from "./constants.js";
|
|
10
|
-
import { isOrigin,
|
|
10
|
+
import { isOrigin, localIso, parseNote, serializeNote, stripLeadingFrontmatter } from "./frontmatter.js";
|
|
11
11
|
import { namespaceSlugs, noteFileName, physicalPath, scopeDir, SLUG_PATTERN } from "./paths.js";
|
|
12
12
|
import { projectHomes, projectReceipt } from "./project-home.js";
|
|
13
13
|
// Recency sorts tie-break by address, so two writes sharing one Date.now() tick would silently invert the recent-first contract. Write stamps are strictly increasing per process.
|
|
@@ -112,23 +112,6 @@ function assertWho(value) {
|
|
|
112
112
|
}
|
|
113
113
|
return value;
|
|
114
114
|
}
|
|
115
|
-
async function homesFor(identity, opts) {
|
|
116
|
-
if (opts.scope !== undefined) {
|
|
117
|
-
if (!isScope(opts.scope))
|
|
118
|
-
throw new NoteError("invalid_scope", `scope must be one of session, project, human, agent, model (got ${JSON.stringify(opts.scope)})`);
|
|
119
|
-
const scope = opts.scope;
|
|
120
|
-
if (opts.who !== undefined) {
|
|
121
|
-
const who = assertWho(opts.who);
|
|
122
|
-
if (scope !== "agent" && scope !== "model")
|
|
123
|
-
throw new NoteError("invalid_scope", "who is only valid with agent or model scope");
|
|
124
|
-
return [{ scope, who }];
|
|
125
|
-
}
|
|
126
|
-
return [{ scope }];
|
|
127
|
-
}
|
|
128
|
-
if (opts.who !== undefined)
|
|
129
|
-
throw new NoteError("invalid_scope", "who requires agent or model scope");
|
|
130
|
-
return await homesForPattern(normalizePattern(opts.glob, identity), identity) ?? SCOPE_ORDER.map((scope) => ({ scope }));
|
|
131
|
-
}
|
|
132
115
|
/**
|
|
133
116
|
* Line numbers (1-based) of every occurrence of `needle` in `body`. The scan walks forward
|
|
134
117
|
* once, counting newlines as it goes, so a body that repeats one anchor thousands of times
|
|
@@ -270,30 +253,46 @@ export function createNotesStore(input) {
|
|
|
270
253
|
async function update(address, edits, options = {}) {
|
|
271
254
|
const operations = edits === undefined ? [] : edits.map((operation) => ({ ...operation }));
|
|
272
255
|
const stableOptions = { ...options };
|
|
273
|
-
const
|
|
256
|
+
const from = assertAddress(address);
|
|
257
|
+
const destination = stableOptions.renameTo === undefined ? from : assertAddress(stableOptions.renameTo);
|
|
274
258
|
assertWritablePath(destination.path);
|
|
275
259
|
const scope = destination.scope;
|
|
260
|
+
assertWritableHome(from.scope, from.who, identity);
|
|
276
261
|
assertWritableHome(scope, destination.who, identity);
|
|
277
|
-
if (operations.length === 0 && stableOptions.origin === undefined && stableOptions.crumpled === undefined) {
|
|
278
|
-
throw new NoteError("nothing_to_do", "Nothing to change:
|
|
262
|
+
if (operations.length === 0 && stableOptions.origin === undefined && stableOptions.crumpled === undefined && stableOptions.renameTo === undefined) {
|
|
263
|
+
throw new NoteError("nothing_to_do", "Nothing to change: provide edits, an origin, a crumpled state, or a new address.");
|
|
279
264
|
}
|
|
265
|
+
const fromPath = physicalPath(from.scope, from.path, identity, from.who);
|
|
280
266
|
const path = physicalPath(scope, destination.path, identity, destination.who);
|
|
281
|
-
|
|
282
|
-
|
|
267
|
+
const differentPaths = resolve(fromPath) !== resolve(path);
|
|
268
|
+
const mutate = async () => {
|
|
269
|
+
const raw = await readFileIfExists(fromPath);
|
|
283
270
|
if (raw === undefined)
|
|
284
271
|
throw new NoteError("not_found", `No note at ${noteIdentity(identity, address).address}.`);
|
|
272
|
+
const targetRaw = differentPaths ? await readFileIfExists(path) : undefined;
|
|
273
|
+
// Case and symlink aliases must not turn write-then-remove into deleting the result.
|
|
274
|
+
const sourceReal = targetRaw === undefined ? undefined : await realpath(fromPath);
|
|
275
|
+
const sameFile = sourceReal !== undefined && sourceReal === await realpath(path);
|
|
276
|
+
const moved = differentPaths && !sameFile;
|
|
277
|
+
if (moved && targetRaw !== undefined && parseNote(targetRaw).meta.crumpledAt === undefined) {
|
|
278
|
+
throw new NoteError("already_exists", `${noteIdentity(identity, stableOptions.renameTo).address} already holds a note; crumple it first or pick another address.`);
|
|
279
|
+
}
|
|
285
280
|
const { meta, body } = parseNote(raw);
|
|
286
|
-
meta.scope = scope;
|
|
287
281
|
const beforeMeta = { ...meta };
|
|
282
|
+
meta.scope = scope;
|
|
283
|
+
if (from.scope !== "session" && scope === "session")
|
|
284
|
+
meta.project = identity.projectKey;
|
|
285
|
+
if (from.scope === "session" && scope !== "session")
|
|
286
|
+
delete meta.project;
|
|
288
287
|
let next = body;
|
|
289
288
|
let applied = 0;
|
|
290
289
|
operations.forEach((operation, index) => {
|
|
291
290
|
const oldText = operation?.oldText;
|
|
292
291
|
const newText = operation?.newText;
|
|
293
292
|
if (typeof oldText !== "string" || oldText.length === 0)
|
|
294
|
-
throw new NoteError("
|
|
293
|
+
throw new NoteError("invalid_edit", `edits[${index}].oldText must be a non-empty string.`, { editIndex: index });
|
|
295
294
|
if (typeof newText !== "string")
|
|
296
|
-
throw new NoteError("
|
|
295
|
+
throw new NoteError("invalid_edit", `edits[${index}].newText must be a string.`, { editIndex: index });
|
|
297
296
|
const lines = matchLineNumbers(next, oldText);
|
|
298
297
|
if (lines.length === 0)
|
|
299
298
|
throw new NoteError("no_match", `edits[${index}].oldText isn't in the note${index > 0 ? " (after the earlier edits)" : ""}. Nothing was saved.`, { editIndex: index });
|
|
@@ -318,7 +317,7 @@ export function createNotesStore(input) {
|
|
|
318
317
|
delete meta.crumpledAt;
|
|
319
318
|
const bodyChanged = body !== next;
|
|
320
319
|
const originChanged = beforeMeta.origin !== meta.origin;
|
|
321
|
-
if (bodyChanged || originChanged)
|
|
320
|
+
if (bodyChanged || originChanged || moved)
|
|
322
321
|
meta.updatedAt = writeStamp();
|
|
323
322
|
const serialized = serializeNote(meta, next);
|
|
324
323
|
assertSerializedSize(serialized);
|
|
@@ -326,7 +325,7 @@ export function createNotesStore(input) {
|
|
|
326
325
|
let change;
|
|
327
326
|
// A body edit that also rewrites frontmatter is still a body change; its diff inputs span the
|
|
328
327
|
// whole serialized file, so the frontmatter part stays visible in the diff.
|
|
329
|
-
if (bodyChanged && metadataChanged)
|
|
328
|
+
if (bodyChanged && (metadataChanged || moved))
|
|
330
329
|
change = { kind: "body", before: raw, after: serialized };
|
|
331
330
|
else if (bodyChanged)
|
|
332
331
|
change = { kind: "body", before: body, after: next };
|
|
@@ -334,50 +333,21 @@ export function createNotesStore(input) {
|
|
|
334
333
|
change = { kind: "metadata", before: frontmatterOf(beforeMeta), after: frontmatterOf(meta) };
|
|
335
334
|
else
|
|
336
335
|
change = { kind: "none", before: "", after: "" };
|
|
337
|
-
await atomicWrite(path, serialized);
|
|
338
|
-
|
|
339
|
-
|
|
336
|
+
await atomicWrite(sameFile ? sourceReal : path, serialized);
|
|
337
|
+
if (moved)
|
|
338
|
+
await rm(fromPath, { force: true });
|
|
339
|
+
return { meta, applied, resolvedScope: scope, change, moved, replacedCrumpledTarget: moved && targetRaw !== undefined };
|
|
340
|
+
};
|
|
341
|
+
// Exact aliases share one queue; other spellings lock both paths in stable order.
|
|
342
|
+
if (!differentPaths)
|
|
343
|
+
return withPathQueue(path, mutate);
|
|
344
|
+
const [first, second] = [fromPath, path].sort();
|
|
345
|
+
return withPathQueue(first, () => withPathQueue(second, mutate));
|
|
340
346
|
}
|
|
341
|
-
/**
|
|
342
|
-
* Move one note to a new address with every metadata key preserved. Both ends must be
|
|
343
|
-
* writable; a live target refuses, a crumpled target is replaced. Locks both paths in
|
|
344
|
-
* sorted order so crossed renames cannot deadlock.
|
|
345
|
-
*/
|
|
347
|
+
/** Moving alone shares validation and persistence with a combined edit-and-move. */
|
|
346
348
|
async function rename(fromAddress, toAddress) {
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
const fromScope = from.scope;
|
|
350
|
-
const toScope = to.scope;
|
|
351
|
-
assertWritablePath(to.path);
|
|
352
|
-
assertWritableHome(fromScope, from.who, identity);
|
|
353
|
-
assertWritableHome(toScope, to.who, identity);
|
|
354
|
-
const fromPath = physicalPath(fromScope, from.path, identity, from.who);
|
|
355
|
-
const toPath = physicalPath(toScope, to.path, identity, to.who);
|
|
356
|
-
if (resolve(fromPath) === resolve(toPath))
|
|
357
|
-
throw new NoteError("nothing_to_do", "rename_to points at the note itself.");
|
|
358
|
-
const [first, second] = [fromPath, toPath].sort();
|
|
359
|
-
return withPathQueue(first, () => withPathQueue(second, async () => {
|
|
360
|
-
const raw = await readFileIfExists(fromPath);
|
|
361
|
-
if (raw === undefined)
|
|
362
|
-
throw new NoteError("not_found", `No note at ${noteIdentity(identity, fromAddress).address}.`);
|
|
363
|
-
const targetRaw = await readFileIfExists(toPath);
|
|
364
|
-
if (targetRaw !== undefined && parseNote(targetRaw).meta.crumpledAt === undefined) {
|
|
365
|
-
throw new NoteError("already_exists", `${noteIdentity(identity, toAddress).address} already holds a note; crumple it first or pick another address.`);
|
|
366
|
-
}
|
|
367
|
-
const { meta, body } = parseNote(raw);
|
|
368
|
-
meta.scope = toScope;
|
|
369
|
-
// Project ownership only changes when the move crosses the session boundary.
|
|
370
|
-
if (fromScope !== "session" && toScope === "session")
|
|
371
|
-
meta.project = identity.projectKey;
|
|
372
|
-
if (fromScope === "session" && toScope !== "session")
|
|
373
|
-
delete meta.project;
|
|
374
|
-
meta.updatedAt = writeStamp();
|
|
375
|
-
const serialized = serializeNote(meta, body);
|
|
376
|
-
assertSerializedSize(serialized);
|
|
377
|
-
await atomicWrite(toPath, serialized);
|
|
378
|
-
await rm(fromPath, { force: true });
|
|
379
|
-
return { meta, replacedCrumpledTarget: targetRaw !== undefined };
|
|
380
|
-
}));
|
|
349
|
+
const { meta, replacedCrumpledTarget } = await update(fromAddress, undefined, { renameTo: toAddress });
|
|
350
|
+
return { meta, replacedCrumpledTarget };
|
|
381
351
|
}
|
|
382
352
|
async function* scan(options, status) {
|
|
383
353
|
const pattern = normalizePattern(options.glob, identity);
|
|
@@ -385,7 +355,7 @@ export function createNotesStore(input) {
|
|
|
385
355
|
const matcher = normalized === undefined ? undefined : globToRegExp(normalized);
|
|
386
356
|
let homes;
|
|
387
357
|
try {
|
|
388
|
-
homes = await
|
|
358
|
+
homes = await homesForPattern(normalized, identity) ?? SCOPE_ORDER.map((scope) => ({ scope }));
|
|
389
359
|
}
|
|
390
360
|
catch (error) {
|
|
391
361
|
if (!status || !isFilesystemError(error) || !/^@(projects|agents|models)\//.test(options.glob ?? ""))
|
package/dist/src/pi/runtime.js
CHANGED
|
@@ -195,7 +195,7 @@ export function registerContext(pi, settingsManager) {
|
|
|
195
195
|
}
|
|
196
196
|
cmdCtx.ui.notify("🥣 Brain being emptied", "info");
|
|
197
197
|
try {
|
|
198
|
-
pi.sendMessage({ customType: MANUAL_WIPE_TYPE, content: warningContent(prompt ? `/empty
|
|
198
|
+
pi.sendMessage({ customType: MANUAL_WIPE_TYPE, content: warningContent(prompt ? `/empty ${prompt}` : undefined), display: false }, { triggerTurn: true, deliverAs: "steer" });
|
|
199
199
|
}
|
|
200
200
|
catch (error) {
|
|
201
201
|
resets.clear();
|
|
@@ -203,13 +203,13 @@ export function registerContext(pi, settingsManager) {
|
|
|
203
203
|
}
|
|
204
204
|
},
|
|
205
205
|
};
|
|
206
|
-
pi.registerCommand("empty
|
|
206
|
+
pi.registerCommand("empty", emptyBrainCommand);
|
|
207
207
|
pi.registerCommand("fresh-window", emptyBrainCommand);
|
|
208
208
|
pi.registerTool(defineTool({
|
|
209
209
|
name: "empty_brain",
|
|
210
210
|
label: "Empty Brain",
|
|
211
211
|
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.",
|
|
212
|
-
parameters: Type.Object({ last_word: Type.Optional(Type.String({
|
|
212
|
+
parameters: Type.Object({ last_word: Type.Optional(Type.String({ 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 }),
|
|
213
213
|
async execute(_id, params, _signal, _update, ctx) {
|
|
214
214
|
if (!enabled)
|
|
215
215
|
return output({ error: "notesoup is off, so memory can't be cleared; the user can turn it on with `/notesoup on`." });
|
package/dist/src/tools/notes.js
CHANGED
|
@@ -7,7 +7,7 @@ import { failure, fitsResult, resultSchema, readTextWindow, renderOutcome, rende
|
|
|
7
7
|
import { nullableString, InvalidQueryError, searchQueries, searchQuery } from "./schema.js";
|
|
8
8
|
const ORIGIN_VALUES = [Type.Literal("user"), Type.Literal("self"), Type.Literal("external")];
|
|
9
9
|
const ORIGIN = Type.Optional(Type.Union([...ORIGIN_VALUES], {
|
|
10
|
-
description: "(optional
|
|
10
|
+
description: "(optional) Who wrote it: user, self, or external. Omit to keep the existing origin; new notes default to self.",
|
|
11
11
|
}));
|
|
12
12
|
const CRUMPLED_PARAMETER = Type.Optional(Type.Boolean({ description: "(optional) true = crumple (hide from list and search, still readable); false = restore." }));
|
|
13
13
|
const CRUMPLED_LIST_PARAMETER = Type.Optional(Type.Boolean({ description: "(optional) true = list only crumpled notes." }));
|
|
@@ -184,7 +184,7 @@ export const notesWrite = {
|
|
|
184
184
|
parameters: notesWriteParameters, outputSchema: resultSchema(NotesWriteDataSchema), executionMode: "sequential",
|
|
185
185
|
async execute(params, identity) {
|
|
186
186
|
try {
|
|
187
|
-
const { outcome } = await createNotesStore(identity).write(params.address, params.content, { origin: params.origin
|
|
187
|
+
const { outcome } = await createNotesStore(identity).write(params.address, params.content, { origin: params.origin });
|
|
188
188
|
return success({ ...noteIdentity(identity, params.address), outcome });
|
|
189
189
|
}
|
|
190
190
|
catch (error) {
|
|
@@ -199,7 +199,7 @@ export const notesUpdateParameters = Type.Object({
|
|
|
199
199
|
origin: ORIGIN,
|
|
200
200
|
crumpled: CRUMPLED_PARAMETER,
|
|
201
201
|
replace_all: Type.Optional(Type.Boolean({ description: "(optional) true = replace every match of `oldText`." })),
|
|
202
|
-
rename_to: Type.Optional(Type.String({ description: "(optional) Move to this address,
|
|
202
|
+
rename_to: Type.Optional(Type.String({ description: "(optional) Move to this address, optionally with edits or metadata changes. Won't overwrite a live note; references aren't updated." })),
|
|
203
203
|
}, { additionalProperties: false });
|
|
204
204
|
function renderUpdateData(data) {
|
|
205
205
|
const head = data.rename_from === undefined
|
|
@@ -235,17 +235,11 @@ export const notesUpdate = {
|
|
|
235
235
|
const store = createNotesStore(identity);
|
|
236
236
|
// Empty filler is not a request: models that pass every parameter get the edit path.
|
|
237
237
|
const renameTo = params.rename_to === "" ? undefined : params.rename_to;
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const from = noteIdentity(identity, params.address).address;
|
|
244
|
-
const to = noteIdentity(identity, renameTo);
|
|
245
|
-
return boundedUpdate({ ...to, rename_from: from, change_kind: "moved", diff: `rename ${from} -> ${to.address}` });
|
|
246
|
-
}
|
|
247
|
-
const { change } = await store.update(params.address, params.edits, { origin: params.origin, crumpled: params.crumpled, replaceAll: params.replace_all });
|
|
248
|
-
return boundedUpdate({ ...noteIdentity(identity, params.address), change_kind: change.kind, diff: renderDiff(change) });
|
|
238
|
+
const { change, moved } = await store.update(params.address, params.edits, { origin: params.origin, crumpled: params.crumpled, replaceAll: params.replace_all, renameTo });
|
|
239
|
+
const from = noteIdentity(identity, params.address).address;
|
|
240
|
+
const to = noteIdentity(identity, renameTo ?? params.address);
|
|
241
|
+
const diff = renderDiff(change);
|
|
242
|
+
return boundedUpdate({ ...to, ...(moved ? { rename_from: from } : {}), change_kind: moved ? "moved" : change.kind, diff: moved ? [`rename ${from} -> ${to.address}`, diff].filter(Boolean).join("\n") : diff });
|
|
249
243
|
}
|
|
250
244
|
catch (error) {
|
|
251
245
|
return failureOf(error);
|
|
@@ -464,7 +464,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
|
|
|
464
464
|
if (request === 1)
|
|
465
465
|
return assistant(fixture, [{ type: "text", text: "before manual reset" }]);
|
|
466
466
|
if (request === 2) {
|
|
467
|
-
assert.ok(text(context).includes(WARNING_JSON), "idle /empty
|
|
467
|
+
assert.ok(text(context).includes(WARNING_JSON), "idle /empty sends the shared checkpoint prompt");
|
|
468
468
|
return assistant(fixture, [{ type: "toolCall", id: "manual-note", name: "notes_write", arguments: { address: "manual-a.md", content: "MANUAL_NOTE_ALPHA" } }], "toolUse");
|
|
469
469
|
}
|
|
470
470
|
assert.equal(request, 3, "the close-out turn finishes in the old window");
|
|
@@ -475,7 +475,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
|
|
|
475
475
|
try {
|
|
476
476
|
await fixture.session.prompt("MANUAL_CLOSEOUT_OLD_SENTINEL");
|
|
477
477
|
await fixture.session.waitForIdle();
|
|
478
|
-
await fixture.session.prompt("/empty
|
|
478
|
+
await fixture.session.prompt("/empty");
|
|
479
479
|
await fixture.session.waitForIdle();
|
|
480
480
|
assert.equal(fixture.requests.length, 3, "the run stops at settlement instead of continuing in the fresh window");
|
|
481
481
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
@@ -504,7 +504,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
|
|
|
504
504
|
}
|
|
505
505
|
});
|
|
506
506
|
test("real AgentSession: a clear command keeps its prompt out of the fresh window and resumes once", { timeout: 25000 }, async () => {
|
|
507
|
-
for (const mode of ["empty
|
|
507
|
+
for (const mode of ["empty", "fresh-window", "hard-reserve", "overflow"]) {
|
|
508
508
|
let fixture;
|
|
509
509
|
const prompt = 'AFTER_CLEAR_PROMPT_SENTINEL /cm "literal text"';
|
|
510
510
|
// `text()` serializes to JSON, so a quoted argument reaches the provider in its escaped form.
|
|
@@ -532,7 +532,7 @@ test("real AgentSession: a clear command keeps its prompt out of the fresh windo
|
|
|
532
532
|
});
|
|
533
533
|
try {
|
|
534
534
|
await fixture.session.prompt("PROMPT_RESET_OLD_SENTINEL");
|
|
535
|
-
await fixture.session.prompt(`/${mode === "empty
|
|
535
|
+
await fixture.session.prompt(`/${mode === "empty" ? "empty" : "fresh-window"} ${prompt} `);
|
|
536
536
|
await fixture.session.waitForIdle();
|
|
537
537
|
assert.equal(fixture.requests.length, 3);
|
|
538
538
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
@@ -598,7 +598,7 @@ test("real AgentSession: streaming clear prompt keeps the first request", { time
|
|
|
598
598
|
const running = fixture.session.prompt("streaming old work");
|
|
599
599
|
await ready;
|
|
600
600
|
await fixture.session.prompt("/fresh-window FIRST_RESET_PROMPT", { streamingBehavior: "steer" });
|
|
601
|
-
await fixture.session.prompt("/empty
|
|
601
|
+
await fixture.session.prompt("/empty IGNORED_RESET_PROMPT", { streamingBehavior: "steer" });
|
|
602
602
|
release();
|
|
603
603
|
await running;
|
|
604
604
|
await fixture.session.waitForIdle();
|
|
@@ -630,7 +630,7 @@ test("real AgentSession: manual hard-reserve reset stops clean and mixed-tool tu
|
|
|
630
630
|
});
|
|
631
631
|
try {
|
|
632
632
|
await fixture.session.prompt("HARD_RESERVE_OLD_SENTINEL");
|
|
633
|
-
await fixture.session.prompt("/empty
|
|
633
|
+
await fixture.session.prompt("/empty");
|
|
634
634
|
await fixture.session.waitForIdle();
|
|
635
635
|
assert.equal(fixture.requests.length, 2);
|
|
636
636
|
assert.equal(resetMarkers(fixture).length, 1, "the safety wipe is not repeated at settlement");
|
|
@@ -678,7 +678,7 @@ test("real AgentSession: manual safety reset answers queued user input once befo
|
|
|
678
678
|
});
|
|
679
679
|
try {
|
|
680
680
|
await fixture.session.prompt("QUEUED_SAFETY_OLD_SENTINEL");
|
|
681
|
-
await fixture.session.prompt("/empty
|
|
681
|
+
await fixture.session.prompt("/empty");
|
|
682
682
|
await fixture.session.waitForIdle();
|
|
683
683
|
assert.equal(fixture.requests.length, 4, "queued input is answered once after Pi's tool follow-up, then the stop lands");
|
|
684
684
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
@@ -701,7 +701,7 @@ test("real AgentSession: manual overflow wipes and stops even with automatic res
|
|
|
701
701
|
});
|
|
702
702
|
try {
|
|
703
703
|
await fixture.session.prompt("MANUAL_OVERFLOW_OLD_SENTINEL");
|
|
704
|
-
await fixture.session.prompt("/empty
|
|
704
|
+
await fixture.session.prompt("/empty");
|
|
705
705
|
await fixture.session.waitForIdle();
|
|
706
706
|
assert.equal(fixture.requests.length, 2);
|
|
707
707
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
@@ -712,7 +712,7 @@ test("real AgentSession: manual overflow wipes and stops even with automatic res
|
|
|
712
712
|
fixture.close();
|
|
713
713
|
}
|
|
714
714
|
});
|
|
715
|
-
test("real AgentSession: streaming /empty
|
|
715
|
+
test("real AgentSession: streaming /empty steers a close-out and stops at settlement", { timeout: 20000 }, async () => {
|
|
716
716
|
let fixture;
|
|
717
717
|
let announceStarted;
|
|
718
718
|
let releaseResponse;
|
|
@@ -734,8 +734,8 @@ test("real AgentSession: streaming /empty-brain steers a close-out and stops at
|
|
|
734
734
|
try {
|
|
735
735
|
const running = fixture.session.prompt("STREAMING_WIPE_OLD_SENTINEL");
|
|
736
736
|
await started;
|
|
737
|
-
await fixture.session.prompt("/empty
|
|
738
|
-
await fixture.session.prompt("/empty
|
|
737
|
+
await fixture.session.prompt("/empty", { streamingBehavior: "steer" });
|
|
738
|
+
await fixture.session.prompt("/empty", { streamingBehavior: "followUp" });
|
|
739
739
|
assert.equal(fixture.notices.filter((notice) => notice.includes("Brain being emptied")).length, 1, "the user is notified once while output is ongoing");
|
|
740
740
|
assert.equal(resetMarkers(fixture).length, 0, "the ongoing turn is not interrupted");
|
|
741
741
|
releaseResponse();
|
|
@@ -769,9 +769,9 @@ test("real AgentSession: repeated manual commands share one pending window", { t
|
|
|
769
769
|
},
|
|
770
770
|
});
|
|
771
771
|
try {
|
|
772
|
-
const first = fixture.session.prompt("/empty
|
|
772
|
+
const first = fixture.session.prompt("/empty");
|
|
773
773
|
await started;
|
|
774
|
-
const second = fixture.session.prompt("/empty
|
|
774
|
+
const second = fixture.session.prompt("/empty");
|
|
775
775
|
releaseResponse();
|
|
776
776
|
await Promise.all([first, second]);
|
|
777
777
|
await fixture.session.waitForIdle();
|
|
@@ -854,7 +854,7 @@ test("real AgentSession: steering and follow-up queued during a manual reset are
|
|
|
854
854
|
},
|
|
855
855
|
});
|
|
856
856
|
try {
|
|
857
|
-
const command = fixture.session.prompt("/empty
|
|
857
|
+
const command = fixture.session.prompt("/empty");
|
|
858
858
|
await started;
|
|
859
859
|
if (delivery === "steer")
|
|
860
860
|
fixture.session.steer("QUEUED_DURING_FALLBACK");
|
|
@@ -1093,7 +1093,7 @@ test("real AgentSession: hidden or missing reset boots refuse to move the bounda
|
|
|
1093
1093
|
try {
|
|
1094
1094
|
await fixture.session.prompt("ROOT_BEFORE_HIDDEN_BOOT");
|
|
1095
1095
|
await fixture.session.waitForIdle();
|
|
1096
|
-
await fixture.session.prompt("/empty
|
|
1096
|
+
await fixture.session.prompt("/empty");
|
|
1097
1097
|
await fixture.session.waitForIdle();
|
|
1098
1098
|
await fixture.session.prompt("VALID_POST_MARKER_WORK");
|
|
1099
1099
|
await fixture.session.waitForIdle();
|
|
@@ -74,7 +74,7 @@ test("the root boot and reset boot carry durable window identity", async () => {
|
|
|
74
74
|
assert.equal(rootText.includes(NORMAL_CONTINUATIONS[0]), false, "root startup carries no reset handoff");
|
|
75
75
|
assertBootHistory(rootText, historyFromSession(ctx));
|
|
76
76
|
assert.ok(rootText.includes("decisions.md"));
|
|
77
|
-
const decisionsMeta = (await listNotes(ctx
|
|
77
|
+
const decisionsMeta = (await listNotes(ctx)).find((row) => row.path === "decisions.md")?.meta;
|
|
78
78
|
assert.ok(decisionsMeta);
|
|
79
79
|
assert.match(rootText, /decisions\.md · (?:just now|\d+s ago)/, "boot note metadata carries a relative update time");
|
|
80
80
|
assert.ok(rootText.includes(NOTES_PROTOCOL_OPEN_TAG));
|
|
@@ -316,10 +316,10 @@ test("empty_brain uses one turn boundary and never calls ctx.compact", async ()
|
|
|
316
316
|
assert.equal(sessionManager.getBranch().filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE).length, 1);
|
|
317
317
|
assert.equal(sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === BOOT_TYPE && entry.details && typeof entry.details === "object" && "windowId" in entry.details).length, 1);
|
|
318
318
|
});
|
|
319
|
-
test("/empty
|
|
319
|
+
test("/empty waits out non-agent busy work before starting its single-turn request", async () => {
|
|
320
320
|
const sessionManager = manager();
|
|
321
321
|
const captured = makeExtension(sessionManager);
|
|
322
|
-
const cmd = captured.commands.get("empty
|
|
322
|
+
const cmd = captured.commands.get("empty");
|
|
323
323
|
assert.ok(cmd);
|
|
324
324
|
let waits = 0;
|
|
325
325
|
const notices = [];
|
|
@@ -334,7 +334,7 @@ test("/empty-brain waits out non-agent busy work before starting its single-turn
|
|
|
334
334
|
assert.equal(captured.sent[0]?.options?.triggerTurn, true);
|
|
335
335
|
assert.equal(notices.filter((message) => message.includes("Brain being emptied")).length, 1);
|
|
336
336
|
});
|
|
337
|
-
test("notesoup command toggles future work, /empty
|
|
337
|
+
test("notesoup command toggles future work, /empty schedules a turn-end reset, and /compact remains disabled", async () => {
|
|
338
338
|
const sessionManager = manager();
|
|
339
339
|
appendText(sessionManager, "user", "hello");
|
|
340
340
|
const captured = makeExtension(sessionManager);
|
|
@@ -353,7 +353,7 @@ test("notesoup command toggles future work, /empty-brain schedules a turn-end re
|
|
|
353
353
|
assert.match(offResult.error ?? "", /off/, "empty_brain refuses while off");
|
|
354
354
|
notices = await runCommand(captured, "notesoup", "on", low);
|
|
355
355
|
assert.match(notices[0]?.message ?? "", /on/);
|
|
356
|
-
notices = await runCommand(captured, "empty
|
|
356
|
+
notices = await runCommand(captured, "empty", "", low);
|
|
357
357
|
assert.equal(notices.length, 1, "the command acknowledges the reset request");
|
|
358
358
|
assert.match(notices[0]?.message ?? "", /Brain being emptied/);
|
|
359
359
|
assert.equal(captured.sent.length, 2, "the command persists one hidden warning after the startup boot");
|
|
@@ -463,7 +463,7 @@ test("Claude Mod headless detection skips compaction and logs once", async (t) =
|
|
|
463
463
|
await invoke("turn.complete");
|
|
464
464
|
assert.equal(attempts, 0, "headless sessions skip the unsupported capability from startup");
|
|
465
465
|
assert.deepEqual(notifications, ["🥣 No brain when headless"]);
|
|
466
|
-
const manual = await invoke("command.run", { command: "empty
|
|
466
|
+
const manual = await invoke("command.run", { command: "empty" });
|
|
467
467
|
assert.match(manual.text, /No brain when headless/);
|
|
468
468
|
assert.equal(notifications.length, 1);
|
|
469
469
|
const boot = await handlers.get("prompt.context")(host, {}, async () => ({ blocks: [] }));
|
|
@@ -522,6 +522,8 @@ test("Claude Mod manual reset uses one hidden close-out turn, then recovers its
|
|
|
522
522
|
const home = mkdtempSync(join(tmpdir(), "claude-manual-home-"));
|
|
523
523
|
t.after(() => rmSync(home, { recursive: true, force: true }));
|
|
524
524
|
const { host } = fakeEngine(home);
|
|
525
|
+
const commands = [];
|
|
526
|
+
host.command.register = async (spec) => { commands.push(spec.name); return { command: spec.name }; };
|
|
525
527
|
let handlers = new Map();
|
|
526
528
|
const invoke = (name, e = {}) => handlers.get(name)(host, e, async () => ({}));
|
|
527
529
|
const timers = [];
|
|
@@ -542,7 +544,10 @@ test("Claude Mod manual reset uses one hidden close-out turn, then recovers its
|
|
|
542
544
|
};
|
|
543
545
|
(await loadHookModule(t)).register((event, handler) => handlers.set(event, handler));
|
|
544
546
|
await invoke("session.start", { cwd: home, isInteractive: true });
|
|
545
|
-
|
|
547
|
+
assert.deepEqual(commands.sort(), ["empty", "fresh-window"], "only the new short name and the retained alias are registered");
|
|
548
|
+
assert.deepEqual(await invoke("command.run", { command: "empty-brain" }), {}, "the retired spelling passes through instead of resetting");
|
|
549
|
+
assert.equal(timers.length, 0);
|
|
550
|
+
const command = await invoke("command.run", { command: "empty" });
|
|
546
551
|
assert.match(command.text, /Brain being emptied/);
|
|
547
552
|
await Promise.resolve();
|
|
548
553
|
assert.equal(compactions, 0, "command.run must not call compact under its held turn");
|
|
@@ -560,7 +565,7 @@ test("Claude Mod manual reset uses one hidden close-out turn, then recovers its
|
|
|
560
565
|
await invoke("session.start", { cwd: home, isInteractive: true });
|
|
561
566
|
assert.deepEqual(await handlers.get("prompt.context")(host, {}, async () => ({ blocks: [] })), { blocks: [] }, "reload does not duplicate the already-retained boot");
|
|
562
567
|
await invoke("turn.start");
|
|
563
|
-
await invoke("command.run", { command: "empty
|
|
568
|
+
await invoke("command.run", { command: "empty" });
|
|
564
569
|
await invoke("turn.complete");
|
|
565
570
|
assert.equal(prompts.length, 1, "a busy manual request reuses the current turn instead of submitting another");
|
|
566
571
|
assert.match(kept[0].text, /Current context window id: claude:hook-session:2/);
|
|
@@ -631,7 +636,7 @@ test("Claude Mod stops the automatic reset and the manual command under DISABLE_
|
|
|
631
636
|
await invoke("session.start", { cwd: home, isInteractive: true });
|
|
632
637
|
assert.equal(notifications.length, 1, "one startup line");
|
|
633
638
|
assert.match(notifications[0], /DISABLE_COMPACT/);
|
|
634
|
-
const manual = await invoke("command.run", { command: "empty
|
|
639
|
+
const manual = await invoke("command.run", { command: "empty" });
|
|
635
640
|
assert.match(manual.text, /DISABLE_COMPACT/);
|
|
636
641
|
assert.equal(timers.length, 0, "no close-out turn is queued");
|
|
637
642
|
await invoke("turn.start");
|
|
@@ -794,7 +799,7 @@ test("Claude session.end gives /clear, /resume and /branch a fresh boot and iden
|
|
|
794
799
|
host.session.usage = async () => ({ context: { tokens: 142_424, window: 200_000 } });
|
|
795
800
|
assert.equal((await context()).blocks[0]?.name, "notesoup:warning", "the old window has already warned");
|
|
796
801
|
await invoke("turn.start");
|
|
797
|
-
await invoke("command.run", { command: "empty
|
|
802
|
+
await invoke("command.run", { command: "empty" });
|
|
798
803
|
const ended = { sentinel: action };
|
|
799
804
|
assert.equal(await invoke("session.end", { reason: action === "clear" ? "clear" : "resume", sessionId: "hook-session" }, ended), ended);
|
|
800
805
|
host.session.id = async () => `after-${action}`;
|
|
@@ -156,7 +156,7 @@ test("configured extension source and moved dream CLI are executable current ent
|
|
|
156
156
|
registerCommand(name) { commands.push(name); },
|
|
157
157
|
});
|
|
158
158
|
assert.deepEqual(tools.map((tool) => tool.name).sort(), ["empty_brain", "get_context_remaining", "history_list", "history_read", "history_windows", "notes_list", "notes_read", "notes_search", "notes_update", "notes_write"]);
|
|
159
|
-
assert.deepEqual(commands.sort(), ["empty
|
|
159
|
+
assert.deepEqual(commands.sort(), ["empty", "fresh-window", "notesoup"]);
|
|
160
160
|
const help = execFileSync(process.execPath, [resolve(root, manifest.bin.dream), "--help"], { cwd: root, encoding: "utf8" });
|
|
161
161
|
assert.ok(help.startsWith("dream doctor [--notes-home <dir>]"));
|
|
162
162
|
assert.ok(help.includes("Default playbook: <installed package root>/playbook.md"));
|
|
@@ -193,6 +193,18 @@ test("shared note operations return canonical outcomes with a body-only read win
|
|
|
193
193
|
assert.equal(updated.diff, "caller-rendered-diff");
|
|
194
194
|
const defaultReceipt = data(await notesUpdate.execute({ address: "@project/test.md", edits: [{ oldText: "gamma", newText: "delta" }] }, notesIdentity));
|
|
195
195
|
assert.equal(defaultReceipt.diff, "note body");
|
|
196
|
+
await notesWrite.execute({ address: "owned.md", content: "first", origin: "user" }, notesIdentity);
|
|
197
|
+
await notesWrite.execute({ address: "owned.md", content: "rewritten" }, notesIdentity);
|
|
198
|
+
assert.equal(data(await notesRead.execute({ address: "owned.md" }, notesIdentity)).metadata.origin, "user", "tool overwrites preserve an omitted origin");
|
|
199
|
+
const invalid = refusal(await notesUpdate.execute({ address: "owned.md", edits: [{ oldText: "", newText: "x" }] }, notesIdentity));
|
|
200
|
+
assert.equal(invalid.code, "invalid_edit");
|
|
201
|
+
const moved = data(await notesUpdate.execute({ address: "owned.md", rename_to: "@project/renamed.md", edits: [{ oldText: "rewritten", newText: "final" }], origin: "external" }, notesIdentity));
|
|
202
|
+
assert.equal(moved.change_kind, "moved");
|
|
203
|
+
assert.equal(moved.rename_from, "owned.md");
|
|
204
|
+
assert.match(moved.diff, /rename owned\.md -> @project\/renamed\.md/);
|
|
205
|
+
const renamed = data(await notesRead.execute({ address: moved.address }, notesIdentity));
|
|
206
|
+
assert.equal(renamed.text, "final");
|
|
207
|
+
assert.equal(renamed.metadata.origin, "external");
|
|
196
208
|
const unchanged = data(await notesUpdate.execute({ address: "@project/test.md", edits: [{ oldText: "delta", newText: "delta" }] }, notesIdentity));
|
|
197
209
|
assert.equal(unchanged.change_kind, "none");
|
|
198
210
|
assert.equal(unchanged.diff, "");
|
|
@@ -103,8 +103,8 @@ test("the countdown closes the second-tier notice only, in both hosts", () => {
|
|
|
103
103
|
assert.ok(pi.endsWith(`\n${GUIDANCE_CLOSE_TAG}`));
|
|
104
104
|
assert.ok(pi.includes(`\n${LAST_WORD_HINT}\n${COUNTDOWN_LINE}\n`), "the countdown comes after the Pi-only last-word hint");
|
|
105
105
|
assert.equal(pi.split(COUNTDOWN_LINE).length - 1, 1, "the second tier carries the countdown exactly once");
|
|
106
|
-
const prompted = warningContent("/empty
|
|
107
|
-
assert.ok(prompted.includes("<notesoup:next_window_prompt>\n/empty
|
|
106
|
+
const prompted = warningContent("/empty keep going");
|
|
107
|
+
assert.ok(prompted.includes("<notesoup:next_window_prompt>\n/empty keep going\n</notesoup:next_window_prompt>"));
|
|
108
108
|
assert.ok(prompted.endsWith(`\n${COUNTDOWN_LINE}\n${GUIDANCE_CLOSE_TAG}`), "the prompt block does not displace the countdown");
|
|
109
109
|
assert.equal(CLAUDE_WARNING_PROMPT.endsWith(`\n${COUNTDOWN_LINE}`), true, "Claude's variant ends the same way");
|
|
110
110
|
assert.equal(tokenBudgetGuidance(100, "empty_brain").includes(COUNTDOWN_LINE), false, "the first tier never counts down");
|