@skild/core 0.10.16 → 0.10.17

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 (2) hide show
  1. package/dist/index.js +29 -11
  2. 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
- async function cloneRemote(degitSrc, targetPath) {
460
- const emitter = degit(degitSrc, { force: true, verbose: false });
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
- try {
470
- await cloneRemote(degitSrc, targetPath);
471
- return degitSrc;
472
- } catch (error) {
473
- if (!degitSrc.includes("#") || !isMissingRefError(error)) {
474
- throw error;
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
- const fallbackSrc = stripSourceRef(degitSrc);
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skild/core",
3
- "version": "0.10.16",
3
+ "version": "0.10.17",
4
4
  "description": "Skild core library (headless) for installing, validating, and managing Agent Skills locally.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",