xab 8.0.0 → 10.0.0

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 (2) hide show
  1. package/dist/index.js +128 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -448,7 +448,28 @@ async function runStreamedWithProgress(thread, prompt, onProgress, turnOpts) {
448
448
  const cmd = item.command ?? "";
449
449
  const status = item.status;
450
450
  if (status === "in_progress") {
451
- onProgress("exec", `$ ${cmd}`);
451
+ const inner = cmd.replace(/^\/bin\/(?:ba)?sh\s+-\w+\s+['"](.*)['"]$/s, "$1") || cmd;
452
+ const readMatch = inner.match(/\b(?:cat|head|tail|less|bat|nl)\s+(?:-\w+\s+)*['"]?([^\s'"|\]]+)/);
453
+ const sedMatch = inner.match(/\bsed\s+-n\s+['"]?\d+.*?['"]?\s+['"]?([^\s'"]+)/);
454
+ const rgMatch = inner.match(/\brg\s+(?:-[^\s]+\s+)*['"]?(.+?)['"]?\s+(\S+)/);
455
+ const gitShowMatch = inner.match(/\bgit\s+show\s+(\S+)/);
456
+ const gitDiffMatch = inner.match(/\bgit\s+diff\b/);
457
+ const gitLogMatch = inner.match(/\bgit\s+log\b/);
458
+ if (readMatch) {
459
+ onProgress("read", readMatch[1]);
460
+ } else if (sedMatch) {
461
+ onProgress("read", sedMatch[1]);
462
+ } else if (rgMatch) {
463
+ onProgress("grep", `"${rgMatch[1]}" in ${rgMatch[2]}`);
464
+ } else if (gitShowMatch) {
465
+ onProgress("read", `git show ${gitShowMatch[1]}`);
466
+ } else if (gitDiffMatch) {
467
+ onProgress("exec", `$ ${inner.slice(0, 120)}`);
468
+ } else if (gitLogMatch) {
469
+ onProgress("exec", `$ ${inner.slice(0, 120)}`);
470
+ } else {
471
+ onProgress("exec", `$ ${inner.slice(0, 120)}`);
472
+ }
452
473
  } else if (status === "completed") {
453
474
  const output = item.aggregated_output ?? "";
454
475
  if (output) {
@@ -468,17 +489,45 @@ async function runStreamedWithProgress(thread, prompt, onProgress, turnOpts) {
468
489
  }
469
490
  break;
470
491
  }
492
+ case "mcp_tool_call": {
493
+ const tool = item.tool ?? "";
494
+ const args = item.arguments ?? {};
495
+ const status = item.status;
496
+ if (status === "in_progress") {
497
+ if (tool.toLowerCase().includes("read")) {
498
+ onProgress("read", (args.file_path ?? args.path ?? tool).slice(0, 120));
499
+ } else if (tool.toLowerCase().includes("grep") || tool.toLowerCase().includes("search")) {
500
+ onProgress("grep", `"${(args.pattern ?? "").slice(0, 60)}" ${args.path ?? ""}`);
501
+ } else if (tool.toLowerCase().includes("glob") || tool.toLowerCase().includes("find")) {
502
+ onProgress("glob", (args.pattern ?? args.path ?? tool).slice(0, 120));
503
+ } else {
504
+ onProgress("tool", `${tool} ${JSON.stringify(args).slice(0, 80)}`);
505
+ }
506
+ }
507
+ break;
508
+ }
471
509
  case "reasoning": {
472
510
  const text = item.text ?? "";
473
- if (text && event.type === "item.completed") {
474
- onProgress("think", text.split(`
475
- `)[0].slice(0, 120));
511
+ if (text) {
512
+ const lines = text.split(`
513
+ `).filter(Boolean);
514
+ for (const line of lines.slice(0, 3)) {
515
+ onProgress("think", line.slice(0, 150));
516
+ }
476
517
  }
477
518
  break;
478
519
  }
479
520
  case "agent_message": {
521
+ const text = item.text ?? "";
480
522
  if (event.type === "item.completed") {
481
- finalResponse = item.text ?? "";
523
+ finalResponse = text;
524
+ }
525
+ if (event.type === "item.updated" && text) {
526
+ const lastLine = text.split(`
527
+ `).filter(Boolean).pop();
528
+ if (lastLine && lastLine.length > 10) {
529
+ onProgress("think", lastLine.slice(0, 150));
530
+ }
482
531
  }
483
532
  break;
484
533
  }
@@ -774,26 +823,41 @@ async function reviewAppliedDiff(worktreePath, packet, onProgress) {
774
823
  normal: "Be thorough but reasonable. Reject clear issues, accept minor style differences.",
775
824
  lenient: "Focus on correctness and safety. Accept reasonable adaptations even if imperfect."
776
825
  };
777
- const prompt = `You are reviewing a curated merge. A commit from "${packet.sourceBranch}" was applied to a branch based on "${packet.targetBranch}".
826
+ const prompt = `You are reviewing a curated merge commit. Codex adapted a source commit from "${packet.sourceBranch}" and applied it to this worktree (based on "${packet.targetBranch}").
778
827
 
779
- ## Codex analysis of the source commit
780
- Summary: ${packet.analysis.summary}
781
- Decision: alreadyInTarget=${packet.analysis.alreadyInTarget}
782
- Strategy: ${packet.analysis.applicationStrategy}
783
- Affected components: ${packet.analysis.affectedComponents.join(", ")}
828
+ Your job: review the NEW commit Codex created. Verify it is correct, clean, and faithful to the source commit's intent while respecting the target's architecture.
784
829
 
785
- ## Source commit
830
+ ## Source commit (what was being backmerged)
786
831
  Hash: ${packet.commitHash}
787
832
  Message: ${packet.commitMessage}
833
+ Branch: ${packet.sourceBranch}
834
+
835
+ ### Original source diff:
836
+ \`\`\`diff
837
+ ${packet.sourcePatch.slice(0, 15000)}
838
+ \`\`\`
839
+
840
+ ## Codex's analysis
841
+ Summary: ${packet.analysis.summary}
842
+ Already in target: ${packet.analysis.alreadyInTarget}
843
+ Strategy used: ${packet.analysis.applicationStrategy}
844
+ Components: ${packet.analysis.affectedComponents.join(", ")}
788
845
 
789
- ## Applied diff (what was actually committed):
846
+ ## Codex's applied commit (what you are reviewing)
847
+ ${packet.newCommitHash ? `Commit: ${packet.newCommitHash} (in this worktree)
848
+ Run \`git show ${packet.newCommitHash.slice(0, 8)}\` to inspect it.` : `Run \`git show HEAD\` to inspect it.`}
849
+
850
+ ### Applied diff:
790
851
  \`\`\`diff
791
852
  ${packet.appliedDiff.slice(0, 30000)}
792
853
  \`\`\`
793
854
 
794
- ## Diff stat:
855
+ ### Diff stat:
795
856
  ${packet.appliedDiffStat}
796
857
 
858
+ ## Key question: does the applied commit correctly adapt the source commit's intent?
859
+ Compare the source diff with the applied diff. The applied commit should capture the same behavior/fix but adapted for the target branch's codebase structure.
860
+
797
861
  ${packet.repoContext ? `## Repository context
798
862
  ${packet.repoContext}
799
863
  ` : ""}
@@ -904,15 +968,22 @@ Your objections will be sent back to the apply agent for fixing, so be specific
904
968
  }
905
969
  }
906
970
  if (message.type === "result") {
907
- if ("result" in message) {
908
- resultText = message.result;
971
+ const msg = message;
972
+ if (msg.structured_output) {
973
+ resultText = typeof msg.structured_output === "string" ? msg.structured_output : JSON.stringify(msg.structured_output);
974
+ } else if (msg.result) {
975
+ resultText = msg.result;
909
976
  }
910
977
  break;
911
978
  }
912
979
  }
913
980
  if (!resultText) {
981
+ if (onProgress)
982
+ onProgress("review", "WARNING: no structured_output or result in review response");
914
983
  return { approved: false, issues: ["Review produced no output"], summary: "Review failed", confidence: "low" };
915
984
  }
985
+ if (onProgress)
986
+ onProgress("review", `got ${resultText.length} chars of review output`);
916
987
  try {
917
988
  return JSON.parse(resultText);
918
989
  } catch {
@@ -1712,6 +1783,7 @@ async function processOneCommit(o) {
1712
1783
  packet = {
1713
1784
  commitHash: commit.hash,
1714
1785
  commitMessage: commit.message,
1786
+ newCommitHash: validation.newCommitHash ?? undefined,
1715
1787
  sourceBranch: o.sourceRef,
1716
1788
  targetBranch: o.targetRef,
1717
1789
  analysis,
@@ -1975,8 +2047,46 @@ async function runBatch(opts) {
1975
2047
  onProgress(phase, msg) {
1976
2048
  if (jsonl)
1977
2049
  emitJsonl({ event: "progress", phase, msg });
1978
- const icon = phase === "apply" ? chalk.green("\u25B8") : chalk.blue("\u25B8");
1979
- log(` ${ts()} ${icon} ${chalk.dim(msg)}`);
2050
+ const subMatch = msg.match(/^\[(\w+)\]\s*(.*)/);
2051
+ const sub = subMatch ? subMatch[1] : phase;
2052
+ const text = subMatch ? subMatch[2] : msg;
2053
+ let icon;
2054
+ switch (sub) {
2055
+ case "read":
2056
+ icon = chalk.cyan("\uD83D\uDCD6");
2057
+ break;
2058
+ case "grep":
2059
+ icon = chalk.cyan("\uD83D\uDD0D");
2060
+ break;
2061
+ case "glob":
2062
+ icon = chalk.cyan("\uD83D\uDCC2");
2063
+ break;
2064
+ case "exec":
2065
+ icon = chalk.yellow("\u26A1");
2066
+ break;
2067
+ case "file":
2068
+ icon = chalk.green("\u270F\uFE0F");
2069
+ break;
2070
+ case "think":
2071
+ icon = chalk.blue("\uD83D\uDCAD");
2072
+ break;
2073
+ case "tool":
2074
+ icon = chalk.dim("\uD83D\uDD27");
2075
+ break;
2076
+ case "analyze":
2077
+ icon = chalk.blue("\u25C6");
2078
+ break;
2079
+ case "apply":
2080
+ icon = chalk.green("\u25B8");
2081
+ break;
2082
+ case "review":
2083
+ icon = chalk.magenta("\u25CF");
2084
+ break;
2085
+ default:
2086
+ icon = chalk.dim("\xB7");
2087
+ break;
2088
+ }
2089
+ log(` ${ts()} ${icon} ${chalk.dim(text)}`);
1980
2090
  },
1981
2091
  onLog(msg, color) {
1982
2092
  if (jsonl)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xab",
3
- "version": "8.0.0",
3
+ "version": "10.0.0",
4
4
  "description": "AI-powered curated branch reconciliation engine",
5
5
  "type": "module",
6
6
  "bin": {