skilld 1.7.4 → 2.1.0

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 (172) hide show
  1. package/README.md +25 -0
  2. package/dist/_chunks/add.mjs +67 -0
  3. package/dist/_chunks/add.mjs.map +1 -0
  4. package/dist/_chunks/agent-prompt.mjs +88 -0
  5. package/dist/_chunks/agent-prompt.mjs.map +1 -0
  6. package/dist/_chunks/agent.mjs +359 -157
  7. package/dist/_chunks/agent.mjs.map +1 -1
  8. package/dist/_chunks/args.mjs +42 -0
  9. package/dist/_chunks/args.mjs.map +1 -0
  10. package/dist/_chunks/assemble.mjs +12 -9
  11. package/dist/_chunks/assemble.mjs.map +1 -1
  12. package/dist/_chunks/author.mjs +35 -19
  13. package/dist/_chunks/author.mjs.map +1 -1
  14. package/dist/_chunks/cache.mjs +153 -185
  15. package/dist/_chunks/cache.mjs.map +1 -1
  16. package/dist/_chunks/cache2.mjs +9 -8
  17. package/dist/_chunks/cache2.mjs.map +1 -1
  18. package/dist/_chunks/client.mjs +118 -0
  19. package/dist/_chunks/client.mjs.map +1 -0
  20. package/dist/_chunks/core.mjs +5 -5
  21. package/dist/_chunks/detect.mjs +54 -44
  22. package/dist/_chunks/detect.mjs.map +1 -1
  23. package/dist/_chunks/detect2.mjs +1 -1
  24. package/dist/_chunks/eject.mjs +69 -0
  25. package/dist/_chunks/eject.mjs.map +1 -0
  26. package/dist/_chunks/embedding-cache.mjs +1 -1
  27. package/dist/_chunks/embedding-cache2.mjs +2 -2
  28. package/dist/_chunks/embedding-cache2.mjs.map +1 -1
  29. package/dist/_chunks/env.mjs +19 -0
  30. package/dist/_chunks/env.mjs.map +1 -0
  31. package/dist/_chunks/install-many.mjs +377 -0
  32. package/dist/_chunks/install-many.mjs.map +1 -0
  33. package/dist/_chunks/install.mjs +93 -334
  34. package/dist/_chunks/install.mjs.map +1 -1
  35. package/dist/_chunks/intro.mjs +63 -0
  36. package/dist/_chunks/intro.mjs.map +1 -0
  37. package/dist/_chunks/list.mjs +5 -4
  38. package/dist/_chunks/list.mjs.map +1 -1
  39. package/dist/_chunks/lockfile.mjs +10 -7
  40. package/dist/_chunks/lockfile.mjs.map +1 -1
  41. package/dist/_chunks/login.mjs +234 -0
  42. package/dist/_chunks/login.mjs.map +1 -0
  43. package/dist/_chunks/logout.mjs +27 -0
  44. package/dist/_chunks/logout.mjs.map +1 -0
  45. package/dist/_chunks/map.mjs +11 -0
  46. package/dist/_chunks/map.mjs.map +1 -0
  47. package/dist/_chunks/markdown.mjs +81 -56
  48. package/dist/_chunks/markdown.mjs.map +1 -1
  49. package/dist/_chunks/menu.mjs +33 -0
  50. package/dist/_chunks/menu.mjs.map +1 -0
  51. package/dist/_chunks/model-picker.mjs +61 -0
  52. package/dist/_chunks/model-picker.mjs.map +1 -0
  53. package/dist/_chunks/monorepo.mjs +7 -4
  54. package/dist/_chunks/monorepo.mjs.map +1 -1
  55. package/dist/_chunks/package-json.mjs +7 -5
  56. package/dist/_chunks/package-json.mjs.map +1 -1
  57. package/dist/_chunks/paths.mjs +3 -5
  58. package/dist/_chunks/paths.mjs.map +1 -1
  59. package/dist/_chunks/{sync-pipeline.mjs → pipeline.mjs} +360 -323
  60. package/dist/_chunks/pipeline.mjs.map +1 -0
  61. package/dist/_chunks/pool.mjs +1 -1
  62. package/dist/_chunks/pool2.mjs +2 -2
  63. package/dist/_chunks/pool2.mjs.map +1 -1
  64. package/dist/_chunks/portable.mjs +151 -0
  65. package/dist/_chunks/portable.mjs.map +1 -0
  66. package/dist/_chunks/prepare-hook.mjs +2 -0
  67. package/dist/_chunks/prepare-hook2.mjs +61 -0
  68. package/dist/_chunks/prepare-hook2.mjs.map +1 -0
  69. package/dist/_chunks/prepare.mjs +58 -8
  70. package/dist/_chunks/prepare.mjs.map +1 -1
  71. package/dist/_chunks/prepare2.mjs +14 -11
  72. package/dist/_chunks/prepare2.mjs.map +1 -1
  73. package/dist/_chunks/prompts.mjs +488 -76
  74. package/dist/_chunks/prompts.mjs.map +1 -1
  75. package/dist/_chunks/pull.mjs +220 -0
  76. package/dist/_chunks/pull.mjs.map +1 -0
  77. package/dist/_chunks/regex.mjs +19 -0
  78. package/dist/_chunks/regex.mjs.map +1 -0
  79. package/dist/_chunks/retriv.mjs +2 -171
  80. package/dist/_chunks/retriv2.mjs +159 -0
  81. package/dist/_chunks/retriv2.mjs.map +1 -0
  82. package/dist/_chunks/sanitize.mjs +13 -10
  83. package/dist/_chunks/sanitize.mjs.map +1 -1
  84. package/dist/_chunks/search-helpers.mjs +11 -9
  85. package/dist/_chunks/search-helpers.mjs.map +1 -1
  86. package/dist/_chunks/search-interactive.mjs +25 -22
  87. package/dist/_chunks/search-interactive.mjs.map +1 -1
  88. package/dist/_chunks/search.mjs +6 -6
  89. package/dist/_chunks/search.mjs.map +1 -1
  90. package/dist/_chunks/semver.mjs +2793 -5
  91. package/dist/_chunks/semver.mjs.map +1 -1
  92. package/dist/_chunks/skill-installer.mjs +1 -1
  93. package/dist/_chunks/skill-installer2.mjs +31 -23
  94. package/dist/_chunks/skill-installer2.mjs.map +1 -1
  95. package/dist/_chunks/skills.mjs +9 -10
  96. package/dist/_chunks/skills.mjs.map +1 -1
  97. package/dist/_chunks/store.mjs +107 -0
  98. package/dist/_chunks/store.mjs.map +1 -0
  99. package/dist/_chunks/sync.mjs +422 -915
  100. package/dist/_chunks/sync.mjs.map +1 -1
  101. package/dist/_chunks/sync2.mjs +2 -5
  102. package/dist/_chunks/telemetry.mjs +26 -0
  103. package/dist/_chunks/telemetry.mjs.map +1 -0
  104. package/dist/_chunks/uninstall.mjs +38 -32
  105. package/dist/_chunks/uninstall.mjs.map +1 -1
  106. package/dist/_chunks/update.mjs +172 -0
  107. package/dist/_chunks/update.mjs.map +1 -0
  108. package/dist/_chunks/upload.mjs +16 -13
  109. package/dist/_chunks/upload.mjs.map +1 -1
  110. package/dist/_chunks/validate.mjs +1 -1
  111. package/dist/_chunks/validate.mjs.map +1 -1
  112. package/dist/_chunks/version.mjs +16 -17
  113. package/dist/_chunks/version.mjs.map +1 -1
  114. package/dist/_chunks/whoami.mjs +21 -0
  115. package/dist/_chunks/whoami.mjs.map +1 -0
  116. package/dist/_chunks/wizard.mjs +2 -190
  117. package/dist/_chunks/wizard2.mjs +200 -0
  118. package/dist/_chunks/wizard2.mjs.map +1 -0
  119. package/dist/_chunks/yaml.mjs +1 -1
  120. package/dist/_chunks/yaml.mjs.map +1 -1
  121. package/dist/cli-entry.d.mts +1 -1
  122. package/dist/cli.d.mts +1 -1
  123. package/dist/cli.mjs +94 -71
  124. package/dist/cli.mjs.map +1 -1
  125. package/dist/prepare.d.mts +1 -1
  126. package/dist/prepare.mjs +9 -6
  127. package/dist/prepare.mjs.map +1 -1
  128. package/dist/retriv/worker.d.mts +5 -1
  129. package/dist/retriv/worker.d.mts.map +1 -1
  130. package/dist/retriv/worker.mjs +1 -1
  131. package/dist/retriv/worker.mjs.map +1 -1
  132. package/package.json +27 -37
  133. package/dist/_chunks/author-group.mjs +0 -17
  134. package/dist/_chunks/author-group.mjs.map +0 -1
  135. package/dist/_chunks/cli-helpers.mjs +0 -335
  136. package/dist/_chunks/cli-helpers.mjs.map +0 -1
  137. package/dist/_chunks/cli-helpers2.mjs +0 -2
  138. package/dist/_chunks/index.d.mts +0 -344
  139. package/dist/_chunks/index.d.mts.map +0 -1
  140. package/dist/_chunks/index2.d.mts +0 -279
  141. package/dist/_chunks/index2.d.mts.map +0 -1
  142. package/dist/_chunks/index3.d.mts +0 -44
  143. package/dist/_chunks/index3.d.mts.map +0 -1
  144. package/dist/_chunks/index4.d.mts +0 -553
  145. package/dist/_chunks/index4.d.mts.map +0 -1
  146. package/dist/_chunks/package-registry.mjs +0 -465
  147. package/dist/_chunks/package-registry.mjs.map +0 -1
  148. package/dist/_chunks/retriv.mjs.map +0 -1
  149. package/dist/_chunks/setup.mjs +0 -17
  150. package/dist/_chunks/setup.mjs.map +0 -1
  151. package/dist/_chunks/sources.mjs +0 -2654
  152. package/dist/_chunks/sources.mjs.map +0 -1
  153. package/dist/_chunks/sync-pipeline.mjs.map +0 -1
  154. package/dist/_chunks/sync-registry.mjs +0 -65
  155. package/dist/_chunks/sync-registry.mjs.map +0 -1
  156. package/dist/_chunks/types.d.mts +0 -76
  157. package/dist/_chunks/types.d.mts.map +0 -1
  158. package/dist/_chunks/types2.d.mts +0 -88
  159. package/dist/_chunks/types2.d.mts.map +0 -1
  160. package/dist/_chunks/wizard.mjs.map +0 -1
  161. package/dist/agent/index.d.mts +0 -2
  162. package/dist/agent/index.mjs +0 -4
  163. package/dist/cache/index.d.mts +0 -2
  164. package/dist/cache/index.mjs +0 -5
  165. package/dist/index.d.mts +0 -6
  166. package/dist/index.mjs +0 -6
  167. package/dist/retriv/index.d.mts +0 -3
  168. package/dist/retriv/index.mjs +0 -2
  169. package/dist/sources/index.d.mts +0 -3
  170. package/dist/sources/index.mjs +0 -3
  171. package/dist/types.d.mts +0 -4
  172. package/dist/types.mjs +0 -1
@@ -1,20 +1,19 @@
1
- import { l as getPackageDbPath, p as skillInternalDir, u as getRepoCacheDir } from "./paths.mjs";
2
- import { L as updateConfig, P as readConfig, b as writeToRepoCache, h as listReferenceFiles, k as defaultFeatures, t as createReferenceCache, y as writeToCache } from "./cache.mjs";
3
- import { t as getCacheDir } from "./version.mjs";
4
- import { r as resolvePkgDir } from "./prepare.mjs";
5
- import { n as sanitizeMarkdown } from "./sanitize.mjs";
6
- import { i as parseFrontmatter } from "./markdown.mjs";
7
- import { o as listIndexIds, r as createIndex, t as SearchDepsUnavailableError } from "./retriv.mjs";
8
- import { o as getPrereleaseChangelogRef, t as getBlogPreset } from "./package-registry.mjs";
9
- import { $ as fetchReleaseNotes, C as resolveEntryFiles, D as generateDiscussionIndex, E as formatDiscussionAsMarkdown, F as downloadLlmsDocs, H as formatIssueAsMarkdown, J as isShallowGitDocs, K as fetchGitDocs, L as fetchLlmsTxt, N as fetchReadmeContent, O as fetchCrawledDocs, T as fetchGitHubDiscussions, U as generateIssueIndex, V as fetchGitHubIssues, W as isGhAvailable, Z as fetchBlogReleases, at as fetchGitHubRaw, et as generateReleaseIndex, k as toCrawlPattern, q as filterFrameworkDocs, s as fetchNpmPackage, tt as isPrerelease, ut as parseGitHubUrl, w as generateDocsIndex, z as normalizeLlmsLinks } from "./sources.mjs";
10
- import { a as getModelName, i as getModelLabel, o as createToolProgress, r as getAvailableModels, t as optimizeDocs } from "./agent.mjs";
11
- import { D as maxItems, E as SECTION_OUTPUT_FILES, O as maxLines, T as SECTION_MERGE_ORDER, n as writeGeneratedSkillMd, w as wrapSection, y as buildAllSectionPrompts } from "./prompts.mjs";
12
- import { g as pickModel, n as NO_MODELS_MESSAGE, p as isInteractive } from "./cli-helpers.mjs";
13
- import { c as readLock, t as buildPackageDirMap } from "./lockfile.mjs";
14
- import { t as semverDiff } from "./semver.mjs";
1
+ import { createToolProgress, getAvailableModels, getModelLabel, getModelName, optimizeDocs } from "./agent.mjs";
2
+ import { SECTION_MERGE_ORDER, SECTION_OUTPUT_FILES, buildAllSectionPrompts, getBlogPreset, getPrereleaseChangelogRef, maxItems, maxLines, wrapSection, writeGeneratedSkillMd } from "./prompts.mjs";
3
+ import { getPackageDbPath, getRepoCacheDir, skillInternalDir } from "./paths.mjs";
4
+ import { sanitizeMarkdown } from "./sanitize.mjs";
5
+ import { getCacheDir, resolvePkgDir } from "./prepare.mjs";
6
+ import { createReferenceCache, defaultFeatures, listReferenceFiles, readConfig, updateConfig, writeToRepoCache } from "./cache.mjs";
7
+ import { isInteractive } from "./env.mjs";
8
+ import { NO_MODELS_MESSAGE, pickModel } from "./model-picker.mjs";
9
+ import { downloadLlmsDocs, fetchBlogReleases, fetchCrawledDocs, fetchGitDocs, fetchGitHubDiscussions, fetchGitHubIssues, fetchGitHubRaw, fetchLlmsTxt, fetchNpmPackage, fetchReadmeContent, fetchReleaseNotes, filterFrameworkDocs, formatDiscussionAsMarkdown, formatIssueAsMarkdown, generateDiscussionIndex, generateDocsIndex, generateIssueIndex, generateReleaseIndex, isGhAvailable, isPrerelease, isShallowGitDocs, normalizeLlmsLinks, parseGitHubUrl, resolveEntryFiles, semverDiff, toCrawlPattern } from "./semver.mjs";
10
+ import { parseFrontmatter } from "./markdown.mjs";
11
+ import { buildPackageDirMap, readLock } from "./lockfile.mjs";
12
+ import { SearchDepsUnavailableError, createIndex, listIndexIds } from "./retriv2.mjs";
15
13
  import { existsSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
16
- import { join, relative } from "pathe";
14
+ import { styleText } from "node:util";
17
15
  import * as p from "@clack/prompts";
16
+ import { join, relative } from "pathe";
18
17
  const RATE_LIMIT_RE = /\b429\b|rate.?limit|exhausted.*capacity|quota.*reset/i;
19
18
  async function runSkillEnhancement(ctx, run, onProgress) {
20
19
  const { packageName, cachePackageName, version, skillDir, dirName, resolved, relatedSkills, references, packages, features, overheadLines } = ctx;
@@ -81,8 +80,8 @@ async function enhanceSkillWithLLM(ctx, run) {
81
80
  const costSuffix = costParts.length > 0 ? ` (${costParts.join(", ")})` : "";
82
81
  llmLog.success(`Generated best practices${costSuffix}`);
83
82
  if (debugLogsDir) p.log.info(`Debug logs: ${relative(process.cwd(), debugLogsDir)}`);
84
- if (error) p.log.warn(`\x1B[33mPartial failure: ${error}\x1B[0m`);
85
- if (warnings?.length) for (const w of warnings) p.log.warn(`\x1B[33m${w}\x1B[0m`);
83
+ if (error) p.log.warn(styleText("yellow", `Partial failure: ${error}`));
84
+ if (warnings?.length) for (const w of warnings) p.log.warn(styleText("yellow", w));
86
85
  } else if (error && RATE_LIMIT_RE.test(error)) llmLog.error(`Rate limited by LLM provider. Try again shortly or use a different model via \`skilld config\``);
87
86
  else llmLog.error(`Enhancement failed${error ? `: ${error}` : ""}`);
88
87
  }
@@ -156,7 +155,7 @@ function writePromptFiles(ctx, run) {
156
155
  const relDir = relative(process.cwd(), skillDir);
157
156
  const promptFiles = written.map((s) => `PROMPT_${s}.md`).join(", ");
158
157
  const outputFileList = written.map((s) => SECTION_OUTPUT_FILES[s]).join(", ");
159
- p.log.info(`Prompt files written to ${relDir}/.skilld/\n\x1B[2m\x1B[3m Read each prompt file (${promptFiles}) in ${relDir}/.skilld/, read the\n referenced files, then write your output to the matching file (${outputFileList}).\n When done, run: skilld assemble\x1B[0m`);
158
+ p.log.info(`Prompt files written to ${relDir}/.skilld/\n${styleText(["dim", "italic"], ` Read each prompt file (${promptFiles}) in ${relDir}/.skilld/, read the\n referenced files, then write your output to the matching file (${outputFileList}).\n When done, run: skilld assemble`)}`);
160
159
  }
161
160
  return written;
162
161
  }
@@ -210,11 +209,9 @@ async function selectSkillSections(message = "Enhance SKILL.md") {
210
209
  budgetLines.push(` API changes ${maxItems(6, 12, n)}–${maxItems(6, Math.round(12 * 1.6), n)} items (adapts to release churn)`);
211
210
  break;
212
211
  case "best-practices":
213
- budgetLines.push(` Best practices ${maxItems(4, 10, n)}–${maxItems(4, Math.round(10 * 1.3), n)} items`);
214
- break;
215
- case "custom":
216
- budgetLines.push(` Custom ≤${maxLines(50, 80, n)} lines`);
212
+ budgetLines.push(` Best practices ${maxItems(4, 10, n)}–${maxItems(4, Math.round(13), n)} items`);
217
213
  break;
214
+ case "custom": budgetLines.push(` Custom ≤${maxLines(50, 80, n)} lines`);
218
215
  }
219
216
  p.log.info(`Budget (${n} sections):\n${budgetLines.join("\n")}`);
220
217
  }
@@ -265,7 +262,7 @@ async function selectLlmConfig(presetModel, message, updateCtx) {
265
262
  let defaultModel;
266
263
  if (config.model && available.some((m) => m.id === config.model)) defaultModel = config.model;
267
264
  else {
268
- if (config.model) p.log.warn(`Configured model \x1B[36m${config.model}\x1B[0m is unavailable — using auto-selected fallback`);
265
+ if (config.model) p.log.warn(`Configured model ${styleText("cyan", config.model)} is unavailable — using auto-selected fallback`);
269
266
  defaultModel = available.find((m) => m.recommended)?.id ?? available[0].id;
270
267
  }
271
268
  const defaultModelName = getModelName(defaultModel);
@@ -288,7 +285,7 @@ async function selectLlmConfig(presetModel, message, updateCtx) {
288
285
  }
289
286
  if (updateCtx.wasEnhanced) ageParts.push("LLM-enhanced");
290
287
  const hint = [updateCtx.oldVersion && updateCtx.newVersion ? `${updateCtx.oldVersion} → ${updateCtx.newVersion}` : null, ...ageParts].filter(Boolean).join(" · ");
291
- if (hint) enhanceMessage = `Enhance SKILL.md? \x1B[90m(${hint})\x1B[0m`;
288
+ if (hint) enhanceMessage = `Enhance SKILL.md? ${styleText("gray", `(${hint})`)}`;
292
289
  if (updateCtx.wasEnhanced && isSmallBump) defaultToSkip = true;
293
290
  }
294
291
  const choice = await p.select({
@@ -400,7 +397,8 @@ async function indexResources(opts) {
400
397
  onProgress: ({ phase, current, total }) => {
401
398
  if (phase === "storing") {
402
399
  const d = allDocs[current - 1];
403
- onProgress(`Storing ${d?.metadata?.type === "source" || d?.metadata?.type === "types" ? "code" : d?.metadata?.type || "doc"} (${current}/${total})`);
400
+ const type = d?.metadata?.type === "source" || d?.metadata?.type === "types" ? "code" : d?.metadata?.type || "doc";
401
+ onProgress(`Storing ${type} (${current}/${total})`);
404
402
  } else if (phase === "embedding") onProgress(`Creating embeddings (${current}/${total})`);
405
403
  }
406
404
  });
@@ -439,7 +437,8 @@ async function indexResources(opts) {
439
437
  onProgress: ({ phase, current, total }) => {
440
438
  if (phase === "storing") {
441
439
  const d = newDocs[current - 1];
442
- onProgress(`Storing ${d?.metadata?.type === "source" || d?.metadata?.type === "types" ? "code" : d?.metadata?.type || "doc"} (${current}/${total})`);
440
+ const type = d?.metadata?.type === "source" || d?.metadata?.type === "types" ? "code" : d?.metadata?.type || "doc";
441
+ onProgress(`Storing ${type} (${current}/${total})`);
443
442
  } else if (phase === "embedding") onProgress(`Creating embeddings (${current}/${total})`);
444
443
  }
445
444
  });
@@ -448,241 +447,378 @@ async function indexResources(opts) {
448
447
  else throw err;
449
448
  }
450
449
  }
451
- async function resolveContentDocs(opts) {
452
- const { packageName, resolved, version, onProgress } = opts;
453
- const docs = [];
454
- const docsToIndex = [];
455
- const warnings = [];
456
- let docSource = resolved.readmeUrl || "readme";
457
- let docsType = "readme";
458
- const isFrameworkDoc = (path) => filterFrameworkDocs([path], packageName).length > 0;
459
- if (resolved.gitDocsUrl && resolved.repoUrl) {
460
- const gh = parseGitHubUrl(resolved.repoUrl);
461
- if (gh) {
462
- const r = await tryGitDocs({
463
- owner: gh.owner,
464
- repo: gh.repo,
465
- version,
466
- packageName,
467
- repoUrl: resolved.repoUrl,
468
- llmsUrl: resolved.llmsUrl,
469
- docsUrl: resolved.docsUrl,
470
- onProgress
471
- });
472
- if (r) {
473
- docs.push(...r.docs);
474
- docsToIndex.push(...r.docsToIndex);
475
- if (r.warning) warnings.push(r.warning);
476
- if (r.kind === "git") {
477
- docSource = r.docSource;
478
- docsType = "docs";
450
+ function defineStep(step) {
451
+ return step;
452
+ }
453
+ async function walkSteps(steps, ctx) {
454
+ for (const step of steps) {
455
+ if (step.canResolve && !step.canResolve(ctx)) continue;
456
+ await step.run(ctx);
457
+ }
458
+ }
459
+ const crawlUrlStep = defineStep({
460
+ id: "crawl-url",
461
+ canResolve: (ctx) => !!ctx.resolved.crawlUrl && ctx.docs.length === 0,
462
+ async run(ctx) {
463
+ const crawlUrl = ctx.resolved.crawlUrl;
464
+ ctx.onProgress("Crawling website");
465
+ const crawled = await fetchCrawledDocs(crawlUrl, ctx.onProgress).catch((err) => {
466
+ ctx.warnings.push(`Crawl failed for ${crawlUrl}: ${err?.message || err}`);
467
+ return [];
468
+ });
469
+ if (crawled.length === 0) ctx.warnings.push(`Crawl returned 0 docs from ${crawlUrl}`);
470
+ let added = 0;
471
+ for (const doc of crawled) {
472
+ if (!ctx.isFrameworkDoc(doc.path)) continue;
473
+ ctx.docs.push(doc);
474
+ ctx.docsToIndex.push({
475
+ id: doc.path,
476
+ content: doc.content,
477
+ metadata: {
478
+ package: ctx.packageName,
479
+ source: doc.path,
480
+ type: "doc"
479
481
  }
480
- }
482
+ });
483
+ added++;
484
+ }
485
+ if (added > 0) {
486
+ ctx.docSource = crawlUrl;
487
+ ctx.docsType = "docs";
481
488
  }
482
489
  }
483
- if (resolved.crawlUrl && docs.length === 0) {
484
- onProgress("Crawling website");
485
- const crawled = await fetchCrawledDocs(resolved.crawlUrl, onProgress).catch((err) => {
486
- warnings.push(`Crawl failed for ${resolved.crawlUrl}: ${err?.message || err}`);
490
+ });
491
+ const docsCrawlStep = defineStep({
492
+ id: "docs-crawl",
493
+ canResolve: (ctx) => !!ctx.resolved.docsUrl && !ctx.docs.some((d) => d.path.startsWith("docs/")),
494
+ async run(ctx) {
495
+ const crawlPattern = ctx.resolved.crawlUrl || toCrawlPattern(ctx.resolved.docsUrl);
496
+ ctx.onProgress("Crawling docs site");
497
+ const maxPages = ctx.resolved.crawlUrl ? 200 : 400;
498
+ const crawled = await fetchCrawledDocs(crawlPattern, ctx.onProgress, maxPages).catch((err) => {
499
+ ctx.warnings.push(`Crawl failed for ${crawlPattern}: ${err?.message || err}`);
487
500
  return [];
488
501
  });
489
- if (crawled.length === 0) warnings.push(`Crawl returned 0 docs from ${resolved.crawlUrl}`);
502
+ let added = 0;
490
503
  for (const doc of crawled) {
491
- if (!isFrameworkDoc(doc.path)) continue;
492
- docs.push(doc);
493
- docsToIndex.push({
504
+ if (!ctx.isFrameworkDoc(doc.path)) continue;
505
+ ctx.docs.push(doc);
506
+ ctx.docsToIndex.push({
494
507
  id: doc.path,
495
508
  content: doc.content,
496
509
  metadata: {
497
- package: packageName,
510
+ package: ctx.packageName,
498
511
  source: doc.path,
499
512
  type: "doc"
500
513
  }
501
514
  });
515
+ added++;
502
516
  }
503
- if (docs.length > 0) {
504
- docSource = resolved.crawlUrl;
505
- docsType = "docs";
517
+ if (added > 0) {
518
+ ctx.docSource = crawlPattern;
519
+ ctx.docsType = "docs";
506
520
  }
507
521
  }
508
- if (resolved.llmsUrl && docs.length === 0) {
509
- onProgress("Fetching llms.txt");
510
- const llmsContent = await fetchLlmsTxt(resolved.llmsUrl);
511
- if (llmsContent) {
512
- docSource = resolved.llmsUrl;
513
- docsType = "llms.txt";
514
- const baseUrl = resolved.docsUrl || new URL(resolved.llmsUrl).origin;
515
- docs.push({
522
+ });
523
+ const BATCH_SIZE = 20;
524
+ const defaultContentSteps = [
525
+ defineStep({
526
+ id: "git-docs",
527
+ canResolve: (ctx) => !!ctx.resolved.gitDocsUrl && !!ctx.resolved.repoUrl,
528
+ async run(ctx) {
529
+ const gh = parseGitHubUrl(ctx.resolved.repoUrl);
530
+ if (!gh) return;
531
+ ctx.onProgress("Fetching git docs");
532
+ const gitDocs = await fetchGitDocs(gh.owner, gh.repo, ctx.version, ctx.packageName);
533
+ if (!gitDocs || gitDocs.files.length === 0) return;
534
+ if (gitDocs.fallback) ctx.warnings.push(`Docs fetched from ${gitDocs.ref} branch (no tag found for v${ctx.version})`);
535
+ const results = [];
536
+ for (let i = 0; i < gitDocs.files.length; i += BATCH_SIZE) {
537
+ const batch = gitDocs.files.slice(i, i + BATCH_SIZE);
538
+ ctx.onProgress(`Downloading docs ${Math.min(i + BATCH_SIZE, gitDocs.files.length)}/${gitDocs.files.length} from ${gitDocs.ref}`);
539
+ const batchResults = await Promise.all(batch.map(async (file) => {
540
+ const url = `${gitDocs.baseUrl}/${file}`;
541
+ const content = await fetchGitHubRaw(url);
542
+ return content ? {
543
+ file,
544
+ content
545
+ } : null;
546
+ }));
547
+ results.push(...batchResults);
548
+ }
549
+ const docs = [];
550
+ const docsToIndex = [];
551
+ for (const r of results) {
552
+ if (!r) continue;
553
+ const stripped = gitDocs.docsPrefix ? r.file.replace(gitDocs.docsPrefix, "") : r.file;
554
+ const cachePath = stripped.startsWith("docs/") ? stripped : `docs/${stripped}`;
555
+ docs.push({
556
+ path: cachePath,
557
+ content: r.content
558
+ });
559
+ docsToIndex.push({
560
+ id: cachePath,
561
+ content: r.content,
562
+ metadata: {
563
+ package: ctx.packageName,
564
+ source: cachePath,
565
+ type: "doc"
566
+ }
567
+ });
568
+ }
569
+ if (isShallowGitDocs(docs.length) && ctx.resolved.llmsUrl) {
570
+ ctx.onProgress(`Shallow git-docs (${docs.length} files), trying llms.txt`);
571
+ return;
572
+ }
573
+ ctx.docs.push(...docs);
574
+ ctx.docsToIndex.push(...docsToIndex);
575
+ ctx.docSource = `${ctx.resolved.repoUrl}/tree/${gitDocs.ref}/docs`;
576
+ ctx.docsType = "docs";
577
+ if (ctx.resolved.llmsUrl) {
578
+ ctx.onProgress("Caching supplementary llms.txt");
579
+ const llmsContent = await fetchLlmsTxt(ctx.resolved.llmsUrl);
580
+ if (llmsContent) {
581
+ const baseUrl = ctx.resolved.docsUrl || new URL(ctx.resolved.llmsUrl).origin;
582
+ ctx.docs.push({
583
+ path: "llms.txt",
584
+ content: normalizeLlmsLinks(llmsContent.raw, baseUrl)
585
+ });
586
+ if (llmsContent.links.length > 0) {
587
+ ctx.onProgress(`Downloading ${llmsContent.links.length} supplementary docs`);
588
+ const supplementary = await downloadLlmsDocs(llmsContent, baseUrl, (_url, done, total) => {
589
+ ctx.onProgress(`Downloading supplementary doc ${done + 1}/${total}`);
590
+ });
591
+ for (const doc of supplementary) {
592
+ if (!ctx.isFrameworkDoc(doc.url)) continue;
593
+ const localPath = doc.url.startsWith("/") ? doc.url.slice(1) : doc.url;
594
+ ctx.docs.push({
595
+ path: join("llms-docs", ...localPath.split("/")),
596
+ content: doc.content
597
+ });
598
+ }
599
+ }
600
+ }
601
+ }
602
+ }
603
+ }),
604
+ crawlUrlStep,
605
+ defineStep({
606
+ id: "llms.txt",
607
+ canResolve: (ctx) => !!ctx.resolved.llmsUrl && ctx.docs.length === 0,
608
+ async run(ctx) {
609
+ const llmsUrl = ctx.resolved.llmsUrl;
610
+ ctx.onProgress("Fetching llms.txt");
611
+ const llmsContent = await fetchLlmsTxt(llmsUrl);
612
+ if (!llmsContent) return;
613
+ ctx.docSource = llmsUrl;
614
+ ctx.docsType = "llms.txt";
615
+ const baseUrl = ctx.resolved.docsUrl || new URL(llmsUrl).origin;
616
+ ctx.docs.push({
516
617
  path: "llms.txt",
517
618
  content: normalizeLlmsLinks(llmsContent.raw, baseUrl)
518
619
  });
519
620
  if (llmsContent.links.length > 0) {
520
- onProgress(`Downloading ${llmsContent.links.length} linked docs`);
621
+ ctx.onProgress(`Downloading ${llmsContent.links.length} linked docs`);
521
622
  const linked = await downloadLlmsDocs(llmsContent, baseUrl, (_url, done, total) => {
522
- onProgress(`Downloading linked doc ${done + 1}/${total}`);
623
+ ctx.onProgress(`Downloading linked doc ${done + 1}/${total}`);
523
624
  });
524
625
  for (const doc of linked) {
525
- if (!isFrameworkDoc(doc.url)) continue;
526
- const cachePath = join("docs", ...(doc.url.startsWith("/") ? doc.url.slice(1) : doc.url).split("/"));
527
- docs.push({
626
+ if (!ctx.isFrameworkDoc(doc.url)) continue;
627
+ const localPath = doc.url.startsWith("/") ? doc.url.slice(1) : doc.url;
628
+ const cachePath = join("docs", ...localPath.split("/"));
629
+ ctx.docs.push({
528
630
  path: cachePath,
529
631
  content: doc.content
530
632
  });
531
- docsToIndex.push({
633
+ ctx.docsToIndex.push({
532
634
  id: doc.url,
533
635
  content: doc.content,
534
636
  metadata: {
535
- package: packageName,
637
+ package: ctx.packageName,
536
638
  source: cachePath,
537
639
  type: "doc"
538
640
  }
539
641
  });
540
642
  }
541
- if (linked.length > 0) docsType = "docs";
643
+ if (linked.length > 0) ctx.docsType = "docs";
542
644
  }
543
645
  }
544
- }
545
- if (resolved.docsUrl && !docs.some((d) => d.path.startsWith("docs/"))) {
546
- const crawlPattern = resolved.crawlUrl || toCrawlPattern(resolved.docsUrl);
547
- onProgress("Crawling docs site");
548
- const crawled = await fetchCrawledDocs(crawlPattern, onProgress, resolved.crawlUrl ? 200 : 400).catch((err) => {
549
- warnings.push(`Crawl failed for ${crawlPattern}: ${err?.message || err}`);
550
- return [];
551
- });
552
- let added = 0;
553
- for (const doc of crawled) {
554
- if (!isFrameworkDoc(doc.path)) continue;
555
- docs.push(doc);
556
- docsToIndex.push({
557
- id: doc.path,
558
- content: doc.content,
559
- metadata: {
560
- package: packageName,
561
- source: doc.path,
562
- type: "doc"
563
- }
564
- });
565
- added++;
566
- }
567
- if (added > 0) {
568
- docSource = crawlPattern;
569
- docsType = "docs";
570
- }
571
- }
572
- if (resolved.readmeUrl && docs.length === 0) {
573
- onProgress("Fetching README");
574
- const content = await fetchReadmeContent(resolved.readmeUrl);
575
- if (content) {
576
- docs.push({
646
+ }),
647
+ docsCrawlStep,
648
+ defineStep({
649
+ id: "readme",
650
+ canResolve: (ctx) => !!ctx.resolved.readmeUrl && ctx.docs.length === 0,
651
+ async run(ctx) {
652
+ ctx.onProgress("Fetching README");
653
+ const content = await fetchReadmeContent(ctx.resolved.readmeUrl);
654
+ if (!content) return;
655
+ ctx.docs.push({
577
656
  path: "docs/README.md",
578
657
  content
579
658
  });
580
- docsToIndex.push({
659
+ ctx.docsToIndex.push({
581
660
  id: "README.md",
582
661
  content,
583
662
  metadata: {
584
- package: packageName,
663
+ package: ctx.packageName,
585
664
  source: "docs/README.md",
586
665
  type: "doc"
587
666
  }
588
667
  });
589
668
  }
590
- }
669
+ })
670
+ ];
671
+ async function resolveContentDocs(opts) {
672
+ const { packageName, resolved, version, onProgress } = opts;
673
+ const ctx = {
674
+ packageName,
675
+ resolved,
676
+ version,
677
+ onProgress,
678
+ isFrameworkDoc: (path) => filterFrameworkDocs([path], packageName).length > 0,
679
+ docs: [],
680
+ docsToIndex: [],
681
+ warnings: [],
682
+ docSource: resolved.readmeUrl || "readme",
683
+ docsType: "readme"
684
+ };
685
+ await walkSteps(defaultContentSteps, ctx);
591
686
  return {
592
- docs,
593
- docsToIndex,
594
- docSource,
595
- docsType,
596
- warnings
687
+ docs: ctx.docs,
688
+ docsToIndex: ctx.docsToIndex,
689
+ docSource: ctx.docSource,
690
+ docsType: ctx.docsType,
691
+ warnings: ctx.warnings
597
692
  };
598
693
  }
599
- async function tryGitDocs(opts) {
600
- const { owner, repo, version, packageName, repoUrl, llmsUrl, docsUrl, onProgress } = opts;
601
- onProgress("Fetching git docs");
602
- const gitDocs = await fetchGitDocs(owner, repo, version, packageName);
603
- if (!gitDocs || gitDocs.files.length === 0) return null;
604
- let warning;
605
- if (gitDocs.fallback) warning = `Docs fetched from ${gitDocs.ref} branch (no tag found for v${version})`;
606
- const BATCH_SIZE = 20;
607
- const results = [];
608
- for (let i = 0; i < gitDocs.files.length; i += BATCH_SIZE) {
609
- const batch = gitDocs.files.slice(i, i + BATCH_SIZE);
610
- onProgress(`Downloading docs ${Math.min(i + BATCH_SIZE, gitDocs.files.length)}/${gitDocs.files.length} from ${gitDocs.ref}`);
611
- const batchResults = await Promise.all(batch.map(async (file) => {
612
- const content = await fetchGitHubRaw(`${gitDocs.baseUrl}/${file}`);
613
- return content ? {
614
- file,
615
- content
616
- } : null;
617
- }));
618
- results.push(...batchResults);
619
- }
620
- const docs = [];
621
- const docsToIndex = [];
622
- for (const r of results) {
623
- if (!r) continue;
624
- const stripped = gitDocs.docsPrefix ? r.file.replace(gitDocs.docsPrefix, "") : r.file;
625
- const cachePath = stripped.startsWith("docs/") ? stripped : `docs/${stripped}`;
626
- docs.push({
627
- path: cachePath,
628
- content: r.content
629
- });
630
- docsToIndex.push({
631
- id: cachePath,
632
- content: r.content,
694
+ const discussionsStep = defineStep({
695
+ id: "discussions",
696
+ canResolve: (ctx) => ctx.features.discussions && !!ctx.repoInfo && isGhAvailable() && !existsSync(ctx.discussionsDir),
697
+ async run(ctx) {
698
+ const { owner, repo } = ctx.repoInfo;
699
+ ctx.onProgress("Fetching discussions via GitHub API");
700
+ const discussions = await fetchGitHubDiscussions(owner, repo, 20, ctx.resolved.releasedAt, ctx.from).catch(() => []);
701
+ if (discussions.length === 0) return;
702
+ ctx.onProgress(`Caching ${discussions.length} discussions`);
703
+ const docs = [...discussions.map((d) => ({
704
+ path: `discussions/discussion-${d.number}.md`,
705
+ content: formatDiscussionAsMarkdown(d)
706
+ })), {
707
+ path: "discussions/_INDEX.md",
708
+ content: generateDiscussionIndex(discussions)
709
+ }];
710
+ writeToRepoCache(owner, repo, docs);
711
+ for (const d of discussions) ctx.docsToIndex.push({
712
+ id: `discussion-${d.number}`,
713
+ content: sanitizeMarkdown(`#${d.number}: ${d.title}\n\n${d.body || ""}`),
633
714
  metadata: {
634
- package: packageName,
635
- source: cachePath,
636
- type: "doc"
715
+ package: ctx.packageName,
716
+ source: `discussions/discussion-${d.number}.md`,
717
+ type: "discussion",
718
+ number: d.number
637
719
  }
638
720
  });
639
721
  }
640
- if (isShallowGitDocs(docs.length) && llmsUrl) {
641
- onProgress(`Shallow git-docs (${docs.length} files), trying llms.txt`);
642
- return {
643
- kind: "discarded",
644
- docs: [],
645
- docsToIndex: [],
646
- docSource: "",
647
- warning
648
- };
722
+ });
723
+ const issuesStep = defineStep({
724
+ id: "issues",
725
+ canResolve: (ctx) => ctx.features.issues && !!ctx.repoInfo && isGhAvailable() && !existsSync(ctx.issuesDir),
726
+ async run(ctx) {
727
+ const { owner, repo } = ctx.repoInfo;
728
+ ctx.onProgress("Fetching issues via GitHub API");
729
+ const issues = await fetchGitHubIssues(owner, repo, 30, ctx.resolved.releasedAt, ctx.from).catch(() => []);
730
+ if (issues.length === 0) return;
731
+ ctx.onProgress(`Caching ${issues.length} issues`);
732
+ const docs = [...issues.map((issue) => ({
733
+ path: `issues/issue-${issue.number}.md`,
734
+ content: formatIssueAsMarkdown(issue)
735
+ })), {
736
+ path: "issues/_INDEX.md",
737
+ content: generateIssueIndex(issues)
738
+ }];
739
+ writeToRepoCache(owner, repo, docs);
740
+ for (const issue of issues) ctx.docsToIndex.push({
741
+ id: `issue-${issue.number}`,
742
+ content: sanitizeMarkdown(`#${issue.number}: ${issue.title}\n\n${issue.body || ""}`),
743
+ metadata: {
744
+ package: ctx.packageName,
745
+ source: `issues/issue-${issue.number}.md`,
746
+ type: "issue",
747
+ number: issue.number
748
+ }
749
+ });
649
750
  }
650
- if (llmsUrl) {
651
- onProgress("Caching supplementary llms.txt");
652
- const llmsContent = await fetchLlmsTxt(llmsUrl);
653
- if (llmsContent) {
654
- const baseUrl = docsUrl || new URL(llmsUrl).origin;
655
- docs.push({
656
- path: "llms.txt",
657
- content: normalizeLlmsLinks(llmsContent.raw, baseUrl)
751
+ });
752
+ const BLOG_VERSION_RE = /blog-(.+)\.md$/;
753
+ const defaultTimelineSteps = [
754
+ issuesStep,
755
+ discussionsStep,
756
+ defineStep({
757
+ id: "releases",
758
+ canResolve: (ctx) => ctx.features.releases && !!ctx.repoInfo && isGhAvailable() && !existsSync(ctx.releasesPath),
759
+ async run(ctx) {
760
+ const { owner, repo } = ctx.repoInfo;
761
+ const { packageName, version, resolved, from } = ctx;
762
+ ctx.onProgress("Fetching releases via GitHub API");
763
+ const changelogRef = isPrerelease(version) ? getPrereleaseChangelogRef(packageName) : void 0;
764
+ const releaseDocs = await fetchReleaseNotes(owner, repo, version, resolved.gitRef, packageName, from, changelogRef).catch(() => []);
765
+ let blogDocs = [];
766
+ if (getBlogPreset(packageName)) {
767
+ ctx.onProgress("Fetching blog release notes");
768
+ blogDocs = await fetchBlogReleases(packageName, version).catch(() => []);
769
+ }
770
+ const allDocs = [...releaseDocs, ...blogDocs];
771
+ const blogEntries = blogDocs.filter((d) => !d.path.endsWith("_INDEX.md")).map((d) => {
772
+ const versionMatch = d.path.match(BLOG_VERSION_RE);
773
+ const fm = parseFrontmatter(d.content);
774
+ return {
775
+ version: versionMatch?.[1] ?? "",
776
+ title: fm.title ?? `Release ${versionMatch?.[1]}`,
777
+ date: fm.date ?? ""
778
+ };
779
+ }).filter((b) => b.version);
780
+ const ghReleases = releaseDocs.filter((d) => d.path.startsWith("releases/") && !d.path.endsWith("CHANGELOG.md")).map((d) => {
781
+ const fm = parseFrontmatter(d.content);
782
+ const tag = fm.tag ?? "";
783
+ const name = fm.name ?? tag;
784
+ const published = fm.published ?? "";
785
+ return {
786
+ id: 0,
787
+ tag,
788
+ name,
789
+ prerelease: false,
790
+ createdAt: published,
791
+ publishedAt: published,
792
+ markdown: ""
793
+ };
794
+ }).filter((r) => r.tag);
795
+ const hasChangelog = allDocs.some((d) => d.path === "releases/CHANGELOG.md");
796
+ if (ghReleases.length > 0 || blogEntries.length > 0) allDocs.push({
797
+ path: "releases/_INDEX.md",
798
+ content: generateReleaseIndex({
799
+ releases: ghReleases,
800
+ packageName,
801
+ blogReleases: blogEntries,
802
+ hasChangelog
803
+ })
658
804
  });
659
- if (llmsContent.links.length > 0) {
660
- onProgress(`Downloading ${llmsContent.links.length} supplementary docs`);
661
- const supplementary = await downloadLlmsDocs(llmsContent, baseUrl, (_url, done, total) => {
662
- onProgress(`Downloading supplementary doc ${done + 1}/${total}`);
663
- });
664
- for (const doc of supplementary) {
665
- if (filterFrameworkDocs([doc.url], packageName).length === 0) continue;
666
- const localPath = doc.url.startsWith("/") ? doc.url.slice(1) : doc.url;
667
- docs.push({
668
- path: join("llms-docs", ...localPath.split("/")),
669
- content: doc.content
670
- });
805
+ if (allDocs.length === 0) return;
806
+ ctx.onProgress(`Caching ${allDocs.length} releases`);
807
+ writeToRepoCache(owner, repo, allDocs);
808
+ for (const doc of allDocs) ctx.docsToIndex.push({
809
+ id: doc.path,
810
+ content: doc.content,
811
+ metadata: {
812
+ package: packageName,
813
+ source: doc.path,
814
+ type: "release"
671
815
  }
672
- }
816
+ });
673
817
  }
674
- }
675
- return {
676
- kind: "git",
677
- docs,
678
- docsToIndex,
679
- docSource: `${repoUrl}/tree/${gitDocs.ref}/docs`,
680
- warning
681
- };
682
- }
818
+ })
819
+ ];
683
820
  async function resolveTimelineReferences(opts) {
684
821
  const { packageName, resolved, version, features, from, onProgress } = opts;
685
- const docsToIndex = [];
686
822
  const gh = resolved.repoUrl ? parseGitHubUrl(resolved.repoUrl) : null;
687
823
  const repoInfo = gh ? {
688
824
  owner: gh.owner,
@@ -690,125 +826,25 @@ async function resolveTimelineReferences(opts) {
690
826
  } : void 0;
691
827
  const repoCacheDir = repoInfo ? getRepoCacheDir(repoInfo.owner, repoInfo.repo) : null;
692
828
  const cacheDir = getCacheDir(packageName, version);
693
- const issuesDir = repoCacheDir ? join(repoCacheDir, "issues") : join(cacheDir, "issues");
694
- const discussionsDir = repoCacheDir ? join(repoCacheDir, "discussions") : join(cacheDir, "discussions");
695
- const releasesPath = repoCacheDir ? join(repoCacheDir, "releases") : join(cacheDir, "releases");
696
- if (features.issues && gh && isGhAvailable() && !existsSync(issuesDir)) {
697
- onProgress("Fetching issues via GitHub API");
698
- const issues = await fetchGitHubIssues(gh.owner, gh.repo, 30, resolved.releasedAt, from).catch(() => []);
699
- if (issues.length > 0) {
700
- onProgress(`Caching ${issues.length} issues`);
701
- const issueDocs = [...issues.map((issue) => ({
702
- path: `issues/issue-${issue.number}.md`,
703
- content: formatIssueAsMarkdown(issue)
704
- })), {
705
- path: "issues/_INDEX.md",
706
- content: generateIssueIndex(issues)
707
- }];
708
- if (repoInfo) writeToRepoCache(repoInfo.owner, repoInfo.repo, issueDocs);
709
- else writeToCache(packageName, version, issueDocs);
710
- for (const issue of issues) docsToIndex.push({
711
- id: `issue-${issue.number}`,
712
- content: sanitizeMarkdown(`#${issue.number}: ${issue.title}\n\n${issue.body || ""}`),
713
- metadata: {
714
- package: packageName,
715
- source: `issues/issue-${issue.number}.md`,
716
- type: "issue",
717
- number: issue.number
718
- }
719
- });
720
- }
721
- }
722
- if (features.discussions && gh && isGhAvailable() && !existsSync(discussionsDir)) {
723
- onProgress("Fetching discussions via GitHub API");
724
- const discussions = await fetchGitHubDiscussions(gh.owner, gh.repo, 20, resolved.releasedAt, from).catch(() => []);
725
- if (discussions.length > 0) {
726
- onProgress(`Caching ${discussions.length} discussions`);
727
- const discussionDocs = [...discussions.map((d) => ({
728
- path: `discussions/discussion-${d.number}.md`,
729
- content: formatDiscussionAsMarkdown(d)
730
- })), {
731
- path: "discussions/_INDEX.md",
732
- content: generateDiscussionIndex(discussions)
733
- }];
734
- if (repoInfo) writeToRepoCache(repoInfo.owner, repoInfo.repo, discussionDocs);
735
- else writeToCache(packageName, version, discussionDocs);
736
- for (const d of discussions) docsToIndex.push({
737
- id: `discussion-${d.number}`,
738
- content: sanitizeMarkdown(`#${d.number}: ${d.title}\n\n${d.body || ""}`),
739
- metadata: {
740
- package: packageName,
741
- source: `discussions/discussion-${d.number}.md`,
742
- type: "discussion",
743
- number: d.number
744
- }
745
- });
746
- }
747
- }
748
- if (features.releases && gh && isGhAvailable() && !existsSync(releasesPath)) {
749
- onProgress("Fetching releases via GitHub API");
750
- const changelogRef = isPrerelease(version) ? getPrereleaseChangelogRef(packageName) : void 0;
751
- const releaseDocs = await fetchReleaseNotes(gh.owner, gh.repo, version, resolved.gitRef, packageName, from, changelogRef).catch(() => []);
752
- let blogDocs = [];
753
- if (getBlogPreset(packageName)) {
754
- onProgress("Fetching blog release notes");
755
- blogDocs = await fetchBlogReleases(packageName, version).catch(() => []);
756
- }
757
- const allDocs = [...releaseDocs, ...blogDocs];
758
- const blogEntries = blogDocs.filter((d) => !d.path.endsWith("_INDEX.md")).map((d) => {
759
- const versionMatch = d.path.match(/blog-(.+)\.md$/);
760
- const fm = parseFrontmatter(d.content);
761
- return {
762
- version: versionMatch?.[1] ?? "",
763
- title: fm.title ?? `Release ${versionMatch?.[1]}`,
764
- date: fm.date ?? ""
765
- };
766
- }).filter((b) => b.version);
767
- const ghReleases = releaseDocs.filter((d) => d.path.startsWith("releases/") && !d.path.endsWith("CHANGELOG.md")).map((d) => {
768
- const fm = parseFrontmatter(d.content);
769
- const tag = fm.tag ?? "";
770
- const name = fm.name ?? tag;
771
- const published = fm.published ?? "";
772
- return {
773
- id: 0,
774
- tag,
775
- name,
776
- prerelease: false,
777
- createdAt: published,
778
- publishedAt: published,
779
- markdown: ""
780
- };
781
- }).filter((r) => r.tag);
782
- const hasChangelog = allDocs.some((d) => d.path === "releases/CHANGELOG.md");
783
- if (ghReleases.length > 0 || blogEntries.length > 0) allDocs.push({
784
- path: "releases/_INDEX.md",
785
- content: generateReleaseIndex({
786
- releases: ghReleases,
787
- packageName,
788
- blogReleases: blogEntries,
789
- hasChangelog
790
- })
791
- });
792
- if (allDocs.length > 0) {
793
- onProgress(`Caching ${allDocs.length} releases`);
794
- if (repoInfo) writeToRepoCache(repoInfo.owner, repoInfo.repo, allDocs);
795
- else writeToCache(packageName, version, allDocs);
796
- for (const doc of allDocs) docsToIndex.push({
797
- id: doc.path,
798
- content: doc.content,
799
- metadata: {
800
- package: packageName,
801
- source: doc.path,
802
- type: "release"
803
- }
804
- });
805
- }
806
- }
829
+ const ctx = {
830
+ packageName,
831
+ version,
832
+ resolved,
833
+ features,
834
+ from,
835
+ onProgress,
836
+ repoInfo,
837
+ issuesDir: repoCacheDir ? join(repoCacheDir, "issues") : join(cacheDir, "issues"),
838
+ discussionsDir: repoCacheDir ? join(repoCacheDir, "discussions") : join(cacheDir, "discussions"),
839
+ releasesPath: repoCacheDir ? join(repoCacheDir, "releases") : join(cacheDir, "releases"),
840
+ docsToIndex: []
841
+ };
842
+ await walkSteps(defaultTimelineSteps, ctx);
807
843
  return {
808
- docsToIndex,
809
- hasIssues: features.issues && existsSync(issuesDir),
810
- hasDiscussions: features.discussions && existsSync(discussionsDir),
811
- hasReleases: features.releases && existsSync(releasesPath),
844
+ docsToIndex: ctx.docsToIndex,
845
+ hasIssues: features.issues && existsSync(ctx.issuesDir),
846
+ hasDiscussions: features.discussions && existsSync(ctx.discussionsDir),
847
+ hasReleases: features.releases && existsSync(ctx.releasesPath),
812
848
  repoInfo
813
849
  };
814
850
  }
@@ -902,11 +938,12 @@ async function fetchAndCacheResources(opts) {
902
938
  };
903
939
  }
904
940
  async function prepareSkillReferences(opts) {
905
- const { packageName, version, cwd, skillDir, resources, features, baseDir, onIndexProgress } = opts;
941
+ const { packageName, version, cwd, skillDir, resources, features, baseDir, extraPackages, onIndexProgress } = opts;
906
942
  const cache = createReferenceCache(packageName, version);
907
943
  cache.linkInto(skillDir, cwd, resources.docsType, {
908
944
  features,
909
- repoInfo: resources.repoInfo
945
+ repoInfo: resources.repoInfo,
946
+ extraPackages
910
947
  });
911
948
  if (features.search) await indexResources({
912
949
  packageName,
@@ -947,6 +984,6 @@ function buildSkillContext(opts) {
947
984
  overheadLines: opts.overheadLines
948
985
  };
949
986
  }
950
- export { prepareSkillReferences as a, resolveAutoModel as c, applyCachedSections as d, enhanceSkillWithLLM as f, writePromptFiles as h, findRelatedSkills as i, selectLlmConfig as l, writeBaseSkill as m, detectChangelog as n, indexResources as o, runSkillEnhancement as p, fetchAndCacheResources as r, DEFAULT_SECTIONS as s, buildSkillContext as t, selectSkillSections as u };
987
+ export { DEFAULT_SECTIONS, applyCachedSections, buildSkillContext, detectChangelog, enhanceSkillWithLLM, fetchAndCacheResources, findRelatedSkills, prepareSkillReferences, resolveAutoModel, runSkillEnhancement, selectLlmConfig, writeBaseSkill, writePromptFiles };
951
988
 
952
- //# sourceMappingURL=sync-pipeline.mjs.map
989
+ //# sourceMappingURL=pipeline.mjs.map