fix(project): use directory param instead of process.cwd() for agents, commands, and slash commands

Extends the process.cwd() fix to cover all project-level loaders. In the desktop app, process.cwd() points to the app installation directory instead of the project directory, causing project-level agents, commands, and slash commands to not be discovered. Each function now accepts an optional directory parameter (defaulting to process.cwd() for backward compatibility) and callers pass ctx.directory from the plugin context.
This commit is contained in:
Willy
2026-02-13 11:09:35 +08:00
parent 6914f2fd04
commit f9ea9a4ee9
6 changed files with 18 additions and 18 deletions

View File

@@ -78,8 +78,8 @@ export function loadUserAgents(): Record<string, AgentConfig> {
return result
}
export function loadProjectAgents(): Record<string, AgentConfig> {
const projectAgentsDir = join(process.cwd(), ".claude", "agents")
export function loadProjectAgents(directory?: string): Record<string, AgentConfig> {
const projectAgentsDir = join(directory ?? process.cwd(), ".claude", "agents")
const agents = loadAgentsFromDir(projectAgentsDir, "project")
const result: Record<string, AgentConfig> = {}