@@ -13,7 +13,7 @@ import { discoverAgents } from "@oh-my-pi/pi-coding-agent/task/discovery";
1313import "@oh-my-pi/pi-coding-agent/discovery/claude-plugins" ;
1414import type { Skill } from "@oh-my-pi/pi-coding-agent/capability/skill" ;
1515import type { SlashCommand } from "@oh-my-pi/pi-coding-agent/capability/slash-command" ;
16-
16+ import { getAgentDir , getConfigDirName , setAgentDir } from "@oh-my-pi/pi-utils" ;
1717describe ( "parseClaudePluginsRegistry" , ( ) => {
1818 test ( "parses valid registry" , ( ) => {
1919 const content = JSON . stringify ( {
@@ -60,25 +60,36 @@ describe("parseClaudePluginsRegistry", () => {
6060describe ( "listClaudePluginRoots" , ( ) => {
6161 let tempDir : string ;
6262 let originalHome : string | undefined ;
63-
63+ let originalAgentDir : string ;
64+ let originalXdgDataHome : string | undefined ;
6465 beforeEach ( async ( ) => {
6566 clearClaudePluginRootsCache ( ) ;
6667 clearFsCache ( ) ;
6768 originalHome = process . env . HOME ;
69+ originalAgentDir = getAgentDir ( ) ;
70+ originalXdgDataHome = process . env . XDG_DATA_HOME ;
71+ delete process . env . XDG_DATA_HOME ;
6872 tempDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "claude-plugins-test-" ) ) ;
6973 process . env . HOME = tempDir ;
7074 vi . spyOn ( os , "homedir" ) . mockReturnValue ( tempDir ) ;
75+ setAgentDir ( path . join ( tempDir , getConfigDirName ( ) , "agent" ) ) ;
7176 } ) ;
7277
7378 afterEach ( async ( ) => {
7479 clearClaudePluginRootsCache ( ) ;
7580 clearFsCache ( ) ;
7681 vi . restoreAllMocks ( ) ;
82+ setAgentDir ( originalAgentDir ) ;
7783 if ( originalHome === undefined ) {
7884 delete process . env . HOME ;
7985 } else {
8086 process . env . HOME = originalHome ;
8187 }
88+ if ( originalXdgDataHome === undefined ) {
89+ delete process . env . XDG_DATA_HOME ;
90+ } else {
91+ process . env . XDG_DATA_HOME = originalXdgDataHome ;
92+ }
8293 await fs . rm ( tempDir , { recursive : true , force : true } ) ;
8394 } ) ;
8495
0 commit comments