@henryqw/pi-add-dir 3.2.2 → 3.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/add-dir-helpers.ts +3 -3
- package/extensions/add-dir.ts +11 -16
- package/package.json +1 -1
|
@@ -11,14 +11,14 @@ export interface AddedDir {
|
|
|
11
11
|
export interface DirContext {
|
|
12
12
|
agentsMd: string | null;
|
|
13
13
|
claudeMd: string | null;
|
|
14
|
-
skills:
|
|
14
|
+
skills: string[];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const CONTEXT_FILES = ["AGENTS.md", "CLAUDE.md"] as const;
|
|
18
18
|
const SKILL_DIRS = [".pi/skills", ".agents/skills", ".claude/skills"] as const;
|
|
19
19
|
const SKIPPED_SEARCH_DIRS = new Set([".git", "node_modules"]);
|
|
20
20
|
|
|
21
|
-
function isMissingPathError(error: unknown): boolean {
|
|
21
|
+
export function isMissingPathError(error: unknown): boolean {
|
|
22
22
|
if (!error || typeof error !== "object" || !("code" in error)) return false;
|
|
23
23
|
return error.code === "ENOENT" || error.code === "ENOTDIR";
|
|
24
24
|
}
|
|
@@ -95,7 +95,7 @@ export function scanDirContext(dir: string): DirContext {
|
|
|
95
95
|
return {
|
|
96
96
|
agentsMd: readContextFile(dir, "AGENTS.md"),
|
|
97
97
|
claudeMd: readContextFile(dir, "CLAUDE.md"),
|
|
98
|
-
skills:
|
|
98
|
+
skills: skillFiles(dir).map(({ name }) => name),
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
|
package/extensions/add-dir.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
collectSkillPaths,
|
|
17
17
|
dirExists,
|
|
18
18
|
findFiles,
|
|
19
|
+
isMissingPathError,
|
|
19
20
|
resolveDir,
|
|
20
21
|
scanDirContext,
|
|
21
22
|
type AddedDir,
|
|
@@ -129,9 +130,7 @@ function hasGitMarker(cwd: string): boolean {
|
|
|
129
130
|
lstatSync(join(directory, ".git"));
|
|
130
131
|
return true;
|
|
131
132
|
} catch (error) {
|
|
132
|
-
if (!
|
|
133
|
-
throw error;
|
|
134
|
-
}
|
|
133
|
+
if (!isMissingPathError(error)) throw error;
|
|
135
134
|
}
|
|
136
135
|
const parent = dirname(directory);
|
|
137
136
|
if (parent === directory) return false;
|
|
@@ -148,20 +147,11 @@ function overlaps(a: string, b: string): boolean {
|
|
|
148
147
|
return isWithinDir(a, b) || isWithinDir(b, a);
|
|
149
148
|
}
|
|
150
149
|
|
|
151
|
-
function contextDetails(dirCtx: DirContext, absolutePath: string): AddDirectoryDetails {
|
|
152
|
-
return {
|
|
153
|
-
directory: absolutePath,
|
|
154
|
-
hasAgentsMd: dirCtx.agentsMd !== null,
|
|
155
|
-
hasClaudeMd: dirCtx.claudeMd !== null,
|
|
156
|
-
skillNames: [...dirCtx.skills],
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
150
|
function contextSummary(dirCtx: DirContext): string {
|
|
161
151
|
const found: string[] = [];
|
|
162
152
|
if (dirCtx.agentsMd !== null) found.push("AGENTS.md");
|
|
163
153
|
if (dirCtx.claudeMd !== null) found.push("CLAUDE.md");
|
|
164
|
-
if (dirCtx.skills.
|
|
154
|
+
if (dirCtx.skills.length > 0) found.push(`${dirCtx.skills.length} skill(s)`);
|
|
165
155
|
return found.length > 0 ? ` Found: ${found.join(", ")}.` : " No context files found.";
|
|
166
156
|
}
|
|
167
157
|
|
|
@@ -614,15 +604,20 @@ export default function addDirExtension(pi: ExtensionAPI, options: ExtensionOpti
|
|
|
614
604
|
if (context.claudeMd !== null) {
|
|
615
605
|
response.push(`\nCLAUDE.md instructions from ${absolutePath}:\n${context.claudeMd}`);
|
|
616
606
|
}
|
|
617
|
-
if (context.skills.
|
|
618
|
-
response.push(`\nDiscovered skills: ${
|
|
607
|
+
if (context.skills.length > 0) {
|
|
608
|
+
response.push(`\nDiscovered skills: ${context.skills.join(", ")}`);
|
|
619
609
|
}
|
|
620
610
|
if (result.resourcesChanged) response.push("Run /reload to update external skills.");
|
|
621
611
|
response.push(`\nYou can now access files at: ${absolutePath}`);
|
|
622
612
|
|
|
623
613
|
return {
|
|
624
614
|
content: [{ type: "text", text: response.join("\n") }],
|
|
625
|
-
details:
|
|
615
|
+
details: {
|
|
616
|
+
directory: absolutePath,
|
|
617
|
+
hasAgentsMd: context.agentsMd !== null,
|
|
618
|
+
hasClaudeMd: context.claudeMd !== null,
|
|
619
|
+
skillNames: context.skills,
|
|
620
|
+
} satisfies AddDirectoryDetails,
|
|
626
621
|
};
|
|
627
622
|
},
|
|
628
623
|
|