jinzd-ai-cli 0.4.214 → 0.4.216

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +2 -0
  2. package/dist/{batch-NPUUDETK.js → batch-C6HCXZIG.js} +2 -2
  3. package/dist/{chunk-JQC7IATA.js → chunk-6HLKCSB3.js} +1 -1
  4. package/dist/{chunk-YMFGGCUP.js → chunk-77HDCGTN.js} +1 -1
  5. package/dist/{chunk-DBYMX2ZC.js → chunk-7YWS3JLU.js} +1 -1
  6. package/dist/{ci-3TU7WCY4.js → chunk-GY3C3C2Y.js} +40 -46
  7. package/dist/{chunk-JOJA35RK.js → chunk-OLN7VUZA.js} +1 -1
  8. package/dist/{chunk-5FG7PSVM.js → chunk-PNTLA3MN.js} +2 -2
  9. package/dist/{chunk-R5CJD2AB.js → chunk-TCOC4AUI.js} +3 -3
  10. package/dist/chunk-TJ6GGN4B.js +105 -0
  11. package/dist/{chunk-TR6MSPSS.js → chunk-VW7Y27WW.js} +1 -1
  12. package/dist/{chunk-YFHF3PVB.js → chunk-WAI3WPV2.js} +1 -1
  13. package/dist/ci-6ZTFO3LX.js +19 -0
  14. package/dist/ci-format-CLZ6QJRL.js +18 -0
  15. package/dist/{constants-BKR7T3QH.js → constants-APSORFOH.js} +1 -1
  16. package/dist/{doctor-cli-TGVSWKDB.js → doctor-cli-GUIX4X5F.js} +4 -4
  17. package/dist/electron-server.js +2 -2
  18. package/dist/{hub-GURYEW6F.js → hub-ZGHQWNWE.js} +1 -1
  19. package/dist/index.js +58 -22
  20. package/dist/pr-JOL3IAGV.js +267 -0
  21. package/dist/{run-tests-R6FL6CQ3.js → run-tests-4PKSIVK5.js} +1 -1
  22. package/dist/{run-tests-F44JA2YW.js → run-tests-ZRK4TQUN.js} +2 -2
  23. package/dist/{server-FXWCSCDZ.js → server-FXUF5P64.js} +7 -7
  24. package/dist/{server-GQXC46R5.js → server-O3XHT56X.js} +4 -4
  25. package/dist/{task-orchestrator-6AZD5WSR.js → task-orchestrator-TUMDTOAX.js} +4 -4
  26. package/dist/{usage-W7J2QA3G.js → usage-X7MJX4YD.js} +2 -2
  27. package/dist/web/client/actions.js +1 -0
  28. package/dist/web/client/app.js +182 -13
  29. package/dist/web/client/index.html +21 -3
  30. package/dist/web/client/style.css +62 -0
  31. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  scanProject,
16
16
  sessionHasMeaningfulContent,
17
17
  setupProxy
18
- } from "./chunk-5FG7PSVM.js";
18
+ } from "./chunk-PNTLA3MN.js";
19
19
  import {
20
20
  buildReviewPrompt,
21
21
  buildSecurityReviewPrompt
@@ -47,10 +47,10 @@ import {
47
47
  trustHook,
48
48
  undoStack,
49
49
  untrustHook
50
- } from "./chunk-R5CJD2AB.js";
50
+ } from "./chunk-TCOC4AUI.js";
51
51
  import "./chunk-T2NL5ZIA.js";
52
52
  import "./chunk-BXP6YZ2P.js";
53
- import "./chunk-TR6MSPSS.js";
53
+ import "./chunk-VW7Y27WW.js";
54
54
  import {
55
55
  SessionManager,
56
56
  getContentText
@@ -67,7 +67,7 @@ import {
67
67
  getConfigDirUsage,
68
68
  listRecentCrashes,
69
69
  writeCrashLog
70
- } from "./chunk-JQC7IATA.js";
70
+ } from "./chunk-6HLKCSB3.js";
71
71
  import {
72
72
  ProviderRegistry
73
73
  } from "./chunk-QMXC327F.js";
@@ -76,7 +76,7 @@ import {
76
76
  getTopFailingTools,
77
77
  getTopUsedTools,
78
78
  installFlushOnExit
79
- } from "./chunk-YMFGGCUP.js";
79
+ } from "./chunk-77HDCGTN.js";
80
80
  import {
81
81
  CONTENT_ONLY_STREAM_REMINDER,
82
82
  TEE_FINAL_USER_NUDGE,
@@ -98,7 +98,7 @@ import {
98
98
  } from "./chunk-XPBEJB27.js";
99
99
  import {
100
100
  ConfigManager
101
- } from "./chunk-YFHF3PVB.js";
101
+ } from "./chunk-WAI3WPV2.js";
102
102
  import {
103
103
  AuthError,
104
104
  ProviderError,
@@ -124,7 +124,7 @@ import {
124
124
  SKILLS_DIR_NAME,
125
125
  VERSION,
126
126
  buildUserIdentityPrompt
127
- } from "./chunk-DBYMX2ZC.js";
127
+ } from "./chunk-7YWS3JLU.js";
128
128
  import {
129
129
  formatGitContextForPrompt,
130
130
  getGitContext,
@@ -1661,7 +1661,7 @@ No tools match "${filter}".
1661
1661
  const { join: join5 } = await import("path");
1662
1662
  const { existsSync: existsSync5 } = await import("fs");
1663
1663
  const { getGitRoot: getGitRoot2 } = await import("./git-context-EXOEHQSF.js");
1664
- const { MCP_PROJECT_CONFIG_NAME: MCP_PROJECT_CONFIG_NAME2 } = await import("./constants-BKR7T3QH.js");
1664
+ const { MCP_PROJECT_CONFIG_NAME: MCP_PROJECT_CONFIG_NAME2 } = await import("./constants-APSORFOH.js");
1665
1665
  const { approveProject, hashMcpFile } = await import("./project-trust-NKYHL3VZ.js");
1666
1666
  const cwd = process.cwd();
1667
1667
  const projectRoot = getGitRoot2(cwd) ?? cwd;
@@ -2720,7 +2720,7 @@ ${hint}` : "")
2720
2720
  usage: "/test [command|filter]",
2721
2721
  async execute(args, ctx) {
2722
2722
  try {
2723
- const { executeTests } = await import("./run-tests-F44JA2YW.js");
2723
+ const { executeTests } = await import("./run-tests-ZRK4TQUN.js");
2724
2724
  const argStr = args.join(" ").trim();
2725
2725
  let testArgs = {};
2726
2726
  if (argStr) {
@@ -7207,7 +7207,7 @@ program.command("web").description("Start Web UI server with browser-based chat
7207
7207
  console.error("Error: Invalid port number. Must be between 1 and 65535.");
7208
7208
  process.exit(1);
7209
7209
  }
7210
- const { startWebServer } = await import("./server-FXWCSCDZ.js");
7210
+ const { startWebServer } = await import("./server-FXUF5P64.js");
7211
7211
  await startWebServer({ port, host: options.host });
7212
7212
  });
7213
7213
  program.command("user [action] [username]").description("Manage Web UI users (list | create <name> | delete <name> | reset-password <name> | logout-all <name> | migrate <name>)").action(async (action, username) => {
@@ -7374,16 +7374,16 @@ program.command("sessions").description("List recent conversation sessions").opt
7374
7374
  console.log(footer + "\n");
7375
7375
  });
7376
7376
  program.command("usage").description("Show token + cost usage grouped by provider/model (cross-session)").option("--days <n>", "Only the last N days (inclusive of today)").option("--month <ym>", "Only a specific month, format YYYY-MM (e.g. 2026-06)").option("--json", "Output as JSON (for scripting)").action(async (options) => {
7377
- const { runUsageCli } = await import("./usage-W7J2QA3G.js");
7377
+ const { runUsageCli } = await import("./usage-X7MJX4YD.js");
7378
7378
  await runUsageCli(options);
7379
7379
  });
7380
7380
  program.command("doctor").description("Health check: API keys, config, MCP, recent crashes, tool usage, disk usage").option("--json", "Output as JSON (for scripting)").option("--reset-stats", "Reset accumulated tool usage statistics").action(async (options) => {
7381
- const { runDoctorCli } = await import("./doctor-cli-TGVSWKDB.js");
7381
+ const { runDoctorCli } = await import("./doctor-cli-GUIX4X5F.js");
7382
7382
  await runDoctorCli({ json: !!options.json, resetStats: !!options.resetStats });
7383
7383
  });
7384
7384
  program.command("batch <action> [arg] [arg2]").description("Anthropic Message Batches: submit | list | status <id> | results <id> [out] | cancel <id>").option("--dry-run", "Parse and validate input without submitting (submit only)").action(async (action, arg, arg2, options) => {
7385
7385
  try {
7386
- const batch = await import("./batch-NPUUDETK.js");
7386
+ const batch = await import("./batch-C6HCXZIG.js");
7387
7387
  switch (action) {
7388
7388
  case "submit":
7389
7389
  if (!arg) {
@@ -7426,7 +7426,7 @@ program.command("batch <action> [arg] [arg2]").description("Anthropic Message Ba
7426
7426
  }
7427
7427
  });
7428
7428
  program.command("mcp-serve").description("Start an MCP server over STDIO, exposing aicli's built-in tools to Claude Desktop / Cursor / other MCP clients").option("--allow-destructive", "Allow bash / run_interactive / task_create (always destructive in MCP mode)").option("--allow-outside-cwd", "Allow tool path arguments to escape the sandbox root \u2014 disabled by default").option("--tools <list>", "Comma-separated whitelist of tools to expose (default: all eligible tools)").option("--cwd <path>", "Working directory AND sandbox root (default: current directory)").action(async (options) => {
7429
- const { startMcpServer } = await import("./server-GQXC46R5.js");
7429
+ const { startMcpServer } = await import("./server-O3XHT56X.js");
7430
7430
  await startMcpServer({
7431
7431
  allowDestructive: !!options.allowDestructive,
7432
7432
  allowOutsideCwd: !!options.allowOutsideCwd,
@@ -7434,8 +7434,39 @@ program.command("mcp-serve").description("Start an MCP server over STDIO, exposi
7434
7434
  cwd: options.cwd
7435
7435
  });
7436
7436
  });
7437
- program.command("ci").description("Headless PR review (code + security) \u2014 reads git/gh diff, optionally posts to PR. Designed for GitHub Actions.").option("--pr <num>", "PR number; diff fetched via `gh pr diff <num>`", (v) => parseInt(v, 10)).option("--base <ref>", "Base ref for `git diff <ref>...HEAD` (ignored when --pr set)").option("--post", "Post review as a PR comment (requires gh CLI + GH_TOKEN, needs --pr)").option("--no-update", "Always create a new comment instead of updating the previous aicli review").option("--skip-code", "Skip the code review section").option("--skip-security", "Skip the security review section").option("--detailed", "Use the detailed code-review prompt").option("--max-diff <n>", "Max diff chars sent to the model (default 30000)", (v) => parseInt(v, 10)).option("--provider <id>", "Override provider (default: config.defaultProvider)").option("--model <id>", "Override model").option("--dry-run", "Print result to stdout instead of posting (overrides --post)").action(async (options) => {
7438
- const { runCi } = await import("./ci-3TU7WCY4.js");
7437
+ program.command("pr <action> [target]").description("PR review helpers: review | security-review | summarize. Defaults to git diff main...HEAD.").option("--base <ref>", "Base ref for git diff <ref>...HEAD (ignored when --pr set)").option("--head <ref>", "Head ref for local git diff (default: HEAD)").option("--post", "Post/update a PR comment; only when target is a GitHub PR number or URL").option("--no-update", "Always create a new PR comment instead of updating the previous aicli review").option("--detailed", "Use the detailed code-review prompt").option("--agents <list>", "Comma-separated review lenses: security,bugs,tests,maintainability").option("--max-diff <n>", "Max diff chars sent to the model (default 30000)", (v) => parseInt(v, 10)).option("--provider <id>", "Override provider (default: config.defaultProvider)").option("--model <id>", "Override model").option("--dry-run", "Print result to stdout instead of posting (overrides --post)").action(async (action, target, options) => {
7438
+ if (!["review", "security-review", "summarize"].includes(action)) {
7439
+ console.error(`Unknown pr action: ${action}. Use review | security-review | summarize.`);
7440
+ process.exit(1);
7441
+ }
7442
+ const { runPrCli } = await import("./pr-JOL3IAGV.js");
7443
+ const result = await runPrCli({
7444
+ action,
7445
+ target,
7446
+ base: options.base,
7447
+ head: options.head,
7448
+ post: !!options.post,
7449
+ update: options.update !== false,
7450
+ detailed: !!options.detailed,
7451
+ agents: options.agents,
7452
+ maxDiffChars: options.maxDiff,
7453
+ provider: options.provider,
7454
+ model: options.model,
7455
+ dryRun: !!options.dryRun
7456
+ });
7457
+ process.stdout.write(result.markdown + "\n");
7458
+ if (result.posted) process.stderr.write("\n\u2705 Posted PR review comment\n");
7459
+ process.exit(result.exitCode);
7460
+ });
7461
+ program.command("ci").description("Headless PR review (code + security) \u2014 reads git/gh diff, optionally posts to PR. Designed for GitHub Actions.").option("--pr <num>", "PR number or URL; diff fetched via gh pr diff <value>", (v) => /^#?\d+$/.test(v) ? parseInt(v.replace(/^#/, ""), 10) : v).option("--base <ref>", "Base ref for git diff <ref>...HEAD (ignored when --pr set)").option("--post", "Post review as a PR comment (requires gh CLI + GH_TOKEN, needs --pr)").option("--no-update", "Always create a new comment instead of updating the previous aicli review").option("--skip-code", "Skip the code review section").option("--skip-security", "Skip the security review section").option("--detailed", "Use the detailed code-review prompt").option("--max-diff <n>", "Max diff chars sent to the model (default 30000)", (v) => parseInt(v, 10)).option("--provider <id>", "Override provider (default: config.defaultProvider)").option("--model <id>", "Override model").option("--dry-run", "Print result to stdout instead of posting (overrides --post)").option("--json", "Output a structured JSON report").option("--markdown", "Output Markdown report (default)").option("--sarif", "Output SARIF 2.1.0 for code scanning artifacts").option("--fail-on-security-high", "Fail when the security review contains HIGH/CRITICAL findings (default)").option("--no-fail-on-security-high", "Do not fail on security HIGH/CRITICAL findings").option("--fail-on-test-failure", "Fail when the report mentions test failures (default)").option("--no-fail-on-test-failure", "Do not fail on test failure findings").option("--fail-on-lint-failure", "Fail when the report mentions lint/typecheck failures (default)").option("--no-fail-on-lint-failure", "Do not fail on lint/typecheck failure findings").action(async (options) => {
7462
+ const { runCi } = await import("./ci-6ZTFO3LX.js");
7463
+ const { formatCiResult } = await import("./ci-format-CLZ6QJRL.js");
7464
+ const formats = [options.json, options.markdown, options.sarif].filter(Boolean).length;
7465
+ if (formats > 1) {
7466
+ console.error("Choose only one output format: --json, --markdown, or --sarif.");
7467
+ process.exit(2);
7468
+ }
7469
+ const outputFormat = options.json ? "json" : options.sarif ? "sarif" : "markdown";
7439
7470
  const result = await runCi({
7440
7471
  pr: options.pr,
7441
7472
  base: options.base,
@@ -7447,13 +7478,16 @@ program.command("ci").description("Headless PR review (code + security) \u2014 r
7447
7478
  maxDiffChars: options.maxDiff,
7448
7479
  provider: options.provider,
7449
7480
  model: options.model,
7450
- dryRun: !!options.dryRun
7481
+ dryRun: !!options.dryRun,
7482
+ thresholds: {
7483
+ securityHigh: options.failOnSecurityHigh !== false,
7484
+ testFailure: options.failOnTestFailure !== false,
7485
+ lintFailure: options.failOnLintFailure !== false
7486
+ }
7451
7487
  });
7452
- process.stdout.write(result.markdown + "\n");
7488
+ process.stdout.write(formatCiResult({ version: VERSION, ...result }, outputFormat) + "\n");
7453
7489
  if (result.posted) {
7454
- process.stderr.write(`
7455
- \u2705 Posted review to PR #${options.pr}${result.updatedCommentId ? " (updated existing comment)" : ""}
7456
- `);
7490
+ process.stderr.write("\n\u2705 Posted review to PR #" + options.pr + (result.updatedCommentId ? " (updated existing comment)" : "") + "\n");
7457
7491
  }
7458
7492
  process.exit(result.exitCode);
7459
7493
  });
@@ -7484,6 +7518,8 @@ program.command("help").description("Show a comprehensive guide to all aicli fea
7484
7518
  ` ${G}aicli usage${R} Token + cost usage by provider/model (--days/--month/--json)`,
7485
7519
  ` ${G}aicli user <action>${R} User management (list/create/delete)`,
7486
7520
  ` ${G}aicli batch <action>${R} Anthropic Batches API (50% off, 24h): submit/list/status/results/cancel`,
7521
+ ` ${G}aicli pr <action>${R} Local PR review/summarize commands`,
7522
+ ` ${G}aicli ci [options]${R} Headless PR review for GitHub Actions`,
7487
7523
  ` ${G}aicli mcp-serve${R} MCP server over STDIO (expose tools to Claude Desktop / Cursor)`,
7488
7524
  "",
7489
7525
  `${B}${C} \u25A0 STARTUP OPTIONS${R}`,
@@ -7581,7 +7617,7 @@ program.command("hub [topic]").description("Start multi-agent hub (discuss / bra
7581
7617
  }),
7582
7618
  config.get("customProviders")
7583
7619
  );
7584
- const { startHub } = await import("./hub-GURYEW6F.js");
7620
+ const { startHub } = await import("./hub-ZGHQWNWE.js");
7585
7621
  await startHub(
7586
7622
  {
7587
7623
  topic: topic ?? "",
@@ -0,0 +1,267 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ countSeverity,
4
+ runCi
5
+ } from "./chunk-GY3C3C2Y.js";
6
+ import "./chunk-TJ6GGN4B.js";
7
+ import {
8
+ buildReviewPrompt,
9
+ buildSecurityReviewPrompt,
10
+ truncateDiff
11
+ } from "./chunk-HLWUDRBO.js";
12
+ import {
13
+ ProviderRegistry
14
+ } from "./chunk-QMXC327F.js";
15
+ import "./chunk-XPBEJB27.js";
16
+ import {
17
+ ConfigManager
18
+ } from "./chunk-WAI3WPV2.js";
19
+ import "./chunk-TZQHYZKT.js";
20
+ import {
21
+ VERSION
22
+ } from "./chunk-7YWS3JLU.js";
23
+ import "./chunk-IW3Q7AE5.js";
24
+
25
+ // src/cli/pr.ts
26
+ import { execFileSync } from "child_process";
27
+ var ALLOWED_AGENTS = /* @__PURE__ */ new Set(["security", "bugs", "tests", "maintainability"]);
28
+ function parsePrTarget(input) {
29
+ if (!input) return {};
30
+ const s = input.trim();
31
+ if (/^https:\/\/github\.com\/[^/]+\/[^/]+\/pull\/\d+(?:[/?#].*)?$/.test(s)) return { pr: s };
32
+ if (/^#?\d+$/.test(s)) return { pr: parseInt(s.replace(/^#/, ""), 10) };
33
+ const range = s.match(/^([^\s.][^\s]*?)\.\.\.([^\s]+)$/);
34
+ if (range) return { base: range[1], head: range[2] };
35
+ return { base: s, head: "HEAD" };
36
+ }
37
+ function parseAgentList(input) {
38
+ if (!input) return [];
39
+ const agents = input.split(",").map((s) => s.trim()).filter(Boolean);
40
+ const invalid = agents.filter((a) => !ALLOWED_AGENTS.has(a));
41
+ if (invalid.length) throw new Error(`unknown PR review agent(s): ${invalid.join(", ")}. Allowed: ${Array.from(ALLOWED_AGENTS).join(", ")}`);
42
+ return [...new Set(agents)];
43
+ }
44
+ function validateGitRef(ref) {
45
+ if (!/^[A-Za-z0-9._/\-]+$/.test(ref)) throw new Error(`unsafe ref: ${ref}`);
46
+ }
47
+ function hasGitHubToken() {
48
+ return !!(process.env.GH_TOKEN || process.env.GITHUB_TOKEN);
49
+ }
50
+ function fetchPrMetadata(pr) {
51
+ if (!hasGitHubToken()) return null;
52
+ try {
53
+ const out = execFileSync("gh", ["pr", "view", String(pr), "--json", "number,url,title,author,state,baseRefName,headRefName"], {
54
+ encoding: "utf-8",
55
+ maxBuffer: 5 * 1024 * 1024,
56
+ timeout: 3e4
57
+ });
58
+ const parsed = JSON.parse(out);
59
+ return {
60
+ number: parsed.number,
61
+ url: parsed.url,
62
+ title: parsed.title,
63
+ state: parsed.state,
64
+ baseRefName: parsed.baseRefName,
65
+ headRefName: parsed.headRefName,
66
+ author: parsed.author?.login
67
+ };
68
+ } catch {
69
+ return null;
70
+ }
71
+ }
72
+ function fetchDiffSource(opts) {
73
+ const target = parsePrTarget(opts.target);
74
+ if (opts.diffOverride != null) {
75
+ const isPr = target.pr != null;
76
+ return {
77
+ kind: isPr ? "github-pr" : "git",
78
+ label: isPr ? `PR ${String(target.pr)}` : opts.base ? `${opts.base}...${opts.head || "HEAD"}` : "injected diff",
79
+ diff: opts.diffOverride,
80
+ metadata: opts.metadataOverride ?? null
81
+ };
82
+ }
83
+ const pr = target.pr;
84
+ const base = opts.base ?? target.base ?? "main";
85
+ const head = opts.head ?? target.head ?? "HEAD";
86
+ if (pr != null) {
87
+ try {
88
+ const diff = execFileSync("gh", ["pr", "diff", String(pr)], {
89
+ encoding: "utf-8",
90
+ maxBuffer: 50 * 1024 * 1024,
91
+ timeout: 6e4
92
+ });
93
+ return { kind: "github-pr", label: `PR ${String(pr)}`, diff, metadata: fetchPrMetadata(pr) };
94
+ } catch (err) {
95
+ const msg = err.stderr?.toString() ?? err.message;
96
+ throw new Error(`gh pr diff ${String(pr)} failed: ${msg.trim() || "unknown error"}. For local review without GitHub auth, use --base/--head instead.`);
97
+ }
98
+ }
99
+ validateGitRef(base);
100
+ validateGitRef(head);
101
+ try {
102
+ const diff = execFileSync("git", ["diff", `${base}...${head}`], {
103
+ encoding: "utf-8",
104
+ maxBuffer: 50 * 1024 * 1024,
105
+ timeout: 3e4
106
+ });
107
+ return { kind: "git", label: `${base}...${head}`, diff, metadata: null };
108
+ } catch (err) {
109
+ throw new Error(`git diff ${base}...${head} failed: ${err.message}`);
110
+ }
111
+ }
112
+ function metadataMarkdown(meta) {
113
+ if (!meta) return "";
114
+ const parts = [
115
+ meta.number != null ? `#${meta.number}` : void 0,
116
+ meta.title,
117
+ meta.state,
118
+ meta.author ? `by @${meta.author}` : void 0,
119
+ meta.baseRefName && meta.headRefName ? `${meta.baseRefName} \u2190 ${meta.headRefName}` : void 0,
120
+ meta.url
121
+ ].filter(Boolean);
122
+ return parts.length ? `
123
+ PR metadata: ${parts.join(" \xB7 ")}` : "";
124
+ }
125
+ function buildGitContext(src) {
126
+ const parts = [`Source: ${src.label}`, `Reviewer: aicli v${VERSION}`];
127
+ if (src.metadata?.number != null) parts.push(`PR: #${src.metadata.number}`);
128
+ if (src.metadata?.title) parts.push(`Title: ${src.metadata.title}`);
129
+ if (src.metadata?.baseRefName && src.metadata?.headRefName) parts.push(`Base/Head: ${src.metadata.baseRefName}...${src.metadata.headRefName}`);
130
+ return parts.join(" | ");
131
+ }
132
+ function buildSummaryPrompt(diff, gitContext) {
133
+ return `# Pull Request Summary Request
134
+
135
+ Summarize this pull request for maintainers. Focus on what changed, why it matters, risk areas, tests implied by the diff, and release-note worthy behavior.
136
+
137
+ ## Git Context
138
+ ${gitContext}
139
+
140
+ ## Code Changes (diff)
141
+ \`\`\`diff
142
+ ${diff}
143
+ \`\`\`
144
+
145
+ ## Output Format
146
+ 1. **Summary**: 2-4 bullets
147
+ 2. **Key Files**: important files and why they changed
148
+ 3. **Risk / Review Focus**: areas reviewers should inspect
149
+ 4. **Testing Notes**: tests present or missing
150
+ 5. **Suggested PR Description**: concise markdown description`;
151
+ }
152
+ function buildAgentPrompt(agent, diff, gitContext) {
153
+ const focus = {
154
+ security: "security vulnerabilities, secret handling, authz/authn, injection, unsafe network/file behavior",
155
+ bugs: "logic bugs, edge cases, race conditions, incorrect assumptions, regressions",
156
+ tests: "missing tests, weak assertions, CI breakage risk, testability gaps",
157
+ maintainability: "complexity, naming, duplication, API shape, future maintenance risk"
158
+ };
159
+ return `# PR Review Agent: ${agent}
160
+
161
+ Review the diff only from this lens: ${focus[agent]}. Be concise and cite file paths/lines when possible.
162
+
163
+ ## Git Context
164
+ ${gitContext}
165
+
166
+ ## Diff
167
+ \`\`\`diff
168
+ ${diff}
169
+ \`\`\`
170
+
171
+ ## Output Format
172
+ - Findings first, ordered by severity
173
+ - If no material findings, say so clearly
174
+ - Keep recommendations actionable`;
175
+ }
176
+ async function getProvider(opts) {
177
+ const config = new ConfigManager();
178
+ const registry = new ProviderRegistry();
179
+ await registry.initialize(
180
+ (id) => config.getApiKey(id),
181
+ (id) => ({ baseUrl: config.get("customBaseUrls")[id], timeout: config.get("timeouts")[id], proxy: config.get("proxy") }),
182
+ config.get("customProviders")
183
+ );
184
+ const providerId = opts.provider ?? config.getDefaultProvider();
185
+ if (!registry.has(providerId)) throw new Error(`Provider '${providerId}' is not configured. Set the right AICLI_API_KEY_* env var or pass --provider.`);
186
+ const info = registry.get(providerId).info;
187
+ return { registry, providerId, modelId: opts.model ?? config.get("defaultModels")[providerId] ?? info.defaultModel };
188
+ }
189
+ async function runPrompt(registry, providerId, modelId, prompt) {
190
+ const provider = registry.get(providerId);
191
+ const resp = await provider.chat({
192
+ messages: [{ role: "user", content: prompt, timestamp: /* @__PURE__ */ new Date() }],
193
+ model: modelId,
194
+ stream: false,
195
+ temperature: 0.3,
196
+ maxTokens: 8192
197
+ });
198
+ return resp.content?.trim() ?? "";
199
+ }
200
+ async function runPrCli(opts) {
201
+ let source;
202
+ try {
203
+ source = fetchDiffSource(opts);
204
+ } catch (err) {
205
+ return { exitCode: 2, markdown: `\u274C ${err.message}`, posted: false, severity: { critical: 0, high: 0, warning: 0, info: 0 } };
206
+ }
207
+ const diff = source.diff.trim();
208
+ if (!diff) return { exitCode: 0, markdown: `\u2705 No changes to review (${source.label}).`, posted: false, severity: { critical: 0, high: 0, warning: 0, info: 0 } };
209
+ const parsedTarget = parsePrTarget(opts.target);
210
+ const requestedAgents = parseAgentList(opts.agents);
211
+ if (opts.post && source.kind !== "github-pr") {
212
+ return { exitCode: 2, markdown: "\u274C --post requires a GitHub PR number or URL target.", posted: false, severity: { critical: 0, high: 0, warning: 0, info: 0 } };
213
+ }
214
+ if (opts.post && opts.action === "summarize") {
215
+ return { exitCode: 2, markdown: "\u274C --post is currently supported for pr review and pr security-review only.", posted: false, severity: { critical: 0, high: 0, warning: 0, info: 0 } };
216
+ }
217
+ if (opts.post && requestedAgents.length > 0) {
218
+ return { exitCode: 2, markdown: "\u274C --post is currently not supported together with --agents; run without --agents or post the Markdown manually.", posted: false, severity: { critical: 0, high: 0, warning: 0, info: 0 } };
219
+ }
220
+ if ((opts.action === "review" || opts.action === "security-review") && requestedAgents.length === 0) {
221
+ const ci = await runCi({
222
+ pr: source.kind === "github-pr" ? parsedTarget.pr : void 0,
223
+ diffOverride: diff,
224
+ base: source.kind === "git" ? source.label.split("...")[0] : void 0,
225
+ post: !!opts.post,
226
+ update: opts.update !== false,
227
+ skipCode: opts.action === "security-review",
228
+ skipSecurity: opts.action === "review",
229
+ detailed: !!opts.detailed,
230
+ maxDiffChars: opts.maxDiffChars,
231
+ provider: opts.provider,
232
+ model: opts.model,
233
+ dryRun: !!opts.dryRun
234
+ });
235
+ return { exitCode: ci.exitCode, markdown: ci.markdown + metadataMarkdown(source.metadata), posted: ci.posted, severity: ci.severity };
236
+ }
237
+ const maxDiff = opts.maxDiffChars ?? 3e4;
238
+ const { diff: trimmedDiff, truncated } = truncateDiff(diff, maxDiff);
239
+ const gitContext = buildGitContext(source);
240
+ let providerBundle;
241
+ try {
242
+ providerBundle = await getProvider(opts);
243
+ } catch (err) {
244
+ return { exitCode: 2, markdown: `\u274C ${err.message}`, posted: false, severity: { critical: 0, high: 0, warning: 0, info: 0 } };
245
+ }
246
+ const sections = [`## \u{1F916} aicli pr ${opts.action}`, `*Provider: \`${providerBundle.providerId}\` \xB7 Model: \`${providerBundle.modelId}\` \xB7 Source: \`${source.label}\` \xB7 aicli v${VERSION}*`, ""];
247
+ if (source.metadata) sections.push(`> ${metadataMarkdown(source.metadata).trim()}`, "");
248
+ try {
249
+ const prompt = opts.action === "security-review" ? buildSecurityReviewPrompt(trimmedDiff, gitContext) : opts.action === "summarize" ? buildSummaryPrompt(trimmedDiff, gitContext) : buildReviewPrompt(trimmedDiff, gitContext, !!opts.detailed);
250
+ sections.push(await runPrompt(providerBundle.registry, providerBundle.providerId, providerBundle.modelId, prompt), "");
251
+ if (requestedAgents.length) {
252
+ const outputs = await Promise.all(requestedAgents.map(async (agent) => ({ agent, output: await runPrompt(providerBundle.registry, providerBundle.providerId, providerBundle.modelId, buildAgentPrompt(agent, trimmedDiff, gitContext)) })));
253
+ sections.push("### Agent Lenses", "");
254
+ for (const item of outputs) sections.push(`#### ${item.agent}`, item.output, "");
255
+ }
256
+ } catch (err) {
257
+ return { exitCode: 2, markdown: `\u274C PR review call failed: ${err.message}`, posted: false, severity: { critical: 0, high: 0, warning: 0, info: 0 } };
258
+ }
259
+ if (truncated) sections.push(`> \u26A0 Diff was truncated to ${maxDiff} chars (original: ${diff.length}). Consider splitting large PRs.`);
260
+ const markdown = sections.join("\n");
261
+ return { exitCode: 0, markdown, posted: false, severity: countSeverity(markdown) };
262
+ }
263
+ export {
264
+ parseAgentList,
265
+ parsePrTarget,
266
+ runPrCli
267
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  executeTests,
3
3
  runTestsTool
4
- } from "./chunk-JOJA35RK.js";
4
+ } from "./chunk-OLN7VUZA.js";
5
5
  export {
6
6
  executeTests,
7
7
  runTestsTool
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  executeTests,
4
4
  runTestsTool
5
- } from "./chunk-TR6MSPSS.js";
6
- import "./chunk-DBYMX2ZC.js";
5
+ } from "./chunk-VW7Y27WW.js";
6
+ import "./chunk-7YWS3JLU.js";
7
7
  export {
8
8
  executeTests,
9
9
  runTestsTool
@@ -24,7 +24,7 @@ import {
24
24
  scanDirTree,
25
25
  scanProject,
26
26
  setupProxy
27
- } from "./chunk-5FG7PSVM.js";
27
+ } from "./chunk-PNTLA3MN.js";
28
28
  import {
29
29
  buildReviewPrompt,
30
30
  buildSecurityReviewPrompt
@@ -61,10 +61,10 @@ import {
61
61
  spawnAgentContext,
62
62
  truncateOutput,
63
63
  undoStack
64
- } from "./chunk-R5CJD2AB.js";
64
+ } from "./chunk-TCOC4AUI.js";
65
65
  import "./chunk-T2NL5ZIA.js";
66
66
  import "./chunk-BXP6YZ2P.js";
67
- import "./chunk-TR6MSPSS.js";
67
+ import "./chunk-VW7Y27WW.js";
68
68
  import {
69
69
  SessionManager,
70
70
  getContentText
@@ -78,7 +78,7 @@ import {
78
78
  } from "./chunk-QMXC327F.js";
79
79
  import {
80
80
  runTool
81
- } from "./chunk-YMFGGCUP.js";
81
+ } from "./chunk-77HDCGTN.js";
82
82
  import {
83
83
  CONTENT_ONLY_STREAM_REMINDER,
84
84
  TEE_FINAL_USER_NUDGE,
@@ -97,7 +97,7 @@ import {
97
97
  } from "./chunk-XPBEJB27.js";
98
98
  import {
99
99
  ConfigManager
100
- } from "./chunk-YFHF3PVB.js";
100
+ } from "./chunk-WAI3WPV2.js";
101
101
  import "./chunk-TZQHYZKT.js";
102
102
  import {
103
103
  AGENTIC_BEHAVIOR_GUIDELINE,
@@ -116,7 +116,7 @@ import {
116
116
  SKILLS_DIR_NAME,
117
117
  VERSION,
118
118
  buildUserIdentityPrompt
119
- } from "./chunk-DBYMX2ZC.js";
119
+ } from "./chunk-7YWS3JLU.js";
120
120
  import {
121
121
  formatGitContextForPrompt,
122
122
  getGitContext,
@@ -2755,7 +2755,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
2755
2755
  case "test": {
2756
2756
  this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
2757
2757
  try {
2758
- const { executeTests } = await import("./run-tests-F44JA2YW.js");
2758
+ const { executeTests } = await import("./run-tests-ZRK4TQUN.js");
2759
2759
  const argStr = args.join(" ").trim();
2760
2760
  let testArgs = {};
2761
2761
  if (argStr) {
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ToolRegistry
4
- } from "./chunk-R5CJD2AB.js";
4
+ } from "./chunk-TCOC4AUI.js";
5
5
  import "./chunk-T2NL5ZIA.js";
6
6
  import "./chunk-BXP6YZ2P.js";
7
- import "./chunk-TR6MSPSS.js";
7
+ import "./chunk-VW7Y27WW.js";
8
8
  import {
9
9
  runTool
10
- } from "./chunk-YMFGGCUP.js";
10
+ } from "./chunk-77HDCGTN.js";
11
11
  import {
12
12
  getDangerLevel,
13
13
  schemaToJsonSchema
@@ -15,7 +15,7 @@ import {
15
15
  import "./chunk-TZQHYZKT.js";
16
16
  import {
17
17
  VERSION
18
- } from "./chunk-DBYMX2ZC.js";
18
+ } from "./chunk-7YWS3JLU.js";
19
19
  import "./chunk-4BKXL7SM.js";
20
20
  import "./chunk-TB4W4Y4T.js";
21
21
  import "./chunk-KHYD3WXE.js";
@@ -3,13 +3,13 @@ import {
3
3
  ToolRegistry,
4
4
  googleSearchContext,
5
5
  truncateOutput
6
- } from "./chunk-R5CJD2AB.js";
6
+ } from "./chunk-TCOC4AUI.js";
7
7
  import "./chunk-T2NL5ZIA.js";
8
8
  import "./chunk-BXP6YZ2P.js";
9
- import "./chunk-TR6MSPSS.js";
9
+ import "./chunk-VW7Y27WW.js";
10
10
  import {
11
11
  runTool
12
- } from "./chunk-YMFGGCUP.js";
12
+ } from "./chunk-77HDCGTN.js";
13
13
  import {
14
14
  getDangerLevel,
15
15
  runLeanAgentLoop
@@ -17,7 +17,7 @@ import {
17
17
  import "./chunk-TZQHYZKT.js";
18
18
  import {
19
19
  SUBAGENT_ALLOWED_TOOLS
20
- } from "./chunk-DBYMX2ZC.js";
20
+ } from "./chunk-7YWS3JLU.js";
21
21
  import "./chunk-4BKXL7SM.js";
22
22
  import "./chunk-TB4W4Y4T.js";
23
23
  import "./chunk-KHYD3WXE.js";
@@ -8,9 +8,9 @@ import {
8
8
  } from "./chunk-E44DTERW.js";
9
9
  import {
10
10
  ConfigManager
11
- } from "./chunk-YFHF3PVB.js";
11
+ } from "./chunk-WAI3WPV2.js";
12
12
  import "./chunk-TZQHYZKT.js";
13
- import "./chunk-DBYMX2ZC.js";
13
+ import "./chunk-7YWS3JLU.js";
14
14
  import "./chunk-IW3Q7AE5.js";
15
15
 
16
16
  // src/cli/usage.ts
@@ -24,6 +24,7 @@ function handleDeclarativeAction(action, el) {
24
24
  case 'batch-deny-response': window.respondBatchDeny(el.dataset.requestId, el); break;
25
25
  case 'ask-user-response': window.respondAskUser(el.dataset.requestId); break;
26
26
  case 'auto-pause-response': window.respondAutoPause(el.dataset.requestId, el.dataset.pauseAction); break;
27
+ case 'copy-confirm-diff': window.copyConfirmDiff(el); break;
27
28
  case 'use-template': useTemplate(el.closest('[data-tpl-id]')?.dataset.tplId); break;
28
29
  case 'edit-template': editTemplate(el.closest('[data-tpl-id]')?.dataset.tplId); break;
29
30
  case 'delete-template': deleteTemplate(el.closest('[data-tpl-id]')?.dataset.tplId); break;