@redue/cli 0.1.0-alpha.21 → 0.1.0-alpha.23

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,72 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.0-alpha.23 — 2026-10-26
4
+
5
+ One command to set up REDUE with Claude Code, and one to undo it.
6
+
7
+ - **`redue setup claude`** runs `init` (when there is no
8
+ `redue.config.json`), connects Claude Code, starts the observer, waits for
9
+ it to index the project, and records each check that can qualify once. It
10
+ asks once (`--yes` for no prompts), prints every file it writes, and a
11
+ second run changes nothing. It stops before writing when dependencies are
12
+ not installed or nothing can be set up.
13
+ - **`redue remove`** undoes exactly what setup created: the integration (or
14
+ only this machine's hooks), the observer state, the local ignore line, and
15
+ the config if it is unchanged since setup wrote it. Anything that existed
16
+ before setup stays. Setup notes what it created in the clone's Git
17
+ directory, never in a committed file.
18
+ - **Hooks find REDUE.** The Claude Code hooks name plain `redue` only when
19
+ the `redue` that your shell and a login shell find is this install;
20
+ otherwise they name this install's Node and entry by absolute path, so a
21
+ Claude Code started from an IDE or with a shorter PATH still runs it.
22
+ Checks the hook runs for the agent follow the same rule.
23
+ - `init` keeps a typecheck that runs TypeScript 7's `tsc` (or `tsgo` from
24
+ `@typescript/native-preview`) recording-only and says why. The pnpm and
25
+ Yarn TypeScript recipes refuse TypeScript 7 with a clear reason instead
26
+ of an error from inside the compiler API.
27
+ - The README is rewritten around a 5-minute quickstart, what REDUE covers
28
+ today (census qualifiers) and what it won't do.
29
+ - Known limits, found by the stranger test: a Vitest run writes under
30
+ `node_modules/.vite`, which makes a direct TypeScript typecheck STALE until
31
+ it runs again; an installed file with a second hard link (esbuild's install
32
+ makes one) keeps the test check UNVERIFIED.
33
+
34
+ - Contributors: the census can run every recipe (`--all-recipes`) and
35
+ counts direct TypeScript checks; its unrecorded-program check no longer
36
+ flags Yarn's temporary `node` wrapper; `eval/stranger.mjs` runs fresh
37
+ Claude Code sessions that set REDUE up from the README alone.
38
+
39
+ ## 0.1.0-alpha.22 — 2026-10-25
40
+
41
+ A correctness fix for recorded runs. Earlier alphas could report CURRENT for
42
+ a script that replaced itself with another program.
43
+
44
+ - **Fixed: a script that replaced itself with another program could be
45
+ CURRENT.** Node's `process.execve` (Node 22.15 and later) swaps a process
46
+ for another program under the same PID. The recorder did not see it, so
47
+ that program ran unseen. TypeScript 7's `tsc` does this to start its
48
+ native compiler, so alphas 19 to 21 could report a TypeScript 7 typecheck
49
+ as CURRENT while REDUE saw none of what the compiler did. The general
50
+ recipe and the direct test recipe now judge the new program like any
51
+ program a run starts: TypeScript 7's `tsc` makes the run UNVERIFIED and
52
+ names it. Support for TypeScript 7 is planned.
53
+ - Runs that use Node's bindings with file, network or program access
54
+ (`process.binding('fs')`, `'spawn_sync'` and others), or run Node with
55
+ `--expose-internals`, are UNVERIFIED: the recorder cannot follow them.
56
+ - Direct test recipe: a shell a test starts is read by its command, as in the
57
+ general recipe. One that runs another program before it becomes Node makes
58
+ the run UNVERIFIED.
59
+ - General recipe, on Linux: pnpm 12 writes a file with no name in
60
+ `node_modules` when it rewrites its workspace state, which left the first
61
+ run after an install UNVERIFIED. That file now counts as the run's output
62
+ when the pnpm executable ran and no file has its name. Known limit: another
63
+ program's file with no name there, during such a run, is taken as pnpm's.
64
+ - UNVERIFIED reasons for an input that changed during a run name up to five
65
+ files and a count of the rest.
66
+
67
+ - Contributors: the census traces each run on Linux and flags programs the
68
+ recorder missed.
69
+
3
70
  ## 0.1.0-alpha.21 — 2026-10-25
4
71
 
5
72
  `init` finds more typecheck scripts and no longer stops in large monorepos.
package/README.md CHANGED
@@ -1,229 +1,146 @@
1
1
  # REDUE
2
2
 
3
- Maintainer notice: alpha.4 withdraws automatic npm-launcher applicability.
4
- Npm commands still execute and record historical outcomes, but remain UNVERIFIED.
5
- [Why this changed and how to upgrade without deleting receipts](docs/user/npm-launcher-notice.md).
6
- Alpha.2 users should also review the [receipt correction](docs/user/receipt-selection-notice.md).
3
+ **Know which checks still hold. Redo what's due.**
7
4
 
8
- **Know what still holds. Redo what's due.**
5
+ You or your coding agent ran the typecheck, the linter or the tests. Then the
6
+ code changed, or a new agent session started with no memory of it. REDUE
7
+ records each check's result with the exact inputs it ran on, and tells you and
8
+ your agent whether that result still applies to the code you have now, so a
9
+ check that still holds is not run again and one that is stale is.
9
10
 
10
- You ran the checks. Then the code changed—or a new coding agent started with no
11
- conversation history. Which results can you still use?
11
+ ## Quickstart (about 5 minutes)
12
12
 
13
- REDUE keeps persistent verification state for your codebase so developers and
14
- coding agents can see which previous checks still apply to the code they have now.
15
- It records evidence, not proofs of correctness.
16
-
17
- For a qualified direct-compiler or supported Yarn/pnpm check (ordinary npm scripts are recording-only):
18
-
19
- ```text
20
- $ redue status --sync
21
- ✓ typecheck CURRENT / PASS
22
- ? test UNVERIFIED / PASS
23
- Recording-only: test runtime, transforms and cache inputs need review
24
-
25
- # Later, after a relevant edit:
26
- $ redue explain typecheck
27
- typecheck: STALE / PASS
28
- src/main.ts changed
29
- Relevant inputs changed:
30
- src/main.ts
31
- Due again when verification is needed: redue run "typecheck"
32
- ```
33
-
34
- Agent A verifies and exits. Agent B starts fresh. The receipt is still there;
35
- REDUE checks whether it still applies. Unrelated documentation edits can preserve
36
- it; relevant source edits make it stale. [Run the reproducible demo](docs/contributor/demo.md).
37
-
38
- ## Install the alpha
39
-
40
- The opt-in pilot uses **0.1.0-alpha.18**. Follow the
41
- [fixed-version pilot guide](docs/user/pilot.md) for supported projects, setup,
42
- updates and voluntary feedback. No external usage results are claimed yet.
43
-
44
-
45
- REDUE is published on npm as `@redue/cli`. The installed command is `redue`.
13
+ You need macOS or Linux, Node 22 or 24, Git, Claude Code, and a JavaScript or
14
+ TypeScript project with its dependencies installed (`npm install`,
15
+ `pnpm install` or `yarn`). On Linux, also Python 3.
46
16
 
47
17
  ```sh
48
18
  npm install --global @redue/cli@alpha
19
+ cd your-project
20
+ redue setup claude
49
21
  ```
50
22
 
51
- To test a source candidate, run `npm ci` and `npm pack --json`, then install the
52
- reported tarball filename with `npm install --global ./<filename>`.
53
-
54
- Use a Node installation you own; REDUE does not need administrator privileges.
55
- If a global prefix is not writable, use a user-owned `--prefix` or run the
56
- installed CLI with Node. [Installation and removal](docs/user/getting-started.md)
57
- includes PowerShell and isolated-prefix instructions.
58
-
59
- Inside an existing, trusted Git project with dependencies already installed:
60
-
61
- ```sh
62
- cd my-project
63
- redue init
64
- redue start
65
- redue run typecheck # use a check name printed by init
66
- redue status
67
- ```
23
+ `setup` shows what it will do and asks once (`--yes` skips the question). It
24
+ stops before writing anything if the dependencies are not installed. It:
68
25
 
69
- `init` discovers existing scripts, explains which can qualify and which are
70
- recording-only, and writes a small `redue.config.json`. It never runs your checks
71
- or changes your package manager, source, scripts, or dependencies. Commit the
72
- reviewed project config; local evidence stays outside the checkout.
26
+ - finds your typecheck, lint and test scripts and writes `redue.config.json`
27
+ (it never changes your scripts, source or dependencies). Checks REDUE can
28
+ only record, not reuse, are listed as recording-only;
29
+ - connects Claude Code: a short section in `CLAUDE.md`, a skill, and two hooks
30
+ in `.claude/settings.local.json`;
31
+ - starts REDUE's file observer, waits while it indexes the project (a minute
32
+ or more in a large one), then runs each check that can qualify once, so
33
+ there is a first result to reuse;
34
+ - prints every file it writes. Running it again changes nothing.
73
35
 
74
- Start with ordinary `status`. When it cannot establish caller context, use
75
- `redue status --sync` if that is worthwhile—or just rerun an inexpensive check.
76
- **Synchronization can cost more than rerunning a cheap check, particularly on
77
- Windows.** REDUE does not choose or execute that tradeoff for you.
36
+ Then start a new Claude Code session in the project and work as usual. When
37
+ the agent is about to rerun a check whose last pass still applies, the hook
38
+ skips it and tells the agent why. After an edit, the hook runs the check
39
+ through REDUE so the new result is recorded.
78
40
 
79
- `init` tries the strict recipes first: the [direct compiler recipe](docs/user/direct-typescript.md)
80
- for npm typechecks, the pnpm and Yarn TypeScript recipes, and the
81
- [direct test recipe](docs/user/tests-direct.md). A root typecheck or lint
82
- script none of them takes can use the [general recipe](docs/user/node-script.md),
83
- which runs the script through the package manager and records every Node
84
- process; a script that starts another program (git, esbuild, turbo) stays
85
- UNVERIFIED and the reason names it. Test scripts use the direct test recipe
86
- (Vitest, Jest); other test scripts stay recording-only.
41
+ To look yourself:
87
42
 
88
- ## Connect your agent (experimental)
43
+ ```text
44
+ $ redue status --sync
45
+ ✓ typecheck CURRENT / PASS
46
+ ✓ lint CURRENT / PASS
89
47
 
90
- ```sh
91
- redue agent setup codex --dry-run
92
- redue agent setup codex --apply # or claude
93
- redue agent doctor
48
+ # after editing src/main.ts
49
+ $ redue explain typecheck
50
+ typecheck: STALE / PASS
51
+ src/main.ts changed
52
+ Due again when verification is needed: redue run "typecheck"
94
53
  ```
95
54
 
96
- Start a fresh agent session and give it an ordinary task. Project-local guidance
97
- teaches it to inspect evidence before deciding whether verification needs repeating.
98
- Setup is explicit, reversible, and does not change tool permissions or run checks.
99
- [Activation, removal, and generic-agent guidance](docs/user/agents.md).
100
-
101
- The experimental claim is **opt-in project-local agent activation and direct TypeScript
102
- evidence, with fresh-session reuse demonstrated in the tested Codex/macOS
103
- configuration and measured for Claude Code below**. Cross-host reuse is not
104
- tested. This is experimental guidance, not guaranteed agent compliance, general
105
- sandbox compatibility, or a promise of time savings.
106
-
107
- ### Measured with Claude Code
108
-
109
- Four public TypeScript projects, four tasks each, three sessions per task with
110
- and without REDUE: 96 headless Claude Code sessions (Sonnet 5.5, CI Linux
111
- runner, alpha.12 code, October 2026). Plain `tsc --noEmit` takes 10–19 s on
112
- these projects. Medians per task, summed over the four projects:
113
-
114
- | Task | Session time, without → with REDUE | Input tokens | Typechecks skipped |
115
- |---|---|---|---|
116
- | Docs edit, then "make sure it still typechecks" | 97 → 45 s | 169k → 162k | 12 of 12 |
117
- | "Does it still typecheck?" after a pull | 74 → 22 s | 117k → 89k | 12 of 12 |
118
- | Source change, typecheck, then a docs edit | 141 → 112 s | 210k → 200k | 9 of 12 |
119
- | Source change with tests | 152 → 151 s | 269k → 234k | 0 of 12 |
120
- | **All tasks** | **464 → 330 s** | **765k → 685k** | 33 |
121
-
122
- - **Correctness:** every typecheck REDUE skipped was checked afterwards with
123
- plain tsc on the exact tree it was skipped on. All 33 agreed, and all 96
124
- final trees passed plain tsc and the task checks in both arms.
125
- - **Cost:** API cost was the same ($0.65 without, $0.66 with). One-time setup
126
- per checkout was 3–5 s, plus one recorded typecheck; the CLAUDE.md section
127
- REDUE adds is about 60 tokens.
128
- - **How:** each session gets a fresh clone at a pinned commit; the REDUE arm
129
- first runs `redue init`, `agent setup claude`, `start` and one
130
- `redue run typecheck`, standing for an earlier session's passing check.
131
- The harness, tasks and raw results are in [`eval/`](eval/README.md).
132
- - **Limits:** four projects and three runs per cell show direction, not a
133
- general rate. Savings come only when an earlier pass still applies: tasks
134
- that change source code save nothing, and on one project the docs edit came
135
- after source edits that made the result STALE, so nothing was skipped. The
136
- projects were chosen because they qualify for the direct TypeScript recipe;
137
- of 38 screened projects, 19 qualified at alpha.12 and 22 at alpha.13. Times are agent session
138
- time only, on one runner type.
139
-
140
- ### Unit tests, measured with Claude Code
141
-
142
- Three public projects (cheerio with Vitest 4, SwitchHosts with Vitest 5, twilio
143
- with Jest 29), four tasks each, three sessions per task with and without REDUE:
144
- 72 headless Claude Code sessions (Sonnet 5.5, CI Linux runner, alpha.14 code,
145
- October 2026), using the opt-in [direct test recipe](docs/user/tests-direct.md).
146
- Medians per task, summed over the three projects:
147
-
148
- | Task | Session time, without → with REDUE | Input tokens | Test runs skipped |
149
- |---|---|---|---|
150
- | Docs edit, then "make sure the unit tests still pass" | 95 → 41 s | 131k → 121k | 9 of 9 |
151
- | "Do the unit tests still pass?" after a pull | 80 → 22 s | 62k → 63k | 9 of 9 |
152
- | Source change, tests, then a docs edit | 171 → 111 s | 224k → 213k | 3 of 9 |
153
- | Source change with tests | 169 → 120 s | 172k → 164k | 0 of 9 |
154
- | **All tasks** | **515 → 295 s** | **589k → 559k** | 21 |
155
-
156
- - **Correctness:** every skipped test run was rerun plainly three times on the
157
- exact tree it was skipped on; all 21 passed every time. All 72 final trees
158
- passed the tests and the task checks in both arms.
159
- - **Limits:** one run of three projects shows direction, not a rate. The
160
- source-change task skipped nothing; its time difference is session variance.
161
- In two mixed-task sessions the agent left out its final test run on its own
162
- after a README-only edit, without asking REDUE, and said so; the eval report
163
- lists such sessions. Since alpha.15 the agent instructions ask agents to run
164
- the check and leave skipping to REDUE; in a 12-session rerun of that task,
165
- no agent left it out. Cost was the same ($0.54 without, $0.56 with).
55
+ `--sync` checks the files and your environment before it answers; this is
56
+ what the agent asks. Plain `redue status` is a fast cached answer and can say
57
+ UNVERIFIED ("cannot confirm your execution context") where `--sync` would say
58
+ CURRENT.
59
+
60
+ To undo everything setup did: `redue remove`.
61
+
62
+ ## What it covers today
63
+
64
+ In a census of 120 active public TypeScript repositories (October 2026, REDUE
65
+ at commit c9034e5, just after 0.1.0-alpha.22), 89 installed cleanly. A check
66
+ counts when two recorded runs on the same code both came out CURRENT on the
67
+ same inputs. 31 repositories had at least one such check:
68
+
69
+ | Check | Repositories | How |
70
+ |---|---|---|
71
+ | Typecheck | 22 | 16 by running the project's script with every Node process recorded ([general recipe](docs/user/node-script.md)); 6 by running the local `tsc` directly ([direct recipe](docs/user/direct-typescript.md)) |
72
+ | Lint | 18 | general recipe |
73
+ | Tests | 2 | Vitest run directly ([direct test recipe](docs/user/tests-direct.md)) |
74
+
75
+ Everything else stays UNVERIFIED, with a reason you can read in
76
+ `redue explain`. The usual ones: a script starts a program REDUE cannot see
77
+ into (esbuild, turbo, nx, oxlint's tsgolint, TypeScript 7's native compiler),
78
+ the project uses Bun, or a test suite writes into its own inputs. Two you may
79
+ meet right after setup: a Vitest run writes its results under
80
+ `node_modules/.vite`, which the direct TypeScript recipe counts as an
81
+ installed input, so the typecheck turns STALE until it runs again; and an
82
+ installed file with a second hard link (esbuild's install makes one) keeps
83
+ the test check UNVERIFIED.
84
+ [Supported projects](docs/user/supported-projects.md) has the details.
85
+
86
+ ## Measured with Claude Code
87
+
88
+ Headless Claude Code sessions (Sonnet 5.5, CI Linux runner) on the same tasks
89
+ with and without REDUE, three sessions per task. Session time, medians per
90
+ task summed over the projects:
91
+
92
+ - **Typecheck** (twilio-node, semiotic, Ultra-Card, SwitchHosts; four tasks;
93
+ 96 sessions; 0.1.0-alpha.12 code): 464 s without, 330 s with. REDUE skipped
94
+ 33 typechecks. Each was checked afterwards with plain `tsc` on the exact tree
95
+ it was skipped on, and all 33 agreed.
96
+ - **Unit tests** (cheerio with Vitest 4, SwitchHosts with Vitest 5, twilio-node
97
+ with Jest 29; four tasks; 72 sessions; 0.1.0-alpha.14 code): 515 s without,
98
+ 295 s with. REDUE skipped 21 test runs. Each was rerun plainly three times on
99
+ the exact tree, and all passed every time.
100
+
101
+ API cost was the same in both arms. The savings come only when an earlier
102
+ pass still applies: a task that changes source code saves nothing. A handful
103
+ of projects and three runs per task show direction, not a general rate. The
104
+ harness, tasks and raw results are in [`eval/`](eval/README.md).
105
+
106
+ ## What REDUE won't do
107
+
108
+ - **Prove your code is correct.** CURRENT means the inputs of the recorded
109
+ run are unchanged, not that the code works. A failure stays a failure.
110
+ - **Run checks for you.** Nothing runs in the background; checks run when you
111
+ or the agent run them.
112
+ - **Trust what it cannot see.** A program it cannot account for, a file it
113
+ does not observe, or a gap in observation makes the result UNVERIFIED and
114
+ says why. It never turns that into CURRENT by guessing.
115
+ - **Support yet:** TypeScript 7's native compiler, Bun, per-package checks in
116
+ large monorepos, results shared across machines, and the general recipe on
117
+ Windows (Windows has the strict recipes only).
166
118
 
167
119
  ## What the states mean
168
120
 
169
- | State | Meaning | Normal next step |
121
+ | State | Meaning | Next step |
170
122
  | --- | --- | --- |
171
- | CURRENT | The recorded result applies to the declared inputs. | Reuse a passing result; do not rerun merely for freshness. |
172
- | STALE | Relevant inputs changed since the recorded result. | Rerun when verification is needed. |
173
- | UNVERIFIED | Applicability is unknown: no receipt, incomplete coverage, pending observation, or missing context. | Read the reason; synchronize if worthwhile, or run the check. |
174
- | FAILED | The invocation failed. Its applicability is tracked separately. | Keep the failure visible; it is not green evidence. |
175
-
176
- A historical PASS remains PASS when stale or unverified. A historical failure
177
- never becomes a successful check. CURRENT does not mean every product behavior
178
- has been verified.
179
-
180
- ## Supported alpha path
181
-
182
- - macOS, Linux, and Windows on supported local filesystems; Node 22+.
183
- - Linux also requires Python 3 for observation. No WSL or Git Bash needed on Windows.
184
- - npm, pinned Yarn `node-modules`, and pinned pnpm 12 isolated/hoisted layouts.
185
- - Automatic qualification for supported Yarn/pnpm TypeScript invocations; ordinary npm
186
- launcher checks remain recording-only. Explicitly select the
187
- [direct local compiler recipe](docs/user/direct-typescript.md) for the reviewed
188
- npm/TypeScript boundary. Workspace
189
- boundaries follow the files actually consumed, including built declarations.
190
- - Opt-in [direct test recipe](docs/user/tests-direct.md) for Vitest 4/5 and
191
- Jest 29 in single-package npm projects on macOS and Linux.
192
- - Other test/lint/build and arbitrary commands can record results while
193
- their applicability remains unqualified.
194
-
195
- The [supported-project boundary](docs/user/supported-projects.md) is deliberately
196
- narrow. A script named `test` is not automatically a complete test contract.
197
-
198
- ## Alpha limitations
199
-
200
- - REDUE records evidence; it does not prove correctness.
201
- - Direct commands outside `redue run` do not create receipts.
202
- - Some tests, lints, and builds remain UNVERIFIED/PASS because their input contract is incomplete.
203
- - Synchronized applicability has nontrivial cost and can lose to an inexpensive rerun.
204
- - Unsupported/exotic install layouts and filesystems remain conservative; they do not become green through guesses.
205
- - No cloud/team synchronization, IDE extension, or automatic background check execution.
206
- - Alpha configuration and APIs may evolve. Neither cached nor synchronized status is an atomic snapshot against concurrent edits.
207
-
208
- ## Humans, shells, and agents
123
+ | CURRENT | The recorded result applies to the code as it is now. | Reuse a pass; no need to rerun. |
124
+ | STALE | An input changed since the recorded result. | Rerun when you need the answer. |
125
+ | UNVERIFIED | REDUE cannot tell: no result yet, an input it cannot see, or observation not ready. | Read the reason; rerun if it matters. |
126
+ | FAILED | The last run failed: the check ran and reported a failure, or could not run. | Fix and rerun. |
127
+
128
+ ## Without Claude Code, or step by step
209
129
 
210
130
  ```sh
211
- redue explain typecheck # synchronized explanation; may run read-only probes
212
- redue status --json # conservative cached data
213
- redue status --sync --json # caller-aware decision
214
- redue status --short # small cached indicator; never synchronizes
215
- redue stop # retains historical receipts
216
- redue remove-state # removes only this config's owned local state
131
+ redue init # write redue.config.json from your scripts
132
+ redue start # start the file observer
133
+ redue run typecheck # run a check through REDUE and record the result
134
+ redue status --sync # what still holds
217
135
  ```
218
136
 
219
- Agents should use [the documented JSON interface](docs/user/json.md), not parse
220
- terminal prose. [The canonical agent loop](docs/user/agents.md) keeps the
221
- sync-versus-rerun choice explicit. [Shell usage](docs/user/shell.md) does not put
222
- synchronized work in a prompt.
137
+ Codex is supported too (`redue agent setup codex --apply`); see
138
+ [agents](docs/user/agents.md). Agents should read
139
+ [the JSON interface](docs/user/json.md), not the terminal text.
223
140
 
224
- [User docs](docs/README.md) · [Contributing](CONTRIBUTING.md) ·
225
- [Architecture](docs/contributor/architecture.md) · [Acceptance evidence](docs/acceptance/README.md)
141
+ [Getting started](docs/user/getting-started.md) · [User docs](docs/README.md) ·
142
+ [Contributing](CONTRIBUTING.md) · [Architecture](docs/contributor/architecture.md)
226
143
 
227
144
  ## License
228
145
 
229
- REDUE is licensed under [Apache-2.0](LICENSE). Dependencies retain their own licenses.
146
+ REDUE is licensed under [Apache-2.0](LICENSE). Dependencies keep their own licenses.
package/bin/redue.mjs CHANGED
@@ -28,6 +28,9 @@ const help=`REDUE ${version}
28
28
  Usage: redue [--config FILE] [--state-dir DIR] COMMAND [OPTIONS]
29
29
 
30
30
  Commands:
31
+ setup claude [--yes] Set up REDUE and Claude Code in this project in one step:
32
+ init, agent setup claude, start, one recorded run per check
33
+ remove [--yes] Undo setup: integration, observer state, and the config setup created
31
34
  init [--dry-run] [--workspace NAME] [--check KIND] [--recipe typescript-direct|tests-direct|node-script]
32
35
  Discover existing scripts; optionally select one workspace/check
33
36
  agent setup codex|claude [--dry-run|--apply] [--json]
@@ -58,7 +61,18 @@ if(args.length===3&&args[0]==='agent'&&args[1]==='hook'&&args[2]==='claude'){
58
61
  await runClaudeHook(fileURLToPath(import.meta.url));process.exit(0);
59
62
  }
60
63
  if(args.length===1&&args[0]==='--version'){console.log(version);process.exit(0);}
64
+ // Internal: the entry this command runs, so setup and the hook can tell
65
+ // whether the `redue` on PATH (a link, a package manager's shim, a wrapper)
66
+ // is this install.
67
+ if(args.length===1&&args[0]==='--entry'){console.log(fs.realpathSync(fileURLToPath(import.meta.url)));process.exit(0);}
61
68
  if(args.includes('--help')||args.includes('-h')||!args.length){console.log(help);await exit(0);}
69
+ if(args[0]==='setup'||args[0]==='remove'){
70
+ // Loaded on demand; setup works before a config exists.
71
+ const {setupCommand}=await import('../src/setup.mjs');
72
+ try{await setupCommand(args,{entry:fileURLToPath(import.meta.url)});}
73
+ catch(e){error(e.message);}
74
+ await exit(0);
75
+ }
62
76
  let configFile=null,stateOverride=null;
63
77
  for(let i=0;i<args.length;){
64
78
  if(args[i]==='--config'||args[i]==='--state-dir'){
@@ -124,7 +138,7 @@ if(command==='init'){
124
138
  checks:discovery.checks.map(({config:check,level,reason})=>({name:check.name,
125
139
  script:check.script||null,command:check.command||null,
126
140
  workspace:check.workspace||null,level,reason})),config:configFile,
127
- written:willWrite,existing:configured};
141
+ written:willWrite,existing:configured,writable:!configured&&!unsupported&&discovery.checks.length>0};
128
142
  if(!json) {
129
143
  console.log(`Node ${summary.node}; ${summary.package_manager||'unknown package manager'}`+
130
144
  `${summary.version?' '+summary.version:''}; ${summary.installation_layout} installation.`);
@@ -74,10 +74,18 @@ observer when a session starts (below); otherwise use `redue start`.
74
74
 
75
75
  ## Claude Code typecheck hook
76
76
 
77
- `redue agent setup claude --apply` also adds a PreToolUse hook and a
78
- SessionStart hook to `.claude/settings.local.json`. Both run
79
- `redue agent hook claude`, which needs a local REDUE install, so they are
80
- per-developer; keep that file out of commits. Other settings in the file are kept,
77
+ `redue agent setup claude --apply` (and `redue setup claude`) also adds a
78
+ PreToolUse hook and a SessionStart hook to `.claude/settings.local.json`.
79
+ Both run `redue agent hook claude`, which needs a local REDUE install, so
80
+ they are per-developer; keep that file out of commits. Setup names REDUE
81
+ plainly only when the `redue` that both your shell and a login shell find on
82
+ PATH is the install running setup. Otherwise the hooks name this install's
83
+ Node and entry by absolute path, so a Claude Code started from an IDE, a
84
+ desktop app or another shell still runs the right REDUE; run setup again
85
+ after moving or upgrading Node. `redue agent doctor` reports a hook whose
86
+ paths no longer exist. When the hook runs a check through REDUE for the
87
+ agent, it likewise writes plain `redue run` only if its own PATH finds this
88
+ install, else the absolute form. Other settings in the file are kept,
81
89
  but the file is rewritten as 2-space JSON. `.claude/settings.json` is not touched.
82
90
  `redue agent remove claude --apply` removes only the entries REDUE added.
83
91
 
@@ -7,7 +7,9 @@ not mean npm or npm lifecycle scripts completed.
7
7
  For a supported single-package npm project with a typecheck script of `tsc`
8
8
  runs (see [script forms](#script-forms)) or no typecheck script and a root
9
9
  `tsconfig.json`, installed dependencies, Node 22/24 and TypeScript 5.x or 6.0
10
- (see [compiler identity](#compiler-identity)):
10
+ (see [compiler identity](#compiler-identity)). TypeScript 7 is a native
11
+ compiler this recipe cannot run: `init` refuses it
12
+ (`direct-typescript-version-unsupported`):
11
13
 
12
14
  ```sh
13
15
  redue init --recipe typescript-direct --check typecheck --dry-run
@@ -67,7 +67,26 @@ the package alone does not update project instructions.
67
67
 
68
68
  ## First project
69
69
 
70
- From the project root:
70
+ With Claude Code, one command does the steps below and connects the agent:
71
+
72
+ ```sh
73
+ redue setup claude # asks once; --yes for no prompts
74
+ ```
75
+
76
+ It runs `init` when the project has no `redue.config.json`, `agent setup
77
+ claude`, and `start`, then records each check that can qualify once, unless
78
+ it is already CURRENT. It prints every file it writes, and running it again
79
+ changes nothing that is already set up. When `.claude/settings.local.json`
80
+ is not ignored by Git, it adds it to `.git/info/exclude`; it refuses when
81
+ that file is committed. What setup created is noted in the clone's Git
82
+ directory (`.git/redue-setup-<id>.json`, never committed). `redue remove`
83
+ undoes exactly that: the integration (or only this machine's hooks, when the
84
+ integration was already in the project), the observer and its state
85
+ (receipts included), the local ignore line, and the config if setup wrote it
86
+ and it has not been edited since. A config or observer state that existed
87
+ before setup stays. `remove` asks before it deletes; Enter means no.
88
+
89
+ Step by step, from the project root:
71
90
 
72
91
  ```sh
73
92
  redue init --dry-run
@@ -69,12 +69,16 @@ anywhere in it.
69
69
 
70
70
  Two installed files are rewritten by tools during a run. pnpm rewrites
71
71
  `node_modules/.pnpm-workspace-state-v1.json` at the first run after an
72
- install, through a temporary `node_modules/.tmpXXXXXX` file. vue-tsc writes
72
+ install, through a temporary `node_modules/.tmpXXXXXX` file, and on Linux
73
+ writes a file with no name there (`O_TMPFILE`), whose writes the file
74
+ watcher reports as `node_modules/#NUMBER`. vue-tsc writes
73
75
  `node_modules/.vue-global-types/*.d.ts` before it reads them. These files stay
74
76
  inputs. When they are the only files a run changed, and the run wrote them,
75
77
  the result is kept with the files as the run left them. A recorded process
76
78
  counts as writing a file it wrote; for pnpm's files, the pnpm executable must
77
- have run. A later change to them makes the result STALE.
79
+ have run. A `#NUMBER` event counts only directly in the root `node_modules`,
80
+ on Linux, when no file has that name. A later change to them makes the
81
+ result STALE.
78
82
 
79
83
  It does not mean a rerun would give the same result: a test that depends on
80
84
  the time or on randomness can pass now and fail later on the same inputs.
@@ -107,6 +111,13 @@ one REDUE can account for:
107
111
  content;
108
112
  - `ps -A -o ppid,pid`, which pnpm loaded into Corepack runs.
109
113
 
114
+ A process that replaces itself with another program through
115
+ `process.execve` (TypeScript 7's `tsc` does this to start its native
116
+ compiler) is judged the same way as a program it starts. `init` reads
117
+ TypeScript 7's launchers (`tsc` from `typescript@7`, `tsgo` from
118
+ `@typescript/native-preview`) as that native compiler and keeps such a script
119
+ recording-only.
120
+
110
121
  Anything else makes the result UNVERIFIED and names the program: `git`,
111
122
  `sleep`, `find`, and native programs from installed packages such as esbuild,
112
123
  turbo, tsgo, tsgolint and biome, whose reads, writes and network use REDUE
@@ -142,11 +153,19 @@ inputs.
142
153
  run (pnpm 12 does this) can be reported by the file watcher as an event on
143
154
  the root itself, an observation gap that makes the run UNVERIFIED. Linux
144
155
  reports the file, which is not an input.
156
+ - On Linux, any program's file with no name in the root `node_modules`,
157
+ written during a run that started the pnpm executable, is taken as pnpm's.
158
+ If that program gives the file a real name (any name, `node_modules`
159
+ included) and then writes through the open file, REDUE misses those
160
+ writes. A real file named `node_modules/#NUMBER` that is created and
161
+ removed within such a run is treated the same way. Outside a pnpm run,
162
+ these writes leave the run UNVERIFIED.
145
163
  - The pnpm executable and the pnpm launchers' helpers are trusted as
146
164
  toolchain: what they read is not checked.
147
165
  - Code that copies the environment and reads the copy, and native code that
148
- reads files or variables (native addons such as Rust-based resolvers), is
149
- not seen.
166
+ reads files or variables or starts programs (native addons such as
167
+ Rust-based resolvers), is not seen. Neither are files opened by
168
+ `node:sqlite` or preopened for `node:wasi`.
150
169
  - A project whose `.npmrc` sets `node-options` stays UNVERIFIED: npm replaces
151
170
  `NODE_OPTIONS` with it, which drops REDUE's recorder.
152
171
  - A script that runs a build first (`npm run build && tsc --noEmit`) usually
@@ -83,7 +83,11 @@ entries stay inputs: an import can still reach an excluded file); a file the
83
83
  program reads outside them keeps the check recording-only. This avoids pnpm's task-run bookkeeping
84
84
  writes during `pnpm run`; it does not alter the project's script. Test, lint,
85
85
  build, and ambiguous TypeScript scripts still execute through `pnpm run`; root
86
- typecheck and lint ones can use the [general recipe](node-script.md). The generated `@typescript-bin:WORKSPACE` token resolves
86
+ typecheck and lint ones can use the [general recipe](node-script.md). The pnpm
87
+ and Yarn TypeScript recipes read TypeScript's compiler API, which TypeScript 7
88
+ does not ship: with TypeScript 7 installed they refuse and say so. The
89
+ general recipe runs such a script, but TypeScript 7's native compiler is a
90
+ program REDUE does not record, so the result is UNVERIFIED. The generated `@typescript-bin:WORKSPACE` token resolves
87
91
  the local compiler when the check runs; it is not an absolute machine path.
88
92
 
89
93
  The pnpm contract indexes consumed installed package contents inside the
@@ -80,7 +80,14 @@ kept but marked UNVERIFIED, with the reason, when the run:
80
80
  - connected to anything other than loopback or a local socket, or asked DNS
81
81
  about a name other than localhost;
82
82
  - started a process that did not load the recorder: a shell, a binary, or a
83
- Node process with its own environment;
83
+ Node process with its own environment. A process that replaces itself with
84
+ another program (`process.execve`) counts as starting it, and it must
85
+ become a recorded Node process. A shell is read by its command, as the
86
+ [general recipe](node-script.md#programs) reads it: one that runs another
87
+ program before it becomes Node counts too;
88
+ - used one of Node's bindings with file, network or program access
89
+ (`process.binding('fs')`, `'spawn_sync'` and others), or ran Node with
90
+ `--expose-internals`: the recorder cannot follow those;
84
91
  - had an installed file with another hard link, other than a link into the
85
92
  pnpm store the install recorded in `node_modules/.modules.yaml` (pnpm's
86
93
  default on Linux). A change through a link elsewhere, such as Yarn's