#!/usr/bin/env node import { Command } from "commander"; import { readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; const __dirname = dirname(fileURLToPath(import.meta.url)); const pkg = JSON.parse(readFileSync(join(__dirname, "../../package.json"), "utf-8")); const program = new Command(); program .name("agentlens") .description("Cross-agent config migration & output QA for AI coding agents") .version(pkg.version); program .command("scan") .description("Detect all AI agent configs in the current project and show rules summary") .option("-p, --path ", "project root", process.cwd()) .action(async (opts) => { const { scanProject } = await import("./commands/scan.js"); await scanProject(opts.path); }); program .command("move") .description("Migrate rules from one agent format to another") .requiredOption("--from ", "source agent (claude|cursor|codex|windsurf|copilot)") .requiredOption("--to ", "target agent (claude|cursor|codex|windsurf|copilot)") .option("-p, --path ", "project root", process.cwd()) .option("-o, --output ", "output file path") .action(async (opts) => { const { moveRules } = await import("./commands/move.js"); await moveRules(opts); }); program .command("drift") .description("Detect config drift across agent rule files") .option("-p, --path ", "project root", process.cwd()) .action(async (opts) => { const { detectDrift } = await import("./commands/drift.js"); await detectDrift(opts.path); }); program .command("check") .description("Run adversarial QA on code changes or files") .argument("[target]", "git diff range or file path", "HEAD~1..HEAD") .option("-p, --path ", "project root", process.cwd()) .action(async (target, opts) => { const { checkCode } = await import("./commands/check.js"); await checkCode(target, opts.path); }); program .command("install") .description("One-click install AgentLens into target AI agents as MCP server") .option("--target ", "target agent (claude|cursor|codex|all)", "all") .action(async (opts) => { const { installTo } = await import("./commands/install.js"); await installTo(opts.target); }); program .command("export") .description("Export a full agent data bundle (personas + materials + conversations) — currently DSH only") .requiredOption("--from ", "source agent (dsh)") .option("-o, --out ", "output directory", "./dsh-export") .option("--with-attachments", "also copy attachments (can be hundreds of MB)") .option("--no-materials", "skip workspace/memory materials") .option("--no-conversations", "skip conversation transcripts") .action(async (opts) => { const { exportData } = await import("./commands/export.js"); await exportData(opts); }); program .command("import") .description("One-click: export DSH data AND wire it into a target agent's real config (instructions + skill)") .requiredOption("--from ", "source agent (dsh)") .requiredOption("--to ", "target agent (codex|claude|zcode|workbuddy|mimo)") .option("-o, --out ", "data directory (default ~/-import)") .option("--with-attachments", "also copy attachments (can be hundreds of MB)") .action(async (opts) => { const { importData } = await import("./commands/import.js"); await importData(opts); }); program .command("mcp") .description("Start AgentLens as an MCP server (for Claude Code, Cursor, etc.)") .action(async () => { const { startMcpServer } = await import("../mcp/server.js"); await startMcpServer(); }); program.parse();