@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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-stef/superpowers-adapter",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Bridges the superpowers skill system to pi's extension API with TodoWrite, Task, and Skill tools.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -94,11 +94,54 @@ function findSkillsDirs(
94
94
  }
95
95
  }
96
96
 
97
- export function discoverSkills(cwd: string): Map<string, SkillMeta> {
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
- const nodeModulesDir = join(cwd, "node_modules", "@pi-stef");
130
- if (existsSync(nodeModulesDir)) {
131
- try {
132
- const packages = readdirSync(nodeModulesDir, { withFileTypes: true });
133
- for (const pkg of packages) {
134
- if (pkg.isDirectory()) {
135
- const pkgSkillsDir = join(nodeModulesDir, pkg.name, "skills");
136
- if (existsSync(pkgSkillsDir)) {
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)) {