ape-claw 0.1.5 → 0.1.6
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/package.json +1 -1
- package/src/cli.mjs +45 -27
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -379,7 +379,12 @@ function safeSkillVersion(v) {
|
|
|
379
379
|
return s;
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
const TRUSTED_SKILL_API_HOSTS = new Set([
|
|
382
|
+
const TRUSTED_SKILL_API_HOSTS = new Set([
|
|
383
|
+
"apeclaw.ai", "www.apeclaw.ai", "api.apeclaw.ai",
|
|
384
|
+
"acceptable-cat-production.up.railway.app",
|
|
385
|
+
]);
|
|
386
|
+
|
|
387
|
+
const SKILL_API_FALLBACK = "https://acceptable-cat-production.up.railway.app";
|
|
383
388
|
|
|
384
389
|
function resolveSkillApiBase(args = {}) {
|
|
385
390
|
const explicit = String(args.api || "").trim();
|
|
@@ -460,36 +465,49 @@ function resolveBundledSkillFile(packageRoot, slug) {
|
|
|
460
465
|
return "";
|
|
461
466
|
}
|
|
462
467
|
|
|
468
|
+
async function fetchSkillFromApiOnce(slug, apiBase) {
|
|
469
|
+
const url = `${apiBase}/api/skills/get?slug=${encodeURIComponent(slug)}`;
|
|
470
|
+
const res = await fetch(url, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(15000) });
|
|
471
|
+
if (!res.ok) return null;
|
|
472
|
+
const ct = String(res.headers.get("content-type") || "");
|
|
473
|
+
if (!ct.includes("json")) return null;
|
|
474
|
+
const json = await res.json();
|
|
475
|
+
if (!json?.ok) return null;
|
|
476
|
+
|
|
477
|
+
const skillMeta = json?.skill && typeof json.skill === "object" ? json.skill : null;
|
|
478
|
+
let card = json?.card && typeof json.card === "object" ? json.card : null;
|
|
479
|
+
if (!card && skillMeta) {
|
|
480
|
+
card = {
|
|
481
|
+
name: skillMeta.name || slug,
|
|
482
|
+
slug: skillMeta.slug || slug,
|
|
483
|
+
version: "1.0.0",
|
|
484
|
+
description: skillMeta.description || skillMeta.name || slug,
|
|
485
|
+
riskTier: skillMeta.riskTier ?? 2,
|
|
486
|
+
provenance: skillMeta.provenance || { publisher: "imported", signed: false },
|
|
487
|
+
constraints: { riskTier: skillMeta.riskTier ?? 2 },
|
|
488
|
+
documentation_md: skillMeta.description
|
|
489
|
+
? `# ${skillMeta.name || slug}\n\n${skillMeta.description}`
|
|
490
|
+
: `# ${skillMeta.name || slug}\n`,
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
return { card, skillMeta, url, apiBase };
|
|
494
|
+
}
|
|
495
|
+
|
|
463
496
|
async function fetchSkillFromApi(slug, args = {}) {
|
|
464
497
|
const apiBase = resolveSkillApiBase(args);
|
|
465
|
-
const url = `${apiBase}/api/skills/get?slug=${encodeURIComponent(slug)}`;
|
|
466
498
|
try {
|
|
467
|
-
const
|
|
468
|
-
if (
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
card = {
|
|
477
|
-
name: skillMeta.name || slug,
|
|
478
|
-
slug: skillMeta.slug || slug,
|
|
479
|
-
version: "1.0.0",
|
|
480
|
-
description: skillMeta.description || skillMeta.name || slug,
|
|
481
|
-
riskTier: skillMeta.riskTier ?? 2,
|
|
482
|
-
provenance: skillMeta.provenance || { publisher: "imported", signed: false },
|
|
483
|
-
constraints: { riskTier: skillMeta.riskTier ?? 2 },
|
|
484
|
-
documentation_md: skillMeta.description
|
|
485
|
-
? `# ${skillMeta.name || slug}\n\n${skillMeta.description}`
|
|
486
|
-
: `# ${skillMeta.name || slug}\n`,
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
return { card, skillMeta, url, apiBase };
|
|
490
|
-
} catch {
|
|
491
|
-
return { card: null, skillMeta: null, url, apiBase };
|
|
499
|
+
const result = await fetchSkillFromApiOnce(slug, apiBase);
|
|
500
|
+
if (result) return result;
|
|
501
|
+
} catch { /* primary failed, try fallback */ }
|
|
502
|
+
|
|
503
|
+
if (apiBase !== SKILL_API_FALLBACK) {
|
|
504
|
+
try {
|
|
505
|
+
const fallbackResult = await fetchSkillFromApiOnce(slug, SKILL_API_FALLBACK);
|
|
506
|
+
if (fallbackResult) return fallbackResult;
|
|
507
|
+
} catch { /* fallback also failed */ }
|
|
492
508
|
}
|
|
509
|
+
|
|
510
|
+
return { card: null, skillMeta: null, url: `${apiBase}/api/skills/get?slug=${encodeURIComponent(slug)}`, apiBase };
|
|
493
511
|
}
|
|
494
512
|
|
|
495
513
|
function resolveHumanizerDependencySlug(packageRoot) {
|