@@ -2,6 +2,8 @@ import type { OpenCodeClient, OpenCodeEvent } from "@opencode/client/effect"
22import type { Agent } from "@opencode/schema/agent"
33import type { Command } from "@opencode/schema/command"
44import type { Model } from "@opencode/schema/model"
5+ import type { Provider } from "@opencode/schema/provider"
6+ import type { Skill } from "@opencode/schema/skill"
57import { FSUtil } from "@opencode/util/fs-util"
68import { Cause , Deferred , Effect , Exit , Schedule , Semaphore , Stream , SubscriptionRef } from "effect"
79import { ACPError } from "./error"
@@ -16,6 +18,9 @@ export type Catalog = {
1618 readonly modes : ReadonlyArray < { id : Agent . ID ; name : string ; description ?: string } >
1719 readonly defaultModeID : Agent . ID
1820 readonly commands : ReadonlyArray < Command . Info >
21+ /** Skills whose ID no command or built-in command already claims. */
22+ readonly skills : ReadonlyArray < Skill . Info >
23+ readonly providerNames : ReadonlyMap < Provider . ID , string >
1924}
2025
2126export function findModel ( models : ReadonlyArray < Model . Info > , ref : Model . Ref ) {
@@ -36,7 +41,13 @@ type Entry = {
3641 loadedGeneration : number
3742}
3843
39- const reloadOn = new Set < OpenCodeEvent [ "type" ] > ( [ "model.updated" , "agent.updated" , "command.updated" ] )
44+ const reloadOn = new Set < OpenCodeEvent [ "type" ] > ( [
45+ "model.updated" ,
46+ "agent.updated" ,
47+ "command.updated" ,
48+ "skill.updated" ,
49+ "provider.updated" ,
50+ ] )
4051
4152export const make = Effect . fnUntraced ( function * ( client : OpenCodeClient ) {
4253 const scope = yield * Effect . scope
@@ -138,12 +149,14 @@ const load = Effect.fn("cli.acp.catalog.load")(function* (client: OpenCodeClient
138149
139150const read = Effect . fnUntraced ( function * ( client : OpenCodeClient , cwd : string ) {
140151 const location = { directory : cwd }
141- const [ modelResult , defaultResult , agentResult , commandResult ] = yield * Effect . all (
152+ const [ modelResult , defaultResult , agentResult , commandResult , skillResult , providerResult ] = yield * Effect . all (
142153 [
143154 client . model . list ( { location } ) ,
144155 client . model . default ( { location } ) ,
145156 client . agent . list ( { location } ) ,
146157 client . command . list ( { location } ) ,
158+ client . skill . list ( { location } ) ,
159+ client . provider . list ( { location } ) ,
147160 ] ,
148161 { concurrency : "unbounded" } ,
149162 ) . pipe ( Effect . mapError ( ( cause ) => new ACPError . CatalogLoadError ( { cause } ) ) )
@@ -156,6 +169,8 @@ const read = Effect.fnUntraced(function* (client: OpenCodeClient, cwd: string) {
156169 // Core lists its resolved default agent first, the same one a new session runs.
157170 const defaultAgent = agents [ 0 ]
158171 if ( ! defaultAgent ) return yield * new ACPError . CatalogNotReadyError ( { reason : "agents" } )
172+ const commands = commandResult . data . filter ( ( command ) => ! builtinCommands . has ( command . name ) )
173+ const commandNames = new Set ( commands . map ( ( command ) => command . name ) )
159174 return {
160175 models,
161176 defaultModel : {
@@ -165,7 +180,9 @@ const read = Effect.fnUntraced(function* (client: OpenCodeClient, cwd: string) {
165180 } ,
166181 modes : agents . map ( ( agent ) => ( { id : agent . id , name : agent . name , description : agent . description } ) ) ,
167182 defaultModeID : defaultAgent . id ,
168- commands : commandResult . data . filter ( ( command ) => ! builtinCommands . has ( command . name ) ) ,
183+ commands,
184+ skills : skillResult . data . filter ( ( skill ) => ! builtinCommands . has ( skill . id ) && ! commandNames . has ( skill . id ) ) ,
185+ providerNames : new Map ( providerResult . data . map ( ( provider ) => [ provider . id , provider . name ] ) ) ,
169186 } satisfies Catalog
170187} )
171188
0 commit comments