Skip to content

Commit bdf01e7

Browse files
author
Peter Steinberger
committed
fix(plugins): surface actionable doctor warnings
1 parent aa2a5c9 commit bdf01e7

2 files changed

Lines changed: 50 additions & 1 deletion

File tree

‎src/cli/plugins-cli.list.test.ts‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,55 @@ describe("plugins cli list", () => {
100100
expect(runtimeLogs).toContain(cleanDoctorMessage);
101101
});
102102

103+
it.each([
104+
{
105+
description: "a required plugin is missing",
106+
diagnostic: {
107+
level: "warn" as const,
108+
pluginId: "calendar",
109+
message: 'plugin "calendar" requires plugin "contacts"; install "contacts" to use it',
110+
},
111+
expected: 'calendar: plugin "calendar" requires plugin "contacts"',
112+
},
113+
{
114+
description: "discovery cannot read an extensions directory",
115+
diagnostic: {
116+
level: "warn" as const,
117+
message: "failed to read extensions dir: /tmp/plugins (permission denied)",
118+
},
119+
expected: "failed to read extensions dir: /tmp/plugins (permission denied)",
120+
},
121+
])(
122+
"reports actionable discovery warnings when $description",
123+
async ({ diagnostic, expected }) => {
124+
buildPluginDiagnosticsReport.mockReturnValue({ plugins: [], diagnostics: [diagnostic] });
125+
126+
await runPluginsCommand(["plugins", "doctor"]);
127+
128+
const output = runtimeLogs.join("\n");
129+
expect(output).toContain("Diagnostics:");
130+
expect(output).toContain(expected);
131+
expect(output).not.toContain(cleanDoctorMessage);
132+
},
133+
);
134+
135+
it("keeps actionable discovery warnings alongside existing errors", async () => {
136+
buildPluginDiagnosticsReport.mockReturnValue({
137+
plugins: [],
138+
diagnostics: [
139+
{ level: "error", pluginId: "broken", message: "plugin manifest invalid" },
140+
{ level: "warn", pluginId: "calendar", message: "required plugin contacts is missing" },
141+
],
142+
});
143+
144+
await runPluginsCommand(["plugins", "doctor"]);
145+
146+
const output = runtimeLogs.join("\n");
147+
expect(output).toContain("broken: plugin manifest invalid");
148+
expect(output).toContain("calendar: required plugin contacts is missing");
149+
expect(output).not.toContain(cleanDoctorMessage);
150+
});
151+
103152
it("reports stale plugin config in doctor output without claiming full plugin health", async () => {
104153
const sourceConfig = {
105154
plugins: {

‎src/cli/plugins-cli.runtime.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ export async function runPluginsDoctorCommand(): Promise<void> {
375375
| undefined;
376376
const report = buildPluginDiagnosticsReport({ config: cfg, effectiveOnly: true });
377377
const errors = report.plugins.filter((p) => p.status === "error");
378-
const diags = report.diagnostics.filter((d) => d.level === "error");
378+
const diags = report.diagnostics.filter((entry) => !isConfigSelectedShadowDiagnostic(entry));
379379
const shadowed = report.diagnostics.filter((entry) =>
380380
isErroredConfigSelectedShadowDiagnostic({ entry, plugins: report.plugins }),
381381
);

0 commit comments

Comments
 (0)