@eliya-oss/agent-diff 0.1.0-alpha.2 → 0.1.0-alpha.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Commands run on Node 22 and up, and opening the terminal finds a Node 26 on your machine.
8
+
3
9
  ## 0.1.0-alpha.2
4
10
 
5
11
  ### 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
 
@@ -65,9 +66,14 @@ Teaches an agent the whole loop: collect comments, act on them, write the story.
65
66
 
66
67
  ## Requirements
67
68
 
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.
69
+ Either install gives you an `adiff` on your PATH. Brew brings a Node 26 along with it, so
70
+ everything works the moment it finishes.
71
+
72
+ The commands run on Node 22 or newer. The terminal is the one part that wants Node 26: it draws
73
+ through opentui, which reaches its native renderer over `node:ffi`, a module Node exposes behind
74
+ `--experimental-ffi` from 26 onward. When you open the terminal on an older Node, adiff looks for a
75
+ Node 26 among your fnm, nvm, asdf, volta and Homebrew installs and runs the terminal on that, so a
76
+ global npm install keeps working across a version switch.
71
77
 
72
78
  pnpm 12 is a Rust rewrite and still in beta, so
73
79
  [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 "../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 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)
package/package.json CHANGED
@@ -16,12 +16,12 @@
16
16
  "@opentui/core": "^0.4.5"
17
17
  },
18
18
  "engines": {
19
- "node": ">=26"
19
+ "node": ">=22"
20
20
  },
21
21
  "bin": {
22
22
  "adiff": "./bin/adiff.js"
23
23
  },
24
- "version": "0.1.0-alpha.2",
24
+ "version": "0.1.0-alpha.3",
25
25
  "description": "Review agent work across git worktrees like a PR, and hand the comments back to the agent.",
26
26
  "license": "MIT",
27
27
  "repository": {
@@ -121,6 +121,20 @@ Setting a story again supersedes the previous one and bumps `version`; the story
121
121
  it was written for, and adiff reports it as `stale` once the branch moves past that commit. After
122
122
  you address a review, write the story again.
123
123
 
124
+ ## Tell the reviewer how to read it
125
+
126
+ The person you are handing work to has to open the review themselves, so end your reply with the
127
+ command and the keys. Name the repository they should point at, which is the repository the
128
+ worktree belongs to:
129
+
130
+ > Open it with `adiff review open --repo <repo>`, then press `enter` on this branch. The sidebar
131
+ > lists the steps in reading order; `j` and `k` move between them and the diff follows. Inside a
132
+ > step, `]` and `[` walk its files. Select lines with `v`, write a comment with `c`, stage it with
133
+ > `ctrl+a`, and send the whole review with `S`. Press `?` for the rest.
134
+
135
+ Say what you want looked at hardest, and where you are unsure. A reviewer who knows which step you
136
+ doubt spends their attention there.
137
+
124
138
  ## Discovering the rest
125
139
 
126
140
  ```bash