notesoup 0.54.1 ā 0.55.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/plugins/pi/budget.js +1 -1
- package/dist/plugins/pi/marker.d.ts +1 -1
- package/dist/plugins/pi/marker.js +11 -7
- package/dist/plugins/pi/notes/tools.js +5 -1
- package/dist/plugins/pi/render.d.ts +4 -1
- package/dist/plugins/pi/render.js +3 -7
- package/dist/plugins/pi/runtime.js +4 -2
- package/dist/plugins/pi/tool-result.d.ts +4 -2
- package/dist/plugins/pi/tool-result.js +4 -3
- package/dist/src/history/history.d.ts +1 -1
- package/dist/src/history/history.js +1 -1
- package/dist/src/tools/history.js +4 -7
- package/dist/src/tools/notes.d.ts +2 -7
- package/dist/src/tools/notes.js +5 -26
- package/dist/test/budget-settings.integration.test.js +2 -2
- package/dist/test/claude-history.test.js +4 -6
- package/dist/test/codex-history.test.js +3 -2
- package/dist/test/dependencies.test.js +3 -4
- package/dist/test/dream-tools.test.js +3 -3
- package/dist/test/history-corpus.test.js +1 -1
- package/dist/test/history.integration.test.js +9 -9
- package/dist/test/host-neutral.test.js +7 -9
- package/dist/test/marker.test.js +34 -27
- package/dist/test/notes.integration.test.js +8 -10
- package/dist/test/notes.test.js +9 -7
- package/dist/test/pi-render.test.js +7 -7
- package/dist/test/project-namespace.test.js +4 -4
- package/docs/tool-results.md +1 -1
- package/package.json +3 -4
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +493 -514
- package/plugins/codex/dist/codex/notesoup.js +667 -688
- package/plugins/paseo/OVERVIEW.md +2 -2
- package/plugins/paseo/client/brain-empty-card.tsx +1 -1
- package/plugins/paseo/client/notes-op-card.tsx +2 -2
- package/plugins/paseo/client/notes-op-transformer.ts +16 -1
- package/plugins/paseo/client/paper-palette.ts +18 -18
- package/plugins/paseo/test/fixtures/claude-tool-calls.ts +1 -1
- package/plugins/paseo/test/notes-op.test.ts +4 -4
- package/plugins/paseo/test/paper-palette.test.ts +3 -3
- package/plugins/pi/budget.ts +1 -1
- package/plugins/pi/marker.ts +11 -6
- package/plugins/pi/notes/tools.ts +5 -1
- package/plugins/pi/render.ts +7 -8
- package/plugins/pi/runtime.ts +3 -1
- package/plugins/pi/tool-result.ts +9 -8
- package/src/history/history.ts +1 -1
- package/src/tools/history.ts +4 -7
- package/src/tools/notes.ts +5 -27
|
@@ -105,7 +105,7 @@ export function registerBudget(pi, isEnabled, settingsManager) {
|
|
|
105
105
|
// An aborted request does not undo the low-budget condition or repeat the toast.
|
|
106
106
|
if (!notifiedWindows.has(windowId)) {
|
|
107
107
|
notifiedWindows.add(windowId);
|
|
108
|
-
ctx.ui.notify("š„£ Brain almost full
|
|
108
|
+
ctx.ui.notify("š„£ Brain almost full", "warning");
|
|
109
109
|
}
|
|
110
110
|
return result({ customType: WARNING_TYPE, content: pendingWarning.content });
|
|
111
111
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
/** Spacing between durable seq breadcrumbs, in projected history seq. */
|
|
3
|
-
export declare const MARKER_INTERVAL =
|
|
3
|
+
export declare const MARKER_INTERVAL = 120;
|
|
4
4
|
/**
|
|
5
5
|
* Stamp the current seq every MARKER_INTERVAL seqs. The marker names the seq it occupies, so a
|
|
6
6
|
* model paging history_list meets a breadcrumb that tells it where it is. Skipped while a reset
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { piSequenceCount } from "../../src/history/pi.js";
|
|
2
|
+
import { BOOT_TYPE, MARKER_TYPE } from "./entries.js";
|
|
2
3
|
import { nextHistorySeq } from "./history.js";
|
|
3
4
|
import { inspectResetTail } from "./reset/artifacts.js";
|
|
4
5
|
import { markerContent } from "./text.js";
|
|
5
6
|
import { currentReset } from "./window.js";
|
|
6
7
|
/** Spacing between durable seq breadcrumbs, in projected history seq. */
|
|
7
|
-
export const MARKER_INTERVAL =
|
|
8
|
-
/** Highest seq already
|
|
8
|
+
export const MARKER_INTERVAL = 120;
|
|
9
|
+
/** Highest seq already anchored by a window boot or marker; 0 before the first. */
|
|
9
10
|
function lastMarkerSeq(ctx) {
|
|
10
11
|
let last = 0;
|
|
12
|
+
let nextSeq = 1;
|
|
11
13
|
for (const entry of ctx.sessionManager.getEntries()) {
|
|
12
|
-
|
|
14
|
+
const count = piSequenceCount(entry);
|
|
15
|
+
if (count === 0)
|
|
13
16
|
continue;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
if (entry.type === "custom_message" && (entry.customType === MARKER_TYPE || entry.customType === BOOT_TYPE)) {
|
|
18
|
+
last = nextSeq;
|
|
19
|
+
}
|
|
20
|
+
nextSeq += count;
|
|
17
21
|
}
|
|
18
22
|
return last;
|
|
19
23
|
}
|
|
@@ -27,7 +27,11 @@ export function registerNotesTools(pi) {
|
|
|
27
27
|
const identity = (ctx) => dreamingIdentity(notesIdentityFromPi(ctx), dreamOf(ctx));
|
|
28
28
|
const toolContext = (ctx) => notesToolContext(identity(ctx), ctx.cwd);
|
|
29
29
|
registerOperation(pi, notesWrite, (params, ctx) => notesWrite.execute(params, toolContext(ctx)), NOTES_NAMESPACE, notesWriteRenderers);
|
|
30
|
-
registerOperation(pi, notesUpdate, (params, ctx) =>
|
|
30
|
+
registerOperation(pi, notesUpdate, async (params, ctx) => {
|
|
31
|
+
let diff = "";
|
|
32
|
+
const outcome = await notesUpdate.execute(params, toolContext(ctx), (change) => { diff = renderDiff(change); });
|
|
33
|
+
return diff ? { ...outcome, details: { diff } } : outcome;
|
|
34
|
+
}, NOTES_NAMESPACE, notesUpdateRenderers);
|
|
31
35
|
registerOperation(pi, notesRead, (params, ctx) => notesRead.execute(params, toolContext(ctx)), NOTES_NAMESPACE, notesReadRenderers);
|
|
32
36
|
registerOperation(pi, notesList, (params, ctx) => notesList.execute(params, toolContext(ctx)), NOTES_NAMESPACE);
|
|
33
37
|
registerOperation(pi, notesSearch, (params, ctx) => notesSearch.execute(params, toolContext(ctx)), NOTES_NAMESPACE);
|
|
@@ -15,9 +15,12 @@ export declare const notesWriteRenderers: {
|
|
|
15
15
|
}, theme: Theme, context: CallContext<NotesWriteArgs>): Component;
|
|
16
16
|
};
|
|
17
17
|
export type NotesUpdateArgs = Static<typeof notesUpdateParameters>;
|
|
18
|
+
export type NotesUpdateDetails = {
|
|
19
|
+
diff?: string;
|
|
20
|
+
};
|
|
18
21
|
export declare const notesUpdateRenderers: {
|
|
19
22
|
renderCall(args: NotesUpdateArgs, theme: Theme): Component;
|
|
20
|
-
renderResult(result: AgentToolResult<undefined>, options: {
|
|
23
|
+
renderResult(result: AgentToolResult<NotesUpdateDetails | undefined>, options: {
|
|
21
24
|
expanded: boolean;
|
|
22
25
|
}, theme: Theme, context: CallContext<NotesUpdateArgs>): Component;
|
|
23
26
|
};
|
|
@@ -83,6 +83,7 @@ export const notesUpdateRenderers = {
|
|
|
83
83
|
return errorComponent(theme, error, options.expanded);
|
|
84
84
|
if (!data)
|
|
85
85
|
return receiptFallback(result, theme);
|
|
86
|
+
const diff = result.details?.diff ?? "";
|
|
86
87
|
let head;
|
|
87
88
|
if (context.args?.crumpled === true) {
|
|
88
89
|
head = `ā crumpled ${theme.strikethrough(theme.fg("dim", data.address))}`;
|
|
@@ -98,18 +99,13 @@ export const notesUpdateRenderers = {
|
|
|
98
99
|
}
|
|
99
100
|
else {
|
|
100
101
|
head = `edited ${addressText(theme, data.address)}`;
|
|
101
|
-
const peek = firstAddedLine(
|
|
102
|
+
const peek = firstAddedLine(diff);
|
|
102
103
|
if (peek !== undefined && peek !== "")
|
|
103
104
|
head += theme.fg("dim", " Ā· ") + theme.fg("toolDiffAdded", `+ ${peek}`);
|
|
104
105
|
}
|
|
105
106
|
if (!options.expanded)
|
|
106
107
|
return new TruncatedText(head, 0, 0);
|
|
107
|
-
|
|
108
|
-
if (data.diff !== "")
|
|
109
|
-
parts.push("", renderDiff(data.diff));
|
|
110
|
-
if (data.change_kind !== "moved" && data.rename_from !== undefined)
|
|
111
|
-
parts.push(theme.fg("dim", `renamed from ${data.rename_from}`));
|
|
112
|
-
return new Text(parts.join("\n"), 0, 0);
|
|
108
|
+
return new Text(diff !== "" ? `${head}\n\n${renderDiff(diff)}` : head, 0, 0);
|
|
113
109
|
},
|
|
114
110
|
};
|
|
115
111
|
export const notesReadRenderers = {
|
|
@@ -78,11 +78,13 @@ export function registerContext(pi, settingsManager) {
|
|
|
78
78
|
ctx.ui.notify("š„£ Brain forcibly emptied: overflow", "warning");
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
|
-
pi.on("
|
|
82
|
-
notifyCommittedResets(ctx);
|
|
81
|
+
pi.on("before_agent_start", (_event, ctx) => {
|
|
83
82
|
if (enabled)
|
|
84
83
|
maybeSendMarker(pi, ctx);
|
|
85
84
|
});
|
|
85
|
+
pi.on("turn_start", (_event, ctx) => {
|
|
86
|
+
notifyCommittedResets(ctx);
|
|
87
|
+
});
|
|
86
88
|
pi.on("agent_settled", (_event, ctx) => {
|
|
87
89
|
notifyCommittedResets(ctx);
|
|
88
90
|
pendingResetNotices.clear();
|
|
@@ -20,6 +20,8 @@ export declare const NOTES_NAMESPACE: ToolNamespace;
|
|
|
20
20
|
export declare const DREAM_NAMESPACE: ToolNamespace;
|
|
21
21
|
export declare const HISTORY_NAMESPACE: ToolNamespace;
|
|
22
22
|
/** Optional TUI renderers; without them the host draws its default call line and receipt text. */
|
|
23
|
-
export type OperationRenderers<TParams extends TSchema> = Pick<ToolDefinition<TParams,
|
|
23
|
+
export type OperationRenderers<TParams extends TSchema, TDetails = undefined> = Pick<ToolDefinition<TParams, TDetails>, "renderCall" | "renderResult">;
|
|
24
24
|
/** Register `operation` as a Pi tool; `run` supplies only the host context it needs. */
|
|
25
|
-
export declare function registerOperation<TParams extends TSchema, TData, TRest extends readonly unknown[]>(pi: ExtensionAPI, operation: Operation<TParams, TData, TRest>, run: (params: Static<TParams>, ctx: ExtensionToolContext) => Promise<Outcome<TData
|
|
25
|
+
export declare function registerOperation<TParams extends TSchema, TData, TRest extends readonly unknown[], TDetails = undefined>(pi: ExtensionAPI, operation: Operation<TParams, TData, TRest>, run: (params: Static<TParams>, ctx: ExtensionToolContext) => Promise<Outcome<TData> & {
|
|
26
|
+
details?: TDetails;
|
|
27
|
+
}>, namespace?: ToolNamespace, renderers?: OperationRenderers<TParams, TDetails>, exposure?: ToolExposure): void;
|
|
@@ -8,12 +8,12 @@ export function output(value, details, terminate = false) {
|
|
|
8
8
|
return { content: [{ type: "text", text: JSON.stringify(value) }], details, terminate, ...(refused ? { isError: true } : {}) };
|
|
9
9
|
}
|
|
10
10
|
/** Operation data is schema-derived JSON; only the unresolved generic needs a JsonValue assertion. */
|
|
11
|
-
function piOperationResult(render, outcome) {
|
|
11
|
+
function piOperationResult(render, outcome, details) {
|
|
12
12
|
return {
|
|
13
13
|
content: [{ type: "text", text: render(outcome) }],
|
|
14
14
|
structuredContent: wireResult(outcome),
|
|
15
15
|
isError: !outcome.ok,
|
|
16
|
-
details:
|
|
16
|
+
details: details,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
export const NOTES_NAMESPACE = { name: "notes", description: "Notes you choose to keep across context windows. See the memory skill." };
|
|
@@ -32,7 +32,8 @@ export function registerOperation(pi, operation, run, namespace, renderers, expo
|
|
|
32
32
|
...(exposure ? { exposure } : {}),
|
|
33
33
|
...renderers,
|
|
34
34
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
35
|
-
|
|
35
|
+
const result = await run(params, ctx);
|
|
36
|
+
return piOperationResult(operation.render, result, result.details);
|
|
36
37
|
},
|
|
37
38
|
}));
|
|
38
39
|
}
|
|
@@ -91,7 +91,7 @@ export declare function contentText(content: unknown): string;
|
|
|
91
91
|
export declare function historyDocument(event: HistoryEvent): string;
|
|
92
92
|
/** Memoized `historyDocument`: search, preview, and read must agree on the same characters. */
|
|
93
93
|
export declare function eventDocument(event: HistoryEvent): string;
|
|
94
|
-
/** Pair results into call events; consumed result seqs
|
|
94
|
+
/** Pair results into call events; consumed result seqs redirect to their call event on read. */
|
|
95
95
|
export declare function projectHistory(rawWindows: DecodedHistoryWindow[], highestSeq: number, branchSeqs: Set<number>): HistoryProjection;
|
|
96
96
|
/** Summary shared by list, search and read. Full arguments/calls are in the document. */
|
|
97
97
|
export declare const NestedCallSummarySchema: Type.TObject<{
|
|
@@ -73,7 +73,7 @@ function toolEvent(item, result) {
|
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
/** Pair results into call events; consumed result seqs
|
|
76
|
+
/** Pair results into call events; consumed result seqs redirect to their call event on read. */
|
|
77
77
|
export function projectHistory(rawWindows, highestSeq, branchSeqs) {
|
|
78
78
|
// Pair in durable address order, not window presentation order. Unnumbered
|
|
79
79
|
// segments need not have a provable chronological order relative to each other.
|
|
@@ -155,10 +155,9 @@ export const historyRead = {
|
|
|
155
155
|
projection = loaded.data.projection;
|
|
156
156
|
identity = { session: sessionIdentity(target.data), ...(loaded.data.notice === undefined ? {} : { notice: loaded.data.notice }) };
|
|
157
157
|
}
|
|
158
|
-
const item = allItems(projection).find((event) => event.seq === params.seq);
|
|
159
158
|
// Address checks run in one order: past the end of the file, off this branch, then
|
|
160
|
-
//
|
|
161
|
-
if (
|
|
159
|
+
// resolved through any tool-result pairing to its call event.
|
|
160
|
+
if (params.seq > projection.highestSeq) {
|
|
162
161
|
return failure("unknown_seq", `There is no seq ${params.seq}; this session runs from seq 1 to ${projection.highestSeq}.`);
|
|
163
162
|
}
|
|
164
163
|
if (!projection.branchSeqs.has(params.seq)) {
|
|
@@ -166,11 +165,9 @@ export const historyRead = {
|
|
|
166
165
|
return failure("unconfirmed_seq", `Seq ${params.seq} is outside the confirmed selected history; it may be on another branch or beyond an unresolved ancestry gap.`);
|
|
167
166
|
return failure("not_on_branch", `Seq ${params.seq} is on another branch of this session; it can't be read from here.`);
|
|
168
167
|
}
|
|
168
|
+
const targetSeq = projection.pairedResults.get(params.seq) ?? params.seq;
|
|
169
|
+
const item = allItems(projection).find((event) => event.seq === targetSeq);
|
|
169
170
|
if (item === undefined) {
|
|
170
|
-
const callSeq = projection.pairedResults.get(params.seq);
|
|
171
|
-
if (callSeq !== undefined) {
|
|
172
|
-
return failure("not_an_event", `Seq ${params.seq} is a tool result, shown together with its call; read seq ${callSeq} instead.`);
|
|
173
|
-
}
|
|
174
171
|
return failure("unknown_seq", `Seq ${params.seq} holds nothing to read.`);
|
|
175
172
|
}
|
|
176
173
|
const document = eventDocument(item);
|
|
@@ -49,7 +49,6 @@ export declare const NotesWriteDataSchema: Type.TObject<{
|
|
|
49
49
|
export type NotesWriteData = Static<typeof NotesWriteDataSchema>;
|
|
50
50
|
export declare const NotesUpdateDataSchema: Type.TObject<{
|
|
51
51
|
change_kind: Type.TUnion<[Type.TLiteral<"none">, Type.TLiteral<"body">, Type.TLiteral<"metadata">, Type.TLiteral<"moved">]>;
|
|
52
|
-
diff: Type.TString;
|
|
53
52
|
rename_from: Type.TOptional<Type.TString>;
|
|
54
53
|
project_root: Type.TOptional<Type.TString>;
|
|
55
54
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
@@ -174,9 +173,6 @@ export declare const notesUpdateParameters: Type.TObject<{
|
|
|
174
173
|
rename_to: Type.TOptional<Type.TString>;
|
|
175
174
|
cwd: Type.TOptional<Type.TString>;
|
|
176
175
|
}>;
|
|
177
|
-
declare function renderUpdate(result: Outcome<NotesUpdateData>): string;
|
|
178
|
-
/** A shortened diff still says so in the receipt's own text, on both surfaces. */
|
|
179
|
-
export declare const DIFF_SHORTENED_MARKER = "[diff truncated; update applied]";
|
|
180
176
|
export declare const notesUpdate: {
|
|
181
177
|
readonly name: "notes_update";
|
|
182
178
|
readonly label: "Notes update";
|
|
@@ -195,7 +191,6 @@ export declare const notesUpdate: {
|
|
|
195
191
|
}>;
|
|
196
192
|
readonly outputSchema: Type.TUnion<[Type.TObject<{
|
|
197
193
|
change_kind: Type.TUnion<[Type.TLiteral<"none">, Type.TLiteral<"body">, Type.TLiteral<"metadata">, Type.TLiteral<"moved">]>;
|
|
198
|
-
diff: Type.TString;
|
|
199
194
|
rename_from: Type.TOptional<Type.TString>;
|
|
200
195
|
project_root: Type.TOptional<Type.TString>;
|
|
201
196
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
@@ -209,8 +204,8 @@ export declare const notesUpdate: {
|
|
|
209
204
|
code: Type.TString;
|
|
210
205
|
}>]>;
|
|
211
206
|
readonly executionMode: "sequential";
|
|
212
|
-
readonly execute: (params: Static<typeof notesUpdateParameters>, context: NotesToolContext,
|
|
213
|
-
readonly render:
|
|
207
|
+
readonly execute: (params: Static<typeof notesUpdateParameters>, context: NotesToolContext, onChange?: (change: NoteChange) => void) => Promise<Outcome<NotesUpdateData>>;
|
|
208
|
+
readonly render: (result: Outcome<NotesUpdateData>) => string;
|
|
214
209
|
};
|
|
215
210
|
export declare const notesReadParameters: Type.TObject<{
|
|
216
211
|
cwd: Type.TOptional<Type.TString>;
|
package/dist/src/tools/notes.js
CHANGED
|
@@ -140,7 +140,6 @@ export const NotesWriteDataSchema = Type.Object({
|
|
|
140
140
|
export const NotesUpdateDataSchema = Type.Object({
|
|
141
141
|
...NoteIdentitySchema,
|
|
142
142
|
change_kind: Type.Union([Type.Literal("none"), Type.Literal("body"), Type.Literal("metadata"), Type.Literal("moved")]),
|
|
143
|
-
diff: Type.String(),
|
|
144
143
|
rename_from: Type.Optional(Type.String()),
|
|
145
144
|
}, { additionalProperties: false });
|
|
146
145
|
export const NotesReadDataSchema = Type.Object({
|
|
@@ -212,51 +211,31 @@ export const notesUpdateParameters = Type.Object({
|
|
|
212
211
|
cwd: CWD_PARAMETER,
|
|
213
212
|
}, { additionalProperties: false });
|
|
214
213
|
function renderUpdateData(data) {
|
|
215
|
-
|
|
214
|
+
return data.rename_from === undefined
|
|
216
215
|
? `${data.change_kind === "none" ? "unchanged" : "updated"} ${renderIdentity(data)}`
|
|
217
216
|
: `moved ${data.rename_from} -> ${data.address}`;
|
|
218
|
-
const lines = [head];
|
|
219
|
-
if (data.diff.length > 0)
|
|
220
|
-
lines.push("diff:", data.diff);
|
|
221
|
-
return lines.join("\n");
|
|
222
|
-
}
|
|
223
|
-
function renderUpdate(result) {
|
|
224
|
-
return renderOutcome(result, renderUpdateData);
|
|
225
|
-
}
|
|
226
|
-
/** A shortened diff still says so in the receipt's own text, on both surfaces. */
|
|
227
|
-
export const DIFF_SHORTENED_MARKER = "[diff truncated; update applied]";
|
|
228
|
-
const RECEIPT_TOO_LONG = `Saved, but the receipt is too long to hand back (${TOOL_OUTPUT_LIMIT} per call). Check the note with \`notes_read\`.`;
|
|
229
|
-
/** Bound a mutation receipt on both surfaces; a huge diff is cut to the longest fitting prefix and marked. */
|
|
230
|
-
function boundedUpdate(data) {
|
|
231
|
-
if (fitsResult(success(data), renderUpdate))
|
|
232
|
-
return success(data);
|
|
233
|
-
if (data.diff === "")
|
|
234
|
-
return failure("output_too_large", RECEIPT_TOO_LONG);
|
|
235
|
-
const diff = prefixFit(data.diff, (candidate) => fitsResult(success({ ...data, diff: `${candidate}\n${DIFF_SHORTENED_MARKER}` }), renderUpdate));
|
|
236
|
-
const result = success({ ...data, diff: `${diff}\n${DIFF_SHORTENED_MARKER}` });
|
|
237
|
-
return fitsResult(result, renderUpdate) ? result : failure("output_too_large", RECEIPT_TOO_LONG);
|
|
238
217
|
}
|
|
239
218
|
export const notesUpdate = {
|
|
240
219
|
name: "notes_update", label: "Notes update",
|
|
241
220
|
description: `Change part of a note's body, its origin or crumpled state, or its address. When things change, replace the stale part in place; don't just tack an update onto the bottom. Each \`oldText\` must match exactly once unless \`replace_all\` is true. ${ADDRESS_DESCRIPTION}`,
|
|
242
221
|
parameters: notesUpdateParameters, outputSchema: resultSchema(NotesUpdateDataSchema), executionMode: "sequential",
|
|
243
|
-
async execute(params, context,
|
|
222
|
+
async execute(params, context, onChange) {
|
|
244
223
|
try {
|
|
245
224
|
const identity = notesIdentityForCall(context, params.cwd);
|
|
246
225
|
const store = createNotesStore(identity);
|
|
247
226
|
// Empty filler is not a request: models that pass every parameter get the edit path.
|
|
248
227
|
const renameTo = params.rename_to === "" ? undefined : params.rename_to;
|
|
249
228
|
const { change, moved } = await store.update(params.address, params.edits, { origin: params.origin, crumpled: params.crumpled, replaceAll: params.replace_all, renameTo });
|
|
229
|
+
onChange?.(change);
|
|
250
230
|
const from = noteIdentity(identity, params.address).address;
|
|
251
231
|
const to = noteIdentity(identity, renameTo ?? params.address);
|
|
252
|
-
|
|
253
|
-
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 });
|
|
232
|
+
return success({ ...to, ...(moved ? { rename_from: from } : {}), change_kind: moved ? "moved" : change.kind });
|
|
254
233
|
}
|
|
255
234
|
catch (error) {
|
|
256
235
|
return failureOf(error);
|
|
257
236
|
}
|
|
258
237
|
},
|
|
259
|
-
render:
|
|
238
|
+
render: (result) => renderOutcome(result, renderUpdateData),
|
|
260
239
|
};
|
|
261
240
|
export const notesReadParameters = Type.Object({ address: Type.String(), ...TextWindowRequestSchema, cwd: CWD_PARAMETER }, { additionalProperties: false });
|
|
262
241
|
function renderReadData(data) {
|
|
@@ -108,12 +108,12 @@ test("early guidance stays silent and the final warning notifies immediately onc
|
|
|
108
108
|
const final = context(sm, undefined, { tokens: 181_000, percent: 90.5, contextWindow: 200_000 });
|
|
109
109
|
const warning = await runContextHook(captured, final);
|
|
110
110
|
assert.equal(warning?.messages[0]?.customType, WARNING_TYPE);
|
|
111
|
-
assert.equal(noticesOf(final).filter((notice) => notice.message === "š„£ Brain almost full
|
|
111
|
+
assert.equal(noticesOf(final).filter((notice) => notice.message === "š„£ Brain almost full").length, 1, "notify at injection, before any turn_end");
|
|
112
112
|
await runContextHook(captured, final);
|
|
113
113
|
await commitTurnEndBoundary(captured, sm, final);
|
|
114
114
|
await runHandlers(captured, "turn_start", {}, final);
|
|
115
115
|
await runHandlers(captured, "agent_settled", {}, final);
|
|
116
|
-
assert.equal(noticesOf(final).filter((notice) => notice.message === "š„£ Brain almost full
|
|
116
|
+
assert.equal(noticesOf(final).filter((notice) => notice.message === "š„£ Brain almost full").length, 1, "repeated injection and commit do not notify again");
|
|
117
117
|
});
|
|
118
118
|
test("the reported room ends at the hard reserve, clamps at zero, and preserves unknown usage", async () => {
|
|
119
119
|
const fixture = settingsFixture({
|
|
@@ -66,9 +66,8 @@ test("Claude append and result arrival preserve call addresses and use the share
|
|
|
66
66
|
assert.doesNotMatch(read.data.text, /hidden/);
|
|
67
67
|
assert.equal(allItems(completed).find((event) => event.seq === 4)?.execution?.status, "error");
|
|
68
68
|
const resultRead = await historyRead.execute({ seq: 7 }, completed);
|
|
69
|
-
assert.ok(
|
|
70
|
-
assert.equal(resultRead.
|
|
71
|
-
assert.match(resultRead.error.message, /read seq 3/);
|
|
69
|
+
assert.ok(resultRead.ok);
|
|
70
|
+
assert.equal(resultRead.data.seq, 3);
|
|
72
71
|
const search = await historyList.execute({ query: "output one" }, completed);
|
|
73
72
|
assert.ok(search.ok);
|
|
74
73
|
assert.deepEqual(search.data.items.map((item) => "seq" in item ? item.seq : -1), [3]);
|
|
@@ -349,9 +348,8 @@ test("Claude gap windows sort by confirmed ordinal despite forward references, w
|
|
|
349
348
|
assert.deepEqual(allItems(projection).filter((event) => event.role === "tool").map((event) => [event.seq, event.text]), [[4, "output"]]);
|
|
350
349
|
assert.equal(projection.pairedResults.get(8), 4);
|
|
351
350
|
const alias = await historyRead.execute({ seq: 8 }, projection);
|
|
352
|
-
assert.ok(
|
|
353
|
-
assert.equal(alias.
|
|
354
|
-
assert.match(alias.error.message, /read seq 4/);
|
|
351
|
+
assert.ok(alias.ok);
|
|
352
|
+
assert.equal(alias.data.seq, 4);
|
|
355
353
|
});
|
|
356
354
|
test("Claude gap notices participate in list/read budgets without changing read coordinates", async (t) => {
|
|
357
355
|
const root = mkdtempSync(join(tmpdir(), "claude-history-budget-"));
|
|
@@ -93,8 +93,9 @@ test("root: raw messages, top-level envelope metadata, native tool pairing and n
|
|
|
93
93
|
assert.equal(tool.data.output_truncated, undefined);
|
|
94
94
|
assert.equal(tool.data.nested_calls, undefined);
|
|
95
95
|
const paired = await historyRead.execute({ seq: 9 }, projection);
|
|
96
|
-
assert.equal(paired.ok,
|
|
97
|
-
|
|
96
|
+
assert.equal(paired.ok, true);
|
|
97
|
+
if (paired.ok)
|
|
98
|
+
assert.equal(paired.data.seq, 7);
|
|
98
99
|
const omitted = await historyRead.execute({ seq: 6 }, projection);
|
|
99
100
|
assert.match(historyRead.render(omitted), /holds nothing/);
|
|
100
101
|
const page = await historyList.execute({ query: "printf output" }, projection);
|
|
@@ -46,10 +46,9 @@ test("the host-neutral core resolves without any SDK or plugin dependency", () =
|
|
|
46
46
|
const sharedRuntime = new Set(["typebox"]);
|
|
47
47
|
assert.deepEqual(dependencyViolations(root, shared, parsed.options, sharedRuntime), []);
|
|
48
48
|
for (const name of sharedRuntime) {
|
|
49
|
-
assert.equal(
|
|
50
|
-
assert.equal(manifest.
|
|
51
|
-
assert.equal(manifest.
|
|
52
|
-
assert.equal(manifest.peerDependenciesMeta?.[name], undefined, `${name} has no peer metadata`);
|
|
49
|
+
assert.equal(manifest.dependencies?.[name], undefined, `${name} is supplied by the host`);
|
|
50
|
+
assert.equal(manifest.peerDependencies?.[name], "*", `${name} is a host-supplied peer dependency`);
|
|
51
|
+
assert.equal(typeof manifest.devDependencies?.[name], "string", `${name} is pinned in devDependencies`);
|
|
53
52
|
}
|
|
54
53
|
for (const name of ["@earendil-works/pi-agent-core", "@earendil-works/pi-ai", "@earendil-works/pi-coding-agent"]) {
|
|
55
54
|
assert.equal(manifest.dependencies?.[name], undefined, `${name} is supplied by the host`);
|
|
@@ -46,7 +46,7 @@ test("a dream opens one other project, writes its notes, deletes only crumpled o
|
|
|
46
46
|
assert.ok(existsSync(join(home, ".dream.lock")), "the notes-home lock is held");
|
|
47
47
|
assert.equal((await dreamBegin.execute({ project: "beta" }, as("other", "alpha"), {})).ok, false, "another session can't dream the same project");
|
|
48
48
|
assert.ok((await notesWrite.execute({ address: "@projects/beta/rule", content: "merged" }, ident())).ok);
|
|
49
|
-
assert.ok((await notesUpdate.execute({ address: "@sessions/b1/checkpoint", edits: [{ oldText: "old", newText: "new" }] }, ident()
|
|
49
|
+
assert.ok((await notesUpdate.execute({ address: "@sessions/b1/checkpoint", edits: [{ oldText: "old", newText: "new" }] }, ident())).ok);
|
|
50
50
|
assert.equal((await notesWrite.execute({ address: "@sessions/a1/mine", content: "x" }, ident())).ok, false, "another project's session stays read-only");
|
|
51
51
|
assert.equal((await notesWrite.execute({ address: "@projects/alpha/x", content: "x" }, ident())).ok, false, "other projects stay read-only");
|
|
52
52
|
const read = await notesRead.execute({ address: "@human/none" }, ident());
|
|
@@ -188,12 +188,12 @@ test("named-project mutation receipts carry their project metadata and fit their
|
|
|
188
188
|
assert.equal(written.data.project_root, "/work/two/beta");
|
|
189
189
|
assert.deepEqual(written.data.project_siblings, [{ name: "beta", path: "/work/beta" }]);
|
|
190
190
|
assert.equal(Check(notesWrite.outputSchema, written.data), true, "notes_write accepts its own named-project receipt");
|
|
191
|
-
const updated = await notesUpdate.execute({ address: "@projects/beta-1/rule", edits: [{ oldText: "merged", newText: "done" }] }, ident()
|
|
191
|
+
const updated = await notesUpdate.execute({ address: "@projects/beta-1/rule", edits: [{ oldText: "merged", newText: "done" }] }, ident());
|
|
192
192
|
assert.ok(updated.ok);
|
|
193
193
|
assert.equal(updated.data.project_root, "/work/two/beta");
|
|
194
194
|
assert.deepEqual(updated.data.project_siblings, [{ name: "beta", path: "/work/beta" }]);
|
|
195
195
|
assert.equal(Check(notesUpdate.outputSchema, updated.data), true, "notes_update accepts its own named-project receipt");
|
|
196
|
-
assert.ok((await notesUpdate.execute({ address: "@projects/beta-1/rule", crumpled: true }, ident()
|
|
196
|
+
assert.ok((await notesUpdate.execute({ address: "@projects/beta-1/rule", crumpled: true }, ident())).ok);
|
|
197
197
|
const forgotten = await dreamForget.execute({ address: "@projects/beta-1/rule" }, me, state);
|
|
198
198
|
assert.ok(forgotten.ok);
|
|
199
199
|
assert.equal(forgotten.data.project_root, "/work/two/beta");
|
|
@@ -158,7 +158,7 @@ test("native filesystem discovery decodes three harnesses, compressed Codex, and
|
|
|
158
158
|
const tool = data(await historyRead.execute({ session: "pi:pi-one", seq: 3 }, f.ctx));
|
|
159
159
|
assert.equal(tool.tool, "read");
|
|
160
160
|
assert.match(tool.text, /needle\.md.*\n--- output ---\nneedle tool output/);
|
|
161
|
-
|
|
161
|
+
assert.equal(data(await historyRead.execute({ session: "pi:pi-one", seq: 4 }, f.ctx)).seq, 3);
|
|
162
162
|
for (let index = 0; index < paths.length; index++) {
|
|
163
163
|
assert.deepEqual(await readFile(paths[index]), before[index].bytes);
|
|
164
164
|
assert.equal((await stat(paths[index])).mtimeMs, before[index].time);
|
|
@@ -131,8 +131,8 @@ test("pairing uses append seq rather than the presentation order of unnumbered s
|
|
|
131
131
|
assert.deepEqual(projection.windows.map((window) => window.windowId), ["unknown-a", "unknown-b"], "pairing must not invent segment chronology");
|
|
132
132
|
assert.deepEqual(projection.windows.flatMap((window) => window.items).filter((event) => event.role === "tool").map((event) => [event.seq, event.text]), [[2, "output"]]);
|
|
133
133
|
const alias = await historyRead.execute({ seq: 3 }, projection);
|
|
134
|
-
assert.ok(
|
|
135
|
-
assert.equal(alias.
|
|
134
|
+
assert.ok(alias.ok);
|
|
135
|
+
assert.equal(alias.data.seq, 2);
|
|
136
136
|
});
|
|
137
137
|
test("seq is stable across branch changes, abandoned entries stay unreadable, and a paired result seq is refused precisely", async () => {
|
|
138
138
|
const session = manager();
|
|
@@ -154,7 +154,7 @@ test("seq is stable across branch changes, abandoned entries stay unreadable, an
|
|
|
154
154
|
assert.equal(unknown.code, "unknown_seq");
|
|
155
155
|
assert.match(unknown.message, /\b4\b.*\b3\b/);
|
|
156
156
|
});
|
|
157
|
-
test("a result address consumed by a pairing
|
|
157
|
+
test("a result address consumed by a pairing resolves directly to its call event", async () => {
|
|
158
158
|
const session = manager();
|
|
159
159
|
const captured = makeExtension(session);
|
|
160
160
|
const ctx = context(session);
|
|
@@ -162,9 +162,9 @@ test("a result address consumed by a pairing names its call instead of serving a
|
|
|
162
162
|
toolResult(session, "paired", "edit", "edited");
|
|
163
163
|
// The assistant message takes seq 1 and its tool call seq 2; the result at seq 3 is absorbed.
|
|
164
164
|
assert.deepEqual(seqs(await call(captured, "history_list", { roles: ["tool"] }, ctx)), [2], "the pairing is one event at the call's address");
|
|
165
|
-
const consumed =
|
|
166
|
-
assert.equal(consumed.
|
|
167
|
-
assert.
|
|
165
|
+
const consumed = resultRead(await call(captured, "history_read", { seq: 3 }, ctx));
|
|
166
|
+
assert.equal(consumed.seq, 2);
|
|
167
|
+
assert.equal(consumed.content, 'edit {"path":"a.md"}\n--- output ---\nedited');
|
|
168
168
|
const callSeq = resultRead(await call(captured, "history_read", { seq: 2 }, ctx));
|
|
169
169
|
assert.equal(callSeq.seq, 2);
|
|
170
170
|
assert.equal(callSeq.content, 'edit {"path":"a.md"}\n--- output ---\nedited');
|
|
@@ -703,9 +703,9 @@ test("historyDocument is one deterministic projection of the facts, with no UI h
|
|
|
703
703
|
assert.equal(hit.offset_chars, earliestMatchOffsetChars('read {"path":"one"}\n--- output ---\nš needle', ["NEEDLE"]));
|
|
704
704
|
}
|
|
705
705
|
const consumed = await historyRead.execute({ seq: 6 }, projection);
|
|
706
|
-
assert.equal(consumed.ok,
|
|
707
|
-
if (
|
|
708
|
-
assert.equal(consumed.
|
|
706
|
+
assert.equal(consumed.ok, true);
|
|
707
|
+
if (consumed.ok)
|
|
708
|
+
assert.equal(consumed.data.seq, 5);
|
|
709
709
|
const offBranch = await historyRead.execute({ seq: 12 }, projection);
|
|
710
710
|
assert.equal(offBranch.ok, false);
|
|
711
711
|
if (!offBranch.ok)
|
|
@@ -187,14 +187,13 @@ test("shared note operations return canonical outcomes with a body-only read win
|
|
|
187
187
|
assert.equal(written.address, "@project/test.md");
|
|
188
188
|
assert.equal(written.project_key, notesIdentity.projectKey);
|
|
189
189
|
assert.equal(written.outcome, "created");
|
|
190
|
+
let observedKind = "";
|
|
190
191
|
const updated = data(await notesUpdate.execute({ address: "@project/test.md", edits: [{ oldText: "alpha", newText: "gamma" }] }, toolContext, (change) => {
|
|
191
|
-
|
|
192
|
-
return "caller-rendered-diff";
|
|
192
|
+
observedKind = change.kind;
|
|
193
193
|
}));
|
|
194
|
+
assert.equal(observedKind, "body");
|
|
194
195
|
assert.equal(updated.change_kind, "body");
|
|
195
|
-
assert.equal(updated
|
|
196
|
-
const defaultReceipt = data(await notesUpdate.execute({ address: "@project/test.md", edits: [{ oldText: "gamma", newText: "delta" }] }, toolContext));
|
|
197
|
-
assert.equal(defaultReceipt.diff, "note body");
|
|
196
|
+
assert.equal(notesUpdate.render(success(updated)), `updated @project/test.md (project ${notesIdentity.projectKey})`);
|
|
198
197
|
await notesWrite.execute({ address: "owned.md", content: "first", origin: "user" }, toolContext);
|
|
199
198
|
await notesWrite.execute({ address: "owned.md", content: "rewritten" }, toolContext);
|
|
200
199
|
assert.equal(data(await notesRead.execute({ address: "owned.md" }, toolContext)).metadata.origin, "user", "tool overwrites preserve an omitted origin");
|
|
@@ -203,13 +202,12 @@ test("shared note operations return canonical outcomes with a body-only read win
|
|
|
203
202
|
const moved = data(await notesUpdate.execute({ address: "owned.md", rename_to: "@project/renamed.md", edits: [{ oldText: "rewritten", newText: "final" }], origin: "external" }, toolContext));
|
|
204
203
|
assert.equal(moved.change_kind, "moved");
|
|
205
204
|
assert.equal(moved.rename_from, "owned.md");
|
|
206
|
-
assert.
|
|
205
|
+
assert.equal(notesUpdate.render(success(moved)), "moved owned.md -> @project/renamed.md");
|
|
207
206
|
const renamed = data(await notesRead.execute({ address: moved.address }, toolContext));
|
|
208
207
|
assert.equal(renamed.text, "final");
|
|
209
208
|
assert.equal(renamed.metadata.origin, "external");
|
|
210
|
-
const unchanged = data(await notesUpdate.execute({ address: "@project/test.md", edits: [{ oldText: "
|
|
209
|
+
const unchanged = data(await notesUpdate.execute({ address: "@project/test.md", edits: [{ oldText: "gamma", newText: "gamma" }] }, toolContext));
|
|
211
210
|
assert.equal(unchanged.change_kind, "none");
|
|
212
|
-
assert.equal(unchanged.diff, "");
|
|
213
211
|
// Frontmatter is metadata, not body: the window addresses the body and counts only the body.
|
|
214
212
|
const stored = await createNotesStore(notesIdentity).read("@project/test.md");
|
|
215
213
|
assert.ok(stored, "the note is on disk");
|
|
@@ -260,7 +258,7 @@ test("shared history operations read typed events through the addresses the adap
|
|
|
260
258
|
assert.match(fromMatch.text, /^needle output/, "the match offset lands on the matched text");
|
|
261
259
|
assert.equal(fromMatch.total_chars, full.total_chars, "one document, one length");
|
|
262
260
|
assert.match(refusal(await historyRead.execute({ seq: 9_999 }, projection)).message, /9,?999/, "an unknown address is refused by name");
|
|
263
|
-
assert.equal(
|
|
261
|
+
assert.equal(data(await historyRead.execute({ seq: 3 }, projection)).seq, 2, "a paired result address resolves to its call event");
|
|
264
262
|
});
|
|
265
263
|
test("one role schema declares the four public roles for the page item, the read payload, and the role filter", () => {
|
|
266
264
|
const read = (role) => ({
|