UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

48 lines (47 loc) • 1.4 kB
import { r as resolveOpenClawPackageRootSync } from "./openclaw-root-C-ayo09z.mjs"; import fs from "node:fs"; import { fileURLToPath } from "node:url"; import path from "node:path"; //#region src/skills/loading/bundled-dir.ts function looksLikeSkillsDir(e) { try { return fs.readdirSync(e, { withFileTypes: true }).some((t) => !t.name.startsWith(".") && (t.isFile() && t.name.endsWith(".md") || t.isDirectory() && fs.existsSync(path.join(e, t.name, "SKILL.md")))); } catch { return false; } } function resolveBundledSkillsDir(e = {}) { const t = process.env.OPENCLAW_BUNDLED_SKILLS_DIR?.trim(); if (t) return t; try { const t = e.execPath ?? process.execPath; const n = path.dirname(t); const r = path.join(n, "skills"); if (fs.existsSync(r)) return r; } catch {} try { const t = e.moduleUrl ?? import.meta.url; const n = path.dirname(fileURLToPath(t)); const r = e.argv1 ?? process.argv[1]; const i = e.cwd ?? process.cwd(); const a = resolveOpenClawPackageRootSync({ argv1: r, moduleUrl: t, cwd: i }); if (a) { const e = path.join(a, "skills"); if (looksLikeSkillsDir(e)) return e; } let o = n; for (let e = 0; e < 6; e += 1) { const e = path.join(o, "skills"); if (looksLikeSkillsDir(e)) return e; const t = path.dirname(o); if (t === o) break; o = t; } } catch {} } //#endregion export { resolveBundledSkillsDir as t };