@@ -284,6 +284,55 @@ describe("SkillManager", () => {
284284 expect ( mockedGitUtil . cloneRepository ) . not . toHaveBeenCalled ( ) ;
285285 } ) ;
286286
287+ it ( "should pull cached registry before installing skill" , async ( ) => {
288+ const repoPath = path . join ( os . homedir ( ) , ".ai-devkit" , "skills" , mockRegistryId ) ;
289+
290+ ( mockedFs . pathExists as any ) . mockImplementation ( ( checkPath : string ) => {
291+ if ( checkPath === repoPath ) {
292+ return Promise . resolve ( true ) ;
293+ }
294+ if ( checkPath . includes ( `${ path . sep } skills${ path . sep } ${ mockSkillName } ` ) ) {
295+ return Promise . resolve ( true ) ;
296+ }
297+ if ( checkPath . endsWith ( `${ path . sep } SKILL.md` ) ) {
298+ return Promise . resolve ( true ) ;
299+ }
300+ return Promise . resolve ( true ) ;
301+ } ) ;
302+
303+ mockedGitUtil . isGitRepository . mockResolvedValue ( true ) ;
304+ mockedGitUtil . pullRepository . mockResolvedValue ( undefined ) ;
305+
306+ await skillManager . addSkill ( mockRegistryId , mockSkillName ) ;
307+
308+ expect ( mockedGitUtil . cloneRepository ) . not . toHaveBeenCalled ( ) ;
309+ expect ( mockedGitUtil . pullRepository ) . toHaveBeenCalledWith ( repoPath ) ;
310+ } ) ;
311+
312+ it ( "should skip pull when cached registry is not a git repository" , async ( ) => {
313+ const repoPath = path . join ( os . homedir ( ) , ".ai-devkit" , "skills" , mockRegistryId ) ;
314+
315+ ( mockedFs . pathExists as any ) . mockImplementation ( ( checkPath : string ) => {
316+ if ( checkPath === repoPath ) {
317+ return Promise . resolve ( true ) ;
318+ }
319+ if ( checkPath . includes ( `${ path . sep } skills${ path . sep } ${ mockSkillName } ` ) ) {
320+ return Promise . resolve ( true ) ;
321+ }
322+ if ( checkPath . endsWith ( `${ path . sep } SKILL.md` ) ) {
323+ return Promise . resolve ( true ) ;
324+ }
325+ return Promise . resolve ( true ) ;
326+ } ) ;
327+
328+ mockedGitUtil . isGitRepository . mockResolvedValue ( false ) ;
329+
330+ await skillManager . addSkill ( mockRegistryId , mockSkillName ) ;
331+
332+ expect ( mockedGitUtil . pullRepository ) . not . toHaveBeenCalled ( ) ;
333+ expect ( mockedGitUtil . cloneRepository ) . not . toHaveBeenCalled ( ) ;
334+ } ) ;
335+
287336 it ( "should throw error if skill not found in repository" , async ( ) => {
288337 ( mockedFs . pathExists as any ) . mockResolvedValue ( false ) ;
289338
0 commit comments