openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.14 kB
JavaScript
import{r as resolveOpenClawPackageRootSync}from"./openclaw-root-DP80HYD2.mjs";import fs from"node:fs";import{fileURLToPath}from"node:url";import path from"node:path";
//!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{}}export{resolveBundledSkillsDir as t};