Files
skills/orchestrator/templates/prune.js
T
Kevin Veen-BirkenbachandClaude Opus 5.5 6323f087bc feat(orchestrator): hub page for requirements 085 to 099
085 calm Match deck: no header hourglass, centred bare empty state, the
release card as a deck card (Cancel, Skip, Release), fixed card height.
086 motion: vanish() fade everywhere with a lint test, view transitions,
a lub-dub heartbeat for working objects, confetti that lands and fades.
087 time readout under the pivot of every analog clock.
088 prune dialog grouped by prefix with tri-state boxes, search, stepper
and sticky footer.
089 one-row task toolbar with Filter and Actions menus and a filter chip.
090 card border by state colour with a soft glow and owner avatars.
091 draggable limit lines with staged changes and one Save, a Limits menu
with the matrix, View toggles, the GPU cause in its tooltip.
093 request chips Open, Expired, Stale, Failed, All and a signed Delete.
094 closed cards leave the deck within 5 s; open in Claude stamps.
095 compact agent message box with Post/Call, attach, mic and Send in
the field.
096 Reject on an expired card drops it silently as Drop (expired).
097 Show filter in Match's right-click menu.
098 docked speech bubbles carry the speaker's avatar and a skip button.
099 Match card headlines cut to 120 characters with the full title in
the tooltip; the code box keeps the whole command.
tests/test_hub_path_links.py: a unicode fixture without German.

Full make test green through the queue (2605 tests, ruff, shellcheck,
markdownlint). Gate missed on the operator's word: break 7 %, the E2E
specs (13 new, 15 updated) run next.

🎯 Fix: 92 %
💥 Break: 7 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 86
🚦 Gate: ⛔ break 7 % > 5

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 01:47:41 +00:00

116 lines
4.7 KiB
JavaScript

const Prune = (() => {
"use strict";
const {staleFor, STALE_DAYS} = typeof Plan === "object" ? Plan : require("./plan.js");
const {marks} = typeof KanbanMarks === "object" ? KanbanMarks : require("./kanban-marks.js");
const KIND = "prune";
const ANNOUNCE = "announce";
const APPLY = "prune";
const MINUTE = 60;
const MINUTES = {value: 10, min: 1, max: 60, page: 5};
const DAYS = {min: 1, max: 999};
const OTHER = "other";
/**
* @param rows - the hub's task rows.
* @param sources - the mark sources of KanbanMarks.marks: {now, tasks, beats, runner}.
* @param days - N: how many days without a register change make a task stale.
* @returns the stale tasks, oldest change first: register tasks the operator may change (editable: open, no
* operator/ or hotfix/ record) without a register change for N days and without a running mark.
*/
function stale(rows, sources, days) {
const found = rows.filter((row) => row.editable && staleFor(row, sources.now, days) && !marks(row, sources).length);
return found.sort((a, b) => a.updated - b.updated || a.task.localeCompare(b.task));
}
/**
* @param tasks - the ticked task slugs.
* @param days - N of the stale list.
* @param since - the epoch the list was taken at; a register change after it keeps a task.
* @param minutes - the answer window on the dial.
* @returns the two items one passkey assertion signs: the announce job, run at once, and the rasci.py prune job,
* which the runner holds back until the deadline since + minutes.
*/
function items(tasks, days, since, minutes) {
const deadline = since + minutes * MINUTE;
return [
{kind: KIND, argv: [ANNOUNCE, "--days", String(days), "--deadline", String(deadline), ...tasks]},
{kind: KIND, argv: [APPLY, "--since", String(since), ...tasks], not_before: deadline},
];
}
/**
* @param jobs - the hub's runner jobs (state.jobs).
* @param now - the hub's epoch seconds.
* @returns the queued apply job of a signed prune nearest its deadline as {job, deadline, tasks, left}, left the whole
* seconds until the deadline and never below 0; null without one.
*/
function pending(jobs, now) {
const queued = jobs.filter((job) => job.kind === KIND && job.status === "queued" && typeof job.not_before === "number" && Array.isArray(job.argv) && job.argv[0] === APPLY);
const next = queued.sort((a, b) => a.not_before - b.not_before)[0];
return next ? {job: next.id, deadline: next.not_before, tasks: next.argv.slice(3), left: Math.max(0, Math.ceil(next.not_before - now))} : null;
}
/**
* @param text - what the operator typed in the days field.
* @returns the whole number of days between DAYS.min and DAYS.max it names, else null.
*/
function daysOf(text) {
const value = /^[0-9]{1,3}$/.test(text.trim()) ? Number(text.trim()) : NaN;
return value >= DAYS.min && value <= DAYS.max ? value : null;
}
/**
* @param task - a register task slug.
* @returns the text before its first "/", OTHER for a slug without one.
*/
function prefixOf(task) {
const cut = task.indexOf("/");
return cut > 0 ? task.slice(0, cut) : OTHER;
}
/**
* @param rows - the stale rows of stale().
* @returns one {prefix, rows} per prefixOf() among the rows, the prefixes in alphabetical order with OTHER last,
* each group's rows in the order given.
*/
function groups(rows) {
const found = new Map();
for (const row of rows) {
const prefix = prefixOf(row.task);
if (!found.has(prefix)) {
found.set(prefix, []);
}
found.get(prefix).push(row);
}
const order = [...found.keys()].sort((a, b) => (a === OTHER) - (b === OTHER) || a.localeCompare(b));
return order.map((prefix) => ({prefix, rows: found.get(prefix)}));
}
/**
* @param row - a hub task row.
* @returns its owner as the board shows it: the worker, else the first R holder, else "-".
*/
function owner(row) {
if (row.worker && row.worker !== "-") {
return row.worker;
}
const first = String(row.responsible || "-").split(", ")[0];
return first || "-";
}
/**
* @param row - a hub task row.
* @param text - what the operator typed in the filter field.
* @returns whether the row's slug, title or owner holds the trimmed text, ignoring case; true for an empty text.
*/
function matches(row, text) {
const needle = text.trim().toLowerCase();
return !needle || [row.task, row.title, owner(row)].some((value) => String(value || "").toLowerCase().includes(needle));
}
return {KIND, MINUTE, MINUTES, DAYS, STALE_DAYS, OTHER, stale, items, pending, daysOf, prefixOf, groups, owner, matches};
})();
if (typeof module === "object" && module.exports) {
module.exports = Prune;
}