@pi-stef/superpowers-adapter 0.3.5 → 0.3.7
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/README.md +3 -0
- package/package.json +1 -1
- package/src/tools/skill.ts +54 -19
package/README.md
CHANGED
|
@@ -64,6 +64,9 @@ Load skill instructions by name. Discovers skills from standard pi skill directo
|
|
|
64
64
|
- `<cwd>/.agents/skills/`
|
|
65
65
|
- `~/.pi/agent/skills/`
|
|
66
66
|
- `~/.agents/skills/`
|
|
67
|
+
- Workspace packages: `<cwd>/packages/<pkg>/skills/`
|
|
68
|
+
- Locally installed packages: `<cwd>/node_modules/<pkg>/skills/` (any scope)
|
|
69
|
+
- Globally installed packages: `~/.pi/agent/npm/node_modules/<pkg>/skills/` (any scope)
|
|
67
70
|
- Recursively under `~/.pi/agent/git/` (depth 10)
|
|
68
71
|
|
|
69
72
|
**Limitation:** The YAML frontmatter parser handles simple `key: value` pairs only. Nested values, multi-line values, and quoted strings with complex escaping are not supported.
|
package/package.json
CHANGED
package/src/tools/skill.ts
CHANGED
|
@@ -94,11 +94,54 @@ function findSkillsDirs(
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Collect `skills/` directories from a node_modules layout.
|
|
99
|
+
* Handles scoped (@scope/pkg) and unscoped (pkg) packages.
|
|
100
|
+
*/
|
|
101
|
+
function collectNodeModulesSkillPaths(
|
|
102
|
+
nodeModulesDir: string,
|
|
103
|
+
skillPaths: string[],
|
|
104
|
+
): void {
|
|
105
|
+
if (!existsSync(nodeModulesDir)) return;
|
|
106
|
+
let entries;
|
|
107
|
+
try {
|
|
108
|
+
entries = readdirSync(nodeModulesDir, { withFileTypes: true });
|
|
109
|
+
} catch {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
for (const entry of entries) {
|
|
113
|
+
if (!entry.isDirectory()) continue;
|
|
114
|
+
if (entry.name.startsWith("@")) {
|
|
115
|
+
// Scope directory: iterate packages one level deeper.
|
|
116
|
+
const scopeDir = join(nodeModulesDir, entry.name);
|
|
117
|
+
let scopedEntries;
|
|
118
|
+
try {
|
|
119
|
+
scopedEntries = readdirSync(scopeDir, { withFileTypes: true });
|
|
120
|
+
} catch {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
for (const pkg of scopedEntries) {
|
|
124
|
+
if (!pkg.isDirectory()) continue;
|
|
125
|
+
const pkgSkillsDir = join(scopeDir, pkg.name, "skills");
|
|
126
|
+
if (existsSync(pkgSkillsDir)) {
|
|
127
|
+
skillPaths.push(pkgSkillsDir);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
// Unscoped package directory.
|
|
132
|
+
const pkgSkillsDir = join(nodeModulesDir, entry.name, "skills");
|
|
133
|
+
if (existsSync(pkgSkillsDir)) {
|
|
134
|
+
skillPaths.push(pkgSkillsDir);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function discoverSkills(cwd: string, homeDir?: string): Map<string, SkillMeta> {
|
|
98
141
|
if (skillCache) return skillCache;
|
|
99
142
|
|
|
100
143
|
const skills = new Map<string, SkillMeta>();
|
|
101
|
-
const home = homedir();
|
|
144
|
+
const home = homeDir ?? homedir();
|
|
102
145
|
|
|
103
146
|
const skillPaths = [
|
|
104
147
|
join(cwd, ".pi", "skills"),
|
|
@@ -125,23 +168,15 @@ export function discoverSkills(cwd: string): Map<string, SkillMeta> {
|
|
|
125
168
|
}
|
|
126
169
|
}
|
|
127
170
|
|
|
128
|
-
// Add installed package skills (node_modules pattern)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
skillPaths.push(pkgSkillsDir);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
} catch {
|
|
142
|
-
// Skip if can't read node_modules directory
|
|
143
|
-
}
|
|
144
|
-
}
|
|
171
|
+
// Add locally installed package skills (node_modules pattern), any scope.
|
|
172
|
+
collectNodeModulesSkillPaths(join(cwd, "node_modules"), skillPaths);
|
|
173
|
+
|
|
174
|
+
// Add globally installed package skills (~/.pi/agent/npm/node_modules pattern).
|
|
175
|
+
// This is where `pi install`/catalog packages live on consumer machines.
|
|
176
|
+
collectNodeModulesSkillPaths(
|
|
177
|
+
join(home, ".pi", "agent", "npm", "node_modules"),
|
|
178
|
+
skillPaths,
|
|
179
|
+
);
|
|
145
180
|
|
|
146
181
|
const gitPackagesDir = join(home, ".pi", "agent", "git");
|
|
147
182
|
if (existsSync(gitPackagesDir)) {
|