@@ -128,10 +128,17 @@ function classifySkillLocation(
128128 location : string ,
129129 globalPrefix : string ,
130130 repos : Repo [ ] ,
131+ customDirectory ?: string ,
131132) : { scope : SkillScope ; repo ?: Repo } | null {
132133 if ( location . startsWith ( globalPrefix + path . sep ) ) {
133134 return { scope : 'global' }
134135 }
136+ if ( customDirectory ) {
137+ const projectPrefix = path . join ( customDirectory , '.opencode' , 'skills' )
138+ if ( location . startsWith ( projectPrefix + path . sep ) ) {
139+ return { scope : 'project' }
140+ }
141+ }
135142 for ( const repo of repos ) {
136143 const projectPrefix = getProjectSkillsPath ( repo )
137144 if ( location . startsWith ( projectPrefix + path . sep ) ) {
@@ -160,34 +167,46 @@ export async function listManagedSkills(
160167 db : Database ,
161168 openCodeClient : OpenCodeClient ,
162169 repoId ?: number ,
170+ directory ?: string ,
163171) : Promise < SkillFileInfo [ ] > {
164172 const globalPrefix = getGlobalSkillsPath ( )
165173 const allRepos = listRepos ( db )
166174
167- const targetRepos = repoId
168- ? allRepos . filter ( r => r . id === repoId )
169- : allRepos
170-
171- if ( repoId && targetRepos . length === 0 ) {
172- throw new Error ( `Repository with id ${ repoId } not found` )
173- }
174-
175- const directories = targetRepos . length > 0
176- ? targetRepos . map ( r => r . fullPath )
177- : [ getWorkspacePath ( ) ]
178-
179175 const seenLocations = new Set < string > ( )
180176 const result : SkillFileInfo [ ] = [ ]
181177
182- for ( const directory of directories ) {
178+ if ( directory ) {
183179 const skills = await fetchOpenCodeSkills ( openCodeClient , directory )
184180 for ( const skill of skills ) {
185181 if ( seenLocations . has ( skill . location ) ) continue
186- const classification = classifySkillLocation ( skill . location , globalPrefix , allRepos )
182+ const classification = classifySkillLocation ( skill . location , globalPrefix , allRepos , directory )
187183 if ( ! classification ) continue
188184 seenLocations . add ( skill . location )
189185 result . push ( toSkillFileInfo ( skill , classification ) )
190186 }
187+ } else {
188+ const targetRepos = repoId
189+ ? allRepos . filter ( r => r . id === repoId )
190+ : allRepos
191+
192+ if ( repoId && targetRepos . length === 0 ) {
193+ throw new Error ( `Repository with id ${ repoId } not found` )
194+ }
195+
196+ const directories = targetRepos . length > 0
197+ ? targetRepos . map ( r => r . fullPath )
198+ : [ getWorkspacePath ( ) ]
199+
200+ for ( const dir of directories ) {
201+ const skills = await fetchOpenCodeSkills ( openCodeClient , dir )
202+ for ( const skill of skills ) {
203+ if ( seenLocations . has ( skill . location ) ) continue
204+ const classification = classifySkillLocation ( skill . location , globalPrefix , allRepos )
205+ if ( ! classification ) continue
206+ seenLocations . add ( skill . location )
207+ result . push ( toSkillFileInfo ( skill , classification ) )
208+ }
209+ }
191210 }
192211
193212 return result
0 commit comments