import { t as resolveDaoCorePackageRoot } from "./daocore-root-CYblIxyF.js";
import fs from "node:fs";
import path from "node:path";
//#region src/agents/docs-path.ts
const DAOCORE_DOCS_URL = "https://daocore-ai.vercel.app";
const DAOCORE_SOURCE_URL = "https://github.com/gaodefa/daocore-AI-assistant";
function isUsableDocsDir(docsDir) {
	return fs.existsSync(path.join(docsDir, "docs.json"));
}
function isGitCheckout(rootDir) {
	return fs.existsSync(path.join(rootDir, ".git"));
}
async function resolveDaoCoreDocsPath(params) {
	const workspaceDir = params.workspaceDir?.trim();
	if (workspaceDir) {
		const workspaceDocs = path.join(workspaceDir, "docs");
		if (isUsableDocsDir(workspaceDocs)) return workspaceDocs;
	}
	const packageRoot = await resolveDaoCorePackageRoot({
		cwd: params.cwd,
		argv1: params.argv1,
		moduleUrl: params.moduleUrl
	});
	if (!packageRoot) return null;
	const packageDocs = path.join(packageRoot, "docs");
	return isUsableDocsDir(packageDocs) ? packageDocs : null;
}
async function resolveDaoCoreSourcePath(params) {
	const packageRoot = await resolveDaoCorePackageRoot({
		cwd: params.cwd,
		argv1: params.argv1,
		moduleUrl: params.moduleUrl
	});
	if (!packageRoot || !isGitCheckout(packageRoot)) return null;
	return packageRoot;
}
async function resolveDaoCoreReferencePaths(params) {
	const [docsPath, sourcePath] = await Promise.all([resolveDaoCoreDocsPath(params), resolveDaoCoreSourcePath(params)]);
	return {
		docsPath,
		sourcePath
	};
}
//#endregion
export { resolveDaoCoreSourcePath as a, resolveDaoCoreReferencePaths as i, DAOCORE_SOURCE_URL as n, resolveDaoCoreDocsPath as r, DAOCORE_DOCS_URL as t };
