skilld 2.3.0 → 3.0.0-beta.2
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 +142 -353
- package/bin/skilld.mjs +56 -0
- package/loader/resolve-artifact.mjs +37 -0
- package/package.json +28 -55
- package/dist/_chunks/add.mjs +0 -95
- package/dist/_chunks/add.mjs.map +0 -1
- package/dist/_chunks/agent-prompt.mjs +0 -90
- package/dist/_chunks/agent-prompt.mjs.map +0 -1
- package/dist/_chunks/agent.mjs +0 -1817
- package/dist/_chunks/agent.mjs.map +0 -1
- package/dist/_chunks/args.mjs +0 -49
- package/dist/_chunks/args.mjs.map +0 -1
- package/dist/_chunks/assemble.mjs +0 -126
- package/dist/_chunks/assemble.mjs.map +0 -1
- package/dist/_chunks/author.mjs +0 -432
- package/dist/_chunks/author.mjs.map +0 -1
- package/dist/_chunks/cache.mjs +0 -367
- package/dist/_chunks/cache.mjs.map +0 -1
- package/dist/_chunks/cache2.mjs +0 -151
- package/dist/_chunks/cache2.mjs.map +0 -1
- package/dist/_chunks/changes-digest.mjs +0 -49
- package/dist/_chunks/changes-digest.mjs.map +0 -1
- package/dist/_chunks/changes.mjs +0 -23
- package/dist/_chunks/changes.mjs.map +0 -1
- package/dist/_chunks/client.mjs +0 -182
- package/dist/_chunks/client.mjs.map +0 -1
- package/dist/_chunks/core.mjs +0 -13
- package/dist/_chunks/detect.mjs +0 -614
- package/dist/_chunks/detect.mjs.map +0 -1
- package/dist/_chunks/detect2.mjs +0 -2
- package/dist/_chunks/eject.mjs +0 -69
- package/dist/_chunks/eject.mjs.map +0 -1
- package/dist/_chunks/embedding-cache.mjs +0 -2
- package/dist/_chunks/embedding-cache2.mjs +0 -61
- package/dist/_chunks/embedding-cache2.mjs.map +0 -1
- package/dist/_chunks/env.mjs +0 -19
- package/dist/_chunks/env.mjs.map +0 -1
- package/dist/_chunks/index-identity.mjs +0 -365
- package/dist/_chunks/index-identity.mjs.map +0 -1
- package/dist/_chunks/index-identity2.mjs +0 -2
- package/dist/_chunks/install-many.mjs +0 -542
- package/dist/_chunks/install-many.mjs.map +0 -1
- package/dist/_chunks/install.mjs +0 -259
- package/dist/_chunks/install.mjs.map +0 -1
- package/dist/_chunks/intro.mjs +0 -63
- package/dist/_chunks/intro.mjs.map +0 -1
- package/dist/_chunks/list.mjs +0 -102
- package/dist/_chunks/list.mjs.map +0 -1
- package/dist/_chunks/lockfile.mjs +0 -174
- package/dist/_chunks/lockfile.mjs.map +0 -1
- package/dist/_chunks/login.mjs +0 -247
- package/dist/_chunks/login.mjs.map +0 -1
- package/dist/_chunks/logout.mjs +0 -27
- package/dist/_chunks/logout.mjs.map +0 -1
- package/dist/_chunks/map.mjs +0 -11
- package/dist/_chunks/map.mjs.map +0 -1
- package/dist/_chunks/markdown.mjs +0 -101
- package/dist/_chunks/markdown.mjs.map +0 -1
- package/dist/_chunks/menu.mjs +0 -33
- package/dist/_chunks/menu.mjs.map +0 -1
- package/dist/_chunks/model-picker.mjs +0 -61
- package/dist/_chunks/model-picker.mjs.map +0 -1
- package/dist/_chunks/monorepo.mjs +0 -74
- package/dist/_chunks/monorepo.mjs.map +0 -1
- package/dist/_chunks/package-json.mjs +0 -84
- package/dist/_chunks/package-json.mjs.map +0 -1
- package/dist/_chunks/paths.mjs +0 -47
- package/dist/_chunks/paths.mjs.map +0 -1
- package/dist/_chunks/pipeline.mjs +0 -993
- package/dist/_chunks/pipeline.mjs.map +0 -1
- package/dist/_chunks/pool.mjs +0 -2
- package/dist/_chunks/pool2.mjs +0 -121
- package/dist/_chunks/pool2.mjs.map +0 -1
- package/dist/_chunks/portable.mjs +0 -152
- package/dist/_chunks/portable.mjs.map +0 -1
- package/dist/_chunks/prepare-hook.mjs +0 -2
- package/dist/_chunks/prepare-hook2.mjs +0 -61
- package/dist/_chunks/prepare-hook2.mjs.map +0 -1
- package/dist/_chunks/prepare.mjs +0 -113
- package/dist/_chunks/prepare.mjs.map +0 -1
- package/dist/_chunks/prepare2.mjs +0 -80
- package/dist/_chunks/prepare2.mjs.map +0 -1
- package/dist/_chunks/prompts.mjs +0 -1252
- package/dist/_chunks/prompts.mjs.map +0 -1
- package/dist/_chunks/pull.mjs +0 -190
- package/dist/_chunks/pull.mjs.map +0 -1
- package/dist/_chunks/regex.mjs +0 -19
- package/dist/_chunks/regex.mjs.map +0 -1
- package/dist/_chunks/retriv.mjs +0 -2
- package/dist/_chunks/retriv2.mjs +0 -177
- package/dist/_chunks/retriv2.mjs.map +0 -1
- package/dist/_chunks/sanitize.mjs +0 -260
- package/dist/_chunks/sanitize.mjs.map +0 -1
- package/dist/_chunks/search-helpers.mjs +0 -88
- package/dist/_chunks/search-helpers.mjs.map +0 -1
- package/dist/_chunks/search-interactive.mjs +0 -249
- package/dist/_chunks/search-interactive.mjs.map +0 -1
- package/dist/_chunks/search.mjs +0 -247
- package/dist/_chunks/search.mjs.map +0 -1
- package/dist/_chunks/semver.mjs +0 -2831
- package/dist/_chunks/semver.mjs.map +0 -1
- package/dist/_chunks/skill-installer.mjs +0 -2
- package/dist/_chunks/skill-installer2.mjs +0 -163
- package/dist/_chunks/skill-installer2.mjs.map +0 -1
- package/dist/_chunks/skills.mjs +0 -187
- package/dist/_chunks/skills.mjs.map +0 -1
- package/dist/_chunks/store.mjs +0 -107
- package/dist/_chunks/store.mjs.map +0 -1
- package/dist/_chunks/sync.mjs +0 -1009
- package/dist/_chunks/sync.mjs.map +0 -1
- package/dist/_chunks/sync2.mjs +0 -2
- package/dist/_chunks/telemetry.mjs +0 -26
- package/dist/_chunks/telemetry.mjs.map +0 -1
- package/dist/_chunks/uninstall.mjs +0 -214
- package/dist/_chunks/uninstall.mjs.map +0 -1
- package/dist/_chunks/update.mjs +0 -133
- package/dist/_chunks/update.mjs.map +0 -1
- package/dist/_chunks/upload.mjs +0 -155
- package/dist/_chunks/upload.mjs.map +0 -1
- package/dist/_chunks/validate.mjs +0 -60
- package/dist/_chunks/validate.mjs.map +0 -1
- package/dist/_chunks/version.mjs +0 -19
- package/dist/_chunks/version.mjs.map +0 -1
- package/dist/_chunks/watch.mjs +0 -2
- package/dist/_chunks/watch2.mjs +0 -118
- package/dist/_chunks/watch2.mjs.map +0 -1
- package/dist/_chunks/whoami.mjs +0 -21
- package/dist/_chunks/whoami.mjs.map +0 -1
- package/dist/_chunks/wizard.mjs +0 -2
- package/dist/_chunks/wizard2.mjs +0 -200
- package/dist/_chunks/wizard2.mjs.map +0 -1
- package/dist/_chunks/yaml.mjs +0 -33
- package/dist/_chunks/yaml.mjs.map +0 -1
- package/dist/cli-entry.d.mts +0 -1
- package/dist/cli-entry.mjs +0 -5
- package/dist/cli-entry.mjs.map +0 -1
- package/dist/cli.d.mts +0 -1
- package/dist/cli.mjs +0 -1330
- package/dist/cli.mjs.map +0 -1
- package/dist/prepare.d.mts +0 -1
- package/dist/prepare.mjs +0 -84
- package/dist/prepare.mjs.map +0 -1
- package/dist/retriv/worker.d.mts +0 -37
- package/dist/retriv/worker.d.mts.map +0 -1
- package/dist/retriv/worker.mjs +0 -46
- package/dist/retriv/worker.mjs.map +0 -1
package/dist/_chunks/prepare.mjs
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { REFERENCES_DIR } from "./paths.mjs";
|
|
2
|
-
import { README_FILENAME_RE } from "./regex.mjs";
|
|
3
|
-
import { readPackageJsonSafe } from "./package-json.mjs";
|
|
4
|
-
import { existsSync, lstatSync, mkdirSync, readdirSync, rmSync, symlinkSync, unlinkSync } from "node:fs";
|
|
5
|
-
import { basename, join, resolve } from "pathe";
|
|
6
|
-
const VALID_PKG_NAME = /^(?:@[a-z0-9][-a-z0-9._]*\/)?[a-z0-9][-a-z0-9._]*$/;
|
|
7
|
-
const VALID_VERSION = /^[a-z0-9][-\w.+]*$/i;
|
|
8
|
-
function isValidCachePackageName(name) {
|
|
9
|
-
return VALID_PKG_NAME.test(name);
|
|
10
|
-
}
|
|
11
|
-
function isValidCacheVersion(version) {
|
|
12
|
-
return VALID_VERSION.test(version);
|
|
13
|
-
}
|
|
14
|
-
function getVersionKey(version) {
|
|
15
|
-
return version;
|
|
16
|
-
}
|
|
17
|
-
function getCacheKey(name, version) {
|
|
18
|
-
return `${name}@${getVersionKey(version)}`;
|
|
19
|
-
}
|
|
20
|
-
function getCacheDir(name, version) {
|
|
21
|
-
if (!isValidCachePackageName(name)) throw new Error(`Invalid package name: ${name}`);
|
|
22
|
-
if (!isValidCacheVersion(version)) throw new Error(`Invalid version: ${version}`);
|
|
23
|
-
const dir = resolve(REFERENCES_DIR, getCacheKey(name, version));
|
|
24
|
-
if (!dir.startsWith(REFERENCES_DIR)) throw new Error(`Path traversal detected: ${dir}`);
|
|
25
|
-
return dir;
|
|
26
|
-
}
|
|
27
|
-
const STATIC_REGEX_2 = /^changelog\.md$/i;
|
|
28
|
-
function toStorageName(name) {
|
|
29
|
-
if (name.startsWith("crate:")) return `@skilld-crate/${name.slice(6)}`;
|
|
30
|
-
return name;
|
|
31
|
-
}
|
|
32
|
-
function resolvePkgDir(name, cwd, version) {
|
|
33
|
-
if (!isValidCachePackageName(name)) return null;
|
|
34
|
-
const nodeModulesPath = join(cwd, "node_modules", name);
|
|
35
|
-
if (existsSync(nodeModulesPath)) return nodeModulesPath;
|
|
36
|
-
if (version) {
|
|
37
|
-
if (!isValidCacheVersion(version)) return null;
|
|
38
|
-
const cachedPkgDir = join(getCacheDir(name, version), "pkg");
|
|
39
|
-
if (existsSync(join(cachedPkgDir, "package.json"))) return cachedPkgDir;
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
function restorePkgSymlink(skillsDir, name, info, cwd) {
|
|
44
|
-
const refsDir = join(skillsDir, name, ".skilld");
|
|
45
|
-
const pkgLink = join(refsDir, "pkg");
|
|
46
|
-
if (!existsSync(join(skillsDir, name))) return;
|
|
47
|
-
try {
|
|
48
|
-
if (lstatSync(pkgLink).isSymbolicLink()) {
|
|
49
|
-
if (existsSync(pkgLink)) return;
|
|
50
|
-
unlinkSync(pkgLink);
|
|
51
|
-
} else return;
|
|
52
|
-
} catch (err) {
|
|
53
|
-
if (err.code !== "ENOENT") return;
|
|
54
|
-
}
|
|
55
|
-
const pkgDir = resolvePkgDir(toStorageName(info.packageName || name), cwd, info.version);
|
|
56
|
-
if (!pkgDir) return;
|
|
57
|
-
mkdirSync(refsDir, { recursive: true });
|
|
58
|
-
symlinkSync(pkgDir, pkgLink);
|
|
59
|
-
}
|
|
60
|
-
function getShippedSkills(name, cwd, version) {
|
|
61
|
-
const pkgPath = resolvePkgDir(name, cwd, version);
|
|
62
|
-
if (!pkgPath) return [];
|
|
63
|
-
const skillsPath = join(pkgPath, "skills");
|
|
64
|
-
if (!existsSync(skillsPath)) return [];
|
|
65
|
-
return readdirSync(skillsPath, { withFileTypes: true }).filter((d) => d.isDirectory() && (existsSync(join(skillsPath, d.name, "SKILL.md")) || existsSync(join(skillsPath, d.name, "_SKILL.md")))).map((d) => ({
|
|
66
|
-
skillName: d.name,
|
|
67
|
-
skillDir: join(skillsPath, d.name)
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
function linkShippedSkill(baseDir, skillName, targetDir) {
|
|
71
|
-
const linkPath = join(baseDir, skillName);
|
|
72
|
-
if (existsSync(linkPath)) {
|
|
73
|
-
if (lstatSync(linkPath).isSymbolicLink()) unlinkSync(linkPath);
|
|
74
|
-
else rmSync(linkPath, {
|
|
75
|
-
recursive: true,
|
|
76
|
-
force: true
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
symlinkSync(targetDir, linkPath);
|
|
80
|
-
}
|
|
81
|
-
function hasShippedDocs(name, cwd, version) {
|
|
82
|
-
const pkgPath = resolvePkgDir(name, cwd, version);
|
|
83
|
-
if (!pkgPath) return false;
|
|
84
|
-
for (const candidate of [
|
|
85
|
-
"docs",
|
|
86
|
-
"documentation",
|
|
87
|
-
"doc"
|
|
88
|
-
]) {
|
|
89
|
-
const docsPath = join(pkgPath, candidate);
|
|
90
|
-
if (existsSync(docsPath)) return true;
|
|
91
|
-
}
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
function getPkgKeyFiles(name, cwd, version) {
|
|
95
|
-
const pkgPath = resolvePkgDir(name, cwd, version);
|
|
96
|
-
if (!pkgPath) return [];
|
|
97
|
-
const files = [];
|
|
98
|
-
const pkgJsonPath = join(pkgPath, "package.json");
|
|
99
|
-
const pkgJsonResult = readPackageJsonSafe(pkgJsonPath);
|
|
100
|
-
if (pkgJsonResult) {
|
|
101
|
-
const pkg = pkgJsonResult.parsed;
|
|
102
|
-
if (pkg.main) files.push(basename(pkg.main));
|
|
103
|
-
if (pkg.module && pkg.module !== pkg.main) files.push(basename(pkg.module));
|
|
104
|
-
const typesPath = pkg.types || pkg.typings;
|
|
105
|
-
if (typesPath && existsSync(join(pkgPath, typesPath))) files.push(typesPath);
|
|
106
|
-
}
|
|
107
|
-
const entries = readdirSync(pkgPath).filter((f) => README_FILENAME_RE.test(f) || STATIC_REGEX_2.test(f));
|
|
108
|
-
files.push(...entries);
|
|
109
|
-
return [...new Set(files)];
|
|
110
|
-
}
|
|
111
|
-
export { getCacheDir, getPkgKeyFiles, getShippedSkills, getVersionKey, hasShippedDocs, linkShippedSkill, resolvePkgDir, restorePkgSymlink };
|
|
112
|
-
|
|
113
|
-
//# sourceMappingURL=prepare.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.mjs","names":[],"sources":["../../src/cache/internal/version.ts","../../src/core/prepare.ts"],"sourcesContent":["/**\n * Version utilities\n */\n\nimport { resolve } from 'pathe'\nimport { REFERENCES_DIR } from '../../core/paths.ts'\n\n/** Validate npm package name (scoped or unscoped) */\nconst VALID_PKG_NAME = /^(?:@[a-z0-9][-a-z0-9._]*\\/)?[a-z0-9][-a-z0-9._]*$/\n\n/** Validate version string (semver-ish, no path separators) */\nconst VALID_VERSION = /^[a-z0-9][-\\w.+]*$/i\n\nexport function isValidCachePackageName(name: string): boolean {\n return VALID_PKG_NAME.test(name)\n}\n\nexport function isValidCacheVersion(version: string): boolean {\n return VALID_VERSION.test(version)\n}\n\n/**\n * Get exact version key for cache keying\n */\nexport function getVersionKey(version: string): string {\n return version\n}\n\n/**\n * Get cache key for a package: name@version\n */\nexport function getCacheKey(name: string, version: string): string {\n return `${name}@${getVersionKey(version)}`\n}\n\n/**\n * Get path to cached package references.\n * Validates name/version to prevent path traversal.\n */\nexport function getCacheDir(name: string, version: string): string {\n if (!isValidCachePackageName(name))\n throw new Error(`Invalid package name: ${name}`)\n if (!isValidCacheVersion(version))\n throw new Error(`Invalid version: ${version}`)\n\n const dir = resolve(REFERENCES_DIR, getCacheKey(name, version))\n if (!dir.startsWith(REFERENCES_DIR))\n throw new Error(`Path traversal detected: ${dir}`)\n return dir\n}\n","/**\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 { basename, join } from 'pathe'\nimport { getCacheDir, isValidCachePackageName, isValidCacheVersion } from '../cache/internal/version.ts'\nimport { readPackageJsonSafe } from './package-json.ts'\nimport { README_FILENAME_RE } from './regex.ts'\n\nconst STATIC_REGEX_2 = /^changelog\\.md$/i\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 if (!isValidCachePackageName(name))\n return null\n\n const nodeModulesPath = join(cwd, 'node_modules', name)\n if (existsSync(nodeModulesPath))\n return nodeModulesPath\n\n if (version) {\n if (!isValidCacheVersion(version))\n return null\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\n/** Check if a package ships a docs/, documentation/, or doc/ directory */\nexport function hasShippedDocs(name: string, cwd: string, version?: string): boolean {\n const pkgPath = resolvePkgDir(name, cwd, version)\n if (!pkgPath)\n return false\n\n const docsCandidates = ['docs', 'documentation', 'doc']\n for (const candidate of docsCandidates) {\n const docsPath = join(pkgPath, candidate)\n if (existsSync(docsPath))\n return true\n }\n return false\n}\n\n/**\n * Get key files from a package directory for display.\n * Returns entry points + docs files.\n */\nexport function getPkgKeyFiles(name: string, cwd: string, version?: string): string[] {\n const pkgPath = resolvePkgDir(name, cwd, version)\n if (!pkgPath)\n return []\n\n const files: string[] = []\n const pkgJsonPath = join(pkgPath, 'package.json')\n\n const pkgJsonResult = readPackageJsonSafe(pkgJsonPath)\n if (pkgJsonResult) {\n const pkg = pkgJsonResult.parsed as Record<string, any>\n\n if (pkg.main)\n files.push(basename(pkg.main))\n if (pkg.module && pkg.module !== pkg.main)\n files.push(basename(pkg.module))\n\n const typesPath = pkg.types || pkg.typings\n if (typesPath && existsSync(join(pkgPath, typesPath)))\n files.push(typesPath)\n }\n\n const entries = readdirSync(pkgPath).filter(f =>\n README_FILENAME_RE.test(f) || STATIC_REGEX_2.test(f),\n )\n files.push(...entries)\n\n return [...new Set(files)]\n}\n"],"mappings":";;;;;;AAQA,MAAM,gBAAA;;CAGN,OAAM,eAAgB,KAAA,IAAA;AAEtB;AACE,SAAO,oBAAoB,SAAI;CACjC,OAAA,cAAA,KAAA,OAAA;AAEA;AAEA,SAAA,cAAA,SAAA;;;AAKA,SAAgB,YAAA,MAAc,SAAyB;CACrD,OAAO,GAAA,KAAA,GAAA,cAAA,OAAA;AACT;;;CAKA,IAAA,CAAA,oBAA4B,OAAc,GAAyB,MAAA,IAAA,MAAA,oBAAA,SAAA;CACjE,MAAA,MAAU,QAAQ,gBAAc,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
-
import { targets } from "./detect.mjs";
|
|
2
|
-
import "./agent.mjs";
|
|
3
|
-
import { linkSkillToAgents, todayIsoDate } from "./prompts.mjs";
|
|
4
|
-
import { getSharedSkillsDir } from "./paths.mjs";
|
|
5
|
-
import { VERSION_RANGE_PREFIX_RE } from "./regex.mjs";
|
|
6
|
-
import { getShippedSkills, linkShippedSkill, restorePkgSymlink } from "./prepare.mjs";
|
|
7
|
-
import { resolveAgent } from "./agent-prompt.mjs";
|
|
8
|
-
import { readLock, writeLock } from "./lockfile.mjs";
|
|
9
|
-
import { getProjectState } from "./skills.mjs";
|
|
10
|
-
import { existsSync, mkdirSync } from "node:fs";
|
|
11
|
-
import * as p from "@clack/prompts";
|
|
12
|
-
import { defineCommand } from "citty";
|
|
13
|
-
import { join } from "pathe";
|
|
14
|
-
const prepareCommandDef = defineCommand({
|
|
15
|
-
meta: {
|
|
16
|
-
name: "prepare",
|
|
17
|
-
description: "Restore references and sync shipped skills (for package.json hooks)"
|
|
18
|
-
},
|
|
19
|
-
args: { agent: {
|
|
20
|
-
type: "enum",
|
|
21
|
-
options: Object.keys(targets),
|
|
22
|
-
alias: "a",
|
|
23
|
-
description: "Target agent"
|
|
24
|
-
} },
|
|
25
|
-
async run({ args }) {
|
|
26
|
-
const cwd = process.cwd();
|
|
27
|
-
const agent = resolveAgent(args.agent);
|
|
28
|
-
if (!agent || agent === "none") return;
|
|
29
|
-
const agentConfig = targets[agent];
|
|
30
|
-
const shared = getSharedSkillsDir(cwd);
|
|
31
|
-
const skillsDir = shared || join(cwd, agentConfig.skillsDir);
|
|
32
|
-
const lock = readLock(skillsDir);
|
|
33
|
-
if (lock && Object.keys(lock.skills).length > 0) {
|
|
34
|
-
let allIntact = true;
|
|
35
|
-
for (const [name, info] of Object.entries(lock.skills)) {
|
|
36
|
-
if (!info.version) continue;
|
|
37
|
-
const skillDir = join(skillsDir, name);
|
|
38
|
-
if (existsSync(skillDir)) {
|
|
39
|
-
if (info.source !== "shipped") restorePkgSymlink(skillsDir, name, info, cwd);
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
allIntact = false;
|
|
43
|
-
if (info.source === "shipped") {
|
|
44
|
-
const pkgName = info.packageName || name;
|
|
45
|
-
const match = getShippedSkills(pkgName, cwd, info.version).find((s) => s.skillName === name);
|
|
46
|
-
if (match) linkShippedSkill(skillsDir, name, match.skillDir);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (allIntact) return;
|
|
50
|
-
}
|
|
51
|
-
const state = await getProjectState(cwd);
|
|
52
|
-
let shippedCount = 0;
|
|
53
|
-
if (state.shipped.length > 0) {
|
|
54
|
-
mkdirSync(skillsDir, { recursive: true });
|
|
55
|
-
for (const entry of state.shipped) {
|
|
56
|
-
const version = state.deps.get(entry.packageName)?.replace(VERSION_RANGE_PREFIX_RE, "") || "0.0.0";
|
|
57
|
-
for (const skill of entry.skills) {
|
|
58
|
-
linkShippedSkill(skillsDir, skill.skillName, skill.skillDir);
|
|
59
|
-
writeLock(skillsDir, skill.skillName, {
|
|
60
|
-
packageName: entry.packageName,
|
|
61
|
-
version,
|
|
62
|
-
source: "shipped",
|
|
63
|
-
syncedAt: todayIsoDate(),
|
|
64
|
-
generator: "skilld"
|
|
65
|
-
});
|
|
66
|
-
if (shared) linkSkillToAgents(skill.skillName, shared, cwd, agent);
|
|
67
|
-
shippedCount++;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (shippedCount > 0) p.log.success(`Installed ${shippedCount} shipped skill${shippedCount > 1 ? "s" : ""}`);
|
|
71
|
-
}
|
|
72
|
-
if (state.outdated.length > 0) {
|
|
73
|
-
const n = state.outdated.length;
|
|
74
|
-
p.log.info(`${n} package${n > 1 ? "s" : ""} ha${n > 1 ? "ve" : "s"} new features and/or breaking changes. Run \`skilld update\` to sync.`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
export { prepareCommandDef };
|
|
79
|
-
|
|
80
|
-
//# sourceMappingURL=prepare2.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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/agent-prompt.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 { VERSION_RANGE_PREFIX_RE } from '../core/regex.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(VERSION_RANGE_PREFIX_RE, '') || '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":";;;;;;;;;;;;;;;;;;;;EAsBA,SAAa,OAAA,KAAA,OAAoB;EAC/B,OAAM;EAAE,aAAM;CAAW,EAAA;CAAmF,MAAA,IAAA,EAAA,QAAA;EAC5G,MAAM,MACJ,QAAO,IAAA;EACL,MAAM,QAAA,aAAA,KAAA,KAAA;EACN,IAAA,CAAA,SAAS,UAAYA,QAAM;EAC3B,MAAA,cAAO,QAAA;EACP,MAAA,SAAa,mBAAA,GAAA;EACf,MACF,YAAA,UAAA,KAAA,KAAA,Y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