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 a bundled default-on plugin as enabled without settings" , ( ) => {
18+ expect ( isPluginEnabledForSurface ( bundledSkills , { } ) ) . toBe ( true ) ;
19+ } ) ;
20+
21+ test ( "projects explicit disabled and enabled settings" , ( ) => {
22+ expect (
23+ isPluginEnabledForSurface ( bundledSkills , {
24+ "corbits-skills" : { enabled : false } ,
25+ } ) ,
26+ ) . toBe ( false ) ;
27+ expect (
28+ isPluginEnabledForSurface ( bundledSkills , {
29+ "corbits-skills" : { enabled : true } ,
30+ } ) ,
31+ ) . toBe ( true ) ;
32+ } ) ;
33+ } ) ;
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" ;
@@ -2470,7 +2471,7 @@ export async function runTUI(initialConfig: Config): Promise<number> {
24702471 return {
24712472 id : p . id ,
24722473 name : p . name ,
2473- enabled : cfg [ p . id ] ?. enabled === true ,
2474+ enabled : isPluginEnabledForSurface ( mod , cfg ) ,
24742475 credentials : p . credentials ,
24752476 credentialValues : cfg [ p . id ] ?. credentials ?? { } ,
24762477 ...( p . kind !== undefined ? { kind : p . kind } : { } ) ,
You can’t perform that action at this time.
0 commit comments