notesoup 0.53.1 → 0.54.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 +2 -2
- package/dist/plugins/claude/src/helper.js +2 -1
- package/dist/plugins/claude/src/history.js +2 -3
- package/dist/plugins/claude/src/thresholds.js +4 -2
- package/dist/plugins/codex/src/hooks.js +1 -1
- package/dist/plugins/codex/src/identity.d.ts +1 -1
- package/dist/plugins/codex/src/identity.js +3 -3
- package/dist/plugins/codex/src/mcp.js +2 -1
- package/dist/plugins/codex/src/text.d.ts +1 -1
- package/dist/plugins/codex/src/text.js +2 -2
- package/dist/plugins/dsh/engine.js +2 -2
- package/dist/plugins/dsh/tools.js +8 -7
- package/dist/plugins/dsh/window.d.ts +1 -0
- package/dist/plugins/dsh/window.js +7 -3
- package/dist/plugins/pi/entries.d.ts +1 -0
- package/dist/plugins/pi/entries.js +1 -0
- package/dist/plugins/pi/history-tools.d.ts +1 -1
- package/dist/plugins/pi/history-tools.js +4 -4
- package/dist/plugins/pi/marker.d.ts +9 -0
- package/dist/plugins/pi/marker.js +36 -0
- package/dist/plugins/pi/notes/tools.js +8 -6
- package/dist/plugins/pi/render.js +7 -4
- package/dist/plugins/pi/reset/artifacts.d.ts +2 -2
- package/dist/plugins/pi/reset/artifacts.js +2 -2
- package/dist/plugins/pi/runtime.js +11 -8
- package/dist/plugins/pi/text.d.ts +2 -0
- package/dist/plugins/pi/text.js +4 -0
- package/dist/plugins/pi/window.js +21 -7
- package/dist/src/boot/render.js +7 -7
- package/dist/src/boot/snapshot.d.ts +7 -7
- package/dist/src/boot/snapshot.js +17 -17
- package/dist/src/boot/text.d.ts +2 -2
- package/dist/src/boot/text.js +7 -5
- package/dist/src/dream/git.d.ts +2 -11
- package/dist/src/dream/git.js +6 -23
- package/dist/src/dream/lock.d.ts +2 -2
- package/dist/src/dream/lock.js +3 -3
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +3 -2
- package/dist/src/notes/address.d.ts +8 -8
- package/dist/src/notes/address.js +13 -13
- package/dist/src/notes/errors.d.ts +1 -1
- package/dist/src/notes/frontmatter.js +2 -2
- package/dist/src/notes/index.d.ts +1 -1
- package/dist/src/notes/index.js +1 -1
- package/dist/src/notes/paths.d.ts +6 -6
- package/dist/src/notes/paths.js +9 -9
- package/dist/src/notes/{project-home.d.ts → project-namespace.d.ts} +7 -7
- package/dist/src/notes/{project-home.js → project-namespace.js} +67 -25
- package/dist/src/notes/store.d.ts +4 -4
- package/dist/src/notes/store.js +55 -52
- package/dist/src/tools/dream.d.ts +21 -3
- package/dist/src/tools/dream.js +54 -16
- package/dist/src/tools/notes-context.d.ts +10 -0
- package/dist/src/tools/notes-context.js +27 -0
- package/dist/src/tools/notes.d.ts +69 -20
- package/dist/src/tools/notes.js +40 -31
- package/dist/test/agent-loop.test.js +8 -8
- package/dist/test/boot.integration.test.js +5 -5
- package/dist/test/claude-history.test.js +26 -0
- package/dist/test/claude-mod.test.js +257 -86
- package/dist/test/codex-plugin.test.js +18 -1
- package/dist/test/context-edit-budget.test.js +121 -0
- package/dist/test/dependencies.test.js +71 -4
- package/dist/test/dream-tools.test.js +153 -8
- package/dist/test/dsh.test.js +62 -15
- package/dist/test/helpers/dsh.d.ts +4 -1
- package/dist/test/helpers/dsh.js +20 -4
- package/dist/test/helpers/extension.d.ts +5 -0
- package/dist/test/helpers/extension.js +33 -2
- package/dist/test/host-neutral.test.js +17 -15
- package/dist/test/marker.test.js +78 -0
- package/dist/test/model-facing-text.test.js +12 -8
- package/dist/test/notes-cwd.test.d.ts +1 -0
- package/dist/test/notes-cwd.test.js +114 -0
- package/dist/test/notes-library.test.js +4 -4
- package/dist/test/notes-query-namespaces.test.d.ts +1 -0
- package/dist/test/{notes-query-homes.test.js → notes-query-namespaces.test.js} +13 -13
- package/dist/test/notes.integration.test.js +72 -23
- package/dist/test/notes.test.js +50 -20
- package/dist/test/pi-render.test.js +33 -1
- package/dist/test/project-namespace.test.d.ts +1 -0
- package/dist/test/project-namespace.test.js +324 -0
- package/dist/test/reset-lifecycle.test.js +12 -0
- package/docs/architecture.md +13 -8
- package/docs/claude-code-mod.md +7 -7
- package/docs/codex.md +4 -4
- package/docs/dsh.md +8 -8
- package/docs/notes-library.md +9 -5
- package/docs/skills.md +3 -3
- package/docs/tool-results.md +6 -2
- package/package.json +4 -6
- package/playbook.md +6 -6
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +681 -617
- package/plugins/claude/hooks/register.ts +61 -65
- package/plugins/claude/playbook.md +6 -6
- package/plugins/claude/skills/memory/SKILL.md +4 -4
- package/plugins/claude/src/helper.ts +3 -2
- package/plugins/claude/src/history.ts +2 -3
- package/plugins/claude/src/thresholds.ts +4 -2
- package/plugins/codex/README.md +1 -1
- package/plugins/codex/dist/codex/notesoup.js +877 -815
- package/plugins/codex/src/hooks.ts +1 -1
- package/plugins/codex/src/identity.ts +3 -3
- package/plugins/codex/src/mcp.ts +2 -1
- package/plugins/codex/src/text.ts +2 -2
- package/plugins/dsh/engine.ts +2 -2
- package/plugins/dsh/tools.ts +8 -7
- package/plugins/dsh/window.ts +8 -3
- package/plugins/paseo/OVERVIEW.md +4 -4
- package/plugins/paseo/README.md +1 -1
- package/plugins/paseo/client/brain-empty-card.tsx +3 -4
- package/plugins/paseo/client/markdown.tsx +179 -0
- package/plugins/paseo/client/notes-op-card.tsx +35 -34
- package/plugins/paseo/client/notes-op-transformer.ts +17 -68
- package/plugins/paseo/client/paper-card.tsx +8 -19
- package/plugins/paseo/client/paper-palette.ts +40 -0
- package/plugins/paseo/client/sticky-card.tsx +6 -4
- package/plugins/paseo/package.json +3 -0
- package/plugins/paseo/paseo-plugin.json +2 -2
- package/plugins/paseo/shared/notes-op.ts +13 -9
- package/plugins/paseo/test/notes-op.test.ts +52 -73
- package/plugins/paseo/test/paper-palette.test.ts +54 -0
- package/plugins/pi/entries.ts +1 -0
- package/plugins/pi/history-tools.ts +4 -4
- package/plugins/pi/marker.ts +39 -0
- package/plugins/pi/notes/tools.ts +8 -6
- package/plugins/pi/render.ts +6 -4
- package/plugins/pi/reset/artifacts.ts +2 -2
- package/plugins/pi/runtime.ts +9 -8
- package/plugins/pi/text.ts +5 -0
- package/plugins/pi/window.ts +22 -7
- package/skills/memory/SKILL.md +4 -4
- package/src/boot/render.ts +8 -8
- package/src/boot/snapshot.ts +20 -20
- package/src/boot/text.ts +7 -5
- package/src/dream/git.ts +7 -24
- package/src/dream/lock.ts +3 -3
- package/src/index.ts +4 -3
- package/src/notes/address.ts +13 -13
- package/src/notes/errors.ts +1 -1
- package/src/notes/frontmatter.ts +2 -2
- package/src/notes/index.ts +1 -1
- package/src/notes/paths.ts +9 -9
- package/src/notes/{project-home.ts → project-namespace.ts} +59 -28
- package/src/notes/store.ts +61 -58
- package/src/tools/dream.ts +63 -16
- package/src/tools/notes-context.ts +29 -0
- package/src/tools/notes.ts +39 -29
- package/dist/test/project-home.test.js +0 -134
- /package/dist/test/{notes-query-homes.test.d.ts → context-edit-budget.test.d.ts} +0 -0
- /package/dist/test/{project-home.test.d.ts → marker.test.d.ts} +0 -0
|
@@ -1,39 +1,28 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { Platform, StyleSheet, View } from "react-native";
|
|
3
|
-
|
|
4
|
-
/** Shared paper palette, independent of the host theme. */
|
|
5
|
-
export const PAPER = {
|
|
6
|
-
background: "#f8f3e1",
|
|
7
|
-
edge: "#cbbd94",
|
|
8
|
-
tape: "rgba(222, 205, 140, 0.72)",
|
|
9
|
-
tapeEdge: "rgba(160, 140, 80, 0.18)",
|
|
10
|
-
ink: "#33301f",
|
|
11
|
-
inkMuted: "#867c63",
|
|
12
|
-
added: "#357a44",
|
|
13
|
-
removed: "#b0493e",
|
|
14
|
-
crumpled: "#ece6d1",
|
|
15
|
-
};
|
|
3
|
+
import type { PaperPalette } from "./paper-palette.ts";
|
|
16
4
|
|
|
17
5
|
export const MONO = Platform.select({ ios: "Menlo", android: "monospace", default: "ui-monospace, Menlo, monospace" });
|
|
18
6
|
|
|
19
|
-
|
|
7
|
+
function Tape({ paper }: { paper: PaperPalette }) {
|
|
20
8
|
return (
|
|
21
9
|
<View style={{
|
|
22
10
|
alignSelf: "flex-start", width: 76, height: 15, marginLeft: 28, marginBottom: -9, zIndex: 1,
|
|
23
|
-
backgroundColor:
|
|
11
|
+
backgroundColor: paper.tape, borderLeftWidth: 1, borderRightWidth: 1, borderColor: paper.tapeEdge,
|
|
24
12
|
transform: [{ rotate: "-2deg" }],
|
|
25
13
|
}} />
|
|
26
14
|
);
|
|
27
15
|
}
|
|
28
16
|
|
|
29
|
-
export function PaperCard({ compact, crumpled = false, children }: {
|
|
17
|
+
export function PaperCard({ paper, compact, crumpled = false, children }: {
|
|
18
|
+
paper: PaperPalette;
|
|
30
19
|
compact: boolean;
|
|
31
20
|
crumpled?: boolean;
|
|
32
21
|
children: ReactNode;
|
|
33
22
|
}) {
|
|
34
23
|
return (
|
|
35
24
|
<View style={{ paddingTop: 7 }}>
|
|
36
|
-
<Tape />
|
|
25
|
+
<Tape paper={paper} />
|
|
37
26
|
<View style={{
|
|
38
27
|
paddingVertical: compact ? 8 : 9,
|
|
39
28
|
paddingHorizontal: 10,
|
|
@@ -41,8 +30,8 @@ export function PaperCard({ compact, crumpled = false, children }: {
|
|
|
41
30
|
minWidth: 0,
|
|
42
31
|
borderRadius: 3,
|
|
43
32
|
borderWidth: StyleSheet.hairlineWidth,
|
|
44
|
-
borderColor:
|
|
45
|
-
backgroundColor: crumpled ?
|
|
33
|
+
borderColor: paper.edge,
|
|
34
|
+
backgroundColor: crumpled ? paper.crumpled : paper.background,
|
|
46
35
|
}}>
|
|
47
36
|
{children}
|
|
48
37
|
</View>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { PluginTheme } from "@getpaseo/plugin";
|
|
2
|
+
|
|
3
|
+
const LIGHT_PAPER = {
|
|
4
|
+
background: "#f8f3e1",
|
|
5
|
+
edge: "#cbbd94",
|
|
6
|
+
tape: "rgba(222, 205, 140, 0.72)",
|
|
7
|
+
tapeEdge: "rgba(160, 140, 80, 0.18)",
|
|
8
|
+
ink: "#33301f",
|
|
9
|
+
inkMuted: "#867c63",
|
|
10
|
+
added: "#357a44",
|
|
11
|
+
removed: "#b0493e",
|
|
12
|
+
crumpled: "#ece6d1",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type PaperPalette = typeof LIGHT_PAPER;
|
|
16
|
+
|
|
17
|
+
const DARK_PAPER: PaperPalette = {
|
|
18
|
+
background: "#302e27",
|
|
19
|
+
edge: "#58513e",
|
|
20
|
+
tape: "rgba(139, 122, 70, 0.55)",
|
|
21
|
+
tapeEdge: "rgba(194, 170, 100, 0.18)",
|
|
22
|
+
ink: "#e8e1cc",
|
|
23
|
+
inkMuted: "#b5aa8e",
|
|
24
|
+
added: "#91c79a",
|
|
25
|
+
removed: "#e69a8f",
|
|
26
|
+
crumpled: "#292824",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Paseo theme colors are hex (#RGB, #RRGGBB or #RRGGBBAA). */
|
|
30
|
+
function brightness(hex: string): number {
|
|
31
|
+
const rgb = hex.length === 4 ? hex.slice(1).replace(/./g, digit => digit + digit) : hex.slice(1, 7);
|
|
32
|
+
return 0.299 * parseInt(rgb.slice(0, 2), 16)
|
|
33
|
+
+ 0.587 * parseInt(rgb.slice(2, 4), 16)
|
|
34
|
+
+ 0.114 * parseInt(rgb.slice(4, 6), 16);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function paperPalette(theme: PluginTheme): PaperPalette {
|
|
38
|
+
// The SDK exposes colors, not appearance. Use the host theme, never the OS color scheme.
|
|
39
|
+
return brightness(theme.colors.foreground) > brightness(theme.colors.surface0) ? DARK_PAPER : LIGHT_PAPER;
|
|
40
|
+
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { PluginTimelineItemProps } from "@getpaseo/plugin/client";
|
|
2
2
|
import { Text } from "react-native";
|
|
3
3
|
import type { LastWord } from "../shared/last-word.ts";
|
|
4
|
-
import {
|
|
4
|
+
import { PaperCard } from "./paper-card.tsx";
|
|
5
|
+
import { paperPalette } from "./paper-palette.ts";
|
|
5
6
|
|
|
6
|
-
export function StickyCard({ item, layout }: PluginTimelineItemProps<LastWord>) {
|
|
7
|
+
export function StickyCard({ item, layout, theme }: PluginTimelineItemProps<LastWord>) {
|
|
8
|
+
const paper = paperPalette(theme);
|
|
7
9
|
const text = item.data.text.replace(/^\*You peel a sticky note off your forehead\.\*\n/, "");
|
|
8
10
|
return (
|
|
9
|
-
<PaperCard compact={layout.compact}>
|
|
10
|
-
<Text selectable style={{ color:
|
|
11
|
+
<PaperCard paper={paper} compact={layout.compact}>
|
|
12
|
+
<Text selectable style={{ color: paper.ink, fontSize: 13, lineHeight: 19, flexShrink: 1 }}>{text}</Text>
|
|
11
13
|
</PaperCard>
|
|
12
14
|
);
|
|
13
15
|
}
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
+
/** Client display budget, including the omission line; source history stays unchanged. */
|
|
4
|
+
export const OUTPUT_DISPLAY_MAX_CHARS = 32_000;
|
|
5
|
+
export const COLLAPSED_PREVIEW_MAX_CHARS = 1_000;
|
|
6
|
+
export function outputPreview(text: string, maxChars = OUTPUT_DISPLAY_MAX_CHARS): string {
|
|
7
|
+
if (text.length <= maxChars) return text;
|
|
8
|
+
const middle = "\n\n… Showing the beginning and end; the middle is hidden in this preview. …\n\n";
|
|
9
|
+
const headChars = Math.floor((maxChars - middle.length) / 2);
|
|
10
|
+
// Budget in UTF-16 units, but never split a surrogate pair.
|
|
11
|
+
const head = text.slice(0, headChars).replace(/[\uD800-\uDBFF]$/, "");
|
|
12
|
+
const tail = text.slice(-(maxChars - middle.length - headChars)).replace(/^[\uDC00-\uDFFF]/, "");
|
|
13
|
+
return head + middle + tail;
|
|
14
|
+
}
|
|
15
|
+
|
|
3
16
|
export const NOTES_OP_KIND = "notes-op";
|
|
4
17
|
export const NOTES_OP_TOOLS = ["notes_read", "notes_write", "notes_update"] as const;
|
|
5
18
|
export type NotesOpTool = (typeof NOTES_OP_TOOLS)[number];
|
|
6
19
|
|
|
7
|
-
/** Card data stays small: the plugin timeline refuses payloads over 64 KB. */
|
|
8
|
-
export const READ_TEXT_MAX_CHARS = 4000;
|
|
9
|
-
export const DIFF_MAX_CHARS = 8000;
|
|
10
|
-
export const PREVIEW_MAX_CHARS = 4000;
|
|
11
|
-
|
|
12
20
|
export const notesOpSchema = z.object({
|
|
13
21
|
op: z.enum(["read", "write", "update"]),
|
|
14
22
|
address: z.string(),
|
|
@@ -16,15 +24,11 @@ export const notesOpSchema = z.object({
|
|
|
16
24
|
error: z.string().optional(),
|
|
17
25
|
// read
|
|
18
26
|
text: z.string().optional(),
|
|
19
|
-
totalChars: z.number().optional(),
|
|
20
27
|
// write
|
|
21
|
-
outcome: z.string().optional(),
|
|
22
28
|
preview: z.string().optional(),
|
|
23
29
|
// update
|
|
24
|
-
changeKind: z.string().optional(),
|
|
25
30
|
diff: z.string().optional(),
|
|
26
31
|
renamedFrom: z.string().optional(),
|
|
27
32
|
crumpled: z.boolean().optional(),
|
|
28
|
-
truncated: z.boolean().optional(),
|
|
29
33
|
});
|
|
30
34
|
export type NotesOp = z.infer<typeof notesOpSchema>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
import { notesOpTransformer } from "../client/notes-op-transformer.ts";
|
|
4
|
-
import {
|
|
4
|
+
import { OUTPUT_DISPLAY_MAX_CHARS, notesOpSchema } from "../shared/notes-op.ts";
|
|
5
5
|
import { claudeReadCompleted, claudeReadFailed, claudeUpdateCompleted, claudeWriteCompleted } from "./fixtures/claude-tool-calls.ts";
|
|
6
6
|
|
|
7
7
|
function toolCall(overrides: Record<string, unknown>) {
|
|
@@ -18,75 +18,60 @@ function toolCall(overrides: Record<string, unknown>) {
|
|
|
18
18
|
|
|
19
19
|
const transform = (overrides: Record<string, unknown>) => notesOpTransformer.transform({ item: toolCall(overrides) as never });
|
|
20
20
|
|
|
21
|
-
test("
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
assert.deepEqual(data, { op: "read", address: "@self/foo.md", status: "completed", text: "hello note", totalChars: 9999, truncated: true });
|
|
21
|
+
test("live and replay project the same complete delivered read, including continuation", () => {
|
|
22
|
+
const body = "笔记🦈\n".repeat(3000) + "\n[truncated; continue at offset_chars=15000]";
|
|
23
|
+
const content = [{ type: "text", text: `big.md\norigin self | created today | updated today\n\n${body}` }];
|
|
24
|
+
const replay = transform({ detail: { type: "unknown", input: { address: "big.md" }, output: { content } } });
|
|
25
|
+
const live = transform({ detail: { type: "unknown", input: { address: "big.md" }, output: {
|
|
26
|
+
content, structuredContent: { text: body, next_offset_chars: 15000 },
|
|
27
|
+
} } });
|
|
28
|
+
assert.equal(notesOpSchema.parse(replay!.items[0]!.data).text, body);
|
|
29
|
+
assert.deepEqual(live, replay);
|
|
31
30
|
});
|
|
32
31
|
|
|
33
|
-
test("
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
test("write and moved update project the entire input and delivered diff", () => {
|
|
33
|
+
const body = "long note\n".repeat(2000);
|
|
34
|
+
const write = transform({ name: "notes_write", detail: { type: "unknown",
|
|
35
|
+
input: { address: "a.md", content: body }, output: { content: [{ type: "text", text: "created a.md" }] },
|
|
36
|
+
} });
|
|
37
|
+
assert.equal(notesOpSchema.parse(write!.items[0]!.data).preview, body);
|
|
38
|
+
const diff = "+ 1 + new\n".repeat(2000) + "[diff truncated; update applied]";
|
|
39
|
+
const update = transform({ name: "notes_update", detail: { type: "unknown",
|
|
40
|
+
input: { address: "a.md", rename_to: "b.md" },
|
|
41
|
+
output: { content: [{ type: "text", text: `moved a.md -> b.md\ndiff:\n${diff}` }] },
|
|
42
|
+
} });
|
|
43
|
+
assert.deepEqual(notesOpSchema.parse(update!.items[0]!.data), {
|
|
44
|
+
op: "update", address: "b.md", renamedFrom: "a.md", status: "completed", diff,
|
|
41
45
|
});
|
|
42
|
-
const data = notesOpSchema.parse(result!.items[0]!.data);
|
|
43
|
-
assert.equal(data.op, "write");
|
|
44
|
-
assert.equal(data.outcome, "created");
|
|
45
|
-
assert.equal(data.preview!.length, PREVIEW_MAX_CHARS);
|
|
46
|
-
assert.equal(data.truncated, true);
|
|
47
46
|
});
|
|
48
47
|
|
|
49
|
-
test("
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
48
|
+
test("oversized read, write and diff displays retain head and tail without changing history", () => {
|
|
49
|
+
const body = "START\n" + "🦈".repeat(500_000) + "\nEND";
|
|
50
|
+
for (const [name, field, receipt] of [
|
|
51
|
+
["notes_read", "text", `a.md\nmetadata\n\n${body}`],
|
|
52
|
+
["notes_write", "preview", "created a.md"],
|
|
53
|
+
["notes_update", "diff", `updated a.md\ndiff:\n${body}`],
|
|
54
|
+
] as const) {
|
|
55
|
+
const source = { name, detail: { type: "unknown", input: { address: "a.md", content: body },
|
|
56
|
+
output: { content: [{ type: "text", text: receipt }] } } };
|
|
57
|
+
const before = JSON.stringify(source);
|
|
58
|
+
const data = notesOpSchema.parse(transform(source)!.items[0]!.data);
|
|
59
|
+
const preview = data[field]!;
|
|
60
|
+
assert.ok(preview.length <= OUTPUT_DISPLAY_MAX_CHARS);
|
|
61
|
+
assert.ok(preview.startsWith("START\n") && preview.endsWith("\nEND"));
|
|
62
|
+
assert.match(preview, /middle is hidden/);
|
|
63
|
+
assert.equal(Buffer.from(preview).toString("utf8"), preview);
|
|
64
|
+
assert.equal(JSON.stringify(source), before);
|
|
65
|
+
}
|
|
63
66
|
});
|
|
64
67
|
|
|
65
|
-
test("
|
|
66
|
-
const
|
|
67
|
-
detail: { type: "unknown", input: { address: "
|
|
68
|
-
});
|
|
69
|
-
assert.equal(notesOpSchema.parse(refused!.items[0]!.data).error, "No note at @self/foo.md.");
|
|
70
|
-
|
|
71
|
-
const failed = transform({
|
|
72
|
-
status: "failed",
|
|
73
|
-
error: { message: "boom" },
|
|
74
|
-
detail: { type: "unknown", input: { address: "@self/foo.md" }, output: { content: [{ type: "text", text: "io failed" }] } },
|
|
68
|
+
test("failed calls surface the refusal text; running calls need only input", () => {
|
|
69
|
+
const failed = transform({ status: "failed", error: { message: "boom" },
|
|
70
|
+
detail: { type: "unknown", input: { address: "a.md" }, output: { content: [{ type: "text", text: "io failed" }] } },
|
|
75
71
|
});
|
|
76
72
|
assert.equal(notesOpSchema.parse(failed!.items[0]!.data).error, "io failed");
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test("running calls render from input alone; long reads clip to the card budget", () => {
|
|
80
|
-
const running = transform({ status: "running", detail: { type: "unknown", input: { address: "@human/map.md" }, output: null } });
|
|
81
|
-
assert.deepEqual(notesOpSchema.parse(running!.items[0]!.data), { op: "read", address: "@human/map.md", status: "running" });
|
|
82
|
-
|
|
83
|
-
const long = transform({
|
|
84
|
-
detail: { type: "unknown", input: { address: "big.md" }, output: { structuredContent: { address: "big.md", text: "z".repeat(READ_TEXT_MAX_CHARS + 500), total_chars: 50000, next_offset_chars: null } } },
|
|
85
|
-
});
|
|
86
|
-
const data = notesOpSchema.parse(long!.items[0]!.data);
|
|
87
|
-
assert.equal(data.text!.length, READ_TEXT_MAX_CHARS);
|
|
88
|
-
assert.equal(data.truncated, true);
|
|
89
|
-
assert.ok(JSON.stringify(result_items(long)).length < 64 * 1024, "plugin payload stays under the timeline limit");
|
|
73
|
+
const running = transform({ status: "running", detail: { type: "unknown", input: { address: "a.md" }, output: null } });
|
|
74
|
+
assert.deepEqual(notesOpSchema.parse(running!.items[0]!.data), { op: "read", address: "a.md", status: "running" });
|
|
90
75
|
});
|
|
91
76
|
|
|
92
77
|
test("history replay has no structured payload: the rendered text is parsed instead", () => {
|
|
@@ -100,7 +85,6 @@ test("history replay has no structured payload: the rendered text is parsed inst
|
|
|
100
85
|
detail: { type: "unknown", input: { address: "a.md", content: "the new body" }, output: { content: [{ type: "text", text: "overwrote a.md (project pi-context)" }] } },
|
|
101
86
|
});
|
|
102
87
|
const writeData = notesOpSchema.parse(write!.items[0]!.data);
|
|
103
|
-
assert.equal(writeData.outcome, "overwrote");
|
|
104
88
|
assert.equal(writeData.preview, "the new body", "replay carries the call arguments, so the content preview comes from input on every path");
|
|
105
89
|
|
|
106
90
|
const update = transform({
|
|
@@ -108,14 +92,13 @@ test("history replay has no structured payload: the rendered text is parsed inst
|
|
|
108
92
|
detail: { type: "unknown", input: { address: "a.md" }, output: { content: [{ type: "text", text: "updated a.md\ndiff:\n- 1 - old\n+ 1 + new" }] } },
|
|
109
93
|
});
|
|
110
94
|
const updateData = notesOpSchema.parse(update!.items[0]!.data);
|
|
111
|
-
assert.equal(updateData.changeKind, "body");
|
|
112
95
|
assert.equal(updateData.diff, "- 1 - old\n+ 1 + new");
|
|
113
96
|
|
|
114
97
|
const moved = transform({
|
|
115
98
|
name: "notes_update",
|
|
116
|
-
detail: { type: "unknown", input: { address: "a.md" }, output: { content: [{ type: "text", text: "moved a.md -> b.md" }] } },
|
|
99
|
+
detail: { type: "unknown", input: { address: "a.md", rename_to: "b.md" }, output: { content: [{ type: "text", text: "moved a.md -> b.md" }] } },
|
|
117
100
|
});
|
|
118
|
-
assert.equal(notesOpSchema.parse(moved!.items[0]!.data).
|
|
101
|
+
assert.equal(notesOpSchema.parse(moved!.items[0]!.data).address, "b.md");
|
|
119
102
|
});
|
|
120
103
|
|
|
121
104
|
test("non-notes tools, unknown shapes and missing addresses stay untouched", () => {
|
|
@@ -131,10 +114,10 @@ test("Claude completed calls use the adapter's output text for read, write previ
|
|
|
131
114
|
const read = notesOpSchema.parse(transform(claudeReadCompleted)!.items[0]!.data);
|
|
132
115
|
assert.deepEqual(read, { op: "read", address: "@self/foo.md", status: "completed", text: "body line one\nbody line two" });
|
|
133
116
|
assert.deepEqual(notesOpSchema.parse(transform(claudeWriteCompleted)!.items[0]!.data), {
|
|
134
|
-
op: "write", address: "a.md", status: "completed",
|
|
117
|
+
op: "write", address: "a.md", status: "completed", preview: "the new body",
|
|
135
118
|
});
|
|
136
119
|
assert.deepEqual(notesOpSchema.parse(transform(claudeUpdateCompleted)!.items[0]!.data), {
|
|
137
|
-
op: "update", address: "a.md", status: "completed",
|
|
120
|
+
op: "update", address: "a.md", status: "completed", diff: "- 1 - old\n+ 1 + new",
|
|
138
121
|
});
|
|
139
122
|
});
|
|
140
123
|
|
|
@@ -162,21 +145,17 @@ test("Claude failures keep raw error content and transport messages instead of p
|
|
|
162
145
|
assert.deepEqual(notesOpSchema.parse(update!.items[0]!.data), { op: "update", address: "a.md", status: "failed", error: "MCP connection closed" });
|
|
163
146
|
});
|
|
164
147
|
|
|
165
|
-
function result_items(result: { items: Array<{ data: unknown }> } | undefined) {
|
|
166
|
-
return result!.items.map((item) => item.data);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
148
|
test("a crumple call is marked from the input alone", () => {
|
|
170
149
|
const result = transform({
|
|
171
150
|
name: "notes_update",
|
|
172
151
|
detail: {
|
|
173
152
|
type: "unknown",
|
|
174
153
|
input: { address: "@self/stale.md", crumpled: true },
|
|
175
|
-
output: {
|
|
154
|
+
output: { content: [{ type: "text", text: "updated @self/stale.md" }] },
|
|
176
155
|
},
|
|
177
156
|
});
|
|
178
157
|
const data = notesOpSchema.parse(result!.items[0]!.data);
|
|
179
158
|
assert.equal(data.crumpled, true);
|
|
180
|
-
assert.equal(transform({ name: "notes_update", detail: { type: "unknown", input: { address: "@self/a.md", crumpled: false }, output: {
|
|
159
|
+
assert.equal(transform({ name: "notes_update", detail: { type: "unknown", input: { address: "@self/a.md", crumpled: false }, output: { content: [{ type: "text", text: "updated @self/a.md" }] } } })!
|
|
181
160
|
.items[0]!.data.crumpled, undefined);
|
|
182
161
|
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import type { PluginTheme } from "@getpaseo/plugin";
|
|
4
|
+
import { paperPalette } from "../client/paper-palette.ts";
|
|
5
|
+
|
|
6
|
+
function theme(surface0: string, foreground: string): PluginTheme {
|
|
7
|
+
return { colors: {
|
|
8
|
+
surface0, foreground,
|
|
9
|
+
surface1: surface0, surface2: surface0, border: foreground,
|
|
10
|
+
foregroundMuted: foreground, accent: foreground, accentForeground: surface0,
|
|
11
|
+
statusSuccess: foreground, statusWarning: foreground, statusDanger: foreground,
|
|
12
|
+
} };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function luminance(hex: string): number {
|
|
16
|
+
const [r, g, b] = [1, 3, 5].map(index => {
|
|
17
|
+
const channel = parseInt(hex.slice(index, index + 2), 16) / 255;
|
|
18
|
+
return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
|
|
19
|
+
});
|
|
20
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function contrast(a: string, b: string): number {
|
|
24
|
+
const lighter = Math.max(luminance(a), luminance(b));
|
|
25
|
+
const darker = Math.min(luminance(a), luminance(b));
|
|
26
|
+
return (lighter + 0.05) / (darker + 0.05);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
test("paper follows the host theme and preserves the light palette when switching back", () => {
|
|
30
|
+
const light = theme("#ffffff", "#18181b");
|
|
31
|
+
const dark = theme("#18181b", "#fafafa");
|
|
32
|
+
const paper = paperPalette(light);
|
|
33
|
+
assert.equal(paper.background, "#f8f3e1");
|
|
34
|
+
assert.equal(paper.ink, "#33301f");
|
|
35
|
+
assert.ok(luminance(paperPalette(dark).background) < 0.05);
|
|
36
|
+
assert.notDeepEqual(paperPalette(dark), paper);
|
|
37
|
+
assert.deepEqual(paperPalette(light), paper);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("host hex shorthand and alpha colors select the same dark paper", () => {
|
|
41
|
+
const paper = paperPalette(theme("#000000", "#ffffff"));
|
|
42
|
+
assert.deepEqual(paperPalette(theme("#000", "#fff")), paper);
|
|
43
|
+
assert.deepEqual(paperPalette(theme("#000000ff", "#ffffffff")), paper);
|
|
44
|
+
assert.equal(paperPalette(theme("#fff", "#000")).background, "#f8f3e1");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("dark text, muted labels, additions and errors remain readable on normal and crumpled paper", () => {
|
|
48
|
+
const paper = paperPalette(theme("#18181b", "#fafafa"));
|
|
49
|
+
for (const background of [paper.background, paper.crumpled]) {
|
|
50
|
+
for (const ink of [paper.ink, paper.inkMuted, paper.added, paper.removed]) {
|
|
51
|
+
assert.ok(contrast(ink, background) >= 4.5, `${ink} on ${background} must meet WCAG AA text contrast`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
package/plugins/pi/entries.ts
CHANGED
|
@@ -7,3 +7,4 @@ export const CONTINUATION_TYPE = "notesoup/continuation";
|
|
|
7
7
|
export const RESET_LAST_WORD_TYPE = "notesoup/reset-last-word";
|
|
8
8
|
export const CARRIED_INPUT_TYPE = "notesoup/carried-input";
|
|
9
9
|
export const NEXT_WINDOW_PROMPT_TYPE = "notesoup/next-window-prompt";
|
|
10
|
+
export const MARKER_TYPE = "notesoup/marker";
|
|
@@ -3,9 +3,9 @@ import { historyWindows, historyList, historyRead } from "../../src/tools/histor
|
|
|
3
3
|
import { historyFromSession } from "./history.js";
|
|
4
4
|
import { HISTORY_NAMESPACE, registerOperation } from "./tool-result.js";
|
|
5
5
|
|
|
6
|
-
/** Register the three
|
|
6
|
+
/** Register the three deferred history operations; the adapter allocates addresses and supplies them. */
|
|
7
7
|
export function registerHistoryTools(pi: ExtensionAPI) {
|
|
8
|
-
registerOperation(pi, historyWindows, (params, ctx) => historyWindows.execute(params, historyFromSession(ctx), ctx.sessionManager.getSessionId()), HISTORY_NAMESPACE);
|
|
9
|
-
registerOperation(pi, historyList, (params, ctx) => historyList.execute(params, historyFromSession(ctx)), HISTORY_NAMESPACE);
|
|
10
|
-
registerOperation(pi, historyRead, (params, ctx) => historyRead.execute(params, historyFromSession(ctx)), HISTORY_NAMESPACE);
|
|
8
|
+
registerOperation(pi, historyWindows, (params, ctx) => historyWindows.execute(params, historyFromSession(ctx), ctx.sessionManager.getSessionId()), HISTORY_NAMESPACE, undefined, "deferred");
|
|
9
|
+
registerOperation(pi, historyList, (params, ctx) => historyList.execute(params, historyFromSession(ctx)), HISTORY_NAMESPACE, undefined, "deferred");
|
|
10
|
+
registerOperation(pi, historyRead, (params, ctx) => historyRead.execute(params, historyFromSession(ctx)), HISTORY_NAMESPACE, undefined, "deferred");
|
|
11
11
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { MARKER_TYPE } from "./entries.js";
|
|
3
|
+
import { nextHistorySeq } from "./history.js";
|
|
4
|
+
import { inspectResetTail } from "./reset/artifacts.js";
|
|
5
|
+
import { markerContent } from "./text.js";
|
|
6
|
+
import { currentReset } from "./window.js";
|
|
7
|
+
|
|
8
|
+
/** Spacing between durable seq breadcrumbs, in projected history seq. */
|
|
9
|
+
export const MARKER_INTERVAL = 50;
|
|
10
|
+
|
|
11
|
+
/** Highest seq already stamped by a marker; 0 before the first. */
|
|
12
|
+
function lastMarkerSeq(ctx: ExtensionContext): number {
|
|
13
|
+
let last = 0;
|
|
14
|
+
for (const entry of ctx.sessionManager.getEntries()) {
|
|
15
|
+
if (entry.type !== "custom_message" || entry.customType !== MARKER_TYPE) continue;
|
|
16
|
+
const seq = (entry.details as { seq?: unknown } | undefined)?.seq;
|
|
17
|
+
if (typeof seq === "number" && seq > last) last = seq;
|
|
18
|
+
}
|
|
19
|
+
return last;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Stamp the current seq every MARKER_INTERVAL seqs. The marker names the seq it occupies, so a
|
|
24
|
+
* model paging history_list meets a breadcrumb that tells it where it is. Skipped while a reset
|
|
25
|
+
* tail still awaits boot or continuation: a foreign message there would close the repair shape.
|
|
26
|
+
*/
|
|
27
|
+
export function maybeSendMarker(pi: ExtensionAPI, ctx: ExtensionContext): void {
|
|
28
|
+
const reset = currentReset(ctx);
|
|
29
|
+
if (reset) {
|
|
30
|
+
const tail = inspectResetTail(ctx, reset.id, reset.data.windowId);
|
|
31
|
+
if (tail && (!tail.boot || !tail.continuation)) return;
|
|
32
|
+
}
|
|
33
|
+
const seq = nextHistorySeq(ctx);
|
|
34
|
+
if (seq - lastMarkerSeq(ctx) < MARKER_INTERVAL) return;
|
|
35
|
+
pi.sendMessage(
|
|
36
|
+
{ customType: MARKER_TYPE, content: markerContent(seq), display: false, details: { seq } },
|
|
37
|
+
{ triggerTurn: false },
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -5,6 +5,7 @@ import { notesIdentityFromPi } from "./adapter.js";
|
|
|
5
5
|
import { notesReadRenderers, notesUpdateRenderers, notesWriteRenderers } from "../render.js";
|
|
6
6
|
import { DREAM_NAMESPACE, NOTES_NAMESPACE, registerOperation } from "../tool-result.js";
|
|
7
7
|
import type { NoteChange } from "../../../src/notes/index.js";
|
|
8
|
+
import { notesToolContext } from "../../../src/tools/notes-context.js";
|
|
8
9
|
|
|
9
10
|
function renderDiff(change: NoteChange): string {
|
|
10
11
|
return change.kind === "none" ? "" : generateDiffString(change.before, change.after, 1).diff;
|
|
@@ -12,7 +13,7 @@ function renderDiff(change: NoteChange): string {
|
|
|
12
13
|
|
|
13
14
|
/** Register the five shared note operations and the three hidden dream tools; an open dream widens the note identity. */
|
|
14
15
|
export function registerNotesTools(pi: ExtensionAPI) {
|
|
15
|
-
// One open dream per session
|
|
16
|
+
// One pending or open dream per session: shutdown releases ownership without the end commit.
|
|
16
17
|
const dreams = new Map<string, DreamState>();
|
|
17
18
|
pi.on("session_shutdown", () => {
|
|
18
19
|
for (const state of dreams.values()) abandonDream(state);
|
|
@@ -25,11 +26,12 @@ export function registerNotesTools(pi: ExtensionAPI) {
|
|
|
25
26
|
return state;
|
|
26
27
|
};
|
|
27
28
|
const identity = (ctx: ExtensionContext) => dreamingIdentity(notesIdentityFromPi(ctx), dreamOf(ctx));
|
|
28
|
-
|
|
29
|
-
registerOperation(pi,
|
|
30
|
-
registerOperation(pi,
|
|
31
|
-
registerOperation(pi,
|
|
32
|
-
registerOperation(pi,
|
|
29
|
+
const toolContext = (ctx: ExtensionContext) => notesToolContext(identity(ctx), ctx.cwd);
|
|
30
|
+
registerOperation(pi, notesWrite, (params, ctx) => notesWrite.execute(params, toolContext(ctx)), NOTES_NAMESPACE, notesWriteRenderers);
|
|
31
|
+
registerOperation(pi, notesUpdate, (params, ctx) => notesUpdate.execute(params, toolContext(ctx), renderDiff), NOTES_NAMESPACE, notesUpdateRenderers);
|
|
32
|
+
registerOperation(pi, notesRead, (params, ctx) => notesRead.execute(params, toolContext(ctx)), NOTES_NAMESPACE, notesReadRenderers);
|
|
33
|
+
registerOperation(pi, notesList, (params, ctx) => notesList.execute(params, toolContext(ctx)), NOTES_NAMESPACE);
|
|
34
|
+
registerOperation(pi, notesSearch, (params, ctx) => notesSearch.execute(params, toolContext(ctx)), NOTES_NAMESPACE);
|
|
33
35
|
registerOperation(pi, dreamBegin, (params, ctx) => dreamBegin.execute(params, notesIdentityFromPi(ctx), dreamOf(ctx)), DREAM_NAMESPACE, undefined, "deferred");
|
|
34
36
|
registerOperation(pi, dreamForget, (params, ctx) => dreamForget.execute(params, notesIdentityFromPi(ctx), dreamOf(ctx)), DREAM_NAMESPACE, undefined, "deferred");
|
|
35
37
|
registerOperation(pi, dreamEnd, (params, ctx) => dreamEnd.execute(params, notesIdentityFromPi(ctx), dreamOf(ctx)), DREAM_NAMESPACE, undefined, "deferred");
|
package/plugins/pi/render.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Pi TUI renderers for notesoup's own tools: collapsed one-line slips, expandable bodies. */
|
|
2
2
|
import { renderDiff, type AgentToolResult, type Theme } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import { Text, TruncatedText, visibleWidth, type Component } from "@earendil-works/pi-tui";
|
|
3
|
+
import { Text, TruncatedText, truncateToWidth, visibleWidth, type Component } from "@earendil-works/pi-tui";
|
|
4
4
|
import type { Static } from "typebox";
|
|
5
5
|
import type { NotesReadData, NotesUpdateData, NotesWriteData } from "../../src/tools/notes.js";
|
|
6
6
|
import { notesReadParameters, notesUpdateParameters, notesWriteParameters } from "../../src/tools/notes.js";
|
|
@@ -153,12 +153,14 @@ export const emptyBrainRenderers = {
|
|
|
153
153
|
return {
|
|
154
154
|
invalidate() {},
|
|
155
155
|
render(width: number): string[] {
|
|
156
|
+
if (width <= 0) return [];
|
|
156
157
|
const label = "✂ brain emptied";
|
|
157
158
|
const prefix = "── ";
|
|
158
|
-
const fill = Math.max(
|
|
159
|
+
const fill = Math.max(0, width - visibleWidth(prefix) - visibleWidth(label) - 1);
|
|
159
160
|
const lines = [theme.fg("dim", `${prefix}${label} ${"─".repeat(fill)}`)];
|
|
160
|
-
if (lastWord !== undefined) lines.push(theme.fg("warning", theme.italic(`“${lastWord}”`)));
|
|
161
|
-
|
|
161
|
+
if (lastWord !== undefined) lines.push(...new Text(theme.fg("warning", theme.italic(`“${lastWord}”`)), 0, 0).render(width));
|
|
162
|
+
// The divider, or a wide glyph in a one-column viewport, may still need clipping.
|
|
163
|
+
return lines.map((line) => truncateToWidth(line, width, ""));
|
|
162
164
|
},
|
|
163
165
|
};
|
|
164
166
|
},
|
|
@@ -19,10 +19,10 @@ export function isCarriedInputEntry(entry: SessionEntry): boolean {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/** Advertised size: the description quotes this softer limit so sloppy character counts still fit. */
|
|
22
|
-
export const LAST_WORD_ADVERTISED_CHARS =
|
|
22
|
+
export const LAST_WORD_ADVERTISED_CHARS = 300;
|
|
23
23
|
|
|
24
24
|
/** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
|
|
25
|
-
export const MAX_LAST_WORD_CHARS =
|
|
25
|
+
export const MAX_LAST_WORD_CHARS = 500;
|
|
26
26
|
|
|
27
27
|
/** How the next window finds the note. */
|
|
28
28
|
export const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
|
package/plugins/pi/runtime.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { buildResetDrafts, LAST_WORD_ADVERTISED_CHARS, MAX_LAST_WORD_CHARS, repa
|
|
|
11
11
|
import { BOOT_TYPE, MANUAL_WIPE_TYPE } from "./entries.js";
|
|
12
12
|
import { commandWarningContent } from "./text.js";
|
|
13
13
|
import { buildBootMessage, sendBoot, type IncompleteNotesNotifier } from "./boot.js";
|
|
14
|
+
import { maybeSendMarker } from "./marker.js";
|
|
14
15
|
import { nextHistorySeq } from "./history.js";
|
|
15
16
|
import { errorMessage } from "../../src/error-message.js";
|
|
16
17
|
|
|
@@ -73,13 +74,13 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
73
74
|
const marker = branch.find((entry): entry is WindowMarker => isWindowMarker(entry) && entry.data.windowId === windowId);
|
|
74
75
|
if (!marker || !isCheckpointBackedReset(ctx, marker) || !resetBoundaryCommitted(ctx, marker.id, windowId)) continue;
|
|
75
76
|
pendingResetNotices.delete(windowId);
|
|
76
|
-
|
|
77
|
-
// committed notice stays a one-line marker instead of repeating it.
|
|
78
|
-
const forced = markerResetOrigin(marker) === "forced";
|
|
79
|
-
ctx.ui.notify(forced ? "🥣 Brain forcibly emptied: overflow" : "🥣 Fresh brain", forced ? "warning" : "info");
|
|
77
|
+
if (markerResetOrigin(marker) === "forced") ctx.ui.notify("🥣 Brain forcibly emptied: overflow", "warning");
|
|
80
78
|
}
|
|
81
79
|
};
|
|
82
|
-
pi.on("turn_start", (_event, ctx) =>
|
|
80
|
+
pi.on("turn_start", (_event, ctx) => {
|
|
81
|
+
notifyCommittedResets(ctx);
|
|
82
|
+
if (enabled) maybeSendMarker(pi, ctx);
|
|
83
|
+
});
|
|
83
84
|
pi.on("agent_settled", (_event, ctx) => {
|
|
84
85
|
notifyCommittedResets(ctx);
|
|
85
86
|
pendingResetNotices.clear();
|
|
@@ -87,8 +88,8 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
87
88
|
const notifyIncompleteNotes: IncompleteNotesNotifier = (ctx, windowId, snapshot) => {
|
|
88
89
|
if (snapshot.unavailable.length === 0 || incompleteNotesNotified.has(windowId)) return;
|
|
89
90
|
incompleteNotesNotified.add(windowId);
|
|
90
|
-
const
|
|
91
|
-
ctx.ui.notify(`🥣 Some notes went missing: ${
|
|
91
|
+
const namespaces = snapshot.unavailable.map((namespace) => namespace.label).join(", ");
|
|
92
|
+
ctx.ui.notify(`🥣 Some notes went missing: ${namespaces}`, "warning");
|
|
92
93
|
};
|
|
93
94
|
const budget = registerBudget(pi, () => enabled, settingsManager);
|
|
94
95
|
|
|
@@ -189,7 +190,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
|
|
|
189
190
|
cmdCtx.ui.notify("🥣 Brain already being emptied", "info");
|
|
190
191
|
return;
|
|
191
192
|
}
|
|
192
|
-
cmdCtx.ui.notify("🥣 Brain
|
|
193
|
+
cmdCtx.ui.notify("🥣 Dumping Brain", "info");
|
|
193
194
|
try {
|
|
194
195
|
pi.sendMessage({ customType: MANUAL_WIPE_TYPE, content: commandWarningContent(prompt !== undefined ? `/empty ${prompt}` : undefined), display: false }, { triggerTurn: true, deliverAs: "steer" });
|
|
195
196
|
} catch (error) {
|
package/plugins/pi/text.ts
CHANGED
|
@@ -11,6 +11,11 @@ Unless the human explicitly directs otherwise, decide for yourself when to call
|
|
|
11
11
|
|
|
12
12
|
export { warningNotice as warningContent } from "../../src/budget/text.js";
|
|
13
13
|
|
|
14
|
+
/** Odometer breadcrumb: the marker names its own seq, so history paging reads the landscape directly. */
|
|
15
|
+
export function markerContent(seq: number): string {
|
|
16
|
+
return `<notesoup:marker seq="${seq}" />`;
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
/** The closing model sees deferred input as a bare next-window prompt block. */
|
|
15
20
|
export function promptBlock(commandLine: string): string {
|
|
16
21
|
return `<notesoup:next_window_prompt>\n${commandLine}\n</notesoup:next_window_prompt>`;
|