skilld 1.7.3 → 2.0.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/dist/_chunks/add.mjs +66 -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 +737 -619
- 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 +11 -8
- package/dist/_chunks/assemble.mjs.map +1 -1
- package/dist/_chunks/author.mjs +77 -131
- package/dist/_chunks/author.mjs.map +1 -1
- package/dist/_chunks/cache.mjs +320 -54
- package/dist/_chunks/cache.mjs.map +1 -1
- package/dist/_chunks/cache2.mjs +7 -6
- package/dist/_chunks/cache2.mjs.map +1 -1
- package/dist/_chunks/client.mjs +117 -0
- package/dist/_chunks/client.mjs.map +1 -0
- package/dist/_chunks/core.mjs +7 -4
- package/dist/_chunks/detect.mjs +54 -44
- package/dist/_chunks/detect.mjs.map +1 -1
- package/dist/_chunks/eject.mjs +69 -0
- package/dist/_chunks/eject.mjs.map +1 -0
- package/dist/_chunks/embedding-cache2.mjs +2 -2
- package/dist/_chunks/env.mjs +19 -0
- package/dist/_chunks/env.mjs.map +1 -0
- package/dist/_chunks/install-many.mjs +376 -0
- package/dist/_chunks/install-many.mjs.map +1 -0
- package/dist/_chunks/install.mjs +86 -371
- 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 +2 -2
- package/dist/_chunks/list.mjs.map +1 -1
- package/dist/_chunks/lockfile.mjs +31 -7
- package/dist/_chunks/lockfile.mjs.map +1 -1
- package/dist/_chunks/login.mjs +233 -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 +79 -54
- 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 +73 -0
- package/dist/_chunks/monorepo.mjs.map +1 -0
- package/dist/_chunks/package-json.mjs.map +1 -1
- package/dist/_chunks/paths.mjs +47 -0
- package/dist/_chunks/paths.mjs.map +1 -0
- package/dist/_chunks/pipeline.mjs +985 -0
- package/dist/_chunks/pipeline.mjs.map +1 -0
- package/dist/_chunks/pool2.mjs +2 -2
- 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 +47 -3
- package/dist/_chunks/prepare.mjs.map +1 -1
- package/dist/_chunks/prepare2.mjs +9 -8
- package/dist/_chunks/prepare2.mjs.map +1 -1
- package/dist/_chunks/prompts.mjs +784 -26
- package/dist/_chunks/prompts.mjs.map +1 -1
- package/dist/_chunks/pull.mjs +219 -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 +12 -9
- package/dist/_chunks/sanitize.mjs.map +1 -1
- package/dist/_chunks/search-helpers.mjs +9 -8
- package/dist/_chunks/search-helpers.mjs.map +1 -1
- package/dist/_chunks/search-interactive.mjs +23 -20
- package/dist/_chunks/search-interactive.mjs.map +1 -1
- package/dist/_chunks/search.mjs +3 -4
- package/dist/_chunks/search.mjs.map +1 -1
- package/dist/_chunks/{sources.mjs → semver.mjs} +1128 -838
- package/dist/_chunks/semver.mjs.map +1 -0
- package/dist/_chunks/skill-installer.mjs +2 -0
- package/dist/_chunks/skill-installer2.mjs +154 -0
- package/dist/_chunks/skill-installer2.mjs.map +1 -0
- package/dist/_chunks/skills.mjs +12 -12
- 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 +761 -1349
- package/dist/_chunks/sync.mjs.map +1 -1
- package/dist/_chunks/sync2.mjs +2 -3
- package/dist/_chunks/telemetry.mjs +26 -0
- package/dist/_chunks/telemetry.mjs.map +1 -0
- package/dist/_chunks/uninstall.mjs +15 -13
- package/dist/_chunks/uninstall.mjs.map +1 -1
- package/dist/_chunks/update.mjs +171 -0
- package/dist/_chunks/update.mjs.map +1 -0
- package/dist/_chunks/upload.mjs +4 -4
- package/dist/_chunks/validate.mjs +1 -1
- package/dist/_chunks/version.mjs +16 -27
- 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/cli.mjs +77 -59
- package/dist/cli.mjs.map +1 -1
- package/dist/prepare.mjs +5 -4
- 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/package.json +20 -29
- 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/config.mjs +0 -122
- package/dist/_chunks/config.mjs.map +0 -1
- package/dist/_chunks/index.d.mts +0 -151
- package/dist/_chunks/index.d.mts.map +0 -1
- package/dist/_chunks/index2.d.mts +0 -44
- package/dist/_chunks/index2.d.mts.map +0 -1
- package/dist/_chunks/index3.d.mts +0 -589
- package/dist/_chunks/index3.d.mts.map +0 -1
- package/dist/_chunks/prefix.mjs +0 -108
- package/dist/_chunks/prefix.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/shared.mjs +0 -503
- package/dist/_chunks/shared.mjs.map +0 -1
- package/dist/_chunks/skill.mjs +0 -329
- package/dist/_chunks/skill.mjs.map +0 -1
- package/dist/_chunks/sources.mjs.map +0 -1
- package/dist/_chunks/sync-registry.mjs +0 -59
- package/dist/_chunks/sync-registry.mjs.map +0 -1
- package/dist/_chunks/sync-shared.mjs +0 -2
- package/dist/_chunks/sync-shared2.mjs +0 -1020
- package/dist/_chunks/sync-shared2.mjs.map +0 -1
- package/dist/_chunks/types.d.mts +0 -88
- package/dist/_chunks/types.d.mts.map +0 -1
- package/dist/_chunks/wizard.mjs.map +0 -1
- package/dist/agent/index.d.mts +0 -346
- package/dist/agent/index.d.mts.map +0 -1
- package/dist/agent/index.mjs +0 -5
- package/dist/cache/index.d.mts +0 -2
- package/dist/cache/index.mjs +0 -4
- package/dist/index.d.mts +0 -5
- package/dist/index.mjs +0 -5
- package/dist/retriv/index.d.mts +0 -3
- package/dist/retriv/index.mjs +0 -2
- package/dist/sources/index.d.mts +0 -2
- package/dist/sources/index.mjs +0 -3
- package/dist/types.d.mts +0 -4
- package/dist/types.mjs +0 -1
package/dist/_chunks/install.mjs
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import { a as getModelLabel, r as createToolProgress, s as optimizeDocs } from "./agent.mjs";
|
|
2
|
-
import { c as getRepoCacheDir, s as getPackageDbPath, t as getCacheDir } from "./version.mjs";
|
|
3
|
-
import { i as readPackageJsonSafe } from "./package-json.mjs";
|
|
4
|
-
import { n as linkShippedSkill, r as resolvePkgDir, t as getShippedSkills } from "./prepare.mjs";
|
|
5
|
-
import { n as sanitizeMarkdown } from "./sanitize.mjs";
|
|
6
|
-
import { a as hasShippedDocs, c as isReadmeOnlyCache, d as linkPkgNamed, h as readCachedDocs, i as getPkgKeyFiles, m as listReferenceFiles, o as inferDocsTypeFromCache, r as ensureCacheDir, s as isCached, v as writeToCache } from "./cache.mjs";
|
|
7
|
-
import { r as createIndex, t as SearchDepsUnavailableError } from "./retriv.mjs";
|
|
8
|
-
import { n as getSharedSkillsDir } from "./shared.mjs";
|
|
9
|
-
import { A as filterFrameworkDocs, E as fetchGitDocs, I as fetchLlmsTxt, P as downloadLlmsDocs, Q as fetchGitHubRaw, R as normalizeLlmsLinks, _ as resolveEntryFiles, d as resolvePackageDocs, j as isShallowGitDocs, k as fetchReadmeContent, m as fetchGitSkills, rt as parseGitHubUrl } from "./sources.mjs";
|
|
10
1
|
import { a as targets } from "./detect.mjs";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
2
|
+
import { i as getModelLabel } from "./agent.mjs";
|
|
3
|
+
import { h as timedSpinner, i as linkSkillToAgents, n as writeSkillMd } from "./prompts.mjs";
|
|
4
|
+
import { f as getSharedSkillsDir, m as skillInternalDir } from "./paths.mjs";
|
|
5
|
+
import { n as sanitizeMarkdown } from "./sanitize.mjs";
|
|
6
|
+
import { a as resolvePkgDir, i as linkShippedSkill, n as getShippedSkills, s as getCacheDir } from "./prepare.mjs";
|
|
7
|
+
import { i as readPackageJsonSafe } from "./package-json.mjs";
|
|
8
|
+
import { d as readConfig, o as defaultFeatures, r as ensureCacheDir, t as createReferenceCache } from "./cache.mjs";
|
|
9
|
+
import { n as promptForAgent, r as resolveAgent } from "./agent-prompt.mjs";
|
|
10
|
+
import { t as sharedArgs } from "./args.mjs";
|
|
11
|
+
import { _ as fetchGitSkills, a as resolvePackageDocs, l as toStoragePackageName } from "./semver.mjs";
|
|
12
|
+
import { a as parsePackageNames, c as readLock, d as writeLock, i as mergeLocks, o as parsePackages, u as syncLockfilesToDirs } from "./lockfile.mjs";
|
|
13
|
+
import { a as prepareSkillReferences, c as selectLlmConfig, f as writeBaseSkill, p as writePromptFiles, r as fetchAndCacheResources, t as buildSkillContext, u as enhanceSkillWithLLM } from "./pipeline.mjs";
|
|
17
14
|
import { n as shutdownWorker } from "./pool2.mjs";
|
|
18
|
-
import "
|
|
19
|
-
import {
|
|
20
|
-
import { dirname, join } from "pathe";
|
|
21
|
-
import { copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
|
|
16
|
+
import { styleText } from "node:util";
|
|
22
17
|
import * as p from "@clack/prompts";
|
|
23
18
|
import { defineCommand } from "citty";
|
|
19
|
+
import { dirname, join } from "pathe";
|
|
20
|
+
import { homedir } from "node:os";
|
|
21
|
+
const STATIC_REGEX_1 = /ungh:\/\/([^/]+)\/(.+)/;
|
|
24
22
|
async function installCommand(opts) {
|
|
25
23
|
const cwd = process.cwd();
|
|
26
24
|
const agent = targets[opts.agent];
|
|
@@ -46,7 +44,7 @@ async function installCommand(opts) {
|
|
|
46
44
|
continue;
|
|
47
45
|
}
|
|
48
46
|
const skillDir = join(skillsDir, name);
|
|
49
|
-
const referencesPath =
|
|
47
|
+
const referencesPath = skillInternalDir(skillDir);
|
|
50
48
|
const skillMdPath = join(skillDir, "SKILL.md");
|
|
51
49
|
if (!existsSync(skillDir) || !existsSync(skillMdPath) || !existsSync(referencesPath) || hasStaleReferences(referencesPath, toStoragePackageName(info.packageName || name), info.version, features)) toRestore.push({
|
|
52
50
|
name,
|
|
@@ -59,11 +57,11 @@ async function installCommand(opts) {
|
|
|
59
57
|
}
|
|
60
58
|
p.log.info(`Restoring ${toRestore.length} references`);
|
|
61
59
|
ensureCacheDir();
|
|
62
|
-
const allSkillNames = skills.map(([, info]) => info.packageName || "").filter(Boolean);
|
|
63
60
|
const regenerated = [];
|
|
64
61
|
for (const { name, info } of toRestore) {
|
|
65
62
|
const version = info.version;
|
|
66
|
-
const
|
|
63
|
+
const identityName = info.packageName || unsanitizeName(name, info.source);
|
|
64
|
+
const pkgName = toStoragePackageName(identityName);
|
|
67
65
|
if (info.source === "shipped") {
|
|
68
66
|
const match = getShippedSkills(pkgName, cwd, version).find((s) => s.skillName === name);
|
|
69
67
|
if (match) {
|
|
@@ -97,260 +95,75 @@ async function installCommand(opts) {
|
|
|
97
95
|
continue;
|
|
98
96
|
}
|
|
99
97
|
const skillDir = join(skillsDir, name);
|
|
100
|
-
const
|
|
101
|
-
const globalCachePath = getCacheDir(pkgName, version);
|
|
98
|
+
const cache = createReferenceCache(pkgName, version);
|
|
102
99
|
const spin = timedSpinner();
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
linkPkgSymlink(referencesPath, pkgName, cwd, version);
|
|
108
|
-
for (const pkg of parsePackages(info.packages)) linkPkgNamed(skillDir, pkg.name, cwd, pkg.version);
|
|
109
|
-
if (!pkgHasShippedDocs(pkgName, cwd, version) && !isReadmeOnlyCache(globalCachePath)) {
|
|
110
|
-
const docsLink = join(referencesPath, "docs");
|
|
111
|
-
const cachedDocs = join(globalCachePath, "docs");
|
|
112
|
-
if (existsSync(docsLink)) unlinkSync(docsLink);
|
|
113
|
-
if (existsSync(cachedDocs)) symlinkSync(cachedDocs, docsLink, "junction");
|
|
114
|
-
}
|
|
115
|
-
const repoGh = info.repo ? parseGitHubUrl(`https://github.com/${info.repo}`) : null;
|
|
116
|
-
const repoCachePath = repoGh ? getRepoCacheDir(repoGh.owner, repoGh.repo) : null;
|
|
117
|
-
if (features.issues) {
|
|
118
|
-
const issuesLink = join(referencesPath, "issues");
|
|
119
|
-
const repoIssues = repoCachePath ? join(repoCachePath, "issues") : null;
|
|
120
|
-
const cachedIssues = repoIssues && existsSync(repoIssues) ? repoIssues : join(globalCachePath, "issues");
|
|
121
|
-
if (existsSync(issuesLink)) unlinkSync(issuesLink);
|
|
122
|
-
if (existsSync(cachedIssues)) symlinkSync(cachedIssues, issuesLink, "junction");
|
|
123
|
-
}
|
|
124
|
-
if (features.discussions) {
|
|
125
|
-
const discussionsLink = join(referencesPath, "discussions");
|
|
126
|
-
const repoDiscussions = repoCachePath ? join(repoCachePath, "discussions") : null;
|
|
127
|
-
const cachedDiscussions = repoDiscussions && existsSync(repoDiscussions) ? repoDiscussions : join(globalCachePath, "discussions");
|
|
128
|
-
if (existsSync(discussionsLink)) unlinkSync(discussionsLink);
|
|
129
|
-
if (existsSync(cachedDiscussions)) symlinkSync(cachedDiscussions, discussionsLink, "junction");
|
|
130
|
-
}
|
|
131
|
-
if (features.releases) {
|
|
132
|
-
const releasesLink = join(referencesPath, "releases");
|
|
133
|
-
const repoReleases = repoCachePath ? join(repoCachePath, "releases") : null;
|
|
134
|
-
const cachedReleases = repoReleases && existsSync(repoReleases) ? repoReleases : join(globalCachePath, "releases");
|
|
135
|
-
if (existsSync(releasesLink)) unlinkSync(releasesLink);
|
|
136
|
-
if (existsSync(cachedReleases)) symlinkSync(cachedReleases, releasesLink, "junction");
|
|
137
|
-
}
|
|
138
|
-
const sectionsLink = join(referencesPath, "sections");
|
|
139
|
-
const cachedSections = join(globalCachePath, "sections");
|
|
140
|
-
if (existsSync(sectionsLink)) unlinkSync(sectionsLink);
|
|
141
|
-
if (existsSync(cachedSections)) symlinkSync(cachedSections, sectionsLink, "junction");
|
|
142
|
-
if (features.search && !existsSync(getPackageDbPath(pkgName, version))) {
|
|
143
|
-
spin.message(`Indexing ${name}`);
|
|
144
|
-
await indexResources({
|
|
145
|
-
packageName: pkgName,
|
|
146
|
-
version,
|
|
147
|
-
cwd,
|
|
148
|
-
docsToIndex: readCachedDocs(pkgName, version).map((d) => ({
|
|
149
|
-
id: d.path,
|
|
150
|
-
content: d.content,
|
|
151
|
-
metadata: {
|
|
152
|
-
package: pkgName,
|
|
153
|
-
source: d.path,
|
|
154
|
-
type: classifyCachedDoc(d.path).type
|
|
155
|
-
}
|
|
156
|
-
})),
|
|
157
|
-
features,
|
|
158
|
-
onProgress: (msg) => spin.message(msg)
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
if (!copyFromExistingAgent(skillDir, name, allSkillsDirs)) {
|
|
162
|
-
if (regenerateBaseSkillMd(skillDir, pkgName, version, cwd, allSkillNames, info.source, info.packages)) regenerated.push({
|
|
163
|
-
name,
|
|
164
|
-
pkgName,
|
|
165
|
-
version,
|
|
166
|
-
skillDir,
|
|
167
|
-
packages: info.packages
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
spin.stop(`Linked ${name}`);
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
spin.start(`Downloading ${name}@${version}`);
|
|
174
|
-
const resolved = await resolvePackageDocs(pkgName, { version });
|
|
100
|
+
const wasCacheHit = cache.has();
|
|
101
|
+
spin.start(wasCacheHit ? `Linking ${name}` : `Downloading ${name}@${version}`);
|
|
102
|
+
mkdirSync(skillDir, { recursive: true });
|
|
103
|
+
const resolved = wasCacheHit ? synthesizeResolved(identityName, version, info, cwd) : await resolvePackageDocs(pkgName, { version });
|
|
175
104
|
if (!resolved) {
|
|
176
105
|
spin.stop(`Could not resolve: ${name}`);
|
|
177
106
|
continue;
|
|
178
107
|
}
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const content = await fetchGitHubRaw(`${gitDocs.baseUrl}/${file}`);
|
|
192
|
-
if (!content) return null;
|
|
193
|
-
return {
|
|
194
|
-
file,
|
|
195
|
-
content
|
|
196
|
-
};
|
|
197
|
-
}));
|
|
198
|
-
for (const r of results) if (r) {
|
|
199
|
-
const stripped = gitDocs.docsPrefix ? r.file.replace(gitDocs.docsPrefix, "") : r.file;
|
|
200
|
-
const cachePath = stripped.startsWith("docs/") ? stripped : `docs/${stripped}`;
|
|
201
|
-
cachedDocs.push({
|
|
202
|
-
path: cachePath,
|
|
203
|
-
content: r.content
|
|
204
|
-
});
|
|
205
|
-
docsToIndex.push({
|
|
206
|
-
id: cachePath,
|
|
207
|
-
content: r.content,
|
|
208
|
-
metadata: {
|
|
209
|
-
package: pkgName,
|
|
210
|
-
source: cachePath,
|
|
211
|
-
type: "doc"
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
if (isShallowGitDocs(cachedDocs.length) && resolved.llmsUrl) {
|
|
217
|
-
cachedDocs.length = 0;
|
|
218
|
-
docsToIndex.length = 0;
|
|
219
|
-
} else if (cachedDocs.length > 0 && resolved.llmsUrl) {
|
|
220
|
-
const llmsContent = await fetchLlmsTxt(resolved.llmsUrl);
|
|
221
|
-
if (llmsContent) {
|
|
222
|
-
const baseUrl = resolved.docsUrl || new URL(resolved.llmsUrl).origin;
|
|
223
|
-
cachedDocs.push({
|
|
224
|
-
path: "llms.txt",
|
|
225
|
-
content: normalizeLlmsLinks(llmsContent.raw)
|
|
226
|
-
});
|
|
227
|
-
if (llmsContent.links.length > 0) {
|
|
228
|
-
const docs = await downloadLlmsDocs(llmsContent, baseUrl);
|
|
229
|
-
for (const doc of docs) {
|
|
230
|
-
if (!isFrameworkDoc(doc.url)) continue;
|
|
231
|
-
const localPath = doc.url.startsWith("/") ? doc.url.slice(1) : doc.url;
|
|
232
|
-
cachedDocs.push({
|
|
233
|
-
path: join("llms-docs", ...localPath.split("/")),
|
|
234
|
-
content: doc.content
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if (resolved.llmsUrl && cachedDocs.length === 0) {
|
|
244
|
-
const llmsContent = await fetchLlmsTxt(resolved.llmsUrl);
|
|
245
|
-
if (llmsContent) {
|
|
246
|
-
cachedDocs.push({
|
|
247
|
-
path: "llms.txt",
|
|
248
|
-
content: normalizeLlmsLinks(llmsContent.raw)
|
|
249
|
-
});
|
|
250
|
-
if (llmsContent.links.length > 0) {
|
|
251
|
-
const docs = await downloadLlmsDocs(llmsContent, resolved.docsUrl || new URL(resolved.llmsUrl).origin);
|
|
252
|
-
for (const doc of docs) {
|
|
253
|
-
if (!isFrameworkDoc(doc.url)) continue;
|
|
254
|
-
const cachePath = join("docs", ...(doc.url.startsWith("/") ? doc.url.slice(1) : doc.url).split("/"));
|
|
255
|
-
cachedDocs.push({
|
|
256
|
-
path: cachePath,
|
|
257
|
-
content: doc.content
|
|
258
|
-
});
|
|
259
|
-
docsToIndex.push({
|
|
260
|
-
id: doc.url,
|
|
261
|
-
content: doc.content,
|
|
262
|
-
metadata: {
|
|
263
|
-
package: pkgName,
|
|
264
|
-
source: cachePath,
|
|
265
|
-
type: "doc"
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
if (resolved.readmeUrl && cachedDocs.length === 0) {
|
|
273
|
-
const content = await fetchReadmeContent(resolved.readmeUrl);
|
|
274
|
-
if (content) {
|
|
275
|
-
cachedDocs.push({
|
|
276
|
-
path: "docs/README.md",
|
|
277
|
-
content
|
|
278
|
-
});
|
|
279
|
-
docsToIndex.push({
|
|
280
|
-
id: "README.md",
|
|
281
|
-
content,
|
|
282
|
-
metadata: {
|
|
283
|
-
package: pkgName,
|
|
284
|
-
source: "docs/README.md",
|
|
285
|
-
type: "doc"
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
}
|
|
108
|
+
const resources = await fetchAndCacheResources({
|
|
109
|
+
packageName: pkgName,
|
|
110
|
+
resolved,
|
|
111
|
+
version,
|
|
112
|
+
useCache: wasCacheHit,
|
|
113
|
+
features,
|
|
114
|
+
onProgress: (msg) => spin.message(msg)
|
|
115
|
+
});
|
|
116
|
+
for (const w of resources.warnings) p.log.warn(`${name}: ${w}`);
|
|
117
|
+
if (!cache.has()) {
|
|
118
|
+
spin.stop(`No docs found for ${name}`);
|
|
119
|
+
continue;
|
|
289
120
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
if (!copyFromExistingAgent(skillDir, name, allSkillsDirs)) {
|
|
318
|
-
if (regenerateBaseSkillMd(skillDir, pkgName, version, cwd, allSkillNames, info.source, info.packages)) regenerated.push({
|
|
121
|
+
const ctx = buildSkillContext({
|
|
122
|
+
packageName: identityName,
|
|
123
|
+
cachePackageName: pkgName,
|
|
124
|
+
version,
|
|
125
|
+
skillDir,
|
|
126
|
+
skillDirName: name,
|
|
127
|
+
resources,
|
|
128
|
+
prepared: await prepareSkillReferences({
|
|
129
|
+
packageName: pkgName,
|
|
130
|
+
version,
|
|
131
|
+
cwd,
|
|
132
|
+
skillDir,
|
|
133
|
+
resources,
|
|
134
|
+
features,
|
|
135
|
+
baseDir: skillsDir,
|
|
136
|
+
extraPackages: parsePackages(info.packages),
|
|
137
|
+
onIndexProgress: (msg) => spin.message(msg)
|
|
138
|
+
}),
|
|
139
|
+
resolved,
|
|
140
|
+
packages: parsePackageNames(info.packages),
|
|
141
|
+
features
|
|
142
|
+
});
|
|
143
|
+
if (!copyFromExistingAgent(skillDir, name, allSkillsDirs)) {
|
|
144
|
+
if (!existsSync(join(skillDir, "SKILL.md"))) {
|
|
145
|
+
writeBaseSkill(ctx);
|
|
146
|
+
regenerated.push({
|
|
319
147
|
name,
|
|
320
|
-
|
|
321
|
-
version,
|
|
322
|
-
skillDir,
|
|
323
|
-
packages: info.packages
|
|
148
|
+
ctx
|
|
324
149
|
});
|
|
325
150
|
}
|
|
326
|
-
|
|
327
|
-
|
|
151
|
+
}
|
|
152
|
+
spin.stop(wasCacheHit ? `Linked ${name}` : `Downloaded and linked ${name}`);
|
|
328
153
|
}
|
|
329
154
|
if (regenerated.length > 0 && !readConfig().skipLlm) {
|
|
330
155
|
const llmConfig = await selectLlmConfig(void 0, `Enhance SKILL.md for ${regenerated.map((r) => r.name).join(", ")}`);
|
|
331
|
-
if (llmConfig?.promptOnly) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
packageName: pkgName,
|
|
337
|
-
skillDir,
|
|
338
|
-
version,
|
|
339
|
-
hasIssues: existsSync(join(globalCachePath, "issues")),
|
|
340
|
-
hasDiscussions: existsSync(join(globalCachePath, "discussions")),
|
|
341
|
-
hasReleases: existsSync(join(globalCachePath, "releases")),
|
|
342
|
-
hasChangelog: false,
|
|
343
|
-
docsType: "docs",
|
|
344
|
-
hasShippedDocs: false,
|
|
345
|
-
pkgFiles: getPkgKeyFiles(pkgName, process.cwd(), version),
|
|
346
|
-
sections: llmConfig.sections,
|
|
347
|
-
customPrompt: llmConfig.customPrompt,
|
|
348
|
-
features
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
} else if (llmConfig) {
|
|
156
|
+
if (llmConfig?.promptOnly) for (const { ctx } of regenerated) writePromptFiles(ctx, {
|
|
157
|
+
sections: llmConfig.sections,
|
|
158
|
+
customPrompt: llmConfig.customPrompt
|
|
159
|
+
});
|
|
160
|
+
else if (llmConfig) {
|
|
352
161
|
p.log.step(getModelLabel(llmConfig.model));
|
|
353
|
-
for (const {
|
|
162
|
+
for (const { ctx } of regenerated) await enhanceSkillWithLLM(ctx, {
|
|
163
|
+
model: llmConfig.model,
|
|
164
|
+
sections: llmConfig.sections,
|
|
165
|
+
customPrompt: llmConfig.customPrompt
|
|
166
|
+
});
|
|
354
167
|
}
|
|
355
168
|
}
|
|
356
169
|
for (const [name, info] of Object.entries(lock.skills)) writeLock(skillsDir, name, info);
|
|
@@ -375,7 +188,7 @@ function copyFromExistingAgent(skillDir, name, allSkillsDirs) {
|
|
|
375
188
|
}
|
|
376
189
|
function unsanitizeName(sanitized, source) {
|
|
377
190
|
if (source?.includes("ungh://")) {
|
|
378
|
-
const match = source.match(
|
|
191
|
+
const match = source.match(STATIC_REGEX_1);
|
|
379
192
|
if (match) return `@${match[1]}/${match[2]}`;
|
|
380
193
|
}
|
|
381
194
|
if (sanitized.startsWith("antfu-")) return `@antfu/${sanitized.slice(6)}`;
|
|
@@ -385,78 +198,15 @@ function unsanitizeName(sanitized, source) {
|
|
|
385
198
|
if (sanitized.startsWith("vueuse-")) return `@vueuse/${sanitized.slice(7)}`;
|
|
386
199
|
return sanitized;
|
|
387
200
|
}
|
|
388
|
-
function
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
symlinkSync(pkgPath, pkgLink, "junction");
|
|
394
|
-
}
|
|
395
|
-
function pkgHasShippedDocs(name, cwd, version) {
|
|
396
|
-
const pkgPath = resolvePkgDir(name, cwd, version);
|
|
397
|
-
if (!pkgPath) return false;
|
|
398
|
-
for (const candidate of [
|
|
399
|
-
"docs",
|
|
400
|
-
"documentation",
|
|
401
|
-
"doc"
|
|
402
|
-
]) if (existsSync(join(pkgPath, candidate))) return true;
|
|
403
|
-
return false;
|
|
404
|
-
}
|
|
405
|
-
async function enhanceRegenerated(pkgName, version, skillDir, model, sections, customPrompt, packages) {
|
|
406
|
-
const llmLog = p.taskLog({
|
|
407
|
-
title: `Agent exploring ${pkgName}`,
|
|
408
|
-
limit: 3
|
|
409
|
-
});
|
|
410
|
-
const docFiles = listReferenceFiles(skillDir);
|
|
411
|
-
const globalCachePath = getCacheDir(pkgName, version);
|
|
412
|
-
const hasIssues = existsSync(join(globalCachePath, "issues"));
|
|
413
|
-
const hasDiscussions = existsSync(join(globalCachePath, "discussions"));
|
|
414
|
-
const hasGithub = hasIssues || hasDiscussions;
|
|
415
|
-
const hasReleases = existsSync(join(globalCachePath, "releases"));
|
|
416
|
-
const features = readConfig().features ?? defaultFeatures;
|
|
417
|
-
const { optimized, wasOptimized } = await optimizeDocs({
|
|
418
|
-
packageName: pkgName,
|
|
419
|
-
skillDir,
|
|
420
|
-
model,
|
|
201
|
+
function synthesizeResolved(identityName, version, info, cwd) {
|
|
202
|
+
const repoUrl = info.repo?.includes("/") ? `https://github.com/${info.repo}` : void 0;
|
|
203
|
+
const pkgPath = resolvePkgDir(toStoragePackageName(identityName), cwd, version);
|
|
204
|
+
return {
|
|
205
|
+
name: identityName,
|
|
421
206
|
version,
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
sections,
|
|
426
|
-
customPrompt,
|
|
427
|
-
features,
|
|
428
|
-
pkgFiles: getPkgKeyFiles(pkgName, process.cwd(), version),
|
|
429
|
-
onProgress: createToolProgress(llmLog)
|
|
430
|
-
});
|
|
431
|
-
if (wasOptimized) {
|
|
432
|
-
llmLog.success("Generated best practices");
|
|
433
|
-
const cwd = process.cwd();
|
|
434
|
-
const pkgPath = resolvePkgDir(pkgName, cwd, version);
|
|
435
|
-
let description;
|
|
436
|
-
if (pkgPath) {
|
|
437
|
-
const pkgJsonResult = readPackageJsonSafe(join(pkgPath, "package.json"));
|
|
438
|
-
if (pkgJsonResult) description = pkgJsonResult.parsed.description;
|
|
439
|
-
}
|
|
440
|
-
const docsType = inferDocsTypeFromCache(globalCachePath);
|
|
441
|
-
const dirName = skillDir.split("/").pop();
|
|
442
|
-
const allPackages = parsePackageNames(packages);
|
|
443
|
-
writeGeneratedSkillMd(skillDir, {
|
|
444
|
-
name: pkgName,
|
|
445
|
-
version,
|
|
446
|
-
description,
|
|
447
|
-
body: optimized,
|
|
448
|
-
relatedSkills: [],
|
|
449
|
-
hasIssues,
|
|
450
|
-
hasDiscussions,
|
|
451
|
-
hasReleases,
|
|
452
|
-
docsType,
|
|
453
|
-
hasShippedDocs: hasShippedDocs(pkgName, cwd, version),
|
|
454
|
-
pkgFiles: getPkgKeyFiles(pkgName, cwd, version),
|
|
455
|
-
dirName,
|
|
456
|
-
packages: allPackages.length > 1 ? allPackages : void 0,
|
|
457
|
-
features
|
|
458
|
-
});
|
|
459
|
-
} else llmLog.message("Enhancement skipped");
|
|
207
|
+
repoUrl,
|
|
208
|
+
description: pkgPath ? readPackageJsonSafe(join(pkgPath, "package.json"))?.parsed.description : void 0
|
|
209
|
+
};
|
|
460
210
|
}
|
|
461
211
|
const installCommandDef = defineCommand({
|
|
462
212
|
meta: {
|
|
@@ -475,48 +225,13 @@ const installCommandDef = defineCommand({
|
|
|
475
225
|
if (!picked || picked === "none") return;
|
|
476
226
|
agent = picked;
|
|
477
227
|
}
|
|
478
|
-
p.intro(
|
|
228
|
+
p.intro(`${styleText(["bold", "magenta"], "skilld")} install`);
|
|
479
229
|
return installCommand({
|
|
480
230
|
global: args.global,
|
|
481
231
|
agent
|
|
482
232
|
});
|
|
483
233
|
}
|
|
484
234
|
});
|
|
485
|
-
function regenerateBaseSkillMd(skillDir, pkgName, version, cwd, allSkillNames, source, packages) {
|
|
486
|
-
if (existsSync(join(skillDir, "SKILL.md"))) return false;
|
|
487
|
-
const pkgPath = resolvePkgDir(pkgName, cwd, version);
|
|
488
|
-
let description;
|
|
489
|
-
if (pkgPath) {
|
|
490
|
-
const pkgResult = readPackageJsonSafe(join(pkgPath, "package.json"));
|
|
491
|
-
if (pkgResult) description = pkgResult.parsed.description;
|
|
492
|
-
}
|
|
493
|
-
const globalCachePath = getCacheDir(pkgName, version);
|
|
494
|
-
const docsType = inferDocsTypeFromCache(globalCachePath, source);
|
|
495
|
-
const feat = readConfig().features ?? defaultFeatures;
|
|
496
|
-
const hasIssues = feat.issues && existsSync(join(globalCachePath, "issues"));
|
|
497
|
-
const hasDiscussions = feat.discussions && existsSync(join(globalCachePath, "discussions"));
|
|
498
|
-
const hasReleases = feat.releases && existsSync(join(globalCachePath, "releases"));
|
|
499
|
-
const relatedSkills = allSkillNames.filter((n) => n !== pkgName);
|
|
500
|
-
const dirName = skillDir.split("/").pop();
|
|
501
|
-
const allPackages = parsePackageNames(packages);
|
|
502
|
-
mkdirSync(skillDir, { recursive: true });
|
|
503
|
-
writeGeneratedSkillMd(skillDir, {
|
|
504
|
-
name: pkgName,
|
|
505
|
-
version,
|
|
506
|
-
description,
|
|
507
|
-
relatedSkills,
|
|
508
|
-
hasIssues,
|
|
509
|
-
hasDiscussions,
|
|
510
|
-
hasReleases,
|
|
511
|
-
docsType,
|
|
512
|
-
hasShippedDocs: hasShippedDocs(pkgName, cwd, version),
|
|
513
|
-
pkgFiles: getPkgKeyFiles(pkgName, cwd, version),
|
|
514
|
-
dirName,
|
|
515
|
-
packages: allPackages.length > 1 ? allPackages : void 0,
|
|
516
|
-
features: readConfig().features ?? defaultFeatures
|
|
517
|
-
});
|
|
518
|
-
return true;
|
|
519
|
-
}
|
|
520
235
|
function hasStaleReferences(referencesPath, pkgName, version, features) {
|
|
521
236
|
for (const entry of readdirSync(referencesPath)) {
|
|
522
237
|
const entryPath = join(referencesPath, entry);
|