sra-skills 0.2.3 → 0.3.1
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/index.mjs +91 -16
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -275,8 +275,15 @@ if (cmd === 'add') {
|
|
|
275
275
|
console.log(`Repo "${name}" exists, updating...`);
|
|
276
276
|
execSync('git pull', { cwd: repoPath, stdio: 'inherit' });
|
|
277
277
|
} else {
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
const refIdx = cmdArgs.indexOf('--ref');
|
|
279
|
+
const ref = refIdx >= 0 ? cmdArgs[refIdx + 1] : 'release';
|
|
280
|
+
console.log(`Cloning ${url} (${ref})...`);
|
|
281
|
+
try {
|
|
282
|
+
execSync(`git clone --depth 1 -b "${ref}" "${url}" "${repoPath}"`, { stdio: 'inherit' });
|
|
283
|
+
} catch {
|
|
284
|
+
console.log(` ⚠ Branch "${ref}" not found, using default branch`);
|
|
285
|
+
execSync(`git clone --depth 1 "${url}" "${repoPath}"`, { stdio: 'inherit' });
|
|
286
|
+
}
|
|
280
287
|
execSync('git fetch --tags --depth 1', { cwd: repoPath, stdio: 'ignore' });
|
|
281
288
|
}
|
|
282
289
|
}
|
|
@@ -290,7 +297,10 @@ if (cmd === 'add') {
|
|
|
290
297
|
runPostInstall(repoPath);
|
|
291
298
|
|
|
292
299
|
const m = readManifest();
|
|
293
|
-
|
|
300
|
+
const refIdx2 = cmdArgs.indexOf('--ref');
|
|
301
|
+
const savedRef = refIdx2 >= 0 ? cmdArgs[refIdx2 + 1] : undefined;
|
|
302
|
+
m.repos[name] = { path: repoPath, ...(url && { url }), ...(savedRef && { ref: savedRef }),
|
|
303
|
+
version: getVersion(repoPath), skills: skills.map(s => s.name),
|
|
294
304
|
updated_at: new Date().toISOString() };
|
|
295
305
|
m.tools = tools;
|
|
296
306
|
writeManifest(m);
|
|
@@ -327,21 +337,83 @@ if (cmd === 'add') {
|
|
|
327
337
|
if (!repo) { console.error(`Repo "${name}" not found`); continue; }
|
|
328
338
|
console.log(`Updating ${name}...`);
|
|
329
339
|
try { execSync('git pull', { cwd: repo.path, stdio: 'inherit' }); } catch {}
|
|
330
|
-
const
|
|
340
|
+
const allSkills = discoverSkills(repo.path);
|
|
341
|
+
const saved = repo.skills;
|
|
342
|
+
const skills = saved ? allSkills.filter(s => saved.includes(s.name)) : allSkills;
|
|
331
343
|
linkSkills(skills, tools);
|
|
332
344
|
runToolSetup(repo.path, tools);
|
|
345
|
+
runPostInstall(repo.path);
|
|
346
|
+
repo.skills = skills.map(s => s.name);
|
|
333
347
|
repo.version = getVersion(repo.path);
|
|
334
348
|
repo.updated_at = new Date().toISOString();
|
|
335
349
|
}
|
|
336
350
|
m.tools = tools;
|
|
337
351
|
writeManifest(m);
|
|
338
352
|
|
|
353
|
+
} else if (cmd === 'skill') {
|
|
354
|
+
const subCmd = cmdArgs[0];
|
|
355
|
+
const skillName = cmdArgs[1];
|
|
356
|
+
const m = readManifest();
|
|
357
|
+
const tools = m.tools || detectTools();
|
|
358
|
+
|
|
359
|
+
if (subCmd === 'add' && skillName) {
|
|
360
|
+
for (const [rname, repo] of Object.entries(m.repos)) {
|
|
361
|
+
const allSkills = discoverSkills(repo.path);
|
|
362
|
+
const match = allSkills.filter(s => s.name === skillName);
|
|
363
|
+
if (match.length) {
|
|
364
|
+
const saved = repo.skills || [];
|
|
365
|
+
if (saved.includes(skillName)) {
|
|
366
|
+
console.log(`${skillName} is already enabled`);
|
|
367
|
+
process.exit(0);
|
|
368
|
+
}
|
|
369
|
+
linkSkills(match, tools);
|
|
370
|
+
saved.push(skillName);
|
|
371
|
+
repo.skills = saved;
|
|
372
|
+
writeManifest(m);
|
|
373
|
+
console.log(`Enabled ${skillName} (from ${rname})`);
|
|
374
|
+
process.exit(0);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
console.error(`Skill "${skillName}" not found in any installed repo`);
|
|
378
|
+
console.error('Available skills:');
|
|
379
|
+
for (const [rname, repo] of Object.entries(m.repos)) {
|
|
380
|
+
const allSkills = discoverSkills(repo.path);
|
|
381
|
+
const saved = repo.skills || [];
|
|
382
|
+
allSkills.filter(s => !saved.includes(s.name)).forEach(s =>
|
|
383
|
+
console.error(` ${s.name} (${rname})`));
|
|
384
|
+
}
|
|
385
|
+
process.exit(1);
|
|
386
|
+
|
|
387
|
+
} else if (subCmd === 'remove' && skillName) {
|
|
388
|
+
for (const [rname, repo] of Object.entries(m.repos)) {
|
|
389
|
+
const saved = repo.skills || [];
|
|
390
|
+
if (saved.includes(skillName)) {
|
|
391
|
+
const allSkills = discoverSkills(repo.path);
|
|
392
|
+
const match = allSkills.filter(s => s.name === skillName);
|
|
393
|
+
if (match.length) unlinkSkills(match, tools);
|
|
394
|
+
repo.skills = saved.filter(s => s !== skillName);
|
|
395
|
+
writeManifest(m);
|
|
396
|
+
console.log(`Disabled ${skillName} (from ${rname})`);
|
|
397
|
+
process.exit(0);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
console.error(`Skill "${skillName}" is not currently enabled`);
|
|
401
|
+
process.exit(1);
|
|
402
|
+
|
|
403
|
+
} else {
|
|
404
|
+
console.log(`Usage: sra skill <add|remove> <skill-name>`);
|
|
405
|
+
}
|
|
406
|
+
|
|
339
407
|
} else if (cmd === 'list') {
|
|
340
408
|
const m = readManifest();
|
|
341
409
|
for (const [name, info] of Object.entries(m.repos)) {
|
|
342
|
-
const
|
|
410
|
+
const allSkills = discoverSkills(info.path);
|
|
411
|
+
const saved = info.skills;
|
|
343
412
|
console.log(`${name} (${info.version || 'unknown'}):`);
|
|
344
|
-
|
|
413
|
+
allSkills.forEach(s => {
|
|
414
|
+
const enabled = !saved || saved.includes(s.name);
|
|
415
|
+
console.log(` ${enabled ? '' : '(disabled) '}${s.name}`);
|
|
416
|
+
});
|
|
345
417
|
}
|
|
346
418
|
if (m.tools?.length) console.log(`\nTools: ${m.tools.join(', ')}`);
|
|
347
419
|
|
|
@@ -352,18 +424,21 @@ if (cmd === 'add') {
|
|
|
352
424
|
}
|
|
353
425
|
|
|
354
426
|
} else {
|
|
355
|
-
console.log(`Usage: sra <
|
|
427
|
+
console.log(`Usage: sra <command> [args]
|
|
356
428
|
|
|
357
429
|
Commands:
|
|
358
|
-
add <git-url>
|
|
359
|
-
add --local <path>
|
|
360
|
-
remove <repo-name>
|
|
361
|
-
update [repo-name]
|
|
362
|
-
|
|
363
|
-
|
|
430
|
+
add <git-url> Clone repo, discover skills, symlink, configure tools
|
|
431
|
+
add --local <path> Register existing repo directory
|
|
432
|
+
remove <repo-name> Unlink skills, remove repo
|
|
433
|
+
update [repo-name] Git pull, re-link, re-configure
|
|
434
|
+
skill add <skill-name> Enable a skill from an installed repo
|
|
435
|
+
skill remove <skill-name> Disable a skill (remove symlink)
|
|
436
|
+
list Show installed repos and skills
|
|
437
|
+
version Show repo versions
|
|
364
438
|
|
|
365
439
|
Options:
|
|
366
|
-
--tool <name>
|
|
367
|
-
|
|
368
|
-
--
|
|
440
|
+
--tool <name> Target tool (claude|codex|cursor|openclaw|all)
|
|
441
|
+
--name <name> Override repo name (for add)
|
|
442
|
+
--ref <branch|tag> Git branch or tag (default: release)
|
|
443
|
+
-y, --yes Skip interactive selection (install all)`);
|
|
369
444
|
}
|