walkdiff 0.5.0 → 0.6.1

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.
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Walkdiff review</title>
7
- <script type="module" crossorigin src="./assets/index-GjC9TYrP.js"></script>
8
- <link rel="stylesheet" crossorigin href="./assets/index-Dz8FNp8V.css">
7
+ <script type="module" crossorigin src="./assets/index-OPmnJb4s.js"></script>
8
+ <link rel="stylesheet" crossorigin href="./assets/index-FnUe0sJM.css">
9
9
  </head>
10
10
  <body>
11
11
  <!-- Replaced when the script starts, so a script that never runs is not a blank page. -->
package/walkdiff.mjs CHANGED
@@ -304,12 +304,14 @@ const unitChangeSchema = z.discriminatedUnion("kind", [
304
304
  z.object({
305
305
  kind: z.literal(UnitChangeKind.MovedIn),
306
306
  from: unitLocationSchema,
307
+ edited: z.boolean().default(false),
307
308
  before: unitSnapshotSchema,
308
309
  after: unitSnapshotSchema
309
310
  }),
310
311
  z.object({
311
312
  kind: z.literal(UnitChangeKind.MovedOut),
312
313
  to: unitLocationSchema,
314
+ edited: z.boolean().default(false),
313
315
  before: unitSnapshotSchema
314
316
  })
315
317
  ]);
@@ -755,14 +757,17 @@ function totalsOf(rows) {
755
757
  function changedUnitsOf(file) {
756
758
  return file.syntax.status === SyntaxAnalysisStatus.Analyzed ? file.syntax.units : [];
757
759
  }
758
- /** False for formatting, comments, renames and moves, which leave behaviour as it was. */
760
+ /**
761
+ * False for formatting, comments, renames and unedited moves, which leave behaviour as it was.
762
+ * An edited move counts once, where the unit arrived: the side it left has nothing new to read.
763
+ */
759
764
  function isBehaviourChange(change) {
760
765
  switch (change.kind) {
761
766
  case UnitChangeKind.Added:
762
767
  case UnitChangeKind.Removed: return true;
763
768
  case UnitChangeKind.Modified: return change.weight === ModificationWeight.Semantic;
769
+ case UnitChangeKind.MovedIn: return change.edited;
764
770
  case UnitChangeKind.Renamed:
765
- case UnitChangeKind.MovedIn:
766
771
  case UnitChangeKind.MovedOut: return false;
767
772
  }
768
773
  }
@@ -956,6 +961,21 @@ const ReviewEvent = {
956
961
  };
957
962
  const MAX_COMMENT_CHARS = 6e4;
958
963
  const lineSchema = z.number().int().positive();
964
+ const LineSide = {
965
+ Old: "old",
966
+ New: "new"
967
+ };
968
+ /** A line in the diff, by its number on each side; an unchanged line has both. */
969
+ const diffLineRefSchema = z.object({
970
+ oldLine: lineSchema.nullable(),
971
+ newLine: lineSchema.nullable()
972
+ });
973
+ /** Lines a reviewer chose, on one side of the diff, from `start` to `end`. */
974
+ const lineRangeSchema = z.object({
975
+ side: z.enum(LineSide),
976
+ start: diffLineRefSchema,
977
+ end: diffLineRefSchema
978
+ });
959
979
  const reviewCommentSchema = z.object({
960
980
  path: z.string().min(1),
961
981
  /** The file's previous path when it was renamed. GitLab needs both. */
@@ -964,6 +984,8 @@ const reviewCommentSchema = z.object({
964
984
  line: lineSchema.nullable(),
965
985
  /** What the comment is about, used when it can't sit on a line. */
966
986
  label: z.string(),
987
+ /** Lines the reviewer picked. Takes the place of `line` when set. */
988
+ range: lineRangeSchema.nullable().default(null),
967
989
  body: z.string().trim().min(1).max(MAX_COMMENT_CHARS)
968
990
  });
969
991
  /** What a reviewer submits. `headSha` is the commit they read, so a newer push can't be approved unseen. */
@@ -1017,6 +1039,18 @@ z.object({
1017
1039
  truncated: z.boolean()
1018
1040
  });
1019
1041
  z.object({ url: z.string() });
1042
+ /** Whether a comment can sit on lines of the diff; the others go in the review's text. */
1043
+ function isPlacedComment(comment) {
1044
+ return comment.range !== null || comment.line !== null;
1045
+ }
1046
+ /** Where a comment ends: the last line it covers, as a host addresses it. */
1047
+ function lastLineOf(comment) {
1048
+ if (comment.range !== null) return comment.range.end;
1049
+ return comment.line === null ? void 0 : {
1050
+ oldLine: null,
1051
+ newLine: comment.line
1052
+ };
1053
+ }
1020
1054
  // packages/engine/src/blobs.ts
1021
1055
  const NEWLINE = 10;
1022
1056
  /**
@@ -1633,7 +1667,7 @@ function toDefinition(spec, raw, lines) {
1633
1667
  text: outline(lines, startLine - 1, endLine - 1, raw.children),
1634
1668
  elidesNestedUnits: raw.children.length > 0
1635
1669
  },
1636
- codeTokenCount: code.length,
1670
+ codeTokens: code.map((token) => token.text),
1637
1671
  shape: raw.header.kind === UnitKind.Function || raw.header.kind === UnitKind.Method ? extractShape(spec.shape, raw.node) : void 0,
1638
1672
  fingerprints: {
1639
1673
  code: hashCode(code),
@@ -2495,8 +2529,8 @@ function searchedNameFor(unit) {
2495
2529
  case UnitChangeKind.Modified: return unit.change.weight === ModificationWeight.Semantic ? unit.name : void 0;
2496
2530
  case UnitChangeKind.Removed: return unit.name;
2497
2531
  case UnitChangeKind.Renamed: return unit.change.previousName;
2532
+ case UnitChangeKind.MovedIn: return unit.change.edited ? unit.name : void 0;
2498
2533
  case UnitChangeKind.Added:
2499
- case UnitChangeKind.MovedIn:
2500
2534
  case UnitChangeKind.MovedOut: return;
2501
2535
  }
2502
2536
  }
@@ -6365,6 +6399,32 @@ function coverageGaps(files, ignoredCount) {
6365
6399
  function byImportance(a, b) {
6366
6400
  return SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity] || Number(isSecurityFinding(b)) - Number(isSecurityFinding(a)) || (a.location?.path ?? "").localeCompare(b.location?.path ?? "") || (a.location?.line ?? 0) - (b.location?.line ?? 0);
6367
6401
  }
6402
+ // packages/engine/src/syntax/similarity.ts
6403
+ /**
6404
+ * How alike two token sequences are, from 0 (nothing shared) to 1 (the same).
6405
+ *
6406
+ * This is the Dice coefficient over adjacent token pairs. Pairs keep some of the order:
6407
+ * two functions that use the same keywords and names in a different arrangement score
6408
+ * lower than a function and its edited copy. Counting pairs as a multiset rather than
6409
+ * a set keeps a repeated line from looking as alike as the whole body.
6410
+ */
6411
+ function tokenSimilarity(a, b) {
6412
+ const pairsOfA = pairCounts(a);
6413
+ const pairsOfB = pairCounts(b);
6414
+ const total = a.length - 1 + (b.length - 1);
6415
+ if (total <= 0) return a.join("") === b.join("") ? 1 : 0;
6416
+ let shared = 0;
6417
+ for (const [pair, count] of pairsOfA) shared += Math.min(count, pairsOfB.get(pair) ?? 0);
6418
+ return 2 * shared / total;
6419
+ }
6420
+ function pairCounts(tokens) {
6421
+ const counts = /* @__PURE__ */ new Map();
6422
+ for (let index = 1; index < tokens.length; index++) {
6423
+ const pair = `${tokens[index - 1]}\0${tokens[index]}`;
6424
+ counts.set(pair, (counts.get(pair) ?? 0) + 1);
6425
+ }
6426
+ return counts;
6427
+ }
6368
6428
  // packages/engine/src/syntax/compareUnits.ts
6369
6429
  /**
6370
6430
  * Below this many code tokens, identical bodies are too common to call a move:
@@ -6372,13 +6432,33 @@ function byImportance(a, b) {
6372
6432
  */
6373
6433
  const MIN_MOVED_UNIT_TOKENS = 20;
6374
6434
  /**
6435
+ * How alike, by `tokenSimilarity`, a unit and a same-named one elsewhere must be to call
6436
+ * them one unit moved and edited. Measured on the cases in compareUnits.test.ts: a moved
6437
+ * function with one call changed scores about 0.93, while unrelated functions sharing a name
6438
+ * scored 0.24 to 0.45, and a rewrite of the same function 0.36. Lower, and different code
6439
+ * that shares a name would be shown as one edit; higher, and a moved function with a real
6440
+ * fix in it would be shown as removed and added again.
6441
+ */
6442
+ const MIN_EDITED_MOVE_SIMILARITY = .6;
6443
+ /**
6444
+ * Keywords that make a definition visible to other modules. Moving a function into a module
6445
+ * of its own usually means exporting it, so a move whose only change is one of these, before
6446
+ * the name, is shown as unedited: the new `export` isn't something to review.
6447
+ */
6448
+ const VISIBILITY_KEYWORDS = /* @__PURE__ */ new Set(["export", "pub"]);
6449
+ const RUST_VISIBILITY_GROUP_OPEN = "(";
6450
+ const RUST_VISIBILITY_GROUP_CLOSE = ")";
6451
+ /**
6375
6452
  * Compares unit versions across all files of a change. Outline:
6376
6453
  * 1. Per file, pair definitions by key; a pair whose own tokens differ is "modified".
6377
6454
  * 2. Unpaired definitions become added/removed candidates, topmost only (a new class
6378
6455
  * is reported once, not once per method).
6379
6456
  * 3. Across candidates, an added/removed pair with the same body under a new name in
6380
6457
  * the same container is a rename; the same body anywhere else is a move.
6381
- * 4. Remaining candidates are reported as added or removed.
6458
+ * 4. Of the rest, a pair of the same kind and name whose bodies are alike is a move with
6459
+ * edits. The most alike pairs are taken first, so three similar `parse`s can't steal
6460
+ * each other's match.
6461
+ * 5. Remaining candidates are reported as added or removed.
6382
6462
  */
6383
6463
  function compareUnits(files) {
6384
6464
  const unitsByPath = new Map(files.map((file) => [file.path, []]));
@@ -6410,25 +6490,8 @@ function compareUnits(files) {
6410
6490
  after: to.definition.snapshot
6411
6491
  }
6412
6492
  });
6413
- for (const [from, to] of takeMatches(removed, added, isMove)) {
6414
- report(from.path, {
6415
- ...describe(from.definition),
6416
- change: {
6417
- kind: UnitChangeKind.MovedOut,
6418
- to: locationOf(to),
6419
- before: from.definition.snapshot
6420
- }
6421
- });
6422
- report(to.path, {
6423
- ...describe(to.definition),
6424
- change: {
6425
- kind: UnitChangeKind.MovedIn,
6426
- from: locationOf(from),
6427
- before: from.definition.snapshot,
6428
- after: to.definition.snapshot
6429
- }
6430
- });
6431
- }
6493
+ for (const [from, to] of takeMatches(removed, added, isMove)) reportMove(report, from, to, MoveEdits.None);
6494
+ for (const [from, to] of takeMostAlike(removed, added)) reportMove(report, from, to, differsOnlyInVisibility(from.definition, to.definition) ? MoveEdits.None : MoveEdits.Code);
6432
6495
  for (const { path, definition } of added) report(path, {
6433
6496
  ...describe(definition),
6434
6497
  change: {
@@ -6446,6 +6509,35 @@ function compareUnits(files) {
6446
6509
  for (const units of unitsByPath.values()) units.sort(byPositionInFile);
6447
6510
  return unitsByPath;
6448
6511
  }
6512
+ const MoveEdits = {
6513
+ None: "none",
6514
+ Code: "code"
6515
+ };
6516
+ function reportMove(report, from, to, edits) {
6517
+ const edited = edits === MoveEdits.Code;
6518
+ const before = from.definition;
6519
+ const after = to.definition;
6520
+ report(from.path, {
6521
+ ...describe(before),
6522
+ change: {
6523
+ kind: UnitChangeKind.MovedOut,
6524
+ to: locationOf(to),
6525
+ edited,
6526
+ before: before.snapshot
6527
+ }
6528
+ });
6529
+ report(to.path, {
6530
+ ...describe(after),
6531
+ facts: edited && before.shape !== void 0 && after.shape !== void 0 ? factsBetween(before.shape, after.shape) : null,
6532
+ change: {
6533
+ kind: UnitChangeKind.MovedIn,
6534
+ from: locationOf(from),
6535
+ edited,
6536
+ before: before.snapshot,
6537
+ after: after.snapshot
6538
+ }
6539
+ });
6540
+ }
6449
6541
  function pairDefinitions(file) {
6450
6542
  const before = keyed(file.before?.definitions ?? []);
6451
6543
  const after = keyed(file.after?.definitions ?? []);
@@ -6524,7 +6616,57 @@ function isRename(from, to) {
6524
6616
  return from.path === to.path && from.definition.kind === to.definition.kind && from.definition.parentKey === to.definition.parentKey && from.definition.name !== to.definition.name && from.definition.fingerprints.nameAgnosticCode === to.definition.fingerprints.nameAgnosticCode;
6525
6617
  }
6526
6618
  function isMove(from, to) {
6527
- return from.definition.kind === to.definition.kind && from.definition.codeTokenCount >= MIN_MOVED_UNIT_TOKENS && from.definition.fingerprints.code === to.definition.fingerprints.code;
6619
+ return from.definition.kind === to.definition.kind && from.definition.codeTokens.length >= MIN_MOVED_UNIT_TOKENS && from.definition.fingerprints.code === to.definition.fingerprints.code;
6620
+ }
6621
+ function isEditedMoveCandidate(from, to) {
6622
+ return from.definition.kind === to.definition.kind && from.definition.name === to.definition.name && from.definition.codeTokens.length >= MIN_MOVED_UNIT_TOKENS && to.definition.codeTokens.length >= MIN_MOVED_UNIT_TOKENS;
6623
+ }
6624
+ function differsOnlyInVisibility(before, after) {
6625
+ const left = withoutVisibility(before.codeTokens, before.name);
6626
+ const right = withoutVisibility(after.codeTokens, after.name);
6627
+ return left.length === right.length && left.every((token, index) => token === right[index]);
6628
+ }
6629
+ /** The tokens with visibility keywords before the definition's name left out. */
6630
+ function withoutVisibility(tokens, name) {
6631
+ const nameAt = tokens.indexOf(name);
6632
+ if (nameAt === -1) return tokens;
6633
+ const head = [];
6634
+ for (let index = 0; index < nameAt; index++) {
6635
+ const token = tokens[index] ?? "";
6636
+ if (!VISIBILITY_KEYWORDS.has(token)) {
6637
+ head.push(token);
6638
+ continue;
6639
+ }
6640
+ if (tokens[index + 1] === RUST_VISIBILITY_GROUP_OPEN) {
6641
+ const close = tokens.indexOf(RUST_VISIBILITY_GROUP_CLOSE, index + 1);
6642
+ if (close !== -1 && close < nameAt) index = close;
6643
+ }
6644
+ }
6645
+ return [...head, ...tokens.slice(nameAt)];
6646
+ }
6647
+ /** Pairs edited moves best match first, removing each matched pair from both arrays. */
6648
+ function takeMostAlike(froms, tos) {
6649
+ const scored = froms.flatMap((from) => tos.filter((to) => isEditedMoveCandidate(from, to)).map((to) => ({
6650
+ from,
6651
+ to,
6652
+ similarity: tokenSimilarity(from.definition.codeTokens, to.definition.codeTokens)
6653
+ })).filter((pair) => pair.similarity >= MIN_EDITED_MOVE_SIMILARITY));
6654
+ scored.sort((a, b) => b.similarity - a.similarity);
6655
+ const taken = /* @__PURE__ */ new Set();
6656
+ const pairs = [];
6657
+ for (const { from, to } of scored) {
6658
+ if (taken.has(from) || taken.has(to)) continue;
6659
+ taken.add(from);
6660
+ taken.add(to);
6661
+ pairs.push([from, to]);
6662
+ }
6663
+ removeAll(froms, taken);
6664
+ removeAll(tos, taken);
6665
+ return pairs;
6666
+ }
6667
+ function removeAll(items, taken) {
6668
+ const kept = items.filter((item) => !taken.has(item));
6669
+ items.splice(0, items.length, ...kept);
6528
6670
  }
6529
6671
  /** Pairs elements of `froms` and `tos` one to one, removing each matched pair from both arrays. */
6530
6672
  function takeMatches(froms, tos, matches) {
@@ -7077,7 +7219,8 @@ function renderUnit(id, path, unit) {
7077
7219
  });
7078
7220
  };
7079
7221
  const { change } = unit;
7080
- if ("before" in change && change.kind !== UnitChangeKind.MovedIn) show("before", CitationSide.Before, change.before);
7222
+ const beforeAddsNothing = change.kind === UnitChangeKind.MovedIn && !change.edited;
7223
+ if ("before" in change && !beforeAddsNothing) show("before", CitationSide.Before, change.before);
7081
7224
  if ("after" in change) show("after", CitationSide.After, change.after);
7082
7225
  parts.push("</unit>");
7083
7226
  return {
@@ -7085,8 +7228,13 @@ function renderUnit(id, path, unit) {
7085
7228
  ranges
7086
7229
  };
7087
7230
  }
7231
+ function changeAttribute(change) {
7232
+ if (change.kind === UnitChangeKind.Modified) return `modified (${change.weight})`;
7233
+ if (change.kind === UnitChangeKind.MovedIn && change.edited) return `${change.kind} (edited)`;
7234
+ return change.kind;
7235
+ }
7088
7236
  function unitHeader(id, path, unit, summarized) {
7089
- const change = unit.change.kind === UnitChangeKind.Modified ? `modified (${unit.change.weight})` : unit.change.kind;
7237
+ const change = changeAttribute(unit.change);
7090
7238
  const impact = unit.impact?.status === UnitImpactStatus.Traced ? ` callers="${unit.impact.totalReferences}"` : "";
7091
7239
  const close = summarized ? ` summarized="input budget reached"/>` : ">";
7092
7240
  return `<unit id="${id}" path="${attribute(path)}" name="${attribute(unit.qualifiedName)}" kind="${unit.kind}" change="${change}"${impact}${close}`;
@@ -8140,14 +8288,25 @@ function getJson(request) {
8140
8288
  return send(request, { headers: request.headers });
8141
8289
  }
8142
8290
  function writeJson(request) {
8143
- return send(request, {
8291
+ return send(request, jsonWriteInit(request));
8292
+ }
8293
+ /**
8294
+ * Sends a write whose reply isn't needed, without reading the reply. Some writes answer
8295
+ * 204 No Content, such as GitLab publishing draft notes; parsing that empty body as JSON
8296
+ * reported a review that had been posted as failed, and posting again duplicated it.
8297
+ */
8298
+ async function writeIgnoringReply(request) {
8299
+ await throwIfFailed(await fetchWithinOrigin(request.url, jsonWriteInit(request)), request);
8300
+ }
8301
+ function jsonWriteInit(request) {
8302
+ return {
8144
8303
  method: request.method,
8145
8304
  headers: {
8146
8305
  ...request.headers,
8147
8306
  "Content-Type": "application/json"
8148
8307
  },
8149
8308
  body: JSON.stringify(request.body)
8150
- });
8309
+ };
8151
8310
  }
8152
8311
  /**
8153
8312
  * Downloads a file, or resolves to undefined if it is larger than `maxBytes`. Unlike API calls this
@@ -8193,14 +8352,16 @@ async function readLimited(response, maxBytes) {
8193
8352
  }
8194
8353
  async function send(request, init) {
8195
8354
  const response = await fetchWithinOrigin(request.url, init);
8196
- if (!response.ok) {
8197
- const body = (await response.text()).slice(0, MAX_ERROR_BODY_CHARS);
8198
- const detail = UNAUTHORIZED_STATUSES.has(response.status) ? `${body}\n${request.authHint}` : body;
8199
- throw new HostApiError(response.status, request.url, detail);
8200
- }
8355
+ await throwIfFailed(response, request);
8201
8356
  const body = await response.json();
8202
8357
  return request.schema.parse(body);
8203
8358
  }
8359
+ async function throwIfFailed(response, request) {
8360
+ if (response.ok) return;
8361
+ const body = (await response.text()).slice(0, MAX_ERROR_BODY_CHARS);
8362
+ const detail = UNAUTHORIZED_STATUSES.has(response.status) ? `${body}\n${request.authHint}` : body;
8363
+ throw new HostApiError(response.status, request.url, detail);
8364
+ }
8204
8365
  /**
8205
8366
  * Follows redirects only on the same origin. `fetch` drops `Authorization` when it leaves an
8206
8367
  * origin but keeps custom headers, so GitLab's `PRIVATE-TOKEN` would go wherever a redirect
@@ -8398,7 +8559,7 @@ var GitHubHost = class {
8398
8559
  };
8399
8560
  }
8400
8561
  async submitReview(review) {
8401
- const onLines = review.comments.filter((comment) => comment.line !== null);
8562
+ const onLines = review.comments.filter(isPlacedComment);
8402
8563
  return { url: (await writeJson({
8403
8564
  method: "POST",
8404
8565
  url: `${this.#repoApi()}/pulls/${this.#ref.number}/reviews`,
@@ -8409,12 +8570,7 @@ var GitHubHost = class {
8409
8570
  commit_id: review.headSha,
8410
8571
  event: REVIEW_EVENTS[review.event],
8411
8572
  body: withUnplacedComments$1(review),
8412
- comments: onLines.map((comment) => ({
8413
- path: comment.path,
8414
- line: comment.line,
8415
- side: "RIGHT",
8416
- body: comment.body
8417
- }))
8573
+ comments: onLines.map(githubReviewComment)
8418
8574
  }
8419
8575
  })).html_url };
8420
8576
  }
@@ -8476,12 +8632,11 @@ var GitHubHost = class {
8476
8632
  });
8477
8633
  }
8478
8634
  async #write(method, url, body) {
8479
- await writeJson({
8635
+ await writeIgnoringReply({
8480
8636
  method,
8481
8637
  url,
8482
8638
  body,
8483
8639
  headers: this.#headers(),
8484
- schema: z.unknown(),
8485
8640
  authHint: this.#authHint
8486
8641
  });
8487
8642
  }
@@ -8509,7 +8664,7 @@ const graphqlResponseSchema = z.object({
8509
8664
  const GRAPHQL_FAILURE_STATUS = 502;
8510
8665
  /** GitHub only accepts comments on lines, so anything without one joins the review's own text. */
8511
8666
  function withUnplacedComments$1(review) {
8512
- const unplaced = review.comments.filter((comment) => comment.line === null).map((comment) => `**\`${comment.label}\`** in \`${comment.path}\`\n\n${comment.body}`);
8667
+ const unplaced = review.comments.filter((comment) => !isPlacedComment(comment)).map((comment) => `**\`${comment.label}\`** in \`${comment.path}\`\n\n${comment.body}`);
8513
8668
  return [review.body, ...unplaced].filter((part) => part !== "").join("\n\n---\n\n");
8514
8669
  }
8515
8670
  function graphqlUrl(webOrigin) {
@@ -8518,6 +8673,29 @@ function graphqlUrl(webOrigin) {
8518
8673
  function apiBase(webOrigin) {
8519
8674
  return webOrigin === GITHUB_DOT_COM_ORIGIN$1 ? GITHUB_DOT_COM_API : `${webOrigin}/api/v3`;
8520
8675
  }
8676
+ function githubReviewComment(comment) {
8677
+ if (comment.range === null) return {
8678
+ path: comment.path,
8679
+ line: comment.line,
8680
+ side: "RIGHT",
8681
+ body: comment.body
8682
+ };
8683
+ const { side, start, end } = comment.range;
8684
+ const githubSide = side === LineSide.Old ? "LEFT" : "RIGHT";
8685
+ const number = (ref) => side === LineSide.Old ? ref.oldLine : ref.newLine;
8686
+ const startLine = number(start);
8687
+ const endLine = number(end);
8688
+ return {
8689
+ path: comment.path,
8690
+ line: endLine,
8691
+ side: githubSide,
8692
+ ...startLine !== endLine ? {
8693
+ start_line: startLine,
8694
+ start_side: githubSide
8695
+ } : {},
8696
+ body: comment.body
8697
+ };
8698
+ }
8521
8699
  // packages/providers/src/gitlab.ts
8522
8700
  const GITLAB_GIT_USERNAME = "oauth2";
8523
8701
  const AUTH_HINT = "Set GITLAB_TOKEN to a token with the read_api and read_repository scopes; posting comments needs the api scope.";
@@ -8583,8 +8761,17 @@ const pipelinesSchema = z.array(z.object({ id: z.number() }));
8583
8761
  const pipelineJobsSchema = z.array(z.object({
8584
8762
  id: z.number(),
8585
8763
  name: z.string(),
8586
- artifacts_file: z.object({ size: z.number() }).nullish()
8764
+ artifacts_file: z.object({ size: z.number() }).nullish(),
8765
+ artifacts: z.array(z.object({ file_type: z.string() })).nullish()
8587
8766
  }));
8767
+ /**
8768
+ * The artifact type GitLab gives a job's `reports: coverage_report`. GitLab teams usually publish
8769
+ * coverage this way from a job named `test`, so the job's name alone would miss it.
8770
+ */
8771
+ const COVERAGE_REPORT_ARTIFACT_TYPE = "cobertura";
8772
+ function declaresCoverageReport(job) {
8773
+ return job.artifacts?.some((artifact) => artifact.file_type === COVERAGE_REPORT_ARTIFACT_TYPE) === true;
8774
+ }
8588
8775
  var GitLabHost = class {
8589
8776
  #ref;
8590
8777
  #token;
@@ -8667,18 +8854,22 @@ var GitLabHost = class {
8667
8854
  const mergeRequest = await this.#get(api, mergeRequestSchema);
8668
8855
  const refs = mergeRequest.diff_refs;
8669
8856
  if (refs === null) throw new DiffNotReadyError(mergeRequest.web_url);
8670
- for (const comment of review.comments.filter((candidate) => candidate.line !== null)) await this.#write("POST", `${api}/draft_notes`, {
8671
- note: comment.body,
8672
- position: {
8673
- position_type: "text",
8674
- base_sha: refs.base_sha,
8675
- start_sha: refs.start_sha,
8676
- head_sha: refs.head_sha,
8677
- old_path: comment.previousPath,
8678
- new_path: comment.path,
8679
- new_line: comment.line
8680
- }
8681
- });
8857
+ for (const comment of review.comments.filter(isPlacedComment)) {
8858
+ const last = lastLineOf(comment);
8859
+ await this.#write("POST", `${api}/draft_notes`, {
8860
+ note: gitlabNote(comment),
8861
+ position: {
8862
+ position_type: "text",
8863
+ base_sha: refs.base_sha,
8864
+ start_sha: refs.start_sha,
8865
+ head_sha: refs.head_sha,
8866
+ old_path: comment.previousPath,
8867
+ new_path: comment.path,
8868
+ ...last?.oldLine == null ? {} : { old_line: last.oldLine },
8869
+ ...last?.newLine == null ? {} : { new_line: last.newLine }
8870
+ }
8871
+ });
8872
+ }
8682
8873
  const text = withUnplacedComments(review);
8683
8874
  if (text !== "") await this.#write("POST", `${api}/draft_notes`, { note: text });
8684
8875
  const reviewerState = REVIEWER_PUBLISH_STATES[review.event];
@@ -8729,7 +8920,10 @@ var GitLabHost = class {
8729
8920
  });
8730
8921
  const [pipeline] = await read(`${projectApi}/pipelines?sha=${encodeURIComponent(headSha)}&per_page=1`, pipelinesSchema);
8731
8922
  if (pipeline === void 0) return [];
8732
- const wanted = (await read(`${projectApi}/pipelines/${pipeline.id}/jobs?per_page=100`, pipelineJobsSchema)).filter((job) => job.artifacts_file != null && job.artifacts_file.size <= 209715200 && COVERAGE_ARCHIVE_NAME.test(job.name)).slice(0, 5);
8923
+ const jobs = await read(`${projectApi}/pipelines/${pipeline.id}/jobs?per_page=100`, pipelineJobsSchema);
8924
+ const declared = jobs.filter(declaresCoverageReport);
8925
+ const named = jobs.filter((job) => !declaresCoverageReport(job) && COVERAGE_ARCHIVE_NAME.test(job.name));
8926
+ const wanted = [...declared, ...named].filter((job) => job.artifacts_file != null && job.artifacts_file.size <= 209715200).slice(0, 5);
8733
8927
  return (await Promise.all(wanted.map(async (job) => ({
8734
8928
  name: job.name,
8735
8929
  zip: await downloadFile({
@@ -8748,12 +8942,11 @@ var GitLabHost = class {
8748
8942
  return `${webOrigin}/api/v4/projects/${encodeURIComponent(projectPath)}/merge_requests/${number}`;
8749
8943
  }
8750
8944
  async #write(method, url, body) {
8751
- await writeJson({
8945
+ await writeIgnoringReply({
8752
8946
  method,
8753
8947
  url,
8754
8948
  body,
8755
8949
  headers: this.#headers(),
8756
- schema: z.unknown(),
8757
8950
  authHint: this.#authHint
8758
8951
  });
8759
8952
  }
@@ -8769,9 +8962,21 @@ var GitLabHost = class {
8769
8962
  };
8770
8963
  /** Comments without a line, and the summary, go together as one note. */
8771
8964
  function withUnplacedComments(review) {
8772
- const unplaced = review.comments.filter((comment) => comment.line === null).map((comment) => `**\`${comment.label}\`** in \`${comment.path}\`\n\n${comment.body}`);
8965
+ const unplaced = review.comments.filter((comment) => !isPlacedComment(comment)).map((comment) => `**\`${comment.label}\`** in \`${comment.path}\`\n\n${comment.body}`);
8773
8966
  return [review.body, ...unplaced].filter((part) => part !== "").join("\n\n---\n\n");
8774
8967
  }
8968
+ /**
8969
+ * GitLab's multi-line position needs line codes this can't check without a real instance, so a range
8970
+ * sits on its last line and says which lines it covers.
8971
+ */
8972
+ function gitlabNote(comment) {
8973
+ const range = comment.range;
8974
+ if (range === null) return comment.body;
8975
+ const number = (ref) => range.side === LineSide.Old ? ref.oldLine : ref.newLine;
8976
+ const first = number(range.start);
8977
+ const last = number(range.end);
8978
+ return first === last ? comment.body : `Lines ${first}–${last}${range.side === LineSide.Old ? " (before)" : ""}:\n\n${comment.body}`;
8979
+ }
8775
8980
  // packages/providers/src/trustedHosts.ts
8776
8981
  const TRUSTED_GITHUB_HOSTS_VARIABLE = "WALKDIFF_TRUSTED_GITHUB_HOSTS";
8777
8982
  const TRUSTED_GITLAB_HOSTS_VARIABLE = "WALKDIFF_TRUSTED_GITLAB_HOSTS";
@@ -1 +0,0 @@
1
- :root{--bg:#fff;--bg-subtle:#f6f8fa;--border:#d0d7de;--text:#1f2328;--text-muted:#59636e;--accent:#0969da;--added-bg:#dafbe1;--added-text:#1a7f37;--removed-bg:#ffebe9;--removed-text:#cf222e;--hunk-bg:#ddf4ff;--selected-bg:#eaeef2;--mono:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--topbar-height:48px;--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark}@media (prefers-color-scheme:dark){:root{--lightningcss-light: ;--lightningcss-dark:initial;--bg:#0d1117;--bg-subtle:#151b23;--border:#3d444d;--text:#e6edf3;--text-muted:#9198a1;--accent:#4493f8;--added-bg:#12261e;--added-text:#3fb950;--removed-bg:#25171c;--removed-text:#f85149;--hunk-bg:#121d2f;--selected-bg:#212830}}*{box-sizing:border-box}body{background:var(--bg);color:var(--text);margin:0;font:14px/1.5 system-ui,-apple-system,Segoe UI,sans-serif}a{color:var(--accent)}code{font-family:var(--mono);background:var(--bg-subtle);border-radius:4px;padding:1px 4px;font-size:12px}.layout{flex-direction:column;height:100vh;display:flex}.changes-panel{flex:1;grid-template-columns:minmax(240px,320px) 1fr;min-height:0;display:grid}.changes-panel[hidden]{display:none}.tab-panel{flex:1;min-height:0}.tab-panel>*{max-width:960px}.report-tabs{border-bottom:1px solid var(--border);flex-wrap:wrap;gap:4px;padding:0 24px;display:flex}.report-tab{color:var(--text-muted);font:inherit;cursor:pointer;background:0 0;border:0;border-bottom:2px solid #0000;align-items:center;gap:6px;margin-bottom:-1px;padding:8px 12px;display:inline-flex}.report-tab:hover{color:var(--text)}.report-tab[aria-selected=true]{border-bottom-color:var(--accent);color:var(--text);font-weight:600}.tab-count{background:var(--selected-bg);border-radius:10px;padding:0 6px;font-size:11px;font-weight:600}.tab-intro{color:var(--text-muted);margin:0 0 12px;font-size:13px}.impact-entry{border:1px solid var(--border);border-radius:6px;margin-bottom:12px}.impact-entry-title{background:var(--bg-subtle);flex-wrap:wrap;align-items:baseline;gap:8px;margin:0;padding:8px 12px;font-size:13px;display:flex}.file-risks>summary{cursor:pointer;padding:4px 0;font-weight:600}.header{border-bottom:1px solid var(--border);padding:16px 24px}.header h1{margin:0 0 4px;font-size:20px}.meta{color:var(--text-muted);margin:0}.file-list{border-right:1px solid var(--border);background:var(--bg-subtle);overflow-y:auto}.file-list ul{margin:0;padding:8px 0;list-style:none}.file{width:100%;color:inherit;font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;align-items:baseline;gap:8px;padding:4px 12px;display:flex}.file:hover,.file.selected{background:var(--selected-bg)}.path{overflow-wrap:anywhere;font-family:var(--mono);flex:1;font-size:12px}.counts{white-space:nowrap;font-size:12px}.status{font-family:var(--mono);color:var(--text-muted);font-size:11px;font-weight:600}.status-added{color:var(--added-text)}.status-deleted{color:var(--removed-text)}.added{color:var(--added-text)}.removed{color:var(--removed-text)}.content{padding:16px 24px;overflow:auto}.previous-path{color:var(--text-muted)}.similarity{color:var(--text-muted);font-weight:400}.hunk-header td{background:var(--hunk-bg);color:var(--text-muted);padding:4px 8px}.line-number{width:1%;color:var(--text-muted);text-align:right;-webkit-user-select:none;user-select:none;white-space:nowrap;padding:0 8px}.marker{-webkit-user-select:none;user-select:none;width:1.5ch;display:inline-block}.line-added{background:var(--added-bg)}.line-removed{background:var(--removed-bg)}.notice{color:var(--text-muted);padding:24px}.notice-error{color:var(--removed-text)}@media (width<=720px){.layout{height:auto}.changes-panel{grid-template-rows:auto 1fr;grid-template-columns:1fr}.report-tabs{padding:0 8px}.file-list{border-right:0;border-bottom:1px solid var(--border);max-height:40vh}}:root{--quiet-text:#6e7781;--word-added-bg:#aceebb;--word-removed-bg:#ffcecb}@media (prefers-color-scheme:dark){:root{--quiet-text:#7d8590;--word-added-bg:#1a5c34;--word-removed-bg:#8e2a2f}}.review-summary{margin:6px 0 0}.file-group-title{text-transform:uppercase;letter-spacing:.04em;color:var(--text-muted);margin:8px 12px 0;font-size:11px;font-weight:600}.file-hint{color:var(--text-muted);font-family:system-ui,-apple-system,Segoe UI,sans-serif;font-size:11px;display:block}.file-view-header{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:12px;display:flex}.file-view-header h2{font-family:var(--mono);overflow-wrap:anywhere;margin:0;font-size:14px}.view-toggle{border:1px solid var(--border);border-radius:6px;display:inline-flex;overflow:hidden}.view-toggle button{background:var(--bg);color:var(--text);font:inherit;cursor:pointer;border:0;padding:4px 10px;font-size:12px}.view-toggle button[aria-pressed=true]{background:var(--selected-bg);font-weight:600}.unit-summary{color:var(--text-muted);margin:0 0 12px}.unit{border:1px solid var(--border);border-radius:6px;margin-bottom:12px;overflow:hidden}.unit>summary{background:var(--bg-subtle);cursor:pointer;flex-wrap:wrap;align-items:baseline;gap:8px;padding:8px 12px;display:flex}.unit[open]>summary{border-bottom:1px solid var(--border)}.unit-kind{text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:600}.unit-name{background:0 0;padding:0;font-size:13px;font-weight:600}.change-label{margin-left:auto;font-size:12px;font-weight:600}.tone-added{color:var(--added-text)}.tone-removed{color:var(--removed-text)}.tone-modified{color:var(--accent)}.tone-quiet{color:var(--quiet-text);font-weight:400}.unit-note{color:var(--text-muted);margin:0;padding:8px 12px}.code{border-collapse:collapse;table-layout:fixed;width:100%;font-family:var(--mono);font-size:12px}.hunks{border:1px solid var(--border)}.line-number-column{width:48px}.line{white-space:pre-wrap;overflow-wrap:anywhere;vertical-align:top;padding:0 8px}.side-by-side .line-number:nth-child(3){border-left:1px solid var(--border)}.empty{background:var(--bg-subtle)}.word-added{background:var(--word-added-bg);border-radius:2px}.word-removed{background:var(--word-removed-bg);border-radius:2px}:root{--syntax-comment:#59636e;--syntax-string:#0a3069;--syntax-constant:#0550ae;--syntax-keyword:#a40e26;--syntax-type:#953800;--syntax-function:#6639ba;--syntax-meta:#116329}@media (prefers-color-scheme:dark){:root{--syntax-comment:#9198a1;--syntax-string:#a5d6ff;--syntax-constant:#79c0ff;--syntax-keyword:#ff7b72;--syntax-type:#ffa657;--syntax-function:#d2a8ff;--syntax-meta:#7ee787}}.syntax{color:var(--syntax-color)}.syntax-comment{--syntax-color:var(--syntax-comment)}.syntax-string{--syntax-color:var(--syntax-string)}.syntax-constant{--syntax-color:var(--syntax-constant)}.syntax-keyword{--syntax-color:var(--syntax-keyword)}.syntax-type{--syntax-color:var(--syntax-type)}.syntax-function{--syntax-color:var(--syntax-function)}.syntax-meta{--syntax-color:var(--syntax-meta)}.syntax.word-added,.syntax.word-removed{color:color-mix(in srgb, var(--syntax-color) 40%, var(--text))}.elided td{background:var(--hunk-bg);padding:0}.elided button{width:100%;color:var(--text-muted);font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;padding:2px 8px}@media (width<=720px){.line-number-column{width:32px}}:root{--warning-text:#9a6700;--warning-bg:#fff8c5}@media (prefers-color-scheme:dark){:root{--warning-text:#d29922;--warning-bg:#2b2111}}.impact-summary,.file-hint-impact{color:var(--warning-text)}.impact-badge{background:var(--warning-bg);color:var(--warning-text);border-radius:10px;padding:0 6px;font-size:11px;font-weight:600}.impact{border-top:1px solid var(--border);padding:8px 12px;font-size:13px}.impact-warning{background:var(--warning-bg)}.impact-note{color:var(--text-muted);margin:0}.impact-title{margin:0 0 6px;font-weight:600}.impact-touched>summary{color:var(--text-muted);cursor:pointer;margin-top:6px}.impact-more{color:var(--text-muted);margin:6px 0 0}.reference-list{margin:0;padding:0;list-style:none}.reference{grid-template-columns:auto auto 1fr;align-items:baseline;gap:2px 8px;padding:3px 0;display:grid}.reference a{font-family:var(--mono);font-size:12px}.reference-caller{color:var(--text-muted);font-size:12px}.reference-snippet{overflow-wrap:anywhere;white-space:pre-wrap;grid-column:2/-1}.confidence{text-transform:uppercase;color:var(--text-muted);font-size:10px;font-weight:600}.confidence-exact{color:var(--added-text)}.confidence-possible{color:var(--quiet-text);font-weight:400}:root{--high-text:#cf222e;--high-bg:#ffebe9;--medium-text:#9a6700;--medium-bg:#fff8c5;--low-text:#59636e;--low-bg:#eaeef2}@media (prefers-color-scheme:dark){:root{--high-text:#f85149;--high-bg:#3c1618;--medium-text:#d29922;--medium-bg:#2b2111;--low-text:#9198a1;--low-bg:#262c36}}.level-badge,.severity{text-transform:uppercase;vertical-align:middle;border-radius:4px;padding:0 6px;font-size:11px;font-weight:600;display:inline-block}.level-high,.severity-high{background:var(--high-bg);color:var(--high-text)}.level-medium,.severity-medium{background:var(--medium-bg);color:var(--medium-text)}.level-low,.severity-low{background:var(--low-bg);color:var(--low-text)}.risk-view{max-width:960px}.level-box{border-radius:6px;padding:12px 16px}.level-title{margin:0 0 4px;font-size:16px}.level-explanation{color:var(--text);opacity:.85;margin:0;font-size:13px}.section-title{margin:24px 0 8px;font-size:15px}.risk-list,.risk-places,.not-checked{margin:0;padding:0;list-style:none}.risk{border:1px solid var(--border);border-left-width:3px;border-radius:6px;margin-bottom:8px;padding:8px 12px}.risk-high{border-left-color:var(--high-text)}.risk-medium{border-left-color:var(--medium-text)}.risk-header{flex-wrap:wrap;align-items:baseline;gap:8px;display:flex}.risk-category{color:var(--text-muted);font-size:12px}.risk-title{font-weight:600}.risk-count{color:var(--text-muted)}.risk-detail{color:var(--text-muted);margin:4px 0;font-size:13px}.risk-place{flex-wrap:wrap;align-items:baseline;gap:4px 8px;padding:2px 0;font-size:12px;display:flex}.risk-evidence{overflow-wrap:anywhere;white-space:pre-wrap;flex-basis:100%}.link-button{color:var(--accent);font-family:var(--mono);cursor:pointer;background:0 0;border:0;padding:0;font-size:12px}.link-button:hover{text-decoration:underline}.not-checked li{color:var(--text-muted);padding:4px 0;font-size:13px}.file-risks{margin-bottom:12px}.ai-note{color:var(--text-muted);margin:16px 0 0;font-size:13px}.chapters{margin:0;padding-left:20px}.chapter{margin-bottom:12px}.chapter-title{margin:0;font-weight:600}.chapter-summary{color:var(--text-muted);margin:2px 0 4px;font-size:13px}.chapter-units,.citations{margin:0;padding:0;list-style:none}.chapter-units li,.citations li{flex-wrap:wrap;align-items:baseline;gap:6px;padding:1px 0;font-size:12px;display:flex}.chapter-path{color:var(--text-muted);font-family:var(--mono);font-size:11px}.ai-list{margin:0;padding:0;list-style:none}.ai-list.questions{padding-left:20px;list-style:decimal}.ai-item{margin-bottom:10px}.ai-item-title{font-weight:600}.ai-item-detail{color:var(--text-muted);margin:2px 0 4px;font-size:13px}.verdict{text-transform:uppercase;border-radius:4px;margin-right:8px;padding:0 6px;font-size:11px;font-weight:600;display:inline-block}.verdict-matches{background:var(--added-bg);color:var(--added-text)}.verdict-contradicts{background:var(--high-bg);color:var(--high-text)}.verdict-undocumented,.verdict-notFound{background:var(--medium-bg);color:var(--medium-text)}.file-map{border:1px solid var(--border);background:var(--bg-subtle);border-radius:6px;margin-bottom:12px;padding:8px 12px}.file-map-note{color:var(--text-muted);margin:0 0 6px;font-size:12px}.file-map-rows{margin:0;padding:0;list-style:none}.file-map-row{flex-wrap:wrap;align-items:baseline;gap:2px 8px;padding:2px 0;font-size:12px;display:flex}.file-map-row .change-label{margin-left:0}.file-map-size,.file-map-link,.file-map-unchanged{color:var(--text-muted);font-size:11px}.file-map-unchanged{padding:1px 0;font-style:italic}.unit-facts{border-bottom:1px solid var(--border);margin:0;padding:6px 12px 6px 28px;font-size:12px}.unit{scroll-margin-top:8px}.guide{max-width:1120px;margin:0 auto;padding:36px 32px 72px;font-size:15px}.guide-eyebrow,.guide-path,.guide-note,.guide-keys,.guide-lede{color:var(--text-muted);margin:0}.guide-eyebrow{margin-bottom:8px;font-size:14px}.guide-title{letter-spacing:-.01em;text-wrap:balance;margin:0 0 8px;font-size:30px;font-weight:650;line-height:1.25}.guide-title+.guide-lede{margin-top:-20px;margin-bottom:28px}.guide-heading{margin:0 0 10px;font-size:15px;font-weight:600}.guide-all-clear{border:1px solid var(--border);border-radius:8px;padding:14px 16px}.guide-checks{border:1px solid var(--border);border-radius:8px;margin:0 0 8px;padding:0;list-style:none}.guide-check{border-left:3px solid var(--border);overflow-wrap:anywhere;padding:12px 16px 12px 14px}.guide-check+.guide-check{border-top:1px solid var(--border)}.guide-check-high{border-left-color:var(--high-text)}.guide-check-medium{border-left-color:var(--medium-text)}.guide-start{border:1px solid var(--border);background:var(--bg-subtle);border-radius:12px;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:16px 24px;margin:0 0 28px;padding:22px 24px;display:flex}.guide-effort{flex:280px;min-width:0}.guide-button{border:1px solid var(--border);color:var(--text);white-space:nowrap;border-radius:6px;padding:9px 18px;font-weight:500;text-decoration:none;display:inline-block}.guide-button:hover{background:var(--bg-subtle)}.guide-button-primary,.guide-button-primary:hover{border-color:var(--accent);background:var(--accent);color:var(--bg);font-weight:600}.guide-button-primary:hover{filter:brightness(1.08)}.guide-start .guide-button-primary{border-radius:8px;padding:11px 26px;font-size:15px}.guide-progress{background:var(--selected-bg);border-radius:2px;height:4px}.guide-progress-bar{background:var(--accent);border-radius:2px;height:4px}.guide-stop-title{overflow-wrap:anywhere;margin:0 0 2px;font-size:20px}.guide-stop-kind{color:var(--text-muted);margin-left:6px;font-size:13px;font-weight:400}.guide-path{overflow-wrap:anywhere;margin-bottom:14px;font-size:13px}.guide-why{background:var(--bg-subtle);border-radius:8px;margin:14px 0;padding:12px 16px}.guide-why-title{margin:0 0 4px;font-weight:600}.guide-why ul,.guide-facts,.guide-plain-list{margin:0;padding-left:20px}.guide-why p{margin:0}.guide-facts{color:var(--text-muted);margin-bottom:14px;font-size:14px}.guide-section{margin-top:24px}.guide-details>summary{cursor:pointer;font-weight:600}.guide-evidence{overflow-wrap:anywhere;font-size:14px}.guide-evidence p{color:var(--text-muted);margin:0 0 6px}.guide-evidence .guide-coverage{color:var(--text)}.guide-coverage-full strong{color:var(--added-text)}.guide-coverage-gap strong{color:var(--medium-text)}.guide-nav{border-top:1px solid var(--border);justify-content:space-between;align-items:center;gap:16px;margin-top:32px;padding-top:16px;display:flex}.guide-keys{text-align:center;margin-top:10px;font-size:12px}.guide-check a{color:inherit;text-decoration:underline;-webkit-text-decoration-color:var(--border);text-decoration-color:var(--border);text-underline-offset:3px}.guide-with-rail{grid-template-columns:300px minmax(0,1fr);align-items:start;max-width:1500px;margin:0 auto;display:grid}.guide-rail{top:var(--topbar-height);box-sizing:border-box;height:calc(100vh - var(--topbar-height));border-right:1px solid var(--border);flex-direction:column;padding:20px 12px 16px;font-size:13px;display:flex;position:sticky}.guide-rail-brief{margin:0 8px 14px}.guide-rail-title{margin:0 8px 8px;font-size:14px;font-weight:600}.guide-rail>.guide-progress{flex:none;margin:0 8px 12px}.guide-rail-list{flex:1;min-height:0;margin:0;padding:0;list-style:none;overflow-y:auto}.guide-rail-item{color:var(--text);border-radius:6px;align-items:flex-start;gap:10px;padding:7px 8px;text-decoration:none;display:flex}.guide-rail-item:hover{background:var(--bg-subtle);text-decoration:none}.guide-rail-item-current,.guide-rail-item-current:hover{background:var(--selected-bg)}.guide-rail-mark{box-sizing:border-box;border:1px solid var(--border);width:20px;height:20px;color:var(--text-muted);text-align:center;border-radius:50%;flex:none;font-size:11px;line-height:18px}.guide-rail-item-current .guide-rail-mark{border-color:var(--accent);color:var(--accent)}.guide-rail-item-done .guide-rail-mark{border-color:var(--added-text);background:var(--added-text);color:var(--bg)}.guide-rail-text{flex:1;min-width:0}.guide-rail-name,.guide-rail-path{text-overflow:ellipsis;white-space:nowrap;display:block;overflow:hidden}.guide-rail-name{font-family:var(--mono);font-size:12px}.guide-rail-item-done .guide-rail-name{color:var(--text-muted)}.guide-rail-path{color:var(--text-muted);text-align:left;direction:rtl;font-size:11px}.guide-rail-comment{color:var(--accent);flex:none;font-size:11px}.guide-rail-finish{color:var(--text);border-radius:6px;flex:none;margin-top:6px;padding:7px 8px 7px 38px}.guide-rail-finish-current{background:var(--selected-bg)}.guide-rail-overall{border-top:1px solid var(--border);color:var(--text-muted);flex:none;margin:10px 8px 0;padding-top:12px}.guide-rail-overall p{margin:0 0 6px}.guide-rail-overall a{margin-top:8px;display:inline-block}.guide-stop{min-width:0;padding:28px 32px 48px;font-size:15px}.guide-finish{max-width:760px}.guide-stop-number{color:var(--text-muted);margin-right:4px;font-weight:400}.guide-nav-forward{flex-wrap:wrap;gap:10px;display:flex}button.guide-button{background:var(--bg);font:inherit;cursor:pointer;font-weight:500}button.guide-button:hover{background:var(--bg-subtle)}button.guide-button-primary,button.guide-button-primary:hover{background:var(--accent)}.review-controls{flex-wrap:wrap;align-items:flex-start;gap:8px 12px;display:flex}.review-mark,.review-comment-add{border:1px solid var(--border);background:var(--bg);color:var(--text);font:inherit;cursor:pointer;border-radius:6px;padding:5px 12px;font-size:13px}.review-mark:hover,.review-comment-add:hover{background:var(--bg-subtle)}.review-mark-done{border-color:var(--added-text);color:var(--added-text)}.review-comment{flex:100%}.review-comment-label{margin-bottom:4px;font-size:13px;font-weight:600;display:block}.review-comment textarea{box-sizing:border-box;border:1px solid var(--border);background:var(--bg);width:100%;color:var(--text);font:inherit;resize:vertical;border-radius:6px;padding:8px 10px;font-size:14px}.review-comment-note{color:var(--text-muted);margin:4px 0 0;font-size:12px}.unit-review{border-top:1px solid var(--border);padding:10px 12px}.unit-reviewed,.file-review-done{color:var(--added-text)}.unit-reviewed{font-size:12px}.file-review-mark{color:var(--text-muted);flex:none;margin-left:4px;font-size:11px}.file-review-done{color:var(--added-text);font-size:13px}.guide-comment-list{margin:0 0 12px;padding:0;list-style:none}.guide-comment-list li{border-top:1px solid var(--border);overflow-wrap:anywhere;padding:10px 0}.guide-comment-list p{white-space:pre-wrap;margin:4px 0 0}@media (width<=900px){.guide-with-rail{grid-template-columns:minmax(0,1fr)}.guide-rail{border-right:0;border-bottom:1px solid var(--border);height:auto;max-height:45vh;position:static}.guide-stop{padding:20px 16px 40px}}.guide-updated{background:var(--hunk-bg);border-radius:8px;margin:0 0 20px;padding:12px 16px}.guide-since{margin:0 0 6px;font-weight:600}.guide-rail-item-outdated .guide-rail-mark{border-color:var(--medium-text);color:var(--medium-text)}.unit-changed{color:var(--medium-text);font-size:12px}.guide-panel{border:1px solid var(--border);background:var(--bg-subtle);border-radius:8px;margin-top:20px;padding:16px 18px}.guide-panel .guide-note{margin-top:8px}.guide-warning{border:1px solid var(--medium-text);background:var(--medium-bg);border-radius:8px;margin-top:24px;padding:16px 18px}.guide-warning-title{color:var(--medium-text);margin:0 0 4px;font-size:16px;font-weight:600}.guide-warning-lede{margin:0 0 12px}.guide-warning-list{margin:0;padding:0;list-style:none}.guide-warning-list li{border-top:1px solid var(--border);overflow-wrap:anywhere;padding:10px 0}.guide-warning-reason{margin-top:2px;font-size:14px;display:block}.guide-warning-reason code{background:var(--bg);font-family:var(--mono);border-radius:4px;padding:1px 5px;font-size:12px}.guide-submit textarea{box-sizing:border-box;border:1px solid var(--border);background:var(--bg);width:100%;color:var(--text);font:inherit;resize:vertical;border-radius:6px;padding:8px 10px;font-size:14px}.guide-submit-events{border:0;gap:8px;margin:12px 0;padding:0;display:grid}.guide-submit-events label{cursor:pointer;gap:8px;display:flex}.guide-submit-hint{color:var(--text-muted);font-size:13px;display:block}.guide-submit-row{flex-wrap:wrap;align-items:center;gap:12px;margin-top:12px;display:flex}.guide-submit-posted{color:var(--added-text);font-weight:600}.guide-error{color:var(--high-text);white-space:pre-wrap;overflow-wrap:anywhere;margin:8px 0 0}.reviewer-summary{flex-wrap:wrap;gap:8px;margin:-16px 0 20px;padding:0;font-size:13px;list-style:none;display:flex}.reviewer-badge{background:var(--low-bg);color:var(--low-text);border-radius:999px;padding:2px 10px}.reviewer-badge-approved{background:var(--added-bg);color:var(--added-text)}.reviewer-badge-changesRequested{background:var(--high-bg);color:var(--high-text)}.conversation{max-width:900px}.thread{border:1px solid var(--border);overflow-wrap:anywhere;border-radius:8px;margin:12px 0;padding:12px 14px}.thread-resolved{background:var(--bg-subtle)}.thread-place{color:var(--text-muted);font-family:var(--mono);margin:0 0 8px;font-size:12px}.thread-comment{border-top:1px solid var(--border);padding:8px 0}.thread-comment p{white-space:pre-wrap;margin:4px 0 0}.thread-author{font-size:13px;font-weight:600}.thread-actions{flex-wrap:wrap;gap:8px;margin-top:10px;display:flex}.thread-actions textarea{box-sizing:border-box;border:1px solid var(--border);background:var(--bg);color:var(--text);font:inherit;border-radius:6px;flex:100%;padding:8px 10px;font-size:14px}.sr-only{clip-path:inset(50%);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}.impact-lead{flex-wrap:wrap;justify-content:space-between;align-items:baseline;gap:8px 16px;margin-bottom:14px;display:flex}.impact-lead-text{color:var(--text-muted);flex:420px;margin:0}.impact-lead-text strong{color:var(--text)}.impact-view .impact-entry{border:1px solid var(--border);border-left-width:3px;border-radius:6px;margin:0 0 8px;padding:0}.impact-tone-warning{border-left-color:var(--high-text)!important}.impact-tone-attention{border-left-color:var(--medium-text)!important}.impact-entry-summary{cursor:pointer;padding:10px 14px 10px 30px;list-style:none;display:block;position:relative}.impact-entry-summary::-webkit-details-marker{display:none}.impact-entry-summary:before{content:"▸";color:var(--text-muted);position:absolute;left:12px}.impact-entry[open]>.impact-entry-summary:before{content:"▾"}.impact-entry-summary:hover{background:var(--bg-subtle)}.impact-entry-headline{overflow-wrap:anywhere;font-weight:600;display:block}.impact-tone-warning .impact-entry-headline{color:var(--high-text)}.impact-entry-place{color:var(--text-muted);overflow-wrap:anywhere;margin-top:2px;font-size:13px;display:block}.impact-entry-body{border-top:1px solid var(--border);padding:4px 14px 12px}.guide-explain,.ai-more{border:1px solid var(--border);border-radius:8px;margin:14px 0;padding:10px 14px}.guide-explain summary,.ai-more>summary{cursor:pointer;font-weight:600}.guide-explain li{margin-bottom:4px}.guide-tools{color:var(--text-muted);margin:8px 0}.guide-tools strong{color:var(--text)}.check-table{border-collapse:collapse;width:100%;margin-bottom:8px}.check-table th,.check-table td{border-bottom:1px solid var(--border);text-align:left;vertical-align:top;padding:7px 10px}.check-table thead th{color:var(--text-muted);font-size:12px;font-weight:600}.check-table tbody td:last-child{color:var(--text-muted);overflow-wrap:anywhere}.check-result{white-space:nowrap}.check-issues .check-result,.check-notRun .check-result{color:var(--medium-text);font-weight:600}.check-clean .check-result{color:var(--added-text)}.ai-points{margin:0 0 8px;padding:0;list-style:none}.ai-point{border-bottom:1px solid var(--border);padding:8px 0}.ai-point summary,.ai-notes summary,.ai-chapters summary{cursor:pointer}.ai-notes{margin:0;padding:0;list-style:none}.ai-notes li{padding:6px 0}.ai-chapters{margin:10px 0 0;padding-left:22px}.ai-chapters li{margin-bottom:6px}.topbar{z-index:10;box-sizing:border-box;min-height:var(--topbar-height);border-bottom:1px solid var(--border);background:var(--bg-subtle);flex-shrink:0;align-items:center;gap:8px 28px;padding:6px 24px;font-size:13px;display:flex;position:sticky;top:0}.topbar-trail{white-space:nowrap;align-items:center;gap:8px;min-width:0;display:flex}.topbar-brand{align-items:center;gap:8px;font-size:14px;font-weight:650;display:inline-flex}.topbar-logo{border-radius:5px;flex-shrink:0}.topbar-separator,.topbar-progress{color:var(--text-muted)}.topbar-nav{gap:4px;display:flex}.topbar-nav a{color:var(--text-muted);white-space:nowrap;border-radius:6px;padding:5px 10px;text-decoration:none}.topbar-nav a:hover{color:var(--text)}.topbar-nav a[aria-current=page]{background:var(--selected-bg);color:var(--text);font-weight:600}.topbar-progress{white-space:nowrap;margin:0 0 0 auto}.guide-heading-block{border-bottom:1px solid var(--border);margin-bottom:28px;padding-bottom:24px}.guide-columns{grid-template-columns:minmax(0,1fr) 300px;align-items:start;gap:32px;display:grid}.guide-effort-title{letter-spacing:-.01em;margin:0 0 2px;font-size:20px;font-weight:650}.guide-effort .guide-progress{margin-top:10px}.guide-sidebar{gap:16px;display:grid}.guide-stats{border:1px solid var(--border);background:var(--border);border-radius:12px;grid-template-columns:1fr 1fr;gap:1px;margin:0;display:grid;overflow:hidden}.guide-stat{background:var(--bg);min-width:0;padding:12px 14px}.guide-stat dt{color:var(--text-muted);font-size:12px}.guide-stat dd{overflow-wrap:anywhere;margin:2px 0 0;font-size:20px;font-weight:650}.guide-card{border:1px solid var(--border);border-radius:12px;padding:14px 16px}.guide-card-title{justify-content:space-between;margin:0 0 8px;font-size:13px;font-weight:600;display:flex}.guide-card-title a{font-weight:400}.guide-check-summary{margin:0;padding:0;font-size:13px;list-style:none}.guide-check-summary li{justify-content:space-between;gap:12px;padding:3px 0;display:flex}.guide-all-clear,.guide-checks{margin-bottom:24px}@media (width<=900px){.guide{padding:24px 16px 56px}.guide-title{font-size:24px}.guide-columns{grid-template-columns:minmax(0,1fr);gap:24px}.topbar{flex-wrap:wrap;padding:6px 16px}.topbar-progress{display:none}}