@hivey/cli 0.9.41 → 0.9.43
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/native/darwin-arm64/hivey +0 -0
- package/package.json +1 -1
- package/repo/skills/hivey/SKILL.md +10 -0
- package/repo/skills/hivey/scripts/critic-brief.md +46 -0
- package/repo/skills/hivey/scripts/fresh_review.py +381 -0
- package/repo/skills/hivey-agent-creator/SKILL.md +18 -12
- package/repo/skills/hivey-agent-creator/references/agent-claude-md.md +16 -8
- package/repo/skills/hivey-agent-creator/scripts/setup_agent.py +29 -22
- package/repo/skills/hivey-swarm-creator/SKILL.md +50 -27
- package/repo/skills/hivey-swarm-creator/references/agent-claude-md.md +40 -50
- package/repo/skills/hivey-swarm-creator/references/wiki-memory.md +3 -3
- package/repo/skills/hivey-swarm-creator/scripts/swarm_tasks.py +141 -8
- package/repo/skills/hivey-agent-creator/references/reviewer-agent.md +0 -35
|
@@ -6,19 +6,29 @@ Tasks live in <root>/.swarm/tasks.json (locked on every write) and are rendered
|
|
|
6
6
|
swarm's timeline (addons such as the watcher may log there too). hivey's dashboard reads
|
|
7
7
|
tasks.json, so keep its format.
|
|
8
8
|
|
|
9
|
-
Statuses: open → in-progress → review (deliverable
|
|
9
|
+
Statuses: open → in-progress → review (deliverable submitted, fresh review running) → approved
|
|
10
10
|
(+ blocked at any point)
|
|
11
11
|
Rules: a task can be claimed only by its owner (or anyone if unowned) and only once all
|
|
12
12
|
its deps are approved. If a task has a `check` command, `approved` requires it to pass.
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
Checks run outside the board lock, so a long test suite doesn't stall other agents.
|
|
14
|
+
|
|
15
|
+
Review: `submit` starts a fresh review in the background (the hivey skill's
|
|
16
|
+
fresh_review.py): N one-shot critics (config `<root>/.swarm/review.json`, default 2 × sonnet),
|
|
17
|
+
each in an empty context with no saved session, read the task spec, `<root>/.swarm/REQUEST.md`
|
|
18
|
+
(the user's request) and the artifact, run the check and exit. All PASS and the check exits 0
|
|
19
|
+
→ the task is `approved` (by `fresh-review`); otherwise it goes back to `in-progress` with the
|
|
20
|
+
merged review, and the owner gets a message either way. After `rounds` failed rounds (default
|
|
21
|
+
3) it's `blocked` and the coordinator is told. Besides that, only the coordinator approves.
|
|
22
|
+
With `critics: 0` there's no fresh review: `submit` sets `review` for the coordinator.
|
|
15
23
|
|
|
16
24
|
Usage (root is found by walking up from cwd to the folder containing .swarm/):
|
|
17
|
-
swarm_tasks.py add ID "title" [--owner A] [--deps T1,T2] [--path P] [--check "cmd"]
|
|
25
|
+
swarm_tasks.py add ID "title" [--owner A] [--deps T1,T2] [--path P] [--check "cmd"]
|
|
26
|
+
[--spec "done when …"] [--as coordinator]
|
|
18
27
|
swarm_tasks.py list [--owner A] [--status S]
|
|
19
28
|
swarm_tasks.py claim ID --as A
|
|
20
29
|
swarm_tasks.py set ID STATUS --as A [--note TEXT]
|
|
21
30
|
swarm_tasks.py verify ID --as A # run the task's check command
|
|
31
|
+
swarm_tasks.py submit ID --as A [--artifact P]... [--repo R --range main...swarm/A]
|
|
22
32
|
swarm_tasks.py log TYPE --as A [--note TEXT] # append a free-form event
|
|
23
33
|
"""
|
|
24
34
|
import argparse
|
|
@@ -32,7 +42,8 @@ from contextlib import contextmanager
|
|
|
32
42
|
from pathlib import Path
|
|
33
43
|
|
|
34
44
|
STATUSES = ["open", "in-progress", "blocked", "review", "approved"]
|
|
35
|
-
APPROVERS = {"
|
|
45
|
+
APPROVERS = {"coordinator", "critic"} # "critic": swarms made before fresh review
|
|
46
|
+
REVIEWER = "fresh-review" # the actor of approvals that fresh_review.py earned
|
|
36
47
|
|
|
37
48
|
|
|
38
49
|
def find_root(start=None):
|
|
@@ -97,18 +108,133 @@ def run_check(root, t):
|
|
|
97
108
|
return False, "check timed out after 900s"
|
|
98
109
|
|
|
99
110
|
|
|
111
|
+
|
|
112
|
+
def fresh_review_script():
|
|
113
|
+
"""$HIVEY_FRESH_REVIEW, else the installed hivey skill, else the repo copy next to this skill."""
|
|
114
|
+
candidates = [os.environ.get("HIVEY_FRESH_REVIEW")] + [
|
|
115
|
+
str(d / "fresh_review.py") for d in (Path.home() / ".claude/skills/hivey/scripts",
|
|
116
|
+
Path.home() / ".agents/skills/hivey/scripts",
|
|
117
|
+
Path(__file__).resolve().parents[2] / "hivey/scripts")]
|
|
118
|
+
for f in candidates:
|
|
119
|
+
if f and Path(f).is_file():
|
|
120
|
+
return Path(f)
|
|
121
|
+
sys.exit("fresh_review.py not found: install the hivey skill (hivey skill install)")
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def review_config(root):
|
|
125
|
+
try:
|
|
126
|
+
cfg = json.loads((Path(root) / ".swarm" / "review.json").read_text())
|
|
127
|
+
except (OSError, ValueError):
|
|
128
|
+
cfg = {}
|
|
129
|
+
return {"critics": int(cfg.get("critics", 2)), "rounds": int(cfg.get("rounds", 3))}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def submit(root, args):
|
|
133
|
+
"""Mark the task in review and start its fresh review in a detached process."""
|
|
134
|
+
cfg = review_config(root)
|
|
135
|
+
with board(root) as data:
|
|
136
|
+
t = get(data, args.id)
|
|
137
|
+
if t.get("owner") and t["owner"] != args.actor:
|
|
138
|
+
sys.exit(f"{args.id} is owned by {t['owner']}: only the owner submits it")
|
|
139
|
+
if t["status"] == "review":
|
|
140
|
+
sys.exit(f"{args.id} is already in review; wait for the verdict message")
|
|
141
|
+
if t["status"] == "approved":
|
|
142
|
+
sys.exit(f"{args.id} is already approved")
|
|
143
|
+
t["status"] = "review"
|
|
144
|
+
rnd = t.get("review_round", 0) + 1
|
|
145
|
+
if cfg["critics"] > 0:
|
|
146
|
+
t["review_round"] = rnd
|
|
147
|
+
log_event(root, "review_submitted", args.actor, task=args.id, round=rnd, critics=cfg["critics"])
|
|
148
|
+
task = dict(t)
|
|
149
|
+
if cfg["critics"] <= 0:
|
|
150
|
+
print(f"{args.id} is in review. Fresh review is off for this swarm (critics: 0): "
|
|
151
|
+
f"send DONE to the coordinator, who approves it.")
|
|
152
|
+
return
|
|
153
|
+
worker = [sys.executable, str(Path(__file__).resolve()), "--root", str(root), "_review", args.id,
|
|
154
|
+
"--as", args.actor, "--round", str(rnd)]
|
|
155
|
+
for a in args.artifact:
|
|
156
|
+
worker += ["--artifact", a]
|
|
157
|
+
if args.repo:
|
|
158
|
+
worker += ["--repo", args.repo, "--range", args.range or "HEAD~1..HEAD"]
|
|
159
|
+
reviews = Path(root) / ".swarm" / "reviews"
|
|
160
|
+
reviews.mkdir(parents=True, exist_ok=True)
|
|
161
|
+
log = open(reviews / f"{args.id}-r{rnd}.log", "w")
|
|
162
|
+
subprocess.Popen(worker, stdout=log, stderr=subprocess.STDOUT, start_new_session=True, cwd=str(root))
|
|
163
|
+
print(f"{args.id} round {rnd}: {cfg['critics']} fresh critics are reviewing it in the background "
|
|
164
|
+
f"(review: .swarm/reviews/{args.id}-r{rnd}.md). You'll get a message with the verdict; "
|
|
165
|
+
f"work on something else meanwhile.")
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def review_worker(root, args):
|
|
169
|
+
"""Detached: run fresh_review.py for one task, then record the verdict on the board."""
|
|
170
|
+
cfg = review_config(root)
|
|
171
|
+
t = get(load(root), args.id)
|
|
172
|
+
out = Path(root) / ".swarm" / "reviews" / f"{args.id}-r{args.round}.md"
|
|
173
|
+
spec = (f"Task {t['id']}: {t['title']}\nOwner: {t.get('owner') or '-'}\n"
|
|
174
|
+
f"Deliverable: {t.get('path') or '-'}\nDone when: {t.get('spec') or '(see the title and the check)'}")
|
|
175
|
+
cmd = [sys.executable, str(fresh_review_script()), "run", "--folder", str(root), "--label", t["id"],
|
|
176
|
+
"--round", str(args.round), "--spec", spec, "--out", str(out), "--check-cwd", str(root)]
|
|
177
|
+
request = Path(root) / ".swarm" / "REQUEST.md"
|
|
178
|
+
if request.exists():
|
|
179
|
+
cmd += ["--spec-file", str(request)]
|
|
180
|
+
if t.get("check"):
|
|
181
|
+
cmd += ["--check", t["check"]]
|
|
182
|
+
if t.get("last_review"):
|
|
183
|
+
cmd += ["--previous", t["last_review"]]
|
|
184
|
+
artifacts = list(args.artifact) + ([str(Path(root) / t["path"])] if t.get("path") else [])
|
|
185
|
+
for a in artifacts:
|
|
186
|
+
if Path(a).expanduser().exists():
|
|
187
|
+
cmd += ["--artifact", a]
|
|
188
|
+
if args.repo:
|
|
189
|
+
cmd += ["--repo", args.repo, "--range", args.range]
|
|
190
|
+
code = subprocess.run(cmd).returncode
|
|
191
|
+
verdict = {0: "APPROVED", 1: "CHANGES"}.get(code, "ERROR")
|
|
192
|
+
owner = t.get("owner") or args.actor
|
|
193
|
+
escalate = verdict == "CHANGES" and args.round >= cfg["rounds"]
|
|
194
|
+
with board(root) as data:
|
|
195
|
+
t = get(data, args.id)
|
|
196
|
+
t["last_review"] = str(out)
|
|
197
|
+
if verdict == "APPROVED":
|
|
198
|
+
t["status"], actor = "approved", REVIEWER
|
|
199
|
+
elif escalate:
|
|
200
|
+
t["status"], actor = "blocked", REVIEWER
|
|
201
|
+
else:
|
|
202
|
+
t["status"], actor = ("in-progress" if verdict == "CHANGES" else "review"), REVIEWER
|
|
203
|
+
t["notes"].append(f"{time.strftime('%Y-%m-%d %H:%M')} {REVIEWER}: r{args.round} {verdict} → {out}")
|
|
204
|
+
log_event(root, "review_" + verdict.lower(), actor, task=args.id, round=args.round, review=str(out))
|
|
205
|
+
rel = out.relative_to(root)
|
|
206
|
+
msgs = {"APPROVED": f"APPROVED {args.id} (fresh review r{args.round}, every critic PASS, check passed) → {rel}",
|
|
207
|
+
"CHANGES": f"CRITIQUE r{args.round} {args.id} → {rel}: fix every defect in its Defects list in one "
|
|
208
|
+
f"revision, then submit again",
|
|
209
|
+
"ERROR": f"Fresh review r{args.round} of {args.id} failed to run (see {rel} and its .log); "
|
|
210
|
+
f"tell the coordinator"}
|
|
211
|
+
if escalate:
|
|
212
|
+
msgs["CHANGES"] = (f"CRITIQUE r{args.round} {args.id} → {rel}: that was the last review round; "
|
|
213
|
+
f"the task is blocked and the coordinator decides")
|
|
214
|
+
send = ["hivey", "msg", "send"]
|
|
215
|
+
subprocess.run(send + [owner, msgs[verdict]], capture_output=True)
|
|
216
|
+
if escalate or verdict == "ERROR":
|
|
217
|
+
subprocess.run(send + ["coordinator", f"{args.id} needs you: fresh review r{args.round} "
|
|
218
|
+
f"{verdict} → {rel}"], capture_output=True)
|
|
219
|
+
|
|
100
220
|
def main():
|
|
101
221
|
p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
102
222
|
p.add_argument("--root")
|
|
103
223
|
sub = p.add_subparsers(dest="cmd", required=True)
|
|
104
224
|
a = sub.add_parser("add"); a.add_argument("id"); a.add_argument("title")
|
|
105
225
|
a.add_argument("--owner"); a.add_argument("--deps", default=""); a.add_argument("--path")
|
|
106
|
-
a.add_argument("--check"); a.add_argument("--
|
|
226
|
+
a.add_argument("--check"); a.add_argument("--spec", help="the deliverable's 'done when', for the critics")
|
|
227
|
+
a.add_argument("--as", dest="actor", default="coordinator")
|
|
107
228
|
ls = sub.add_parser("list"); ls.add_argument("--owner"); ls.add_argument("--status")
|
|
108
229
|
c = sub.add_parser("claim"); c.add_argument("id"); c.add_argument("--as", dest="actor", required=True)
|
|
109
230
|
s = sub.add_parser("set"); s.add_argument("id"); s.add_argument("status", choices=STATUSES)
|
|
110
231
|
s.add_argument("--as", dest="actor", required=True); s.add_argument("--note", default="")
|
|
111
232
|
v = sub.add_parser("verify"); v.add_argument("id"); v.add_argument("--as", dest="actor", required=True)
|
|
233
|
+
sb = sub.add_parser("submit"); sb.add_argument("id"); sb.add_argument("--as", dest="actor", required=True)
|
|
234
|
+
sb.add_argument("--artifact", action="append", default=[]); sb.add_argument("--repo"); sb.add_argument("--range")
|
|
235
|
+
rw = sub.add_parser("_review"); rw.add_argument("id"); rw.add_argument("--as", dest="actor", required=True)
|
|
236
|
+
rw.add_argument("--round", type=int, required=True); rw.add_argument("--artifact", action="append", default=[])
|
|
237
|
+
rw.add_argument("--repo"); rw.add_argument("--range")
|
|
112
238
|
lg = sub.add_parser("log"); lg.add_argument("type"); lg.add_argument("--as", dest="actor", required=True)
|
|
113
239
|
lg.add_argument("--note", default="")
|
|
114
240
|
args = p.parse_args()
|
|
@@ -119,12 +245,19 @@ def main():
|
|
|
119
245
|
and (not args.status or t["status"] == args.status)]
|
|
120
246
|
print(json.dumps(ts, indent=2))
|
|
121
247
|
return
|
|
248
|
+
if args.cmd == "submit":
|
|
249
|
+
submit(root, args)
|
|
250
|
+
return
|
|
251
|
+
if args.cmd == "_review":
|
|
252
|
+
review_worker(root, args)
|
|
253
|
+
return
|
|
122
254
|
if args.cmd == "log":
|
|
123
255
|
log_event(root, args.type, args.actor, note=args.note)
|
|
124
256
|
print(json.dumps({"ok": True}))
|
|
125
257
|
return
|
|
126
258
|
if args.cmd == "set" and args.status == "approved" and args.actor not in APPROVERS:
|
|
127
|
-
sys.exit(f"only
|
|
259
|
+
sys.exit(f"only a fresh review or the coordinator can approve {args.id}: run "
|
|
260
|
+
f"`swarm_tasks.py submit {args.id} --as {args.actor}`")
|
|
128
261
|
if args.cmd == "verify" or (args.cmd == "set" and args.status == "approved"):
|
|
129
262
|
t = get(load(root), args.id)
|
|
130
263
|
if t.get("check"): # run outside the board lock: a check can take minutes
|
|
@@ -146,7 +279,7 @@ def main():
|
|
|
146
279
|
sys.exit(f"task {args.id} already exists")
|
|
147
280
|
t = {"id": args.id, "title": args.title, "owner": args.owner, "status": "open",
|
|
148
281
|
"deps": [d for d in args.deps.split(",") if d], "path": args.path, "check": args.check,
|
|
149
|
-
"notes": []}
|
|
282
|
+
"spec": args.spec, "notes": []}
|
|
150
283
|
data["tasks"].append(t)
|
|
151
284
|
log_event(root, "task_added", args.actor, task=args.id, title=args.title, owner=args.owner)
|
|
152
285
|
elif args.cmd == "claim":
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: reviewer
|
|
3
|
-
description: Independent reviewer for this agent's work. Use it before declaring any run or deliverable done. Give it the paths of what you produced. It checks them against The ask, the Deliverables table and the sources they cite, and returns PASS or a numbered list of concrete defects. It never edits files.
|
|
4
|
-
tools: Read, Grep, Glob, Bash, WebFetch
|
|
5
|
-
model: sonnet
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
You are the reviewer for the agent whose `CLAUDE.md` is in the current directory. You didn't do
|
|
9
|
-
the work, so judge it cold, with no charity for intentions. Your only output is a verdict.
|
|
10
|
-
|
|
11
|
-
## What to do
|
|
12
|
-
1. Read `CLAUDE.md` in the current directory: **The ask** (the user's verbatim request), the
|
|
13
|
-
**Deliverables** table (paths, "done when", check commands) and the **Method** (plus
|
|
14
|
-
`METHOD.md` if it exists).
|
|
15
|
-
2. Open every artifact you were given; don't trust the agent's summary of it.
|
|
16
|
-
3. Run each relevant **Check** command from the Deliverables table and record its exit code.
|
|
17
|
-
4. Verify the content:
|
|
18
|
-
- Does it answer The ask, or something nearby?
|
|
19
|
-
- Spot-check at least 3 concrete claims (numbers, names, dates, quotes) against the source
|
|
20
|
-
they came from (open the URL or file). Report each mismatch with the correct value and
|
|
21
|
-
where you found it.
|
|
22
|
-
- Is anything required missing: sections, links, files, formats?
|
|
23
|
-
- Is anything stated that the sources don't support?
|
|
24
|
-
5. Don't modify any file. Don't fix things yourself: the agent fixes, you report.
|
|
25
|
-
|
|
26
|
-
## Output format
|
|
27
|
-
```
|
|
28
|
-
VERDICT: PASS | FAIL
|
|
29
|
-
Checks: <command> → exit <n> (one line each)
|
|
30
|
-
Defects:
|
|
31
|
-
1. <file:line or section> — <what's wrong> — <evidence / correct value + source>
|
|
32
|
-
Verified OK: <the claims you checked that held up>
|
|
33
|
-
```
|
|
34
|
-
PASS only if every check exits 0 and you found no defect that changes meaning. Keep it short.
|
|
35
|
-
Style nits aren't defects.
|