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:
@@ -126,6 +126,72 @@ describe("pipelines", () => {
|
||||
const lanes = require("../lib/lanes");
|
||||
const features = require("../lib/lane-features");
|
||||
|
||||
describe("per-node driver command", () => {
|
||||
it("gives every built-in template's nodes a command field, and carries it into the render states", () => {
|
||||
for (const pipeline of listPipelines()) {
|
||||
for (const node of pipeline.nodes) {
|
||||
assert.equal(
|
||||
typeof node.command,
|
||||
"string",
|
||||
`${pipeline.id}/${node.id} must declare a command string`
|
||||
);
|
||||
}
|
||||
const states = nodeStates(pipeline, { stage: pipeline.nodes[0].id, stages: {} });
|
||||
assert.deepEqual(
|
||||
states.map((n) => n.command),
|
||||
pipeline.nodes.map((n) => n.command),
|
||||
`${pipeline.id}: nodeStates must pass each node's command through`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it("names a real driver for the stages an agent actually drives", () => {
|
||||
const ship = getPipeline("ship-feature");
|
||||
const byId = Object.fromEntries(ship.nodes.map((n) => [n.id, n.command]));
|
||||
|
||||
assert.equal(byId.intake, "/superpowers:brainstorming");
|
||||
assert.equal(byId.implementing, "/superpowers:test-driven-development");
|
||||
assert.equal(byId.gates, "ccam lanes hook ci-gate");
|
||||
// A terminal node has no driver of its own: reaching `done` is a
|
||||
// declaration, not something a command performs.
|
||||
assert.equal(byId.done, "");
|
||||
});
|
||||
|
||||
it("defaults a template node that declares no command to the empty string", () => {
|
||||
// A custom template written before this field existed must keep loading -
|
||||
// an undefined command would render as "undefined" in the UI.
|
||||
const fs = require("node:fs");
|
||||
const dir = fs.mkdtempSync(pathMod.join(os.tmpdir(), "pipelines-nocmd-"));
|
||||
fs.writeFileSync(
|
||||
pathMod.join(dir, "legacy.json"),
|
||||
JSON.stringify({
|
||||
id: "legacy-nocmd",
|
||||
name: "Legacy",
|
||||
nodes: [
|
||||
{ id: "start", label: "Start" },
|
||||
{ id: "done", command: 42 },
|
||||
],
|
||||
})
|
||||
);
|
||||
const prev = process.env.DASHBOARD_PIPELINES_DIR;
|
||||
process.env.DASHBOARD_PIPELINES_DIR = dir;
|
||||
const { reload } = require("../lib/pipelines");
|
||||
reload();
|
||||
try {
|
||||
const p = getPipeline("legacy-nocmd");
|
||||
assert.deepEqual(
|
||||
p.nodes.map((n) => n.command),
|
||||
["", ""],
|
||||
"a missing or non-string command must normalize to empty, never leak through"
|
||||
);
|
||||
} finally {
|
||||
if (prev === undefined) delete process.env.DASHBOARD_PIPELINES_DIR;
|
||||
else process.env.DASHBOARD_PIPELINES_DIR = prev;
|
||||
reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("lanes lib", () => {
|
||||
it("creates, lists, updates and deletes a lane", () => {
|
||||
const l = lanes.createLane({ title: "Feature A", cwd: "/tmp/wt/a", branch: "feat/a" });
|
||||
|
||||
Reference in New Issue
Block a user