@eliya-oss/agent-diff 0.1.0-alpha.0
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/.agents/adr/README.md +33 -0
- package/.agents/prd/README.md +74 -0
- package/CHANGELOG.md +58 -0
- package/README.md +239 -0
- package/bin/adiff.js +2 -0
- package/package.json +54 -0
- package/skills/adiff/SKILL.md +135 -0
- package/src/cli/catalog.ts +178 -0
- package/src/cli/commands.ts +335 -0
- package/src/cli/error.ts +44 -0
- package/src/cli/index.ts +24 -0
- package/src/cli/parse.ts +31 -0
- package/src/cli/report.ts +96 -0
- package/src/cli/story.ts +223 -0
- package/src/domain/narrative/coverage.ts +54 -0
- package/src/domain/narrative/index.ts +4 -0
- package/src/domain/narrative/model.ts +46 -0
- package/src/domain/narrative/version.ts +63 -0
- package/src/domain/patch/anchor.ts +40 -0
- package/src/domain/patch/index.ts +7 -0
- package/src/domain/patch/model.ts +54 -0
- package/src/domain/patch/parse.ts +106 -0
- package/src/domain/patch/render.ts +48 -0
- package/src/domain/patch/sticky.ts +39 -0
- package/src/domain/review/index.ts +4 -0
- package/src/domain/review/lifecycle.ts +45 -0
- package/src/domain/review/model.ts +23 -0
- package/src/domain/review/vouch.ts +15 -0
- package/src/main.ts +186 -0
- package/src/service/git/error.ts +16 -0
- package/src/service/git/index.ts +3 -0
- package/src/service/git/model.ts +13 -0
- package/src/service/git/run.ts +27 -0
- package/src/service/git/service.ts +133 -0
- package/src/service/store/error.ts +11 -0
- package/src/service/store/index.ts +5 -0
- package/src/service/store/model.ts +33 -0
- package/src/service/store/paths.ts +25 -0
- package/src/service/store/service.ts +154 -0
- package/src/testing/agent-surface.test.ts +92 -0
- package/src/testing/batch.test.ts +93 -0
- package/src/testing/branch-state.test.ts +99 -0
- package/src/testing/chrome-tone.test.ts +57 -0
- package/src/testing/comment-block.test.ts +84 -0
- package/src/testing/comment-walk.test.ts +96 -0
- package/src/testing/compose-box.test.ts +97 -0
- package/src/testing/compose.test.ts +67 -0
- package/src/testing/context.test.ts +77 -0
- package/src/testing/cursor.test.ts +49 -0
- package/src/testing/delivery.test.ts +94 -0
- package/src/testing/domains/agent/driver.ts +50 -0
- package/src/testing/domains/agent/index.ts +2 -0
- package/src/testing/domains/app/driver.ts +168 -0
- package/src/testing/domains/app/index.ts +2 -0
- package/src/testing/domains/branch/driver.ts +51 -0
- package/src/testing/domains/branch/index.ts +3 -0
- package/src/testing/domains/branch/model.ts +39 -0
- package/src/testing/domains/screen/driver.ts +241 -0
- package/src/testing/domains/screen/index.ts +2 -0
- package/src/testing/driver.ts +31 -0
- package/src/testing/escape.test.ts +56 -0
- package/src/testing/focus.test.ts +104 -0
- package/src/testing/footer-chips.test.ts +65 -0
- package/src/testing/footer.test.ts +64 -0
- package/src/testing/gaps.test.ts +47 -0
- package/src/testing/highlight.test.ts +49 -0
- package/src/testing/home-screen.test.ts +51 -0
- package/src/testing/index.ts +4 -0
- package/src/testing/inline-comments.test.ts +131 -0
- package/src/testing/marks.test.ts +49 -0
- package/src/testing/mouse.test.ts +87 -0
- package/src/testing/navigate.test.ts +73 -0
- package/src/testing/palette.test.ts +68 -0
- package/src/testing/pending.test.ts +70 -0
- package/src/testing/pin-align.test.ts +37 -0
- package/src/testing/progress.test.ts +88 -0
- package/src/testing/report.test.ts +83 -0
- package/src/testing/resume.test.ts +39 -0
- package/src/testing/review.test.ts +181 -0
- package/src/testing/roundtrip.test.ts +70 -0
- package/src/testing/scale.test.ts +55 -0
- package/src/testing/scroll-feel.test.ts +81 -0
- package/src/testing/sent-comments.test.ts +106 -0
- package/src/testing/state.ts +55 -0
- package/src/testing/sticky-removed.test.ts +67 -0
- package/src/testing/sticky.test.ts +90 -0
- package/src/testing/story-rail.test.ts +122 -0
- package/src/testing/story.test.ts +183 -0
- package/src/testing/stress.test.ts +74 -0
- package/src/testing/tree-collapse.test.ts +108 -0
- package/src/testing/tree-rows.test.ts +66 -0
- package/src/testing/tree.test.ts +91 -0
- package/src/testing/tui.test.ts +73 -0
- package/src/testing/typing.test.ts +65 -0
- package/src/testing/vouch-next.test.ts +65 -0
- package/src/testing/vouch-tui.test.ts +77 -0
- package/src/testing/wash.test.ts +32 -0
- package/src/testing/width.test.ts +62 -0
- package/src/tui/app.ts +467 -0
- package/src/tui/command.ts +390 -0
- package/src/tui/diffview.ts +333 -0
- package/src/tui/index.ts +9 -0
- package/src/tui/marks.ts +102 -0
- package/src/tui/match.ts +34 -0
- package/src/tui/model.ts +310 -0
- package/src/tui/reduce.ts +305 -0
- package/src/tui/render.ts +897 -0
- package/src/tui/report.ts +74 -0
- package/src/tui/session.ts +32 -0
- package/src/tui/theme.ts +61 -0
- package/src/tui/tree.ts +149 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# ADRs — adiff
|
|
2
|
+
|
|
3
|
+
An ADR records a durable technical decision: why adiff runs on the runtime it does, why it is built
|
|
4
|
+
the way it is, why it is tested the way it is. ADRs explain choices that outlive any one feature.
|
|
5
|
+
|
|
6
|
+
- `.agents/prd/` — behavior contracts. What adiff does.
|
|
7
|
+
- `.agents/adr/` — durable technical decisions. Why it is built this way.
|
|
8
|
+
- GitHub issues — implementation work items. How to do a slice now.
|
|
9
|
+
|
|
10
|
+
## Index
|
|
11
|
+
|
|
12
|
+
| ADR | Decision |
|
|
13
|
+
| --- | --- |
|
|
14
|
+
| [ADR-001](ADR-001-node-26-runtime.md) | Node 26 with `--experimental-ffi` as the runtime |
|
|
15
|
+
| [ADR-002](ADR-002-effect-v4-and-module-boundaries.md) | Effect v4, and modules sealed behind `index.ts` |
|
|
16
|
+
| [ADR-003](ADR-003-blackbox-testdriver.md) | Black-box tests through a TestDriver, and no unit tests |
|
|
17
|
+
| [ADR-004](ADR-004-pnpm-native-releases.md) | pnpm's own release tooling instead of Changesets |
|
|
18
|
+
|
|
19
|
+
## Writing one
|
|
20
|
+
|
|
21
|
+
Copy `TEMPLATE.md` to `ADR-NNN-short-title.md`. Every section is required.
|
|
22
|
+
|
|
23
|
+
**Alternatives Considered** is the section that makes an ADR worth writing. An ADR without serious
|
|
24
|
+
alternatives is a description of what happened, not a decision — and it gives a future reader
|
|
25
|
+
nothing to reason with when the context changes.
|
|
26
|
+
|
|
27
|
+
**Revisit When** names the signal that should reopen the question. An ADR with no revisit condition
|
|
28
|
+
is a decision nobody can ever safely revisit.
|
|
29
|
+
|
|
30
|
+
## Status
|
|
31
|
+
|
|
32
|
+
`proposed`, `accepted`, or `superseded by ADR-NNN`. Do not delete a superseded ADR; the reasoning
|
|
33
|
+
that was replaced is part of the record.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# PRDs — adiff
|
|
2
|
+
|
|
3
|
+
Every runtime behavior in adiff is specified as a PRD before code is written. The PRD is the single
|
|
4
|
+
source of truth for what adiff does, what it accepts, what it refuses, and how that is verified.
|
|
5
|
+
|
|
6
|
+
PRDs are not the place for every implementation detail. Use the split below:
|
|
7
|
+
|
|
8
|
+
- `.agents/prd/` — stable behavior contracts.
|
|
9
|
+
- GitHub issues — implementation work items: file paths, helper names, test names, order.
|
|
10
|
+
- `.agents/adr/` — durable technical decisions: runtime, framework, testing strategy.
|
|
11
|
+
|
|
12
|
+
## How to read these PRDs
|
|
13
|
+
|
|
14
|
+
- Start with `000-overview.md`. It states the problem adiff exists for, maps every PRD onto the
|
|
15
|
+
module that owns the behavior, and lists the cross-cutting concerns every PRD inherits.
|
|
16
|
+
- Read `CONTEXT.md` next. The glossary defines the vocabulary every PRD reuses. adiff has a short
|
|
17
|
+
language on purpose; a synonym invented in a PRD is a defect.
|
|
18
|
+
- Read the PRD that owns the behavior. Follow its links to ADRs for durable choices and issues for
|
|
19
|
+
implementation steps.
|
|
20
|
+
|
|
21
|
+
## How to write a new PRD
|
|
22
|
+
|
|
23
|
+
1. Copy `TEMPLATE.md` to the next free slot, for example `010-tool-something.md`.
|
|
24
|
+
2. Use the glossary from `CONTEXT.md`. Add new terms there instead of inventing them in the PRD.
|
|
25
|
+
3. Fill in every section. "None, because …" is a valid answer; a blank section is not.
|
|
26
|
+
4. Keep detail that will change quickly — file paths, helper names, function signatures, rollout
|
|
27
|
+
order — out of the PRD. Put it in GitHub issues.
|
|
28
|
+
5. Keep durable runtime or architecture rationale out of the PRD. Put it in `.agents/adr/`.
|
|
29
|
+
6. If the PRD defers a decision, say so in **Implementation Decisions** and name the trigger that
|
|
30
|
+
resolves it.
|
|
31
|
+
7. Add the PRD to the index in `000-overview.md`.
|
|
32
|
+
|
|
33
|
+
## What a PRD is, and isn't
|
|
34
|
+
|
|
35
|
+
A PRD **is**:
|
|
36
|
+
|
|
37
|
+
- A description of the observable behavior of one slice of adiff.
|
|
38
|
+
- A statement of contracts: inputs, outputs, errors, what reaches the agent.
|
|
39
|
+
- A list of acceptance tests framed as behavior, not implementation.
|
|
40
|
+
- A statement of what is out of scope.
|
|
41
|
+
|
|
42
|
+
A PRD **isn't**:
|
|
43
|
+
|
|
44
|
+
- A design document for internal helpers. Those evolve; pin them in code.
|
|
45
|
+
- A line-by-line description of the current implementation. Each decision is justified by the
|
|
46
|
+
problem it solves, never by "this is how it works today".
|
|
47
|
+
- A schedule or a backlog. Those live in GitHub issues.
|
|
48
|
+
- An ADR. Runtime and framework rationale lives in `.agents/adr/`.
|
|
49
|
+
|
|
50
|
+
## Conventions
|
|
51
|
+
|
|
52
|
+
- 3-digit zero-padded prefixes. Gaps are allowed when PRDs merge, split, or retire. Renaming
|
|
53
|
+
breaks cross-links; do not renumber an existing PRD.
|
|
54
|
+
- One PRD per orthogonal concern. Past ~200 lines, move implementation detail to an issue or
|
|
55
|
+
durable rationale to an ADR.
|
|
56
|
+
- Active voice, in terms of "adiff …", "the terminal …", "the agent …" — never "we".
|
|
57
|
+
- Inline domain terms link to `CONTEXT.md` on first use: `[anchor](CONTEXT.md#anchor)`.
|
|
58
|
+
- Every PRD ends with `## Out of Scope` and `## Further Notes`, even when short. They signal
|
|
59
|
+
completeness.
|
|
60
|
+
|
|
61
|
+
## Review checklist
|
|
62
|
+
|
|
63
|
+
Before treating a PRD as ready:
|
|
64
|
+
|
|
65
|
+
- [ ] Problem stated from the reviewer's or the agent's perspective, not the code's.
|
|
66
|
+
- [ ] Solution stated as observable behavior, before any implementation choice is named.
|
|
67
|
+
- [ ] User stories cover the happy path, the empty result, the refusal, and the stale case.
|
|
68
|
+
- [ ] Implementation Decisions are concrete enough that two engineers would build interchangeable
|
|
69
|
+
implementations.
|
|
70
|
+
- [ ] File paths, helper names, and rollout order live in GitHub issues.
|
|
71
|
+
- [ ] Durable runtime or framework rationale lives in `.agents/adr/`.
|
|
72
|
+
- [ ] Testing Decisions describe behavior observable at one of the two boundaries in PRD 008.
|
|
73
|
+
- [ ] Out of Scope names behaviors a reader might expect but this PRD does not cover.
|
|
74
|
+
- [ ] All cross-references resolve.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @eliya-oss/agent-diff
|
|
2
|
+
|
|
3
|
+
## 0.1.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Mark files reviewed from the terminal, with progress in the header and the tree.
|
|
8
|
+
|
|
9
|
+
- Fix the render crash on large diffs; the terminal now owns scrolling. Expandable context, and simulator variants.
|
|
10
|
+
|
|
11
|
+
- Review what is staged before sending it, and send the batch from the terminal.
|
|
12
|
+
|
|
13
|
+
- Navigate a long diff: g/G, half-page scroll, and hunk jumps.
|
|
14
|
+
|
|
15
|
+
- Separate panes with a rule, switch focus with tab, and zoom the diff.
|
|
16
|
+
|
|
17
|
+
- Sticky scope: the whole enclosing chain, read from the file rather than the diff.
|
|
18
|
+
|
|
19
|
+
- Compose shows the code being commented on, takes multiple lines, and can stage.
|
|
20
|
+
|
|
21
|
+
- Review a diff by the argument instead of the filesystem. An agent writes a story over its own
|
|
22
|
+
worktree with `adiff story set`, and the review terminal lists its numbered steps in place of the
|
|
23
|
+
file tree, scoping the diff to the step you are on. adiff computes coverage itself, so the hunks no
|
|
24
|
+
step claims are reported by `adiff story show` and shown to the reviewer under "not in any step".
|
|
25
|
+
|
|
26
|
+
- Own the diff rendering: one parse per file, no highlight flash on scroll.
|
|
27
|
+
|
|
28
|
+
- First alpha of the review terminal and the agent hand-over.
|
|
29
|
+
|
|
30
|
+
- File tree navigation, and GitHub-style review batching with comment stage / review submit.
|
|
31
|
+
|
|
32
|
+
- The branch list shows which branches have work waiting, and refreshes when you return to it.
|
|
33
|
+
|
|
34
|
+
- Simulate large branches, and keep the file list usable at that size.
|
|
35
|
+
|
|
36
|
+
- Per-directory tree folding, with crowded directories closed on open.
|
|
37
|
+
|
|
38
|
+
- Mouse wheel scrolling, drag selection, and a file tree that reads like the prototype's.
|
|
39
|
+
|
|
40
|
+
- ctrl+b writes a bug report with the surrounding context and copies it to the clipboard.
|
|
41
|
+
|
|
42
|
+
- Command palette and sticky scope in the review terminal.
|
|
43
|
+
|
|
44
|
+
- Agent-readable command surface: noun-verb commands, compact JSON, failures on stderr with actionable exit codes, --fields projection, and describe.
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- The pinned scope lines up with the code it names.
|
|
49
|
+
|
|
50
|
+
- Every letter is typeable in a comment, and commented lines are marked in the gutter.
|
|
51
|
+
|
|
52
|
+
- A coherent theme: fewer hues, more contrast levels, semantic names.
|
|
53
|
+
|
|
54
|
+
- Footer chips with key glyphs, a selection readout, and messages that expire.
|
|
55
|
+
|
|
56
|
+
- Pin the right scope, align the sign column and the tree, and say when lines are hidden.
|
|
57
|
+
|
|
58
|
+
- The pinned scope keeps its syntax highlighting; the simulator ships with comments already on it.
|
package/README.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# adiff
|
|
2
|
+
|
|
3
|
+
Review the work an agent did in a git worktree, in the terminal, and hand your comments back to
|
|
4
|
+
the agent that is still sitting in that worktree.
|
|
5
|
+
|
|
6
|
+
You select lines on a diff the way you would on GitHub, write a comment, and the agent working in
|
|
7
|
+
that branch picks it up on its next `adiff take`. No pull request, no browser, no copying file
|
|
8
|
+
paths and line numbers into chat.
|
|
9
|
+
|
|
10
|
+
`comment add` sends immediately; `comment stage` holds a comment back until `review submit` sends
|
|
11
|
+
the whole set as one batch, so the agent wakes once for a review rather than once per remark —
|
|
12
|
+
the difference between a chat message and a pull request review.
|
|
13
|
+
|
|
14
|
+
The surface is built for agents as much as people: compact JSON, failures off stdout, exit codes
|
|
15
|
+
that mean something, and `adiff describe` so a caller can discover the commands instead of being
|
|
16
|
+
told about them.
|
|
17
|
+
|
|
18
|
+
## Requirements
|
|
19
|
+
|
|
20
|
+
Node 26 or newer. adiff draws through opentui, which reaches its native renderer over `node:ffi` —
|
|
21
|
+
a module Node only exposes behind `--experimental-ffi`, and only from 26 onward. Every entry point
|
|
22
|
+
in this repo passes the flag for you.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
corepack disable pnpm
|
|
26
|
+
npm install -g --allow-scripts=pnpm pnpm@next-12
|
|
27
|
+
pnpm install
|
|
28
|
+
pnpm review
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
pnpm 12 is a Rust rewrite and is still beta, so
|
|
32
|
+
[corepack cannot install it](https://pnpm.io/installation) — install it directly, as above. The
|
|
33
|
+
`packageManager` pin in `package.json` stays for CI, which reads it through `pnpm/action-setup`.
|
|
34
|
+
|
|
35
|
+
## Working on the look
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm watch
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Builds the seven-branch workspace once under `~/.cache/adiff/watch`, then runs the terminal under
|
|
42
|
+
`node --watch`. Save a file in `src/` and it restarts, resuming on the same branch, file and line
|
|
43
|
+
you were looking at — the review remembers where you were whenever `ADIFF_SESSION` says where to.
|
|
44
|
+
`pnpm watch --fresh` throws the workspace away and builds it again.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pnpm serve # localhost:4319 — every screen, repainting as you save
|
|
48
|
+
pnpm play # localhost:4320 — the terminal itself, in the browser
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`play` keeps a real review running on the server against the same headless renderer the tests use,
|
|
52
|
+
sends your keys and mouse to it, and paints back what it drew. It is not a mock: the branches are
|
|
53
|
+
real worktrees and a comment written in the browser lands in the store like any other. Dragging
|
|
54
|
+
selects lines, the wheel scrolls, and saving a file in `src/` restarts it on the file you were
|
|
55
|
+
reading.
|
|
56
|
+
|
|
57
|
+
The browser is the fastest way to work on the look: `serve` watches `src/`, recaptures every
|
|
58
|
+
screen in a fresh process on each save, and pushes a reload down an event stream. Colours are the
|
|
59
|
+
real ones, span by span, so a wrong shade shows up instead of hiding in a character dump. Nothing
|
|
60
|
+
of adiff runs in the page — it is a recording, not the terminal.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pnpm sketch # every glyph set, rendered side by side
|
|
64
|
+
pnpm sketch ring dot # just these two
|
|
65
|
+
ADIFF_MARKS=bubble pnpm simulate
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Glyphs live in one place, `src/tui/marks.ts`. `sketch` renders the same diff once per set so a
|
|
69
|
+
choice can be made by looking at it rather than by imagining it.
|
|
70
|
+
|
|
71
|
+
## Trying it
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pnpm simulate
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Builds a throwaway repository with four branches an agent has already worked on — a new error type
|
|
78
|
+
and its call sites, a React panel gaining failure states, a deleted legacy file, a new module, and
|
|
79
|
+
a 42-file migration of just over a thousand lines each way — and opens the terminal on it. Nothing touches your real repos or `~/.adiff`; the
|
|
80
|
+
workspace is a temp directory, removed when you quit.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pnpm simulate --small # drop the large branch
|
|
84
|
+
pnpm simulate --files 80 --lines 40 # bigger still
|
|
85
|
+
pnpm simulate --agent # a fake agent reads your comments as you send them
|
|
86
|
+
pnpm simulate --probe # headless: run the whole round trip, print it, exit
|
|
87
|
+
pnpm simulate --keep # leave the workspace on disk and print its path
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`--probe` is the fastest way to see the product without a terminal:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
branches {"ok":true,"branches":[{"branch":"cdr-42-distinguish-missing-incidents","files":3,"added":18,...
|
|
94
|
+
vouch {"ok":true,"vouched":["src/api/incidents.ts"],"total":3}
|
|
95
|
+
agent takes {"ok":true,"comments":[{"file":"src/api/incidents.ts","side":"new","start":12,"end":13,
|
|
96
|
+
"snippet":" if (res.status === 404) throw new IncidentNotFound(id)\n if (!res.ok) ...",
|
|
97
|
+
"body":"Two throws where one union would do."}]}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Reviewing
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
adiff review open --repo /path/to/repo
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Opens on the worktrees that have something to review. `enter` opens one, `j`/`k` move down the
|
|
107
|
+
diff, `v` starts a selection, `c` writes a comment, `ctrl+s` sends it. `[` and `]` move between
|
|
108
|
+
files, `q` quits. The footer always lists the keys for wherever you are.
|
|
109
|
+
|
|
110
|
+
Everything the terminal does is also a command, so nothing is trapped in the UI:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
adiff branch list --repo .
|
|
114
|
+
adiff comment add --repo . --branch cdr-1 --file src/api.ts --start 4 --end 5 --body "why"
|
|
115
|
+
adiff comment stage --repo . --branch cdr-1 --file src/api.ts --start 4 --end 5 --body "why"
|
|
116
|
+
adiff review submit --repo . --branch cdr-1 # sends the staged comments as one review
|
|
117
|
+
adiff file vouch --repo . --branch cdr-1 --file src/api.ts
|
|
118
|
+
adiff review progress --repo . --branch cdr-1
|
|
119
|
+
adiff story show --worktree . # the story of a diff, and what it skips
|
|
120
|
+
adiff describe # the catalog, as JSON
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Each prints one compact JSON line on stdout and exits 0. Failures go to **stderr** as
|
|
124
|
+
`{"ok":false,"error":{...}}`, so stdout is always parseable, with an exit code saying what to do
|
|
125
|
+
about it: `2` malformed request, `3` not found, `1` unexpected. Every error carries a `suggestion`
|
|
126
|
+
naming the command that resolves it.
|
|
127
|
+
|
|
128
|
+
`--fields` trims the answer to what you actually read:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
adiff branch list --repo . --fields branch,files
|
|
132
|
+
{"ok":true,"branches":[{"branch":"cdr-1","files":3}]}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## The agent side
|
|
136
|
+
|
|
137
|
+
In the worktree being reviewed:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
adiff comment take --worktree . # everything written since the last take
|
|
141
|
+
adiff comment take --worktree . --wait 300 # block until something arrives
|
|
142
|
+
adiff story set --worktree . --json - # the reading order for the work just done
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
A story is an ordered set of steps over the diff — "add the data model", "add the API", "build the
|
|
146
|
+
UI" — each covering spans of files. Where a branch has one, the terminal lists its steps instead of
|
|
147
|
+
the file tree and scopes the diff to the step you are on. adiff computes coverage itself and
|
|
148
|
+
answers with the hunks no step claims, so a story can never hide part of the change: whatever the
|
|
149
|
+
agent left out shows up under `not in any step`.
|
|
150
|
+
|
|
151
|
+
Comments come back with the exact snippet they were written against, so the agent needs no other
|
|
152
|
+
reference. `skills/adiff/SKILL.md` teaches an agent the loop — symlink it into `~/.claude/skills/`
|
|
153
|
+
to make it available everywhere:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
ln -s "$PWD/skills/adiff" ~/.claude/skills/adiff
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Releasing
|
|
160
|
+
|
|
161
|
+
Published as `@eliya-oss/agent-diff`, on the `alpha` lane — so every release is a prerelease under
|
|
162
|
+
the `alpha` dist-tag and nothing reaches `latest` by accident:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
pnpm add -D @eliya-oss/agent-diff@alpha
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Record intent with the change, not at release time.** A change that should ship gets an intent
|
|
169
|
+
in the same commit; the person who knows what changed decides the bump:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
pnpm change @eliya-oss/agent-diff --bump patch --summary "Anchor comments to the right side."
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
That writes a markdown file to `.changeset/`. Commit it with the code.
|
|
176
|
+
|
|
177
|
+
**Check the plan** before merging:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
pnpm change status # the pending intents and what they produce
|
|
181
|
+
pnpm version -r --dry-run # 0.1.0 → 0.1.0-alpha.0
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Merging to `main` does the rest.** The release workflow runs the full check, applies the pending
|
|
185
|
+
intents, publishes under the `alpha` tag, tags the commit, and pushes. With no pending intent it
|
|
186
|
+
does nothing — so `main` is always safe to merge into.
|
|
187
|
+
|
|
188
|
+
There is no publish token. The workflow authenticates to npm over
|
|
189
|
+
[OIDC trusted publishing](https://docs.npmjs.com/trusted-publishers): it requests a short-lived
|
|
190
|
+
identity with `id-token: write`, and npm checks it against a trusted publisher registered on the
|
|
191
|
+
package. Nothing is stored in repository secrets.
|
|
192
|
+
|
|
193
|
+
### Bootstrapping the first release
|
|
194
|
+
|
|
195
|
+
npm cannot create a package through trusted publishing — the settings live on a package that must
|
|
196
|
+
already exist ([npm/cli#8544](https://github.com/npm/cli/issues/8544)). So the first version goes
|
|
197
|
+
out by hand, once:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
npm login
|
|
201
|
+
pnpm version -r # 0.1.0 → 0.1.0-alpha.0, writes the changelog
|
|
202
|
+
pnpm publish --tag alpha # never omit --tag, or it lands on latest
|
|
203
|
+
git commit -am "release 0.1.0-alpha.0" && git tag v0.1.0-alpha.0 && git push --follow-tags
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Then on npmjs.com, under the package's **Settings → Trusted Publisher**, add:
|
|
207
|
+
|
|
208
|
+
| Field | Value |
|
|
209
|
+
| --- | --- |
|
|
210
|
+
| Publisher | GitHub Actions |
|
|
211
|
+
| Organization or user | `Newbie012` |
|
|
212
|
+
| Repository | `agent-diff` |
|
|
213
|
+
| Workflow filename | `release.yml` |
|
|
214
|
+
| Allowed actions | `npm publish` |
|
|
215
|
+
|
|
216
|
+
Every release after that is credential-free. Until the package exists the workflow holds with a
|
|
217
|
+
notice instead of failing, and the hold clears itself once it does.
|
|
218
|
+
|
|
219
|
+
Renaming `release.yml` breaks publishing until the trusted publisher is updated to match.
|
|
220
|
+
|
|
221
|
+
**Leaving alpha** is deliberate, and the only way to reach `latest`:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
pnpm lane main --filter @eliya-oss/agent-diff
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
[ADR-004](.agents/adr/ADR-004-pnpm-native-releases.md) explains why this is not Changesets, and
|
|
228
|
+
records one beta quirk: on a lane, a minor intent at `0.1.0` produces `0.1.0-alpha.0` rather than
|
|
229
|
+
`0.2.0-alpha.0`.
|
|
230
|
+
|
|
231
|
+
## Working on adiff
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
pnpm check # typecheck, lint, style rules, tests
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
adiff is PRD-driven: runtime behavior is specified in `.agents/prd/` before code changes. Start at
|
|
238
|
+
`.agents/prd/000-overview.md` for what adiff is and which PRD owns which behavior, `AGENTS.md` for
|
|
239
|
+
how to make a change, and `ARCHITECTURE.md` for how the code is laid out.
|
package/bin/adiff.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eliya-oss/agent-diff",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"devDependencies": {
|
|
5
|
+
"@effect/vitest": "^4.0.0-beta.102",
|
|
6
|
+
"@types/node": "^26.1.2",
|
|
7
|
+
"oxlint": "^1.76.0",
|
|
8
|
+
"vitest": "^4.1.10"
|
|
9
|
+
},
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"typescript": "^7.0.2"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@opentui/core": "^0.4.5",
|
|
15
|
+
"effect": "^4.0.0-beta.102"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=26"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"adiff": "./bin/adiff.js"
|
|
22
|
+
},
|
|
23
|
+
"version": "0.1.0-alpha.0",
|
|
24
|
+
"description": "Review agent work across git worktrees like a PR, and hand the comments back to the agent.",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/Newbie012/agent-diff.git"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"bin",
|
|
32
|
+
"src",
|
|
33
|
+
"skills",
|
|
34
|
+
"README.md"
|
|
35
|
+
],
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"check": "pnpm run typecheck && pnpm run lint && pnpm test",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"lint": "oxlint && node scripts/check-style.ts",
|
|
43
|
+
"test": "NODE_OPTIONS=--experimental-ffi vitest run",
|
|
44
|
+
"test:watch": "NODE_OPTIONS=--experimental-ffi vitest",
|
|
45
|
+
"dev": "node --experimental-ffi --disable-warning=ExperimentalWarning src/main.ts",
|
|
46
|
+
"review": "pnpm run dev -- review --repo .",
|
|
47
|
+
"simulate": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/simulate.ts",
|
|
48
|
+
"frames": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/frames.ts",
|
|
49
|
+
"sketch": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/sketch.ts",
|
|
50
|
+
"watch": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/watch.ts",
|
|
51
|
+
"serve": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/serve.ts",
|
|
52
|
+
"play": "node --watch --watch-path=src --watch-path=scripts --experimental-ffi --disable-warning=ExperimentalWarning scripts/play.ts"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: adiff
|
|
3
|
+
description: Pick up review comments left on this worktree's diff in the adiff terminal, act on them, and write the story that explains the diff. Use when the user says they left comments, asks you to check adiff, asks you to watch for review feedback, or asks you to hand work over for review.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# adiff
|
|
7
|
+
|
|
8
|
+
A human is reviewing your work in the adiff terminal. When they select lines and comment, the
|
|
9
|
+
comment is filed against this worktree. This skill is how you collect those comments.
|
|
10
|
+
|
|
11
|
+
## Collect what is waiting
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
adiff comment take --worktree .
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Returns one JSON line:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{"ok":true,"comments":[{"at":"2026-07-30T09:12:04.881Z","head":"8e67f663","file":"src/api.ts","side":"new","start":4,"end":5,"snippet":" const third = 3\n return first + second + third","body":"third is unused outside this sum"}]}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Each comment carries the code it is about. `snippet` is the exact text the reviewer had selected,
|
|
24
|
+
`side` says whether the line numbers are in the new file (`new`) or the version being replaced
|
|
25
|
+
(`old`), and `head` is the commit the diff was read at.
|
|
26
|
+
|
|
27
|
+
A comment is handed over exactly once. A second `take` returns only what was written since.
|
|
28
|
+
|
|
29
|
+
## Wait for the next one
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
adiff comment take --worktree . --wait 300
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Blocks until a comment arrives or the timeout in seconds elapses, then returns the same envelope.
|
|
36
|
+
An empty `comments` array means the wait expired with nothing new — that is not an error.
|
|
37
|
+
|
|
38
|
+
## Acting on a comment
|
|
39
|
+
|
|
40
|
+
Read `snippet` before opening the file: the reviewer commented on the diff, and the file may have
|
|
41
|
+
moved on since. If `head` no longer matches `git rev-parse --short HEAD`, the change you are being
|
|
42
|
+
asked about may already be gone — say so rather than guessing at what they meant.
|
|
43
|
+
|
|
44
|
+
Answer the comment by doing the work, not by replying. The reviewer is watching the diff; your
|
|
45
|
+
next commit is the reply. When a comment is a question rather than a request, answer it in the
|
|
46
|
+
commit message of the change it concerns, or plainly in chat if no change is needed.
|
|
47
|
+
|
|
48
|
+
Handle every comment in the batch before taking again.
|
|
49
|
+
|
|
50
|
+
## Failure
|
|
51
|
+
|
|
52
|
+
Failures go to **stderr**, never stdout, so stdout is always safe to parse. The shape is
|
|
53
|
+
`{"ok":false,"error":{"type":"...","retriable":false,"suggestion":"..."}}`, and the exit code says
|
|
54
|
+
what kind of problem it is: `2` the request was malformed, `3` the branch or file does not exist,
|
|
55
|
+
`1` something unexpected.
|
|
56
|
+
|
|
57
|
+
Read `suggestion` before doing anything else — it names the command that resolves the failure.
|
|
58
|
+
Retry only when `retriable` is true. `UnknownBranch` means this worktree is not one adiff knows
|
|
59
|
+
about, because the reviewer has not opened it; report that rather than looping.
|
|
60
|
+
|
|
61
|
+
## Handing work over: write the story
|
|
62
|
+
|
|
63
|
+
You know the order the change was built in. The reviewer does not, and rebuilding it by reading
|
|
64
|
+
every file is the most expensive way to learn something you already have. When you finish a piece
|
|
65
|
+
of work, write a **story**: an ordered set of steps over the diff, each one a claim about a span of
|
|
66
|
+
code. The reviewer then walks the argument instead of the filesystem.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
adiff story set --worktree . --json - <<'JSON'
|
|
70
|
+
{
|
|
71
|
+
"summary": "Team invitations, end to end",
|
|
72
|
+
"steps": [
|
|
73
|
+
{
|
|
74
|
+
"title": "Add the invitation data model",
|
|
75
|
+
"note": "The record every later step leans on",
|
|
76
|
+
"spans": [{ "path": "src/db/invites.ts", "start": 1, "end": 48 }]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"title": "Add the invitation API",
|
|
80
|
+
"spans": [
|
|
81
|
+
{ "path": "src/api/invites.ts", "start": 1, "end": 96 },
|
|
82
|
+
{ "path": "src/api/router.ts", "start": 12, "end": 14 }
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"title": "Build the invite & members UI",
|
|
87
|
+
"spans": [{ "path": "src/ui/Members.tsx", "start": 1, "end": 210 }]
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
JSON
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Rules that make a story worth reading:
|
|
95
|
+
|
|
96
|
+
- **Order is the point.** Step 1 is what the reader must understand before step 2 makes sense.
|
|
97
|
+
Data model, then the code that uses it, then the surface, then the mechanical bits last.
|
|
98
|
+
- **A title is a claim, not a file name.** "Add the invitation API", never "changes to
|
|
99
|
+
src/api/invites.ts".
|
|
100
|
+
- **Line numbers are the new side of the diff**, the same numbers `adiff comment take` reports.
|
|
101
|
+
- **Cover everything.** adiff computes coverage itself and answers with the hunks no step claims;
|
|
102
|
+
those show up for the reviewer under "not in any step" whatever you do. A story that quietly
|
|
103
|
+
skips a third of the diff is worse than no story, so put the leftovers in a final step and say
|
|
104
|
+
they are mechanical.
|
|
105
|
+
|
|
106
|
+
The answer to `story set` is the honest report — check it before you claim to be done:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{"ok":true,"story":{"version":1,"stale":false,"covered":7,"total":9,"uncovered":[{"path":"src/api/router.ts","start":40,"end":52}],"vanished":[],"steps":[{"title":"Add the invitation data model","files":["src/db/invites.ts"]}]}}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`covered`/`total` count hunks. `uncovered` names the ones no step claims — claim them and set the
|
|
113
|
+
story again. `vanished` names paths a step points at that this branch does not change, which
|
|
114
|
+
usually means a typo in a path. Read it back at any time with:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
adiff story show --worktree . --fields covered,total,uncovered
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Setting a story again supersedes the previous one and bumps `version`; the story records the commit
|
|
121
|
+
it was written for, and adiff reports it as `stale` once the branch moves past that commit. After
|
|
122
|
+
you address a review, write the story again.
|
|
123
|
+
|
|
124
|
+
## Discovering the rest
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
adiff describe
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Returns every command with its options, which are required, and where its payload sits. Use it
|
|
131
|
+
instead of guessing, and use `--fields` to keep answers small:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
adiff branch list --repo . --fields branch,files
|
|
135
|
+
```
|