@agent-nexus/csreg 0.1.8 → 0.1.9
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/dist/index.js +60 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -320,6 +320,28 @@ function readSkillsConfig() {
|
|
|
320
320
|
}
|
|
321
321
|
return null;
|
|
322
322
|
}
|
|
323
|
+
function addToSkillsConfig(claudeDir, scope, name, version) {
|
|
324
|
+
const configPath = join3(claudeDir, "skills.json");
|
|
325
|
+
let config;
|
|
326
|
+
if (existsSync3(configPath)) {
|
|
327
|
+
const raw = readFileSync2(configPath, "utf-8");
|
|
328
|
+
config = JSON.parse(raw);
|
|
329
|
+
} else {
|
|
330
|
+
config = { skills: [] };
|
|
331
|
+
}
|
|
332
|
+
const newRef = `@${scope}/${name}@${version}`;
|
|
333
|
+
const existingIndex = config.skills.findIndex((entry) => {
|
|
334
|
+
const parsed = parseSkillRef(entry.ref);
|
|
335
|
+
return parsed.scope === scope && parsed.name === name;
|
|
336
|
+
});
|
|
337
|
+
const newEntry = { ref: newRef, version };
|
|
338
|
+
if (existingIndex >= 0) {
|
|
339
|
+
config.skills[existingIndex] = newEntry;
|
|
340
|
+
} else {
|
|
341
|
+
config.skills.push(newEntry);
|
|
342
|
+
}
|
|
343
|
+
writeFileSync3(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
344
|
+
}
|
|
323
345
|
async function pullSkill(scope, name, version, targetDir) {
|
|
324
346
|
const spin = spinner(`Fetching ${scope}/${name}${version ? `@${version}` : ""}...`);
|
|
325
347
|
const client = new ApiClient();
|
|
@@ -427,8 +449,10 @@ var pullCommand = new Command7("pull").description("Download and install a skill
|
|
|
427
449
|
}
|
|
428
450
|
const { scope, name, version } = parseSkillRef(ref);
|
|
429
451
|
let targetDir;
|
|
452
|
+
let isCustomPath = false;
|
|
430
453
|
if (opts.path) {
|
|
431
454
|
targetDir = resolve4(opts.path);
|
|
455
|
+
isCustomPath = true;
|
|
432
456
|
} else {
|
|
433
457
|
const detected = findClaudeSkillsDir();
|
|
434
458
|
if (detected) {
|
|
@@ -445,6 +469,7 @@ var pullCommand = new Command7("pull").description("Download and install a skill
|
|
|
445
469
|
default: join3(".", ".claude", "skills")
|
|
446
470
|
});
|
|
447
471
|
targetDir = resolve4(custom);
|
|
472
|
+
isCustomPath = true;
|
|
448
473
|
}
|
|
449
474
|
} else {
|
|
450
475
|
targetDir = join3(resolve4("."), ".claude", "skills");
|
|
@@ -460,6 +485,7 @@ var pullCommand = new Command7("pull").description("Download and install a skill
|
|
|
460
485
|
default: targetDir
|
|
461
486
|
});
|
|
462
487
|
targetDir = resolve4(custom);
|
|
488
|
+
isCustomPath = true;
|
|
463
489
|
}
|
|
464
490
|
}
|
|
465
491
|
}
|
|
@@ -467,6 +493,40 @@ var pullCommand = new Command7("pull").description("Download and install a skill
|
|
|
467
493
|
console.log("");
|
|
468
494
|
success(`Pulled ${scope}/${name}@${result.version}`);
|
|
469
495
|
info(`Skill is ready at ${join3(targetDir, name)}/SKILL.md`);
|
|
496
|
+
if (!isCustomPath) {
|
|
497
|
+
try {
|
|
498
|
+
const fullRef = `@${scope}/${name}@${result.version}`;
|
|
499
|
+
const claudeDir = dirname(targetDir);
|
|
500
|
+
const configPath = join3(claudeDir, "skills.json");
|
|
501
|
+
let alreadyTracked = false;
|
|
502
|
+
if (existsSync3(configPath)) {
|
|
503
|
+
try {
|
|
504
|
+
const raw = readFileSync2(configPath, "utf-8");
|
|
505
|
+
const config = JSON.parse(raw);
|
|
506
|
+
alreadyTracked = config.skills.some((entry) => {
|
|
507
|
+
const parsed = parseSkillRef(entry.ref);
|
|
508
|
+
return parsed.scope === scope && parsed.name === name && parsed.version === result.version;
|
|
509
|
+
});
|
|
510
|
+
} catch {
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
if (alreadyTracked) {
|
|
514
|
+
info(`Already tracked in .claude/skills.json`);
|
|
515
|
+
} else {
|
|
516
|
+
console.log("");
|
|
517
|
+
const addIt = await confirm2({
|
|
518
|
+
message: `Add ${fullRef} to .claude/skills.json?`,
|
|
519
|
+
default: true
|
|
520
|
+
});
|
|
521
|
+
if (addIt) {
|
|
522
|
+
addToSkillsConfig(claudeDir, scope, name, result.version);
|
|
523
|
+
success(`Added to ${configPath}`);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
} catch (err) {
|
|
527
|
+
warn(`Could not update .claude/skills.json: ${err instanceof Error ? err.message : String(err)}`);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
470
530
|
} catch (err) {
|
|
471
531
|
handleError(err);
|
|
472
532
|
}
|