From aac222bee1d2f3df0a5458713427389901908445 Mon Sep 17 00:00:00 2001 From: alexion Date: Mon, 14 Sep 2026 10:57:14 -0400 Subject: [PATCH] revert(pi): reset carried vendored source deltas --- .../coding-agent/src/core/package-manager.ts | 85 ++++++++++--------- .../coding-agent/src/utils/tools-manager.ts | 6 +- 2 files changed, 48 insertions(+), 43 deletions(-) diff --git a/third_party/pi/packages/coding-agent/src/core/package-manager.ts b/third_party/pi/packages/coding-agent/src/core/package-manager.ts index dc57e09..d65386c 100644 --- a/third_party/pi/packages/coding-agent/src/core/package-manager.ts +++ b/third_party/pi/packages/coding-agent/src/core/package-manager.ts @@ -459,14 +459,14 @@ function findGitRepoRoot(startDir: string): string | null { } } -function collectAncestorConfigDirs(startDir: string, configDirName: string): string[] { - const configDirs: string[] = []; +function collectAncestorAgentsSkillDirs(startDir: string): string[] { + const skillDirs: string[] = []; const resolvedStartDir = resolve(startDir); const gitRepoRoot = findGitRepoRoot(resolvedStartDir); let dir = resolvedStartDir; while (true) { - configDirs.push(join(dir, configDirName)); + skillDirs.push(join(dir, ".agents", "skills")); if (gitRepoRoot && dir === gitRepoRoot) { break; } @@ -477,7 +477,7 @@ function collectAncestorConfigDirs(startDir: string, configDirName: string): str dir = parent; } - return configDirs; + return skillDirs; } function collectAutoPromptEntries(dir: string): string[] { @@ -2388,13 +2388,16 @@ export class DefaultPackageManager implements PackageManager { prompts: join(globalBaseDir, "prompts"), themes: join(globalBaseDir, "themes"), }; + const projectDirs = { + extensions: join(projectBaseDir, "extensions"), + skills: join(projectBaseDir, "skills"), + prompts: join(projectBaseDir, "prompts"), + themes: join(projectBaseDir, "themes"), + }; const userAgentsSkillsDir = join(getHomeDir(), ".agents", "skills"); const projectTrusted = this.settingsManager.isProjectTrusted(); - const projectConfigDirs = projectTrusted - ? collectAncestorConfigDirs(this.cwd, CONFIG_DIR_NAME).filter((dir) => resolve(dir) !== resolve(globalBaseDir)) - : []; - const projectAgentsDirs = projectTrusted - ? collectAncestorConfigDirs(this.cwd, ".agents").filter((dir) => resolve(dir) !== resolve(dirname(userAgentsSkillsDir))) + const projectAgentsSkillDirs = projectTrusted + ? collectAncestorAgentsSkillDirs(this.cwd).filter((dir) => resolve(dir) !== resolve(userAgentsSkillsDir)) : []; const addResources = ( @@ -2411,54 +2414,56 @@ export class DefaultPackageManager implements PackageManager { } }; - // Project resources from .pi/ in cwd and ancestors. - for (const configDir of projectConfigDirs) { - const configMetadata: PathMetadata = { - ...projectMetadata, - baseDir: configDir, - }; + if (projectTrusted) { + // Project extensions from .pi/ addResources( "extensions", - collectAutoExtensionEntries(join(configDir, "extensions")), - configMetadata, + collectAutoExtensionEntries(projectDirs.extensions), + projectMetadata, projectOverrides.extensions, - configDir, + projectBaseDir, ); + + // Project skills from .pi/ addResources( "skills", - collectAutoSkillEntries(join(configDir, "skills"), "pi"), - configMetadata, + collectAutoSkillEntries(projectDirs.skills, "pi"), + projectMetadata, projectOverrides.skills, - configDir, - ); - addResources( - "prompts", - collectAutoPromptEntries(join(configDir, "prompts")), - configMetadata, - projectOverrides.prompts, - configDir, - ); - addResources( - "themes", - collectAutoThemeEntries(join(configDir, "themes")), - configMetadata, - projectOverrides.themes, - configDir, + projectBaseDir, ); } - // Project skills from .agents/ in cwd and ancestors. - for (const agentsDir of projectAgentsDirs) { + // Project skills from .agents/ (each with its own baseDir) + for (const agentsSkillsDir of projectAgentsSkillDirs) { + const agentsBaseDir = dirname(agentsSkillsDir); // the .agents directory const agentsMetadata: PathMetadata = { ...projectMetadata, - baseDir: agentsDir, + baseDir: agentsBaseDir, }; addResources( "skills", - collectAutoSkillEntries(join(agentsDir, "skills"), "agents"), + collectAutoSkillEntries(agentsSkillsDir, "agents"), agentsMetadata, projectOverrides.skills, - agentsDir, + agentsBaseDir, + ); + } + + if (projectTrusted) { + addResources( + "prompts", + collectAutoPromptEntries(projectDirs.prompts), + projectMetadata, + projectOverrides.prompts, + projectBaseDir, + ); + addResources( + "themes", + collectAutoThemeEntries(projectDirs.themes), + projectMetadata, + projectOverrides.themes, + projectBaseDir, ); } diff --git a/third_party/pi/packages/coding-agent/src/utils/tools-manager.ts b/third_party/pi/packages/coding-agent/src/utils/tools-manager.ts index 2bcca47..f040f52 100644 --- a/third_party/pi/packages/coding-agent/src/utils/tools-manager.ts +++ b/third_party/pi/packages/coding-agent/src/utils/tools-manager.ts @@ -72,8 +72,8 @@ const TOOLS: Record = { function commandExists(cmd: string): boolean { try { const result = spawnSync(cmd, ["--version"], { stdio: "pipe" }); - // Downloaded generic Linux binaries can exist but fail on NixOS before they print a version. - return (result.error === undefined || result.error === null) && result.status === 0; + // Check for ENOENT error (command not found) + return result.error === undefined || result.error === null; } catch { return false; } @@ -86,7 +86,7 @@ export function getToolPath(tool: "fd" | "rg"): string | null { // Check our tools directory first const localPath = join(TOOLS_DIR, config.binaryName + (platform() === "win32" ? ".exe" : "")); - if (existsSync(localPath) && commandExists(localPath)) { + if (existsSync(localPath)) { return localPath; }