Open History to see the last commit
1// @effect-diagnostics nodeBuiltinImport:off -- Pi extensions run outside Effect; these tests exercise their native filesystem boundary.
2import * as NodeFSP from "node:fs/promises";
3import * as NodePath from "node:path";
4import * as NodeOS from "node:os";
5import * as NodeModule from "node:module";
6import * as NodeVM from "node:vm";
7import { assert, describe, expect, it } from "@effect/vitest";
8
9import { PI_T3_MCP_EXTENSION_SOURCE } from "./mcpExtensionSource.ts";
10import { loadMcpBridge } from "./mcpBridge.testkit.ts";
11
12type RequestHook = (
13 event: { payload: unknown },
14 ctx: { model: { provider: string } },
15) => Record<string, unknown> | undefined;
16
17interface SkillCommand {
18 readonly name: string;
19 readonly source: string;
20 readonly sourceInfo: { readonly path: string };
21}
22
23type InputHook = (
24 event: { text: string; images?: ReadonlyArray<unknown> },
25 ctx: { ui: { notify: (message: string, level: string) => void } },
26) => Promise<{ action: string; text: string; images?: ReadonlyArray<unknown> } | undefined>;
27
28async function loadHooks(commands: ReadonlyArray<SkillCommand> = []) {
29 const handlers = new Map<string, unknown>();
30 const source = NodeModule.stripTypeScriptTypes(
31 PI_T3_MCP_EXTENSION_SOURCE.replace(/^import .*;$/gm, "").replace(
32 "export default async function",
33 "async function",
34 ),
35 );
36 await NodeVM.runInNewContext(`${source}\nt3McpExtension(pi)`, {
37 process: { env: {} },
38 NodeFSP,
39 NodePath,
40 stripFrontmatter: (content: string) => content,
41 pi: {
42 on: (name: string, handler: unknown) => handlers.set(name, handler),
43 getCommands: () => commands,
44 },
45 });
46 return handlers;
47}
48
49describe("Pi orchestration prompt section", () => {
50 it("adds a stable section without overriding the prompt or skipping discovery", async () => {
51 const bridge = await loadMcpBridge({ modern: true, toolSearchAvailable: true });
52 const hook = bridge.handlers.get("before_agent_start")!;
53 const sections: Record<string, string> = { existing: "keep me" };
54 const event = { systemPrompt: "base", systemPromptOptions: { sections } };
55 const ctx = { model: { api: "openai-completions" }, ui: { notify: assert.fail } };
56
57 assert.isUndefined(await hook(event, ctx));
58 assert.include(sections.t3_code_orchestration, "orchestrator_capabilities");
59 assert.equal(event.systemPrompt, "base");
60 assert.include(bridge.getActiveTools(), "mcp__t3-code__preview_snapshot");
61
62 const guidance = sections.t3_code_orchestration!;
63 assert.isUndefined(await hook(event, ctx));
64 assert.deepEqual(event.systemPromptOptions.sections, {
65 existing: "keep me",
66 t3_code_orchestration: guidance,
67 });
68 });
69
70 it.each([
71 {
72 name: "on Pi builds without prompt sections",
73 events: [
74 { systemPrompt: "base" },
75 { systemPrompt: "base", systemPromptOptions: {} },
76 { systemPrompt: "base", systemPromptOptions: { sections: null } },
77 ],
78 },
79 {
80 name: "when an earlier extension forces the system prompt",
81 events: [
82 {
83 systemPrompt: "forced",
84 systemPromptOptions: { sections: {}, forceSystemPrompt: "forced" },
85 },
86 ],
87 },
88 ])("appends guidance $name", async ({ events }) => {
89 const bridge = await loadMcpBridge();
90 const hook = bridge.handlers.get("before_agent_start")!;
91 for (const event of events) {
92 const result = await hook(event, { ui: { notify: assert.fail } });
93 assert.isDefined(result);
94 assert.isTrue(result!.systemPrompt.startsWith(`${event.systemPrompt}\n\n`));
95 assert.include(result!.systemPrompt, "orchestrator_capabilities");
96 }
97 });
98});
99
100describe("Pi MCP tool results", () => {
101 it("returns mixed screenshot blocks and typed script output without repeating structured text", async () => {
102 const content = [
103 { type: "text", text: "Browser screenshot" },
104 { type: "image", data: "AAAA", mimeType: "image/png", _meta: { private: true } },
105 { type: "text", text: "Screenshot captured" },
106 ] as const;
107 const result = { content, structuredContent: { count: 2 }, _meta: { private: true } };
108 const bridge = await loadMcpBridge({ modern: true, result });
109 const tool = bridge.tools.find((tool) => tool.name === "mcp__t3-code__preview_snapshot")!;
110 const output = await tool.execute("snapshot", {});
111 assert.deepEqual(output.content, [
112 content[0],
113 { type: "image", data: "AAAA", mimeType: "image/png" },
114 content[2],
115 ]);
116 assert.deepEqual(output.structuredContent, { content, structuredContent: { count: 2 } });
117 assert.deepEqual(tool.outputSchema, {
118 type: "object",
119 properties: {
120 content: { type: "array", items: { type: "object" } },
121 structuredContent: { type: "object", properties: { count: { type: "number" } } },
122 isError: { type: "boolean" },
123 _meta: { type: "object" },
124 },
125 required: ["content"],
126 });
127 });
128
129 it.each([false, true])(
130 "preserves image-only results and error status, isError=%s",
131 async (isError) => {
132 const image = { type: "image", data: "AAAA", mimeType: "image/png" };
133 const result = { content: [image], isError };
134 const bridge = await loadMcpBridge({ result });
135 const output = await bridge.tools[0]!.execute("image", {});
136 assert.deepEqual(output.content[0], image);
137 assert.equal(output.content.length, isError ? 2 : 1);
138 if (isError) assert.include(output.content[1]?.text ?? "", "returned an error");
139 assert.equal(output.isError, isError ? true : undefined);
140 assert.deepEqual(output.structuredContent, result);
141 },
142 );
143
144 it("uses structured output as model text when content is empty", async () => {
145 const result = { content: [], structuredContent: { count: 2 } };
146 const bridge = await loadMcpBridge({ result });
147 const output = await bridge.tools[0]!.execute("structured", {});
148 assert.deepEqual(output.content, [{ type: "text", text: '{"count":2}' }]);
149 assert.deepEqual(output.structuredContent, result);
150 });
151
152 it("propagates cancellation without returning a successful result", async () => {
153 const bridge = await loadMcpBridge();
154 const controller = new AbortController();
155 controller.abort();
156 await expect(bridge.tools[0]!.execute("cancelled", {}, controller.signal)).rejects.toThrow(
157 "aborted",
158 );
159 });
160});
161
162describe("Pi MCP tool exposure", () => {
163 const discoveryContext = {
164 model: { api: "anthropic-messages" },
165 ui: { notify: () => undefined },
166 };
167
168 it.each(["session_start", "session_tree", "model_select", "before_agent_start"])(
169 "declares optional T3 tools for OpenAI-compatible gateways at %s",
170 async (hookName) => {
171 const bridge = await loadMcpBridge({ modern: true, toolSearchAvailable: true });
172 const hook = bridge.handlers.get(hookName);
173 assert.isDefined(hook);
174 await hook!(
175 { systemPrompt: "Pi system prompt" },
176 { model: { api: "openai-completions" }, ui: { notify: assert.fail } },
177 );
178 assert.isTrue(
179 bridge.tools
180 .filter((tool) => tool.name.startsWith("mcp__t3-code__"))
181 .every((tool) => bridge.getActiveTools().includes(tool.name)),
182 );
183 const result = await bridge.tools
184 .find((tool) => tool.name === "mcp__t3-code__preview_snapshot")!
185 .execute("gateway-call", {});
186 assert.equal(result.content[0]?.text, "browser snapshot");
187 assert.equal(bridge.tools.filter((tool) => tool.exposure === "hidden").length, 4);
188 },
189 );
190
191 it("keeps orchestration direct and optional bridge tools discoverable on modern Pi", async () => {
192 const bridge = await loadMcpBridge({ modern: true, toolSearchAvailable: true });
193 await bridge.handlers.get("session_start")!({ systemPrompt: "" }, discoveryContext);
194 const start = bridge.handlers.get("before_agent_start");
195 assert.isDefined(start);
196 const prompt = await start!({ systemPrompt: "Pi system prompt" }, discoveryContext);
197 assert.include(prompt?.systemPrompt ?? "", "orchestrator_capabilities");
198 assert.equal(bridge.servers.length, 0);
199 assert.equal(bridge.tools.length, 8);
200 assert.deepEqual(bridge.getActiveTools(), ["read", "tool_search"]);
201 assert.deepEqual(
202 bridge.tools
203 .filter((tool) => tool.exposure !== "hidden")
204 .map((tool) => [tool.name, tool.exposure]),
205 [
206 ["mcp__t3-code__orchestrator_capabilities", "direct"],
207 ["mcp__t3-code__delegate_task", "direct"],
208 ["mcp__t3-code__task_status", "direct"],
209 ["mcp__t3-code__preview_snapshot", "deferred"],
210 ],
211 );
212 assert.deepEqual(
213 bridge.tools.filter((tool) => tool.exposure === "hidden").map((tool) => tool.name),
214 [
215 "mcp__t3_code__orchestrator_capabilities",
216 "mcp__t3_code__delegate_task",
217 "mcp__t3_code__task_status",
218 "mcp__t3_code__preview_snapshot",
219 ],
220 );
221 const result = await bridge.tools
222 .find((tool) => tool.name === "mcp__t3-code__preview_snapshot")!
223 .execute("call-1", { depth: 2 });
224 assert.equal(result.content[0]?.text, "browser snapshot");
225 assert.equal(bridge.requests.at(-1)?.method, "tools/call");
226 });
227
228 it("restores gateway declarations after model switches and older tree loadouts without excluded tools", async () => {
229 const bridge = await loadMcpBridge({
230 modern: true,
231 toolSearchAvailable: true,
232 allowsTool: (name) => name !== "mcp__t3-code__delegate_task",
233 });
234 const event = { systemPrompt: "" };
235 await bridge.handlers.get("session_start")!(event, discoveryContext);
236 const gatewayContext = { model: { api: "openai-completions" }, ui: { notify: assert.fail } };
237 await bridge.handlers.get("model_select")!(event, gatewayContext);
238 bridge.restoreActiveTools(["read", "mcp__t3-code__task_status"]);
239 await bridge.handlers.get("session_tree")!(event, gatewayContext);
240 assert.deepEqual(bridge.getActiveTools(), [
241 "read",
242 "mcp__t3-code__task_status",
243 "tool_search",
244 "mcp__t3-code__orchestrator_capabilities",
245 "mcp__t3-code__preview_snapshot",
246 ]);
247 await bridge.handlers.get("model_select")!(event, discoveryContext);
248 assert.equal(
249 bridge.tools.find((tool) => tool.name === "mcp__t3-code__preview_snapshot")?.exposure,
250 "deferred",
251 );
252 assert.include(bridge.getActiveTools(), "mcp__t3-code__preview_snapshot");
253 });
254
255 it.each(["legacy Pi", "disabled tool search"])(
256 "keeps tool execution available with %s",
257 async (mode) => {
258 const bridge = await loadMcpBridge({
259 modern: mode !== "legacy Pi",
260 toolSearchAvailable: mode === "disabled tool search",
261 toolSearchDisabled: mode === "disabled tool search",
262 });
263 if (mode !== "legacy Pi") {
264 const start = bridge.handlers.get("session_start");
265 await start!({ systemPrompt: "Pi system prompt" }, discoveryContext);
266 }
267 assert.equal(bridge.tools.filter((tool) => tool.exposure !== "hidden").length, 4);
268 assert.isTrue(
269 bridge.tools
270 .filter((tool) => tool.exposure !== "hidden")
271 .every((tool) => tool.exposure === undefined || tool.exposure === "direct"),
272 );
273 const tool = bridge.tools.find((tool) => tool.name === "mcp__t3-code__preview_snapshot");
274 assert.isDefined(tool);
275 const controller = new AbortController();
276 const result = await tool!.execute("call-1", { depth: 2 }, controller.signal);
277 assert.equal(result.content[0]?.text, "browser snapshot");
278 assert.strictEqual(bridge.transports.at(-1)?.signal, controller.signal);
279 assert.equal(bridge.transports.at(-1)?.url, "http://fixture.invalid/mcp");
280 assert.equal(bridge.transports.at(-1)?.authorization, "Bearer fixture-token");
281 assert.deepEqual(JSON.parse(JSON.stringify(bridge.requests.at(-1))), {
282 jsonrpc: "2.0",
283 id: 3,
284 method: "tools/call",
285 params: { name: "preview_snapshot", arguments: { depth: 2 } },
286 });
287 assert.isUndefined(tool?.promptSnippet);
288 assert.isUndefined(tool?.promptGuidelines);
289 },
290 );
291
292 it("preserves legacy wildcard tool selection", async () => {
293 const bridge = await loadMcpBridge({
294 modern: true,
295 toolSearchAvailable: true,
296 allowsTool: (name) =>
297 name === "read" || name === "tool_search" || name.startsWith("mcp__t3-code__"),
298 });
299 await bridge.handlers.get("session_start")!({ systemPrompt: "" }, discoveryContext);
300 assert.equal(bridge.tools.length, 4);
301 assert.equal(bridge.tools.filter((tool) => tool.exposure === "direct").length, 3);
302 const tool = bridge.tools.find((tool) => tool.name === "mcp__t3-code__preview_snapshot");
303 assert.isDefined(tool);
304 assert.equal((await tool!.execute("selected", {})).content[0]?.text, "browser snapshot");
305 });
306
307 it.each([false, true])(
308 "reconciles tree loadouts while honoring search exclusion: %s",
309 async (excludeSearch) => {
310 const bridge = await loadMcpBridge({
311 modern: true,
312 toolSearchAvailable: true,
313 allowsTool: (name) =>
314 name !== "mcp__t3-code__delegate_task" && (!excludeSearch || name !== "tool_search"),
315 });
316 await bridge.handlers.get("session_start")!({ systemPrompt: "" }, discoveryContext);
317 bridge.restoreActiveTools([
318 "read",
319 "mcp__t3-code__task_status",
320 "mcp__t3-code__preview_snapshot",
321 ]);
322 const tree = bridge.handlers.get("session_tree");
323 assert.isDefined(tree);
324 await tree!({ systemPrompt: "" }, discoveryContext);
325 assert.deepEqual(bridge.getActiveTools(), [
326 "read",
327 "mcp__t3-code__task_status",
328 "mcp__t3-code__preview_snapshot",
329 ...(!excludeSearch ? ["tool_search"] : []),
330 ]);
331 assert.isFalse(
332 bridge.tools.some(
333 (tool) => tool.exposure !== "hidden" && tool.name.endsWith("__delegate_task"),
334 ),
335 );
336 },
337 );
338});
339
340describe("Pi tool discovery permissions", () => {
341 it.each(["approval-required", "auto-accept-edits", "auto"])(
342 "allows annotated T3 reads in %s while gating mutations and replacements",
343 async (runtimeMode) => {
344 const bridge = await loadMcpBridge({ modern: true, runtimeMode });
345 const hook = bridge.handlers.get("tool_call") as unknown as (
346 event: { toolName: string; input: unknown },
347 ctx: { ui: { confirm: (title: string) => Promise<boolean> } },
348 ) => Promise<{ block: true; reason: string } | undefined>;
349 const confirmations: string[] = [];
350 const ctx = {
351 ui: {
352 confirm: async (title: string) => {
353 confirmations.push(title);
354 return false;
355 },
356 },
357 };
358 for (const prefix of ["mcp__t3-code__", "mcp__t3_code__"]) {
359 assert.isUndefined(
360 await hook({ toolName: prefix + "orchestrator_capabilities", input: {} }, ctx),
361 );
362 assert.equal(
363 (await hook({ toolName: prefix + "delegate_task", input: {} }, ctx))?.block,
364 true,
365 );
366 assert.equal(
367 (await hook({ toolName: prefix + "task_status", input: {} }, ctx))?.block,
368 true,
369 );
370 }
371 assert.equal(confirmations.length, 4);
372 bridge.setBridgeSourcePath("/user/extensions/replacement.ts");
373 assert.equal(
374 (await hook({ toolName: "mcp__t3-code__orchestrator_capabilities", input: {} }, ctx))
375 ?.block,
376 true,
377 );
378 assert.equal(
379 (await hook({ toolName: "mcp__other__orchestrator_capabilities", input: {} }, ctx))?.block,
380 true,
381 );
382 assert.equal(confirmations.length, 6);
383 },
384 );
385
386 it("allows discovery without confirmation and still gates the discovered tool", async () => {
387 type ToolCallHook = (
388 event: { toolName: string; input: unknown },
389 ctx: {
390 signal: AbortSignal;
391 ui: {
392 confirm: (
393 title: string,
394 detail: string,
395 options: { signal: AbortSignal },
396 ) => Promise<boolean>;
397 };
398 },
399 ) => Promise<{ block: true; reason: string } | undefined>;
400 let toolCall: ToolCallHook | undefined;
401 let searchPath = "builtin:tool-search";
402 const source = NodeModule.stripTypeScriptTypes(
403 PI_T3_MCP_EXTENSION_SOURCE.replace(/^import .*;$/gm, "").replace(
404 "export default async function",
405 "async function",
406 ),
407 );
408 await NodeVM.runInNewContext(`${source}\nt3McpExtension(pi)`, {
409 process: { env: { T3_PI_RUNTIME_MODE: "approval-required" } },
410 pi: {
411 on: (name: string, handler: ToolCallHook) => {
412 if (name === "tool_call") toolCall = handler;
413 },
414 getAllTools: () => [{ name: "tool_search", sourceInfo: { path: searchPath } }],
415 },
416 });
417 assert.isDefined(toolCall);
418 const confirmations: string[] = [];
419 const controller = new AbortController();
420 const ctx = {
421 signal: controller.signal,
422 ui: {
423 confirm: async (title: string, _detail: string, options: { signal: AbortSignal }) => {
424 assert.strictEqual(options.signal, controller.signal);
425 confirmations.push(title);
426 return false;
427 },
428 },
429 };
430 assert.isUndefined(
431 await toolCall!({ toolName: "tool_search", input: { query: "preview_snapshot" } }, ctx),
432 );
433 assert.equal(confirmations.length, 0);
434 const result = await toolCall!({ toolName: "mcp__t3-code__preview_snapshot", input: {} }, ctx);
435 assert.equal(result?.block, true);
436 assert.deepEqual(confirmations, ["Allow mcp__t3-code__preview_snapshot?"]);
437
438 searchPath = "/extensions/custom-search.ts";
439 const replaced = await toolCall!({ toolName: "tool_search", input: {} }, ctx);
440 assert.equal(replaced?.block, true);
441 assert.equal(confirmations.at(-1), "Allow tool_search?");
442 });
443});
444
445async function loadRequestHook(): Promise<RequestHook> {
446 const handlers = new Map<string, RequestHook>();
447 const source = NodeModule.stripTypeScriptTypes(
448 PI_T3_MCP_EXTENSION_SOURCE.replace(/^import .*;$/gm, "").replace(
449 "export default async function",
450 "async function",
451 ),
452 );
453 await NodeVM.runInNewContext(`${source}\nt3McpExtension(pi)`, {
454 process: { env: {} },
455 pi: { on: (name: string, handler: RequestHook) => handlers.set(name, handler) },
456 });
457 const hook = handlers.get("before_provider_request");
458 assert.isDefined(hook);
459 return hook!;
460}
461
462describe("Pi upstream output-budget workaround", () => {
463 it.each(["max_tokens", "max_completion_tokens"])(
464 "caps %s without changing the conversation or tools",
465 async (key) => {
466 const hook = await loadRequestHook();
467 const payload = {
468 model: "moonshotai/kimi-k2.6",
469 messages: [{ role: "user", content: "hello" }],
470 tools: [{ type: "function", function: { name: "read" } }],
471 [key]: 231_969,
472 };
473 const result = hook({ payload }, { model: { provider: "openrouter" } });
474 assert.equal(result?.[key], 32_768);
475 assert.strictEqual(result?.messages, payload.messages);
476 assert.strictEqual(result?.tools, payload.tools);
477 assert.equal(result?.model, payload.model);
478 assert.equal(payload[key], 231_969);
479 },
480 );
481
482 it("preserves smaller budgets and other providers' payloads", async () => {
483 const hook = await loadRequestHook();
484 for (const payload of [{ max_tokens: 8192 }, { max_completion_tokens: 32_768 }, {}, null]) {
485 assert.isUndefined(hook({ payload }, { model: { provider: "openrouter" } }));
486 }
487 assert.isUndefined(
488 hook({ payload: { max_tokens: 231_969 } }, { model: { provider: "anthropic" } }),
489 );
490 });
491});
492
493async function loadInputHook(commands: ReadonlyArray<SkillCommand>) {
494 const handlers = await loadHooks(commands);
495 const hook = handlers.get("input");
496 assert.isDefined(hook);
497 return hook as InputHook;
498}
499
500describe("Pi skill references", () => {
501 it("loads every selected skill once while preserving inline prose, whitespace, and images", async () => {
502 const directory = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "pi-skill-mentions-"));
503 try {
504 const alpha = NodePath.join(directory, "alpha.md");
505 const beta = NodePath.join(directory, "beta.md");
506 await NodeFSP.writeFile(alpha, "ALPHA_INSTRUCTIONS");
507 await NodeFSP.writeFile(beta, "BETA_INSTRUCTIONS");
508 const hook = await loadInputHook([
509 { name: "skill:alpha", source: "skill", sourceInfo: { path: alpha } },
510 { name: "skill:beta", source: "skill", sourceInfo: { path: beta } },
511 ]);
512 const text =
513 "Please use the $alpha philosophy, then $beta and $alpha\n```ts\n const x = 1;\n```";
514 const images = [{ type: "image", data: "fixture" }];
515 const result = await hook({ text, images }, { ui: { notify: assert.fail } });
516 assert.equal(result?.action, "transform");
517 assert.isTrue(result?.text.startsWith(text + "\n\n"));
518 assert.equal(result?.text.split("ALPHA_INSTRUCTIONS").length, 2);
519 assert.equal(result?.text.split("BETA_INSTRUCTIONS").length, 2);
520 assert.include(result?.text ?? "", `References are relative to ${directory}.`);
521 assert.strictEqual(result?.images, images);
522 } finally {
523 await NodeFSP.rm(directory, { recursive: true });
524 }
525 });
526
527 it("leaves unknown references and native skill commands for Pi", async () => {
528 const hook = await loadInputHook([
529 { name: "skill:alpha", source: "skill", sourceInfo: { path: "/unused" } },
530 ]);
531 for (const text of [
532 "Explain $HOME",
533 "/skill:alpha use $alpha",
534 "Hello",
535 "$missing",
536 "Use $alpha, then continue",
537 "Use ($alpha)",
538 ]) {
539 assert.isUndefined(await hook({ text }, { ui: { notify: assert.fail } }));
540 }
541 });
542
543 it("loads additional chips without duplicating a leading native skill", async () => {
544 const directory = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "pi-skill-mentions-"));
545 try {
546 const path = NodePath.join(directory, "beta.md");
547 await NodeFSP.writeFile(path, "BETA_INSTRUCTIONS");
548 const hook = await loadInputHook([
549 { name: "skill:alpha", source: "skill", sourceInfo: { path: "/unused" } },
550 { name: "skill:beta", source: "skill", sourceInfo: { path } },
551 ]);
552 const text = "/skill:alpha use $alpha and $beta";
553 const result = await hook({ text }, { ui: { notify: assert.fail } });
554 assert.isTrue(result?.text.startsWith(text + "\n\n"));
555 assert.notInclude(result?.text ?? "", '<skill name="alpha"');
556 assert.include(result?.text ?? "", "BETA_INSTRUCTIONS");
557 } finally {
558 await NodeFSP.rm(directory, { recursive: true });
559 }
560 });
561
562 it("reports an unreadable skill without deleting its reference or other selected instructions", async () => {
563 const directory = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "pi-skill-mentions-"));
564 try {
565 const path = NodePath.join(directory, "readable.md");
566 await NodeFSP.writeFile(path, "READABLE_INSTRUCTIONS");
567 const hook = await loadInputHook([
568 {
569 name: "skill:missing",
570 source: "skill",
571 sourceInfo: { path: NodePath.join(directory, "missing.md") },
572 },
573 { name: "skill:readable", source: "skill", sourceInfo: { path } },
574 ]);
575 const notices: string[] = [];
576 const text = "Use $missing and $readable";
577 const result = await hook(
578 { text },
579 {
580 ui: {
581 notify: (message) => {
582 notices.push(message);
583 },
584 },
585 },
586 );
587 assert.isTrue(result?.text.startsWith(text + "\n\n"));
588 assert.include(result?.text ?? "", "READABLE_INSTRUCTIONS");
589 assert.equal(notices.length, 1);
590 assert.include(notices[0] ?? "", "Could not load skill missing");
591 } finally {
592 await NodeFSP.rm(directory, { recursive: true });
593 }
594 });
595});