@eliya-oss/agent-diff 0.1.0-alpha.15 → 0.1.0-alpha.150

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.
@@ -15,6 +15,9 @@ the way it is, why it is tested the way it is. ADRs explain choices that outlive
15
15
  | [ADR-002](ADR-002-effect-v4-and-module-boundaries.md) | Effect v4, and modules sealed behind `index.ts` |
16
16
  | [ADR-003](ADR-003-blackbox-testdriver.md) | Black-box tests through a TestDriver, and no unit tests |
17
17
  | [ADR-004](ADR-004-pnpm-native-releases.md) | pnpm's own release tooling instead of Changesets |
18
+ | [ADR-005](ADR-005-a-mechanical-style-contract.md) | Style is a lint rule, not a document |
19
+ | [ADR-006](ADR-006-the-terminal-runs-on-effect.md) | The terminal runs on Effect |
20
+ | [ADR-007](ADR-007-model-with-effect-not-only-run-on-it.md) | Model with Effect, not only run on it |
18
21
 
19
22
  ## Writing one
20
23
 
@@ -0,0 +1,137 @@
1
+ ---
2
+ name: create-pr
3
+ description: Open or update an adiff pull request — a short body, a change intent, and a recording of every test the branch adds, embedded inline via GitHub user-attachments. Use when asked to create, update or fix up a PR in this repository.
4
+ ---
5
+
6
+ # Create an adiff PR
7
+
8
+ Load `release-notes` first and apply every rule in it: the change intent shape, the `kind(area):`
9
+ sentence, the no-gerund rule, and what never goes in a body. Everything here is additive.
10
+
11
+ A reviewer of an adiff PR wants two things: one line saying what changed, and a moving picture of it
12
+ working. The body carries the first. `pnpm record` carries the second.
13
+
14
+ ## One command
15
+
16
+ ```bash
17
+ pnpm record
18
+ ```
19
+
20
+ It reads the test files this branch changed against `origin/main`, runs them with tracing on, and for
21
+ each test builds its world into a real repository, boots adiff in a real terminal, replays the keys
22
+ the test pressed, encodes an mp4 and uploads it. It prints a finished `## Recorded tests` section.
23
+ Paste that under the body.
24
+
25
+ `pnpm record --test <path>` records one file instead of the whole branch. `pnpm record --base
26
+ <branch>` reads the branch against something other than `origin/main`, which is what a PR stacked on
27
+ another PR needs so it records only its own tests.
28
+
29
+ A recording narrates itself, so somebody who has never opened adiff can follow it:
30
+
31
+ - it opens on a title card carrying the test's `when` and `then`
32
+ - each step is held for a second, with a band naming it in plain words — `open the branch`,
33
+ `leave a comment saying "worth a second look"` — and a key cap in the corner showing the key as it
34
+ is pressed, so the caption, the key and what happens on screen line up
35
+ - every `expect` stops the screen, rings the pane it is about, and says the claim as a sentence:
36
+ `the review panel contains worth a second look`
37
+
38
+ The sentence names its own subject, which is why it needs no label. Assertions running one after
39
+ another with nothing in between share a beat and the band lists them; assertions separated by
40
+ something the reviewer does each get their own. `--pace <ms>` and `--hold <ms>` change the timings.
41
+
42
+ The ring comes from the view accessor the assertion read — `reviewPanel()` rings the review panel,
43
+ `focus()` rings whichever pane the keys reach. An assertion about no single region, such as which
44
+ panes are on screen, gets the sentence and no ring.
45
+
46
+ For the caption to appear, the test must take `expect` from the testing barrel rather than from
47
+ vitest directly. A test that does not still records; it just has no captions.
48
+
49
+ The recording is driven by the test's own trace, so it cannot show something the test does not do. If
50
+ a test fails, nothing is recorded — a green run is the precondition, not a claim to make in prose.
51
+
52
+ ## A recording replays keys, and nothing else
53
+
54
+ The replay rebuilds the world from the trace — the branch fixture and the layers, and nothing more —
55
+ then presses the keys. Anything a test does by another route is not there: a file changed or
56
+ committed after the world was built, a comment or an answer seeded through the store or the command
57
+ line, a preference set from outside. A test that does any of those marks its trace unreplayable, and
58
+ `pnpm record` skips it and says which route it took.
59
+
60
+ So a test that needs one of those things has two honest endings, and no third:
61
+
62
+ - **Write it with keys instead**, if the same rule can be reached that way. A reviewer's reply
63
+ exercises the same drawing rule an agent's answer does, and a reply is keys. That test records.
64
+ - **Let it be skipped**, and say in the PR body which behavior has no film and why.
65
+
66
+ **Never paste a recording you have not looked at.** Take the still of the same trace and read it:
67
+
68
+ ```bash
69
+ pnpm shot --trace <trace.jsonl> --test-name "<when> > <then>" --local
70
+ ```
71
+
72
+ `--local` writes the frame to `shots/` and uploads nothing, so reading it first publishes nothing.
73
+ Leave `--local` off once the frame is the one you meant, and the capture uploads and prints the
74
+ markdown to paste.
75
+
76
+ The still is the last frame of the film. If it does not show the behavior the test names, the film
77
+ does not either — and a film that shows the wrong screen is worse than no film, because a reviewer
78
+ believes it. `pnpm record` writes its trace to a temp directory and prints the path in its error
79
+ output; to keep one, run the tests yourself with `ADIFF_TRACE=<path>` set.
80
+
81
+ A run appends to that file rather than replacing it, so running the same test into it twice leaves
82
+ two traces under one name. The capture takes the newest, so a re-run shows the re-run. A trace the
83
+ test marked unreplayable is refused, naming the route the test took, so nothing is uploaded from it.
84
+
85
+ ## What gets recorded
86
+
87
+ Every test the branch adds, one recording each, not a representative sample. Skip only when the
88
+ branch changes nothing a reviewer could see: a refactor, a type, a script, a document.
89
+
90
+ A test that presses no keys produces no recording, which is the right answer for a pure CLI or store
91
+ test. Do not invent keystrokes to make one.
92
+
93
+ ## The section it prints
94
+
95
+ ```markdown
96
+ ## Recorded tests
97
+
98
+ - when the review panel is opened
99
+
100
+ <details>
101
+ <summary><code>then the keys are already on the comments</code></summary>
102
+
103
+ <bare user-attachments URL>
104
+
105
+ </details>
106
+ ```
107
+
108
+ The `describe` is the plain-text list item and the `test` is the summary of a `<details>` nested
109
+ under it, indented two spaces so it stays inside the item. Two tests under one `when` share the list
110
+ item.
111
+
112
+ Leave the URL bare. GitHub wraps a player around a user-attachments URL on its own line; image
113
+ markdown (`![…](…)`) around a video renders nothing. The summary is the test title only — no
114
+ duration, no dimensions, no file size.
115
+
116
+ ## Where it goes
117
+
118
+ After the prose and after `## What changed`, before anything else. A reviewer reads what changed,
119
+ then watches it.
120
+
121
+ ## Nothing private, ever
122
+
123
+ This repository is public and so is every attachment. `pnpm record` is safe by construction: it
124
+ builds each world from the test's own fixture, which is invented code in an invented repository, and
125
+ it never opens a real one. Keep it that way — never point a capture at a real checkout, and never
126
+ paste a branch name, path, ticket id or line of source from private work into a body.
127
+
128
+ An attachment cannot be deleted once uploaded.
129
+
130
+ ## Before it will work
131
+
132
+ ```bash
133
+ cargo install --locked terminal-control # once
134
+ gh extension install drogers0/gh-image # once, then `gh image check-token`
135
+ ```
136
+
137
+ `termctrl` lives in `~/.cargo/bin`, which is not always on the PATH of a non-interactive shell.
@@ -0,0 +1,283 @@
1
+ ---
2
+ name: release-notes
3
+ description: Write the change intent, the PR description and the release note for a change to adiff. Use when opening a PR here, when adding or editing a file in .changeset/, when asked to fix up a PR body or a release note, or when deciding whether a change is worth a release at all.
4
+ ---
5
+
6
+ # Release notes for adiff
7
+
8
+ Every release note in this repo comes from one place: a change intent file in `.changeset/`.
9
+ `scripts/changelog.ts` reads those files, groups them, and writes `CHANGELOG.md` and the text on
10
+ the GitHub release page. Nothing else is edited by hand — do not edit `CHANGELOG.md` yourself.
11
+
12
+ A reader of a release note wants two things in this order: **which part of adiff changed**, and
13
+ **what it does now**. Give them that in one sentence. Everything else goes behind a fold.
14
+
15
+ ## Does this change deserve a release at all?
16
+
17
+ Only four kinds of change ship a note:
18
+
19
+ | Kind | Write it as | Lands under |
20
+ | --- | --- | --- |
21
+ | Something adiff could not do before | `feat(area): …` | `### Added` |
22
+ | Something adiff did wrong | `fix(area): …` | `### Fixed` |
23
+ | Something measurably faster or smaller | `perf(area): …` | `### Performance` |
24
+ | Something that changes what an existing command or key means | `breaking(area): …` | `### Breaking` |
25
+
26
+ **A refactor, a test, a doc, a CI change or a rename gets no change intent file.** No file, no
27
+ version bump, no note. If the change is invisible to a reviewer using adiff, it is invisible in the
28
+ changelog too. Say so in the PR body instead. A PR that touches only `src/testing/`, `.agents/`,
29
+ `.github/`, `README.md` or `ARCHITECTURE.md` almost never needs one.
30
+
31
+ If you are unsure, ask: would someone who upgraded notice? If no, no file.
32
+
33
+ ## The shape of a change intent
34
+
35
+ `.changeset/<name>.md`. Name it the way you would name the test: the sentence, kebab-cased, no
36
+ gerund — `a-file-with-an-accent.md`, not `keeping-a-file-with-an-accent.md`. The bump is `patch`
37
+ until this reaches 1.0, whatever the kind says.
38
+
39
+ `.changeset/` holds only what has not shipped yet, so it is usually empty or nearly so. A release
40
+ collects the intents it consumed and deletes them — their words live on in `CHANGELOG.md`, and
41
+ `.changeset/ledger.yaml` records which release took which. Do not go looking for a neighbouring
42
+ file to copy; follow this page.
43
+
44
+ ```markdown
45
+ ---
46
+ "@eliya-oss/agent-diff": patch
47
+ ---
48
+
49
+ fix(layers rail): the cursor stays on the rail when you collapse the layer you are reading.
50
+
51
+ <details><summary>What was wrong</summary>
52
+
53
+ Collapsing took the cursor off the whole rail — nothing said where you were, and the layer read
54
+ like one you had not started.
55
+
56
+ </details>
57
+ ```
58
+
59
+ which renders as:
60
+
61
+ ```markdown
62
+ ## 0.1.0-alpha.132
63
+
64
+ ### Fixed
65
+
66
+ - **Layers rail** — the cursor stays on the rail when you collapse the layer you are reading.
67
+
68
+ <details><summary>What was wrong</summary>
69
+ …
70
+ </details>
71
+ ```
72
+
73
+ Rules the generator and `a-changelog-that-says-what-kind-of-change.test.ts` enforce:
74
+
75
+ - The first line of every entry is `kind(area): one sentence.` — a full stop at the end, no
76
+ capital at the start, no line break inside it.
77
+ - `kind` is exactly one of `feat`, `fix`, `perf`, `breaking`.
78
+ - `area` is lowercase, and is capitalised for you when it is rendered. Write `CLI` and `README` in
79
+ the case you want them.
80
+ - Anything between one entry and the next belongs to the entry above it, and is indented under its
81
+ bullet.
82
+
83
+ ## One entry per thing that changed
84
+
85
+ A PR that fixes five things writes **five entries in one file**, not one paragraph covering five.
86
+ This is the single biggest difference from how this repo used to write notes.
87
+
88
+ ```markdown
89
+ fix(layers rail): the cursor stays on the rail when you collapse the layer you are reading.
90
+
91
+ <details>…</details>
92
+
93
+ fix(reading order): a first layer naming no file in the diff opens at the first file, not the last.
94
+
95
+ <details>…</details>
96
+ ```
97
+
98
+ Each one gets its own bullet, under the right heading, and can be found by someone searching for
99
+ the part of adiff it names.
100
+
101
+ ## Naming the area
102
+
103
+ Use the name a reviewer would use for the thing on screen. The ones already in use:
104
+
105
+ `diff` · `file tree` · `layers` · `layers rail` · `reading order` · `review panel` · `footer` ·
106
+ `marks` · `keys` · `search` · `key sheet` · `command palette` · `home screen` · `comment delivery` ·
107
+ `store` · `preferences` · `upgrade` · `CLI` · `changelog`
108
+
109
+ Reuse one before inventing another, and check `.agents/prd/CONTEXT.md` — never invent a word the
110
+ glossary already has.
111
+
112
+ ## The sentence
113
+
114
+ Write what is true **now**, in the present tense, from the reviewer's side of the screen.
115
+
116
+ - `fix(diff): a binary file says it is binary instead of drawing an empty pane.`
117
+ - `feat(search): typing narrows the matches as you type.`
118
+ - `perf(review): opening a 131-file branch takes 1.5s, down from 2.85s.`
119
+
120
+ Not:
121
+
122
+ - ~~`fix(diff): fixed the binary file handling`~~ — says nothing about what a reader will see.
123
+ - ~~`fix(diff): refactored patch parsing so binary blobs short-circuit`~~ — describes the code.
124
+ - ~~`fix(diff): a binary file that adiff cannot show`~~ — a title, not a statement.
125
+
126
+ **No gerund titles.** "Saying what is not there", "Opening onto one branch", "Asking before
127
+ leaving" are all wrong. Write a statement with a verb in it: "a file with no newline is drawn as
128
+ one line, not two". This holds for the sentence, the branch name, the changeset filename, the PR
129
+ title and the test filename.
130
+
131
+ Do not write "says so". It carries no meaning of its own: it borrows the subject clause beside it,
132
+ and the moment the sentence is split across a `describe` and a `test`, or read off a PR page or a
133
+ recording's title card, nothing is left. Name what is said.
134
+
135
+ For `perf`, give both numbers and what they were measured on. A speed claim with no measurement is
136
+ not a release note.
137
+
138
+ ## What goes behind the fold
139
+
140
+ The `<details>` block is for the reader who hits the bug and wants to know it is the one they hit.
141
+ Put the symptom there, in the words someone would use to describe what they saw. Keep it to a
142
+ paragraph or two.
143
+
144
+ Leave it out entirely when the sentence is the whole story — most `feat` entries need nothing.
145
+
146
+ Do not put in it: the file you changed, the function you added, the test you wrote, a count of
147
+ tests, or how long it took you. Those belong in the PR.
148
+
149
+ ## The PR description
150
+
151
+ ### The template
152
+
153
+ ```markdown
154
+ ## What changed
155
+
156
+ ### Fixed
157
+
158
+ - **Layers rail** — the cursor stays on the rail when you collapse the layer you are reading.
159
+ - **Reading order** — a first layer naming no file in the diff opens at the first file, not the last.
160
+
161
+ ### Added
162
+
163
+ - **Search** — typing narrows the matches as you type.
164
+
165
+ ## The rail lost the cursor when you folded the layer you were in
166
+
167
+ The repro, as keys to press. Then what the fix was.
168
+
169
+ <table>
170
+ <tr><th>Before</th><th>After</th></tr>
171
+ <tr>
172
+ <td><img src="https://github.com/user-attachments/assets/…" alt="before"></td>
173
+ <td><img src="https://github.com/user-attachments/assets/…" alt="after"></td>
174
+ </tr>
175
+ </table>
176
+
177
+ ## Reading order opened at the end
178
+
179
+ The repro. Then what the fix was.
180
+ ```
181
+
182
+ - The **title** is the entry sentence without the `kind(area):` prefix, and follows the same
183
+ no-gerund rule.
184
+ - **Nothing comes before `## What changed`.** No opening paragraph, no framing, no "two things a
185
+ reviewer hits". The bullets say what changed; a reader who wants the story reads the section for
186
+ the one that bit them. The template's paragraph is for a PR with no change intent at all.
187
+ - **Every section is two or three sentences.** The repro, then what it does now. A reader deciding
188
+ whether this is their bug does not read a fourth sentence.
189
+ - **`## What changed` is generated, never typed.** `node scripts/pr-summary.ts` prints it from the
190
+ change intents on this branch. The PR and the changelog then cannot drift apart. Commit the
191
+ intent first — the summary is read from the diff against `origin/main`, so an uncommitted file
192
+ is not on the branch yet and the script will say there is nothing to paste.
193
+ - **One `##` section per thing changed**, in the order the bullets list them, titled with the
194
+ symptom rather than the fix. That is what a reader searching their own bug will match on.
195
+ - A PR with **one entry and nothing to reproduce** is a title and a sentence. The template starts
196
+ earning its keep at two. This is about the `##` sections, not about the pictures: a single-entry
197
+ PR that changes a screen still owes a before and an after.
198
+ - A PR with **no change intent** — a refactor, a test, a doc — writes prose. `pnpm pr-summary`
199
+ will tell you there is nothing to paste, and that is the correct answer, not a problem to fix.
200
+
201
+ ### What never goes in a PR body
202
+
203
+ - **Raw command output.** No `ls` listings, no shell transcripts, no stack traces pasted whole.
204
+ Quote the one line that matters.
205
+ - **Backticks around anything a shell would run.** Writing a body in a heredoc executes
206
+ `` `l` `` and pastes its output into your prose. Write the body to a file, then
207
+ `gh pr create --body-file`.
208
+ - **Test counts, timings, or self-assessment.** No "full suite green", no "740 tests", no
209
+ "verified twice". CI says whether the tests pass.
210
+ - **Anything from a private repository.** See below.
211
+
212
+ ### Nothing private, ever
213
+
214
+ This repository is public, and so is every PR body, screenshot and recording attached to it. Before
215
+ you open or edit a PR, read what you wrote and confirm none of it carries:
216
+
217
+ - an employer's or a customer's name, or a private repository's name
218
+ - a ticket id, an internal URL, a dashboard link, or an internal hostname
219
+ - a real branch name, file path, or line of source from private work
220
+ - a colleague's name or address, or any credential, token or key
221
+
222
+ A screenshot leaks all of this faster than prose does, which is why **every capture runs against the
223
+ synthetic demo repository** — `scripts/simulate.ts` builds a repo of invented invitation code with
224
+ invented branch names. Never screenshot a review of real work. If you cannot reproduce a bug on the
225
+ synthetic repo, describe it instead, or seed what you need in `scripts/simulation/seed.ts`.
226
+
227
+ An attachment cannot be deleted once uploaded. There is no public deletion API for
228
+ user-attachments, so a leak is permanent.
229
+
230
+ ### Showing a screen
231
+
232
+ adiff is a terminal, so a screenshot is a real PNG of a real terminal, captured with
233
+ [terminal-control](https://github.com/anomalyco/terminal-control) and uploaded to GitHub's
234
+ attachment store.
235
+
236
+ ```bash
237
+ cargo install --locked terminal-control # once
238
+ gh extension install drogers0/gh-image # once, then `gh image check-token`
239
+ ```
240
+
241
+ **Something new** gets one image:
242
+
243
+ ```bash
244
+ pnpm shot --keys "enter text:l" --label "a layer opened"
245
+ ```
246
+
247
+ **Something that changed** gets a before and an after, in a one-row table so the two sit side by
248
+ side rather than a screen apart:
249
+
250
+ ```bash
251
+ pnpm shot --keys "enter text:l" --label "the layers rail" --against origin/main
252
+ ```
253
+
254
+ `--against` builds a worktree at the merge base, captures the same keystrokes on the code as it was,
255
+ and prints the finished `<table>` with both images uploaded. Paste it under the section it belongs
256
+ to. If the two frames come out identical the script says so and stops — those keys do not reach the
257
+ screen you changed.
258
+
259
+ **Something about motion** — scroll feel, focus moving, a gap opening ten lines at a time — gets a
260
+ recording, because a still frame cannot show it:
261
+
262
+ ```bash
263
+ pnpm shot --keys "enter text:l text:l text:l" --label "the gap opening" --video
264
+ ```
265
+
266
+ That prints a bare URL. Leave it bare: GitHub wraps a player around a user-attachments URL on its
267
+ own line, and `![…](…)` image markdown around a video renders nothing.
268
+
269
+ Keys are termctrl's: `enter`, `escape`, `tab`, `up`, `down`, `page-up`, `ctrl-a` through `ctrl-z`,
270
+ and `text:<value>` for anything typed, including single letters like `text:l`. Add `--keep` to leave
271
+ the files in `shots/` instead of deleting them after upload.
272
+
273
+ ## Before you open the PR
274
+
275
+ ```bash
276
+ node scripts/changelog.ts # rewrites CHANGELOG.md from every change intent
277
+ node scripts/changelog.ts 0.1.0-alpha.133 # prints one release's note, as the release page shows it
278
+ node scripts/pr-summary.ts # prints the `## What changed` block for this branch
279
+ ```
280
+
281
+ `CHANGELOG.md` is regenerated by the release workflow, so it does not need to be committed with the
282
+ change intent — but run the generator and read the output. If your entry looks wrong there, it will
283
+ look wrong on the release page.