From ea443934df9992b5067999eed869a628c0441723 Mon Sep 17 00:00:00 2001 From: Sawyer Cutler Date: Fri, 11 Sep 2026 21:24:59 -0700 Subject: [PATCH 1/2] Warn when an agent plugin prompt file is missing --- src/plugins/agent-plugins.test.ts | 17 +++++++++++++++++ src/plugins/agent-plugins.ts | 16 ++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/plugins/agent-plugins.test.ts b/src/plugins/agent-plugins.test.ts index 8533cd0eb..25ea23f03 100644 --- a/src/plugins/agent-plugins.test.ts +++ b/src/plugins/agent-plugins.test.ts @@ -176,4 +176,21 @@ describe("resolveAgentPluginProfiles", () => { ), ).toBe(true); }); + + test("warns once when a prompt file is missing and still loads the profile", async () => { + const { mod, config } = agentModule("p1", [ + { id: "scout", systemPromptPath: "prompts/does-not-exist.md" }, + ]); + mod.dir = "/tmp/wt-cl-6724-missing-prompt-dir"; + const warnings: string[] = []; + const profiles = await resolveAgentPluginProfiles([mod], config, (msg) => + warnings.push(msg), + ); + expect(profiles.length).toBe(1); + expect(defined(profiles[0]).systemPromptRole).toBeUndefined(); + expect(warnings.length).toBe(1); + expect(warnings[0]).toContain('"p1"'); + expect(warnings[0]).toContain('"scout"'); + expect(warnings[0]).toContain("prompts/does-not-exist.md"); + }); }); diff --git a/src/plugins/agent-plugins.ts b/src/plugins/agent-plugins.ts index f8bb37c36..cc912fa75 100644 --- a/src/plugins/agent-plugins.ts +++ b/src/plugins/agent-plugins.ts @@ -90,14 +90,18 @@ export async function resolveAgentPluginProfiles( profile.systemPromptRole === undefined && mod.dir !== undefined ) { + const promptPath = join(mod.dir, profile.systemPromptPath); try { - const promptRaw = await readFile( - join(mod.dir, profile.systemPromptPath), - "utf8", - ); + const promptRaw = await readFile(promptPath, "utf8"); profile.systemPromptRole = promptRaw.trim(); - } catch { - // Missing prompt file is non-fatal — the profile loads without a role. + } catch (err) { + const reason = + (err instanceof Error ? err.message : String(err)) + .split("\n")[0] + ?.trim() || "unknown error"; + onWarning( + `plugin "${mod.manifest.id}" agent "${profile.id}" systemPromptPath "${profile.systemPromptPath}" unreadable (${promptPath}): ${reason}`, + ); } } // Provenance for search_agents: Claude marketplace installs stamp From 3eaf17bed23529cf1792af99d8fccc4797032b04 Mon Sep 17 00:00:00 2001 From: Sawyer Cutler Date: Fri, 11 Sep 2026 21:46:26 -0700 Subject: [PATCH 2/2] Pin unreadable marker in missing-prompt warning test --- src/plugins/agent-plugins.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/agent-plugins.test.ts b/src/plugins/agent-plugins.test.ts index 25ea23f03..6266b0b97 100644 --- a/src/plugins/agent-plugins.test.ts +++ b/src/plugins/agent-plugins.test.ts @@ -192,5 +192,6 @@ describe("resolveAgentPluginProfiles", () => { expect(warnings[0]).toContain('"p1"'); expect(warnings[0]).toContain('"scout"'); expect(warnings[0]).toContain("prompts/does-not-exist.md"); + expect(defined(warnings[0])).toMatch(/unreadable|missing/i); }); });