@eliya-oss/agent-diff 0.1.0-alpha.19 → 0.1.0-alpha.190

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,162 @@
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
+ - each step is held for a second, with a band naming it in plain words — `open the branch`,
32
+ `leave a comment saying "worth a second look"` — and a key cap in the corner showing the key as it
33
+ is pressed, so the caption, the key and what happens on screen line up
34
+ - every `expect` stops the screen, rings the pane it is about, and says the claim as a sentence:
35
+ `the review panel contains worth a second look`
36
+
37
+ The sentence names its own subject, which is why it needs no label. Assertions running one after
38
+ another with nothing in between share a beat and the band lists them; assertions separated by
39
+ something the reviewer does each get their own. `--pace <ms>` and `--hold <ms>` change the timings.
40
+
41
+ The ring comes from the view accessor the assertion read — `reviewPanel()` rings the review panel,
42
+ `focus()` rings whichever pane the keys reach. An assertion about no single region, such as which
43
+ panes are on screen, gets the sentence and no ring.
44
+
45
+ For the caption to appear, the test must take `expect` from the testing barrel rather than from
46
+ vitest directly. A test that does not still records; it just has no captions.
47
+
48
+ The recording is driven by the test's own trace, so it cannot show something the test does not do. If
49
+ a test fails, nothing is recorded — a green run is the precondition, not a claim to make in prose.
50
+
51
+ ## A recording replays keys, and nothing else
52
+
53
+ The replay rebuilds the world from the trace — the branch fixture and the layers, and nothing more —
54
+ then presses the keys. Anything a test does by another route is not there: a file changed or
55
+ committed after the world was built, a comment or an answer seeded through the store or the command
56
+ line, a preference set from outside. A test that does any of those marks its trace unreplayable, and
57
+ `pnpm record` skips it and says which route it took.
58
+
59
+ So a test that needs one of those things has two honest endings, and no third:
60
+
61
+ - **Write it with keys instead**, if the same rule can be reached that way. A reviewer's reply
62
+ exercises the same drawing rule an agent's answer does, and a reply is keys. That test records.
63
+ - **Let it be skipped**, and say in the PR body which behavior has no film and why.
64
+
65
+ **Never paste a recording you have not looked at.** Take the still of the same trace and read it:
66
+
67
+ ```bash
68
+ pnpm shot --trace <trace.jsonl> --test-name "<when> > <then>" --local
69
+ ```
70
+
71
+ `--local` writes the frame to `shots/` and uploads nothing, so reading it first publishes nothing.
72
+ Leave `--local` off once the frame is the one you meant, and the capture uploads and prints the
73
+ markdown to paste.
74
+
75
+ The still is the last frame of the film. If it does not show the behavior the test names, the film
76
+ does not either — and a film that shows the wrong screen is worse than no film, because a reviewer
77
+ believes it. `pnpm record` writes its trace to a temp directory and prints the path in its error
78
+ output; to keep one, run the tests yourself with `ADIFF_TRACE=<path>` set.
79
+
80
+ A run appends to that file rather than replacing it, so running the same test into it twice leaves
81
+ two traces under one name. The capture takes the newest, so a re-run shows the re-run. A trace the
82
+ test marked unreplayable is refused, naming the route the test took, so nothing is uploaded from it.
83
+
84
+ ## What gets recorded
85
+
86
+ Every test the branch adds, one recording each, not a representative sample. Skip only when the
87
+ branch changes nothing a reviewer could see: a refactor, a type, a script, a document.
88
+
89
+ A test that presses no keys produces no recording, which is the right answer for a pure CLI or store
90
+ test. Do not invent keystrokes to make one.
91
+
92
+ ## The section it prints
93
+
94
+ ```markdown
95
+ ## Recorded tests
96
+
97
+ - when the review panel is opened
98
+
99
+ <details>
100
+ <summary><code>then the keys are already on the comments</code></summary>
101
+
102
+ <bare user-attachments URL>
103
+
104
+ </details>
105
+ ```
106
+
107
+ The `describe` is the plain-text list item and the `test` is the summary of a `<details>` nested
108
+ under it, indented two spaces so it stays inside the item. Two tests under one `when` share the list
109
+ item.
110
+
111
+ Leave the URL bare. GitHub wraps a player around a user-attachments URL on its own line; image
112
+ markdown (`![…](…)`) around a video renders nothing. The summary is the test title only — no
113
+ duration, no dimensions, no file size.
114
+
115
+ ## Where it goes
116
+
117
+ After the prose and after `## What changed`, before anything else. A reviewer reads what changed,
118
+ then watches it.
119
+
120
+ ## The whole template
121
+
122
+ ```markdown
123
+ ### What changed
124
+
125
+ <one paragraph, 200-300 characters, high level, technical>
126
+
127
+ ### Recorded tests
128
+
129
+ <the pnpm record section, when the branch adds tests that press keys>
130
+ ```
131
+
132
+ Two headings, in that order, and nothing else: no prose above `### What changed`, no "why", no
133
+ investigation, no test counts. A branch with no recordings carries the first heading alone.
134
+
135
+ ## Check the body before it is posted
136
+
137
+ ```bash
138
+ pnpm check-body body.md
139
+ ```
140
+
141
+ Run it on the file you are about to pass to `gh pr create --body-file` or `gh pr edit --body-file`,
142
+ every time. It refuses a body that says who reported the change, places it with somebody at work,
143
+ carries a private repository or a ticket, or runs past 300 characters of prose. A body says what
144
+ changed and what it does now — never who asked for it.
145
+
146
+ ## Nothing private, ever
147
+
148
+ This repository is public and so is every attachment. `pnpm record` is safe by construction: it
149
+ builds each world from the test's own fixture, which is invented code in an invented repository, and
150
+ it never opens a real one. Keep it that way — never point a capture at a real checkout, and never
151
+ paste a branch name, path, ticket id or line of source from private work into a body.
152
+
153
+ An attachment cannot be deleted once uploaded.
154
+
155
+ ## Before it will work
156
+
157
+ ```bash
158
+ cargo install --locked terminal-control # once
159
+ gh extension install drogers0/gh-image # once, then `gh image check-token`
160
+ ```
161
+
162
+ `termctrl` lives in `~/.cargo/bin`, which is not always on the PATH of a non-interactive shell.
@@ -0,0 +1,318 @@
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
+ ### The template
213
+
214
+ A body is two headings and nothing else:
215
+
216
+ ```markdown
217
+ ### What changed
218
+
219
+ <one paragraph, 200-300 characters, high level, technical>
220
+
221
+ ### Recorded tests
222
+
223
+ <what pnpm record printed>
224
+ ```
225
+
226
+ ### The body says what changed, and nothing about who asked
227
+
228
+ A body is the change, not its history. Two rules, and a command that enforces both:
229
+
230
+ - **Never say who reported it.** Not a name, not "a teammate", not "a user", not "somebody on the
231
+ team". Who found a defect is private to the people who found it, and it changes nothing about the
232
+ fix. Write what broke and what it does now. "Guy reported it" is the sentence this rule exists to
233
+ stop, and it reached a public PR once already.
234
+ - **Say it in 300 characters or fewer.** What changed, in the plain case, technical. Not the
235
+ investigation, not the reasoning, not what it felt like to find.
236
+
237
+ ```bash
238
+ pnpm check-body <path-to-body.md> # before every gh pr create and gh pr edit
239
+ ```
240
+
241
+ It refuses a body that names who asked, places the defect with somebody at work, carries a private
242
+ repository or a ticket, or runs past 300 characters of prose, and it proves each refusal on its own
243
+ fixtures before it reads yours. `pnpm lint` runs the same rules over every change intent, the wiki,
244
+ the PRDs, the changelog and the README, so nothing in the repository can carry them either.
245
+
246
+ ### Nothing private, ever
247
+
248
+ This repository is public, and so is every PR body, screenshot and recording attached to it. Before
249
+ you open or edit a PR, read what you wrote and confirm none of it carries:
250
+
251
+ - an employer's or a customer's name, or a private repository's name
252
+ - a ticket id, an internal URL, a dashboard link, or an internal hostname
253
+ - a real branch name, file path, or line of source from private work
254
+ - a colleague's name or address, or any credential, token or key
255
+ - who reported the bug, in any words at all
256
+
257
+ A screenshot leaks all of this faster than prose does, which is why **every capture runs against the
258
+ synthetic demo repository** — `scripts/simulate.ts` builds a repo of invented invitation code with
259
+ invented branch names. Never screenshot a review of real work. If you cannot reproduce a bug on the
260
+ synthetic repo, describe it instead, or seed what you need in `scripts/simulation/seed.ts`.
261
+
262
+ An attachment cannot be deleted once uploaded. There is no public deletion API for
263
+ user-attachments, so a leak is permanent.
264
+
265
+ ### Showing a screen
266
+
267
+ adiff is a terminal, so a screenshot is a real PNG of a real terminal, captured with
268
+ [terminal-control](https://github.com/anomalyco/terminal-control) and uploaded to GitHub's
269
+ attachment store.
270
+
271
+ ```bash
272
+ cargo install --locked terminal-control # once
273
+ gh extension install drogers0/gh-image # once, then `gh image check-token`
274
+ ```
275
+
276
+ **Something new** gets one image:
277
+
278
+ ```bash
279
+ pnpm shot --keys "enter text:l" --label "a layer opened"
280
+ ```
281
+
282
+ **Something that changed** gets a before and an after, in a one-row table so the two sit side by
283
+ side rather than a screen apart:
284
+
285
+ ```bash
286
+ pnpm shot --keys "enter text:l" --label "the layers rail" --against origin/main
287
+ ```
288
+
289
+ `--against` builds a worktree at the merge base, captures the same keystrokes on the code as it was,
290
+ and prints the finished `<table>` with both images uploaded. Paste it under the section it belongs
291
+ to. If the two frames come out identical the script says so and stops — those keys do not reach the
292
+ screen you changed.
293
+
294
+ **Something about motion** — scroll feel, focus moving, a gap opening ten lines at a time — gets a
295
+ recording, because a still frame cannot show it:
296
+
297
+ ```bash
298
+ pnpm shot --keys "enter text:l text:l text:l" --label "the gap opening" --video
299
+ ```
300
+
301
+ That prints a bare URL. Leave it bare: GitHub wraps a player around a user-attachments URL on its
302
+ own line, and `![…](…)` image markdown around a video renders nothing.
303
+
304
+ Keys are termctrl's: `enter`, `escape`, `tab`, `up`, `down`, `page-up`, `ctrl-a` through `ctrl-z`,
305
+ and `text:<value>` for anything typed, including single letters like `text:l`. Add `--keep` to leave
306
+ the files in `shots/` instead of deleting them after upload.
307
+
308
+ ## Before you open the PR
309
+
310
+ ```bash
311
+ node scripts/changelog.ts # rewrites CHANGELOG.md from every change intent
312
+ node scripts/changelog.ts 0.1.0-alpha.133 # prints one release's note, as the release page shows it
313
+ node scripts/pr-summary.ts # prints the `## What changed` block for this branch
314
+ ```
315
+
316
+ `CHANGELOG.md` is regenerated by the release workflow, so it does not need to be committed with the
317
+ change intent — but run the generator and read the output. If your entry looks wrong there, it will
318
+ look wrong on the release page.