@tritard/waterbrother 0.5.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 +279 -0
- package/bin/waterbrother.js +7 -0
- package/package.json +46 -0
- package/src/agent.js +551 -0
- package/src/cli.js +5760 -0
- package/src/config.js +216 -0
- package/src/decider.js +131 -0
- package/src/grok-client.js +268 -0
- package/src/impact.js +161 -0
- package/src/mcp.js +376 -0
- package/src/modes.js +84 -0
- package/src/panel.js +154 -0
- package/src/path-utils.js +78 -0
- package/src/prompt.js +182 -0
- package/src/reviewer.js +140 -0
- package/src/session-store.js +154 -0
- package/src/task-store.js +178 -0
- package/src/tools.js +2206 -0
- package/src/workflow.js +153 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Phillip Holland
|
|
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
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# waterbrother
|
|
2
|
+
|
|
3
|
+
A local coding CLI that connects to Grok (`api.x.ai`) with codex/claude-style interactive workflows, local tool calls, session persistence, and approval controls.
|
|
4
|
+
|
|
5
|
+
## Web docs interface
|
|
6
|
+
|
|
7
|
+
This repo includes a static docs web interface:
|
|
8
|
+
|
|
9
|
+
- `/` landing page
|
|
10
|
+
- `/onboarding` onboarding + API key guide
|
|
11
|
+
- `/install` install instructions
|
|
12
|
+
- `/usage` usage guide
|
|
13
|
+
- `/commands` command reference
|
|
14
|
+
- `/prod-readiness` production-readiness checklist and release blockers
|
|
15
|
+
- `/changelog` release notes
|
|
16
|
+
- `/faq` FAQ
|
|
17
|
+
|
|
18
|
+
It is Vercel-ready via `vercel.json` (clean URLs, no build step required).
|
|
19
|
+
|
|
20
|
+
## Implemented features
|
|
21
|
+
|
|
22
|
+
- Interactive and one-shot chat modes
|
|
23
|
+
- Codex-style non-interactive commands:
|
|
24
|
+
- `waterbrother exec <prompt>`
|
|
25
|
+
- `waterbrother review <prompt>`
|
|
26
|
+
- `waterbrother resume [session-id] [prompt]`
|
|
27
|
+
- `waterbrother resume --last`
|
|
28
|
+
- First-run onboarding wizard in terminal
|
|
29
|
+
- asks for API key
|
|
30
|
+
- offers opening `https://console.x.ai/`
|
|
31
|
+
- prompts for default model and agent profile
|
|
32
|
+
- Grok API integration (`/chat/completions`)
|
|
33
|
+
- Vision command for local images: `waterbrother vision <image-path> <prompt>`
|
|
34
|
+
- Authenticated GitHub repo reading for GitHub URLs, including private repos when `gh` is logged in
|
|
35
|
+
- Built-in webpage reading and web search tools for pasted URLs and open-web research prompts
|
|
36
|
+
- MCP stdio server support via config-driven `mcpServers`
|
|
37
|
+
- Interactive URL drop support: paste a public `https://...` URL directly and Waterbrother will read and summarize it
|
|
38
|
+
- Multiline paste stays buffered until explicit Enter, with a prompt-row placeholder like `[Pasted Content 14083 chars]`
|
|
39
|
+
- Agent profiles: `coder`, `designer`, `reviewer`, `planner`
|
|
40
|
+
- Model discovery command (`waterbrother models list`)
|
|
41
|
+
- Local model catalog (`waterbrother models catalog`)
|
|
42
|
+
- Onboarding guide command (`waterbrother onboarding`)
|
|
43
|
+
- Local self-update command (`waterbrother update`)
|
|
44
|
+
- git-clone installs pull latest source, install deps, and run checks
|
|
45
|
+
- npm installs upgrade with `npm install -g @tritard/waterbrother@latest`
|
|
46
|
+
- Environment diagnostics (`waterbrother doctor`)
|
|
47
|
+
- Tool calling for file, shell, search, and git tasks
|
|
48
|
+
- Diff preview in approval prompts: see exactly what will change before approving file writes and replacements
|
|
49
|
+
- Fuzzy whitespace-tolerant matching in `replace_in_file` to reduce failed edits
|
|
50
|
+
- Shell working directory tracking (`cd` commands update the shell cwd for subsequent calls)
|
|
51
|
+
- Approval policy for mutating/shell tools: `auto`, `on-request`, `never`
|
|
52
|
+
- supports path-aware allow/ask/deny rules via config
|
|
53
|
+
- supports command-aware shell allow/ask/deny rules via config
|
|
54
|
+
- includes `apply_patch`, `make_directory`, and `restore_checkpoint` in approval-protected actions
|
|
55
|
+
- `restore_checkpoint` is treated as high-risk and always requires explicit approval
|
|
56
|
+
- On-request prompt supports keyboard-first actions:
|
|
57
|
+
- `↑/↓` changes the highlighted approval row
|
|
58
|
+
- `Enter` or `y` approve once
|
|
59
|
+
- `p` saves a session approval rule for the current shell-command prefix or tool
|
|
60
|
+
- `Esc` denies and optionally provides alternate guidance
|
|
61
|
+
- the chooser renders in a bordered block with the default action highlighted
|
|
62
|
+
- the footer shows a short rules indicator when session approval rules are active
|
|
63
|
+
- AI-powered commit command: `waterbrother commit [--push]`
|
|
64
|
+
- Split config layers:
|
|
65
|
+
- user config (`~/.waterbrother/config.json`)
|
|
66
|
+
- project overrides (`.waterbrother/config.json`)
|
|
67
|
+
- Session persistence (`~/.waterbrother/sessions/*.json`)
|
|
68
|
+
- Two-tier project memory:
|
|
69
|
+
- global instructions (`~/.waterbrother/WATERBROTHER.md`)
|
|
70
|
+
- project instructions (`WATERBROTHER.md`) — both merged into system prompt
|
|
71
|
+
- Accurate token tracking using API usage data when available (falls back to estimation)
|
|
72
|
+
- Manual compaction command (`/compact`) for long-running sessions
|
|
73
|
+
- Session forking with `/fork`
|
|
74
|
+
- Session cost tracking with `/cost`
|
|
75
|
+
- Working tree inspection with `/diff`
|
|
76
|
+
- Git-backed local checkpoints with restore support (`/checkpoints`, `/rewind [id]`)
|
|
77
|
+
- Deterministic patch application tool (`apply_patch`) with preflight validation
|
|
78
|
+
- Turn contracts (new)
|
|
79
|
+
- agent must declare intended scope before edits or risky shell calls
|
|
80
|
+
- contract includes summary, allowed paths, expected commands, and verification commands
|
|
81
|
+
- runtime blocks out-of-scope mutations automatically
|
|
82
|
+
- Turn receipts (new)
|
|
83
|
+
- every tool-heavy or mutating turn writes a local receipt under `.waterbrother/receipts/`
|
|
84
|
+
- receipt captures contract, files touched, checkpoint, verification results, and command/tool provenance
|
|
85
|
+
- inspect with `/receipts`, `/receipt last`, `/receipt <id>`
|
|
86
|
+
- summary printing is configurable with `receiptMode` / `--receipts auto|off|verbose`
|
|
87
|
+
- default `auto` suppresses noisy receipt lines for minimal read-only turns
|
|
88
|
+
- Automatic post-edit verification
|
|
89
|
+
- verification commands from the turn contract run automatically after edits
|
|
90
|
+
- optional default verification commands available through config
|
|
91
|
+
- Auto-compaction near context limits (`autoCompactThreshold`, default `0.9`)
|
|
92
|
+
- Interactive slash controls with command palette
|
|
93
|
+
- `/` opens command menu
|
|
94
|
+
- `↑/↓` changes selection
|
|
95
|
+
- `Enter` accepts selected command
|
|
96
|
+
- Read-only file tools can inspect common home folders such as ~/Desktop, ~/Downloads, and ~/Documents without falling back to shell; /desktop, /downloads, and /documents are treated as aliases for those locations on macOS
|
|
97
|
+
- Turn presentation improvements
|
|
98
|
+
- streaming assistant output for faster perceived response
|
|
99
|
+
- explicit run-state tracking (`planning`, `reading`, `editing`, `running`, `reviewing`, `done`, `error`) persisted in session metadata
|
|
100
|
+
- heartbeat/stuck detection with interrupt hint during long-running steps
|
|
101
|
+
- spinner/progress animation while model or tools are running
|
|
102
|
+
- live visible trace lines during turns for phases like thinking and tool use, with verbose-only run-state heartbeat details
|
|
103
|
+
- per-turn summary with duration, tool outcomes, and token usage when available
|
|
104
|
+
- compact trace grouping so tool retries do not spam the status line
|
|
105
|
+
- formatted code-fence rendering with line numbers
|
|
106
|
+
- Headless pipe mode for one-shot automation:
|
|
107
|
+
- `-p` reads prompt from stdin or `--prompt`
|
|
108
|
+
- `--output-format text|json|stream-json`
|
|
109
|
+
- Production-readiness tracking page for the active P0/P1/P2 release matrix
|
|
110
|
+
|
|
111
|
+
## Quick start
|
|
112
|
+
|
|
113
|
+
User install (after the npm package is published):
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm install -g @tritard/waterbrother
|
|
117
|
+
waterbrother
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Source install for contributors:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
git clone https://github.com/PhillipHolland/waterbrother.git
|
|
124
|
+
cd waterbrother
|
|
125
|
+
npm install
|
|
126
|
+
npm link
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Start interactive mode (first run launches onboarding wizard):
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
waterbrother --approval on-request
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
One-shot prompt:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
waterbrother "inspect this project and explain the structure"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Non-interactive command forms:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
waterbrother exec "summarize the repository architecture"
|
|
145
|
+
waterbrother review "review changed files for bugs and missing tests"
|
|
146
|
+
waterbrother resume --last "continue and finish the previous task"
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Vision/web design prompt with local image:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
waterbrother vision ./mockup.png "Suggest concrete CSS and layout improvements"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Git workflow:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
waterbrother commit # stage, diff, generate commit message, confirm
|
|
159
|
+
waterbrother commit --push # same as above, then push
|
|
160
|
+
waterbrother pr # commit, push, generate PR title+body, create via gh
|
|
161
|
+
waterbrother pr --branch=my-feat # create branch first if on main, then PR
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Utility commands:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
waterbrother doctor
|
|
168
|
+
waterbrother models list
|
|
169
|
+
waterbrother models catalog
|
|
170
|
+
waterbrother mcp list
|
|
171
|
+
waterbrother onboarding
|
|
172
|
+
waterbrother update
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Web research examples:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
waterbrother "Read https://console.x.ai and summarize how to create an API key"
|
|
179
|
+
waterbrother "Search the web for the latest xAI API docs about vision support and cite the sources"
|
|
180
|
+
|
|
181
|
+
# interactive
|
|
182
|
+
/read https://console.x.ai/
|
|
183
|
+
/search latest xAI vision docs
|
|
184
|
+
/open 1
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Long-running session controls:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# inside interactive mode
|
|
191
|
+
/compact
|
|
192
|
+
/compact 32
|
|
193
|
+
/cost
|
|
194
|
+
/fork
|
|
195
|
+
/diff
|
|
196
|
+
/run inspect the project and summarize the architecture
|
|
197
|
+
/receipt-mode
|
|
198
|
+
/receipt-mode off
|
|
199
|
+
/contract
|
|
200
|
+
/receipts
|
|
201
|
+
/receipt last
|
|
202
|
+
/checkpoints
|
|
203
|
+
/rewind
|
|
204
|
+
/memory init
|
|
205
|
+
/memory add Always run tests before final answer.
|
|
206
|
+
/memory reload
|
|
207
|
+
|
|
208
|
+
# config tuning
|
|
209
|
+
waterbrother config set autoCompactThreshold 0.9
|
|
210
|
+
waterbrother config set traceMode verbose
|
|
211
|
+
waterbrother config set receiptMode verbose
|
|
212
|
+
waterbrother config set model grok-4.20-beta-0309-reasoning --scope project
|
|
213
|
+
waterbrother config set-json approvalPolicy '{"autoApprovePaths":["src/**"],"askPaths":["package.json"],"denyShellPatterns":["git\\s+reset\\s+--hard"]}' --scope project
|
|
214
|
+
waterbrother config set-json verification '{"commands":["npm run lint","npm test"],"timeoutMs":180000}' --scope project
|
|
215
|
+
waterbrother config set-json mcpServers '{"filesystem":{"command":"npx","args":["-y","@modelcontextprotocol/server-filesystem","."]}}' --scope project
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Pipe mode examples:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
printf 'summarize this repo' | waterbrother -p
|
|
222
|
+
printf 'read https://example.com and summarize it' | waterbrother -p --output-format json
|
|
223
|
+
printf 'inspect package.json' | waterbrother -p --output-format stream-json
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Config scope notes:
|
|
227
|
+
|
|
228
|
+
- `waterbrother config set ...` defaults to user scope (`~/.waterbrother/config.json`)
|
|
229
|
+
- add `--scope project` to save repo-local overrides in `.waterbrother/config.json`
|
|
230
|
+
- `waterbrother config get ...` and `waterbrother config list` default to merged runtime values
|
|
231
|
+
|
|
232
|
+
MCP setup example:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
waterbrother config set-json mcpServers '{"filesystem":{"command":"npx","args":["-y","@modelcontextprotocol/server-filesystem","."]}}' --scope project
|
|
236
|
+
waterbrother mcp list
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Task console
|
|
240
|
+
|
|
241
|
+
Waterbrother treats serious work as **tasks**, not chat turns.
|
|
242
|
+
|
|
243
|
+
### Commands
|
|
244
|
+
|
|
245
|
+
| Command | Description |
|
|
246
|
+
|---------|-------------|
|
|
247
|
+
| `/feature <name>` | Start a new task (creates branch, sets up tracking) |
|
|
248
|
+
| `/tasks` | List recent tasks |
|
|
249
|
+
| `/task` | Show active task details |
|
|
250
|
+
| `/decide [goal]` | Run decision pass — get structured implementation options |
|
|
251
|
+
| `/choose <option>` | Choose a decision option and lock contract |
|
|
252
|
+
| `/redecide` | Clear decision and re-plan |
|
|
253
|
+
| `/surgeon <paths...>` | Set contract scope directly, skip `/decide` |
|
|
254
|
+
| `/build <prompt>` | Execute within task contract |
|
|
255
|
+
| `/review` | Show structured review panel |
|
|
256
|
+
| `/challenge` | Adversarial re-review of last changes |
|
|
257
|
+
| `/accept` | Accept reviewed changes |
|
|
258
|
+
| `/tighten <paths...>` | Narrow contract scope |
|
|
259
|
+
| `/close` | Close the active task |
|
|
260
|
+
| `/panel` | Show/toggle operator panel |
|
|
261
|
+
|
|
262
|
+
### Typical flow
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
/feature auth-rework
|
|
266
|
+
/decide add Google login without breaking auth API
|
|
267
|
+
/choose minimal
|
|
268
|
+
/build implement the adapter layer
|
|
269
|
+
/review
|
|
270
|
+
/accept
|
|
271
|
+
/close
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Supported in this release:
|
|
275
|
+
|
|
276
|
+
- stdio MCP servers
|
|
277
|
+
- automatic tool discovery at startup
|
|
278
|
+
- tool routing through normal approval + trace flow
|
|
279
|
+
- interactive inspection with `/mcp`
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tritard/waterbrother",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Waterbrother: Grok-powered coding CLI with local tools, sessions, operator modes, and approval controls",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"waterbrother": "bin/waterbrother.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
"src/",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"package.json"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"start": "node bin/waterbrother.js",
|
|
18
|
+
"dev": "node --watch bin/waterbrother.js",
|
|
19
|
+
"check": "node -e \"import('./src/cli.js')\"",
|
|
20
|
+
"smoke": "node scripts/smoke.js",
|
|
21
|
+
"soak:long-session": "node scripts/long-session-soak.mjs"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/PhillipHolland/waterbrother.git"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/PhillipHolland/waterbrother#readme",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/PhillipHolland/waterbrother/issues"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"cli",
|
|
36
|
+
"grok",
|
|
37
|
+
"coding-agent",
|
|
38
|
+
"terminal",
|
|
39
|
+
"ai",
|
|
40
|
+
"mcp"
|
|
41
|
+
],
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"license": "MIT"
|
|
46
|
+
}
|