Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 48 additions & 6 deletions .agents/skills/bearings/assets/board-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,23 @@
.bb-call > .bb-decision[hidden] { display: none; }
.bb-decision { display: flex; flex-direction: column; }
.bb-decision__pad { padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.bb-decision__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bb-decision__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
/* Safety net for the risk-value contract owned by fm-bearings-board.sh: unlike
every other badge, this pin may still receive a long bare level. */
.bb-decision__risk { white-space: normal; overflow-wrap: anywhere; text-align: left;
min-width: 0; flex: 0 1 auto; line-height: 1.35; }
.bb-decision__repo { font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--text-faint); white-space: nowrap; }
.bb-decision__title { margin: 0; font-size: var(--fs-h4); font-weight: 800; color: var(--text-strong); line-height: 1.25; }
.bb-decision__detail { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.45; }
/* about / decide / recommended - three scannable context rows */
/* about / decide / recommended - three scannable context rows.
The shared value boundary also receives composed text moved off the risk pin,
so it must break a justification even when that text is one unbroken token. */
.bb-ctx { display: flex; flex-direction: column; gap: 6px; }
.bb-ctx__row { display: grid; grid-template-columns: 78px minmax(0,1fr); gap: 8px; align-items: baseline; }
.bb-ctx__k { font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.04em;
text-transform: uppercase; color: var(--text-faint); white-space: nowrap; }
.bb-ctx__v { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.4; min-width: 0; }
.bb-ctx__v { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.4; min-width: 0;
overflow-wrap: anywhere; }
.bb-decision__link { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ocean-600); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.bb-decision__link:hover { text-decoration: underline; }
/* One rhythm owner: the answer form is a flex column with the same 12px gap as
Expand Down Expand Up @@ -241,10 +248,17 @@
}
.bb-row:first-child { border-top: none; }
.bb-row__main { min-width: 0; flex: 1 1 auto; }
/* Row text wraps before it clips: a one-line clamp hid what these rows were
about, so the title gets three lines and its secondary line two.
overflow-wrap keeps an unbreakable URL or id from setting a min-content width
that the .bb-row__main min-width:0 shrink could not absorb, and overflow
hidden keeps whatever passes the clamp off the page's own horizontal axis. */
.bb-row__title { font-size: var(--fs-sm); font-weight: 700; color: var(--text-strong); line-height: 1.3;
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
overflow: hidden; text-overflow: ellipsis; overflow-wrap: anywhere; }
.bb-row__sub { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.3; margin-top: 1px;
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
overflow: hidden; text-overflow: ellipsis; overflow-wrap: anywhere; }
.bb-row__id { font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--text-faint); white-space: nowrap; }
.bb-row__pr { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600; color: var(--ocean-600); white-space: nowrap; }
.bb-row__pr:hover { text-decoration: underline; }
Expand Down Expand Up @@ -477,6 +491,22 @@

/* Captain's Call deck: every item renders as the same full card */
var deck = document.getElementById("bb-call");
/* Implements the fm-bearings-board.v1 risk contract documented in the
builder header. */
function splitRisk(value) {
var text = String(value == null ? "" : value).trim();
var cut = text.indexOf(".");
if (cut < 0) return { level: text, detail: "" };
return { level: text.slice(0, cut).trim(), detail: text.slice(cut + 1).trim() };
}

/* Do not broaden this to substring matching; see the builder header's
fail-cautious tone contract. */
var LOW_RISK_LEVELS = ["low", "faible"];
function isLowRisk(level) {
return LOW_RISK_LEVELS.indexOf(String(level == null ? "" : level).trim().toLowerCase()) >= 0;
}

function ctxRow(k, v, rec) {
var row = el("div", "bb-ctx__row" + (rec ? " bb-ctx__row--rec" : ""));
row.appendChild(el("span", "bb-ctx__k", k));
Expand All @@ -487,11 +517,18 @@
data.captains_call.forEach(function (item) {
var card = el("div", "fm-card fm-card--poster bb-decision");
var pad = el("div", "bb-decision__pad");
var risk = item.type === "merge" ? splitRisk(item.risk) : null;

var top = el("div", "bb-decision__top");
if (item.type === "merge") {
top.appendChild(badge("online", "checks green"));
top.appendChild(badge(item.risk === "low" ? "neutral" : "warn", "risk " + item.risk));
/* Preserve the builder header's empty-level rule: never announce a bare,
alert-colored "risk" badge. */
if (risk.level) {
var riskPin = badge(isLowRisk(risk.level) ? "neutral" : "warn", "risk " + risk.level);
riskPin.className += " bb-decision__risk";
top.appendChild(riskPin);
}
} else {
top.appendChild(badge("solid", "decision"));
top.appendChild(el("span", "bb-decision__repo", item.repo));
Expand All @@ -502,6 +539,11 @@

if (item.type === "merge") {
if (item.detail) pad.appendChild(el("p", "bb-decision__detail", item.detail));
if (risk.detail) {
var riskCtx = el("div", "bb-ctx");
riskCtx.appendChild(ctxRow("risk", risk.detail));
pad.appendChild(riskCtx);
}
if (item.pr_url) {
var pr = el("a", "bb-decision__link", item.pr_url);
pr.href = item.pr_url; pr.target = "_blank"; pr.rel = "noopener";
Expand Down
10 changes: 10 additions & 0 deletions bin/fm-bearings-board.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@
# that date with a UTC timestamp) the template orders the section by, newest
# first; a row with no comparable date keeps its payload order after every dated
# row. Anything else in that field refuses rather than sorting on garbage.
# A merge item's `risk` is one display string with one parsing rule: trimmed
# text before the first period is the level shown on the pin, and trimmed text
# after it is the justification shown in the card body. With no period, the
# whole value is a bare level and no justification row is rendered. A
# whitespace-only level renders no pin, even though the field itself must be a
# non-empty string. Only the trimmed, lower-cased levels `low` and `faible`
# receive the neutral tone; every unrecognized level stays alert. The renderer
# wraps either part, including an unbroken token, so neither can escape its
# card. The body placement keeps the justification available on touch and in
# print instead of hiding it behind hover.
#
# The board path is stable - $FM_HOME/.lavish/bearings-board.html - so a
# re-invocation rebuilds the same file in place, which keeps the same Lavish
Expand Down
25 changes: 22 additions & 3 deletions bin/fm-test-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@
# recorded family-level coupling still expands to the whole family.
# tests/lib.sh, tests/fixtures.sh, tests/*-helpers.sh and tests/*-fixture.sh are
# shared files that map to the suites naming them; a fixture under
# tests/fixtures/<dir>/ is mapped by that directory instead. Curated family arms
# above those also name individual tests/ files explicitly.
# tests/fixtures/<dir>/ is mapped by that directory instead, and a file under
# tests/assets/ by the suites naming its path. Curated family arms above those
# also name individual tests/ files explicitly.
set -eu

now_ms() {
Expand Down Expand Up @@ -375,7 +376,8 @@ family_for_basename() {
fm-afk-contract.test.sh|fm-afk-inject-e2e.test.sh|fm-afk-return.test.sh)
printf '%s\n' afk
;;
fm-bearings-board-render.test.sh|fm-bearings-snapshot.test.sh|\
fm-bearings-board-layout.test.sh|fm-bearings-board-render.test.sh|\
fm-bearings-snapshot.test.sh|\
fm-fleet-snapshot-view.test.sh|fm-home-summary-refresh.test.sh)
printf '%s\n' snapshot-bearings
;;
Expand Down Expand Up @@ -1584,6 +1586,23 @@ families_for_changed_path() {
|| printf '%s\n' "__unmapped__:$path"
fi
;;
tests/assets/*)
# An asset belongs to whichever suite reads it, found by the same
# reference scan used for shared helpers. Scan references even after
# deletion so an unchanged consumer still gets selected, and report an
# asset no suite names as unmapped rather than selecting nothing.
# Keep this arm above tests/*), which would otherwise claim every asset.
# Fixtures in tests/fm-test-run.test.sh must name synthetic assets, never
# a real tests/assets/ file: this scan reads test sources, so a real name
# embedded there would answer for the asset itself and hide the unmapped
# fallback behind that suite's own family.
if [ -e "$path" ]; then
families_for_test_reference "$path" \
|| printf '%s\n' "__unmapped__:$path"
else
families_for_test_reference "$path" || true
fi
;;
tests/*)
printf '%s\n' "__unmapped__:$path"
;;
Expand Down
42 changes: 38 additions & 4 deletions tests/assets/board-render-harness.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// Usage: node board-render-harness.mjs <built-board.html>
// Prints one JSON document:
// { stats:[{n,label}], underway:[{title,sub,badges}],
// charted:[{title,sub,badges,pickable}], empty, more, error }
// charted:[{title,sub,badges,pickable}],
// calls:[{title,badges,ctx:[{k,v}]}], empty, more, error }
import { readFileSync } from "node:fs";

const html = readFileSync(process.argv[2], "utf8");
Expand All @@ -24,9 +25,18 @@ class Node {
this.type = "";
this.value = "";
this.checked = false;
const tokens = () => this.className.split(/\s+/).filter(Boolean);
this.classList = {
add: (c) => { this.className = (this.className + " " + c).trim(); },
contains: (c) => this.className.split(/\s+/).includes(c),
contains: (c) => tokens().includes(c),
remove: (c) => { this.className = tokens().filter((t) => t !== c).join(" "); },
// Card-deck navigation drives the class it wants with an explicit second
// argument, so honour force before falling back to flipping.
toggle: (c, force) => {
const on = force === undefined ? !tokens().includes(c) : Boolean(force);
if (on) this.classList.add(c); else this.classList.remove(c);
return on;
},
};
}
get textContent() {
Expand Down Expand Up @@ -87,7 +97,12 @@ new Function(script)();
const badgesOf = (row) =>
row.children
.filter((c) => c.className.includes("fm-badge"))
.map((c) => ({ tone: c.className.replace(/.*fm-badge--/, "").trim(), text: c.textContent }));
// A badge may carry further classes after its tone, so read the tone token
// itself rather than everything that follows the prefix.
.map((c) => ({
tone: (c.className.match(/fm-badge--([\w-]+)/) || [, ""])[1],
text: c.textContent,
}));

const strip = byId.get("bb-stats") || new Node("div");
const stats = strip.children.map((t) => ({
Expand All @@ -113,6 +128,25 @@ const underway = rowsOf(uw);

const ch = byId.get("bb-charted") || new Node("div");
const charted = rowsOf(ch);
// Captain's Call cards: the badges each card wears and the context rows in its
// body, so what the risk value renders as is asserted through the template.
const deck = byId.get("bb-call") || new Node("div");
const calls = deck.children
.filter((c) => c.className.split(/\s+/).includes("bb-decision"))
.map((card) => {
const pad = card.children.find((c) => c.className.includes("bb-decision__pad"));
const top = pad?.children.find((c) => c.className.includes("bb-decision__top"));
const ctx = pad?.children.find((c) => c.className.includes("bb-ctx"));
return {
title: pad?.children.find((c) => c.className.includes("bb-decision__title"))?.textContent ?? "",
badges: top ? badgesOf(top) : [],
ctx: (ctx?.children ?? []).map((row) => ({
k: row.children.find((c) => c.className.includes("bb-ctx__k"))?.textContent ?? "",
v: row.children.find((c) => c.className.includes("bb-ctx__v"))?.textContent ?? "",
})),
};
});

// A fail-closed render replaces the page body instead of the board sections, so
// surface it rather than reporting an empty board as a successful render.
const errorText = [...byId.entries()]
Expand All @@ -123,4 +157,4 @@ const empty = ch.children.filter((c) => c.className.includes("bb-empty")).map((c
const more = ch.children.filter((c) => c.className.includes("bb-morechip")).map((c) => c.textContent);

process.stdout.write(
JSON.stringify({ stats, underway, charted, empty, more, error: errorText }) + "\n");
JSON.stringify({ stats, underway, charted, calls, empty, more, error: errorText }) + "\n");
Loading
Loading