notesoup 0.60.1 → 0.62.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 -10
- 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 +2 -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 +1 -1
- package/dist/plugins/pi/budget.js +3 -2
- package/dist/plugins/pi/entries.d.ts +1 -0
- package/dist/plugins/pi/entries.js +1 -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/lifecycle.d.ts +1 -1
- package/dist/plugins/pi/reset/lifecycle.js +8 -9
- package/dist/plugins/pi/runtime.js +102 -61
- package/dist/plugins/pi/tool-result.js +7 -7
- package/dist/plugins/pi/window.d.ts +33 -3
- package/dist/plugins/pi/window.js +209 -9
- package/dist/src/boot/render.d.ts +5 -0
- package/dist/src/boot/render.js +60 -28
- package/dist/src/boot/text.d.ts +3 -3
- package/dist/src/boot/text.js +27 -26
- package/dist/src/budget/text.d.ts +2 -2
- package/dist/src/budget/text.js +13 -13
- 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 +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/notes/frontmatter.d.ts +4 -0
- package/dist/src/notes/frontmatter.js +15 -1
- 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 +47 -6
- package/dist/src/notes/store.d.ts +14 -0
- package/dist/src/notes/store.js +33 -12
- 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 -91
- 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 +58 -160
- package/dist/src/tools/notes.js +151 -99
- 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 +198 -16
- 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 +133 -14
- package/dist/test/claude-history.test.js +14 -13
- package/dist/test/claude-mod.test.js +9 -6
- 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 +65 -2
- package/dist/test/helpers/extension.js +72 -3
- 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/note-policy.test.js +189 -56
- 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 +2 -2
- package/docs/antigravity.md +44 -0
- package/docs/architecture.md +6 -4
- package/docs/claude-code-mod.md +2 -2
- package/docs/codex.md +36 -38
- package/docs/dsh.md +4 -4
- package/docs/history-sessions.md +28 -50
- package/docs/notes-library.md +6 -6
- 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 +3 -3
- 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 +1129 -549
- package/plugins/claude/hooks/register.ts +2 -2
- package/plugins/claude/playbook.md +3 -3
- package/plugins/claude/skills/dream/SKILL.md +2 -2
- package/plugins/claude/skills/notesoup/SKILL.md +92 -0
- package/plugins/claude/src/helper.ts +2 -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 +18494 -17905
- 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 +3 -3
- package/plugins/pi/entries.ts +1 -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/lifecycle.ts +9 -10
- package/plugins/pi/runtime.ts +96 -60
- package/plugins/pi/tool-result.ts +8 -8
- package/plugins/pi/window.ts +198 -9
- package/skills/dream/SKILL.md +2 -2
- package/skills/notesoup/SKILL.md +92 -0
- package/src/boot/render.ts +59 -25
- package/src/boot/text.ts +30 -27
- package/src/budget/text.ts +13 -13
- 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 +1 -1
- package/src/notes/frontmatter.ts +16 -1
- package/src/notes/index.ts +1 -1
- package/src/notes/policy.ts +45 -6
- package/src/notes/store.ts +30 -15
- 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 +150 -112
- 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
|
@@ -3,12 +3,13 @@ import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import test from "node:test";
|
|
6
|
-
import { createAssistantMessageEventStream, getCurrentSystemMessage, getSystemMessageText } from "@earendil-works/pi-ai";
|
|
6
|
+
import { createAssistantMessageEventStream, getCurrentSystemMessage, getCurrentTools, getSystemMessageText } from "@earendil-works/pi-ai";
|
|
7
7
|
import { createAgentSession, convertToLlm, createCodemodeExtension, DefaultResourceLoader, ModelRuntime, SessionManager, SettingsManager, } from "@earendil-works/pi-coding-agent";
|
|
8
8
|
import notesoup, { createNotesoup } from "../plugins/pi/extension.js";
|
|
9
|
-
import { BOOT_TYPE, CARRIED_INPUT_TYPE, CONTINUATION_TYPE, GUIDANCE_TYPE, MANUAL_WIPE_TYPE, MARKER_TYPE, RESET_LAST_WORD_TYPE, RESET_MARKER_TYPE, WARNING_TYPE } from "../plugins/pi/entries.js";
|
|
9
|
+
import { BOOT_TYPE, CARRIED_INPUT_TYPE, CONTINUATION_TYPE, ENABLED_TYPE, GUIDANCE_TYPE, MANUAL_WIPE_TYPE, MARKER_TYPE, RESET_LAST_WORD_TYPE, RESET_MARKER_TYPE, WARNING_TYPE } from "../plugins/pi/entries.js";
|
|
10
10
|
import { historyFromSession } from "../plugins/pi/history.js";
|
|
11
11
|
import { MARKER_INTERVAL } from "../plugins/pi/marker.js";
|
|
12
|
+
import { NOTESOUP_TOOL_NAMES, rootWindowId } from "../plugins/pi/window.js";
|
|
12
13
|
import { assertBootHistory } from "./helpers/extension.js";
|
|
13
14
|
import { DEFAULT_BOOT_TOOL_NAMES, MAPS_BLOCK, NAMELESS_AGENT, NOTES_PROTOCOL_OPEN_TAG, WINDOW_IDENTITY_OPEN_TAG, renderProtocolBlock } from "../src/boot/text.js";
|
|
14
15
|
import { createNotesStore } from "../src/notes/index.js";
|
|
@@ -76,7 +77,8 @@ async function openFixture(options) {
|
|
|
76
77
|
agentDir,
|
|
77
78
|
settingsManager,
|
|
78
79
|
noExtensions: true,
|
|
79
|
-
noSkills:
|
|
80
|
+
noSkills: options.skillPaths === undefined,
|
|
81
|
+
additionalSkillPaths: options.skillPaths,
|
|
80
82
|
noThemes: true,
|
|
81
83
|
noPromptTemplates: true,
|
|
82
84
|
systemPromptOverride: () => options.systemPrompt ?? "Use the tools as requested.",
|
|
@@ -241,6 +243,9 @@ test("real AgentSession: turn-end markers reach tool continuations and allow one
|
|
|
241
243
|
: assistant(fixture, [{ type: "text", text: "steered input handled" }]),
|
|
242
244
|
});
|
|
243
245
|
try {
|
|
246
|
+
// Seed the root boot explicitly so the marker interval starts at a stable anchor;
|
|
247
|
+
// lazy boot placement is covered by its own tests below.
|
|
248
|
+
fixture.sessionManager.appendCustomMessageEntry(BOOT_TYPE, "seed boot", false, { windowId: rootWindowId(fixture.sessionManager.getSessionId()) });
|
|
244
249
|
for (let i = 0; i < seedCount; i++)
|
|
245
250
|
fixture.sessionManager.appendMessage(assistant(fixture, [{ type: "text", text: "seed" }]));
|
|
246
251
|
await fixture.session.prompt("MARKER_INITIAL_USER");
|
|
@@ -378,12 +383,12 @@ test("real AgentSession: identity changes update system teaching and the next bo
|
|
|
378
383
|
process.env.NOTESOUP_AGENT = previousAgent;
|
|
379
384
|
}
|
|
380
385
|
});
|
|
381
|
-
test("real Pi codemode receives
|
|
386
|
+
test("real Pi codemode receives strings except structured notes_read, including refusals", async () => {
|
|
382
387
|
let fixture;
|
|
383
388
|
fixture = await openFixture({
|
|
384
389
|
codemode: true,
|
|
385
390
|
compactionEnabled: false,
|
|
386
|
-
tools: ["codemode", "notes_write", "notes_read", "notes_list", "history_list", "history_read"],
|
|
391
|
+
tools: ["codemode", "notes_write", "notes_read", "notes_list", "history_list", "history_read", "history_search"],
|
|
387
392
|
script: (request) => {
|
|
388
393
|
if (request === 1)
|
|
389
394
|
return assistant(fixture, [{ type: "toolCall", id: "structured-smoke", name: "codemode", arguments: { code: `
|
|
@@ -391,35 +396,38 @@ const written = await tools.notes_write({ address: "smoke.md", content: "A😀
|
|
|
391
396
|
const listed = await tools.notes_list({});
|
|
392
397
|
const read = await tools.notes_read({ address: "smoke.md", offset_chars: 1, max_chars: 2 });
|
|
393
398
|
const refused = await tools.notes_read({ address: "missing.md" });
|
|
394
|
-
if ("
|
|
399
|
+
if (typeof written !== "string" || !written.includes("smoke.md") || typeof listed !== "string" || !listed.includes("smoke.md")) throw new Error("wrong text outcomes");
|
|
395
400
|
if (read.text !== "😀界" || read.next_offset_chars !== 3) throw new Error("wrong window");
|
|
396
401
|
if (refused.code !== "not_found") throw new Error("missing typed refusal");
|
|
397
|
-
|
|
402
|
+
let plainRefusal;
|
|
403
|
+
try { await tools.notes_write({ address: "../invalid", content: "no" }); }
|
|
404
|
+
catch (error) { plainRefusal = String(error); }
|
|
405
|
+
if (!plainRefusal || !plainRefusal.includes("invalid_address")) throw new Error("missing text refusal");
|
|
406
|
+
text({ marker: "TYPED_SMOKE", body: read.text, error: refused.code });
|
|
398
407
|
` } }], "toolUse");
|
|
399
408
|
if (request === 2)
|
|
400
409
|
return assistant(fixture, [{ type: "toolCall", id: "structured-history-smoke", name: "codemode", arguments: { code: `
|
|
401
410
|
const page = await tools.history_list({ roles: ["tool"] });
|
|
402
|
-
if ("
|
|
403
|
-
const parent =
|
|
411
|
+
if (typeof page !== "string") throw new Error("history list must be text");
|
|
412
|
+
const parent = /seq (\\d+) \\| tool(?: \\| [^|\\n]+)?\\ntool codemode/.exec(page);
|
|
404
413
|
if (!parent) throw new Error("missing codemode parent");
|
|
405
|
-
const read = await tools.history_read({ seq: parent
|
|
406
|
-
if ("
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
text({ marker: "HISTORY_SMOKE", calls: calls.call_count, complete: calls.complete });
|
|
414
|
+
const read = await tools.history_read({ seq: Number(parent[1]) });
|
|
415
|
+
if (typeof read !== "string" || !read.includes("tool codemode")) throw new Error("missing tool summary");
|
|
416
|
+
if (!read.includes("nested calls 5 recorded, complete") || !read.includes("notes_read [error]")) throw new Error("missing nested refusal evidence");
|
|
417
|
+
text({ marker: "HISTORY_SMOKE" });
|
|
410
418
|
` } }], "toolUse");
|
|
411
419
|
return assistant(fixture, [{ type: "text", text: "structured smoke complete" }]);
|
|
412
420
|
},
|
|
413
421
|
});
|
|
414
422
|
try {
|
|
415
|
-
await fixture.session.prompt("Exercise
|
|
423
|
+
await fixture.session.prompt("Exercise notes and history through real codemode.");
|
|
416
424
|
const results = fixture.sessionManager.getBranch().flatMap(entry => entry.type === "message" && entry.message.role === "toolResult" ? [entry.message] : []);
|
|
417
425
|
assert.equal(results.length, 2, "nested calls are not separate transcript events");
|
|
418
426
|
assert.ok(results.every(result => !result.isError), JSON.stringify(results));
|
|
419
427
|
const output = results.map(result => result.content.filter(part => part.type === "text").map(part => part.text).join("\n")).join("\n");
|
|
420
428
|
assert.match(output, /TYPED_SMOKE/);
|
|
421
429
|
assert.match(output, /HISTORY_SMOKE/);
|
|
422
|
-
assert.equal(results[0].nestedCalls?.calls.length,
|
|
430
|
+
assert.equal(results[0].nestedCalls?.calls.length, 5);
|
|
423
431
|
assert.equal(results[0].nestedCalls?.complete, true);
|
|
424
432
|
}
|
|
425
433
|
finally {
|
|
@@ -1942,3 +1950,177 @@ test("real AgentSession: warning precedes a durable checkpoint, including failed
|
|
|
1942
1950
|
}
|
|
1943
1951
|
}
|
|
1944
1952
|
});
|
|
1953
|
+
function bootEntries(fixture) {
|
|
1954
|
+
return fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === BOOT_TYPE);
|
|
1955
|
+
}
|
|
1956
|
+
function branchIndex(fixture, predicate) {
|
|
1957
|
+
return fixture.sessionManager.getBranch().findIndex(predicate);
|
|
1958
|
+
}
|
|
1959
|
+
test("real AgentSession: the root boot is lazy, beats the first user message, and also serves an idle custom turn", async () => {
|
|
1960
|
+
let fixture;
|
|
1961
|
+
fixture = await openFixture({
|
|
1962
|
+
compactionEnabled: false,
|
|
1963
|
+
script: () => assistant(fixture, [{ type: "text", text: "ok" }]),
|
|
1964
|
+
});
|
|
1965
|
+
try {
|
|
1966
|
+
await fixture.session.prompt("/notesoup off");
|
|
1967
|
+
await fixture.session.prompt("OFF_BEFORE_FIRST_TURN");
|
|
1968
|
+
await fixture.session.waitForIdle();
|
|
1969
|
+
assert.equal(bootEntries(fixture).length, 0, "a disabled session writes no root boot");
|
|
1970
|
+
assert.equal(fixture.requests.length, 1);
|
|
1971
|
+
await fixture.session.prompt("/notesoup on");
|
|
1972
|
+
await fixture.session.prompt("FIRST_ON_TURN");
|
|
1973
|
+
await fixture.session.waitForIdle();
|
|
1974
|
+
const boots = bootEntries(fixture);
|
|
1975
|
+
assert.equal(boots.length, 1, "the first enabled turn writes exactly one root boot");
|
|
1976
|
+
const bootIndex = fixture.sessionManager.getBranch().indexOf(boots[0]);
|
|
1977
|
+
const userIndex = branchIndex(fixture, (entry) => entry.type === "message" && entry.message.role === "user" && JSON.stringify(entry.message.content).includes("FIRST_ON_TURN"));
|
|
1978
|
+
assert.ok(bootIndex >= 0 && bootIndex < userIndex, "the boot is persisted before the user message it introduces");
|
|
1979
|
+
}
|
|
1980
|
+
finally {
|
|
1981
|
+
fixture.close();
|
|
1982
|
+
}
|
|
1983
|
+
let custom;
|
|
1984
|
+
custom = await openFixture({
|
|
1985
|
+
compactionEnabled: false,
|
|
1986
|
+
script: () => assistant(custom, [{ type: "text", text: "custom ok" }]),
|
|
1987
|
+
});
|
|
1988
|
+
try {
|
|
1989
|
+
custom.session.sendCustomMessage({ customType: "test/custom-turn", content: "CUSTOM_TRIGGER", display: false }, { triggerTurn: true });
|
|
1990
|
+
await custom.session.waitForIdle();
|
|
1991
|
+
const boots = bootEntries(custom);
|
|
1992
|
+
assert.equal(boots.length, 1, "before_agent_start boots a custom-triggered idle turn");
|
|
1993
|
+
const bootIndex = custom.sessionManager.getBranch().indexOf(boots[0]);
|
|
1994
|
+
const assistantIndex = branchIndex(custom, (entry) => entry.type === "message" && entry.message.role === "assistant");
|
|
1995
|
+
assert.ok(assistantIndex >= 0, "the custom turn produced a response");
|
|
1996
|
+
assert.ok(bootIndex >= 0 && bootIndex < assistantIndex, "the boot is persisted before the response it introduces");
|
|
1997
|
+
}
|
|
1998
|
+
finally {
|
|
1999
|
+
custom.close();
|
|
2000
|
+
}
|
|
2001
|
+
});
|
|
2002
|
+
test("real AgentSession: /notesoup off strips teaching, skills and tools, survives reload, and /notesoup on restores them", async (t) => {
|
|
2003
|
+
const customSkillDir = mkdtempSync(join(tmpdir(), "notesoup-keep-skill-"));
|
|
2004
|
+
t.after(() => rmSync(customSkillDir, { recursive: true, force: true }));
|
|
2005
|
+
writeFileSync(join(customSkillDir, "SKILL.md"), "---\nname: keep-skill\ndescription: a non-notesoup skill\n---\n");
|
|
2006
|
+
const allTools = [...NOTESOUP_TOOL_NAMES].sort();
|
|
2007
|
+
let fixture;
|
|
2008
|
+
fixture = await openFixture({
|
|
2009
|
+
compactionEnabled: false,
|
|
2010
|
+
skillPaths: [join(process.cwd(), "skills"), customSkillDir],
|
|
2011
|
+
tools: [...NOTESOUP_TOOL_NAMES],
|
|
2012
|
+
script: (request, context) => {
|
|
2013
|
+
const system = getCurrentSystemMessage(context.messages);
|
|
2014
|
+
const customTypes = context.messages.filter((message) => message.role === "custom").map((message) => message.customType);
|
|
2015
|
+
if (request === 2 || request === 3) {
|
|
2016
|
+
assert.equal(system?.sections?.notesoup_protocol, undefined, "the protocol section is stripped while off");
|
|
2017
|
+
assert.equal(system?.sections?.notesoup_tools, undefined, "the tool directory section is stripped while off");
|
|
2018
|
+
const skills = system?.sections?.skills ?? "";
|
|
2019
|
+
assert.ok(skills.includes("<name>keep-skill</name>"), "a non-notesoup skill survives");
|
|
2020
|
+
assert.equal(skills.includes("<name>notesoup</name>"), false, "notesoup skill is stripped");
|
|
2021
|
+
assert.equal(skills.includes("<name>dream</name>"), false, "notesoup dream skill is stripped");
|
|
2022
|
+
assert.deepEqual(getCurrentTools(context.messages), [], "all 12 notesoup tools leave the projection");
|
|
2023
|
+
for (const type of [BOOT_TYPE, MARKER_TYPE, GUIDANCE_TYPE, WARNING_TYPE, CONTINUATION_TYPE, RESET_LAST_WORD_TYPE, MANUAL_WIPE_TYPE]) {
|
|
2024
|
+
assert.equal(customTypes.includes(type), false, `${type} is stripped while off`);
|
|
2025
|
+
}
|
|
2026
|
+
assert.ok(customTypes.includes(CARRIED_INPUT_TYPE), "carried human input survives");
|
|
2027
|
+
const deltas = context.messages.filter((message) => message.role === "system").slice(1);
|
|
2028
|
+
assert.equal(deltas.some((message) => {
|
|
2029
|
+
const delta = message;
|
|
2030
|
+
const emptyContent = delta.content === "" || (Array.isArray(delta.content) && delta.content.length === 0);
|
|
2031
|
+
return emptyContent && !delta.toolsAdded?.length && !delta.toolsRemoved?.length && !(delta.sections && Object.keys(delta.sections).length > 0);
|
|
2032
|
+
}), false, "empty delta system messages are dropped while off");
|
|
2033
|
+
}
|
|
2034
|
+
else if (request === 4) {
|
|
2035
|
+
assert.ok(system?.sections?.notesoup_protocol?.includes(NOTES_PROTOCOL_OPEN_TAG), "the protocol returns after /notesoup on");
|
|
2036
|
+
assert.equal(typeof system?.sections?.notesoup_tools, "string", "the tool directory returns");
|
|
2037
|
+
const skills = system?.sections?.skills ?? "";
|
|
2038
|
+
for (const name of ["notesoup", "dream", "keep-skill"])
|
|
2039
|
+
assert.ok(skills.includes(`<name>${name}</name>`), `${name} skill is visible after on`);
|
|
2040
|
+
assert.deepEqual(getCurrentTools(context.messages).map((tool) => tool.name).sort(), allTools, "all 12 notesoup tools return");
|
|
2041
|
+
}
|
|
2042
|
+
return assistant(fixture, [{ type: "text", text: "done" }]);
|
|
2043
|
+
},
|
|
2044
|
+
});
|
|
2045
|
+
try {
|
|
2046
|
+
await fixture.session.prompt("FIRST_TURN_SENTINEL");
|
|
2047
|
+
await fixture.session.waitForIdle();
|
|
2048
|
+
assert.equal(bootEntries(fixture).length, 1);
|
|
2049
|
+
for (const type of [MARKER_TYPE, GUIDANCE_TYPE, WARNING_TYPE, CONTINUATION_TYPE, RESET_LAST_WORD_TYPE, MANUAL_WIPE_TYPE, CARRIED_INPUT_TYPE]) {
|
|
2050
|
+
fixture.sessionManager.appendCustomMessageEntry(type, `${type}-sentinel`, false);
|
|
2051
|
+
}
|
|
2052
|
+
await fixture.session.prompt("/notesoup off");
|
|
2053
|
+
assert.equal(resetMarkers(fixture).length, 0);
|
|
2054
|
+
await fixture.session.prompt("OFF_TURN");
|
|
2055
|
+
await fixture.session.waitForIdle();
|
|
2056
|
+
assert.equal(fixture.sessionManager.getBranch().some((entry) => entry.type === "custom" && entry.customType === ENABLED_TYPE && entry.data.enabled === false), true, "the off choice is durable on the branch");
|
|
2057
|
+
await fixture.session.reload();
|
|
2058
|
+
await fixture.session.prompt("AFTER_RELOAD");
|
|
2059
|
+
await fixture.session.waitForIdle();
|
|
2060
|
+
assert.equal(fixture.requests.length, 3, "reload neither boots nor adds a request");
|
|
2061
|
+
await fixture.session.prompt("/notesoup on");
|
|
2062
|
+
await fixture.session.prompt("RESTORED_TURN");
|
|
2063
|
+
await fixture.session.waitForIdle();
|
|
2064
|
+
assert.equal(fixture.requests.length, 4);
|
|
2065
|
+
}
|
|
2066
|
+
finally {
|
|
2067
|
+
fixture.close();
|
|
2068
|
+
}
|
|
2069
|
+
});
|
|
2070
|
+
test("real AgentSession: /notesoup off after reset allows native compaction and /notesoup on re-boots cleanly", async () => {
|
|
2071
|
+
let fixture;
|
|
2072
|
+
fixture = await openFixture({
|
|
2073
|
+
compactionEnabled: true,
|
|
2074
|
+
tools: [...NOTESOUP_TOOL_NAMES],
|
|
2075
|
+
script: (request, context) => {
|
|
2076
|
+
if (request === 1) {
|
|
2077
|
+
return assistant(fixture, [{ type: "toolCall", id: "wipe-1", name: "empty_brain", arguments: {} }], "toolUse");
|
|
2078
|
+
}
|
|
2079
|
+
if (request === 2) {
|
|
2080
|
+
return assistant(fixture, [{ type: "text", text: "POST_RESET_REPLY" }]);
|
|
2081
|
+
}
|
|
2082
|
+
if (request === 3) {
|
|
2083
|
+
const rendered = text(context);
|
|
2084
|
+
assert.equal(rendered.includes("PRE_RESET_SENTINEL"), false, "pre-reset history stays hidden while off");
|
|
2085
|
+
assert.equal(context.messages.some((m) => m.role === "compactionSummary"), false, "empty reset wrapper stays stripped before native compaction");
|
|
2086
|
+
return assistant(fixture, [{ type: "text", text: "OFF_BEFORE_COMPACT_REPLY" }]);
|
|
2087
|
+
}
|
|
2088
|
+
if (request === 4) {
|
|
2089
|
+
const rendered = text(context);
|
|
2090
|
+
assert.ok(rendered.includes("NATIVE_SUMMARY_WHILE_OFF"), "native compaction summary reaches the model while off");
|
|
2091
|
+
assert.equal(rendered.includes("PRE_RESET_SENTINEL"), false);
|
|
2092
|
+
return assistant(fixture, [{ type: "text", text: "OFF_AFTER_COMPACT_REPLY" }]);
|
|
2093
|
+
}
|
|
2094
|
+
if (request === 5) {
|
|
2095
|
+
const rendered = text(context);
|
|
2096
|
+
assert.ok(rendered.includes("NATIVE_SUMMARY_WHILE_OFF"), "re-enabling notesoup keeps the native compaction summary");
|
|
2097
|
+
assert.ok(context.messages.some((m) => m.role === "custom" && m.customType === BOOT_TYPE), "re-enabling notesoup lazily injects a fresh boot");
|
|
2098
|
+
return assistant(fixture, [{ type: "text", text: "BACK_ON_REPLY" }]);
|
|
2099
|
+
}
|
|
2100
|
+
return assistant(fixture, [{ type: "text", text: `reply-${request}` }]);
|
|
2101
|
+
},
|
|
2102
|
+
});
|
|
2103
|
+
try {
|
|
2104
|
+
await fixture.session.prompt("PRE_RESET_SENTINEL");
|
|
2105
|
+
await fixture.session.waitForIdle();
|
|
2106
|
+
assert.equal(resetMarkers(fixture).length, 1);
|
|
2107
|
+
await fixture.session.prompt("/notesoup off");
|
|
2108
|
+
await fixture.session.prompt("OFF_BEFORE_COMPACT_PROMPT");
|
|
2109
|
+
await fixture.session.waitForIdle();
|
|
2110
|
+
assert.equal(fixture.requests.length, 3);
|
|
2111
|
+
// Simulate Pi native compaction landing while notesoup is off (keeping only the latest turn).
|
|
2112
|
+
const keptId = [...fixture.sessionManager.getBranch()].reverse().find((entry) => entry.type === "message")?.id ?? null;
|
|
2113
|
+
fixture.sessionManager.appendCompaction("NATIVE_SUMMARY_WHILE_OFF", keptId, 42_000);
|
|
2114
|
+
await fixture.session.prompt("OFF_AFTER_COMPACT_PROMPT");
|
|
2115
|
+
await fixture.session.waitForIdle();
|
|
2116
|
+
assert.equal(fixture.requests.length, 4);
|
|
2117
|
+
await fixture.session.prompt("/notesoup on");
|
|
2118
|
+
await fixture.session.prompt("BACK_ON_PROMPT");
|
|
2119
|
+
await fixture.session.waitForIdle();
|
|
2120
|
+
assert.equal(fixture.requests.length, 5);
|
|
2121
|
+
assert.equal(bootEntries(fixture).length, 3, "root boot + reset boot + post-compaction re-enable boot");
|
|
2122
|
+
}
|
|
2123
|
+
finally {
|
|
2124
|
+
fixture.close();
|
|
2125
|
+
}
|
|
2126
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
});
|