@jphutchins/code-review 0.1.0-alpha.46 → 0.1.0-alpha.47

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.
package/dist/index.js CHANGED
@@ -477,13 +477,7 @@ var normalizeCodeCounts = (codes, priorCodes) => {
477
477
  if (typeof codes !== "object" || codes === null || Array.isArray(codes)) return void 0;
478
478
  const entries = Object.entries(codes).filter(
479
479
  (e) => typeof e[1] === "number" && Number.isSafeInteger(e[1]) && e[1] > 0
480
- ).sort((a, b) => {
481
- if (b[1] !== a[1]) return b[1] - a[1];
482
- const aPrior = hasCode(priorCodes, a[0]) ? 1 : 0;
483
- const bPrior = hasCode(priorCodes, b[0]) ? 1 : 0;
484
- if (aPrior !== bPrior) return bPrior - aPrior;
485
- return a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
486
- });
480
+ );
487
481
  if (entries.length === 0) return void 0;
488
482
  const sorted = entries.sort((a, b) => {
489
483
  if (b[1] !== a[1]) return b[1] - a[1];
@@ -666,6 +660,14 @@ var priorBelowFloorNits = (priorDoc, floor = DEFAULT_NIT_VISIBILITY_FLOOR) => {
666
660
  };
667
661
  var convergenceBadge = (c) => c.converged ? `**Convergence** \u{1F3C1} ${formatScore(c.score)} \u2264 ${String(c.threshold)} \u2014 converged` : `**Convergence** \u{1F504} ${formatScore(c.score)} > ${String(c.threshold)} \u2014 iterating`;
668
662
  var convergenceSummary = (doc, threshold = DEFAULT_CONVERGENCE_THRESHOLD) => convergenceBadge(convergenceSignal(doc, threshold));
663
+ var nextRoundNumber = (priorTraj, priorConvRounds) => {
664
+ const last = (rounds) => rounds.length > 0 ? rounds[rounds.length - 1]?.round ?? rounds.length : 0;
665
+ return Math.max(last(priorTraj), last(priorConvRounds)) + 1;
666
+ };
667
+ var inProgressConvergence = (prior, runningRound) => {
668
+ const rounds = prior.rounds ?? [];
669
+ return rounds.length === 0 ? "" : `${roundsSummary(rounds, runningRound)} \u2192 \u23F3`;
670
+ };
669
671
  var SURFACE_SCHEMA_VERSION = "0.8.0";
670
672
  var convergenceSignal = (doc, threshold = DEFAULT_CONVERGENCE_THRESHOLD) => {
671
673
  const score = convergenceScore(doc, threshold);
@@ -1170,7 +1172,6 @@ var render = (input) => {
1170
1172
  // (issue #174) — no separate signal or rounds marker rides beside it. post always supplies the
1171
1173
  // precomputed marker; the standalone `render` command falls back to encoding the doc here.
1172
1174
  findingsPointer: input.findingsPointer ?? findingsPointer(input.findings, input.jsonUrl),
1173
- roundsMarker: "",
1174
1175
  roundsSummary: roundsSummary(trajectory, input.roundCount),
1175
1176
  metastasisNote: advisoryAllowed ? metastasisNote(trajectory) : "",
1176
1177
  sameRootNotes: advisoryAllowed ? sameRootNotes : {},
@@ -2378,8 +2379,7 @@ var post = async (input, ghApi = runGhApi) => {
2378
2379
  const priorBody = existingSticky?.body ?? "";
2379
2380
  const priorTraj = priorTrajectory(priorDoc, priorBody);
2380
2381
  const priorConv = carriedConvergence(priorDoc, priorBody);
2381
- const lastRound = (rounds) => rounds.length > 0 ? rounds[rounds.length - 1]?.round ?? rounds.length : 0;
2382
- const priorRoundCount = Math.max(lastRound(priorTraj), lastRound(priorConv?.rounds ?? []));
2382
+ const priorRoundCount = nextRoundNumber(priorTraj, priorConv?.rounds ?? []) - 1;
2383
2383
  const stampConvergence = (doc, conv) => ({
2384
2384
  ...doc,
2385
2385
  convergence: conv ?? void 0
@@ -2724,12 +2724,22 @@ var bodyRefsRun = (body, runUrl) => {
2724
2724
  const runId = runIdFromUrl(runUrl);
2725
2725
  return runId === null ? body.includes(runUrl) : new RegExp(`/actions/runs/${runId}(?!\\d)`).test(body);
2726
2726
  };
2727
- var announceBody = (headSha, runUrl, existingBody) => noticeBody(
2728
- `${DEFAULT_MARKER}
2727
+ var announceBody = (headSha, runUrl, existingBody) => {
2728
+ const priorDoc = existingBody !== void 0 ? parseFindingsMarker(existingBody) : null;
2729
+ const prior = existingBody !== void 0 ? carriedConvergence(priorDoc, existingBody) : null;
2730
+ const progress = prior !== null ? inProgressConvergence(
2731
+ prior,
2732
+ nextRoundNumber(priorTrajectory(priorDoc, existingBody ?? ""), prior.rounds ?? [])
2733
+ ) : "";
2734
+ return noticeBody(
2735
+ `${DEFAULT_MARKER}
2729
2736
 
2730
- \u{1F504} **Code review in progress** for \`${headSha.slice(0, 7)}\` \u2014 see the [workflow run](${runUrl}) for progress; this comment is updated with the review when it completes.`,
2731
- existingBody
2732
- );
2737
+ \u{1F504} **Code review in progress** for \`${headSha.slice(0, 7)}\` \u2014 see the [workflow run](${runUrl}) for progress; this comment is updated with the review when it completes.${progress ? `
2738
+
2739
+ ${progress}` : ""}`,
2740
+ existingBody
2741
+ );
2742
+ };
2733
2743
  var announce = async (input, ghApi = runGhApi) => {
2734
2744
  const candidates = await fetchPrCandidates(input.repo, input.headSha, ghApi);
2735
2745
  const resolution = resolvePr(candidates, input.headBranch);