skilld 0.11.3 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/config.mjs +6 -1
- package/dist/_chunks/config.mjs.map +1 -1
- package/dist/_chunks/detect-imports.mjs +51 -25
- package/dist/_chunks/detect-imports.mjs.map +1 -1
- package/dist/_chunks/npm.mjs +71 -5
- package/dist/_chunks/npm.mjs.map +1 -1
- package/dist/_chunks/package-registry.mjs +20 -1
- package/dist/_chunks/package-registry.mjs.map +1 -1
- package/dist/_chunks/storage.mjs +32 -3
- package/dist/_chunks/storage.mjs.map +1 -1
- package/dist/_chunks/utils.d.mts +26 -2
- package/dist/_chunks/utils.d.mts.map +1 -1
- package/dist/_chunks/version.d.mts +14 -1
- package/dist/_chunks/version.d.mts.map +1 -1
- package/dist/agent/index.d.mts +6 -6
- package/dist/agent/index.d.mts.map +1 -1
- package/dist/cache/index.d.mts +2 -2
- package/dist/cache/index.mjs +3 -3
- package/dist/cli.mjs +200 -139
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/sources/index.d.mts +2 -2
- package/dist/sources/index.mjs +3 -3
- package/dist/types.d.mts +2 -2
- package/package.json +2 -1
package/dist/_chunks/npm.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as getCacheDir } from "./config.mjs";
|
|
2
2
|
import { i as parseFrontmatter, n as extractLinks, r as extractTitle, t as extractDescription } from "./markdown.mjs";
|
|
3
|
-
import { n as getDocOverride, t as getBlogPreset } from "./package-registry.mjs";
|
|
3
|
+
import { n as getCrawlUrl, r as getDocOverride, t as getBlogPreset } from "./package-registry.mjs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
4
5
|
import { basename, dirname, join, resolve } from "pathe";
|
|
5
6
|
import { createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, unlinkSync } from "node:fs";
|
|
6
7
|
import { htmlToMarkdown } from "mdream";
|
|
7
8
|
import { spawnSync } from "node:child_process";
|
|
8
9
|
import { gt } from "semver";
|
|
9
10
|
import { ofetch } from "ofetch";
|
|
11
|
+
import { crawlAndGenerate } from "@mdream/crawl";
|
|
10
12
|
import { globby } from "globby";
|
|
11
13
|
import pLimit from "p-limit";
|
|
12
14
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -722,6 +724,38 @@ async function fetchBlogReleases(packageName, installedVersion) {
|
|
|
722
724
|
content: formatBlogRelease(r)
|
|
723
725
|
}));
|
|
724
726
|
}
|
|
727
|
+
async function fetchCrawledDocs(url, onProgress, maxPages = 200) {
|
|
728
|
+
const outputDir = join(tmpdir(), "skilld-crawl", Date.now().toString());
|
|
729
|
+
onProgress?.(`Crawling ${url}`);
|
|
730
|
+
const results = await crawlAndGenerate({
|
|
731
|
+
urls: [url],
|
|
732
|
+
outputDir,
|
|
733
|
+
driver: "http",
|
|
734
|
+
generateLlmsTxt: false,
|
|
735
|
+
generateIndividualMd: false,
|
|
736
|
+
maxRequestsPerCrawl: maxPages
|
|
737
|
+
}, (progress) => {
|
|
738
|
+
if (progress.crawling.status === "processing" && progress.crawling.total > 0) onProgress?.(`Crawling ${progress.crawling.processed}/${progress.crawling.total} pages`);
|
|
739
|
+
});
|
|
740
|
+
rmSync(outputDir, {
|
|
741
|
+
recursive: true,
|
|
742
|
+
force: true
|
|
743
|
+
});
|
|
744
|
+
const docs = [];
|
|
745
|
+
for (const result of results) {
|
|
746
|
+
if (!result.success || !result.content) continue;
|
|
747
|
+
const path = `docs/${(new URL(result.url).pathname.replace(/\/$/, "") || "/index").split("/").filter(Boolean).join("/")}.md`;
|
|
748
|
+
docs.push({
|
|
749
|
+
path,
|
|
750
|
+
content: result.content
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
onProgress?.(`Crawled ${docs.length} pages`);
|
|
754
|
+
return docs;
|
|
755
|
+
}
|
|
756
|
+
function toCrawlPattern(docsUrl) {
|
|
757
|
+
return `${docsUrl.replace(/\/+$/, "")}/**`;
|
|
758
|
+
}
|
|
725
759
|
const HIGH_VALUE_CATEGORIES = new Set([
|
|
726
760
|
"q&a",
|
|
727
761
|
"help",
|
|
@@ -1372,6 +1406,27 @@ async function findLatestReleaseTag(owner, repo, packageName) {
|
|
|
1372
1406
|
function filterDocFiles(files, pathPrefix) {
|
|
1373
1407
|
return files.filter((f) => f.startsWith(pathPrefix) && /\.(?:md|mdx)$/.test(f));
|
|
1374
1408
|
}
|
|
1409
|
+
const FRAMEWORK_NAMES = new Set([
|
|
1410
|
+
"vue",
|
|
1411
|
+
"react",
|
|
1412
|
+
"solid",
|
|
1413
|
+
"angular",
|
|
1414
|
+
"svelte",
|
|
1415
|
+
"preact",
|
|
1416
|
+
"lit",
|
|
1417
|
+
"qwik"
|
|
1418
|
+
]);
|
|
1419
|
+
function filterFrameworkDocs(files, packageName) {
|
|
1420
|
+
if (!packageName) return files;
|
|
1421
|
+
const shortName = packageName.replace(/^@.*\//, "");
|
|
1422
|
+
const targetFramework = [...FRAMEWORK_NAMES].find((fw) => shortName.includes(fw));
|
|
1423
|
+
if (!targetFramework) return files;
|
|
1424
|
+
const frameworkPattern = new RegExp(`(?:^|/)(?:framework/)?(?:${[...FRAMEWORK_NAMES].join("|")})/`);
|
|
1425
|
+
if (!files.some((f) => frameworkPattern.test(f))) return files;
|
|
1426
|
+
const otherFrameworks = [...FRAMEWORK_NAMES].filter((fw) => fw !== targetFramework);
|
|
1427
|
+
const excludePattern = new RegExp(`(?:^|/)(?:framework/)?(?:${otherFrameworks.join("|")})/`);
|
|
1428
|
+
return files.filter((f) => !excludePattern.test(f));
|
|
1429
|
+
}
|
|
1375
1430
|
const NOISE_PATTERNS = [
|
|
1376
1431
|
/^\.changeset\//,
|
|
1377
1432
|
/CHANGELOG\.md$/i,
|
|
@@ -1421,8 +1476,16 @@ function scoreDocDir(dir, fileCount) {
|
|
|
1421
1476
|
const depth = getPathDepth(dir) || 1;
|
|
1422
1477
|
return fileCount * (hasDocDirBonus(dir) ? 1.5 : 1) / depth;
|
|
1423
1478
|
}
|
|
1424
|
-
function discoverDocFiles(allFiles) {
|
|
1479
|
+
function discoverDocFiles(allFiles, packageName) {
|
|
1425
1480
|
const mdFiles = allFiles.filter((f) => /\.(?:md|mdx)$/.test(f)).filter((f) => !NOISE_PATTERNS.some((p) => p.test(f))).filter((f) => f.includes("/"));
|
|
1481
|
+
if (packageName?.includes("/")) {
|
|
1482
|
+
const subPkgPrefix = `packages/${packageName.split("/").pop().toLowerCase()}/`;
|
|
1483
|
+
const subPkgFiles = mdFiles.filter((f) => f.startsWith(subPkgPrefix));
|
|
1484
|
+
if (subPkgFiles.length >= 3) return {
|
|
1485
|
+
files: subPkgFiles,
|
|
1486
|
+
prefix: subPkgPrefix
|
|
1487
|
+
};
|
|
1488
|
+
}
|
|
1426
1489
|
const docsGroups = /* @__PURE__ */ new Map();
|
|
1427
1490
|
for (const file of mdFiles) {
|
|
1428
1491
|
const docsIdx = file.lastIndexOf("/docs/");
|
|
@@ -1485,13 +1548,14 @@ async function fetchGitDocs(owner, repo, version, packageName, repoUrl) {
|
|
|
1485
1548
|
let docsPrefix;
|
|
1486
1549
|
let allFiles;
|
|
1487
1550
|
if (docs.length === 0) {
|
|
1488
|
-
const discovered = discoverDocFiles(tag.files);
|
|
1551
|
+
const discovered = discoverDocFiles(tag.files, packageName);
|
|
1489
1552
|
if (discovered) {
|
|
1490
1553
|
docs = discovered.files;
|
|
1491
1554
|
docsPrefix = discovered.prefix || void 0;
|
|
1492
1555
|
allFiles = tag.files;
|
|
1493
1556
|
}
|
|
1494
1557
|
}
|
|
1558
|
+
docs = filterFrameworkDocs(docs, packageName);
|
|
1495
1559
|
if (docs.length === 0) return null;
|
|
1496
1560
|
return {
|
|
1497
1561
|
baseUrl: `https://raw.githubusercontent.com/${owner}/${repo}/${tag.ref}`,
|
|
@@ -1875,6 +1939,8 @@ async function resolvePackageDocsWithAttempts(packageName, options = {}) {
|
|
|
1875
1939
|
message: "No repository URL in package.json and GitHub search found no match"
|
|
1876
1940
|
});
|
|
1877
1941
|
}
|
|
1942
|
+
const crawlUrl = getCrawlUrl(packageName);
|
|
1943
|
+
if (crawlUrl) result.crawlUrl = crawlUrl;
|
|
1878
1944
|
if (result.docsUrl) {
|
|
1879
1945
|
onProgress?.("llms.txt");
|
|
1880
1946
|
const llmsUrl = await fetchLlmsUrl(result.docsUrl);
|
|
@@ -2104,6 +2170,6 @@ function getInstalledSkillVersion(skillDir) {
|
|
|
2104
2170
|
if (!existsSync(skillPath)) return null;
|
|
2105
2171
|
return readFileSync(skillPath, "utf-8").match(/^version:\s*"?([^"\n]+)"?/m)?.[1] || null;
|
|
2106
2172
|
}
|
|
2107
|
-
export {
|
|
2173
|
+
export { formatIssueAsMarkdown as $, parseSkillFrontmatterName as A, fetchReleaseNotes as B, extractSections as C, parseMarkdownLinks as D, normalizeLlmsLinks as E, generateDiscussionIndex as F, extractBranchHint as G, isPrerelease as H, fetchCrawledDocs as I, normalizeRepoUrl as J, fetchText as K, toCrawlPattern as L, generateDocsIndex as M, fetchGitHubDiscussions as N, fetchGitSkills as O, formatDiscussionAsMarkdown as P, fetchGitHubIssues as Q, fetchBlogReleases as R, downloadLlmsDocs as S, fetchLlmsUrl as T, parseSemver as U, generateReleaseIndex as V, $fetch as W, parsePackageSpec as X, parseGitHubUrl as Y, verifyUrl as Z, fetchReadme as _, getInstalledSkillVersion as a, semverGt as at, resolveGitHubRepo as b, readLocalPackageInfo as c, resolvePackageDocs as d, generateIssueIndex as et, resolvePackageDocsWithAttempts as f, fetchGitHubRepoMeta as g, fetchGitDocs as h, fetchPkgDist as i, mapInsert as it, resolveEntryFiles as j, parseGitSkillInput as k, resolveInstalledVersion as l, MIN_GIT_DOCS as m, fetchNpmPackage as n, SHARED_SKILLS_DIR as nt, parseVersionSpecifier as o, searchNpmPackages as p, isGitHubRepoUrl as q, fetchNpmRegistryMeta as r, getSharedSkillsDir as rt, readLocalDependencies as s, fetchLatestVersion as t, isGhAvailable as tt, resolveLocalPackageDocs as u, fetchReadmeContent as v, fetchLlmsTxt as w, validateGitDocsWithLlms as x, isShallowGitDocs as y, compareSemver as z };
|
|
2108
2174
|
|
|
2109
2175
|
//# sourceMappingURL=npm.mjs.map
|