File size: 3,723 Bytes
7bedc79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36277c7
 
 
 
 
 
 
 
 
 
 
 
 
12880e4
 
 
 
 
 
 
 
 
 
 
 
7bedc79
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/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 <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 <agent>", "source agent (claude|cursor|codex|windsurf|copilot)")
  .requiredOption("--to <agent>", "target agent (claude|cursor|codex|windsurf|copilot)")
  .option("-p, --path <path>", "project root", process.cwd())
  .option("-o, --output <file>", "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 <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 <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 <agent>", "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 <agent>", "source agent (dsh)")
  .option("-o, --out <dir>", "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 <agent>", "source agent (dsh)")
  .requiredOption("--to <agent>", "target agent (codex|claude|zcode|workbuddy|mimo)")
  .option("-o, --out <dir>", "data directory (default ~/<target>-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();