ralph-review 0.0.1 → 0.1.0
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/LICENSE +21 -0
- package/README.md +203 -6
- package/package.json +73 -14
- package/src/cli-core.ts +221 -0
- package/src/cli-rrr.ts +65 -0
- package/src/cli.ts +197 -0
- package/src/commands/.gitkeep +0 -0
- package/src/commands/config.ts +777 -0
- package/src/commands/dashboard.ts +306 -0
- package/src/commands/doctor.ts +364 -0
- package/src/commands/init.ts +1078 -0
- package/src/commands/list.ts +14 -0
- package/src/commands/log.ts +416 -0
- package/src/commands/run.ts +698 -0
- package/src/commands/status.ts +13 -0
- package/src/commands/stop.ts +152 -0
- package/src/lib/.gitkeep +0 -0
- package/src/lib/agents/claude.ts +151 -0
- package/src/lib/agents/codex.ts +292 -0
- package/src/lib/agents/core.ts +117 -0
- package/src/lib/agents/display.ts +27 -0
- package/src/lib/agents/droid.ts +132 -0
- package/src/lib/agents/gemini.ts +120 -0
- package/src/lib/agents/index.ts +3 -0
- package/src/lib/agents/models.ts +122 -0
- package/src/lib/agents/opencode.ts +34 -0
- package/src/lib/agents/pi.ts +324 -0
- package/src/lib/agents/registry.ts +53 -0
- package/src/lib/agents/runner.ts +84 -0
- package/src/lib/agents/types.ts +403 -0
- package/src/lib/cli-parser.ts +397 -0
- package/src/lib/config.ts +241 -0
- package/src/lib/diagnostics/capabilities.ts +264 -0
- package/src/lib/diagnostics/checks.ts +496 -0
- package/src/lib/diagnostics/format.ts +5 -0
- package/src/lib/diagnostics/index.ts +8 -0
- package/src/lib/diagnostics/remediation.ts +226 -0
- package/src/lib/diagnostics/tmux-install.ts +165 -0
- package/src/lib/diagnostics/types.ts +44 -0
- package/src/lib/engine.ts +878 -0
- package/src/lib/format.ts +23 -0
- package/src/lib/git.ts +421 -0
- package/src/lib/html/dashboard/page.ts +173 -0
- package/src/lib/html/dashboard/script.ts +662 -0
- package/src/lib/html/dashboard/styles.ts +614 -0
- package/src/lib/html/dashboard/view-model.ts +149 -0
- package/src/lib/html/log/page.ts +172 -0
- package/src/lib/html/log/styles.ts +107 -0
- package/src/lib/html/priority.ts +29 -0
- package/src/lib/html/shared.ts +47 -0
- package/src/lib/html.ts +33 -0
- package/src/lib/lockfile.ts +445 -0
- package/src/lib/logger.ts +1105 -0
- package/src/lib/notify/sound.ts +118 -0
- package/src/lib/paths.ts +5 -0
- package/src/lib/prompts/defaults/code-simplifier.md +46 -0
- package/src/lib/prompts/defaults/review.md +104 -0
- package/src/lib/prompts/fixer.ts +102 -0
- package/src/lib/prompts/index.ts +4 -0
- package/src/lib/prompts/protocol.ts +45 -0
- package/src/lib/prompts/review.ts +49 -0
- package/src/lib/prompts/simplifier.ts +50 -0
- package/src/lib/server.ts +229 -0
- package/src/lib/structured-output.ts +379 -0
- package/src/lib/tmux.ts +222 -0
- package/src/lib/tui/colors.ts +30 -0
- package/src/lib/tui/components/Dashboard.tsx +201 -0
- package/src/lib/tui/components/Header.tsx +135 -0
- package/src/lib/tui/components/HelpOverlay.tsx +63 -0
- package/src/lib/tui/components/OutputPanel.tsx +81 -0
- package/src/lib/tui/components/ProgressBar.tsx +26 -0
- package/src/lib/tui/components/SessionPanel.tsx +603 -0
- package/src/lib/tui/components/Spinner.tsx +23 -0
- package/src/lib/tui/components/StatusBar.tsx +50 -0
- package/src/lib/tui/index.tsx +22 -0
- package/src/lib/tui/session-panel-utils.ts +288 -0
- package/src/lib/tui/types.ts +43 -0
- package/src/lib/tui/use-dashboard-state.ts +415 -0
- package/src/lib/types/config.ts +94 -0
- package/src/lib/types/domain.ts +34 -0
- package/src/lib/types/fix.ts +107 -0
- package/src/lib/types/index.ts +41 -0
- package/src/lib/types/log.ts +70 -0
- package/src/lib/types/review.ts +296 -0
- package/src/lib/types/run.ts +28 -0
- package/src/lib/types/stats.ts +84 -0
- package/src/terminal/palette.ts +10 -0
- package/src/terminal/theme.ts +300 -0
- package/index.ts +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kenryu42
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,15 +1,212 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Ralph Review
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/kenryu42/ralph-review/actions/workflows/ci.yml)
|
|
4
|
+
[](https://codecov.io/github/kenryu42/ralph-review)
|
|
5
|
+
[](https://github.com/kenryu42/ralph-review)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
A CLI tool that orchestrates agentic review-fix cycles until your code is clean.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Table of Contents
|
|
13
|
+
|
|
14
|
+
- [Why This Exists](#why-this-exists)
|
|
15
|
+
- [How It Works](#how-it-works)
|
|
16
|
+
- [Agent Roles](#agent-roles)
|
|
17
|
+
- [Prerequisites](#prerequisites)
|
|
18
|
+
- [Installation](#installation)
|
|
19
|
+
- [Quick Start](#quick-start)
|
|
20
|
+
- [Commands](#commands)
|
|
21
|
+
- [Supported Coding Agents](#supported-coding-agents)
|
|
22
|
+
- [Configuration](#configuration)
|
|
23
|
+
- [License](#license)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Why This Exists
|
|
28
|
+
|
|
29
|
+
I've been a huge fan of Codex's review feature ever since its [first release](https://x.com/DanielEdrisian/status/1968819243694104899). Because the GPT Codex model actually reads many files to gather context and reasoning, it is slower than other agents, but it consistently finds bugs they miss.
|
|
30
|
+
|
|
31
|
+
My usual workflow was repetitive: run a Codex review, copy and paste the findings into a new session,
|
|
32
|
+
ask another agent if it agrees, and then ask it to fix the issues.
|
|
33
|
+
|
|
34
|
+
Why not fix it in the same session? Because I wanted an independent second opinion before applying changes, and a fresh context helped avoid the first agent’s bias carrying into the fix.
|
|
35
|
+
|
|
36
|
+
Doing that manually is tedious and time-consuming, so I built this tool to automate the loop. Inspired by the [Ralph Wiggum technique](https://ghuntley.com/ralph/) by Geoffrey Huntley. I also
|
|
37
|
+
wanted an easy way to try different coding agents and models.
|
|
38
|
+
|
|
39
|
+
I also occasionally run a code simplifier pass before review, so I included that workflow here too.
|
|
40
|
+
|
|
41
|
+
If this helps other people, great. If not, it still helps me.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## How It Works
|
|
46
|
+
|
|
47
|
+
Ralph Review automates code review by pairing two AI agents -- a **reviewer** and a **fixer** -- and looping until the code is clean or the iteration limit is reached.
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
┌──────────────────────────────┐
|
|
51
|
+
│ Your changes │
|
|
52
|
+
└──────────────┬───────────────┘
|
|
53
|
+
│
|
|
54
|
+
▼
|
|
55
|
+
┌──────────────────────────────┐
|
|
56
|
+
│ Code Simplifier (optional) │
|
|
57
|
+
└──────────────┬───────────────┘
|
|
58
|
+
│
|
|
59
|
+
▼
|
|
60
|
+
┌─────────────────┐
|
|
61
|
+
│ Reviewer agent │ ◀───────────────────────────────────────┐
|
|
62
|
+
└────────┬────────┘ │
|
|
63
|
+
│ │
|
|
64
|
+
▼ │
|
|
65
|
+
┌───────────────────────┐ │
|
|
66
|
+
│ Create git checkpoint │ │
|
|
67
|
+
└───────────┬───────────┘ │
|
|
68
|
+
│ │
|
|
69
|
+
▼ │
|
|
70
|
+
┌─────────────────┐ │
|
|
71
|
+
│ Fixer agent │ │
|
|
72
|
+
│ (verify & fix) │ │
|
|
73
|
+
└────────┬────────┘ │
|
|
74
|
+
│ │
|
|
75
|
+
▼ │
|
|
76
|
+
┌───────────────────────┐ │
|
|
77
|
+
│ Parse fix summary │ │
|
|
78
|
+
└──────────┬────────────┘ │
|
|
79
|
+
│ │
|
|
80
|
+
├── no issues found (verified by fixer) ──▶ Stop │
|
|
81
|
+
├── issues found, all skipped by fixer ──▶ Stop │
|
|
82
|
+
│ │
|
|
83
|
+
▼ │
|
|
84
|
+
Discard checkpoint, loop back to Reviewer ──────────────────────┘
|
|
85
|
+
(until max iterations reached)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**How the cycle works:**
|
|
89
|
+
|
|
90
|
+
1. An optional **code simplifier** pass can run first (enabled with `--simplifier`) to reduce code complexity before review.
|
|
91
|
+
2. The **reviewer** analyzes your changes and returns structured review output.
|
|
92
|
+
3. A **git checkpoint** is created so the fixer's changes can be rolled back if something goes wrong.
|
|
93
|
+
4. The **fixer** independently reads the code, confirms each issue is real, and applies fixes only where warranted. It does not blindly trust the reviewer.
|
|
94
|
+
5. The fixer outputs a structured summary. If it reports no actionable issues left -- either no real issues were found or all remaining items were safely skipped -- the cycle ends.
|
|
95
|
+
6. Otherwise, the cycle repeats from step 2 until no issues remain or the configured iteration limit is hit.
|
|
96
|
+
|
|
97
|
+
You can assign different AI agents to each role (e.g. Claude reviews, Gemini fixes).
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Agent Roles
|
|
102
|
+
|
|
103
|
+
Ralph Review orchestrates three distinct roles. You can assign any [supported coding agent](#supported-coding-agents) to each role.
|
|
104
|
+
|
|
105
|
+
### Code Simplifier (optional)
|
|
106
|
+
|
|
107
|
+
Enabled with `--simplifier`. Runs once before the review loop begins, reducing code complexity while preserving exact behavior. Operates on the same diff scope as the reviewer (uncommitted changes, base branch diff, or a specific commit).
|
|
108
|
+
|
|
109
|
+
Prompt adapted from the [Claude Code code-simplifier plugin](https://github.com/anthropics/claude-plugins-official/blob/main/plugins/code-simplifier/agents/code-simplifier.md).
|
|
110
|
+
|
|
111
|
+
### Reviewer
|
|
112
|
+
|
|
113
|
+
Analyzes changes for bugs that impact correctness, security, reliability, or maintainability. Outputs structured JSON with findings, each tagged P0–P3 by priority. Ignores style nits and pre-existing issues — only flags bugs introduced in the change. Does not suggest fixes.
|
|
114
|
+
|
|
115
|
+
Prompt adapted from the [Codex CLI review prompt](https://github.com/openai/codex/blob/main/codex-rs/core/review_prompt.md).
|
|
116
|
+
|
|
117
|
+
### Fixer
|
|
118
|
+
|
|
119
|
+
Treats review findings as untrusted input — verifies every claim against actual code before acting. Classifies each issue as APPLY (real and fixable) or SKIP (false positive or not actionable). Applies minimal safe changes, then runs project verification (lint, typecheck, tests, build). When no actionable issues remain, signals the cycle to stop.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Prerequisites
|
|
124
|
+
|
|
125
|
+
- [Bun](https://bun.sh) (runtime)
|
|
126
|
+
- [tmux](https://github.com/tmux/tmux) (background sessions)
|
|
127
|
+
- At least one [supported agent CLI](#supported-coding-agents) installed and authenticated
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Installation
|
|
4
132
|
|
|
5
133
|
```bash
|
|
6
|
-
|
|
134
|
+
npm install -g ralph-review
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Quick Start
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Auto-detect installed agents and configure reviewer/fixer
|
|
143
|
+
rr init
|
|
144
|
+
|
|
145
|
+
# Start a review cycle (runs in tmux)
|
|
146
|
+
rr run
|
|
147
|
+
|
|
148
|
+
# Or use shorthand alias for `rr run`
|
|
149
|
+
rrr
|
|
7
150
|
```
|
|
8
151
|
|
|
9
|
-
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Commands
|
|
155
|
+
|
|
156
|
+
| Command | Description |
|
|
157
|
+
|---------|-------------|
|
|
158
|
+
| `rr init` | Configure reviewer, fixer, and simplifier agents (auto-detects installed CLIs) |
|
|
159
|
+
| `rr run` | Start review cycle in a tmux session |
|
|
160
|
+
| `rr run --base main` | Review changes against a base branch |
|
|
161
|
+
| `rr run --uncommitted` | Review staged, unstaged, and untracked changes |
|
|
162
|
+
| `rr run --commit SHA` | Review changes introduced by a specific commit |
|
|
163
|
+
| `rr run --max N` | Set max iterations |
|
|
164
|
+
| `rr run --simplifier` | Run a code-simplifier pass before review iterations |
|
|
165
|
+
| `rr config show` | Print full configuration |
|
|
166
|
+
| `rr config set KEY VAL` | Update a config value (e.g. `rr config set maxIterations 8`) |
|
|
167
|
+
| `rr list` | List active review sessions |
|
|
168
|
+
| `rr status` | Show current review status |
|
|
169
|
+
| `rr stop` | Stop running review session (`--all` to stop all) |
|
|
170
|
+
| `rr log` | View review logs (`-n 5` for last 5, `--json` for JSON output) |
|
|
171
|
+
| `rr dashboard` | Open review dashboard in browser |
|
|
172
|
+
| `rr doctor` | Run environment and configuration diagnostics (`--fix` to auto-resolve) |
|
|
173
|
+
|
|
174
|
+
The `rrr` command is a shorthand alias for `rr run` -- all flags work the same.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Supported Coding Agents
|
|
179
|
+
|
|
180
|
+
| Agent | Link |
|
|
181
|
+
|-------|------|
|
|
182
|
+
| Claude Code | https://code.claude.com/docs/en/overview |
|
|
183
|
+
| Codex | https://openai.com/codex/ |
|
|
184
|
+
| Droid | https://factory.ai/ |
|
|
185
|
+
| Gemini CLI | https://geminicli.com/ |
|
|
186
|
+
| OpenCode | https://opencode.ai/ |
|
|
187
|
+
| Pi | https://pi.dev |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Configuration
|
|
192
|
+
|
|
193
|
+
After running `rr init`, Ralph Review stores its configuration in your project directory. You can view and modify settings with the `rr config` subcommand:
|
|
10
194
|
|
|
11
195
|
```bash
|
|
12
|
-
|
|
196
|
+
# View current configuration
|
|
197
|
+
rr config show
|
|
198
|
+
|
|
199
|
+
# Edit configuration in your editor
|
|
200
|
+
rr config edit
|
|
201
|
+
|
|
202
|
+
# Or set a specific config using cli
|
|
203
|
+
rr config set maxIterations 5
|
|
13
204
|
```
|
|
14
205
|
|
|
15
|
-
|
|
206
|
+
Run `rr doctor` to verify that your environment and configuration are valid. Add `--fix` to let it auto-resolve common issues.
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,25 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ralph-review",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A CLI tool that orchestrates agentic review-fix cycles until your code is clean.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "J Liew",
|
|
9
|
+
"email": "jliew@420024lab.com"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/kenryu42/ralph-review.git"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/kenryu42/ralph-review#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/kenryu42/ralph-review/issues"
|
|
18
|
+
},
|
|
19
|
+
"os": [
|
|
20
|
+
"!win32"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"cli",
|
|
24
|
+
"code-review",
|
|
25
|
+
"ai",
|
|
26
|
+
"codex",
|
|
27
|
+
"claude",
|
|
28
|
+
"opencode",
|
|
29
|
+
"automation",
|
|
30
|
+
"developer-tools"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"bun": ">=1.0.0"
|
|
34
|
+
},
|
|
35
|
+
"bin": {
|
|
36
|
+
"ralph-review": "src/cli.ts",
|
|
37
|
+
"rr": "src/cli.ts",
|
|
38
|
+
"rrr": "src/cli-rrr.ts"
|
|
15
39
|
},
|
|
16
40
|
"files": [
|
|
17
|
-
"
|
|
41
|
+
"src/cli.ts",
|
|
42
|
+
"src/cli-rrr.ts",
|
|
43
|
+
"src/cli-core.ts",
|
|
44
|
+
"src/commands",
|
|
45
|
+
"src/lib",
|
|
46
|
+
"src/terminal"
|
|
18
47
|
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"dev:tui": "bun run scripts/tui-dev.tsx",
|
|
50
|
+
"build:schema": "bun run scripts/build-schema.ts",
|
|
51
|
+
"publish:dry-run": "bun run scripts/publish.ts --dry-run",
|
|
52
|
+
"publish:recover": "bun run scripts/publish.ts --recover",
|
|
53
|
+
"publish:recover:execute": "bun run scripts/publish.ts --recover --execute",
|
|
54
|
+
"rr": "bun run src/cli.ts",
|
|
55
|
+
"test": "bun test",
|
|
56
|
+
"prepublishOnly": "bun test",
|
|
57
|
+
"typecheck": "tsc --noEmit",
|
|
58
|
+
"knip": "knip-bun",
|
|
59
|
+
"lint": "biome check --write .",
|
|
60
|
+
"lint:ci": "biome ci .",
|
|
61
|
+
"lint-staged": "lint-staged",
|
|
62
|
+
"check": "bun run typecheck && bun run knip && bun run lint && AGENT=1 bun test --coverage",
|
|
63
|
+
"check:ci": "bun run typecheck && bun run knip && bun run lint:ci && AGENT=1 bun test --coverage",
|
|
64
|
+
"prepare": "husky && bun run setup-hooks",
|
|
65
|
+
"setup-hooks": "bun -e 'await Bun.write(\".husky/pre-commit\", \"#!/usr/bin/env sh\\n\\nbun run knip && bun run lint-staged\\n\")' && chmod +x .husky/pre-commit"
|
|
66
|
+
},
|
|
19
67
|
"devDependencies": {
|
|
20
|
-
"@
|
|
68
|
+
"@biomejs/biome": "^2.3.12",
|
|
69
|
+
"@types/bun": "latest",
|
|
70
|
+
"@types/react": "^19.0.0",
|
|
71
|
+
"husky": "^9.1.7",
|
|
72
|
+
"knip": "^5.82.1",
|
|
73
|
+
"lint-staged": "^16.2.7",
|
|
74
|
+
"typescript": "^5",
|
|
75
|
+
"zod": "^4.3.6"
|
|
21
76
|
},
|
|
22
|
-
"peerDependencies": {
|
|
23
|
-
|
|
77
|
+
"peerDependencies": {},
|
|
78
|
+
"dependencies": {
|
|
79
|
+
"@clack/prompts": "1.0.0-alpha.9",
|
|
80
|
+
"@opentui/core": "^0.1.75",
|
|
81
|
+
"@opentui/react": "^0.1.75",
|
|
82
|
+
"react": "^19.0.0"
|
|
24
83
|
}
|
|
25
84
|
}
|
package/src/cli-core.ts
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CommandDef,
|
|
3
|
+
formatCommandHelp,
|
|
4
|
+
formatMainHelp,
|
|
5
|
+
type OptionDef,
|
|
6
|
+
} from "./lib/cli-parser";
|
|
7
|
+
|
|
8
|
+
const SIMPLIFIER_OPTION: OptionDef = {
|
|
9
|
+
name: "simplifier",
|
|
10
|
+
type: "boolean",
|
|
11
|
+
description: "Run one code simplifier phase before review iterations",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const COMMANDS: CommandDef[] = [
|
|
15
|
+
{
|
|
16
|
+
name: "init",
|
|
17
|
+
description: "Configure reviewer, fixer, and simplifier agents (auto or custom)",
|
|
18
|
+
examples: ["rr init"],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "config",
|
|
22
|
+
description: "Inspect and update configuration",
|
|
23
|
+
positional: [
|
|
24
|
+
{
|
|
25
|
+
name: "subcommand",
|
|
26
|
+
description:
|
|
27
|
+
"show = print full config | get = read one key | set = update one key | edit = open in $EDITOR",
|
|
28
|
+
},
|
|
29
|
+
{ name: "key", description: "Dot-path config key (required for get/set)" },
|
|
30
|
+
{ name: "value", description: "Value to write (required for set)" },
|
|
31
|
+
],
|
|
32
|
+
examples: [
|
|
33
|
+
"rr config show",
|
|
34
|
+
"rr config get reviewer.agent",
|
|
35
|
+
"rr config set maxIterations 8",
|
|
36
|
+
"rr config edit",
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "run",
|
|
41
|
+
description: "Start review cycle",
|
|
42
|
+
options: [
|
|
43
|
+
{ name: "max", alias: "m", type: "number", description: "Max iterations" },
|
|
44
|
+
{
|
|
45
|
+
name: "force",
|
|
46
|
+
alias: "f",
|
|
47
|
+
type: "boolean",
|
|
48
|
+
description: "Run full max iterations even if no issues are found",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "base",
|
|
52
|
+
type: "string",
|
|
53
|
+
placeholder: "BRANCH",
|
|
54
|
+
description: "Review changes against the given base branch",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "uncommitted",
|
|
58
|
+
type: "boolean",
|
|
59
|
+
description: "Review staged, unstaged, and untracked changes",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "commit",
|
|
63
|
+
type: "string",
|
|
64
|
+
placeholder: "SHA",
|
|
65
|
+
description: "Review the changes introduced by a commit",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "custom",
|
|
69
|
+
type: "string",
|
|
70
|
+
placeholder: "PROMPT",
|
|
71
|
+
description: "Custom review instructions",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "sound",
|
|
75
|
+
type: "boolean",
|
|
76
|
+
description: "Play a sound when session finishes (override config)",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "no-sound",
|
|
80
|
+
type: "boolean",
|
|
81
|
+
description: "Disable finish sound for this run (override config)",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "watch",
|
|
85
|
+
type: "boolean",
|
|
86
|
+
description: "Open Session Panel after starting the run (override config)",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "no-watch",
|
|
90
|
+
type: "boolean",
|
|
91
|
+
description: "Start run without opening Session Panel (override config)",
|
|
92
|
+
},
|
|
93
|
+
SIMPLIFIER_OPTION,
|
|
94
|
+
],
|
|
95
|
+
examples: ["rr run", "rr run --base main", "rr run --no-watch"],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "list",
|
|
99
|
+
aliases: ["ls"],
|
|
100
|
+
description: "List active review sessions",
|
|
101
|
+
examples: ["rr list", "rr ls"],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "status",
|
|
105
|
+
description: "Show review status",
|
|
106
|
+
examples: ["rr status"],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "stop",
|
|
110
|
+
description: "Stop running review session",
|
|
111
|
+
options: [
|
|
112
|
+
{ name: "all", alias: "A", type: "boolean", description: "Stop all running review sessions" },
|
|
113
|
+
],
|
|
114
|
+
examples: ["rr stop", "rr stop --all"],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "log",
|
|
118
|
+
description: "View review logs",
|
|
119
|
+
options: [
|
|
120
|
+
{ name: "json", type: "boolean", description: "Output as JSON" },
|
|
121
|
+
{
|
|
122
|
+
name: "last",
|
|
123
|
+
alias: "n",
|
|
124
|
+
type: "number",
|
|
125
|
+
description: "Number of sessions to show",
|
|
126
|
+
default: 1,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "global",
|
|
130
|
+
type: "boolean",
|
|
131
|
+
description: "Show all sessions across all projects (requires --json)",
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
examples: ["rr log", "rr log -n 5", "rr log --json", "rr log --json --global"],
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "dashboard",
|
|
138
|
+
description: "Open review dashboard in browser",
|
|
139
|
+
examples: ["rr dashboard"],
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "doctor",
|
|
143
|
+
description: "Run environment and configuration diagnostics",
|
|
144
|
+
options: [
|
|
145
|
+
{
|
|
146
|
+
name: "fix",
|
|
147
|
+
type: "boolean",
|
|
148
|
+
description: "Automatically fix issues that can be resolved",
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
examples: ["rr doctor", "rr doctor --fix"],
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "_run-foreground",
|
|
155
|
+
description: "Internal: run review cycle in tmux foreground",
|
|
156
|
+
hidden: true,
|
|
157
|
+
options: [
|
|
158
|
+
{ name: "max", type: "number", description: "Max iterations" },
|
|
159
|
+
{
|
|
160
|
+
name: "force",
|
|
161
|
+
alias: "f",
|
|
162
|
+
type: "boolean",
|
|
163
|
+
description: "Run full max iterations even if no issues are found",
|
|
164
|
+
},
|
|
165
|
+
SIMPLIFIER_OPTION,
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
export function getCommandDef(name: string): CommandDef | undefined {
|
|
171
|
+
return COMMANDS.find((c) => c.name === name || c.aliases?.includes(name));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface ParsedArgs {
|
|
175
|
+
command: string;
|
|
176
|
+
args: string[];
|
|
177
|
+
showHelp: boolean;
|
|
178
|
+
showVersion: boolean;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function parseArgs(argv: string[]): ParsedArgs {
|
|
182
|
+
const result: ParsedArgs = {
|
|
183
|
+
command: "",
|
|
184
|
+
args: [],
|
|
185
|
+
showHelp: false,
|
|
186
|
+
showVersion: false,
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
for (const arg of argv) {
|
|
190
|
+
if (arg === "--help" || arg === "-h") {
|
|
191
|
+
result.showHelp = true;
|
|
192
|
+
} else if (arg === "--version" || arg === "-v") {
|
|
193
|
+
result.showVersion = true;
|
|
194
|
+
} else if (!result.command && !arg.startsWith("-")) {
|
|
195
|
+
result.command = arg;
|
|
196
|
+
} else {
|
|
197
|
+
result.args.push(arg);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function getVersion(): string {
|
|
205
|
+
try {
|
|
206
|
+
const pkg = require("../package.json");
|
|
207
|
+
return pkg.version || "0.1.0";
|
|
208
|
+
} catch {
|
|
209
|
+
return "0.1.0";
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export function printUsage(): string {
|
|
214
|
+
return formatMainHelp(COMMANDS, getVersion());
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function printCommandHelp(commandName: string): string | undefined {
|
|
218
|
+
const def = getCommandDef(commandName);
|
|
219
|
+
if (!def) return undefined;
|
|
220
|
+
return formatCommandHelp(def);
|
|
221
|
+
}
|
package/src/cli-rrr.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { printCommandHelp } from "@/cli-core";
|
|
4
|
+
import { startReview } from "@/commands/run";
|
|
5
|
+
|
|
6
|
+
export interface RrrDeps {
|
|
7
|
+
printCommandHelp: typeof printCommandHelp;
|
|
8
|
+
startReview: typeof startReview;
|
|
9
|
+
log: (message: string) => void;
|
|
10
|
+
error: (message: string) => void;
|
|
11
|
+
exit: (code: number) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const CONSOLE_LOG = console.log.bind(console) as (message: string) => void;
|
|
15
|
+
const CONSOLE_ERROR = console.error.bind(console) as (message: string) => void;
|
|
16
|
+
const PROCESS_EXIT = process.exit.bind(process) as (code: number) => void;
|
|
17
|
+
|
|
18
|
+
const DEFAULT_RRR_DEPS: RrrDeps = {
|
|
19
|
+
printCommandHelp,
|
|
20
|
+
startReview,
|
|
21
|
+
log: CONSOLE_LOG,
|
|
22
|
+
error: CONSOLE_ERROR,
|
|
23
|
+
exit: PROCESS_EXIT,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function buildRrrDeps(overrides: Partial<RrrDeps>): RrrDeps {
|
|
27
|
+
return { ...DEFAULT_RRR_DEPS, ...overrides };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function runRrr(
|
|
31
|
+
args: string[] = process.argv.slice(2),
|
|
32
|
+
deps: Partial<RrrDeps> = {}
|
|
33
|
+
): Promise<void> {
|
|
34
|
+
const rrrDeps = buildRrrDeps(deps);
|
|
35
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
36
|
+
rrrDeps.log("rrr - Quick alias for 'rr run'\n");
|
|
37
|
+
rrrDeps.log("USAGE:");
|
|
38
|
+
rrrDeps.log(" rrr [options]\n");
|
|
39
|
+
rrrDeps.log("All options are passed through to 'rr run'.\n");
|
|
40
|
+
const optionsMatch = rrrDeps
|
|
41
|
+
.printCommandHelp("run")
|
|
42
|
+
?.match(/OPTIONS:[\s\S]*?(?=\nEXAMPLES:|\n\n|$)/);
|
|
43
|
+
if (optionsMatch) {
|
|
44
|
+
rrrDeps.log(optionsMatch[0]);
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
await rrrDeps.startReview(args);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function runRrrEntrypoint(
|
|
53
|
+
run?: () => Promise<void>,
|
|
54
|
+
deps: Pick<RrrDeps, "error" | "exit"> = DEFAULT_RRR_DEPS
|
|
55
|
+
): void {
|
|
56
|
+
const runFn = run ?? runRrr;
|
|
57
|
+
runFn().catch((error) => {
|
|
58
|
+
deps.error(`Error: ${error}`);
|
|
59
|
+
deps.exit(1);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (import.meta.main) {
|
|
64
|
+
runRrrEntrypoint();
|
|
65
|
+
}
|