Skip to content

Commit 83784fd

Browse files
feat(engine): add hasPlanSkippedSteps
Expose a pure plan-DAG skipped-step check for miner and dashboard flows that need a quick skipped/not-skipped signal. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent f96e067 commit 83784fd

3 files changed

Lines changed: 63 additions & 0 deletions

File tree

packages/gittensory-engine/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export { isPlanFullyCompleted } from "./plan-completion.js";
143143
export { hasPlanFailedSteps } from "./plan-failure.js";
144144
export { hasPlanPendingSteps } from "./plan-pending.js";
145145
export { hasPlanRunningSteps } from "./plan-running.js";
146+
export { hasPlanSkippedSteps } from "./plan-skipped.js";
146147
export * from "./plan-templates.js";
147148
export * from "./portfolio/queue.js";
148149
export {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { PlanDag } from "./plan-export.js";
2+
3+
/**
4+
* Return whether any step in the plan was skipped. Pure — reads the plan DAG only.
5+
*/
6+
export function hasPlanSkippedSteps(plan: PlanDag): boolean {
7+
return plan.steps.some((step) => step.status === "skipped");
8+
}

test/unit/plan-skipped.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { describe, expect, it } from "vitest";
2+
3+
import { hasPlanSkippedSteps } from "../../packages/gittensory-engine/src/plan-skipped";
4+
import type { PlanStep } from "../../packages/gittensory-engine/src/plan-export";
5+
6+
function step(over: Partial<PlanStep> & { id: string; title: string }): PlanStep {
7+
return {
8+
actionClass: undefined,
9+
dependsOn: [],
10+
status: "pending",
11+
attempts: 0,
12+
maxAttempts: 3,
13+
lastError: null,
14+
...over,
15+
};
16+
}
17+
18+
describe("hasPlanSkippedSteps", () => {
19+
it("returns false for an empty plan", () => {
20+
expect(hasPlanSkippedSteps({ steps: [] })).toBe(false);
21+
});
22+
23+
it("returns false when no step was skipped", () => {
24+
expect(
25+
hasPlanSkippedSteps({
26+
steps: [
27+
step({ id: "a", title: "Build", status: "completed" }),
28+
step({ id: "b", title: "Test", status: "pending" }),
29+
],
30+
}),
31+
).toBe(false);
32+
});
33+
34+
it("returns true when at least one step was skipped", () => {
35+
expect(
36+
hasPlanSkippedSteps({
37+
steps: [
38+
step({ id: "a", title: "Build", status: "completed" }),
39+
step({ id: "b", title: "Deploy", status: "skipped" }),
40+
],
41+
}),
42+
).toBe(true);
43+
});
44+
45+
it("is exported from the package barrel", async () => {
46+
const barrel = await import("../../packages/gittensory-engine/src/index");
47+
expect(typeof barrel.hasPlanSkippedSteps).toBe("function");
48+
expect(
49+
barrel.hasPlanSkippedSteps({
50+
steps: [step({ id: "a", title: "A", status: "skipped" })],
51+
}),
52+
).toBe(true);
53+
});
54+
});

0 commit comments

Comments
 (0)