skilld 1.5.4 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/_chunks/agent.mjs +10 -78
- package/dist/_chunks/agent.mjs.map +1 -1
- package/dist/_chunks/assemble.mjs +0 -17
- package/dist/_chunks/assemble.mjs.map +1 -1
- package/dist/_chunks/author.mjs +0 -18
- package/dist/_chunks/author.mjs.map +1 -1
- package/dist/_chunks/cache.mjs +0 -72
- package/dist/_chunks/cache.mjs.map +1 -1
- package/dist/_chunks/cache2.mjs +84 -17
- package/dist/_chunks/cache2.mjs.map +1 -1
- package/dist/_chunks/cli-helpers.mjs +2 -49
- package/dist/_chunks/cli-helpers.mjs.map +1 -1
- package/dist/_chunks/cli-helpers2.mjs +0 -11
- package/dist/_chunks/config.mjs +0 -27
- package/dist/_chunks/config.mjs.map +1 -1
- package/dist/_chunks/core.mjs +9 -0
- package/dist/_chunks/detect.mjs +29 -226
- package/dist/_chunks/detect.mjs.map +1 -1
- package/dist/_chunks/embedding-cache.mjs +0 -5
- package/dist/_chunks/embedding-cache2.mjs +1 -2
- package/dist/_chunks/formatting.mjs +0 -6
- package/dist/_chunks/formatting.mjs.map +1 -1
- package/dist/_chunks/index.d.mts +0 -10
- package/dist/_chunks/index.d.mts.map +1 -1
- package/dist/_chunks/index2.d.mts +3 -6
- package/dist/_chunks/index2.d.mts.map +1 -1
- package/dist/_chunks/index3.d.mts +2 -31
- package/dist/_chunks/index3.d.mts.map +1 -1
- package/dist/_chunks/install.mjs +0 -15
- package/dist/_chunks/install.mjs.map +1 -1
- package/dist/_chunks/libs/@sinclair/typebox.mjs +0 -444
- package/dist/_chunks/libs/@sinclair/typebox.mjs.map +1 -1
- package/dist/_chunks/list.mjs +0 -16
- package/dist/_chunks/list.mjs.map +1 -1
- package/dist/_chunks/lockfile.mjs +1 -10
- package/dist/_chunks/lockfile.mjs.map +1 -1
- package/dist/_chunks/markdown.mjs +0 -9
- package/dist/_chunks/markdown.mjs.map +1 -1
- package/dist/_chunks/package-json.mjs +0 -25
- package/dist/_chunks/package-json.mjs.map +1 -1
- package/dist/_chunks/pool2.mjs +0 -2
- package/dist/_chunks/pool2.mjs.map +1 -1
- package/dist/_chunks/prepare.mjs +8 -7
- package/dist/_chunks/prepare.mjs.map +1 -1
- package/dist/_chunks/prepare2.mjs +0 -18
- package/dist/_chunks/prepare2.mjs.map +1 -1
- package/dist/_chunks/prompts.mjs +1 -102
- package/dist/_chunks/prompts.mjs.map +1 -1
- package/dist/_chunks/retriv.mjs +23 -24
- package/dist/_chunks/retriv.mjs.map +1 -1
- package/dist/_chunks/rolldown-runtime.mjs +0 -2
- package/dist/_chunks/sanitize.mjs +0 -78
- package/dist/_chunks/sanitize.mjs.map +1 -1
- package/dist/_chunks/search-interactive.mjs +0 -17
- package/dist/_chunks/search-interactive.mjs.map +1 -1
- package/dist/_chunks/search.mjs +0 -19
- package/dist/_chunks/search2.mjs +3 -12
- package/dist/_chunks/search2.mjs.map +1 -1
- package/dist/_chunks/setup.mjs +0 -13
- package/dist/_chunks/setup.mjs.map +1 -1
- package/dist/_chunks/shared.mjs +0 -10
- package/dist/_chunks/shared.mjs.map +1 -1
- package/dist/_chunks/skills.mjs +2 -2
- package/dist/_chunks/skills.mjs.map +1 -1
- package/dist/_chunks/sources.mjs +3 -453
- package/dist/_chunks/sources.mjs.map +1 -1
- package/dist/_chunks/sync-shared.mjs +0 -16
- package/dist/_chunks/sync-shared2.mjs +0 -42
- package/dist/_chunks/sync-shared2.mjs.map +1 -1
- package/dist/_chunks/sync.mjs +1 -21
- package/dist/_chunks/sync.mjs.map +1 -1
- package/dist/_chunks/sync2.mjs +0 -20
- package/dist/_chunks/types.d.mts +0 -2
- package/dist/_chunks/types.d.mts.map +1 -1
- package/dist/_chunks/uninstall.mjs +0 -25
- package/dist/_chunks/uninstall.mjs.map +1 -1
- package/dist/_chunks/validate.mjs +0 -7
- package/dist/_chunks/validate.mjs.map +1 -1
- package/dist/_chunks/wizard.mjs +15 -12
- package/dist/_chunks/wizard.mjs.map +1 -1
- package/dist/_chunks/yaml.mjs +0 -21
- package/dist/_chunks/yaml.mjs.map +1 -1
- package/dist/agent/index.d.mts +0 -24
- package/dist/agent/index.d.mts.map +1 -1
- package/dist/agent/index.mjs +0 -8
- package/dist/cache/index.mjs +0 -2
- package/dist/cli-entry.mjs +0 -6
- package/dist/cli-entry.mjs.map +1 -1
- package/dist/cli.mjs +37 -44
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +0 -6
- package/dist/prepare.mjs +0 -12
- package/dist/prepare.mjs.map +1 -1
- package/dist/retriv/index.mjs +0 -2
- package/dist/retriv/worker.d.mts +0 -3
- package/dist/retriv/worker.d.mts.map +1 -1
- package/dist/retriv/worker.mjs +0 -2
- package/dist/retriv/worker.mjs.map +1 -1
- package/dist/sources/index.mjs +0 -4
- package/package.json +17 -17
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<h1>skilld</h1>
|
|
1
|
+
<h1><a href="https://skilld.dev"><img src=".github/logos/logo-mark.svg" alt="" width="28" height="28" valign="middle"></a> skilld</h1>
|
|
2
2
|
|
|
3
3
|
[](https://npmjs.com/package/skilld)
|
|
4
4
|
[](https://npm.chart.dev/skilld)
|
|
5
|
-
[](https://github.com/
|
|
5
|
+
[](https://github.com/skilld-dev/skilld/blob/main/LICENSE)
|
|
6
6
|
|
|
7
7
|
> Generate AI agent skills from your NPM dependencies.
|
|
8
8
|
|
|
@@ -330,4 +330,4 @@ DO_NOT_TRACK=1
|
|
|
330
330
|
|
|
331
331
|
## License
|
|
332
332
|
|
|
333
|
-
Licensed under the [MIT license](https://github.com/
|
|
333
|
+
Licensed under the [MIT license](https://github.com/skilld-dev/skilld/blob/main/LICENSE).
|
package/dist/_chunks/agent.mjs
CHANGED
|
@@ -20,7 +20,6 @@ import { getEnvApiKey, getModel, getModels, getProviders, streamSimple } from "@
|
|
|
20
20
|
import { getOAuthApiKey, getOAuthProvider, getOAuthProviders } from "@mariozechner/pi-ai/oauth";
|
|
21
21
|
import { readFile } from "node:fs/promises";
|
|
22
22
|
import { parseSync } from "oxc-parser";
|
|
23
|
-
//#region src/agent/clis/claude.ts
|
|
24
23
|
var claude_exports = /* @__PURE__ */ __exportAll({
|
|
25
24
|
agentId: () => agentId$2,
|
|
26
25
|
buildArgs: () => buildArgs$2,
|
|
@@ -73,16 +72,6 @@ function buildArgs$2(model, skillDir, symlinkDirs) {
|
|
|
73
72
|
"--no-session-persistence"
|
|
74
73
|
];
|
|
75
74
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Parse claude stream-json events
|
|
78
|
-
*
|
|
79
|
-
* Event types:
|
|
80
|
-
* - stream_event/content_block_delta/text_delta → token streaming
|
|
81
|
-
* - stream_event/content_block_start/tool_use → tool invocation starting
|
|
82
|
-
* - assistant message with tool_use content → tool name + input
|
|
83
|
-
* - assistant message with text content → full text (non-streaming fallback)
|
|
84
|
-
* - result → usage, cost, turns
|
|
85
|
-
*/
|
|
86
75
|
function parseLine$2(line) {
|
|
87
76
|
try {
|
|
88
77
|
const obj = JSON.parse(line);
|
|
@@ -126,8 +115,6 @@ function parseLine$2(line) {
|
|
|
126
115
|
} catch {}
|
|
127
116
|
return {};
|
|
128
117
|
}
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region src/agent/clis/codex.ts
|
|
131
118
|
var codex_exports = /* @__PURE__ */ __exportAll({
|
|
132
119
|
agentId: () => agentId$1,
|
|
133
120
|
buildArgs: () => buildArgs$1,
|
|
@@ -201,8 +188,6 @@ function parseLine$1(line) {
|
|
|
201
188
|
} catch {}
|
|
202
189
|
return {};
|
|
203
190
|
}
|
|
204
|
-
//#endregion
|
|
205
|
-
//#region src/agent/clis/gemini.ts
|
|
206
191
|
var gemini_exports = /* @__PURE__ */ __exportAll({
|
|
207
192
|
agentId: () => agentId,
|
|
208
193
|
buildArgs: () => buildArgs,
|
|
@@ -238,7 +223,6 @@ function buildArgs(model, skillDir, symlinkDirs) {
|
|
|
238
223
|
...symlinkDirs.flatMap((d) => ["--include-directories", d])
|
|
239
224
|
];
|
|
240
225
|
}
|
|
241
|
-
/** Parse gemini stream-json events — turn level (full message per event) */
|
|
242
226
|
function parseLine(line) {
|
|
243
227
|
try {
|
|
244
228
|
const obj = JSON.parse(line);
|
|
@@ -271,12 +255,9 @@ function parseLine(line) {
|
|
|
271
255
|
} catch {}
|
|
272
256
|
return {};
|
|
273
257
|
}
|
|
274
|
-
//#endregion
|
|
275
|
-
//#region src/agent/clis/pi-ai.ts
|
|
276
258
|
function isPiAiModel(model) {
|
|
277
259
|
return model.startsWith("pi:");
|
|
278
260
|
}
|
|
279
|
-
/** Parse a pi:provider/model-id string → { provider, modelId } */
|
|
280
261
|
function parsePiAiModelId(model) {
|
|
281
262
|
if (!model.startsWith("pi:")) return null;
|
|
282
263
|
const rest = model.slice(3);
|
|
@@ -287,9 +268,14 @@ function parsePiAiModelId(model) {
|
|
|
287
268
|
modelId: rest.slice(slashIdx + 1)
|
|
288
269
|
};
|
|
289
270
|
}
|
|
290
|
-
|
|
271
|
+
const BLOCKED_OAUTH_PROVIDERS = new Set([
|
|
272
|
+
"google-antigravity",
|
|
273
|
+
"google-gemini-cli",
|
|
274
|
+
"github-copilot",
|
|
275
|
+
"anthropic",
|
|
276
|
+
"openai-codex"
|
|
277
|
+
]);
|
|
291
278
|
const PI_AGENT_AUTH_PATH = join(process.env.PI_CODING_AGENT_DIR || join(homedir(), ".pi", "agent"), "auth.json");
|
|
292
|
-
/** skilld's own auth file — used when user logs in via skilld */
|
|
293
279
|
const SKILLD_AUTH_PATH = join(homedir(), ".skilld", "pi-ai-auth.json");
|
|
294
280
|
function readAuthFile(path) {
|
|
295
281
|
if (!existsSync(path)) return {};
|
|
@@ -299,7 +285,6 @@ function readAuthFile(path) {
|
|
|
299
285
|
return {};
|
|
300
286
|
}
|
|
301
287
|
}
|
|
302
|
-
/** Load auth from pi coding agent first (~/.pi/agent/auth.json), then skilld's own */
|
|
303
288
|
function loadAuth() {
|
|
304
289
|
const piAuth = readAuthFile(PI_AGENT_AUTH_PATH);
|
|
305
290
|
return {
|
|
@@ -307,7 +292,6 @@ function loadAuth() {
|
|
|
307
292
|
...piAuth
|
|
308
293
|
};
|
|
309
294
|
}
|
|
310
|
-
/** Save auth to skilld's own file — never writes to pi agent's auth */
|
|
311
295
|
function saveAuth(auth) {
|
|
312
296
|
mkdirSync(join(homedir(), ".skilld"), {
|
|
313
297
|
recursive: true,
|
|
@@ -315,22 +299,17 @@ function saveAuth(auth) {
|
|
|
315
299
|
});
|
|
316
300
|
writeFileSync(SKILLD_AUTH_PATH, JSON.stringify(auth, null, 2), { mode: 384 });
|
|
317
301
|
}
|
|
318
|
-
/**
|
|
319
|
-
* Overrides for model-provider → OAuth-provider mapping.
|
|
320
|
-
* Most providers share the same ID in both systems (auto-matched).
|
|
321
|
-
* Only list exceptions where the IDs diverge.
|
|
322
|
-
*/
|
|
323
302
|
const OAUTH_PROVIDER_OVERRIDES = {
|
|
324
303
|
google: "google-gemini-cli",
|
|
325
304
|
openai: "openai-codex"
|
|
326
305
|
};
|
|
327
|
-
/** Resolve model provider ID → OAuth provider ID */
|
|
328
306
|
function resolveOAuthProviderId(modelProvider) {
|
|
307
|
+
const oauthId = OAUTH_PROVIDER_OVERRIDES[modelProvider] ?? modelProvider;
|
|
308
|
+
if (BLOCKED_OAUTH_PROVIDERS.has(oauthId)) return null;
|
|
329
309
|
if (OAUTH_PROVIDER_OVERRIDES[modelProvider]) return OAUTH_PROVIDER_OVERRIDES[modelProvider];
|
|
330
310
|
if (new Set(getOAuthProviders().map((p) => p.id)).has(modelProvider)) return modelProvider;
|
|
331
311
|
return null;
|
|
332
312
|
}
|
|
333
|
-
/** Resolve API key for a provider — checks env vars first, then OAuth credentials */
|
|
334
313
|
async function resolveApiKey(provider) {
|
|
335
314
|
const envKey = getEnvApiKey(provider);
|
|
336
315
|
if (envKey) return envKey;
|
|
@@ -348,16 +327,14 @@ async function resolveApiKey(provider) {
|
|
|
348
327
|
saveAuth(skilldAuth);
|
|
349
328
|
return result.apiKey;
|
|
350
329
|
}
|
|
351
|
-
/** Get available OAuth providers for login */
|
|
352
330
|
function getOAuthProviderList() {
|
|
353
331
|
const auth = loadAuth();
|
|
354
|
-
return getOAuthProviders().map((p) => ({
|
|
332
|
+
return getOAuthProviders().filter((p) => !BLOCKED_OAUTH_PROVIDERS.has(p.id)).map((p) => ({
|
|
355
333
|
id: p.id,
|
|
356
334
|
name: p.name ?? p.id,
|
|
357
335
|
loggedIn: !!auth[p.id]
|
|
358
336
|
}));
|
|
359
337
|
}
|
|
360
|
-
/** Run OAuth login for a provider, saving credentials to ~/.skilld/ */
|
|
361
338
|
async function loginOAuthProvider(providerId, callbacks) {
|
|
362
339
|
const provider = getOAuthProvider(providerId);
|
|
363
340
|
if (!provider) return false;
|
|
@@ -374,14 +351,12 @@ async function loginOAuthProvider(providerId, callbacks) {
|
|
|
374
351
|
saveAuth(auth);
|
|
375
352
|
return true;
|
|
376
353
|
}
|
|
377
|
-
/** Remove OAuth credentials for a provider */
|
|
378
354
|
function logoutOAuthProvider(providerId) {
|
|
379
355
|
const auth = loadAuth();
|
|
380
356
|
delete auth[providerId];
|
|
381
357
|
saveAuth(auth);
|
|
382
358
|
}
|
|
383
359
|
const MIN_CONTEXT_WINDOW = 32e3;
|
|
384
|
-
/** Legacy model patterns — old generations that clutter the model list */
|
|
385
360
|
const LEGACY_MODEL_PATTERNS = [
|
|
386
361
|
/^claude-3-/,
|
|
387
362
|
/^claude-3\.5-/,
|
|
@@ -398,13 +373,11 @@ const LEGACY_MODEL_PATTERNS = [
|
|
|
398
373
|
function isLegacyModel(modelId) {
|
|
399
374
|
return LEGACY_MODEL_PATTERNS.some((p) => p.test(modelId));
|
|
400
375
|
}
|
|
401
|
-
/** Preferred model per provider for auto-selection (cheapest reliable option) */
|
|
402
376
|
const RECOMMENDED_MODELS = {
|
|
403
377
|
anthropic: /haiku/,
|
|
404
378
|
google: /flash/,
|
|
405
379
|
openai: /gpt-4\.1-mini/
|
|
406
380
|
};
|
|
407
|
-
/** Get all pi-ai models for providers with auth configured */
|
|
408
381
|
function getAvailablePiAiModels() {
|
|
409
382
|
const providers = getProviders();
|
|
410
383
|
const auth = loadAuth();
|
|
@@ -482,13 +455,11 @@ const SAFE_COMMANDS = new Set([
|
|
|
482
455
|
"find"
|
|
483
456
|
]);
|
|
484
457
|
const SHELL_META_RE = /[;&|`$()<>]/;
|
|
485
|
-
/** Resolve a path safely within skilldDir, blocking traversal */
|
|
486
458
|
function resolveSandboxedPath(p, skilldDir) {
|
|
487
459
|
const resolved = resolve$1(skilldDir, String(p).replace(/^\.\/\.skilld\//, "./").replace(/^\.skilld\//, "./").replace(/^\.\//, ""));
|
|
488
460
|
if (!resolved.startsWith(`${skilldDir}/`) && resolved !== skilldDir) throw new Error(`Path traversal blocked: ${p}`);
|
|
489
461
|
return resolved;
|
|
490
462
|
}
|
|
491
|
-
/** Match a file path against a glob pattern using simple segment matching (no regex from user input) */
|
|
492
463
|
function globMatch(filePath, pattern) {
|
|
493
464
|
const segments = pattern.split("**");
|
|
494
465
|
if (segments.length === 1) {
|
|
@@ -532,7 +503,6 @@ function globMatch(filePath, pattern) {
|
|
|
532
503
|
}
|
|
533
504
|
return true;
|
|
534
505
|
}
|
|
535
|
-
/** Execute a tool call against the .skilld/ directory */
|
|
536
506
|
function executeTool(toolCall, skilldDir) {
|
|
537
507
|
const args = toolCall.arguments;
|
|
538
508
|
switch (toolCall.name) {
|
|
@@ -579,7 +549,6 @@ function executeTool(toolCall, skilldDir) {
|
|
|
579
549
|
default: return `Unknown tool: ${toolCall.name}`;
|
|
580
550
|
}
|
|
581
551
|
}
|
|
582
|
-
/** Optimize a single section using pi-ai agentic API with tool use */
|
|
583
552
|
async function optimizeSectionPiAi(opts) {
|
|
584
553
|
const parsed = parsePiAiModelId(opts.model);
|
|
585
554
|
if (!parsed) throw new Error(`Invalid pi-ai model ID: ${opts.model}. Expected format: pi:provider/model-id`);
|
|
@@ -693,8 +662,6 @@ async function optimizeSectionPiAi(opts) {
|
|
|
693
662
|
cost: totalCost
|
|
694
663
|
};
|
|
695
664
|
}
|
|
696
|
-
//#endregion
|
|
697
|
-
//#region src/agent/clis/index.ts
|
|
698
665
|
const TOOL_VERBS = {
|
|
699
666
|
Read: "Reading",
|
|
700
667
|
Glob: "Searching",
|
|
@@ -708,11 +675,9 @@ const TOOL_VERBS = {
|
|
|
708
675
|
search_file_content: "Searching",
|
|
709
676
|
run_shell_command: "Running"
|
|
710
677
|
};
|
|
711
|
-
/** Create a progress callback that emits one line per tool call, Claude Code style */
|
|
712
678
|
function createToolProgress(log) {
|
|
713
679
|
let lastMsg = "";
|
|
714
680
|
let repeatCount = 0;
|
|
715
|
-
/** Per-section timestamp of last "Writing..." emission — throttles text_delta spam */
|
|
716
681
|
const lastTextEmit = /* @__PURE__ */ new Map();
|
|
717
682
|
const TEXT_THROTTLE_MS = 2e3;
|
|
718
683
|
function emit(msg) {
|
|
@@ -777,7 +742,6 @@ const CLI_PARSE_LINE = {
|
|
|
777
742
|
gemini: parseLine,
|
|
778
743
|
codex: parseLine$1
|
|
779
744
|
};
|
|
780
|
-
/** Map CLI agent IDs to their LLM provider name (not the agent/tool name) */
|
|
781
745
|
const CLI_PROVIDER_NAMES = {
|
|
782
746
|
"claude-code": "Anthropic",
|
|
783
747
|
"gemini-cli": "Google",
|
|
@@ -860,7 +824,6 @@ async function getAvailableModels() {
|
|
|
860
824
|
});
|
|
861
825
|
return [...cliModels, ...piAiEntries];
|
|
862
826
|
}
|
|
863
|
-
/** Resolve symlinks in .skilld/ to get real paths for --add-dir */
|
|
864
827
|
function resolveReferenceDirs(skillDir) {
|
|
865
828
|
const refsDir = join(skillDir, ".skilld");
|
|
866
829
|
if (!existsSync(refsDir)) return [];
|
|
@@ -873,7 +836,6 @@ function resolveReferenceDirs(skillDir) {
|
|
|
873
836
|
return [...resolved, ...parents];
|
|
874
837
|
}
|
|
875
838
|
const CACHE_DIR = join(homedir(), ".skilld", "llm-cache");
|
|
876
|
-
/** Strip absolute paths from prompt so the hash is project-independent */
|
|
877
839
|
function normalizePromptForHash(prompt) {
|
|
878
840
|
return prompt.replace(/\/[^\s`]*\.(?:claude|codex|gemini)\/skills\/[^\s/`]+/g, "<SKILL_DIR>");
|
|
879
841
|
}
|
|
@@ -962,7 +924,6 @@ async function optimizeSectionViaPiAi(opts) {
|
|
|
962
924
|
};
|
|
963
925
|
}
|
|
964
926
|
}
|
|
965
|
-
/** Spawn a single CLI process for one section, or call pi-ai directly */
|
|
966
927
|
function optimizeSection(opts) {
|
|
967
928
|
const { section, prompt, outputFile, skillDir, model, onProgress, timeout, debug, preExistingFiles } = opts;
|
|
968
929
|
if (isPiAiModel(model)) return optimizeSectionViaPiAi({
|
|
@@ -1333,37 +1294,31 @@ async function optimizeDocs(opts) {
|
|
|
1333
1294
|
debugLogsDir
|
|
1334
1295
|
};
|
|
1335
1296
|
}
|
|
1336
|
-
/** Check if an error string indicates a rate limit (429) */
|
|
1337
1297
|
function isRateLimitError(error) {
|
|
1338
1298
|
if (!error) return false;
|
|
1339
1299
|
return /\b429\b/.test(error) || /rate.?limit/i.test(error) || /exhausted.*capacity/i.test(error) || /quota.*reset/i.test(error);
|
|
1340
1300
|
}
|
|
1341
|
-
/** Parse delay hint from rate limit error (e.g. "reset after 5s" → 5). Returns undefined if not a rate limit. */
|
|
1342
1301
|
function parseRateLimitDelay(error) {
|
|
1343
1302
|
if (!error || !isRateLimitError(error)) return void 0;
|
|
1344
1303
|
const match = error.match(/reset\s+after\s+(\d+)s/i);
|
|
1345
1304
|
return match ? Number(match[1]) : 10;
|
|
1346
1305
|
}
|
|
1347
|
-
/** Extract error string from a PromiseSettledResult */
|
|
1348
1306
|
function getRetryError(result) {
|
|
1349
1307
|
if (result.status === "rejected") return String(result.reason);
|
|
1350
1308
|
return result.value.error;
|
|
1351
1309
|
}
|
|
1352
|
-
/** Shorten absolute paths for display: /home/user/project/.claude/skills/vue/SKILL.md → .claude/.../SKILL.md */
|
|
1353
1310
|
function shortenPath(p) {
|
|
1354
1311
|
const refIdx = p.indexOf(".skilld/");
|
|
1355
1312
|
if (refIdx !== -1) return p.slice(refIdx + 8);
|
|
1356
1313
|
const parts = p.split("/");
|
|
1357
1314
|
return parts.length > 2 ? `.../${parts.slice(-2).join("/")}` : p;
|
|
1358
1315
|
}
|
|
1359
|
-
/** Replace absolute paths in a command string with shortened versions */
|
|
1360
1316
|
function shortenCommand(cmd) {
|
|
1361
1317
|
return cmd.replace(/\/[^\s"']+/g, (match) => {
|
|
1362
1318
|
if (match.includes(".claude/") || match.includes(".skilld/") || match.includes("node_modules/")) return `.../${match.split("/").slice(-2).join("/")}`;
|
|
1363
1319
|
return match;
|
|
1364
1320
|
});
|
|
1365
1321
|
}
|
|
1366
|
-
/** Clean a single section's LLM output: strip markdown fences, frontmatter, sanitize */
|
|
1367
1322
|
function cleanSectionOutput(content) {
|
|
1368
1323
|
let cleaned = content.trim();
|
|
1369
1324
|
const wrapMatch = cleaned.match(/^```(?:markdown|md)?[^\S\n]*\n([\s\S]+)\n```[^\S\n]*$/);
|
|
@@ -1399,8 +1354,6 @@ function cleanSectionOutput(content) {
|
|
|
1399
1354
|
if (!/^##\s/m.test(cleaned) && !/^- (?:BREAKING|DEPRECATED|NEW): /m.test(cleaned) && !/\[source\]/.test(cleaned)) return "";
|
|
1400
1355
|
return cleaned;
|
|
1401
1356
|
}
|
|
1402
|
-
//#endregion
|
|
1403
|
-
//#region src/agent/detect-presets.ts
|
|
1404
1357
|
const NUXT_CONFIG_FILES = [
|
|
1405
1358
|
"nuxt.config.ts",
|
|
1406
1359
|
"nuxt.config.js",
|
|
@@ -1422,10 +1375,6 @@ async function findNuxtConfig(cwd) {
|
|
|
1422
1375
|
}
|
|
1423
1376
|
return null;
|
|
1424
1377
|
}
|
|
1425
|
-
/**
|
|
1426
|
-
* Walk AST node to find all string values inside a `modules` array property.
|
|
1427
|
-
* Handles: defineNuxtConfig({ modules: [...] }) and export default { modules: [...] }
|
|
1428
|
-
*/
|
|
1429
1378
|
function extractModuleStrings(node) {
|
|
1430
1379
|
if (!node || typeof node !== "object") return [];
|
|
1431
1380
|
if (node.type === "Property" && !node.computed && node.key?.type === "Identifier" && node.key.name === "modules" && node.value?.type === "ArrayExpression") return node.value.elements.filter((el) => el?.type === "Literal" && typeof el.value === "string").map((el) => el.value);
|
|
@@ -1438,9 +1387,6 @@ function extractModuleStrings(node) {
|
|
|
1438
1387
|
}
|
|
1439
1388
|
return results;
|
|
1440
1389
|
}
|
|
1441
|
-
/**
|
|
1442
|
-
* Detect Nuxt modules from nuxt.config.{ts,js,mjs}
|
|
1443
|
-
*/
|
|
1444
1390
|
async function detectNuxtModules(cwd) {
|
|
1445
1391
|
const config = await findNuxtConfig(cwd);
|
|
1446
1392
|
if (!config) return [];
|
|
@@ -1465,18 +1411,9 @@ async function detectNuxtModules(cwd) {
|
|
|
1465
1411
|
}
|
|
1466
1412
|
return packages;
|
|
1467
1413
|
}
|
|
1468
|
-
/**
|
|
1469
|
-
* Run all preset detectors and merge results
|
|
1470
|
-
*/
|
|
1471
1414
|
async function detectPresetPackages(cwd) {
|
|
1472
1415
|
return detectNuxtModules(cwd);
|
|
1473
1416
|
}
|
|
1474
|
-
//#endregion
|
|
1475
|
-
//#region src/agent/detect-imports.ts
|
|
1476
|
-
/**
|
|
1477
|
-
* Detect directly-used npm packages by scanning source files
|
|
1478
|
-
* Uses mlly for proper ES module parsing + tinyglobby for file discovery
|
|
1479
|
-
*/
|
|
1480
1417
|
const PATTERNS = ["**/*.{ts,js,vue,mjs,cjs,tsx,jsx,mts,cts}"];
|
|
1481
1418
|
const IGNORE = [
|
|
1482
1419
|
"**/node_modules/**",
|
|
@@ -1490,10 +1427,6 @@ function addPackage(counts, specifier) {
|
|
|
1490
1427
|
const name = specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0];
|
|
1491
1428
|
if (!isNodeBuiltin(name)) counts.set(name, (counts.get(name) || 0) + 1);
|
|
1492
1429
|
}
|
|
1493
|
-
/**
|
|
1494
|
-
* Scan source files to detect all directly-imported npm packages
|
|
1495
|
-
* Async with gitignore support for proper spinner animation
|
|
1496
|
-
*/
|
|
1497
1430
|
async function detectImportedPackages(cwd = process.cwd()) {
|
|
1498
1431
|
try {
|
|
1499
1432
|
const counts = /* @__PURE__ */ new Map();
|
|
@@ -1578,7 +1511,6 @@ function isNodeBuiltin(pkg) {
|
|
|
1578
1511
|
const base = pkg.startsWith("node:") ? pkg.slice(5) : pkg;
|
|
1579
1512
|
return NODE_BUILTINS.has(base.split("/")[0]);
|
|
1580
1513
|
}
|
|
1581
|
-
//#endregion
|
|
1582
1514
|
export { getModelLabel as a, getOAuthProviderList as c, getAvailableModels as i, loginOAuthProvider as l, cleanSectionOutput as n, getModelName as o, createToolProgress as r, optimizeDocs as s, detectImportedPackages as t, logoutOAuthProvider as u };
|
|
1583
1515
|
|
|
1584
1516
|
//# sourceMappingURL=agent.mjs.map
|