@hivey/cli 0.9.46 → 0.9.48

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hivey/cli",
3
- "version": "0.9.46",
3
+ "version": "0.9.48",
4
4
  "description": "All your AI swarms, one terminal: a workspace and lead agent for teams of Claude Code and Codex agents",
5
5
  "keywords": [
6
6
  "hivey",
@@ -97,7 +97,13 @@ Lower level (what providers call): `hivey swarm launch <root> --slug S <agent>..
97
97
  [--kinds b=codex,c=grok,d=agy] [--addon ID]... [--channel C0…] [--heartbeat 15m --heartbeat-task "…"]
98
98
  [--budget-min N] [--kickoff "…"]`. Run it from the pane that should become the master.
99
99
  Each agent runs on Claude Code unless `--kinds` (or `--kind` for `--solo`) says `codex`, `grok`
100
- or `agy` (Antigravity, Gemini). They all read the CLAUDE.md you write: launch links `AGENTS.md`
100
+ or `agy` (Antigravity, Gemini). A Claude agent with model `deepseek` (DeepSeek V4.1 Flash 1017) or
101
+ `openrouter:<id>` runs Claude Code on OpenRouter: launch writes its `.claude/settings.local.json`,
102
+ and the key comes from `key_command` in `~/.hivey/openrouter.json` (else `$OPENROUTER_API_KEY`).
103
+ Model `muse` runs it on Muse Glimmer 30B (MLX 6-bit, `~/models/muse-glimmer-30b-mlx-6bit`) on this
104
+ computer: launch starts `mlx_vlm.server` on 127.0.0.1:8092 if it isn't up (log
105
+ `~/.hivey/logs/muse-server.log`; ~25 GB of memory, 131k context, slow first turns, free).
106
+ They all read the CLAUDE.md you write: launch links `AGENTS.md`
101
107
  (and `GEMINI.md` for agy) to it. Per-CLI flags: `--claude-args`, `--codex-args`, `--grok-args`,
102
108
  `--agy-args` (defaults run them unattended). Pick the CLI per agent with the user: Claude Code
103
109
  for most work, Codex for code review and a second opinion, Grok for X/web research, agy for
@@ -60,7 +60,7 @@ From the request, work out:
60
60
 
61
61
  | Kind (`--kind`) | Suggest it for | Model |
62
62
  |---|---|---|
63
- | `claude`, Claude Code (default) | most work: building, research, writing, ops; browser control | `opus` for code and deep reasoning; `sonnet` for research, writing, routine ops; `haiku` for trivial jobs |
63
+ | `claude`, Claude Code (default) | most work: building, research, writing, ops; browser control | `opus` for code and deep reasoning; `sonnet` for research, writing, routine ops; `haiku` for trivial jobs; `deepseek` (DeepSeek V4.1 Flash on OpenRouter, ~$0.15/$0.60 per M tokens) for cheap high-volume work, or `openrouter:<id>` for any OpenRouter model; `muse` (Muse Glimmer 30B on this Mac, free and private but slow, 131k context) for offline or private jobs |
64
64
  | `codex`, Codex | code review, a second opinion from another model family | leave out to use the user's configured model |
65
65
  | `grok`, Grok | X/Twitter and web research | `grok models` lists them |
66
66
  | `agy`, Antigravity (Gemini) | fast, cheap tasks; image generation | see the `hivey-agy` skill's model table |
@@ -81,7 +81,11 @@ For each agent decide:
81
81
  `AGENTS.md` (and `GEMINI.md` for agy) to it.
82
82
  - **model** (`--models`): for Claude Code, `opus` for builders and deep reasoning; `sonnet`
83
83
  for research, writing and data gathering, at a fraction of the cost. A swarm costs
84
- many times what one agent does, so spend the strong model where it pays off. For Codex, Grok
84
+ many times what one agent does, so spend the strong model where it pays off. `deepseek`
85
+ (DeepSeek V4.1 Flash 1017 through OpenRouter, still on Claude Code) is far cheaper for
86
+ high-volume workers; `openrouter:<id>` picks any other OpenRouter model. `muse` (Muse
87
+ Glimmer 30B, local on this Mac) is free and private but slow, and all its agents share one
88
+ local server, so give it to one or two agents at most. For Codex, Grok
85
89
  and agy leave it to the CLI's default unless the user names one.
86
90
  - **skills**: run `hivey skills guide` and follow it for every agent (skylls first, skills.sh
87
91
  only with the user's OK). Skills go in the plan per agent and land in each agent's own
@@ -188,7 +192,16 @@ to the swarm root (`permissions.additionalDirectories`, plus `--vault` if the va
188
192
  elsewhere) and sets `AGENTS_TTS=0` so workers stay silent. **Code swarms:** make sure the repo
189
193
  (e.g. `<root>/app`) exists with at least one commit, then pass `--worktree <repo>` for each
190
194
  builder: it gets `<root>/<agent>/repo` on branch `swarm/<agent>`. Builders commit on their
191
- branch; the integrator merges into the main checkout and runs the checks there.
195
+ branch; the integrator merges into the main checkout and runs the checks there. A fresh
196
+ worktree has no gitignored files: if the builders need local config (an env file, keys), list
197
+ those paths in the repo's `.worktreeinclude` (gitignore syntax, the file Claude Code's own
198
+ worktrees read) before running `setup_agent.py`, and it copies them in.
199
+
200
+ It also registers the **swarm done gate** in each agent's settings (Claude Code only; `--no-gate`
201
+ leaves it out): when an agent tries to stop while it still owns an `in-progress` task, it is
202
+ reminded once to `submit` it, set it `blocked` with a note, or say why it stays open. Each
203
+ worker's helper subagents run on Haiku (`CLAUDE_CODE_SUBAGENT_MODEL`, set by `hivey swarm
204
+ launch`; an agent on DeepSeek or Muse keeps its own model).
192
205
 
193
206
  Then install each agent's skills as `hivey skills guide` says (step 4 of the guide), and check
194
207
  `ls <root>/<agent>/.claude/skills`.
@@ -364,6 +377,14 @@ that ended in ERROR, is yours: read the review and accept it (`set <ID> approved
364
377
  coordinator`), re-scope it, or give the owner a specific fix. If an owner disputes a defect, it
365
378
  tells you with evidence; you decide. Don't review deliverables yourself instead of the critics.
366
379
 
380
+ **Big fan-out jobs: suggest a dynamic workflow.** For a job that needs many parallel reads with
381
+ cross-checked results (audit every file for one issue, a migration across hundreds of files,
382
+ research cross-checked across many sources), suggest the user run it as a Claude Code dynamic
383
+ workflow: a script that runs up to dozens of subagents, verifies their findings against each
384
+ other and returns one result, so it doesn't take a swarm agent's whole context. It starts only
385
+ when the user opts in (their message says `ultracode` or "use a workflow"); never start one on
386
+ your own. It uses much more quota, so suggest trying it on one folder first.
387
+
367
388
  **Too much talk.** If agents ping-pong, flood `@all` or Slack, tighten the swarm's limits
368
389
  (`hivey swarm comms <name> --preset quiet`, or one flag such as `--hourly-wakes 12` or
369
390
  `--slack masters`) and tell the agents involved to batch their messages. Ask the user before
@@ -5,23 +5,58 @@ Creates <root>/<agent>/ (and <root>/<agent>/.claude/skills/) and writes
5
5
  <root>/<agent>/.claude/settings.json with:
6
6
  - permissions.additionalDirectories: the swarm root (and --vault, if given), so the agent
7
7
  can read and write the whole swarm folder;
8
- - env.AGENTS_TTS = "0": workers stay silent; only the master speaks its summaries.
8
+ - env.AGENTS_TTS = "0": workers stay silent; only the master speaks its summaries;
9
+ - hooks.Stop: the swarm done gate (swarm_gate.py, Claude Code only): an agent that tries
10
+ to stop while it still owns an in-progress task is reminded once to submit it, mark it
11
+ blocked, or say why it stays open. --no-gate leaves it out.
9
12
  Existing settings are kept and merged. The coordinator writes the agent's CLAUDE.md; skills
10
13
  are installed separately, as `hivey skills guide` says.
11
14
 
12
15
  --worktree REPO gives a coding agent its own git worktree of REPO at <root>/<agent>/repo on
13
16
  branch swarm/<agent>, so parallel builders never overwrite each other. REPO needs at least one
14
- commit. The integrator (the critic or a dedicated agent) merges the branches.
17
+ commit. The integrator (the critic or a dedicated agent) merges the branches. Gitignored files
18
+ the worktree needs (`.env`, local config) are copied in when REPO has a `.worktreeinclude`
19
+ (gitignore syntax, the same file Claude Code's own worktrees read).
15
20
 
16
- Usage: setup_agent.py <swarm_root> <agent> [--vault PATH] [--worktree REPO]
21
+ Usage: setup_agent.py <swarm_root> <agent> [--vault PATH] [--worktree REPO] [--no-gate]
17
22
  """
18
23
  import argparse
19
24
  import json
20
25
  import re
26
+ import shutil
21
27
  import subprocess
22
28
  from pathlib import Path
23
29
 
24
30
  NAME_RE = re.compile(r"^[a-z][a-z0-9_-]{0,31}$") # hivey agent-name rule
31
+ GATE = Path(__file__).absolute().parent / "swarm_gate.py" # keep the installed path
32
+
33
+
34
+ def copy_included(repo, worktree):
35
+ """Copy REPO's untracked files that match its .worktreeinclude into the new worktree."""
36
+ include = repo / ".worktreeinclude"
37
+ if not include.is_file():
38
+ return []
39
+ r = subprocess.run(["git", "-C", str(repo), "ls-files", "--others", "--ignored",
40
+ f"--exclude-from={include}"], capture_output=True, text=True)
41
+ copied = []
42
+ for rel in r.stdout.splitlines():
43
+ src, dst = repo / rel, worktree / rel
44
+ if not src.is_file() or dst.exists():
45
+ continue
46
+ dst.parent.mkdir(parents=True, exist_ok=True)
47
+ shutil.copy2(src, dst)
48
+ copied.append(rel)
49
+ return copied
50
+
51
+
52
+ def add_gate(settings):
53
+ """Register the swarm done gate as a Stop hook (idempotent). True when added."""
54
+ cmd = f"python3 {GATE}"
55
+ entries = settings.setdefault("hooks", {}).setdefault("Stop", [])
56
+ if any(h.get("command") == cmd for m in entries for h in m.get("hooks", [])):
57
+ return False
58
+ entries.append({"hooks": [{"type": "command", "command": cmd, "timeout": 30}]})
59
+ return True
25
60
 
26
61
 
27
62
  def add_worktree(repo, worktree, agent):
@@ -42,6 +77,8 @@ def main():
42
77
  p.add_argument("agent", help="agent key, e.g. builder (matches [a-z][a-z0-9_-]{0,31})")
43
78
  p.add_argument("--vault", help="the swarm's wiki, if it lives outside the root; the agent gets access")
44
79
  p.add_argument("--worktree", metavar="REPO", help="git repo to give this agent its own worktree of")
80
+ p.add_argument("--no-gate", action="store_true",
81
+ help="don't register the done gate (the Stop hook that reminds about open tasks)")
45
82
  args = p.parse_args()
46
83
 
47
84
  if not NAME_RE.match(args.agent):
@@ -51,10 +88,12 @@ def main():
51
88
  agent_dir = root / args.agent
52
89
  (agent_dir / ".claude" / "skills").mkdir(parents=True, exist_ok=True)
53
90
 
54
- worktree = None
91
+ worktree, copied = None, []
55
92
  if args.worktree:
56
93
  worktree = agent_dir / "repo"
57
- add_worktree(Path(args.worktree).expanduser().resolve(), worktree, args.agent)
94
+ repo = Path(args.worktree).expanduser().resolve()
95
+ add_worktree(repo, worktree, args.agent)
96
+ copied = copy_included(repo, worktree)
58
97
 
59
98
  settings_path = agent_dir / ".claude" / "settings.json"
60
99
  try:
@@ -66,10 +105,12 @@ def main():
66
105
  if str(d) not in dirs:
67
106
  dirs.append(str(d))
68
107
  settings.setdefault("env", {})["AGENTS_TTS"] = "0" # workers stay silent; only the master speaks
108
+ gate = False if args.no_gate else add_gate(settings)
69
109
  settings_path.write_text(json.dumps(settings, indent=2) + "\n")
70
110
 
71
111
  print(json.dumps({"agent": args.agent, "dir": str(agent_dir), "settings": str(settings_path),
72
- "worktree": str(worktree) if worktree else None}, indent=2))
112
+ "worktree": str(worktree) if worktree else None, "copied": copied,
113
+ "gate_added": gate}, indent=2))
73
114
 
74
115
 
75
116
  if __name__ == "__main__":
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env python3
2
+ """Stop-hook "done gate" for a hivey swarm agent (Claude Code), from hivey-swarm-creator.
3
+
4
+ Registered in the agent's own .claude/settings.json by setup_agent.py. When the agent tries
5
+ to finish a turn while it still owns an `in-progress` task on the swarm's board
6
+ (<root>/.swarm/tasks.json), the stop is blocked once with a reminder: submit the task for
7
+ review, mark it blocked with a note, or say in one line why it stays open (waiting for a reply
8
+ or for background work). One reminder per task per in-progress episode, so it can never loop,
9
+ and nothing happens when the agent owns no open task. Standard library only; any problem just
10
+ lets the agent stop.
11
+
12
+ Usage: registered as `python3 swarm_gate.py` (reads the Stop hook's JSON on stdin).
13
+ """
14
+ import json
15
+ import os
16
+ import sys
17
+ import time
18
+ from pathlib import Path
19
+
20
+ HERE = Path(__file__).absolute().parent
21
+ TASKS = HERE / "swarm_tasks.py"
22
+
23
+
24
+ def find_agent(start):
25
+ """(swarm root, agent key): the folder holding .swarm/ and the first folder below it."""
26
+ p = Path(start).resolve()
27
+ for d in [p, *p.parents]:
28
+ if (d / ".swarm").is_dir():
29
+ if d == p:
30
+ return None
31
+ return d, p.relative_to(d).parts[0]
32
+ return None
33
+
34
+
35
+ def log_event(root, actor, **fields):
36
+ rec = {"ts": time.strftime("%Y-%m-%dT%H:%M:%S"), "type": "gate", "actor": actor, **fields}
37
+ try:
38
+ with open(root / ".swarm" / "events.jsonl", "a") as f:
39
+ f.write(json.dumps(rec) + "\n")
40
+ except OSError:
41
+ pass
42
+
43
+
44
+ def main():
45
+ try:
46
+ event = json.load(sys.stdin)
47
+ except ValueError:
48
+ event = {}
49
+ found = find_agent(event.get("cwd") or os.environ.get("CLAUDE_PROJECT_DIR") or ".")
50
+ if not found:
51
+ return
52
+ root, agent = found
53
+ try:
54
+ tasks = json.loads((root / ".swarm" / "tasks.json").read_text()).get("tasks", [])
55
+ except (OSError, ValueError):
56
+ return
57
+ open_ids = sorted(t["id"] for t in tasks
58
+ if t.get("owner") == agent and t.get("status") == "in-progress")
59
+
60
+ state_path = root / ".swarm" / "gate" / f"{agent}.json"
61
+ try:
62
+ reminded = set(json.loads(state_path.read_text()).get("reminded", []))
63
+ except (OSError, ValueError):
64
+ reminded = set()
65
+ # A task that left in-progress starts a new episode next time.
66
+ reminded &= set(open_ids)
67
+ fresh = [tid for tid in open_ids if tid not in reminded]
68
+ if fresh:
69
+ reminded |= set(fresh)
70
+ try:
71
+ state_path.parent.mkdir(parents=True, exist_ok=True)
72
+ state_path.write_text(json.dumps({"reminded": sorted(reminded)}) + "\n")
73
+ except OSError:
74
+ return
75
+ if not fresh:
76
+ return
77
+
78
+ ids = ", ".join(fresh)
79
+ first = fresh[0]
80
+ log_event(root, agent, tasks=fresh)
81
+ print(json.dumps({
82
+ "decision": "block",
83
+ "reason": (
84
+ f"Swarm done gate: you still own {ids} (in-progress) on the board. Before you stop:\n"
85
+ f"- finished: `python3 {TASKS} submit {first} --as {agent} --artifact <path>` "
86
+ "(add --repo/--range for code), so the fresh critics review it;\n"
87
+ f"- stuck or waiting on someone: `python3 {TASKS} set {first} blocked --as {agent} "
88
+ "--note '<why>'` and tell your master;\n"
89
+ "- only pausing (waiting for a reply or background work): say so in one line and stop.\n"
90
+ "This reminder comes once per task."
91
+ ),
92
+ }))
93
+
94
+
95
+ if __name__ == "__main__":
96
+ main()