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.
- package/README.md +25 -0
- package/dist/_chunks/add.mjs +67 -0
- package/dist/_chunks/add.mjs.map +1 -0
- package/dist/_chunks/agent-prompt.mjs +88 -0
- package/dist/_chunks/agent-prompt.mjs.map +1 -0
- package/dist/_chunks/agent.mjs +359 -157
- package/dist/_chunks/agent.mjs.map +1 -1
- package/dist/_chunks/args.mjs +42 -0
- package/dist/_chunks/args.mjs.map +1 -0
- package/dist/_chunks/assemble.mjs +12 -9
- package/dist/_chunks/assemble.mjs.map +1 -1
- package/dist/_chunks/author.mjs +35 -19
- package/dist/_chunks/author.mjs.map +1 -1
- package/dist/_chunks/cache.mjs +153 -185
- package/dist/_chunks/cache.mjs.map +1 -1
- package/dist/_chunks/cache2.mjs +9 -8
- package/dist/_chunks/cache2.mjs.map +1 -1
- package/dist/_chunks/client.mjs +118 -0
- package/dist/_chunks/client.mjs.map +1 -0
- package/dist/_chunks/core.mjs +5 -5
- package/dist/_chunks/detect.mjs +54 -44
- package/dist/_chunks/detect.mjs.map +1 -1
- package/dist/_chunks/detect2.mjs +1 -1
- package/dist/_chunks/eject.mjs +69 -0
- package/dist/_chunks/eject.mjs.map +1 -0
- package/dist/_chunks/embedding-cache.mjs +1 -1
- package/dist/_chunks/embedding-cache2.mjs +2 -2
- package/dist/_chunks/embedding-cache2.mjs.map +1 -1
- package/dist/_chunks/env.mjs +19 -0
- package/dist/_chunks/env.mjs.map +1 -0
- package/dist/_chunks/install-many.mjs +377 -0
- package/dist/_chunks/install-many.mjs.map +1 -0
- package/dist/_chunks/install.mjs +93 -334
- package/dist/_chunks/install.mjs.map +1 -1
- package/dist/_chunks/intro.mjs +63 -0
- package/dist/_chunks/intro.mjs.map +1 -0
- package/dist/_chunks/list.mjs +5 -4
- package/dist/_chunks/list.mjs.map +1 -1
- package/dist/_chunks/lockfile.mjs +10 -7
- package/dist/_chunks/lockfile.mjs.map +1 -1
- package/dist/_chunks/login.mjs +234 -0
- package/dist/_chunks/login.mjs.map +1 -0
- package/dist/_chunks/logout.mjs +27 -0
- package/dist/_chunks/logout.mjs.map +1 -0
- package/dist/_chunks/map.mjs +11 -0
- package/dist/_chunks/map.mjs.map +1 -0
- package/dist/_chunks/markdown.mjs +81 -56
- package/dist/_chunks/markdown.mjs.map +1 -1
- package/dist/_chunks/menu.mjs +33 -0
- package/dist/_chunks/menu.mjs.map +1 -0
- package/dist/_chunks/model-picker.mjs +61 -0
- package/dist/_chunks/model-picker.mjs.map +1 -0
- package/dist/_chunks/monorepo.mjs +7 -4
- package/dist/_chunks/monorepo.mjs.map +1 -1
- package/dist/_chunks/package-json.mjs +7 -5
- package/dist/_chunks/package-json.mjs.map +1 -1
- package/dist/_chunks/paths.mjs +3 -5
- package/dist/_chunks/paths.mjs.map +1 -1
- package/dist/_chunks/{sync-pipeline.mjs → pipeline.mjs} +360 -323
- package/dist/_chunks/pipeline.mjs.map +1 -0
- package/dist/_chunks/pool.mjs +1 -1
- package/dist/_chunks/pool2.mjs +2 -2
- package/dist/_chunks/pool2.mjs.map +1 -1
- package/dist/_chunks/portable.mjs +151 -0
- package/dist/_chunks/portable.mjs.map +1 -0
- package/dist/_chunks/prepare-hook.mjs +2 -0
- package/dist/_chunks/prepare-hook2.mjs +61 -0
- package/dist/_chunks/prepare-hook2.mjs.map +1 -0
- package/dist/_chunks/prepare.mjs +58 -8
- package/dist/_chunks/prepare.mjs.map +1 -1
- package/dist/_chunks/prepare2.mjs +14 -11
- package/dist/_chunks/prepare2.mjs.map +1 -1
- package/dist/_chunks/prompts.mjs +488 -76
- package/dist/_chunks/prompts.mjs.map +1 -1
- package/dist/_chunks/pull.mjs +220 -0
- package/dist/_chunks/pull.mjs.map +1 -0
- package/dist/_chunks/regex.mjs +19 -0
- package/dist/_chunks/regex.mjs.map +1 -0
- package/dist/_chunks/retriv.mjs +2 -171
- package/dist/_chunks/retriv2.mjs +159 -0
- package/dist/_chunks/retriv2.mjs.map +1 -0
- package/dist/_chunks/sanitize.mjs +13 -10
- package/dist/_chunks/sanitize.mjs.map +1 -1
- package/dist/_chunks/search-helpers.mjs +11 -9
- package/dist/_chunks/search-helpers.mjs.map +1 -1
- package/dist/_chunks/search-interactive.mjs +25 -22
- package/dist/_chunks/search-interactive.mjs.map +1 -1
- package/dist/_chunks/search.mjs +6 -6
- package/dist/_chunks/search.mjs.map +1 -1
- package/dist/_chunks/semver.mjs +2793 -5
- package/dist/_chunks/semver.mjs.map +1 -1
- package/dist/_chunks/skill-installer.mjs +1 -1
- package/dist/_chunks/skill-installer2.mjs +31 -23
- package/dist/_chunks/skill-installer2.mjs.map +1 -1
- package/dist/_chunks/skills.mjs +9 -10
- package/dist/_chunks/skills.mjs.map +1 -1
- package/dist/_chunks/store.mjs +107 -0
- package/dist/_chunks/store.mjs.map +1 -0
- package/dist/_chunks/sync.mjs +422 -915
- package/dist/_chunks/sync.mjs.map +1 -1
- package/dist/_chunks/sync2.mjs +2 -5
- package/dist/_chunks/telemetry.mjs +26 -0
- package/dist/_chunks/telemetry.mjs.map +1 -0
- package/dist/_chunks/uninstall.mjs +38 -32
- package/dist/_chunks/uninstall.mjs.map +1 -1
- package/dist/_chunks/update.mjs +172 -0
- package/dist/_chunks/update.mjs.map +1 -0
- package/dist/_chunks/upload.mjs +16 -13
- package/dist/_chunks/upload.mjs.map +1 -1
- package/dist/_chunks/validate.mjs +1 -1
- package/dist/_chunks/validate.mjs.map +1 -1
- package/dist/_chunks/version.mjs +16 -17
- package/dist/_chunks/version.mjs.map +1 -1
- package/dist/_chunks/whoami.mjs +21 -0
- package/dist/_chunks/whoami.mjs.map +1 -0
- package/dist/_chunks/wizard.mjs +2 -190
- package/dist/_chunks/wizard2.mjs +200 -0
- package/dist/_chunks/wizard2.mjs.map +1 -0
- package/dist/_chunks/yaml.mjs +1 -1
- package/dist/_chunks/yaml.mjs.map +1 -1
- package/dist/cli-entry.d.mts +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +94 -71
- package/dist/cli.mjs.map +1 -1
- package/dist/prepare.d.mts +1 -1
- package/dist/prepare.mjs +9 -6
- package/dist/prepare.mjs.map +1 -1
- package/dist/retriv/worker.d.mts +5 -1
- package/dist/retriv/worker.d.mts.map +1 -1
- package/dist/retriv/worker.mjs +1 -1
- package/dist/retriv/worker.mjs.map +1 -1
- package/package.json +27 -37
- package/dist/_chunks/author-group.mjs +0 -17
- package/dist/_chunks/author-group.mjs.map +0 -1
- package/dist/_chunks/cli-helpers.mjs +0 -335
- package/dist/_chunks/cli-helpers.mjs.map +0 -1
- package/dist/_chunks/cli-helpers2.mjs +0 -2
- package/dist/_chunks/index.d.mts +0 -344
- package/dist/_chunks/index.d.mts.map +0 -1
- package/dist/_chunks/index2.d.mts +0 -279
- package/dist/_chunks/index2.d.mts.map +0 -1
- package/dist/_chunks/index3.d.mts +0 -44
- package/dist/_chunks/index3.d.mts.map +0 -1
- package/dist/_chunks/index4.d.mts +0 -553
- package/dist/_chunks/index4.d.mts.map +0 -1
- package/dist/_chunks/package-registry.mjs +0 -465
- package/dist/_chunks/package-registry.mjs.map +0 -1
- package/dist/_chunks/retriv.mjs.map +0 -1
- package/dist/_chunks/setup.mjs +0 -17
- package/dist/_chunks/setup.mjs.map +0 -1
- package/dist/_chunks/sources.mjs +0 -2654
- package/dist/_chunks/sources.mjs.map +0 -1
- package/dist/_chunks/sync-pipeline.mjs.map +0 -1
- package/dist/_chunks/sync-registry.mjs +0 -65
- package/dist/_chunks/sync-registry.mjs.map +0 -1
- package/dist/_chunks/types.d.mts +0 -76
- package/dist/_chunks/types.d.mts.map +0 -1
- package/dist/_chunks/types2.d.mts +0 -88
- package/dist/_chunks/types2.d.mts.map +0 -1
- package/dist/_chunks/wizard.mjs.map +0 -1
- package/dist/agent/index.d.mts +0 -2
- package/dist/agent/index.mjs +0 -4
- package/dist/cache/index.d.mts +0 -2
- package/dist/cache/index.mjs +0 -5
- package/dist/index.d.mts +0 -6
- package/dist/index.mjs +0 -6
- package/dist/retriv/index.d.mts +0 -3
- package/dist/retriv/index.mjs +0 -2
- package/dist/sources/index.d.mts +0 -3
- package/dist/sources/index.mjs +0 -3
- package/dist/types.d.mts +0 -4
- package/dist/types.mjs +0 -1
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
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 {
|
|
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(
|
|
85
|
-
if (warnings?.length) for (const w of warnings) p.log.warn(
|
|
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
|
|
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(
|
|
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
|
|
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?
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
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
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
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
|
-
|
|
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 (
|
|
504
|
-
docSource =
|
|
505
|
-
docsType = "docs";
|
|
517
|
+
if (added > 0) {
|
|
518
|
+
ctx.docSource = crawlPattern;
|
|
519
|
+
ctx.docsType = "docs";
|
|
506
520
|
}
|
|
507
521
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
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
|
|
527
|
-
docs.
|
|
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
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
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
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
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:
|
|
636
|
-
type: "
|
|
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
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
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
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
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 (
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
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
|
-
|
|
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
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
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 {
|
|
987
|
+
export { DEFAULT_SECTIONS, applyCachedSections, buildSkillContext, detectChangelog, enhanceSkillWithLLM, fetchAndCacheResources, findRelatedSkills, prepareSkillReferences, resolveAutoModel, runSkillEnhancement, selectLlmConfig, writeBaseSkill, writePromptFiles };
|
|
951
988
|
|
|
952
|
-
//# sourceMappingURL=
|
|
989
|
+
//# sourceMappingURL=pipeline.mjs.map
|