@@ -3,11 +3,13 @@ import { mkdtemp, rm, mkdir, writeFile, symlink } from 'node:fs/promises';
33import { tmpdir } from 'node:os' ;
44import { join } from 'node:path' ;
55import { dump } from 'js-yaml' ;
6+ import { stubHomeDir } from '../../helpers/env.js' ;
67import {
78 getAllSkillsFromPlugins ,
89 discoverNestedSkillEntries ,
910 type SkillInfo ,
1011} from '../../../src/core/skills.js' ;
12+ import { resetFetchCache } from '../../../src/core/plugin.js' ;
1113import { getPluginCachePath } from '../../../src/utils/plugin-path.js' ;
1214
1315describe ( 'getAllSkillsFromPlugins' , ( ) => {
@@ -224,23 +226,33 @@ describe('getAllSkillsFromPlugins', () => {
224226 } ) ;
225227
226228 it ( 'skips GitHub URL entries whose subpath no longer exists in cache' , async ( ) => {
227- const originalHome = process . env . HOME ;
228- process . env . HOME = tmpDir ;
229+ const restoreHomeDir = stubHomeDir ( tmpDir ) ;
230+ resetFetchCache ( ) ;
229231 try {
230232 const cachePath = getPluginCachePath ( 'owner' , 'repo' , 'main' ) ;
231- await mkdir ( cachePath , { recursive : true } ) ;
233+ const siblingPath = join ( cachePath , 'available' ) ;
234+ await mkdir ( siblingPath , { recursive : true } ) ;
235+ await writeFile ( join ( siblingPath , 'SKILL.md' ) , '# Cached sibling' ) ;
236+
237+ const missingSource = 'https://github.com/owner/repo/tree/main/missing/path' ;
238+ const siblingSource = 'https://github.com/owner/repo/tree/main/available' ;
232239
233240 const config = {
234241 repositories : [ ] ,
235- plugins : [ 'https://github.com/owner/repo/tree/main/missing/path' ] ,
242+ plugins : [ missingSource , siblingSource ] ,
236243 clients : [ 'claude' ] ,
237244 } ;
238245 await writeFile ( join ( tmpDir , '.allagents/workspace.yaml' ) , dump ( config ) ) ;
239246
240247 const skills = await getAllSkillsFromPlugins ( tmpDir ) ;
241- expect ( skills ) . toEqual ( [ ] ) ;
248+ expect (
249+ skills . map ( ( { name, pluginSource, path } ) => ( { name, pluginSource, path } ) ) ,
250+ ) . toEqual ( [
251+ { name : 'available' , pluginSource : siblingSource , path : siblingPath } ,
252+ ] ) ;
242253 } finally {
243- process . env . HOME = originalHome ;
254+ restoreHomeDir ( ) ;
255+ resetFetchCache ( ) ;
244256 }
245257 } ) ;
246258} ) ;
0 commit comments