@workingpayload/agent-skills 2.0.2 → 2.2.0
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/AuthorGuard/skill.md +110 -0
- package/README.md +29 -15
- package/bin/cli.js +533 -439
- package/package.json +44 -42
- package/scripts/doctor.py +548 -542
- package/scripts/install.py +486 -437
- package/skills-routing.json +28 -2
- package/skills.json +68 -2
package/bin/cli.js
CHANGED
|
@@ -1,439 +1,533 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { execSync, spawnSync } = require("child_process");
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const os = require("os");
|
|
7
|
-
|
|
8
|
-
// ── Resolve paths ──────────────────────────────────────────────────
|
|
9
|
-
const PKG_ROOT = path.resolve(__dirname, "..");
|
|
10
|
-
const SCRIPTS_DIR = path.join(PKG_ROOT, "scripts");
|
|
11
|
-
const HOME = os.homedir();
|
|
12
|
-
|
|
13
|
-
const TARGETS = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync, spawnSync } = require("child_process");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const os = require("os");
|
|
7
|
+
|
|
8
|
+
// ── Resolve paths ──────────────────────────────────────────────────
|
|
9
|
+
const PKG_ROOT = path.resolve(__dirname, "..");
|
|
10
|
+
const SCRIPTS_DIR = path.join(PKG_ROOT, "scripts");
|
|
11
|
+
const HOME = os.homedir();
|
|
12
|
+
|
|
13
|
+
const TARGETS = {
|
|
14
|
+
agents: {
|
|
15
|
+
label: "Agent Skills compatible CLIs",
|
|
16
|
+
installDir: path.join(HOME, ".agents", "skills"),
|
|
17
|
+
},
|
|
18
|
+
claude: {
|
|
19
|
+
label: "Claude Code",
|
|
20
|
+
installDir: path.join(HOME, ".claude", "skills"),
|
|
21
|
+
},
|
|
22
|
+
copilot: {
|
|
23
|
+
label: "GitHub Copilot CLI",
|
|
24
|
+
installDir: path.join(HOME, ".copilot", "skills"),
|
|
25
|
+
},
|
|
26
|
+
codex: {
|
|
27
|
+
label: "OpenAI Codex CLI",
|
|
28
|
+
installDir: path.join(HOME, ".codex", "skills"),
|
|
29
|
+
},
|
|
30
|
+
gemini: {
|
|
31
|
+
label: "Gemini CLI",
|
|
32
|
+
installDir: path.join(HOME, ".gemini", "skills"),
|
|
33
|
+
},
|
|
34
|
+
antigravity: {
|
|
35
|
+
label: "Google Antigravity",
|
|
36
|
+
installDir: path.join(HOME, ".gemini", "antigravity", "skills"),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const TARGET_NAMES = Object.keys(TARGETS);
|
|
40
|
+
const CANONICAL_TARGET = "agents";
|
|
41
|
+
|
|
42
|
+
// ── Helpers ────────────────────────────────────────────────────────
|
|
43
|
+
function hasPython() {
|
|
44
|
+
for (const cmd of ["python3", "python"]) {
|
|
45
|
+
try {
|
|
46
|
+
execSync(`${cmd} --version`, { stdio: "ignore" });
|
|
47
|
+
return cmd;
|
|
48
|
+
} catch (_) {}
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function runPythonScript(scriptName, args = []) {
|
|
54
|
+
const py = hasPython();
|
|
55
|
+
if (!py) {
|
|
56
|
+
console.error("Error: Python 3 is required but not found in PATH.");
|
|
57
|
+
console.error("Install Python 3: https://python.org/downloads/");
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
const scriptPath = path.join(SCRIPTS_DIR, scriptName);
|
|
61
|
+
if (!fs.existsSync(scriptPath)) {
|
|
62
|
+
console.error(`Error: Script not found: ${scriptPath}`);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
const result = spawnSync(py, [scriptPath, ...args], {
|
|
66
|
+
stdio: "inherit",
|
|
67
|
+
cwd: PKG_ROOT,
|
|
68
|
+
});
|
|
69
|
+
process.exit(result.status || 0);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function findSkillFiles() {
|
|
73
|
+
const skills = [];
|
|
74
|
+
const entries = fs.readdirSync(PKG_ROOT, { withFileTypes: true });
|
|
75
|
+
for (const entry of entries) {
|
|
76
|
+
if (!entry.isDirectory() || entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "bin" || entry.name === "scripts") continue;
|
|
77
|
+
const dir = path.join(PKG_ROOT, entry.name);
|
|
78
|
+
for (const fname of ["skill.md", "SKILL.md"]) {
|
|
79
|
+
const fpath = path.join(dir, fname);
|
|
80
|
+
if (fs.existsSync(fpath)) {
|
|
81
|
+
skills.push({ name: entry.name, file: fname, fullPath: fpath, dir: entry.name });
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return skills;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function slugify(name) {
|
|
90
|
+
return name.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function copyDirSync(src, dest) {
|
|
94
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
95
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
96
|
+
const srcPath = path.join(src, entry.name);
|
|
97
|
+
const destPath = path.join(dest, entry.name);
|
|
98
|
+
if (entry.isDirectory()) {
|
|
99
|
+
copyDirSync(srcPath, destPath);
|
|
100
|
+
} else {
|
|
101
|
+
fs.copyFileSync(srcPath, destPath);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function resolveTargets(value, defaultToAll = true) {
|
|
107
|
+
const requested = value
|
|
108
|
+
? value.split(",").map(target => target.trim().toLowerCase()).filter(Boolean)
|
|
109
|
+
: (defaultToAll ? ["all"] : ["claude"]);
|
|
110
|
+
const targets = requested.includes("all") ? TARGET_NAMES : [...new Set(requested)];
|
|
111
|
+
const unknown = targets.filter(target => !TARGETS[target]);
|
|
112
|
+
if (unknown.length > 0) {
|
|
113
|
+
console.error(`Unknown target(s): ${unknown.join(", ")}.`);
|
|
114
|
+
console.error(`Use "all" or a comma-separated list of: ${TARGET_NAMES.join(", ")}.`);
|
|
115
|
+
process.exit(2);
|
|
116
|
+
}
|
|
117
|
+
return targets;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function skillPath(installDir, slug) {
|
|
121
|
+
return path.join(installDir, slug, "SKILL.md");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function pathEntryExists(entryPath) {
|
|
125
|
+
try {
|
|
126
|
+
fs.lstatSync(entryPath);
|
|
127
|
+
return true;
|
|
128
|
+
} catch (err) {
|
|
129
|
+
if (err.code === "ENOENT") return false;
|
|
130
|
+
throw err;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function installCanonicalSkills(skills, options) {
|
|
135
|
+
const { installDir } = TARGETS[CANONICAL_TARGET];
|
|
136
|
+
const { dryRun, force, validate } = options;
|
|
137
|
+
|
|
138
|
+
if (!dryRun) {
|
|
139
|
+
fs.mkdirSync(installDir, { recursive: true });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
console.log("\nCanonical skill store");
|
|
143
|
+
|
|
144
|
+
let installed = 0, skipped = 0, failed = 0;
|
|
145
|
+
const meta = loadMeta(installDir);
|
|
146
|
+
|
|
147
|
+
for (const skill of skills) {
|
|
148
|
+
const slug = slugify(skill.name);
|
|
149
|
+
const destFile = skillPath(installDir, slug);
|
|
150
|
+
if (fs.existsSync(destFile) && !force) {
|
|
151
|
+
console.log(` SKIP ${slug} (already exists, use --force to overwrite)`);
|
|
152
|
+
skipped++;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (validate) {
|
|
157
|
+
const content = fs.readFileSync(skill.fullPath, "utf8");
|
|
158
|
+
const issues = validateSkill(content);
|
|
159
|
+
if (issues.length > 0) {
|
|
160
|
+
console.log(` FAIL ${slug} — validation errors:`);
|
|
161
|
+
issues.forEach(issue => console.log(` - ${issue}`));
|
|
162
|
+
failed++;
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (dryRun) {
|
|
168
|
+
console.log(` Would store ${slug}`);
|
|
169
|
+
installed++;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
const skillDir = path.dirname(destFile);
|
|
175
|
+
fs.mkdirSync(skillDir, { recursive: true });
|
|
176
|
+
fs.copyFileSync(skill.fullPath, destFile);
|
|
177
|
+
const srcDir = path.dirname(skill.fullPath);
|
|
178
|
+
for (const subdir of ["scripts", "references", "assets"]) {
|
|
179
|
+
const srcSub = path.join(srcDir, subdir);
|
|
180
|
+
const destSub = path.join(skillDir, subdir);
|
|
181
|
+
if (fs.existsSync(srcSub) && fs.statSync(srcSub).isDirectory()) {
|
|
182
|
+
fs.rmSync(destSub, { recursive: true, force: true });
|
|
183
|
+
copyDirSync(srcSub, destSub);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
meta[slug] = {
|
|
187
|
+
name: slug,
|
|
188
|
+
source: skill.fullPath,
|
|
189
|
+
filename: path.join(slug, "SKILL.md"),
|
|
190
|
+
installed_at: new Date().toISOString(),
|
|
191
|
+
directory: skill.dir,
|
|
192
|
+
};
|
|
193
|
+
installed++;
|
|
194
|
+
console.log(` OK ${slug}`);
|
|
195
|
+
} catch (err) {
|
|
196
|
+
console.log(` FAIL ${slug} — ${err.message}`);
|
|
197
|
+
failed++;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (!dryRun) {
|
|
202
|
+
saveMeta(installDir, meta);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
console.log(`${installed} installed, ${skipped} skipped, ${failed} failed.`);
|
|
206
|
+
return { installed, skipped, failed };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function linkSkillsToTarget(target, skills, options) {
|
|
210
|
+
const { installDir, label } = TARGETS[target];
|
|
211
|
+
const canonicalDir = TARGETS[CANONICAL_TARGET].installDir;
|
|
212
|
+
const { dryRun, force } = options;
|
|
213
|
+
|
|
214
|
+
if (!dryRun) {
|
|
215
|
+
fs.mkdirSync(installDir, { recursive: true });
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
console.log(`\n${label}`);
|
|
219
|
+
let linked = 0, skipped = 0, failed = 0;
|
|
220
|
+
const meta = loadMeta(installDir);
|
|
221
|
+
|
|
222
|
+
for (const skill of skills) {
|
|
223
|
+
const slug = slugify(skill.name);
|
|
224
|
+
const canonicalSkillDir = path.join(canonicalDir, slug);
|
|
225
|
+
const linkPath = path.join(installDir, slug);
|
|
226
|
+
|
|
227
|
+
if (pathEntryExists(linkPath) && !force) {
|
|
228
|
+
console.log(` SKIP ${slug} (already exists, use --force to replace with a link)`);
|
|
229
|
+
skipped++;
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (dryRun) {
|
|
234
|
+
console.log(` Would link ${slug}`);
|
|
235
|
+
linked++;
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
try {
|
|
240
|
+
if (!fs.existsSync(skillPath(canonicalDir, slug))) {
|
|
241
|
+
throw new Error("canonical skill is missing");
|
|
242
|
+
}
|
|
243
|
+
if (pathEntryExists(linkPath)) {
|
|
244
|
+
fs.rmSync(linkPath, { recursive: true, force: true });
|
|
245
|
+
}
|
|
246
|
+
fs.symlinkSync(
|
|
247
|
+
canonicalSkillDir,
|
|
248
|
+
linkPath,
|
|
249
|
+
process.platform === "win32" ? "junction" : "dir",
|
|
250
|
+
);
|
|
251
|
+
meta[slug] = {
|
|
252
|
+
name: slug,
|
|
253
|
+
source: skill.fullPath,
|
|
254
|
+
filename: path.join(slug, "SKILL.md"),
|
|
255
|
+
linked_from: canonicalSkillDir,
|
|
256
|
+
installed_at: new Date().toISOString(),
|
|
257
|
+
directory: skill.dir,
|
|
258
|
+
};
|
|
259
|
+
linked++;
|
|
260
|
+
console.log(` OK ${slug}`);
|
|
261
|
+
} catch (err) {
|
|
262
|
+
console.log(` FAIL ${slug} — ${err.message}`);
|
|
263
|
+
failed++;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (!dryRun) {
|
|
268
|
+
saveMeta(installDir, meta);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
console.log(`${linked} linked, ${skipped} skipped, ${failed} failed.`);
|
|
272
|
+
return { linked, skipped, failed };
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// ── Commands ───────────────────────────────────────────────────────
|
|
276
|
+
|
|
277
|
+
function cmdInstall(args) {
|
|
278
|
+
const flags = parseFlags(args, { target: "t", skills: "s", force: null, "dry-run": null, validate: null });
|
|
279
|
+
const targets = resolveTargets(flags.target);
|
|
280
|
+
const dryRun = flags["dry-run"] || false;
|
|
281
|
+
const force = flags.force || false;
|
|
282
|
+
|
|
283
|
+
// Find skills
|
|
284
|
+
let skills = findSkillFiles();
|
|
285
|
+
if (flags.skills) {
|
|
286
|
+
const wanted = new Set(flags.skills.split(",").map(s => s.trim().toLowerCase()));
|
|
287
|
+
skills = skills.filter(s => wanted.has(s.name.toLowerCase()) || wanted.has(slugify(s.name)));
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const nativeTargets = targets.filter(target => target !== CANONICAL_TARGET);
|
|
291
|
+
console.log(`Preparing ${skills.length} skill(s) for: ${targets.join(", ")}`);
|
|
292
|
+
if (dryRun) console.log("[DRY RUN — no files will be written]");
|
|
293
|
+
|
|
294
|
+
const stored = installCanonicalSkills(skills, {
|
|
295
|
+
dryRun,
|
|
296
|
+
force,
|
|
297
|
+
validate: flags.validate || false,
|
|
298
|
+
});
|
|
299
|
+
const totals = nativeTargets.reduce((summary, target) => {
|
|
300
|
+
const result = linkSkillsToTarget(target, skills, { dryRun, force });
|
|
301
|
+
summary.linked += result.linked;
|
|
302
|
+
summary.skipped += result.skipped;
|
|
303
|
+
summary.failed += result.failed;
|
|
304
|
+
return summary;
|
|
305
|
+
}, { linked: 0, skipped: 0, failed: 0 });
|
|
306
|
+
|
|
307
|
+
const failed = stored.failed + totals.failed;
|
|
308
|
+
console.log(
|
|
309
|
+
`\nTotal: ${stored.installed} stored, ${totals.linked} linked, ` +
|
|
310
|
+
`${stored.skipped + totals.skipped} skipped, ${failed} failed.`,
|
|
311
|
+
);
|
|
312
|
+
if (!dryRun && (stored.installed > 0 || totals.linked > 0)) {
|
|
313
|
+
console.log("\nSkills are available to supported agents automatically and can be invoked by name.");
|
|
314
|
+
}
|
|
315
|
+
if (failed > 0) {
|
|
316
|
+
process.exitCode = 1;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function cmdUninstall(args) {
|
|
321
|
+
const flags = parseFlags(args, { target: "t" });
|
|
322
|
+
const targets = resolveTargets(flags.target);
|
|
323
|
+
const removalOrder = [
|
|
324
|
+
...targets.filter(target => target !== CANONICAL_TARGET),
|
|
325
|
+
...targets.filter(target => target === CANONICAL_TARGET),
|
|
326
|
+
];
|
|
327
|
+
const names = flags._.filter(n => n !== "uninstall");
|
|
328
|
+
|
|
329
|
+
if (names.length === 0) {
|
|
330
|
+
console.error("Usage: agent-skills uninstall <skill-name> [<skill-name>...] [-t all|claude|copilot|codex|gemini|antigravity|agents]");
|
|
331
|
+
process.exit(2);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
let removed = 0;
|
|
335
|
+
for (const target of removalOrder) {
|
|
336
|
+
const installDir = TARGETS[target].installDir;
|
|
337
|
+
const meta = loadMeta(installDir);
|
|
338
|
+
console.log(`\nTarget: ${TARGETS[target].label} (${target})`);
|
|
339
|
+
for (const name of names) {
|
|
340
|
+
const slug = slugify(name);
|
|
341
|
+
const skillDir = path.join(installDir, slug);
|
|
342
|
+
if (pathEntryExists(skillDir)) {
|
|
343
|
+
fs.rmSync(skillDir, { recursive: true, force: true });
|
|
344
|
+
delete meta[slug];
|
|
345
|
+
console.log(` Removed ${slug}`);
|
|
346
|
+
removed++;
|
|
347
|
+
} else {
|
|
348
|
+
console.log(` Not found: ${slug}`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (fs.existsSync(installDir)) saveMeta(installDir, meta);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
console.log(`\n${removed} skill(s) removed.`);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function cmdList(args) {
|
|
358
|
+
const flags = parseFlags(args, { target: "t" });
|
|
359
|
+
const targets = resolveTargets(flags.target);
|
|
360
|
+
for (const target of targets) {
|
|
361
|
+
const installDir = TARGETS[target].installDir;
|
|
362
|
+
console.log(`\nInstalled skills (${target})`);
|
|
363
|
+
if (!fs.existsSync(installDir)) {
|
|
364
|
+
console.log(" None (directory does not exist).");
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
const entries = Object.values(loadMeta(installDir));
|
|
368
|
+
if (entries.length === 0) {
|
|
369
|
+
console.log(" None.");
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
console.log(" Name Installed At");
|
|
373
|
+
console.log(" " + "-".repeat(60));
|
|
374
|
+
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
375
|
+
const date = entry.installed_at ? entry.installed_at.slice(0, 19).replace("T", " ") : "unknown";
|
|
376
|
+
console.log(` ${entry.name.padEnd(30)} ${date}`);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function cmdDoctor(args) {
|
|
382
|
+
runPythonScript("doctor.py", args);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function cmdRoute(args) {
|
|
386
|
+
runPythonScript("route.py", args);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function cmdValidate(args) {
|
|
390
|
+
runPythonScript("validate.py", args);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function cmdScore(args) {
|
|
394
|
+
runPythonScript("score.py", args);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function cmdTest(args) {
|
|
398
|
+
runPythonScript("test_skill.py", args);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function cmdBuildIndex(args) {
|
|
402
|
+
runPythonScript("build_index.py", args);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function cmdHelp() {
|
|
406
|
+
console.log(`
|
|
407
|
+
agent-skills — portable AI skills for Copilot, Claude, Codex, Gemini, and other agents
|
|
408
|
+
|
|
409
|
+
Usage:
|
|
410
|
+
agent-skills <command> [options]
|
|
411
|
+
|
|
412
|
+
Commands:
|
|
413
|
+
install Store skills once and link them into supported AI CLIs
|
|
414
|
+
-t, --target Target(s): "all", "agents", "claude", "copilot", "codex",
|
|
415
|
+
"gemini", or "antigravity" (comma-separated; default: all)
|
|
416
|
+
-s, --skills Comma-separated skill names (default: all)
|
|
417
|
+
--force Overwrite existing skills
|
|
418
|
+
--dry-run Preview without writing files
|
|
419
|
+
--validate Validate skills before installing
|
|
420
|
+
|
|
421
|
+
uninstall <names> Remove installed skills
|
|
422
|
+
-t, --target Target(s) to remove from (default: all)
|
|
423
|
+
|
|
424
|
+
list List installed skills
|
|
425
|
+
-t, --target Target(s) to list (default: all)
|
|
426
|
+
|
|
427
|
+
route "<prompt>" Find the best skill for a task
|
|
428
|
+
-n, --top-n Number of results (default: 3)
|
|
429
|
+
--json Output as JSON
|
|
430
|
+
--interactive Interactive prompt mode
|
|
431
|
+
|
|
432
|
+
doctor Check health of installed skills
|
|
433
|
+
-t, --target Target: "agents", "claude", "copilot", "codex", "gemini",
|
|
434
|
+
or "antigravity" (default: all)
|
|
435
|
+
|
|
436
|
+
validate Lint all skill files
|
|
437
|
+
--fix Auto-fix known issues
|
|
438
|
+
|
|
439
|
+
score Score all skills on quality metrics
|
|
440
|
+
--json Output as JSON
|
|
441
|
+
|
|
442
|
+
test Run adversarial tests on all skills
|
|
443
|
+
|
|
444
|
+
build-index Regenerate skills.json and skills-routing.json
|
|
445
|
+
|
|
446
|
+
Examples:
|
|
447
|
+
npx agent-skills install # Store once and link every supported CLI
|
|
448
|
+
npx agent-skills install -t copilot,codex # Link only selected AI CLIs
|
|
449
|
+
npx agent-skills install -t gemini -s CodeSage,TestCrafter
|
|
450
|
+
npx agent-skills install -t antigravity # Install all to Google Antigravity
|
|
451
|
+
npx agent-skills route "review my Python code"
|
|
452
|
+
npx agent-skills doctor
|
|
453
|
+
npx agent-skills list
|
|
454
|
+
npx agent-skills score --json > report.json
|
|
455
|
+
`);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// ── Utilities ──────────────────────────────────────────────────────
|
|
459
|
+
|
|
460
|
+
function parseFlags(args, aliases = {}) {
|
|
461
|
+
const result = { _: [] };
|
|
462
|
+
let i = 0;
|
|
463
|
+
while (i < args.length) {
|
|
464
|
+
const arg = args[i];
|
|
465
|
+
if (arg.startsWith("--")) {
|
|
466
|
+
const key = arg.slice(2);
|
|
467
|
+
if (i + 1 < args.length && !args[i + 1].startsWith("-")) {
|
|
468
|
+
result[key] = args[++i];
|
|
469
|
+
} else {
|
|
470
|
+
result[key] = true;
|
|
471
|
+
}
|
|
472
|
+
} else if (arg.startsWith("-") && arg.length === 2) {
|
|
473
|
+
const short = arg.slice(1);
|
|
474
|
+
const long = Object.entries(aliases).find(([, v]) => v === short)?.[0];
|
|
475
|
+
const key = long || short;
|
|
476
|
+
if (i + 1 < args.length && !args[i + 1].startsWith("-")) {
|
|
477
|
+
result[key] = args[++i];
|
|
478
|
+
} else {
|
|
479
|
+
result[key] = true;
|
|
480
|
+
}
|
|
481
|
+
} else {
|
|
482
|
+
result._.push(arg);
|
|
483
|
+
}
|
|
484
|
+
i++;
|
|
485
|
+
}
|
|
486
|
+
return result;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function validateSkill(content) {
|
|
490
|
+
const issues = [];
|
|
491
|
+
if (!content.startsWith("---")) issues.push("Missing frontmatter (---)");
|
|
492
|
+
if (!content.match(/^#{1}\s/m)) issues.push("No H1 heading found");
|
|
493
|
+
if (!content.match(/^#{2}\s/m)) issues.push("No H2 section found");
|
|
494
|
+
if (!content.includes("```")) issues.push("No code examples found");
|
|
495
|
+
if (content.length < 500) issues.push("Content too short (< 500 chars)");
|
|
496
|
+
return issues;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function loadMeta(installDir) {
|
|
500
|
+
const metaPath = path.join(installDir, ".skills-meta.json");
|
|
501
|
+
if (fs.existsSync(metaPath)) {
|
|
502
|
+
try { return JSON.parse(fs.readFileSync(metaPath, "utf8")); } catch (_) {}
|
|
503
|
+
}
|
|
504
|
+
return {};
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function saveMeta(installDir, meta) {
|
|
508
|
+
const metaPath = path.join(installDir, ".skills-meta.json");
|
|
509
|
+
fs.writeFileSync(metaPath, JSON.stringify(meta, null, 2) + "\n");
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// ── Main ───────────────────────────────────────────────────────────
|
|
513
|
+
|
|
514
|
+
const [, , command, ...args] = process.argv;
|
|
515
|
+
|
|
516
|
+
switch (command) {
|
|
517
|
+
case "install": cmdInstall(args); break;
|
|
518
|
+
case "uninstall": cmdUninstall(args); break;
|
|
519
|
+
case "list": cmdList(args); break;
|
|
520
|
+
case "route": cmdRoute(args); break;
|
|
521
|
+
case "doctor": cmdDoctor(args); break;
|
|
522
|
+
case "validate": cmdValidate(args); break;
|
|
523
|
+
case "score": cmdScore(args); break;
|
|
524
|
+
case "test": cmdTest(args); break;
|
|
525
|
+
case "build-index": cmdBuildIndex(args); break;
|
|
526
|
+
case "help":
|
|
527
|
+
case "--help":
|
|
528
|
+
case "-h":
|
|
529
|
+
case undefined: cmdHelp(); break;
|
|
530
|
+
default:
|
|
531
|
+
console.error(`Unknown command: ${command}\nRun "agent-skills help" for usage.`);
|
|
532
|
+
process.exit(1);
|
|
533
|
+
}
|