@calmo/task-runner 4.1.0 → 4.2.0
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/.jules/nexus.md +5 -0
- package/.release-please-manifest.json +1 -1
- package/AGENTS.md +2 -0
- package/CHANGELOG.md +27 -0
- package/README.md +34 -0
- package/conductor/code_styleguides/general.md +23 -0
- package/conductor/code_styleguides/javascript.md +51 -0
- package/conductor/code_styleguides/typescript.md +43 -0
- package/conductor/product-guidelines.md +14 -0
- package/conductor/product.md +16 -0
- package/conductor/setup_state.json +1 -0
- package/conductor/tech-stack.md +19 -0
- package/conductor/workflow.md +334 -0
- package/dist/EventBus.js +16 -16
- package/dist/EventBus.js.map +1 -1
- package/dist/PluginManager.d.ts +22 -0
- package/dist/PluginManager.js +39 -0
- package/dist/PluginManager.js.map +1 -0
- package/dist/TaskGraphValidator.d.ts +1 -1
- package/dist/TaskGraphValidator.js +16 -21
- package/dist/TaskGraphValidator.js.map +1 -1
- package/dist/TaskRunner.d.ts +8 -1
- package/dist/TaskRunner.js +29 -19
- package/dist/TaskRunner.js.map +1 -1
- package/dist/TaskStateManager.js +9 -5
- package/dist/TaskStateManager.js.map +1 -1
- package/dist/WorkflowExecutor.js +19 -10
- package/dist/WorkflowExecutor.js.map +1 -1
- package/dist/contracts/Plugin.d.ts +30 -0
- package/dist/contracts/Plugin.js +2 -0
- package/dist/contracts/Plugin.js.map +1 -0
- package/openspec/changes/add-middleware-support/proposal.md +19 -0
- package/openspec/changes/add-middleware-support/specs/task-runner/spec.md +34 -0
- package/openspec/changes/add-middleware-support/tasks.md +9 -0
- package/openspec/changes/add-resource-concurrency/tasks.md +1 -0
- package/openspec/changes/allow-plugin-hooks/design.md +51 -0
- package/openspec/changes/allow-plugin-hooks/proposal.md +12 -0
- package/openspec/changes/allow-plugin-hooks/specs/post-task/spec.md +21 -0
- package/openspec/changes/allow-plugin-hooks/specs/pre-task/spec.md +32 -0
- package/openspec/changes/allow-plugin-hooks/tasks.md +7 -0
- package/openspec/changes/archive/2026-02-15-implement-plugin-system/design.md +45 -0
- package/openspec/changes/archive/2026-02-15-implement-plugin-system/proposal.md +13 -0
- package/openspec/changes/archive/2026-02-15-implement-plugin-system/specs/plugin-context/spec.md +17 -0
- package/openspec/changes/archive/2026-02-15-implement-plugin-system/specs/plugin-loading/spec.md +27 -0
- package/openspec/changes/archive/2026-02-15-implement-plugin-system/tasks.md +7 -0
- package/openspec/changes/feat-completion-dependencies/proposal.md +58 -0
- package/openspec/changes/feat-completion-dependencies/tasks.md +46 -0
- package/openspec/changes/feat-task-loop/proposal.md +22 -0
- package/openspec/changes/feat-task-loop/specs/task-runner/spec.md +34 -0
- package/openspec/changes/feat-task-loop/tasks.md +8 -0
- package/openspec/specs/plugin-context/spec.md +19 -0
- package/openspec/specs/plugin-loading/spec.md +29 -0
- package/package.json +1 -1
- package/src/EventBus.ts +7 -8
- package/src/PluginManager.ts +41 -0
- package/src/TaskGraphValidator.ts +22 -24
- package/src/TaskRunner.ts +36 -23
- package/src/TaskStateManager.ts +9 -5
- package/src/WorkflowExecutor.ts +24 -11
- package/src/contracts/Plugin.ts +32 -0
package/.jules/nexus.md
CHANGED
|
@@ -19,3 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
**Insight:** Blindly retrying failing tasks is a "Product Anti-pattern". Retrying a `SyntaxError` or invalid user input 3 times (with exponential backoff!) is annoying and wasteful.
|
|
21
21
|
**Action:** We must distinguish between "Transient" (network, resource lock) and "Permanent" (logic, validation) failures. Exposing a `shouldRetry` predicate gives the user control without complicating the core runner logic.
|
|
22
|
+
|
|
23
|
+
## 2026-01-24 - The Cleanup Paradox
|
|
24
|
+
|
|
25
|
+
**Insight:** "Continue On Error" is often misused for Cleanup logic. Users mark critical tasks as "Optional" just to ensure subsequent cleanup tasks run, which incorrectly allows *other* dependents to run too. True "Teardown" requires the *dependent* to assert its resilience, not the *dependency* to declare its weakness.
|
|
26
|
+
**Action:** Invert the control. Instead of the failing task saying "I don't matter" (`continueOnError`), the cleanup task should say "I run anyway" (`runCondition: 'always'`). This preserves the criticality of the workflow while ensuring resource hygiene.
|
package/AGENTS.md
CHANGED
|
@@ -26,6 +26,8 @@ Keep this managed block so 'openspec update' can refresh the instructions.
|
|
|
26
26
|
- **Strict Null Safety:** Do not use `??` or optional chaining `?.` when you can guarantee existence via prior validation. Use non-null assertions `!` only when the invariant is locally provable or enforced by a validator.
|
|
27
27
|
- **Dead Code Elimination:** Avoid `v8 ignore` comments. If code is unreachable, restructure the logic to prove it is unreachable to the compiler, or remove the branch if the invariant is guaranteed.
|
|
28
28
|
- **Signal Combination:** Prefer `AbortSignal.any()` over manual event listeners when combining multiple `AbortSignal`s to simplify logic and avoid memory leaks.
|
|
29
|
+
- **Map Lookups:** Avoid double lookups in Maps (e.g., `has()` followed by `get()`). Check the result of `get()` against `undefined` to perform the check in a single operation.
|
|
30
|
+
- **String Replacement:** Always favor `String.prototype.replaceAll` over `String.prototype.replace` with global regex for clarity.
|
|
29
31
|
|
|
30
32
|
## Operational Protocols
|
|
31
33
|
|
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,33 @@
|
|
|
18
18
|
* refactor: Refactor TaskRunner to reduce cognitive complexity (#89) ([95c67d9](https://github.com/thalesraymond/task-runner/commit/95c67d9)), closes [#89](https://github.com/thalesraymond/task-runner/issues/89)
|
|
19
19
|
* Refactor TaskGraphValidator to address SonarCloud issues (#88) ([77c1538](https://github.com/thalesraymond/task-runner/commit/77c1538)), closes [#88](https://github.com/thalesraymond/task-runner/issues/88)
|
|
20
20
|
|
|
21
|
+
## [4.2.0](https://github.com/thalesraymond/task-runner/compare/task-runner-v4.1.0...task-runner-v4.2.0) (2026-02-15)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
* 🎸 mvp for plugin system ([7d85610](https://github.com/thalesraymond/task-runner/commit/7d856103651416826bdf6b440d9aa613ab2ac997))
|
|
27
|
+
* add middleware support proposal ([#123](https://github.com/thalesraymond/task-runner/issues/123)) ([e93c2f1](https://github.com/thalesraymond/task-runner/commit/e93c2f1bd34764dbb084ff9645836ec20fdef026))
|
|
28
|
+
* **spec:** add task loop proposal ([#157](https://github.com/thalesraymond/task-runner/issues/157)) ([a89a846](https://github.com/thalesraymond/task-runner/commit/a89a8462cd7ff2a54625805e30ee0c14eae95fa2))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* 🛰️ Sonar Specialist: Fix issues in `src/TaskRunner.ts` ([#128](https://github.com/thalesraymond/task-runner/issues/128)) ([fd87799](https://github.com/thalesraymond/task-runner/commit/fd877993497539728b6c7ba55d1a34ea7e1d7737))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Performance Improvements
|
|
37
|
+
|
|
38
|
+
* ⚡ Optimize Mermaid graph generation performance ([#155](https://github.com/thalesraymond/task-runner/issues/155)) ([18d3e93](https://github.com/thalesraymond/task-runner/commit/18d3e934631907a2c41ceb2c60942d3ec50b9dc5))
|
|
39
|
+
* ⚡ Optimize WorkflowExecutor loop performance ([#153](https://github.com/thalesraymond/task-runner/issues/153)) ([c0457f0](https://github.com/thalesraymond/task-runner/commit/c0457f00f9a1315f7b23829fec08d3bceba37a14))
|
|
40
|
+
* optimize cascadeFailure to O(N) using index pointer ([#135](https://github.com/thalesraymond/task-runner/issues/135)) ([1ecd7b8](https://github.com/thalesraymond/task-runner/commit/1ecd7b8fe1c72ebc7f97aaaa6bc9aeacdb830ae2))
|
|
41
|
+
* optimize EventBus scheduling with queueMicrotask ([#154](https://github.com/thalesraymond/task-runner/issues/154)) ([4d74788](https://github.com/thalesraymond/task-runner/commit/4d74788aa689da0f296986dc15fe8a4fd080bbc7))
|
|
42
|
+
* optimize Mermaid graph generation by removing redundant ID loop ([#158](https://github.com/thalesraymond/task-runner/issues/158)) ([940bdc5](https://github.com/thalesraymond/task-runner/commit/940bdc5c377a0b54567f73e968202f8c7e5c5020))
|
|
43
|
+
* optimize mermaid graph generation deduplication ([#150](https://github.com/thalesraymond/task-runner/issues/150)) ([ff5db6d](https://github.com/thalesraymond/task-runner/commit/ff5db6d7a8ac22c414f260d04e13e06ec894b30c))
|
|
44
|
+
* optimize TaskStateManager initialization to avoid double map lookups ([#132](https://github.com/thalesraymond/task-runner/issues/132)) ([02c516c](https://github.com/thalesraymond/task-runner/commit/02c516cc030b27b4c3bb143107e25c91503b0dd8))
|
|
45
|
+
* remove redundant processLoop call in WorkflowExecutor ([#151](https://github.com/thalesraymond/task-runner/issues/151)) ([8286223](https://github.com/thalesraymond/task-runner/commit/8286223c6e28f5a60414a554b877792f73e1b147))
|
|
46
|
+
* **validator:** optimize graph validation (3x speedup) ([#127](https://github.com/thalesraymond/task-runner/issues/127)) ([66f97e7](https://github.com/thalesraymond/task-runner/commit/66f97e7bc3999d38b78640e29cd47b086532a97a))
|
|
47
|
+
|
|
21
48
|
## [4.1.0](https://github.com/thalesraymond/task-runner/compare/task-runner-v4.0.4...task-runner-v4.1.0) (2026-01-24)
|
|
22
49
|
|
|
23
50
|
|
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ Try the [Showcase App](https://task-runner-mu.vercel.app/) to see the runner in
|
|
|
21
21
|
- **Event System**: Subscribe to lifecycle events for logging or monitoring.
|
|
22
22
|
- **Runtime Validation**: Automatically detects circular dependencies and missing dependencies.
|
|
23
23
|
- **Conditional Execution**: Skip tasks dynamically based on context state.
|
|
24
|
+
- **Plugin System**: Extend functionality with custom logic and event listeners.
|
|
24
25
|
|
|
25
26
|
## Usage Example
|
|
26
27
|
|
|
@@ -139,6 +140,39 @@ console.log(graph);
|
|
|
139
140
|
// Output: graph TD; A-->B; ...
|
|
140
141
|
```
|
|
141
142
|
|
|
143
|
+
## Plugin System
|
|
144
|
+
|
|
145
|
+
You can extend the `TaskRunner` with plugins to inject custom logic or listen to events without modifying the core.
|
|
146
|
+
|
|
147
|
+
### Creating a Plugin
|
|
148
|
+
|
|
149
|
+
A plugin is an object with a `name`, `version`, and an `install` method.
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import { Plugin, PluginContext } from "@calmo/task-runner";
|
|
153
|
+
|
|
154
|
+
const MyLoggerPlugin: Plugin<MyContext> = {
|
|
155
|
+
name: "my-logger-plugin",
|
|
156
|
+
version: "1.0.0",
|
|
157
|
+
install: (context: PluginContext<MyContext>) => {
|
|
158
|
+
context.events.on("taskStart", ({ step }) => {
|
|
159
|
+
console.log(`[Plugin] Starting task: ${step.name}`);
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Using a Plugin
|
|
166
|
+
|
|
167
|
+
Register the plugin using the `use()` method on the `TaskRunner` instance.
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
const runner = new TaskRunner(context);
|
|
171
|
+
runner.use(MyLoggerPlugin);
|
|
172
|
+
|
|
173
|
+
await runner.execute(steps);
|
|
174
|
+
```
|
|
175
|
+
|
|
142
176
|
## Skip Propagation
|
|
143
177
|
|
|
144
178
|
If a task fails or is skipped, the `TaskRunner` automatically marks all subsequent tasks that depend on it as `skipped`. This ensures that your pipeline doesn't attempt to run steps with missing prerequisites.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# General Code Style Principles
|
|
2
|
+
|
|
3
|
+
This document outlines general coding principles that apply across all languages and frameworks used in this project.
|
|
4
|
+
|
|
5
|
+
## Readability
|
|
6
|
+
- Code should be easy to read and understand by humans.
|
|
7
|
+
- Avoid overly clever or obscure constructs.
|
|
8
|
+
|
|
9
|
+
## Consistency
|
|
10
|
+
- Follow existing patterns in the codebase.
|
|
11
|
+
- Maintain consistent formatting, naming, and structure.
|
|
12
|
+
|
|
13
|
+
## Simplicity
|
|
14
|
+
- Prefer simple solutions over complex ones.
|
|
15
|
+
- Break down complex problems into smaller, manageable parts.
|
|
16
|
+
|
|
17
|
+
## Maintainability
|
|
18
|
+
- Write code that is easy to modify and extend.
|
|
19
|
+
- Minimize dependencies and coupling.
|
|
20
|
+
|
|
21
|
+
## Documentation
|
|
22
|
+
- Document *why* something is done, not just *what*.
|
|
23
|
+
- Keep documentation up-to-date with code changes.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Google JavaScript Style Guide Summary
|
|
2
|
+
|
|
3
|
+
This document summarizes key rules and best practices from the Google JavaScript Style Guide.
|
|
4
|
+
|
|
5
|
+
## 1. Source File Basics
|
|
6
|
+
- **File Naming:** All lowercase, with underscores (`_`) or dashes (`-`). Extension must be `.js`.
|
|
7
|
+
- **File Encoding:** UTF-8.
|
|
8
|
+
- **Whitespace:** Use only ASCII horizontal spaces (0x20). Tabs are forbidden for indentation.
|
|
9
|
+
|
|
10
|
+
## 2. Source File Structure
|
|
11
|
+
- New files should be ES modules (`import`/`export`).
|
|
12
|
+
- **Exports:** Use named exports (`export {MyClass};`). **Do not use default exports.**
|
|
13
|
+
- **Imports:** Do not use line-wrapped imports. The `.js` extension in import paths is mandatory.
|
|
14
|
+
|
|
15
|
+
## 3. Formatting
|
|
16
|
+
- **Braces:** Required for all control structures (`if`, `for`, `while`, etc.), even single-line blocks. Use K&R style ("Egyptian brackets").
|
|
17
|
+
- **Indentation:** +2 spaces for each new block.
|
|
18
|
+
- **Semicolons:** Every statement must be terminated with a semicolon.
|
|
19
|
+
- **Column Limit:** 80 characters.
|
|
20
|
+
- **Line-wrapping:** Indent continuation lines at least +4 spaces.
|
|
21
|
+
- **Whitespace:** Use single blank lines between methods. No trailing whitespace.
|
|
22
|
+
|
|
23
|
+
## 4. Language Features
|
|
24
|
+
- **Variable Declarations:** Use `const` by default, `let` if reassignment is needed. **`var` is forbidden.**
|
|
25
|
+
- **Array Literals:** Use trailing commas. Do not use the `Array` constructor.
|
|
26
|
+
- **Object Literals:** Use trailing commas and shorthand properties. Do not use the `Object` constructor.
|
|
27
|
+
- **Classes:** Do not use JavaScript getter/setter properties (`get name()`). Provide ordinary methods instead.
|
|
28
|
+
- **Functions:** Prefer arrow functions for nested functions to preserve `this` context.
|
|
29
|
+
- **String Literals:** Use single quotes (`'`). Use template literals (`` ` ``) for multi-line strings or complex interpolation.
|
|
30
|
+
- **Control Structures:** Prefer `for-of` loops. `for-in` loops should only be used on dict-style objects.
|
|
31
|
+
- **`this`:** Only use `this` in class constructors, methods, or in arrow functions defined within them.
|
|
32
|
+
- **Equality Checks:** Always use identity operators (`===` / `!==`).
|
|
33
|
+
|
|
34
|
+
## 5. Disallowed Features
|
|
35
|
+
- `with` keyword.
|
|
36
|
+
- `eval()` or `Function(...string)`.
|
|
37
|
+
- Automatic Semicolon Insertion.
|
|
38
|
+
- Modifying builtin objects (`Array.prototype.foo = ...`).
|
|
39
|
+
|
|
40
|
+
## 6. Naming
|
|
41
|
+
- **Classes:** `UpperCamelCase`.
|
|
42
|
+
- **Methods & Functions:** `lowerCamelCase`.
|
|
43
|
+
- **Constants:** `CONSTANT_CASE` (all uppercase with underscores).
|
|
44
|
+
- **Non-constant Fields & Variables:** `lowerCamelCase`.
|
|
45
|
+
|
|
46
|
+
## 7. JSDoc
|
|
47
|
+
- JSDoc is used on all classes, fields, and methods.
|
|
48
|
+
- Use `@param`, `@return`, `@override`, `@deprecated`.
|
|
49
|
+
- Type annotations are enclosed in braces (e.g., `/** @param {string} userName */`).
|
|
50
|
+
|
|
51
|
+
*Source: [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html)*
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Google TypeScript Style Guide Summary
|
|
2
|
+
|
|
3
|
+
This document summarizes key rules and best practices from the Google TypeScript Style Guide, which is enforced by the `gts` tool.
|
|
4
|
+
|
|
5
|
+
## 1. Language Features
|
|
6
|
+
- **Variable Declarations:** Always use `const` or `let`. **`var` is forbidden.** Use `const` by default.
|
|
7
|
+
- **Modules:** Use ES6 modules (`import`/`export`). **Do not use `namespace`.**
|
|
8
|
+
- **Exports:** Use named exports (`export {MyClass};`). **Do not use default exports.**
|
|
9
|
+
- **Classes:**
|
|
10
|
+
- **Do not use `#private` fields.** Use TypeScript's `private` visibility modifier.
|
|
11
|
+
- Mark properties never reassigned outside the constructor with `readonly`.
|
|
12
|
+
- **Never use the `public` modifier** (it's the default). Restrict visibility with `private` or `protected` where possible.
|
|
13
|
+
- **Functions:** Prefer function declarations for named functions. Use arrow functions for anonymous functions/callbacks.
|
|
14
|
+
- **String Literals:** Use single quotes (`'`). Use template literals (`` ` ``) for interpolation and multi-line strings.
|
|
15
|
+
- **Equality Checks:** Always use triple equals (`===`) and not equals (`!==`).
|
|
16
|
+
- **Type Assertions:** **Avoid type assertions (`x as SomeType`) and non-nullability assertions (`y!`)**. If you must use them, provide a clear justification.
|
|
17
|
+
|
|
18
|
+
## 2. Disallowed Features
|
|
19
|
+
- **`any` Type:** **Avoid `any`**. Prefer `unknown` or a more specific type.
|
|
20
|
+
- **Wrapper Objects:** Do not instantiate `String`, `Boolean`, or `Number` wrapper classes.
|
|
21
|
+
- **Automatic Semicolon Insertion (ASI):** Do not rely on it. **Explicitly end all statements with a semicolon.**
|
|
22
|
+
- **`const enum`:** Do not use `const enum`. Use plain `enum` instead.
|
|
23
|
+
- **`eval()` and `Function(...string)`:** Forbidden.
|
|
24
|
+
|
|
25
|
+
## 3. Naming
|
|
26
|
+
- **`UpperCamelCase`:** For classes, interfaces, types, enums, and decorators.
|
|
27
|
+
- **`lowerCamelCase`:** For variables, parameters, functions, methods, and properties.
|
|
28
|
+
- **`CONSTANT_CASE`:** For global constant values, including enum values.
|
|
29
|
+
- **`_` Prefix/Suffix:** **Do not use `_` as a prefix or suffix** for identifiers, including for private properties.
|
|
30
|
+
|
|
31
|
+
## 4. Type System
|
|
32
|
+
- **Type Inference:** Rely on type inference for simple, obvious types. Be explicit for complex types.
|
|
33
|
+
- **`undefined` and `null`:** Both are supported. Be consistent within your project.
|
|
34
|
+
- **Optional vs. `|undefined`:** Prefer optional parameters and fields (`?`) over adding `|undefined` to the type.
|
|
35
|
+
- **`Array<T>` Type:** Use `T[]` for simple types. Use `Array<T>` for more complex union types (e.g., `Array<string | number>`).
|
|
36
|
+
- **`{}` Type:** **Do not use `{}`**. Prefer `unknown`, `Record<string, unknown>`, or `object`.
|
|
37
|
+
|
|
38
|
+
## 5. Comments and Documentation
|
|
39
|
+
- **JSDoc:** Use `/** JSDoc */` for documentation, `//` for implementation comments.
|
|
40
|
+
- **Redundancy:** **Do not declare types in `@param` or `@return` blocks** (e.g., `/** @param {string} user */`). This is redundant in TypeScript.
|
|
41
|
+
- **Add Information:** Comments must add information, not just restate the code.
|
|
42
|
+
|
|
43
|
+
*Source: [Google TypeScript Style Guide](https://google.github.io/styleguide/tsguide.html)*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Product Guidelines
|
|
2
|
+
|
|
3
|
+
## Documentation Style
|
|
4
|
+
- Tone: Professional, technical, and friendly.
|
|
5
|
+
- Style: Clear, concise, and focused on accuracy, while remaining approachable with instructional examples.
|
|
6
|
+
- Examples: Focused, bite-sized code snippets illustrating specific features for quick comprehension.
|
|
7
|
+
|
|
8
|
+
## Brand Messaging & Visual Identity
|
|
9
|
+
- Core Value: Stability and Reliability.
|
|
10
|
+
- Focus: Emphasize robust testing, production-readiness, and the "engine-like" nature of the orchestrator.
|
|
11
|
+
|
|
12
|
+
## Quality Standards
|
|
13
|
+
- Clarity over brevity in technical explanations.
|
|
14
|
+
- Prioritize accuracy and reliability in all user-facing communications.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Initial Concept
|
|
2
|
+
A lightweight, type-safe, and domain-agnostic task orchestration engine. It resolves a Directed Acyclic Graph (DAG) of steps, executes independent tasks in parallel, and manages a shared context across the pipeline.
|
|
3
|
+
|
|
4
|
+
## Target Users
|
|
5
|
+
- Developers building complex CI/CD pipelines.
|
|
6
|
+
- Engineers creating automated data processing workflows.
|
|
7
|
+
|
|
8
|
+
## Goals
|
|
9
|
+
- Provide a simple and intuitive API for defining and running task graphs.
|
|
10
|
+
|
|
11
|
+
## Key Features
|
|
12
|
+
- Enhanced observability and logging for complex task graphs.
|
|
13
|
+
- Support for persistent state to allow resuming long-running workflows.
|
|
14
|
+
|
|
15
|
+
## Complexity & Architecture
|
|
16
|
+
- Provide a hybrid approach with optional plugins for advanced features like persistence.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"last_successful_step": "2.5_workflow"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Technology Stack
|
|
2
|
+
|
|
3
|
+
## Core
|
|
4
|
+
- **Programming Language:** TypeScript
|
|
5
|
+
- **Runtime:** Node.js
|
|
6
|
+
|
|
7
|
+
## Development Tools
|
|
8
|
+
- **Package Manager:** pnpm
|
|
9
|
+
- **Build Tool:** tsc (TypeScript Compiler)
|
|
10
|
+
|
|
11
|
+
## Quality Assurance
|
|
12
|
+
- **Test Framework:** Vitest
|
|
13
|
+
- **Code Coverage:** @vitest/coverage-v8
|
|
14
|
+
- **Linting:** ESLint (typescript-eslint)
|
|
15
|
+
- **Formatting:** Prettier
|
|
16
|
+
|
|
17
|
+
## Infrastructure & Release
|
|
18
|
+
- **Release Management:** release-please
|
|
19
|
+
- **Static Analysis:** SonarCloud
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
# Project Workflow
|
|
2
|
+
|
|
3
|
+
## Guiding Principles
|
|
4
|
+
|
|
5
|
+
1. **The Plan is the Source of Truth:** All work must be tracked in `plan.md`
|
|
6
|
+
2. **The Tech Stack is Deliberate:** Changes to the tech stack must be documented in `tech-stack.md` *before* implementation
|
|
7
|
+
3. **Test-Driven Development:** Write unit tests before implementing functionality
|
|
8
|
+
4. **High Code Coverage:** Aim for 100% code coverage for all modules
|
|
9
|
+
5. **User Experience First:** Every decision should prioritize user experience
|
|
10
|
+
6. **Non-Interactive & CI-Aware:** Prefer non-interactive commands. Use `CI=true` for watch-mode tools (tests, linters) to ensure single execution.
|
|
11
|
+
|
|
12
|
+
## Task Workflow
|
|
13
|
+
|
|
14
|
+
All tasks follow a strict lifecycle:
|
|
15
|
+
|
|
16
|
+
### Standard Task Workflow
|
|
17
|
+
|
|
18
|
+
1. **Select Task:** Choose the next available task from `plan.md` in sequential order
|
|
19
|
+
|
|
20
|
+
2. **Mark In Progress:** Before beginning work, edit `plan.md` and change the task from `[ ]` to `[~]`
|
|
21
|
+
|
|
22
|
+
3. **Write Failing Tests (Red Phase):**
|
|
23
|
+
- Create a new test file for the feature or bug fix.
|
|
24
|
+
- Write one or more unit tests that clearly define the expected behavior and acceptance criteria for the task.
|
|
25
|
+
- **CRITICAL:** Run the tests and confirm that they fail as expected. This is the "Red" phase of TDD. Do not proceed until you have failing tests.
|
|
26
|
+
|
|
27
|
+
4. **Implement to Pass Tests (Green Phase):**
|
|
28
|
+
- Write the minimum amount of application code necessary to make the failing tests pass.
|
|
29
|
+
- Run the test suite again and confirm that all tests now pass. This is the "Green" phase.
|
|
30
|
+
|
|
31
|
+
5. **Refactor (Optional but Recommended):**
|
|
32
|
+
- With the safety of passing tests, refactor the implementation code and the test code to improve clarity, remove duplication, and enhance performance without changing the external behavior.
|
|
33
|
+
- Rerun tests to ensure they still pass after refactoring.
|
|
34
|
+
|
|
35
|
+
6. **Verify Coverage:** Run coverage reports using the project's chosen tools. For example, in a Python project, this might look like:
|
|
36
|
+
```bash
|
|
37
|
+
pytest --cov=app --cov-report=html
|
|
38
|
+
```
|
|
39
|
+
Target: 100% coverage for new code. The specific tools and commands will vary by language and framework.
|
|
40
|
+
|
|
41
|
+
7. **Document Deviations:** If implementation differs from tech stack:
|
|
42
|
+
- **STOP** implementation
|
|
43
|
+
- Update `tech-stack.md` with new design
|
|
44
|
+
- Add dated note explaining the change
|
|
45
|
+
- Resume implementation
|
|
46
|
+
|
|
47
|
+
8. **Commit Code Changes:**
|
|
48
|
+
- Stage all code changes related to the task.
|
|
49
|
+
- Always use conventional commits
|
|
50
|
+
- Propose a clear, concise commit message e.g, `feat(ui): Create basic HTML structure for calculator`.
|
|
51
|
+
- Perform the commit.
|
|
52
|
+
|
|
53
|
+
9. **Attach Task Summary with Git Notes:**
|
|
54
|
+
- **Step 9.1: Get Commit Hash:** Obtain the hash of the *just-completed commit* (`git log -1 --format="%H"`).
|
|
55
|
+
- **Step 9.2: Draft Note Content:** Create a detailed summary for the completed task. This should include the task name, a summary of changes, a list of all created/modified files, and the core "why" for the change.
|
|
56
|
+
- **Step 9.3: Attach Note:** Use the `git notes` command to attach the summary to the commit.
|
|
57
|
+
```bash
|
|
58
|
+
# The note content from the previous step is passed via the -m flag.
|
|
59
|
+
git notes add -m "<note content>" <commit_hash>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
10. **Get and Record Task Commit SHA:**
|
|
63
|
+
- **Step 10.1: Update Plan:** Read `plan.md`, find the line for the completed task, update its status from `[~]` to `[x]`, and append the first 7 characters of the *just-completed commit's* commit hash.
|
|
64
|
+
- **Step 10.2: Write Plan:** Write the updated content back to `plan.md`.
|
|
65
|
+
|
|
66
|
+
11. **Commit Plan Update:**
|
|
67
|
+
- **Action:** Stage the modified `plan.md` file.
|
|
68
|
+
- **Action:** Commit this change with a descriptive message (e.g., `conductor(plan): Mark task 'Create user model' as complete`).
|
|
69
|
+
|
|
70
|
+
### Phase Completion Verification and Checkpointing Protocol
|
|
71
|
+
|
|
72
|
+
**Trigger:** This protocol is executed immediately after a task is completed that also concludes a phase in `plan.md`.
|
|
73
|
+
|
|
74
|
+
1. **Announce Protocol Start:** Inform the user that the phase is complete and the verification and checkpointing protocol has begun.
|
|
75
|
+
|
|
76
|
+
2. **Ensure Test Coverage for Phase Changes:**
|
|
77
|
+
- **Step 2.1: Determine Phase Scope:** To identify the files changed in this phase, you must first find the starting point. Read `plan.md` to find the Git commit SHA of the *previous* phase's checkpoint. If no previous checkpoint exists, the scope is all changes since the first commit.
|
|
78
|
+
- **Step 2.2: List Changed Files:** Execute `git diff --name-only <previous_checkpoint_sha> HEAD` to get a precise list of all files modified during this phase.
|
|
79
|
+
- **Step 2.3: Verify and Create Tests:** For each file in the list:
|
|
80
|
+
- **CRITICAL:** First, check its extension. Exclude non-code files (e.g., `.json`, `.md`, `.yaml`).
|
|
81
|
+
- For each remaining code file, verify a corresponding test file exists.
|
|
82
|
+
- If a test file is missing, you **must** create one. Before writing the test, **first, analyze other test files in the repository to determine the correct naming convention and testing style.** The new tests **must** validate the functionality described in this phase's tasks (`plan.md`).
|
|
83
|
+
|
|
84
|
+
3. **Execute Automated Tests with Proactive Debugging:**
|
|
85
|
+
- Before execution, you **must** announce the exact shell command you will use to run the tests.
|
|
86
|
+
- **Example Announcement:** "I will now run the automated test suite to verify the phase. **Command:** `CI=true npm test`"
|
|
87
|
+
- Execute the announced command.
|
|
88
|
+
- If tests fail, you **must** inform the user and begin debugging. You may attempt to propose a fix a **maximum of two times**. If the tests still fail after your second proposed fix, you **must stop**, report the persistent failure, and ask the user for guidance.
|
|
89
|
+
|
|
90
|
+
4. **Propose a Detailed, Actionable Manual Verification Plan:**
|
|
91
|
+
- **CRITICAL:** To generate the plan, first analyze `product.md`, `product-guidelines.md`, and `plan.md` to determine the user-facing goals of the completed phase.
|
|
92
|
+
- You **must** generate a step-by-step plan that walks the user through the verification process, including any necessary commands and specific, expected outcomes.
|
|
93
|
+
- The plan you present to the user **must** follow this format:
|
|
94
|
+
|
|
95
|
+
**For a Frontend Change:**
|
|
96
|
+
```
|
|
97
|
+
The automated tests have passed. For manual verification, please follow these steps:
|
|
98
|
+
|
|
99
|
+
**Manual Verification Steps:**
|
|
100
|
+
1. **Start the development server with the command:** `npm run dev`
|
|
101
|
+
2. **Open your browser to:** `http://localhost:3000`
|
|
102
|
+
3. **Confirm that you see:** The new user profile page, with the user's name and email displayed correctly.
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**For a Backend Change:**
|
|
106
|
+
```
|
|
107
|
+
The automated tests have passed. For manual verification, please follow these steps:
|
|
108
|
+
|
|
109
|
+
**Manual Verification Steps:**
|
|
110
|
+
1. **Ensure the server is running.**
|
|
111
|
+
2. **Execute the following command in your terminal:** `curl -X POST http://localhost:8080/api/v1/users -d '{"name": "test"}'`
|
|
112
|
+
3. **Confirm that you receive:** A JSON response with a status of `201 Created`.
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
5. **Await Explicit User Feedback:**
|
|
116
|
+
- After presenting the detailed plan, ask the user for confirmation: "**Does this meet your expectations? Please confirm with yes or provide feedback on what needs to be changed.**"
|
|
117
|
+
- **PAUSE** and await the user's response. Do not proceed without an explicit yes or confirmation.
|
|
118
|
+
|
|
119
|
+
6. **Create Checkpoint Commit:**
|
|
120
|
+
- Stage all changes. If no changes occurred in this step, proceed with an empty commit.
|
|
121
|
+
- Perform the commit with a clear and concise message (e.g., `conductor(checkpoint): Checkpoint end of Phase X`).
|
|
122
|
+
|
|
123
|
+
7. **Attach Auditable Verification Report using Git Notes:**
|
|
124
|
+
- **Step 7.1: Draft Note Content:** Create a detailed verification report including the automated test command, the manual verification steps, and the user's confirmation.
|
|
125
|
+
- **Step 7.2: Attach Note:** Use the `git notes` command and the full commit hash from the previous step to attach the full report to the checkpoint commit.
|
|
126
|
+
|
|
127
|
+
8. **Get and Record Phase Checkpoint SHA:**
|
|
128
|
+
- **Step 8.1: Get Commit Hash:** Obtain the hash of the *just-created checkpoint commit* (`git log -1 --format="%H"`).
|
|
129
|
+
- **Step 8.2: Update Plan:** Read `plan.md`, find the heading for the completed phase, and append the first 7 characters of the commit hash in the format `[checkpoint: <sha>]`.
|
|
130
|
+
- **Step 8.3: Write Plan:** Write the updated content back to `plan.md`.
|
|
131
|
+
|
|
132
|
+
9. **Commit Plan Update:**
|
|
133
|
+
- **Action:** Stage the modified `plan.md` file.
|
|
134
|
+
- **Action:** Commit this change with a descriptive message following the format `conductor(plan): Mark phase '<PHASE NAME>' as complete`.
|
|
135
|
+
|
|
136
|
+
10. **Announce Completion:** Inform the user that the phase is complete and the checkpoint has been created, with the detailed verification report attached as a git note.
|
|
137
|
+
|
|
138
|
+
### Quality Gates
|
|
139
|
+
|
|
140
|
+
Before marking any task complete, verify:
|
|
141
|
+
|
|
142
|
+
- [ ] All tests pass
|
|
143
|
+
- [ ] Code coverage meets requirements (100%)
|
|
144
|
+
- [ ] Code follows project's code style guidelines (as defined in `code_styleguides/`)
|
|
145
|
+
- [ ] All public functions/methods are documented (e.g., docstrings, JSDoc, GoDoc)
|
|
146
|
+
- [ ] Type safety is enforced (e.g., type hints, TypeScript types, Go types)
|
|
147
|
+
- [ ] No linting or static analysis errors (using the project's configured tools)
|
|
148
|
+
- [ ] Works correctly on mobile (if applicable)
|
|
149
|
+
- [ ] Documentation updated if needed
|
|
150
|
+
- [ ] No security vulnerabilities introduced
|
|
151
|
+
|
|
152
|
+
## Development Commands
|
|
153
|
+
|
|
154
|
+
**AI AGENT INSTRUCTION: This section should be adapted to the project's specific language, framework, and build tools.**
|
|
155
|
+
|
|
156
|
+
### Setup
|
|
157
|
+
```bash
|
|
158
|
+
# Example: Commands to set up the development environment (e.g., install dependencies, configure database)
|
|
159
|
+
# e.g., for a Node.js project: npm install
|
|
160
|
+
# e.g., for a Go project: go mod tidy
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Daily Development
|
|
164
|
+
```bash
|
|
165
|
+
# Example: Commands for common daily tasks (e.g., start dev server, run tests, lint, format)
|
|
166
|
+
# e.g., for a Node.js project: npm run dev, npm test, npm run lint
|
|
167
|
+
# e.g., for a Go project: go run main.go, go test ./..., go fmt ./...
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Before Committing
|
|
171
|
+
```bash
|
|
172
|
+
# Example: Commands to run all pre-commit checks (e.g., format, lint, type check, run tests)
|
|
173
|
+
# e.g., for a Node.js project: npm run check
|
|
174
|
+
# e.g., for a Go project: make check (if a Makefile exists)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Testing Requirements
|
|
178
|
+
|
|
179
|
+
### Unit Testing
|
|
180
|
+
- Every module must have corresponding tests.
|
|
181
|
+
- Use appropriate test setup/teardown mechanisms (e.g., fixtures, beforeEach/afterEach).
|
|
182
|
+
- Mock external dependencies.
|
|
183
|
+
- Test both success and failure cases.
|
|
184
|
+
|
|
185
|
+
### Integration Testing
|
|
186
|
+
- Test complete user flows
|
|
187
|
+
- Verify database transactions
|
|
188
|
+
- Test authentication and authorization
|
|
189
|
+
- Check form submissions
|
|
190
|
+
|
|
191
|
+
### Mobile Testing
|
|
192
|
+
- Test on actual iPhone when possible
|
|
193
|
+
- Use Safari developer tools
|
|
194
|
+
- Test touch interactions
|
|
195
|
+
- Verify responsive layouts
|
|
196
|
+
- Check performance on 3G/4G
|
|
197
|
+
|
|
198
|
+
## Code Review Process
|
|
199
|
+
|
|
200
|
+
### Self-Review Checklist
|
|
201
|
+
Before requesting review:
|
|
202
|
+
|
|
203
|
+
1. **Functionality**
|
|
204
|
+
- Feature works as specified
|
|
205
|
+
- Edge cases handled
|
|
206
|
+
- Error messages are user-friendly
|
|
207
|
+
|
|
208
|
+
2. **Code Quality**
|
|
209
|
+
- Follows style guide
|
|
210
|
+
- DRY principle applied
|
|
211
|
+
- Clear variable/function names
|
|
212
|
+
- Appropriate comments
|
|
213
|
+
|
|
214
|
+
3. **Testing**
|
|
215
|
+
- Unit tests comprehensive
|
|
216
|
+
- Integration tests pass
|
|
217
|
+
- Coverage adequate (100%)
|
|
218
|
+
|
|
219
|
+
4. **Security**
|
|
220
|
+
- No hardcoded secrets
|
|
221
|
+
- Input validation present
|
|
222
|
+
- SQL injection prevented
|
|
223
|
+
- XSS protection in place
|
|
224
|
+
|
|
225
|
+
5. **Performance**
|
|
226
|
+
- Database queries optimized
|
|
227
|
+
- Images optimized
|
|
228
|
+
- Caching implemented where needed
|
|
229
|
+
|
|
230
|
+
6. **Mobile Experience**
|
|
231
|
+
- Touch targets adequate (44x44px)
|
|
232
|
+
- Text readable without zooming
|
|
233
|
+
- Performance acceptable on mobile
|
|
234
|
+
- Interactions feel native
|
|
235
|
+
|
|
236
|
+
## Commit Guidelines
|
|
237
|
+
|
|
238
|
+
### Message Format
|
|
239
|
+
```
|
|
240
|
+
<type>(<scope>): <description>
|
|
241
|
+
|
|
242
|
+
[optional body]
|
|
243
|
+
|
|
244
|
+
[optional footer]
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Types
|
|
248
|
+
- `feat`: New feature
|
|
249
|
+
- `fix`: Bug fix
|
|
250
|
+
- `docs`: Documentation only
|
|
251
|
+
- `style`: Formatting, missing semicolons, etc.
|
|
252
|
+
- `refactor`: Code change that neither fixes a bug nor adds a feature
|
|
253
|
+
- `test`: Adding missing tests
|
|
254
|
+
- `chore`: Maintenance tasks
|
|
255
|
+
|
|
256
|
+
### Examples
|
|
257
|
+
```bash
|
|
258
|
+
git commit -m "feat(auth): Add remember me functionality"
|
|
259
|
+
git commit -m "fix(posts): Correct excerpt generation for short posts"
|
|
260
|
+
git commit -m "test(comments): Add tests for emoji reaction limits"
|
|
261
|
+
git commit -m "style(mobile): Improve button touch targets"
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Definition of Done
|
|
265
|
+
|
|
266
|
+
A task is complete when:
|
|
267
|
+
|
|
268
|
+
1. All code implemented to specification
|
|
269
|
+
2. Unit tests written and passing
|
|
270
|
+
3. Code coverage meets project requirements
|
|
271
|
+
4. Documentation complete (if applicable)
|
|
272
|
+
5. Code passes all configured linting and static analysis checks
|
|
273
|
+
6. Works beautifully on mobile (if applicable)
|
|
274
|
+
7. Implementation notes added to `plan.md`
|
|
275
|
+
8. Changes committed with proper message
|
|
276
|
+
9. Git note with task summary attached to the commit
|
|
277
|
+
|
|
278
|
+
## Emergency Procedures
|
|
279
|
+
|
|
280
|
+
### Critical Bug in Production
|
|
281
|
+
1. Create hotfix branch from main
|
|
282
|
+
2. Write failing test for bug
|
|
283
|
+
3. Implement minimal fix
|
|
284
|
+
4. Test thoroughly including mobile
|
|
285
|
+
5. Deploy immediately
|
|
286
|
+
6. Document in plan.md
|
|
287
|
+
|
|
288
|
+
### Data Loss
|
|
289
|
+
1. Stop all write operations
|
|
290
|
+
2. Restore from latest backup
|
|
291
|
+
3. Verify data integrity
|
|
292
|
+
4. Document incident
|
|
293
|
+
5. Update backup procedures
|
|
294
|
+
|
|
295
|
+
### Security Breach
|
|
296
|
+
1. Rotate all secrets immediately
|
|
297
|
+
2. Review access logs
|
|
298
|
+
3. Patch vulnerability
|
|
299
|
+
4. Notify affected users (if any)
|
|
300
|
+
5. Document and update security procedures
|
|
301
|
+
|
|
302
|
+
## Deployment Workflow
|
|
303
|
+
|
|
304
|
+
### Pre-Deployment Checklist
|
|
305
|
+
- [ ] All tests passing
|
|
306
|
+
- [ ] Coverage 100%
|
|
307
|
+
- [ ] No linting errors
|
|
308
|
+
- [ ] Mobile testing complete
|
|
309
|
+
- [ ] Environment variables configured
|
|
310
|
+
- [ ] Database migrations ready
|
|
311
|
+
- [ ] Backup created
|
|
312
|
+
|
|
313
|
+
### Deployment Steps
|
|
314
|
+
1. Merge feature branch to main
|
|
315
|
+
2. Tag release with version
|
|
316
|
+
3. Push to deployment service
|
|
317
|
+
4. Run database migrations
|
|
318
|
+
5. Verify deployment
|
|
319
|
+
6. Test critical paths
|
|
320
|
+
7. Monitor for errors
|
|
321
|
+
|
|
322
|
+
### Post-Deployment
|
|
323
|
+
1. Monitor analytics
|
|
324
|
+
2. Check error logs
|
|
325
|
+
3. Gather user feedback
|
|
326
|
+
4. Plan next iteration
|
|
327
|
+
|
|
328
|
+
## Continuous Improvement
|
|
329
|
+
|
|
330
|
+
- Review workflow weekly
|
|
331
|
+
- Update based on pain points
|
|
332
|
+
- Document lessons learned
|
|
333
|
+
- Optimize for user happiness
|
|
334
|
+
- Keep things simple and maintainable
|