@eliya-oss/agent-diff 0.1.0-alpha.2 β†’ 0.1.0-alpha.200

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,111 +2,49 @@
2
2
 
3
3
  # adiff
4
4
 
5
- Review the work an agent did in a git worktree, in your terminal, and hand your comments back to
6
- the agent still sitting in that worktree. You select lines the way you would on GitHub, write a
7
- comment, and the agent picks it up.
5
+ An agent finishes a piece of work and leaves you a diff. adiff puts the conversation on the code:
6
+ you comment on the lines in a terminal, the agent that wrote them answers under your words, and a
7
+ point stays open until you settle it.
8
8
 
9
- <pre align="center">npm i -g @eliya-oss/agent-diff@alpha</pre>
9
+ <pre align="center">brew install Newbie012/tap/adiff</pre>
10
+ <pre align="center">npx skills add Newbie012/agent-diff --skill adiff -g</pre>
10
11
 
11
- </div>
12
-
13
- ## Usage
14
-
15
- ```bash
16
- adiff review open --repo .
17
- adiff branch list --repo . --fields branch,files
18
- adiff comment add --repo . --branch add-teammate-invitations --file src/api/invitations.ts --start 4 --end 5 --body "why"
19
- adiff comment stage --repo . --branch add-teammate-invitations --file src/api/invitations.ts --start 4 --end 5 --body "why"
20
- adiff review submit --repo . --branch add-teammate-invitations
21
- adiff file vouch --repo . --branch add-teammate-invitations --file src/api/invitations.ts
22
- adiff story show --worktree . --fields covered,total,uncovered
23
- adiff describe
24
- ```
25
-
26
- `comment add` reaches the agent right away. `comment stage` holds a comment until `review submit`
27
- sends the whole set as one wake-up, so the agent reads a review rather than a stream of remarks.
28
-
29
- ## Reviewing
30
-
31
- `adiff review open --repo .` lists the worktrees that have something to review. Enter opens one,
32
- `j` and `k` move down the diff, `[` and `]` move between files, `v` starts a selection, `c` writes
33
- a comment, `ctrl+s` sends it and `ctrl+a` adds it to the review instead. `m` marks a file reviewed,
34
- `ctrl+p` finds any command by name, and the footer lists the keys for wherever you are.
35
-
36
- ## The agent side
37
-
38
- In the worktree being reviewed:
12
+ <p align="center"><a href="docs/install.md">Other ways to install</a></p>
39
13
 
40
- ```bash
41
- adiff comment take --worktree . # everything written since the last take
42
- adiff comment take --worktree . --wait 300 # block until something arrives
43
- ```
14
+ <img src="assets/terminal.webp" alt="The adiff worktree list, showing seven branches with their sizes, layers and review state" width="820">
44
15
 
45
- Each comment carries the exact snippet it was written against, the side of the diff, and the commit
46
- the diff was read at, so the agent needs no other reference. A comment is handed over once.
47
-
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
51
- cannot hide code:
16
+ </div>
52
17
 
53
- ```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}]}}
56
- ```
18
+ ### Features
57
19
 
58
- ## Skill
20
+ - ⚑ **Live review** - A comment reaches the agent at once, and it starts work.
21
+ - πŸ’¬ **Answers in place** - The agent replies under your comment, or asks you to decide.
22
+ - 🌿 **Review in parallel** - Keep several agents going from one list of branches.
23
+ - πŸ”— **Pull request remarks** - Turn them on, then accept or dismiss each one without leaving the terminal.
24
+ - πŸ—ΊοΈ **Read in layers** - Follow the agent's own order, or read the diff by file.
59
25
 
60
- ```bash
61
- npx skills add Newbie012/agent-diff --skill adiff
62
- ```
26
+ ### Usage
63
27
 
64
- Teaches an agent the whole loop: collect comments, act on them, write the story.
28
+ 1. Install adiff and its skill with the two commands above.
29
+ 2. In your agent, run `/adiff layer this work and hand it over for review`.
30
+ 3. Comment on the lines. The agent answers under your words, and `?` lists every key.
65
31
 
66
32
  ## Requirements
67
33
 
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.
71
-
72
- pnpm 12 is a Rust rewrite and still in beta, so
73
- [corepack cannot install it](https://pnpm.io/installation):
74
-
75
- ```bash
76
- corepack disable pnpm
77
- npm install -g --allow-scripts=pnpm pnpm@next-12
78
- pnpm install
79
- ```
80
-
81
- `pnpm simulate` builds a throwaway repository with seven branches an agent has already worked on,
82
- from a three-file error type up to a 42-file migration of just over a thousand lines each way, and
83
- opens the terminal on it. Your real repos and `~/.adiff` are untouched, and the workspace is removed
84
- when you quit. `pnpm simulate --probe` runs the whole round trip headless and prints it:
85
-
86
- ```
87
- branches {"ok":true,"branches":[{"branch":"add-teammate-invitations","files":3,"added":27,"removed":2,...
88
- vouch {"ok":true,"vouched":["src/api/incidents.ts"],"total":3}
89
- agent takes {"ok":true,"comments":[{"file":"src/api/incidents.ts","side":"new","start":12,"end":13,
90
- "snippet":" if (res.status === 404) throw new IncidentNotFound(id)\n if (!res.ok) ...",
91
- "body":"Two throws where one union would do."}]}
92
- ```
34
+ The Homebrew formula installs one compiled binary, which draws the terminal itself and needs no Node
35
+ at all. A global npm install runs on Node 22 or newer, and the terminal there needs Node 26: adiff
36
+ finds one among your fnm, nvm, asdf, volta and Homebrew installs and runs the terminal on that, and
37
+ says so when there is none, while every other command runs where you are.
93
38
 
94
39
  ## Notes
95
40
 
96
- Everything the terminal does is also a command, so nothing is trapped in the UI. Each command prints
97
- one compact JSON line on stdout and exits 0, and `--fields` trims the answer to what you read:
98
-
99
- ```bash
100
- adiff branch list --repo . --fields branch,files
101
- {"ok":true,"branches":[{"branch":"add-teammate-invitations","files":3}]}
102
- ```
41
+ adiff is alpha, and one person's tool. Every release goes out under the `alpha` tag.
103
42
 
104
- Failures go to stderr as `{"ok":false,"error":{...}}`, so stdout is always parseable, with an exit
105
- code saying what to do about it: `2` malformed request, `3` not found, `1` unexpected. Every error
106
- carries a `suggestion` naming the command that resolves it, and `adiff describe` returns the whole
107
- catalog as JSON so a caller can discover the commands.
43
+ The [wiki](https://github.com/Newbie012/agent-diff/wiki) is the documentation: installing adiff, a
44
+ walkthrough of one review, every key, the commands an agent runs, and what to do when something goes
45
+ wrong. Its pages are written in `wiki/` in this repository and published from there.
108
46
 
109
- Project docs live in `.agents/`. `AGENTS.md` covers making a change, `ARCHITECTURE.md` how the code
47
+ The project docs live in `.agents/`: `AGENTS.md` covers making a change, `ARCHITECTURE.md` how the code
110
48
  is laid out.
111
49
 
112
50
  ## License
package/bin/adiff.js CHANGED
@@ -1,2 +1,80 @@
1
- #!/usr/bin/env -S node --experimental-ffi --disable-warning=ExperimentalWarning
2
- import "../dist/main.js"
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 watched = () => process.stdout.isTTY && process.stdin.isTTY
31
+
32
+ const drawsTerminal = (argv) => {
33
+ const words = argv.filter((token) => !token.startsWith("--"))
34
+ if (argv.length === 0) return watched()
35
+ return words[0] === "review" && words[1] === "open"
36
+ }
37
+
38
+ const rendersHere = () =>
39
+ process.versions.bun !== undefined ||
40
+ (typeof process.getBuiltinModule === "function" &&
41
+ process.getBuiltinModule("node:ffi") !== undefined)
42
+
43
+ const NODE_DIRECTORY = /^(?:v?\d|node)/
44
+
45
+ const majorOf = (name) => Number(/\d+/.exec(name)?.[0] ?? Number.NaN)
46
+
47
+ const listed = (directory) => {
48
+ try {
49
+ return readdirSync(directory)
50
+ } catch {
51
+ return []
52
+ }
53
+ }
54
+
55
+ const installsUnder = ([root, versions, binary]) =>
56
+ listed(join(root, versions))
57
+ .filter((name) => NODE_DIRECTORY.test(name))
58
+ .map((name) => ({ major: majorOf(name), path: join(root, versions, name, binary) }))
59
+
60
+ const findRuntime = () => {
61
+ if (majorOf(process.versions.node) >= RENDERER_MAJOR) return process.execPath
62
+ const found = SOURCES.flatMap(installsUnder)
63
+ .filter((install) => install.major >= RENDERER_MAJOR && existsSync(install.path))
64
+ .toSorted((a, b) => b.major - a.major)
65
+ return found[0]?.path
66
+ }
67
+
68
+ const relaunch = () => {
69
+ const runtime = findRuntime()
70
+ if (runtime === undefined) {
71
+ process.stderr.write(`${MESSAGE}\n`)
72
+ process.exit(1)
73
+ }
74
+ const args = [...RENDERER_FLAGS, ENTRY, ...process.argv.slice(2)]
75
+ const run = spawnSync(runtime, args, { stdio: "inherit" })
76
+ process.exit(run.status ?? 1)
77
+ }
78
+
79
+ if (drawsTerminal(process.argv.slice(2)) && !rendersHere()) relaunch()
80
+ else await import(ENTRY)
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Max Brunsfeld
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,76 @@
1
+ (comment) @comment
2
+
3
+ (tag_name) @tag
4
+ (nesting_selector) @tag
5
+ (universal_selector) @tag
6
+
7
+ "~" @operator
8
+ ">" @operator
9
+ "+" @operator
10
+ "-" @operator
11
+ "*" @operator
12
+ "/" @operator
13
+ "=" @operator
14
+ "^=" @operator
15
+ "|=" @operator
16
+ "~=" @operator
17
+ "$=" @operator
18
+ "*=" @operator
19
+
20
+ "and" @operator
21
+ "or" @operator
22
+ "not" @operator
23
+ "only" @operator
24
+
25
+ (attribute_selector (plain_value) @string)
26
+
27
+ ((property_name) @variable
28
+ (#match? @variable "^--"))
29
+ ((plain_value) @variable
30
+ (#match? @variable "^--"))
31
+
32
+ (class_name) @property
33
+ (id_name) @property
34
+ (namespace_name) @property
35
+ (property_name) @property
36
+ (feature_name) @property
37
+
38
+ (pseudo_element_selector (tag_name) @attribute)
39
+ (pseudo_class_selector (class_name) @attribute)
40
+ (attribute_name) @attribute
41
+
42
+ (function_name) @function
43
+
44
+ "@media" @keyword
45
+ "@import" @keyword
46
+ "@charset" @keyword
47
+ "@namespace" @keyword
48
+ "@supports" @keyword
49
+ "@keyframes" @keyword
50
+ (at_keyword) @keyword
51
+ (to) @keyword
52
+ (from) @keyword
53
+ (important) @keyword
54
+
55
+ (string_value) @string
56
+ (color_value) @string.special
57
+
58
+ (integer_value) @number
59
+ (float_value) @number
60
+ (unit) @type
61
+
62
+ [
63
+ "#"
64
+ ","
65
+ "."
66
+ ":"
67
+ "::"
68
+ ";"
69
+ ] @punctuation.delimiter
70
+
71
+ [
72
+ "{"
73
+ ")"
74
+ "("
75
+ "}"
76
+ ] @punctuation.bracket