@eliya-oss/agent-diff 0.1.0-alpha.1 → 0.1.0-alpha.10

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.
Files changed (111) hide show
  1. package/.agents/prd/README.md +2 -2
  2. package/CHANGELOG.md +64 -0
  3. package/README.md +21 -11
  4. package/bin/adiff.js +76 -2
  5. package/dist/main.js +15039 -0
  6. package/package.json +8 -6
  7. package/skills/adiff/SKILL.md +40 -18
  8. package/src/cli/catalog.ts +0 -178
  9. package/src/cli/commands.ts +0 -335
  10. package/src/cli/error.ts +0 -44
  11. package/src/cli/index.ts +0 -24
  12. package/src/cli/parse.ts +0 -31
  13. package/src/cli/report.ts +0 -96
  14. package/src/cli/story.ts +0 -223
  15. package/src/domain/narrative/coverage.ts +0 -54
  16. package/src/domain/narrative/index.ts +0 -4
  17. package/src/domain/narrative/model.ts +0 -46
  18. package/src/domain/narrative/version.ts +0 -63
  19. package/src/domain/patch/anchor.ts +0 -40
  20. package/src/domain/patch/index.ts +0 -7
  21. package/src/domain/patch/model.ts +0 -54
  22. package/src/domain/patch/parse.ts +0 -106
  23. package/src/domain/patch/render.ts +0 -48
  24. package/src/domain/patch/sticky.ts +0 -39
  25. package/src/domain/review/index.ts +0 -4
  26. package/src/domain/review/lifecycle.ts +0 -45
  27. package/src/domain/review/model.ts +0 -23
  28. package/src/domain/review/vouch.ts +0 -15
  29. package/src/main.ts +0 -186
  30. package/src/service/git/error.ts +0 -16
  31. package/src/service/git/index.ts +0 -3
  32. package/src/service/git/model.ts +0 -13
  33. package/src/service/git/run.ts +0 -27
  34. package/src/service/git/service.ts +0 -133
  35. package/src/service/store/error.ts +0 -11
  36. package/src/service/store/index.ts +0 -5
  37. package/src/service/store/model.ts +0 -33
  38. package/src/service/store/paths.ts +0 -25
  39. package/src/service/store/service.ts +0 -154
  40. package/src/testing/agent-surface.test.ts +0 -92
  41. package/src/testing/batch.test.ts +0 -93
  42. package/src/testing/branch-state.test.ts +0 -99
  43. package/src/testing/chrome-tone.test.ts +0 -57
  44. package/src/testing/comment-block.test.ts +0 -84
  45. package/src/testing/comment-walk.test.ts +0 -96
  46. package/src/testing/compose-box.test.ts +0 -97
  47. package/src/testing/compose.test.ts +0 -67
  48. package/src/testing/context.test.ts +0 -77
  49. package/src/testing/cursor.test.ts +0 -49
  50. package/src/testing/delivery.test.ts +0 -94
  51. package/src/testing/domains/agent/driver.ts +0 -50
  52. package/src/testing/domains/agent/index.ts +0 -2
  53. package/src/testing/domains/app/driver.ts +0 -168
  54. package/src/testing/domains/app/index.ts +0 -2
  55. package/src/testing/domains/branch/driver.ts +0 -51
  56. package/src/testing/domains/branch/index.ts +0 -3
  57. package/src/testing/domains/branch/model.ts +0 -39
  58. package/src/testing/domains/screen/driver.ts +0 -241
  59. package/src/testing/domains/screen/index.ts +0 -2
  60. package/src/testing/driver.ts +0 -31
  61. package/src/testing/escape.test.ts +0 -56
  62. package/src/testing/focus.test.ts +0 -104
  63. package/src/testing/footer-chips.test.ts +0 -65
  64. package/src/testing/footer.test.ts +0 -64
  65. package/src/testing/gaps.test.ts +0 -47
  66. package/src/testing/highlight.test.ts +0 -49
  67. package/src/testing/home-screen.test.ts +0 -51
  68. package/src/testing/index.ts +0 -4
  69. package/src/testing/inline-comments.test.ts +0 -131
  70. package/src/testing/marks.test.ts +0 -49
  71. package/src/testing/mouse.test.ts +0 -87
  72. package/src/testing/navigate.test.ts +0 -73
  73. package/src/testing/palette.test.ts +0 -68
  74. package/src/testing/pending.test.ts +0 -70
  75. package/src/testing/pin-align.test.ts +0 -37
  76. package/src/testing/progress.test.ts +0 -88
  77. package/src/testing/report.test.ts +0 -83
  78. package/src/testing/resume.test.ts +0 -39
  79. package/src/testing/review.test.ts +0 -181
  80. package/src/testing/roundtrip.test.ts +0 -70
  81. package/src/testing/scale.test.ts +0 -55
  82. package/src/testing/scroll-feel.test.ts +0 -81
  83. package/src/testing/sent-comments.test.ts +0 -106
  84. package/src/testing/state.ts +0 -55
  85. package/src/testing/sticky-removed.test.ts +0 -67
  86. package/src/testing/sticky.test.ts +0 -90
  87. package/src/testing/story-rail.test.ts +0 -122
  88. package/src/testing/story.test.ts +0 -183
  89. package/src/testing/stress.test.ts +0 -74
  90. package/src/testing/tree-collapse.test.ts +0 -108
  91. package/src/testing/tree-rows.test.ts +0 -66
  92. package/src/testing/tree.test.ts +0 -91
  93. package/src/testing/tui.test.ts +0 -73
  94. package/src/testing/typing.test.ts +0 -65
  95. package/src/testing/vouch-next.test.ts +0 -65
  96. package/src/testing/vouch-tui.test.ts +0 -77
  97. package/src/testing/wash.test.ts +0 -32
  98. package/src/testing/width.test.ts +0 -62
  99. package/src/tui/app.ts +0 -467
  100. package/src/tui/command.ts +0 -390
  101. package/src/tui/diffview.ts +0 -333
  102. package/src/tui/index.ts +0 -9
  103. package/src/tui/marks.ts +0 -102
  104. package/src/tui/match.ts +0 -34
  105. package/src/tui/model.ts +0 -310
  106. package/src/tui/reduce.ts +0 -305
  107. package/src/tui/render.ts +0 -897
  108. package/src/tui/report.ts +0 -74
  109. package/src/tui/session.ts +0 -32
  110. package/src/tui/theme.ts +0 -61
  111. package/src/tui/tree.ts +0 -149
@@ -16,7 +16,7 @@ PRDs are not the place for every implementation detail. Use the split below:
16
16
  - Read `CONTEXT.md` next. The glossary defines the vocabulary every PRD reuses. adiff has a short
17
17
  language on purpose; a synonym invented in a PRD is a defect.
18
18
  - Read the PRD that owns the behavior. Follow its links to ADRs for durable choices and issues for
19
- implementation steps.
19
+ implementation layers.
20
20
 
21
21
  ## How to write a new PRD
22
22
 
@@ -64,7 +64,7 @@ Before treating a PRD as ready:
64
64
 
65
65
  - [ ] Problem stated from the reviewer's or the agent's perspective, not the code's.
66
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.
67
+ - [ ] User layers cover the happy path, the empty result, the refusal, and the stale case.
68
68
  - [ ] Implementation Decisions are concrete enough that two engineers would build interchangeable
69
69
  implementations.
70
70
  - [ ] File paths, helper names, and rollout order live in GitHub issues.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,69 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.10
4
+
5
+ ### Patch Changes
6
+
7
+ - The rail shows a layer's prose block by block, each above the file it introduces.
8
+
9
+ - layers show says a stale layer set needs a new revision.
10
+
11
+ ## 0.1.0-alpha.9
12
+
13
+ ### Patch Changes
14
+
15
+ - A seeded layer covers two files, so the demo shows what a layer spanning files looks like.
16
+
17
+ ## 0.1.0-alpha.8
18
+
19
+ ### Patch Changes
20
+
21
+ - The simulator seeds layers, so a demo run shows them.
22
+
23
+ - The worktree list says whether a branch already has a pull request.
24
+
25
+ ## 0.1.0-alpha.7
26
+
27
+ ### Patch Changes
28
+
29
+ - A layer's prose reads in the diff, above the code it introduces.
30
+
31
+ ## 0.1.0-alpha.6
32
+
33
+ ### Patch Changes
34
+
35
+ - The diff holds still when a trackpad gesture drifts sideways.
36
+
37
+ - The reading order an agent writes is called layers. adiff layers set and adiff layers show replace the story verbs, and the JSON carries layers where it carried steps.
38
+
39
+ - A layer lists the files it covers, and the footer says how to switch between layers and files.
40
+
41
+ ## 0.1.0-alpha.5
42
+
43
+ ### Patch Changes
44
+
45
+ - Wheel bursts move the diff once a frame, the worktree list shows which branches carry a reading order, and a story the branch has moved past says so.
46
+
47
+ - Scrolling with a trackpad settles as soon as your fingers stop.
48
+
49
+ ## 0.1.0-alpha.4
50
+
51
+ ### Patch Changes
52
+
53
+ - Open the lines a diff leaves out one gap at a time with l, and put them away with h.
54
+
55
+ ## 0.1.0-alpha.3
56
+
57
+ ### Patch Changes
58
+
59
+ - Commands run on Node 22 and up, and opening the terminal finds a Node 26 on your machine.
60
+
61
+ ## 0.1.0-alpha.2
62
+
63
+ ### Patch Changes
64
+
65
+ - Ship the CLI as a bundled JavaScript file so a global install runs, and starts in about half the time.
66
+
3
67
  ## 0.1.0-alpha.1
4
68
 
5
69
  ### Patch Changes
package/README.md CHANGED
@@ -6,7 +6,8 @@ Review the work an agent did in a git worktree, in your terminal, and hand your
6
6
  the agent still sitting in that worktree. You select lines the way you would on GitHub, write a
7
7
  comment, and the agent picks it up.
8
8
 
9
- <pre align="center">npm i -g @eliya-oss/agent-diff@alpha</pre>
9
+ <pre align="center">brew install Newbie012/tap/adiff
10
+ npm i -g @eliya-oss/agent-diff@alpha</pre>
10
11
 
11
12
  </div>
12
13
 
@@ -19,7 +20,7 @@ adiff comment add --repo . --branch add-teammate-invitations --file src/api
19
20
  adiff comment stage --repo . --branch add-teammate-invitations --file src/api/invitations.ts --start 4 --end 5 --body "why"
20
21
  adiff review submit --repo . --branch add-teammate-invitations
21
22
  adiff file vouch --repo . --branch add-teammate-invitations --file src/api/invitations.ts
22
- adiff story show --worktree . --fields covered,total,uncovered
23
+ adiff layers show --worktree . --fields covered,total,uncovered
23
24
  adiff describe
24
25
  ```
25
26
 
@@ -33,6 +34,10 @@ sends the whole set as one wake-up, so the agent reads a review rather than a st
33
34
  a comment, `ctrl+s` sends it and `ctrl+a` adds it to the review instead. `m` marks a file reviewed,
34
35
  `ctrl+p` finds any command by name, and the footer lists the keys for wherever you are.
35
36
 
37
+ Where the diff leaves lines out, a row says how many. Put the cursor on it and `l` brings ten of
38
+ them back where you are standing, `h` puts them away again, and the rest of the file stays as small
39
+ as it was. Opened lines are ordinary lines: you can select them and comment on them.
40
+
36
41
  ## The agent side
37
42
 
38
43
  In the worktree being reviewed:
@@ -45,14 +50,14 @@ adiff comment take --worktree . --wait 300 # block until something arrives
45
50
  Each comment carries the exact snippet it was written against, the side of the diff, and the commit
46
51
  the diff was read at, so the agent needs no other reference. A comment is handed over once.
47
52
 
48
- An agent can also record the reading order for its own work as a story: ordered steps over spans of
49
- files, set with `adiff story set --worktree . --json -`. Where a branch has one, the terminal lists
50
- its steps and scopes the diff to the step you are on. adiff computes the coverage itself, so a story
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
51
56
  cannot hide code:
52
57
 
53
58
  ```bash
54
- adiff story show --worktree . --fields covered,total,uncovered
55
- {"ok":true,"story":{"covered":1,"total":3,"uncovered":[{"path":"docs/incidents.md","start":1,"end":6},{"path":"src/api/errors.ts","start":1,"end":11}]}}
59
+ 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}]}}
56
61
  ```
57
62
 
58
63
  ## Skill
@@ -61,13 +66,18 @@ adiff story show --worktree . --fields covered,total,uncovered
61
66
  npx skills add Newbie012/agent-diff --skill adiff
62
67
  ```
63
68
 
64
- Teaches an agent the whole loop: collect comments, act on them, write the story.
69
+ Teaches an agent the whole loop: collect comments, act on them, write the layers.
65
70
 
66
71
  ## Requirements
67
72
 
68
- Node 26 or newer. adiff draws through opentui, which reaches its native renderer over `node:ffi`, a
69
- module Node exposes behind `--experimental-ffi` from 26 onward. Every entry point in this repo
70
- passes the flag for you.
73
+ Either install gives you an `adiff` on your PATH. Brew brings a Node 26 along with it, so
74
+ everything works the moment it finishes.
75
+
76
+ The commands run on Node 22 or newer. The terminal is the one part that wants Node 26: it draws
77
+ through opentui, which reaches its native renderer over `node:ffi`, a module Node exposes behind
78
+ `--experimental-ffi` from 26 onward. When you open the terminal on an older Node, adiff looks for a
79
+ Node 26 among your fnm, nvm, asdf, volta and Homebrew installs and runs the terminal on that, so a
80
+ global npm install keeps working across a version switch.
71
81
 
72
82
  pnpm 12 is a Rust rewrite and still in beta, so
73
83
  [corepack cannot install it](https://pnpm.io/installation):
package/bin/adiff.js CHANGED
@@ -1,2 +1,76 @@
1
- #!/usr/bin/env -S node --experimental-ffi --disable-warning=ExperimentalWarning
2
- import "../src/main.ts"
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process"
3
+ import { existsSync, readdirSync } from "node:fs"
4
+ import { homedir } from "node:os"
5
+ import { join } from "node:path"
6
+ import { fileURLToPath } from "node:url"
7
+
8
+ const RENDERER_FLAGS = ["--experimental-ffi", "--disable-warning=ExperimentalWarning"]
9
+ const RENDERER_MAJOR = 26
10
+ const ENTRY = fileURLToPath(new URL("../dist/main.js", import.meta.url))
11
+
12
+ const home = homedir()
13
+
14
+ const SOURCES = [
15
+ [process.env["FNM_DIR"] ?? join(home, ".local", "share", "fnm"), "node-versions", "installation/bin/node"],
16
+ [join(home, "Library", "Application Support", "fnm"), "node-versions", "installation/bin/node"],
17
+ [process.env["NVM_DIR"] ?? join(home, ".nvm"), "versions/node", "bin/node"],
18
+ [process.env["ASDF_DATA_DIR"] ?? join(home, ".asdf"), "installs/nodejs", "bin/node"],
19
+ [process.env["VOLTA_HOME"] ?? join(home, ".volta"), "tools/image/node", "bin/node"],
20
+ [process.env["HOMEBREW_PREFIX"] ?? "/opt/homebrew", "opt", "bin/node"],
21
+ ["/usr/local", "opt", "bin/node"],
22
+ ]
23
+
24
+ const MESSAGE = [
25
+ "adiff review open draws its terminal through node:ffi, which needs Node 26 or newer.",
26
+ `This is Node ${process.versions.node}, and no Node ${RENDERER_MAJOR} was found on this machine.`,
27
+ "Every other adiff command runs here. Install Node 26 to open the terminal.",
28
+ ].join("\n")
29
+
30
+ const drawsTerminal = (argv) => {
31
+ const words = argv.filter((token) => !token.startsWith("--"))
32
+ return words[0] === "review" && words[1] === "open"
33
+ }
34
+
35
+ const rendersHere = () =>
36
+ typeof process.getBuiltinModule === "function" &&
37
+ process.getBuiltinModule("node:ffi") !== undefined
38
+
39
+ const NODE_DIRECTORY = /^(?:v?\d|node)/
40
+
41
+ const majorOf = (name) => Number(/\d+/.exec(name)?.[0] ?? Number.NaN)
42
+
43
+ const listed = (directory) => {
44
+ try {
45
+ return readdirSync(directory)
46
+ } catch {
47
+ return []
48
+ }
49
+ }
50
+
51
+ const installsUnder = ([root, versions, binary]) =>
52
+ listed(join(root, versions))
53
+ .filter((name) => NODE_DIRECTORY.test(name))
54
+ .map((name) => ({ major: majorOf(name), path: join(root, versions, name, binary) }))
55
+
56
+ const findRuntime = () => {
57
+ if (majorOf(process.versions.node) >= RENDERER_MAJOR) return process.execPath
58
+ const found = SOURCES.flatMap(installsUnder)
59
+ .filter((install) => install.major >= RENDERER_MAJOR && existsSync(install.path))
60
+ .toSorted((a, b) => b.major - a.major)
61
+ return found[0]?.path
62
+ }
63
+
64
+ const relaunch = () => {
65
+ const runtime = findRuntime()
66
+ if (runtime === undefined) {
67
+ process.stderr.write(`${MESSAGE}\n`)
68
+ process.exit(1)
69
+ }
70
+ const args = [...RENDERER_FLAGS, ENTRY, ...process.argv.slice(2)]
71
+ const run = spawnSync(runtime, args, { stdio: "inherit" })
72
+ process.exit(run.status ?? 1)
73
+ }
74
+
75
+ if (drawsTerminal(process.argv.slice(2)) && !rendersHere()) relaunch()
76
+ else await import(ENTRY)