@agent-nexus/csreg 0.1.8 → 0.1.10

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.
@@ -1,7 +1,8 @@
1
1
  // src/commands/push.ts
2
2
  import { Command as Command2 } from "commander";
3
3
  import { resolve as resolve3, join as join6, basename as basename3 } from "path";
4
- import { existsSync as existsSync5, readFileSync as readFileSync3, statSync as statSync3, readdirSync as readdirSync3, lstatSync as lstatSync2 } from "fs";
4
+ import { existsSync as existsSync5, readFileSync as readFileSync3, writeFileSync as writeFileSync2, statSync as statSync3, readdirSync as readdirSync3, lstatSync as lstatSync2 } from "fs";
5
+ import { input } from "@inquirer/prompts";
5
6
  import { createHash as createHash2 } from "crypto";
6
7
 
7
8
  // src/commands/validate.ts
@@ -519,6 +520,16 @@ function collectFileTree(dir, prefix = "") {
519
520
  }
520
521
  return files;
521
522
  }
523
+ function addFrontmatterField(dir, field, value) {
524
+ const skillPath = join6(dir, "SKILL.md");
525
+ const raw = readFileSync3(skillPath, "utf-8");
526
+ const updated = raw.replace(
527
+ /^(---\s*\n[\s\S]*?\n)(---\s*\n?)/,
528
+ `$1${field}: "${value}"
529
+ $2`
530
+ );
531
+ writeFileSync2(skillPath, updated, "utf-8");
532
+ }
522
533
  async function pushSingle(resolved) {
523
534
  const spin = spinner("Validating skill...");
524
535
  const validation = runValidation(resolved);
@@ -532,14 +543,31 @@ async function pushSingle(resolved) {
532
543
  spin.succeed("Validation passed.");
533
544
  const manifest = parseManifest(resolved);
534
545
  if (!manifest.version) {
535
- throw new CliError('Missing "version" in SKILL.md frontmatter.', [
536
- 'Add a version field: version: "1.0.0"'
537
- ]);
546
+ const version = await input({
547
+ message: "Version (semver):",
548
+ default: "1.0.0",
549
+ validate: (value) => {
550
+ const semver = /^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$/;
551
+ if (!semver.test(value.trim())) return "Must be valid semver (e.g., 1.0.0).";
552
+ return true;
553
+ }
554
+ });
555
+ manifest.version = version.trim();
556
+ addFrontmatterField(resolved, "version", manifest.version);
538
557
  }
539
558
  if (!manifest.scope) {
540
- throw new CliError('Missing "scope" in SKILL.md frontmatter.', [
541
- "Add a scope field: scope: my-team"
542
- ]);
559
+ const scope = await input({
560
+ message: "Scope (team or username):",
561
+ validate: (value) => {
562
+ if (!value.trim()) return "Scope is required.";
563
+ if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(value.trim())) {
564
+ return "Must be lowercase alphanumeric with hyphens (e.g., my-team).";
565
+ }
566
+ return true;
567
+ }
568
+ });
569
+ manifest.scope = scope.trim();
570
+ addFrontmatterField(resolved, "scope", manifest.scope);
543
571
  }
544
572
  spin.start("Packing skill...");
545
573
  const archive = await pack(resolved);
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  success,
20
20
  validateCommand,
21
21
  warn
22
- } from "./chunk-Z27YSJYQ.js";
22
+ } from "./chunk-YPG2FR7G.js";
23
23
 
24
24
  // src/index.ts
25
25
  import { Command as Command11 } from "commander";
@@ -266,7 +266,7 @@ var releaseCommand = new Command6("release").description("Bump the version in SK
266
266
  writeFileSync2(skillPath, updated, "utf-8");
267
267
  info(`Updated version to ${newVersion}`);
268
268
  }
269
- const { pushCommand: pushCommand2 } = await import("./push-NOK3Z7EW.js");
269
+ const { pushCommand: pushCommand2 } = await import("./push-X5G76LYV.js");
270
270
  await pushCommand2.parseAsync([dir], { from: "user" });
271
271
  } catch (err) {
272
272
  handleError(err);
@@ -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
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pushCommand
3
- } from "./chunk-Z27YSJYQ.js";
3
+ } from "./chunk-YPG2FR7G.js";
4
4
  export {
5
5
  pushCommand
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-nexus/csreg",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "CLI for Claude Skills Registry",
5
5
  "license": "MIT",
6
6
  "type": "module",