import { fileURLToPath } from "node:url";
import fs from "node:fs";
import path from "node:path";
//#region src/klaw/repo-paths.ts
let cachedRoot = null;
/**
* Resolve the repo root by walking up from this module's location until we
* find `klaw.mjs`. Falls back to two-levels-up only if the marker is missing.
*/
function getRepoRoot() {
	if (cachedRoot) return cachedRoot;
	const here = path.dirname(fileURLToPath(import.meta.url));
	let dir = here;
	for (let i = 0; i < 8; i++) {
		if (fs.existsSync(path.join(dir, "klaw.mjs"))) {
			cachedRoot = dir;
			return dir;
		}
		const parent = path.dirname(dir);
		if (parent === dir) break;
		dir = parent;
	}
	cachedRoot = path.resolve(here, "..", "..");
	return cachedRoot;
}
/** Path to klaw.mjs at the repo root. */
function resolveKlawBin() {
	return path.join(getRepoRoot(), "klaw.mjs");
}
/** Path to the klaw-skills directory at the repo root. */
function resolveSkillsDir() {
	return path.join(getRepoRoot(), "klaw-skills");
}
/** Path to the klaw-agents directory at the repo root. */
function resolveAgentsDir() {
	return path.join(getRepoRoot(), "klaw-agents");
}
//#endregion
export { resolveSkillsDir as i, resolveAgentsDir as n, resolveKlawBin as r, getRepoRoot as t };
