skilld 1.7.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/dist/_chunks/add.mjs +67 -0
- package/dist/_chunks/add.mjs.map +1 -0
- package/dist/_chunks/agent-prompt.mjs +88 -0
- package/dist/_chunks/agent-prompt.mjs.map +1 -0
- package/dist/_chunks/agent.mjs +359 -157
- package/dist/_chunks/agent.mjs.map +1 -1
- package/dist/_chunks/args.mjs +42 -0
- package/dist/_chunks/args.mjs.map +1 -0
- package/dist/_chunks/assemble.mjs +12 -9
- package/dist/_chunks/assemble.mjs.map +1 -1
- package/dist/_chunks/author.mjs +35 -19
- package/dist/_chunks/author.mjs.map +1 -1
- package/dist/_chunks/cache.mjs +153 -185
- package/dist/_chunks/cache.mjs.map +1 -1
- package/dist/_chunks/cache2.mjs +9 -8
- package/dist/_chunks/cache2.mjs.map +1 -1
- package/dist/_chunks/client.mjs +118 -0
- package/dist/_chunks/client.mjs.map +1 -0
- package/dist/_chunks/core.mjs +5 -5
- package/dist/_chunks/detect.mjs +54 -44
- package/dist/_chunks/detect.mjs.map +1 -1
- package/dist/_chunks/detect2.mjs +1 -1
- package/dist/_chunks/eject.mjs +69 -0
- package/dist/_chunks/eject.mjs.map +1 -0
- package/dist/_chunks/embedding-cache.mjs +1 -1
- package/dist/_chunks/embedding-cache2.mjs +2 -2
- package/dist/_chunks/embedding-cache2.mjs.map +1 -1
- package/dist/_chunks/env.mjs +19 -0
- package/dist/_chunks/env.mjs.map +1 -0
- package/dist/_chunks/install-many.mjs +377 -0
- package/dist/_chunks/install-many.mjs.map +1 -0
- package/dist/_chunks/install.mjs +93 -334
- package/dist/_chunks/install.mjs.map +1 -1
- package/dist/_chunks/intro.mjs +63 -0
- package/dist/_chunks/intro.mjs.map +1 -0
- package/dist/_chunks/list.mjs +5 -4
- package/dist/_chunks/list.mjs.map +1 -1
- package/dist/_chunks/lockfile.mjs +10 -7
- package/dist/_chunks/lockfile.mjs.map +1 -1
- package/dist/_chunks/login.mjs +234 -0
- package/dist/_chunks/login.mjs.map +1 -0
- package/dist/_chunks/logout.mjs +27 -0
- package/dist/_chunks/logout.mjs.map +1 -0
- package/dist/_chunks/map.mjs +11 -0
- package/dist/_chunks/map.mjs.map +1 -0
- package/dist/_chunks/markdown.mjs +81 -56
- package/dist/_chunks/markdown.mjs.map +1 -1
- package/dist/_chunks/menu.mjs +33 -0
- package/dist/_chunks/menu.mjs.map +1 -0
- package/dist/_chunks/model-picker.mjs +61 -0
- package/dist/_chunks/model-picker.mjs.map +1 -0
- package/dist/_chunks/monorepo.mjs +7 -4
- package/dist/_chunks/monorepo.mjs.map +1 -1
- package/dist/_chunks/package-json.mjs +7 -5
- package/dist/_chunks/package-json.mjs.map +1 -1
- package/dist/_chunks/paths.mjs +3 -5
- package/dist/_chunks/paths.mjs.map +1 -1
- package/dist/_chunks/{sync-pipeline.mjs → pipeline.mjs} +360 -323
- package/dist/_chunks/pipeline.mjs.map +1 -0
- package/dist/_chunks/pool.mjs +1 -1
- package/dist/_chunks/pool2.mjs +2 -2
- package/dist/_chunks/pool2.mjs.map +1 -1
- package/dist/_chunks/portable.mjs +151 -0
- package/dist/_chunks/portable.mjs.map +1 -0
- package/dist/_chunks/prepare-hook.mjs +2 -0
- package/dist/_chunks/prepare-hook2.mjs +61 -0
- package/dist/_chunks/prepare-hook2.mjs.map +1 -0
- package/dist/_chunks/prepare.mjs +58 -8
- package/dist/_chunks/prepare.mjs.map +1 -1
- package/dist/_chunks/prepare2.mjs +14 -11
- package/dist/_chunks/prepare2.mjs.map +1 -1
- package/dist/_chunks/prompts.mjs +488 -76
- package/dist/_chunks/prompts.mjs.map +1 -1
- package/dist/_chunks/pull.mjs +220 -0
- package/dist/_chunks/pull.mjs.map +1 -0
- package/dist/_chunks/regex.mjs +19 -0
- package/dist/_chunks/regex.mjs.map +1 -0
- package/dist/_chunks/retriv.mjs +2 -171
- package/dist/_chunks/retriv2.mjs +159 -0
- package/dist/_chunks/retriv2.mjs.map +1 -0
- package/dist/_chunks/sanitize.mjs +13 -10
- package/dist/_chunks/sanitize.mjs.map +1 -1
- package/dist/_chunks/search-helpers.mjs +11 -9
- package/dist/_chunks/search-helpers.mjs.map +1 -1
- package/dist/_chunks/search-interactive.mjs +25 -22
- package/dist/_chunks/search-interactive.mjs.map +1 -1
- package/dist/_chunks/search.mjs +6 -6
- package/dist/_chunks/search.mjs.map +1 -1
- package/dist/_chunks/semver.mjs +2793 -5
- package/dist/_chunks/semver.mjs.map +1 -1
- package/dist/_chunks/skill-installer.mjs +1 -1
- package/dist/_chunks/skill-installer2.mjs +31 -23
- package/dist/_chunks/skill-installer2.mjs.map +1 -1
- package/dist/_chunks/skills.mjs +9 -10
- package/dist/_chunks/skills.mjs.map +1 -1
- package/dist/_chunks/store.mjs +107 -0
- package/dist/_chunks/store.mjs.map +1 -0
- package/dist/_chunks/sync.mjs +422 -915
- package/dist/_chunks/sync.mjs.map +1 -1
- package/dist/_chunks/sync2.mjs +2 -5
- package/dist/_chunks/telemetry.mjs +26 -0
- package/dist/_chunks/telemetry.mjs.map +1 -0
- package/dist/_chunks/uninstall.mjs +38 -32
- package/dist/_chunks/uninstall.mjs.map +1 -1
- package/dist/_chunks/update.mjs +172 -0
- package/dist/_chunks/update.mjs.map +1 -0
- package/dist/_chunks/upload.mjs +16 -13
- 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 +16 -17
- package/dist/_chunks/version.mjs.map +1 -1
- package/dist/_chunks/whoami.mjs +21 -0
- package/dist/_chunks/whoami.mjs.map +1 -0
- package/dist/_chunks/wizard.mjs +2 -190
- package/dist/_chunks/wizard2.mjs +200 -0
- package/dist/_chunks/wizard2.mjs.map +1 -0
- package/dist/_chunks/yaml.mjs +1 -1
- package/dist/_chunks/yaml.mjs.map +1 -1
- package/dist/cli-entry.d.mts +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +94 -71
- package/dist/cli.mjs.map +1 -1
- package/dist/prepare.d.mts +1 -1
- package/dist/prepare.mjs +9 -6
- package/dist/prepare.mjs.map +1 -1
- package/dist/retriv/worker.d.mts +5 -1
- package/dist/retriv/worker.d.mts.map +1 -1
- package/dist/retriv/worker.mjs +1 -1
- package/dist/retriv/worker.mjs.map +1 -1
- package/package.json +27 -37
- package/dist/_chunks/author-group.mjs +0 -17
- package/dist/_chunks/author-group.mjs.map +0 -1
- package/dist/_chunks/cli-helpers.mjs +0 -335
- package/dist/_chunks/cli-helpers.mjs.map +0 -1
- package/dist/_chunks/cli-helpers2.mjs +0 -2
- package/dist/_chunks/index.d.mts +0 -344
- package/dist/_chunks/index.d.mts.map +0 -1
- package/dist/_chunks/index2.d.mts +0 -279
- package/dist/_chunks/index2.d.mts.map +0 -1
- package/dist/_chunks/index3.d.mts +0 -44
- package/dist/_chunks/index3.d.mts.map +0 -1
- package/dist/_chunks/index4.d.mts +0 -553
- package/dist/_chunks/index4.d.mts.map +0 -1
- package/dist/_chunks/package-registry.mjs +0 -465
- package/dist/_chunks/package-registry.mjs.map +0 -1
- package/dist/_chunks/retriv.mjs.map +0 -1
- package/dist/_chunks/setup.mjs +0 -17
- package/dist/_chunks/setup.mjs.map +0 -1
- package/dist/_chunks/sources.mjs +0 -2654
- package/dist/_chunks/sources.mjs.map +0 -1
- package/dist/_chunks/sync-pipeline.mjs.map +0 -1
- package/dist/_chunks/sync-registry.mjs +0 -65
- package/dist/_chunks/sync-registry.mjs.map +0 -1
- package/dist/_chunks/types.d.mts +0 -76
- package/dist/_chunks/types.d.mts.map +0 -1
- package/dist/_chunks/types2.d.mts +0 -88
- package/dist/_chunks/types2.d.mts.map +0 -1
- package/dist/_chunks/wizard.mjs.map +0 -1
- package/dist/agent/index.d.mts +0 -2
- package/dist/agent/index.mjs +0 -4
- package/dist/cache/index.d.mts +0 -2
- package/dist/cache/index.mjs +0 -5
- package/dist/index.d.mts +0 -6
- package/dist/index.mjs +0 -6
- package/dist/retriv/index.d.mts +0 -3
- package/dist/retriv/index.mjs +0 -2
- package/dist/sources/index.d.mts +0 -3
- package/dist/sources/index.mjs +0 -3
- package/dist/types.d.mts +0 -4
- package/dist/types.mjs +0 -1
package/dist/_chunks/sync.mjs
CHANGED
|
@@ -1,42 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { a as ensureProjectFiles, c as linkShippedToAgents, i as ensureGitignore, l as resolveBaseDir, o as handleShippedSkills, s as installSkill } from "./skill-installer2.mjs";
|
|
16
|
-
import { a as prepareSkillReferences, c as resolveAutoModel, d as applyCachedSections, h as writePromptFiles, i as findRelatedSkills, l as selectLlmConfig, m as writeBaseSkill, p as runSkillEnhancement, r as fetchAndCacheResources, s as DEFAULT_SECTIONS, t as buildSkillContext } from "./sync-pipeline.mjs";
|
|
17
|
-
import { n as shutdownWorker } from "./pool2.mjs";
|
|
18
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
19
|
-
import { dirname, join, relative, resolve } from "pathe";
|
|
20
|
-
import pLimit from "p-limit";
|
|
1
|
+
import { detectImportedPackages, getModelLabel } from "./agent.mjs";
|
|
2
|
+
import { computeSkillDirName, formatDuration, linkSkillToAgents, sanitizeName, timedSpinner, todayIsoDate, writeGeneratedSkillMd } from "./prompts.mjs";
|
|
3
|
+
import { getSharedSkillsDir, skillRefsSection } from "./paths.mjs";
|
|
4
|
+
import { getVersionKey } from "./prepare.mjs";
|
|
5
|
+
import { createReferenceCache, ensureCacheDir, getActiveFeatures, readConfig } from "./cache.mjs";
|
|
6
|
+
import { suggestPrepareHook } from "./prepare-hook2.mjs";
|
|
7
|
+
import { fetchPkgDist, isCrateSpec, isPrerelease, parseGitHubRepoSlug, parsePackageSpec, resolveGitHubRepo, resolvePackageOrCrate, searchNpmPackages, semverDiff, toStoragePackageName } from "./semver.mjs";
|
|
8
|
+
import { parseFrontmatter } from "./markdown.mjs";
|
|
9
|
+
import { findSkillDirByPackage, parsePackageNames, readLock } from "./lockfile.mjs";
|
|
10
|
+
import { ensureProjectFiles, handleShippedSkills, installSkill, linkShippedToAgents, resolveBaseDir } from "./skill-installer2.mjs";
|
|
11
|
+
import { DEFAULT_SECTIONS, applyCachedSections, buildSkillContext, fetchAndCacheResources, findRelatedSkills, prepareSkillReferences, resolveAutoModel, runSkillEnhancement, selectLlmConfig, writeBaseSkill, writePromptFiles } from "./pipeline.mjs";
|
|
12
|
+
import { shutdownWorker } from "./pool2.mjs";
|
|
13
|
+
import { existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
14
|
+
import { styleText } from "node:util";
|
|
21
15
|
import * as p from "@clack/prompts";
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
16
|
+
import pLimit from "p-limit";
|
|
17
|
+
import { join, relative, resolve } from "pathe";
|
|
24
18
|
import logUpdate from "log-update";
|
|
25
|
-
|
|
26
|
-
const SKILLS_VERSION = "1.3.9";
|
|
27
|
-
function isEnabled() {
|
|
28
|
-
return !process.env.DISABLE_TELEMETRY && !process.env.DO_NOT_TRACK;
|
|
29
|
-
}
|
|
30
|
-
function track(data) {
|
|
31
|
-
if (!isEnabled()) return;
|
|
32
|
-
try {
|
|
33
|
-
const params = new URLSearchParams();
|
|
34
|
-
params.set("v", SKILLS_VERSION);
|
|
35
|
-
if (isCI) params.set("ci", "1");
|
|
36
|
-
for (const [key, value] of Object.entries(data)) if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
37
|
-
fetch(`${TELEMETRY_URL}?${params.toString()}`).catch(() => {});
|
|
38
|
-
} catch {}
|
|
39
|
-
}
|
|
19
|
+
import { createHooks } from "hookable";
|
|
40
20
|
const npmResolver = async (spec, opts) => {
|
|
41
21
|
const resolution = await resolvePackageOrCrate(spec, {
|
|
42
22
|
cwd: opts.cwd,
|
|
@@ -92,20 +72,31 @@ function createGithubResolver(owner, repo) {
|
|
|
92
72
|
};
|
|
93
73
|
}
|
|
94
74
|
const RATE_LIMIT_RE = /\b429\b|rate.?limit|exhausted.*capacity|quota.*reset/i;
|
|
95
|
-
async function runBaseSync(spec, config,
|
|
96
|
-
|
|
75
|
+
async function runBaseSync(spec, config, hooks, resolver, cwd, defaultSections) {
|
|
76
|
+
await hooks.callHook("resolve:start", { spec });
|
|
97
77
|
const resolverResult = await resolver(spec, {
|
|
98
78
|
cwd,
|
|
99
79
|
agent: config.agent,
|
|
100
80
|
global: config.global,
|
|
101
|
-
onProgress: (msg) =>
|
|
81
|
+
onProgress: (msg) => hooks.callHook("resolve:progress", {
|
|
82
|
+
spec,
|
|
83
|
+
message: msg
|
|
84
|
+
})
|
|
102
85
|
});
|
|
103
86
|
if (!("resolved" in resolverResult)) {
|
|
104
87
|
if (resolverResult.shipped && resolverResult.shipped.length > 0) {
|
|
105
|
-
for (const s of resolverResult.shipped)
|
|
88
|
+
for (const s of resolverResult.shipped) await hooks.callHook("shipped:installed", {
|
|
89
|
+
spec,
|
|
90
|
+
skillName: s.skillName,
|
|
91
|
+
skillDir: s.skillDir
|
|
92
|
+
});
|
|
106
93
|
return { kind: "shipped" };
|
|
107
94
|
}
|
|
108
|
-
|
|
95
|
+
await hooks.callHook("resolve:failed", {
|
|
96
|
+
spec,
|
|
97
|
+
identityName: resolverResult.identityName,
|
|
98
|
+
attempts: resolverResult.attempts
|
|
99
|
+
});
|
|
109
100
|
return {
|
|
110
101
|
kind: "unresolved",
|
|
111
102
|
unresolved: resolverResult
|
|
@@ -116,24 +107,33 @@ async function runBaseSync(spec, config, ui, resolver, cwd, defaultSections) {
|
|
|
116
107
|
if (config.force) cache.clearForce();
|
|
117
108
|
const useCache = cache.has();
|
|
118
109
|
if (kind !== "crate" && !existsSync(join(cwd, "node_modules", identityName))) {
|
|
119
|
-
|
|
110
|
+
await hooks.callHook("dist:downloading", { spec });
|
|
120
111
|
await fetchPkgDist(identityName, version);
|
|
121
112
|
}
|
|
122
113
|
if (kind !== "crate") {
|
|
123
114
|
const shipped = handleShippedSkills(identityName, version, cwd, config.agent, config.global);
|
|
124
115
|
if (shipped) {
|
|
125
116
|
linkShippedToAgents(shipped.shipped, cwd, config.agent, config.global);
|
|
126
|
-
for (const s of shipped.shipped)
|
|
117
|
+
for (const s of shipped.shipped) await hooks.callHook("shipped:installed", {
|
|
118
|
+
spec,
|
|
119
|
+
skillName: s.skillName,
|
|
120
|
+
skillDir: s.skillDir
|
|
121
|
+
});
|
|
127
122
|
return { kind: "shipped" };
|
|
128
123
|
}
|
|
129
124
|
}
|
|
130
|
-
|
|
125
|
+
await hooks.callHook("resolve:done", {
|
|
126
|
+
spec,
|
|
127
|
+
version,
|
|
131
128
|
cached: useCache,
|
|
132
129
|
force: config.force
|
|
133
130
|
});
|
|
134
131
|
if (kind === "npm" && !localVersion && !requestedTag && !isPrerelease(version)) {
|
|
135
132
|
const nextTag = resolved.distTags?.next ?? resolved.distTags?.beta ?? resolved.distTags?.alpha;
|
|
136
|
-
if (nextTag && (!resolved.releasedAt || !nextTag.releasedAt || nextTag.releasedAt > resolved.releasedAt))
|
|
133
|
+
if (nextTag && (!resolved.releasedAt || !nextTag.releasedAt || nextTag.releasedAt > resolved.releasedAt)) await hooks.callHook("warn", {
|
|
134
|
+
spec,
|
|
135
|
+
message: `No local dependency found — using latest stable (${version}). Prerelease ${nextTag.version} available: skilld add ${identityName}@beta`
|
|
136
|
+
});
|
|
137
137
|
}
|
|
138
138
|
cache.ensure();
|
|
139
139
|
const isEject = !!config.eject;
|
|
@@ -171,7 +171,7 @@ async function runBaseSync(spec, config, ui, resolver, cwd, defaultSections) {
|
|
|
171
171
|
})()
|
|
172
172
|
} : void 0;
|
|
173
173
|
const features = getActiveFeatures(config.noSearch ? { search: false } : void 0);
|
|
174
|
-
|
|
174
|
+
await hooks.callHook("fetch:start", { spec });
|
|
175
175
|
const resources = await fetchAndCacheResources({
|
|
176
176
|
packageName: storageName,
|
|
177
177
|
resolved,
|
|
@@ -179,7 +179,10 @@ async function runBaseSync(spec, config, ui, resolver, cwd, defaultSections) {
|
|
|
179
179
|
useCache,
|
|
180
180
|
features,
|
|
181
181
|
from: config.from,
|
|
182
|
-
onProgress: (msg) =>
|
|
182
|
+
onProgress: (msg) => hooks.callHook("fetch:progress", {
|
|
183
|
+
spec,
|
|
184
|
+
message: msg
|
|
185
|
+
})
|
|
183
186
|
});
|
|
184
187
|
const parts = [];
|
|
185
188
|
if (resources.docsToIndex.length > 0) {
|
|
@@ -189,9 +192,16 @@ async function runBaseSync(spec, config, ui, resolver, cwd, defaultSections) {
|
|
|
189
192
|
if (resources.hasIssues) parts.push("issues");
|
|
190
193
|
if (resources.hasDiscussions) parts.push("discussions");
|
|
191
194
|
if (resources.hasReleases) parts.push("releases");
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
+
await hooks.callHook("fetch:done", {
|
|
196
|
+
spec,
|
|
197
|
+
parts,
|
|
198
|
+
cached: resources.usedCache
|
|
199
|
+
});
|
|
200
|
+
for (const w of resources.warnings) await hooks.callHook("warn", {
|
|
201
|
+
spec,
|
|
202
|
+
message: w
|
|
203
|
+
});
|
|
204
|
+
if (features.search) await hooks.callHook("index:start", { spec });
|
|
195
205
|
const prepared = await prepareSkillReferences({
|
|
196
206
|
packageName: storageName,
|
|
197
207
|
version,
|
|
@@ -200,9 +210,12 @@ async function runBaseSync(spec, config, ui, resolver, cwd, defaultSections) {
|
|
|
200
210
|
resources,
|
|
201
211
|
features,
|
|
202
212
|
baseDir,
|
|
203
|
-
onIndexProgress: (msg) =>
|
|
213
|
+
onIndexProgress: (msg) => hooks.callHook("index:progress", {
|
|
214
|
+
spec,
|
|
215
|
+
message: msg
|
|
216
|
+
})
|
|
204
217
|
});
|
|
205
|
-
if (features.search)
|
|
218
|
+
if (features.search) await hooks.callHook("index:done", { spec });
|
|
206
219
|
if (!isEject) {
|
|
207
220
|
const repoSlug = parseGitHubRepoSlug(resolved.repoUrl);
|
|
208
221
|
cache.linkPkgNamed(skillDir, cwd);
|
|
@@ -225,7 +238,8 @@ async function runBaseSync(spec, config, ui, resolver, cwd, defaultSections) {
|
|
|
225
238
|
skipLinkAgents: true
|
|
226
239
|
});
|
|
227
240
|
}
|
|
228
|
-
const
|
|
241
|
+
const updatedLock = isEject ? void 0 : readLock(baseDir)?.skills[skillDirName];
|
|
242
|
+
const allPackages = parsePackageNames(updatedLock?.packages);
|
|
229
243
|
const ctx = buildSkillContext({
|
|
230
244
|
packageName: identityName,
|
|
231
245
|
cachePackageName: storageName,
|
|
@@ -239,9 +253,13 @@ async function runBaseSync(spec, config, ui, resolver, cwd, defaultSections) {
|
|
|
239
253
|
features
|
|
240
254
|
});
|
|
241
255
|
ctx.overheadLines = writeBaseSkill(ctx, { eject: isEject }).split("\n").length;
|
|
242
|
-
|
|
256
|
+
await hooks.callHook("base:done", {
|
|
257
|
+
spec,
|
|
258
|
+
skillDir: relative(cwd, skillDir),
|
|
259
|
+
mode: config.mode === "update" ? "update" : "add"
|
|
260
|
+
});
|
|
243
261
|
const allSectionsCached = !config.force && applyCachedSections(ctx, defaultSections, { eject: isEject });
|
|
244
|
-
if (allSectionsCached)
|
|
262
|
+
if (allSectionsCached) await hooks.callHook("sections:cached", { spec });
|
|
245
263
|
return {
|
|
246
264
|
kind: "ready",
|
|
247
265
|
state: {
|
|
@@ -259,8 +277,9 @@ async function runBaseSync(spec, config, ui, resolver, cwd, defaultSections) {
|
|
|
259
277
|
}
|
|
260
278
|
};
|
|
261
279
|
}
|
|
262
|
-
async function runEnhancePhase(state, llmConfig, config,
|
|
280
|
+
async function runEnhancePhase(state, llmConfig, config, hooks, cwd) {
|
|
263
281
|
const isEject = !!config.eject;
|
|
282
|
+
const spec = state.identityName;
|
|
264
283
|
if (llmConfig?.promptOnly) writePromptFiles({
|
|
265
284
|
...state.ctx,
|
|
266
285
|
packageName: state.ctx.cachePackageName ?? state.ctx.packageName,
|
|
@@ -269,10 +288,10 @@ async function runEnhancePhase(state, llmConfig, config, ui, cwd) {
|
|
|
269
288
|
sections: llmConfig.sections,
|
|
270
289
|
customPrompt: llmConfig.customPrompt
|
|
271
290
|
});
|
|
272
|
-
else if (llmConfig) await
|
|
291
|
+
else if (llmConfig) await enhanceWithHooks(state.ctx, llmConfig, {
|
|
273
292
|
...config,
|
|
274
293
|
eject: isEject
|
|
275
|
-
},
|
|
294
|
+
}, hooks, spec);
|
|
276
295
|
if (isEject) {
|
|
277
296
|
const cache = createReferenceCache(state.storageName, state.version);
|
|
278
297
|
if (!config.debug) cache.clearSkillInternal(state.skillDir);
|
|
@@ -291,8 +310,11 @@ async function runEnhancePhase(state, llmConfig, config, ui, cwd) {
|
|
|
291
310
|
shared
|
|
292
311
|
});
|
|
293
312
|
}
|
|
294
|
-
async function
|
|
295
|
-
|
|
313
|
+
async function enhanceWithHooks(ctx, llmConfig, config, hooks, spec) {
|
|
314
|
+
await hooks.callHook("enhance:start", {
|
|
315
|
+
spec,
|
|
316
|
+
modelLabel: getModelLabel(llmConfig.model)
|
|
317
|
+
});
|
|
296
318
|
const result = await runSkillEnhancement(ctx, {
|
|
297
319
|
model: llmConfig.model,
|
|
298
320
|
force: config.force,
|
|
@@ -300,276 +322,199 @@ async function enhanceWithUi(ctx, llmConfig, config, ui) {
|
|
|
300
322
|
sections: llmConfig.sections,
|
|
301
323
|
customPrompt: llmConfig.customPrompt,
|
|
302
324
|
eject: !!config.eject
|
|
303
|
-
}, (progress) =>
|
|
304
|
-
|
|
325
|
+
}, (progress) => hooks.callHook("enhance:progress", {
|
|
326
|
+
spec,
|
|
327
|
+
progress
|
|
328
|
+
}));
|
|
329
|
+
if (result.wasOptimized) await hooks.callHook("enhance:done", {
|
|
330
|
+
spec,
|
|
305
331
|
usage: result.usage ? { totalTokens: result.usage.totalTokens } : void 0,
|
|
306
332
|
cost: result.cost,
|
|
307
333
|
debugLogsDir: result.debugLogsDir,
|
|
308
334
|
error: result.error,
|
|
309
335
|
warnings: result.warnings
|
|
310
336
|
});
|
|
311
|
-
else
|
|
337
|
+
else await hooks.callHook("enhance:failed", {
|
|
338
|
+
spec,
|
|
339
|
+
error: result.error ?? "",
|
|
340
|
+
rateLimited: !!result.error && RATE_LIMIT_RE.test(result.error)
|
|
341
|
+
});
|
|
312
342
|
}
|
|
313
|
-
function
|
|
343
|
+
function createSyncRun(opts) {
|
|
344
|
+
const hooks = createHooks();
|
|
345
|
+
async function runBase(spec) {
|
|
346
|
+
const result = await runBaseSync(spec, {
|
|
347
|
+
agent: opts.agent,
|
|
348
|
+
global: opts.global,
|
|
349
|
+
mode: opts.mode,
|
|
350
|
+
force: opts.force,
|
|
351
|
+
noSearch: opts.noSearch,
|
|
352
|
+
name: opts.name,
|
|
353
|
+
from: opts.from,
|
|
354
|
+
eject: opts.eject
|
|
355
|
+
}, hooks, opts.resolver, opts.cwd, opts.defaultSections);
|
|
356
|
+
if (result.kind === "shipped") return {
|
|
357
|
+
kind: "shipped",
|
|
358
|
+
spec
|
|
359
|
+
};
|
|
360
|
+
if (result.kind === "unresolved") return {
|
|
361
|
+
kind: "unresolved",
|
|
362
|
+
spec,
|
|
363
|
+
identityName: result.unresolved.identityName,
|
|
364
|
+
attempts: result.unresolved.attempts
|
|
365
|
+
};
|
|
366
|
+
if (result.kind === "merge-needed") {
|
|
367
|
+
if (opts.onMergeNeeded) {
|
|
368
|
+
await opts.onMergeNeeded(result.state);
|
|
369
|
+
return {
|
|
370
|
+
kind: "merged",
|
|
371
|
+
spec
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
return {
|
|
375
|
+
kind: "error",
|
|
376
|
+
spec,
|
|
377
|
+
reason: `Skill dir already holds ${result.state.existingLock.packageName} — run sequentially to merge`
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
return {
|
|
381
|
+
kind: "ready",
|
|
382
|
+
spec,
|
|
383
|
+
state: result.state
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
async function runEnhance(state, llmConfig) {
|
|
387
|
+
await runEnhancePhase(state, llmConfig, {
|
|
388
|
+
agent: opts.agent,
|
|
389
|
+
global: opts.global,
|
|
390
|
+
force: opts.force,
|
|
391
|
+
debug: opts.debug,
|
|
392
|
+
eject: opts.eject
|
|
393
|
+
}, hooks, opts.cwd);
|
|
394
|
+
}
|
|
395
|
+
async function run(spec) {
|
|
396
|
+
const base = await runBase(spec);
|
|
397
|
+
if (base.kind !== "ready") return base;
|
|
398
|
+
let llmConfig = null;
|
|
399
|
+
if (!base.state.allSectionsCached && opts.resolveLlmConfig) llmConfig = await opts.resolveLlmConfig({ ready: [{
|
|
400
|
+
spec,
|
|
401
|
+
state: base.state
|
|
402
|
+
}] }) ?? null;
|
|
403
|
+
await runEnhance(base.state, llmConfig);
|
|
404
|
+
return {
|
|
405
|
+
kind: "enhanced",
|
|
406
|
+
spec,
|
|
407
|
+
state: base.state
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
async function runMany(specs, runOpts) {
|
|
411
|
+
const limit = pLimit(runOpts?.concurrency ?? 5);
|
|
412
|
+
return (await Promise.allSettled(specs.map((spec) => limit(() => runBase(spec))))).map((r, i) => r.status === "fulfilled" ? r.value : {
|
|
413
|
+
kind: "error",
|
|
414
|
+
spec: specs[i],
|
|
415
|
+
reason: r.reason instanceof Error ? r.reason.message : String(r.reason)
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
return {
|
|
419
|
+
hooks,
|
|
420
|
+
runBase,
|
|
421
|
+
runEnhance,
|
|
422
|
+
run,
|
|
423
|
+
runMany
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function bindClackUi(hooks, { cwd }) {
|
|
314
427
|
let spinner = null;
|
|
315
428
|
let resourceSpinner = null;
|
|
316
429
|
let indexSpinner = null;
|
|
317
430
|
let llmLog = null;
|
|
318
431
|
let currentSpec = "";
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
warn(
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
});
|
|
378
|
-
},
|
|
379
|
-
llmProgress(progress) {
|
|
380
|
-
if (!llmLog) return;
|
|
381
|
-
const sectionPrefix = progress.section ? `[${progress.section}] ` : "";
|
|
382
|
-
const line = progress.chunk.startsWith("[") ? `${sectionPrefix}${progress.chunk}` : `${sectionPrefix}${progress.chunk}`;
|
|
383
|
-
llmLog.message(line);
|
|
384
|
-
},
|
|
385
|
-
llmDone(info) {
|
|
386
|
-
if (!llmLog) return;
|
|
387
|
-
const parts = [];
|
|
388
|
-
if (info.usage) parts.push(`${Math.round(info.usage.totalTokens / 1e3)}k tokens`);
|
|
389
|
-
if (info.cost) parts.push(`$${info.cost.toFixed(2)}`);
|
|
390
|
-
const suffix = parts.length > 0 ? ` (${parts.join(", ")})` : "";
|
|
391
|
-
llmLog.success(`Generated best practices${suffix}`);
|
|
392
|
-
llmLog = null;
|
|
393
|
-
if (info.debugLogsDir) p.log.info(`Debug logs: ${relative(cwd, info.debugLogsDir)}`);
|
|
394
|
-
if (info.error) p.log.warn(`\x1B[33mPartial failure: ${info.error}\x1B[0m`);
|
|
395
|
-
if (info.warnings) for (const w of info.warnings) p.log.warn(`\x1B[33m${w}\x1B[0m`);
|
|
396
|
-
},
|
|
397
|
-
llmFailed(error, opts) {
|
|
398
|
-
if (!llmLog) return;
|
|
399
|
-
if (opts.rateLimited) llmLog.error(`Rate limited by LLM provider. Try again shortly or use a different model via \`skilld config\``);
|
|
400
|
-
else llmLog.error(`Enhancement failed${error ? `: ${error}` : ""}`);
|
|
401
|
-
llmLog = null;
|
|
402
|
-
},
|
|
403
|
-
shippedInstalled(skillName, relPath) {
|
|
404
|
-
p.log.success(`Using published SKILL.md: ${skillName} → ${relPath}`);
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
async function syncGitSkills(opts) {
|
|
409
|
-
const { source, agent, global: isGlobal, yes } = opts;
|
|
410
|
-
const cwd = process.cwd();
|
|
411
|
-
const agentConfig = targets[agent];
|
|
412
|
-
const baseDir = isGlobal ? join(CACHE_DIR, "skills") : join(cwd, agentConfig.skillsDir);
|
|
413
|
-
const label = source.type === "local" ? source.localPath : `${source.owner}/${source.repo}`;
|
|
414
|
-
const spin = timedSpinner();
|
|
415
|
-
spin.start(`Fetching skills from ${label}`);
|
|
416
|
-
const { skills } = await fetchGitSkills(source, (msg) => spin.message(msg));
|
|
417
|
-
if (skills.length === 0) {
|
|
418
|
-
if (source.type === "github" && source.owner && source.repo) {
|
|
419
|
-
spin.stop(`No pre-authored skills in ${label}, generating from repo docs...`);
|
|
420
|
-
return syncGitHubRepo(opts);
|
|
421
|
-
}
|
|
422
|
-
spin.stop(`No skills found in ${label}`);
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
spin.stop(`Found ${skills.length} skill(s) in ${label}`);
|
|
426
|
-
let selected = skills;
|
|
427
|
-
if (opts.skillFilter?.length) {
|
|
428
|
-
const filterSet = new Set(opts.skillFilter.map((s) => s.toLowerCase().replace(/-skilld$/, "")));
|
|
429
|
-
selected = skills.filter((s) => filterSet.has(s.name.toLowerCase().replace(/-skilld$/, "")));
|
|
430
|
-
if (selected.length === 0) {
|
|
431
|
-
p.log.warn(`No skills matched: ${opts.skillFilter.join(", ")}`);
|
|
432
|
-
p.log.message(`Available: ${skills.map((s) => s.name).join(", ")}`);
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
} else if (source.skillPath) selected = skills;
|
|
436
|
-
else if (skills.length > 1 && !yes) {
|
|
437
|
-
const choices = await p.autocompleteMultiselect({
|
|
438
|
-
message: `Select skills to install from ${label}`,
|
|
439
|
-
options: skills.map((s) => ({
|
|
440
|
-
label: s.name.replace(/-skilld$/, ""),
|
|
441
|
-
value: s.name,
|
|
442
|
-
hint: s.description || s.path
|
|
443
|
-
})),
|
|
444
|
-
initialValues: []
|
|
445
|
-
});
|
|
446
|
-
if (p.isCancel(choices)) return;
|
|
447
|
-
const selectedNames = new Set(choices);
|
|
448
|
-
selected = skills.filter((s) => selectedNames.has(s.name));
|
|
449
|
-
if (selected.length === 0) return;
|
|
450
|
-
}
|
|
451
|
-
mkdirSync(baseDir, { recursive: true });
|
|
452
|
-
for (const skill of selected) {
|
|
453
|
-
const skillDir = join(baseDir, skill.name);
|
|
454
|
-
mkdirSync(skillDir, { recursive: true });
|
|
455
|
-
writeSkillMd(skillDir, sanitizeMarkdown(skill.content));
|
|
456
|
-
if (skill.files.length > 0) for (const f of skill.files) {
|
|
457
|
-
const filePath = join(skillDir, f.path);
|
|
458
|
-
mkdirSync(dirname(filePath), { recursive: true });
|
|
459
|
-
writeFileSync(filePath, f.content);
|
|
460
|
-
}
|
|
461
|
-
const sourceType = source.type === "local" ? "local" : source.type;
|
|
462
|
-
installSkill({
|
|
463
|
-
cwd,
|
|
464
|
-
agent,
|
|
465
|
-
global: isGlobal,
|
|
466
|
-
baseDir,
|
|
467
|
-
skillDirName: skill.name,
|
|
468
|
-
lock: {
|
|
469
|
-
source: sourceType,
|
|
470
|
-
repo: source.type === "local" ? source.localPath : `${source.owner}/${source.repo}`,
|
|
471
|
-
path: skill.path || void 0,
|
|
472
|
-
ref: source.ref || "main",
|
|
473
|
-
syncedAt: todayIsoDate(),
|
|
474
|
-
generator: "external"
|
|
475
|
-
},
|
|
476
|
-
skipLinkAgents: true
|
|
432
|
+
hooks.hook("resolve:start", ({ spec }) => {
|
|
433
|
+
currentSpec = spec;
|
|
434
|
+
spinner = timedSpinner();
|
|
435
|
+
spinner.start(`Resolving ${spec}`);
|
|
436
|
+
});
|
|
437
|
+
hooks.hook("resolve:progress", ({ message }) => {
|
|
438
|
+
spinner?.message(message);
|
|
439
|
+
});
|
|
440
|
+
hooks.hook("resolve:done", ({ version, cached, force }) => {
|
|
441
|
+
const suffix = force ? " (force)" : cached ? " (cached)" : "";
|
|
442
|
+
spinner?.stop(`Resolved ${currentSpec}@${version}${suffix}`);
|
|
443
|
+
spinner = null;
|
|
444
|
+
});
|
|
445
|
+
hooks.hook("resolve:failed", ({ identityName }) => {
|
|
446
|
+
spinner?.stop(`Could not find docs for: ${identityName}`);
|
|
447
|
+
spinner = null;
|
|
448
|
+
});
|
|
449
|
+
hooks.hook("dist:downloading", () => {
|
|
450
|
+
spinner?.message("Downloading dist");
|
|
451
|
+
});
|
|
452
|
+
hooks.hook("fetch:start", () => {
|
|
453
|
+
resourceSpinner = timedSpinner();
|
|
454
|
+
resourceSpinner.start("Finding resources");
|
|
455
|
+
});
|
|
456
|
+
hooks.hook("fetch:progress", ({ message }) => {
|
|
457
|
+
resourceSpinner?.message(message);
|
|
458
|
+
});
|
|
459
|
+
hooks.hook("fetch:done", ({ parts, cached }) => {
|
|
460
|
+
const summary = parts.length > 0 ? parts.join(", ") : "resources";
|
|
461
|
+
resourceSpinner?.stop(cached ? `Loaded ${summary} (cached)` : `Fetched ${summary}`);
|
|
462
|
+
resourceSpinner = null;
|
|
463
|
+
});
|
|
464
|
+
hooks.hook("index:start", () => {
|
|
465
|
+
indexSpinner = timedSpinner();
|
|
466
|
+
indexSpinner.start("Creating search index");
|
|
467
|
+
});
|
|
468
|
+
hooks.hook("index:progress", ({ message }) => {
|
|
469
|
+
indexSpinner?.message(message);
|
|
470
|
+
});
|
|
471
|
+
hooks.hook("index:done", () => {
|
|
472
|
+
indexSpinner?.stop("Search index ready");
|
|
473
|
+
indexSpinner = null;
|
|
474
|
+
});
|
|
475
|
+
hooks.hook("warn", ({ message }) => {
|
|
476
|
+
p.log.warn(styleText("yellow", message));
|
|
477
|
+
});
|
|
478
|
+
hooks.hook("base:done", ({ skillDir, mode }) => {
|
|
479
|
+
p.log.success(mode === "update" ? `Updated skill: ${skillDir}` : `Created base skill: ${skillDir}`);
|
|
480
|
+
});
|
|
481
|
+
hooks.hook("sections:cached", () => {
|
|
482
|
+
p.log.success("Applied cached SKILL.md sections");
|
|
483
|
+
});
|
|
484
|
+
hooks.hook("enhance:start", ({ spec, modelLabel }) => {
|
|
485
|
+
currentSpec = spec;
|
|
486
|
+
p.log.step(modelLabel);
|
|
487
|
+
llmLog = p.taskLog({
|
|
488
|
+
title: `Agent exploring ${spec}`,
|
|
489
|
+
limit: 3
|
|
477
490
|
});
|
|
478
|
-
}
|
|
479
|
-
if (source.type !== "local" && source.owner && source.repo) track({
|
|
480
|
-
event: "install",
|
|
481
|
-
source: `${source.owner}/${source.repo}`,
|
|
482
|
-
skills: selected.map((s) => s.name).join(","),
|
|
483
|
-
agents: agent,
|
|
484
|
-
...isGlobal && { global: "1" },
|
|
485
|
-
sourceType: source.type
|
|
486
491
|
});
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
async function syncGitHubRepo(opts) {
|
|
494
|
-
const { source, agent, global: isGlobal, yes } = opts;
|
|
495
|
-
const owner = source.owner;
|
|
496
|
-
const repo = source.repo;
|
|
497
|
-
const cwd = process.cwd();
|
|
498
|
-
const ui = createClackUi({ cwd });
|
|
499
|
-
const spec = `${owner}/${repo}`;
|
|
500
|
-
const result = await runBaseSync(spec, {
|
|
501
|
-
agent,
|
|
502
|
-
global: isGlobal,
|
|
503
|
-
force: opts.force,
|
|
504
|
-
from: opts.from
|
|
505
|
-
}, ui, createGithubResolver(owner, repo), cwd, DEFAULT_SECTIONS);
|
|
506
|
-
if (result.kind !== "ready") return;
|
|
507
|
-
const { state } = result;
|
|
508
|
-
const globalConfig = readConfig();
|
|
509
|
-
let llmConfig = null;
|
|
510
|
-
if (!state.allSectionsCached && !globalConfig.skipLlm && (!yes || opts.model)) llmConfig = await selectLlmConfig(opts.model);
|
|
511
|
-
await runEnhancePhase(state, llmConfig, {
|
|
512
|
-
agent,
|
|
513
|
-
global: isGlobal,
|
|
514
|
-
force: opts.force,
|
|
515
|
-
debug: opts.debug
|
|
516
|
-
}, ui, cwd);
|
|
517
|
-
await shutdownWorker();
|
|
518
|
-
track({
|
|
519
|
-
event: "install",
|
|
520
|
-
source: spec,
|
|
521
|
-
skills: state.skillDirName,
|
|
522
|
-
agents: agent,
|
|
523
|
-
...isGlobal && { global: "1" },
|
|
524
|
-
sourceType: "github-generated"
|
|
492
|
+
hooks.hook("enhance:progress", ({ progress }) => {
|
|
493
|
+
if (!llmLog) return;
|
|
494
|
+
const line = `${progress.section ? `[${progress.section}] ` : ""}${progress.chunk}`;
|
|
495
|
+
llmLog.message(line);
|
|
525
496
|
});
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
cwd,
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
baseDir,
|
|
538
|
-
skillDirName,
|
|
539
|
-
lock: {
|
|
540
|
-
packageName: identityName,
|
|
541
|
-
version,
|
|
542
|
-
repo: repoSlug,
|
|
543
|
-
source: existingLock.source,
|
|
544
|
-
syncedAt: todayIsoDate(),
|
|
545
|
-
generator: "skilld"
|
|
546
|
-
},
|
|
547
|
-
skipLinkAgents: true
|
|
497
|
+
hooks.hook("enhance:done", (info) => {
|
|
498
|
+
if (!llmLog) return;
|
|
499
|
+
const parts = [];
|
|
500
|
+
if (info.usage) parts.push(`${Math.round(info.usage.totalTokens / 1e3)}k tokens`);
|
|
501
|
+
if (info.cost) parts.push(`$${info.cost.toFixed(2)}`);
|
|
502
|
+
const suffix = parts.length > 0 ? ` (${parts.join(", ")})` : "";
|
|
503
|
+
llmLog.success(`Generated best practices${suffix}`);
|
|
504
|
+
llmLog = null;
|
|
505
|
+
if (info.debugLogsDir) p.log.info(`Debug logs: ${relative(cwd, info.debugLogsDir)}`);
|
|
506
|
+
if (info.error) p.log.warn(styleText("yellow", `Partial failure: ${info.error}`));
|
|
507
|
+
if (info.warnings) for (const w of info.warnings) p.log.warn(styleText("yellow", w));
|
|
548
508
|
});
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
name: existingLock.packageName,
|
|
558
|
-
version: existingLock.version,
|
|
559
|
-
relatedSkills,
|
|
560
|
-
hasIssues: features.issues && existsSync(skillRefsSection(skillDir, "issues")),
|
|
561
|
-
hasDiscussions: features.discussions && existsSync(skillRefsSection(skillDir, "discussions")),
|
|
562
|
-
hasReleases: features.releases && existsSync(skillRefsSection(skillDir, "releases")),
|
|
563
|
-
docsType: existingLock.source?.includes("llms.txt") ? "llms.txt" : "docs",
|
|
564
|
-
hasShippedDocs: shippedDocs,
|
|
565
|
-
pkgFiles,
|
|
566
|
-
dirName: skillDirName,
|
|
567
|
-
packages: allPackages,
|
|
568
|
-
features
|
|
509
|
+
hooks.hook("enhance:failed", ({ error, rateLimited }) => {
|
|
510
|
+
if (!llmLog) return;
|
|
511
|
+
if (rateLimited) llmLog.error(`Rate limited by LLM provider. Try again shortly or use a different model via \`skilld config\``);
|
|
512
|
+
else llmLog.error(`Enhancement failed${error ? `: ${error}` : ""}`);
|
|
513
|
+
llmLog = null;
|
|
514
|
+
});
|
|
515
|
+
hooks.hook("shipped:installed", ({ skillName, skillDir }) => {
|
|
516
|
+
p.log.success(`Using published SKILL.md: ${skillName} → ${relative(cwd, skillDir)}`);
|
|
569
517
|
});
|
|
570
|
-
const sharedDir = !config.global && getSharedSkillsDir(cwd);
|
|
571
|
-
if (sharedDir) linkSkillToAgents(skillDirName, sharedDir, cwd, config.agent);
|
|
572
|
-
p.outro(`Merged ${identityName} into ${skillDirName}`);
|
|
573
518
|
}
|
|
574
519
|
const STATUS_ICONS = {
|
|
575
520
|
pending: "○",
|
|
@@ -583,37 +528,35 @@ const STATUS_ICONS = {
|
|
|
583
528
|
error: "✗"
|
|
584
529
|
};
|
|
585
530
|
const STATUS_COLORS = {
|
|
586
|
-
pending: "
|
|
587
|
-
resolving: "
|
|
588
|
-
downloading: "
|
|
589
|
-
embedding: "
|
|
590
|
-
exploring: "
|
|
591
|
-
thinking: "
|
|
592
|
-
generating: "
|
|
593
|
-
done: "
|
|
594
|
-
error: "
|
|
531
|
+
pending: "gray",
|
|
532
|
+
resolving: "cyan",
|
|
533
|
+
downloading: "cyan",
|
|
534
|
+
embedding: "cyan",
|
|
535
|
+
exploring: "blue",
|
|
536
|
+
thinking: "magenta",
|
|
537
|
+
generating: "yellow",
|
|
538
|
+
done: "green",
|
|
539
|
+
error: "red"
|
|
595
540
|
};
|
|
596
541
|
function renderParallel(r) {
|
|
597
542
|
const maxNameLen = Math.max(...[...r.states.keys()].map((n) => n.length), 20);
|
|
598
543
|
const lines = [...r.states.values()].map((s) => {
|
|
599
|
-
const icon = STATUS_ICONS[s.status];
|
|
600
|
-
const color = STATUS_COLORS[s.status];
|
|
601
|
-
const reset = "\x1B[0m";
|
|
602
|
-
const dim = "\x1B[90m";
|
|
544
|
+
const icon = styleText(STATUS_COLORS[s.status], STATUS_ICONS[s.status]);
|
|
603
545
|
const name = s.name.padEnd(maxNameLen);
|
|
604
|
-
const version = s.version ? `${
|
|
605
|
-
const elapsed = (s.status === "done" || s.status === "error") && s.startedAt && s.completedAt ? ` ${
|
|
606
|
-
const preview = s.streamPreview ? ` ${
|
|
607
|
-
return ` ${
|
|
546
|
+
const version = s.version ? `${styleText("gray", s.version)} ` : "";
|
|
547
|
+
const elapsed = (s.status === "done" || s.status === "error") && s.startedAt && s.completedAt ? ` ${styleText("gray", `(${formatDuration(s.completedAt - s.startedAt)})`)}` : "";
|
|
548
|
+
const preview = s.streamPreview ? ` ${styleText("gray", s.streamPreview)}` : "";
|
|
549
|
+
return ` ${icon} ${name} ${version}${s.message}${elapsed}${preview}`;
|
|
608
550
|
});
|
|
609
551
|
const doneCount = [...r.states.values()].filter((s) => s.status === "done").length;
|
|
610
552
|
const errorCount = [...r.states.values()].filter((s) => s.status === "error").length;
|
|
611
|
-
|
|
553
|
+
const header = `${styleText("bold", `${r.verb} ${r.total} packages`)} (${doneCount} done${errorCount > 0 ? `, ${errorCount} failed` : ""})\n`;
|
|
554
|
+
logUpdate(header + lines.join("\n"));
|
|
612
555
|
}
|
|
613
|
-
function
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
556
|
+
function bindParallelUi(hooks, render) {
|
|
557
|
+
function update(spec, status, message, ver) {
|
|
558
|
+
const state = render.states.get(spec);
|
|
559
|
+
if (!state) return;
|
|
617
560
|
if (!state.startedAt && status !== "pending") state.startedAt = performance.now();
|
|
618
561
|
if ((status === "done" || status === "error") && !state.completedAt) state.completedAt = performance.now();
|
|
619
562
|
state.status = status;
|
|
@@ -622,58 +565,31 @@ function createParallelUi(name, render, version) {
|
|
|
622
565
|
if (ver) state.version = ver;
|
|
623
566
|
renderParallel(render);
|
|
624
567
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
indexProgress(msg) {
|
|
651
|
-
update("embedding", msg);
|
|
652
|
-
},
|
|
653
|
-
indexDone() {},
|
|
654
|
-
warn(_msg) {},
|
|
655
|
-
baseDone(_relPath, mode) {
|
|
656
|
-
update("done", mode === "update" ? "Skill updated" : "Base skill created");
|
|
657
|
-
},
|
|
658
|
-
sectionsCached() {},
|
|
659
|
-
llmStart(modelLabel) {
|
|
660
|
-
update("generating", modelLabel);
|
|
661
|
-
},
|
|
662
|
-
llmProgress(progress) {
|
|
663
|
-
const status = progress.type === "reasoning" ? "exploring" : "generating";
|
|
664
|
-
const sectionPrefix = progress.section ? `[${progress.section}] ` : "";
|
|
665
|
-
update(status, progress.chunk.startsWith("[") ? `${sectionPrefix}${progress.chunk}` : `${sectionPrefix}${progress.chunk}`);
|
|
666
|
-
},
|
|
667
|
-
llmDone(_info) {
|
|
668
|
-
update("done", "Skill optimized");
|
|
669
|
-
},
|
|
670
|
-
llmFailed(error, _opts) {
|
|
671
|
-
update("error", error);
|
|
672
|
-
},
|
|
673
|
-
shippedInstalled(_skillName, _relPath) {
|
|
674
|
-
update("done", "Published SKILL.md");
|
|
675
|
-
}
|
|
676
|
-
};
|
|
568
|
+
hooks.hook("resolve:start", ({ spec }) => update(spec, "resolving", "Resolving..."));
|
|
569
|
+
hooks.hook("resolve:progress", ({ spec, message }) => update(spec, "resolving", message));
|
|
570
|
+
hooks.hook("resolve:done", ({ spec, version, cached, force }) => {
|
|
571
|
+
update(spec, "downloading", cached ? "Using cache" : force ? "Re-fetching docs..." : "Fetching docs...", version);
|
|
572
|
+
});
|
|
573
|
+
hooks.hook("resolve:failed", () => {});
|
|
574
|
+
hooks.hook("dist:downloading", ({ spec }) => update(spec, "downloading", "Downloading dist..."));
|
|
575
|
+
hooks.hook("fetch:start", () => {});
|
|
576
|
+
hooks.hook("fetch:progress", ({ spec, message }) => update(spec, "downloading", message));
|
|
577
|
+
hooks.hook("fetch:done", ({ spec }) => update(spec, "downloading", "Linking references..."));
|
|
578
|
+
hooks.hook("index:start", ({ spec }) => update(spec, "embedding", "Indexing docs"));
|
|
579
|
+
hooks.hook("index:progress", ({ spec, message }) => update(spec, "embedding", message));
|
|
580
|
+
hooks.hook("index:done", () => {});
|
|
581
|
+
hooks.hook("warn", () => {});
|
|
582
|
+
hooks.hook("base:done", ({ spec, mode }) => {
|
|
583
|
+
update(spec, "done", mode === "update" ? "Skill updated" : "Base skill created");
|
|
584
|
+
});
|
|
585
|
+
hooks.hook("sections:cached", () => {});
|
|
586
|
+
hooks.hook("enhance:start", ({ spec, modelLabel }) => update(spec, "generating", modelLabel));
|
|
587
|
+
hooks.hook("enhance:progress", ({ spec, progress }) => {
|
|
588
|
+
update(spec, progress.type === "reasoning" ? "exploring" : "generating", `${progress.section ? `[${progress.section}] ` : ""}${progress.chunk}`);
|
|
589
|
+
});
|
|
590
|
+
hooks.hook("enhance:done", ({ spec }) => update(spec, "done", "Skill optimized"));
|
|
591
|
+
hooks.hook("enhance:failed", ({ spec, error }) => update(spec, "error", error));
|
|
592
|
+
hooks.hook("shipped:installed", ({ spec }) => update(spec, "done", "Published SKILL.md"));
|
|
677
593
|
}
|
|
678
594
|
const DIFF_RANK = {
|
|
679
595
|
major: 5,
|
|
@@ -688,11 +604,16 @@ async function syncPackagesParallel(config) {
|
|
|
688
604
|
const { packages, concurrency = 5 } = config;
|
|
689
605
|
const cwd = process.cwd();
|
|
690
606
|
const states = /* @__PURE__ */ new Map();
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
607
|
+
const specToName = /* @__PURE__ */ new Map();
|
|
608
|
+
for (const spec of packages) {
|
|
609
|
+
const { name } = parsePackageSpec(spec);
|
|
610
|
+
specToName.set(spec, name);
|
|
611
|
+
states.set(spec, {
|
|
612
|
+
name,
|
|
613
|
+
status: "pending",
|
|
614
|
+
message: "Waiting..."
|
|
615
|
+
});
|
|
616
|
+
}
|
|
696
617
|
const render = {
|
|
697
618
|
states,
|
|
698
619
|
verb: config.mode === "update" ? "Updating" : "Syncing",
|
|
@@ -700,17 +621,19 @@ async function syncPackagesParallel(config) {
|
|
|
700
621
|
};
|
|
701
622
|
ensureCacheDir();
|
|
702
623
|
renderParallel(render);
|
|
703
|
-
const
|
|
704
|
-
|
|
624
|
+
const run = createSyncRun({
|
|
625
|
+
cwd,
|
|
626
|
+
resolver: npmResolver,
|
|
705
627
|
agent: config.agent,
|
|
706
628
|
global: config.global,
|
|
707
629
|
mode: config.mode,
|
|
708
|
-
force: config.force
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
630
|
+
force: config.force,
|
|
631
|
+
debug: config.debug,
|
|
632
|
+
defaultSections: DEFAULT_SECTIONS
|
|
633
|
+
});
|
|
634
|
+
bindParallelUi(run.hooks, render);
|
|
635
|
+
const limit = pLimit(concurrency);
|
|
636
|
+
const baseResults = await Promise.allSettled(packages.map((spec) => limit(() => run.runBase(spec))));
|
|
714
637
|
logUpdate.done();
|
|
715
638
|
const ready = [];
|
|
716
639
|
const shippedCount = [];
|
|
@@ -736,13 +659,13 @@ async function syncPackagesParallel(config) {
|
|
|
736
659
|
continue;
|
|
737
660
|
}
|
|
738
661
|
if (result.kind === "unresolved") {
|
|
739
|
-
const npmAttempt = result.
|
|
662
|
+
const npmAttempt = result.attempts.find((a) => a.source === "npm");
|
|
740
663
|
let reason;
|
|
741
664
|
if (npmAttempt?.status === "not-found") {
|
|
742
|
-
const suggestions = await searchNpmPackages(result.
|
|
665
|
+
const suggestions = await searchNpmPackages(result.identityName, 3);
|
|
743
666
|
const hint = suggestions.length > 0 ? ` (try: ${suggestions.map((s) => s.name).join(", ")})` : "";
|
|
744
667
|
reason = (npmAttempt.message || "Not on npm") + hint;
|
|
745
|
-
} else reason = result.
|
|
668
|
+
} else reason = result.attempts.filter((a) => a.status !== "success").map((a) => a.message || a.source).join("; ") || "No docs found";
|
|
746
669
|
const slot = states.get(spec);
|
|
747
670
|
if (slot) {
|
|
748
671
|
slot.status = "error";
|
|
@@ -754,14 +677,14 @@ async function syncPackagesParallel(config) {
|
|
|
754
677
|
});
|
|
755
678
|
continue;
|
|
756
679
|
}
|
|
757
|
-
if (result.kind === "
|
|
680
|
+
if (result.kind === "error") {
|
|
758
681
|
errors.push({
|
|
759
682
|
spec,
|
|
760
|
-
reason:
|
|
683
|
+
reason: result.reason
|
|
761
684
|
});
|
|
762
685
|
continue;
|
|
763
686
|
}
|
|
764
|
-
ready.push({
|
|
687
|
+
if (result.kind === "ready") ready.push({
|
|
765
688
|
spec,
|
|
766
689
|
state: result.state
|
|
767
690
|
});
|
|
@@ -770,7 +693,7 @@ async function syncPackagesParallel(config) {
|
|
|
770
693
|
logUpdate.done();
|
|
771
694
|
const pastVerb = config.mode === "update" ? "Updated" : "Created";
|
|
772
695
|
p.log.success(`${pastVerb} ${ready.length} base skills${shippedCount.length > 0 ? ` (${shippedCount.length} shipped)` : ""}`);
|
|
773
|
-
for (const w of aggregatedWarnings) p.log.warn(
|
|
696
|
+
for (const w of aggregatedWarnings) p.log.warn(styleText("yellow", w));
|
|
774
697
|
for (const { spec, reason } of errors) p.log.error(` ${spec}: ${reason}`);
|
|
775
698
|
const cachedPkgs = [];
|
|
776
699
|
const uncached = [];
|
|
@@ -780,7 +703,8 @@ async function syncPackagesParallel(config) {
|
|
|
780
703
|
const globalConfig = readConfig();
|
|
781
704
|
const resolvedModel = await resolveAutoModel(config.model, config.yes);
|
|
782
705
|
if (uncached.length > 0 && !globalConfig.skipLlm && !(config.yes && !resolvedModel)) {
|
|
783
|
-
const
|
|
706
|
+
const updateCtx = config.mode === "update" ? aggregateUpdateCtx(uncached) : void 0;
|
|
707
|
+
const llmConfig = await selectLlmConfig(resolvedModel, void 0, updateCtx);
|
|
784
708
|
if (llmConfig?.promptOnly) {
|
|
785
709
|
for (const r of uncached) {
|
|
786
710
|
const slot = states.get(r.spec);
|
|
@@ -790,46 +714,25 @@ async function syncPackagesParallel(config) {
|
|
|
790
714
|
}
|
|
791
715
|
}
|
|
792
716
|
renderParallel(render);
|
|
793
|
-
for (const r of uncached)
|
|
794
|
-
const ui = createParallelUi(r.spec, render, getVersionKey(r.state.version));
|
|
795
|
-
await runEnhancePhase(r.state, llmConfig, {
|
|
796
|
-
agent: config.agent,
|
|
797
|
-
global: config.global,
|
|
798
|
-
force: config.force,
|
|
799
|
-
debug: config.debug
|
|
800
|
-
}, ui, cwd);
|
|
801
|
-
}
|
|
717
|
+
for (const r of uncached) await run.runEnhance(r.state, llmConfig);
|
|
802
718
|
} else if (llmConfig) {
|
|
803
719
|
p.log.step(getModelLabel(llmConfig.model));
|
|
804
|
-
for (const r of uncached)
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
720
|
+
for (const r of uncached) {
|
|
721
|
+
const displayName = specToName.get(r.spec) ?? r.spec;
|
|
722
|
+
states.set(r.spec, {
|
|
723
|
+
name: displayName,
|
|
724
|
+
status: "pending",
|
|
725
|
+
message: "Waiting...",
|
|
726
|
+
version: getVersionKey(r.state.version)
|
|
727
|
+
});
|
|
728
|
+
}
|
|
810
729
|
renderParallel(render);
|
|
811
|
-
const llmResults = await Promise.allSettled(uncached.map((r) => limit(
|
|
812
|
-
const ui = createParallelUi(r.spec, render, getVersionKey(r.state.version));
|
|
813
|
-
await runEnhancePhase(r.state, llmConfig, {
|
|
814
|
-
agent: config.agent,
|
|
815
|
-
global: config.global,
|
|
816
|
-
force: config.force,
|
|
817
|
-
debug: config.debug
|
|
818
|
-
}, ui, cwd);
|
|
819
|
-
})));
|
|
730
|
+
const llmResults = await Promise.allSettled(uncached.map((r) => limit(() => run.runEnhance(r.state, llmConfig))));
|
|
820
731
|
logUpdate.done();
|
|
821
732
|
const llmSucceeded = llmResults.filter((x) => x.status === "fulfilled").length;
|
|
822
733
|
p.log.success(`Enhanced ${llmSucceeded}/${uncached.length} skills with LLM`);
|
|
823
734
|
}
|
|
824
|
-
} else for (const r of ready)
|
|
825
|
-
const ui = createParallelUi(r.spec, render, getVersionKey(r.state.version));
|
|
826
|
-
await runEnhancePhase(r.state, null, {
|
|
827
|
-
agent: config.agent,
|
|
828
|
-
global: config.global,
|
|
829
|
-
force: config.force,
|
|
830
|
-
debug: config.debug
|
|
831
|
-
}, ui, cwd);
|
|
832
|
-
}
|
|
735
|
+
} else for (const r of ready) await run.runEnhance(r.state, null);
|
|
833
736
|
await ensureProjectFiles({
|
|
834
737
|
cwd,
|
|
835
738
|
agent: config.agent,
|
|
@@ -837,7 +740,7 @@ async function syncPackagesParallel(config) {
|
|
|
837
740
|
});
|
|
838
741
|
await shutdownWorker();
|
|
839
742
|
p.outro(`${pastVerb} ${ready.length}/${packages.length} packages`);
|
|
840
|
-
const { suggestPrepareHook } = await import("./
|
|
743
|
+
const { suggestPrepareHook } = await import("./prepare-hook.mjs");
|
|
841
744
|
try {
|
|
842
745
|
await suggestPrepareHook(cwd);
|
|
843
746
|
} catch (err) {
|
|
@@ -866,6 +769,53 @@ function aggregateUpdateCtx(ready) {
|
|
|
866
769
|
bumpType: maxDiff || void 0
|
|
867
770
|
};
|
|
868
771
|
}
|
|
772
|
+
async function handleMerge(state, config, cwd) {
|
|
773
|
+
const { identityName, storageName, version, resolved, baseDir, skillDir, skillDirName, existingLock } = state;
|
|
774
|
+
p.log.step(`Merging ${identityName} into ${skillDirName}`);
|
|
775
|
+
createReferenceCache(storageName, version).linkPkgNamed(skillDir, cwd);
|
|
776
|
+
const repoSlug = parseGitHubRepoSlug(resolved.repoUrl);
|
|
777
|
+
installSkill({
|
|
778
|
+
cwd,
|
|
779
|
+
agent: config.agent,
|
|
780
|
+
global: config.global,
|
|
781
|
+
baseDir,
|
|
782
|
+
skillDirName,
|
|
783
|
+
lock: {
|
|
784
|
+
packageName: identityName,
|
|
785
|
+
version,
|
|
786
|
+
repo: repoSlug,
|
|
787
|
+
source: existingLock.source,
|
|
788
|
+
syncedAt: todayIsoDate(),
|
|
789
|
+
generator: "skilld"
|
|
790
|
+
},
|
|
791
|
+
skipLinkAgents: true
|
|
792
|
+
});
|
|
793
|
+
const updatedLock = readLock(baseDir)?.skills[skillDirName];
|
|
794
|
+
const allPackages = parsePackageNames(updatedLock?.packages);
|
|
795
|
+
const relatedSkills = await findRelatedSkills(storageName, baseDir);
|
|
796
|
+
const existingStorageName = toStoragePackageName(existingLock.packageName);
|
|
797
|
+
const existingCache = createReferenceCache(existingStorageName, existingLock.version);
|
|
798
|
+
const pkgFiles = existingCache.keyFiles(cwd);
|
|
799
|
+
const shippedDocs = existingCache.hasShipped(cwd);
|
|
800
|
+
const features = getActiveFeatures();
|
|
801
|
+
writeGeneratedSkillMd(skillDir, {
|
|
802
|
+
name: existingLock.packageName,
|
|
803
|
+
version: existingLock.version,
|
|
804
|
+
relatedSkills,
|
|
805
|
+
hasIssues: features.issues && existsSync(skillRefsSection(skillDir, "issues")),
|
|
806
|
+
hasDiscussions: features.discussions && existsSync(skillRefsSection(skillDir, "discussions")),
|
|
807
|
+
hasReleases: features.releases && existsSync(skillRefsSection(skillDir, "releases")),
|
|
808
|
+
docsType: existingLock.source?.includes("llms.txt") ? "llms.txt" : "docs",
|
|
809
|
+
hasShippedDocs: shippedDocs,
|
|
810
|
+
pkgFiles,
|
|
811
|
+
dirName: skillDirName,
|
|
812
|
+
packages: allPackages,
|
|
813
|
+
features
|
|
814
|
+
});
|
|
815
|
+
const sharedDir = !config.global && getSharedSkillsDir(cwd);
|
|
816
|
+
if (sharedDir) linkSkillToAgents(skillDirName, sharedDir, cwd, config.agent);
|
|
817
|
+
p.outro(`Merged ${identityName} into ${skillDirName}`);
|
|
818
|
+
}
|
|
869
819
|
const RESOLVE_SOURCE_LABELS = {
|
|
870
820
|
"npm": "npm registry",
|
|
871
821
|
"github-docs": "GitHub versioned docs",
|
|
@@ -878,11 +828,12 @@ const RESOLVE_SOURCE_LABELS = {
|
|
|
878
828
|
};
|
|
879
829
|
function showResolveAttempts(attempts) {
|
|
880
830
|
if (attempts.length === 0) return;
|
|
881
|
-
p.log.message("
|
|
831
|
+
p.log.message(styleText("gray", "Doc resolution:"));
|
|
882
832
|
for (const attempt of attempts) {
|
|
883
|
-
const icon = attempt.status === "success" ? "
|
|
884
|
-
const
|
|
885
|
-
const
|
|
833
|
+
const icon = attempt.status === "success" ? styleText("green", "✓") : styleText("gray", "✗");
|
|
834
|
+
const label = RESOLVE_SOURCE_LABELS[attempt.source] ?? attempt.source;
|
|
835
|
+
const source = styleText("gray", label);
|
|
836
|
+
const msg = attempt.message ? ` ${styleText("gray", `— ${attempt.message}`)}` : "";
|
|
886
837
|
p.log.message(` ${icon} ${source}${msg}`);
|
|
887
838
|
}
|
|
888
839
|
}
|
|
@@ -924,7 +875,8 @@ async function syncCommand(state, opts) {
|
|
|
924
875
|
async function interactivePicker(state) {
|
|
925
876
|
const spin = timedSpinner();
|
|
926
877
|
spin.start("Detecting imports...");
|
|
927
|
-
const
|
|
878
|
+
const cwd = process.cwd();
|
|
879
|
+
const { packages: detected, error } = await detectImportedPackages(cwd);
|
|
928
880
|
const declaredMap = state.deps;
|
|
929
881
|
if (error || detected.length === 0) {
|
|
930
882
|
spin.stop(error ? `Detection failed: ${error}` : "No imports detected");
|
|
@@ -979,9 +931,10 @@ async function pickFromList(packages, state) {
|
|
|
979
931
|
}
|
|
980
932
|
async function runSimpleSync(packageSpec, config) {
|
|
981
933
|
const cwd = process.cwd();
|
|
982
|
-
const ui = createClackUi({ cwd });
|
|
983
934
|
const isEject = !!config.eject;
|
|
984
|
-
const
|
|
935
|
+
const run = createSyncRun({
|
|
936
|
+
cwd,
|
|
937
|
+
resolver: npmResolver,
|
|
985
938
|
agent: config.agent,
|
|
986
939
|
global: config.global,
|
|
987
940
|
mode: config.mode,
|
|
@@ -989,18 +942,25 @@ async function runSimpleSync(packageSpec, config) {
|
|
|
989
942
|
noSearch: config.noSearch,
|
|
990
943
|
name: config.name,
|
|
991
944
|
from: config.from,
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
945
|
+
debug: config.debug,
|
|
946
|
+
eject: config.eject,
|
|
947
|
+
defaultSections: DEFAULT_SECTIONS,
|
|
948
|
+
onMergeNeeded: (state) => handleMerge(state, {
|
|
949
|
+
agent: config.agent,
|
|
950
|
+
global: config.global
|
|
951
|
+
}, cwd)
|
|
952
|
+
});
|
|
953
|
+
bindClackUi(run.hooks, { cwd });
|
|
954
|
+
const base = await run.runBase(packageSpec);
|
|
955
|
+
if (base.kind === "shipped") {
|
|
995
956
|
p.outro(`Synced ${packageSpec}`);
|
|
996
957
|
return;
|
|
997
958
|
}
|
|
998
|
-
if (
|
|
999
|
-
const { unresolved } = result;
|
|
959
|
+
if (base.kind === "unresolved") {
|
|
1000
960
|
if (!isCrateSpec(packageSpec)) {
|
|
1001
|
-
const suggestions = await searchNpmPackages(
|
|
961
|
+
const suggestions = await searchNpmPackages(base.identityName);
|
|
1002
962
|
if (suggestions.length > 0) {
|
|
1003
|
-
showResolveAttempts(
|
|
963
|
+
showResolveAttempts(base.attempts);
|
|
1004
964
|
const selected = await p.select({
|
|
1005
965
|
message: "Did you mean one of these?",
|
|
1006
966
|
options: [...suggestions.map((s) => ({
|
|
@@ -1016,28 +976,16 @@ async function runSimpleSync(packageSpec, config) {
|
|
|
1016
976
|
return;
|
|
1017
977
|
}
|
|
1018
978
|
}
|
|
1019
|
-
showResolveAttempts(
|
|
979
|
+
showResolveAttempts(base.attempts);
|
|
1020
980
|
return;
|
|
1021
981
|
}
|
|
1022
|
-
if (
|
|
1023
|
-
|
|
1024
|
-
agent: config.agent,
|
|
1025
|
-
global: config.global
|
|
1026
|
-
}, cwd);
|
|
1027
|
-
return;
|
|
1028
|
-
}
|
|
1029
|
-
const { state } = result;
|
|
982
|
+
if (base.kind === "merged" || base.kind === "error") return;
|
|
983
|
+
const { state } = base;
|
|
1030
984
|
const globalConfig = readConfig();
|
|
1031
985
|
const resolvedModel = await resolveAutoModel(config.model, config.yes);
|
|
1032
986
|
let llmConfig = null;
|
|
1033
987
|
if (!state.allSectionsCached && !globalConfig.skipLlm && !(config.yes && !resolvedModel)) llmConfig = await selectLlmConfig(resolvedModel, void 0, state.updateCtx);
|
|
1034
|
-
await
|
|
1035
|
-
agent: config.agent,
|
|
1036
|
-
global: config.global,
|
|
1037
|
-
force: config.force,
|
|
1038
|
-
debug: config.debug,
|
|
1039
|
-
eject: config.eject
|
|
1040
|
-
}, ui, cwd);
|
|
988
|
+
await run.runEnhance(state, llmConfig);
|
|
1041
989
|
await shutdownWorker();
|
|
1042
990
|
const ejectMsg = isEject ? " (ejected)" : "";
|
|
1043
991
|
const relDir = relative(cwd, state.skillDir);
|
|
@@ -1055,447 +1003,6 @@ async function syncSinglePackage(packageSpec, config) {
|
|
|
1055
1003
|
}
|
|
1056
1004
|
return runSimpleSync(packageSpec, config);
|
|
1057
1005
|
}
|
|
1058
|
-
|
|
1059
|
-
meta: {
|
|
1060
|
-
name: "add",
|
|
1061
|
-
description: "Install skills (npm:<pkg>, crate:<name>, gh:<owner/repo>, @<curator>)"
|
|
1062
|
-
},
|
|
1063
|
-
args: {
|
|
1064
|
-
package: {
|
|
1065
|
-
type: "positional",
|
|
1066
|
-
description: "Package(s) to sync (space/comma-separated; npm:<pkg>, crate:<name>, or owner/repo)",
|
|
1067
|
-
required: true
|
|
1068
|
-
},
|
|
1069
|
-
skill: {
|
|
1070
|
-
type: "string",
|
|
1071
|
-
alias: "s",
|
|
1072
|
-
description: "Select specific skills from a git repo (comma-separated)",
|
|
1073
|
-
valueHint: "name"
|
|
1074
|
-
},
|
|
1075
|
-
...sharedArgs
|
|
1076
|
-
},
|
|
1077
|
-
async run({ args }) {
|
|
1078
|
-
const cwd = process.cwd();
|
|
1079
|
-
let agent = resolveAgent(args.agent);
|
|
1080
|
-
if (!agent) {
|
|
1081
|
-
agent = await promptForAgent();
|
|
1082
|
-
if (!agent) return;
|
|
1083
|
-
}
|
|
1084
|
-
const rawInputs = [...new Set([args.package, ...args._ || []].map((s) => s.trim()).filter(Boolean))];
|
|
1085
|
-
if (agent === "none") {
|
|
1086
|
-
const packages = [...new Set(rawInputs.flatMap((s) => s.split(/[,\s]+/)).map((s) => s.trim()).filter(Boolean))];
|
|
1087
|
-
for (const pkg of packages) await exportPortablePrompts(pkg, {
|
|
1088
|
-
force: args.force,
|
|
1089
|
-
agent: "none"
|
|
1090
|
-
});
|
|
1091
|
-
return;
|
|
1092
|
-
}
|
|
1093
|
-
if (!hasCompletedWizard()) await runWizard({ agent });
|
|
1094
|
-
const parsedSources = rawInputs.map(parseSkillInput);
|
|
1095
|
-
const gitSources = [];
|
|
1096
|
-
const npmEntries = [];
|
|
1097
|
-
const crateSpecs = [];
|
|
1098
|
-
const unsupported = [];
|
|
1099
|
-
for (const source of parsedSources) switch (source.type) {
|
|
1100
|
-
case "git":
|
|
1101
|
-
gitSources.push(source.source);
|
|
1102
|
-
break;
|
|
1103
|
-
case "npm":
|
|
1104
|
-
npmEntries.push({
|
|
1105
|
-
name: source.package,
|
|
1106
|
-
spec: source.tag ? `${source.package}@${source.tag}` : source.package
|
|
1107
|
-
});
|
|
1108
|
-
break;
|
|
1109
|
-
case "crate":
|
|
1110
|
-
crateSpecs.push(source.version ? `crate:${source.package}@${source.version}` : `crate:${source.package}`);
|
|
1111
|
-
break;
|
|
1112
|
-
case "bare":
|
|
1113
|
-
p.log.warn(`Bare names are deprecated. Use \x1B[36mnpm:${source.package}\x1B[0m instead.`);
|
|
1114
|
-
npmEntries.push({
|
|
1115
|
-
name: source.package,
|
|
1116
|
-
spec: source.tag ? `${source.package}@${source.tag}` : source.package
|
|
1117
|
-
});
|
|
1118
|
-
break;
|
|
1119
|
-
case "curator":
|
|
1120
|
-
unsupported.push(`@${source.handle} (curator)`);
|
|
1121
|
-
break;
|
|
1122
|
-
case "collection":
|
|
1123
|
-
unsupported.push(`@${source.handle}/${source.name} (collection)`);
|
|
1124
|
-
break;
|
|
1125
|
-
default: throw new Error(`Unhandled SkillSource type: ${JSON.stringify(source)}`);
|
|
1126
|
-
}
|
|
1127
|
-
if (unsupported.length > 0) {
|
|
1128
|
-
p.log.error(`Curator and collection installs are not yet available:\n ${unsupported.join("\n ")}\n\nFollow https://skilld.dev for launch updates.`);
|
|
1129
|
-
process.exitCode = 1;
|
|
1130
|
-
if (gitSources.length === 0 && npmEntries.length === 0 && crateSpecs.length === 0) return;
|
|
1131
|
-
}
|
|
1132
|
-
if (gitSources.length > 0) for (const source of gitSources) {
|
|
1133
|
-
const skillFilter = args.skill ? args.skill.split(/[,\s]+/).map((s) => s.trim()).filter(Boolean) : void 0;
|
|
1134
|
-
await syncGitSkills({
|
|
1135
|
-
source,
|
|
1136
|
-
global: args.global,
|
|
1137
|
-
agent,
|
|
1138
|
-
yes: args.yes,
|
|
1139
|
-
model: args.model,
|
|
1140
|
-
force: args.force,
|
|
1141
|
-
debug: args.debug,
|
|
1142
|
-
skillFilter
|
|
1143
|
-
});
|
|
1144
|
-
}
|
|
1145
|
-
if (npmEntries.length > 0) {
|
|
1146
|
-
const { syncRegistrySkill } = await import("./sync-registry.mjs");
|
|
1147
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1148
|
-
const dedupedEntries = npmEntries.filter((e) => {
|
|
1149
|
-
if (seen.has(e.name)) return false;
|
|
1150
|
-
seen.add(e.name);
|
|
1151
|
-
return true;
|
|
1152
|
-
});
|
|
1153
|
-
const fallbackPackages = [];
|
|
1154
|
-
for (const entry of dedupedEntries) {
|
|
1155
|
-
const result = await syncRegistrySkill({
|
|
1156
|
-
packageName: entry.name,
|
|
1157
|
-
agent,
|
|
1158
|
-
cwd
|
|
1159
|
-
});
|
|
1160
|
-
if (result) p.log.success(`Installed \x1B[36m${result.name}\x1B[0m from registry`);
|
|
1161
|
-
else fallbackPackages.push(entry.spec);
|
|
1162
|
-
}
|
|
1163
|
-
if (fallbackPackages.length > 0) {
|
|
1164
|
-
const state = await getProjectState(cwd);
|
|
1165
|
-
p.intro(introLine({
|
|
1166
|
-
state,
|
|
1167
|
-
agentId: agent || void 0
|
|
1168
|
-
}));
|
|
1169
|
-
await syncCommand(state, {
|
|
1170
|
-
packages: [...fallbackPackages, ...crateSpecs],
|
|
1171
|
-
global: args.global,
|
|
1172
|
-
agent,
|
|
1173
|
-
model: args.model,
|
|
1174
|
-
yes: args.yes,
|
|
1175
|
-
force: args.force,
|
|
1176
|
-
debug: args.debug
|
|
1177
|
-
});
|
|
1178
|
-
return;
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
if (crateSpecs.length > 0) {
|
|
1182
|
-
const state = await getProjectState(cwd);
|
|
1183
|
-
p.intro(introLine({
|
|
1184
|
-
state,
|
|
1185
|
-
agentId: agent || void 0
|
|
1186
|
-
}));
|
|
1187
|
-
await syncCommand(state, {
|
|
1188
|
-
packages: crateSpecs,
|
|
1189
|
-
global: args.global,
|
|
1190
|
-
agent,
|
|
1191
|
-
model: args.model,
|
|
1192
|
-
yes: args.yes,
|
|
1193
|
-
force: args.force,
|
|
1194
|
-
debug: args.debug
|
|
1195
|
-
});
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
});
|
|
1199
|
-
const ejectCommandDef = defineCommand({
|
|
1200
|
-
meta: {
|
|
1201
|
-
name: "eject",
|
|
1202
|
-
description: "Eject skill with references as real files (portable, no symlinks)"
|
|
1203
|
-
},
|
|
1204
|
-
args: {
|
|
1205
|
-
package: {
|
|
1206
|
-
type: "positional",
|
|
1207
|
-
description: "Package to eject",
|
|
1208
|
-
required: true
|
|
1209
|
-
},
|
|
1210
|
-
name: {
|
|
1211
|
-
type: "string",
|
|
1212
|
-
alias: "n",
|
|
1213
|
-
description: "Custom skill directory name (default: derived from package)"
|
|
1214
|
-
},
|
|
1215
|
-
out: {
|
|
1216
|
-
type: "string",
|
|
1217
|
-
alias: "o",
|
|
1218
|
-
description: "Output directory path override"
|
|
1219
|
-
},
|
|
1220
|
-
from: {
|
|
1221
|
-
type: "string",
|
|
1222
|
-
description: "Collect releases/issues/discussions from this date onward (YYYY-MM-DD)"
|
|
1223
|
-
},
|
|
1224
|
-
search: {
|
|
1225
|
-
type: "boolean",
|
|
1226
|
-
description: "Build search index / embeddings (use --no-search to skip)",
|
|
1227
|
-
default: true
|
|
1228
|
-
},
|
|
1229
|
-
...sharedArgs
|
|
1230
|
-
},
|
|
1231
|
-
async run({ args }) {
|
|
1232
|
-
const cwd = process.cwd();
|
|
1233
|
-
const resolved = resolveAgent(args.agent);
|
|
1234
|
-
const agent = resolved && resolved !== "none" ? resolved : "claude-code";
|
|
1235
|
-
if (!hasCompletedWizard()) await runWizard({ agent });
|
|
1236
|
-
const state = await getProjectState(cwd);
|
|
1237
|
-
p.intro(introLine({
|
|
1238
|
-
state,
|
|
1239
|
-
agentId: agent || void 0
|
|
1240
|
-
}));
|
|
1241
|
-
return syncCommand(state, {
|
|
1242
|
-
packages: [args.package],
|
|
1243
|
-
global: args.global,
|
|
1244
|
-
agent,
|
|
1245
|
-
model: args.model,
|
|
1246
|
-
yes: args.yes,
|
|
1247
|
-
force: args.force,
|
|
1248
|
-
debug: args.debug,
|
|
1249
|
-
eject: args.out || true,
|
|
1250
|
-
name: args.name,
|
|
1251
|
-
from: args.from,
|
|
1252
|
-
noSearch: !args.search
|
|
1253
|
-
});
|
|
1254
|
-
}
|
|
1255
|
-
});
|
|
1256
|
-
const updateCommandDef = defineCommand({
|
|
1257
|
-
meta: {
|
|
1258
|
-
name: "update",
|
|
1259
|
-
description: "Update outdated skills"
|
|
1260
|
-
},
|
|
1261
|
-
args: {
|
|
1262
|
-
package: {
|
|
1263
|
-
type: "positional",
|
|
1264
|
-
description: "Package(s) to update (space or comma-separated). Without args, syncs all outdated.",
|
|
1265
|
-
required: false
|
|
1266
|
-
},
|
|
1267
|
-
background: {
|
|
1268
|
-
type: "boolean",
|
|
1269
|
-
alias: "b",
|
|
1270
|
-
description: "Run in background (detached process, non-interactive)",
|
|
1271
|
-
default: false
|
|
1272
|
-
},
|
|
1273
|
-
...sharedArgs
|
|
1274
|
-
},
|
|
1275
|
-
async run({ args }) {
|
|
1276
|
-
const cwd = process.cwd();
|
|
1277
|
-
if (args.background) {
|
|
1278
|
-
const { spawn } = await import("node:child_process");
|
|
1279
|
-
const updateArgs = [
|
|
1280
|
-
"update",
|
|
1281
|
-
...args.package ? [args.package] : [],
|
|
1282
|
-
...args.agent ? ["--agent", args.agent] : [],
|
|
1283
|
-
...args.model ? ["--model", args.model] : []
|
|
1284
|
-
];
|
|
1285
|
-
spawn(process.execPath, [process.argv[1], ...updateArgs], {
|
|
1286
|
-
cwd,
|
|
1287
|
-
detached: true,
|
|
1288
|
-
stdio: "ignore"
|
|
1289
|
-
}).unref();
|
|
1290
|
-
return;
|
|
1291
|
-
}
|
|
1292
|
-
const silent = !isInteractive();
|
|
1293
|
-
let agent = resolveAgent(args.agent);
|
|
1294
|
-
if (!agent) {
|
|
1295
|
-
agent = await promptForAgent();
|
|
1296
|
-
if (!agent) return;
|
|
1297
|
-
}
|
|
1298
|
-
if (agent === "none") {
|
|
1299
|
-
const state = await getProjectState(cwd);
|
|
1300
|
-
const packages = args.package ? Array.from(new Set([args.package, ...args._ || []].flatMap((s) => s.split(/[,\s]+/)).map((s) => s.trim()).filter(Boolean)), (s) => resolveSkillName(s)).filter((s) => s !== null) : state.outdated.map((s) => s.packageName || s.name);
|
|
1301
|
-
if (packages.length === 0) {
|
|
1302
|
-
if (!silent) p.log.success("All skills up to date");
|
|
1303
|
-
return;
|
|
1304
|
-
}
|
|
1305
|
-
for (const pkg of packages) await exportPortablePrompts(pkg, {
|
|
1306
|
-
force: args.force,
|
|
1307
|
-
agent: "none"
|
|
1308
|
-
});
|
|
1309
|
-
return;
|
|
1310
|
-
}
|
|
1311
|
-
const config = readConfig();
|
|
1312
|
-
const state = await getProjectState(cwd);
|
|
1313
|
-
if (!silent) {
|
|
1314
|
-
const generators = getInstalledGenerators();
|
|
1315
|
-
p.intro(introLine({
|
|
1316
|
-
state,
|
|
1317
|
-
generators,
|
|
1318
|
-
modelId: config.model,
|
|
1319
|
-
agentId: config.agent || agent || void 0
|
|
1320
|
-
}));
|
|
1321
|
-
}
|
|
1322
|
-
if (args.package) {
|
|
1323
|
-
const raw = [...new Set([args.package, ...args._ || []].flatMap((s) => s.split(/[,\s]+/)).map((s) => s.trim()).filter(Boolean))];
|
|
1324
|
-
const packages = [];
|
|
1325
|
-
for (const r of raw) {
|
|
1326
|
-
const name = resolveSkillName(r);
|
|
1327
|
-
if (!name) {
|
|
1328
|
-
p.log.warn(`Cannot update \x1B[36m${r}\x1B[0m: curator/collection inputs are not addressable here.`);
|
|
1329
|
-
continue;
|
|
1330
|
-
}
|
|
1331
|
-
packages.push(name);
|
|
1332
|
-
}
|
|
1333
|
-
if (packages.length === 0) return;
|
|
1334
|
-
return syncCommand(state, {
|
|
1335
|
-
packages,
|
|
1336
|
-
global: args.global,
|
|
1337
|
-
agent,
|
|
1338
|
-
model: args.model || (silent ? config.model : void 0),
|
|
1339
|
-
yes: args.yes || silent,
|
|
1340
|
-
force: args.force,
|
|
1341
|
-
debug: args.debug,
|
|
1342
|
-
mode: "update"
|
|
1343
|
-
});
|
|
1344
|
-
}
|
|
1345
|
-
const crateSpecs = state.skills.map((s) => s.info?.packageName).filter((name) => !!name && name.startsWith("crate:"));
|
|
1346
|
-
if (state.outdated.length === 0 && crateSpecs.length === 0) {
|
|
1347
|
-
p.log.success("All skills up to date");
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
return syncCommand(state, {
|
|
1351
|
-
packages: [...state.outdated.map((s) => s.packageName || s.name), ...crateSpecs],
|
|
1352
|
-
global: args.global,
|
|
1353
|
-
agent,
|
|
1354
|
-
model: args.model || (silent ? config.model : void 0),
|
|
1355
|
-
yes: args.yes || silent,
|
|
1356
|
-
force: args.force,
|
|
1357
|
-
debug: args.debug,
|
|
1358
|
-
mode: "update"
|
|
1359
|
-
});
|
|
1360
|
-
}
|
|
1361
|
-
});
|
|
1362
|
-
async function exportPortablePrompts(packageSpec, opts) {
|
|
1363
|
-
const sections = opts.sections ?? DEFAULT_SECTIONS;
|
|
1364
|
-
const spin = timedSpinner();
|
|
1365
|
-
spin.start(`Resolving ${packageSpec}`);
|
|
1366
|
-
const cwd = process.cwd();
|
|
1367
|
-
const { packageName, localVersion, resolved } = await resolvePackageOrCrate(packageSpec, {
|
|
1368
|
-
cwd,
|
|
1369
|
-
onProgress: (label) => spin.message(`${packageSpec}: ${label}`)
|
|
1370
|
-
});
|
|
1371
|
-
if (!resolved) {
|
|
1372
|
-
spin.stop(`Could not find docs for: ${packageSpec}`);
|
|
1373
|
-
return;
|
|
1374
|
-
}
|
|
1375
|
-
const version = localVersion || resolved.version || "latest";
|
|
1376
|
-
const cache = createReferenceCache(packageName, version);
|
|
1377
|
-
const useCache = !opts.force && cache.has();
|
|
1378
|
-
if (!existsSync(join(cwd, "node_modules", packageName))) {
|
|
1379
|
-
spin.message(`Downloading ${packageName}@${version} dist`);
|
|
1380
|
-
await fetchPkgDist(packageName, version);
|
|
1381
|
-
}
|
|
1382
|
-
spin.stop(`Resolved ${packageName}@${useCache ? cache.versionKey : version}`);
|
|
1383
|
-
cache.ensure();
|
|
1384
|
-
const skillDirName = computeSkillDirName(packageName);
|
|
1385
|
-
const features = getActiveFeatures();
|
|
1386
|
-
const agent = opts.agent === "none" ? null : opts.agent ?? await import("./detect2.mjs").then((m) => m.detectTargetAgent());
|
|
1387
|
-
const baseDir = agent ? resolveBaseDir(cwd, agent, false) : join(cwd, ".claude", "skills");
|
|
1388
|
-
const skillDir = opts.out ? resolve(cwd, opts.out) : join(baseDir, skillDirName);
|
|
1389
|
-
if (existsSync(skillDir) && !opts.force) {
|
|
1390
|
-
const existing = Object.values(SECTION_OUTPUT_FILES).filter((f) => existsSync(join(skillDir, f)));
|
|
1391
|
-
if (existing.length > 0) p.log.warn(`Overwriting existing output files in ${relative(cwd, skillDir)}: ${existing.join(", ")}`);
|
|
1392
|
-
}
|
|
1393
|
-
mkdirSync(skillDir, { recursive: true });
|
|
1394
|
-
const resSpin = timedSpinner();
|
|
1395
|
-
resSpin.start("Fetching resources");
|
|
1396
|
-
const resources = await fetchAndCacheResources({
|
|
1397
|
-
packageName,
|
|
1398
|
-
resolved,
|
|
1399
|
-
version,
|
|
1400
|
-
useCache,
|
|
1401
|
-
features,
|
|
1402
|
-
onProgress: (msg) => resSpin.message(msg)
|
|
1403
|
-
});
|
|
1404
|
-
resSpin.stop("Resources ready");
|
|
1405
|
-
for (const w of resources.warnings) p.log.warn(`\x1B[33m${w}\x1B[0m`);
|
|
1406
|
-
const { hasChangelog, shippedDocs, pkgFiles, relatedSkills } = await prepareSkillReferences({
|
|
1407
|
-
packageName,
|
|
1408
|
-
version,
|
|
1409
|
-
cwd,
|
|
1410
|
-
skillDir,
|
|
1411
|
-
resources,
|
|
1412
|
-
features,
|
|
1413
|
-
baseDir: join(skillDir, "..")
|
|
1414
|
-
});
|
|
1415
|
-
const docFiles = listReferenceFiles(skillDir);
|
|
1416
|
-
const prompts = buildAllSectionPrompts({
|
|
1417
|
-
packageName,
|
|
1418
|
-
skillDir,
|
|
1419
|
-
version,
|
|
1420
|
-
hasIssues: resources.hasIssues,
|
|
1421
|
-
hasDiscussions: resources.hasDiscussions,
|
|
1422
|
-
hasReleases: resources.hasReleases,
|
|
1423
|
-
hasChangelog,
|
|
1424
|
-
docFiles,
|
|
1425
|
-
docsType: resources.docsType,
|
|
1426
|
-
hasShippedDocs: shippedDocs,
|
|
1427
|
-
pkgFiles,
|
|
1428
|
-
features,
|
|
1429
|
-
sections
|
|
1430
|
-
});
|
|
1431
|
-
cache.eject(skillDir, cwd, resources.docsType, {
|
|
1432
|
-
features,
|
|
1433
|
-
repoInfo: resources.repoInfo
|
|
1434
|
-
});
|
|
1435
|
-
cache.clearSkillInternal(skillDir);
|
|
1436
|
-
for (const [section, prompt] of prompts) {
|
|
1437
|
-
const portable = portabilizePrompt(prompt, section);
|
|
1438
|
-
writeFileSync(join(skillDir, `PROMPT_${section}.md`), portable);
|
|
1439
|
-
}
|
|
1440
|
-
writeGeneratedSkillMd(skillDir, {
|
|
1441
|
-
name: packageName,
|
|
1442
|
-
version,
|
|
1443
|
-
releasedAt: resolved.releasedAt,
|
|
1444
|
-
description: resolved.description,
|
|
1445
|
-
distTags: resolved.distTags,
|
|
1446
|
-
relatedSkills,
|
|
1447
|
-
hasIssues: resources.hasIssues,
|
|
1448
|
-
hasDiscussions: resources.hasDiscussions,
|
|
1449
|
-
hasReleases: resources.hasReleases,
|
|
1450
|
-
hasChangelog,
|
|
1451
|
-
docsType: resources.docsType,
|
|
1452
|
-
hasShippedDocs: shippedDocs,
|
|
1453
|
-
pkgFiles,
|
|
1454
|
-
repoUrl: resolved.repoUrl,
|
|
1455
|
-
features,
|
|
1456
|
-
eject: true
|
|
1457
|
-
});
|
|
1458
|
-
const repoSlug = parseGitHubRepoSlug(resolved.repoUrl);
|
|
1459
|
-
if (agent) {
|
|
1460
|
-
const { shared } = installSkill({
|
|
1461
|
-
cwd,
|
|
1462
|
-
agent,
|
|
1463
|
-
global: false,
|
|
1464
|
-
baseDir,
|
|
1465
|
-
skillDirName,
|
|
1466
|
-
lock: {
|
|
1467
|
-
packageName,
|
|
1468
|
-
version,
|
|
1469
|
-
repo: repoSlug,
|
|
1470
|
-
source: resources.docSource,
|
|
1471
|
-
syncedAt: todayIsoDate(),
|
|
1472
|
-
generator: "skilld"
|
|
1473
|
-
}
|
|
1474
|
-
});
|
|
1475
|
-
await ensureProjectFiles({
|
|
1476
|
-
cwd,
|
|
1477
|
-
agent,
|
|
1478
|
-
global: false,
|
|
1479
|
-
shared
|
|
1480
|
-
});
|
|
1481
|
-
} else {
|
|
1482
|
-
writeLock(baseDir, skillDirName, {
|
|
1483
|
-
packageName,
|
|
1484
|
-
version,
|
|
1485
|
-
repo: repoSlug,
|
|
1486
|
-
source: resources.docSource,
|
|
1487
|
-
syncedAt: todayIsoDate(),
|
|
1488
|
-
generator: "skilld"
|
|
1489
|
-
});
|
|
1490
|
-
await ensureGitignore(".claude/skills", cwd, false);
|
|
1491
|
-
}
|
|
1492
|
-
const relDir = relative(cwd, skillDir);
|
|
1493
|
-
const sectionList = [...prompts.keys()];
|
|
1494
|
-
p.log.success(`Skill installed to ${relDir}`);
|
|
1495
|
-
const promptFiles = sectionList.map((s) => `PROMPT_${s}.md`).join(", ");
|
|
1496
|
-
const outputFileList = sectionList.map((s) => SECTION_OUTPUT_FILES[s]).join(", ");
|
|
1497
|
-
p.log.info(`Have your agent enhance the skill. Give it this prompt:\n\x1B[2m\x1B[3m Read each prompt file (${promptFiles}) in ${relDir}/, read the\n referenced files, then write your output to the matching file (${outputFileList}).\n When done, run: skilld assemble\x1B[0m`);
|
|
1498
|
-
}
|
|
1499
|
-
export { updateCommandDef as a, syncCommand as i, ejectCommandDef as n, exportPortablePrompts as r, addCommandDef as t };
|
|
1006
|
+
export { bindClackUi, createGithubResolver, createSyncRun, syncCommand };
|
|
1500
1007
|
|
|
1501
1008
|
//# sourceMappingURL=sync.mjs.map
|