@weareikko/code-review 0.10.1 → 0.10.3

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.
@@ -660,11 +660,16 @@ async function git$1(args, options = {}) {
660
660
  function remoteRef(remote, branch) {
661
661
  return `refs/remotes/${remote}/${branch}`;
662
662
  }
663
- function getMergeDiffArguments(targetBranch, options = {}) {
663
+ /**
664
+ * Diff the target branch with the MR head commit, not `HEAD`: CI checks out a
665
+ * merge commit (GitHub `refs/pull/N/merge`, GitLab merged results) whose base
666
+ * can be stale, and then `HEAD` carries commits the MR does not change.
667
+ */
668
+ function getMergeDiffArguments(targetBranch, headSha, options = {}) {
664
669
  const remote = options.remote ?? "origin";
665
670
  const context = options.context ?? DEFAULT_DIFF_CONTEXT;
666
671
  return [
667
- `${remoteRef(remote, targetBranch)}...HEAD`,
672
+ `${remoteRef(remote, targetBranch)}...${headSha}`,
668
673
  `--unified=${context}`,
669
674
  "--"
670
675
  ];
@@ -676,12 +681,12 @@ function getMergeDiffArguments(targetBranch, options = {}) {
676
681
  * leaving such comments with invalid one-sided positions that 500 on
677
682
  * `bulk_publish`. Diffing literally also gives the reviewer readable paths.
678
683
  */
679
- function getMergeDiffCommand(targetBranch, options = {}) {
684
+ function getMergeDiffCommand(targetBranch, headSha, options = {}) {
680
685
  return [
681
686
  "-c",
682
687
  "core.quotepath=false",
683
688
  "diff",
684
- ...getMergeDiffArguments(targetBranch, options)
689
+ ...getMergeDiffArguments(targetBranch, headSha, options)
685
690
  ];
686
691
  }
687
692
  async function fetchBranch(remote, branch, options) {
@@ -718,7 +723,7 @@ async function removeGeneratedCodeQualityArtifacts(paths = DEFAULT_CODEQUALITY_A
718
723
  }
719
724
  return removed;
720
725
  }
721
- async function prepareGitHistory(sourceBranch, targetBranch, options = {}) {
726
+ async function prepareGitHistory(sourceBranch, targetBranch, headSha, options = {}) {
722
727
  const remote = options.remote ?? "origin";
723
728
  await removeGeneratedCodeQualityArtifacts(options.codeQualityArtifacts, options);
724
729
  await git$1([
@@ -738,29 +743,29 @@ async function prepareGitHistory(sourceBranch, targetBranch, options = {}) {
738
743
  await git$1([
739
744
  "merge-base",
740
745
  remoteRef(remote, targetBranch),
741
- "HEAD"
746
+ headSha
742
747
  ], options);
743
748
  } catch (error) {
744
749
  const fetchDetail = fetchErrors.length > 0 ? `\nFetch warnings:\n${fetchErrors.join("\n")}` : "";
745
- throw new GitError(`Unable to prepare Git history for MR review: merge-base ${remoteRef(remote, targetBranch)} HEAD failed.`, {
750
+ throw new GitError(`Unable to prepare Git history for MR review: merge-base ${remoteRef(remote, targetBranch)} ${headSha} failed.`, {
746
751
  cause: error,
747
- hint: `Set GIT_DEPTH: 0 or ensure ${remote}/${targetBranch} is fetchable.${fetchDetail}\n${gitErrorMessage(error)}`
752
+ hint: `Set GIT_DEPTH: 0 or ensure ${remote}/${targetBranch} and ${remote}/${sourceBranch} are fetchable.${fetchDetail}\n${gitErrorMessage(error)}`
748
753
  });
749
754
  }
750
755
  }
751
- async function getMergeDiff(targetBranch, options = {}) {
752
- return git$1(getMergeDiffCommand(targetBranch, options), options);
756
+ async function getMergeDiff(targetBranch, headSha, options = {}) {
757
+ return git$1(getMergeDiffCommand(targetBranch, headSha, options), options);
753
758
  }
754
- function getMergeCommitLogArguments(targetBranch, options = {}) {
759
+ function getMergeCommitLogArguments(targetBranch, headSha, options = {}) {
755
760
  return [
756
- `${remoteRef(options.remote ?? "origin", targetBranch)}...HEAD`,
761
+ `${remoteRef(options.remote ?? "origin", targetBranch)}...${headSha}`,
757
762
  "--pretty=tformat:commit %h%nAuthor: %an%nDate: %as%n%n%s%n%n%b",
758
763
  "--reverse",
759
764
  "--no-merges"
760
765
  ];
761
766
  }
762
- async function getMergeCommitLog(targetBranch, options = {}) {
763
- return git$1(["log", ...getMergeCommitLogArguments(targetBranch, options)], options);
767
+ async function getMergeCommitLog(targetBranch, headSha, options = {}) {
768
+ return git$1(["log", ...getMergeCommitLogArguments(targetBranch, headSha, options)], options);
764
769
  }
765
770
  /**
766
771
  * Summarize a unified diff into file/line counts for telemetry. Counts one file
@@ -1767,7 +1772,7 @@ function buildSummaryBody(summary, costFooter, options = {}) {
1767
1772
  return `${withFooter}\n\n${buildSummaryHistoryBlock(historyEntries)}`;
1768
1773
  }
1769
1774
  function buildReviewedCommitFooter(commitSha) {
1770
- return `Reviewed by ${PRODUCT_LINK} v0.10.1 for commit ${commitSha}.`;
1775
+ return `Reviewed by ${PRODUCT_LINK} v0.10.3 for commit ${commitSha}.`;
1771
1776
  }
1772
1777
  function extractReviewedCommitSha(body) {
1773
1778
  return REVIEWED_COMMIT_FOOTER_PATTERN.exec(body)?.[1] ?? null;
@@ -3382,7 +3387,7 @@ async function connectOne(config, options) {
3382
3387
  };
3383
3388
  const client = new McpClient({
3384
3389
  name: PRODUCT_NAME,
3385
- version: "0.10.1",
3390
+ version: "0.10.3",
3386
3391
  requestTimeoutMs: MCP_CONNECT_TIMEOUT_MS
3387
3392
  });
3388
3393
  try {
@@ -7056,7 +7061,7 @@ async function loadDefaultRuntime() {
7056
7061
  const [sdkNode, resources, semconv] = modules;
7057
7062
  const serviceResource = resources.resourceFromAttributes({
7058
7063
  [semconv.ATTR_SERVICE_NAME ?? "service.name"]: SERVICE_NAME,
7059
- [semconv.ATTR_SERVICE_VERSION ?? "service.version"]: "0.10.1"
7064
+ [semconv.ATTR_SERVICE_VERSION ?? "service.version"]: "0.10.3"
7060
7065
  });
7061
7066
  applyOtelExporterDefaults(process.env);
7062
7067
  const sdk = new sdkNode.NodeSDK({ resource: resources.defaultResource().merge(serviceResource) });
@@ -7569,7 +7574,7 @@ function boldCommentTitle(body) {
7569
7574
  */
7570
7575
  function buildCommentBody(body, commitSha, confidence) {
7571
7576
  const confidenceLine = `_Confidence: ${confidence}._`;
7572
- const footer = `<sub>Reviewed by ${PRODUCT_LINK} v0.10.1 for commit ${commitSha}.</sub>`;
7577
+ const footer = `<sub>Reviewed by ${PRODUCT_LINK} v0.10.3 for commit ${commitSha}.</sub>`;
7573
7578
  return `${boldCommentTitle(body.trim())}\n\n${confidenceLine}\n\n---\n\n${footer}`;
7574
7579
  }
7575
7580
  function buildPayload(comment, body, refs, resolved) {
@@ -8221,7 +8226,7 @@ function gitRepoWebUrl(cloneUrl) {
8221
8226
  */
8222
8227
  function skillSourceUrl(origin, context = {}) {
8223
8228
  switch (origin.kind) {
8224
- case "builtin": return blobUrl(PRODUCT_URL, "0.10.1", `skills/${origin.name}/SKILL.md`);
8229
+ case "builtin": return blobUrl(PRODUCT_URL, "0.10.3", `skills/${origin.name}/SKILL.md`);
8225
8230
  case "project":
8226
8231
  if (!context.projectWebUrl || !context.commitSha) return void 0;
8227
8232
  return blobUrl(context.projectWebUrl, context.commitSha, `${origin.path}/SKILL.md`);
@@ -8533,9 +8538,9 @@ async function run(config, bridges) {
8533
8538
  };
8534
8539
  }
8535
8540
  logger.info("Fetching diff...");
8536
- await traceDiagnosticPhase("git.prepare_history", config, runId, () => prepareGitHistory(mr.source_branch, mr.target_branch, { cwd: config.cwd }));
8541
+ await traceDiagnosticPhase("git.prepare_history", config, runId, () => prepareGitHistory(mr.source_branch, mr.target_branch, refs.head_sha, { cwd: config.cwd }));
8537
8542
  const diff = await traceDiagnosticPhase("git.get_merge_diff", config, runId, async (context) => {
8538
- const merged = await getMergeDiff(mr.target_branch, {
8543
+ const merged = await getMergeDiff(mr.target_branch, refs.head_sha, {
8539
8544
  cwd: config.cwd,
8540
8545
  ...config.diffContext > 0 ? { context: config.diffContext } : {}
8541
8546
  });
@@ -8545,7 +8550,7 @@ async function run(config, bridges) {
8545
8550
  context.diffLinesRemoved = summary.linesRemoved;
8546
8551
  return merged;
8547
8552
  });
8548
- const commitLog = await traceDiagnosticPhase("git.get_commit_log", config, runId, () => getMergeCommitLog(mr.target_branch, { cwd: config.cwd }));
8553
+ const commitLog = await traceDiagnosticPhase("git.get_commit_log", config, runId, () => getMergeCommitLog(mr.target_branch, refs.head_sha, { cwd: config.cwd }));
8549
8554
  const priorThreads = extractPriorThreads(initialDiscussions, extractChangedFiles(diff));
8550
8555
  if (priorThreads.length > 0) logger.info(`Found ${priorThreads.length} prior thread(s) with developer replies — including as context.`);
8551
8556
  logger.info("Running review...");
@@ -8652,6 +8657,30 @@ async function run(config, bridges) {
8652
8657
  summary: null
8653
8658
  };
8654
8659
  }
8660
+ let draftsPublishFailed = 0;
8661
+ let raceLost = 0;
8662
+ const posted = await traceDiagnosticPhase("scm.post_comments", config, runId, withHttpStamping(() => platform.lastResponse(), async (context) => {
8663
+ const result = await platform.postComments(generated, config.postingMode);
8664
+ recordCommentCounts(context, generated);
8665
+ context.posted = result.posted;
8666
+ if (result.drafts) {
8667
+ context.draftsAbandoned = result.drafts.abandoned;
8668
+ context.draftsCreated = result.drafts.created;
8669
+ context.draftsDeletedPrePublish = result.drafts.deletedPrePublish;
8670
+ context.draftsPublished = result.drafts.published;
8671
+ context.draftsPublishFailed = result.drafts.publishFailed;
8672
+ draftsPublishFailed = result.drafts.publishFailed;
8673
+ raceLost = result.drafts.deletedPrePublish;
8674
+ }
8675
+ return result.posted;
8676
+ }));
8677
+ const duplicates = generated.length - newCount;
8678
+ const raceExtra = raceLost > 0 ? `, ${raceLost} dropped by pre-publish re-check` : "";
8679
+ console.log(`Posted ${posted} new review comment(s) (${duplicates} duplicates skipped${raceExtra}).`);
8680
+ if (draftsPublishFailed > 0) console.warn(`[code-review] ${draftsPublishFailed} comment(s) could not be published individually after bulk_publish failed and were dropped.`);
8681
+ runContext.posted = posted;
8682
+ runContext.draftsPublishFailed = draftsPublishFailed;
8683
+ if (posted > 0) runContext.postedBySeverity = countPostedBySeverity(generated);
8655
8684
  let summary = null;
8656
8685
  if (config.postSummary && parsed.summary) {
8657
8686
  summary = await traceDiagnosticPhase("scm.upsert_summary", config, runId, withHttpStamping(() => platform.lastResponse(), async (context) => {
@@ -8683,30 +8712,6 @@ async function run(config, bridges) {
8683
8712
  runContext.summaryNoteId = summary.noteId;
8684
8713
  console.log(summary.action === "updated" ? `Updated MR summary note (id ${summary.noteId}).` : `Posted MR summary note (id ${summary.noteId}).`);
8685
8714
  } else if (config.postSummary && !parsed.summary) console.log("No summary returned by the reviewer; skipping summary note.");
8686
- let draftsPublishFailed = 0;
8687
- let raceLost = 0;
8688
- const posted = await traceDiagnosticPhase("scm.post_comments", config, runId, withHttpStamping(() => platform.lastResponse(), async (context) => {
8689
- const result = await platform.postComments(generated, config.postingMode);
8690
- recordCommentCounts(context, generated);
8691
- context.posted = result.posted;
8692
- if (result.drafts) {
8693
- context.draftsAbandoned = result.drafts.abandoned;
8694
- context.draftsCreated = result.drafts.created;
8695
- context.draftsDeletedPrePublish = result.drafts.deletedPrePublish;
8696
- context.draftsPublished = result.drafts.published;
8697
- context.draftsPublishFailed = result.drafts.publishFailed;
8698
- draftsPublishFailed = result.drafts.publishFailed;
8699
- raceLost = result.drafts.deletedPrePublish;
8700
- }
8701
- return result.posted;
8702
- }));
8703
- const duplicates = generated.length - newCount;
8704
- const raceExtra = raceLost > 0 ? `, ${raceLost} dropped by pre-publish re-check` : "";
8705
- console.log(`Posted ${posted} new review comment(s) (${duplicates} duplicates skipped${raceExtra}).`);
8706
- if (draftsPublishFailed > 0) console.warn(`[code-review] ${draftsPublishFailed} comment(s) could not be published individually after bulk_publish failed and were dropped.`);
8707
- runContext.posted = posted;
8708
- runContext.draftsPublishFailed = draftsPublishFailed;
8709
- if (posted > 0) runContext.postedBySeverity = countPostedBySeverity(generated);
8710
8715
  const labelChange = resolveLabelChange(config, posted > 0);
8711
8716
  if (labelChange) try {
8712
8717
  await platform.updateLabels(labelChange.add, labelChange.remove);
@@ -8889,10 +8894,10 @@ async function main(argv = process.argv.slice(2)) {
8889
8894
  return;
8890
8895
  }
8891
8896
  if (argv.includes("--version") || argv.includes("-v")) {
8892
- console.log("0.10.1");
8897
+ console.log("0.10.3");
8893
8898
  return;
8894
8899
  }
8895
- process.stderr.write(`[code-review] @weareikko/code-review v0.10.1\n`);
8900
+ process.stderr.write(`[code-review] @weareikko/code-review v0.10.3\n`);
8896
8901
  assertNodeVersion();
8897
8902
  applyCodeReviewEnvPrefix();
8898
8903
  applyDefaultCacheRetention();
@@ -8915,4 +8920,4 @@ if (isDirectRun()) main().catch((error) => {
8915
8920
  //#endregion
8916
8921
  export { buildSummaryHistoryEntries as $, connectMcpServers as A, traceMcpDiagnostic as B, findSkillForPath as C, readToolPath as D, formatSkillUsageState as E, createDiagnosticRunId as F, SUMMARY_HISTORY_ENTRY_START as G, toGitLabReviewSeverity as H, diagnosticChannels as I, SUMMARY_MARKER as J, SUMMARY_HISTORY_LIMIT as K, mcpDiagnosticChannels as L, DIAGNOSTIC_CHANNEL_PREFIX as M, MCP_DIAGNOSTIC_CHANNEL_NAMES as N, parseReviewMarkdown as O, createDiagnosticContext as P, buildSummaryBody as Q, traceDiagnostic as R, createSkillReadCounter as S, formatReviewUsageSummary as T, SUMMARY_HISTORY_END as U, normalizeSeverity as V, SUMMARY_HISTORY_ENTRY_END as W, buildReviewedCommitFooter as X, buildArchivedSummaryEntry as Y, buildSizeNoticeBlock as Z, buildPayload as _, resolveNpmSkillDir as _t, formatSkillsFooter as a, stripSummaryHistory as at, filterDiff as b, resolveLabelChange as c, appendFingerprintMarkers as ct, blobUrl as d, fingerprints as dt, extractReviewedCommitSha as et, formatSkillLink as f, normalizeBody as ft, buildGeneratedComments as g, parseSkillSpec as gt, skillSourceUrl as h, loadNamedSkill as ht, formatPerModelUsage as i, findExistingSummaryNoteId as it, DIAGNOSTIC_CHANNEL_NAMES as j, parseReviewMarkdownWithWarnings as k, run as l, extractDiffHunkContext as lt, skillDisplayName as m, gitSkillCacheKey as mt, formatLabelChange as n, findExistingReviewedCommitSha as nt, formatUsageLine as o, stripSummaryMarker as ot, gitRepoWebUrl as p, sha256 as pt, SUMMARY_HISTORY_START as q, formatMcpFooter as r, findExistingSummaryNote as rt, main as s, upsertSummaryNote as st, countPostedBySeverity as t, extractSummaryHistoryEntries as tt, withHttpStamping as u, extractExistingFingerprints as ut, isOtelEnabled as v, resolveSkillCacheDir as vt, formatMcpUsageState as w, runReview as x, startOtelBridge as y, traceDiagnosticPhase as z };
8917
8922
 
8918
- //# sourceMappingURL=cli-DIXQI0Bd.js.map
8923
+ //# sourceMappingURL=cli-CIKr0_zd.js.map