@skild/core 0.10.16 → 0.10.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +39 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -456,8 +456,12 @@ function ensureInstallableDir(sourcePath) {
|
|
|
456
456
|
throw new SkildError("NOT_A_DIRECTORY", `Source path is not a directory: ${sourcePath}`, { sourcePath });
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
|
-
|
|
460
|
-
|
|
459
|
+
function resetTargetDir(targetPath) {
|
|
460
|
+
removeDir(targetPath);
|
|
461
|
+
fs6.mkdirSync(targetPath, { recursive: true });
|
|
462
|
+
}
|
|
463
|
+
async function cloneRemote(degitSrc, targetPath, mode) {
|
|
464
|
+
const emitter = degit(degitSrc, { force: true, verbose: false, mode });
|
|
461
465
|
await emitter.clone(targetPath);
|
|
462
466
|
}
|
|
463
467
|
function isMissingRefError(error) {
|
|
@@ -466,17 +470,31 @@ function isMissingRefError(error) {
|
|
|
466
470
|
return /could not find commit hash/i.test(message);
|
|
467
471
|
}
|
|
468
472
|
async function cloneRemoteWithFallback(degitSrc, targetPath) {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
473
|
+
const fallbackSrc = degitSrc.includes("#") ? stripSourceRef(degitSrc) : degitSrc;
|
|
474
|
+
const candidates = [
|
|
475
|
+
{ src: degitSrc, mode: "git" }
|
|
476
|
+
];
|
|
477
|
+
if (fallbackSrc !== degitSrc) {
|
|
478
|
+
candidates.push({ src: fallbackSrc, mode: "git" });
|
|
479
|
+
}
|
|
480
|
+
candidates.push({ src: degitSrc, mode: "tar" });
|
|
481
|
+
if (fallbackSrc !== degitSrc) {
|
|
482
|
+
candidates.push({ src: fallbackSrc, mode: "tar" });
|
|
483
|
+
}
|
|
484
|
+
let lastError;
|
|
485
|
+
for (const candidate of candidates) {
|
|
486
|
+
try {
|
|
487
|
+
resetTargetDir(targetPath);
|
|
488
|
+
await cloneRemote(candidate.src, targetPath, candidate.mode);
|
|
489
|
+
return candidate.src;
|
|
490
|
+
} catch (error) {
|
|
491
|
+
lastError = error;
|
|
492
|
+
if (candidate.src === degitSrc && isMissingRefError(error)) {
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
475
495
|
}
|
|
476
496
|
}
|
|
477
|
-
|
|
478
|
-
await cloneRemote(fallbackSrc, targetPath);
|
|
479
|
-
return fallbackSrc;
|
|
497
|
+
throw lastError;
|
|
480
498
|
}
|
|
481
499
|
async function materializeSourceToDir(input) {
|
|
482
500
|
const sourceType = classifySource(input.source);
|
|
@@ -609,7 +627,7 @@ function sha256Hex(buffer) {
|
|
|
609
627
|
}
|
|
610
628
|
async function searchRegistrySkills(registryUrl, query, limit = 50) {
|
|
611
629
|
const q = query.trim();
|
|
612
|
-
const url = new URL(`${registryUrl}/
|
|
630
|
+
const url = new URL(`${registryUrl}/discover`);
|
|
613
631
|
if (q) url.searchParams.set("q", q);
|
|
614
632
|
url.searchParams.set("limit", String(Math.min(Math.max(limit, 1), 100)));
|
|
615
633
|
const res = await fetchWithTimeout(url.toString(), { headers: { accept: "application/json" } }, 1e4);
|
|
@@ -618,10 +636,15 @@ async function searchRegistrySkills(registryUrl, query, limit = 50) {
|
|
|
618
636
|
throw new SkildError("REGISTRY_RESOLVE_FAILED", `Failed to search skills (${res.status}). ${text}`.trim());
|
|
619
637
|
}
|
|
620
638
|
const json = await res.json();
|
|
621
|
-
if (!json?.ok || !Array.isArray(json.
|
|
622
|
-
throw new SkildError("REGISTRY_RESOLVE_FAILED", "Invalid registry response for /
|
|
623
|
-
}
|
|
624
|
-
return json.
|
|
639
|
+
if (!json?.ok || !Array.isArray(json.rows)) {
|
|
640
|
+
throw new SkildError("REGISTRY_RESOLVE_FAILED", "Invalid registry response for /discover.");
|
|
641
|
+
}
|
|
642
|
+
return json.rows.map((row) => ({
|
|
643
|
+
name: String(row.alias || row.title || "").trim(),
|
|
644
|
+
description: typeof row.description === "string" ? row.description : void 0,
|
|
645
|
+
created_at: row.createdAt,
|
|
646
|
+
updated_at: row.updatedAt
|
|
647
|
+
}));
|
|
625
648
|
}
|
|
626
649
|
async function resolveRegistryAlias(registryUrl, alias) {
|
|
627
650
|
const a = alias.trim();
|