skilld 1.7.2 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/agent.mjs +693 -599
- package/dist/_chunks/agent.mjs.map +1 -1
- package/dist/_chunks/assemble.mjs +3 -3
- package/dist/_chunks/assemble.mjs.map +1 -1
- package/dist/_chunks/author-group.mjs.map +1 -1
- package/dist/_chunks/author.mjs +51 -121
- package/dist/_chunks/author.mjs.map +1 -1
- package/dist/_chunks/cache.mjs +315 -9
- package/dist/_chunks/cache.mjs.map +1 -1
- package/dist/_chunks/cache2.mjs +2 -2
- package/dist/_chunks/cache2.mjs.map +1 -1
- package/dist/_chunks/cli-helpers.mjs +3 -3
- package/dist/_chunks/cli-helpers.mjs.map +1 -1
- package/dist/_chunks/core.mjs +7 -4
- package/dist/_chunks/detect.mjs +1 -1
- package/dist/_chunks/detect.mjs.map +1 -1
- package/dist/_chunks/embedding-cache2.mjs +2 -2
- package/dist/_chunks/embedding-cache2.mjs.map +1 -1
- package/dist/_chunks/index.d.mts +305 -112
- package/dist/_chunks/index.d.mts.map +1 -1
- package/dist/_chunks/index2.d.mts +267 -32
- package/dist/_chunks/index2.d.mts.map +1 -1
- package/dist/_chunks/index3.d.mts +32 -577
- package/dist/_chunks/index3.d.mts.map +1 -1
- package/dist/_chunks/index4.d.mts +553 -0
- package/dist/_chunks/index4.d.mts.map +1 -0
- package/dist/_chunks/install.mjs +48 -88
- package/dist/_chunks/install.mjs.map +1 -1
- package/dist/_chunks/list.mjs +1 -1
- package/dist/_chunks/list.mjs.map +1 -1
- package/dist/_chunks/lockfile.mjs +29 -6
- package/dist/_chunks/lockfile.mjs.map +1 -1
- package/dist/_chunks/markdown.mjs.map +1 -1
- package/dist/_chunks/monorepo.mjs +71 -0
- package/dist/_chunks/monorepo.mjs.map +1 -0
- package/dist/_chunks/package-json.mjs.map +1 -1
- package/dist/_chunks/{shared.mjs → package-registry.mjs} +2 -40
- package/dist/_chunks/package-registry.mjs.map +1 -0
- package/dist/_chunks/paths.mjs +49 -0
- package/dist/_chunks/paths.mjs.map +1 -0
- package/dist/_chunks/pool2.mjs +7 -2
- package/dist/_chunks/pool2.mjs.map +1 -1
- package/dist/_chunks/prepare.mjs +1 -1
- package/dist/_chunks/prepare.mjs.map +1 -1
- package/dist/_chunks/prepare2.mjs +5 -5
- package/dist/_chunks/prepare2.mjs.map +1 -1
- package/dist/_chunks/prompts.mjs +366 -18
- package/dist/_chunks/prompts.mjs.map +1 -1
- package/dist/_chunks/retriv.mjs.map +1 -1
- package/dist/_chunks/sanitize.mjs.map +1 -1
- package/dist/_chunks/search-helpers.mjs +5 -6
- package/dist/_chunks/search-helpers.mjs.map +1 -1
- package/dist/_chunks/search-interactive.mjs +1 -1
- package/dist/_chunks/search-interactive.mjs.map +1 -1
- package/dist/_chunks/search.mjs +1 -2
- package/dist/_chunks/search.mjs.map +1 -1
- package/dist/_chunks/semver.mjs +13 -0
- package/dist/_chunks/semver.mjs.map +1 -0
- package/dist/_chunks/setup.mjs.map +1 -1
- package/dist/_chunks/skill-installer.mjs +2 -0
- package/dist/_chunks/skill-installer2.mjs +155 -0
- package/dist/_chunks/skill-installer2.mjs.map +1 -0
- package/dist/_chunks/skills.mjs +10 -9
- package/dist/_chunks/skills.mjs.map +1 -1
- package/dist/_chunks/sources.mjs +575 -386
- package/dist/_chunks/sources.mjs.map +1 -1
- package/dist/_chunks/sync-pipeline.mjs +952 -0
- package/dist/_chunks/sync-pipeline.mjs.map +1 -0
- package/dist/_chunks/sync-registry.mjs +19 -13
- package/dist/_chunks/sync-registry.mjs.map +1 -1
- package/dist/_chunks/sync.mjs +797 -886
- package/dist/_chunks/sync.mjs.map +1 -1
- package/dist/_chunks/sync2.mjs +4 -2
- package/dist/_chunks/types.d.mts +65 -77
- package/dist/_chunks/types.d.mts.map +1 -1
- package/dist/_chunks/types2.d.mts +88 -0
- package/dist/_chunks/types2.d.mts.map +1 -0
- package/dist/_chunks/uninstall.mjs +7 -8
- package/dist/_chunks/uninstall.mjs.map +1 -1
- package/dist/_chunks/upload.mjs +2 -2
- 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 +3 -13
- package/dist/_chunks/version.mjs.map +1 -1
- package/dist/_chunks/wizard.mjs +2 -2
- package/dist/_chunks/wizard.mjs.map +1 -1
- package/dist/_chunks/yaml.mjs.map +1 -1
- package/dist/agent/index.d.mts +2 -346
- package/dist/agent/index.mjs +2 -3
- package/dist/cache/index.d.mts +2 -2
- package/dist/cache/index.mjs +4 -3
- package/dist/cli.mjs +12 -13
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +5 -4
- package/dist/index.mjs +4 -3
- package/dist/prepare.mjs +2 -2
- package/dist/prepare.mjs.map +1 -1
- package/dist/retriv/index.d.mts +2 -2
- package/dist/retriv/worker.d.mts +2 -1
- package/dist/retriv/worker.d.mts.map +1 -1
- package/dist/retriv/worker.mjs +2 -1
- package/dist/retriv/worker.mjs.map +1 -1
- package/dist/sources/index.d.mts +3 -2
- package/dist/sources/index.mjs +3 -3
- package/dist/types.d.mts +3 -3
- package/package.json +5 -5
- package/dist/_chunks/config.mjs +0 -122
- package/dist/_chunks/config.mjs.map +0 -1
- package/dist/_chunks/prefix.mjs +0 -108
- package/dist/_chunks/prefix.mjs.map +0 -1
- package/dist/_chunks/shared.mjs.map +0 -1
- package/dist/_chunks/skill.mjs +0 -329
- package/dist/_chunks/skill.mjs.map +0 -1
- package/dist/_chunks/sync-shared.mjs +0 -2
- package/dist/_chunks/sync-shared2.mjs +0 -1020
- package/dist/_chunks/sync-shared2.mjs.map +0 -1
- package/dist/agent/index.d.mts.map +0 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { i as readPackageJsonSafe } from "./package-json.mjs";
|
|
2
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
|
+
import { join, resolve } from "pathe";
|
|
4
|
+
const QUOTE_PREFIX_RE = /^['"]/;
|
|
5
|
+
const QUOTE_SUFFIX_RE = /['"]$/;
|
|
6
|
+
function readRepoUrl(pkg) {
|
|
7
|
+
return typeof pkg.repository === "string" ? pkg.repository : pkg.repository?.url?.replace(/^git\+/, "").replace(/\.git$/, "");
|
|
8
|
+
}
|
|
9
|
+
function readWorkspacePatterns(cwd, pkg) {
|
|
10
|
+
let patterns = [];
|
|
11
|
+
if (Array.isArray(pkg.workspaces)) patterns = pkg.workspaces;
|
|
12
|
+
else if (pkg.workspaces?.packages) patterns = pkg.workspaces.packages;
|
|
13
|
+
if (patterns.length === 0) {
|
|
14
|
+
const pnpmWs = join(cwd, "pnpm-workspace.yaml");
|
|
15
|
+
if (existsSync(pnpmWs)) {
|
|
16
|
+
const lines = readFileSync(pnpmWs, "utf-8").split("\n");
|
|
17
|
+
for (const line of lines) {
|
|
18
|
+
const trimmed = line.trim();
|
|
19
|
+
if (!trimmed.startsWith("-")) continue;
|
|
20
|
+
const value = trimmed.slice(1).trim().replace(QUOTE_PREFIX_RE, "").replace(QUOTE_SUFFIX_RE, "");
|
|
21
|
+
if (value) patterns.push(value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return patterns;
|
|
26
|
+
}
|
|
27
|
+
function detectMonorepoPackages(cwd) {
|
|
28
|
+
const rootResult = readPackageJsonSafe(join(cwd, "package.json"));
|
|
29
|
+
if (!rootResult) return null;
|
|
30
|
+
const pkg = rootResult.parsed;
|
|
31
|
+
if (!pkg.private) return null;
|
|
32
|
+
const patterns = readWorkspacePatterns(cwd, pkg);
|
|
33
|
+
if (patterns.length === 0) return null;
|
|
34
|
+
const packages = [];
|
|
35
|
+
for (const pattern of patterns) {
|
|
36
|
+
const scanDir = resolve(cwd, pattern.replace(/\/?\*+$/, ""));
|
|
37
|
+
if (!existsSync(scanDir)) continue;
|
|
38
|
+
const directResult = readPackageJsonSafe(join(scanDir, "package.json"));
|
|
39
|
+
if (directResult) {
|
|
40
|
+
const directPkg = directResult.parsed;
|
|
41
|
+
if (!directPkg.private && directPkg.name) {
|
|
42
|
+
packages.push({
|
|
43
|
+
name: directPkg.name,
|
|
44
|
+
version: directPkg.version || "0.0.0",
|
|
45
|
+
description: directPkg.description,
|
|
46
|
+
repoUrl: readRepoUrl(directPkg),
|
|
47
|
+
dir: scanDir
|
|
48
|
+
});
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
for (const entry of readdirSync(scanDir, { withFileTypes: true })) {
|
|
53
|
+
if (!entry.isDirectory()) continue;
|
|
54
|
+
const childResult = readPackageJsonSafe(join(scanDir, entry.name, "package.json"));
|
|
55
|
+
if (!childResult) continue;
|
|
56
|
+
const childPkg = childResult.parsed;
|
|
57
|
+
if (childPkg.private || !childPkg.name) continue;
|
|
58
|
+
packages.push({
|
|
59
|
+
name: childPkg.name,
|
|
60
|
+
version: childPkg.version || "0.0.0",
|
|
61
|
+
description: childPkg.description,
|
|
62
|
+
repoUrl: readRepoUrl(childPkg),
|
|
63
|
+
dir: join(scanDir, entry.name)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return packages.length > 0 ? packages : null;
|
|
68
|
+
}
|
|
69
|
+
export { detectMonorepoPackages as t };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=monorepo.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monorepo.mjs","names":[],"sources":["../../src/core/monorepo.ts"],"sourcesContent":["/**\n * Monorepo detection — discovers public packages in a workspace root.\n * Used by author flow to drive multi-package skill generation.\n */\n\nimport { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { join, resolve } from 'pathe'\nimport { readPackageJsonSafe } from './package-json.ts'\n\nconst QUOTE_PREFIX_RE = /^['\"]/\nconst QUOTE_SUFFIX_RE = /['\"]$/\n\nexport interface MonorepoPackage {\n name: string\n version: string\n description?: string\n repoUrl?: string\n dir: string\n}\n\nfunction readRepoUrl(pkg: Record<string, any>): string | undefined {\n return typeof pkg.repository === 'string'\n ? pkg.repository\n : pkg.repository?.url?.replace(/^git\\+/, '').replace(/\\.git$/, '')\n}\n\nfunction readWorkspacePatterns(cwd: string, pkg: Record<string, any>): string[] {\n let patterns: string[] = []\n\n if (Array.isArray(pkg.workspaces))\n patterns = pkg.workspaces\n else if (pkg.workspaces?.packages)\n patterns = pkg.workspaces.packages\n\n if (patterns.length === 0) {\n const pnpmWs = join(cwd, 'pnpm-workspace.yaml')\n if (existsSync(pnpmWs)) {\n const lines = readFileSync(pnpmWs, 'utf-8').split('\\n')\n for (const line of lines) {\n const trimmed = line.trim()\n if (!trimmed.startsWith('-'))\n continue\n const value = trimmed.slice(1).trim().replace(QUOTE_PREFIX_RE, '').replace(QUOTE_SUFFIX_RE, '')\n if (value)\n patterns.push(value)\n }\n }\n }\n\n return patterns\n}\n\n/**\n * Detect public (non-private) packages declared by a workspace root.\n * Returns null if `cwd` is not a private workspace root or has no public\n * packages. Supports `package.json#workspaces` (array or `{ packages }`)\n * and `pnpm-workspace.yaml`.\n */\nexport function detectMonorepoPackages(cwd: string): MonorepoPackage[] | null {\n const rootResult = readPackageJsonSafe(join(cwd, 'package.json'))\n if (!rootResult)\n return null\n\n const pkg = rootResult.parsed as Record<string, any>\n if (!pkg.private)\n return null\n\n const patterns = readWorkspacePatterns(cwd, pkg)\n if (patterns.length === 0)\n return null\n\n const packages: MonorepoPackage[] = []\n\n for (const pattern of patterns) {\n const base = pattern.replace(/\\/?\\*+$/, '')\n const scanDir = resolve(cwd, base)\n if (!existsSync(scanDir))\n continue\n\n const directResult = readPackageJsonSafe(join(scanDir, 'package.json'))\n if (directResult) {\n const directPkg = directResult.parsed as Record<string, any>\n if (!directPkg.private && directPkg.name) {\n packages.push({\n name: directPkg.name,\n version: directPkg.version || '0.0.0',\n description: directPkg.description,\n repoUrl: readRepoUrl(directPkg),\n dir: scanDir,\n })\n continue\n }\n }\n\n for (const entry of readdirSync(scanDir, { withFileTypes: true })) {\n if (!entry.isDirectory())\n continue\n const childResult = readPackageJsonSafe(join(scanDir, entry.name, 'package.json'))\n if (!childResult)\n continue\n\n const childPkg = childResult.parsed as Record<string, any>\n if (childPkg.private || !childPkg.name)\n continue\n\n packages.push({\n name: childPkg.name,\n version: childPkg.version || '0.0.0',\n description: childPkg.description,\n repoUrl: readRepoUrl(childPkg),\n dir: join(scanDir, entry.name),\n })\n }\n }\n\n return packages.length > 0 ? packages : null\n}\n"],"mappings":";;;;;;CASA,OAAM,OAAA,IAAA,eAAkB,WAAA,IAAA,aAAA,IAAA,YAAA,KAAA,QAAA,UAAA,GAAA,CAAA,QAAA,UAAA,GAAA;;AAWxB,SAAS,sBAA0D,KAAA,KAAA;CACjE,IAAA,WAAc,EAAA;;MAKhB,IAAS,IAAA,YAAA,UAAmC,WAAoC,IAAA,WAAA;CAC9E,IAAI,SAAA,WAAuB,GAAA;EAE3B,MAAI,SAAM,KAAQ,KAAI,sBACT;MACR,WAAQ,OAAA,EAAY;GAGzB,MAAI,QAAS,aAAc,QAAA,QAAA,CAAA,MAAA,KAAA;GACzB,KAAM,MAAA,QAAc,OAAK;IACzB,MAAI,UAAW,KAAO,MAAE;IACtB,IAAA,CAAM,QAAQ,WAAA,IAAa,EAAA;IAC3B,MAAK,QAAM,QAAQ,MAAO,EAAA,CAAA,MAAA,CAAA,QAAA,iBAAA,GAAA,CAAA,QAAA,iBAAA,GAAA;IACxB,IAAA,OAAM,SAAU,KAAK,MAAM;;;;;;SAU1B,uBAAA,KAAA;;;;;;;;CAST,KAAA,MAAgB,WAAA,UAAuB;EACrC,MAAM,UAAA,QAAa,KAAA,QAAA,QAAyB,WAAK,GAAA,CAAA;EACjD,IAAK,CAAA,WACH,QAAO,EAAA;EAET,MAAM,eAAM,oBAAW,KAAA,SAAA,eAAA,CAAA;EACvB,IAAK,cACH;GAEF,MAAM,YAAW,aAAA;GACjB,IAAI,CAAA,UAAS,WACX,UAAO,MAAA;IAET,SAAM,KAA8B;KAEpC,MAAK,UAAM;KAET,SAAM,UAAU,WADH;KAEb,aAAgB,UACd;KAEF,SAAM,YAAe,UAAA;KACrB,KAAI;KACF,CAAA;IACA;;;OAGI,MAAA,SAAS,YAAU,SAAW,EAAA,eAAA,MAAA,CAAA,EAAA;OAC9B,CAAA,MAAA,aAAa,EAAU;SACvB,cAAS,oBAAsB,KAAA,SAAA,MAAA,MAAA,eAAA,CAAA;OAC/B,CAAA,aAAK;SACL,WAAA,YAAA;OACF,SAAA,WAAA,CAAA,SAAA,MAAA;;;IAIJ,SAAW,SAAS,WAAA;IAClB,aAAW,SAAA;IAEX,SAAM,YAAc,SAAA;IACpB,KAAK,KAAA,SACH,MAAA,KAAA;IAEF,CAAA;;;QAKE,SAAM,SAAS,IAAA,WAAA;;SAGf,0BAA8B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-json.mjs","names":[],"sources":["../../src/core/package-json.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs'\nimport { applyEdits, modify, parseTree } from 'jsonc-parser'\n\nexport interface EditOptions {\n /** Formatting options for inserted content */\n tabSize?: number\n insertSpaces?: boolean\n}\n\nconst defaultEditOptions: EditOptions = { tabSize: 2, insertSpaces: true }\n\n// ── Cached reader ──────────────────────────────────────────────\n\nconst cache = new Map<string, { raw: string, parsed: Record<string, unknown> }>()\n\n/**\n * Read and parse a package.json, returning cached result on repeat calls.\n * Throws if the file does not exist.\n */\nexport function readPackageJson(pkgPath: string): { raw: string, parsed: Record<string, unknown> } {\n const hit = cache.get(pkgPath)\n if (hit)\n return hit\n const raw = readFileSync(pkgPath, 'utf-8')\n const parsed = JSON.parse(raw) as Record<string, unknown>\n const entry = { raw, parsed }\n cache.set(pkgPath, entry)\n return entry\n}\n\n/**\n * Same as readPackageJson but returns null when the file is missing or unparseable.\n */\nexport function readPackageJsonSafe(pkgPath: string): { raw: string, parsed: Record<string, unknown> } | null {\n if (cache.has(pkgPath))\n return cache.get(pkgPath)!\n if (!existsSync(pkgPath))\n return null\n try {\n return readPackageJson(pkgPath)\n }\n catch {\n return null\n }\n}\n\n/**\n * Drop any cached entry so the next read hits disk.\n */\nexport function invalidatePackageJson(pkgPath: string): void {\n cache.delete(pkgPath)\n}\n\n/**\n * Clear all cached entries. Useful in tests.\n */\nexport function clearPackageJsonCache(): void {\n cache.clear()\n}\n\n// ── JSON editing helpers ───────────────────────────────────────\n\n/**\n * Set a value at a JSON path, preserving all surrounding formatting.\n * Returns the modified file content as a string.\n */\nexport function editJsonProperty(raw: string, path: (string | number)[], value: unknown, options?: EditOptions): string {\n const opts = { ...defaultEditOptions, ...options }\n const edits = modify(raw, path, value, {\n formattingOptions: { tabSize: opts.tabSize!, insertSpaces: opts.insertSpaces! },\n })\n return applyEdits(raw, edits)\n}\n\n/**\n * Remove a value at a JSON path, preserving all surrounding formatting.\n */\nexport function removeJsonProperty(raw: string, path: (string | number)[]): string {\n const edits = modify(raw, path, undefined, {})\n return applyEdits(raw, edits)\n}\n\n/**\n * Read a package.json, apply an edit function, write it back, and invalidate the cache.\n * The edit function receives the raw text and parsed object,\n * and returns the new raw text (or null to skip writing).\n */\nexport function patchPackageJson(\n pkgPath: string,\n editFn: (raw: string, pkg: Record<string, unknown>) => string | null,\n): boolean {\n const { raw, parsed } = readPackageJson(pkgPath)\n const result = editFn(raw, parsed)\n if (result === null)\n return false\n writeFileSync(pkgPath, result)\n invalidatePackageJson(pkgPath)\n return true\n}\n\n/**\n * Append a value to a JSON array at the given path, preserving formatting.\n * Inserts in sorted order if the array contains strings.\n */\nexport function appendToJsonArray(raw: string, path: string[], value: string, options?: EditOptions): string {\n const opts = { ...defaultEditOptions, ...options }\n const tree = parseTree(raw)\n if (!tree)\n return editJsonProperty(raw, path, [value], opts)\n\n // Walk to the target array node\n let node = tree\n for (const key of path) {\n const child = node.children?.find(c =>\n c.type === 'property' && c.children?.[0]?.value === key,\n )\n if (!child?.children?.[1])\n return editJsonProperty(raw, path, [value], opts)\n node = child.children[1]\n }\n\n if (node.type !== 'array' || !node.children)\n return editJsonProperty(raw, path, [value], opts)\n\n // Find sorted insertion index (only for string-only arrays)\n const allStrings = node.children.every(c => typeof c.value === 'string')\n let idx = node.children.length\n if (allStrings) {\n const items = node.children.map(c => c.value as string)\n for (let i = 0; i < items.length; i++) {\n if (value.localeCompare(items[i]!) < 0) {\n idx = i\n break\n }\n }\n }\n\n const edits = modify(raw, [...path, idx], value, {\n formattingOptions: { tabSize: opts.tabSize!, insertSpaces: opts.insertSpaces! },\n isArrayInsertion: true,\n })\n return applyEdits(raw, edits)\n}\n"],"mappings":";;AASA,MAAM,qBAAkC;CAAE,SAAS;CAAG,cAAc;CAAM;AAI1E,MAAM,wBAAQ,IAAI,KAA+D;;;;CAMjF,MAAA,MAAgB,aAAgB,SAAmE,QAAA;CACjG,MAAM,QAAM;EACZ;EAEA,QAAM,KAAM,MAAA,IAAA;EAEZ;OAAgB,IAAA,SAAA,MAAA;QAAK;;
|
|
1
|
+
{"version":3,"file":"package-json.mjs","names":[],"sources":["../../src/core/package-json.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs'\nimport { applyEdits, modify, parseTree } from 'jsonc-parser'\n\nexport interface EditOptions {\n /** Formatting options for inserted content */\n tabSize?: number\n insertSpaces?: boolean\n}\n\nconst defaultEditOptions: EditOptions = { tabSize: 2, insertSpaces: true }\n\n// ── Cached reader ──────────────────────────────────────────────\n\nconst cache = new Map<string, { raw: string, parsed: Record<string, unknown> }>()\n\n/**\n * Read and parse a package.json, returning cached result on repeat calls.\n * Throws if the file does not exist.\n */\nexport function readPackageJson(pkgPath: string): { raw: string, parsed: Record<string, unknown> } {\n const hit = cache.get(pkgPath)\n if (hit)\n return hit\n const raw = readFileSync(pkgPath, 'utf-8')\n const parsed = JSON.parse(raw) as Record<string, unknown>\n const entry = { raw, parsed }\n cache.set(pkgPath, entry)\n return entry\n}\n\n/**\n * Same as readPackageJson but returns null when the file is missing or unparseable.\n */\nexport function readPackageJsonSafe(pkgPath: string): { raw: string, parsed: Record<string, unknown> } | null {\n if (cache.has(pkgPath))\n return cache.get(pkgPath)!\n if (!existsSync(pkgPath))\n return null\n try {\n return readPackageJson(pkgPath)\n }\n catch {\n return null\n }\n}\n\n/**\n * Drop any cached entry so the next read hits disk.\n */\nexport function invalidatePackageJson(pkgPath: string): void {\n cache.delete(pkgPath)\n}\n\n/**\n * Clear all cached entries. Useful in tests.\n */\nexport function clearPackageJsonCache(): void {\n cache.clear()\n}\n\n// ── JSON editing helpers ───────────────────────────────────────\n\n/**\n * Set a value at a JSON path, preserving all surrounding formatting.\n * Returns the modified file content as a string.\n */\nexport function editJsonProperty(raw: string, path: (string | number)[], value: unknown, options?: EditOptions): string {\n const opts = { ...defaultEditOptions, ...options }\n const edits = modify(raw, path, value, {\n formattingOptions: { tabSize: opts.tabSize!, insertSpaces: opts.insertSpaces! },\n })\n return applyEdits(raw, edits)\n}\n\n/**\n * Remove a value at a JSON path, preserving all surrounding formatting.\n */\nexport function removeJsonProperty(raw: string, path: (string | number)[]): string {\n const edits = modify(raw, path, undefined, {})\n return applyEdits(raw, edits)\n}\n\n/**\n * Read a package.json, apply an edit function, write it back, and invalidate the cache.\n * The edit function receives the raw text and parsed object,\n * and returns the new raw text (or null to skip writing).\n */\nexport function patchPackageJson(\n pkgPath: string,\n editFn: (raw: string, pkg: Record<string, unknown>) => string | null,\n): boolean {\n const { raw, parsed } = readPackageJson(pkgPath)\n const result = editFn(raw, parsed)\n if (result === null)\n return false\n writeFileSync(pkgPath, result)\n invalidatePackageJson(pkgPath)\n return true\n}\n\n/**\n * Append a value to a JSON array at the given path, preserving formatting.\n * Inserts in sorted order if the array contains strings.\n */\nexport function appendToJsonArray(raw: string, path: string[], value: string, options?: EditOptions): string {\n const opts = { ...defaultEditOptions, ...options }\n const tree = parseTree(raw)\n if (!tree)\n return editJsonProperty(raw, path, [value], opts)\n\n // Walk to the target array node\n let node = tree\n for (const key of path) {\n const child = node.children?.find(c =>\n c.type === 'property' && c.children?.[0]?.value === key,\n )\n if (!child?.children?.[1])\n return editJsonProperty(raw, path, [value], opts)\n node = child.children[1]\n }\n\n if (node.type !== 'array' || !node.children)\n return editJsonProperty(raw, path, [value], opts)\n\n // Find sorted insertion index (only for string-only arrays)\n const allStrings = node.children.every(c => typeof c.value === 'string')\n let idx = node.children.length\n if (allStrings) {\n const items = node.children.map(c => c.value as string)\n for (let i = 0; i < items.length; i++) {\n if (value.localeCompare(items[i]!) < 0) {\n idx = i\n break\n }\n }\n }\n\n const edits = modify(raw, [...path, idx], value, {\n formattingOptions: { tabSize: opts.tabSize!, insertSpaces: opts.insertSpaces! },\n isArrayInsertion: true,\n })\n return applyEdits(raw, edits)\n}\n"],"mappings":";;AASA,MAAM,qBAAkC;CAAE,SAAS;CAAG,cAAc;CAAM;AAI1E,MAAM,wBAAQ,IAAI,KAA+D;;;;CAMjF,MAAA,MAAgB,aAAgB,SAAmE,QAAA;CACjG,MAAM,QAAM;EACZ;EAEA,QAAM,KAAM,MAAA,IAAA;EAEZ;OAAgB,IAAA,SAAA,MAAA;QAAK;;SAEd,oBAAA,SAAA;;;;;SAMO;EACd,OAAI;;;SAOE,sBAAA,SAAA;OACJ,OAAO,QAAA;;;;;EAOX,GAAA;EACE;;;;;;SAiBM,iBAAO,SAAA,QAAA;OAAK,EAAA,KAAA,WAAA,gBAAA,QAAA;OAAuB,SAAA,OAAA,KAAA,OAAA;KAAS,WAAA,MAAA,OAAA;CAIlD,cAAO,SAHO,OAAO;uBACgB,QAAA;QAAU;;;;;;;CAkBjD,MAAA,OAAgB,UAAA,IACd;CAGA,IAAA,CAAA,MAAQ,OAAK,iBAAW,KAAgB,MAAA,CAAA,MAAQ,EAAA,KAAA;CAChD,IAAA,OAAM;CACN,KAAI,MAAA,OAAW,MACb;EACF,MAAA,QAAc,KAAA,UAAgB,MAAA,MAAA,EAAA,SAAA,cAAA,EAAA,WAAA,IAAA,UAAA,IAAA;EAC9B,IAAA,CAAA,OAAA,WAAsB,IAAA,OAAQ,iBAAA,KAAA,MAAA,CAAA,MAAA,EAAA,KAAA;EAC9B,OAAO,MAAA,SAAA;;;;;;EAOT,MAAA,QAAgB,KAAA,SAAkB,KAAa,MAAgB,EAAA,MAAe;EAC5E,KAAM,IAAA,IAAO,GAAA,IAAA,MAAA,QAAA,KAAA,IAAA,MAAA,cAAA,MAAA,GAAA,GAAA,GAAA;GAAE,MAAG;GAAoB;;;CAEtC,OAAK,WACI,KAAA,OAAA,KAAiB,CAAA,GAAA,MAAK,IAAO,EAAA,OAAQ;EAG9C,mBAAW;GACX,SAAW,KAAA;GACT,cAAc,KAAK;GAGnB;EAEA,kBAAa;;;SAQX,uBAAoB,GAAA,oBAAA,GAAA,oBAAA,GAAA,qBAAA"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { join } from "pathe";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { execSync } from "node:child_process";
|
|
4
|
-
import { diff, gt, valid } from "semver";
|
|
5
|
-
import { isWindows } from "std-env";
|
|
6
1
|
const REPO_REGISTRY = {
|
|
7
2
|
"vuejs/core": {
|
|
8
3
|
owner: "vuejs",
|
|
@@ -465,39 +460,6 @@ function getRelatedPackages(packageName) {
|
|
|
465
460
|
if (!entry) return [];
|
|
466
461
|
return Object.keys(entry.packages);
|
|
467
462
|
}
|
|
468
|
-
|
|
469
|
-
let val = map.get(key);
|
|
470
|
-
if (val === void 0) {
|
|
471
|
-
val = create();
|
|
472
|
-
map.set(key, val);
|
|
473
|
-
}
|
|
474
|
-
return val;
|
|
475
|
-
}
|
|
476
|
-
function semverValid(v) {
|
|
477
|
-
return valid(v, true);
|
|
478
|
-
}
|
|
479
|
-
function semverGt(a, b) {
|
|
480
|
-
return gt(a, b, true);
|
|
481
|
-
}
|
|
482
|
-
function semverDiff(a, b) {
|
|
483
|
-
return diff(a, b);
|
|
484
|
-
}
|
|
485
|
-
let _skilldCommand;
|
|
486
|
-
function resolveSkilldCommand() {
|
|
487
|
-
if (_skilldCommand !== void 0) return _skilldCommand;
|
|
488
|
-
try {
|
|
489
|
-
execSync(`${isWindows ? "where" : "which"} skilld`, { stdio: "ignore" });
|
|
490
|
-
_skilldCommand = "skilld";
|
|
491
|
-
} catch {
|
|
492
|
-
_skilldCommand = "npx -y skilld";
|
|
493
|
-
}
|
|
494
|
-
return _skilldCommand;
|
|
495
|
-
}
|
|
496
|
-
const SHARED_SKILLS_DIR = ".skills";
|
|
497
|
-
function getSharedSkillsDir(cwd = process.cwd()) {
|
|
498
|
-
const dir = join(cwd, SHARED_SKILLS_DIR);
|
|
499
|
-
return existsSync(dir) ? dir : null;
|
|
500
|
-
}
|
|
501
|
-
export { semverDiff as a, getBlogPreset as c, getFilePatterns as d, getPackageRules as f, getRepoKeyForPackage as g, getRepoEntry as h, resolveSkilldCommand as i, getCrawlUrl as l, getRelatedPackages as m, getSharedSkillsDir as n, semverGt as o, getPrereleaseChangelogRef as p, mapInsert as r, semverValid as s, SHARED_SKILLS_DIR as t, getDocOverride as u };
|
|
463
|
+
export { getPackageRules as a, getRepoEntry as c, getFilePatterns as i, getRepoKeyForPackage as l, getCrawlUrl as n, getPrereleaseChangelogRef as o, getDocOverride as r, getRelatedPackages as s, getBlogPreset as t };
|
|
502
464
|
|
|
503
|
-
//# sourceMappingURL=
|
|
465
|
+
//# sourceMappingURL=package-registry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-registry.mjs","names":[],"sources":["../../src/sources/package-registry.data.ts","../../src/sources/package-registry.ts"],"sourcesContent":["/**\n * Curated repo registry data — keyed by GitHub 'owner/repo'.\n * Maintained as a TypeScript const so RepoEntry types validate it.\n * Lookup helpers and reverse index live in package-registry.ts.\n */\n\nimport type { RepoEntry } from './package-registry.ts'\n\nexport const REPO_REGISTRY: Record<string, RepoEntry> = {\n // ── Frameworks with doc overrides ──\n\n 'vuejs/core': {\n owner: 'vuejs',\n repo: 'core',\n docsRepo: 'docs',\n docsPath: 'src',\n homepage: 'https://vuejs.org',\n prereleaseChangelogRef: 'minor',\n packages: {\n 'vue': { primary: true, filePatterns: ['*.vue'], rules: ['ALWAYS use `<script setup lang=\"ts\">`', 'Use ```vue code fences for SFC examples containing `<script>` or `<template>` tags, ```ts for plain TypeScript'] },\n '@vue/compiler-core': {},\n '@vue/compiler-dom': {},\n '@vue/reactivity': {},\n '@vue/runtime-core': {},\n '@vue/runtime-dom': {},\n '@vue/shared': {},\n },\n blogReleases: [\n { version: '3.5', url: 'https://blog.vuejs.org/posts/vue-3-5', date: '2024-09-01' },\n { version: '3.4', url: 'https://blog.vuejs.org/posts/vue-3-4', date: '2023-12-28' },\n { version: '3.3', url: 'https://blog.vuejs.org/posts/vue-3-3', date: '2023-05-11' },\n { version: '3.2', url: 'https://blog.vuejs.org/posts/vue-3-2', date: '2021-08-05' },\n { version: '3.1', url: 'https://blog.vuejs.org/posts/vue-3-1', date: '2021-06-07' },\n { version: '3.0', url: 'https://blog.vuejs.org/posts/vue-3-0', date: '2020-09-18' },\n ],\n },\n\n 'tailwindlabs/tailwindcss': {\n owner: 'tailwindlabs',\n repo: 'tailwindcss',\n docsRepo: 'tailwindcss.com',\n docsPath: 'src/docs',\n homepage: 'https://tailwindcss.com',\n packages: {\n tailwindcss: { primary: true },\n },\n },\n\n 'withastro/astro': {\n owner: 'withastro',\n repo: 'astro',\n docsRepo: 'docs',\n docsPath: 'src/content/docs/en',\n homepage: 'https://docs.astro.build',\n packages: {\n astro: { primary: true, filePatterns: ['*.astro'] },\n },\n },\n\n 'vueuse/vueuse': {\n owner: 'vueuse',\n repo: 'vueuse',\n docsPath: 'packages',\n packages: {\n '@vueuse/core': { primary: true },\n },\n },\n\n // ── Frameworks (file patterns only) ──\n\n 'sveltejs/svelte': {\n owner: 'sveltejs',\n repo: 'svelte',\n packages: {\n svelte: { primary: true, filePatterns: ['*.svelte'], rules: ['ALWAYS use runes syntax ($state, $derived, $effect, $props)'] },\n },\n },\n\n 'solidjs/solid': {\n owner: 'solidjs',\n repo: 'solid',\n packages: {\n 'solid-js': { primary: true, filePatterns: ['*.jsx', '*.tsx'] },\n },\n },\n\n 'QwikDev/qwik': {\n owner: 'QwikDev',\n repo: 'qwik',\n packages: {\n qwik: { primary: true, filePatterns: ['*.tsx'] },\n },\n },\n\n 'marko-js/marko': {\n owner: 'marko-js',\n repo: 'marko',\n packages: {\n marko: { primary: true, filePatterns: ['*.marko'] },\n },\n },\n\n 'riot/riot': {\n owner: 'riot',\n repo: 'riot',\n packages: {\n riot: { primary: true, filePatterns: ['*.riot'] },\n },\n },\n\n // ── Languages/transpilers ──\n\n 'microsoft/TypeScript': {\n owner: 'microsoft',\n repo: 'TypeScript',\n packages: {\n typescript: { primary: true, filePatterns: ['*.ts', '*.tsx', '*.mts', '*.cts'] },\n },\n blogReleases: [\n { version: '6.0', url: 'https://devblogs.microsoft.com/typescript/announcing-typescript-6-0-beta/', date: '2026-02-11', title: 'Announcing TypeScript 6.0 Beta' },\n { version: '5.9', url: 'https://devblogs.microsoft.com/typescript/announcing-typescript-5-9/', date: '2025-08-01', title: 'Announcing TypeScript 5.9' },\n { version: '5.8', url: 'https://devblogs.microsoft.com/typescript/announcing-typescript-5-8/', date: '2025-02-28', title: 'Announcing TypeScript 5.8' },\n { version: '5.7', url: 'https://devblogs.microsoft.com/typescript/announcing-typescript-5-7/', date: '2024-11-22', title: 'Announcing TypeScript 5.7' },\n { version: '5.6', url: 'https://devblogs.microsoft.com/typescript/announcing-typescript-5-6/', date: '2024-09-09', title: 'Announcing TypeScript 5.6' },\n { version: '5.5', url: 'https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/', date: '2024-06-20', title: 'Announcing TypeScript 5.5' },\n ],\n },\n\n 'jashkenas/coffeescript': {\n owner: 'jashkenas',\n repo: 'coffeescript',\n packages: {\n coffeescript: { primary: true, filePatterns: ['*.coffee'] },\n },\n },\n\n 'gkz/LiveScript': {\n owner: 'gkz',\n repo: 'LiveScript',\n packages: {\n livescript: { primary: true, filePatterns: ['*.ls'] },\n },\n },\n\n 'elm/compiler': {\n owner: 'elm',\n repo: 'compiler',\n packages: {\n elm: { primary: true, filePatterns: ['*.elm'] },\n },\n },\n\n // ── CSS preprocessors ──\n\n 'sass/dart-sass': {\n owner: 'sass',\n repo: 'dart-sass',\n packages: {\n sass: { primary: true, filePatterns: ['*.scss', '*.sass'] },\n },\n },\n\n 'less/less.js': {\n owner: 'less',\n repo: 'less.js',\n packages: {\n less: { primary: true, filePatterns: ['*.less'] },\n },\n },\n\n 'stylus/stylus': {\n owner: 'stylus',\n repo: 'stylus',\n packages: {\n stylus: { primary: true, filePatterns: ['*.styl'] },\n },\n },\n\n 'postcss/postcss': {\n owner: 'postcss',\n repo: 'postcss',\n packages: {\n postcss: { primary: true, filePatterns: ['*.css', '*.pcss'] },\n },\n },\n\n // ── Template engines ──\n\n 'pugjs/pug': {\n owner: 'pugjs',\n repo: 'pug',\n packages: {\n pug: { primary: true, filePatterns: ['*.pug'] },\n },\n },\n\n 'mde/ejs': {\n owner: 'mde',\n repo: 'ejs',\n packages: {\n ejs: { primary: true, filePatterns: ['*.ejs'] },\n },\n },\n\n 'handlebars-lang/handlebars.js': {\n owner: 'handlebars-lang',\n repo: 'handlebars.js',\n packages: {\n handlebars: { primary: true, filePatterns: ['*.hbs', '*.handlebars'] },\n },\n },\n\n 'janl/mustache.js': {\n owner: 'janl',\n repo: 'mustache.js',\n packages: {\n mustache: { primary: true, filePatterns: ['*.mustache'] },\n },\n },\n\n 'mozilla/nunjucks': {\n owner: 'mozilla',\n repo: 'nunjucks',\n packages: {\n nunjucks: { primary: true, filePatterns: ['*.njk'] },\n },\n },\n\n 'Shopify/liquid': {\n owner: 'Shopify',\n repo: 'liquid',\n packages: {\n liquid: { primary: true, filePatterns: ['*.liquid'] },\n },\n },\n\n // ── Data formats ──\n\n 'eemeli/yaml': {\n owner: 'eemeli',\n repo: 'yaml',\n packages: {\n yaml: { primary: true, filePatterns: ['*.yaml', '*.yml'] },\n },\n },\n\n 'nodeca/js-yaml': {\n owner: 'nodeca',\n repo: 'js-yaml',\n packages: {\n 'js-yaml': { primary: true, filePatterns: ['*.yaml', '*.yml'] },\n },\n },\n\n 'BinaryMuse/toml-node': {\n owner: 'BinaryMuse',\n repo: 'toml-node',\n packages: {\n 'toml': { primary: true, filePatterns: ['*.toml'] },\n '@iarna/toml': { filePatterns: ['*.toml'] },\n },\n },\n\n 'json5/json5': {\n owner: 'json5',\n repo: 'json5',\n packages: {\n json5: { primary: true, filePatterns: ['*.json5'] },\n },\n },\n\n 'microsoft/node-jsonc-parser': {\n owner: 'microsoft',\n repo: 'node-jsonc-parser',\n packages: {\n 'jsonc-parser': { primary: true, filePatterns: ['*.jsonc'] },\n },\n },\n\n // ── Markdown ──\n\n 'markdown-it/markdown-it': {\n owner: 'markdown-it',\n repo: 'markdown-it',\n packages: {\n 'markdown-it': { primary: true, filePatterns: ['*.md'] },\n },\n },\n\n 'markedjs/marked': {\n owner: 'markedjs',\n repo: 'marked',\n packages: {\n marked: { primary: true, filePatterns: ['*.md'] },\n },\n },\n\n 'remarkjs/remark': {\n owner: 'remarkjs',\n repo: 'remark',\n packages: {\n remark: { primary: true, filePatterns: ['*.md', '*.mdx'] },\n },\n },\n\n 'mdx-js/mdx': {\n owner: 'mdx-js',\n repo: 'mdx',\n packages: {\n '@mdx-js/mdx': { primary: true, filePatterns: ['*.mdx'] },\n },\n },\n\n // ── GraphQL ──\n\n 'graphql/graphql-js': {\n owner: 'graphql',\n repo: 'graphql-js',\n packages: {\n 'graphql': { primary: true, filePatterns: ['*.graphql', '*.gql'] },\n 'graphql-tag': { filePatterns: ['*.graphql', '*.gql'] },\n },\n },\n\n 'dotansimha/graphql-code-generator': {\n owner: 'dotansimha',\n repo: 'graphql-code-generator',\n packages: {\n '@graphql-codegen/cli': { primary: true, filePatterns: ['*.graphql', '*.gql'] },\n },\n },\n\n // ── UI Frameworks ──\n\n 'quasarframework/quasar': {\n owner: 'quasarframework',\n repo: 'quasar',\n docsPath: 'docs/src/pages',\n docsRef: 'dev',\n homepage: 'https://quasar.dev',\n packages: {\n quasar: { primary: true },\n },\n },\n\n // ── Animation ──\n\n 'motiondivision/motion-vue': {\n owner: 'motiondivision',\n repo: 'motion-vue',\n homepage: 'https://motion.dev',\n crawlUrl: 'https://motion.dev/docs/vue**',\n packages: {\n 'motion-v': { primary: true },\n },\n },\n\n // ── Other ──\n\n 'prisma/prisma': {\n owner: 'prisma',\n repo: 'prisma',\n packages: {\n 'prisma': { primary: true, filePatterns: ['*.prisma'] },\n '@prisma/client': { filePatterns: ['*.prisma'] },\n },\n },\n\n 'nicolo-ribaudo/tc39-proposal-wasm-esm-integration': {\n owner: 'nicolo-ribaudo',\n repo: 'tc39-proposal-wasm-esm-integration',\n packages: {\n 'wasm-pack': { primary: true, filePatterns: ['*.wasm'] },\n },\n },\n}\n","/**\n * Package registry — types, lookup helpers, and reverse index.\n * Curated registry data lives in package-registry.data.ts.\n * Keyed by GitHub 'owner/repo' (source code repo).\n */\n\nimport { REPO_REGISTRY } from './package-registry.data.ts'\n\nexport interface BlogRelease {\n version: string\n url: string\n date: string\n title?: string\n}\n\nexport interface PackageEntry {\n filePatterns?: string[]\n primary?: boolean\n /** Extra rules injected into skill generation prompts */\n rules?: string[]\n}\n\nexport interface RepoEntry {\n owner: string\n repo: string\n /** Separate docs repo name (e.g. 'docs' → owner/docs) */\n docsRepo?: string\n /** Path prefix to filter markdown files */\n docsPath?: string\n /** Branch/ref override */\n docsRef?: string\n /** Homepage URL */\n homepage?: string\n /** URL pattern to crawl for docs (glob, e.g. 'https://example.com/docs/**') */\n crawlUrl?: string\n /** Branch to fetch CHANGELOG.md from when installed version is a prerelease (e.g. 'minor' for Vue) */\n prereleaseChangelogRef?: string\n /** Packages in this repo */\n packages: Record<string, PackageEntry>\n /** Curated blog release posts */\n blogReleases?: BlogRelease[]\n}\n\n// Backwards-compatible types\nexport interface DocOverride {\n owner: string\n repo: string\n path: string\n ref?: string\n homepage?: string\n}\n\nexport interface BlogPreset {\n packageName: string\n releases: BlogRelease[]\n}\n\n// ── Reverse index (auto-generated) ──\n\nconst PACKAGE_TO_REPO_MAP: Record<string, string> = {}\n\nfor (const [repoKey, entry] of Object.entries(REPO_REGISTRY)) {\n for (const packageName of Object.keys(entry.packages)) {\n PACKAGE_TO_REPO_MAP[packageName] = repoKey\n }\n}\n\n// ── Backwards-compatible helpers ──\n\nexport function getDocOverride(packageName: string): DocOverride | undefined {\n const repoKey = PACKAGE_TO_REPO_MAP[packageName]\n if (!repoKey)\n return undefined\n const entry = REPO_REGISTRY[repoKey]\n if (!entry?.docsRepo && !entry?.docsPath)\n return undefined\n\n return {\n owner: entry.owner,\n repo: entry.docsRepo || entry.repo,\n path: entry.docsPath || '',\n ref: entry.docsRef,\n homepage: entry.homepage,\n }\n}\n\nexport function getBlogPreset(packageName: string): BlogPreset | undefined {\n const repoKey = PACKAGE_TO_REPO_MAP[packageName]\n if (!repoKey)\n return undefined\n const entry = REPO_REGISTRY[repoKey]\n if (!entry?.blogReleases)\n return undefined\n\n return {\n packageName,\n releases: entry.blogReleases,\n }\n}\n\nexport function getFilePatterns(packageName: string): string[] | undefined {\n const repoKey = PACKAGE_TO_REPO_MAP[packageName]\n if (!repoKey)\n return undefined\n return REPO_REGISTRY[repoKey]?.packages[packageName]?.filePatterns\n}\n\n// ── New APIs ──\n\nexport function getRepoEntry(repoKey: string): RepoEntry | undefined {\n return REPO_REGISTRY[repoKey]\n}\n\nexport function getRepoKeyForPackage(packageName: string): string | undefined {\n return PACKAGE_TO_REPO_MAP[packageName]\n}\n\nexport function getPackageRules(packageName: string): string[] {\n const repoKey = PACKAGE_TO_REPO_MAP[packageName]\n if (!repoKey)\n return []\n return REPO_REGISTRY[repoKey]?.packages[packageName]?.rules ?? []\n}\n\nexport function getPrereleaseChangelogRef(packageName: string): string | undefined {\n const repoKey = PACKAGE_TO_REPO_MAP[packageName]\n if (!repoKey)\n return undefined\n return REPO_REGISTRY[repoKey]?.prereleaseChangelogRef\n}\n\nexport function getCrawlUrl(packageName: string): string | undefined {\n const repoKey = PACKAGE_TO_REPO_MAP[packageName]\n if (!repoKey)\n return undefined\n return REPO_REGISTRY[repoKey]?.crawlUrl\n}\n\nexport function getRelatedPackages(packageName: string): string[] {\n const repoKey = PACKAGE_TO_REPO_MAP[packageName]\n if (!repoKey)\n return []\n const entry = REPO_REGISTRY[repoKey]\n if (!entry)\n return []\n return Object.keys(entry.packages)\n}\n"],"mappings":"AAQA,MAAa,gBAA2C;CAGtD,cAAc;EACZ,OAAO;EACP,MAAM;EACN,UAAU;EACV,UAAU;EACV,UAAU;EACV,wBAAwB;EACxB,UAAU;GACR,OAAO;IAAE,SAAS;IAAM,cAAc,CAAC,QAAQ;IAAE,OAAO,CAAC,2CAAyC,iHAAiH;IAAE;GACrN,sBAAsB,EAAE;GACxB,qBAAqB,EAAE;GACvB,mBAAmB,EAAE;GACrB,qBAAqB,EAAE;GACvB,oBAAoB,EAAE;GACtB,eAAe,EAAE;GAClB;EACD,cAAc;GACZ;IAAE,SAAS;IAAO,KAAK;IAAwC,MAAM;IAAc;GACnF;IAAE,SAAS;IAAO,KAAK;IAAwC,MAAM;IAAc;GACnF;IAAE,SAAS;IAAO,KAAK;IAAwC,MAAM;IAAc;GACnF;IAAE,SAAS;IAAO,KAAK;IAAwC,MAAM;IAAc;GACnF;IAAE,SAAS;IAAO,KAAK;IAAwC,MAAM;IAAc;GACnF;IAAE,SAAS;IAAO,KAAK;IAAwC,MAAM;IAAc;GACpF;EACF;CAED,4BAA4B;EAC1B,OAAO;EACP,MAAM;EACN,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU,EACR,aAAa,EAAE,SAAS,MAAM,EAC/B;EACF;CAED,mBAAmB;EACjB,OAAO;EACP,MAAM;EACN,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU,EACR,OAAO;GAAE,SAAS;GAAM,cAAc,CAAC,UAAU;GAA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EA,UAAM,MAAQ;EACd;;SAIE,gBAAA,aAAA;OACA,UAAU,oBAAM;KACjB,CAAA,SAAA,OAAA,KAAA;;;SAIK,aAAU,SAAA;CAChB,OAAK,cACI;;;CAMX,OAAA,oBAA6B;;;CAI7B,MAAA,UAAgB,oBAAqB;CACnC,IAAA,CAAA,SAAO,OAAA,EAAA;;;SAID,0BAAU,aAAoB;CACpC,MAAK,UACH,oBAAS;CACX,IAAA,CAAA,SAAO,OAAc,KAAA;;;SAIf,YAAU,aAAA;CAChB,MAAK,UACH,oBAAO;CACT,IAAA,CAAA,SAAO,OAAc,KAAA;;;SAIf,mBAAU,aAAoB;CACpC,MAAK,UACH,oBAAO;CACT,IAAA,CAAA,SAAO,OAAc,EAAA;;CAGvB,IAAA,CAAA,OAAgB,OAAA,EAAA;CACd,OAAM,OAAA,KAAU,MAAA,SAAA;;SAIX,mBACM,GAAA,gBAAA,GAAA,mBAAA,GAAA,wBAAA,GAAA,eAAA,GAAA,6BAAA,GAAA,kBAAA,GAAA,sBAAA,GAAA,iBAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "pathe";
|
|
4
|
+
const SHARED_SKILLS_DIR = ".skills";
|
|
5
|
+
const SKILL_INTERNAL_DIRNAME = ".skilld";
|
|
6
|
+
const SKILL_INTERNAL_FILENAME = "_SKILL.md";
|
|
7
|
+
const LOCK_FILENAME = "skilld-lock.yaml";
|
|
8
|
+
const CONFIG_FILENAME = "config.yaml";
|
|
9
|
+
const CACHE_DIR = join(homedir(), ".skilld");
|
|
10
|
+
const REFERENCES_DIR = join(CACHE_DIR, "references");
|
|
11
|
+
const REPOS_DIR = join(CACHE_DIR, "repos");
|
|
12
|
+
const LLM_CACHE_DIR = join(CACHE_DIR, "llm-cache");
|
|
13
|
+
join(CACHE_DIR, "skills");
|
|
14
|
+
join(CACHE_DIR, "git-skills");
|
|
15
|
+
join(CACHE_DIR, "embeddings.db");
|
|
16
|
+
const CONFIG_PATH = join(CACHE_DIR, CONFIG_FILENAME);
|
|
17
|
+
const PI_AI_AUTH_PATH = join(CACHE_DIR, "pi-ai-auth.json");
|
|
18
|
+
function getSharedSkillsDir(cwd = process.cwd()) {
|
|
19
|
+
const dir = join(cwd, SHARED_SKILLS_DIR);
|
|
20
|
+
return existsSync(dir) ? dir : null;
|
|
21
|
+
}
|
|
22
|
+
function lockfilePath(skillsDir) {
|
|
23
|
+
return join(skillsDir, LOCK_FILENAME);
|
|
24
|
+
}
|
|
25
|
+
function skillInternalDir(skillDir) {
|
|
26
|
+
return join(skillDir, SKILL_INTERNAL_DIRNAME);
|
|
27
|
+
}
|
|
28
|
+
function skillInternalFile(skillDir) {
|
|
29
|
+
return join(skillDir, SKILL_INTERNAL_DIRNAME, SKILL_INTERNAL_FILENAME);
|
|
30
|
+
}
|
|
31
|
+
function skillLogDir(skillDir) {
|
|
32
|
+
return join(skillDir, SKILL_INTERNAL_DIRNAME, "logs");
|
|
33
|
+
}
|
|
34
|
+
function skillRefsSection(skillDir, section) {
|
|
35
|
+
return join(skillDir, SKILL_INTERNAL_DIRNAME, section);
|
|
36
|
+
}
|
|
37
|
+
function getReferencesDir(name, version) {
|
|
38
|
+
return join(REFERENCES_DIR, `${name}@${version}`);
|
|
39
|
+
}
|
|
40
|
+
function getRepoCacheDir(owner, repo) {
|
|
41
|
+
if (owner.includes("..") || repo.includes("..") || owner.includes("/") || repo.includes("/")) throw new Error(`Invalid repo path: ${owner}/${repo}`);
|
|
42
|
+
return join(REPOS_DIR, owner, repo);
|
|
43
|
+
}
|
|
44
|
+
function getPackageDbPath(name, version) {
|
|
45
|
+
return join(getReferencesDir(name, version), "search.db");
|
|
46
|
+
}
|
|
47
|
+
export { PI_AI_AUTH_PATH as a, SHARED_SKILLS_DIR as c, getSharedSkillsDir as d, lockfilePath as f, skillRefsSection as g, skillLogDir as h, LOCK_FILENAME as i, getPackageDbPath as l, skillInternalFile as m, CONFIG_PATH as n, REFERENCES_DIR as o, skillInternalDir as p, LLM_CACHE_DIR as r, REPOS_DIR as s, CACHE_DIR as t, getRepoCacheDir as u };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=paths.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.mjs","names":[],"sources":["../../src/core/paths.ts"],"sourcesContent":["/**\n * Project layout: every `~/.skilld/...` and `.claude/skills/...` path lives here.\n *\n * Two layers:\n * 1. Global cache under `~/.skilld/` (references, repos, llm-cache, etc.)\n * 2. Per-skill internals: `<skillDir>/.skilld/` holds reference symlinks,\n * logs, and the canonical `_SKILL.md`. The lockfile sits as a sibling\n * of skill dirs as `skilld-lock.yaml`.\n *\n * Per-agent target dirs (`.claude/skills/`, `.cursor/skills/`, ...) are owned\n * by the agent registry (`src/agent/registry.ts`); this module exposes the\n * agent-agnostic `.skills/` shared dir and helpers that compose with target dirs.\n */\n\nimport { existsSync } from 'node:fs'\nimport { homedir } from 'node:os'\nimport { join } from 'pathe'\n\n// ── Project-relative names ──\n\n/** Shared, agent-agnostic skills directory at project root */\nexport const SHARED_SKILLS_DIR = '.skills'\n\n/** Per-skill internals directory (cache symlinks, logs, prompts, _SKILL.md) */\nexport const SKILL_INTERNAL_DIRNAME = '.skilld'\n\n/** Canonical SKILL.md copy inside the per-skill internals dir (frontmatter source of truth) */\nexport const SKILL_INTERNAL_FILENAME = '_SKILL.md'\n\n/** Lockfile sibling of skill directories */\nexport const LOCK_FILENAME = 'skilld-lock.yaml'\n\n/** Config filename inside the global cache */\nexport const CONFIG_FILENAME = 'config.yaml'\n\n// ── Global cache layout (~/.skilld/) ──\n\n/** Root of the global cache */\nexport const CACHE_DIR: string = join(homedir(), '.skilld')\n\n/** References subdirectory: `~/.skilld/references/<pkg>@<version>/` */\nexport const REFERENCES_DIR: string = join(CACHE_DIR, 'references')\n\n/** Repo-level cache (issues, discussions, releases shared across monorepo packages) */\nexport const REPOS_DIR: string = join(CACHE_DIR, 'repos')\n\n/** LLM output cache: `~/.skilld/llm-cache/<sha256>.json` */\nexport const LLM_CACHE_DIR: string = join(CACHE_DIR, 'llm-cache')\n\n/** Global skill installs (skilld install --global) */\nexport const GLOBAL_SKILLS_DIR: string = join(CACHE_DIR, 'skills')\n\n/** Cloned git skills repos */\nexport const GIT_SKILLS_DIR: string = join(CACHE_DIR, 'git-skills')\n\n/** sqlite-vec embedding cache */\nexport const EMBEDDINGS_DB_PATH: string = join(CACHE_DIR, 'embeddings.db')\n\n/** Global config file */\nexport const CONFIG_PATH: string = join(CACHE_DIR, CONFIG_FILENAME)\n\n/** pi-ai auth credentials */\nexport const PI_AI_AUTH_PATH: string = join(CACHE_DIR, 'pi-ai-auth.json')\n\n// ── Helpers ──\n\n/** Returns the shared skills directory path if `.skills/` exists at project root, else null */\nexport function getSharedSkillsDir(cwd: string = process.cwd()): string | null {\n const dir = join(cwd, SHARED_SKILLS_DIR)\n return existsSync(dir) ? dir : null\n}\n\n/** Path to the lockfile inside a skills directory */\nexport function lockfilePath(skillsDir: string): string {\n return join(skillsDir, LOCK_FILENAME)\n}\n\n/** Per-skill internals dir (`<skillDir>/.skilld`) */\nexport function skillInternalDir(skillDir: string): string {\n return join(skillDir, SKILL_INTERNAL_DIRNAME)\n}\n\n/** Per-skill canonical SKILL.md (`<skillDir>/.skilld/_SKILL.md`) */\nexport function skillInternalFile(skillDir: string): string {\n return join(skillDir, SKILL_INTERNAL_DIRNAME, SKILL_INTERNAL_FILENAME)\n}\n\n/** Per-skill log dir (`<skillDir>/.skilld/logs`) */\nexport function skillLogDir(skillDir: string): string {\n return join(skillDir, SKILL_INTERNAL_DIRNAME, 'logs')\n}\n\n/** Per-skill section dir (`<skillDir>/.skilld/<section>`), e.g. issues/discussions/releases/docs */\nexport function skillRefsSection(skillDir: string, section: string): string {\n return join(skillDir, SKILL_INTERNAL_DIRNAME, section)\n}\n\n/** References cache dir for a `name@version` */\nexport function getReferencesDir(name: string, version: string): string {\n return join(REFERENCES_DIR, `${name}@${version}`)\n}\n\n/** Repo cache dir with path-traversal validation */\nexport function getRepoCacheDir(owner: string, repo: string): string {\n if (owner.includes('..') || repo.includes('..') || owner.includes('/') || repo.includes('/'))\n throw new Error(`Invalid repo path: ${owner}/${repo}`)\n return join(REPOS_DIR, owner, repo)\n}\n\n/** search.db path for a `name@version` */\nexport function getPackageDbPath(name: string, version: string): string {\n return join(getReferencesDir(name, version), 'search.db')\n}\n"],"mappings":";;;;;;;;;AAqBA,MAAa,iBAAA,KAAoB,WAAA,aAAA;AAGjC,MAAa,YAAA,KAAA,WAAyB,QAAA;AAGtC,MAAa,gBAAA,KAAA,WAA0B,YAAA;AAGV,KAAA,WAAA,SAAA;AAGhB,KAAkB,WAAA,aAAA;AAKO,KAAS,WAAE,gBAAU;AAG3D,MAAa,cAAA,KAAyB,WAAK,gBAAwB;AAGnE,MAAa,kBAAyB,KAAA,WAAW,kBAAQ;AAGzD,SAAa,mBAA6B,MAAA,QAAW,KAAA,EAAA;;CAGrD,OAAa,WAAA,IAAA,GAA4B,MAAK;;;CAM9C,OAAa,KAAA,WAAA,cAAkC;;;CAM/C,OAAa,KAAA,UAAA,uBAA0C;;SAM/C,kBAAgB,UAAA;CACtB,OAAO,KAAA,UAAe,wBAAS,wBAAA;;AAIjC,SAAgB,YAAA,UAAa;CAC3B,OAAO,KAAK,UAAA,wBAAyB,OAAA;;AAIvC,SAAgB,iBAAiB,UAA0B,SAAA;CACzD,OAAO,KAAK,UAAU,wBAAuB,QAAA;;AAI/C,SAAgB,iBAAA,MAAkB,SAA0B;CAC1D,OAAO,KAAK,gBAAU,GAAA,KAAA,GAAA,UAAwB;;AAIhD,SAAgB,gBAAY,OAA0B,MAAA;CACpD,IAAA,MAAO,SAAK,KAAU,IAAA,KAAA,SAAA,KAAwB,IAAA,MAAO,SAAA,IAAA,IAAA,KAAA,SAAA,IAAA,EAAA,MAAA,IAAA,MAAA,sBAAA,MAAA,GAAA,OAAA;;;SAK9C,iBAAe,MAAA,SAAA;;;SAKf,mBAAK,GAAgB,qBAAqB,GAAA,sBAAA,GAAA,gBAAA,GAAA,oBAAA,GAAA,eAAA,GAAA,iBAAA,GAAA,oBAAA,GAAA,qBAAA,GAAA,eAAA,GAAA,kBAAA,GAAA,oBAAA,GAAA,iBAAA,GAAA,aAAA,GAAA,aAAA,GAAA,mBAAA"}
|
package/dist/_chunks/pool2.mjs
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as SearchDepsUnavailableError } from "./retriv.mjs";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "pathe";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
import { Worker } from "node:worker_threads";
|
|
6
|
+
function reconstructError(message, name) {
|
|
7
|
+
if (name === "SearchDepsUnavailableError") return new SearchDepsUnavailableError(void 0, message);
|
|
8
|
+
return new Error(message);
|
|
9
|
+
}
|
|
5
10
|
let worker = null;
|
|
6
11
|
let taskId = 0;
|
|
7
12
|
const pending = /* @__PURE__ */ new Map();
|
|
@@ -32,7 +37,7 @@ function ensureWorker() {
|
|
|
32
37
|
task.resolve();
|
|
33
38
|
} else if (msg.type === "error") {
|
|
34
39
|
pending.delete(msg.id);
|
|
35
|
-
task.reject(
|
|
40
|
+
task.reject(reconstructError(msg.message, msg.name));
|
|
36
41
|
}
|
|
37
42
|
});
|
|
38
43
|
w.on("error", (err) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool2.mjs","names":[],"sources":["../../src/retriv/pool.ts"],"sourcesContent":["import type { IndexConfig, Document as RetrivDocument } from './types.ts'\nimport type { WorkerMessage, WorkerResponse } from './worker.ts'\nimport { existsSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { Worker } from 'node:worker_threads'\nimport { dirname, join } from 'pathe'\n\ninterface PendingTask {\n id: number\n resolve: () => void\n reject: (err: Error) => void\n onProgress?: IndexConfig['onProgress']\n}\n\nlet worker: Worker | null = null\nlet taskId = 0\nconst pending = new Map<number, PendingTask>()\nconst queue: Array<() => void> = []\nlet running = false\n\nfunction resolveWorkerPath(): { path: string, execArgv?: string[] } {\n const dir = dirname(fileURLToPath(import.meta.url))\n\n // Bundled: dist/retriv/worker.mjs (resolve from package root, not chunk dir)\n for (const candidate of [join(dir, 'worker.mjs'), join(dir, '..', 'retriv', 'worker.mjs')]) {\n if (existsSync(candidate))\n return { path: candidate }\n }\n\n // Dev stub: src/retriv/pool.ts → src/retriv/worker.ts\n return { path: join(dir, 'worker.ts'), execArgv: ['--experimental-strip-types'] }\n}\n\nfunction ensureWorker(): Worker {\n if (worker)\n return worker\n\n const config = resolveWorkerPath()\n const w = new Worker(config.path, {\n execArgv: config.execArgv,\n })\n\n w.on('message', (msg: WorkerResponse) => {\n const task = pending.get(msg.id)\n if (!task)\n return\n\n if (msg.type === 'progress') {\n task.onProgress?.({ phase: msg.phase as any, current: msg.current, total: msg.total })\n }\n else if (msg.type === 'done') {\n pending.delete(msg.id)\n task.resolve()\n }\n else if (msg.type === 'error') {\n pending.delete(msg.id)\n task.reject(
|
|
1
|
+
{"version":3,"file":"pool2.mjs","names":[],"sources":["../../src/retriv/pool.ts"],"sourcesContent":["import type { IndexConfig, Document as RetrivDocument } from './types.ts'\nimport type { WorkerMessage, WorkerResponse } from './worker.ts'\nimport { existsSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { Worker } from 'node:worker_threads'\nimport { dirname, join } from 'pathe'\nimport { SearchDepsUnavailableError } from './index.ts'\n\nfunction reconstructError(message: string, name?: string): Error {\n if (name === 'SearchDepsUnavailableError')\n return new SearchDepsUnavailableError(undefined, message)\n return new Error(message)\n}\n\ninterface PendingTask {\n id: number\n resolve: () => void\n reject: (err: Error) => void\n onProgress?: IndexConfig['onProgress']\n}\n\nlet worker: Worker | null = null\nlet taskId = 0\nconst pending = new Map<number, PendingTask>()\nconst queue: Array<() => void> = []\nlet running = false\n\nfunction resolveWorkerPath(): { path: string, execArgv?: string[] } {\n const dir = dirname(fileURLToPath(import.meta.url))\n\n // Bundled: dist/retriv/worker.mjs (resolve from package root, not chunk dir)\n for (const candidate of [join(dir, 'worker.mjs'), join(dir, '..', 'retriv', 'worker.mjs')]) {\n if (existsSync(candidate))\n return { path: candidate }\n }\n\n // Dev stub: src/retriv/pool.ts → src/retriv/worker.ts\n return { path: join(dir, 'worker.ts'), execArgv: ['--experimental-strip-types'] }\n}\n\nfunction ensureWorker(): Worker {\n if (worker)\n return worker\n\n const config = resolveWorkerPath()\n const w = new Worker(config.path, {\n execArgv: config.execArgv,\n })\n\n w.on('message', (msg: WorkerResponse) => {\n const task = pending.get(msg.id)\n if (!task)\n return\n\n if (msg.type === 'progress') {\n task.onProgress?.({ phase: msg.phase as any, current: msg.current, total: msg.total })\n }\n else if (msg.type === 'done') {\n pending.delete(msg.id)\n task.resolve()\n }\n else if (msg.type === 'error') {\n pending.delete(msg.id)\n task.reject(reconstructError(msg.message, msg.name))\n }\n })\n\n w.on('error', (err: Error) => {\n for (const task of pending.values())\n task.reject(err)\n pending.clear()\n worker = null\n })\n\n w.on('exit', (code) => {\n if (pending.size > 0) {\n const err = new Error(`Worker exited (code ${code}) with ${pending.size} pending tasks`)\n for (const task of pending.values())\n task.reject(err)\n pending.clear()\n }\n worker = null\n })\n\n worker = w\n return w\n}\n\nfunction drainQueue() {\n if (running || queue.length === 0)\n return\n const next = queue.shift()!\n next()\n}\n\nexport async function createIndexInWorker(\n documents: RetrivDocument[],\n config: IndexConfig & { removeIds?: string[] },\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const run = () => {\n running = true\n const id = ++taskId\n\n let w: Worker\n try {\n w = ensureWorker()\n }\n catch (err) {\n running = false\n drainQueue()\n reject(err instanceof Error ? err : new Error(String(err)))\n return\n }\n\n pending.set(id, {\n id,\n resolve: () => {\n running = false\n drainQueue()\n resolve()\n },\n reject: (err) => {\n running = false\n drainQueue()\n reject(err)\n },\n onProgress: config.onProgress,\n })\n\n const msg: WorkerMessage = {\n type: 'index',\n id,\n documents,\n dbPath: config.dbPath,\n removeIds: config.removeIds,\n }\n\n w.postMessage(msg)\n }\n\n if (running) {\n queue.push(run)\n }\n else {\n run()\n }\n })\n}\n\nexport async function shutdownWorker(): Promise<void> {\n if (!worker)\n return\n\n const w = worker\n worker = null\n\n return new Promise<void>((resolve) => {\n const timeout = setTimeout(() => {\n w.terminate().then(() => resolve(), () => resolve())\n }, 5000)\n\n w.once('exit', () => {\n clearTimeout(timeout)\n resolve()\n })\n\n w.postMessage({ type: 'shutdown' } satisfies WorkerMessage)\n })\n}\n"],"mappings":";;;;;AAQA,SAAS,iBAAiB,SAAiB,MAAsB;CAC/D,IAAI,SAAS,8BACX,OAAO,IAAI,2BAA2B,KAAA,GAAW,QAAQ;CAC3D,OAAO,IAAI,MAAM,QAAQ;;AAU3B,IAAI,SAAwB;AAC5B,IAAI,SAAS;AACb,MAAM,0BAAU,IAAI,KAA0B;AAC9C,MAAM,QAA2B,EAAE;AACnC,IAAI,UAAU;AAEd,SAAS,oBAA2D;CAClE,MAAM,MAAM,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;CAGnD,KAAK,MAAM,aAAa,CAAC,KAAK,KAAK,aAAa,EAAE,KAAK,KAAK,MAAM,UAAU,aAAa,CAAC,EACxF,IAAI,WAAW,UAAU,EACvB,OAAO,EAAE,MAAM,WAAW;CAI9B,OAAO;EAAE,MAAM,KAAK,KAAK,YAAY;EAAE,UAAU,CAAC,6BAA6B;EAAE;;AAGnF,SAAS,eAAuB;CAC9B,IAAI,QACF,OAAO;CAET,MAAM,SAAS,mBAAmB;CAClC,MAAM,IAAI,IAAI,OAAO,OAAO,MAAM,EAChC,UAAU,OAAO,UAClB,CAAC;CAEF,EAAE,GAAG,YAAY,QAAwB;EACvC,MAAM,OAAO,QAAQ,IAAI,IAAI,GAAG;EAChC,IAAI,CAAC,MACH;EAEF,IAAI,IAAI,SAAS,YACf,KAA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IACA,QAAQ,OAAO;IACf,WAAW,OAAO;IACnB;GAED,EAAE,YAAY,IAAI;;EAGpB,IAAI,SACF,MAAM,KAAK,IAAI;OAGf,KAAK;GAEP;;AAGJ,eAAsB,iBAAgC;CACpD,IAAI,CAAC,QACH;CAEF,MAAM,IAAI;CACV,SAAS;CAET,OAAO,IAAI,SAAe,YAAY;EACpC,MAAM,UAAU,iBAAiB;GAC/B,EAAE,WAAW,CAAC,WAAW,SAAS,QAAQ,SAAS,CAAC;KACnD,IAAK;EAER,EAAE,KAAK,cAAc;GACnB,aAAa,QAAQ;GACrB,SAAS;IACT;EAEF,EAAE,YAAY,EAAE,MAAM,YAAY,CAAyB;GAC3D"}
|
package/dist/_chunks/prepare.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as getCacheDir } from "./version.mjs";
|
|
2
|
-
import { join } from "pathe";
|
|
3
2
|
import { existsSync, lstatSync, mkdirSync, readdirSync, rmSync, symlinkSync, unlinkSync } from "node:fs";
|
|
3
|
+
import { join } from "pathe";
|
|
4
4
|
function toStorageName(name) {
|
|
5
5
|
if (name.startsWith("crate:")) return `@skilld-crate/${name.slice(6)}`;
|
|
6
6
|
return name;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.mjs","names":[],"sources":["../../src/core/prepare.ts"],"sourcesContent":["/**\n * Shared prepare utilities used by both the fast entry (src/prepare.ts)\n * and the full CLI command (src/commands/prepare.ts).\n *\n * Keep this module lightweight: no imports from agent/, cache/storage.ts,\n * or any module that pulls in sanitize/clack/citty.\n */\n\nimport type { SkillInfo } from './lockfile.ts'\nimport { existsSync, lstatSync, mkdirSync, readdirSync, rmSync, symlinkSync, unlinkSync } from 'node:fs'\nimport { join } from 'pathe'\nimport { getCacheDir } from '../cache/version.ts'\n\n/** Map lockfile identity name to storage-safe cache key (crate:X → @skilld-crate/X) */\nfunction toStorageName(name: string): string {\n if (name.startsWith('crate:'))\n return `@skilld-crate/${name.slice('crate:'.length)}`\n return name\n}\n\n/** Resolve package directory: node_modules first, then global cache */\nexport function resolvePkgDir(name: string, cwd: string, version?: string): string | null {\n const nodeModulesPath = join(cwd, 'node_modules', name)\n if (existsSync(nodeModulesPath))\n return nodeModulesPath\n\n if (version) {\n const cachedPkgDir = join(getCacheDir(name, version), 'pkg')\n if (existsSync(join(cachedPkgDir, 'package.json')))\n return cachedPkgDir\n }\n\n return null\n}\n\n/** Restore .skilld/pkg symlink to node_modules if broken */\nexport function restorePkgSymlink(skillsDir: string, name: string, info: SkillInfo, cwd: string): void {\n const refsDir = join(skillsDir, name, '.skilld')\n const pkgLink = join(refsDir, 'pkg')\n\n if (!existsSync(join(skillsDir, name)))\n return\n\n // Use lstatSync to detect dangling symlinks — existsSync follows symlinks\n // and returns false for dangling ones, causing symlinkSync to throw EEXIST\n try {\n const stat = lstatSync(pkgLink)\n if (stat.isSymbolicLink()) {\n if (existsSync(pkgLink))\n return // symlink exists and target is valid\n unlinkSync(pkgLink) // dangling symlink — remove before re-creating\n }\n else {\n return // real file/dir exists at this path\n }\n }\n catch (err) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT')\n return // permission/IO error — bail instead of masking\n }\n\n const pkgName = toStorageName(info.packageName || name)\n const pkgDir = resolvePkgDir(pkgName, cwd, info.version)\n if (!pkgDir)\n return\n\n mkdirSync(refsDir, { recursive: true })\n symlinkSync(pkgDir, pkgLink)\n}\n\nexport interface ShippedSkill {\n skillName: string\n skillDir: string\n}\n\n/** Check if package ships a skills/ directory with SKILL.md or _SKILL.md subdirs */\nexport function getShippedSkills(name: string, cwd: string, version?: string): ShippedSkill[] {\n const pkgPath = resolvePkgDir(name, cwd, version)\n if (!pkgPath)\n return []\n\n const skillsPath = join(pkgPath, 'skills')\n if (!existsSync(skillsPath))\n return []\n\n return readdirSync(skillsPath, { withFileTypes: true })\n .filter(d => d.isDirectory() && (existsSync(join(skillsPath, d.name, 'SKILL.md')) || existsSync(join(skillsPath, d.name, '_SKILL.md'))))\n .map(d => ({ skillName: d.name, skillDir: join(skillsPath, d.name) }))\n}\n\n/** Create symlink from skills dir to shipped skill dir */\nexport function linkShippedSkill(baseDir: string, skillName: string, targetDir: string): void {\n const linkPath = join(baseDir, skillName)\n if (existsSync(linkPath)) {\n const stat = lstatSync(linkPath)\n if (stat.isSymbolicLink())\n unlinkSync(linkPath)\n else rmSync(linkPath, { recursive: true, force: true })\n }\n symlinkSync(targetDir, linkPath)\n}\n"],"mappings":";;;AAcA,SAAS,cAAc,MAAsB;
|
|
1
|
+
{"version":3,"file":"prepare.mjs","names":[],"sources":["../../src/core/prepare.ts"],"sourcesContent":["/**\n * Shared prepare utilities used by both the fast entry (src/prepare.ts)\n * and the full CLI command (src/commands/prepare.ts).\n *\n * Keep this module lightweight: no imports from agent/, cache/storage.ts,\n * or any module that pulls in sanitize/clack/citty.\n */\n\nimport type { SkillInfo } from './lockfile.ts'\nimport { existsSync, lstatSync, mkdirSync, readdirSync, rmSync, symlinkSync, unlinkSync } from 'node:fs'\nimport { join } from 'pathe'\nimport { getCacheDir } from '../cache/version.ts'\n\n/** Map lockfile identity name to storage-safe cache key (crate:X → @skilld-crate/X) */\nfunction toStorageName(name: string): string {\n if (name.startsWith('crate:'))\n return `@skilld-crate/${name.slice('crate:'.length)}`\n return name\n}\n\n/** Resolve package directory: node_modules first, then global cache */\nexport function resolvePkgDir(name: string, cwd: string, version?: string): string | null {\n const nodeModulesPath = join(cwd, 'node_modules', name)\n if (existsSync(nodeModulesPath))\n return nodeModulesPath\n\n if (version) {\n const cachedPkgDir = join(getCacheDir(name, version), 'pkg')\n if (existsSync(join(cachedPkgDir, 'package.json')))\n return cachedPkgDir\n }\n\n return null\n}\n\n/** Restore .skilld/pkg symlink to node_modules if broken */\nexport function restorePkgSymlink(skillsDir: string, name: string, info: SkillInfo, cwd: string): void {\n const refsDir = join(skillsDir, name, '.skilld')\n const pkgLink = join(refsDir, 'pkg')\n\n if (!existsSync(join(skillsDir, name)))\n return\n\n // Use lstatSync to detect dangling symlinks — existsSync follows symlinks\n // and returns false for dangling ones, causing symlinkSync to throw EEXIST\n try {\n const stat = lstatSync(pkgLink)\n if (stat.isSymbolicLink()) {\n if (existsSync(pkgLink))\n return // symlink exists and target is valid\n unlinkSync(pkgLink) // dangling symlink — remove before re-creating\n }\n else {\n return // real file/dir exists at this path\n }\n }\n catch (err) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT')\n return // permission/IO error — bail instead of masking\n }\n\n const pkgName = toStorageName(info.packageName || name)\n const pkgDir = resolvePkgDir(pkgName, cwd, info.version)\n if (!pkgDir)\n return\n\n mkdirSync(refsDir, { recursive: true })\n symlinkSync(pkgDir, pkgLink)\n}\n\nexport interface ShippedSkill {\n skillName: string\n skillDir: string\n}\n\n/** Check if package ships a skills/ directory with SKILL.md or _SKILL.md subdirs */\nexport function getShippedSkills(name: string, cwd: string, version?: string): ShippedSkill[] {\n const pkgPath = resolvePkgDir(name, cwd, version)\n if (!pkgPath)\n return []\n\n const skillsPath = join(pkgPath, 'skills')\n if (!existsSync(skillsPath))\n return []\n\n return readdirSync(skillsPath, { withFileTypes: true })\n .filter(d => d.isDirectory() && (existsSync(join(skillsPath, d.name, 'SKILL.md')) || existsSync(join(skillsPath, d.name, '_SKILL.md'))))\n .map(d => ({ skillName: d.name, skillDir: join(skillsPath, d.name) }))\n}\n\n/** Create symlink from skills dir to shipped skill dir */\nexport function linkShippedSkill(baseDir: string, skillName: string, targetDir: string): void {\n const linkPath = join(baseDir, skillName)\n if (existsSync(linkPath)) {\n const stat = lstatSync(linkPath)\n if (stat.isSymbolicLink())\n unlinkSync(linkPath)\n else rmSync(linkPath, { recursive: true, force: true })\n }\n symlinkSync(targetDir, linkPath)\n}\n"],"mappings":";;;AAcA,SAAS,cAAc,MAAsB;CAC3C,IAAI,KAAK,WAAW,SAAS,EAC3B,OAAO,iBAAiB,KAAK,MAAM,EAAgB;CACrD,OAAO;;AAIT,SAAgB,cAAc,MAAc,KAAa,SAAiC;CACx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AmB,WAAyB;CAC5F,MAAM,WAAW,KAAK,SAAS,UAAU;CACzC,IAAI,WAAW,SAAS,EAEtB,IADa,UAAU,SACf,CAAC,gBAAgB,EACvB,WAAW,SAAS;MACjB,OAAO,UAAU;EAAE,WAAW;EAAM,OAAO;EAAM,CAAC;CAEzD,YAAY,WAAW,SAAS"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import "./
|
|
1
|
+
import { d as getSharedSkillsDir } from "./paths.mjs";
|
|
2
2
|
import { i as restorePkgSymlink, n as linkShippedSkill, t as getShippedSkills } from "./prepare.mjs";
|
|
3
|
-
import { n as getSharedSkillsDir } from "./shared.mjs";
|
|
4
3
|
import { a as targets } from "./detect.mjs";
|
|
5
|
-
import
|
|
4
|
+
import "./agent.mjs";
|
|
5
|
+
import { o as linkSkillToAgents, v as todayIsoDate } from "./prompts.mjs";
|
|
6
6
|
import { b as resolveAgent } from "./cli-helpers.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { c as readLock, d as writeLock } from "./lockfile.mjs";
|
|
8
8
|
import { t as getProjectState } from "./skills.mjs";
|
|
9
|
-
import { join } from "pathe";
|
|
10
9
|
import { existsSync, mkdirSync } from "node:fs";
|
|
10
|
+
import { join } from "pathe";
|
|
11
11
|
import * as p from "@clack/prompts";
|
|
12
12
|
import { defineCommand } from "citty";
|
|
13
13
|
const prepareCommandDef = defineCommand({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare2.mjs","names":["agents"],"sources":["../../src/commands/prepare.ts"],"sourcesContent":["/**\n * Prepare command — lightweight hook for package.json \"prepare\" script.\n *\n * Designed to run on every `pnpm install` / `npm install`. Blocking, fast, no LLM calls.\n * 1. Restore broken symlinks from lockfile (like `install` but skips doc fetching)\n * 2. Auto-install shipped skills from deps (just symlinks + lockfile writes)\n * 3. Report outdated skills count and suggest `skilld update`\n */\n\nimport { existsSync, mkdirSync } from 'node:fs'\nimport * as p from '@clack/prompts'\nimport { defineCommand } from 'citty'\nimport { join } from 'pathe'\nimport { agents, linkSkillToAgents } from '../agent/index.ts'\nimport { resolveAgent } from '../cli-helpers.ts'\nimport { todayIsoDate } from '../core/formatting.ts'\nimport { readLock, writeLock } from '../core/lockfile.ts'\nimport {
|
|
1
|
+
{"version":3,"file":"prepare2.mjs","names":["agents"],"sources":["../../src/commands/prepare.ts"],"sourcesContent":["/**\n * Prepare command — lightweight hook for package.json \"prepare\" script.\n *\n * Designed to run on every `pnpm install` / `npm install`. Blocking, fast, no LLM calls.\n * 1. Restore broken symlinks from lockfile (like `install` but skips doc fetching)\n * 2. Auto-install shipped skills from deps (just symlinks + lockfile writes)\n * 3. Report outdated skills count and suggest `skilld update`\n */\n\nimport { existsSync, mkdirSync } from 'node:fs'\nimport * as p from '@clack/prompts'\nimport { defineCommand } from 'citty'\nimport { join } from 'pathe'\nimport { agents, linkSkillToAgents } from '../agent/index.ts'\nimport { resolveAgent } from '../cli-helpers.ts'\nimport { todayIsoDate } from '../core/formatting.ts'\nimport { readLock, writeLock } from '../core/lockfile.ts'\nimport { getSharedSkillsDir } from '../core/paths.ts'\nimport { getShippedSkills, linkShippedSkill, restorePkgSymlink } from '../core/prepare.ts'\nimport { getProjectState } from '../core/skills.ts'\n\nexport const prepareCommandDef = defineCommand({\n meta: { name: 'prepare', description: 'Restore references and sync shipped skills (for package.json hooks)' },\n args: {\n agent: {\n type: 'enum' as const,\n options: Object.keys(agents),\n alias: 'a',\n description: 'Target agent',\n },\n },\n async run({ args }) {\n const cwd = process.cwd()\n\n const agent = resolveAgent(args.agent)\n if (!agent || agent === 'none')\n return\n\n const agentConfig = agents[agent]\n const shared = getSharedSkillsDir(cwd)\n const skillsDir = shared || join(cwd, agentConfig.skillsDir)\n\n // ── Fast path: read primary lockfile, check all skills intact ──\n\n const lock = readLock(skillsDir)\n if (lock && Object.keys(lock.skills).length > 0) {\n let allIntact = true\n\n for (const [name, info] of Object.entries(lock.skills)) {\n if (!info.version)\n continue\n\n const skillDir = join(skillsDir, name)\n if (existsSync(skillDir)) {\n // Skill dir exists; for non-shipped, also check .skilld/pkg symlink\n if (info.source !== 'shipped')\n restorePkgSymlink(skillsDir, name, info, cwd)\n continue\n }\n\n // Skill dir missing, needs restore\n allIntact = false\n\n if (info.source === 'shipped') {\n const pkgName = info.packageName || name\n const shipped = getShippedSkills(pkgName, cwd, info.version)\n const match = shipped.find(s => s.skillName === name)\n if (match)\n linkShippedSkill(skillsDir, name, match.skillDir)\n }\n }\n\n // If all skills intact, skip expensive getProjectState entirely\n if (allIntact)\n return\n }\n\n // ── Slow path: discover new shipped skills + report outdated ──\n\n const state = await getProjectState(cwd)\n let shippedCount = 0\n\n if (state.shipped.length > 0) {\n mkdirSync(skillsDir, { recursive: true })\n\n for (const entry of state.shipped) {\n const version = state.deps.get(entry.packageName)?.replace(/^[\\^~>=<]+/, '') || '0.0.0'\n\n for (const skill of entry.skills) {\n linkShippedSkill(skillsDir, skill.skillName, skill.skillDir)\n writeLock(skillsDir, skill.skillName, {\n packageName: entry.packageName,\n version,\n source: 'shipped',\n syncedAt: todayIsoDate(),\n generator: 'skilld',\n })\n\n if (shared)\n linkSkillToAgents(skill.skillName, shared, cwd, agent)\n\n shippedCount++\n }\n }\n\n if (shippedCount > 0)\n p.log.success(`Installed ${shippedCount} shipped skill${shippedCount > 1 ? 's' : ''}`)\n }\n\n if (state.outdated.length > 0) {\n const n = state.outdated.length\n p.log.info(`${n} package${n > 1 ? 's' : ''} ha${n > 1 ? 've' : 's'} new features and/or breaking changes. Run \\`skilld update\\` to sync.`)\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;EAqBA,SAAa,OAAA,KAAA,QAAoB;EAC/B,OAAM;EAAE,aAAM;EAAW,EAAA;OAAoF,IAAA,EAAA,QAAA;EAC7G,MAAM,MACJ,QAAO,KAAA;EACL,MAAM,QAAA,aAAA,KAAA,MAAA;EACN,IAAA,CAAA,SAAS,UAAYA,QAAO;EAC5B,MAAA,cAAO,QAAA;EACP,MAAA,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