@eliya-oss/agent-diff 0.1.0-alpha.170 → 0.1.0-alpha.171
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 +15 -0
- package/dist/main.js +195 -175
- package/package.json +1 -1
- package/skills/adiff/SKILL.md +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @eliya-oss/agent-diff
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.171
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat(comment delivery): a comment on code a layer explains tells the agent which layer it will have to rewrite.
|
|
8
|
+
|
|
9
|
+
<details><summary>Why the agent is told</summary>
|
|
10
|
+
|
|
11
|
+
The work a comment asks for moves the code its layer describes, so the layers go stale as soon as
|
|
12
|
+
the agent acts. `comment take` now carries `layer`, the title of the layer whose spans cover the
|
|
13
|
+
comment's lines, read from the reading order as it stands when the comment is handed over. Where two
|
|
14
|
+
layers claim the line the tighter span wins, and code no layer claims carries none.
|
|
15
|
+
|
|
16
|
+
</details>
|
|
17
|
+
|
|
3
18
|
## 0.1.0-alpha.170
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/main.js
CHANGED
|
@@ -10500,9 +10500,169 @@ var init_review = __esmMin((() => {
|
|
|
10500
10500
|
init_vouch();
|
|
10501
10501
|
}));
|
|
10502
10502
|
//#endregion
|
|
10503
|
+
//#region src/domain/layers/model.ts
|
|
10504
|
+
var REMAINDER_TITLE;
|
|
10505
|
+
var init_model$4 = __esmMin((() => {
|
|
10506
|
+
REMAINDER_TITLE = "not in any layer";
|
|
10507
|
+
}));
|
|
10508
|
+
//#endregion
|
|
10509
|
+
//#region src/domain/layers/coverage.ts
|
|
10510
|
+
var codeBlockOf$1, codeBlocks, noteOf, spansOf$1, changedLines, holds, claimsHunk, runsOf, tallyOf, coverage, sharedHunks, runsSaid, filesSaid, leftSaid, unordered, withFullCoverage, proseAnchors;
|
|
10511
|
+
var init_coverage = __esmMin((() => {
|
|
10512
|
+
init_dist();
|
|
10513
|
+
init_model$4();
|
|
10514
|
+
codeBlockOf$1 = (span) => ({
|
|
10515
|
+
kind: "code",
|
|
10516
|
+
path: span.path,
|
|
10517
|
+
start: span.start,
|
|
10518
|
+
end: span.end
|
|
10519
|
+
});
|
|
10520
|
+
codeBlocks = (layer) => layer.blocks.filter((block) => block.kind === "code");
|
|
10521
|
+
noteOf = (layer) => layer.blocks.filter((block) => block.kind === "prose").map((block) => block.markdown.trim()).filter((markdown) => markdown.length > 0).join(" ");
|
|
10522
|
+
spansOf$1 = (layers) => layers.flatMap((layer) => codeBlocks(layer).map(({ path, start, end }) => ({
|
|
10523
|
+
path,
|
|
10524
|
+
start,
|
|
10525
|
+
end
|
|
10526
|
+
})));
|
|
10527
|
+
changedLines = (hunk) => hunk.rows.filter((row) => row.kind !== "context").flatMap((row) => match$3(orElse(row.newLine, () => row.oldLine), {
|
|
10528
|
+
onNone: () => [],
|
|
10529
|
+
onSome: (line) => [line]
|
|
10530
|
+
}));
|
|
10531
|
+
holds = (span, path, line) => span.path === path && span.start <= line && span.end >= line;
|
|
10532
|
+
claimsHunk = (spans, path, hunk) => changedLines(hunk).some((line) => spans.some((span) => holds(span, path, line)));
|
|
10533
|
+
runsOf = (path, lines) => {
|
|
10534
|
+
const runs = [];
|
|
10535
|
+
for (const line of lines.toSorted((a, b) => a - b)) {
|
|
10536
|
+
const open = runs.at(-1);
|
|
10537
|
+
if (open !== void 0 && line <= open.end + 1) open.end = Math.max(open.end, line);
|
|
10538
|
+
else runs.push({
|
|
10539
|
+
path,
|
|
10540
|
+
start: line,
|
|
10541
|
+
end: line
|
|
10542
|
+
});
|
|
10543
|
+
}
|
|
10544
|
+
return runs;
|
|
10545
|
+
};
|
|
10546
|
+
tallyOf = (patch, hunk, claimed) => {
|
|
10547
|
+
const changed = changedLines(hunk);
|
|
10548
|
+
const loose = changed.filter((line) => !claimed.some((span) => holds(span, patch.path, line)));
|
|
10549
|
+
const whole = changed.length > 0 && loose.length === 0;
|
|
10550
|
+
const some = loose.length > 0 && loose.length < changed.length;
|
|
10551
|
+
return {
|
|
10552
|
+
covered: whole ? 1 : 0,
|
|
10553
|
+
partial: some ? 1 : 0,
|
|
10554
|
+
missing: runsOf(patch.path, loose)
|
|
10555
|
+
};
|
|
10556
|
+
};
|
|
10557
|
+
coverage = (patches, layers) => {
|
|
10558
|
+
const claimed = spansOf$1(layers);
|
|
10559
|
+
const tallies = patches.flatMap((patch) => patch.hunks.filter((hunk) => changedLines(hunk).length > 0).map((hunk) => tallyOf(patch, hunk, claimed)));
|
|
10560
|
+
return {
|
|
10561
|
+
total: tallies.length,
|
|
10562
|
+
covered: tallies.reduce((sum, tally) => sum + tally.covered, 0),
|
|
10563
|
+
partial: tallies.reduce((sum, tally) => sum + tally.partial, 0),
|
|
10564
|
+
missing: tallies.flatMap((tally) => tally.missing)
|
|
10565
|
+
};
|
|
10566
|
+
};
|
|
10567
|
+
sharedHunks = (patches, layers) => {
|
|
10568
|
+
const claiming = (patch, hunk) => layers.filter((layer) => claimsHunk(spansOf$1([layer]), patch.path, hunk)).length;
|
|
10569
|
+
return patches.reduce((sum, patch) => sum + patch.hunks.filter((hunk) => changedLines(hunk).length > 0 && claiming(patch, hunk) > 1).length, 0);
|
|
10570
|
+
};
|
|
10571
|
+
runsSaid = (count) => count === 1 ? "One run of changed lines the layers do not account for." : `${count} runs of changed lines the layers do not account for.`;
|
|
10572
|
+
filesSaid = (count) => count === 1 ? "One file the layers had no lines to order." : `${count} files the layers had no lines to order.`;
|
|
10573
|
+
leftSaid = (runs, files) => {
|
|
10574
|
+
if (runs > 0 && files > 0) return `${runsSaid(runs)} ${filesSaid(files)}`;
|
|
10575
|
+
if (runs > 0) return runsSaid(runs);
|
|
10576
|
+
return files > 0 ? filesSaid(files) : "";
|
|
10577
|
+
};
|
|
10578
|
+
unordered = (patches, layers, missing) => {
|
|
10579
|
+
const named = /* @__PURE__ */ new Set([...spansOf$1(layers).map((span) => span.path), ...missing.map((span) => span.path)]);
|
|
10580
|
+
return patches.filter((patch) => !named.has(patch.path)).map((patch) => ({
|
|
10581
|
+
path: patch.path,
|
|
10582
|
+
start: 1,
|
|
10583
|
+
end: 1
|
|
10584
|
+
}));
|
|
10585
|
+
};
|
|
10586
|
+
withFullCoverage = (patches, layers) => {
|
|
10587
|
+
const gap = coverage(patches, layers.layers);
|
|
10588
|
+
const left = unordered(patches, layers.layers, gap.missing);
|
|
10589
|
+
const spans = [...gap.missing, ...left];
|
|
10590
|
+
if (spans.length === 0) return layers;
|
|
10591
|
+
const said = leftSaid(gap.missing.length, left.length);
|
|
10592
|
+
const remainder = {
|
|
10593
|
+
title: REMAINDER_TITLE,
|
|
10594
|
+
blocks: [...said.length === 0 ? [] : [{
|
|
10595
|
+
kind: "prose",
|
|
10596
|
+
markdown: said
|
|
10597
|
+
}], ...spans.map((span) => codeBlockOf$1(span))]
|
|
10598
|
+
};
|
|
10599
|
+
return {
|
|
10600
|
+
...layers,
|
|
10601
|
+
layers: [...layers.layers, remainder]
|
|
10602
|
+
};
|
|
10603
|
+
};
|
|
10604
|
+
proseAnchors = (layer) => {
|
|
10605
|
+
const anchors = [];
|
|
10606
|
+
let pending = [];
|
|
10607
|
+
let last;
|
|
10608
|
+
for (const block of layer.blocks) {
|
|
10609
|
+
if (block.kind === "prose") {
|
|
10610
|
+
const markdown = block.markdown.trim();
|
|
10611
|
+
if (markdown.length > 0) pending.push(markdown);
|
|
10612
|
+
continue;
|
|
10613
|
+
}
|
|
10614
|
+
for (const markdown of pending) anchors.push({
|
|
10615
|
+
path: block.path,
|
|
10616
|
+
line: block.start,
|
|
10617
|
+
markdown,
|
|
10618
|
+
after: false
|
|
10619
|
+
});
|
|
10620
|
+
pending = [];
|
|
10621
|
+
last = block;
|
|
10622
|
+
}
|
|
10623
|
+
if (last === void 0) return anchors;
|
|
10624
|
+
return [...anchors, ...pending.map((markdown) => ({
|
|
10625
|
+
path: last.path,
|
|
10626
|
+
line: last.end,
|
|
10627
|
+
markdown,
|
|
10628
|
+
after: true
|
|
10629
|
+
}))];
|
|
10630
|
+
};
|
|
10631
|
+
}));
|
|
10632
|
+
//#endregion
|
|
10633
|
+
//#region src/domain/layers/version.ts
|
|
10634
|
+
var statusOf$1;
|
|
10635
|
+
var init_version = __esmMin((() => {
|
|
10636
|
+
init_coverage();
|
|
10637
|
+
statusOf$1 = (patches, layers, branchHead) => {
|
|
10638
|
+
const gap = coverage(patches, layers.layers);
|
|
10639
|
+
const present = new Set(patches.map((patch) => patch.path));
|
|
10640
|
+
const mentioned = new Set(spansOf$1(layers.layers).map((span) => span.path));
|
|
10641
|
+
return {
|
|
10642
|
+
version: layers.version,
|
|
10643
|
+
parent: layers.parent,
|
|
10644
|
+
stale: layers.head !== branchHead,
|
|
10645
|
+
layersHead: layers.head,
|
|
10646
|
+
branchHead,
|
|
10647
|
+
uncovered: gap.missing,
|
|
10648
|
+
vanished: [...mentioned].filter((path) => !present.has(path)),
|
|
10649
|
+
covered: gap.covered,
|
|
10650
|
+
partial: gap.partial,
|
|
10651
|
+
total: gap.total
|
|
10652
|
+
};
|
|
10653
|
+
};
|
|
10654
|
+
}));
|
|
10655
|
+
//#endregion
|
|
10656
|
+
//#region src/domain/layers/index.ts
|
|
10657
|
+
var init_layers$1 = __esmMin((() => {
|
|
10658
|
+
init_coverage();
|
|
10659
|
+
init_version();
|
|
10660
|
+
init_model$4();
|
|
10661
|
+
}));
|
|
10662
|
+
//#endregion
|
|
10503
10663
|
//#region src/domain/preferences/model.ts
|
|
10504
10664
|
var preferences, preferenceNames, preferenceNamed, asFlag, heldValue, heldValues;
|
|
10505
|
-
var init_model$
|
|
10665
|
+
var init_model$3 = __esmMin((() => {
|
|
10506
10666
|
preferences = [
|
|
10507
10667
|
{
|
|
10508
10668
|
name: "wrap",
|
|
@@ -10562,7 +10722,7 @@ var init_model$4 = __esmMin((() => {
|
|
|
10562
10722
|
//#endregion
|
|
10563
10723
|
//#region src/domain/preferences/index.ts
|
|
10564
10724
|
var init_preferences = __esmMin((() => {
|
|
10565
|
-
init_model$
|
|
10725
|
+
init_model$3();
|
|
10566
10726
|
})), UnknownBranch, UnknownBase, UnknownFile, UnknownComment, UnknownRemark, NothingSaid, RemarkTaken, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownCommand, MissingOption, UnknownWorktree, MalformedLayers, UnknownField, UnknownOption, BadOption, UnknownDraft, NothingDrafted, PartlySent, PullMoved, NoLayers;
|
|
10567
10727
|
var init_error = __esmMin((() => {
|
|
10568
10728
|
init_dist();
|
|
@@ -10592,12 +10752,13 @@ var init_error = __esmMin((() => {
|
|
|
10592
10752
|
}));
|
|
10593
10753
|
//#endregion
|
|
10594
10754
|
//#region src/cli/commands.ts
|
|
10595
|
-
var realOf, CONTEXT, POLL, AUTO, askedFor$1, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, waitingOn, summaryOf, summaryFor, listBranches, readParts, blobOf, vouchIn, toggleVouch, readingOf, markOpened, lastOpenedIn, progressIn, reviewProgress, bodyOf, saidTo, spunOf, sentOf, whereItSitsNow$1, linesIn, trimmedLines, NAMES_SOMETHING, worthMatching, blockAt, wholeSnippetIn, stillInFile, foundOutsideTheHunks, sentIn, listSent, anchorIn, commentsIn, commentIn, submitComment, submitComments, without$2, submitReply, listPatches, patchIn, flatten, threadBefore, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, readPreferences, readPreference, ON, OFF, preferenceValue, savePreference, listRefs, forOne, recentBases, setBase, clearBase, markRead;
|
|
10755
|
+
var realOf, CONTEXT, POLL, AUTO, askedFor$1, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, waitingOn, summaryOf, summaryFor, listBranches, readParts, blobOf, vouchIn, toggleVouch, readingOf, markOpened, lastOpenedIn, progressIn, reviewProgress, bodyOf, saidTo, spunOf, sentOf, whereItSitsNow$1, linesIn, trimmedLines, NAMES_SOMETHING, worthMatching, blockAt, wholeSnippetIn, stillInFile, foundOutsideTheHunks, sentIn, listSent, anchorIn, commentsIn, commentIn, submitComment, submitComments, without$2, submitReply, listPatches, patchIn, flatten, threadBefore, layerOver, layersOn, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, readPreferences, readPreference, ON, OFF, preferenceValue, savePreference, listRefs, forOne, recentBases, setBase, clearBase, markRead;
|
|
10596
10756
|
var init_commands = __esmMin((() => {
|
|
10597
10757
|
init_dist();
|
|
10598
10758
|
init_patch();
|
|
10599
10759
|
init_git();
|
|
10600
10760
|
init_review();
|
|
10761
|
+
init_layers$1();
|
|
10601
10762
|
init_store();
|
|
10602
10763
|
init_preferences();
|
|
10603
10764
|
init_error();
|
|
@@ -11041,17 +11202,36 @@ var init_commands = __esmMin((() => {
|
|
|
11041
11202
|
body: turn.body
|
|
11042
11203
|
}));
|
|
11043
11204
|
};
|
|
11205
|
+
layerOver = (layers, comment) => {
|
|
11206
|
+
return layers.flatMap((layer) => codeBlocks(layer).filter((block) => block.path === comment.file && comment.start <= block.end && comment.end >= block.start).map((block) => ({
|
|
11207
|
+
title: layer.title,
|
|
11208
|
+
room: block.end - block.start
|
|
11209
|
+
}))).reduce((tightest, one) => tightest === void 0 || one.room < tightest.room ? one : tightest, void 0)?.title;
|
|
11210
|
+
};
|
|
11211
|
+
layersOn = fn("Cli.layersOn")(function* (worktree) {
|
|
11212
|
+
const found = yield* (yield* Store).layers(worktree);
|
|
11213
|
+
return match$3(found, {
|
|
11214
|
+
onNone: () => [],
|
|
11215
|
+
onSome: (held) => held.layers
|
|
11216
|
+
});
|
|
11217
|
+
});
|
|
11044
11218
|
takeComments = fn("Cli.takeComments")(function* (worktree) {
|
|
11045
11219
|
const store = yield* Store;
|
|
11046
11220
|
const resolved = yield* realOf(worktree);
|
|
11047
11221
|
const at = (/* @__PURE__ */ new Date()).toISOString();
|
|
11048
11222
|
yield* ignore(store.noteWatching(resolved, at));
|
|
11049
11223
|
const owed = flatten(yield* store.take(resolved, at));
|
|
11050
|
-
if (owed.
|
|
11224
|
+
if (owed.length === 0) return owed;
|
|
11225
|
+
const layers = yield* layersOn(resolved);
|
|
11226
|
+
const under = (one) => {
|
|
11227
|
+
const title = layerOver(layers, one);
|
|
11228
|
+
return title === void 0 ? one : Object.assign({}, one, { layer: title });
|
|
11229
|
+
};
|
|
11230
|
+
if (owed.every((one) => one.replyTo === void 0)) return owed.map(under);
|
|
11051
11231
|
const held = flatten(yield* store.inbox(resolved));
|
|
11052
11232
|
const spoken = yield* store.answers(resolved);
|
|
11053
11233
|
const carried = (one) => one.replyTo === void 0 ? one : Object.assign({}, one, { thread: threadBefore(one, held, spoken) });
|
|
11054
|
-
return owed.map(carried);
|
|
11234
|
+
return owed.map(carried).map(under);
|
|
11055
11235
|
});
|
|
11056
11236
|
repoOf$1 = fn("Cli.repoOf")(function* (worktree) {
|
|
11057
11237
|
return yield* (yield* Git).repoOf(worktree);
|
|
@@ -11421,10 +11601,10 @@ var init_pane = __esmMin((() => {
|
|
|
11421
11601
|
//#region package.json
|
|
11422
11602
|
init_drafts();
|
|
11423
11603
|
init_pane();
|
|
11424
|
-
var version$1 = "0.1.0-alpha.
|
|
11604
|
+
var version$1 = "0.1.0-alpha.171";
|
|
11425
11605
|
//#endregion
|
|
11426
11606
|
//#region src/cli/upgrade.ts
|
|
11427
|
-
var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf$1, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, ranChild, runUpgrade, statusOf
|
|
11607
|
+
var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf$1, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, ranChild, runUpgrade, statusOf, sayFound, sayDone, attempted, SAY_SKILL_TOO, upgradeReport;
|
|
11428
11608
|
var init_upgrade$1 = __esmMin((() => {
|
|
11429
11609
|
init_dist();
|
|
11430
11610
|
PACKAGE = "@eliya-oss/agent-diff";
|
|
@@ -11560,16 +11740,16 @@ var init_upgrade$1 = __esmMin((() => {
|
|
|
11560
11740
|
"inherit"
|
|
11561
11741
|
]
|
|
11562
11742
|
}, (code) => code === 0, false).pipe(withSpan("Cli.runUpgrade"));
|
|
11563
|
-
statusOf
|
|
11743
|
+
statusOf = (found) => {
|
|
11564
11744
|
if (!found.checked) return `adiff ${found.version} is installed. The registry did not answer.`;
|
|
11565
11745
|
if (found.current === true) return `adiff ${found.version} is the newest build.`;
|
|
11566
11746
|
return `adiff ${found.version} is installed, ${found.latest} is out.`;
|
|
11567
11747
|
};
|
|
11568
11748
|
sayFound = (found, check) => {
|
|
11569
|
-
if (found.current === true) return statusOf
|
|
11570
|
-
if (willUpgrade(found, check)) return found.checked ? `$ ${found.command}` : `${statusOf
|
|
11749
|
+
if (found.current === true) return statusOf(found);
|
|
11750
|
+
if (willUpgrade(found, check)) return found.checked ? `$ ${found.command}` : `${statusOf(found)}\n$ ${found.command}`;
|
|
11571
11751
|
const offer = RUNNABLE.has(found.route) ? `Run \`adiff upgrade\`, or \`${found.command}\` yourself.` : `Run: ${found.command}`;
|
|
11572
|
-
return `${statusOf
|
|
11752
|
+
return `${statusOf(found)} ${NOTES[found.route]} ${offer}`;
|
|
11573
11753
|
};
|
|
11574
11754
|
sayDone = (found, ran) => {
|
|
11575
11755
|
if (!ran) return `That did not work. Run \`${found.command}\` yourself to see what it said.`;
|
|
@@ -11583,7 +11763,7 @@ var init_upgrade$1 = __esmMin((() => {
|
|
|
11583
11763
|
};
|
|
11584
11764
|
SAY_SKILL_TOO = "Run `npx skills update adiff` to bring the skill up with it.";
|
|
11585
11765
|
upgradeReport = (found, ran, check) => {
|
|
11586
|
-
const note = found.current === true ? statusOf
|
|
11766
|
+
const note = found.current === true ? statusOf(found) : willUpgrade(found, check) ? `${statusOf(found)} ${attempted(found, ran)}` : `${statusOf(found)} ${NOTES[found.route]} Run \`${found.command}\` to upgrade.`;
|
|
11587
11767
|
return {
|
|
11588
11768
|
...found,
|
|
11589
11769
|
ran,
|
|
@@ -11591,7 +11771,7 @@ var init_upgrade$1 = __esmMin((() => {
|
|
|
11591
11771
|
};
|
|
11592
11772
|
};
|
|
11593
11773
|
})), DATA_ENDS, DATA_NAMES, DATA_STARTS, DATA_PARTS, TEST_PARTS, TEST_ENDS, partsOf, nameOf$1, isData, isTest, tierOf, KEYWORDS, escaped, BORROWS, declaresIn, bandOf, TIERS, BANDS, rankOf, inFile, byRank, byFile, countedIn, ranked;
|
|
11594
|
-
var init_model$
|
|
11774
|
+
var init_model$2 = __esmMin((() => {
|
|
11595
11775
|
DATA_ENDS = [
|
|
11596
11776
|
".txt",
|
|
11597
11777
|
".csv",
|
|
@@ -11755,7 +11935,7 @@ var init_model$3 = __esmMin((() => {
|
|
|
11755
11935
|
//#endregion
|
|
11756
11936
|
//#region src/domain/search/index.ts
|
|
11757
11937
|
var init_search$1 = __esmMin((() => {
|
|
11758
|
-
init_model$
|
|
11938
|
+
init_model$2();
|
|
11759
11939
|
}));
|
|
11760
11940
|
//#endregion
|
|
11761
11941
|
//#region src/cli/search.ts
|
|
@@ -11820,166 +12000,6 @@ var init_search = __esmMin((() => {
|
|
|
11820
12000
|
});
|
|
11821
12001
|
}));
|
|
11822
12002
|
//#endregion
|
|
11823
|
-
//#region src/domain/layers/model.ts
|
|
11824
|
-
var REMAINDER_TITLE;
|
|
11825
|
-
var init_model$2 = __esmMin((() => {
|
|
11826
|
-
REMAINDER_TITLE = "not in any layer";
|
|
11827
|
-
}));
|
|
11828
|
-
//#endregion
|
|
11829
|
-
//#region src/domain/layers/coverage.ts
|
|
11830
|
-
var codeBlockOf$1, codeBlocks, noteOf, spansOf$1, changedLines, holds, claimsHunk, runsOf, tallyOf, coverage, sharedHunks, runsSaid, filesSaid, leftSaid, unordered, withFullCoverage, proseAnchors;
|
|
11831
|
-
var init_coverage = __esmMin((() => {
|
|
11832
|
-
init_dist();
|
|
11833
|
-
init_model$2();
|
|
11834
|
-
codeBlockOf$1 = (span) => ({
|
|
11835
|
-
kind: "code",
|
|
11836
|
-
path: span.path,
|
|
11837
|
-
start: span.start,
|
|
11838
|
-
end: span.end
|
|
11839
|
-
});
|
|
11840
|
-
codeBlocks = (layer) => layer.blocks.filter((block) => block.kind === "code");
|
|
11841
|
-
noteOf = (layer) => layer.blocks.filter((block) => block.kind === "prose").map((block) => block.markdown.trim()).filter((markdown) => markdown.length > 0).join(" ");
|
|
11842
|
-
spansOf$1 = (layers) => layers.flatMap((layer) => codeBlocks(layer).map(({ path, start, end }) => ({
|
|
11843
|
-
path,
|
|
11844
|
-
start,
|
|
11845
|
-
end
|
|
11846
|
-
})));
|
|
11847
|
-
changedLines = (hunk) => hunk.rows.filter((row) => row.kind !== "context").flatMap((row) => match$3(orElse(row.newLine, () => row.oldLine), {
|
|
11848
|
-
onNone: () => [],
|
|
11849
|
-
onSome: (line) => [line]
|
|
11850
|
-
}));
|
|
11851
|
-
holds = (span, path, line) => span.path === path && span.start <= line && span.end >= line;
|
|
11852
|
-
claimsHunk = (spans, path, hunk) => changedLines(hunk).some((line) => spans.some((span) => holds(span, path, line)));
|
|
11853
|
-
runsOf = (path, lines) => {
|
|
11854
|
-
const runs = [];
|
|
11855
|
-
for (const line of lines.toSorted((a, b) => a - b)) {
|
|
11856
|
-
const open = runs.at(-1);
|
|
11857
|
-
if (open !== void 0 && line <= open.end + 1) open.end = Math.max(open.end, line);
|
|
11858
|
-
else runs.push({
|
|
11859
|
-
path,
|
|
11860
|
-
start: line,
|
|
11861
|
-
end: line
|
|
11862
|
-
});
|
|
11863
|
-
}
|
|
11864
|
-
return runs;
|
|
11865
|
-
};
|
|
11866
|
-
tallyOf = (patch, hunk, claimed) => {
|
|
11867
|
-
const changed = changedLines(hunk);
|
|
11868
|
-
const loose = changed.filter((line) => !claimed.some((span) => holds(span, patch.path, line)));
|
|
11869
|
-
const whole = changed.length > 0 && loose.length === 0;
|
|
11870
|
-
const some = loose.length > 0 && loose.length < changed.length;
|
|
11871
|
-
return {
|
|
11872
|
-
covered: whole ? 1 : 0,
|
|
11873
|
-
partial: some ? 1 : 0,
|
|
11874
|
-
missing: runsOf(patch.path, loose)
|
|
11875
|
-
};
|
|
11876
|
-
};
|
|
11877
|
-
coverage = (patches, layers) => {
|
|
11878
|
-
const claimed = spansOf$1(layers);
|
|
11879
|
-
const tallies = patches.flatMap((patch) => patch.hunks.filter((hunk) => changedLines(hunk).length > 0).map((hunk) => tallyOf(patch, hunk, claimed)));
|
|
11880
|
-
return {
|
|
11881
|
-
total: tallies.length,
|
|
11882
|
-
covered: tallies.reduce((sum, tally) => sum + tally.covered, 0),
|
|
11883
|
-
partial: tallies.reduce((sum, tally) => sum + tally.partial, 0),
|
|
11884
|
-
missing: tallies.flatMap((tally) => tally.missing)
|
|
11885
|
-
};
|
|
11886
|
-
};
|
|
11887
|
-
sharedHunks = (patches, layers) => {
|
|
11888
|
-
const claiming = (patch, hunk) => layers.filter((layer) => claimsHunk(spansOf$1([layer]), patch.path, hunk)).length;
|
|
11889
|
-
return patches.reduce((sum, patch) => sum + patch.hunks.filter((hunk) => changedLines(hunk).length > 0 && claiming(patch, hunk) > 1).length, 0);
|
|
11890
|
-
};
|
|
11891
|
-
runsSaid = (count) => count === 1 ? "One run of changed lines the layers do not account for." : `${count} runs of changed lines the layers do not account for.`;
|
|
11892
|
-
filesSaid = (count) => count === 1 ? "One file the layers had no lines to order." : `${count} files the layers had no lines to order.`;
|
|
11893
|
-
leftSaid = (runs, files) => {
|
|
11894
|
-
if (runs > 0 && files > 0) return `${runsSaid(runs)} ${filesSaid(files)}`;
|
|
11895
|
-
if (runs > 0) return runsSaid(runs);
|
|
11896
|
-
return files > 0 ? filesSaid(files) : "";
|
|
11897
|
-
};
|
|
11898
|
-
unordered = (patches, layers, missing) => {
|
|
11899
|
-
const named = /* @__PURE__ */ new Set([...spansOf$1(layers).map((span) => span.path), ...missing.map((span) => span.path)]);
|
|
11900
|
-
return patches.filter((patch) => !named.has(patch.path)).map((patch) => ({
|
|
11901
|
-
path: patch.path,
|
|
11902
|
-
start: 1,
|
|
11903
|
-
end: 1
|
|
11904
|
-
}));
|
|
11905
|
-
};
|
|
11906
|
-
withFullCoverage = (patches, layers) => {
|
|
11907
|
-
const gap = coverage(patches, layers.layers);
|
|
11908
|
-
const left = unordered(patches, layers.layers, gap.missing);
|
|
11909
|
-
const spans = [...gap.missing, ...left];
|
|
11910
|
-
if (spans.length === 0) return layers;
|
|
11911
|
-
const said = leftSaid(gap.missing.length, left.length);
|
|
11912
|
-
const remainder = {
|
|
11913
|
-
title: REMAINDER_TITLE,
|
|
11914
|
-
blocks: [...said.length === 0 ? [] : [{
|
|
11915
|
-
kind: "prose",
|
|
11916
|
-
markdown: said
|
|
11917
|
-
}], ...spans.map((span) => codeBlockOf$1(span))]
|
|
11918
|
-
};
|
|
11919
|
-
return {
|
|
11920
|
-
...layers,
|
|
11921
|
-
layers: [...layers.layers, remainder]
|
|
11922
|
-
};
|
|
11923
|
-
};
|
|
11924
|
-
proseAnchors = (layer) => {
|
|
11925
|
-
const anchors = [];
|
|
11926
|
-
let pending = [];
|
|
11927
|
-
let last;
|
|
11928
|
-
for (const block of layer.blocks) {
|
|
11929
|
-
if (block.kind === "prose") {
|
|
11930
|
-
const markdown = block.markdown.trim();
|
|
11931
|
-
if (markdown.length > 0) pending.push(markdown);
|
|
11932
|
-
continue;
|
|
11933
|
-
}
|
|
11934
|
-
for (const markdown of pending) anchors.push({
|
|
11935
|
-
path: block.path,
|
|
11936
|
-
line: block.start,
|
|
11937
|
-
markdown,
|
|
11938
|
-
after: false
|
|
11939
|
-
});
|
|
11940
|
-
pending = [];
|
|
11941
|
-
last = block;
|
|
11942
|
-
}
|
|
11943
|
-
if (last === void 0) return anchors;
|
|
11944
|
-
return [...anchors, ...pending.map((markdown) => ({
|
|
11945
|
-
path: last.path,
|
|
11946
|
-
line: last.end,
|
|
11947
|
-
markdown,
|
|
11948
|
-
after: true
|
|
11949
|
-
}))];
|
|
11950
|
-
};
|
|
11951
|
-
}));
|
|
11952
|
-
//#endregion
|
|
11953
|
-
//#region src/domain/layers/version.ts
|
|
11954
|
-
var statusOf;
|
|
11955
|
-
var init_version = __esmMin((() => {
|
|
11956
|
-
init_coverage();
|
|
11957
|
-
statusOf = (patches, layers, branchHead) => {
|
|
11958
|
-
const gap = coverage(patches, layers.layers);
|
|
11959
|
-
const present = new Set(patches.map((patch) => patch.path));
|
|
11960
|
-
const mentioned = new Set(spansOf$1(layers.layers).map((span) => span.path));
|
|
11961
|
-
return {
|
|
11962
|
-
version: layers.version,
|
|
11963
|
-
parent: layers.parent,
|
|
11964
|
-
stale: layers.head !== branchHead,
|
|
11965
|
-
layersHead: layers.head,
|
|
11966
|
-
branchHead,
|
|
11967
|
-
uncovered: gap.missing,
|
|
11968
|
-
vanished: [...mentioned].filter((path) => !present.has(path)),
|
|
11969
|
-
covered: gap.covered,
|
|
11970
|
-
partial: gap.partial,
|
|
11971
|
-
total: gap.total
|
|
11972
|
-
};
|
|
11973
|
-
};
|
|
11974
|
-
}));
|
|
11975
|
-
//#endregion
|
|
11976
|
-
//#region src/domain/layers/index.ts
|
|
11977
|
-
var init_layers$1 = __esmMin((() => {
|
|
11978
|
-
init_coverage();
|
|
11979
|
-
init_version();
|
|
11980
|
-
init_model$2();
|
|
11981
|
-
}));
|
|
11982
|
-
//#endregion
|
|
11983
12003
|
//#region src/cli/layers.ts
|
|
11984
12004
|
var STALE_ADVICE, unique, spansOfLayer, tidyPath, spanFault, blockFault, codeBlockOf, tidyBlock, blocksOf, layerFault, layerOf, parsed, readLayers, fromStored, toStored, reportedLayers, reportOf, resolve$1, resolveAll, worktreeAt, storedLayers, setLayers, showLayers, layersIn, partsOfFile, vouchPartIn;
|
|
11985
12005
|
var init_layers = __esmMin((() => {
|
|
@@ -12107,7 +12127,7 @@ var init_layers = __esmMin((() => {
|
|
|
12107
12127
|
});
|
|
12108
12128
|
};
|
|
12109
12129
|
reportOf = (patches, layers, branchHead) => {
|
|
12110
|
-
const status = statusOf(patches, layers, branchHead);
|
|
12130
|
+
const status = statusOf$1(patches, layers, branchHead);
|
|
12111
12131
|
return {
|
|
12112
12132
|
version: status.version,
|
|
12113
12133
|
parent: getOrUndefined$1(status.parent),
|
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.
|
|
26
|
+
"version": "0.1.0-alpha.171",
|
|
27
27
|
"description": "Review the work an agent left you without losing the thread: comments live on the lines, the agent answers them, and each point stays open until you settle it.",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"repository": {
|
package/skills/adiff/SKILL.md
CHANGED
|
@@ -24,6 +24,11 @@ Each comment carries the code it is about. `snippet` is the exact text the revie
|
|
|
24
24
|
`side` says whether the line numbers are in the new file (`new`) or the version being replaced
|
|
25
25
|
(`old`), and `head` is the commit the diff was read at.
|
|
26
26
|
|
|
27
|
+
A comment on code one of your layers explains carries `layer`, that layer's title as your latest
|
|
28
|
+
revision has it. The code the layer describes is about to change under your hands, so the layers go
|
|
29
|
+
stale the moment you act on the comment: write a new revision with `adiff layers set` before you
|
|
30
|
+
answer, and say in the answer that you did.
|
|
31
|
+
|
|
27
32
|
A comment keeps coming back until it is answered. A second `take` returns it again, so answer what
|
|
28
33
|
you take. Settling or removing it also retires it: those are the reviewer saying they no longer
|
|
29
34
|
need one.
|