@eliya-oss/agent-diff 0.1.0-alpha.7 → 0.1.0-alpha.70

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/README.md CHANGED
@@ -2,76 +2,143 @@
2
2
 
3
3
  # adiff
4
4
 
5
- Review the work an agent did in a git worktree, in your terminal, and hand your comments back to
6
- the agent still sitting in that worktree. You select lines the way you would on GitHub, write a
7
- comment, and the agent picks it up.
5
+ An agent finishes a piece of work and leaves you a diff. You read it without knowing why any of it
6
+ was written that way, and asking means describing a line back in prose and reading the reply
7
+ somewhere far from the code it concerns. On a large change you carry the whole review in your head,
8
+ and it ends when your patience does.
8
9
 
9
- <pre align="center">brew install Newbie012/tap/adiff
10
- npm i -g @eliya-oss/agent-diff@alpha</pre>
10
+ adiff puts the conversation on the code. You comment on the lines in a terminal, the agent that
11
+ wrote them answers under your words, and a point stays open until you settle it.
12
+
13
+ The agent can also hand you a reading order: its own diff in layers, a note on each, and a coverage
14
+ check so nothing is quietly left out of the story.
15
+
16
+ <pre align="center">npm i -g @eliya-oss/agent-diff@alpha</pre>
17
+
18
+ <p align="center"><a href="docs/install.md">Other ways to install</a></p>
19
+
20
+ <img src="assets/terminal.webp" alt="The adiff worktree list, showing seven branches with their sizes, layers and review state" width="820">
11
21
 
12
22
  </div>
13
23
 
14
- ## Usage
24
+ ## The loop
25
+
26
+ You comment on a line:
15
27
 
16
28
  ```bash
17
- adiff review open --repo .
18
- adiff branch list --repo . --fields branch,files
19
- adiff comment add --repo . --branch add-teammate-invitations --file src/api/invitations.ts --start 4 --end 5 --body "why"
20
- adiff comment stage --repo . --branch add-teammate-invitations --file src/api/invitations.ts --start 4 --end 5 --body "why"
21
- adiff review submit --repo . --branch add-teammate-invitations
22
- adiff file vouch --repo . --branch add-teammate-invitations --file src/api/invitations.ts
23
- adiff layers show --worktree . --fields covered,total,uncovered
24
- adiff describe
29
+ adiff comment send --repo . --branch add-teammate-invitations \
30
+ --file src/api/invitations.ts --start 12 --end 13 \
31
+ --body "Three status checks in a row. One error shape would do."
25
32
  ```
26
33
 
27
- `comment add` reaches the agent right away. `comment stage` holds a comment until `review submit`
28
- sends the whole set as one wake-up, so the agent reads a review rather than a stream of remarks.
34
+ The agent in that worktree collects it, carrying the code it was written against:
29
35
 
30
- ## Reviewing
36
+ ```bash
37
+ adiff comment take --worktree .
38
+ {"ok":true,"comments":[{"id":"1c43cb55-6a09-406d-95ad-f048c43e05f5","file":"src/api/invitations.ts",
39
+ "side":"new","start":12,"end":13,"head":"63c11ce3",
40
+ "snippet":" if (res.status === 409) throw new AlreadyInvited(email)\n ...",
41
+ "body":"Three status checks in a row. One error shape would do."}]}
42
+ ```
43
+
44
+ It does the work, then answers the comment it was handed:
45
+
46
+ ```bash
47
+ adiff comment answer --worktree . --id 1c43cb55-6a09-406d-95ad-f048c43e05f5 \
48
+ --body "Folded them into one InviteRejected carrying the reason."
49
+ {"ok":true,"answered":1}
50
+ ```
51
+
52
+ You see that answer under your own words the next time you read the branch, and the thread waits
53
+ there until you settle it with `d`:
54
+
55
+ ```bash
56
+ adiff comment list --repo . --branch add-teammate-invitations
57
+ {"ok":true,"comments":[{"id":"1c43cb55-6a09-406d-95ad-f048c43e05f5","state":"answered",
58
+ "stale":false,"answers":[{"body":"Folded them into one InviteRejected carrying the reason.",
59
+ "asks":false}]}]}
60
+ ```
61
+
62
+ `--question` on an answer marks the thread as waiting on you, for a decision the agent needs before
63
+ it can carry on. Settling is yours alone: the agent that raised the answer cannot close the point.
31
64
 
32
- `adiff review open --repo .` lists the worktrees that have something to review. Enter opens one,
33
- `j` and `k` move down the diff, `[` and `]` move between files, `v` starts a selection, `c` writes
34
- a comment, `ctrl+s` sends it and `ctrl+a` adds it to the review instead. `m` marks a file reviewed,
35
- `ctrl+p` finds any command by name, and the footer lists the keys for wherever you are.
65
+ Every command that acts on a review takes either `--worktree <path>` or `--repo <path>` with
66
+ `--branch <name>`, so the same command works from your checkout and from the agent's worktree.
36
67
 
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.
68
+ A comment is handed over exactly once, so a second `take` returns only what was written since. Add
69
+ `--wait 300` and it blocks until something arrives, which costs nothing while it waits.
40
70
 
41
- ## The agent side
71
+ ## The reading order
42
72
 
43
- In the worktree being reviewed:
73
+ An agent knows the order it built a change in. Rebuilding that order by reading forty files is the
74
+ expensive way to learn something it already has, so it can publish the reading itself when you ask
75
+ for one:
44
76
 
45
77
  ```bash
46
- adiff comment take --worktree . # everything written since the last take
47
- adiff comment take --worktree . --wait 300 # block until something arrives
78
+ adiff layers set --worktree . --json -
48
79
  ```
49
80
 
50
- Each comment carries the exact snippet it was written against, the side of the diff, and the commit
51
- the diff was read at, so the agent needs no other reference. A comment is handed over once.
81
+ Each layer is a claim over spans of the diff, with a note saying what the layer is for. The terminal
82
+ lists them in the sidebar and scopes the diff to the layer you are on, with the prose sitting above
83
+ the code it describes.
52
84
 
53
- An agent can also record the reading order for its own work as a layers: ordered layers over spans of
54
- files, set with `adiff layers set --worktree . --json -`. Where a branch has one, the terminal lists
55
- its layers and scopes the diff to the layer you are on. adiff computes the coverage itself, so a layers
56
- cannot hide code:
85
+ adiff computes the coverage itself, so the reading cannot hide code:
57
86
 
58
87
  ```bash
59
88
  adiff layers show --worktree . --fields covered,total,uncovered
60
- {"ok":true,"layers":{"covered":1,"total":3,"uncovered":[{"path":"docs/incidents.md","start":1,"end":6},{"path":"src/api/errors.ts","start":1,"end":11}]}}
89
+ {"ok":true,"layers":{"covered":3,"total":3,"uncovered":[]}}
61
90
  ```
62
91
 
63
- ## Skill
92
+ Any hunk no layer claims is reported here and shown to you under "not in any layer". The layers
93
+ record the commit they were written for, and adiff marks them stale once the branch moves past it.
94
+
95
+ ## Reviewing
96
+
97
+ `adiff review open --repo .` lists the worktrees with something to review, including the checkout
98
+ you are standing in. Enter opens one.
99
+
100
+ `j` and `k` move down the diff, `[` and `]` between files, `v` starts a selection and `c` writes a
101
+ comment, which `ctrl+s` sends. `y` copies the line you are on, and dragging over lines copies them. `m`
102
+ marks a file reviewed, `d` settles the thread you are on, `s` swaps the sidebar between layers and
103
+ files, `w` wraps long lines, `/` searches for what you selected, `r` reads the branch again, and
104
+ `ctrl+p` finds any command by name. The footer lists the keys for wherever you are.
105
+
106
+ Where the diff leaves lines out, a row says how many. Put the cursor on it and `l` brings ten of them
107
+ back where you stand, `h` puts them away, and the rest of the file stays as small as it was. Opened
108
+ lines are ordinary lines: select them and comment on them.
109
+
110
+ ## Setting up a repository
111
+
112
+ ```bash
113
+ adiff init # shows what it would write
114
+ adiff init --write # writes it
115
+ ```
116
+
117
+ Writes a short passage into `AGENTS.md` and a `CLAUDE.md` that imports it, telling any agent working
118
+ in that repository how the handover runs. It sits between `<!-- adiff:begin -->` and
119
+ `<!-- adiff:end -->`, so a second run changes nothing and removing it is deleting a block you can
120
+ see. `--skill` also writes the full skill into `.claude/skills/adiff/`.
121
+
122
+ For a per-machine install instead:
64
123
 
65
124
  ```bash
66
125
  npx skills add Newbie012/agent-diff --skill adiff
67
126
  ```
68
127
 
69
- Teaches an agent the whole loop: collect comments, act on them, write the layers.
128
+ When someone asks for a review, the agent can put it in front of them:
129
+
130
+ ```bash
131
+ adiff review pane --repo .
132
+ {"ok":true,"opened":true,"pane":"tmux","command":"adiff review open --repo /work/api"}
133
+ ```
134
+
135
+ It splits tmux, Zellij, WezTerm or kitty. Anywhere else it answers `opened:false` and carries the
136
+ command to run, so the agent quotes one line rather than a paragraph.
70
137
 
71
138
  ## Requirements
72
139
 
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.
140
+ Either install gives you an `adiff` on your PATH. Brew brings a Node 26 along with it, so everything
141
+ works the moment it finishes.
75
142
 
76
143
  The commands run on Node 22 or newer. The terminal is the one part that wants Node 26: it draws
77
144
  through opentui, which reaches its native renderer over `node:ffi`, a module Node exposes behind
@@ -79,6 +146,8 @@ through opentui, which reaches its native renderer over `node:ffi`, a module Nod
79
146
  Node 26 among your fnm, nvm, asdf, volta and Homebrew installs and runs the terminal on that, so a
80
147
  global npm install keeps working across a version switch.
81
148
 
149
+ ## Trying it
150
+
82
151
  pnpm 12 is a Rust rewrite and still in beta, so
83
152
  [corepack cannot install it](https://pnpm.io/installation):
84
153
 
@@ -90,19 +159,21 @@ pnpm install
90
159
 
91
160
  `pnpm simulate` builds a throwaway repository with seven branches an agent has already worked on,
92
161
  from a three-file error type up to a 42-file migration of just over a thousand lines each way, and
93
- opens the terminal on it. Your real repos and `~/.adiff` are untouched, and the workspace is removed
94
- when you quit. `pnpm simulate --probe` runs the whole round trip headless and prints it:
162
+ opens the terminal on it. Your real repos and `~/.adiff` are untouched, and the workspace goes when
163
+ you quit. `pnpm simulate --probe` runs the whole round trip headless and prints it:
95
164
 
96
165
  ```
97
- branches {"ok":true,"branches":[{"branch":"add-teammate-invitations","files":3,"added":27,"removed":2,...
98
- vouch {"ok":true,"vouched":["src/api/incidents.ts"],"total":3}
99
- agent takes {"ok":true,"comments":[{"file":"src/api/incidents.ts","side":"new","start":12,"end":13,
100
- "snippet":" if (res.status === 404) throw new IncidentNotFound(id)\n if (!res.ok) ...",
101
- "body":"Two throws where one union would do."}]}
166
+ branches {"ok":true,"branches":[{"branch":"add-teammate-invitations","files":3,"added":27,"removed":2,"layers":2,...
167
+ reviewed {"ok":true,"reviewed":["src/api/invitations.ts"],"total":3}
168
+ agent takes {"ok":true,"comments":[{"id":"a83fc98c-8397-44f5-9c37-731a1cf3cb4c","file":"src/api/invitations.ts",
169
+ "side":"new","start":12,"end":13,"snippet":" if (res.status === 409) throw new AlreadyInvited(email)...",
170
+ "body":"Three status checks in a row. One error shape would do."}]}
102
171
  ```
103
172
 
104
173
  ## Notes
105
174
 
175
+ adiff is alpha, and one person's tool. Every release goes out under the `alpha` tag.
176
+
106
177
  Everything the terminal does is also a command, so nothing is trapped in the UI. Each command prints
107
178
  one compact JSON line on stdout and exits 0, and `--fields` trims the answer to what you read:
108
179
 
@@ -114,7 +185,7 @@ adiff branch list --repo . --fields branch,files
114
185
  Failures go to stderr as `{"ok":false,"error":{...}}`, so stdout is always parseable, with an exit
115
186
  code saying what to do about it: `2` malformed request, `3` not found, `1` unexpected. Every error
116
187
  carries a `suggestion` naming the command that resolves it, and `adiff describe` returns the whole
117
- catalog as JSON so a caller can discover the commands.
188
+ catalog as JSON so a caller can discover the rest.
118
189
 
119
190
  Project docs live in `.agents/`. `AGENTS.md` covers making a change, `ARCHITECTURE.md` how the code
120
191
  is laid out.
package/bin/adiff.js CHANGED
@@ -27,14 +27,18 @@ const MESSAGE = [
27
27
  "Every other adiff command runs here. Install Node 26 to open the terminal.",
28
28
  ].join("\n")
29
29
 
30
+ const watched = () => process.stdout.isTTY && process.stdin.isTTY
31
+
30
32
  const drawsTerminal = (argv) => {
31
33
  const words = argv.filter((token) => !token.startsWith("--"))
34
+ if (argv.length === 0) return watched()
32
35
  return words[0] === "review" && words[1] === "open"
33
36
  }
34
37
 
35
38
  const rendersHere = () =>
36
- typeof process.getBuiltinModule === "function" &&
37
- process.getBuiltinModule("node:ffi") !== undefined
39
+ process.versions.bun !== undefined ||
40
+ (typeof process.getBuiltinModule === "function" &&
41
+ process.getBuiltinModule("node:ffi") !== undefined)
38
42
 
39
43
  const NODE_DIRECTORY = /^(?:v?\d|node)/
40
44