@botpress/adk-cli
Version:
Command-line interface for the Botpress Agent Development Kit (ADK)
199 lines (197 loc) • 6.16 kB
JavaScript
// @bun
import {
installExternalHarnessCapabilities
} from "./chunk-whkrdhta.js";
import {
checkAgent0CapabilitiesStatus,
installAgent0Capabilities,
readAgent0CapabilitiesManifest
} from "./chunk-tt572q4r.js";
import"./chunk-26vqkz52.js";
import"./chunk-nbasj5jm.js";
import {
findAgentRootOrFail
} from "./chunk-kk3h6qaj.js";
import {
createCliLogger
} from "./chunk-gzwt1qdr.js";
import"./chunk-nxy2ya5r.js";
import"./chunk-wzj4dc7n.js";
import"./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-ai-upgrade.ts
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
async function adkAgent0Upgrade(options = {}) {
const isJson = options.format === "json";
const logger = createCliLogger({ format: options.format });
const projectPath = await findAgentRootOrFail(process.cwd());
const status = checkAgent0CapabilitiesStatus(projectPath);
const baseResult = {
success: true,
projectPath,
command: "adk agent0 upgrade",
currentVersion: status.currentVersion,
previousVersion: status.state === "missing" ? undefined : status.installedVersion,
updated: false
};
if (status.state === "current") {
const manifest = readAgent0CapabilitiesManifest(projectPath);
const result = {
...baseResult,
capabilities: manifest ? {
root: manifest.capabilitiesRoot,
manifestPath: status.manifestPath,
skills: manifest.skills.length,
playbooks: manifest.playbooks.length
} : undefined
};
if (isJson) {
logger.info("").result(result);
} else {
logger.info(`Agent(0) capabilities are already current (${status.currentVersion}).`, "green");
}
return;
}
if (!isJson) {
logger.info("Updating Agent(0) project capabilities...");
logger.newline();
}
let frameIdx = 0;
const message = "Writing .agent0/capabilities...";
const spinner = isJson ? null : setInterval(() => {
logger.stdout(`\r ${SPINNER_FRAMES[frameIdx++ % SPINNER_FRAMES.length]} ${message}`);
}, 80);
const clearSpinner = () => {
if (!spinner)
return;
clearInterval(spinner);
logger.stdout("\r" + " ".repeat(message.length + 6) + "\r");
};
try {
const installed = await installAgent0Capabilities(projectPath);
clearSpinner();
const result = {
...baseResult,
updated: true,
capabilities: {
root: installed.capabilitiesRoot,
manifestPath: installed.manifestPath,
source: installed.source,
skills: installed.skills.installed,
playbooks: installed.playbooks.installed
}
};
if (isJson) {
logger.info("").result(result);
} else {
logger.info(`Agent(0) capabilities updated (${installed.skills.installed} skills, ${installed.playbooks.installed} commands).`, "green");
}
} catch (error) {
clearSpinner();
const errorMessage = error instanceof Error ? error.message : String(error);
const result = {
...baseResult,
success: false,
error: errorMessage
};
if (isJson) {
logger.info("").result(result);
return;
}
logger.error(`Failed to update Agent(0) capabilities: ${errorMessage}`);
}
}
async function adkUpdate(options = {}) {
const isJson = options.format === "json";
const logger = createCliLogger({ format: options.format });
const projectPath = await findAgentRootOrFail(process.cwd());
if (!isJson) {
logger.info("Updating ADK skills & commands...");
logger.newline();
}
let frameIdx = 0;
const message = "Updating external coding-agent capabilities...";
const spinner = isJson ? null : setInterval(() => {
logger.stdout(`\r ${SPINNER_FRAMES[frameIdx++ % SPINNER_FRAMES.length]} ${message}`);
}, 80);
const clearSpinner = () => {
if (!spinner)
return;
clearInterval(spinner);
logger.stdout("\r" + " ".repeat(message.length + 6) + "\r");
};
try {
const externalHarness = await installExternalHarnessCapabilities({ projectPath });
clearSpinner();
const result = {
success: externalHarness.success,
projectPath,
skills: externalHarness.skills,
commands: externalHarness.commands
};
if (isJson) {
logger.info("").result(result);
return;
}
if (externalHarness.skills.success) {
logger.info(" ADK skills updated", "green");
} else {
logger.warn(" Failed to update ADK skills. Run manually:");
logger.info(` > ${externalHarness.skills.command}`, "cyan");
}
if (externalHarness.commands.success) {
logger.info(` ADK commands updated (${externalHarness.commands.installedCommands} commands)`, "green");
} else {
logger.warn(" Failed to update ADK commands.");
}
logger.newline();
if (externalHarness.success) {
logger.info("All up to date!", "green");
} else {
logger.warn("Some updates failed. See warnings above.");
}
} catch (error) {
clearSpinner();
const message2 = error instanceof Error ? error.message : String(error);
const result = {
success: false,
projectPath,
error: message2
};
if (isJson) {
logger.info("").result(result);
return;
}
logger.error(`Failed to update ADK skills & commands: ${message2}`);
}
}
export {
adkUpdate,
adkAgent0Upgrade
};