skilld 0.3.0 → 0.3.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/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { a as optimizeDocs, b as getAgentVersion, c as computeSkillDirName, d as yamlEscape, f as yamlParseKV, i as getModelName, n as getAvailableModels, o as generateSkillMd, p as yamlUnescape, r as getModelLabel, t as detectImportedPackages, v as detectInstalledAgents, x as targets, y as detectTargetAgent } from "./_chunks/detect-imports.mjs";
|
|
3
3
|
import { i as getCacheDir, o as getVersionKey, r as getPackageDbPath, t as CACHE_DIR } from "./_chunks/config.mjs";
|
|
4
4
|
import { a as getShippedSkills, b as sanitizeMarkdown, c as linkCachedDir, d as linkShippedSkill, g as resolvePkgDir, i as getPkgKeyFiles, l as linkPkg, m as readCachedDocs, n as clearCache, o as hasShippedDocs, p as listReferenceFiles, r as ensureCacheDir, s as isCached, u as linkPkgNamed, v as writeToCache } from "./_chunks/storage.mjs";
|
|
5
5
|
import "./cache/index.mjs";
|
|
@@ -10,7 +10,7 @@ import "./agent/index.mjs";
|
|
|
10
10
|
import { createRequire } from "node:module";
|
|
11
11
|
import { homedir } from "node:os";
|
|
12
12
|
import { join, relative, resolve } from "pathe";
|
|
13
|
-
import { appendFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { appendFileSync, copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
14
14
|
import { execSync } from "node:child_process";
|
|
15
15
|
import pLimit from "p-limit";
|
|
16
16
|
import * as p from "@clack/prompts";
|
|
@@ -1340,7 +1340,7 @@ async function enhanceSkillWithLLM(opts) {
|
|
|
1340
1340
|
async function installCommand(opts) {
|
|
1341
1341
|
const cwd = process.cwd();
|
|
1342
1342
|
const agent = targets[opts.agent];
|
|
1343
|
-
const skillsDir = opts.global ? join(
|
|
1343
|
+
const skillsDir = opts.global ? join(homedir(), ".skilld", "skills") : join(cwd, agent.skillsDir);
|
|
1344
1344
|
const allSkillsDirs = Object.values(targets).map((t) => opts.global ? t.globalSkillsDir : join(cwd, t.skillsDir));
|
|
1345
1345
|
const allLocks = allSkillsDirs.map((dir) => readLock(dir)).filter((l) => !!l && Object.keys(l.skills).length > 0);
|
|
1346
1346
|
if (allLocks.length === 0) {
|
|
@@ -1418,13 +1418,15 @@ async function installCommand(opts) {
|
|
|
1418
1418
|
const cachedSections = join(globalCachePath, "sections");
|
|
1419
1419
|
if (existsSync(sectionsLink)) unlinkSync(sectionsLink);
|
|
1420
1420
|
if (existsSync(cachedSections)) symlinkSync(cachedSections, sectionsLink, "junction");
|
|
1421
|
-
if (
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1421
|
+
if (!copyFromExistingAgent(skillDir, name, allSkillsDirs)) {
|
|
1422
|
+
if (regenerateBaseSkillMd(skillDir, pkgName, version, cwd, allSkillNames, info.source, info.packages)) regenerated.push({
|
|
1423
|
+
name,
|
|
1424
|
+
pkgName,
|
|
1425
|
+
version,
|
|
1426
|
+
skillDir,
|
|
1427
|
+
packages: info.packages
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1428
1430
|
spin.stop(`Linked ${name}`);
|
|
1429
1431
|
continue;
|
|
1430
1432
|
}
|
|
@@ -1564,13 +1566,15 @@ async function installCommand(opts) {
|
|
|
1564
1566
|
type: e.type
|
|
1565
1567
|
}
|
|
1566
1568
|
})), { dbPath: getPackageDbPath(pkgName, version) });
|
|
1567
|
-
if (
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1569
|
+
if (!copyFromExistingAgent(skillDir, name, allSkillsDirs)) {
|
|
1570
|
+
if (regenerateBaseSkillMd(skillDir, pkgName, version, cwd, allSkillNames, info.source, info.packages)) regenerated.push({
|
|
1571
|
+
name,
|
|
1572
|
+
pkgName,
|
|
1573
|
+
version,
|
|
1574
|
+
skillDir,
|
|
1575
|
+
packages: info.packages
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1574
1578
|
spin.stop(`Downloaded and linked ${name}`);
|
|
1575
1579
|
} else spin.stop(`No docs found for ${name}`);
|
|
1576
1580
|
}
|
|
@@ -1587,6 +1591,20 @@ async function installCommand(opts) {
|
|
|
1587
1591
|
await shutdownWorker();
|
|
1588
1592
|
p.outro("Install complete");
|
|
1589
1593
|
}
|
|
1594
|
+
function copyFromExistingAgent(skillDir, name, allSkillsDirs) {
|
|
1595
|
+
const targetMd = join(skillDir, "SKILL.md");
|
|
1596
|
+
if (existsSync(targetMd)) return false;
|
|
1597
|
+
for (const dir of allSkillsDirs) {
|
|
1598
|
+
if (dir === skillDir) continue;
|
|
1599
|
+
const candidateMd = join(dir, name, "SKILL.md");
|
|
1600
|
+
if (existsSync(candidateMd) && !lstatSync(candidateMd).isSymbolicLink()) {
|
|
1601
|
+
mkdirSync(skillDir, { recursive: true });
|
|
1602
|
+
copyFileSync(candidateMd, targetMd);
|
|
1603
|
+
return true;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
return false;
|
|
1607
|
+
}
|
|
1590
1608
|
function unsanitizeName(sanitized, source) {
|
|
1591
1609
|
if (source?.includes("ungh://")) {
|
|
1592
1610
|
const match = source.match(/ungh:\/\/([^/]+)\/(.+)/);
|
|
@@ -2211,8 +2229,7 @@ async function interactiveSearch(packageFilter) {
|
|
|
2211
2229
|
stdin.on("data", onData);
|
|
2212
2230
|
});
|
|
2213
2231
|
}
|
|
2214
|
-
const
|
|
2215
|
-
const { version: skilldVersion } = require$1("../package.json");
|
|
2232
|
+
const version = createRequire(import.meta.url)("../package.json").version;
|
|
2216
2233
|
function countDocs(packageName, version) {
|
|
2217
2234
|
if (!version) return 0;
|
|
2218
2235
|
const cacheDir = getCacheDir(packageName, version);
|
|
@@ -2231,12 +2248,12 @@ function countDocs(packageName, version) {
|
|
|
2231
2248
|
walk(cacheDir);
|
|
2232
2249
|
return count;
|
|
2233
2250
|
}
|
|
2234
|
-
function countEmbeddings(packageName, version) {
|
|
2251
|
+
async function countEmbeddings(packageName, version) {
|
|
2235
2252
|
if (!version) return null;
|
|
2236
2253
|
const dbPath = getPackageDbPath(packageName, version);
|
|
2237
2254
|
if (!existsSync(dbPath)) return null;
|
|
2238
2255
|
try {
|
|
2239
|
-
const { DatabaseSync } =
|
|
2256
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
2240
2257
|
const db = new DatabaseSync(dbPath, {
|
|
2241
2258
|
open: true,
|
|
2242
2259
|
readOnly: true
|
|
@@ -2281,7 +2298,7 @@ function getLastSynced$1() {
|
|
|
2281
2298
|
function buildConfigLines() {
|
|
2282
2299
|
const config = readConfig();
|
|
2283
2300
|
const lines = [];
|
|
2284
|
-
lines.push(`Version v${
|
|
2301
|
+
lines.push(`Version v${version}`);
|
|
2285
2302
|
const lastSynced = getLastSynced$1();
|
|
2286
2303
|
if (lastSynced) lines.push(`Synced ${dim(lastSynced)}`);
|
|
2287
2304
|
lines.push(`Config ${dim(join(CACHE_DIR, "config.yaml"))}${hasConfig() ? "" : dim(" (not created)")}`);
|
|
@@ -2303,7 +2320,7 @@ function buildConfigLines() {
|
|
|
2303
2320
|
if (config.projects?.length) lines.push(`Projects ${config.projects.length} registered`);
|
|
2304
2321
|
return lines;
|
|
2305
2322
|
}
|
|
2306
|
-
function statusCommand(opts = {}) {
|
|
2323
|
+
async function statusCommand(opts = {}) {
|
|
2307
2324
|
const allSkills = [...iterateSkills({ scope: opts.global ? "global" : "all" })];
|
|
2308
2325
|
p.log.step(bold("Skilld Config"));
|
|
2309
2326
|
p.log.message(buildConfigLines().join("\n"));
|
|
@@ -2325,7 +2342,7 @@ function statusCommand(opts = {}) {
|
|
|
2325
2342
|
});
|
|
2326
2343
|
else map.get(key).agents.add(skill.agent);
|
|
2327
2344
|
}
|
|
2328
|
-
const buildPackageLines = (pkgs) => {
|
|
2345
|
+
const buildPackageLines = async (pkgs) => {
|
|
2329
2346
|
const lines = [];
|
|
2330
2347
|
for (const [, pkg] of pkgs) {
|
|
2331
2348
|
const { info } = pkg;
|
|
@@ -2340,7 +2357,7 @@ function statusCommand(opts = {}) {
|
|
|
2340
2357
|
const pkgName = info.packageName || pkg.name;
|
|
2341
2358
|
const docs = countDocs(pkgName, info.version) || countRefDocs(join(pkg.scope === "global" ? targets[pkg.agents.values().next().value].globalSkillsDir : join(process.cwd(), targets[pkg.agents.values().next().value].skillsDir), pkg.name));
|
|
2342
2359
|
if (docs > 0) meta.push(`${docs} docs`);
|
|
2343
|
-
const embeddings = countEmbeddings(pkgName, info.version);
|
|
2360
|
+
const embeddings = await countEmbeddings(pkgName, info.version);
|
|
2344
2361
|
if (embeddings !== null) meta.push(`${embeddings} chunks`);
|
|
2345
2362
|
const ago = timeAgo(info.syncedAt);
|
|
2346
2363
|
if (ago) meta.push(`synced ${ago}`);
|
|
@@ -2354,11 +2371,11 @@ function statusCommand(opts = {}) {
|
|
|
2354
2371
|
};
|
|
2355
2372
|
if (!opts.global && localPkgs.size > 0) {
|
|
2356
2373
|
p.log.step(`${bold("Local")} (project)`);
|
|
2357
|
-
p.log.message(buildPackageLines(localPkgs).join("\n"));
|
|
2374
|
+
p.log.message((await buildPackageLines(localPkgs)).join("\n"));
|
|
2358
2375
|
}
|
|
2359
2376
|
if (globalPkgs.size > 0) {
|
|
2360
2377
|
p.log.step(bold("Global"));
|
|
2361
|
-
p.log.message(buildPackageLines(globalPkgs).join("\n"));
|
|
2378
|
+
p.log.message((await buildPackageLines(globalPkgs)).join("\n"));
|
|
2362
2379
|
}
|
|
2363
2380
|
if (!opts.global && localPkgs.size === 0) {
|
|
2364
2381
|
p.log.step(`${bold("Local")} (project)`);
|
|
@@ -2599,7 +2616,6 @@ async function runWizard() {
|
|
|
2599
2616
|
}
|
|
2600
2617
|
const _emit = process.emit;
|
|
2601
2618
|
process.emit = (event, ...args) => event === "warning" && args[0]?.name === "ExperimentalWarning" && args[0]?.message?.includes("SQLite") ? false : _emit.apply(process, [event, ...args]);
|
|
2602
|
-
const { version } = createRequire(import.meta.url)("../package.json");
|
|
2603
2619
|
function getRepoHint(name, cwd) {
|
|
2604
2620
|
const pkgJsonPath = join(cwd, "node_modules", name, "package.json");
|
|
2605
2621
|
if (!existsSync(pkgJsonPath)) return void 0;
|
|
@@ -3060,6 +3076,7 @@ const searchSubCommand = defineCommand({
|
|
|
3060
3076
|
runMain(defineCommand({
|
|
3061
3077
|
meta: {
|
|
3062
3078
|
name: "skilld",
|
|
3079
|
+
version,
|
|
3063
3080
|
description: "Sync package documentation for agentic use"
|
|
3064
3081
|
},
|
|
3065
3082
|
args: {
|