@pi-stef/superpowers-adapter 0.3.4 → 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 +73 -2
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"),
|
|
@@ -107,6 +150,34 @@ export function discoverSkills(cwd: string): Map<string, SkillMeta> {
|
|
|
107
150
|
join(home, ".agents", "skills"),
|
|
108
151
|
];
|
|
109
152
|
|
|
153
|
+
// Add workspace package skills (monorepo pattern)
|
|
154
|
+
const packagesDir = join(cwd, "packages");
|
|
155
|
+
if (existsSync(packagesDir)) {
|
|
156
|
+
try {
|
|
157
|
+
const packages = readdirSync(packagesDir, { withFileTypes: true });
|
|
158
|
+
for (const pkg of packages) {
|
|
159
|
+
if (pkg.isDirectory()) {
|
|
160
|
+
const pkgSkillsDir = join(packagesDir, pkg.name, "skills");
|
|
161
|
+
if (existsSync(pkgSkillsDir)) {
|
|
162
|
+
skillPaths.push(pkgSkillsDir);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
} catch {
|
|
167
|
+
// Skip if can't read packages directory
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
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
|
+
);
|
|
180
|
+
|
|
110
181
|
const gitPackagesDir = join(home, ".pi", "agent", "git");
|
|
111
182
|
if (existsSync(gitPackagesDir)) {
|
|
112
183
|
findSkillsDirs(gitPackagesDir, skillPaths);
|