UNPKG

@botpress/adk-cli

Version:

Command-line interface for the Botpress Agent Development Kit (ADK)

37 lines (33 loc) 929 B
// @bun import { AdkError } from "./chunk-wzj4dc7n.js"; // src/utils/agent-root.ts import path from "path"; import fs from "fs/promises"; async function findAgentRoot(startPath) { let currentPath = path.resolve(startPath); const root = path.parse(currentPath).root; while (currentPath !== root) { try { await fs.access(path.join(currentPath, "agent.config.ts")); return currentPath; } catch { currentPath = path.dirname(currentPath); } } return null; } async function findAgentRootOrFail(startPath) { const root = await findAgentRoot(startPath); if (!root) { throw new AdkError({ code: "PROJECT_NOT_FOUND", message: `No ADK agent root found in the current directory or its parents. ` + "Run `adk help` to see all commands\n" + "Run `adk init` to create a new agent", expected: true }); } return root; } export { findAgentRoot, findAgentRootOrFail };