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[] { function collectAncestorAgentsSkillDirs(startDir: string): string[] {
const configDirs: string[] = []; const skillDirs: string[] = [];
const resolvedStartDir = resolve(startDir); const resolvedStartDir = resolve(startDir);
const gitRepoRoot = findGitRepoRoot(resolvedStartDir); const gitRepoRoot = findGitRepoRoot(resolvedStartDir);
let dir = resolvedStartDir; let dir = resolvedStartDir;
while (true) { while (true) {
configDirs.push(join(dir, configDirName)); skillDirs.push(join(dir, ".agents", "skills"));
if (gitRepoRoot && dir === gitRepoRoot) { if (gitRepoRoot && dir === gitRepoRoot) {
break; break;
} }
@@ -477,7 +477,7 @@ function collectAncestorConfigDirs(startDir: string, configDirName: string): str
dir = parent; dir = parent;
} }
return configDirs; return skillDirs;
} }
function collectAutoPromptEntries(dir: string): string[] { function collectAutoPromptEntries(dir: string): string[] {
@@ -2388,13 +2388,16 @@ export class DefaultPackageManager implements PackageManager {
prompts: join(globalBaseDir, "prompts"), prompts: join(globalBaseDir, "prompts"),
themes: join(globalBaseDir, "themes"), 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 userAgentsSkillsDir = join(getHomeDir(), ".agents", "skills");
const projectTrusted = this.settingsManager.isProjectTrusted(); const projectTrusted = this.settingsManager.isProjectTrusted();
const projectConfigDirs = projectTrusted const projectAgentsSkillDirs = projectTrusted
? collectAncestorConfigDirs(this.cwd, CONFIG_DIR_NAME).filter((dir) => resolve(dir) !== resolve(globalBaseDir)) ? collectAncestorAgentsSkillDirs(this.cwd).filter((dir) => resolve(dir) !== resolve(userAgentsSkillsDir))
: [];
const projectAgentsDirs = projectTrusted
? collectAncestorConfigDirs(this.cwd, ".agents").filter((dir) => resolve(dir) !== resolve(dirname(userAgentsSkillsDir)))
: []; : [];
const addResources = ( const addResources = (
@@ -2411,54 +2414,56 @@ export class DefaultPackageManager implements PackageManager {
} }
}; };
// Project resources from .pi/ in cwd and ancestors. if (projectTrusted) {
for (const configDir of projectConfigDirs) { // Project extensions from .pi/
const configMetadata: PathMetadata = {
...projectMetadata,
baseDir: configDir,
};
addResources( addResources(
"extensions", "extensions",
collectAutoExtensionEntries(join(configDir, "extensions")), collectAutoExtensionEntries(projectDirs.extensions),
configMetadata, projectMetadata,
projectOverrides.extensions, projectOverrides.extensions,
configDir, projectBaseDir,
); );
// Project skills from .pi/
addResources( addResources(
"skills", "skills",
collectAutoSkillEntries(join(configDir, "skills"), "pi"), collectAutoSkillEntries(projectDirs.skills, "pi"),
configMetadata, projectMetadata,
projectOverrides.skills, projectOverrides.skills,
configDir, projectBaseDir,
);
addResources(
"prompts",
collectAutoPromptEntries(join(configDir, "prompts")),
configMetadata,
projectOverrides.prompts,
configDir,
);
addResources(
"themes",
collectAutoThemeEntries(join(configDir, "themes")),
configMetadata,
projectOverrides.themes,
configDir,
); );
} }
// Project skills from .agents/ in cwd and ancestors. // Project skills from .agents/ (each with its own baseDir)
for (const agentsDir of projectAgentsDirs) { for (const agentsSkillsDir of projectAgentsSkillDirs) {
const agentsBaseDir = dirname(agentsSkillsDir); // the .agents directory
const agentsMetadata: PathMetadata = { const agentsMetadata: PathMetadata = {
...projectMetadata, ...projectMetadata,
baseDir: agentsDir, baseDir: agentsBaseDir,
}; };
addResources( addResources(
"skills", "skills",
collectAutoSkillEntries(join(agentsDir, "skills"), "agents"), collectAutoSkillEntries(agentsSkillsDir, "agents"),
agentsMetadata, agentsMetadata,
projectOverrides.skills, 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 { function commandExists(cmd: string): boolean {
try { try {
const result = spawnSync(cmd, ["--version"], { stdio: "pipe" }); const result = spawnSync(cmd, ["--version"], { stdio: "pipe" });
// Downloaded generic Linux binaries can exist but fail on NixOS before they print a version. // Check for ENOENT error (command not found)
return (result.error === undefined || result.error === null) && result.status === 0; return result.error === undefined || result.error === null;
} catch { } catch {
return false; return false;
} }
@@ -86,7 +86,7 @@ export function getToolPath(tool: "fd" | "rg"): string | null {
// Check our tools directory first // Check our tools directory first
const localPath = join(TOOLS_DIR, config.binaryName + (platform() === "win32" ? ".exe" : "")); const localPath = join(TOOLS_DIR, config.binaryName + (platform() === "win32" ? ".exe" : ""));
if (existsSync(localPath) && commandExists(localPath)) { if (existsSync(localPath)) {
return localPath; return localPath;
} }