@calmo/task-runner 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/dependabot.yml +7 -7
- package/.github/workflows/ci.yml +4 -4
- package/.jules/backlog_maniac.md +1 -0
- package/.jules/nexus.md +1 -0
- package/.jules/sentinel.md +1 -0
- package/.releaserc.json +2 -7
- package/AGENTS.md +8 -2
- package/CHANGELOG.md +178 -174
- package/README.md +23 -23
- package/coverage/coverage-final.json +8 -8
- package/coverage/index.html +7 -7
- package/coverage/lcov-report/index.html +7 -7
- package/coverage/lcov-report/src/EventBus.ts.html +27 -21
- package/coverage/lcov-report/src/TaskGraphValidationError.ts.html +12 -3
- package/coverage/lcov-report/src/TaskGraphValidator.ts.html +152 -137
- package/coverage/lcov-report/src/TaskRunner.ts.html +48 -45
- package/coverage/lcov-report/src/TaskRunnerBuilder.ts.html +29 -5
- package/coverage/lcov-report/src/TaskRunnerExecutionConfig.ts.html +1 -1
- package/coverage/lcov-report/src/TaskStateManager.ts.html +1 -1
- package/coverage/lcov-report/src/WorkflowExecutor.ts.html +21 -12
- package/coverage/lcov-report/src/contracts/RunnerEvents.ts.html +1 -1
- package/coverage/lcov-report/src/contracts/index.html +1 -1
- package/coverage/lcov-report/src/index.html +8 -8
- package/coverage/lcov-report/src/strategies/DryRunExecutionStrategy.ts.html +4 -4
- package/coverage/lcov-report/src/strategies/RetryingExecutionStrategy.ts.html +29 -11
- package/coverage/lcov-report/src/strategies/StandardExecutionStrategy.ts.html +5 -5
- package/coverage/lcov-report/src/strategies/index.html +1 -1
- package/coverage/lcov.info +266 -262
- package/coverage/src/EventBus.ts.html +27 -21
- package/coverage/src/TaskGraphValidationError.ts.html +12 -3
- package/coverage/src/TaskGraphValidator.ts.html +152 -137
- package/coverage/src/TaskRunner.ts.html +48 -45
- package/coverage/src/TaskRunnerBuilder.ts.html +29 -5
- package/coverage/src/TaskRunnerExecutionConfig.ts.html +1 -1
- package/coverage/src/TaskStateManager.ts.html +1 -1
- package/coverage/src/WorkflowExecutor.ts.html +21 -12
- package/coverage/src/contracts/RunnerEvents.ts.html +1 -1
- package/coverage/src/contracts/index.html +1 -1
- package/coverage/src/index.html +8 -8
- package/coverage/src/strategies/DryRunExecutionStrategy.ts.html +4 -4
- package/coverage/src/strategies/RetryingExecutionStrategy.ts.html +29 -11
- package/coverage/src/strategies/StandardExecutionStrategy.ts.html +5 -5
- package/coverage/src/strategies/index.html +1 -1
- package/dist/EventBus.js +13 -11
- package/dist/EventBus.js.map +1 -1
- package/dist/TaskGraphValidationError.js.map +1 -1
- package/dist/TaskGraphValidator.js +9 -9
- package/dist/TaskGraphValidator.js.map +1 -1
- package/dist/TaskRunner.js.map +1 -1
- package/dist/TaskRunnerBuilder.js.map +1 -1
- package/dist/WorkflowExecutor.js +2 -1
- package/dist/WorkflowExecutor.js.map +1 -1
- package/dist/strategies/RetryingExecutionStrategy.js +3 -1
- package/dist/strategies/RetryingExecutionStrategy.js.map +1 -1
- package/dist/strategies/StandardExecutionStrategy.js +1 -1
- package/dist/strategies/StandardExecutionStrategy.js.map +1 -1
- package/openspec/AGENTS.md +81 -15
- package/openspec/changes/archive/2026-01-18-add-concurrency-control/proposal.md +7 -4
- package/openspec/changes/archive/2026-01-18-add-concurrency-control/tasks.md +1 -0
- package/openspec/changes/archive/2026-01-18-add-external-task-cancellation/proposal.md +4 -1
- package/openspec/changes/archive/2026-01-18-add-external-task-cancellation/tasks.md +2 -1
- package/openspec/changes/archive/2026-01-18-add-integration-tests/proposal.md +3 -0
- package/openspec/changes/archive/2026-01-18-add-integration-tests/tasks.md +1 -0
- package/openspec/changes/archive/2026-01-18-add-task-retry-policy/proposal.md +3 -0
- package/openspec/changes/archive/2026-01-18-add-task-retry-policy/tasks.md +1 -0
- package/openspec/changes/archive/2026-01-18-add-workflow-preview/proposal.md +3 -0
- package/openspec/changes/archive/2026-01-18-add-workflow-preview/tasks.md +1 -0
- package/openspec/changes/archive/2026-01-18-refactor-core-architecture/proposal.md +3 -0
- package/openspec/changes/archive/2026-01-18-refactor-core-architecture/tasks.md +1 -0
- package/openspec/changes/feat-per-task-timeout/proposal.md +11 -6
- package/openspec/changes/feat-per-task-timeout/tasks.md +1 -1
- package/openspec/project.md +21 -15
- package/package.json +1 -1
- package/src/EventBus.ts +18 -16
- package/src/TaskGraph.ts +8 -8
- package/src/TaskGraphValidationError.ts +4 -1
- package/src/TaskGraphValidator.ts +148 -143
- package/src/TaskRunner.ts +42 -41
- package/src/TaskRunnerBuilder.ts +11 -3
- package/src/WorkflowExecutor.ts +13 -10
- package/src/contracts/ITaskGraphValidator.ts +12 -12
- package/src/contracts/ValidationError.ts +6 -6
- package/src/contracts/ValidationResult.ts +4 -4
- package/src/strategies/DryRunExecutionStrategy.ts +3 -3
- package/src/strategies/RetryingExecutionStrategy.ts +15 -9
- package/src/strategies/StandardExecutionStrategy.ts +4 -4
- package/test-report.xml +108 -108
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ runner.on("taskEnd", ({ step, result }) => {
|
|
|
36
36
|
Here is a simple example showing how to define a context, create steps, and execute them.
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
|
-
import { TaskRunner, TaskStep } from
|
|
39
|
+
import { TaskRunner, TaskStep } from "./src";
|
|
40
40
|
|
|
41
41
|
// 1. Define your domain-specific context
|
|
42
42
|
interface ValidationContext {
|
|
@@ -49,42 +49,42 @@ interface ValidationContext {
|
|
|
49
49
|
|
|
50
50
|
// 2. Define your steps
|
|
51
51
|
const UrlFormatStep: TaskStep<ValidationContext> = {
|
|
52
|
-
name:
|
|
52
|
+
name: "UrlFormatStep",
|
|
53
53
|
run: async (ctx) => {
|
|
54
|
-
const valid = ctx.issueBody.includes(
|
|
54
|
+
const valid = ctx.issueBody.includes("github.com");
|
|
55
55
|
return valid
|
|
56
|
-
? { status:
|
|
57
|
-
: { status:
|
|
56
|
+
? { status: "success" }
|
|
57
|
+
: { status: "failure", error: "Invalid URL" };
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
const DataLoaderStep: TaskStep<ValidationContext> = {
|
|
62
|
-
name:
|
|
63
|
-
dependencies: [
|
|
62
|
+
name: "DataLoaderStep",
|
|
63
|
+
dependencies: ["UrlFormatStep"],
|
|
64
64
|
run: async (ctx) => {
|
|
65
65
|
// Simulate API call
|
|
66
|
-
ctx.prData = { additions: 20, ciStatus:
|
|
67
|
-
return { status:
|
|
66
|
+
ctx.prData = { additions: 20, ciStatus: "success" };
|
|
67
|
+
return { status: "success", message: "Data fetched" };
|
|
68
68
|
},
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
const MaxChangesStep: TaskStep<ValidationContext> = {
|
|
72
|
-
name:
|
|
73
|
-
dependencies: [
|
|
72
|
+
name: "MaxChangesStep",
|
|
73
|
+
dependencies: ["DataLoaderStep"],
|
|
74
74
|
run: async (ctx) => {
|
|
75
75
|
// Safe access because dependencies ensured execution order
|
|
76
|
-
if (!ctx.prData) return { status:
|
|
76
|
+
if (!ctx.prData) return { status: "failure", error: "Missing PR Data" };
|
|
77
77
|
|
|
78
78
|
return ctx.prData.additions < 50
|
|
79
|
-
? { status:
|
|
80
|
-
: { status:
|
|
79
|
+
? { status: "success" }
|
|
80
|
+
: { status: "failure", error: "Too many changes" };
|
|
81
81
|
},
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
// 3. Execute the runner
|
|
85
85
|
async function main() {
|
|
86
86
|
const context: ValidationContext = {
|
|
87
|
-
issueBody:
|
|
87
|
+
issueBody: "https://github.com/org/repo/pull/1",
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
const runner = new TaskRunner(context);
|
|
@@ -104,7 +104,7 @@ If a task fails or is skipped, the `TaskRunner` automatically marks all subseque
|
|
|
104
104
|
|
|
105
105
|
## Context Hydration
|
|
106
106
|
|
|
107
|
-
One nice thing to do is to avoid optional parameters and excessive use of
|
|
107
|
+
One nice thing to do is to avoid optional parameters and excessive use of `!` operator, with task dependencies we can chain our steps and context usages to make sure steps are executed only when pre requisites are met.
|
|
108
108
|
|
|
109
109
|
This decouples **Data Loading** from **Business Logic**.
|
|
110
110
|
|
|
@@ -130,23 +130,23 @@ interface MyProjectFullContext extends MyProjectContext {
|
|
|
130
130
|
|
|
131
131
|
// Step 1: Hydrate the context
|
|
132
132
|
class UserLoaderStep implements TaskStep<MyProjectContext> {
|
|
133
|
-
name =
|
|
133
|
+
name = "UserLoaderStep";
|
|
134
134
|
async run(ctx: MyProjectContext & Partial<MyProjectFullContext>) {
|
|
135
135
|
// Fetch data and update context
|
|
136
|
-
ctx.apiData = { user:
|
|
137
|
-
return { status:
|
|
136
|
+
ctx.apiData = { user: "john_doe", isPro: true };
|
|
137
|
+
return { status: "success" };
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
// Step 2: Use the hydrated data
|
|
142
142
|
class PremiumCheckStep implements TaskStep<MyProjectContext> {
|
|
143
|
-
name =
|
|
144
|
-
dependencies = [
|
|
143
|
+
name = "PremiumCheckStep";
|
|
144
|
+
dependencies = ["UserLoaderStep"]; // Ensures data is ready
|
|
145
145
|
|
|
146
146
|
async run(ctx: MyProjectFullContext) {
|
|
147
147
|
return ctx.apiData.isPro
|
|
148
|
-
? { status:
|
|
149
|
-
: { status:
|
|
148
|
+
? { status: "success" }
|
|
149
|
+
: { status: "failure", error: "User is not a Pro member" };
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
```
|