@hivey/cli 0.9.71 → 0.9.73

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.71",
3
+ "version": "0.9.73",
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",
@@ -77,7 +77,10 @@ schemas, `finalize`, repair rules).
77
77
  X content, radars, trading, research swarms). Draw only confirmed links, labelled with what flows
78
78
  (≤ 17 characters: "top-20 tweets", "transcripts"). Fold the rest: a job that belongs to an agent
79
79
  merges into it ("+ nightly 03:15" in its sublabel), many similar jobs become one node ("12 trading
80
- jobs"), and unlinked housekeeping (git auto-commits, upgrades, purges) goes in a "Not drawn" card.
80
+ jobs"), and unlinked housekeeping (git auto-commits, upgrades, purges) becomes one box ("8 housekeeping
81
+ jobs"). **Every scanned job is on the map**: its own box, a group box or its agent's box, listed in that
82
+ box's `map-meta.json` refs. The nightly run gives the model the jobs last night's map left out
83
+ (`enhance.jobs_off_map`), and the map page names any still missing under its legend.
81
84
  **Node tags do not show at default zoom: put cost and status in the sublabel** ("$110 · posts → n8n",
82
85
  "launchd 04:30 · exit 1"). Put an agent that shares no data at a free cell where no line crosses it.
83
86
  Providers and totals go in cards (spend by provider and model, needs attention, spend gaps, not
@@ -50,6 +50,7 @@ NAV_CSS = """
50
50
  """
51
51
 
52
52
  MAP_CSS = """
53
+ .hv-off{margin-top:6px;padding-top:6px;border-top:1px solid rgba(127,127,127,.25);max-width:340px;line-height:1.35}
53
54
  .hv-legend{position:fixed;left:14px;bottom:14px;z-index:40;padding:8px 10px;border-radius:10px;
54
55
  font:12px/1.3 -apple-system,BlinkMacSystemFont,sans-serif;background:rgba(255,255,255,.92);color:#1d2330;
55
56
  border:1px solid rgba(127,127,127,.3);box-shadow:0 2px 10px rgba(0,0,0,.08)}
@@ -264,6 +265,16 @@ new MutationObserver(refill).observe(document.body,{childList:true,subtree:true,
264
265
  """
265
266
 
266
267
 
268
+ def jobs_off_map(spec: dict, meta: dict, snap: dict) -> list[dict]:
269
+ """The scanned jobs no map box stands for: a job is on the map when a box's map-meta refs list it,
270
+ or list the agent it belongs to (links_candidates.belongs_to). The nightly model gets this list
271
+ so new jobs reach the map, and the map page names any still missing."""
272
+ boxes = {str(n.get("id")) for n in spec.get("nodes") or []}
273
+ refs = {r for k, v in (meta.get("nodes") or {}).items() if k in boxes for r in (v or {}).get("refs") or []}
274
+ owner = {b.get("job"): b.get("agent") for b in (snap.get("links_candidates") or {}).get("belongs_to") or []}
275
+ return [j for j in snap.get("jobs") or [] if j.get("id") and j["id"] not in refs and owner.get(j["id"]) not in refs]
276
+
277
+
267
278
  def enhance_folder(folder: Path, snap: dict, job_state) -> None:
268
279
  generated, days = snap.get("generated", ""), snap.get("window_days", 7)
269
280
  stats = folder / "agent-stats.html"
@@ -277,6 +288,11 @@ def enhance_folder(folder: Path, snap: dict, job_state) -> None:
277
288
  except (OSError, ValueError):
278
289
  meta = {}
279
290
  data, top = node_data(snap, spec, meta, job_state)
291
+ off = jobs_off_map(spec, meta, snap)
292
+ off_note = (f'<div class="hv-off" title="{html.escape(", ".join(j["id"] for j in off))}">'
293
+ f'<b>Not on the map yet ({len(off)}):</b> {html.escape(", ".join(j.get("name") or j["id"] for j in off))}'
294
+ '<br><span style="opacity:.65">the next nightly run adds them; the Logs page has every job</span></div>'
295
+ if off else "")
280
296
  stages = dict(STAGE_HELP)
281
297
  stages.update({k.lower(): v for k, v in (meta.get("stages") or {}).items()})
282
298
  script = (MAP_JS.replace("__DATA__", json.dumps(data)).replace("__STAGES__", json.dumps(stages))
@@ -284,5 +300,5 @@ def enhance_folder(folder: Path, snap: dict, job_state) -> None:
284
300
  legend = (f'<div class="hv-legend"><b>Spend, last {span(days)}</b><div class="bar"></div>'
285
301
  f'<div class="ends"><span>$0</span><span>{money(top)}</span></div>'
286
302
  f'<div style="opacity:.65;margin-top:3px">click a box for what it does, tokens and models</div>'
287
- f'<div style="opacity:.65">⚠️ its last run failed, was missed or logged errors</div></div>')
303
+ f'<div style="opacity:.65">⚠️ its last run failed, was missed or logged errors</div>{off_note}</div>')
288
304
  page.write_text(inject(page.read_text(), NAV_CSS + MAP_CSS, nav("agent-map.html", generated, days) + legend, script))
@@ -420,7 +420,14 @@ already built: do not touch stats.archify.md or agent-stats.html.
420
420
  and keep a consumer agent (one a job feeds) without its interactive cost. Each node's sublabel holds
421
421
  its schedule with its start time (a box folding several jobs shows the earliest: "cron from 00:30")
422
422
  or its role, its models and its automated cost when it has one ("cron 04:15 · Grok + Sonnet ·
423
- $0.40"); spend is usage.agents (automated only). Keep at most 25 nodes on 5 stages x rows 0-4;
423
+ $0.40"); spend is usage.agents (automated only). EVERY job in snapshot.json "jobs" must be on the map:
424
+ in its own box, or folded into a box with related jobs (e.g. "5 git backups", "11 trading jobs", "4 X
425
+ jobs") or into the box of the agent it belongs to (links_candidates.belongs_to); map-meta.json refs
426
+ (step 3) list every job id a box stands for. Fold more when space runs out, never drop a job.
427
+ Never fold an agent or swarm into a job's box: a job that feeds its agent (a links_confirmed link)
428
+ gets its own box with an arrow into the agent's box; otherwise it merges into the agent's box,
429
+ named after the agent ("+ nightly 02:45" in its sublabel).
430
+ Keep at most 25 nodes on 5 stages x rows 0-4;
424
431
  refresh the numbers in the cards (automated spend, models in use, needs attention).
425
432
  3. Descriptions: every node in snapshot.json has a "description" (what it does). snapshot.json
426
433
  "descriptions_to_write" lists the ids whose description is empty, cut off, copied from a brief
@@ -478,13 +485,30 @@ def set_token_command(command: str) -> int:
478
485
  return 0
479
486
 
480
487
 
481
- def run_llm(folder: Path, model: str, has_map: bool) -> bool:
488
+ def off_map_task(prev: Path | None, snap: dict) -> str:
489
+ """The map step's words for the scanned jobs last night's map leaves out (see enhance.jobs_off_map)."""
490
+ import enhance
491
+ try:
492
+ spec = json.loads((prev / "map.json").read_text()) if prev else {}
493
+ meta = json.loads((prev / "map-meta.json").read_text()) if prev else {}
494
+ except (OSError, ValueError):
495
+ spec, meta = {}, {}
496
+ off = enhance.jobs_off_map(spec, meta, snap) if spec else []
497
+ if not off:
498
+ return ""
499
+ lines = "\n".join(f" - {j['id']} ({j.get('schedule') or 'no schedule'}): {(j.get('description') or '')[:110]}"
500
+ for j in off)
501
+ return ("\n These scheduled jobs are not on the map yet; add every one of them:\n" + lines)
502
+
503
+
504
+ def run_llm(folder: Path, model: str, has_map: bool, prev: Path | None = None, snap: dict | None = None) -> bool:
482
505
  claude = shutil.which("claude")
483
506
  archify = archify_bin()
484
507
  if not claude or not archify:
485
508
  log(folder, "skipping the map update: claude or archify not found")
486
509
  return False
487
- task = ("map.json is last night's map: update it, adding nodes and flows for newly confirmed links."
510
+ task = ("map.json is last night's map: update it, adding nodes and flows for newly confirmed links and "
511
+ "every scheduled job that is not on it yet." + off_map_task(prev, snap or {})
488
512
  if has_map else "there is no map.json yet: write it following the skill's map rules.")
489
513
  prompt = MAP_PROMPT.format(folder=folder, scripts=SCRIPTS, archify=archify, map_task=task)
490
514
  tools = ("Read,Write,Edit,Glob,Grep,Bash(python3:*),Bash(node:*),Bash(ls:*),Bash(cat:*),"
@@ -600,13 +624,16 @@ def start_time_labels(spec: dict, meta: dict, snap: dict) -> dict[str, list[str]
600
624
  owned: dict[str, list[str]] = {}
601
625
  for b in (snap.get("links_candidates") or {}).get("belongs_to") or []:
602
626
  owned.setdefault(b.get("agent", ""), []).append(b.get("job", ""))
627
+ boxes = {str(n.get("id")) for n in spec.get("nodes") or []}
628
+ own_box = {r for k, v in (meta.get("nodes") or {}).items() if k in boxes for r in (v or {}).get("refs") or [] if r in jobs}
603
629
  out = {}
604
630
  for n in spec.get("nodes") or []:
605
631
  sub = str(n.get("sublabel", ""))
606
632
  if n.get("type") == "database" or re.search(r"\b\d\d:\d\d\b", sub):
607
633
  continue
608
634
  refs = ((meta.get("nodes") or {}).get(n.get("id")) or {}).get("refs") or []
609
- ids = [r for r in refs if r in jobs] or [j for r in refs for j in owned.get(r, []) if j in jobs]
635
+ # an agent's box borrows the times of its jobs, except jobs drawn in a box of their own
636
+ ids = [r for r in refs if r in jobs] or [j for r in refs for j in owned.get(r, []) if j in jobs and j not in own_box]
610
637
  starts = [s for s in (job_start(jobs[j].get("schedule", "")) for j in dict.fromkeys(ids)) if s]
611
638
  if not starts:
612
639
  continue
@@ -686,7 +713,7 @@ def nightly(scan, days: int, model: str, use_llm: bool) -> int:
686
713
  shutil.copy2(prev, folder / "map.json")
687
714
  has_map = (folder / "map.json").is_file()
688
715
  if use_llm:
689
- run_llm(folder, model, has_map)
716
+ run_llm(folder, model, has_map, prev.parent if has_map and prev else None, snap)
690
717
  if (folder / "map.json").is_file() and not html_current(folder, "agent-map.html", "map.json"):
691
718
  good, why = finalize(folder, "dataflow", "map.json", "agent-map.html")
692
719
  if not good and prev and prev.is_file(): # the model broke it: last night's map, unchanged