mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 07:27:40 +00:00
refactor(src): split oversized modules
This commit is contained in:
29
src/agents/skills/bundled-dir.ts
Normal file
29
src/agents/skills/bundled-dir.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export function resolveBundledSkillsDir(): string | undefined {
|
||||
const override = process.env.CLAWDBOT_BUNDLED_SKILLS_DIR?.trim();
|
||||
if (override) return override;
|
||||
|
||||
// bun --compile: ship a sibling `skills/` next to the executable.
|
||||
try {
|
||||
const execDir = path.dirname(process.execPath);
|
||||
const sibling = path.join(execDir, "skills");
|
||||
if (fs.existsSync(sibling)) return sibling;
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
// npm/dev: resolve `<packageRoot>/skills` relative to this module.
|
||||
try {
|
||||
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
||||
const root = path.resolve(moduleDir, "..", "..", "..");
|
||||
const candidate = path.join(root, "skills");
|
||||
if (fs.existsSync(candidate)) return candidate;
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user