UNPKG

@kya-os/cli

Version:

CLI for MCP-I setup and management

210 lines (205 loc) 8.92 kB
#!/usr/bin/env node import { Command } from "commander"; import chalk from "chalk"; import { init } from "./commands/init.js"; import { check } from "./commands/check.js"; import { env } from "./commands/env.js"; import { rotate } from "./commands/rotate.js"; import { claim } from "./commands/claim.js"; import { register } from "./commands/register.js"; import { status } from "./commands/status.js"; import { receipts } from "./commands/receipts.js"; import { dev } from "./commands/dev.js"; import { build } from "./commands/build.js"; import { start } from "./commands/start.js"; import { identityClean, identityRestore } from "./commands/identity.js"; import { createDemoCommand } from "./commands/demo.js"; import { createDcoCommand } from "./commands/dco.js"; import { doctor } from "./commands/doctor.js"; import { verify } from "./commands/verify.js"; export const program = new Command(); // ASCII art logo const logo = chalk.cyan(` ╦╔═╦ ╦╔═╗ ╔═╗╔═╗ ╠╩╗╚╦╝╠═╣───║ ║╚═╗ ╩ ╩ ╩ ╩ ╩ ╚═╝╚═╝ `); program .name("mcpi") .description("CLI for XMCP-I setup and management") .version("1.2.2") .addHelpText("before", logo); // Development commands program .command("dev") .description("Start development server with hot reloading") .action(dev); program .command("build") .description("Build application for production") .action(build); program.command("start").description("Start production server").action(start); // Init command program .command("init") .description("Initialize XMCP-I in your project") .option("-n, --name <name>", "Agent name") .option("-d, --description <description>", "Agent description") .option("-r, --repository <url>", "Repository URL") .option("-p, --platform <platform>", "Target platform (auto-detected if not specified)") .option("--skip-registration", "Skip agent registration (create files only)") .option("--force", "Overwrite existing configuration") .option("--local", "Use local development endpoint (http://localhost:3000)") .option("--endpoint <url>", "Use custom API endpoint") .option("-v, --verbose", "Show detailed debug information") .option("--skip-claim-check", "Skip waiting for agent claim") .option("--no-dco", "Skip the commit signing and PR attribution prompt after registration") .action(init); // Check command program .command("check") .description("Check MCP-I setup status") .option("-v, --verbose", "Show detailed information") .action(check); // Env command with subcommands const envCommand = program .command("env") .description("Manage environment variables"); envCommand .command("show") .description("Show required environment variables") .action(() => env("show")); envCommand .command("copy") .description("Copy environment variables to clipboard") .action(() => env("copy")); envCommand .command("verify") .description("Verify environment variables are set correctly") .action(() => env("verify")); envCommand .command("print") .description("Print platform-specific environment variable names") .action(() => env("print")); // Keys command with subcommands const keysCommand = program.command("keys").description("Manage identity keys"); keysCommand .command("rotate") .description("Rotate identity keys") .option("-f, --force", "Force rotation without confirmation") .option("-r, --reason <reason>", "Reason for rotation") .option("--new-did", "Generate new DID along with new keys") .option("--yes", "Skip interactive confirmation (for automation)") .action(rotate); // Identity command with subcommands const identityCommand = program .command("identity") .description("Manage identity configuration"); identityCommand .command("clean") .description("Clean identity configuration") .option("-f, --force", "Skip confirmation prompt") .option("--no-backup", "Don't create backup before cleaning") .action((options) => identityClean({ force: options.force, backup: options.backup !== false, })); identityCommand .command("restore [backup-file]") .description("Restore identity from backup") .action(identityRestore); // Register command program .command("register") .description("Register agent with Know-That-AI (KTA)") .option("--json", "Output in JSON format for automation") .option("--no-save-receipt", "Don't save receipt to disk") .option("--receipt-path <path>", "Custom path for receipt storage", ".mcpi/receipts") .option("--no-dco", "Skip the commit signing and PR attribution prompt after registration") .action((options) => register(options)); // Claim command program .command("claim [token]") .description("Claim agent with token or get management URLs") .option("--json", "Output in JSON format for automation") .option("--no-save-receipt", "Don't save receipt to disk") .option("--receipt-path <path>", "Custom path for receipt storage", ".mcpi/receipts") .action((token, options) => claim(token, options)); // Status command program .command("status") .description("Show agent status including DID, key ID, KTA URL, and mirror status") .option("--json", "Output in JSON format for automation") .action((options) => status(options)); // Receipts command program .command("receipts") .description("List and manage stored receipts") .option("--json", "Output in JSON format for automation") .option("--path <path>", "Custom path for receipt storage", ".mcpi/receipts") .option("--verify", "Verify receipts against KTA log") .action((options) => receipts(options)); // Demo command (consolidated) program.addCommand(createDemoCommand()); // DCO / attribution commands program.addCommand(createDcoCommand()); // Doctor command program .command("doctor") .description("Check system health and compatibility") .option("--json", "Output in JSON format for automation") .option("-v, --verbose", "Show detailed diagnostic information") .action((options) => doctor(options)); // Verify command program .command("verify") .description("Verify proofs and signatures locally") .option("--local", "Perform offline verification without KTA calls") .option("--json", "Output in JSON format for automation") .option("-v, --verbose", "Show detailed verification information") .option("--proof <path>", "Path to proof file or JSON string") .option("--request <path>", "Path to request file or JSON string") .option("--response <path>", "Path to response file or JSON string") .action((options) => verify(options)); // Add custom help text program.addHelpText("after", ` ${chalk.bold("Available Commands:")} ${chalk.cyan("dev")} Start development server with hot reloading ${chalk.cyan("build")} Build application for production ${chalk.cyan("start")} Start production server ${chalk.cyan("init")} Initialize XMCP-I in your project ${chalk.cyan("register")} Register agent with Know-That-AI (KTA) ${chalk.cyan("claim [token]")} Claim agent with token or get management URLs ${chalk.cyan("dco setup")} Sign commits with your agent identity and attribute PRs ${chalk.cyan("dco status")} Show DCO/attribution setup state ${chalk.cyan("status")} Show agent status and mirror information ${chalk.cyan("keys rotate")} Rotate identity keys ${chalk.cyan("identity clean")} Clean identity configuration ${chalk.cyan("identity restore")} Restore identity from backup ${chalk.cyan("env show|copy|verify|print")} Manage environment variables ${chalk.cyan("receipts")} List and manage stored receipts ${chalk.cyan("doctor")} Check system health and compatibility ${chalk.cyan("verify --local")} Verify proofs and signatures locally ${chalk.bold("Examples:")} ${chalk.gray("# Create and start a new agent")} ${chalk.cyan("npx @kya-os/create-mcpi-app my-agent")} ${chalk.cyan("cd my-agent && mcpi dev")} ${chalk.gray("# Initialize identity and register")} ${chalk.cyan("mcpi init")} ${chalk.cyan("mcpi register")} ${chalk.gray("# Build and deploy")} ${chalk.cyan("mcpi build")} ${chalk.cyan("mcpi start")} ${chalk.gray("# Key management")} ${chalk.cyan("mcpi keys rotate")} ${chalk.cyan("mcpi identity clean --force")} ${chalk.bold("Documentation:")} ${chalk.gray("https://docs.kya-os.ai/xmcp-i")} `); // Parse arguments (removed ES module guard that prevented CLI execution) program.parse(); // Show help if no command specified if (!process.argv.slice(2).length) { program.outputHelp(); } //# sourceMappingURL=index.prod.js.map