revert(pi): reset carried vendored source deltas

This commit is contained in:
2026-09-14 10:57:14 -04:00
parent b6613b3a04
commit aac222bee1
2 changed files with 48 additions and 43 deletions

View File

@@ -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,
);
}

View File

@@ -72,8 +72,8 @@ const TOOLS: Record<string, ToolConfig> = {
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;
}