feat(lanes): give every pipeline node its own driver command

A pipeline template named ONE command for the whole run (`skill`), so the
only way to know what actually moves a given node was to read that node's
`detect` regexes. Each node now carries its own `command`: a slash command
(`/superpowers:writing-plans`) or a shell one (`ccam lanes hook ci-gate`),
whichever its detect rules already watch for.

The values are derived from each node's own detect rules, not invented —
every `ccam …` string was checked against bin/ccam.js and every
`/superpowers:*` against the installed plugin. Nodes reaching which is a
declaration rather than an action (`done`, `merged`, `reported`,
`e2e-feature-passed`, `qc-plan`) are deliberately left empty.

`pipelines.js` normalizes a missing or non-string value to "", so a
custom template written before this field keeps loading rather than
rendering "undefined". `nodeStates()` and GET /api/lanes/pipeline-stats
pass it through. Never executed by the dashboard — display text, the same
contract `skill` already had.

Surfaced where each view has room for it: the Workflows pass-rate panel
shows it under the node label and copies it on click; PipelineMap folds
it into the node tooltip, because a 16-node pipeline has to fit across
one card and there is no width for a second line.

`command?: string` is optional in the client type only to spare four
unrelated test fixtures — the server always sends the key, and the UI has
to branch on the empty string regardless.

Verified: npm run test:server (1373, +3), npm run test:client (459, +2),
tsc --noEmit, prettier and check-headers clean. docs/LANES.md § Custom
template format documents the field. openapi.yaml needs no change: the
lane payload and pipeline-stats were never schematized there.
This commit is contained in:
2026-09-04 11:43:43 +07:00
parent 677cdf007b
commit 6df69d8811
12 changed files with 177 additions and 15 deletions
@@ -139,9 +139,24 @@ export function LanePipelinePanel() {
data-testid={`pipeline-stat-${n.id}`}
className="flex items-center gap-2 text-xs"
>
<span className="w-36 shrink-0 truncate text-fg-secondary" title={n.label}>
<span className="mr-1">{n.icon}</span>
{n.label}
{/* Label over the command that drives this node — the pass rate
to the right answers "how often", this answers "by what". */}
<span className="w-44 shrink-0 overflow-hidden" title={n.label}>
<span className="block truncate text-fg-secondary">
<span className="mr-1">{n.icon}</span>
{n.label}
</span>
{n.command && (
<button
type="button"
data-testid={`pipeline-stat-command-${n.id}`}
title={t("lanes.copyCommand", { command: n.command })}
onClick={() => void navigator.clipboard?.writeText(n.command || "")}
className="block max-w-full truncate font-mono text-[10px] text-fg-muted hover:text-accent"
>
{n.command}
</button>
)}
</span>
{/* Bars are scaled against the busiest node, not against each
@@ -3,7 +3,8 @@
* row per node of the busiest pipeline, distinguishes a proved pass from a
* merely claimed one, and switches templates through the picker. Conflating
* evidence with a bare claim is the failure that matters here — it would make
* an undocumented stage look verified.
* an undocumented stage look verified. Also covers the per-node driver command:
* shown and copyable when the template names one, absent when it does not.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
@@ -18,11 +19,12 @@ vi.mock("../../../lib/api", async (importOriginal) => {
return { ...actual, api: { lanes: { pipelineStats: (id?: number | null) => statsMock(id) } } };
});
const node = (id: string, over: Record<string, number> = {}) => ({
const node = (id: string, over: Record<string, number | string> = {}) => ({
id,
label: id,
icon: "🧭",
gate: false,
command: "",
entered: 0,
passed: 0,
withEvidence: 0,
@@ -37,7 +39,12 @@ const STATS = {
name: "Default feature pipeline",
runs: 4,
nodes: [
node("plan", { entered: 4, passed: 4, withEvidence: 4 }),
node("plan", {
entered: 4,
passed: 4,
withEvidence: 4,
command: "/superpowers:writing-plans",
}),
node("implement", { entered: 4, passed: 4, withEvidence: 0 }),
node("tests", { entered: 3, passed: 2, withEvidence: 2, failed: 1 }),
node("ship"),
@@ -51,6 +58,33 @@ const STATS = {
],
};
describe("LanePipelinePanel per-node command", () => {
it("shows the driver command under a node that declares one, and nothing for a node that does not", async () => {
statsMock.mockResolvedValue(STATS);
render(<LanePipelinePanel />);
const plan = await screen.findByTestId("pipeline-stat-command-plan");
expect(plan).toHaveTextContent("/superpowers:writing-plans");
// `tests` carries no command in the fixture: an empty string must render
// nothing at all, never an empty clickable row.
expect(screen.queryByTestId("pipeline-stat-command-tests")).toBeNull();
});
it("copies the command to the clipboard on click", async () => {
const writeText = vi.fn().mockResolvedValue(undefined);
Object.defineProperty(navigator, "clipboard", {
value: { writeText },
configurable: true,
});
statsMock.mockResolvedValue(STATS);
render(<LanePipelinePanel />);
fireEvent.click(await screen.findByTestId("pipeline-stat-command-plan"));
expect(writeText).toHaveBeenCalledWith("/superpowers:writing-plans");
});
});
describe("LanePipelinePanel", () => {
it("shows pass count, entries and rate per node of the busiest pipeline", async () => {
statsMock.mockResolvedValue(STATS);