Files
skills/orchestrator/templates/kanban-marks.js
T
Kevin Veen-BirkenbachandClaude Opus 5.5 f356083a24 feat(orchestrator): hub requirements 066 to 082 and 084
Radio footer, rules page, schedules editor (System timers and Claude
tasks through signed runner jobs), account usage bar, usage explorer
with a streamed usage.jsonl, queue Controls tab and override, running
tasks on the board, stale task prune with the generic dial, greyed card
stamps, commit-tree diffs from the runner preview, VS Code path links,
expired asks and decisions that stay as EXPIRED cards (asks keyed by a
call digest; an async PostToolUse hook closes those answered in the
terminal), the Match refresh hourglass, attachments by paste, drop and
paperclip in every text field (page CSP gains img-src blob: for the
thumbnails) and the limits board with profiles and a passkey to loosen.
Fixes: one red accept on a red-gate commit and no release while a risk
is open, the send bar footer segments share one height, the mic button
survives a redraw, new Match cards queue before the release card.

E2E specs were still running at commit time (operator order); their
failures follow as separate fixes.

🎯 Fix: 88 %
💥 Break: 8 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 81
🚦 Gate: ⛔ fix 88 % < 90, break 8 % > 5 (committed on the operator's word)

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 19:05:38 +00:00

89 lines
4.0 KiB
JavaScript

const KanbanMarks = (() => {
"use strict";
const DAY = 86400;
const HOUR = 3600;
const MINUTE = 60;
const BEAT_S = 5 * MINUTE;
const HEAD_SHOWN = 32;
const QUEUE = "queue";
const RUNNING = "running";
const RESPONSIBLE = "R";
const NOBODY = "-";
const MARKS = [["queue", "bi-cpu", "accent"], ["agent", "bi-person-workspace", "ok"], ["hub", "bi-terminal", "info"]];
/**
* @param seconds - a span in seconds.
* @returns the span in words, cut to its two largest units: "45 s", "12 min", "2 h 5 min", "3 d 4 h".
*/
function span(seconds) {
const whole = Math.max(0, Math.floor(seconds));
if (whole < MINUTE) {
return `${whole} s`;
}
if (whole < HOUR) {
return `${Math.floor(whole / MINUTE)} min`;
}
const [big, unit, small, rest] = whole < DAY ? [HOUR, "h", MINUTE, "min"] : [DAY, "d", HOUR, "h"];
const part = Math.floor((whole % big) / small);
return part ? `${Math.floor(whole / big)} ${unit} ${part} ${rest}` : `${Math.floor(whole / big)} ${unit}`;
}
/**
* @param command - a hub job's command.
* @returns its first line, cut to HEAD_SHOWN characters with an ellipsis.
*/
function head(command) {
const line = command.trim().split("\n")[0].trim();
return line.length > HEAD_SHOWN ? `${line.slice(0, HEAD_SHOWN - 1)}…` : line;
}
function queueMark(row, tasks, now) {
const own = tasks.filter((job) => job.kind === QUEUE && job.status === RUNNING && (job.task === row.task || job.queue.parent === row.task));
const first = own.filter((job) => job.start !== null).sort((a, b) => a.start - b.start)[0] || own[0];
if (!first) {
return null;
}
const runtime = first.start === null ? "?" : span(now - first.start);
const more = own.length > 1 ? `, ${own.length - 1} more running` : "";
return {text: `${first.queue.kind} · ${runtime}`, hint: `${row.task}: queue job ${first.task} runs ${first.queue.kind} for ${runtime}${more}`, at: first.start};
}
function agentMark(row, beats, now) {
const names = [row.worker, ...Object.entries(row.roles).filter(([, letters]) => letters.includes(RESPONSIBLE)).map(([party]) => party)];
const fresh = [...new Set(names)].filter((name) => name !== NOBODY && Object.hasOwn(beats, name) && now - beats[name] >= -MINUTE && now - beats[name] <= BEAT_S);
const name = fresh.sort((a, b) => beats[b] - beats[a])[0];
if (!name) {
return null;
}
const ago = span(now - beats[name]);
return {text: `${name} · ${ago}`, hint: `${row.task}: ${name} works on it, last beat ${ago} ago`, at: beats[name]};
}
function hubMark(row, runner, now) {
if (!runner || runner.task !== row.task) {
return null;
}
const shown = head(runner.command) || runner.job;
return {text: shown, hint: `${row.task}: the hub runs ${runner.job} for ${span(now - runner.started)}: ${runner.command || runner.job}`, at: runner.started};
}
/**
* @param row - a card's task row: task, worker and roles.
* @param sources - {now, tasks, beats, runner}: now the hub's epoch seconds; tasks the hub's task rows, whose queue
* rows are the entries of queue.json; beats the hub's {agent: epoch of its latest heartbeat}; runner the hub job
* runner-job.json names, {job, task, started, command}, or null.
* @returns the card's marks in MARKS order, each {key, icon, tone, text, hint, at}: queue while a queue job of the
* task or the queue card's own job runs (its kind and runtime), agent while the task's worker or an R beat within
* BEAT_S (the freshest of them and how long ago), hub while runner-job.json names the task (the command's head).
*/
function marks(row, sources) {
const found = {queue: queueMark(row, sources.tasks, sources.now), agent: agentMark(row, sources.beats, sources.now), hub: hubMark(row, sources.runner, sources.now)};
return MARKS.filter(([key]) => found[key]).map(([key, icon, tone]) => ({key, icon, tone, ...found[key]}));
}
return {BEAT_S, MARKS, span, head, marks};
})();
if (typeof module === "object" && module.exports) {
module.exports = KanbanMarks;
}