@eliya-oss/agent-diff 0.1.0-alpha.2 → 0.1.0-alpha.4

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,17 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Open the lines a diff leaves out one gap at a time with l, and put them away with h.
8
+
9
+ ## 0.1.0-alpha.3
10
+
11
+ ### Patch Changes
12
+
13
+ - Commands run on Node 22 and up, and opening the terminal finds a Node 26 on your machine.
14
+
3
15
  ## 0.1.0-alpha.2
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -6,7 +6,8 @@ Review the work an agent did in a git worktree, in your terminal, and hand your
6
6
  the agent still sitting in that worktree. You select lines the way you would on GitHub, write a
7
7
  comment, and the agent picks it up.
8
8
 
9
- <pre align="center">npm i -g @eliya-oss/agent-diff@alpha</pre>
9
+ <pre align="center">brew install Newbie012/tap/adiff
10
+ npm i -g @eliya-oss/agent-diff@alpha</pre>
10
11
 
11
12
  </div>
12
13
 
@@ -33,6 +34,10 @@ sends the whole set as one wake-up, so the agent reads a review rather than a st
33
34
  a comment, `ctrl+s` sends it and `ctrl+a` adds it to the review instead. `m` marks a file reviewed,
34
35
  `ctrl+p` finds any command by name, and the footer lists the keys for wherever you are.
35
36
 
37
+ Where the diff leaves lines out, a row says how many. Put the cursor on it and `l` brings ten of
38
+ them back where you are standing, `h` puts them away again, and the rest of the file stays as small
39
+ as it was. Opened lines are ordinary lines: you can select them and comment on them.
40
+
36
41
  ## The agent side
37
42
 
38
43
  In the worktree being reviewed:
@@ -65,9 +70,14 @@ Teaches an agent the whole loop: collect comments, act on them, write the story.
65
70
 
66
71
  ## Requirements
67
72
 
68
- Node 26 or newer. adiff draws through opentui, which reaches its native renderer over `node:ffi`, a
69
- module Node exposes behind `--experimental-ffi` from 26 onward. Every entry point in this repo
70
- passes the flag for you.
73
+ Either install gives you an `adiff` on your PATH. Brew brings a Node 26 along with it, so
74
+ everything works the moment it finishes.
75
+
76
+ The commands run on Node 22 or newer. The terminal is the one part that wants Node 26: it draws
77
+ through opentui, which reaches its native renderer over `node:ffi`, a module Node exposes behind
78
+ `--experimental-ffi` from 26 onward. When you open the terminal on an older Node, adiff looks for a
79
+ Node 26 among your fnm, nvm, asdf, volta and Homebrew installs and runs the terminal on that, so a
80
+ global npm install keeps working across a version switch.
71
81
 
72
82
  pnpm 12 is a Rust rewrite and still in beta, so
73
83
  [corepack cannot install it](https://pnpm.io/installation):
package/bin/adiff.js CHANGED
@@ -1,2 +1,76 @@
1
- #!/usr/bin/env -S node --experimental-ffi --disable-warning=ExperimentalWarning
2
- import "../dist/main.js"
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process"
3
+ import { existsSync, readdirSync } from "node:fs"
4
+ import { homedir } from "node:os"
5
+ import { join } from "node:path"
6
+ import { fileURLToPath } from "node:url"
7
+
8
+ const RENDERER_FLAGS = ["--experimental-ffi", "--disable-warning=ExperimentalWarning"]
9
+ const RENDERER_MAJOR = 26
10
+ const ENTRY = fileURLToPath(new URL("../dist/main.js", import.meta.url))
11
+
12
+ const home = homedir()
13
+
14
+ const SOURCES = [
15
+ [process.env["FNM_DIR"] ?? join(home, ".local", "share", "fnm"), "node-versions", "installation/bin/node"],
16
+ [join(home, "Library", "Application Support", "fnm"), "node-versions", "installation/bin/node"],
17
+ [process.env["NVM_DIR"] ?? join(home, ".nvm"), "versions/node", "bin/node"],
18
+ [process.env["ASDF_DATA_DIR"] ?? join(home, ".asdf"), "installs/nodejs", "bin/node"],
19
+ [process.env["VOLTA_HOME"] ?? join(home, ".volta"), "tools/image/node", "bin/node"],
20
+ [process.env["HOMEBREW_PREFIX"] ?? "/opt/homebrew", "opt", "bin/node"],
21
+ ["/usr/local", "opt", "bin/node"],
22
+ ]
23
+
24
+ const MESSAGE = [
25
+ "adiff review open draws its terminal through node:ffi, which needs Node 26 or newer.",
26
+ `This is Node ${process.versions.node}, and no Node ${RENDERER_MAJOR} was found on this machine.`,
27
+ "Every other adiff command runs here. Install Node 26 to open the terminal.",
28
+ ].join("\n")
29
+
30
+ const drawsTerminal = (argv) => {
31
+ const words = argv.filter((token) => !token.startsWith("--"))
32
+ return words[0] === "review" && words[1] === "open"
33
+ }
34
+
35
+ const rendersHere = () =>
36
+ typeof process.getBuiltinModule === "function" &&
37
+ process.getBuiltinModule("node:ffi") !== undefined
38
+
39
+ const NODE_DIRECTORY = /^(?:v?\d|node)/
40
+
41
+ const majorOf = (name) => Number(/\d+/.exec(name)?.[0] ?? Number.NaN)
42
+
43
+ const listed = (directory) => {
44
+ try {
45
+ return readdirSync(directory)
46
+ } catch {
47
+ return []
48
+ }
49
+ }
50
+
51
+ const installsUnder = ([root, versions, binary]) =>
52
+ listed(join(root, versions))
53
+ .filter((name) => NODE_DIRECTORY.test(name))
54
+ .map((name) => ({ major: majorOf(name), path: join(root, versions, name, binary) }))
55
+
56
+ const findRuntime = () => {
57
+ if (majorOf(process.versions.node) >= RENDERER_MAJOR) return process.execPath
58
+ const found = SOURCES.flatMap(installsUnder)
59
+ .filter((install) => install.major >= RENDERER_MAJOR && existsSync(install.path))
60
+ .toSorted((a, b) => b.major - a.major)
61
+ return found[0]?.path
62
+ }
63
+
64
+ const relaunch = () => {
65
+ const runtime = findRuntime()
66
+ if (runtime === undefined) {
67
+ process.stderr.write(`${MESSAGE}\n`)
68
+ process.exit(1)
69
+ }
70
+ const args = [...RENDERER_FLAGS, ENTRY, ...process.argv.slice(2)]
71
+ const run = spawnSync(runtime, args, { stdio: "inherit" })
72
+ process.exit(run.status ?? 1)
73
+ }
74
+
75
+ if (drawsTerminal(process.argv.slice(2)) && !rendersHere()) relaunch()
76
+ else await import(ENTRY)
package/dist/main.js CHANGED
@@ -10524,6 +10524,7 @@ const openHunk = (draft, line) => {
10524
10524
  marker: line,
10525
10525
  scope: (header?.[3] ?? "").trim(),
10526
10526
  startRow: draft.rows.length,
10527
+ newStart: draft.newLine,
10527
10528
  rows: [],
10528
10529
  skipped: draft.hunks.length === 0 ? 0 : Math.max(0, draft.newLine - previousNew)
10529
10530
  });
@@ -10951,6 +10952,7 @@ var NoStory = class extends TaggedError("NoStory") {};
10951
10952
  //#endregion
10952
10953
  //#region src/cli/commands.ts
10953
10954
  const CONTEXT = 3;
10955
+ const WHOLE_FILE$1 = 1e5;
10954
10956
  const POLL = "500 millis";
10955
10957
  const findBranch = fn("Cli.findBranch")(function* (repo, branch) {
10956
10958
  const worktrees = yield* (yield* Git).worktrees(repo);
@@ -10961,8 +10963,8 @@ const findBranch = fn("Cli.findBranch")(function* (repo, branch) {
10961
10963
  known: worktrees.map((w) => w.branch)
10962
10964
  }) : succeed(found);
10963
10965
  });
10964
- const patchesOf = fn("Cli.patchesOf")(function* (worktree) {
10965
- const raw = yield* (yield* Git).diff(worktree, CONTEXT);
10966
+ const patchesOf = fn("Cli.patchesOf")(function* (worktree, context = CONTEXT) {
10967
+ const raw = yield* (yield* Git).diff(worktree, context);
10966
10968
  return parsePatches(raw);
10967
10969
  });
10968
10970
  const findPatch = (patches, file) => fromNullishOr(patches.find((patch) => patch.path === file));
@@ -11041,7 +11043,7 @@ const reviewProgress = fn("Cli.reviewProgress")(function* (repo, branch) {
11041
11043
  });
11042
11044
  const anchorRequest = fn("Cli.anchorRequest")(function* (request) {
11043
11045
  const worktree = yield* findBranch(request.repo, request.branch);
11044
- const patches = yield* patchesOf(worktree);
11046
+ const patches = yield* patchesOf(worktree, WHOLE_FILE$1);
11045
11047
  const resolved = yield* match$2(findPatch(patches, request.file), {
11046
11048
  onNone: () => new UnknownFile({
11047
11049
  file: request.file,
@@ -11124,7 +11126,7 @@ const submitReview = fn("Cli.submitReview")(function* (repo, branch, id, at) {
11124
11126
  const submitComment = fn("Cli.submitComment")(function* (request) {
11125
11127
  const store = yield* Store;
11126
11128
  const worktree = yield* findBranch(request.repo, request.branch);
11127
- const patches = yield* patchesOf(worktree);
11129
+ const patches = yield* patchesOf(worktree, WHOLE_FILE$1);
11128
11130
  const patch = findPatch(patches, request.file);
11129
11131
  const resolved = yield* match$2(patch, {
11130
11132
  onNone: () => new UnknownFile({
@@ -11200,7 +11202,8 @@ const codeBlockOf$1 = (span) => ({
11200
11202
  end: span.end
11201
11203
  });
11202
11204
  const codeBlocks = (step) => step.blocks.filter((block) => block.kind === "code");
11203
- const spansOf = (steps) => steps.flatMap((step) => codeBlocks(step).map(({ path, start, end }) => ({
11205
+ const noteOf = (step) => step.blocks.filter((block) => block.kind === "prose").map((block) => block.markdown.trim()).filter((markdown) => markdown.length > 0).join(" ");
11206
+ const spansOf$1 = (steps) => steps.flatMap((step) => codeBlocks(step).map(({ path, start, end }) => ({
11204
11207
  path,
11205
11208
  start,
11206
11209
  end
@@ -11218,7 +11221,7 @@ const spanOfHunk = (patch, hunk) => {
11218
11221
  };
11219
11222
  const overlaps = (a, b) => a.path === b.path && a.start <= b.end && a.end >= b.start;
11220
11223
  const coverage = (patches, steps) => {
11221
- const claimed = spansOf(steps);
11224
+ const claimed = spansOf$1(steps);
11222
11225
  const hunks = patches.flatMap((patch) => patch.hunks.flatMap((hunk) => match$2(spanOfHunk(patch, hunk), {
11223
11226
  onNone: () => [],
11224
11227
  onSome: (s) => [s]
@@ -11250,7 +11253,7 @@ const withFullCoverage = (patches, story) => {
11250
11253
  const statusOf = (patches, story, branchHead) => {
11251
11254
  const gap = coverage(patches, story.steps);
11252
11255
  const present = new Set(patches.map((patch) => patch.path));
11253
- const mentioned = new Set(spansOf(story.steps).map((span) => span.path));
11256
+ const mentioned = new Set(spansOf$1(story.steps).map((span) => span.path));
11254
11257
  return {
11255
11258
  version: story.version,
11256
11259
  parent: story.parent,
@@ -11342,6 +11345,7 @@ const stepsOf = (patches, story) => {
11342
11345
  const present = new Set(patches.map((patch) => patch.path));
11343
11346
  return withFullCoverage(patches, story).steps.map((step) => ({
11344
11347
  title: step.title,
11348
+ note: noteOf(step),
11345
11349
  files: unique(spansOfStep(step).map((span) => span.path)).filter((path) => present.has(path)),
11346
11350
  spans: spansOfStep(step)
11347
11351
  }));
@@ -11725,6 +11729,142 @@ const failure = (cause) => {
11725
11729
  };
11726
11730
  };
11727
11731
  //#endregion
11732
+ //#region src/tui/gaps.ts
11733
+ const sourceLength = (source) => source.at(-1)?.trim() === "" ? source.length - 1 : source.length;
11734
+ const markerText = (hidden) => `⋯ ${hidden} lines hidden · press l`;
11735
+ const lastNewLine = (patch) => {
11736
+ const found = patch.rows.findLast((row) => isSome(row.newLine));
11737
+ return found === void 0 ? 0 : getOrElse(found.newLine, () => 0);
11738
+ };
11739
+ const spansOf = (patch, total) => {
11740
+ const leading = {
11741
+ lo: 1,
11742
+ hi: (patch.hunks[0]?.newStart ?? 1) - 1
11743
+ };
11744
+ const between = patch.hunks.slice(1).map((hunk) => ({
11745
+ lo: hunk.newStart - hunk.skipped,
11746
+ hi: hunk.newStart - 1
11747
+ }));
11748
+ const trailing = {
11749
+ lo: lastNewLine(patch) + 1,
11750
+ hi: total
11751
+ };
11752
+ return [
11753
+ leading,
11754
+ ...between,
11755
+ trailing
11756
+ ];
11757
+ };
11758
+ const linesFrom = (build, from, to) => build.full === void 0 || to < from ? [] : build.full.rows.filter((row) => match$2(row.newLine, {
11759
+ onNone: () => false,
11760
+ onSome: (line) => line >= from && line <= to
11761
+ }));
11762
+ const push = (made, row) => {
11763
+ made.rows.push({
11764
+ ...row,
11765
+ index: made.rows.length
11766
+ });
11767
+ };
11768
+ const markGap = (made, index, hidden) => {
11769
+ made.gaps.push({
11770
+ index,
11771
+ hidden,
11772
+ row: made.rows.length
11773
+ });
11774
+ push(made, {
11775
+ kind: "context",
11776
+ oldLine: none(),
11777
+ newLine: none(),
11778
+ text: markerText(hidden)
11779
+ });
11780
+ };
11781
+ const openOf = (build, index, count) => {
11782
+ if (build.full === void 0) return 0;
11783
+ const asked = build.reveals.find((entry) => entry.gap === index)?.lines ?? 0;
11784
+ return Math.min(count, Math.max(0, asked));
11785
+ };
11786
+ const countOf = (span) => Math.max(0, span.hi - span.lo + 1);
11787
+ const openAbove = (made, build, index) => {
11788
+ const span = build.spans[index];
11789
+ if (span === void 0) return 0;
11790
+ const count = countOf(span);
11791
+ const open = openOf(build, index, count);
11792
+ const left = count - open;
11793
+ if (left > 0) markGap(made, index, left);
11794
+ for (const row of linesFrom(build, span.hi - open + 1, span.hi)) push(made, row);
11795
+ return left;
11796
+ };
11797
+ const openBelow = (made, build) => {
11798
+ const index = build.base.hunks.length;
11799
+ const span = build.spans[index];
11800
+ if (span === void 0) return;
11801
+ const count = countOf(span);
11802
+ const open = openOf(build, index, count);
11803
+ for (const row of linesFrom(build, span.lo, span.lo + open - 1)) push(made, row);
11804
+ if (count - open > 0) markGap(made, index, count - open);
11805
+ };
11806
+ const makeRows = (build) => {
11807
+ const made = {
11808
+ rows: [],
11809
+ hunks: [],
11810
+ gaps: []
11811
+ };
11812
+ for (const [index, hunk] of build.base.hunks.entries()) {
11813
+ const left = openAbove(made, build, index);
11814
+ const startRow = made.rows.length;
11815
+ for (const row of hunk.rows) push(made, row);
11816
+ made.hunks.push({
11817
+ ...hunk,
11818
+ startRow,
11819
+ rows: made.rows.slice(startRow),
11820
+ skipped: index === 0 ? 0 : left
11821
+ });
11822
+ }
11823
+ openBelow(made, build);
11824
+ return made;
11825
+ };
11826
+ const compose = (build) => {
11827
+ const made = makeRows(build);
11828
+ return {
11829
+ patch: {
11830
+ ...build.base,
11831
+ rows: made.rows,
11832
+ hunks: made.hunks
11833
+ },
11834
+ gaps: made.gaps
11835
+ };
11836
+ };
11837
+ const cache = /* @__PURE__ */ new WeakMap();
11838
+ const keyOf = (total, full, reveals) => [
11839
+ total,
11840
+ full === void 0 ? 0 : full.rows.length,
11841
+ reveals.map((entry) => `${entry.gap}-${entry.lines}`).join(",")
11842
+ ].join(":");
11843
+ const shownOf = (state) => {
11844
+ const base = state.patches[state.patchIndex];
11845
+ if (base === void 0) return void 0;
11846
+ const full = state.full.find((patch) => patch.path === base.path);
11847
+ const total = sourceLength(state.source);
11848
+ const reveals = state.revealed.filter((entry) => entry.file === base.path);
11849
+ const key = keyOf(total, full, reveals);
11850
+ const known = cache.get(base);
11851
+ const found = known?.get(key);
11852
+ if (found !== void 0) return found;
11853
+ const made = compose({
11854
+ base,
11855
+ full,
11856
+ spans: spansOf(base, total),
11857
+ reveals
11858
+ });
11859
+ const map = known ?? /* @__PURE__ */ new Map();
11860
+ map.set(key, made);
11861
+ cache.set(base, map);
11862
+ return made;
11863
+ };
11864
+ const gapAtRow = (state, row) => shownOf(state)?.gaps.find((gap) => gap.row === row);
11865
+ const gapNumbered = (state, index) => shownOf(state)?.gaps.find((gap) => gap.index === index);
11866
+ const gapRowSet = (shown) => new Set(shown.gaps.map((gap) => gap.row));
11867
+ //#endregion
11728
11868
  //#region src/tui/tree.ts
11729
11869
  const add = (tree, input) => {
11730
11870
  const id = tree.nodes.length;
@@ -11875,10 +12015,13 @@ const initialState = (branches) => ({
11875
12015
  context: 3,
11876
12016
  top: 0,
11877
12017
  source: [],
12018
+ full: [],
12019
+ revealed: [],
11878
12020
  focus: "diff",
11879
12021
  navOpen: true,
11880
12022
  steps: [],
11881
12023
  stepIndex: 0,
12024
+ openSteps: [],
11882
12025
  rail: "tree"
11883
12026
  });
11884
12027
  const onSteps = (state) => state.rail === "steps" && state.steps.length > 0;
@@ -11895,22 +12038,50 @@ const stepHolding = (state, fileIndex) => {
11895
12038
  const at = state.steps.findIndex((step) => step.files.includes(path ?? ""));
11896
12039
  return at === -1 ? state.stepIndex : at;
11897
12040
  };
11898
- const stepWindow = (state, height) => {
11899
- const titles = state.steps.map((step) => step.title);
11900
- if (titles.length <= height) return {
11901
- first: 0,
11902
- titles,
12041
+ const stepOpen = (state, stepIndex) => state.openSteps.includes(stepIndex);
12042
+ const chunked = (word, room) => word.length <= room ? [word] : [word.slice(0, room), ...chunked(word.slice(room), room)];
12043
+ const packed = (lines, word, room) => {
12044
+ const last = lines.at(-1);
12045
+ if (last === void 0 || last.length + 1 + word.length > room) return [...lines, word];
12046
+ return [...lines.slice(0, -1), `${last} ${word}`];
12047
+ };
12048
+ const wrapped = (text, room) => {
12049
+ const width = Math.max(1, room);
12050
+ return text.split(/\s+/).filter((word) => word.length > 0).flatMap((word) => chunked(word, width)).reduce((lines, word) => packed(lines, word, width), []);
12051
+ };
12052
+ const NO_NOTE = "no note";
12053
+ const noteRows$1 = (state, stepIndex, room) => {
12054
+ const lines = wrapped(state.steps[stepIndex]?.note ?? "", room);
12055
+ return (lines.length === 0 ? [NO_NOTE] : lines).map((text) => ({
12056
+ index: stepIndex,
12057
+ kind: "note",
12058
+ text,
12059
+ lead: false
12060
+ }));
12061
+ };
12062
+ const titleRows = (state, stepIndex, room) => wrapped(state.steps[stepIndex]?.title ?? "", room).map((text, at) => ({
12063
+ index: stepIndex,
12064
+ kind: "title",
12065
+ text,
12066
+ lead: at === 0
12067
+ }));
12068
+ const stepRows = (state, titleRoom, noteRoom) => state.steps.flatMap((_, index) => stepOpen(state, index) ? [...titleRows(state, index, titleRoom), ...noteRows$1(state, index, noteRoom)] : titleRows(state, index, titleRoom));
12069
+ const railWindow = (rows, height, stepIndex) => {
12070
+ if (rows.length <= height) return {
12071
+ rows,
11903
12072
  more: 0
11904
12073
  };
11905
- const start = Math.max(0, Math.min(titles.length - height, state.stepIndex - Math.floor(height / 2)));
12074
+ const first = Math.max(0, rows.findIndex((row) => row.index === stepIndex));
12075
+ const block = rows.findLastIndex((row) => row.index === stepIndex) - first + 1;
12076
+ const wanted = block >= height ? first : first - Math.floor((height - block) / 2);
12077
+ const start = Math.max(0, Math.min(rows.length - height, wanted));
11906
12078
  return {
11907
- first: start,
11908
- titles: titles.slice(start, start + height),
11909
- more: titles.length - height
12079
+ rows: rows.slice(start, start + height),
12080
+ more: rows.length - height
11910
12081
  };
11911
12082
  };
11912
12083
  const selectedBranch = (state) => state.branches[state.branchIndex];
11913
- const selectedPatch = (state) => state.patches[state.patchIndex];
12084
+ const selectedPatch = (state) => shownOf(state)?.patch;
11914
12085
  const treeOf = (state) => buildTree(state.patches.map((patch) => patch.path));
11915
12086
  const treeRows = (state) => {
11916
12087
  const tree = treeOf(state);
@@ -11946,23 +12117,7 @@ const commentsOn = (state, fileIndex) => {
11946
12117
  if (patch === void 0) return 0;
11947
12118
  return state.pending.filter((entry) => entry.file === patch.path).length;
11948
12119
  };
11949
- const firstShownLine = (patch) => {
11950
- const found = patch.rows.find((row) => isSome(row.newLine));
11951
- return found === void 0 ? 1 : getOrElse(found.newLine, () => 1);
11952
- };
11953
- const lastShownLine = (patch) => {
11954
- const found = patch.rows.findLast((row) => isSome(row.newLine));
11955
- return found === void 0 ? 0 : getOrElse(found.newLine, () => 0);
11956
- };
11957
- const hiddenLines = (state) => {
11958
- const patch = selectedPatch(state);
11959
- if (patch === void 0) return 0;
11960
- const between = patch.hunks.reduce((total, hunk) => total + hunk.skipped, 0);
11961
- const above = Math.max(0, firstShownLine(patch) - 1);
11962
- const lines = state.source.at(-1)?.trim() === "" ? state.source.length - 1 : state.source.length;
11963
- const below = lines === 0 ? 0 : Math.max(0, lines - lastShownLine(patch));
11964
- return between + above + below;
11965
- };
12120
+ const hiddenLines = (state) => shownOf(state)?.gaps.reduce((total, gap) => total + gap.hidden, 0) ?? 0;
11966
12121
  const markedRows = (state) => {
11967
12122
  const patch = selectedPatch(state);
11968
12123
  if (patch === void 0) return /* @__PURE__ */ new Set();
@@ -11998,12 +12153,13 @@ const selectionReadout = (state) => {
11998
12153
  const lines = to - from + 1;
11999
12154
  return `${patch.path} ${lines} lines`;
12000
12155
  };
12156
+ const WHOLE_FILE = 1e5;
12001
12157
  const CONTEXT_STEPS = [
12002
12158
  3,
12003
12159
  10,
12004
12160
  25,
12005
12161
  60,
12006
- 1e5
12162
+ WHOLE_FILE
12007
12163
  ];
12008
12164
  const stepContext = (current, delta) => {
12009
12165
  const at = CONTEXT_STEPS.indexOf(current);
@@ -12030,7 +12186,7 @@ const rowAtSourceLine = (patch, line) => {
12030
12186
  };
12031
12187
  const lineOnSide = (row, side) => getOrUndefined$1(side === "old" ? row.oldLine : row.newLine);
12032
12188
  const commentRowsIn = (state, fileIndex) => {
12033
- const patch = state.patches[fileIndex];
12189
+ const patch = fileIndex === state.patchIndex ? selectedPatch(state) : state.patches[fileIndex];
12034
12190
  if (patch === void 0) return [];
12035
12191
  const notes = [...state.pending, ...state.sent].filter((entry) => entry.file === patch.path);
12036
12192
  return patch.rows.filter((row) => notes.some((note) => lineOnSide(row, note.side) === note.end)).map((row) => row.index).toSorted((left, right) => left - right);
@@ -12258,14 +12414,14 @@ const commands = [
12258
12414
  }),
12259
12415
  command({
12260
12416
  action: "tree.collapse",
12261
- title: "Collapse the file tree",
12417
+ title: "Close the folder, step, or gap",
12262
12418
  category: "Files",
12263
12419
  keys: ["h"],
12264
12420
  screens: ["review"]
12265
12421
  }),
12266
12422
  command({
12267
12423
  action: "tree.expand",
12268
- title: "Expand the file tree",
12424
+ title: "Open the folder, step, or gap",
12269
12425
  category: "Files",
12270
12426
  keys: ["l"],
12271
12427
  screens: ["review"]
@@ -12571,6 +12727,14 @@ const foldDirectory = (state, shut) => {
12571
12727
  closed: shut ? [...closed, directory] : closed
12572
12728
  };
12573
12729
  };
12730
+ const foldStep = (state, shut) => {
12731
+ const open = state.openSteps.filter((index) => index !== state.stepIndex);
12732
+ return {
12733
+ ...state,
12734
+ openSteps: shut ? open : [...open, state.stepIndex]
12735
+ };
12736
+ };
12737
+ const fold = (state, shut) => onSteps(state) ? foldStep(state, shut) : foldDirectory(state, shut);
12574
12738
  const moveBranch = (state, delta) => ({
12575
12739
  ...state,
12576
12740
  branchIndex: clamp(state.branchIndex + delta, 0, Math.max(0, state.branches.length - 1))
@@ -12681,8 +12845,8 @@ const transitions = {
12681
12845
  "rail.toggle": toggleRail,
12682
12846
  "file.vouch": (state) => state,
12683
12847
  "file.vouch.next": (state) => state,
12684
- "tree.collapse": (state) => foldDirectory(state, true),
12685
- "tree.expand": (state) => foldDirectory(state, false),
12848
+ "tree.collapse": (state) => fold(state, true),
12849
+ "tree.expand": (state) => fold(state, false),
12686
12850
  "report.open": (state) => ({
12687
12851
  ...state,
12688
12852
  screen: "report",
@@ -12707,10 +12871,40 @@ const withContext = (state, context, patches, cursor) => ({
12707
12871
  ...state,
12708
12872
  context,
12709
12873
  patches,
12874
+ revealed: [],
12710
12875
  cursor,
12711
12876
  anchorRow: cursor,
12712
12877
  selecting: false
12713
12878
  });
12879
+ const withFull = (state, full) => ({
12880
+ ...state,
12881
+ full
12882
+ });
12883
+ const revealsAfter = (state, gap, lines) => {
12884
+ const path = state.patches[state.patchIndex]?.path ?? "";
12885
+ const others = state.revealed.filter((entry) => entry.file !== path || entry.gap !== gap);
12886
+ return lines <= 0 ? others : [...others, {
12887
+ file: path,
12888
+ gap,
12889
+ lines
12890
+ }];
12891
+ };
12892
+ const gapOpened = (state, gap, delta) => {
12893
+ const path = state.patches[state.patchIndex]?.path ?? "";
12894
+ const now = state.revealed.find((entry) => entry.file === path && entry.gap === gap)?.lines ?? 0;
12895
+ const opened = {
12896
+ ...state,
12897
+ revealed: revealsAfter(state, gap, now + delta)
12898
+ };
12899
+ const wanted = gapNumbered(opened, gap)?.row ?? state.cursor;
12900
+ const landed = clamp(wanted, 0, lastRow(selectedPatch(opened)));
12901
+ return withCursorVisible({
12902
+ ...opened,
12903
+ cursor: landed,
12904
+ anchorRow: landed,
12905
+ selecting: false
12906
+ });
12907
+ };
12714
12908
  const withPending = (state, pending, screen) => ({
12715
12909
  ...state,
12716
12910
  pending,
@@ -12727,6 +12921,7 @@ const withStory = (state, steps) => {
12727
12921
  ...state,
12728
12922
  steps,
12729
12923
  stepIndex: 0,
12924
+ openSteps: [],
12730
12925
  rail: steps.length === 0 ? "tree" : "steps"
12731
12926
  };
12732
12927
  if (steps.length === 0) return opened;
@@ -12754,6 +12949,8 @@ const withPatches = (state, patches) => ({
12754
12949
  ...state,
12755
12950
  screen: "review",
12756
12951
  patches,
12952
+ full: [],
12953
+ revealed: [],
12757
12954
  closed: crowdedOf(patches),
12758
12955
  patchIndex: fileOrder({
12759
12956
  ...state,
@@ -12937,6 +13134,7 @@ const syntaxTheme = {
12937
13134
  punctuation: { fg: inkFaint },
12938
13135
  "punctuation.bracket": { fg: inkFaint },
12939
13136
  "punctuation.delimiter": { fg: inkFaint },
13137
+ gap: { fg: inkFaint },
12940
13138
  note: {
12941
13139
  fg: "#9aa7c7",
12942
13140
  italic: true
@@ -13085,20 +13283,20 @@ var DiffView = class {
13085
13283
  rows() {
13086
13284
  return this.fitted;
13087
13285
  }
13088
- show(patch, notes) {
13286
+ show(patch, notes, gaps) {
13089
13287
  const room = notes.length === 0 ? NOTE_MIN : this.noteRoom();
13090
13288
  const key = [room, ...notes.map((note) => `${note.side}${note.line}:${note.body}`)].join("\0");
13091
13289
  if (patch === this.shown && key === this.noted) return;
13092
13290
  this.pinnedText = "";
13093
13291
  this.shown = patch;
13094
13292
  this.noted = key;
13095
- this.display = layout(patch, notes, room);
13293
+ this.display = layout(patch, notes, room, gaps);
13096
13294
  this.starts = /* @__PURE__ */ new Map();
13097
13295
  for (const [index, entry] of this.display.entries()) if (!entry.comment && !this.starts.has(entry.row)) this.starts.set(entry.row, index);
13098
13296
  this.code.filetype = pathToFiletype(patch.path) ?? "text";
13099
13297
  this.code.content = this.display.map((entry) => entry.text).join("\n");
13100
13298
  this.numbers.setLineNumbers(lineNumbers(patch, this.display));
13101
- this.numbers.setHideLineNumbers(new Set(this.display.flatMap((entry, index) => entry.comment ? [index] : [])));
13299
+ this.numbers.setHideLineNumbers(new Set(this.display.flatMap((entry, index) => entry.comment || entry.gap ? [index] : [])));
13102
13300
  this.numbers.setLineSigns(lineSigns(patch, this.display));
13103
13301
  this.numbers.setLineColors(/* @__PURE__ */ new Map());
13104
13302
  const spans = noteSpans(this.display);
@@ -13135,18 +13333,22 @@ var DiffView = class {
13135
13333
  return WASH[kind];
13136
13334
  }
13137
13335
  };
13336
+ const groupOf = (entry) => {
13337
+ if (entry.gap) return "gap";
13338
+ if (!entry.comment) return void 0;
13339
+ if (entry.label) return "note.label";
13340
+ return entry.sent ? "note.sent" : "note";
13341
+ };
13138
13342
  const noteSpans = (display) => {
13139
13343
  const spans = [];
13140
13344
  let at = 0;
13141
13345
  for (const entry of display) {
13142
- if (entry.comment) {
13143
- const group = entry.label ? "note.label" : entry.sent ? "note.sent" : "note";
13144
- spans.push([
13145
- at,
13146
- at + entry.text.length,
13147
- group
13148
- ]);
13149
- }
13346
+ const group = groupOf(entry);
13347
+ if (group !== void 0) spans.push([
13348
+ at,
13349
+ at + entry.text.length,
13350
+ group
13351
+ ]);
13150
13352
  at += entry.text.length + 1;
13151
13353
  }
13152
13354
  return spans;
@@ -13172,9 +13374,10 @@ const noteRows = (note, row, room) => noteLines(note, room).map((line, index) =>
13172
13374
  row,
13173
13375
  comment: true,
13174
13376
  sent: note.sent,
13175
- label: index === 0
13377
+ label: index === 0,
13378
+ gap: false
13176
13379
  }));
13177
- const layout = (patch, notes, room) => {
13380
+ const layout = (patch, notes, room, gaps) => {
13178
13381
  const display = [];
13179
13382
  for (const row of patch.rows) {
13180
13383
  display.push({
@@ -13182,7 +13385,8 @@ const layout = (patch, notes, room) => {
13182
13385
  row: row.index,
13183
13386
  comment: false,
13184
13387
  sent: false,
13185
- label: false
13388
+ label: false,
13389
+ gap: gaps.has(row.index)
13186
13390
  });
13187
13391
  for (const note of notes) if (sideLineOf(row, note.side) === note.line) display.push(...noteRows(note, row.index, room));
13188
13392
  }
@@ -13222,6 +13426,8 @@ const FRAME_PAD = 1;
13222
13426
  const MODAL_ROOM = 8;
13223
13427
  const COMPOSE_CHROME = 3;
13224
13428
  const COMPOSE_ACTION_ROWS = 2;
13429
+ const COMPOSE_PAD = 5;
13430
+ const COMPOSE_MIN_TEXT = 8;
13225
13431
  const reportActions = () => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("copy and save")}`;
13226
13432
  const actionsText = () => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^a")} ${fg(palette.muted)("add to review")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("comment now")}`;
13227
13433
  const SNIPPET_LINES = 4;
@@ -13248,6 +13454,17 @@ const treeWidth = (width) => {
13248
13454
  };
13249
13455
  const homeWidth = (width) => Math.max(0, Math.min(BRANCH_WIDTH, width - 2));
13250
13456
  const modalWidth = (width, wanted) => Math.max(0, Math.min(wanted, width - MODAL_MARGIN));
13457
+ const composeRoom = (width) => {
13458
+ const box = modalWidth(width, COMPOSE_WIDTH);
13459
+ return {
13460
+ box,
13461
+ text: Math.max(COMPOSE_MIN_TEXT, box - COMPOSE_PAD)
13462
+ };
13463
+ };
13464
+ const laidOut = (lines, room) => lines.flatMap((line) => {
13465
+ const parts = wrapped(line, room);
13466
+ return parts.length === 0 ? [""] : parts;
13467
+ });
13251
13468
  const STICKY_MAX = 4;
13252
13469
  const pickPaint = (view, kind, flags) => {
13253
13470
  if (flags.cursor) return {
@@ -13258,11 +13475,16 @@ const pickPaint = (view, kind, flags) => {
13258
13475
  gutter: SELECTION,
13259
13476
  content: SELECTION
13260
13477
  };
13478
+ if (flags.gap) return GAP_PAINT;
13261
13479
  return view.washOf(kind);
13262
13480
  };
13263
13481
  const SELECTION = RGBA.fromHex(palette.selection);
13264
13482
  const CURSOR = RGBA.fromHex(palette.cursor);
13265
13483
  const ACCENT = RGBA.fromHex(palette.accent);
13484
+ const GAP_PAINT = {
13485
+ gutter: RGBA.fromHex(palette.overlay),
13486
+ content: RGBA.fromHex(palette.overlay)
13487
+ };
13266
13488
  const bar = (renderer, id, color) => new TextRenderable(renderer, {
13267
13489
  id,
13268
13490
  content: "",
@@ -13445,18 +13667,21 @@ const makeComposeParts = (renderer) => ({
13445
13667
  title: new TextRenderable(renderer, {
13446
13668
  id: "compose-title",
13447
13669
  content: "",
13448
- fg: palette.ink
13670
+ fg: palette.ink,
13671
+ wrapMode: "none"
13449
13672
  }),
13450
13673
  body: new TextRenderable(renderer, {
13451
13674
  id: "compose-body",
13452
13675
  content: "",
13453
- fg: palette.ink
13676
+ fg: palette.ink,
13677
+ wrapMode: "none"
13454
13678
  }),
13455
13679
  actions: new TextRenderable(renderer, {
13456
13680
  id: "compose-actions",
13457
13681
  content: "",
13458
13682
  fg: palette.muted,
13459
- marginTop: 1
13683
+ marginTop: 1,
13684
+ wrapMode: "none"
13460
13685
  })
13461
13686
  });
13462
13687
  const makeCompose = (renderer) => new BoxRenderable(renderer, {
@@ -13547,14 +13772,33 @@ const treeLine = (state, row, pane) => {
13547
13772
  return `${treeMarks(state, row)}${clip(treeLabel(state, row), room).padEnd(room)}${tail}`;
13548
13773
  };
13549
13774
  const STEP_NUMBER = 3;
13550
- const stepLine = (state, index, pane) => {
13551
- const step = state.steps[index];
13552
- if (step === void 0) return "";
13553
- const mark = index === state.stepIndex ? state.focus === "tree" ? "▸" : "·" : " ";
13554
- const number = `${index + 1}.`.padStart(STEP_NUMBER);
13555
- const tail = `${step.files.length}`;
13556
- const room = Math.max(4, pane - PANE_CHROME - STEP_NUMBER - tail.length - 3);
13557
- return `${mark} ${number} ${clip(step.title, room).padEnd(room)}${tail}`;
13775
+ const STEP_LEAD = 8;
13776
+ const NOTE_LEAD = 10;
13777
+ const STEP_GAP = 1;
13778
+ const stepRoom = (state, pane) => {
13779
+ const tally = Math.max(1, ...state.steps.map((step) => `${step.files.length}`.length));
13780
+ return {
13781
+ title: Math.max(4, pane - PANE_CHROME - STEP_LEAD - STEP_GAP - tally),
13782
+ note: Math.max(4, pane - PANE_CHROME - NOTE_LEAD),
13783
+ tally
13784
+ };
13785
+ };
13786
+ const stepFold = (state, index) => {
13787
+ if (stepOpen(state, index)) return "▾";
13788
+ return (state.steps[index]?.note ?? "").length === 0 ? " " : "▸";
13789
+ };
13790
+ const stepHead = (state, row) => {
13791
+ if (!row.lead) return " ".repeat(STEP_LEAD);
13792
+ return `${row.index === state.stepIndex ? state.focus === "tree" ? "▸" : "·" : " "} ${stepFold(state, row.index)} ${`${row.index + 1}.`.padStart(STEP_NUMBER)} `;
13793
+ };
13794
+ const stepText = (state, row, room) => {
13795
+ if (row.kind === "note") return `${" ".repeat(NOTE_LEAD)}${row.text}`;
13796
+ const tail = (row.lead ? `${state.steps[row.index]?.files.length ?? 0}` : "").padStart(room.tally + STEP_GAP);
13797
+ return `${stepHead(state, row)}${row.text.padEnd(room.title)}${tail}`;
13798
+ };
13799
+ const stepPaint = (state, row) => {
13800
+ if (row.kind === "note") return palette.faint;
13801
+ return row.index === state.stepIndex ? palette.ink : palette.muted;
13558
13802
  };
13559
13803
  var Screen = class {
13560
13804
  header;
@@ -13730,21 +13974,18 @@ var Screen = class {
13730
13974
  }
13731
13975
  stepRail(state) {
13732
13976
  const height = Math.max(1, this.listPane.height - 1);
13733
- const pane = this.paneRoom();
13734
- const window = stepWindow(state, height);
13735
- const rows = window.titles.map((_, offset) => {
13736
- const index = window.first + offset;
13737
- const paint = index === state.stepIndex ? palette.ink : palette.muted;
13738
- return fg(paint)(`${stepLine(state, index, pane)}\n`);
13739
- });
13977
+ const room = stepRoom(state, this.paneRoom());
13978
+ const window = railWindow(stepRows(state, room.title, room.note), height, state.stepIndex);
13979
+ const rows = window.rows.map((row) => fg(stepPaint(state, row))(`${stepText(state, row, room)}\n`));
13740
13980
  const more = window.more > 0 ? [fg(palette.faint)(` … ${window.more} more`)] : [];
13741
13981
  return new StyledText([...rows, ...more]);
13742
13982
  }
13743
13983
  paintDiff(state) {
13744
- const patch = selectedPatch(state);
13745
- if (patch === void 0) return;
13984
+ const shown = shownOf(state);
13985
+ if (shown === void 0) return;
13986
+ const patch = shown.patch;
13746
13987
  this.paintSticky(state, state.top);
13747
- this.view.show(patch, notesFor(state, patch.path));
13988
+ this.view.show(patch, notesFor(state, patch.path), gapRowSet(shown));
13748
13989
  this.view.fit(this.diffScroll.height);
13749
13990
  const height = this.view.rows();
13750
13991
  const top = this.view.scrollTo(state.top, state.cursor);
@@ -13883,18 +14124,18 @@ var Screen = class {
13883
14124
  paintReport(state) {
13884
14125
  this.compose.visible = state.screen === "compose" || state.screen === "report";
13885
14126
  if (state.screen !== "report") return;
13886
- const lines = [
14127
+ const room = composeRoom(this.renderer.width);
14128
+ const lines = laidOut([
13887
14129
  "What went wrong? Everything on screen is attached for you.",
13888
14130
  "",
13889
14131
  `${state.draft}▌`
13890
- ];
14132
+ ], room.text);
13891
14133
  this.composeTitle.content = "Report a bug";
13892
14134
  this.composeBody.content = lines.join("\n");
13893
14135
  this.composeActions.content = reportActions();
13894
- const room = modalWidth(this.renderer.width, COMPOSE_WIDTH);
13895
14136
  this.compose.height = lines.length + COMPOSE_ACTION_ROWS + COMPOSE_CHROME;
13896
- this.compose.width = room;
13897
- this.compose.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room) / 2));
14137
+ this.compose.width = room.box;
14138
+ this.compose.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room.box) / 2));
13898
14139
  this.compose.top = Math.max(2, Math.floor(this.renderer.height / 4));
13899
14140
  }
13900
14141
  paintGutter(state, top, height) {
@@ -13915,13 +14156,16 @@ var Screen = class {
13915
14156
  linePaint(state) {
13916
14157
  const [from, to] = selectionRange(state);
13917
14158
  const selecting = state.selecting || state.screen === "compose";
13918
- const rows = selectedPatch(state)?.rows ?? [];
14159
+ const shown = shownOf(state);
14160
+ const rows = shown?.patch.rows ?? [];
14161
+ const gaps = shown === void 0 ? /* @__PURE__ */ new Set() : gapRowSet(shown);
13919
14162
  return (row) => {
13920
14163
  const kind = rows[row]?.kind;
13921
14164
  if (kind === void 0) return void 0;
13922
14165
  return pickPaint(this.view, kind, {
13923
14166
  cursor: row === state.cursor,
13924
- selected: selecting && row >= from && row <= to
14167
+ selected: selecting && row >= from && row <= to,
14168
+ gap: gaps.has(row)
13925
14169
  });
13926
14170
  };
13927
14171
  }
@@ -13931,24 +14175,24 @@ var Screen = class {
13931
14175
  this.composeBody.content = "";
13932
14176
  return;
13933
14177
  }
14178
+ const room = composeRoom(this.renderer.width);
13934
14179
  const snippet = snippetOf(state, SNIPPET_LINES);
13935
14180
  const more = selectionRange(state)[1] - selectionRange(state)[0] + 1 - snippet.length;
13936
14181
  const tail = more > 0 ? [` … ${more} more lines`] : [];
13937
- const written = `${state.draft}▌`.split("\n");
14182
+ const quoted = [...snippet, ...tail].map((line) => clip(line, room.text));
14183
+ const written = laidOut(`${state.draft}▌`.split("\n"), room.text);
13938
14184
  const lines = [
13939
- ...snippet,
13940
- ...tail,
14185
+ ...quoted,
13941
14186
  "",
13942
14187
  ...written
13943
14188
  ];
13944
- this.composeTitle.content = composeTarget(state);
14189
+ this.composeTitle.content = clip(composeTarget(state), room.text);
13945
14190
  this.composeBody.content = lines.join("\n");
13946
14191
  this.composeActions.content = actionsText();
13947
14192
  const height = lines.length + COMPOSE_ACTION_ROWS + COMPOSE_CHROME;
13948
- const room = modalWidth(this.renderer.width, COMPOSE_WIDTH);
13949
14193
  this.compose.height = height;
13950
- this.compose.width = room;
13951
- this.compose.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room) / 2));
14194
+ this.compose.width = room.box;
14195
+ this.compose.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room.box) / 2));
13952
14196
  this.compose.top = Math.max(2, Math.floor((this.renderer.height - height) / 2));
13953
14197
  }
13954
14198
  };
@@ -14126,9 +14370,24 @@ var App = class {
14126
14370
  back: () => this.goBack(),
14127
14371
  "report.send": () => this.sendReport(),
14128
14372
  "context.more": () => this.expand(1),
14129
- "context.less": () => this.expand(-1)
14373
+ "context.less": () => this.expand(-1),
14374
+ "tree.expand": () => this.unfold(1),
14375
+ "tree.collapse": () => this.unfold(-1)
14130
14376
  };
14131
14377
  }
14378
+ async unfold(delta) {
14379
+ const gap = this.state.focus === "diff" ? gapAtRow(this.state, this.state.cursor) : void 0;
14380
+ const action = delta > 0 ? "tree.expand" : "tree.collapse";
14381
+ if (gap === void 0) return this.commit(reduce(this.measured(), action));
14382
+ if (delta > 0) await this.loadFull();
14383
+ this.commit(gapOpened(this.measured(), gap.index, delta * 10));
14384
+ }
14385
+ async loadFull() {
14386
+ const branch = selectedBranch(this.state);
14387
+ if (branch === void 0 || this.state.full.length > 0) return;
14388
+ const full = await this.run(listPatches(this.repo, branch.branch, WHOLE_FILE));
14389
+ this.commit(withFull(this.state, full));
14390
+ }
14132
14391
  async onKey(key, forced) {
14133
14392
  const action = forced ?? actionFor(this.state.screen, keyName(key));
14134
14393
  this.remember(action, key);
@@ -14246,7 +14505,8 @@ var App = class {
14246
14505
  if (branch === void 0 || next === this.state.context) return;
14247
14506
  const line = sourceLineAt(this.state, this.state.cursor);
14248
14507
  const patches = await this.run(listPatches(this.repo, branch.branch, next));
14249
- const patch = patches[this.state.patchIndex];
14508
+ const widened = withContext(this.state, next, patches, 0);
14509
+ const patch = selectedPatch(widened);
14250
14510
  const cursor = patch === void 0 || line === void 0 ? 0 : rowAtSourceLine(patch, line);
14251
14511
  this.commit(withContext(this.state, next, patches, cursor));
14252
14512
  }
package/package.json CHANGED
@@ -16,12 +16,12 @@
16
16
  "@opentui/core": "^0.4.5"
17
17
  },
18
18
  "engines": {
19
- "node": ">=26"
19
+ "node": ">=22"
20
20
  },
21
21
  "bin": {
22
22
  "adiff": "./bin/adiff.js"
23
23
  },
24
- "version": "0.1.0-alpha.2",
24
+ "version": "0.1.0-alpha.4",
25
25
  "description": "Review agent work across git worktrees like a PR, and hand the comments back to the agent.",
26
26
  "license": "MIT",
27
27
  "repository": {
@@ -35,6 +35,14 @@ adiff comment take --worktree . --wait 300
35
35
  Blocks until a comment arrives or the timeout in seconds elapses, then returns the same envelope.
36
36
  An empty `comments` array means the wait expired with nothing new — that is not an error.
37
37
 
38
+ Run the wait in the background, not in the foreground. A foreground wait holds the turn, so you
39
+ cannot do anything else and the person you are working with cannot talk to you. Backgrounded, the
40
+ harness brings you back the moment a comment lands.
41
+
42
+ Re-arm it after each comment you handle, and keep it running while you work. A reviewer reads at
43
+ their own pace, so comments arrive minutes apart, and the whole point is that they reach you as
44
+ events rather than by you asking. When you finish a piece of work, say you are still listening.
45
+
38
46
  ## Acting on a comment
39
47
 
40
48
  Read `snippet` before opening the file: the reviewer commented on the diff, and the file may have
@@ -121,6 +129,20 @@ Setting a story again supersedes the previous one and bumps `version`; the story
121
129
  it was written for, and adiff reports it as `stale` once the branch moves past that commit. After
122
130
  you address a review, write the story again.
123
131
 
132
+ ## Tell the reviewer how to read it
133
+
134
+ The person you are handing work to has to open the review themselves, so end your reply with the
135
+ command and the keys. Name the repository they should point at, which is the repository the
136
+ worktree belongs to:
137
+
138
+ > Open it with `adiff review open --repo <repo>`, then press `enter` on this branch. The sidebar
139
+ > lists the steps in reading order; `j` and `k` move between them and the diff follows. Inside a
140
+ > step, `]` and `[` walk its files. Select lines with `v`, write a comment with `c`, stage it with
141
+ > `ctrl+a`, and send the whole review with `S`. Press `?` for the rest.
142
+
143
+ Say what you want looked at hardest, and where you are unsure. A reviewer who knows which step you
144
+ doubt spends their attention there.
145
+
124
146
  ## Discovering the rest
125
147
 
126
148
  ```bash