Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/plugins/agent-plugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,22 @@ 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");
expect(defined(warnings[0])).toMatch(/unreadable|missing/i);
});
});
16 changes: 10 additions & 6 deletions src/plugins/agent-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading