skilld 2.3.0 → 3.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +142 -353
  2. package/bin/skilld.mjs +56 -0
  3. package/loader/resolve-artifact.mjs +37 -0
  4. package/package.json +28 -55
  5. package/dist/_chunks/add.mjs +0 -95
  6. package/dist/_chunks/add.mjs.map +0 -1
  7. package/dist/_chunks/agent-prompt.mjs +0 -90
  8. package/dist/_chunks/agent-prompt.mjs.map +0 -1
  9. package/dist/_chunks/agent.mjs +0 -1817
  10. package/dist/_chunks/agent.mjs.map +0 -1
  11. package/dist/_chunks/args.mjs +0 -49
  12. package/dist/_chunks/args.mjs.map +0 -1
  13. package/dist/_chunks/assemble.mjs +0 -126
  14. package/dist/_chunks/assemble.mjs.map +0 -1
  15. package/dist/_chunks/author.mjs +0 -432
  16. package/dist/_chunks/author.mjs.map +0 -1
  17. package/dist/_chunks/cache.mjs +0 -367
  18. package/dist/_chunks/cache.mjs.map +0 -1
  19. package/dist/_chunks/cache2.mjs +0 -151
  20. package/dist/_chunks/cache2.mjs.map +0 -1
  21. package/dist/_chunks/changes-digest.mjs +0 -49
  22. package/dist/_chunks/changes-digest.mjs.map +0 -1
  23. package/dist/_chunks/changes.mjs +0 -23
  24. package/dist/_chunks/changes.mjs.map +0 -1
  25. package/dist/_chunks/client.mjs +0 -182
  26. package/dist/_chunks/client.mjs.map +0 -1
  27. package/dist/_chunks/core.mjs +0 -13
  28. package/dist/_chunks/detect.mjs +0 -614
  29. package/dist/_chunks/detect.mjs.map +0 -1
  30. package/dist/_chunks/detect2.mjs +0 -2
  31. package/dist/_chunks/eject.mjs +0 -69
  32. package/dist/_chunks/eject.mjs.map +0 -1
  33. package/dist/_chunks/embedding-cache.mjs +0 -2
  34. package/dist/_chunks/embedding-cache2.mjs +0 -61
  35. package/dist/_chunks/embedding-cache2.mjs.map +0 -1
  36. package/dist/_chunks/env.mjs +0 -19
  37. package/dist/_chunks/env.mjs.map +0 -1
  38. package/dist/_chunks/index-identity.mjs +0 -365
  39. package/dist/_chunks/index-identity.mjs.map +0 -1
  40. package/dist/_chunks/index-identity2.mjs +0 -2
  41. package/dist/_chunks/install-many.mjs +0 -542
  42. package/dist/_chunks/install-many.mjs.map +0 -1
  43. package/dist/_chunks/install.mjs +0 -259
  44. package/dist/_chunks/install.mjs.map +0 -1
  45. package/dist/_chunks/intro.mjs +0 -63
  46. package/dist/_chunks/intro.mjs.map +0 -1
  47. package/dist/_chunks/list.mjs +0 -102
  48. package/dist/_chunks/list.mjs.map +0 -1
  49. package/dist/_chunks/lockfile.mjs +0 -174
  50. package/dist/_chunks/lockfile.mjs.map +0 -1
  51. package/dist/_chunks/login.mjs +0 -247
  52. package/dist/_chunks/login.mjs.map +0 -1
  53. package/dist/_chunks/logout.mjs +0 -27
  54. package/dist/_chunks/logout.mjs.map +0 -1
  55. package/dist/_chunks/map.mjs +0 -11
  56. package/dist/_chunks/map.mjs.map +0 -1
  57. package/dist/_chunks/markdown.mjs +0 -101
  58. package/dist/_chunks/markdown.mjs.map +0 -1
  59. package/dist/_chunks/menu.mjs +0 -33
  60. package/dist/_chunks/menu.mjs.map +0 -1
  61. package/dist/_chunks/model-picker.mjs +0 -61
  62. package/dist/_chunks/model-picker.mjs.map +0 -1
  63. package/dist/_chunks/monorepo.mjs +0 -74
  64. package/dist/_chunks/monorepo.mjs.map +0 -1
  65. package/dist/_chunks/package-json.mjs +0 -84
  66. package/dist/_chunks/package-json.mjs.map +0 -1
  67. package/dist/_chunks/paths.mjs +0 -47
  68. package/dist/_chunks/paths.mjs.map +0 -1
  69. package/dist/_chunks/pipeline.mjs +0 -993
  70. package/dist/_chunks/pipeline.mjs.map +0 -1
  71. package/dist/_chunks/pool.mjs +0 -2
  72. package/dist/_chunks/pool2.mjs +0 -121
  73. package/dist/_chunks/pool2.mjs.map +0 -1
  74. package/dist/_chunks/portable.mjs +0 -152
  75. package/dist/_chunks/portable.mjs.map +0 -1
  76. package/dist/_chunks/prepare-hook.mjs +0 -2
  77. package/dist/_chunks/prepare-hook2.mjs +0 -61
  78. package/dist/_chunks/prepare-hook2.mjs.map +0 -1
  79. package/dist/_chunks/prepare.mjs +0 -113
  80. package/dist/_chunks/prepare.mjs.map +0 -1
  81. package/dist/_chunks/prepare2.mjs +0 -80
  82. package/dist/_chunks/prepare2.mjs.map +0 -1
  83. package/dist/_chunks/prompts.mjs +0 -1252
  84. package/dist/_chunks/prompts.mjs.map +0 -1
  85. package/dist/_chunks/pull.mjs +0 -190
  86. package/dist/_chunks/pull.mjs.map +0 -1
  87. package/dist/_chunks/regex.mjs +0 -19
  88. package/dist/_chunks/regex.mjs.map +0 -1
  89. package/dist/_chunks/retriv.mjs +0 -2
  90. package/dist/_chunks/retriv2.mjs +0 -177
  91. package/dist/_chunks/retriv2.mjs.map +0 -1
  92. package/dist/_chunks/sanitize.mjs +0 -260
  93. package/dist/_chunks/sanitize.mjs.map +0 -1
  94. package/dist/_chunks/search-helpers.mjs +0 -88
  95. package/dist/_chunks/search-helpers.mjs.map +0 -1
  96. package/dist/_chunks/search-interactive.mjs +0 -249
  97. package/dist/_chunks/search-interactive.mjs.map +0 -1
  98. package/dist/_chunks/search.mjs +0 -247
  99. package/dist/_chunks/search.mjs.map +0 -1
  100. package/dist/_chunks/semver.mjs +0 -2831
  101. package/dist/_chunks/semver.mjs.map +0 -1
  102. package/dist/_chunks/skill-installer.mjs +0 -2
  103. package/dist/_chunks/skill-installer2.mjs +0 -163
  104. package/dist/_chunks/skill-installer2.mjs.map +0 -1
  105. package/dist/_chunks/skills.mjs +0 -187
  106. package/dist/_chunks/skills.mjs.map +0 -1
  107. package/dist/_chunks/store.mjs +0 -107
  108. package/dist/_chunks/store.mjs.map +0 -1
  109. package/dist/_chunks/sync.mjs +0 -1009
  110. package/dist/_chunks/sync.mjs.map +0 -1
  111. package/dist/_chunks/sync2.mjs +0 -2
  112. package/dist/_chunks/telemetry.mjs +0 -26
  113. package/dist/_chunks/telemetry.mjs.map +0 -1
  114. package/dist/_chunks/uninstall.mjs +0 -214
  115. package/dist/_chunks/uninstall.mjs.map +0 -1
  116. package/dist/_chunks/update.mjs +0 -133
  117. package/dist/_chunks/update.mjs.map +0 -1
  118. package/dist/_chunks/upload.mjs +0 -155
  119. package/dist/_chunks/upload.mjs.map +0 -1
  120. package/dist/_chunks/validate.mjs +0 -60
  121. package/dist/_chunks/validate.mjs.map +0 -1
  122. package/dist/_chunks/version.mjs +0 -19
  123. package/dist/_chunks/version.mjs.map +0 -1
  124. package/dist/_chunks/watch.mjs +0 -2
  125. package/dist/_chunks/watch2.mjs +0 -118
  126. package/dist/_chunks/watch2.mjs.map +0 -1
  127. package/dist/_chunks/whoami.mjs +0 -21
  128. package/dist/_chunks/whoami.mjs.map +0 -1
  129. package/dist/_chunks/wizard.mjs +0 -2
  130. package/dist/_chunks/wizard2.mjs +0 -200
  131. package/dist/_chunks/wizard2.mjs.map +0 -1
  132. package/dist/_chunks/yaml.mjs +0 -33
  133. package/dist/_chunks/yaml.mjs.map +0 -1
  134. package/dist/cli-entry.d.mts +0 -1
  135. package/dist/cli-entry.mjs +0 -5
  136. package/dist/cli-entry.mjs.map +0 -1
  137. package/dist/cli.d.mts +0 -1
  138. package/dist/cli.mjs +0 -1330
  139. package/dist/cli.mjs.map +0 -1
  140. package/dist/prepare.d.mts +0 -1
  141. package/dist/prepare.mjs +0 -84
  142. package/dist/prepare.mjs.map +0 -1
  143. package/dist/retriv/worker.d.mts +0 -37
  144. package/dist/retriv/worker.d.mts.map +0 -1
  145. package/dist/retriv/worker.mjs +0 -46
  146. package/dist/retriv/worker.mjs.map +0 -1
package/dist/cli.mjs DELETED
@@ -1,1330 +0,0 @@
1
- #!/usr/bin/env node
2
- import { detectInstalledAgents, detectTargetAgent, getAgentVersion, targets } from "./_chunks/detect.mjs";
3
- import { detectImportedPackages, getAvailableModels, getModelName, getOAuthProviderList, loginOAuthProvider, logoutOAuthProvider } from "./_chunks/agent.mjs";
4
- import { formatSource, timeAgo, timedSpinner, unlinkSkillFromAgents } from "./_chunks/prompts.mjs";
5
- import { EMBED_DEVICES, EMBED_MODELS, defaultFeatures, getAvailableOllamaEmbedModels, hasCompletedWizard, hasConfig, isOllamaEmbedModel, readConfig, resolveEmbedModel, updateConfig } from "./_chunks/index-identity.mjs";
6
- import { CACHE_DIR, getPackageDbPath, getSharedSkillsDir, skillInternalDir } from "./_chunks/paths.mjs";
7
- import { COMMA_OR_WHITESPACE_RE, VERSION_RANGE_PREFIX_RE } from "./_chunks/regex.mjs";
8
- import { getCacheDir } from "./_chunks/prepare.mjs";
9
- import { readPackageJsonSafe } from "./_chunks/package-json.mjs";
10
- import "./_chunks/cache.mjs";
11
- import { isInteractive, isRunningInsideAgent, requireInteractive } from "./_chunks/env.mjs";
12
- import { promptForAgent, resolveAgent } from "./_chunks/agent-prompt.mjs";
13
- import { rootArgs, sharedArgs } from "./_chunks/args.mjs";
14
- import { version } from "./_chunks/version.mjs";
15
- import { formatStatus, getInstalledGenerators, getRepoHint, introLine, relativeTime } from "./_chunks/intro.mjs";
16
- import { guard, menuLoop } from "./_chunks/menu.mjs";
17
- import { hasPrepareHook, suggestPrepareHook } from "./_chunks/prepare-hook2.mjs";
18
- import { NO_MODELS_MESSAGE, OAUTH_NOTE, pickModel } from "./_chunks/model-picker.mjs";
19
- import { fetchLatestVersion, fetchNpmRegistryMeta, parseNpmPackageInputs, resolveSkillName, semverGt, toStoragePackageName } from "./_chunks/semver.mjs";
20
- import { mapInsert } from "./_chunks/map.mjs";
21
- import { parsePackages, removeLockEntry } from "./_chunks/lockfile.mjs";
22
- import { getProjectState, getSkillsDir, isOutdated, iterateSkills } from "./_chunks/skills.mjs";
23
- import { runWizard } from "./_chunks/wizard2.mjs";
24
- import "./_chunks/core.mjs";
25
- import { existsSync, readFileSync, readdirSync, realpathSync, rmSync, statSync } from "node:fs";
26
- import { styleText } from "node:util";
27
- import * as p from "@clack/prompts";
28
- import { defineCommand, runMain } from "citty";
29
- import pLimit from "p-limit";
30
- import { join, resolve } from "pathe";
31
- import logUpdate from "log-update";
32
- async function configCommand() {
33
- const initConfig = readConfig();
34
- const agentId = initConfig.agent || detectTargetAgent() || void 0;
35
- const cyan = (s) => styleText("cyan", s);
36
- const modelLabel = initConfig.skipLlm ? "skip" : initConfig.model ? cyan(getModelName(initConfig.model)) : "auto";
37
- const agentLabel = agentId && targets[agentId] ? cyan(targets[agentId].displayName) : "auto-detect";
38
- p.note(styleText("gray", `Fetch docs → Enhance with ${modelLabel} → Install to ${agentLabel}`), "How skilld works");
39
- await menuLoop({
40
- message: "Settings",
41
- options: () => {
42
- const config = readConfig();
43
- const features = config.features ?? defaultFeatures;
44
- const enabledCount = Object.values(features).filter(Boolean).length;
45
- const modelHint = config.skipLlm ? "disabled" : config.model ? getModelName(config.model) : "auto";
46
- const oauthProviders = getOAuthProviderList();
47
- const options = [{
48
- label: "Data sources",
49
- value: "features",
50
- hint: `${enabledCount}/4 enabled · issues, releases, search, discussions`
51
- }];
52
- if (oauthProviders.length > 0) {
53
- const connectedOAuth = oauthProviders.filter((pr) => pr.loggedIn).length;
54
- const oauthHint = connectedOAuth > 0 ? `${connectedOAuth} connected` : "none";
55
- options.push({
56
- label: "OAuth providers",
57
- value: "oauth",
58
- hint: `${oauthHint} · ⚠ may violate provider ToS`
59
- });
60
- }
61
- const embedModel = resolveEmbedModel(config.embedModel);
62
- const embedHint = features.search ? `${embedModel} · local model powering skilld search` : `${embedModel} · search is disabled in Data sources`;
63
- const embedDevice = config.embedDevice || "auto";
64
- options.push({
65
- label: "Enhancement model",
66
- value: "model",
67
- hint: `${modelHint} · rewrites SKILL.md with best practices`
68
- }, {
69
- label: "Embedding model",
70
- value: "embedModel",
71
- hint: embedHint
72
- }, {
73
- label: "Embedding device",
74
- value: "embedDevice",
75
- hint: `${embedDevice} · where the embedding model runs`
76
- }, {
77
- label: "Target agent",
78
- value: "agent",
79
- hint: `${config.agent || "auto-detect"} · where skills are installed`
80
- });
81
- return options;
82
- },
83
- onSelect: async (action) => {
84
- switch (action) {
85
- case "features": {
86
- const features = readConfig().features ?? defaultFeatures;
87
- const selected = guard(await p.multiselect({
88
- message: "Data sources",
89
- options: [
90
- {
91
- label: "Semantic + token search",
92
- value: "search",
93
- hint: "local query engine to cut token costs and speed up grep"
94
- },
95
- {
96
- label: "Release notes",
97
- value: "releases",
98
- hint: "track changelogs for installed packages"
99
- },
100
- {
101
- label: "GitHub issues",
102
- value: "issues",
103
- hint: "surface common problems and solutions"
104
- },
105
- {
106
- label: "GitHub discussions",
107
- value: "discussions",
108
- hint: "include Q&A and community knowledge"
109
- }
110
- ],
111
- initialValues: Object.entries(features).filter(([, v]) => v).map(([k]) => k),
112
- required: false
113
- }));
114
- updateConfig({ features: {
115
- search: selected.includes("search"),
116
- issues: selected.includes("issues"),
117
- discussions: selected.includes("discussions"),
118
- releases: selected.includes("releases")
119
- } });
120
- p.log.success(`Data sources updated: ${selected.length} enabled`);
121
- break;
122
- }
123
- case "oauth":
124
- await configureOAuth();
125
- break;
126
- case "model":
127
- await configureModel();
128
- break;
129
- case "embedModel":
130
- await configureEmbedModel();
131
- break;
132
- case "embedDevice":
133
- await configureEmbedDevice();
134
- break;
135
- case "agent": {
136
- const config = readConfig();
137
- const agentChoice = guard(await p.select({
138
- message: "Target agent — where should skills be installed?",
139
- options: [{
140
- label: "Auto-detect",
141
- value: ""
142
- }, ...Object.entries(targets).map(([id, a]) => ({
143
- label: a.displayName,
144
- value: id,
145
- hint: a.skillsDir
146
- }))],
147
- initialValue: config.agent || ""
148
- }));
149
- updateConfig({ agent: agentChoice || void 0 });
150
- p.log.success(agentChoice ? `Target agent set to ${agentChoice}` : "Target agent will be auto-detected");
151
- break;
152
- }
153
- }
154
- }
155
- });
156
- }
157
- async function configureOAuth() {
158
- p.note(OAUTH_NOTE, "How OAuth works");
159
- await menuLoop({
160
- message: "OAuth providers",
161
- options: () => {
162
- return getOAuthProviderList().map((pr) => ({
163
- label: pr.name,
164
- value: pr.id,
165
- hint: pr.loggedIn ? styleText("green", "connected") : "not connected"
166
- }));
167
- },
168
- onSelect: async (providerId) => {
169
- const pr = getOAuthProviderList().find((p2) => p2.id === providerId);
170
- if (!pr) return;
171
- if (pr.loggedIn) {
172
- if (guard(await p.select({
173
- message: pr.name,
174
- options: [{
175
- label: "Disconnect",
176
- value: "disconnect"
177
- }, {
178
- label: "Back",
179
- value: "back"
180
- }]
181
- })) === "disconnect") {
182
- await logoutOAuthProvider(providerId);
183
- p.log.success(`Disconnected from ${pr.name}`);
184
- }
185
- return;
186
- }
187
- const spinner = p.spinner();
188
- spinner.start("Connecting...");
189
- const success = await loginOAuthProvider(providerId, {
190
- onAuth: (url, instructions) => {
191
- spinner.stop("Open this URL in your browser:");
192
- p.log.info(` ${styleText("cyan", url)}`);
193
- if (instructions) p.log.info(` ${styleText("gray", instructions)}`);
194
- spinner.start("Waiting for authentication...");
195
- },
196
- onPrompt: async (message, placeholder) => {
197
- const value = await p.text({
198
- message,
199
- placeholder
200
- });
201
- if (p.isCancel(value)) return "";
202
- return value;
203
- },
204
- onProgress: (msg) => p.log.step(msg)
205
- }).catch((err) => {
206
- spinner.stop(`Login failed: ${err.message}`);
207
- return false;
208
- });
209
- spinner.stop();
210
- if (success) p.log.success(`Connected to ${pr.name}`);
211
- }
212
- });
213
- }
214
- async function configureModel() {
215
- while (true) {
216
- const available = await getAvailableModels();
217
- if (available.length === 0) p.log.warn(NO_MODELS_MESSAGE);
218
- const afterOptions = getOAuthProviderList().length > 0 ? [{
219
- label: "⚠ Connect OAuth provider...",
220
- value: "_connect",
221
- hint: "may violate provider ToS"
222
- }, {
223
- label: "Skip enhancement",
224
- value: "_skip",
225
- hint: "base skill with docs, issues, and types"
226
- }] : [{
227
- label: "Skip enhancement",
228
- value: "_skip",
229
- hint: "base skill with docs, issues, and types"
230
- }];
231
- const choice = await pickModel(available, {
232
- before: available.length > 0 ? [{
233
- label: "Auto",
234
- value: "_auto",
235
- hint: "picks best available model from connected providers"
236
- }] : [],
237
- after: afterOptions
238
- });
239
- if (!choice) return;
240
- if (choice === "_connect") {
241
- await configureOAuth();
242
- continue;
243
- }
244
- if (choice === "_skip") {
245
- updateConfig({
246
- model: void 0,
247
- skipLlm: true
248
- });
249
- p.log.success("Enhancement disabled - skills will use raw docs only");
250
- } else if (choice === "_auto") {
251
- updateConfig({
252
- model: void 0,
253
- skipLlm: false
254
- });
255
- p.log.success("Enhancement model will be auto-selected");
256
- } else {
257
- updateConfig({
258
- model: choice,
259
- skipLlm: false
260
- });
261
- p.log.success(`Enhancement model set to ${getModelName(choice)}`);
262
- }
263
- return;
264
- }
265
- }
266
- async function configureEmbedModel() {
267
- const config = readConfig();
268
- const current = resolveEmbedModel(config.embedModel);
269
- const envOverride = process.env.SKILLD_EMBED_MODEL?.trim();
270
- if (envOverride) p.log.warn(`SKILLD_EMBED_MODEL is set to ${envOverride} and overrides this setting for the current shell.`);
271
- const builtIn = EMBED_MODELS.map((m) => ({
272
- label: m.label,
273
- value: m.id,
274
- hint: `${m.dimensions}d · ${m.hint}`
275
- }));
276
- const ollama = (await getAvailableOllamaEmbedModels()).map((m) => ({
277
- label: m.name,
278
- value: m.id,
279
- hint: m.hint
280
- }));
281
- const choice = guard(await p.select({
282
- message: "Embedding model: indexes and queries docs for skilld search",
283
- options: [...builtIn, ...ollama],
284
- initialValue: current
285
- }));
286
- if (choice === config.embedModel || choice === "bge-small-en-v1.5" && !config.embedModel) {
287
- p.log.info(`Embedding model unchanged (${choice})`);
288
- return;
289
- }
290
- updateConfig({ embedModel: choice === "bge-small-en-v1.5" ? void 0 : choice });
291
- p.log.success(`Embedding model set to ${choice}`);
292
- p.log.warn("Run `skilld update` to rebuild existing search indexes with this model.");
293
- }
294
- async function configureEmbedDevice() {
295
- const config = readConfig();
296
- const current = config.embedDevice || "auto";
297
- const isOllama = isOllamaEmbedModel(resolveEmbedModel(config.embedModel));
298
- if (isOllama) p.log.warn("The active embedding model runs inside Ollama, which manages its own device. This setting will have no effect until you switch to a built-in model.");
299
- const envOverride = process.env.SKILLD_EMBED_DEVICE?.trim();
300
- if (envOverride) p.log.warn(`SKILLD_EMBED_DEVICE is set to ${envOverride} and overrides this setting for the current shell.`);
301
- p.note("The fastest backend depends on your hardware. On an Apple M5 Max, WebGPU\nran 2.6 to 2.9 times faster than CPU. CoreML ran 3 to 8 times slower.\nBenchmark before trusting a device on other machines.", "Choosing a device");
302
- const choice = guard(await p.select({
303
- message: "Embedding device: where the model runs",
304
- options: EMBED_DEVICES.map((d) => ({
305
- label: d.label,
306
- value: d.id,
307
- hint: d.hint
308
- })),
309
- initialValue: current
310
- }));
311
- if (choice === current) {
312
- p.log.info(`Embedding device unchanged (${choice})`);
313
- return;
314
- }
315
- updateConfig({ embedDevice: choice === "auto" ? void 0 : choice });
316
- p.log.success(`Embedding device set to ${choice}`);
317
- if (!isOllama) p.log.warn("Run `skilld update` to rebuild existing search indexes on this device.");
318
- if (choice !== "auto" && choice !== "cpu") p.log.info("If indexing fails to start, the backend is unavailable on this machine. Switch back to Auto.");
319
- }
320
- const configCommandDef = defineCommand({
321
- meta: {
322
- name: "config",
323
- description: "Edit settings"
324
- },
325
- args: {},
326
- async run() {
327
- requireInteractive("config");
328
- const cwd = process.cwd();
329
- const state = await getProjectState(cwd);
330
- p.intro(introLine({ state }));
331
- return configCommand();
332
- }
333
- });
334
- async function removeCommand(state, opts) {
335
- const scope = opts.global ? "global" : "local";
336
- const allSkills = [...iterateSkills({ scope })];
337
- if (!isInteractive() && !opts.packages) {
338
- console.error("Error: `skilld remove` requires package names in non-interactive mode.\n Usage: skilld remove <package...>");
339
- process.exit(1);
340
- }
341
- const skills = opts.packages ? allSkills.filter((s) => opts.packages.includes(s.name)) : await pickSkillsToRemove(allSkills, scope);
342
- if (!skills || skills.length === 0) {
343
- p.log.info("No skills selected");
344
- return;
345
- }
346
- if (!opts.yes && isInteractive()) {
347
- const confirmed = await p.confirm({ message: `Remove ${skills.length} skill(s)? ${skills.map((s) => s.name).join(", ")}` });
348
- if (p.isCancel(confirmed) || !confirmed) {
349
- p.cancel("Cancelled");
350
- return;
351
- }
352
- }
353
- const cwd = process.cwd();
354
- const shared = getSharedSkillsDir(cwd);
355
- for (const skill of skills) {
356
- const skillsDir = getSkillsDir(skill.agent, skill.scope);
357
- if (existsSync(skill.dir)) {
358
- rmSync(skill.dir, {
359
- recursive: true,
360
- force: true
361
- });
362
- removeLockEntry(skillsDir, skill.name);
363
- if (shared && skill.scope === "local") unlinkSkillFromAgents(skill.name, cwd, opts.agent);
364
- p.log.success(`Removed ${skill.name}`);
365
- } else p.log.warn(`${skill.name} not found`);
366
- }
367
- p.outro(`Removed ${skills.length} skill(s)`);
368
- }
369
- async function pickSkillsToRemove(skills, scope) {
370
- if (skills.length === 0) {
371
- p.log.warn(`No ${scope} skills installed`);
372
- return null;
373
- }
374
- const options = skills.map((skill) => ({
375
- label: skill.name,
376
- value: skill.name,
377
- hint: skill.info?.version ? `@${skill.info.version}` : void 0
378
- }));
379
- const selected = await p.multiselect({
380
- message: "Select skills to remove",
381
- options,
382
- required: false
383
- });
384
- if (p.isCancel(selected)) {
385
- p.cancel("Cancelled");
386
- return null;
387
- }
388
- const selectedSet = new Set(selected);
389
- return skills.filter((s) => selectedSet.has(s.name));
390
- }
391
- const removeCommandDef = defineCommand({
392
- meta: {
393
- name: "remove",
394
- description: "Remove installed skills"
395
- },
396
- args: {
397
- package: {
398
- type: "positional",
399
- description: "Package(s) to remove (space-separated)",
400
- required: false
401
- },
402
- ...sharedArgs
403
- },
404
- async run({ args }) {
405
- const cwd = process.cwd();
406
- let agent = resolveAgent(args.agent);
407
- if (!agent || agent === "none") {
408
- if (agent === "none") return;
409
- const picked = await promptForAgent();
410
- if (!picked || picked === "none") return;
411
- agent = picked;
412
- }
413
- const state = await getProjectState(cwd);
414
- const generators = getInstalledGenerators();
415
- const config = readConfig();
416
- const scope = args.global ? "global" : "project";
417
- const intro = {
418
- state,
419
- generators,
420
- modelId: config.model,
421
- agentId: agent || config.agent || void 0
422
- };
423
- p.intro(`${introLine(intro)} · remove (${scope})`);
424
- return removeCommand(state, {
425
- packages: args.package ? [...new Set([args.package, ...args._ || []].map((s) => s.trim()).filter(Boolean).map((s) => {
426
- const name = resolveSkillName(s);
427
- if (!name) {
428
- p.log.warn(`Cannot remove ${styleText("cyan", s)}: curator/collection inputs are not addressable here.`);
429
- return null;
430
- }
431
- return name;
432
- }).filter((s) => s !== null))] : void 0,
433
- global: args.global,
434
- agent,
435
- yes: args.yes
436
- });
437
- }
438
- });
439
- function countDocs(packageName, version) {
440
- if (!version) return 0;
441
- const cacheDir = getCacheDir(packageName, version);
442
- if (!existsSync(cacheDir)) return 0;
443
- let count = 0;
444
- const walk = (dir, depth = 0) => {
445
- if (depth > 3) return;
446
- try {
447
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
448
- if (entry.name === "search.db") continue;
449
- if (entry.isDirectory()) walk(join(dir, entry.name), depth + 1);
450
- else if (entry.name.endsWith(".md") || entry.name.endsWith(".mdx")) count++;
451
- }
452
- } catch {}
453
- };
454
- walk(cacheDir);
455
- return count;
456
- }
457
- async function countEmbeddings(packageName, version) {
458
- if (!version) return null;
459
- const dbPath = getPackageDbPath(packageName, version);
460
- if (!existsSync(dbPath)) return null;
461
- try {
462
- const { DatabaseSync } = await import("node:sqlite");
463
- const db = new DatabaseSync(dbPath, {
464
- open: true,
465
- readOnly: true
466
- });
467
- try {
468
- return db.prepare("SELECT count(*) as cnt FROM vector_metadata").get()?.cnt ?? null;
469
- } finally {
470
- db.close();
471
- }
472
- } catch {
473
- return null;
474
- }
475
- }
476
- function countRefDocs(skillDir) {
477
- const refsDir = skillInternalDir(skillDir);
478
- if (!existsSync(refsDir)) return 0;
479
- let count = 0;
480
- const walk = (dir, depth = 0) => {
481
- if (depth > 3) return;
482
- try {
483
- for (const entry of readdirSync(dir, { withFileTypes: true })) if (entry.isDirectory() || entry.isSymbolicLink()) try {
484
- if (statSync(join(dir, entry.name)).isDirectory()) walk(join(dir, entry.name), depth + 1);
485
- } catch {
486
- continue;
487
- }
488
- else if (entry.name.endsWith(".md") || entry.name.endsWith(".mdx")) count++;
489
- } catch {}
490
- };
491
- walk(refsDir);
492
- return count;
493
- }
494
- const dim = (s) => styleText("gray", s);
495
- const bold = (s) => styleText("bold", s);
496
- const green = (s) => styleText("green", s);
497
- function getLastSynced() {
498
- let latest = null;
499
- for (const skill of iterateSkills()) if (skill.info?.syncedAt) {
500
- const d = new Date(skill.info.syncedAt);
501
- if (!latest || d > latest) latest = d;
502
- }
503
- if (!latest) return null;
504
- return timeAgo(latest.toISOString());
505
- }
506
- function buildConfigLines() {
507
- const config = readConfig();
508
- const lines = [];
509
- lines.push(`Version v${version}`);
510
- const lastSynced = getLastSynced();
511
- if (lastSynced) lines.push(`Synced ${dim(lastSynced)}`);
512
- const shared = getSharedSkillsDir();
513
- if (shared) lines.push(`Shared ${dim(shared)}`);
514
- lines.push(`Config ${dim(join(CACHE_DIR, "config.yaml"))}${hasConfig() ? "" : dim(" (not created)")}`);
515
- lines.push(`Cache ${dim(CACHE_DIR)}`);
516
- const withCli = Object.entries(targets).filter(([_, a]) => a.cli);
517
- const installed = [];
518
- for (const [id, agent] of withCli) {
519
- const ver = getAgentVersion(id);
520
- if (ver) installed.push(`${agent.displayName} v${ver}`);
521
- }
522
- if (installed.length > 0) lines.push(`Agents ${installed.join(", ")}`);
523
- if (config.model) lines.push(`Model ${config.model}`);
524
- const features = {
525
- ...defaultFeatures,
526
- ...config.features
527
- };
528
- const parts = Object.entries(features).map(([k, v]) => `${k}: ${v ? green("on") : dim("off")}`);
529
- lines.push(`Features ${parts.join(", ")}`);
530
- if (config.projects?.length) lines.push(`Projects ${config.projects.length} registered`);
531
- return lines;
532
- }
533
- async function statusCommand(opts = {}) {
534
- const allSkills = [...iterateSkills({ scope: opts.global ? "global" : "all" })];
535
- p.log.step(bold("Skilld Config"));
536
- p.log.message(buildConfigLines().join("\n"));
537
- if (allSkills.length === 0) {
538
- p.log.step(bold("Skills"));
539
- p.log.message(`${dim("(none)")}\n\nRun ${bold("skilld add <package>")} to install skills`);
540
- return;
541
- }
542
- const localPkgs = /* @__PURE__ */ new Map();
543
- const globalPkgs = /* @__PURE__ */ new Map();
544
- for (const skill of allSkills) {
545
- const key = skill.info?.packageName || skill.name;
546
- const map = skill.scope === "local" ? localPkgs : globalPkgs;
547
- mapInsert(map, key, () => ({
548
- name: skill.name,
549
- info: skill.info || {},
550
- agents: /* @__PURE__ */ new Set(),
551
- scope: skill.scope
552
- })).agents.add(skill.agent);
553
- }
554
- const buildPackageLines = async (pkgs) => {
555
- const lines = [];
556
- for (const [, pkg] of pkgs) {
557
- const { info } = pkg;
558
- const icon = info.source === "shipped" ? "▶" : "◆";
559
- const pkgsList = parsePackages(info.packages);
560
- const nameDisplay = pkgsList.length > 1 ? `${pkg.name} ${dim(`(${pkgsList.map((p) => p.name).join(", ")})`)}` : pkg.name;
561
- const parts = [`${icon} ${bold(nameDisplay)}`];
562
- if (info.version) parts.push(dim(info.version));
563
- const source = formatSource(info.source);
564
- if (source && source !== "shipped") parts.push(dim(source));
565
- lines.push(parts.join(" "));
566
- const meta = [];
567
- const pkgName = toStoragePackageName(info.packageName || pkg.name);
568
- const docs = countDocs(pkgName, info.version) || countRefDocs(join(pkg.scope === "global" ? targets[pkg.agents.values().next().value].globalSkillsDir : join(process.cwd(), targets[pkg.agents.values().next().value].skillsDir), pkg.name));
569
- if (docs > 0) meta.push(`${docs} docs`);
570
- const embeddings = await countEmbeddings(pkgName, info.version);
571
- if (embeddings !== null) meta.push(`${embeddings} chunks`);
572
- const ago = timeAgo(info.syncedAt);
573
- if (ago) meta.push(`synced ${ago}`);
574
- if (pkg.agents.size > 0) {
575
- const agentNames = Array.from(pkg.agents, (a) => targets[a].displayName);
576
- meta.push(agentNames.join(", "));
577
- }
578
- if (meta.length > 0) lines.push(` ${dim(meta.join(" · "))}`);
579
- }
580
- return lines;
581
- };
582
- if (!opts.global && localPkgs.size > 0) {
583
- p.log.step(`${bold("Local")} (project)`);
584
- p.log.message((await buildPackageLines(localPkgs)).join("\n"));
585
- }
586
- if (globalPkgs.size > 0) {
587
- p.log.step(bold("Global"));
588
- p.log.message((await buildPackageLines(globalPkgs)).join("\n"));
589
- }
590
- if (!opts.global && localPkgs.size === 0) {
591
- p.log.step(`${bold("Local")} (project)`);
592
- p.log.message(dim("(none)"));
593
- }
594
- const total = localPkgs.size + globalPkgs.size;
595
- p.log.info(`${total} package${total !== 1 ? "s" : ""}`);
596
- }
597
- const infoCommandDef = defineCommand({
598
- meta: {
599
- name: "info",
600
- description: "Show skill info and config"
601
- },
602
- args: { global: sharedArgs.global },
603
- run({ args }) {
604
- return statusCommand({ global: args.global });
605
- }
606
- });
607
- const NOISE_CHARS = "⣿⡿⣷⣾⣽⣻⢿⡷⣯⣟⡾⣵⣳⢾⡽⣞⡷⣝⢯";
608
- function djb2(s) {
609
- let h = 5381;
610
- for (let i = 0; i < s.length; i++) h = (h << 5) + h + s.charCodeAt(i) >>> 0;
611
- return h;
612
- }
613
- function hueToChannel(p, q, t) {
614
- const t1 = t < 0 ? t + 1 : t > 1 ? t - 1 : t;
615
- if (t1 < 1 / 6) return p + (q - p) * 6 * t1;
616
- if (t1 < 1 / 2) return q;
617
- if (t1 < 2 / 3) return p + (q - p) * (2 / 3 - t1) * 6;
618
- return p;
619
- }
620
- function hsl(h, s, l) {
621
- const q = l < .5 ? l * (1 + s) : l + s - l * s;
622
- const p = 2 * l - q;
623
- return [
624
- Math.round(hueToChannel(p, q, h + 1 / 3) * 255),
625
- Math.round(hueToChannel(p, q, h) * 255),
626
- Math.round(hueToChannel(p, q, h - 1 / 3) * 255)
627
- ];
628
- }
629
- const BRAND_HUE = djb2(process.cwd()) % 360 / 360;
630
- function noiseChar(brightness, density = 0) {
631
- if (brightness < .08) return " ";
632
- const b = Math.min(brightness, 1);
633
- const ch = Math.random() < density ? "⣿" : NOISE_CHARS[Math.floor(Math.random() * 19)];
634
- const [r, g, bl] = hsl(BRAND_HUE, .4 + b * .15, .35 + b * .25);
635
- return `\x1B[38;2;${r};${g};${bl}m${ch}`;
636
- }
637
- function noiseLine(len, brightnessFn, density = 0) {
638
- let s = "";
639
- for (let i = 0; i < len; i++) s += noiseChar(brightnessFn(i), density);
640
- return `${s}\x1B[0m`;
641
- }
642
- const BRAND_MARK = "\x1B[38;2;251;113;133m⏶\x1B[0m";
643
- function brandFrame(t, floor = 0, density = 0) {
644
- const cx = 5;
645
- const cy = 1;
646
- const brightness = (x, y) => {
647
- const d = Math.sqrt((x - cx) ** 2 + ((y - cy) * 3) ** 2);
648
- let val = 0;
649
- for (let ring = 0; ring < 3; ring++) {
650
- const rt = t - ring * .5;
651
- if (rt <= 0) continue;
652
- const front = rt * 4;
653
- const proximity = Math.abs(d - front);
654
- val += Math.exp(-proximity * proximity * .8) * Math.exp(-rt * .4);
655
- }
656
- const base = Math.max(0, (t - 1.5) * .3) * (Math.random() * .3 + .1);
657
- return Math.min(1, Math.max(floor, val + base));
658
- };
659
- return [
660
- noiseLine(10, (x) => brightness(x, 0), density),
661
- `${noiseLine(2, (x) => brightness(x, 1), density)} ${BRAND_MARK} %NAME% ${noiseLine(2, (x) => brightness(x + 8, 1), density)} %VER%`,
662
- noiseLine(10, (x) => brightness(x, 2), density)
663
- ].join("\n");
664
- }
665
- async function brandLoader(work, minMs = 1500) {
666
- if (process.env.SKILLD_EFFECT === "none") return work();
667
- const name = "\x1B[1m\x1B[38;2;255;255;255mskilld\x1B[0m";
668
- const verStr = styleText("dim", `v${version}`);
669
- const status = styleText("dim", "Setting up your environment");
670
- const start = Date.now();
671
- const sub = (raw) => raw.replace("%NAME%", name).replace("%VER%", verStr);
672
- let done = false;
673
- const result = Promise.all([work(), new Promise((r) => setTimeout(r, minMs))]).then(([v]) => {
674
- done = true;
675
- return v;
676
- });
677
- while (!done) {
678
- const t = (Date.now() - start) / 1e3;
679
- logUpdate(`\n ${sub(brandFrame(t))}\n\n ${status}`);
680
- await new Promise((r) => setTimeout(r, 60));
681
- }
682
- const outroMs = 500;
683
- const outroStart = Date.now();
684
- const tFinal = (outroStart - start) / 1e3;
685
- while (Date.now() - outroStart < outroMs) {
686
- const p = (Date.now() - outroStart) / outroMs;
687
- const eased = p * p;
688
- logUpdate(`\n ${sub(brandFrame(tFinal + p * .5, eased * .9, eased))}\n`);
689
- await new Promise((r) => setTimeout(r, 40));
690
- }
691
- logUpdate(`\n ${sub(brandFrame(tFinal + 1, .9, 1))}\n`);
692
- logUpdate.done();
693
- return result;
694
- }
695
- const STATIC_REGEX_3 = /^[\^~>=<]/;
696
- const _emit = process.emit;
697
- process.emit = (event, ...args) => event === "warning" && args[0]?.name === "ExperimentalWarning" && args[0]?.message?.includes("SQLite") ? false : _emit.apply(process, [event, ...args]);
698
- function deprecatedForwarder(oldName, newName, loader) {
699
- return () => loader().then((cmd) => {
700
- const original = cmd.run;
701
- return defineCommand({
702
- ...cmd,
703
- meta: {
704
- ...cmd.meta,
705
- name: oldName
706
- },
707
- async run(ctx) {
708
- console.warn(styleText("yellow", `⚠ \`skilld ${oldName}\` is deprecated. Use \`skilld ${newName}\` instead.`));
709
- return original(ctx);
710
- }
711
- });
712
- });
713
- }
714
- const SUBCOMMAND_NAMES = [
715
- "add",
716
- "eject",
717
- "update",
718
- "changes",
719
- "watch",
720
- "unwatch",
721
- "info",
722
- "list",
723
- "config",
724
- "remove",
725
- "install",
726
- "uninstall",
727
- "search",
728
- "cache",
729
- "validate",
730
- "assemble",
731
- "setup",
732
- "prepare",
733
- "author",
734
- "publish",
735
- "upload",
736
- "login",
737
- "logout",
738
- "whoami",
739
- "pull"
740
- ];
741
- const main = defineCommand({
742
- meta: {
743
- name: "skilld",
744
- version,
745
- description: "Curated agent skills for your projects"
746
- },
747
- args: rootArgs,
748
- subCommands: {
749
- add: () => import("./_chunks/add.mjs").then((m) => m.addCommandDef),
750
- update: () => import("./_chunks/update.mjs").then((m) => m.updateCommandDef),
751
- changes: () => import("./_chunks/changes.mjs").then((m) => m.changesCommandDef),
752
- watch: () => import("./_chunks/watch.mjs").then((m) => m.watchCommandDef),
753
- unwatch: () => import("./_chunks/watch.mjs").then((m) => m.unwatchCommandDef),
754
- info: () => infoCommandDef,
755
- list: () => import("./_chunks/list.mjs").then((m) => m.listCommandDef),
756
- config: () => configCommandDef,
757
- remove: () => removeCommandDef,
758
- install: () => import("./_chunks/install.mjs").then((m) => m.installCommandDef),
759
- prepare: () => import("./_chunks/prepare2.mjs").then((m) => m.prepareCommandDef),
760
- uninstall: () => import("./_chunks/uninstall.mjs").then((m) => m.uninstallCommandDef),
761
- search: () => import("./_chunks/search.mjs").then((m) => m.searchCommandDef),
762
- cache: () => import("./_chunks/cache2.mjs").then((m) => m.cacheCommandDef),
763
- setup: () => import("./_chunks/wizard.mjs").then((m) => m.setupCommandDef),
764
- login: () => import("./_chunks/login.mjs").then((m) => m.loginCommandDef),
765
- logout: () => import("./_chunks/logout.mjs").then((m) => m.logoutCommandDef),
766
- whoami: () => import("./_chunks/whoami.mjs").then((m) => m.whoamiCommandDef),
767
- pull: () => import("./_chunks/pull.mjs").then((m) => m.pullCommandDef),
768
- author: () => import("./_chunks/author.mjs").then((m) => m.authorGroupDef),
769
- eject: deprecatedForwarder("eject", "author eject", () => import("./_chunks/eject.mjs").then((m) => m.ejectCommandDef)),
770
- validate: deprecatedForwarder("validate", "author validate", () => import("./_chunks/validate.mjs").then((m) => m.validateCommandDef)),
771
- assemble: deprecatedForwarder("assemble", "author assemble", () => import("./_chunks/assemble.mjs").then((m) => m.assembleCommandDef)),
772
- publish: deprecatedForwarder("publish", "author publish", () => import("./_chunks/upload.mjs").then((m) => m.uploadCommandDef)),
773
- upload: deprecatedForwarder("upload", "author publish", () => import("./_chunks/upload.mjs").then((m) => m.uploadCommandDef))
774
- },
775
- async run({ args }) {
776
- const firstArg = process.argv[2];
777
- if (firstArg && !firstArg.startsWith("-") && SUBCOMMAND_NAMES.includes(firstArg)) return;
778
- const cwd = process.cwd();
779
- if (!isInteractive()) {
780
- const state = await getProjectState(cwd);
781
- const status = formatStatus(state.synced.length, state.outdated.length);
782
- console.log(`skilld v${version} · ${status}`);
783
- if (isRunningInsideAgent()) console.log("Interactive wizard requires a standalone terminal (detected agent session).\nUse `skilld add <pkg>` to add skills non-interactively, or run `npx skilld` in a separate terminal.");
784
- return;
785
- }
786
- let currentAgent = resolveAgent(args.agent);
787
- if (!currentAgent) {
788
- currentAgent = await promptForAgent();
789
- if (!currentAgent) return;
790
- }
791
- if (currentAgent === "none") {
792
- if (!hasCompletedWizard()) {
793
- if (!await runWizard()) return;
794
- }
795
- p.log.info(`No agent selected - skills export as portable PROMPT_*.md files.
796
- Run ${styleText("cyan", "skilld add <pkg>")} to generate prompts for any package.\n Run ${styleText("cyan", "skilld config")} to set a target agent later.`);
797
- return;
798
- }
799
- const agent = currentAgent;
800
- let { state, selfUpdate } = await brandLoader(async () => {
801
- const config = readConfig();
802
- const state = await getProjectState(cwd);
803
- let selfUpdate = null;
804
- const tasks = [];
805
- if (!(process.env.npm_command === "exec")) tasks.push(fetchNpmRegistryMeta("skilld", version).then((meta) => {
806
- const latestTag = meta.distTags?.latest;
807
- if (latestTag && semverGt(latestTag.version, version)) selfUpdate = {
808
- latest: latestTag.version,
809
- releasedAt: latestTag.releasedAt
810
- };
811
- }).catch(() => {}));
812
- if (state.unmatched.length > 0) {
813
- const limit = pLimit(5);
814
- tasks.push(Promise.all(state.unmatched.map((skill) => limit(async () => {
815
- const pkgName = skill.info?.packageName || skill.name;
816
- const latest = await fetchLatestVersion(pkgName);
817
- if (latest && isOutdated(skill, latest)) state.outdated.push({
818
- ...skill,
819
- packageName: pkgName,
820
- latestVersion: latest
821
- });
822
- else if (latest) state.synced.push({
823
- ...skill,
824
- packageName: pkgName,
825
- latestVersion: latest
826
- });
827
- }))).then(() => {}));
828
- }
829
- await Promise.all(tasks);
830
- return {
831
- config,
832
- state,
833
- selfUpdate
834
- };
835
- });
836
- if (selfUpdate) {
837
- const released = selfUpdate.releasedAt ? styleText("gray", ` · ${relativeTime(new Date(selfUpdate.releasedAt))}`) : "";
838
- const cmd = `npx nypm add${realpathSync(process.argv[1]).startsWith(resolve(cwd, "node_modules")) ? "" : " -g"} skilld@${selfUpdate.latest}`;
839
- p.note(`${styleText("gray", version)} → ${styleText(["bold", "green"], selfUpdate.latest)}${released}\n${styleText("cyan", cmd)}`, styleText("yellow", "Update available"));
840
- }
841
- if (state.skills.length === 0) {
842
- if (!hasCompletedWizard()) {
843
- if (!await runWizard({
844
- agent,
845
- showOutro: false
846
- })) return;
847
- } else p.log.step("No skills installed yet - pick some packages to get started.");
848
- const pkgJsonPath = join(cwd, "package.json");
849
- const projectPkg = readPackageJsonSafe(pkgJsonPath);
850
- const hasPkgJson = !!projectPkg;
851
- const projectName = projectPkg?.parsed.name;
852
- const projectLabel = projectName ? `Generating skills for ${styleText("cyan", projectName)}` : "Generating skills for current directory";
853
- p.log.step(projectLabel);
854
- if (!hasPkgJson) p.log.warn("No package.json found - enter npm package names manually.\n For best results, run skilld inside a JS/TS project directory.");
855
- if (state.shipped.length > 0) {
856
- const totalShipped = state.shipped.reduce((sum, s) => sum + s.skills.length, 0);
857
- const names = state.shipped.map((s) => s.packageName).join(", ");
858
- p.log.info(`${styleText("cyan", `${totalShipped} ready-to-use skill${totalShipped > 1 ? "s" : ""}`)} shipped by your dependencies: ${names}`);
859
- }
860
- p.log.info("Tip: Add skills for packages with complex APIs or frequent breaking changes - not every dependency needs one.");
861
- let setupComplete = false;
862
- while (!setupComplete) {
863
- const shippedOption = state.shipped.length > 0 ? [{
864
- label: "Install shipped skills",
865
- value: "shipped",
866
- hint: styleText("cyan", `${state.shipped.reduce((sum, s) => sum + s.skills.length, 0)} ready to use`)
867
- }] : [];
868
- const source = hasPkgJson ? await p.select({
869
- message: "How should I find packages?",
870
- options: [
871
- ...shippedOption,
872
- {
873
- label: "Scan source files",
874
- value: "imports",
875
- hint: "find actually used imports"
876
- },
877
- {
878
- label: "Use package.json",
879
- value: "deps",
880
- hint: `all ${state.deps.size} dependencies`
881
- },
882
- {
883
- label: "Enter manually",
884
- value: "manual"
885
- },
886
- {
887
- label: "Skip for now",
888
- value: "skip",
889
- hint: "add skills later with `skilld add <pkg>`"
890
- }
891
- ]
892
- }) : "manual";
893
- if (p.isCancel(source)) {
894
- p.cancel("Setup cancelled");
895
- return;
896
- }
897
- if (source === "skip") {
898
- p.log.info(`Run ${styleText("cyan", "skilld add <pkg>")} or ${styleText("cyan", "skilld")} anytime to add skills.`);
899
- return;
900
- }
901
- if (source === "shipped") {
902
- const { handleShippedSkills: installShipped } = await import("./_chunks/skill-installer.mjs");
903
- for (const pkg of state.shipped) {
904
- const version = state.deps.get(pkg.packageName)?.replace(VERSION_RANGE_PREFIX_RE, "") || "0.0.0";
905
- installShipped(pkg.packageName, version, cwd, agent, false);
906
- for (const sk of pkg.skills) p.log.success(`Installed shipped skill: ${sk.skillName}`);
907
- }
908
- state = await getProjectState(cwd);
909
- continue;
910
- }
911
- let selected;
912
- if (source === "manual") {
913
- const input = await p.text({
914
- message: "Enter package names (space or comma-separated)",
915
- placeholder: "vue npm:nuxt pinia"
916
- });
917
- if (p.isCancel(input)) {
918
- if (!hasPkgJson) {
919
- p.cancel("Setup cancelled");
920
- return;
921
- }
922
- continue;
923
- }
924
- if (!input) {
925
- p.log.warn("No packages entered");
926
- continue;
927
- }
928
- const parsed = parseNpmPackageInputs(input.split(COMMA_OR_WHITESPACE_RE).map((s) => s.trim()).filter(Boolean));
929
- if (parsed._tag === "Err") {
930
- p.log.error(`${parsed.input} is not an npm package. Install it with \`skilld add ${parsed.input}\`.`);
931
- continue;
932
- }
933
- selected = parsed.packageSpecs;
934
- if (selected.length === 0) {
935
- p.log.warn("No valid packages entered");
936
- continue;
937
- }
938
- } else {
939
- let usages;
940
- if (source === "imports") {
941
- const spinner = timedSpinner();
942
- spinner.start("Scanning imports...");
943
- const result = await detectImportedPackages(cwd);
944
- if (result.packages.length === 0) {
945
- spinner.stop("No imports found, falling back to package.json");
946
- usages = Array.from(state.deps.keys(), (name) => ({
947
- name,
948
- count: 0
949
- }));
950
- } else {
951
- const depSet = new Set(state.deps.keys());
952
- usages = result.packages.filter((pkg) => depSet.has(pkg.name) || pkg.source === "preset");
953
- if (usages.length === 0) {
954
- spinner.stop(`Found ${result.packages.length} imported packages but none match dependencies`);
955
- usages = result.packages;
956
- } else spinner.stop(`Found ${usages.length} imported packages`);
957
- }
958
- } else usages = Array.from(state.deps.keys(), (name) => ({
959
- name,
960
- count: 0
961
- }));
962
- const packages = usages.map((u) => u.name);
963
- if (packages.length === 0) {
964
- p.log.warn("No packages found");
965
- continue;
966
- }
967
- const sourceMap = new Map(usages.map((u) => [u.name, u.source]));
968
- const maxLen = Math.max(...packages.map((n) => n.length));
969
- const preselect = packages.filter((name) => {
970
- if (sourceMap.get(name) === "preset") return true;
971
- return (/* @__PURE__ */ new Set([
972
- "vue",
973
- "nuxt",
974
- "react",
975
- "next",
976
- "svelte",
977
- "@sveltejs/kit",
978
- "astro",
979
- "solid-js",
980
- "angular",
981
- "typescript",
982
- "vite",
983
- "vitest"
984
- ])).has(name);
985
- });
986
- const choice = await p.multiselect({
987
- message: `Select packages (${packages.length} found)`,
988
- options: packages.map((name) => {
989
- const ver = state.deps.get(name)?.replace(STATIC_REGEX_3, "") || "";
990
- const repo = getRepoHint(name, cwd);
991
- const hint = sourceMap.get(name) === "preset" ? "nuxt module" : void 0;
992
- const pad = " ".repeat(maxLen - name.length + 2);
993
- const meta = [
994
- ver,
995
- hint,
996
- repo
997
- ].filter(Boolean).join(" ");
998
- return {
999
- label: meta ? `${name}${pad}${styleText("gray", meta)}` : name,
1000
- value: name
1001
- };
1002
- }),
1003
- initialValues: preselect
1004
- });
1005
- if (p.isCancel(choice)) continue;
1006
- if (choice.length === 0) {
1007
- p.log.warn("No packages selected");
1008
- continue;
1009
- }
1010
- selected = choice;
1011
- }
1012
- const wizardConfig = readConfig();
1013
- const { syncCommand } = await import("./_chunks/sync2.mjs");
1014
- await syncCommand(state, {
1015
- packages: selected,
1016
- global: false,
1017
- agent,
1018
- model: wizardConfig.model,
1019
- yes: !wizardConfig.skipLlm
1020
- });
1021
- setupComplete = true;
1022
- }
1023
- const previewSkill = (await getProjectState(cwd)).skills[0];
1024
- if (previewSkill) {
1025
- const previewPath = join(cwd, targets[agent].skillsDir, previewSkill.name, "SKILL.md");
1026
- if (existsSync(previewPath)) {
1027
- const previewContent = readFileSync(previewPath, "utf-8");
1028
- const previewLines = previewContent.split("\n").slice(0, 20).join("\n").replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, "").replace(/\x1B\].*?(?:\x07|\x1B\\)/g, "");
1029
- const fileSize = (Buffer.byteLength(previewContent) / 1024).toFixed(1);
1030
- p.note(styleText("gray", `${previewLines}\n...`), `${targets[agent].skillsDir}/${previewSkill.name}/SKILL.md (${fileSize} KB)`);
1031
- }
1032
- }
1033
- const agentName = targets[agent].displayName;
1034
- const verifyLine = detectInstalledAgents().includes(agent) ? {
1035
- "claude-code": "Start a new Claude Code session - skills load automatically.\nOr type /skill-name to invoke a specific skill.",
1036
- "cursor": "Restart Cursor to pick up new skills.\nSkills appear in Settings > Cursor Rules.",
1037
- "github-copilot": "Restart your editor to pick up new skills.\nCopilot discovers skills from .github/skills/ at startup.",
1038
- "gemini-cli": "Start a new Gemini CLI session.\nVerify with /skills list.",
1039
- "codex": "Start a new Codex session.\nSkills in .agents/skills/ are discovered at startup.",
1040
- "windsurf": "Restart Windsurf to pick up new skills.\nSkills auto-invoke when their description matches your prompt.",
1041
- "cline": "Restart your editor. Cline reads skill descriptions at startup.\nFull content loads on-demand when the agent invokes use_skill.",
1042
- "goose": "Start a new Goose session.\nSkills are discovered automatically at startup.",
1043
- "amp": "Start a new Amp session.\nReads skill descriptions at startup, full content on invocation.",
1044
- "opencode": "Start a new OpenCode session.\nSkills are discovered automatically at startup.",
1045
- "roo": "Restart your editor. Roo reads skill descriptions at startup."
1046
- }[agent] ?? "" : `Skills are ready in ${targets[agent].skillsDir}/.\n${styleText("gray", `${agentName} was not detected on this machine.\nInstall it to use these skills, or run \`skilld config\` to change agents.`)}`;
1047
- const firstPkg = previewSkill?.info?.packageName || previewSkill?.name;
1048
- const trySuggestion = firstPkg ? `\n\n${styleText("cyan", "Try it:")} ask your agent "What are the gotchas or breaking changes in ${firstPkg}?"` : "";
1049
- p.note(`${verifyLine}${trySuggestion}\n\nRun ${styleText("cyan", "skilld info")} to see installed skills.\nRun ${styleText("cyan", "skilld")} again to add more, update, or search.`, `${agentName} - next steps`);
1050
- try {
1051
- await suggestPrepareHook(cwd);
1052
- } catch (err) {
1053
- p.log.warn(`Failed to suggest prepare hook: ${err instanceof Error ? err.message : String(err)}`);
1054
- }
1055
- return;
1056
- }
1057
- const status = formatStatus(state.synced.length, state.outdated.length);
1058
- p.log.info(status);
1059
- let needsPrepareHook = !hasPrepareHook(cwd);
1060
- if (needsPrepareHook) p.log.warn(`${styleText("yellow", "No prepare hook.")} Skills won't auto-restore on ${styleText("cyan", "npm install")}.`);
1061
- if (state.shipped.length > 0) {
1062
- const totalSkills = state.shipped.reduce((sum, s) => sum + s.skills.length, 0);
1063
- const names = state.shipped.map((s) => s.packageName).join(", ");
1064
- p.log.info(`${styleText("cyan", `${totalSkills} ready-to-use skill${totalSkills > 1 ? "s" : ""}`)} shipped by your dependencies: ${names}`);
1065
- }
1066
- const refreshState = async () => {
1067
- state = await getProjectState(cwd);
1068
- };
1069
- await menuLoop({
1070
- message: "What would you like to do?",
1071
- options: () => {
1072
- const opts = [];
1073
- if (state.shipped.length > 0) {
1074
- const total = state.shipped.reduce((sum, s) => sum + s.skills.length, 0);
1075
- opts.push({
1076
- label: "Install shipped skills",
1077
- value: "shipped",
1078
- hint: styleText("cyan", `${total} available`)
1079
- });
1080
- }
1081
- opts.push({
1082
- label: "Add new skills",
1083
- value: "install"
1084
- });
1085
- if (state.outdated.length > 0) opts.push({
1086
- label: "Update skills",
1087
- value: "update",
1088
- hint: styleText("yellow", `${state.outdated.length} outdated`)
1089
- });
1090
- if (needsPrepareHook) opts.push({
1091
- label: "Setup prepare hook",
1092
- value: "prepare-hook",
1093
- hint: styleText("yellow", "recommended")
1094
- });
1095
- opts.push({
1096
- label: "Remove skills",
1097
- value: "remove"
1098
- }, {
1099
- label: "Search docs",
1100
- value: "search"
1101
- }, {
1102
- label: "Info",
1103
- value: "info"
1104
- }, {
1105
- label: "Configure",
1106
- value: "config"
1107
- });
1108
- return opts;
1109
- },
1110
- onSelect: async (action) => {
1111
- switch (action) {
1112
- case "shipped": {
1113
- const allShipped = state.shipped.flatMap((s) => s.skills.map((sk) => ({
1114
- packageName: s.packageName,
1115
- ...sk
1116
- })));
1117
- const selected = guard(await p.multiselect({
1118
- message: "Select shipped skills to install",
1119
- options: allShipped.map((s) => ({
1120
- label: s.skillName,
1121
- value: s,
1122
- hint: s.packageName
1123
- })),
1124
- initialValues: allShipped
1125
- }));
1126
- if (selected.length === 0) return;
1127
- const { handleShippedSkills: installShipped } = await import("./_chunks/skill-installer.mjs");
1128
- const seen = /* @__PURE__ */ new Set();
1129
- for (const s of selected) {
1130
- if (seen.has(s.packageName)) continue;
1131
- seen.add(s.packageName);
1132
- const version = state.deps.get(s.packageName)?.replace(VERSION_RANGE_PREFIX_RE, "") || "0.0.0";
1133
- installShipped(s.packageName, version, cwd, agent, false);
1134
- }
1135
- p.log.success(`Installed ${selected.length} shipped skill${selected.length > 1 ? "s" : ""}`);
1136
- await refreshState();
1137
- return true;
1138
- }
1139
- case "install": {
1140
- const installedNames = new Set([...state.synced.map((s) => s.packageName), ...state.outdated.map((s) => s.packageName)].filter(Boolean));
1141
- const uninstalledDeps = [...state.deps.keys()].filter((d) => !installedNames.has(d));
1142
- const allDepsInstalled = uninstalledDeps.length === 0;
1143
- const source = !!readPackageJsonSafe(join(cwd, "package.json")) ? guard(await p.select({
1144
- message: "How should I find packages?",
1145
- options: [
1146
- {
1147
- label: "Scan source files",
1148
- value: "imports",
1149
- hint: allDepsInstalled ? "all installed" : "find actually used imports",
1150
- disabled: allDepsInstalled
1151
- },
1152
- {
1153
- label: "Use package.json",
1154
- value: "deps",
1155
- hint: allDepsInstalled ? "all installed" : `${uninstalledDeps.length} uninstalled`,
1156
- disabled: allDepsInstalled
1157
- },
1158
- {
1159
- label: "Enter manually",
1160
- value: "manual"
1161
- }
1162
- ]
1163
- })) : "manual";
1164
- let selected;
1165
- if (source === "manual") {
1166
- const input = guard(await p.text({
1167
- message: "Enter package names (space or comma-separated)",
1168
- placeholder: "vue npm:nuxt pinia"
1169
- }));
1170
- if (!input) return;
1171
- const parsed = parseNpmPackageInputs(input.split(COMMA_OR_WHITESPACE_RE).map((s) => s.trim()).filter(Boolean));
1172
- if (parsed._tag === "Err") {
1173
- p.log.error(`${parsed.input} is not an npm package. Install it with \`skilld add ${parsed.input}\`.`);
1174
- return;
1175
- }
1176
- selected = parsed.packageSpecs;
1177
- if (selected.length === 0) return;
1178
- } else {
1179
- let usages;
1180
- if (source === "imports") {
1181
- const spinner = timedSpinner();
1182
- spinner.start("Scanning imports...");
1183
- const result = await detectImportedPackages(cwd);
1184
- if (result.packages.length === 0) {
1185
- spinner.stop("No imports found, falling back to package.json");
1186
- usages = uninstalledDeps.map((name) => ({
1187
- name,
1188
- count: 0
1189
- }));
1190
- } else {
1191
- const depSet = new Set(state.deps.keys());
1192
- const matched = result.packages.filter((pkg) => depSet.has(pkg.name) || pkg.source === "preset");
1193
- const alreadyInstalled = matched.filter((pkg) => installedNames.has(pkg.name));
1194
- usages = matched.filter((pkg) => !installedNames.has(pkg.name));
1195
- if (usages.length === 0) {
1196
- spinner.stop("All detected imports already have skills");
1197
- return;
1198
- } else {
1199
- spinner.stop(`Found ${matched.length} imported packages`);
1200
- if (alreadyInstalled.length > 0) p.log.info(`${alreadyInstalled.length} already have skills installed`);
1201
- }
1202
- }
1203
- } else usages = uninstalledDeps.map((name) => ({
1204
- name,
1205
- count: 0
1206
- }));
1207
- const packages = usages.map((u) => u.name);
1208
- if (packages.length === 0) {
1209
- p.log.warn("No packages found");
1210
- return;
1211
- }
1212
- const usageMap = new Map(usages.map((u) => [u.name, u]));
1213
- const sourceMap = new Map(usages.map((u) => [u.name, u.source]));
1214
- const frameworks = /* @__PURE__ */ new Set([
1215
- "vue",
1216
- "nuxt",
1217
- "react",
1218
- "next",
1219
- "svelte",
1220
- "@sveltejs/kit",
1221
- "astro",
1222
- "solid-js",
1223
- "angular",
1224
- "typescript",
1225
- "vite",
1226
- "vitest"
1227
- ]);
1228
- const maxLen = Math.max(...packages.map((n) => n.length));
1229
- const choice = guard(await p.multiselect({
1230
- message: `Select packages your agent struggles with or that are new to you (${packages.length} found)`,
1231
- options: packages.map((name) => {
1232
- const ver = state.deps.get(name)?.replace(STATIC_REGEX_3, "") || "";
1233
- const repo = getRepoHint(name, cwd);
1234
- const hint = sourceMap.get(name) === "preset" ? "nuxt module" : frameworks.has(name) ? "framework" : (usageMap.get(name)?.count ?? 0) >= 5 ? `${usageMap.get(name).count} imports` : void 0;
1235
- const pad = " ".repeat(maxLen - name.length + 2);
1236
- const meta = [
1237
- ver,
1238
- hint,
1239
- repo
1240
- ].filter(Boolean).join(" ");
1241
- return {
1242
- label: meta ? `${name}${pad}${styleText("gray", meta)}` : name,
1243
- value: name
1244
- };
1245
- }),
1246
- initialValues: []
1247
- }));
1248
- if (choice.length === 0) return;
1249
- selected = choice;
1250
- }
1251
- const { syncCommand: sync } = await import("./_chunks/sync2.mjs");
1252
- await sync(state, {
1253
- packages: selected,
1254
- global: false,
1255
- agent,
1256
- yes: false
1257
- });
1258
- await refreshState();
1259
- return true;
1260
- }
1261
- case "update": {
1262
- if (state.outdated.length === 0) {
1263
- p.log.success("All skills up to date");
1264
- return true;
1265
- }
1266
- const selected = guard(await p.multiselect({
1267
- message: "Select packages to update",
1268
- options: state.outdated.map((s) => ({
1269
- label: s.name,
1270
- value: s.packageName || s.name,
1271
- hint: `${s.info?.version ?? "unknown"} → ${s.latestVersion}`
1272
- })),
1273
- initialValues: state.outdated.map((s) => s.packageName || s.name)
1274
- }));
1275
- if (selected.length === 0) return;
1276
- const { syncCommand: syncUpdate } = await import("./_chunks/sync2.mjs");
1277
- await syncUpdate(state, {
1278
- packages: selected,
1279
- global: false,
1280
- agent,
1281
- yes: false,
1282
- mode: "update"
1283
- });
1284
- await refreshState();
1285
- return true;
1286
- }
1287
- case "remove": {
1288
- const globalSkills = [...iterateSkills({ scope: "global" })];
1289
- let removeGlobal = false;
1290
- if (globalSkills.length > 0) removeGlobal = guard(await p.select({
1291
- message: "Which skills?",
1292
- options: [{
1293
- label: "Project skills",
1294
- value: "local"
1295
- }, {
1296
- label: "Global skills",
1297
- value: "global",
1298
- hint: `${globalSkills.length} installed`
1299
- }]
1300
- })) === "global";
1301
- await removeCommand(state, {
1302
- global: removeGlobal,
1303
- agent,
1304
- yes: false
1305
- });
1306
- await refreshState();
1307
- break;
1308
- }
1309
- case "search": {
1310
- const { interactiveSearch } = await import("./_chunks/search-interactive.mjs");
1311
- await interactiveSearch();
1312
- break;
1313
- }
1314
- case "info":
1315
- await statusCommand({ global: false });
1316
- break;
1317
- case "config":
1318
- await configCommand();
1319
- await refreshState();
1320
- break;
1321
- case "prepare-hook": if (await suggestPrepareHook(cwd)) needsPrepareHook = false;
1322
- }
1323
- }
1324
- });
1325
- }
1326
- });
1327
- runMain(main);
1328
- export {};
1329
-
1330
- //# sourceMappingURL=cli.mjs.map