@feigi/fleet-ctl 3.108.0 → 3.109.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.108.0",
3
+ "version": "3.109.1",
4
4
  "description": "Agent fleet: run-team controller, merge bot, PR reviewer, and the ticket pipeline they share",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,12 +8,13 @@
8
8
  :root { color-scheme: dark; --bg:#0d1117; --panel:#161b22; --line:#30363d;
9
9
  --fg:#e6edf3; --dim:#8b949e; --red:#f85149; --amber:#d29922; --green:#3fb950; --blue:#58a6ff; }
10
10
  * { box-sizing: border-box; }
11
- /* The page is the window's height: header, banner, attention strip,
12
- spend panel and footer keep their natural height and never shrink; #board
13
- takes the rest, and each column scrolls on its own past that. The board's
14
- min-height is the floor for a window too short for the fixed parts — they
15
- then overflow body and the PAGE scrolls, rather than squeezing the
16
- columns to nothing or clipping anything off. */
11
+ /* The page is the window's height: header, banner, attention strip, the tab
12
+ strip and footer keep their natural height and never shrink; the open
13
+ tab's pane (#board or #spend, the other is hidden) takes the rest, and
14
+ each board column scrolls on its own past that. The panes' min-height is
15
+ the floor for a window too short for the fixed parts — they then overflow
16
+ body and the PAGE scrolls, rather than squeezing the columns to nothing or
17
+ clipping anything off. */
17
18
  body { margin:0; background:var(--bg); color:var(--fg);
18
19
  font:14px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;
19
20
  height:100vh; display:flex; flex-direction:column; }
@@ -32,7 +33,8 @@
32
33
  #stale-banner.dead { background:var(--red); color:#fff; }
33
34
  #attention { padding:8px 16px; border-bottom:1px solid var(--line); background:#2d1618; }
34
35
  #attention:empty { display:none; }
35
- .att { display:inline-block; margin:2px 10px 2px 0; }
36
+ .att { display:inline-block; margin:2px 10px 2px 0; color:inherit; text-decoration:none; }
37
+ .att:hover { text-decoration:underline; }
36
38
  .att .n { color:var(--blue); font-weight:600; }
37
39
  .flag { color:var(--red); font-weight:600; }
38
40
  #board { display:grid; grid-template-columns:repeat(5,1fr); grid-template-rows:minmax(0,1fr); gap:10px; padding:14px; align-items:start;
@@ -59,9 +61,19 @@
59
61
  .badge { border:1px solid var(--line); border-radius:10px; padding:0 6px; }
60
62
  .badge.flag { border-color:var(--red); color:var(--red); }
61
63
  footer { color:var(--dim); padding:10px 16px; border-top:1px solid var(--line); font-size:12px; }
64
+ /* A pane carries its own display (grid, block), which would beat the UA's
65
+ [hidden] rule; the closed tab's pane must stay closed. */
66
+ [hidden] { display:none !important; }
67
+ #tabs { display:flex; gap:4px; padding:8px 14px 0; border-bottom:1px solid var(--line); }
68
+ #tabs a { color:var(--dim); text-decoration:none; padding:5px 14px; border:1px solid transparent; border-bottom:0;
69
+ border-radius:6px 6px 0 0; margin-bottom:-1px; }
70
+ #tabs a:hover { color:var(--fg); }
71
+ #tabs a.on { color:var(--fg); background:var(--bg); border-color:var(--line); }
72
+ /* A hash link's target flashes once on arrival. The duration is FLASH_MS in the script. */
73
+ .card.flash { animation:flash 1.2s ease-out 1; }
74
+ @keyframes flash { from { box-shadow:0 0 0 2px var(--blue); background:#12233a; } to { box-shadow:0 0 0 2px transparent; } }
62
75
  footer .filed { margin-top:4px; }
63
- #spend { padding:0 14px 14px; }
64
- #spend:empty { display:none; }
76
+ #spend { padding:14px; flex:1 1 0; min-height:200px; overflow-y:auto; }
65
77
  .spend-wrap { background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:10px 12px; }
66
78
  .spend-hd { display:flex; align-items:baseline; gap:10px; margin-bottom:8px; }
67
79
  .spend-hd h2 { font-size:11px; letter-spacing:.06em; color:var(--dim); margin:0; text-transform:uppercase; }
@@ -83,8 +95,9 @@
83
95
  <header><h1 id="heading">🛰 fleet cockpit</h1><span id="age"></span></header>
84
96
  <div id="stale-banner"></div>
85
97
  <div id="attention"></div>
98
+ <nav id="tabs"><a id="tab-board" class="on" href="#board" aria-current="page">Board</a><a id="tab-tokens" href="#tokens">Tokens</a></nav>
86
99
  <div id="board"></div>
87
- <div id="spend"></div>
100
+ <div id="spend" hidden></div>
88
101
  <footer id="footer"></footer>
89
102
  <script>
90
103
  const COLUMNS = ["POOL", "IMPLEMENTING", "REVIEW", "READY", "MERGED"];
@@ -110,6 +123,37 @@ let repoUrl = null; // full repo URL from the model (carries the host) — PR li
110
123
  const TITLE = "fleet cockpit";
111
124
  function boardTitle(repo) { return repo ? `${TITLE} — ${repo}` : TITLE; }
112
125
 
126
+ // Where a URL hash lands: which tab is open, and which card (an issue number,
127
+ // as a string) to bring into view on it. The router's whole decision, as a
128
+ // value with no DOM or location touched, so it is liftable out of the source
129
+ // the way spendView is. It closes over nothing, for the same reason.
130
+ //
131
+ // Every hash the page draws is a tab (`#board`, `#tokens`) or a card on the
132
+ // Board (`#board/<issue>`). Anything else — no hash, a tab the page does not
133
+ // have, a target the tab does not have — lands on Board's top, or the named
134
+ // tab's top, never on a blank page and never on an error.
135
+ function routeHash(hash) {
136
+ const [tab, target, ...more] = String(hash).replace(/^#/, "").split("/");
137
+ if (tab === "board") return { tab, target: more.length === 0 && /^[1-9]\d*$/.test(target) ? target : null };
138
+ if (tab === "tokens") return { tab, target: null };
139
+ return { tab: "board", target: null };
140
+ }
141
+
142
+ // Each tab, and the pane it opens.
143
+ const PANES = { board: "board", tokens: "spend" };
144
+
145
+ // Which card is still owed a scroll. The cards are rebuilt every tick, so a
146
+ // hash that arrives before the first render (a reload, a pasted link) cannot
147
+ // scroll yet: it waits here for the render.
148
+ let rendered = false;
149
+ let pending = null;
150
+
151
+ // The card flashing now, and when it started. A tick rebuilds every card, so
152
+ // the flash lives here rather than on a node the next tick throws away.
153
+ // FLASH_MS is `.card.flash`'s animation duration.
154
+ const FLASH_MS = 1200;
155
+ let flashing = null;
156
+
113
157
  const el = (t, cls, txt) => { const e = document.createElement(t); if (cls) e.className = cls; if (txt != null) e.textContent = txt; return e; };
114
158
  const mins = (ms) => Math.floor((Date.now() - ms) / 60000);
115
159
 
@@ -236,14 +280,14 @@ function renderSpend(sp) {
236
280
 
237
281
  const wrap = el("div", "spend-wrap");
238
282
  const hd = el("div", "spend-hd");
239
- hd.append(el("h2", null, "spend"));
283
+ hd.append(el("h2", null, "tokens"));
240
284
  hd.append(el("span", "lede", v.lede));
241
285
  hd.append(el("span", "note", v.note));
242
286
  wrap.append(hd);
243
287
 
244
288
  const cols = el("div", "spend-cols");
245
289
  const byRole = el("div");
246
- byRole.append(el("h3", null, "by role"));
290
+ byRole.append(el("h3", null, "by member role"));
247
291
  spendRows(byRole, v.roles, {
248
292
  label: (r) => `${r.role} ×${r.agents}`,
249
293
  value: (r) => k(r.cacheWrite),
@@ -285,10 +329,12 @@ function render(m) {
285
329
  const att = document.getElementById("attention");
286
330
  att.innerHTML = "";
287
331
  for (const t of m.attention || []) {
288
- const span = el("span", "att");
289
- span.append(el("span", "n", "#" + t.issue), document.createTextNode(" "));
290
- span.append(el("span", "flag", (t.flags || []).join(" ")));
291
- att.append(span);
332
+ // A link into the Board, never a new window: the hash carries the card.
333
+ const a = el("a", "att");
334
+ a.href = "#board/" + t.issue;
335
+ a.append(el("span", "n", "#" + t.issue), document.createTextNode(" "));
336
+ a.append(el("span", "flag", (t.flags || []).join(" ")));
337
+ att.append(a);
292
338
  }
293
339
  // columns — each built once and kept, its contents rewritten every tick.
294
340
  // A column scrolls on its own and a scroll offset lives on
@@ -374,6 +420,12 @@ function render(m) {
374
420
  } else if (capMsg) {
375
421
  showBanner(capMsg);
376
422
  } else { banner.style.display = "none"; banner.className = ""; }
423
+ // Last, once the banner and footer have taken their place in the layout, so
424
+ // a card scrolled to is scrolled to where it will stay.
425
+ rendered = true;
426
+ // Its own catch: the board above is already written, so a failed scroll is
427
+ // not a failed render.
428
+ try { settle(); } catch (e) { warn("⚠ scroll to card failed: " + e.message); }
377
429
  }
378
430
 
379
431
  // The heartbeat's mark, rendered. A dead run's tickets keep the label
@@ -421,6 +473,7 @@ function ledgerBanner(state) {
421
473
 
422
474
  function card(t) {
423
475
  const c = el("div", "card");
476
+ c.id = "card-" + t.issue;
424
477
  const top = el("div", "top");
425
478
  top.append(el("span", "n", "#" + t.issue));
426
479
  top.append(el("span", "title", t.title || ""));
@@ -438,6 +491,9 @@ function card(t) {
438
491
  for (const f of t.flags || []) meta.append(el("span", "badge flag", f));
439
492
  if (t.ruling) meta.append(el("span", "badge", "ruled:" + t.ruling));
440
493
  c.append(meta);
494
+ // A card rebuilt mid-flash picks the flash up where it was, not from the start.
495
+ const age = flashing && flashing.issue === String(t.issue) ? Date.now() - flashing.at : Infinity;
496
+ if (age < FLASH_MS) flash(c, age);
441
497
  return c;
442
498
  }
443
499
 
@@ -454,6 +510,49 @@ function warn(msg) {
454
510
  showBanner(msg);
455
511
  }
456
512
 
513
+ // Opens the tab the hash names and settles the card it targets. The two
514
+ // panes stay in the page either way, so a tick keeps filling both.
515
+ function applyHash() {
516
+ const r = routeHash(location.hash);
517
+ for (const [t, pane] of Object.entries(PANES)) {
518
+ const on = t === r.tab;
519
+ document.getElementById(pane).hidden = !on;
520
+ const a = document.getElementById("tab-" + t);
521
+ a.classList.toggle("on", on);
522
+ if (on) a.setAttribute("aria-current", "page"); else a.removeAttribute("aria-current");
523
+ }
524
+ pending = r;
525
+ settle();
526
+ }
527
+
528
+ // The arrival: the target card scrolls into view and flashes once; no target,
529
+ // or a target no card on the board carries, lands on the tab's top. Taken
530
+ // off `pending` first, so a later tick never scrolls the page again; nothing
531
+ // settles before the first render.
532
+ function settle() {
533
+ if (!pending || !rendered) return;
534
+ const { target } = pending;
535
+ pending = null;
536
+ const hit = target && document.getElementById("card-" + target);
537
+ if (!hit) {
538
+ window.scrollTo(0, 0);
539
+ document.getElementById("spend").scrollTop = 0;
540
+ return;
541
+ }
542
+ hit.scrollIntoView({ block: "center" });
543
+ flashing = { issue: target, at: Date.now() };
544
+ flash(hit, 0);
545
+ }
546
+
547
+ // Runs the flash on a card `age` ms into it.
548
+ function flash(node, age) {
549
+ node.classList.remove("flash");
550
+ void node.offsetWidth; // restart the animation when the same card is targeted again
551
+ node.style.animationDelay = -age + "ms";
552
+ node.classList.add("flash");
553
+ node.addEventListener("animationend", () => node.classList.remove("flash"), { once: true });
554
+ }
555
+
457
556
  async function poll() {
458
557
  let r;
459
558
  try {
@@ -473,7 +572,21 @@ async function poll() {
473
572
  }
474
573
  setTimeout(poll, interval * 1000);
475
574
  }
476
- poll();
575
+
576
+ // Clicking the link to the hash already open fires no hashchange, so the
577
+ // click is routed to applyHash by hand: a card scrolled away from can be
578
+ // brought back by the same link.
579
+ function boot() {
580
+ window.addEventListener("hashchange", applyHash);
581
+ document.addEventListener("click", (e) => {
582
+ if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
583
+ const a = e.target.closest?.('a[href^="#"]');
584
+ if (a && a.getAttribute("href") === location.hash) { e.preventDefault(); applyHash(); }
585
+ });
586
+ applyHash();
587
+ poll();
588
+ }
589
+ boot();
477
590
  </script>
478
591
  </body>
479
592
  </html>
@@ -319,10 +319,11 @@ function originMain(root, env) {
319
319
  * A failed ancestry read is followed by `git rev-parse -q --verify B^{commit}`.
320
320
  * Only exit 1 with nothing on stderr is the missing answer: that is what an
321
321
  * absent commit gives. Exit 1 with anything on stderr means git could not
322
- * settle absence — an unopenable loose object, a broken alternate, an object
323
- * that is not a commit, or output unrelated to the object such as GIT_TRACE's
324
- * — and that read's own failure is returned, so `why` carries what git
325
- * printed. Anything else, a corrupt object's exit 128 included, keeps the
322
+ * settle absence — an unopenable loose object (git <= 2.55; git >= 2.56 exits
323
+ * 128 for it, which is the "anything else" below), a broken alternate, an
324
+ * object that is not a commit, or output unrelated to the object such as
325
+ * GIT_TRACE's — and that read's own failure is returned, so `why` carries what
326
+ * git printed. Anything else, a corrupt object's exit 128 included, keeps the
326
327
  * ancestry failure.
327
328
  */
328
329
  function headMove(root, env, was, now) {
@@ -635,12 +635,12 @@ fi
635
635
  #
636
636
  # The count above is only honest when the list can be trusted, and it cannot
637
637
  # always be. `git stash list` prints nothing at rc 0 for a reflog this process
638
- # cannot read (`chmod 000 .git/logs/refs/stash`), nothing at rc 1 for a stash
639
- # ref whose object is gone (`fatal: bad object refs/stash`), and nothing at rc 0
640
- # again for a `refs/stash` FILE this process cannot read (`chmod 000
641
- # .git/refs/stash`) — all measured, and none distinguishable from a genuinely
642
- # empty stash by the list alone, while `0` is the one value the runbook reads as
643
- # nothing to look at.
638
+ # cannot read (`chmod 000 .git/logs/refs/stash`), nothing at a nonzero rc — 1 on
639
+ # git <= 2.55, 128 on git >= 2.56 — for a stash ref whose object is gone
640
+ # (`fatal: bad object refs/stash`), and nothing at rc 0 again for a `refs/stash`
641
+ # FILE this process cannot read (`chmod 000 .git/refs/stash`) — all measured,
642
+ # and none distinguishable from a genuinely empty stash by the list alone, while
643
+ # `0` is the one value the runbook reads as nothing to look at.
644
644
  #
645
645
  # `show-ref` is the discriminator because its exit code separates "no such ref"
646
646
  # from "could not read the ref". Measured, git 2.50.1:
@@ -714,11 +714,12 @@ fi
714
714
  # A corrupt loose object behind a NON-TIP entry is one shape of that ceiling,
715
715
  # and it is not one, because git is loud about it. The reflog there is
716
716
  # intact, so `stash list` resolves the ref, prints the entries it could read,
717
- # says `fatal: loose object ... is corrupt` and exits 1 — a nonempty list at a
718
- # nonzero rc, a shape none of the rows above has, so `show-ref` agrees with the
719
- # ref and the cross-check has nothing to disagree with. The rc is the only
720
- # signal, which is why the list is captured rather than piped: `| wc -l` made
721
- # this statement's status `wc`'s, always 0, and git's own rc unrecoverable.
717
+ # says `fatal: loose object ... is corrupt` and exits nonzero — 1 on git <= 2.55,
718
+ # 128 on git >= 2.56; nothing below reads which — a nonempty list at a nonzero
719
+ # rc, a shape none of the rows above has, so `show-ref` agrees with the ref and
720
+ # the cross-check has nothing to disagree with. The rc is the only signal, which
721
+ # is why the list is captured rather than piped: `| wc -l` made this statement's
722
+ # status `wc`'s, always 0, and git's own rc unrecoverable.
722
723
  # Nothing else moves — the count is still the lines the list printed, its stderr
723
724
  # is still dropped here, and a list that succeeds is still read as a count.
724
725
  #
@@ -771,7 +772,7 @@ if [ "$stash" = 0 ] && [ "$sr_rc" = 1 ]; then
771
772
  fi
772
773
  # Two ways to the same answer, and each names its own state. The empty-list
773
774
  # states are asked first and keep the sentence they already print, because a
774
- # corrupt TIP object satisfies both tests (empty list, rc 1, `show-ref` rc 0)
775
+ # corrupt TIP object satisfies both tests (empty list, nonzero rc, `show-ref` rc 0)
775
776
  # and `refs/stash` is what is wrong with it — the sentence below is about the
776
777
  # ref, and it is the more specific of the two there. What is left for the rc is
777
778
  # the state no cross-check can reach: git printed entries and then said it could
@@ -812,17 +813,18 @@ if [ -n "$msg" ]; then
812
813
  #
813
814
  # `2>&1 >/dev/null` in that order captures stderr and drops stdout — the list
814
815
  # itself is not wanted, it was already counted. `|| true` is load-bearing
815
- # under `set -e`: git exits 1 in exactly the state this exists for, and an
816
+ # under `set -e`: git exits nonzero in exactly the state this exists for, and an
816
817
  # unguarded substitution would abort the audit before it emits a payload,
817
818
  # turning a report into a refusal.
818
819
  #
819
820
  # `tr` because `$diag` is not one line. A stash object that is CORRUPT
820
821
  # rather than missing (`echo junk > .git/objects/<xx>/<rest>`) reaches this
821
- # same branch — list empty at rc 1, show-ref rc 0 — and git says it in 7
822
- # lines, 10 with a bad `objects/info/alternates`. Unfolded they land at
823
- # column 0 in the audit's stderr, which is where only its own `$ git ...`
824
- # step headers belong. `$()` has already stripped the trailing newline, so
825
- # the fold adds no trailing space and the silent states still append nothing.
822
+ # same branch — list empty at rc 1 on git <= 2.55 and rc 128 on git >= 2.56,
823
+ # show-ref rc 0 — and git says it in 7 lines, 10 with a bad
824
+ # `objects/info/alternates`. Unfolded they land at column 0 in the audit's
825
+ # stderr, which is where only its own `$ git ...` step headers belong. `$()`
826
+ # has already stripped the trailing newline, so the fold adds no trailing
827
+ # space and the silent states still append nothing.
826
828
  #
827
829
  # `printf`, not `echo`: `$msg` now carries git's text under `#!/bin/sh`, and
828
830
  # both dash and macOS sh expand escapes in an `echo` operand — a `\c` in it