queen-hive 0.2.0__tar.gz
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.
- queen_hive-0.2.0/LICENSE +21 -0
- queen_hive-0.2.0/MANIFEST.in +2 -0
- queen_hive-0.2.0/PKG-INFO +296 -0
- queen_hive-0.2.0/README.md +261 -0
- queen_hive-0.2.0/hive/.claude-plugin/marketplace.json +11 -0
- queen_hive-0.2.0/hive/__init__.py +13 -0
- queen_hive-0.2.0/hive/claude.py +51 -0
- queen_hive-0.2.0/hive/cli.py +512 -0
- queen_hive-0.2.0/hive/codex.py +409 -0
- queen_hive-0.2.0/hive/compare.py +147 -0
- queen_hive-0.2.0/hive/core/.claude-plugin/plugin.json +9 -0
- queen_hive-0.2.0/hive/core/agents/builder.md +24 -0
- queen_hive-0.2.0/hive/core/agents/reviewer.md +22 -0
- queen_hive-0.2.0/hive/core/agents/scout.md +18 -0
- queen_hive-0.2.0/hive/core/commands/hive.md +18 -0
- queen_hive-0.2.0/hive/core/commands/retro.md +4 -0
- queen_hive-0.2.0/hive/core/hooks/hooks.json +66 -0
- queen_hive-0.2.0/hive/core/rules/queen.md +123 -0
- queen_hive-0.2.0/hive/core/scripts/changes.py +50 -0
- queen_hive-0.2.0/hive/core/scripts/check.py +38 -0
- queen_hive-0.2.0/hive/core/scripts/events.py +188 -0
- queen_hive-0.2.0/hive/core/scripts/hivecore.py +199 -0
- queen_hive-0.2.0/hive/core/scripts/hivepath.py +16 -0
- queen_hive-0.2.0/hive/core/scripts/lastrun.py +60 -0
- queen_hive-0.2.0/hive/core/scripts/protect.py +177 -0
- queen_hive-0.2.0/hive/core/skills/init/SKILL.md +16 -0
- queen_hive-0.2.0/hive/core/skills/review/SKILL.md +22 -0
- queen_hive-0.2.0/hive/core/skills/waggle/SKILL.md +23 -0
- queen_hive-0.2.0/hive/dashboard/__init__.py +1 -0
- queen_hive-0.2.0/hive/dashboard/process.py +97 -0
- queen_hive-0.2.0/hive/dashboard/server.py +286 -0
- queen_hive-0.2.0/hive/dashboard/static/app.js +324 -0
- queen_hive-0.2.0/hive/dashboard/static/index.html +24 -0
- queen_hive-0.2.0/hive/dashboard/static/style.css +123 -0
- queen_hive-0.2.0/hive/folders.py +123 -0
- queen_hive-0.2.0/hive/gemini.py +298 -0
- queen_hive-0.2.0/hive/init.py +170 -0
- queen_hive-0.2.0/hive/job.py +138 -0
- queen_hive-0.2.0/hive/launch.py +197 -0
- queen_hive-0.2.0/hive/memory.py +49 -0
- queen_hive-0.2.0/hive/models.py +348 -0
- queen_hive-0.2.0/hive/modes.py +46 -0
- queen_hive-0.2.0/hive/portable.py +97 -0
- queen_hive-0.2.0/hive/pricing.py +66 -0
- queen_hive-0.2.0/hive/providers.py +109 -0
- queen_hive-0.2.0/hive/records.py +147 -0
- queen_hive-0.2.0/hive/render.py +121 -0
- queen_hive-0.2.0/hive/router.py +202 -0
- queen_hive-0.2.0/hive/stats.py +202 -0
- queen_hive-0.2.0/hive/transcript.py +285 -0
- queen_hive-0.2.0/hive/translate.py +102 -0
- queen_hive-0.2.0/hive/ui.py +47 -0
- queen_hive-0.2.0/hive/verify.py +47 -0
- queen_hive-0.2.0/pyproject.toml +59 -0
- queen_hive-0.2.0/queen_hive.egg-info/PKG-INFO +296 -0
- queen_hive-0.2.0/queen_hive.egg-info/SOURCES.txt +66 -0
- queen_hive-0.2.0/queen_hive.egg-info/dependency_links.txt +1 -0
- queen_hive-0.2.0/queen_hive.egg-info/entry_points.txt +2 -0
- queen_hive-0.2.0/queen_hive.egg-info/requires.txt +9 -0
- queen_hive-0.2.0/queen_hive.egg-info/top_level.txt +1 -0
- queen_hive-0.2.0/setup.cfg +4 -0
- queen_hive-0.2.0/tests/test_dashboard.py +95 -0
- queen_hive-0.2.0/tests/test_folders_init_modes.py +115 -0
- queen_hive-0.2.0/tests/test_launch.py +322 -0
- queen_hive-0.2.0/tests/test_local_models.py +200 -0
- queen_hive-0.2.0/tests/test_memory_and_protection.py +148 -0
- queen_hive-0.2.0/tests/test_providers.py +772 -0
- queen_hive-0.2.0/tests/test_stats_and_tracker.py +88 -0
queen_hive-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Roman Zadvornov
|
|
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.
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: queen-hive
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Queen Hive: a Queen model plans and verifies, cheap worker bees build, scout and review, in Claude Code, Codex or the Gemini CLI.
|
|
5
|
+
Author: Roman Zadvornov
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/rzadvornov/queen-hive
|
|
8
|
+
Project-URL: Documentation, https://github.com/rzadvornov/queen-hive/blob/main/docs/GUIDE.md
|
|
9
|
+
Project-URL: Issues, https://github.com/rzadvornov/queen-hive/issues
|
|
10
|
+
Keywords: claude-code,codex,gemini-cli,ai-agents,multi-agent,llm,code-review,orchestration
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Software Development
|
|
23
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: starlette>=0.37
|
|
28
|
+
Requires-Dist: uvicorn>=0.29
|
|
29
|
+
Requires-Dist: httpx>=0.27
|
|
30
|
+
Provides-Extra: bundled
|
|
31
|
+
Requires-Dist: claude-agent-sdk>=0.2.127; extra == "bundled"
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# 🐝 Queen Hive
|
|
37
|
+
|
|
38
|
+
**Guardrails, an independent review and cost tracking for AI coding agents, in Claude Code, Codex or the Gemini CLI.**
|
|
39
|
+
|
|
40
|
+
A Queen model breaks your goal into small briefs and sends cheap **worker bees** to build, scout and review. She re-runs every check herself, an independent review runs before anything is called done, hooks enforce what agents may not touch, and every job leaves a record of what was done, how it was verified and what it cost.
|
|
41
|
+
|
|
42
|
+
**It saves money with a top model as the Queen, not with a mid-tier one.** Compared like for like on [our benchmarks](#benchmarks), a hive with an Opus 5.5 Queen costs about 40% less than Opus 5.5 alone, with the same results, because the expensive model only coordinates while cheap bees do the reading and writing. With a mid-tier Queen such as Sonnet 5.5 there is little price gap left between her and the bees, so the hive's own turns (briefs, checks, review) cost more than they save: it uses more tokens than Sonnet 5.5 alone, about 25–30% more on the same results. Choose a mid-tier Queen for the guardrails and the review, not to save money.
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
<sub>The output of a real run from the [first benchmark](#benchmarks) (the defaults: Opus 5.5 Queen, full review), replayed faster (the run took 2 minutes).</sub>
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pipx install queen-hive
|
|
50
|
+
hive "Fix the failing tests in ~/projects/api"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## What it adds to a plain agent
|
|
54
|
+
|
|
55
|
+
- **Checks that aren't on trust.** Every brief comes with a runnable *Done when*, and the Queen re-runs it herself; a failing brief goes back with the error, at most 3 times, then she asks you.
|
|
56
|
+
- **An independent review on record:** reviewer bees that never see the builders' reports check the work from separate lenses (goal, correctness, tests, architecture, security …), and the Queen triages every finding.
|
|
57
|
+
- **Guards that are enforced, not requested:** hooks block edits to protected paths (your acceptance tests), keep scouts and reviewers read-only, and stop bees from changing the hive's own rules.
|
|
58
|
+
- **Cost and history you can see:** tokens and cost per stage, against single models (estimated, or measured side by side with `--compare`), a live dashboard and a run history.
|
|
59
|
+
- **One workflow on three providers:** the same rules, bees, guards and reports in Claude Code, Codex and the Gemini CLI.
|
|
60
|
+
- **Memory outside your repo** and a **retro** after each job that proposes rule fixes, applied only when you approve them.
|
|
61
|
+
|
|
62
|
+
**When to use it:** work where a missed defect costs more than the tokens, where you want a record of how a change was checked, or where agents must not touch certain files. **When not to:** quick, self-contained changes. A single model does those faster and cheaper.
|
|
63
|
+
|
|
64
|
+
## Benchmarks
|
|
65
|
+
|
|
66
|
+
Two benchmarks, both on Claude, published as they came out ([bench/](bench/)), with every hive run against single
|
|
67
|
+
models in copies of the same repo. The defaults: Opus 5.5 Queen, Haiku 5.5 bees, full review.
|
|
68
|
+
|
|
69
|
+
**1. Five small tasks** (bug fix, feature, multi-file feature, refactor, implement-from-spec), each with a product
|
|
70
|
+
owner's acceptance test the hive may not edit.
|
|
71
|
+
|
|
72
|
+
| Task | Hive (Opus 5.5 + Haiku 5.5 bees) | Claude Sonnet 5.5 alone | Claude Opus 5.5 alone |
|
|
73
|
+
|---|---|---|---|
|
|
74
|
+
| dates (bug fix) | ✅ $0.22 · 1.2m | ✅ $0.06 · 0.3m | ✅ $0.20 · 0.5m |
|
|
75
|
+
| discounts (feature) | ✅ $0.14 · 0.8m | ✅ $0.05 · 0.2m | ✅ $0.15 · 0.5m |
|
|
76
|
+
| inventory (multi-file feature) | ✅ $0.14 · 1.1m | ✅ $0.06 · 0.3m | ✅ $0.24 · 0.9m |
|
|
77
|
+
| reports (feature + refactor) | ✅ $0.22 · 2.2m | ✅ $0.07 · 0.3m | ✅ $0.35 · 1.3m |
|
|
78
|
+
| ttlcache (implement from spec) | ✅ $0.17 · 1.4m | ✅ $0.07 · 0.3m | ✅ $0.36 · 1.5m |
|
|
79
|
+
| **Total** | **5/5 passed · $0.89** | **5/5 passed · $0.30** | **5/5 passed · $1.30** |
|
|
80
|
+
|
|
81
|
+
**2. Four realistic issues, scored on hidden tests** ([design](bench/HARDER.md)): a vague "totals are off in summer"
|
|
82
|
+
bug (daylight saving), an upload path-traversal fix (symlinks, absolute paths, names like `..hidden` that must keep
|
|
83
|
+
working), a 5× speed-up with byte-identical output, and multi-currency invoices (rounding, JPY). Agents saw only the
|
|
84
|
+
issue and the visible tests; hidden and regression tests were run afterwards. "hive sonnet" is a Sonnet 5.5 Queen
|
|
85
|
+
(light review, her default).
|
|
86
|
+
|
|
87
|
+
Each cell: hidden tests passed · regressions · cost · time.
|
|
88
|
+
|
|
89
|
+
| Task | hive | Claude Sonnet 5.5 alone | Claude Opus 5.5 alone | hive sonnet |
|
|
90
|
+
|---|---|---|---|---|
|
|
91
|
+
| invoices | 100% · 0 · $0.32 · 4.4m | 100% · 0 · $0.11 · 0.5m | 100% · 0 · $0.52 · 2.6m | 100% · 0 · $0.12 · 3.4m |
|
|
92
|
+
| ledger | 100% · 0 · $0.14 · 1.3m | 100% · 0 · $0.05 · 0.2m | 100% · 0 · $0.18 · 0.6m | 100% · 0 · $0.06 · 1.0m |
|
|
93
|
+
| report | 100% · 0 · $0.14 · 1.6m | 100% · 0 · $0.05 · 0.5m | 100% · 0 · $0.63 · 0.2m | 100% · 0 · $0.15 · 8.7m |
|
|
94
|
+
| uploads | 100% · 0 · $0.13 · 0.9m | 100% · 0 · $0.06 · 0.3m | 100% · 0 · $0.17 · 0.6m | 100% · 0 · $0.07 · 1.7m |
|
|
95
|
+
| **Total** | **4/4 correct · $0.72** · $0.18 per correct task | **4/4 correct · $0.26** · $0.06 per correct task | **4/4 correct · $1.49** · $0.37 per correct task | **4/4 correct · $0.41** · $0.10 per correct task |
|
|
96
|
+
|
|
97
|
+
**How the hive got here.** The first runs cost 3× Opus alone: the Queen read files, diffs and test logs herself, so
|
|
98
|
+
she spent more than one model alone on the whole task. Four rounds of changes, each measured on the same nine tasks:
|
|
99
|
+
|
|
100
|
+
Compared like for like, the hive's Queen against the same model alone:
|
|
101
|
+
|
|
102
|
+
| | Hive with an Opus 5.5 Queen, 9 tasks | Opus 5.5 alone |
|
|
103
|
+
|---|---|---|
|
|
104
|
+
| First version | $8.88 | $3.01 |
|
|
105
|
+
| 1. The Queen coordinates and bees read; checks return only the verdict; 5-minute cache for headless runs | (interrupted) | |
|
|
106
|
+
| 2. Queen effort capped at `high`; no automatic second review round; 4-line reviewer briefs | $2.94 | $2.66 |
|
|
107
|
+
| 3. Review sized to the change; headless runs without your personal setup | $2.05 | $2.90 |
|
|
108
|
+
| 4. The request passed to bees word for word; bees in the foreground; no waiting or closing turns (the hive writes the progress note) | **9/9 correct · $1.61** | 9/9 · $2.79 |
|
|
109
|
+
|
|
110
|
+
With a Sonnet 5.5 Queen, measured the same way on all nine tasks against Sonnet 5.5 alone:
|
|
111
|
+
|
|
112
|
+
| | Hive with a Sonnet 5.5 Queen, 9 tasks | Sonnet 5.5 alone |
|
|
113
|
+
|---|---|---|
|
|
114
|
+
| Full review | 8/9 correct · $1.07 | 9/9 · $0.67 |
|
|
115
|
+
| Light review by default, a lighter rule set, the request passed to bees word for word | 9/9 correct · $0.97 | 9/9 · $0.67 |
|
|
116
|
+
| Bees in the foreground (no extra turn per report), no waiting turns | 9/9 correct · $0.74 | 9/9 · $0.59 |
|
|
117
|
+
| No closing turn (the hive writes the progress note), 4-line summary | **9/9 correct · $0.85** | 9/9 · $0.66 |
|
|
118
|
+
|
|
119
|
+
The miss in the first row taught a lesson: the Queen, who no longer reads the code, had narrowed "the rates in
|
|
120
|
+
rates.json" to the currencies the issue named. Briefs now carry the user's request word for word and point to sources
|
|
121
|
+
instead of restating them. The last row came from tracing the Queen's turns: bees ran in the background, so each report woke her with an extra
|
|
122
|
+
turn, and she spent turns waiting. The last Sonnet row is within run-to-run noise of the one before: the Sonnet-Queen hive
|
|
123
|
+
stays about 25–30% dearer than Sonnet alone, a few cents per task, because a Queen still needs a few turns of her own
|
|
124
|
+
(brief, check, review, summary). With an Opus Queen the same changes paid off: about 40% less than Opus alone.
|
|
125
|
+
|
|
126
|
+
Apart from that one miss, every variant passed every task in every round, so these tasks show cost, not quality: on self-contained work of this
|
|
127
|
+
size the hive's checks and review didn't change a result. Each figure is one run per task, and single runs vary
|
|
128
|
+
(Opus alone cost $0.33–0.59 on the same task across rounds). Costs are the API-equivalent price on a Claude
|
|
129
|
+
subscription.
|
|
130
|
+
|
|
131
|
+
## Install
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pipx install queen-hive # or: pip install queen-hive
|
|
135
|
+
hive doctor # is your provider's CLI installed and signed in?
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Requirements: **Python 3.10+**, **macOS or Linux**, and at least one of Claude Code, the Codex CLI or the Gemini CLI, signed in ([Provider setup](#provider-setup)).
|
|
139
|
+
|
|
140
|
+
<details>
|
|
141
|
+
<summary>Install from source, or check your Python version</summary>
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
git clone https://github.com/rzadvornov/queen-hive.git ~/queen-hive && cd ~/queen-hive
|
|
145
|
+
python3 -m venv .venv # or python3.12 -m venv .venv, see below
|
|
146
|
+
.venv/bin/pip install -e .
|
|
147
|
+
ln -s ~/queen-hive/.venv/bin/hive /usr/local/bin/hive # macOS (may need sudo)
|
|
148
|
+
mkdir -p ~/.local/bin && ln -s ~/queen-hive/.venv/bin/hive ~/.local/bin/hive # Linux, if ~/.local/bin is on PATH
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`python3 --version` must show 3.10 or higher. macOS ships 3.9 with the Xcode tools; install a newer one:
|
|
152
|
+
|
|
153
|
+
| OS | Install a newer Python |
|
|
154
|
+
|---|---|
|
|
155
|
+
| macOS | `brew install python@3.12`, or the installer from [python.org](https://www.python.org/downloads/) |
|
|
156
|
+
| Ubuntu / Debian | `sudo apt update && sudo apt install python3.12 python3.12-venv`. On older releases, add the `deadsnakes` PPA first: `sudo add-apt-repository ppa:deadsnakes/ppa` |
|
|
157
|
+
| Fedora | `sudo dnf install python3.12` |
|
|
158
|
+
| Any OS | [pyenv](https://github.com/pyenv/pyenv): `pyenv install 3.12` then `pyenv local 3.12` in the repo |
|
|
159
|
+
|
|
160
|
+
The new version usually doesn't replace `python3`: call it by its full name when you create the venv (`python3.12 -m venv .venv`). If `pip install -e .` says `requires a different Python`, delete `.venv` and create it again with the newer one.
|
|
161
|
+
</details>
|
|
162
|
+
|
|
163
|
+
## Quick start
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
hive # first run: pick Claude, GPT or Gemini, then a folder
|
|
167
|
+
hive models --check # which models your login can use
|
|
168
|
+
hive "Explain how this project is structured" -d ~/some/project
|
|
169
|
+
hive "Add a /health endpoint" --headless --done "npm test" # scripts and CI: no interface, stops at the end
|
|
170
|
+
hive review # independent review of your uncommitted changes
|
|
171
|
+
hive dashboard # live view, history, comparisons (runs in the background)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
`hive` opens your provider's own CLI with the Queen's rules and the bees loaded, so you work in the interface you already know. When you exit, it checks the result and reports each job:
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
🐝 Hive (Claude Opus 5.5 + Claude Haiku 5.5) ✅ $0.60 2.0m
|
|
178
|
+
└ queen ≈$0.58 · review ≈$0.02
|
|
179
|
+
⚖️ Claude Opus 5.5 alone ✅ $0.25 0.8m
|
|
180
|
+
acceptance ✅ $ python3 -m unittest discover -s acceptance -t .
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+

|
|
184
|
+
|
|
185
|
+
## Provider setup
|
|
186
|
+
|
|
187
|
+
The first `hive` asks which AI runs the hive and remembers the answer, so it doesn't ask again:
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
🤖 Which AI should run the hive? (change it later with `hive provider`)
|
|
191
|
+
❯ 1) Claude Claude Code
|
|
192
|
+
2) GPT Codex CLI
|
|
193
|
+
3) Gemini Gemini CLI
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
| Change it | Command |
|
|
197
|
+
|---|---|
|
|
198
|
+
| Switch for good | `hive provider gpt` (or `claude`, `gemini`); `hive provider` alone shows the menu |
|
|
199
|
+
| One run only | `hive "…" --provider gemini` |
|
|
200
|
+
| Pick by model | `hive "…" --queen gpt-5.4` uses that model's provider |
|
|
201
|
+
|
|
202
|
+
Each provider remembers its own last Queen and bee model. A Queen and her bees always come from one provider.
|
|
203
|
+
|
|
204
|
+
| Provider | Default Queen | Default bees |
|
|
205
|
+
|---|---|---|
|
|
206
|
+
| Claude | Claude Opus 5.5 | Claude Haiku 5.5 |
|
|
207
|
+
| GPT | GPT-5.5 with an API key; with a ChatGPT plan, the plan's own model (for example GPT-5.6-Terra) | GPT-6 Luna |
|
|
208
|
+
| Gemini | Gemini 3.1 Pro | Gemini 3.5 Flash-Lite |
|
|
209
|
+
|
|
210
|
+
All bees get the Haiku bees' settings, taken from `hive/core/agents/*.md`: medium effort (in the Gemini CLI, a medium thinking level), and in Codex compaction at 100k tokens.
|
|
211
|
+
|
|
212
|
+
### Claude (Claude Code)
|
|
213
|
+
|
|
214
|
+
1. Install [Claude Code](https://code.claude.com), or use the hive's own copy: `.venv/bin/pip install -e ".[bundled]"`.
|
|
215
|
+
2. Sign in: run `claude` and `/login`, or set `ANTHROPIC_API_KEY`.
|
|
216
|
+
3. `hive provider claude`, then `hive doctor`.
|
|
217
|
+
|
|
218
|
+
### GPT (Codex CLI)
|
|
219
|
+
|
|
220
|
+
1. Install it: `npm install -g @openai/codex`.
|
|
221
|
+
2. Sign in: `codex login` (ChatGPT plan), or set `OPENAI_API_KEY`.
|
|
222
|
+
3. `hive provider gpt`, then `hive models --check`. A ChatGPT plan can't use the API models (GPT-5.5 …). The hive adds the models your plan offers (it reads them from Codex) and uses them by default.
|
|
223
|
+
4. **Approve the hive's hooks once.** Codex runs hooks only after you approve them, and the hive's hooks guard protected paths, keep reviewers read-only and write the live log. Run this from any folder, approve the hooks when Codex asks (or type `/hooks`), then quit:
|
|
224
|
+
```bash
|
|
225
|
+
CODEX_HOME=~/.hive/codex codex
|
|
226
|
+
```
|
|
227
|
+
Until you do, GPT runs don't guard protected paths: in a test, a GPT run wrote a protected `.env`, and once the hooks were approved the same write was blocked. `hive` warns on each GPT run until then.
|
|
228
|
+
5. `hive doctor` should show `hooks: approved`.
|
|
229
|
+
|
|
230
|
+
If Codex keeps your login in the system keychain rather than in `~/.codex/auth.json`, sign in once for the hive: `CODEX_HOME=~/.hive/codex codex login`.
|
|
231
|
+
|
|
232
|
+
### Gemini (Gemini CLI)
|
|
233
|
+
|
|
234
|
+
1. Install it: `npm install -g @google/gemini-cli`.
|
|
235
|
+
2. Create an API key in [Google AI Studio](https://aistudio.google.com/apikey) and export it in your shell's startup file:
|
|
236
|
+
```bash
|
|
237
|
+
echo 'export GEMINI_API_KEY="…"' >> ~/.zshrc # bash: ~/.bashrc
|
|
238
|
+
```
|
|
239
|
+
Google no longer serves the Gemini CLI to personal Google logins, so the key (or Vertex AI credentials) is needed. Put it in `~/.zshrc` rather than only `~/.zprofile`, which some terminals and tools don't read.
|
|
240
|
+
3. `hive provider gemini`, then `hive models --check`.
|
|
241
|
+
4. `hive doctor` warns if `GEMINI_API_KEY` isn't set.
|
|
242
|
+
|
|
243
|
+
### Where provider settings live
|
|
244
|
+
|
|
245
|
+
| What | Where |
|
|
246
|
+
|---|---|
|
|
247
|
+
| Your provider choice and last models | `~/.hive/state.json` |
|
|
248
|
+
| The hive's Codex home (bees, hooks, skills, sessions; your login linked in) | `~/.hive/codex` |
|
|
249
|
+
| The hive's Gemini home (one folder per session in `sessions/`, chat logs shared in `.gemini/tmp`) | `~/.hive/gemini` |
|
|
250
|
+
| Your own prices and local models | `~/.hive/models.json` |
|
|
251
|
+
|
|
252
|
+
Your own `~/.codex` and `~/.gemini` are never edited. GPT and Gemini prices come from price trackers, not the providers' pages, and models a ChatGPT plan offers show as $0 because a plan isn't billed per token. Set your own prices in `~/.hive/models.json` (the numbers below are only an example):
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
{"prices": {"gpt-5.6-terra": {"input": 2, "output": 12, "cache_read": 0.2}}}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Claude, GPT and Gemini compared
|
|
259
|
+
|
|
260
|
+
| | Claude | GPT | Gemini |
|
|
261
|
+
|---|---|---|---|
|
|
262
|
+
| Runs in | Claude Code | Codex CLI | Gemini CLI |
|
|
263
|
+
| Cost in the report | exact, from Claude Code | estimated from tokens × list price ($0 on a ChatGPT plan) | estimated from tokens × list price |
|
|
264
|
+
| Protected paths | hook | hook, once approved | hook |
|
|
265
|
+
| Read-only scouts | hook | Codex sandbox (read-only role) | tool list (no write or shell tools) |
|
|
266
|
+
| Read-only reviewers | hook | hook, once approved | instructions only (the CLI doesn't say which bee runs a tool) |
|
|
267
|
+
| Live log | bees when they start and report, commands with ✅/❌ | bees when they report, commands without ✅/❌ (Codex's hooks don't say either) | bees when they start and report, commands with ✅/❌ |
|
|
268
|
+
| Network for commands | yes | in `plan` and `auto` mode; not in `ask` mode or with `--sandbox` | yes |
|
|
269
|
+
| `--budget` cap, `--compare`, local bees | yes | no | no |
|
|
270
|
+
|
|
271
|
+
> GPT and Gemini have been run against signed-in CLIs (Codex 0.171, Gemini CLI 0.65) on small jobs only, so expect rough edges and run `hive doctor` first.
|
|
272
|
+
|
|
273
|
+
## What you get
|
|
274
|
+
|
|
275
|
+
- **Choose your AI and your Queen:** Claude (Fable 5.1, Opus 5.5, Sonnet 5.5 …), GPT (GPT-5.5, GPT-5.4 …, or your ChatGPT plan's models) or Gemini (Gemini 3.1 Pro, 3.8 Flash …). Any kind of bee can run on another model of the same provider (`--scout`, `--builder`, `--reviewer`). With any of the three, a bee can also run on a **local model** through Ollama, llama.cpp or LM Studio (`--scout qwen-coder`): a router on localhost sends only that bee's requests to it, and its tokens cost nothing.
|
|
276
|
+
- **Runs in the CLI itself:** `hive` opens Claude Code, Codex or the Gemini CLI with the Queen's rules, the bees, the hooks and the skills loaded, then reports and records each job when you exit. Scripts and CI get a headless mode (`--headless`). In Claude Code there's also a `/queen-hive:hive` plugin command.
|
|
277
|
+
- **👑 and 🐝 in the chat:** on every provider the Queen starts her messages with 👑 and names bees with their icon (🔎 scout, 🔨 builder, 🧐 reviewer), and bees start their reports with `🐝 <brief ID>`. The Gemini CLI shows bees as "🔎 Scout bee" and so on; Codex as "Scout bee" (it allows no emoji in names).
|
|
278
|
+
- **Autonomy modes:** `plan` (you approve the briefs), `auto`, or `ask` (risky actions need a y/n).
|
|
279
|
+
- **Briefs with "Done when":** every brief comes with a runnable check. The Queen re-runs each check herself and returns a brief at most 3 times before asking you.
|
|
280
|
+
- **Independent review:** reviewer bees check the finished work from separate lenses (goal, correctness, tests, architecture, performance, rules, security), or only goal and tests with `--review light` (the default for a Sonnet 5.5 Queen). They don't see the builders' reports. `hive review` runs the same review on any diff, branch or PR.
|
|
281
|
+
- **Protected paths:** for example your acceptance tests. A hook blocks file edits to them, and shell writes as far as a parse of the command can tell.
|
|
282
|
+
- **Memory outside your project:** kept in `~/.hive/projects/…`. After each job, a retro (`waggle`) proposes rule fixes and applies only those you approve. Skip it with `--no-waggle`.
|
|
283
|
+
- **Statistics:** tokens and cost per stage. Each job is compared with single models, either estimated or, with `--compare` (Claude only for now), as real side-by-side runs.
|
|
284
|
+
|
|
285
|
+
## Safety: what is enforced and what isn't
|
|
286
|
+
|
|
287
|
+
- **Permissions are the CLI's.** In Claude Code, edits outside the granted folders need your approval, and in `auto` mode shell commands run without asking. Use `ask` mode, or `--sandbox` (writes only inside the granted folders), on machines that matter. Codex always sandboxes commands to the granted folders, with network in `plan` and `auto` mode only. The Gemini CLI runs them unsandboxed unless you pass `--sandbox`. In a headless run in `ask` mode, Claude Code and the Gemini CLI refuse risky actions; Codex runs them inside its sandbox.
|
|
288
|
+
- **Your code goes to the provider you chose:** Anthropic, OpenAI or Google, under that provider's terms.
|
|
289
|
+
- **Hooks are guards, not a sandbox.** The protected-path and read-only-bee checks parse shell commands; a command such as `python -c "…"` can write without being noticed. `--sandbox` is the real boundary. On GPT the hooks only run once you've approved them (see [GPT setup](#gpt-codex-cli)).
|
|
290
|
+
- **Acceptance commands run on your machine.** After a session the hive itself runs the acceptance commands with your shell, outside the CLI's permissions. Yours (`--done`, the profile's `test` command) always run. The Queen's own run automatically only in `plan` and `auto` mode without `--sandbox`, where she could have run them in the session anyway. In `ask` mode or with `--sandbox` you're asked first (default no), and headless runs skip them.
|
|
291
|
+
- **Memory feeds every later session.** The Queen writes `known-issues.md`, `decisions.md` and `progress.md`, and they go into her instructions next time. The end-of-session report lists every line she added (📝), so you can catch an instruction planted by code you don't trust.
|
|
292
|
+
- **`--compare` copies are contained.** Links that lead out of a copy are removed, and with `--sandbox` the solo models run sandboxed too.
|
|
293
|
+
- **Only the Queen changes the hive.** Retro edits to the hive's rules and bees are applied by the Queen after you approve them; the protect hook denies any bee that tries (except in the Gemini CLI, which doesn't say which bee is calling).
|
|
294
|
+
- **Everything stays local.** Memory, run logs and the dashboard never leave your machine, and `~/.hive` is owner-only. The dashboard listens on `127.0.0.1` and answers only its own pages, so other websites can't read it or trigger paid model checks. Local models get no login headers.
|
|
295
|
+
|
|
296
|
+
📖 **Full guide: [docs/GUIDE.md](https://github.com/rzadvornov/queen-hive/blob/main/docs/GUIDE.md)**
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# 🐝 Queen Hive
|
|
2
|
+
|
|
3
|
+
**Guardrails, an independent review and cost tracking for AI coding agents, in Claude Code, Codex or the Gemini CLI.**
|
|
4
|
+
|
|
5
|
+
A Queen model breaks your goal into small briefs and sends cheap **worker bees** to build, scout and review. She re-runs every check herself, an independent review runs before anything is called done, hooks enforce what agents may not touch, and every job leaves a record of what was done, how it was verified and what it cost.
|
|
6
|
+
|
|
7
|
+
**It saves money with a top model as the Queen, not with a mid-tier one.** Compared like for like on [our benchmarks](#benchmarks), a hive with an Opus 5.5 Queen costs about 40% less than Opus 5.5 alone, with the same results, because the expensive model only coordinates while cheap bees do the reading and writing. With a mid-tier Queen such as Sonnet 5.5 there is little price gap left between her and the bees, so the hive's own turns (briefs, checks, review) cost more than they save: it uses more tokens than Sonnet 5.5 alone, about 25–30% more on the same results. Choose a mid-tier Queen for the guardrails and the review, not to save money.
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
<sub>The output of a real run from the [first benchmark](#benchmarks) (the defaults: Opus 5.5 Queen, full review), replayed faster (the run took 2 minutes).</sub>
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pipx install queen-hive
|
|
15
|
+
hive "Fix the failing tests in ~/projects/api"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## What it adds to a plain agent
|
|
19
|
+
|
|
20
|
+
- **Checks that aren't on trust.** Every brief comes with a runnable *Done when*, and the Queen re-runs it herself; a failing brief goes back with the error, at most 3 times, then she asks you.
|
|
21
|
+
- **An independent review on record:** reviewer bees that never see the builders' reports check the work from separate lenses (goal, correctness, tests, architecture, security …), and the Queen triages every finding.
|
|
22
|
+
- **Guards that are enforced, not requested:** hooks block edits to protected paths (your acceptance tests), keep scouts and reviewers read-only, and stop bees from changing the hive's own rules.
|
|
23
|
+
- **Cost and history you can see:** tokens and cost per stage, against single models (estimated, or measured side by side with `--compare`), a live dashboard and a run history.
|
|
24
|
+
- **One workflow on three providers:** the same rules, bees, guards and reports in Claude Code, Codex and the Gemini CLI.
|
|
25
|
+
- **Memory outside your repo** and a **retro** after each job that proposes rule fixes, applied only when you approve them.
|
|
26
|
+
|
|
27
|
+
**When to use it:** work where a missed defect costs more than the tokens, where you want a record of how a change was checked, or where agents must not touch certain files. **When not to:** quick, self-contained changes. A single model does those faster and cheaper.
|
|
28
|
+
|
|
29
|
+
## Benchmarks
|
|
30
|
+
|
|
31
|
+
Two benchmarks, both on Claude, published as they came out ([bench/](bench/)), with every hive run against single
|
|
32
|
+
models in copies of the same repo. The defaults: Opus 5.5 Queen, Haiku 5.5 bees, full review.
|
|
33
|
+
|
|
34
|
+
**1. Five small tasks** (bug fix, feature, multi-file feature, refactor, implement-from-spec), each with a product
|
|
35
|
+
owner's acceptance test the hive may not edit.
|
|
36
|
+
|
|
37
|
+
| Task | Hive (Opus 5.5 + Haiku 5.5 bees) | Claude Sonnet 5.5 alone | Claude Opus 5.5 alone |
|
|
38
|
+
|---|---|---|---|
|
|
39
|
+
| dates (bug fix) | ✅ $0.22 · 1.2m | ✅ $0.06 · 0.3m | ✅ $0.20 · 0.5m |
|
|
40
|
+
| discounts (feature) | ✅ $0.14 · 0.8m | ✅ $0.05 · 0.2m | ✅ $0.15 · 0.5m |
|
|
41
|
+
| inventory (multi-file feature) | ✅ $0.14 · 1.1m | ✅ $0.06 · 0.3m | ✅ $0.24 · 0.9m |
|
|
42
|
+
| reports (feature + refactor) | ✅ $0.22 · 2.2m | ✅ $0.07 · 0.3m | ✅ $0.35 · 1.3m |
|
|
43
|
+
| ttlcache (implement from spec) | ✅ $0.17 · 1.4m | ✅ $0.07 · 0.3m | ✅ $0.36 · 1.5m |
|
|
44
|
+
| **Total** | **5/5 passed · $0.89** | **5/5 passed · $0.30** | **5/5 passed · $1.30** |
|
|
45
|
+
|
|
46
|
+
**2. Four realistic issues, scored on hidden tests** ([design](bench/HARDER.md)): a vague "totals are off in summer"
|
|
47
|
+
bug (daylight saving), an upload path-traversal fix (symlinks, absolute paths, names like `..hidden` that must keep
|
|
48
|
+
working), a 5× speed-up with byte-identical output, and multi-currency invoices (rounding, JPY). Agents saw only the
|
|
49
|
+
issue and the visible tests; hidden and regression tests were run afterwards. "hive sonnet" is a Sonnet 5.5 Queen
|
|
50
|
+
(light review, her default).
|
|
51
|
+
|
|
52
|
+
Each cell: hidden tests passed · regressions · cost · time.
|
|
53
|
+
|
|
54
|
+
| Task | hive | Claude Sonnet 5.5 alone | Claude Opus 5.5 alone | hive sonnet |
|
|
55
|
+
|---|---|---|---|---|
|
|
56
|
+
| invoices | 100% · 0 · $0.32 · 4.4m | 100% · 0 · $0.11 · 0.5m | 100% · 0 · $0.52 · 2.6m | 100% · 0 · $0.12 · 3.4m |
|
|
57
|
+
| ledger | 100% · 0 · $0.14 · 1.3m | 100% · 0 · $0.05 · 0.2m | 100% · 0 · $0.18 · 0.6m | 100% · 0 · $0.06 · 1.0m |
|
|
58
|
+
| report | 100% · 0 · $0.14 · 1.6m | 100% · 0 · $0.05 · 0.5m | 100% · 0 · $0.63 · 0.2m | 100% · 0 · $0.15 · 8.7m |
|
|
59
|
+
| uploads | 100% · 0 · $0.13 · 0.9m | 100% · 0 · $0.06 · 0.3m | 100% · 0 · $0.17 · 0.6m | 100% · 0 · $0.07 · 1.7m |
|
|
60
|
+
| **Total** | **4/4 correct · $0.72** · $0.18 per correct task | **4/4 correct · $0.26** · $0.06 per correct task | **4/4 correct · $1.49** · $0.37 per correct task | **4/4 correct · $0.41** · $0.10 per correct task |
|
|
61
|
+
|
|
62
|
+
**How the hive got here.** The first runs cost 3× Opus alone: the Queen read files, diffs and test logs herself, so
|
|
63
|
+
she spent more than one model alone on the whole task. Four rounds of changes, each measured on the same nine tasks:
|
|
64
|
+
|
|
65
|
+
Compared like for like, the hive's Queen against the same model alone:
|
|
66
|
+
|
|
67
|
+
| | Hive with an Opus 5.5 Queen, 9 tasks | Opus 5.5 alone |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| First version | $8.88 | $3.01 |
|
|
70
|
+
| 1. The Queen coordinates and bees read; checks return only the verdict; 5-minute cache for headless runs | (interrupted) | |
|
|
71
|
+
| 2. Queen effort capped at `high`; no automatic second review round; 4-line reviewer briefs | $2.94 | $2.66 |
|
|
72
|
+
| 3. Review sized to the change; headless runs without your personal setup | $2.05 | $2.90 |
|
|
73
|
+
| 4. The request passed to bees word for word; bees in the foreground; no waiting or closing turns (the hive writes the progress note) | **9/9 correct · $1.61** | 9/9 · $2.79 |
|
|
74
|
+
|
|
75
|
+
With a Sonnet 5.5 Queen, measured the same way on all nine tasks against Sonnet 5.5 alone:
|
|
76
|
+
|
|
77
|
+
| | Hive with a Sonnet 5.5 Queen, 9 tasks | Sonnet 5.5 alone |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| Full review | 8/9 correct · $1.07 | 9/9 · $0.67 |
|
|
80
|
+
| Light review by default, a lighter rule set, the request passed to bees word for word | 9/9 correct · $0.97 | 9/9 · $0.67 |
|
|
81
|
+
| Bees in the foreground (no extra turn per report), no waiting turns | 9/9 correct · $0.74 | 9/9 · $0.59 |
|
|
82
|
+
| No closing turn (the hive writes the progress note), 4-line summary | **9/9 correct · $0.85** | 9/9 · $0.66 |
|
|
83
|
+
|
|
84
|
+
The miss in the first row taught a lesson: the Queen, who no longer reads the code, had narrowed "the rates in
|
|
85
|
+
rates.json" to the currencies the issue named. Briefs now carry the user's request word for word and point to sources
|
|
86
|
+
instead of restating them. The last row came from tracing the Queen's turns: bees ran in the background, so each report woke her with an extra
|
|
87
|
+
turn, and she spent turns waiting. The last Sonnet row is within run-to-run noise of the one before: the Sonnet-Queen hive
|
|
88
|
+
stays about 25–30% dearer than Sonnet alone, a few cents per task, because a Queen still needs a few turns of her own
|
|
89
|
+
(brief, check, review, summary). With an Opus Queen the same changes paid off: about 40% less than Opus alone.
|
|
90
|
+
|
|
91
|
+
Apart from that one miss, every variant passed every task in every round, so these tasks show cost, not quality: on self-contained work of this
|
|
92
|
+
size the hive's checks and review didn't change a result. Each figure is one run per task, and single runs vary
|
|
93
|
+
(Opus alone cost $0.33–0.59 on the same task across rounds). Costs are the API-equivalent price on a Claude
|
|
94
|
+
subscription.
|
|
95
|
+
|
|
96
|
+
## Install
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pipx install queen-hive # or: pip install queen-hive
|
|
100
|
+
hive doctor # is your provider's CLI installed and signed in?
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Requirements: **Python 3.10+**, **macOS or Linux**, and at least one of Claude Code, the Codex CLI or the Gemini CLI, signed in ([Provider setup](#provider-setup)).
|
|
104
|
+
|
|
105
|
+
<details>
|
|
106
|
+
<summary>Install from source, or check your Python version</summary>
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
git clone https://github.com/rzadvornov/queen-hive.git ~/queen-hive && cd ~/queen-hive
|
|
110
|
+
python3 -m venv .venv # or python3.12 -m venv .venv, see below
|
|
111
|
+
.venv/bin/pip install -e .
|
|
112
|
+
ln -s ~/queen-hive/.venv/bin/hive /usr/local/bin/hive # macOS (may need sudo)
|
|
113
|
+
mkdir -p ~/.local/bin && ln -s ~/queen-hive/.venv/bin/hive ~/.local/bin/hive # Linux, if ~/.local/bin is on PATH
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`python3 --version` must show 3.10 or higher. macOS ships 3.9 with the Xcode tools; install a newer one:
|
|
117
|
+
|
|
118
|
+
| OS | Install a newer Python |
|
|
119
|
+
|---|---|
|
|
120
|
+
| macOS | `brew install python@3.12`, or the installer from [python.org](https://www.python.org/downloads/) |
|
|
121
|
+
| Ubuntu / Debian | `sudo apt update && sudo apt install python3.12 python3.12-venv`. On older releases, add the `deadsnakes` PPA first: `sudo add-apt-repository ppa:deadsnakes/ppa` |
|
|
122
|
+
| Fedora | `sudo dnf install python3.12` |
|
|
123
|
+
| Any OS | [pyenv](https://github.com/pyenv/pyenv): `pyenv install 3.12` then `pyenv local 3.12` in the repo |
|
|
124
|
+
|
|
125
|
+
The new version usually doesn't replace `python3`: call it by its full name when you create the venv (`python3.12 -m venv .venv`). If `pip install -e .` says `requires a different Python`, delete `.venv` and create it again with the newer one.
|
|
126
|
+
</details>
|
|
127
|
+
|
|
128
|
+
## Quick start
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
hive # first run: pick Claude, GPT or Gemini, then a folder
|
|
132
|
+
hive models --check # which models your login can use
|
|
133
|
+
hive "Explain how this project is structured" -d ~/some/project
|
|
134
|
+
hive "Add a /health endpoint" --headless --done "npm test" # scripts and CI: no interface, stops at the end
|
|
135
|
+
hive review # independent review of your uncommitted changes
|
|
136
|
+
hive dashboard # live view, history, comparisons (runs in the background)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`hive` opens your provider's own CLI with the Queen's rules and the bees loaded, so you work in the interface you already know. When you exit, it checks the result and reports each job:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
🐝 Hive (Claude Opus 5.5 + Claude Haiku 5.5) ✅ $0.60 2.0m
|
|
143
|
+
└ queen ≈$0.58 · review ≈$0.02
|
|
144
|
+
⚖️ Claude Opus 5.5 alone ✅ $0.25 0.8m
|
|
145
|
+
acceptance ✅ $ python3 -m unittest discover -s acceptance -t .
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+

|
|
149
|
+
|
|
150
|
+
## Provider setup
|
|
151
|
+
|
|
152
|
+
The first `hive` asks which AI runs the hive and remembers the answer, so it doesn't ask again:
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
🤖 Which AI should run the hive? (change it later with `hive provider`)
|
|
156
|
+
❯ 1) Claude Claude Code
|
|
157
|
+
2) GPT Codex CLI
|
|
158
|
+
3) Gemini Gemini CLI
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
| Change it | Command |
|
|
162
|
+
|---|---|
|
|
163
|
+
| Switch for good | `hive provider gpt` (or `claude`, `gemini`); `hive provider` alone shows the menu |
|
|
164
|
+
| One run only | `hive "…" --provider gemini` |
|
|
165
|
+
| Pick by model | `hive "…" --queen gpt-5.4` uses that model's provider |
|
|
166
|
+
|
|
167
|
+
Each provider remembers its own last Queen and bee model. A Queen and her bees always come from one provider.
|
|
168
|
+
|
|
169
|
+
| Provider | Default Queen | Default bees |
|
|
170
|
+
|---|---|---|
|
|
171
|
+
| Claude | Claude Opus 5.5 | Claude Haiku 5.5 |
|
|
172
|
+
| GPT | GPT-5.5 with an API key; with a ChatGPT plan, the plan's own model (for example GPT-5.6-Terra) | GPT-6 Luna |
|
|
173
|
+
| Gemini | Gemini 3.1 Pro | Gemini 3.5 Flash-Lite |
|
|
174
|
+
|
|
175
|
+
All bees get the Haiku bees' settings, taken from `hive/core/agents/*.md`: medium effort (in the Gemini CLI, a medium thinking level), and in Codex compaction at 100k tokens.
|
|
176
|
+
|
|
177
|
+
### Claude (Claude Code)
|
|
178
|
+
|
|
179
|
+
1. Install [Claude Code](https://code.claude.com), or use the hive's own copy: `.venv/bin/pip install -e ".[bundled]"`.
|
|
180
|
+
2. Sign in: run `claude` and `/login`, or set `ANTHROPIC_API_KEY`.
|
|
181
|
+
3. `hive provider claude`, then `hive doctor`.
|
|
182
|
+
|
|
183
|
+
### GPT (Codex CLI)
|
|
184
|
+
|
|
185
|
+
1. Install it: `npm install -g @openai/codex`.
|
|
186
|
+
2. Sign in: `codex login` (ChatGPT plan), or set `OPENAI_API_KEY`.
|
|
187
|
+
3. `hive provider gpt`, then `hive models --check`. A ChatGPT plan can't use the API models (GPT-5.5 …). The hive adds the models your plan offers (it reads them from Codex) and uses them by default.
|
|
188
|
+
4. **Approve the hive's hooks once.** Codex runs hooks only after you approve them, and the hive's hooks guard protected paths, keep reviewers read-only and write the live log. Run this from any folder, approve the hooks when Codex asks (or type `/hooks`), then quit:
|
|
189
|
+
```bash
|
|
190
|
+
CODEX_HOME=~/.hive/codex codex
|
|
191
|
+
```
|
|
192
|
+
Until you do, GPT runs don't guard protected paths: in a test, a GPT run wrote a protected `.env`, and once the hooks were approved the same write was blocked. `hive` warns on each GPT run until then.
|
|
193
|
+
5. `hive doctor` should show `hooks: approved`.
|
|
194
|
+
|
|
195
|
+
If Codex keeps your login in the system keychain rather than in `~/.codex/auth.json`, sign in once for the hive: `CODEX_HOME=~/.hive/codex codex login`.
|
|
196
|
+
|
|
197
|
+
### Gemini (Gemini CLI)
|
|
198
|
+
|
|
199
|
+
1. Install it: `npm install -g @google/gemini-cli`.
|
|
200
|
+
2. Create an API key in [Google AI Studio](https://aistudio.google.com/apikey) and export it in your shell's startup file:
|
|
201
|
+
```bash
|
|
202
|
+
echo 'export GEMINI_API_KEY="…"' >> ~/.zshrc # bash: ~/.bashrc
|
|
203
|
+
```
|
|
204
|
+
Google no longer serves the Gemini CLI to personal Google logins, so the key (or Vertex AI credentials) is needed. Put it in `~/.zshrc` rather than only `~/.zprofile`, which some terminals and tools don't read.
|
|
205
|
+
3. `hive provider gemini`, then `hive models --check`.
|
|
206
|
+
4. `hive doctor` warns if `GEMINI_API_KEY` isn't set.
|
|
207
|
+
|
|
208
|
+
### Where provider settings live
|
|
209
|
+
|
|
210
|
+
| What | Where |
|
|
211
|
+
|---|---|
|
|
212
|
+
| Your provider choice and last models | `~/.hive/state.json` |
|
|
213
|
+
| The hive's Codex home (bees, hooks, skills, sessions; your login linked in) | `~/.hive/codex` |
|
|
214
|
+
| The hive's Gemini home (one folder per session in `sessions/`, chat logs shared in `.gemini/tmp`) | `~/.hive/gemini` |
|
|
215
|
+
| Your own prices and local models | `~/.hive/models.json` |
|
|
216
|
+
|
|
217
|
+
Your own `~/.codex` and `~/.gemini` are never edited. GPT and Gemini prices come from price trackers, not the providers' pages, and models a ChatGPT plan offers show as $0 because a plan isn't billed per token. Set your own prices in `~/.hive/models.json` (the numbers below are only an example):
|
|
218
|
+
|
|
219
|
+
```json
|
|
220
|
+
{"prices": {"gpt-5.6-terra": {"input": 2, "output": 12, "cache_read": 0.2}}}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Claude, GPT and Gemini compared
|
|
224
|
+
|
|
225
|
+
| | Claude | GPT | Gemini |
|
|
226
|
+
|---|---|---|---|
|
|
227
|
+
| Runs in | Claude Code | Codex CLI | Gemini CLI |
|
|
228
|
+
| Cost in the report | exact, from Claude Code | estimated from tokens × list price ($0 on a ChatGPT plan) | estimated from tokens × list price |
|
|
229
|
+
| Protected paths | hook | hook, once approved | hook |
|
|
230
|
+
| Read-only scouts | hook | Codex sandbox (read-only role) | tool list (no write or shell tools) |
|
|
231
|
+
| Read-only reviewers | hook | hook, once approved | instructions only (the CLI doesn't say which bee runs a tool) |
|
|
232
|
+
| Live log | bees when they start and report, commands with ✅/❌ | bees when they report, commands without ✅/❌ (Codex's hooks don't say either) | bees when they start and report, commands with ✅/❌ |
|
|
233
|
+
| Network for commands | yes | in `plan` and `auto` mode; not in `ask` mode or with `--sandbox` | yes |
|
|
234
|
+
| `--budget` cap, `--compare`, local bees | yes | no | no |
|
|
235
|
+
|
|
236
|
+
> GPT and Gemini have been run against signed-in CLIs (Codex 0.171, Gemini CLI 0.65) on small jobs only, so expect rough edges and run `hive doctor` first.
|
|
237
|
+
|
|
238
|
+
## What you get
|
|
239
|
+
|
|
240
|
+
- **Choose your AI and your Queen:** Claude (Fable 5.1, Opus 5.5, Sonnet 5.5 …), GPT (GPT-5.5, GPT-5.4 …, or your ChatGPT plan's models) or Gemini (Gemini 3.1 Pro, 3.8 Flash …). Any kind of bee can run on another model of the same provider (`--scout`, `--builder`, `--reviewer`). With any of the three, a bee can also run on a **local model** through Ollama, llama.cpp or LM Studio (`--scout qwen-coder`): a router on localhost sends only that bee's requests to it, and its tokens cost nothing.
|
|
241
|
+
- **Runs in the CLI itself:** `hive` opens Claude Code, Codex or the Gemini CLI with the Queen's rules, the bees, the hooks and the skills loaded, then reports and records each job when you exit. Scripts and CI get a headless mode (`--headless`). In Claude Code there's also a `/queen-hive:hive` plugin command.
|
|
242
|
+
- **👑 and 🐝 in the chat:** on every provider the Queen starts her messages with 👑 and names bees with their icon (🔎 scout, 🔨 builder, 🧐 reviewer), and bees start their reports with `🐝 <brief ID>`. The Gemini CLI shows bees as "🔎 Scout bee" and so on; Codex as "Scout bee" (it allows no emoji in names).
|
|
243
|
+
- **Autonomy modes:** `plan` (you approve the briefs), `auto`, or `ask` (risky actions need a y/n).
|
|
244
|
+
- **Briefs with "Done when":** every brief comes with a runnable check. The Queen re-runs each check herself and returns a brief at most 3 times before asking you.
|
|
245
|
+
- **Independent review:** reviewer bees check the finished work from separate lenses (goal, correctness, tests, architecture, performance, rules, security), or only goal and tests with `--review light` (the default for a Sonnet 5.5 Queen). They don't see the builders' reports. `hive review` runs the same review on any diff, branch or PR.
|
|
246
|
+
- **Protected paths:** for example your acceptance tests. A hook blocks file edits to them, and shell writes as far as a parse of the command can tell.
|
|
247
|
+
- **Memory outside your project:** kept in `~/.hive/projects/…`. After each job, a retro (`waggle`) proposes rule fixes and applies only those you approve. Skip it with `--no-waggle`.
|
|
248
|
+
- **Statistics:** tokens and cost per stage. Each job is compared with single models, either estimated or, with `--compare` (Claude only for now), as real side-by-side runs.
|
|
249
|
+
|
|
250
|
+
## Safety: what is enforced and what isn't
|
|
251
|
+
|
|
252
|
+
- **Permissions are the CLI's.** In Claude Code, edits outside the granted folders need your approval, and in `auto` mode shell commands run without asking. Use `ask` mode, or `--sandbox` (writes only inside the granted folders), on machines that matter. Codex always sandboxes commands to the granted folders, with network in `plan` and `auto` mode only. The Gemini CLI runs them unsandboxed unless you pass `--sandbox`. In a headless run in `ask` mode, Claude Code and the Gemini CLI refuse risky actions; Codex runs them inside its sandbox.
|
|
253
|
+
- **Your code goes to the provider you chose:** Anthropic, OpenAI or Google, under that provider's terms.
|
|
254
|
+
- **Hooks are guards, not a sandbox.** The protected-path and read-only-bee checks parse shell commands; a command such as `python -c "…"` can write without being noticed. `--sandbox` is the real boundary. On GPT the hooks only run once you've approved them (see [GPT setup](#gpt-codex-cli)).
|
|
255
|
+
- **Acceptance commands run on your machine.** After a session the hive itself runs the acceptance commands with your shell, outside the CLI's permissions. Yours (`--done`, the profile's `test` command) always run. The Queen's own run automatically only in `plan` and `auto` mode without `--sandbox`, where she could have run them in the session anyway. In `ask` mode or with `--sandbox` you're asked first (default no), and headless runs skip them.
|
|
256
|
+
- **Memory feeds every later session.** The Queen writes `known-issues.md`, `decisions.md` and `progress.md`, and they go into her instructions next time. The end-of-session report lists every line she added (📝), so you can catch an instruction planted by code you don't trust.
|
|
257
|
+
- **`--compare` copies are contained.** Links that lead out of a copy are removed, and with `--sandbox` the solo models run sandboxed too.
|
|
258
|
+
- **Only the Queen changes the hive.** Retro edits to the hive's rules and bees are applied by the Queen after you approve them; the protect hook denies any bee that tries (except in the Gemini CLI, which doesn't say which bee is calling).
|
|
259
|
+
- **Everything stays local.** Memory, run logs and the dashboard never leave your machine, and `~/.hive` is owner-only. The dashboard listens on `127.0.0.1` and answers only its own pages, so other websites can't read it or trigger paid model checks. Local models get no login headers.
|
|
260
|
+
|
|
261
|
+
📖 **Full guide: [docs/GUIDE.md](https://github.com/rzadvornov/queen-hive/blob/main/docs/GUIDE.md)**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Queen Hive: a Queen model directs cheap worker bees, in Claude Code, Codex or the Gemini CLI."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
__version__ = "0.2.0"
|
|
7
|
+
|
|
8
|
+
CORE_DIR = Path(__file__).parent / "core" # the rules, bees, hooks and skills; a Claude Code plugin
|
|
9
|
+
SCRIPTS_DIR = CORE_DIR / "scripts"
|
|
10
|
+
|
|
11
|
+
# hivecore lives inside the plugin so its hooks can use it without this package.
|
|
12
|
+
if str(SCRIPTS_DIR) not in sys.path:
|
|
13
|
+
sys.path.insert(0, str(SCRIPTS_DIR))
|