skilld 1.5.5 → 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 +0 -77
- 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 +0 -47
- 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 +0 -2
- 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 +0 -13
- 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);
|
|
@@ -294,9 +275,7 @@ const BLOCKED_OAUTH_PROVIDERS = new Set([
|
|
|
294
275
|
"anthropic",
|
|
295
276
|
"openai-codex"
|
|
296
277
|
]);
|
|
297
|
-
/** pi coding agent stores auth here; env var can override */
|
|
298
278
|
const PI_AGENT_AUTH_PATH = join(process.env.PI_CODING_AGENT_DIR || join(homedir(), ".pi", "agent"), "auth.json");
|
|
299
|
-
/** skilld's own auth file — used when user logs in via skilld */
|
|
300
279
|
const SKILLD_AUTH_PATH = join(homedir(), ".skilld", "pi-ai-auth.json");
|
|
301
280
|
function readAuthFile(path) {
|
|
302
281
|
if (!existsSync(path)) return {};
|
|
@@ -306,7 +285,6 @@ function readAuthFile(path) {
|
|
|
306
285
|
return {};
|
|
307
286
|
}
|
|
308
287
|
}
|
|
309
|
-
/** Load auth from pi coding agent first (~/.pi/agent/auth.json), then skilld's own */
|
|
310
288
|
function loadAuth() {
|
|
311
289
|
const piAuth = readAuthFile(PI_AGENT_AUTH_PATH);
|
|
312
290
|
return {
|
|
@@ -314,7 +292,6 @@ function loadAuth() {
|
|
|
314
292
|
...piAuth
|
|
315
293
|
};
|
|
316
294
|
}
|
|
317
|
-
/** Save auth to skilld's own file — never writes to pi agent's auth */
|
|
318
295
|
function saveAuth(auth) {
|
|
319
296
|
mkdirSync(join(homedir(), ".skilld"), {
|
|
320
297
|
recursive: true,
|
|
@@ -322,16 +299,10 @@ function saveAuth(auth) {
|
|
|
322
299
|
});
|
|
323
300
|
writeFileSync(SKILLD_AUTH_PATH, JSON.stringify(auth, null, 2), { mode: 384 });
|
|
324
301
|
}
|
|
325
|
-
/**
|
|
326
|
-
* Overrides for model-provider → OAuth-provider mapping.
|
|
327
|
-
* Most providers share the same ID in both systems (auto-matched).
|
|
328
|
-
* Only list exceptions where the IDs diverge.
|
|
329
|
-
*/
|
|
330
302
|
const OAUTH_PROVIDER_OVERRIDES = {
|
|
331
303
|
google: "google-gemini-cli",
|
|
332
304
|
openai: "openai-codex"
|
|
333
305
|
};
|
|
334
|
-
/** Resolve model provider ID → OAuth provider ID (returns null for blocked providers) */
|
|
335
306
|
function resolveOAuthProviderId(modelProvider) {
|
|
336
307
|
const oauthId = OAUTH_PROVIDER_OVERRIDES[modelProvider] ?? modelProvider;
|
|
337
308
|
if (BLOCKED_OAUTH_PROVIDERS.has(oauthId)) return null;
|
|
@@ -339,7 +310,6 @@ function resolveOAuthProviderId(modelProvider) {
|
|
|
339
310
|
if (new Set(getOAuthProviders().map((p) => p.id)).has(modelProvider)) return modelProvider;
|
|
340
311
|
return null;
|
|
341
312
|
}
|
|
342
|
-
/** Resolve API key for a provider — checks env vars first, then OAuth credentials */
|
|
343
313
|
async function resolveApiKey(provider) {
|
|
344
314
|
const envKey = getEnvApiKey(provider);
|
|
345
315
|
if (envKey) return envKey;
|
|
@@ -357,7 +327,6 @@ async function resolveApiKey(provider) {
|
|
|
357
327
|
saveAuth(skilldAuth);
|
|
358
328
|
return result.apiKey;
|
|
359
329
|
}
|
|
360
|
-
/** Get available OAuth providers for login (excludes blocked providers) */
|
|
361
330
|
function getOAuthProviderList() {
|
|
362
331
|
const auth = loadAuth();
|
|
363
332
|
return getOAuthProviders().filter((p) => !BLOCKED_OAUTH_PROVIDERS.has(p.id)).map((p) => ({
|
|
@@ -366,7 +335,6 @@ function getOAuthProviderList() {
|
|
|
366
335
|
loggedIn: !!auth[p.id]
|
|
367
336
|
}));
|
|
368
337
|
}
|
|
369
|
-
/** Run OAuth login for a provider, saving credentials to ~/.skilld/ */
|
|
370
338
|
async function loginOAuthProvider(providerId, callbacks) {
|
|
371
339
|
const provider = getOAuthProvider(providerId);
|
|
372
340
|
if (!provider) return false;
|
|
@@ -383,14 +351,12 @@ async function loginOAuthProvider(providerId, callbacks) {
|
|
|
383
351
|
saveAuth(auth);
|
|
384
352
|
return true;
|
|
385
353
|
}
|
|
386
|
-
/** Remove OAuth credentials for a provider */
|
|
387
354
|
function logoutOAuthProvider(providerId) {
|
|
388
355
|
const auth = loadAuth();
|
|
389
356
|
delete auth[providerId];
|
|
390
357
|
saveAuth(auth);
|
|
391
358
|
}
|
|
392
359
|
const MIN_CONTEXT_WINDOW = 32e3;
|
|
393
|
-
/** Legacy model patterns — old generations that clutter the model list */
|
|
394
360
|
const LEGACY_MODEL_PATTERNS = [
|
|
395
361
|
/^claude-3-/,
|
|
396
362
|
/^claude-3\.5-/,
|
|
@@ -407,13 +373,11 @@ const LEGACY_MODEL_PATTERNS = [
|
|
|
407
373
|
function isLegacyModel(modelId) {
|
|
408
374
|
return LEGACY_MODEL_PATTERNS.some((p) => p.test(modelId));
|
|
409
375
|
}
|
|
410
|
-
/** Preferred model per provider for auto-selection (cheapest reliable option) */
|
|
411
376
|
const RECOMMENDED_MODELS = {
|
|
412
377
|
anthropic: /haiku/,
|
|
413
378
|
google: /flash/,
|
|
414
379
|
openai: /gpt-4\.1-mini/
|
|
415
380
|
};
|
|
416
|
-
/** Get all pi-ai models for providers with auth configured */
|
|
417
381
|
function getAvailablePiAiModels() {
|
|
418
382
|
const providers = getProviders();
|
|
419
383
|
const auth = loadAuth();
|
|
@@ -491,13 +455,11 @@ const SAFE_COMMANDS = new Set([
|
|
|
491
455
|
"find"
|
|
492
456
|
]);
|
|
493
457
|
const SHELL_META_RE = /[;&|`$()<>]/;
|
|
494
|
-
/** Resolve a path safely within skilldDir, blocking traversal */
|
|
495
458
|
function resolveSandboxedPath(p, skilldDir) {
|
|
496
459
|
const resolved = resolve$1(skilldDir, String(p).replace(/^\.\/\.skilld\//, "./").replace(/^\.skilld\//, "./").replace(/^\.\//, ""));
|
|
497
460
|
if (!resolved.startsWith(`${skilldDir}/`) && resolved !== skilldDir) throw new Error(`Path traversal blocked: ${p}`);
|
|
498
461
|
return resolved;
|
|
499
462
|
}
|
|
500
|
-
/** Match a file path against a glob pattern using simple segment matching (no regex from user input) */
|
|
501
463
|
function globMatch(filePath, pattern) {
|
|
502
464
|
const segments = pattern.split("**");
|
|
503
465
|
if (segments.length === 1) {
|
|
@@ -541,7 +503,6 @@ function globMatch(filePath, pattern) {
|
|
|
541
503
|
}
|
|
542
504
|
return true;
|
|
543
505
|
}
|
|
544
|
-
/** Execute a tool call against the .skilld/ directory */
|
|
545
506
|
function executeTool(toolCall, skilldDir) {
|
|
546
507
|
const args = toolCall.arguments;
|
|
547
508
|
switch (toolCall.name) {
|
|
@@ -588,7 +549,6 @@ function executeTool(toolCall, skilldDir) {
|
|
|
588
549
|
default: return `Unknown tool: ${toolCall.name}`;
|
|
589
550
|
}
|
|
590
551
|
}
|
|
591
|
-
/** Optimize a single section using pi-ai agentic API with tool use */
|
|
592
552
|
async function optimizeSectionPiAi(opts) {
|
|
593
553
|
const parsed = parsePiAiModelId(opts.model);
|
|
594
554
|
if (!parsed) throw new Error(`Invalid pi-ai model ID: ${opts.model}. Expected format: pi:provider/model-id`);
|
|
@@ -702,8 +662,6 @@ async function optimizeSectionPiAi(opts) {
|
|
|
702
662
|
cost: totalCost
|
|
703
663
|
};
|
|
704
664
|
}
|
|
705
|
-
//#endregion
|
|
706
|
-
//#region src/agent/clis/index.ts
|
|
707
665
|
const TOOL_VERBS = {
|
|
708
666
|
Read: "Reading",
|
|
709
667
|
Glob: "Searching",
|
|
@@ -717,11 +675,9 @@ const TOOL_VERBS = {
|
|
|
717
675
|
search_file_content: "Searching",
|
|
718
676
|
run_shell_command: "Running"
|
|
719
677
|
};
|
|
720
|
-
/** Create a progress callback that emits one line per tool call, Claude Code style */
|
|
721
678
|
function createToolProgress(log) {
|
|
722
679
|
let lastMsg = "";
|
|
723
680
|
let repeatCount = 0;
|
|
724
|
-
/** Per-section timestamp of last "Writing..." emission — throttles text_delta spam */
|
|
725
681
|
const lastTextEmit = /* @__PURE__ */ new Map();
|
|
726
682
|
const TEXT_THROTTLE_MS = 2e3;
|
|
727
683
|
function emit(msg) {
|
|
@@ -786,7 +742,6 @@ const CLI_PARSE_LINE = {
|
|
|
786
742
|
gemini: parseLine,
|
|
787
743
|
codex: parseLine$1
|
|
788
744
|
};
|
|
789
|
-
/** Map CLI agent IDs to their LLM provider name (not the agent/tool name) */
|
|
790
745
|
const CLI_PROVIDER_NAMES = {
|
|
791
746
|
"claude-code": "Anthropic",
|
|
792
747
|
"gemini-cli": "Google",
|
|
@@ -869,7 +824,6 @@ async function getAvailableModels() {
|
|
|
869
824
|
});
|
|
870
825
|
return [...cliModels, ...piAiEntries];
|
|
871
826
|
}
|
|
872
|
-
/** Resolve symlinks in .skilld/ to get real paths for --add-dir */
|
|
873
827
|
function resolveReferenceDirs(skillDir) {
|
|
874
828
|
const refsDir = join(skillDir, ".skilld");
|
|
875
829
|
if (!existsSync(refsDir)) return [];
|
|
@@ -882,7 +836,6 @@ function resolveReferenceDirs(skillDir) {
|
|
|
882
836
|
return [...resolved, ...parents];
|
|
883
837
|
}
|
|
884
838
|
const CACHE_DIR = join(homedir(), ".skilld", "llm-cache");
|
|
885
|
-
/** Strip absolute paths from prompt so the hash is project-independent */
|
|
886
839
|
function normalizePromptForHash(prompt) {
|
|
887
840
|
return prompt.replace(/\/[^\s`]*\.(?:claude|codex|gemini)\/skills\/[^\s/`]+/g, "<SKILL_DIR>");
|
|
888
841
|
}
|
|
@@ -971,7 +924,6 @@ async function optimizeSectionViaPiAi(opts) {
|
|
|
971
924
|
};
|
|
972
925
|
}
|
|
973
926
|
}
|
|
974
|
-
/** Spawn a single CLI process for one section, or call pi-ai directly */
|
|
975
927
|
function optimizeSection(opts) {
|
|
976
928
|
const { section, prompt, outputFile, skillDir, model, onProgress, timeout, debug, preExistingFiles } = opts;
|
|
977
929
|
if (isPiAiModel(model)) return optimizeSectionViaPiAi({
|
|
@@ -1342,37 +1294,31 @@ async function optimizeDocs(opts) {
|
|
|
1342
1294
|
debugLogsDir
|
|
1343
1295
|
};
|
|
1344
1296
|
}
|
|
1345
|
-
/** Check if an error string indicates a rate limit (429) */
|
|
1346
1297
|
function isRateLimitError(error) {
|
|
1347
1298
|
if (!error) return false;
|
|
1348
1299
|
return /\b429\b/.test(error) || /rate.?limit/i.test(error) || /exhausted.*capacity/i.test(error) || /quota.*reset/i.test(error);
|
|
1349
1300
|
}
|
|
1350
|
-
/** Parse delay hint from rate limit error (e.g. "reset after 5s" → 5). Returns undefined if not a rate limit. */
|
|
1351
1301
|
function parseRateLimitDelay(error) {
|
|
1352
1302
|
if (!error || !isRateLimitError(error)) return void 0;
|
|
1353
1303
|
const match = error.match(/reset\s+after\s+(\d+)s/i);
|
|
1354
1304
|
return match ? Number(match[1]) : 10;
|
|
1355
1305
|
}
|
|
1356
|
-
/** Extract error string from a PromiseSettledResult */
|
|
1357
1306
|
function getRetryError(result) {
|
|
1358
1307
|
if (result.status === "rejected") return String(result.reason);
|
|
1359
1308
|
return result.value.error;
|
|
1360
1309
|
}
|
|
1361
|
-
/** Shorten absolute paths for display: /home/user/project/.claude/skills/vue/SKILL.md → .claude/.../SKILL.md */
|
|
1362
1310
|
function shortenPath(p) {
|
|
1363
1311
|
const refIdx = p.indexOf(".skilld/");
|
|
1364
1312
|
if (refIdx !== -1) return p.slice(refIdx + 8);
|
|
1365
1313
|
const parts = p.split("/");
|
|
1366
1314
|
return parts.length > 2 ? `.../${parts.slice(-2).join("/")}` : p;
|
|
1367
1315
|
}
|
|
1368
|
-
/** Replace absolute paths in a command string with shortened versions */
|
|
1369
1316
|
function shortenCommand(cmd) {
|
|
1370
1317
|
return cmd.replace(/\/[^\s"']+/g, (match) => {
|
|
1371
1318
|
if (match.includes(".claude/") || match.includes(".skilld/") || match.includes("node_modules/")) return `.../${match.split("/").slice(-2).join("/")}`;
|
|
1372
1319
|
return match;
|
|
1373
1320
|
});
|
|
1374
1321
|
}
|
|
1375
|
-
/** Clean a single section's LLM output: strip markdown fences, frontmatter, sanitize */
|
|
1376
1322
|
function cleanSectionOutput(content) {
|
|
1377
1323
|
let cleaned = content.trim();
|
|
1378
1324
|
const wrapMatch = cleaned.match(/^```(?:markdown|md)?[^\S\n]*\n([\s\S]+)\n```[^\S\n]*$/);
|
|
@@ -1408,8 +1354,6 @@ function cleanSectionOutput(content) {
|
|
|
1408
1354
|
if (!/^##\s/m.test(cleaned) && !/^- (?:BREAKING|DEPRECATED|NEW): /m.test(cleaned) && !/\[source\]/.test(cleaned)) return "";
|
|
1409
1355
|
return cleaned;
|
|
1410
1356
|
}
|
|
1411
|
-
//#endregion
|
|
1412
|
-
//#region src/agent/detect-presets.ts
|
|
1413
1357
|
const NUXT_CONFIG_FILES = [
|
|
1414
1358
|
"nuxt.config.ts",
|
|
1415
1359
|
"nuxt.config.js",
|
|
@@ -1431,10 +1375,6 @@ async function findNuxtConfig(cwd) {
|
|
|
1431
1375
|
}
|
|
1432
1376
|
return null;
|
|
1433
1377
|
}
|
|
1434
|
-
/**
|
|
1435
|
-
* Walk AST node to find all string values inside a `modules` array property.
|
|
1436
|
-
* Handles: defineNuxtConfig({ modules: [...] }) and export default { modules: [...] }
|
|
1437
|
-
*/
|
|
1438
1378
|
function extractModuleStrings(node) {
|
|
1439
1379
|
if (!node || typeof node !== "object") return [];
|
|
1440
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);
|
|
@@ -1447,9 +1387,6 @@ function extractModuleStrings(node) {
|
|
|
1447
1387
|
}
|
|
1448
1388
|
return results;
|
|
1449
1389
|
}
|
|
1450
|
-
/**
|
|
1451
|
-
* Detect Nuxt modules from nuxt.config.{ts,js,mjs}
|
|
1452
|
-
*/
|
|
1453
1390
|
async function detectNuxtModules(cwd) {
|
|
1454
1391
|
const config = await findNuxtConfig(cwd);
|
|
1455
1392
|
if (!config) return [];
|
|
@@ -1474,18 +1411,9 @@ async function detectNuxtModules(cwd) {
|
|
|
1474
1411
|
}
|
|
1475
1412
|
return packages;
|
|
1476
1413
|
}
|
|
1477
|
-
/**
|
|
1478
|
-
* Run all preset detectors and merge results
|
|
1479
|
-
*/
|
|
1480
1414
|
async function detectPresetPackages(cwd) {
|
|
1481
1415
|
return detectNuxtModules(cwd);
|
|
1482
1416
|
}
|
|
1483
|
-
//#endregion
|
|
1484
|
-
//#region src/agent/detect-imports.ts
|
|
1485
|
-
/**
|
|
1486
|
-
* Detect directly-used npm packages by scanning source files
|
|
1487
|
-
* Uses mlly for proper ES module parsing + tinyglobby for file discovery
|
|
1488
|
-
*/
|
|
1489
1417
|
const PATTERNS = ["**/*.{ts,js,vue,mjs,cjs,tsx,jsx,mts,cts}"];
|
|
1490
1418
|
const IGNORE = [
|
|
1491
1419
|
"**/node_modules/**",
|
|
@@ -1499,10 +1427,6 @@ function addPackage(counts, specifier) {
|
|
|
1499
1427
|
const name = specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0];
|
|
1500
1428
|
if (!isNodeBuiltin(name)) counts.set(name, (counts.get(name) || 0) + 1);
|
|
1501
1429
|
}
|
|
1502
|
-
/**
|
|
1503
|
-
* Scan source files to detect all directly-imported npm packages
|
|
1504
|
-
* Async with gitignore support for proper spinner animation
|
|
1505
|
-
*/
|
|
1506
1430
|
async function detectImportedPackages(cwd = process.cwd()) {
|
|
1507
1431
|
try {
|
|
1508
1432
|
const counts = /* @__PURE__ */ new Map();
|
|
@@ -1587,7 +1511,6 @@ function isNodeBuiltin(pkg) {
|
|
|
1587
1511
|
const base = pkg.startsWith("node:") ? pkg.slice(5) : pkg;
|
|
1588
1512
|
return NODE_BUILTINS.has(base.split("/")[0]);
|
|
1589
1513
|
}
|
|
1590
|
-
//#endregion
|
|
1591
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 };
|
|
1592
1515
|
|
|
1593
1516
|
//# sourceMappingURL=agent.mjs.map
|