notesoup 0.61.0 → 0.63.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/.agents/plugins/marketplace.json +15 -0
- package/README.md +14 -11
- package/dist/plugins/antigravity/src/cli.d.ts +1 -0
- package/dist/plugins/antigravity/src/cli.js +23 -0
- package/dist/plugins/antigravity/src/hooks.d.ts +18 -0
- package/dist/plugins/antigravity/src/hooks.js +53 -0
- package/dist/plugins/antigravity/src/identity.d.ts +26 -0
- package/dist/plugins/antigravity/src/identity.js +129 -0
- package/dist/plugins/claude/src/helper.js +24 -5
- package/dist/plugins/claude/src/text.d.ts +7 -0
- package/dist/plugins/claude/src/text.js +12 -1
- package/dist/plugins/codex/src/hooks.js +1 -0
- package/dist/plugins/codex/src/identity.d.ts +6 -1
- package/dist/plugins/codex/src/identity.js +13 -1
- package/dist/plugins/codex/src/mcp.d.ts +35 -7
- package/dist/plugins/codex/src/mcp.js +26 -88
- package/dist/plugins/codex/src/text.js +3 -3
- package/dist/plugins/dsh/tools.js +8 -4
- package/dist/plugins/mcp/operations.d.ts +15 -0
- package/dist/plugins/mcp/operations.js +43 -0
- package/dist/plugins/mcp/server.d.ts +14 -0
- package/dist/plugins/mcp/server.js +13 -0
- package/dist/plugins/pi/budget.d.ts +4 -1
- package/dist/plugins/pi/budget.js +35 -8
- package/dist/plugins/pi/entries.d.ts +2 -0
- package/dist/plugins/pi/entries.js +2 -0
- package/dist/plugins/pi/history-tools.js +2 -1
- package/dist/plugins/pi/history.js +18 -1
- package/dist/plugins/pi/notes/tools.js +7 -3
- package/dist/plugins/pi/render.d.ts +7 -1
- package/dist/plugins/pi/render.js +2 -2
- package/dist/plugins/pi/reset/artifacts.d.ts +1 -1
- package/dist/plugins/pi/reset/artifacts.js +4 -4
- package/dist/plugins/pi/reset/lifecycle.d.ts +9 -2
- package/dist/plugins/pi/reset/lifecycle.js +109 -31
- package/dist/plugins/pi/runtime.js +104 -63
- package/dist/plugins/pi/tool-result.js +7 -7
- package/dist/plugins/pi/window.d.ts +25 -3
- package/dist/plugins/pi/window.js +219 -9
- package/dist/src/boot/render.js +18 -15
- package/dist/src/boot/text.d.ts +3 -1
- package/dist/src/boot/text.js +22 -20
- package/dist/src/budget/text.d.ts +7 -3
- package/dist/src/budget/text.js +24 -15
- package/dist/src/history/claude.d.ts +2 -0
- package/dist/src/history/claude.js +46 -0
- package/dist/src/history/codex-transcript.js +7 -5
- package/dist/src/history/codex.js +3 -0
- package/dist/src/history/corpus.d.ts +28 -1
- package/dist/src/history/corpus.js +40 -0
- package/dist/src/history/history.d.ts +37 -46
- package/dist/src/history/history.js +21 -40
- package/dist/src/history/local.js +67 -32
- package/dist/src/history/pi.d.ts +2 -1
- package/dist/src/history/pi.js +122 -48
- package/dist/src/history/prefilter.js +76 -19
- package/dist/src/history/query.d.ts +28 -49
- package/dist/src/history/query.js +83 -68
- package/dist/src/history/summary-cache.d.ts +8 -1
- package/dist/src/history/summary-cache.js +138 -12
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/notes/errors.d.ts +1 -1
- package/dist/src/notes/frontmatter.d.ts +0 -2
- package/dist/src/notes/frontmatter.js +0 -2
- package/dist/src/notes/index.d.ts +1 -1
- package/dist/src/notes/index.js +1 -1
- package/dist/src/notes/policy.d.ts +15 -1
- package/dist/src/notes/policy.js +46 -5
- package/dist/src/notes/store.d.ts +12 -0
- package/dist/src/notes/store.js +16 -20
- package/dist/src/text-match.d.ts +10 -1
- package/dist/src/text-match.js +42 -3
- package/dist/src/tools/dream.d.ts +22 -93
- package/dist/src/tools/dream.js +30 -27
- package/dist/src/tools/history.d.ts +33 -26
- package/dist/src/tools/history.js +257 -163
- package/dist/src/tools/notes.d.ts +51 -163
- package/dist/src/tools/notes.js +146 -100
- package/dist/src/tools/output.d.ts +2 -1
- package/dist/src/tools/output.js +2 -1
- package/dist/src/tools/result.d.ts +4 -7
- package/dist/src/tools/result.js +8 -9
- package/dist/src/tools/schema.d.ts +4 -1
- package/dist/src/tools/schema.js +25 -1
- package/dist/test/agent-loop.test.js +394 -56
- package/dist/test/antigravity-live.test.d.ts +1 -0
- package/dist/test/antigravity-live.test.js +142 -0
- package/dist/test/antigravity-plugin.test.d.ts +1 -0
- package/dist/test/antigravity-plugin.test.js +101 -0
- package/dist/test/boot.integration.test.js +156 -15
- package/dist/test/budget-settings.integration.test.js +4 -4
- package/dist/test/claude-history.test.js +14 -13
- package/dist/test/claude-mod.test.js +199 -16
- package/dist/test/claude-validation.test.js +69 -2
- package/dist/test/codex-history.test.js +15 -3
- package/dist/test/codex-plugin.test.js +76 -38
- package/dist/test/dependencies.test.js +7 -3
- package/dist/test/dream-skill.test.js +3 -3
- package/dist/test/dream-tools.test.js +101 -56
- package/dist/test/dsh.test.js +34 -19
- package/dist/test/helpers/dependency-graph.js +2 -2
- package/dist/test/helpers/extension.d.ts +68 -3
- package/dist/test/helpers/extension.js +74 -5
- package/dist/test/history-corpus.test.js +79 -77
- package/dist/test/history-summary-cache.test.js +97 -9
- package/dist/test/history.integration.test.js +234 -168
- package/dist/test/host-neutral.test.js +69 -19
- package/dist/test/marker.test.js +1 -1
- package/dist/test/model-facing-text.test.js +13 -3
- package/dist/test/note-policy.test.js +96 -77
- package/dist/test/notes.integration.test.js +212 -94
- package/dist/test/notes.test.js +184 -113
- package/dist/test/pi-render.test.js +20 -12
- package/dist/test/project-namespace.test.js +3 -2
- package/dist/test/reset-lifecycle.test.js +12 -2
- package/docs/antigravity.md +44 -0
- package/docs/architecture.md +6 -4
- package/docs/claude-code-mod.md +7 -7
- package/docs/codex.md +36 -38
- package/docs/dsh.md +3 -3
- package/docs/history-sessions.md +28 -50
- package/docs/notes-library.md +4 -4
- package/docs/reset-lifecycle.md +1 -1
- package/docs/skills.md +3 -3
- package/docs/tool-results.md +47 -28
- package/package.json +3 -2
- package/playbook.md +1 -1
- package/plugins/antigravity/dist/antigravity/notesoup.js +26886 -0
- package/plugins/antigravity/hooks.json +7 -0
- package/plugins/antigravity/mcp_config.json +8 -0
- package/plugins/antigravity/plugin.json +6 -0
- package/plugins/antigravity/src/cli.ts +22 -0
- package/plugins/antigravity/src/hooks.ts +51 -0
- package/plugins/antigravity/src/identity.ts +127 -0
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +1108 -539
- package/plugins/claude/hooks/register.ts +202 -62
- package/plugins/claude/playbook.md +1 -1
- package/plugins/claude/skills/dream/SKILL.md +1 -1
- package/plugins/claude/skills/notesoup-guide/SKILL.md +92 -0
- package/plugins/claude/src/helper.ts +24 -5
- package/plugins/claude/src/text.ts +14 -1
- package/plugins/codex/.codex-plugin/plugin.json +8 -0
- package/plugins/codex/.mcp.json +11 -0
- package/plugins/codex/README.md +5 -21
- package/plugins/codex/dist/codex/notesoup.js +18480 -17946
- package/plugins/codex/src/hooks.ts +1 -0
- package/plugins/codex/src/identity.ts +14 -1
- package/plugins/codex/src/mcp.ts +28 -98
- package/plugins/codex/src/text.ts +3 -3
- package/plugins/dsh/tools.ts +8 -4
- package/plugins/mcp/operations.ts +50 -0
- package/plugins/mcp/server.ts +23 -0
- package/plugins/paseo/README.md +5 -10
- package/plugins/paseo/client/brain-empty-card.tsx +3 -3
- package/plugins/paseo/client/markdown.tsx +50 -38
- package/plugins/paseo/client/notes-op-card.tsx +12 -9
- package/plugins/paseo/client/paper-card.tsx +6 -5
- package/plugins/paseo/client/paper-palette.ts +2 -9
- package/plugins/paseo/client/sticky-card.tsx +2 -2
- package/plugins/paseo/client/tool-result.ts +7 -14
- package/plugins/paseo/package-lock.json +3406 -0
- package/plugins/paseo/package.json +1 -0
- package/plugins/paseo/test/markdown-core.test.ts +73 -66
- package/plugins/pi/budget.ts +31 -8
- package/plugins/pi/entries.ts +2 -0
- package/plugins/pi/history-tools.ts +2 -1
- package/plugins/pi/history.ts +30 -1
- package/plugins/pi/notes/tools.ts +7 -3
- package/plugins/pi/render.ts +6 -6
- package/plugins/pi/reset/artifacts.ts +4 -3
- package/plugins/pi/reset/lifecycle.ts +125 -32
- package/plugins/pi/runtime.ts +98 -62
- package/plugins/pi/tool-result.ts +8 -8
- package/plugins/pi/window.ts +210 -10
- package/skills/dream/SKILL.md +1 -1
- package/skills/notesoup-guide/SKILL.md +92 -0
- package/src/boot/render.ts +18 -15
- package/src/boot/text.ts +23 -19
- package/src/budget/text.ts +27 -15
- package/src/history/claude.ts +41 -0
- package/src/history/codex-transcript.ts +6 -4
- package/src/history/codex.ts +2 -0
- package/src/history/corpus.ts +51 -2
- package/src/history/history.ts +35 -44
- package/src/history/local.ts +67 -27
- package/src/history/pi.ts +113 -35
- package/src/history/prefilter.ts +73 -15
- package/src/history/query.ts +93 -73
- package/src/history/summary-cache.ts +142 -17
- package/src/index.ts +2 -2
- package/src/notes/errors.ts +1 -1
- package/src/notes/frontmatter.ts +0 -3
- package/src/notes/index.ts +1 -1
- package/src/notes/policy.ts +44 -5
- package/src/notes/store.ts +17 -20
- package/src/text-match.ts +46 -4
- package/src/tools/dream.ts +29 -31
- package/src/tools/history.ts +249 -142
- package/src/tools/notes.ts +145 -113
- package/src/tools/output.ts +2 -1
- package/src/tools/result.ts +12 -11
- package/src/tools/schema.ts +24 -1
- package/plugins/claude/skills/memory/SKILL.md +0 -69
- package/plugins/codex/mcp.json +0 -10
- package/plugins/codex/plugin.json +0 -6
- package/plugins/paseo/client/markdown-core.tsx +0 -189
- package/plugins/paseo/client/typography.ts +0 -24
- package/skills/memory/SKILL.md +0 -69
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
5
|
+
import { createServer } from "node:http";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import { promisify } from "node:util";
|
|
10
|
+
import test from "node:test";
|
|
11
|
+
import { createNotesStore, projectKey } from "../src/notes/index.js";
|
|
12
|
+
const exec = promisify(execFile);
|
|
13
|
+
const agy = process.env.NOTESOUP_AGY_LIVE;
|
|
14
|
+
const PINS = ["SYNTHETIC_HUMAN_BOOT_2187", "SYNTHETIC_PROJECT_BOOT_4271", "SYNTHETIC_MODEL_BOOT_3364"];
|
|
15
|
+
const SERVER = "notesoup_notesoup";
|
|
16
|
+
const OPS = ["notes_read", "notes_write", "notes_update", "notes_list"];
|
|
17
|
+
function repo() {
|
|
18
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
while (!existsSync(join(dir, "tsconfig.json")))
|
|
20
|
+
dir = dirname(dir);
|
|
21
|
+
return dir;
|
|
22
|
+
}
|
|
23
|
+
function responseFor(body, bootOnly) {
|
|
24
|
+
if (bootOnly)
|
|
25
|
+
return { text: "Synthetic boot-only turn complete." };
|
|
26
|
+
const user = body.contents.filter(c => c.role === "user").flatMap(c => c.parts).map(p => p.text ?? "").join("\n");
|
|
27
|
+
const tag = user.includes("CHILD_FIXTURE_PROBE 1") ? "CHILD_ONE" : user.includes("CHILD_FIXTURE_PROBE 2") ? "CHILD_TWO" : "ROOT";
|
|
28
|
+
const calls = body.contents.flatMap(c => c.parts).flatMap(p => p.functionCall ? [p.functionCall.name] : []);
|
|
29
|
+
const n = calls.filter(c => c === "call_mcp_tool").length;
|
|
30
|
+
const mcp = (name, args) => ({ functionCall: { name: "call_mcp_tool", args: { ServerName: SERVER, ToolName: name, Arguments: args } } });
|
|
31
|
+
if (n === 0)
|
|
32
|
+
return mcp("notes_write", { address: "scratch.md", content: `${tag}_SENTINEL` });
|
|
33
|
+
if (n === 1)
|
|
34
|
+
return mcp("notes_read", { address: "scratch.md" });
|
|
35
|
+
if (n === 2)
|
|
36
|
+
return mcp("notes_update", { address: "scratch.md", edits: [{ oldText: `${tag}_SENTINEL`, newText: `${tag}_EDITED` }] });
|
|
37
|
+
if (n === 3)
|
|
38
|
+
return mcp("notes_list", {});
|
|
39
|
+
if (tag !== "ROOT")
|
|
40
|
+
return { text: "Child fixture done." };
|
|
41
|
+
if (!calls.includes("define_subagent"))
|
|
42
|
+
return { functionCall: { name: "define_subagent", args: { Name: "fixture-worker", Description: "Synthetic fixture worker", SystemPrompt: "Only run the fixture.", EnableMCPTools: true } } };
|
|
43
|
+
const count = calls.filter(c => c === "invoke_subagent").length;
|
|
44
|
+
if (count < 2)
|
|
45
|
+
return { functionCall: { name: "invoke_subagent", args: { TypeName: "fixture-worker", Role: "Fixture Worker", Prompt: `CHILD_FIXTURE_PROBE ${count + 1}` } } };
|
|
46
|
+
return { text: "Fixture responder finished." };
|
|
47
|
+
}
|
|
48
|
+
// Opt in with the real agy 1.5.17 executable. This is a local scripted provider, not an LLM quality test.
|
|
49
|
+
// It exercises native plugin install/discovery, native hook injection and actual MCP calls.
|
|
50
|
+
test("native AGY installs Notesoup and injects boot before any tool, including two concurrent children", { skip: !agy, timeout: 90_000 }, async (t) => {
|
|
51
|
+
const root = await mkdtemp(join(tmpdir(), "notesoup-agy-live-"));
|
|
52
|
+
t.after(() => rm(root, { recursive: true, force: true }));
|
|
53
|
+
const home = join(root, "home"), notesHome = join(root, "notes"), cwd = join(root, "work");
|
|
54
|
+
const settings = join(home, ".gemini", "antigravity-cli");
|
|
55
|
+
await Promise.all([mkdir(settings, { recursive: true }), mkdir(cwd), mkdir(notesHome)]);
|
|
56
|
+
await writeFile(join(settings, "settings.json"), JSON.stringify({ modelProvider: "gemini", permissions: { allow: OPS.map(op => `mcp(${SERVER}/${op})`) } }));
|
|
57
|
+
const noExternal = "http://127.0.0.1:1";
|
|
58
|
+
const env = { HOME: home, NOTESOUP_HOME: notesHome, PATH: `${dirname(process.execPath)}:/usr/bin:/bin:/usr/sbin:/sbin`,
|
|
59
|
+
XDG_CONFIG_HOME: join(home, ".config"), XDG_CACHE_HOME: join(home, ".cache"), XDG_DATA_HOME: join(home, ".local/share"),
|
|
60
|
+
GEMINI_API_KEY: "dummy", BROWSER: "/usr/bin/false", HTTP_PROXY: noExternal, HTTPS_PROXY: noExternal, ALL_PROXY: noExternal,
|
|
61
|
+
http_proxy: noExternal, https_proxy: noExternal, all_proxy: noExternal, NO_PROXY: "localhost,127.0.0.1,::1", no_proxy: "localhost,127.0.0.1,::1" };
|
|
62
|
+
const requestLog = [];
|
|
63
|
+
let bootOnly = true;
|
|
64
|
+
let resumeRequests = 0;
|
|
65
|
+
let resuming = false;
|
|
66
|
+
const server = createServer(async (request, response) => {
|
|
67
|
+
try {
|
|
68
|
+
let raw = "";
|
|
69
|
+
for await (const chunk of request)
|
|
70
|
+
raw += chunk;
|
|
71
|
+
const body = JSON.parse(raw);
|
|
72
|
+
requestLog.push(body);
|
|
73
|
+
const part = resuming
|
|
74
|
+
? resumeRequests++ === 0
|
|
75
|
+
? { functionCall: { name: "call_mcp_tool", args: { ServerName: SERVER, ToolName: "notes_read", Arguments: { address: "scratch.md" } } } }
|
|
76
|
+
: { text: "Resumed fixture complete." }
|
|
77
|
+
: responseFor(body, bootOnly);
|
|
78
|
+
const data = { candidates: [{ content: { role: "model", parts: [part] }, finishReason: "STOP" }], usageMetadata: { promptTokenCount: 20, candidatesTokenCount: 4, totalTokenCount: 24 } };
|
|
79
|
+
response.writeHead(200, { "Content-Type": "text/event-stream" });
|
|
80
|
+
response.end(`data: ${JSON.stringify(data)}\n\n`);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
response.writeHead(500);
|
|
84
|
+
response.end(String(error));
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
await new Promise(resolve => server.listen(0, "127.0.0.1", resolve));
|
|
88
|
+
t.after(() => { server.closeAllConnections(); server.close(); });
|
|
89
|
+
const addr = server.address();
|
|
90
|
+
assert.ok(addr && typeof addr !== "string");
|
|
91
|
+
const options = { env: { ...env, GOOGLE_GEMINI_BASE_URL: `http://127.0.0.1:${addr.port}` }, cwd, timeout: 35_000, maxBuffer: 4 * 1024 * 1024 };
|
|
92
|
+
t.diagnostic(`agy ${(await exec(agy, ["--version"], options)).stdout.trim()}`);
|
|
93
|
+
const installed = await exec(agy, ["plugin", "install", join(repo(), "plugins/antigravity")], options);
|
|
94
|
+
assert.match(installed.stdout + installed.stderr, /Installed to/);
|
|
95
|
+
const store = createNotesStore({ home: notesHome, sessionId: "seed", projectKey: projectKey(cwd, notesHome), agent: "anonymous", model: "gemini-3-1-pro-low" });
|
|
96
|
+
await store.write("@human/CHEATSHEET.md", PINS[0]);
|
|
97
|
+
await store.write("@project/CHEATSHEET.md", PINS[1]);
|
|
98
|
+
await store.write("@model/CHEATSHEET.md", PINS[2]);
|
|
99
|
+
const args = ["-p", "Run notesoup fixture probe.", "--output-format", "stream-json", "--add-dir", cwd, "--disable-slash-commands"];
|
|
100
|
+
const boot = await exec(agy, args, options);
|
|
101
|
+
assert.match(boot.stdout, /SUCCESS/);
|
|
102
|
+
assert.equal(requestLog.length, 1);
|
|
103
|
+
const verifyBoot = (body) => {
|
|
104
|
+
const parts = body.contents.flatMap(c => c.parts.map(p => ({ ...p, role: c.role })));
|
|
105
|
+
assert.ok(parts.every(p => p.functionCall === undefined && p.functionResponse === undefined), "boot must precede all tool calls");
|
|
106
|
+
const protocol = parts.find(p => p.text?.includes("<notesoup:notes_protocol>"));
|
|
107
|
+
assert.ok(protocol?.text?.includes("<SYSTEM_MESSAGE>"), "native hook protocol retains system-message provenance");
|
|
108
|
+
const note = parts.find(p => p.text?.includes("YOUR NOTES"));
|
|
109
|
+
assert.equal(note?.role, "user");
|
|
110
|
+
assert.ok(PINS.every(pin => note?.text?.includes(pin) && !protocol?.text?.includes(pin) && !JSON.stringify(body.systemInstruction).includes(pin)));
|
|
111
|
+
const id = /Antigravity conversation ([0-9a-f-]{36})/.exec(note.text)?.[1];
|
|
112
|
+
assert.ok(id);
|
|
113
|
+
return id;
|
|
114
|
+
};
|
|
115
|
+
verifyBoot(requestLog[0]);
|
|
116
|
+
bootOnly = false;
|
|
117
|
+
const callRun = await exec(agy, args, options);
|
|
118
|
+
assert.match(callRun.stdout, /SUCCESS/);
|
|
119
|
+
const fresh = requestLog.slice(1).filter(b => b.contents.flatMap(c => c.parts).every(p => !p.functionCall && !p.functionResponse));
|
|
120
|
+
assert.equal(fresh.length, 3, "root and two parallel children each receive their own first request");
|
|
121
|
+
const ids = fresh.map(verifyBoot);
|
|
122
|
+
assert.equal(new Set(ids).size, 3);
|
|
123
|
+
const sessions = join(notesHome, "pi", "session");
|
|
124
|
+
const outputs = [];
|
|
125
|
+
for (const id of ids)
|
|
126
|
+
outputs.push((await readFile(join(sessions, id, "scratch.md"), "utf8")).trim().split("\n").at(-1));
|
|
127
|
+
assert.deepEqual(outputs.sort(), ["CHILD_ONE_EDITED", "CHILD_TWO_EDITED", "ROOT_EDITED"]);
|
|
128
|
+
assert.equal((await readdir(sessions)).filter(id => ids.includes(id)).length, 3);
|
|
129
|
+
for (const tag of ["CHILD_ONE", "CHILD_TWO", "ROOT"]) {
|
|
130
|
+
const completed = requestLog.find(b => b.contents.flatMap(c => c.parts).some(p => p.functionResponse?.name === "call_mcp_tool" && JSON.stringify(p.functionResponse).includes(`${tag}_SENTINEL`)));
|
|
131
|
+
assert.ok(completed, `${tag} got its own read result`);
|
|
132
|
+
}
|
|
133
|
+
resuming = true;
|
|
134
|
+
const start = requestLog.length;
|
|
135
|
+
const resumed = await exec(agy, ["--conversation", ids[0], ...args], options);
|
|
136
|
+
assert.match(resumed.stdout, /SUCCESS/);
|
|
137
|
+
const followup = requestLog.slice(start);
|
|
138
|
+
const resumedParts = followup[0].contents.flatMap(c => c.parts);
|
|
139
|
+
assert.equal(resumedParts.filter(p => p.text?.includes("YOUR NOTES")).length, 1, "resume retains its original boot without reinjecting");
|
|
140
|
+
assert.ok(resumedParts.some(p => p.text?.includes(ids[0]) && PINS.every(pin => p.text.includes(pin))));
|
|
141
|
+
assert.ok(followup.at(-1).contents.flatMap(c => c.parts).some(p => p.functionResponse?.name === "call_mcp_tool" && JSON.stringify(p.functionResponse).includes("ROOT_EDITED")), "resume reads same isolated session note");
|
|
142
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { mkdir, mkdtemp, rm } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import test from "node:test";
|
|
9
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
10
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
11
|
+
import { createNotesStore } from "../src/notes/index.js";
|
|
12
|
+
import { bindingFromHook, contextForBinding, resolveContext } from "../plugins/antigravity/src/identity.js";
|
|
13
|
+
import { preInvocation } from "../plugins/antigravity/src/hooks.js";
|
|
14
|
+
const ROOT = "02a1590d-9743-492c-a7d1-644b408390c0";
|
|
15
|
+
const CHILD = "02a1590d-9743-492c-a7d1-644b408390c1";
|
|
16
|
+
const SIBLING = "02a1590d-9743-492c-a7d1-644b408390c2";
|
|
17
|
+
const prefix = "antigravity.google/";
|
|
18
|
+
const meta = (id = ROOT, root = ROOT, extra = {}) => ({ [`${prefix}conversation_id`]: id, [`${prefix}root_conversation_id`]: root, ...extra });
|
|
19
|
+
function repo() {
|
|
20
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
while (!existsSync(join(dir, "tsconfig.json")))
|
|
22
|
+
dir = dirname(dir);
|
|
23
|
+
return dir;
|
|
24
|
+
}
|
|
25
|
+
const CLI = join(repo(), "plugins/antigravity/dist/antigravity/notesoup.js");
|
|
26
|
+
/** Producer-shaped fixtures: installed 1.5.17 root hook, native protobuf ancestry fields and MCP keys. */
|
|
27
|
+
test("Antigravity boots each conversation once with user-role notes and binds the current model per invocation", async (t) => {
|
|
28
|
+
const root = await mkdtemp(join(tmpdir(), "notesoup-agy-"));
|
|
29
|
+
t.after(() => rm(root, { recursive: true, force: true }));
|
|
30
|
+
const env = { NOTESOUP_HOME: join(root, "notes"), PLUGIN_DATA: join(root, "data") };
|
|
31
|
+
const cwd = join(root, "project"), childCwd = join(root, "child");
|
|
32
|
+
await Promise.all([mkdir(cwd), mkdir(childCwd)]);
|
|
33
|
+
const hook = { conversationId: ROOT, cwd, hookEventName: "PreInvocation", modelName: "gemini-3.1-pro-low", workspacePaths: [cwd], invocationNum: 0, initialNumSteps: 1 };
|
|
34
|
+
const child = { ...hook, conversationId: CHILD, parentConversationId: ROOT, rootConversationId: ROOT, agentName: "Reviewer", modelName: "models/gemini-flash", cwd: childCwd };
|
|
35
|
+
// Live 1.5.17 dynamic subagent hooks omit all ancestry and name fields.
|
|
36
|
+
const sibling = { ...hook, conversationId: SIBLING, cwd: childCwd };
|
|
37
|
+
await createNotesStore(contextForBinding(bindingFromHook(hook, env)).identity).write("CHEATSHEET.md", "ROOT_ONLY_PIN_12");
|
|
38
|
+
await createNotesStore(contextForBinding(bindingFromHook(child, env)).identity).write("CHEATSHEET.md", "CHILD_ONLY_PIN_34");
|
|
39
|
+
const boot = await preInvocation(hook, env);
|
|
40
|
+
assert.equal(boot.injectSteps?.length, 2);
|
|
41
|
+
const [protocol, data] = boot.injectSteps;
|
|
42
|
+
assert.ok(protocol && "systemMessage" in protocol && protocol.systemMessage.systemMessage.includes("notes_*"));
|
|
43
|
+
assert.ok(data && "userMessage" in data && data.userMessage.includes("ROOT_ONLY_PIN_12") && !data.userMessage.includes("CHILD_ONLY_PIN_34"));
|
|
44
|
+
assert.ok(!JSON.stringify(protocol).includes("ROOT_ONLY_PIN_12"));
|
|
45
|
+
assert.deepEqual(await preInvocation({ ...hook, modelName: "gemini-3.1-pro-high" }, env), {});
|
|
46
|
+
assert.equal((await resolveContext(meta(), env)).identity.model, "gemini-3-1-pro-high");
|
|
47
|
+
const [childBoot, siblingBoot] = await Promise.all([preInvocation(child, env), preInvocation(sibling, env)]);
|
|
48
|
+
assert.match(JSON.stringify(childBoot), /CHILD_ONLY_PIN_34/);
|
|
49
|
+
assert.doesNotMatch(JSON.stringify(siblingBoot), /CHILD_ONLY_PIN_34|ROOT_ONLY_PIN_12/);
|
|
50
|
+
const contexts = await Promise.all([resolveContext(meta(CHILD, ROOT, { [`${prefix}agent_name`]: "Reviewer", [`${prefix}parent_conversation_id`]: ROOT }), env), resolveContext(meta(SIBLING, ROOT, { [`${prefix}parent_conversation_id`]: ROOT }), env), resolveContext(meta(), env)]);
|
|
51
|
+
assert.deepEqual(contexts.map(c => [c.identity.sessionId, c.identity.agent, c.cwd]), [[CHILD, "reviewer", childCwd], [SIBLING, "anonymous", childCwd], [ROOT, "anonymous", cwd]]);
|
|
52
|
+
await assert.rejects(resolveContext({ [`${prefix}root_conversation_id`]: ROOT }, env), /native conversation ID/);
|
|
53
|
+
await assert.rejects(resolveContext(meta(CHILD, SIBLING), env), /disagrees/);
|
|
54
|
+
await assert.rejects(resolveContext(meta(CHILD, ROOT, { [`${prefix}agent_name`]: "Author" }), env), /disagrees/);
|
|
55
|
+
await preInvocation({ ...hook, modelName: "auto" }, env);
|
|
56
|
+
await assert.rejects(resolveContext(meta(), env), /No Notesoup hook binding/);
|
|
57
|
+
});
|
|
58
|
+
test("installed-shape stdio transport exposes four operations, refuses unbound calls, and interleaves conversation notes", async (t) => {
|
|
59
|
+
const root = await mkdtemp(join(tmpdir(), "notesoup-agy-mcp-"));
|
|
60
|
+
t.after(() => rm(root, { recursive: true, force: true }));
|
|
61
|
+
const env = { NOTESOUP_HOME: join(root, "notes"), PLUGIN_DATA: join(root, "data") };
|
|
62
|
+
const base = { cwd: root, hookEventName: "PreInvocation", modelName: "gemini-3.1-pro-low" };
|
|
63
|
+
for (const payload of [{ ...base, conversationId: ROOT }, { ...base, conversationId: CHILD }]) {
|
|
64
|
+
const result = spawnSync(process.execPath, [CLI, "pre-invocation"], { env, input: JSON.stringify(payload), encoding: "utf8" });
|
|
65
|
+
assert.equal(result.status, 0, result.stderr);
|
|
66
|
+
assert.match(result.stdout, /YOUR NOTES/);
|
|
67
|
+
}
|
|
68
|
+
const client = new Client({ name: "fixture", version: "1" });
|
|
69
|
+
await client.connect(new StdioClientTransport({ command: process.execPath, args: [CLI, "mcp"], env }));
|
|
70
|
+
t.after(() => client.close());
|
|
71
|
+
const tools = (await client.listTools()).tools;
|
|
72
|
+
assert.deepEqual(tools.map(x => x.name).sort(), ["notes_list", "notes_read", "notes_update", "notes_write"]);
|
|
73
|
+
for (const tool of tools) {
|
|
74
|
+
if (tool.name === "notes_read")
|
|
75
|
+
assert.equal(tool.outputSchema?.type, "object");
|
|
76
|
+
else
|
|
77
|
+
assert.equal(tool.outputSchema, undefined);
|
|
78
|
+
}
|
|
79
|
+
const write = (id, content) => client.callTool({ name: "notes_write", arguments: { address: "scratch.md", content }, _meta: meta(id) });
|
|
80
|
+
const read = (id) => client.callTool({ name: "notes_read", arguments: { address: "scratch.md" }, _meta: meta(id) });
|
|
81
|
+
const writes = await Promise.all([write(ROOT, "ROOT_SENTINEL"), write(CHILD, "CHILD_SENTINEL")]);
|
|
82
|
+
assert.ok(writes.every(result => !result.isError && result.structuredContent === undefined), JSON.stringify(writes));
|
|
83
|
+
const rootRead = await read(ROOT), childRead = await read(CHILD);
|
|
84
|
+
assert.equal(rootRead.structuredContent.text, "ROOT_SENTINEL");
|
|
85
|
+
assert.equal(childRead.structuredContent.text, "CHILD_SENTINEL");
|
|
86
|
+
assert.match(JSON.stringify(rootRead), /ROOT_SENTINEL/);
|
|
87
|
+
assert.doesNotMatch(JSON.stringify(rootRead), /CHILD_SENTINEL/);
|
|
88
|
+
assert.match(JSON.stringify(childRead), /CHILD_SENTINEL/);
|
|
89
|
+
const update = await client.callTool({ name: "notes_update", arguments: { address: "scratch.md", edits: [{ oldText: "CHILD_SENTINEL", newText: "CHILD_EDITED" }] }, _meta: meta(CHILD) });
|
|
90
|
+
assert.ok(!update.isError, JSON.stringify(update));
|
|
91
|
+
assert.equal(update.structuredContent, undefined);
|
|
92
|
+
assert.match(JSON.stringify(await read(CHILD)), /CHILD_EDITED/);
|
|
93
|
+
const listing = await client.callTool({ name: "notes_list", arguments: {}, _meta: meta(CHILD) });
|
|
94
|
+
assert.ok(!listing.isError, JSON.stringify(listing));
|
|
95
|
+
assert.equal(listing.structuredContent, undefined);
|
|
96
|
+
assert.match(JSON.stringify(listing), /scratch\.md/);
|
|
97
|
+
const unbound = await client.callTool({ name: "notes_read", arguments: { address: "scratch.md" }, _meta: { [`${prefix}root_conversation_id`]: ROOT } });
|
|
98
|
+
assert.equal(unbound.isError, true);
|
|
99
|
+
assert.ok(unbound.structuredContent);
|
|
100
|
+
assert.doesNotMatch(JSON.stringify(unbound), /ROOT_SENTINEL|CHILD_EDITED/);
|
|
101
|
+
});
|
|
@@ -2,15 +2,16 @@ import { resetBoundaryCommitted } from "../plugins/pi/reset/committed.js";
|
|
|
2
2
|
import { inspectResetTail } from "../plugins/pi/reset/artifacts.js";
|
|
3
3
|
import assert from "node:assert/strict";
|
|
4
4
|
import { rmSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
5
6
|
import test from "node:test";
|
|
6
7
|
import { historyFromSession } from "../plugins/pi/history.js";
|
|
7
|
-
import { BOOT_TYPE, GUIDANCE_TYPE, RESET_MARKER_TYPE } from "../plugins/pi/entries.js";
|
|
8
|
+
import { BOOT_TYPE, GUIDANCE_TYPE, MARKER_TYPE, RESET_MARKER_TYPE, WARNING_TYPE } from "../plugins/pi/entries.js";
|
|
8
9
|
import { MAPS_BLOCK, NOTES_PROTOCOL_OPEN_TAG, WINDOW_IDENTITY_CLOSE_TAG, WINDOW_IDENTITY_OPEN_TAG } from "../src/boot/text.js";
|
|
9
|
-
import { rootWindowId } from "../plugins/pi/window.js";
|
|
10
|
+
import { NOTESOUP_TOOL_NAMES, rootWindowId } from "../plugins/pi/window.js";
|
|
10
11
|
import { FORCED_CONTINUATIONS, NORMAL_CONTINUATIONS } from "../src/budget/text.js";
|
|
11
12
|
import { listNotes } from "./helpers/notes.js";
|
|
12
13
|
import { CONTINUATION_TYPE, MANUAL_WIPE_TYPE } from "../plugins/pi/entries.js";
|
|
13
|
-
import { appendText, assertBootHistory, call, commitTurnEndBoundary, context, explicitBoot, makeExtension, manager, noticesOf,
|
|
14
|
+
import { appendText, assertBootHistory, call, commitTurnEndBoundary, context, explicitBoot, makeExtension, manager, noticesOf, resultJson, resultText, runContextHook, runContextWithSystemHook, runHandlers, runManualCompact, runBeforeAgentStart, runCommand, runInput, sentOf, } from "./helpers/extension.js";
|
|
14
15
|
import { installExtensionTestHooks } from "./helpers/extension-test-environment.js";
|
|
15
16
|
const testEnvironment = installExtensionTestHooks("notesoup-integration");
|
|
16
17
|
test("custom reset marker removes old provider context while history remains searchable", async () => {
|
|
@@ -46,11 +47,11 @@ test("custom reset marker removes old provider context while history remains sea
|
|
|
46
47
|
assert.ok(oldWindow);
|
|
47
48
|
const oldSeq = windows[0]?.items.find((item) => item.text.includes("OLD-UNIQUE-TRANSCRIPT"))?.seq;
|
|
48
49
|
assert.ok(oldSeq);
|
|
49
|
-
const read =
|
|
50
|
-
assert.match(read
|
|
51
|
-
const found =
|
|
52
|
-
assert.
|
|
53
|
-
assert.
|
|
50
|
+
const read = resultText(await call(captured, "history_read", { seq: oldSeq }, ctx));
|
|
51
|
+
assert.match(read, /OLD-UNIQUE-TRANSCRIPT/);
|
|
52
|
+
const found = resultText(await call(captured, "history_search", { query: "needle" }, ctx));
|
|
53
|
+
assert.match(found, new RegExp(`seq ${oldSeq} \\| user`));
|
|
54
|
+
assert.match(found, /\bneedle\b/);
|
|
54
55
|
});
|
|
55
56
|
test("a checkpoint-backed reset projects from its boot and drops the empty compaction wrapper", async () => {
|
|
56
57
|
const sessionManager = manager();
|
|
@@ -83,8 +84,10 @@ test("the root boot and reset boot carry durable window identity", async () => {
|
|
|
83
84
|
appendText(sessionManager, "user", "task before reset");
|
|
84
85
|
appendText(sessionManager, "assistant", "working");
|
|
85
86
|
await call(captured, "notes_write", { address: "decisions.md", content: "use terra" }, ctx);
|
|
86
|
-
// Root
|
|
87
|
+
// Root windows boot lazily: startup alone writes nothing, the first input does.
|
|
87
88
|
await runHandlers(captured, "session_start", { reason: "startup" }, ctx);
|
|
89
|
+
assert.equal(captured.sent.length, 0, "session_start never builds a root boot");
|
|
90
|
+
await runInput(captured, ctx);
|
|
88
91
|
assert.equal(captured.sent.length, 1);
|
|
89
92
|
const rootBoot = captured.sent[0];
|
|
90
93
|
assert.equal(rootBoot?.message.customType, BOOT_TYPE);
|
|
@@ -92,6 +95,8 @@ test("the root boot and reset boot carry durable window identity", async () => {
|
|
|
92
95
|
assert.equal(rootBoot?.options?.triggerTurn, false);
|
|
93
96
|
assert.equal(noticesOf(ctx).length, 0, "initial boot is silent");
|
|
94
97
|
await runHandlers(captured, "session_start", { reason: "reload" }, ctx);
|
|
98
|
+
await runInput(captured, ctx);
|
|
99
|
+
assert.equal(captured.sent.length, 1, "reload never duplicates the existing root boot");
|
|
95
100
|
assert.equal(noticesOf(ctx).length, 0, "reload is silent");
|
|
96
101
|
assert.deepEqual(rootBoot?.message.details, { windowId: `pcw:${sessionManager.getSessionId().slice(0, 8)}:root` });
|
|
97
102
|
const rootText = typeof rootBoot?.message.content === "string" ? rootBoot.message.content : "";
|
|
@@ -153,6 +158,7 @@ test("an empty root boot starts at the first projected seq", async () => {
|
|
|
153
158
|
const captured = makeExtension(sessionManager);
|
|
154
159
|
const ctx = context(sessionManager);
|
|
155
160
|
await runHandlers(captured, "session_start", { reason: "startup" }, ctx);
|
|
161
|
+
await runInput(captured, ctx);
|
|
156
162
|
const body = String(captured.sent[0]?.message.content);
|
|
157
163
|
const projection = historyFromSession(ctx);
|
|
158
164
|
assert.equal(projection.windows.length, 1);
|
|
@@ -164,6 +170,7 @@ test("boot ranges include tool-call slots and both completed reset checkpoints",
|
|
|
164
170
|
const captured = makeExtension(sessionManager);
|
|
165
171
|
const ctx = context(sessionManager);
|
|
166
172
|
await runHandlers(captured, "session_start", { reason: "startup" }, ctx);
|
|
173
|
+
await runInput(captured, ctx);
|
|
167
174
|
appendText(sessionManager, "user", "before tools");
|
|
168
175
|
sessionManager.appendMessage({
|
|
169
176
|
role: "assistant",
|
|
@@ -196,6 +203,7 @@ test("a boot beyond three windows shows only root, the previous window, and the
|
|
|
196
203
|
const captured = makeExtension(sessionManager);
|
|
197
204
|
const ctx = context(sessionManager);
|
|
198
205
|
await runHandlers(captured, "session_start", { reason: "startup" }, ctx);
|
|
206
|
+
await runInput(captured, ctx);
|
|
199
207
|
for (let round = 0; round < 4; round++) {
|
|
200
208
|
appendText(sessionManager, "user", `work before reset ${round}`);
|
|
201
209
|
await call(captured, "empty_brain", {}, ctx);
|
|
@@ -338,20 +346,74 @@ test("a marker tail followed by real conversation is never repaired", async () =
|
|
|
338
346
|
assert.equal(sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === BOOT_TYPE).length, 0, "no boot is appended after real work");
|
|
339
347
|
assert.equal(sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === CONTINUATION_TYPE).length, 0, "no continuation is appended after real work");
|
|
340
348
|
});
|
|
341
|
-
test("off preserves an existing
|
|
349
|
+
test("off preserves an existing reset window before compaction, allows native compaction, and lets re-enabling re-boot cleanly", async () => {
|
|
342
350
|
const sessionManager = manager();
|
|
343
351
|
const captured = makeExtension(sessionManager);
|
|
344
352
|
const ctx = context(sessionManager);
|
|
345
353
|
appendText(sessionManager, "user", "old context must stay hidden");
|
|
346
354
|
const windowId = "pcw:test:existing";
|
|
355
|
+
sessionManager.appendCompaction("", null, 0);
|
|
347
356
|
sessionManager.appendCustomEntry(RESET_MARKER_TYPE, { windowId });
|
|
348
357
|
sessionManager.appendCustomMessageEntry(BOOT_TYPE, "fresh boot", false, { windowId });
|
|
358
|
+
sessionManager.appendCustomMessageEntry(WARNING_TYPE, "old warning", false);
|
|
359
|
+
appendText(sessionManager, "user", "post-reset message");
|
|
349
360
|
await runCommand(captured, "notesoup", "off", ctx);
|
|
350
361
|
const before = await runManualCompact(captured, ctx);
|
|
351
|
-
assert.
|
|
352
|
-
const
|
|
353
|
-
|
|
362
|
+
assert.equal(before, undefined, "off hands manual/auto compaction back to native Pi");
|
|
363
|
+
const beforeCompact = await runContextWithSystemHook(captured, ctx, sessionManager.buildSessionProjection().messages);
|
|
364
|
+
const beforeMessages = (beforeCompact?.messages ?? []);
|
|
365
|
+
assert.equal(JSON.stringify(beforeMessages).includes("old context must stay hidden"), false);
|
|
366
|
+
assert.equal(beforeMessages.some((m) => m.role === "compactionSummary"), false, "empty reset wrapper stays hidden before native compaction");
|
|
367
|
+
assert.equal(historyFromSession(ctx).windows.at(-1)?.windowId, windowId);
|
|
368
|
+
// Native compaction runs while off and compacts away the old boot and warning.
|
|
369
|
+
const keptId = appendText(sessionManager, "user", "kept after native compact");
|
|
370
|
+
sessionManager.appendCompaction("NATIVE_COMPACT_SUMMARY", keptId, 12_000);
|
|
371
|
+
appendText(sessionManager, "user", "after native compact");
|
|
372
|
+
const afterCompactOff = await runContextWithSystemHook(captured, ctx, sessionManager.buildSessionProjection().messages);
|
|
373
|
+
const offJson = JSON.stringify(afterCompactOff?.messages ?? []);
|
|
374
|
+
assert.ok(offJson.includes("NATIVE_COMPACT_SUMMARY"), "native compaction summary reaches the model while off");
|
|
375
|
+
assert.ok(offJson.includes("kept after native compact"));
|
|
376
|
+
assert.equal(offJson.includes("old context must stay hidden"), false);
|
|
354
377
|
assert.equal(historyFromSession(ctx).windows.at(-1)?.windowId, windowId);
|
|
378
|
+
// Re-enabling notesoup after native compaction lazily re-boots for the current window and resets warning eligibility.
|
|
379
|
+
await runCommand(captured, "notesoup", "on", ctx);
|
|
380
|
+
const started = await runBeforeAgentStart(captured, ctx);
|
|
381
|
+
const bootMsg = started.result?.message;
|
|
382
|
+
assert.equal(bootMsg?.customType, BOOT_TYPE, "re-enabling after native compaction injects a fresh boot");
|
|
383
|
+
assert.deepEqual(bootMsg?.details, { windowId }, "the fresh boot stays on the branch's logical window");
|
|
384
|
+
sessionManager.appendCustomMessageEntry(BOOT_TYPE, bootMsg.content, false, bootMsg.details);
|
|
385
|
+
const afterCompactOn = await runContextWithSystemHook(captured, ctx, sessionManager.buildSessionProjection().messages);
|
|
386
|
+
const onMessages = (afterCompactOn?.messages ?? []);
|
|
387
|
+
const onJson = JSON.stringify(onMessages);
|
|
388
|
+
assert.ok(onJson.includes("NATIVE_COMPACT_SUMMARY"), "re-enabling notesoup preserves the native compaction summary");
|
|
389
|
+
assert.equal(onMessages.some((m) => m.role === "custom" && m.customType === BOOT_TYPE), true);
|
|
390
|
+
const low = context(sessionManager, undefined, { tokens: 170_000, contextWindow: 200_000, percent: 85 });
|
|
391
|
+
const budgetHook = await runContextHook(captured, low);
|
|
392
|
+
const budgetMessages = (budgetHook?.messages ?? []);
|
|
393
|
+
assert.equal(budgetMessages.some((m) => m.role === "custom" && m.customType === WARNING_TYPE), true, "warning eligibility resets after native compaction");
|
|
394
|
+
});
|
|
395
|
+
test("native compaction that retains an earlier reset boot does not slice away the native summary", async () => {
|
|
396
|
+
const sessionManager = manager();
|
|
397
|
+
const captured = makeExtension(sessionManager);
|
|
398
|
+
const ctx = context(sessionManager);
|
|
399
|
+
const windowId = "pcw:test:retained-boot";
|
|
400
|
+
sessionManager.appendCompaction("", null, 0);
|
|
401
|
+
sessionManager.appendCustomEntry(RESET_MARKER_TYPE, { windowId });
|
|
402
|
+
const bootId = sessionManager.appendCustomMessageEntry(BOOT_TYPE, "retained boot", false, { windowId });
|
|
403
|
+
appendText(sessionManager, "user", "kept user turn");
|
|
404
|
+
await runCommand(captured, "notesoup", "off", ctx);
|
|
405
|
+
sessionManager.appendCompaction("RETAINED_BOOT_NATIVE_SUMMARY", bootId, 12_000);
|
|
406
|
+
const projectedOff = await runContextWithSystemHook(captured, ctx, sessionManager.buildSessionProjection().messages);
|
|
407
|
+
const offMessages = (projectedOff?.messages ?? []);
|
|
408
|
+
assert.ok(JSON.stringify(offMessages).includes("RETAINED_BOOT_NATIVE_SUMMARY"));
|
|
409
|
+
assert.equal(offMessages.some((m) => m.role === "custom" && m.customType === BOOT_TYPE), false, "retained boot stays stripped while off");
|
|
410
|
+
await runCommand(captured, "notesoup", "on", ctx);
|
|
411
|
+
const started = await runBeforeAgentStart(captured, ctx);
|
|
412
|
+
assert.equal(started.result, undefined, "retained boot is reused without emitting a duplicate");
|
|
413
|
+
const projectedOn = await runContextWithSystemHook(captured, ctx, sessionManager.buildSessionProjection().messages);
|
|
414
|
+
const onMessages = (projectedOn?.messages ?? []);
|
|
415
|
+
assert.ok(JSON.stringify(onMessages).includes("RETAINED_BOOT_NATIVE_SUMMARY"));
|
|
416
|
+
assert.equal(onMessages.some((m) => m.role === "custom" && m.customType === BOOT_TYPE), true);
|
|
355
417
|
});
|
|
356
418
|
test("empty_brain uses one turn boundary and never calls ctx.compact", async () => {
|
|
357
419
|
const sessionManager = manager();
|
|
@@ -385,14 +447,17 @@ test("notesoup command toggles future work, /empty schedules a turn-end reset, a
|
|
|
385
447
|
appendText(sessionManager, "user", "hello");
|
|
386
448
|
const captured = makeExtension(sessionManager);
|
|
387
449
|
const low = context(sessionManager, undefined, { tokens: 170_000, contextWindow: 200_000, percent: 85 });
|
|
388
|
-
// On by default:
|
|
450
|
+
// On by default: the first input persists the root boot block.
|
|
389
451
|
await runHandlers(captured, "session_start", { reason: "startup" }, low);
|
|
452
|
+
assert.equal(captured.sent.length, 0, "startup alone is lazy");
|
|
453
|
+
await runInput(captured, low);
|
|
390
454
|
assert.equal(captured.sent.length, 1);
|
|
391
455
|
assert.equal(captured.sent[0]?.message.customType, BOOT_TYPE);
|
|
392
456
|
let notices = await runCommand(captured, "notesoup", "off", low);
|
|
393
457
|
assert.equal(await runContextHook(captured, low), undefined, "no guidance while off");
|
|
394
458
|
assert.equal(sentOf(captured, GUIDANCE_TYPE).length, 0, "no guidance persisted while off");
|
|
395
459
|
await runHandlers(captured, "session_start", { reason: "startup" }, low);
|
|
460
|
+
await runInput(captured, low);
|
|
396
461
|
assert.equal(captured.sent.length, 1, "no new boot block is persisted while off");
|
|
397
462
|
const offResultRaw = await call(captured, "empty_brain", {}, low);
|
|
398
463
|
assert.equal(offResultRaw.isError, true, "a refusal is a failed tool call, not a successful answer");
|
|
@@ -428,7 +493,7 @@ test("only forced resets notify, once and after their durable boundary commits",
|
|
|
428
493
|
};
|
|
429
494
|
if (!forced)
|
|
430
495
|
await call(captured, "empty_brain", {}, ctx);
|
|
431
|
-
await commitTurnEndBoundary(captured, sessionManager, ctx);
|
|
496
|
+
await commitTurnEndBoundary(captured, sessionManager, ctx, forced ? { stopReason: "toolUse" } : undefined);
|
|
432
497
|
await runHandlers(captured, "agent_settled", {}, ctx);
|
|
433
498
|
await runHandlers(captured, "agent_settled", {}, ctx);
|
|
434
499
|
assert.deepEqual(severities, forced ? ["warning"] : []);
|
|
@@ -457,3 +522,79 @@ test("committed reset confirmation survives later work while repair refuses that
|
|
|
457
522
|
partial.appendCustomMessageEntry(CONTINUATION_TYPE, "continuation", false);
|
|
458
523
|
assert.equal(resetBoundaryCommitted(partialCtx, partialMarker, windowId), false, "a bare legacy marker is not evidence of a new checkpoint commit");
|
|
459
524
|
});
|
|
525
|
+
test("--no-notesoup starts disabled; /notesoup on overrides it and /notesoup reset returns to the flag default", async () => {
|
|
526
|
+
const sessionManager = manager();
|
|
527
|
+
const captured = makeExtension(sessionManager, undefined, { flags: { "no-notesoup": true } });
|
|
528
|
+
const ctx = context(sessionManager);
|
|
529
|
+
assert.deepEqual(captured.flags, ["no-notesoup"]);
|
|
530
|
+
const notesoupSkills = join(process.cwd(), "skills");
|
|
531
|
+
const skillPath = join(notesoupSkills, "notesoup", "SKILL.md");
|
|
532
|
+
await runHandlers(captured, "session_start", { reason: "startup" }, ctx);
|
|
533
|
+
await runInput(captured, ctx);
|
|
534
|
+
const disabled = await runBeforeAgentStart(captured, ctx, { skills: [{ name: "notesoup", filePath: skillPath }] });
|
|
535
|
+
assert.equal(captured.sent.length, 0, "the flag suppresses the root boot");
|
|
536
|
+
assert.equal(disabled.result, undefined, "no lazy boot sneaks in from before_agent_start");
|
|
537
|
+
assert.equal(disabled.event.systemPromptOptions.sections.notesoup_tools, undefined, "no tool directory");
|
|
538
|
+
assert.equal(disabled.event.systemPromptOptions.sections.notesoup_protocol, undefined, "no protocol teaching");
|
|
539
|
+
assert.deepEqual(disabled.event.systemPromptOptions.skills, [], "notesoup skills are filtered out");
|
|
540
|
+
assert.match((await runCommand(captured, "notesoup", "", ctx))[0]?.message ?? "", /notesoup off/);
|
|
541
|
+
const disabledMessages = [
|
|
542
|
+
{ role: "system", content: "", timestamp: 0, sections: { preamble: "p", notesoup_tools: "tools", notesoup_protocol: "protocol" },
|
|
543
|
+
toolsAdded: [...NOTESOUP_TOOL_NAMES].map((name) => ({ name, description: name, parameters: {} })) },
|
|
544
|
+
{ role: "custom", customType: MARKER_TYPE, content: "hidden marker", display: false, timestamp: 0 },
|
|
545
|
+
{ role: "user", content: "hello", timestamp: 0 },
|
|
546
|
+
];
|
|
547
|
+
const projected = await runContextWithSystemHook(captured, ctx, disabledMessages);
|
|
548
|
+
const providerMessages = projected?.messages;
|
|
549
|
+
assert.deepEqual(providerMessages[0]?.sections, { preamble: "p" }, "notesoup sections never reach the provider");
|
|
550
|
+
assert.equal(providerMessages[0]?.toolsAdded, undefined, "notesoup tools never reach the provider");
|
|
551
|
+
assert.equal(providerMessages.some((message) => message.role === "custom" && message.customType === MARKER_TYPE), false);
|
|
552
|
+
const on = await runCommand(captured, "notesoup", "on", ctx);
|
|
553
|
+
assert.match(on[0]?.message ?? "", /notesoup on/, "the branch override wins over the flag");
|
|
554
|
+
await runInput(captured, ctx);
|
|
555
|
+
assert.equal(sentOf(captured, BOOT_TYPE).length, 1, "an explicit on boots the root window");
|
|
556
|
+
const reset = await runCommand(captured, "notesoup", "reset", ctx);
|
|
557
|
+
assert.match(reset[0]?.message ?? "", /notesoup off/, "reset clears the branch override back to the flag");
|
|
558
|
+
const stillOff = await runBeforeAgentStart(captured, ctx, { skills: [{ name: "notesoup", filePath: skillPath }] });
|
|
559
|
+
assert.equal(stillOff.event.systemPromptOptions.sections.notesoup_tools, undefined);
|
|
560
|
+
assert.equal(stillOff.event.systemPromptOptions.skills.length, 0);
|
|
561
|
+
});
|
|
562
|
+
test("pi-souls naked state disables notesoup, /notesoup on overrides it, and /soul naked off restores the default", async () => {
|
|
563
|
+
const sessionManager = manager();
|
|
564
|
+
const captured = makeExtension(sessionManager);
|
|
565
|
+
const ctx = context(sessionManager);
|
|
566
|
+
captured.events.on("pi-souls:state", (data) => { data.naked = true; });
|
|
567
|
+
assert.match((await runCommand(captured, "notesoup", "", ctx))[0]?.message ?? "", /notesoup off/, "a naked run starts disabled");
|
|
568
|
+
assert.match((await runCommand(captured, "notesoup", "on", ctx))[0]?.message ?? "", /notesoup on/, "/notesoup on overrides pi-souls");
|
|
569
|
+
assert.match((await runCommand(captured, "notesoup", "", ctx))[0]?.message ?? "", /notesoup on/, "the explicit choice outranks the naked signal");
|
|
570
|
+
// The durable fallback entry, as written by pi-souls when its extension is not loaded.
|
|
571
|
+
const fallback = manager();
|
|
572
|
+
const fallbackCaptured = makeExtension(fallback);
|
|
573
|
+
const fallbackCtx = context(fallback);
|
|
574
|
+
fallback.appendCustomEntry("pi-souls:naked", { naked: true });
|
|
575
|
+
assert.match((await runCommand(fallbackCaptured, "notesoup", "", fallbackCtx))[0]?.message ?? "", /notesoup off/, "the naked entry disables on its own");
|
|
576
|
+
fallback.appendCustomEntry("pi-souls:naked", { naked: false });
|
|
577
|
+
assert.match((await runCommand(fallbackCaptured, "notesoup", "", fallbackCtx))[0]?.message ?? "", /notesoup on/, "/soul naked off re-enables notesoup when no explicit choice exists");
|
|
578
|
+
// Same contract for pi-souls /soul tools none|rw|reset: live event and durable fallback both disable unless overridden.
|
|
579
|
+
for (const mode of ["none", "rw"]) {
|
|
580
|
+
const restrictedManager = manager();
|
|
581
|
+
const restrictedCaptured = makeExtension(restrictedManager);
|
|
582
|
+
const restrictedCtx = context(restrictedManager);
|
|
583
|
+
restrictedCaptured.events.on("pi-souls:state", (data) => { data.tools = mode; });
|
|
584
|
+
assert.match((await runCommand(restrictedCaptured, "notesoup", "", restrictedCtx))[0]?.message ?? "", /notesoup off/, `tools=${mode} disables notesoup by default`);
|
|
585
|
+
assert.match((await runCommand(restrictedCaptured, "notesoup", "on", restrictedCtx))[0]?.message ?? "", /notesoup on/, `/notesoup on overrides tools=${mode}`);
|
|
586
|
+
}
|
|
587
|
+
fallback.appendCustomEntry("pi-souls:tools", { version: 1, tools: "rw" });
|
|
588
|
+
assert.match((await runCommand(fallbackCaptured, "notesoup", "", fallbackCtx))[0]?.message ?? "", /notesoup off/, "durable tools=rw disables notesoup");
|
|
589
|
+
fallback.appendCustomEntry("pi-souls:tools", { version: 1, tools: "none" });
|
|
590
|
+
assert.match((await runCommand(fallbackCaptured, "notesoup", "", fallbackCtx))[0]?.message ?? "", /notesoup off/, "durable tools=none disables notesoup");
|
|
591
|
+
// Live tools: null means pi-souls answered authoritatively (unrestricted), overriding durable fallback.
|
|
592
|
+
const authoritative = manager();
|
|
593
|
+
authoritative.appendCustomEntry("pi-souls:tools", { version: 1, tools: "none" });
|
|
594
|
+
const authoritativeCaptured = makeExtension(authoritative);
|
|
595
|
+
const authoritativeCtx = context(authoritative);
|
|
596
|
+
authoritativeCaptured.events.on("pi-souls:state", (data) => { data.tools = null; });
|
|
597
|
+
assert.match((await runCommand(authoritativeCaptured, "notesoup", "", authoritativeCtx))[0]?.message ?? "", /notesoup on/, "live tools=null answers authoritatively");
|
|
598
|
+
fallback.appendCustomEntry("pi-souls:tools", { version: 1, tools: null });
|
|
599
|
+
assert.match((await runCommand(fallbackCaptured, "notesoup", "", fallbackCtx))[0]?.message ?? "", /notesoup on/, "/soul tools reset re-enables notesoup");
|
|
600
|
+
});
|
|
@@ -62,8 +62,8 @@ test("Pi cap controls warning, reported room and hard wipe, without changing the
|
|
|
62
62
|
const warning = await runContextHook(captured, at(67_232));
|
|
63
63
|
assert.equal(warning?.messages[0]?.customType, WARNING_TYPE);
|
|
64
64
|
assert.equal(await room(at(83_615)), 1);
|
|
65
|
-
assert.equal((await commitTurnEndBoundary(captured, sm, at(83_615))).entries.some((e) => e.type === "custom" && e.customType === RESET_MARKER_TYPE), false);
|
|
66
|
-
const hard = await commitTurnEndBoundary(captured, sm, at(83_616));
|
|
65
|
+
assert.equal((await commitTurnEndBoundary(captured, sm, at(83_615), { stopReason: "toolUse" })).entries.some((e) => e.type === "custom" && e.customType === RESET_MARKER_TYPE), false);
|
|
66
|
+
const hard = await commitTurnEndBoundary(captured, sm, at(83_616), { stopReason: "toolUse" });
|
|
67
67
|
assert.equal(hard.entries.filter((e) => e.type === "custom" && e.customType === RESET_MARKER_TYPE).length, 1);
|
|
68
68
|
assert.equal(await room(at(1000)), 82_616, "the cap survives a notesoup reset");
|
|
69
69
|
assert.equal(await room(at(1000, 64_000)), 46_616, "a cap cannot enlarge a smaller model window");
|
|
@@ -120,10 +120,10 @@ test("Pi warning, reported room, and hard wipe use the notesoup reserve override
|
|
|
120
120
|
const room = async (remaining) => resultJson(await call(captured, "get_context_remaining", {}, at(remaining))).remaining_tokens;
|
|
121
121
|
assert.equal(await room(24_576), 16_384);
|
|
122
122
|
assert.equal(await room(8193), 1);
|
|
123
|
-
const before = await commitTurnEndBoundary(captured, sm, at(8193));
|
|
123
|
+
const before = await commitTurnEndBoundary(captured, sm, at(8193), { stopReason: "toolUse" });
|
|
124
124
|
assert.equal(before.entries.some((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE), false, "no wipe above the overridden reserve, even below Pi's reserve");
|
|
125
125
|
assert.equal(await room(8192), 0);
|
|
126
|
-
const hard = await commitTurnEndBoundary(captured, sm, at(8192));
|
|
126
|
+
const hard = await commitTurnEndBoundary(captured, sm, at(8192), { stopReason: "toolUse" });
|
|
127
127
|
assert.equal(hard.entries.filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE).length, 1, "hard wipe at the overridden reserve");
|
|
128
128
|
});
|
|
129
129
|
test("low-budget guidance and warning persist at turn_end, once per active window", async () => {
|