@hivey/cli 0.9.87 β†’ 0.9.89

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.87",
3
+ "version": "0.9.89",
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",
package/repo/README.md CHANGED
@@ -62,7 +62,11 @@ Turn it off the same way, or with `hivey quiet off`.
62
62
 
63
63
  **Hibernation frees memory.** An agent left idle for 2 days is stopped (the agent CLI and its MCP servers), which gives its memory back. Its pane, name and conversation stay, and the space shows πŸ’€. Open the space again, or send the agent a message, and hivey resumes it with the same conversation on the latest CLI version. Choose the number of days (or off) in **settings β†’ hibernate**. Right-click a space and pick **Hibernate now** or **Resume session** to do it by hand, or **Settings…** to give that swarm or agent its own value. From a terminal: `hivey hibernate`, `hivey hibernate now <pane>`, `hivey agent-settings <space> --hibernate 7`.
64
64
 
65
- **Auto-compact window** is off by default: each Claude agent keeps its own. In **settings β†’ autocompact** (or a space's **Settings…**), pick `auto` or a size such as 200k or 400k tokens, and hivey types `/autocompact <size>` into each of those Claude agents when it starts or when you change the setting, so Claude compacts by itself once its context gets that full. Other sizes (100k–1M): `hivey agent-settings [<space>] --autocompact 350k`.
65
+ **Restart agents** (hivey menu, bottom right; click twice) restarts every agent in the session so it picks up updates: a new Claude Code version, CLAUDE.md, skills, hooks or the autocompact setting. hivey waits until each agent is idle, holding the messages sent to it meanwhile, then exits it and resumes the same conversation, two agents a second. Hibernated agents are left alone, because waking one already starts it fresh. From a terminal: `hivey hibernate restart all`.
66
+
67
+ **Auto-compact window** is off by default: each Claude agent keeps its own. In **settings β†’ autocompact** (or a space's **Settings…**), pick `auto` or a size such as 200k or 400k tokens. hivey then starts that space's Claude agents with `--autocompact <size>`: at launch, in a new session, when one wakes from hibernation, and when hivey restarts. The flag lasts for that session only and doesn't change Claude's own settings. Agents already running pick it up the next time they start; right-click the space β†’ **Restart session** to apply it now (the agent exits and resumes the same conversation). Other sizes (100k–1M): `hivey agent-settings [<space>] --autocompact 350k`.
68
+
69
+ **CLAUDE.md size.** Claude Code warns when a CLAUDE.md is over 40k characters. The agent fleet page shows **⚠ CLAUDE.md** on those agents, with a **🧽 Clean CLAUDE.md** button (click it twice to confirm). Opus rewrites the file to about 30k characters, keeping every rule, path, check and the current status. The original is saved in `~/.hivey/old/claude-md/`. The agent then exits and resumes its conversation in its own terminal, so it loads the new file. From a terminal: `hivey claude-md` lists the sizes, and `hivey claude-md clean <pane>` cleans one.
66
70
 
67
71
  **Voice quiet hours** silence only the voice at the same hours every night, for example from 22:00 to 08:00:
68
72
 
@@ -186,7 +186,7 @@ hivey agent-map schedule install [--at 06:30] [--model sonnet] # | remove | st
186
186
  ## Agent fleet (what every agent does now)
187
187
 
188
188
  `hivey agent-map fleet` (or `fleet`; hivey menu β†’ agent fleet) opens http://127.0.0.1:42817/fleet/ (old /fleet/ links redirect there; files in `reports/fleet/`; a fleet tab already open in Chrome is reloaded and brought to the front, otherwise it opens in a new Chrome window, not a tab in yours; the desktop pet's click does the same by default): every live
189
- agent in hivey at a desk in a 3D fleet, one room per space, and one spaceship per hivey session (`hivey session list`: the default session flies the classic frigate, the others a carrier, an explorer or a recoloured frigate, their name painted on the hull; a stopped session's ship has cold engines and its agents asleep at their desks, read from its saved `session.json`; a running one's engines burn). Click an agent to open its session in a terminal: the one already showing it, or a new Terminal/iTerm window running `hivey session attach <name>`, which also starts a stopped session. Click the name painted on a ship's hull for its menu (hover shows its agent count): open/start the session, or stop it (a second click confirms; `hivey session stop` ends all its agents and closes its terminal; never the default session). The space outside is one of six scenes (violet, emerald, crimson, deep blue, golden twin suns, a singularity with its lensed accretion disk), chosen with the page's 🌌 setting: a new one on every load, or always the one you pick (saved with the ⏱ setting; `?space=1..6` in the address overrides it). Drag the hull name to move the ship; positions are kept in `~/.hivey/agent-map/fleet-settings.json` with the ⏱ setting. Open, compact and clear reach the agent through its own session's socket. The details panel (right-click an agent, or β“˜) has a πŸ“š Wiki section: the agent's own `<name>-wiki/` (in its folder, or the folder named after its space under `~/agents` or `~/swarms`), its 8 newest pages and reports and its latest `log.md` entries; click one to open it in Obsidian (`obsidian://open`; a wiki that is not an Obsidian vault yet opens in the default Markdown app). After a /compact the context shown is the compacted size until the agent's next reply. Solo agents, extra sessions in a space and
189
+ agent in hivey at a desk in a 3D fleet, one room per space, and one spaceship per hivey session (`hivey session list`: the default session flies the classic frigate, the others a carrier, an explorer or a recoloured frigate, their name painted on the hull; a stopped session's ship has cold engines and its agents asleep at their desks, read from its saved `session.json`; a running one's engines burn). Click an agent to open its session in a terminal: the one already showing it, or a new Terminal/iTerm window running `hivey session attach <name>`, which also starts a stopped session. Click the name painted on a ship's hull for its menu (hover shows its agent count): open/start the session, or stop it (a second click confirms; `hivey session stop` ends all its agents and closes its terminal; never the default session). The space outside is one of six scenes (violet, emerald, crimson, deep blue, golden twin suns, a singularity with its lensed accretion disk), chosen with the page's 🌌 setting: a new one on every load, or always the one you pick (saved with the ⏱ setting; `?space=1..6` in the address overrides it). Drag the hull name to move the ship; positions are kept in `~/.hivey/agent-map/fleet-settings.json` with the ⏱ setting. Open, compact and clear reach the agent through its own session's socket. The details panel (right-click an agent, or β“˜) has a πŸ“š Wiki section: the agent's own `<name>-wiki/` (in its folder, or the folder named after its space under `~/agents` or `~/swarms`), its 8 newest pages and reports and its latest `log.md` entries; click one to open it in Obsidian (`obsidian://open`; a wiki that is not an Obsidian vault yet opens in the default Markdown app). After a /compact the context shown is the compacted size until the agent's next reply. A Claude agent whose `CLAUDE.md` is over Claude Code's 40k-character limit (counted like Claude Code: UTF-16 length) gets a red **⚠ CLAUDE.md** badge, a header pill to filter them, and a **🧽 Clean CLAUDE.md** button (two clicks): the server runs `hivey claude-md clean <pane>` in the background (log `~/.hivey/agent-map/claude-md-<pane>.log`): Opus rewrites the file to about 30k, the original goes to `~/.hivey/old/claude-md/`, and once the agent is idle it exits and resumes its conversation in its pane (`hivey hibernate restart`). Solo agents, extra sessions in a space and
190
190
  each swarm's coordinator get a desk; a swarm's workers and critics stand beside their coordinator's desk.
191
191
 
192
192
  - **Reads** each desk's terminal (`hivey pane read`, any CLI) and its Claude Code session log (context
@@ -147,6 +147,7 @@ main{position:relative}
147
147
  .ctx .bar i{display:block;height:100%;border-radius:9px}
148
148
  .badge{display:inline-flex;gap:4px;align-items:center;padding:1px 7px;border-radius:999px;font-size:11px;border:1px solid var(--line)}
149
149
  .badge.compact,.badge.clear{border-color:rgba(245,184,61,.55);color:var(--honey)}
150
+ .badge.md{border-color:rgba(251,113,133,.55);color:#fb7185}
150
151
  .actions{display:flex;gap:6px;margin-top:10px;flex-wrap:wrap}
151
152
  .actions button{background:var(--panel2);border:1px solid var(--line);border-radius:8px;padding:4px 9px;font-size:12px}
152
153
  .actions button:hover{border-color:var(--honey)}
@@ -54,15 +54,24 @@ function ring(p, size = 18) {
54
54
  }
55
55
  function adviceBadge(a) {
56
56
  const s = a.summary || {};
57
- if (s.advice === 'compact') return `<span class="badge compact" title="${esc(s.advice_why)}">πŸ—œ compact</span>`;
58
- if (s.advice === 'clear') return `<span class="badge clear" title="${esc(s.advice_why)}">🧹 clear</span>`;
59
- return '';
57
+ const md = claudeMdBadge(a);
58
+ if (s.advice === 'compact') return `<span class="badge compact" title="${esc(s.advice_why)}">πŸ—œ compact</span>${md}`;
59
+ if (s.advice === 'clear') return `<span class="badge clear" title="${esc(s.advice_why)}">🧹 clear</span>${md}`;
60
+ return md;
61
+ }
62
+ // a CLAUDE.md over Claude Code's 40k-char limit (counted like Claude Code)
63
+ function kchars(n) { return (n / 1000).toFixed(1) + 'k'; }
64
+ function claudeMdBadge(a) {
65
+ const m = a.claude_md;
66
+ if (!m?.over) return '';
67
+ return ` <span class="badge md" title="${esc(m.path)}: ${m.chars} chars, Claude Code warns above ${m.limit}. 🧽 Clean CLAUDE.md shortens it with Opus and restarts the agent.">⚠ CLAUDE.md ${kchars(m.chars)} / ${kchars(m.limit)}</span>`;
60
68
  }
61
69
  function toast(msg) { const t = $('#toast'); t.textContent = msg; t.classList.add('show'); clearTimeout(toast.t); toast.t = setTimeout(() => t.classList.remove('show'), 2600); }
62
70
  function visible(a) {
63
71
  if (ui.filter) {
64
72
  if (ui.filter in STATUS && a.status !== ui.filter) return false;
65
73
  if ((ui.filter === 'compact' || ui.filter === 'clear') && a.summary?.advice !== ui.filter) return false;
74
+ if (ui.filter === 'claude_md' && !a.claude_md?.over) return false;
66
75
  }
67
76
  const q = $('#q').value.trim().toLowerCase();
68
77
  if (!q) return true;
@@ -160,7 +169,7 @@ function armed(btn, a, action) {
160
169
  if (btn.classList.contains('arm')) { btn.classList.remove('arm'); btn.textContent = btn.dataset.label; act(a, action); return; }
161
170
  btn.dataset.label = btn.textContent;
162
171
  btn.classList.add('arm');
163
- btn.textContent = `Click again to ${action}`;
172
+ btn.textContent = btn.dataset.confirm || `Click again to ${action}`;
164
173
  setTimeout(() => { if (btn.classList.contains('arm')) { btn.classList.remove('arm'); btn.textContent = btn.dataset.label; } }, 3000);
165
174
  }
166
175
  function actionButtons(a) {
@@ -169,6 +178,7 @@ function actionButtons(a) {
169
178
  <button class="primary" data-act="focus" title="Open its terminal in hivey">β†— Open</button>
170
179
  ${a.cli_id === 'claude' ? `<button data-act="compact" ${busy ? 'disabled title="Only when it is not working"' : 'title="Type /compact into it and press Enter"'}>πŸ—œ Compact</button>
171
180
  <button data-act="clear" ${busy ? 'disabled title="Only when it is not working"' : 'title="Type /clear into it and press Enter (click twice)"'}>🧹 Clear</button>` : ''}
181
+ ${a.claude_md?.over && !a.asleep ? `<button data-act="clean-claude-md" data-confirm="Click again: Opus rewrites it, then the agent restarts" title="Opus rewrites its CLAUDE.md to about 30k chars (rules, paths, checks and status kept; original backed up), then the agent exits and resumes its conversation in its terminal (click twice)">🧽 Clean CLAUDE.md</button>` : ''}
172
182
  <button data-act="info" title="Everything about it">β“˜ Details</button></div>`;
173
183
  }
174
184
  function wireActions(root) {
@@ -195,6 +205,7 @@ function renderHeader() {
195
205
  const pills = [
196
206
  ['blocked', 'βœ‹', 'needs you', c.blocked], ['working', '⚑', 'working', c.working], ['done', 'βœ…', 'done', c.done],
197
207
  ['idle', 'πŸ’€', 'idle', c.idle], ['compact', 'πŸ—œ', 'to compact', adv.compact], ['clear', '🧹', 'to clear', adv.clear],
208
+ ...(c.claude_md ? [['claude_md', '⚠', 'CLAUDE.md too long', c.claude_md]] : []),
198
209
  ];
199
210
  $('#pills').innerHTML = pills.map(([k, e, l, n]) =>
200
211
  `<button class="pill ${k} ${ui.filter === k ? 'on' : ''}" data-f="${k}" title="Show only these">${e} <b>${n || 0}</b> ${l}</button>`).join('');
@@ -515,6 +515,22 @@ def clean_summary(s: dict) -> dict:
515
515
 
516
516
  # ---------------------------------------------------------------- one refresh
517
517
 
518
+ CLAUDE_MD_LIMIT = 40_000 # Claude Code warns when one instruction file is longer (in JS string length)
519
+
520
+
521
+ def claude_md_info(folder: str | None) -> dict | None:
522
+ """The size of the CLAUDE.md in an agent's folder, counted like Claude Code (UTF-16 units)."""
523
+ if not folder:
524
+ return None
525
+ path = Path(folder) / "CLAUDE.md"
526
+ try:
527
+ text = path.read_text(errors="replace")
528
+ except OSError:
529
+ return None
530
+ chars = len(text.encode("utf-16-le")) // 2
531
+ return {"chars": chars, "limit": CLAUDE_MD_LIMIT, "over": chars > CLAUDE_MD_LIMIT, "path": str(path)}
532
+
533
+
518
534
  def collect(hv: str, sessions: list[dict] | None = None) -> list[dict]:
519
535
  """Every agent of every running hivey session (one spaceship per session on the page)."""
520
536
  people = [d for hs in (sessions or hv_sessions(hv))
@@ -525,6 +541,7 @@ def collect(hv: str, sessions: list[dict] | None = None) -> list[dict]:
525
541
  for d, scr in zip(people, screens):
526
542
  d["screen"] = scr
527
543
  d["wiki"] = wiki_info(d.get("folder"), vaults, d.get("space", ""))
544
+ d["claude_md"] = claude_md_info(d.get("folder")) if d.get("cli_id") == "claude" else None
528
545
  log = session_log(transcript_of(d["session"], d["cli_id"]))
529
546
  d["_log"] = log
530
547
  d["log_uuid"] = log.get("uuid", "")
@@ -636,6 +653,7 @@ def _run(hv: str, model: str, use_llm: bool, quick: bool = False) -> int:
636
653
  counts = {k: sum(1 for d in people if d["status"] == k and not d.get("asleep"))
637
654
  for k in ("working", "blocked", "done", "idle")}
638
655
  counts["asleep"] = sum(1 for d in people if d.get("asleep"))
656
+ counts["claude_md"] = sum(1 for d in people if (d.get("claude_md") or {}).get("over"))
639
657
  full_at = now_iso()
640
658
  if quick: # a live pass: the last full summary pass stays the one already on the page
641
659
  try:
@@ -27,7 +27,9 @@ trigger them:
27
27
  {"id": "wN:p1" | "<session>/wN:p1", "action": "focus" | "compact" | "clear"} for a desk on the
28
28
  fleet page: focus opens the agent's terminal in hivey (and brings the
29
29
  terminal app forward); compact/clear type /compact or /clear into an agent
30
- that is not working
30
+ that is not working; clean-claude-md runs `hivey claude-md clean <pane>` in
31
+ the background (Opus shortens its CLAUDE.md, then the agent restarts; log in
32
+ ~/.hivey/agent-map/claude-md-<pane>.log)
31
33
 
32
34
  While a fleet page is open (it polls /fleet/fleet.json), a live pass runs every minute (status,
33
35
  context, screen; only desks whose status changed go to the model) and a full re-summary every 5 minutes.
@@ -449,6 +451,8 @@ def fleet_action(desk_id: str, action: str, session: str = "", path: str = "") -
449
451
  where = desk.get("hv_session") or "default"
450
452
  return True, {"opened": f"opened in a new terminal on session {where}",
451
453
  "raised": "opened in hivey"}.get(how, "focused in hivey (bring its terminal forward yourself)")
454
+ if action == "clean-claude-md":
455
+ return clean_claude_md(exe, sock, pane)
452
456
  if action in ("compact", "clear"):
453
457
  status = live_status(exe, sock, pane)
454
458
  if status in ("working", "blocked"):
@@ -457,6 +461,24 @@ def fleet_action(desk_id: str, action: str, session: str = "", path: str = "") -
457
461
  return False, "unknown action"
458
462
 
459
463
 
464
+ def clean_claude_md(exe: str, sock: str | None, pane: str) -> tuple[bool, str]:
465
+ """`hivey claude-md clean <pane>` in the background: it takes minutes (Opus rewrites the file), then
466
+ restarts the agent once it is idle."""
467
+ env = dict(os.environ) # like hv(): the inherited session unless the desk names one
468
+ if sock:
469
+ env = {k: v for k, v in env.items() if k not in INHERITED}
470
+ env["HERDR_SOCKET_PATH"] = sock
471
+ log = STATE / f"claude-md-{pane.replace(':', '-')}.log"
472
+ try:
473
+ STATE.mkdir(parents=True, exist_ok=True)
474
+ with open(log, "ab") as out:
475
+ subprocess.Popen([exe, "claude-md", "clean", pane], stdout=out, stderr=out,
476
+ stdin=subprocess.DEVNULL, env=env, start_new_session=True)
477
+ except OSError as e:
478
+ return False, f"cannot start the clean-up: {e}"
479
+ return True, "Opus is shortening its CLAUDE.md (a few minutes); then it restarts with the new file"
480
+
481
+
460
482
  def running(current_only: bool = True) -> int | None:
461
483
  """The port of our server; with current_only, None for an older version (it lacks new actions)."""
462
484
  try: