@brownie-labs/brownie 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Brownie Labs
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,174 @@
1
+ <h1 align="center">
2
+ <img alt="Brownie" src="https://raw.githubusercontent.com/brownie-labs/brownie/main/assets/brownie-logo.png" width="140"><br>
3
+ Brownie
4
+ </h1>
5
+
6
+ <p align="center">
7
+ <strong>Your household sprite for the work you keep putting off. It works while you're not looking.</strong><br>
8
+ <em>Not the cake. The spirit.</em>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/@brownie-labs/brownie"><img alt="npm" src="https://img.shields.io/npm/v/%40brownie-labs%2Fbrownie?logo=npm&color=CB3837"></a>
13
+ <a href="https://github.com/brownie-labs/brownie/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/brownie-labs/brownie/ci.yml?branch=main&logo=github&label=CI"></a>
14
+ <a href="https://github.com/brownie-labs/brownie/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/license-MIT-green"></a>
15
+ <img alt="Node" src="https://img.shields.io/badge/node-%E2%89%A522.16-339933?logo=node.js&logoColor=white">
16
+ </p>
17
+
18
+ <p align="center">
19
+ <img alt="Brownie demo" src="https://raw.githubusercontent.com/brownie-labs/brownie/main/assets/demo.gif" width="800">
20
+ </p>
21
+
22
+ Brownie is a CLI that cyclically runs [Claude Code](https://claude.com/claude-code) sessions in a two-agent setup: the **monitor** watches for tasks, the **executor** completes them, and the **summarizer** writes findings to long-term memory. You sleep — the sprite tidies up.
23
+
24
+ ```
25
+ every N minutes (only during working hours)
26
+
27
+
28
+ ┌───────────────┐ JSON report ┌───────────────┐
29
+ │ MONITOR │ ───────────────▶│ TaskStore │
30
+ │ (haiku) │ (tasks) │ tasks.json │
31
+ └───────────────┘ └───────┬───────┘
32
+ │ wakes (Waker)
33
+
34
+ ┌───────────────┐ session log ┌───────────────┐ pending │
35
+ │ SUMMARIZER │ ◀──────────── │ EXECUTOR │ ◀─────────┘
36
+ │ (sonnet) │ │ (opus) │
37
+ └───────┬───────┘ └───────┬───────┘
38
+ │ findings │ memory_search / memory_get
39
+ ▼ ▼
40
+ ┌───────────────────────────────────────────────┐
41
+ │ Memory (SQLite + FTS5) │
42
+ │ MCP server (stdio) │
43
+ └───────────────────────────────────────────────┘
44
+ ```
45
+
46
+ Two loops run in parallel and talk only through the shared task store: the monitor patrols your sources on an interval and reports tasks as structured JSON; the executor wakes the moment tasks land and completes them one by one, with full tool access and searchable memory of past sessions.
47
+
48
+ ## What can it do for you?
49
+
50
+ Whatever you describe in one markdown file. Some sprites people keep:
51
+
52
+ - **CI medic** — watch the pipeline on `main`, investigate red builds, open a fix PR.
53
+ - **Issue triager** — pick up well-scoped bug reports and turn them into pull requests.
54
+ - **Dependency groundskeeper** — notice pending patch updates, bump, run the tests.
55
+ - **Backlog sweeper** — work through `TODO`s, flaky tests, and lint debt while you build features.
56
+
57
+ The monitor's patrol is just a prompt:
58
+
59
+ ```markdown
60
+ 1. **CI on main** — run `gh run list --branch main --limit 5`. If the latest
61
+ run failed, report a task to investigate and fix it (id: `ci-<run-id>`).
62
+ 2. **Issues labeled `bug`** — for each issue describing a concrete,
63
+ self-contained change, report a task with id `issue-<number>`.
64
+ ```
65
+
66
+ Full examples and prompt-writing tips: [docs/prompts.md](https://github.com/brownie-labs/brownie/blob/main/docs/prompts.md).
67
+
68
+ ## Highlights
69
+
70
+ - 🔁 **Autonomous loop** — the monitor finds work, the executor does it; zero manual queuing (though `/task` adds work by hand).
71
+ - 🧠 **Long-term memory** — SQLite + FTS5 exposed to the executor over MCP; the sprite learns from its own sessions.
72
+ - 📺 **Interactive TUI** — a Claude-Code-style shell (Ink/React): live agent status, switchable views, slash commands.
73
+ - ⏰ **Working hours** — a time window and days of the week (`08:00-18:00`, `mon-fri`); outside them the monitor rests.
74
+ - 🔂 **Smart retries** — transient failures are retried, permanent ones fail fast; stalled tasks recover on restart.
75
+ - ⛔ **Usage-limit aware** — when Claude Code hits its 5-hour or weekly limit, both agents park with a countdown and resume automatically after the reset; interrupted tasks go back to the queue without burning a retry.
76
+ - 📝 **Prompts in files** — the entire personality lives in markdown, no prompts baked into the code.
77
+
78
+ ## Quick start
79
+
80
+ You need Node.js ≥ 22.16 (an official build — brownie's long-term memory needs SQLite with FTS5) and the [Claude Code CLI](https://claude.com/claude-code) (`claude`) installed and logged in.
81
+
82
+ ```bash
83
+ npm install -g @brownie-labs/brownie
84
+
85
+ cd your-project
86
+ brownie # first run asks for the two agent prompts, then opens the TUI
87
+ ```
88
+
89
+ The first-run wizard asks only two questions — what the monitor should watch and how the executor should work — in a multi-line editor built for pasting markdown (Enter adds a line, Ctrl+D submits). Everything else starts with sensible defaults you can change later with slash commands. Agents boot **paused** — nothing runs until you type `/start`.
90
+
91
+ Working from a clone instead: `pnpm install && pnpm start`.
92
+
93
+ ## The TUI
94
+
95
+ A shell in the style of Claude Code: a header with the live status of both agents (state, model, cost, task counters), a view in the middle, and a command input at the bottom (history, tab completion, pgup/pgdn scrolling):
96
+
97
+ | Command | Effect |
98
+ | ----------------------------- | ---------------------------------------------------------- |
99
+ | `/dashboard` | combined view: both agents + the task table |
100
+ | `/monitor`, `/executor` | one agent full-screen with its recent outcomes |
101
+ | `/tasks` | the full task list |
102
+ | `/memory [query]` | browse long-term memory, optionally filtered by FTS search |
103
+ | `/start [monitor\|executor]` | start paused agents — agents boot paused |
104
+ | `/pause [monitor\|executor]` | graceful pause — the current session finishes first |
105
+ | `/task <description>` | add a task by hand (the executor picks it up immediately) |
106
+ | `/retry <task-id>` | requeue a failed task |
107
+ | `/cancel <task-id>` | cancel a pending task |
108
+ | `/model <agent> <model>` | set the model for monitor, executor, or summarizer |
109
+ | `/effort <agent> <level>` | set the reasoning effort (`low`…`max`) |
110
+ | `/interval <minutes>` | set how often the monitor looks for new tasks |
111
+ | `/hours <HH:MM-HH:MM\|off>` | set the monitor working hours, `off` = 24/7 |
112
+ | `/days <days\|off>` | set the monitor working days (`mon-fri`), `off` = daily |
113
+ | `/prompt <monitor\|executor>` | view and edit an agent prompt — Ctrl+D saves, Esc closes |
114
+ | `/config` | show the current configuration |
115
+ | `/help` | list all commands |
116
+ | `/exit` | graceful shutdown (same as ctrl+c) |
117
+
118
+ Configuration commands persist to `.brownie/settings.json` and apply live — the next agent session already uses the new value, no restart needed.
119
+
120
+ ## Headless & servers
121
+
122
+ Without a TTY (systemd, Docker, CI, piping) brownie skips the dashboard, starts the agents immediately, and prints structured line logs to stdout — human-readable by default, NDJSON with `--log-format json` for log aggregators. A running worker is controlled from a second shell over a local control socket:
123
+
124
+ | Command | Effect |
125
+ | --------------------------------------------------------- | ------------------------------------------------------------- |
126
+ | `brownie` | start the worker (TUI in a terminal, headless without one) |
127
+ | `brownie --headless [--log-format json]` | force headless mode even in a terminal |
128
+ | `brownie init --monitor-prompt <f> --executor-prompt <f>` | non-interactive setup for servers (cloud-init, Ansible) |
129
+ | `brownie status [--json]` | live status of the running worker (doubles as a health check) |
130
+ | `brownie pause [monitor\|executor]` | graceful pause, same as `/pause` in the TUI |
131
+ | `brownie resume [monitor\|executor]` | resume paused agents |
132
+
133
+ A second `brownie` in the same project refuses to start while one is already running. The full server story — the NDJSON event schema, a DigitalOcean/systemd runbook, authentication without a browser, and the reference `Dockerfile` + `docker-compose.yml`: [docs/deployment.md](https://github.com/brownie-labs/brownie/blob/main/docs/deployment.md).
134
+
135
+ ## Configuration
136
+
137
+ Like Claude Code's `.claude/`, all per-project state lives in `.brownie/` inside the directory you run brownie from: `settings.json`, the two project prompts, and runtime data (tasks, memory, logs — gitignored automatically). The settings file is a zod-validated JSON where every section is optional — change it with the slash commands above or by hand:
138
+
139
+ ```json
140
+ {
141
+ "monitor": {
142
+ "intervalMinutes": 15,
143
+ "activeHours": "08:00-18:00",
144
+ "activeDays": "mon-fri"
145
+ },
146
+ "executor": { "model": "opus", "effort": "high" }
147
+ }
148
+ ```
149
+
150
+ All settings, the full directory layout, and what to commit: [docs/configuration.md](https://github.com/brownie-labs/brownie/blob/main/docs/configuration.md).
151
+
152
+ ## Security & costs
153
+
154
+ > **⚠️ The sprite works directly in your project.** Agent sessions run with `--permission-mode bypassPermissions` and full tool access **in the directory you run `brownie` from** — there is no isolated sandbox. Run it in projects you trust it with: well-considered prompts, no secrets within reach, version control as your safety net. Treat tasks reported by the monitor like any input to an autonomous agent — the prompts define the boundaries.
155
+
156
+ Brownie spends real tokens: every patrol is a session, every task is a session. Interval × models = your bill, so start conservative — a longer `intervalMinutes`, `sonnet` on the executor — and scale up once you trust the prompts. Working hours keep the sprite from patrolling an empty repo at 3 a.m.
157
+
158
+ ## Development
159
+
160
+ ```bash
161
+ pnpm dev # start with watch (tsx)
162
+ pnpm check # typecheck + lint + format:check + test — before every commit
163
+ pnpm build # tsup -> dist/
164
+ ```
165
+
166
+ Claude sessions are tested against a fake `claude` binary (`test/fixtures/claude`) — no real API calls. Coverage thresholds are enforced. See [CONTRIBUTING.md](https://github.com/brownie-labs/brownie/blob/main/CONTRIBUTING.md).
167
+
168
+ ## License
169
+
170
+ [MIT](https://github.com/brownie-labs/brownie/blob/main/LICENSE) © Brownie Labs
171
+
172
+ ## Why "Brownie"? 🧌
173
+
174
+ In British folklore a **brownie** is a household spirit that, at night — while the household sleeps — quietly finishes their work for them. It has two iron rules: it works unbidden, and it vanishes when watched. Ours is a touch more modern: instead of a bowl of milk it takes tokens, and instead of sweeping the room it closes out your tasks. Watching is allowed (that's what the dashboard is for).