skilld 1.7.2 → 1.7.4

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 (118) hide show
  1. package/dist/_chunks/agent.mjs +693 -599
  2. package/dist/_chunks/agent.mjs.map +1 -1
  3. package/dist/_chunks/assemble.mjs +3 -3
  4. package/dist/_chunks/assemble.mjs.map +1 -1
  5. package/dist/_chunks/author-group.mjs.map +1 -1
  6. package/dist/_chunks/author.mjs +51 -121
  7. package/dist/_chunks/author.mjs.map +1 -1
  8. package/dist/_chunks/cache.mjs +315 -9
  9. package/dist/_chunks/cache.mjs.map +1 -1
  10. package/dist/_chunks/cache2.mjs +2 -2
  11. package/dist/_chunks/cache2.mjs.map +1 -1
  12. package/dist/_chunks/cli-helpers.mjs +3 -3
  13. package/dist/_chunks/cli-helpers.mjs.map +1 -1
  14. package/dist/_chunks/core.mjs +7 -4
  15. package/dist/_chunks/detect.mjs +1 -1
  16. package/dist/_chunks/detect.mjs.map +1 -1
  17. package/dist/_chunks/embedding-cache2.mjs +2 -2
  18. package/dist/_chunks/embedding-cache2.mjs.map +1 -1
  19. package/dist/_chunks/index.d.mts +305 -112
  20. package/dist/_chunks/index.d.mts.map +1 -1
  21. package/dist/_chunks/index2.d.mts +267 -32
  22. package/dist/_chunks/index2.d.mts.map +1 -1
  23. package/dist/_chunks/index3.d.mts +32 -577
  24. package/dist/_chunks/index3.d.mts.map +1 -1
  25. package/dist/_chunks/index4.d.mts +553 -0
  26. package/dist/_chunks/index4.d.mts.map +1 -0
  27. package/dist/_chunks/install.mjs +48 -88
  28. package/dist/_chunks/install.mjs.map +1 -1
  29. package/dist/_chunks/list.mjs +1 -1
  30. package/dist/_chunks/list.mjs.map +1 -1
  31. package/dist/_chunks/lockfile.mjs +29 -6
  32. package/dist/_chunks/lockfile.mjs.map +1 -1
  33. package/dist/_chunks/markdown.mjs.map +1 -1
  34. package/dist/_chunks/monorepo.mjs +71 -0
  35. package/dist/_chunks/monorepo.mjs.map +1 -0
  36. package/dist/_chunks/package-json.mjs.map +1 -1
  37. package/dist/_chunks/{shared.mjs → package-registry.mjs} +2 -40
  38. package/dist/_chunks/package-registry.mjs.map +1 -0
  39. package/dist/_chunks/paths.mjs +49 -0
  40. package/dist/_chunks/paths.mjs.map +1 -0
  41. package/dist/_chunks/pool2.mjs +7 -2
  42. package/dist/_chunks/pool2.mjs.map +1 -1
  43. package/dist/_chunks/prepare.mjs +1 -1
  44. package/dist/_chunks/prepare.mjs.map +1 -1
  45. package/dist/_chunks/prepare2.mjs +5 -5
  46. package/dist/_chunks/prepare2.mjs.map +1 -1
  47. package/dist/_chunks/prompts.mjs +366 -18
  48. package/dist/_chunks/prompts.mjs.map +1 -1
  49. package/dist/_chunks/retriv.mjs.map +1 -1
  50. package/dist/_chunks/sanitize.mjs.map +1 -1
  51. package/dist/_chunks/search-helpers.mjs +5 -6
  52. package/dist/_chunks/search-helpers.mjs.map +1 -1
  53. package/dist/_chunks/search-interactive.mjs +1 -1
  54. package/dist/_chunks/search-interactive.mjs.map +1 -1
  55. package/dist/_chunks/search.mjs +1 -2
  56. package/dist/_chunks/search.mjs.map +1 -1
  57. package/dist/_chunks/semver.mjs +13 -0
  58. package/dist/_chunks/semver.mjs.map +1 -0
  59. package/dist/_chunks/setup.mjs.map +1 -1
  60. package/dist/_chunks/skill-installer.mjs +2 -0
  61. package/dist/_chunks/skill-installer2.mjs +155 -0
  62. package/dist/_chunks/skill-installer2.mjs.map +1 -0
  63. package/dist/_chunks/skills.mjs +10 -9
  64. package/dist/_chunks/skills.mjs.map +1 -1
  65. package/dist/_chunks/sources.mjs +575 -386
  66. package/dist/_chunks/sources.mjs.map +1 -1
  67. package/dist/_chunks/sync-pipeline.mjs +952 -0
  68. package/dist/_chunks/sync-pipeline.mjs.map +1 -0
  69. package/dist/_chunks/sync-registry.mjs +19 -13
  70. package/dist/_chunks/sync-registry.mjs.map +1 -1
  71. package/dist/_chunks/sync.mjs +797 -886
  72. package/dist/_chunks/sync.mjs.map +1 -1
  73. package/dist/_chunks/sync2.mjs +4 -2
  74. package/dist/_chunks/types.d.mts +65 -77
  75. package/dist/_chunks/types.d.mts.map +1 -1
  76. package/dist/_chunks/types2.d.mts +88 -0
  77. package/dist/_chunks/types2.d.mts.map +1 -0
  78. package/dist/_chunks/uninstall.mjs +7 -8
  79. package/dist/_chunks/uninstall.mjs.map +1 -1
  80. package/dist/_chunks/upload.mjs +2 -2
  81. package/dist/_chunks/upload.mjs.map +1 -1
  82. package/dist/_chunks/validate.mjs +1 -1
  83. package/dist/_chunks/validate.mjs.map +1 -1
  84. package/dist/_chunks/version.mjs +3 -13
  85. package/dist/_chunks/version.mjs.map +1 -1
  86. package/dist/_chunks/wizard.mjs +2 -2
  87. package/dist/_chunks/wizard.mjs.map +1 -1
  88. package/dist/_chunks/yaml.mjs.map +1 -1
  89. package/dist/agent/index.d.mts +2 -346
  90. package/dist/agent/index.mjs +2 -3
  91. package/dist/cache/index.d.mts +2 -2
  92. package/dist/cache/index.mjs +4 -3
  93. package/dist/cli.mjs +12 -13
  94. package/dist/cli.mjs.map +1 -1
  95. package/dist/index.d.mts +5 -4
  96. package/dist/index.mjs +4 -3
  97. package/dist/prepare.mjs +2 -2
  98. package/dist/prepare.mjs.map +1 -1
  99. package/dist/retriv/index.d.mts +2 -2
  100. package/dist/retriv/worker.d.mts +2 -1
  101. package/dist/retriv/worker.d.mts.map +1 -1
  102. package/dist/retriv/worker.mjs +2 -1
  103. package/dist/retriv/worker.mjs.map +1 -1
  104. package/dist/sources/index.d.mts +3 -2
  105. package/dist/sources/index.mjs +3 -3
  106. package/dist/types.d.mts +3 -3
  107. package/package.json +5 -5
  108. package/dist/_chunks/config.mjs +0 -122
  109. package/dist/_chunks/config.mjs.map +0 -1
  110. package/dist/_chunks/prefix.mjs +0 -108
  111. package/dist/_chunks/prefix.mjs.map +0 -1
  112. package/dist/_chunks/shared.mjs.map +0 -1
  113. package/dist/_chunks/skill.mjs +0 -329
  114. package/dist/_chunks/skill.mjs.map +0 -1
  115. package/dist/_chunks/sync-shared.mjs +0 -2
  116. package/dist/_chunks/sync-shared2.mjs +0 -1020
  117. package/dist/_chunks/sync-shared2.mjs.map +0 -1
  118. package/dist/agent/index.d.mts.map +0 -1
@@ -1,6 +1,24 @@
1
- import { f as getPackageRules, i as resolveSkilldCommand } from "./shared.mjs";
2
- import "./skill.mjs";
3
- import { dirname } from "pathe";
1
+ import { p as skillInternalDir } from "./paths.mjs";
2
+ import { t as yamlEscape } from "./yaml.mjs";
3
+ import { n as sanitizeMarkdown, t as repairMarkdown } from "./sanitize.mjs";
4
+ import { a as getPackageRules, i as getFilePatterns } from "./package-registry.mjs";
5
+ import { a as targets, t as detectInstalledAgents } from "./detect.mjs";
6
+ import { existsSync, lstatSync, mkdirSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
7
+ import { dirname, join, relative } from "pathe";
8
+ import { execSync } from "node:child_process";
9
+ import * as p from "@clack/prompts";
10
+ import { isWindows } from "std-env";
11
+ let cached;
12
+ function resolveSkilldCommand() {
13
+ if (cached !== void 0) return cached;
14
+ try {
15
+ execSync(`${isWindows ? "where" : "which"} skilld`, { stdio: "ignore" });
16
+ cached = "skilld";
17
+ } catch {
18
+ cached = "npx -y skilld";
19
+ }
20
+ return cached;
21
+ }
4
22
  const TOTAL_TARGET = 500;
5
23
  const DEFAULT_OVERHEAD = 30;
6
24
  function remainingLines(overheadLines) {
@@ -289,16 +307,28 @@ Content addressing the user's instructions above, using concise examples and sou
289
307
  rules: [`- **Custom section "${heading}":** MAX ${customMaxLines} lines, use \`## ${heading}\` heading`]
290
308
  };
291
309
  }
292
- const SECTION_OUTPUT_FILES = {
293
- "best-practices": "_BEST_PRACTICES.md",
294
- "api-changes": "_API_CHANGES.md",
295
- "custom": "_CUSTOM.md"
296
- };
297
- const SECTION_MERGE_ORDER = [
298
- "api-changes",
299
- "best-practices",
300
- "custom"
310
+ const SECTIONS = [
311
+ {
312
+ id: "api-changes",
313
+ outputFile: "_API_CHANGES.md",
314
+ build: (ctx) => apiChangesSection(ctx)
315
+ },
316
+ {
317
+ id: "best-practices",
318
+ outputFile: "_BEST_PRACTICES.md",
319
+ build: (ctx) => bestPracticesSection(ctx)
320
+ },
321
+ {
322
+ id: "custom",
323
+ outputFile: "_CUSTOM.md",
324
+ build: (ctx, customPrompt) => customPrompt ? customSection(customPrompt, ctx.enabledSectionCount, ctx.overheadLines) : null
325
+ }
301
326
  ];
327
+ const SECTION_OUTPUT_FILES = Object.fromEntries(SECTIONS.map((s) => [s.id, s.outputFile]));
328
+ const SECTION_MERGE_ORDER = SECTIONS.map((s) => s.id);
329
+ function getSectionModule(id) {
330
+ return SECTIONS.find((s) => s.id === id);
331
+ }
302
332
  function wrapSection(section, content) {
303
333
  return `<!-- skilld:${section} -->\n${content}\n<!-- /skilld:${section} -->`;
304
334
  }
@@ -372,11 +402,7 @@ ${generateImportantBlock({
372
402
  ${docsSection ? `${docsSection}\n` : ""}`;
373
403
  }
374
404
  function getSectionDef(section, ctx, customPrompt) {
375
- switch (section) {
376
- case "api-changes": return apiChangesSection(ctx);
377
- case "best-practices": return bestPracticesSection(ctx);
378
- case "custom": return customPrompt ? customSection(customPrompt, ctx.enabledSectionCount, ctx.overheadLines) : null;
379
- }
405
+ return getSectionModule(section)?.build(ctx, customPrompt) ?? null;
380
406
  }
381
407
  function getSectionValidator(section) {
382
408
  return getSectionDef(section, { packageName: "" }, section === "custom" ? {
@@ -487,6 +513,328 @@ function portabilizePrompt(prompt, section) {
487
513
  out = out.replace(/\n{3,}/g, "\n\n");
488
514
  return out;
489
515
  }
490
- export { extractMarkedSections as a, wrapSection as c, buildSectionPrompt as i, maxItems as l, SECTION_OUTPUT_FILES as n, getSectionValidator as o, buildAllSectionPrompts as r, portabilizePrompt as s, SECTION_MERGE_ORDER as t, maxLines as u };
516
+ function todayIsoDate() {
517
+ return (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
518
+ }
519
+ function timeAgo(iso) {
520
+ if (!iso) return "";
521
+ const diff = Date.now() - new Date(iso).getTime();
522
+ const days = Math.floor(diff / 864e5);
523
+ if (days <= 0) return "today";
524
+ if (days === 1) return "1d ago";
525
+ if (days < 7) return `${days}d ago`;
526
+ if (days < 30) return `${Math.floor(days / 7)}w ago`;
527
+ return `${Math.floor(days / 30)}mo ago`;
528
+ }
529
+ function formatSource(source) {
530
+ if (!source) return "";
531
+ if (source === "shipped") return "shipped";
532
+ if (source.includes("llms.txt")) return "llms.txt";
533
+ if (source.includes("github.com")) return source.replace(/https?:\/\/github\.com\//, "");
534
+ return source;
535
+ }
536
+ function formatDuration(ms) {
537
+ if (ms < 1e3) return `${Math.round(ms)}ms`;
538
+ return `${(ms / 1e3).toFixed(1)}s`;
539
+ }
540
+ function timedSpinner() {
541
+ const spin = p.spinner();
542
+ let startedAt = 0;
543
+ return {
544
+ start(msg) {
545
+ startedAt = Date.now();
546
+ spin.start(msg);
547
+ },
548
+ message(msg) {
549
+ spin.message(msg);
550
+ },
551
+ stop(msg) {
552
+ const elapsed = startedAt ? formatDuration(Date.now() - startedAt) : "";
553
+ spin.stop(elapsed ? `${msg} \x1B[90m[${elapsed}]\x1B[0m` : msg);
554
+ }
555
+ };
556
+ }
557
+ function highlightTerms(content, terms) {
558
+ if (terms.length === 0) return content;
559
+ const sorted = terms.toSorted((a, b) => b.length - a.length);
560
+ const pattern = new RegExp(`(${sorted.map((t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})`, "gi");
561
+ return content.replace(pattern, "\x1B[33m$1\x1B[0m");
562
+ }
563
+ function scoreLabel(pct) {
564
+ return `${pct >= 70 ? "\x1B[32m" : pct >= 40 ? "\x1B[33m" : "\x1B[90m"}${pct}%\x1B[0m`;
565
+ }
566
+ function normalizeScores(results) {
567
+ const map = /* @__PURE__ */ new Map();
568
+ const max = results.reduce((m, r) => Math.max(m, r.score), 0);
569
+ for (const r of results) map.set(r, max > 0 ? Math.round(r.score / max * 100) : 0);
570
+ return map;
571
+ }
572
+ function formatSnippet(r, versions, pct) {
573
+ const refPath = `.claude/skills/${r.package}/.skilld/${r.source}`;
574
+ const lineRange = r.lineStart === r.lineEnd ? `L${r.lineStart}` : `L${r.lineStart}-${r.lineEnd}`;
575
+ const score = pct != null ? scoreLabel(pct) : `\x1B[90m${r.score.toFixed(2)}\x1B[0m`;
576
+ const version = versions?.get(r.package);
577
+ const pkgLabel = version ? `${r.package}@${version}` : r.package;
578
+ const scopeStr = r.scope?.length ? `${r.scope.map((e) => e.name).join(".")} → ` : "";
579
+ const entityStr = r.entities?.map((e) => e.signature || `${e.type} ${e.name}`).join(", ");
580
+ const highlighted = highlightTerms(r.content, r.highlights);
581
+ return [
582
+ `${pkgLabel} ${score}${entityStr ? ` \x1B[36m${scopeStr}${entityStr}\x1B[0m` : ""}`,
583
+ `\x1B[90m${refPath}:${lineRange}\x1B[0m`,
584
+ ` ${highlighted.replace(/\n/g, "\n ")}`
585
+ ].join("\n");
586
+ }
587
+ function formatCompactSnippet(r, cols) {
588
+ const entityStr = r.entities?.length ? r.entities.map((e) => e.signature || e.name).join(", ") : "";
589
+ const scopeStr = r.scope?.length ? `${r.scope.map((e) => e.name).join(".")} → ` : "";
590
+ const title = entityStr ? `${scopeStr}${entityStr}` : r.source.split("/").pop() || r.source;
591
+ const path = `${`.claude/skills/${r.package}/.skilld/${r.source}`}:${r.lineStart === r.lineEnd ? `L${r.lineStart}` : `L${r.lineStart}-${r.lineEnd}`}`;
592
+ const maxPreview = cols - 6;
593
+ const firstLine = r.content.split("\n").find((l) => l.trim() && l.trim() !== "---" && !/^#+\s*$/.test(l.trim())) || "";
594
+ return {
595
+ title,
596
+ path,
597
+ preview: firstLine.length > maxPreview ? `${firstLine.slice(0, maxPreview - 1)}…` : firstLine
598
+ };
599
+ }
600
+ function sanitizeName(name) {
601
+ return name.toLowerCase().replace(/[^a-z0-9._]+/g, "-").replace(/^[.\-]+|[.\-]+$/g, "").slice(0, 255) || "unnamed-skill";
602
+ }
603
+ function computeSkillDirName(packageName) {
604
+ return `${sanitizeName(packageName)}-skilld`;
605
+ }
606
+ function installSkillForAgents(skillName, skillContent, options = {}) {
607
+ const isGlobal = options.global ?? false;
608
+ const cwd = options.cwd || process.cwd();
609
+ const sanitized = sanitizeName(skillName);
610
+ const explicit = !!options.agents;
611
+ const targetAgents = options.agents || detectInstalledAgents();
612
+ const installed = [];
613
+ const skipped = [];
614
+ const paths = [];
615
+ const writtenDirs = /* @__PURE__ */ new Set();
616
+ for (const agentType of targetAgents) {
617
+ const agent = targets[agentType];
618
+ if (isGlobal && !agent.globalSkillsDir) {
619
+ skipped.push({
620
+ agent: agentType,
621
+ reason: "no global support"
622
+ });
623
+ continue;
624
+ }
625
+ const baseDir = isGlobal ? agent.globalSkillsDir : join(cwd, agent.skillsDir);
626
+ if (!explicit && !existsSync(baseDir)) {
627
+ skipped.push({
628
+ agent: agentType,
629
+ reason: "skills dir not found"
630
+ });
631
+ continue;
632
+ }
633
+ if (isGlobal && (writtenDirs.has(baseDir) || agent.additionalSkillsDirs.some((d) => writtenDirs.has(d)))) {
634
+ skipped.push({
635
+ agent: agentType,
636
+ reason: "already covered by another agent dir"
637
+ });
638
+ continue;
639
+ }
640
+ const skillDir = join(baseDir, sanitized);
641
+ const skilldDir = skillInternalDir(skillDir);
642
+ mkdirSync(skilldDir, { recursive: true });
643
+ writeFileSync(join(skilldDir, "_SKILL.md"), sanitizeMarkdown(repairMarkdown(skillContent)));
644
+ if (options.files) for (const [filename, content] of Object.entries(options.files)) writeFileSync(join(skillDir, filename), filename.endsWith(".md") ? sanitizeMarkdown(repairMarkdown(content)) : content);
645
+ installed.push(agentType);
646
+ paths.push(skillDir);
647
+ writtenDirs.add(baseDir);
648
+ }
649
+ return {
650
+ installed,
651
+ skipped,
652
+ paths
653
+ };
654
+ }
655
+ function linkSkillToAgents(skillName, sharedDir, cwd, agentType) {
656
+ const targetAgents = agentType ? [[agentType, targets[agentType]]] : Object.entries(targets);
657
+ const linkedDirs = /* @__PURE__ */ new Set();
658
+ for (const [type, agent] of targetAgents) {
659
+ const agentSkillsDir = join(cwd, agent.skillsDir);
660
+ if (agentType === type) mkdirSync(agentSkillsDir, { recursive: true });
661
+ else {
662
+ if (!existsSync(agentSkillsDir)) continue;
663
+ if (agent.additionalSkillsDirs.map((d) => join(cwd, d)).some((d) => linkedDirs.has(d))) {
664
+ const staleTarget = join(agentSkillsDir, skillName);
665
+ try {
666
+ if (lstatSync(staleTarget).isSymbolicLink() && !existsSync(staleTarget)) unlinkSync(staleTarget);
667
+ } catch {}
668
+ continue;
669
+ }
670
+ }
671
+ const target = join(agentSkillsDir, skillName);
672
+ let isSymlink = false;
673
+ let targetExists = false;
674
+ try {
675
+ const stat = lstatSync(target);
676
+ targetExists = true;
677
+ isSymlink = stat.isSymbolicLink();
678
+ } catch {}
679
+ if (targetExists && !isSymlink) continue;
680
+ if (isSymlink) unlinkSync(target);
681
+ symlinkSync(relative(agentSkillsDir, join(sharedDir, skillName)), target);
682
+ linkedDirs.add(agentSkillsDir);
683
+ }
684
+ }
685
+ function unlinkSkillFromAgents(skillName, cwd, agentType) {
686
+ const targetAgents = agentType ? [[agentType, targets[agentType]]] : Object.entries(targets);
687
+ for (const [, agent] of targetAgents) {
688
+ const target = join(cwd, agent.skillsDir, skillName);
689
+ try {
690
+ if (lstatSync(target).isSymbolicLink()) unlinkSync(target);
691
+ } catch {}
692
+ }
693
+ }
694
+ function writeSkillMd(skillDir, content) {
695
+ writeFileSync(join(skillDir, "SKILL.md"), content);
696
+ }
697
+ function writeGeneratedSkillMd(skillDir, opts) {
698
+ const content = generateSkillMd(opts);
699
+ writeSkillMd(skillDir, content);
700
+ return content;
701
+ }
702
+ function generateSkillMd(opts) {
703
+ const header = generatePackageHeader(opts);
704
+ const search = !opts.eject && opts.features?.search !== false ? generateSearchBlock(opts.name) : "";
705
+ let body = opts.body;
706
+ if (body && opts.eject) {
707
+ body = body.replace(/\.\/\.skilld\//g, "./references/");
708
+ body = body.replace(/\s*\[source\]\(\.\/references\/pkg\/[^)]*\)/gi, "");
709
+ }
710
+ const content = body ? search ? `${header}\n\n${search}\n\n${body}` : `${header}\n\n${body}` : search ? `${header}\n\n${search}` : header;
711
+ const footer = generateFooter(opts.relatedSkills);
712
+ return sanitizeMarkdown(repairMarkdown(`${generateFrontmatter(opts)}${content}\n${footer}`));
713
+ }
714
+ function formatShortDate(isoDate) {
715
+ const date = new Date(isoDate);
716
+ if (Number.isNaN(date.getTime())) return "";
717
+ return `${[
718
+ "Jan",
719
+ "Feb",
720
+ "Mar",
721
+ "Apr",
722
+ "May",
723
+ "Jun",
724
+ "Jul",
725
+ "Aug",
726
+ "Sep",
727
+ "Oct",
728
+ "Nov",
729
+ "Dec"
730
+ ][date.getUTCMonth()]} ${date.getUTCFullYear()}`;
731
+ }
732
+ function generatePackageHeader({ name, version, distTags, repoUrl, hasIssues, hasDiscussions, hasReleases, docsType, pkgFiles, packages, eject }) {
733
+ const versionSuffix = version ? `@${version}` : "";
734
+ let title = `# ${name}${versionSuffix}`;
735
+ if (repoUrl) {
736
+ const url = repoUrl.startsWith("http") ? repoUrl : `https://github.com/${repoUrl}`;
737
+ title = `# [${repoUrl.startsWith("http") ? repoUrl.split("/").slice(-2).join("/") : repoUrl}](${url}) \`${name}${versionSuffix}\``;
738
+ }
739
+ const lines = [title];
740
+ if (distTags && Object.keys(distTags).length > 0) {
741
+ const tags = Object.entries(distTags).sort(([, a], [, b]) => (b.releasedAt ?? "").localeCompare(a.releasedAt ?? "")).slice(0, 3).map(([tag, info]) => {
742
+ const relDate = info.releasedAt ? ` (${formatShortDate(info.releasedAt)})` : "";
743
+ return `${tag}: ${info.version}${relDate}`;
744
+ }).join(", ");
745
+ lines.push(`**Tags:** ${tags}`);
746
+ }
747
+ lines.push("");
748
+ const refBase = eject ? "./references" : "./.skilld";
749
+ const refs = [];
750
+ if (!eject) {
751
+ refs.push(`[package.json](${refBase}/pkg/package.json)`);
752
+ if (packages && packages.length > 1) for (const pkg of packages) {
753
+ const shortName = pkg.name.split("/").pop().toLowerCase();
754
+ refs.push(`[pkg-${shortName}](${refBase}/pkg-${shortName}/package.json)`);
755
+ }
756
+ if (pkgFiles?.includes("README.md")) refs.push(`[README](${refBase}/pkg/README.md)`);
757
+ }
758
+ if (docsType && docsType !== "readme") refs.push(`[Docs](${refBase}/docs/_INDEX.md)`);
759
+ if (hasIssues) refs.push(`[Issues](${refBase}/issues/_INDEX.md)`);
760
+ if (hasDiscussions) refs.push(`[Discussions](${refBase}/discussions/_INDEX.md)`);
761
+ if (hasReleases) refs.push(`[Releases](${refBase}/releases/_INDEX.md)`);
762
+ if (refs.length > 0) lines.push(`**References:** ${refs.join(" • ")}`);
763
+ return lines.join("\n");
764
+ }
765
+ function expandPackageName(name) {
766
+ const variants = /* @__PURE__ */ new Set();
767
+ const unscoped = name.replace(/^@/, "");
768
+ if (unscoped !== name) {
769
+ variants.add(unscoped);
770
+ variants.add(unscoped.replace(/\//g, " "));
771
+ }
772
+ if (name.includes("-")) {
773
+ const spaced = name.replace(/^@/, "").replace(/\//g, " ").replace(/-/g, " ");
774
+ variants.add(spaced);
775
+ }
776
+ variants.delete(name);
777
+ return [...variants];
778
+ }
779
+ function expandRepoName(repoUrl) {
780
+ const variants = /* @__PURE__ */ new Set();
781
+ const repoName = repoUrl.startsWith("http") ? repoUrl.split("/").pop() : repoUrl.split("/").pop();
782
+ if (!repoName) return [];
783
+ variants.add(repoName);
784
+ if (repoName.includes("-")) variants.add(repoName.replace(/-/g, " "));
785
+ return [...variants];
786
+ }
787
+ function generateFrontmatter({ name, version, description: pkgDescription, globs, body, generatedBy, dirName, packages, repoUrl }) {
788
+ const patterns = globs ?? getFilePatterns(name);
789
+ const globHint = patterns?.length ? ` or working with ${patterns.join(", ")} files` : "";
790
+ const rawDesc = pkgDescription?.replace(/[<>]/g, "").replace(/\.?\s*$/, "");
791
+ const cleanDesc = rawDesc && rawDesc.length > 200 ? `${rawDesc.slice(0, 197)}...` : rawDesc;
792
+ const editHint = globHint ? `editing${globHint} or code importing` : "writing code importing";
793
+ let desc;
794
+ if (packages && packages.length > 1) {
795
+ const importList = packages.map((p) => `"${p.name}"`).join(", ");
796
+ const allKeywords = /* @__PURE__ */ new Set();
797
+ for (const pkg of packages) {
798
+ allKeywords.add(pkg.name);
799
+ for (const kw of expandPackageName(pkg.name)) allKeywords.add(kw);
800
+ }
801
+ const keywordList = [...allKeywords].join(", ");
802
+ desc = `${cleanDesc ? `${cleanDesc}. ` : ""}ALWAYS use when ${editHint} ${importList}. Consult for debugging, best practices, or modifying ${keywordList}.`;
803
+ } else {
804
+ const allKeywords = /* @__PURE__ */ new Set();
805
+ allKeywords.add(name);
806
+ for (const kw of expandPackageName(name)) allKeywords.add(kw);
807
+ if (repoUrl) for (const kw of expandRepoName(repoUrl)) allKeywords.add(kw);
808
+ const nameList = [...allKeywords].join(", ");
809
+ desc = `${cleanDesc ? `${cleanDesc}. ` : ""}ALWAYS use when ${editHint} "${name}". Consult for debugging, best practices, or modifying ${nameList}.`;
810
+ }
811
+ if (desc.length > 1024) desc = `${desc.slice(0, 1021)}...`;
812
+ const lines = [
813
+ "---",
814
+ `name: ${dirName ?? computeSkillDirName(name)}`,
815
+ `description: ${yamlEscape(desc)}`
816
+ ];
817
+ const metaEntries = [];
818
+ if (version) metaEntries.push(` version: ${yamlEscape(version)}`);
819
+ if (body && generatedBy) metaEntries.push(` generated_by: ${yamlEscape(generatedBy)}`);
820
+ metaEntries.push(` generated_at: ${todayIsoDate()}`);
821
+ if (metaEntries.length) {
822
+ lines.push("metadata:");
823
+ lines.push(...metaEntries);
824
+ }
825
+ lines.push("---", "", "");
826
+ return lines.join("\n");
827
+ }
828
+ function generateSearchBlock(name) {
829
+ const cmd = resolveSkilldCommand();
830
+ return `## Search
831
+
832
+ Use \`${cmd} search "query" -p ${name}\` instead of grepping \`.skilld/\` directories. Run \`${cmd} search --guide -p ${name}\` for full syntax, filters, and operators.`;
833
+ }
834
+ function generateFooter(relatedSkills) {
835
+ if (relatedSkills.length === 0) return "";
836
+ return `\nRelated: ${relatedSkills.join(", ")}\n`;
837
+ }
838
+ export { portabilizePrompt as C, maxItems as D, SECTION_OUTPUT_FILES as E, maxLines as O, getSectionValidator as S, SECTION_MERGE_ORDER as T, timedSpinner as _, installSkillForAgents as a, buildSectionPrompt as b, unlinkSkillFromAgents as c, formatSnippet as d, formatSource as f, timeAgo as g, scoreLabel as h, computeSkillDirName as i, resolveSkilldCommand as k, formatCompactSnippet as l, normalizeScores as m, writeGeneratedSkillMd as n, linkSkillToAgents as o, highlightTerms as p, writeSkillMd as r, sanitizeName as s, generateSkillMd as t, formatDuration as u, todayIsoDate as v, wrapSection as w, extractMarkedSections as x, buildAllSectionPrompts as y };
491
839
 
492
840
  //# sourceMappingURL=prompts.mjs.map