File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ } ) ;
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -120,6 +120,7 @@ import { TELEMETRY_NOTICE } from "../telemetry/index.js";
120120import { captureSlashCommand } from "../telemetry/product-events.js" ;
121121import { getTelemetry , liveTelemetry } from "../telemetry/singleton.js" ;
122122import { createTelemetryToggleHandler } from "../telemetry/toggle.js" ;
123+ import { isPluginEnabledForSurface } from "./plugin-surface.js" ;
123124
124125import { loadStartupChangelogMarkdown , stampVersionAfterStartup } from "../changelog/index.js" ;
125126import { 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 } : { } ) ,
You can’t perform that action at this time.
0 commit comments