skilld 1.5.5 → 1.7.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 +32 -23
- package/dist/_chunks/agent.mjs +2 -78
- package/dist/_chunks/agent.mjs.map +1 -1
- package/dist/_chunks/assemble.mjs +1 -18
- package/dist/_chunks/assemble.mjs.map +1 -1
- package/dist/_chunks/author-group.mjs +17 -0
- package/dist/_chunks/author-group.mjs.map +1 -0
- package/dist/_chunks/author.mjs +8 -24
- package/dist/_chunks/author.mjs.map +1 -1
- package/dist/_chunks/cache.mjs +1 -73
- package/dist/_chunks/cache.mjs.map +1 -1
- package/dist/_chunks/cache2.mjs +84 -17
- package/dist/_chunks/cache2.mjs.map +1 -1
- package/dist/_chunks/cli-helpers.mjs +3 -166
- package/dist/_chunks/cli-helpers.mjs.map +1 -1
- package/dist/_chunks/cli-helpers2.mjs +0 -11
- package/dist/_chunks/config.mjs +119 -54
- package/dist/_chunks/config.mjs.map +1 -1
- package/dist/_chunks/core.mjs +9 -0
- package/dist/_chunks/detect.mjs +29 -226
- package/dist/_chunks/detect.mjs.map +1 -1
- package/dist/_chunks/embedding-cache.mjs +0 -5
- package/dist/_chunks/embedding-cache2.mjs +2 -3
- package/dist/_chunks/formatting.mjs +0 -6
- package/dist/_chunks/formatting.mjs.map +1 -1
- package/dist/_chunks/index.d.mts +0 -10
- package/dist/_chunks/index.d.mts.map +1 -1
- package/dist/_chunks/index2.d.mts +3 -6
- package/dist/_chunks/index2.d.mts.map +1 -1
- package/dist/_chunks/index3.d.mts +81 -109
- package/dist/_chunks/index3.d.mts.map +1 -1
- package/dist/_chunks/install.mjs +85 -550
- package/dist/_chunks/install.mjs.map +1 -1
- package/dist/_chunks/install2.mjs +554 -0
- package/dist/_chunks/install2.mjs.map +1 -0
- package/dist/_chunks/libs/@sinclair/typebox.mjs +0 -444
- package/dist/_chunks/libs/@sinclair/typebox.mjs.map +1 -1
- package/dist/_chunks/list.mjs +0 -16
- package/dist/_chunks/list.mjs.map +1 -1
- package/dist/_chunks/lockfile.mjs +2 -10
- package/dist/_chunks/lockfile.mjs.map +1 -1
- package/dist/_chunks/markdown.mjs +0 -9
- package/dist/_chunks/markdown.mjs.map +1 -1
- package/dist/_chunks/package-json.mjs +0 -25
- package/dist/_chunks/package-json.mjs.map +1 -1
- package/dist/_chunks/package-registry.mjs +465 -0
- package/dist/_chunks/package-registry.mjs.map +1 -0
- package/dist/_chunks/pool2.mjs +0 -2
- package/dist/_chunks/pool2.mjs.map +1 -1
- package/dist/_chunks/prefix.mjs +108 -0
- package/dist/_chunks/prefix.mjs.map +1 -0
- package/dist/_chunks/prepare.mjs +14 -9
- package/dist/_chunks/prepare.mjs.map +1 -1
- package/dist/_chunks/prepare2.mjs +1 -19
- package/dist/_chunks/prepare2.mjs.map +1 -1
- package/dist/_chunks/prompts.mjs +6 -201
- package/dist/_chunks/prompts.mjs.map +1 -1
- package/dist/_chunks/retriv.mjs +23 -24
- package/dist/_chunks/retriv.mjs.map +1 -1
- package/dist/_chunks/rolldown-runtime.mjs +0 -2
- package/dist/_chunks/sanitize.mjs +0 -78
- package/dist/_chunks/sanitize.mjs.map +1 -1
- package/dist/_chunks/search-helpers.mjs +99 -0
- package/dist/_chunks/search-helpers.mjs.map +1 -0
- package/dist/_chunks/search-interactive.mjs +1 -18
- package/dist/_chunks/search-interactive.mjs.map +1 -1
- package/dist/_chunks/search.mjs +218 -19
- package/dist/_chunks/search.mjs.map +1 -0
- package/dist/_chunks/setup.mjs +0 -13
- package/dist/_chunks/setup.mjs.map +1 -1
- package/dist/_chunks/shared.mjs +1 -473
- package/dist/_chunks/shared.mjs.map +1 -1
- package/dist/_chunks/skills.mjs +3 -3
- package/dist/_chunks/skills.mjs.map +1 -1
- package/dist/_chunks/sources.mjs +1179 -1440
- package/dist/_chunks/sources.mjs.map +1 -1
- package/dist/_chunks/sync-registry.mjs +59 -0
- package/dist/_chunks/sync-registry.mjs.map +1 -0
- package/dist/_chunks/sync-shared.mjs +0 -16
- package/dist/_chunks/sync-shared2.mjs +10 -49
- package/dist/_chunks/sync-shared2.mjs.map +1 -1
- package/dist/_chunks/sync.mjs +209 -120
- package/dist/_chunks/sync.mjs.map +1 -1
- package/dist/_chunks/sync2.mjs +1 -21
- package/dist/_chunks/types.d.mts +0 -2
- package/dist/_chunks/types.d.mts.map +1 -1
- package/dist/_chunks/uninstall.mjs +3 -27
- package/dist/_chunks/uninstall.mjs.map +1 -1
- package/dist/_chunks/upload.mjs +152 -0
- package/dist/_chunks/upload.mjs.map +1 -0
- package/dist/_chunks/validate.mjs +1 -8
- package/dist/_chunks/validate.mjs.map +1 -1
- package/dist/_chunks/version.mjs +30 -0
- package/dist/_chunks/version.mjs.map +1 -0
- package/dist/_chunks/wizard.mjs +2 -3
- package/dist/_chunks/yaml.mjs +0 -21
- package/dist/_chunks/yaml.mjs.map +1 -1
- package/dist/agent/index.d.mts +0 -24
- package/dist/agent/index.d.mts.map +1 -1
- package/dist/agent/index.mjs +2 -9
- package/dist/cache/index.mjs +1 -3
- package/dist/cli-entry.mjs +0 -6
- package/dist/cli-entry.mjs.map +1 -1
- package/dist/cli.mjs +48 -33
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -8
- package/dist/prepare.mjs +0 -12
- package/dist/prepare.mjs.map +1 -1
- package/dist/retriv/index.mjs +0 -2
- package/dist/retriv/worker.d.mts +0 -3
- package/dist/retriv/worker.d.mts.map +1 -1
- package/dist/retriv/worker.mjs +0 -2
- package/dist/retriv/worker.mjs.map +1 -1
- package/dist/sources/index.d.mts +2 -2
- package/dist/sources/index.mjs +3 -7
- package/dist/types.d.mts +1 -1
- package/package.json +20 -21
- package/dist/_chunks/search2.mjs +0 -319
- package/dist/_chunks/search2.mjs.map +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { t as SHARED_SKILLS_DIR } from "./shared.mjs";
|
|
2
|
+
import { r as linkSkillToAgents } from "./install.mjs";
|
|
3
|
+
import { s as writeLock } from "./lockfile.mjs";
|
|
4
|
+
import { join } from "pathe";
|
|
5
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { ofetch } from "ofetch";
|
|
7
|
+
const DEFAULT_REGISTRY_URL = "https://skilld.dev/api";
|
|
8
|
+
function getRegistryBase() {
|
|
9
|
+
return (process.env.SKILLD_REGISTRY_URL || DEFAULT_REGISTRY_URL).replace(/\/$/, "");
|
|
10
|
+
}
|
|
11
|
+
async function fetchRegistrySkill(packageName, opts = {}) {
|
|
12
|
+
const base = getRegistryBase();
|
|
13
|
+
const hit = (await ofetch(`${base}/skills/resolve`, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
body: { items: [{
|
|
16
|
+
packageName,
|
|
17
|
+
owner: opts.owner
|
|
18
|
+
}] }
|
|
19
|
+
}).catch(() => null))?.[packageName];
|
|
20
|
+
if (!hit) return null;
|
|
21
|
+
const detail = await ofetch(`${base}/skills/${`${hit.owner}/${hit.repo}/${packageName}`}`).catch(() => null);
|
|
22
|
+
if (!detail?.raw) return null;
|
|
23
|
+
return {
|
|
24
|
+
name: detail.name,
|
|
25
|
+
packageName,
|
|
26
|
+
content: detail.raw,
|
|
27
|
+
owner: detail.owner,
|
|
28
|
+
repo: `${detail.owner}/${detail.repo}`,
|
|
29
|
+
displayName: detail.displayName,
|
|
30
|
+
installs: detail.installs,
|
|
31
|
+
official: hit.official,
|
|
32
|
+
branch: detail.branch,
|
|
33
|
+
skillPath: detail.skillPath ?? void 0,
|
|
34
|
+
updatedAt: detail.pushedAt ?? void 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async function syncRegistrySkill(opts) {
|
|
38
|
+
const { packageName, agent, cwd = process.cwd() } = opts;
|
|
39
|
+
const skill = await fetchRegistrySkill(packageName);
|
|
40
|
+
if (!skill) return null;
|
|
41
|
+
const skillDir = join(join(cwd, SHARED_SKILLS_DIR), skill.name);
|
|
42
|
+
mkdirSync(skillDir, { recursive: true });
|
|
43
|
+
writeFileSync(join(skillDir, "SKILL.md"), skill.content);
|
|
44
|
+
const baseDir = join(cwd, ".claude", "skills");
|
|
45
|
+
mkdirSync(baseDir, { recursive: true });
|
|
46
|
+
writeLock(baseDir, skill.name, {
|
|
47
|
+
packageName: skill.packageName,
|
|
48
|
+
version: skill.updatedAt,
|
|
49
|
+
repo: skill.repo,
|
|
50
|
+
source: "registry",
|
|
51
|
+
syncedAt: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
52
|
+
generator: "curator"
|
|
53
|
+
});
|
|
54
|
+
linkSkillToAgents(skill.name, skillDir, cwd, agent);
|
|
55
|
+
return skill;
|
|
56
|
+
}
|
|
57
|
+
export { syncRegistrySkill };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=sync-registry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-registry.mjs","names":[],"sources":["../../src/registry/client.ts","../../src/commands/sync-registry.ts"],"sourcesContent":["/**\n * Registry client for skilld.dev\n *\n * Talks to the public skilld.dev JSON API: resolves an npm package name to a\n * curated skill's owner/repo, then fetches the detail payload which includes\n * the raw SKILL.md. For local development, set SKILLD_REGISTRY_URL (e.g.\n * http://localhost:3000/api) to point at a running Nuxt dev server.\n *\n * Returns null when a skill isn't curated, the API is unreachable, or the\n * skill has no resolvable SKILL.md, so callers fall through to the\n * doc-generation pipeline.\n */\n\nimport { ofetch } from 'ofetch'\n\nconst DEFAULT_REGISTRY_URL = 'https://skilld.dev/api'\n\nexport function getRegistryBase(): string {\n return (process.env.SKILLD_REGISTRY_URL || DEFAULT_REGISTRY_URL).replace(/\\/$/, '')\n}\n\nexport interface RegistrySkill {\n /** Skill directory name (matches what lands in .claude/skills/<name>/) */\n name: string\n /** npm package name used to look up this skill */\n packageName: string\n /** Raw SKILL.md content (frontmatter + body) */\n content: string\n /** Source repo owner */\n owner: string\n /** Full \"owner/repo\" identifier */\n repo: string\n /** Human-readable display name from the registry */\n displayName?: string\n /** Install count reported by the registry */\n installs?: number\n /** True when the source repo is on the official owners list */\n official?: boolean\n /** Default branch the SKILL.md was fetched from */\n branch?: string\n /** Path to SKILL.md within the source repo */\n skillPath?: string\n /** ISO timestamp of the source repo's last push — used for staleness */\n updatedAt?: string\n}\n\nexport interface RegistrySearchHit {\n name: string\n packageName: string\n displayName?: string\n owner: string\n repo: string\n installs?: number\n official?: boolean\n}\n\nexport interface RegistrySearchResult {\n skills: RegistrySearchHit[]\n total: number\n}\n\ninterface ResolveResponseEntry {\n owner: string\n repo: string\n official: boolean\n}\n\ninterface SkillDetailResponse {\n owner: string\n repo: string\n name: string\n displayName: string\n installs: number\n branch?: string\n skillPath?: string | null\n raw?: string | null\n pushedAt?: string | null\n}\n\ninterface SkillListItem {\n name: string\n owner: string\n repo: string\n displayName: string\n installs: number\n official: boolean\n}\n\ninterface SkillListResponse {\n items: SkillListItem[]\n total: number\n}\n\nexport interface FetchRegistrySkillOptions {\n /** Narrow the resolve to a specific owner when multiple skills share a name */\n owner?: string\n}\n\n/**\n * Fetch a curated package skill from the registry.\n * Returns null if no curated skill exists, the SKILL.md can't be loaded, or the API is unreachable.\n */\nexport async function fetchRegistrySkill(\n packageName: string,\n opts: FetchRegistrySkillOptions = {},\n): Promise<RegistrySkill | null> {\n const base = getRegistryBase()\n\n const resolved = await ofetch<Record<string, ResolveResponseEntry>>(`${base}/skills/resolve`, {\n method: 'POST',\n body: { items: [{ packageName, owner: opts.owner }] },\n }).catch(() => null)\n\n const hit = resolved?.[packageName]\n if (!hit)\n return null\n\n const slug = `${hit.owner}/${hit.repo}/${packageName}`\n const detail = await ofetch<SkillDetailResponse>(`${base}/skills/${slug}`).catch(() => null)\n\n if (!detail?.raw)\n return null\n\n return {\n name: detail.name,\n packageName,\n content: detail.raw,\n owner: detail.owner,\n repo: `${detail.owner}/${detail.repo}`,\n displayName: detail.displayName,\n installs: detail.installs,\n official: hit.official,\n branch: detail.branch,\n skillPath: detail.skillPath ?? undefined,\n updatedAt: detail.pushedAt ?? undefined,\n }\n}\n\n/**\n * Search the registry for skills matching a query.\n */\nexport async function searchRegistry(\n query: string,\n opts: { limit?: number, owner?: string, official?: boolean } = {},\n): Promise<RegistrySearchResult> {\n const base = getRegistryBase()\n const result = await ofetch<SkillListResponse>(`${base}/skills`, {\n query: {\n q: query,\n limit: opts.limit ?? 20,\n owner: opts.owner,\n official: opts.official ? 'true' : undefined,\n },\n }).catch(() => null)\n\n if (!result)\n return { skills: [], total: 0 }\n\n return {\n skills: result.items.map(i => ({\n name: i.name,\n packageName: i.name,\n displayName: i.displayName,\n owner: i.owner,\n repo: `${i.owner}/${i.repo}`,\n installs: i.installs,\n official: i.official,\n })),\n total: result.total,\n }\n}\n\n/**\n * Check whether the registry has a newer SKILL.md than the local copy.\n * Returns the new `updatedAt` timestamp if newer, else null.\n */\nexport async function checkRegistryUpdate(\n packageName: string,\n currentUpdatedAt: string | undefined,\n): Promise<string | null> {\n const skill = await fetchRegistrySkill(packageName)\n if (!skill?.updatedAt)\n return null\n if (!currentUpdatedAt || skill.updatedAt > currentUpdatedAt)\n return skill.updatedAt\n return null\n}\n","/**\n * Registry-based skill installation\n *\n * Simplified install flow for curated skills from skilld.dev:\n * fetch SKILL.md → write to disk → update lockfile → link to agents.\n *\n * No doc resolution, no LLM, no caching. Fast path.\n */\n\nimport type { AgentType } from '../agent/index.ts'\nimport type { RegistrySkill } from '../registry/client.ts'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { join } from 'pathe'\nimport { linkSkillToAgents } from '../agent/install.ts'\nimport { writeLock } from '../core/lockfile.ts'\nimport { SHARED_SKILLS_DIR } from '../core/shared.ts'\nimport { fetchRegistrySkill } from '../registry/client.ts'\n\nexport interface SyncRegistryOptions {\n packageName: string\n agent: AgentType\n global?: boolean\n cwd?: string\n}\n\n/**\n * Install a package skill from the skilld.dev registry.\n * Returns the installed skill, or null if no curated skill exists.\n */\nexport async function syncRegistrySkill(opts: SyncRegistryOptions): Promise<RegistrySkill | null> {\n const { packageName, agent, cwd = process.cwd() } = opts\n\n const skill = await fetchRegistrySkill(packageName)\n if (!skill)\n return null\n\n // Write SKILL.md to shared skills dir\n const sharedDir = join(cwd, SHARED_SKILLS_DIR)\n const skillDir = join(sharedDir, skill.name)\n mkdirSync(skillDir, { recursive: true })\n writeFileSync(join(skillDir, 'SKILL.md'), skill.content)\n\n // Update lockfile\n const baseDir = join(cwd, '.claude', 'skills')\n mkdirSync(baseDir, { recursive: true })\n writeLock(baseDir, skill.name, {\n packageName: skill.packageName,\n version: skill.updatedAt,\n repo: skill.repo,\n source: 'registry',\n syncedAt: new Date().toISOString().slice(0, 10),\n generator: 'curator',\n })\n\n // Link to agent skill directories\n linkSkillToAgents(skill.name, skillDir, cwd, agent)\n\n return skill\n}\n"],"mappings":";;;;;;;;;;;;;;;;GAeA,OAAM,KAAA;GAEN,CAAA,EAAA;EACE,CAAA,CAAA,YAAQ,KAAY,IAAA;;;;;;EAoFtB;EAIE,SAAM,OAAO;EAOb,OAAM,OALW;EACf,MAAA,GAAQ,OAAA,MAAA,GAAA,OAAA;EACR,aAAQ,OAAQ;YAAE,OAAA;YAAoB,IAAK;UAAQ,OAAA;EACpD,WAAE,OAAY,aAEQ,KAAA;EACvB,WACE,OAAO,YAAA,KAAA;EAGT;;eAOE,kBAAA,MAAA;OACA,EAAA,aAAgB,OAAA,MAAA,QAAA,KAAA,KAAA;OAChB,QAAO,MAAO,mBAAA,YAAA;KACd,CAAA,MAAS,QAAO;OAChB,WAAa,KAAO,KAAA,KAAA,kBAAA,EAAA,MAAA,KAAA;WACpB,UAAiB,EAAA,WAAA,MAAA,CAAA;eACP,KAAI,UAAA,WAAA,EAAA,MAAA,QAAA;OACd,UAAe,KAAA,KAAA,WAAA,SAAA;WACf,SAAkB,EAAA,WAAa,MAAA,CAAA;WAC/B,SAAkB,MAAA,MAAY;EAC/B,aAAA,MAAA;;;;;;;AC1GH,mBAAsB,MAAA,MAAA,UAA4E,KAAA,MAAA;AAChG,QAAM;;SAQA"}
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
import "./config.mjs";
|
|
2
|
-
import "./package-json.mjs";
|
|
3
|
-
import "./prepare.mjs";
|
|
4
|
-
import "./sanitize.mjs";
|
|
5
|
-
import "./cache.mjs";
|
|
6
|
-
import "./yaml.mjs";
|
|
7
|
-
import "./markdown.mjs";
|
|
8
|
-
import "./retriv.mjs";
|
|
9
|
-
import "./shared.mjs";
|
|
10
|
-
import "./sources.mjs";
|
|
11
|
-
import "./detect.mjs";
|
|
12
|
-
import "./prompts.mjs";
|
|
13
|
-
import "./agent.mjs";
|
|
14
|
-
import "./libs/@sinclair/typebox.mjs";
|
|
15
|
-
import "./cli-helpers.mjs";
|
|
16
|
-
import "./lockfile.mjs";
|
|
17
1
|
import { h as handleShippedSkills } from "./sync-shared2.mjs";
|
|
18
2
|
export { handleShippedSkills };
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as getRepoCacheDir, s as getPackageDbPath, t as getCacheDir } from "./version.mjs";
|
|
2
2
|
import { i as readPackageJsonSafe } from "./package-json.mjs";
|
|
3
3
|
import { n as linkShippedSkill, r as resolvePkgDir, t as getShippedSkills } from "./prepare.mjs";
|
|
4
4
|
import { n as sanitizeMarkdown } from "./sanitize.mjs";
|
|
5
5
|
import { _ as writeToRepoCache, a as hasShippedDocs, c as linkPkg, f as listReferenceFiles, g as writeToCache, l as linkPkgNamed, n as clearCache, p as readCachedDocs, s as linkCachedDir, u as linkRepoCachedDir } from "./cache.mjs";
|
|
6
6
|
import { i as parseFrontmatter } from "./markdown.mjs";
|
|
7
7
|
import { o as listIndexIds, r as createIndex, t as SearchDepsUnavailableError } from "./retriv.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { o as getPrereleaseChangelogRef, t as getBlogPreset } from "./package-registry.mjs";
|
|
9
|
+
import { A as filterFrameworkDocs, B as fetchGitHubIssues, C as toCrawlPattern, E as fetchGitDocs, H as generateIssueIndex, I as fetchLlmsTxt, J as isPrerelease, K as fetchReleaseNotes, P as downloadLlmsDocs, Q as fetchGitHubRaw, R as normalizeLlmsLinks, S as fetchCrawledDocs, U as isGhAvailable, V as formatIssueAsMarkdown, W as fetchBlogReleases, _ as resolveEntryFiles, b as formatDiscussionAsMarkdown, j as isShallowGitDocs, k as fetchReadmeContent, n as fetchNpmPackage, nt as parseGitHubUrl, q as generateReleaseIndex, u as resolveLocalPackageDocs, v as generateDocsIndex, x as generateDiscussionIndex, y as fetchGitHubDiscussions } from "./sources.mjs";
|
|
10
|
+
import { a as semverDiff, n as getSharedSkillsDir } from "./shared.mjs";
|
|
10
11
|
import { a as targets } from "./detect.mjs";
|
|
11
|
-
import {
|
|
12
|
+
import { d as maxLines, i as buildAllSectionPrompts, r as SECTION_OUTPUT_FILES, t as generateSkillMd, u as maxItems } from "./prompts.mjs";
|
|
12
13
|
import { a as getModelLabel, i as getAvailableModels, o as getModelName, r as createToolProgress, s as optimizeDocs } from "./agent.mjs";
|
|
13
|
-
import {
|
|
14
|
+
import { a as readConfig, c as updateConfig, o as registerProject, t as defaultFeatures } from "./config.mjs";
|
|
15
|
+
import { g as pickModel, n as NO_MODELS_MESSAGE, p as isInteractive } from "./cli-helpers.mjs";
|
|
14
16
|
import { i as readLock, n as parsePackages, s as writeLock } from "./lockfile.mjs";
|
|
15
17
|
import { join, relative, resolve } from "pathe";
|
|
16
18
|
import { appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
17
19
|
import * as p from "@clack/prompts";
|
|
18
|
-
//#region src/commands/sync-shared.ts
|
|
19
|
-
/** Max docs sent to the embedding pipeline to prevent oversized indexes */
|
|
20
20
|
const MAX_INDEX_DOCS = 250;
|
|
21
21
|
const RESOLVE_STEP_LABELS = {
|
|
22
22
|
"npm": "npm registry",
|
|
@@ -28,7 +28,6 @@ const RESOLVE_STEP_LABELS = {
|
|
|
28
28
|
"crawl": "website crawl",
|
|
29
29
|
"local": "node_modules"
|
|
30
30
|
};
|
|
31
|
-
/** Classify a cached doc path into the right metadata type */
|
|
32
31
|
function classifyCachedDoc(path) {
|
|
33
32
|
const issueMatch = path.match(/^issues\/issue-(\d+)\.md$/);
|
|
34
33
|
if (issueMatch) return {
|
|
@@ -63,7 +62,6 @@ async function findRelatedSkills(packageName, skillsDir) {
|
|
|
63
62
|
}
|
|
64
63
|
return related.slice(0, 5);
|
|
65
64
|
}
|
|
66
|
-
/** Clear cache + db for --force flag */
|
|
67
65
|
function forceClearCache(packageName, version, repoInfo) {
|
|
68
66
|
clearCache(packageName, version);
|
|
69
67
|
const forcedDbPath = getPackageDbPath(packageName, version);
|
|
@@ -79,7 +77,6 @@ function forceClearCache(packageName, version, repoInfo) {
|
|
|
79
77
|
});
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
|
-
/** Link all reference symlinks (pkg, docs, issues, discussions, releases) */
|
|
83
80
|
function linkAllReferences(skillDir, packageName, cwd, version, docsType, extraPackages, features, repoInfo) {
|
|
84
81
|
const f = features ?? readConfig().features ?? defaultFeatures;
|
|
85
82
|
try {
|
|
@@ -98,7 +95,6 @@ function linkAllReferences(skillDir, packageName, cwd, version, docsType, extraP
|
|
|
98
95
|
}
|
|
99
96
|
} catch {}
|
|
100
97
|
}
|
|
101
|
-
/** Detect docs type from cached directory contents */
|
|
102
98
|
function detectDocsType(packageName, version, repoUrl, llmsUrl) {
|
|
103
99
|
const cacheDir = getCacheDir(packageName, version);
|
|
104
100
|
if (existsSync(join(cacheDir, "docs", "index.md")) || existsSync(join(cacheDir, "docs", "guide"))) return {
|
|
@@ -112,7 +108,6 @@ function detectDocsType(packageName, version, repoUrl, llmsUrl) {
|
|
|
112
108
|
if (existsSync(join(cacheDir, "docs", "README.md"))) return { docsType: "readme" };
|
|
113
109
|
return { docsType: "readme" };
|
|
114
110
|
}
|
|
115
|
-
/** Link shipped skills, write lock entries, register project. Returns result or null if no shipped skills. */
|
|
116
111
|
function handleShippedSkills(packageName, version, cwd, agent, global) {
|
|
117
112
|
const shippedSkills = getShippedSkills(packageName, cwd, version);
|
|
118
113
|
if (shippedSkills.length === 0) return null;
|
|
@@ -134,7 +129,6 @@ function handleShippedSkills(packageName, version, cwd, agent, global) {
|
|
|
134
129
|
baseDir
|
|
135
130
|
};
|
|
136
131
|
}
|
|
137
|
-
/** Resolve the base skills directory for an agent */
|
|
138
132
|
function resolveBaseDir(cwd, agent, global) {
|
|
139
133
|
if (global) return targets[agent].globalSkillsDir;
|
|
140
134
|
const shared = getSharedSkillsDir(cwd);
|
|
@@ -142,7 +136,6 @@ function resolveBaseDir(cwd, agent, global) {
|
|
|
142
136
|
const agentConfig = targets[agent];
|
|
143
137
|
return join(cwd, agentConfig.skillsDir);
|
|
144
138
|
}
|
|
145
|
-
/** Try resolving a `link:` dependency to local package docs. Returns null if not a link dep or resolution fails. */
|
|
146
139
|
async function resolveLocalDep(packageName, cwd) {
|
|
147
140
|
const result = readPackageJsonSafe(join(cwd, "package.json"));
|
|
148
141
|
if (!result) return null;
|
|
@@ -154,7 +147,6 @@ async function resolveLocalDep(packageName, cwd) {
|
|
|
154
147
|
if (!depVersion?.startsWith("link:")) return null;
|
|
155
148
|
return resolveLocalPackageDocs(resolve(cwd, depVersion.slice(5)));
|
|
156
149
|
}
|
|
157
|
-
/** Detect CHANGELOG.md in a package directory or cached releases */
|
|
158
150
|
function detectChangelog(pkgDir, cacheDir) {
|
|
159
151
|
if (pkgDir) {
|
|
160
152
|
const found = ["CHANGELOG.md", "changelog.md"].find((f) => existsSync(join(pkgDir, f)));
|
|
@@ -163,7 +155,6 @@ function detectChangelog(pkgDir, cacheDir) {
|
|
|
163
155
|
if (cacheDir && existsSync(join(cacheDir, "releases", "CHANGELOG.md"))) return "releases/CHANGELOG.md";
|
|
164
156
|
return false;
|
|
165
157
|
}
|
|
166
|
-
/** Fetch and cache all resources for a package (docs cascade + issues + discussions + releases) */
|
|
167
158
|
async function fetchAndCacheResources(opts) {
|
|
168
159
|
const { packageName, resolved, version, onProgress } = opts;
|
|
169
160
|
const features = opts.features ?? readConfig().features ?? defaultFeatures;
|
|
@@ -535,15 +526,10 @@ async function fetchAndCacheResources(opts) {
|
|
|
535
526
|
usedCache: useCache
|
|
536
527
|
};
|
|
537
528
|
}
|
|
538
|
-
/**
|
|
539
|
-
* Extract the parent document ID from a chunk ID.
|
|
540
|
-
* Chunk IDs have the form "docId#chunk-N"; non-chunk IDs return as-is.
|
|
541
|
-
*/
|
|
542
529
|
function parentDocId(id) {
|
|
543
530
|
const idx = id.indexOf("#chunk-");
|
|
544
531
|
return idx === -1 ? id : id.slice(0, idx);
|
|
545
532
|
}
|
|
546
|
-
/** Cap and sort docs by type priority, mutates and truncates allDocs in place */
|
|
547
533
|
function capDocs(allDocs, max, onProgress) {
|
|
548
534
|
if (allDocs.length <= max) return;
|
|
549
535
|
const TYPE_PRIORITY = {
|
|
@@ -563,7 +549,6 @@ function capDocs(allDocs, max, onProgress) {
|
|
|
563
549
|
onProgress(`Indexing capped at ${max}/${allDocs.length} docs (prioritized by type)`);
|
|
564
550
|
allDocs.length = max;
|
|
565
551
|
}
|
|
566
|
-
/** Index all resources into the search database, with incremental support */
|
|
567
552
|
async function indexResources(opts) {
|
|
568
553
|
const { packageName, version, cwd, onProgress } = opts;
|
|
569
554
|
const features = opts.features ?? readConfig().features ?? defaultFeatures;
|
|
@@ -643,11 +628,6 @@ async function indexResources(opts) {
|
|
|
643
628
|
else throw err;
|
|
644
629
|
}
|
|
645
630
|
}
|
|
646
|
-
/**
|
|
647
|
-
* Eject references: copy cached files as real files into references/ dir.
|
|
648
|
-
* Used for portable skills (git repos, sharing). Replaces symlinks with copies.
|
|
649
|
-
* Does NOT copy pkg files — those reference node_modules directly.
|
|
650
|
-
*/
|
|
651
631
|
function ejectReferences(skillDir, packageName, cwd, version, docsType, features, repoInfo) {
|
|
652
632
|
const f = features ?? readConfig().features ?? defaultFeatures;
|
|
653
633
|
const cacheDir = getCacheDir(packageName, version);
|
|
@@ -658,7 +638,6 @@ function ejectReferences(skillDir, packageName, cwd, version, docsType, features
|
|
|
658
638
|
if (f.discussions) copyCachedSubdir(repoDir, refsDir, "discussions");
|
|
659
639
|
if (f.releases) copyCachedSubdir(repoDir, refsDir, "releases");
|
|
660
640
|
}
|
|
661
|
-
/** Recursively copy a cached subdirectory into the references dir */
|
|
662
641
|
function copyCachedSubdir(cacheDir, refsDir, subdir) {
|
|
663
642
|
const srcDir = join(cacheDir, subdir);
|
|
664
643
|
if (!existsSync(srcDir)) return;
|
|
@@ -676,10 +655,6 @@ function copyCachedSubdir(cacheDir, refsDir, subdir) {
|
|
|
676
655
|
}
|
|
677
656
|
walk(srcDir, "");
|
|
678
657
|
}
|
|
679
|
-
/**
|
|
680
|
-
* Check if .gitignore has `.skilld` entry.
|
|
681
|
-
* If missing, prompt to add it. Skipped for global installs.
|
|
682
|
-
*/
|
|
683
658
|
async function ensureGitignore(skillsDir, cwd, isGlobal) {
|
|
684
659
|
if (isGlobal) return;
|
|
685
660
|
const gitignorePath = join(cwd, ".gitignore");
|
|
@@ -714,10 +689,6 @@ function getSkillInstructions(agent) {
|
|
|
714
689
|
function getMdcSkillInstructions(agent) {
|
|
715
690
|
return `---\ndescription: "Activates installed skilld skills before code changes"\nalwaysApply: true\n---\n\n${targets[agent].skillActivationHint || DEFAULT_SKILL_HINT}`;
|
|
716
691
|
}
|
|
717
|
-
/**
|
|
718
|
-
* Check if agent instruction file has skilld skill-activation snippet.
|
|
719
|
-
* If missing, prompt to add it. Skipped for global installs or agents without an instructionFile.
|
|
720
|
-
*/
|
|
721
692
|
async function ensureAgentInstructions(agent, cwd, isGlobal) {
|
|
722
693
|
if (isGlobal) return;
|
|
723
694
|
const agentConfig = targets[agent];
|
|
@@ -769,7 +740,6 @@ activate automatically.
|
|
|
769
740
|
else writeFileSync(filePath, `${getSkillInstructions(agent)}\n`);
|
|
770
741
|
p.log.success(`Updated ${agentConfig.instructionFile}`);
|
|
771
742
|
}
|
|
772
|
-
/** Default sections when model is pre-set (non-interactive) */
|
|
773
743
|
const DEFAULT_SECTIONS = ["best-practices", "api-changes"];
|
|
774
744
|
async function selectSkillSections(message = "Enhance SKILL.md") {
|
|
775
745
|
p.log.info("Budgets adapt to package release density.");
|
|
@@ -849,11 +819,6 @@ async function selectSkillSections(message = "Enhance SKILL.md") {
|
|
|
849
819
|
cancelled: false
|
|
850
820
|
};
|
|
851
821
|
}
|
|
852
|
-
/**
|
|
853
|
-
* Resolve sections + model for LLM enhancement.
|
|
854
|
-
* If presetModel is provided, uses DEFAULT_SECTIONS without prompting.
|
|
855
|
-
* Returns null if cancelled or no sections/model selected.
|
|
856
|
-
*/
|
|
857
822
|
async function selectLlmConfig(presetModel, message, updateCtx) {
|
|
858
823
|
if (presetModel) {
|
|
859
824
|
if ((await getAvailableModels()).some((m) => m.id === presetModel)) return {
|
|
@@ -954,7 +919,8 @@ async function selectLlmConfig(presetModel, message, updateCtx) {
|
|
|
954
919
|
};
|
|
955
920
|
}
|
|
956
921
|
async function enhanceSkillWithLLM(opts) {
|
|
957
|
-
const { packageName, version, skillDir, dirName, model, resolved, relatedSkills, hasIssues, hasDiscussions, hasReleases, hasChangelog, docsType, hasShippedDocs: shippedDocs, pkgFiles, force, debug, sections, customPrompt, packages, features, eject, overheadLines } = opts;
|
|
922
|
+
const { packageName, cachePackageName, version, skillDir, dirName, model, resolved, relatedSkills, hasIssues, hasDiscussions, hasReleases, hasChangelog, docsType, hasShippedDocs: shippedDocs, pkgFiles, force, debug, sections, customPrompt, packages, features, eject, overheadLines } = opts;
|
|
923
|
+
const cacheKey = cachePackageName || packageName;
|
|
958
924
|
const effectiveFeatures = features;
|
|
959
925
|
const llmLog = p.taskLog({
|
|
960
926
|
title: `Agent exploring ${packageName}`,
|
|
@@ -962,7 +928,7 @@ async function enhanceSkillWithLLM(opts) {
|
|
|
962
928
|
});
|
|
963
929
|
const docFiles = listReferenceFiles(skillDir);
|
|
964
930
|
const { optimized, wasOptimized, usage, cost, warnings, error, debugLogsDir } = await optimizeDocs({
|
|
965
|
-
packageName,
|
|
931
|
+
packageName: cacheKey,
|
|
966
932
|
skillDir,
|
|
967
933
|
model,
|
|
968
934
|
version,
|
|
@@ -1018,10 +984,6 @@ async function enhanceSkillWithLLM(opts) {
|
|
|
1018
984
|
} else if (error && /\b429\b|rate.?limit|exhausted.*capacity|quota.*reset/i.test(error)) llmLog.error(`Rate limited by LLM provider. Try again shortly or use a different model via \`skilld config\``);
|
|
1019
985
|
else llmLog.error(`Enhancement failed${error ? `: ${error}` : ""}`);
|
|
1020
986
|
}
|
|
1021
|
-
/**
|
|
1022
|
-
* Build and write PROMPT_*.md files for manual LLM use.
|
|
1023
|
-
* Returns the list of sections that had prompts written.
|
|
1024
|
-
*/
|
|
1025
987
|
function writePromptFiles(opts) {
|
|
1026
988
|
const { skillDir, sections, customPrompt, features } = opts;
|
|
1027
989
|
const docFiles = listReferenceFiles(skillDir);
|
|
@@ -1054,7 +1016,6 @@ function writePromptFiles(opts) {
|
|
|
1054
1016
|
}
|
|
1055
1017
|
return written;
|
|
1056
1018
|
}
|
|
1057
|
-
//#endregion
|
|
1058
1019
|
export { writePromptFiles as S, linkAllReferences as _, classifyCachedDoc as a, selectLlmConfig as b, ejectReferences as c, ensureGitignore as d, fetchAndCacheResources as f, indexResources as g, handleShippedSkills as h, SKILLD_MARKER_START as i, enhanceSkillWithLLM as l, forceClearCache as m, RESOLVE_STEP_LABELS as n, detectChangelog as o, findRelatedSkills as p, SKILLD_MARKER_END as r, detectDocsType as s, DEFAULT_SECTIONS as t, ensureAgentInstructions as u, resolveBaseDir as v, selectSkillSections as x, resolveLocalDep as y };
|
|
1059
1020
|
|
|
1060
1021
|
//# sourceMappingURL=sync-shared2.mjs.map
|