sra-skills 0.3.1 → 0.3.3

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.
Files changed (2) hide show
  1. package/index.mjs +27 -3
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -298,8 +298,8 @@ if (cmd === 'add') {
298
298
 
299
299
  const m = readManifest();
300
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 }),
301
+ const savedRef = refIdx2 >= 0 ? cmdArgs[refIdx2 + 1] : 'release';
302
+ m.repos[name] = { path: repoPath, ...(url && { url }), ref: savedRef,
303
303
  version: getVersion(repoPath), skills: skills.map(s => s.name),
304
304
  updated_at: new Date().toISOString() };
305
305
  m.tools = tools;
@@ -336,7 +336,31 @@ if (cmd === 'add') {
336
336
  const repo = m.repos[name];
337
337
  if (!repo) { console.error(`Repo "${name}" not found`); continue; }
338
338
  console.log(`Updating ${name}...`);
339
- try { execSync('git pull', { cwd: repo.path, stdio: 'inherit' }); } catch {}
339
+ const isCloned = !!repo.url; // --local installs have no url
340
+ if (isCloned) {
341
+ const ref = repo.ref || 'release';
342
+ if (!repo.ref) repo.ref = ref; // backfill for pre-v2.0.1 installs
343
+ const current = execSync('git rev-parse --abbrev-ref HEAD', { cwd: repo.path, encoding: 'utf8' }).trim();
344
+ if (current !== ref) {
345
+ try {
346
+ execSync(`git checkout "${ref}"`, { cwd: repo.path, stdio: 'pipe' });
347
+ console.log(` Switched to ${ref}`);
348
+ } catch {
349
+ try {
350
+ execSync('git remote set-branches origin "*"', { cwd: repo.path, stdio: 'pipe' });
351
+ execSync(`git fetch --depth 1 origin "${ref}"`, { cwd: repo.path, stdio: 'pipe' });
352
+ execSync(`git checkout -b "${ref}" "origin/${ref}"`, { cwd: repo.path, stdio: 'pipe' });
353
+ console.log(` Switched to ${ref}`);
354
+ } catch {
355
+ console.log(` ⚠ Branch "${ref}" not found, staying on ${current}`);
356
+ }
357
+ }
358
+ }
359
+ try { execSync(`git pull origin "${ref}"`, { cwd: repo.path, stdio: 'inherit' }); } catch {}
360
+ try { execSync('git fetch --tags --depth 1', { cwd: repo.path, stdio: 'ignore' }); } catch {}
361
+ } else {
362
+ try { execSync('git pull', { cwd: repo.path, stdio: 'inherit' }); } catch {}
363
+ }
340
364
  const allSkills = discoverSkills(repo.path);
341
365
  const saved = repo.skills;
342
366
  const skills = saved ? allSkills.filter(s => saved.includes(s.name)) : allSkills;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sra-skills",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "SRA agent skills installer — manage AI skill repos",
5
5
  "bin": {
6
6
  "sra": "index.mjs",