@botpress/adk-cli
Version:
Command-line interface for the Botpress Agent Development Kit (ADK)
157 lines (155 loc) • 4.9 kB
JavaScript
// @bun
import {
assertValidProject
} from "./chunk-wmec2w0t.js";
import {
formatStatusLine,
remediationFor,
summarizeStatuses
} from "./chunk-3k2q12qe.js";
import"./chunk-m2h26j5f.js";
import"./chunk-8gqzjqmb.js";
import {
checkNodeVersion
} from "./chunk-5ky86nkb.js";
import {
findAgentRootOrFail
} from "./chunk-kk3h6qaj.js";
import {
createCliLogger
} from "./chunk-gzwt1qdr.js";
import"./chunk-nxy2ya5r.js";
import"./chunk-wzj4dc7n.js";
import {
AdkError,
AgentProject,
ValidationErrorCode,
exports_dependencies,
generateAssetsTypes,
generateLocalTypes
} from "./chunk-p0hjqn4r.js";
import"./chunk-np5wcwfv.js";
import"./chunk-dq2xpa24.js";
import"./chunk-6w0knnta.js";
import"./chunk-40x04ckt.js";
import"./chunk-t76d8fxx.js";
import"./chunk-nh2akp42.js";
import"./chunk-0fdvzjbh.js";
import"./chunk-2a5b6azq.js";
import"./chunk-vay209b5.js";
import"./chunk-3xrpxgq4.js";
import"./chunk-rfm3jr1m.js";
import"./chunk-w346ejn9.js";
import"./chunk-knvm2anf.js";
import"./chunk-65h5trb5.js";
import"./chunk-s2akeqpw.js";
import"./chunk-6771vrjp.js";
import"./chunk-g8mm42v1.js";
import"./chunk-50hzjdck.js";
import"./chunk-nn2jb0x0.js";
import"./chunk-v8xvth6j.js";
import"./chunk-kkk13rcb.js";
import"./chunk-ytpp1kam.js";
import"./chunk-na956zz3.js";
import"./chunk-f4bw8q7c.js";
import"./chunk-0v8vgrns.js";
import"./chunk-54qt5g7m.js";
import"./chunk-dhs2bg35.js";
// src/commands/adk-check.ts
var CHECK_JSON_ONLY_FORMAT_ERROR = 'The --format option only accepts "json" for this command.';
function ensureSupportedFormat(format) {
if (format !== undefined && format !== "json") {
throw new AdkError({ code: "INVALID_FORMAT", message: CHECK_JSON_ONLY_FORMAT_ERROR, expected: true });
}
}
async function adkCheck(options = {}) {
ensureSupportedFormat(options.format);
const logger = createCliLogger({ format: options.format, silent: options.silent });
logger.info("\uD83E\uDE7A Checking ADK project...", "blue");
checkNodeVersion(true);
const agentRoot = await findAgentRootOrFail(process.cwd());
const project = await AgentProject.load(agentRoot, {
adkCommand: "adk-build",
offline: true
});
const isJson = options.format === "json";
const validation = await assertValidProject(project, {
exitOnError: false,
skipRender: isJson,
filterCodes: [ValidationErrorCode.AGENT_NOT_LINKED]
});
let assetsOk = true;
let assetsError;
try {
await generateAssetsTypes(project.path);
} catch (e) {
assetsOk = false;
assetsError = e instanceof Error ? e.message : String(e);
}
let typesOk = true;
let typesError;
try {
await generateLocalTypes(project);
} catch (e) {
typesOk = false;
typesError = e instanceof Error ? e.message : String(e);
}
const primitives = {
actions: project.actions?.length ?? 0,
workflows: project.workflows?.length ?? 0,
conversations: project.conversations?.length ?? 0,
triggers: project.triggers?.length ?? 0,
tables: project.tables?.length ?? 0
};
const dependencyStatuses = await exports_dependencies.resolveDependencyStatuses({
snapshot: await new exports_dependencies.DependencySnapshotStore({ projectPath: agentRoot }).readOrEmpty("dev", {
tolerant: true
})
});
const hasErrors = validation.errors.length > 0 || !typesOk;
const checkResult = {
valid: !hasErrors,
errors: validation.errors,
warnings: validation.warnings,
info: validation.info,
primitives,
assetsOk,
typesOk,
dependencies: dependencyStatuses
};
logger.newline();
if (!hasErrors) {
logger.info(`\u2705 Project "${project.config?.name || "Unknown"}" passed offline checks`, "green");
}
logger.info(` Primitives: ${primitives.actions} actions, ${primitives.workflows} workflows, ${primitives.conversations} conversations, ${primitives.triggers} triggers, ${primitives.tables} tables`, "gray");
if (assetsOk) {
logger.info(" Assets: types generated", "gray");
} else {
logger.warn(` Assets: type generation failed \u2014 ${assetsError ?? "unknown error"}`);
}
if (typesOk) {
logger.info(" Types: generated", "gray");
} else {
logger.warn(` Types: generation failed \u2014 ${typesError ?? "unknown error"}`);
}
if (dependencyStatuses.length > 0) {
logger.info(` Dependencies: ${summarizeStatuses(dependencyStatuses)}`, "gray");
for (const d of dependencyStatuses) {
if (d.state === "available")
continue;
logger.warn(` ${formatStatusLine(d)}`);
const hint = remediationFor(d);
if (hint)
logger.info(` \u21B3 ${hint}`, "gray");
}
}
logger.newline();
logger.info(" Note: skips type-checking (run `tsc --noEmit`) and live integration resolution (run `adk dev`).", "gray").result(checkResult);
if (hasErrors) {
process.exit(1);
}
}
export {
adkCheck,
CHECK_JSON_ONLY_FORMAT_ERROR
};