@@ -73,6 +73,12 @@ const HUB_REPOS_STORAGE_KEY = "openwork.skills.hubRepos.v1";
7373
7474type SetStateAction < T > = T | ( ( current : T ) => T ) ;
7575
76+ type PluginListEntry = {
77+ name : string ;
78+ source : "config" | "dir.project" | "dir.global" ;
79+ removable : boolean ;
80+ } ;
81+
7682export type ExtensionsStoreSnapshot = {
7783 workspaceContextKey : string ;
7884 skills : SkillCard [ ] ;
@@ -93,7 +99,7 @@ export type ExtensionsStoreSnapshot = {
9399 pluginScope : PluginScope ;
94100 pluginConfig : OpencodeConfigFile | null ;
95101 pluginConfigPath : string | null ;
96- pluginList : string [ ] ;
102+ pluginList : PluginListEntry [ ] ;
97103 pluginInput : string ;
98104 pluginStatus : string | null ;
99105 activePluginGuide : string | null ;
@@ -128,7 +134,7 @@ type MutableState = {
128134 pluginScope : PluginScope ;
129135 pluginConfig : OpencodeConfigFile | null ;
130136 pluginConfigPath : string | null ;
131- pluginList : string [ ] ;
137+ pluginList : PluginListEntry [ ] ;
132138 pluginInput : string ;
133139 pluginStatus : string | null ;
134140 activePluginGuide : string | null ;
@@ -172,6 +178,42 @@ function uniqueSkillInstallName(base: string, taken: Set<string>, stableSuffix:
172178 return `skill-${ suffixSource } ` . slice ( 0 , 64 ) ;
173179}
174180
181+ function toConfigPluginListEntries ( names : string [ ] ) : PluginListEntry [ ] {
182+ const next : PluginListEntry [ ] = [ ] ;
183+ const seen = new Set < string > ( ) ;
184+ for ( const rawName of names ) {
185+ const name = rawName . trim ( ) ;
186+ if ( ! name || seen . has ( name ) ) continue ;
187+ seen . add ( name ) ;
188+ next . push ( { name, source : "config" , removable : true } ) ;
189+ }
190+ return next ;
191+ }
192+
193+ function toProjectPluginListEntries (
194+ items : Array < { spec : string ; source : string } > ,
195+ ) : PluginListEntry [ ] {
196+ const byName = new Map < string , PluginListEntry > ( ) ;
197+ for ( const item of items ) {
198+ const name = item . spec . trim ( ) ;
199+ if ( ! name ) continue ;
200+ const source : PluginListEntry [ "source" ] =
201+ item . source === "dir.project" || item . source === "dir.global"
202+ ? item . source
203+ : "config" ;
204+ const entry : PluginListEntry = {
205+ name,
206+ source,
207+ removable : source === "config" ,
208+ } ;
209+ const existing = byName . get ( name ) ;
210+ if ( ! existing || ( entry . removable && ! existing . removable ) ) {
211+ byName . set ( name , entry ) ;
212+ }
213+ }
214+ return [ ...byName . values ( ) ] ;
215+ }
216+
175217export function createExtensionsStore ( options : {
176218 client : ( ) => Client | null ;
177219 projectDir : ( ) => string ;
@@ -1399,23 +1441,23 @@ export function createExtensionsStore(options: {
13991441 }
14001442
14011443 const isPluginInstalledByName = ( pluginName : string , aliases : string [ ] = [ ] ) =>
1402- isPluginInstalled ( snapshot . pluginList , pluginName , aliases ) ;
1444+ isPluginInstalled ( snapshot . pluginList . map ( ( entry ) => entry . name ) , pluginName , aliases ) ;
14031445
14041446 const loadPluginsFromConfig = ( config : OpencodeConfigFile | null ) => {
1405- const nextPluginList : string [ ] = [ ] ;
1447+ const nextPluginNames : string [ ] = [ ] ;
14061448 let nextPluginStatus : string | null = null ;
14071449 loadPluginsFromConfigHelpers (
14081450 config ,
14091451 ( value ) => {
1410- nextPluginList . splice ( 0 , nextPluginList . length , ...applyStateAction ( nextPluginList , value ) ) ;
1452+ nextPluginNames . splice ( 0 , nextPluginNames . length , ...applyStateAction ( nextPluginNames , value ) ) ;
14111453 } ,
14121454 ( message ) => {
14131455 nextPluginStatus = message ;
14141456 } ,
14151457 ) ;
14161458 mutateState ( ( current ) => ( {
14171459 ...current ,
1418- pluginList : nextPluginList ,
1460+ pluginList : toConfigPluginListEntries ( nextPluginNames ) ,
14191461 pluginStatus : nextPluginStatus ,
14201462 } ) ) ;
14211463 } ;
@@ -1622,12 +1664,12 @@ export function createExtensionsStore(options: {
16221664 if ( refreshPluginsAborted ) return ;
16231665 const result = await openworkClient . listPlugins ( openworkWorkspaceId , { includeGlobal : false } ) ;
16241666 if ( refreshPluginsAborted ) return ;
1625- const configItems = result . items . filter ( ( item ) => item . source === "config" && item . scope === "project" ) ;
1626- const list = configItems . map ( ( item ) => item . spec ) ;
1667+ const projectItems = result . items . filter ( ( item ) => item . scope === "project" ) ;
1668+ const list = toProjectPluginListEntries ( projectItems ) ;
16271669 mutateState ( ( current ) => ( {
16281670 ...current ,
16291671 pluginList : list ,
1630- sidebarPluginList : list ,
1672+ sidebarPluginList : list . map ( ( entry ) => entry . name ) ,
16311673 pluginStatus : list . length ? null : "No plugins configured yet." ,
16321674 sidebarPluginStatus : null ,
16331675 pluginsContextKey : getWorkspaceContextKey ( ) ,
@@ -1710,12 +1752,12 @@ export function createExtensionsStore(options: {
17101752 nextSidebarPluginStatus = t ( "skills.failed_parse_opencode" ) ;
17111753 }
17121754
1713- const nextPluginList : string [ ] = [ ] ;
1755+ const nextPluginNames : string [ ] = [ ] ;
17141756 let nextPluginStatus : string | null = null ;
17151757 loadPluginsFromConfigHelpers (
17161758 config ,
17171759 ( value ) => {
1718- nextPluginList . splice ( 0 , nextPluginList . length , ...applyStateAction ( nextPluginList , value ) ) ;
1760+ nextPluginNames . splice ( 0 , nextPluginNames . length , ...applyStateAction ( nextPluginNames , value ) ) ;
17191761 } ,
17201762 ( message ) => {
17211763 nextPluginStatus = message ;
@@ -1724,7 +1766,7 @@ export function createExtensionsStore(options: {
17241766
17251767 mutateState ( ( current ) => ( {
17261768 ...current ,
1727- pluginList : nextPluginList ,
1769+ pluginList : toConfigPluginListEntries ( nextPluginNames ) ,
17281770 pluginStatus : nextPluginStatus ,
17291771 sidebarPluginList : nextSidebarPluginList ,
17301772 sidebarPluginStatus : nextSidebarPluginStatus ,
@@ -1840,6 +1882,11 @@ export function createExtensionsStore(options: {
18401882 const name = pluginName . trim ( ) ;
18411883 if ( ! name ) return ;
18421884 const triggerName = stripPluginVersion ( name ) ;
1885+ const existingPlugin = snapshot . pluginList . find ( ( entry ) => entry . name === name ) ;
1886+ if ( existingPlugin && ! existingPlugin . removable ) {
1887+ setStateField ( "pluginStatus" , "Directory-discovered plugins are read-only." ) ;
1888+ return ;
1889+ }
18431890
18441891 const isLocalWorkspace = options . workspaceType ( ) === "local" ;
18451892 const openworkSnapshot = getOpenworkServerSnapshot ( ) ;
0 commit comments