@eliya-oss/agent-diff 0.1.0-alpha.30 → 0.1.0-alpha.31

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.31
4
+
5
+ ### Patch Changes
6
+
7
+ - Coverage counts the changed lines a layer claims, not the hunks a span touches.
8
+
3
9
  ## 0.1.0-alpha.30
4
10
 
5
11
  ### Patch Changes
package/dist/main.js CHANGED
@@ -17409,29 +17409,43 @@ const spansOf$1 = (layers) => layers.flatMap((layer) => codeBlocks(layer).map(({
17409
17409
  start,
17410
17410
  end
17411
17411
  })));
17412
- const spanOfHunk = (patch, hunk) => {
17413
- const lines = hunk.rows.flatMap((row) => match$3(orElse(row.newLine, () => row.oldLine), {
17414
- onNone: () => [],
17415
- onSome: (n) => [n]
17416
- }));
17417
- return lines.length === 0 ? none() : some({
17418
- path: patch.path,
17419
- start: Math.min(...lines),
17420
- end: Math.max(...lines)
17421
- });
17412
+ const changedLines = (hunk) => hunk.rows.filter((row) => row.kind !== "context").flatMap((row) => match$3(orElse(row.newLine, () => row.oldLine), {
17413
+ onNone: () => [],
17414
+ onSome: (line) => [line]
17415
+ }));
17416
+ const holds = (span, path, line) => span.path === path && span.start <= line && span.end >= line;
17417
+ const runsOf = (path, lines) => {
17418
+ const runs = [];
17419
+ for (const line of lines.toSorted((a, b) => a - b)) {
17420
+ const open = runs.at(-1);
17421
+ if (open !== void 0 && line <= open.end + 1) open.end = Math.max(open.end, line);
17422
+ else runs.push({
17423
+ path,
17424
+ start: line,
17425
+ end: line
17426
+ });
17427
+ }
17428
+ return runs;
17429
+ };
17430
+ const tallyOf = (patch, hunk, claimed) => {
17431
+ const changed = changedLines(hunk);
17432
+ const loose = changed.filter((line) => !claimed.some((span) => holds(span, patch.path, line)));
17433
+ const whole = changed.length > 0 && loose.length === 0;
17434
+ const some = loose.length > 0 && loose.length < changed.length;
17435
+ return {
17436
+ covered: whole ? 1 : 0,
17437
+ partial: some ? 1 : 0,
17438
+ missing: runsOf(patch.path, loose)
17439
+ };
17422
17440
  };
17423
- const overlaps = (a, b) => a.path === b.path && a.start <= b.end && a.end >= b.start;
17424
17441
  const coverage = (patches, layers) => {
17425
17442
  const claimed = spansOf$1(layers);
17426
- const hunks = patches.flatMap((patch) => patch.hunks.flatMap((hunk) => match$3(spanOfHunk(patch, hunk), {
17427
- onNone: () => [],
17428
- onSome: (s) => [s]
17429
- })));
17430
- const missing = hunks.filter((hunk) => !claimed.some((span) => overlaps(span, hunk)));
17443
+ const tallies = patches.flatMap((patch) => patch.hunks.filter((hunk) => changedLines(hunk).length > 0).map((hunk) => tallyOf(patch, hunk, claimed)));
17431
17444
  return {
17432
- total: hunks.length,
17433
- covered: hunks.length - missing.length,
17434
- missing
17445
+ total: tallies.length,
17446
+ covered: tallies.reduce((sum, tally) => sum + tally.covered, 0),
17447
+ partial: tallies.reduce((sum, tally) => sum + tally.partial, 0),
17448
+ missing: tallies.flatMap((tally) => tally.missing)
17435
17449
  };
17436
17450
  };
17437
17451
  const withFullCoverage = (patches, layers) => {
@@ -17441,7 +17455,7 @@ const withFullCoverage = (patches, layers) => {
17441
17455
  title: REMAINDER_TITLE,
17442
17456
  blocks: [{
17443
17457
  kind: "prose",
17444
- markdown: `${gap.missing.length} hunks the agent did not account for.`
17458
+ markdown: `${gap.missing.length} runs of changed lines the agent did not account for.`
17445
17459
  }, ...gap.missing.map((span) => codeBlockOf$1(span))]
17446
17460
  };
17447
17461
  return {
@@ -17491,6 +17505,7 @@ const statusOf = (patches, layers, branchHead) => {
17491
17505
  uncovered: gap.missing,
17492
17506
  vanished: [...mentioned].filter((path) => !present.has(path)),
17493
17507
  covered: gap.covered,
17508
+ partial: gap.partial,
17494
17509
  total: gap.total
17495
17510
  };
17496
17511
  };
@@ -17592,6 +17607,7 @@ const reportOf = (patches, layers, branchHead) => {
17592
17607
  written: layers.written,
17593
17608
  summary: layers.summary,
17594
17609
  covered: status.covered,
17610
+ partial: status.partial,
17595
17611
  total: status.total,
17596
17612
  uncovered: status.uncovered,
17597
17613
  vanished: status.vanished,
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "bin": {
24
24
  "adiff": "./bin/adiff.js"
25
25
  },
26
- "version": "0.1.0-alpha.30",
26
+ "version": "0.1.0-alpha.31",
27
27
  "description": "A code review your agent can answer: comments carry ids, the agent replies under them, and it publishes the reading order for its own diff.",
28
28
  "license": "MIT",
29
29
  "repository": {
@@ -133,23 +133,27 @@ Rules that make a layers worth reading:
133
133
  - **A title is a claim, not a file name.** "Add the invitation API", never "changes to
134
134
  src/api/invites.ts".
135
135
  - **Line numbers are the new side of the diff**, the same numbers `adiff comment take` reports.
136
- - **Cover everything.** adiff computes coverage itself and answers with the hunks no layer claims;
137
- those show up for the reviewer under "not in any layer" whatever you do. A layers that quietly
138
- skips a third of the diff is worse than no layers, so put the leftovers in a final layer and say
139
- they are mechanical.
136
+ - **Cover everything.** adiff computes coverage itself and answers with the changed lines no layer
137
+ claims; those show up for the reviewer under "not in any layer" whatever you do. A layer set that
138
+ quietly skips a third of the diff is worse than none, so put the leftovers in a final layer and
139
+ say they are mechanical. Claim the lines you actually read: a span reaching past them counts only
140
+ the changed lines inside it, so padding the range buys nothing.
140
141
 
141
142
  The answer to `layers set` is the honest report — check it before you claim to be done:
142
143
 
143
144
  ```json
144
- {"ok":true,"layers":{"version":1,"stale":false,"covered":7,"total":9,"uncovered":[{"path":"src/api/router.ts","start":40,"end":52}],"vanished":[],"layers":[{"title":"Add the invitation data model","files":["src/db/invites.ts"]}]}}
145
+ {"ok":true,"layers":{"version":1,"stale":false,"covered":7,"partial":1,"total":9,"uncovered":[{"path":"src/api/router.ts","start":40,"end":52}],"vanished":[],"layers":[{"title":"Add the invitation data model","files":["src/db/invites.ts"]}]}}
145
146
  ```
146
147
 
147
- `covered`/`total` count hunks. `uncovered` names the ones no layer claims — claim them and set the
148
- layers again. `vanished` names paths a layer points at that this branch does not change, which
149
- usually means a typo in a path. Read it back at any time with:
148
+ `total` counts hunks. `covered` counts the ones where every changed line sits inside a layer, and
149
+ `partial` the ones a layer explains only some of. `uncovered` names the runs of changed lines no
150
+ layer claims, so it reads as line numbers a reviewer would otherwise have to find alone: claim them
151
+ and set the layers again. Done means `uncovered` is empty. `vanished` names paths a layer points at
152
+ that this branch does not change, which usually means a typo in a path. Read it back at any time
153
+ with:
150
154
 
151
155
  ```bash
152
- adiff layers show --worktree . --fields covered,total,uncovered
156
+ adiff layers show --worktree . --fields covered,partial,total,uncovered
153
157
  ```
154
158
 
155
159
  Setting a layers again supersedes the previous one and bumps `version`; the layers records the commit