Skip to content

Commit 04cae7c

Browse files
Merge pull request #740 from corbitsdev/cl-7295-enable-bundled-corbits-skills-by-default
Project effective plugin enablement in the Plugins surface
2 parents 1c57d8c + 689249f commit 04cae7c

3 files changed

Lines changed: 49 additions & 1 deletion

File tree

src/tui/plugin-surface.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { describe, expect, test } from "bun:test";
2+
3+
import type { PluginModule } from "../plugins/loader.js";
4+
import { isPluginEnabledForSurface } from "./plugin-surface.js";
5+
6+
const bundledSkills: PluginModule = {
7+
origin: "repo",
8+
manifest: {
9+
id: "corbits-skills",
10+
name: "Corbits Skills",
11+
kind: "command",
12+
defaultEnabled: true,
13+
},
14+
};
15+
16+
describe("isPluginEnabledForSurface", () => {
17+
test("projects an unknown plugin as disabled", () => {
18+
expect(isPluginEnabledForSurface(undefined, {})).toBe(false);
19+
});
20+
21+
test("projects a bundled default-on plugin as enabled without settings", () => {
22+
expect(isPluginEnabledForSurface(bundledSkills, {})).toBe(true);
23+
});
24+
25+
test("projects explicit disabled and enabled settings", () => {
26+
expect(
27+
isPluginEnabledForSurface(bundledSkills, {
28+
"corbits-skills": { enabled: false },
29+
}),
30+
).toBe(false);
31+
expect(
32+
isPluginEnabledForSurface(bundledSkills, {
33+
"corbits-skills": { enabled: true },
34+
}),
35+
).toBe(true);
36+
});
37+
});

src/tui/plugin-surface.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { PluginConfig } from "../config/settings.js";
2+
import type { PluginModule } from "../plugins/loader.js";
3+
import { isPluginModuleEnabled } from "../plugins/register.js";
4+
5+
export function isPluginEnabledForSurface(
6+
plugin: PluginModule | undefined,
7+
config: Record<string, PluginConfig | undefined>,
8+
): boolean {
9+
return plugin !== undefined && isPluginModuleEnabled(plugin, config);
10+
}

src/tui/runner.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ import { TELEMETRY_NOTICE } from "../telemetry/index.js";
120120
import { captureSlashCommand } from "../telemetry/product-events.js";
121121
import { getTelemetry, liveTelemetry } from "../telemetry/singleton.js";
122122
import { createTelemetryToggleHandler } from "../telemetry/toggle.js";
123+
import { isPluginEnabledForSurface } from "./plugin-surface.js";
123124

124125
import { loadStartupChangelogMarkdown, stampVersionAfterStartup } from "../changelog/index.js";
125126
import { scheduleUpgradeNotice } from "../upgrade/index.js";
@@ -2511,7 +2512,7 @@ export async function runTUI(initialConfig: Config): Promise<number> {
25112512
return {
25122513
id: p.id,
25132514
name: p.name,
2514-
enabled: cfg[p.id]?.enabled === true,
2515+
enabled: isPluginEnabledForSurface(mod, cfg),
25152516
credentials: p.credentials,
25162517
credentialValues: cfg[p.id]?.credentials ?? {},
25172518
...(p.kind !== undefined ? { kind: p.kind } : {}),

0 commit comments

Comments
 (0)