|
| 1 | +--- |
| 2 | +name: task-execute-blueprint |
| 3 | +description: Execute an AI Task Manager plan blueprint for this repository. Use when the user asks to run, implement, or carry out a specific plan ID — discovers the local .ai/task-manager root, resolves the plan, validates or auto-generates tasks and the execution blueprint, optionally creates a feature branch, runs phases with lifecycle hooks, enforces validation gates, appends an execution summary, and archives the completed plan. Do not use for generic development work outside the AI Task Manager. |
| 4 | +--- |
| 5 | + |
| 6 | +# task-execute-blueprint |
| 7 | + |
| 8 | +Drive the end-to-end execution of an existing AI Task Manager plan blueprint. The skill is assistant-agnostic and self-contained: every script it invokes lives under this skill's `scripts/` directory and is referenced by relative path. |
| 9 | + |
| 10 | +## Critical Rules |
| 11 | + |
| 12 | +1. **Never skip validation gates** — a phase is not complete until `POST_PHASE.md` succeeds. |
| 13 | +2. **Preserve dependency order** — never execute a task before all of its dependencies are completed. |
| 14 | +3. **Maximize parallelism within each phase** — run all tasks whose dependencies are satisfied simultaneously. |
| 15 | +4. **Fail safely and document everything** — halt on unrecoverable errors, and record all decisions, issues, and outcomes under "Noteworthy Events" in the execution summary. |
| 16 | + |
| 17 | +## Inputs |
| 18 | + |
| 19 | +The user supplies the numeric plan ID conversationally. Treat it as the only authoritative source of intent. Do not invent answers to clarifying questions — prompt the user instead. |
| 20 | + |
| 21 | +## Operating Procedure |
| 22 | + |
| 23 | +### 1. Locate the task-manager root |
| 24 | + |
| 25 | +Run `scripts/find-task-manager-root.cjs` from the user's working directory. The script walks up looking for `.ai/task-manager/.init-metadata.json` and prints the absolute path of the resolved root on success. |
| 26 | + |
| 27 | +If the script exits non-zero, the working directory is not inside an initialized task-manager workspace. Stop and ask the user to run the project initializer (e.g. `npx @e0ipso/ai-task-manager init`) before continuing. Do not attempt to execute a plan outside of a valid root. |
| 28 | + |
| 29 | +For every subsequent step, treat the path printed by this script as `<root>`. |
| 30 | + |
| 31 | +### 2. Resolve the plan |
| 32 | + |
| 33 | +Run `scripts/validate-plan-blueprint.cjs <plan-id> planFile` to obtain the absolute path of the plan file. The same script also accepts these field names (single-field output mode) and exposes them on demand: |
| 34 | + |
| 35 | +- `planDir` — absolute path of the plan directory |
| 36 | +- `taskCount` — number of existing task files in that plan's `tasks/` |
| 37 | +- `blueprintExists` — `yes` or `no` |
| 38 | +- `taskManagerRoot` — absolute path of `<root>` |
| 39 | +- `planId` — the resolved numeric plan ID |
| 40 | + |
| 41 | +If the script exits non-zero, stop and ask the user to confirm the plan ID. Do not guess a different ID. |
| 42 | + |
| 43 | +### 3. Validate tasks and blueprint existence |
| 44 | + |
| 45 | +Inspect the `taskCount` and `blueprintExists` values returned by the validation script. |
| 46 | + |
| 47 | +### 4. Auto-generate tasks and blueprint if missing |
| 48 | + |
| 49 | +If `taskCount` is 0 or `blueprintExists` is `no`: |
| 50 | + |
| 51 | +- Notify the user: "Tasks or execution blueprint not found. Generating tasks automatically..." |
| 52 | +- Follow the `task-generate-tasks` skill for this plan ID. Execute its operating procedure in full, including running `POST_TASK_GENERATION_ALL.md` to produce the execution blueprint. |
| 53 | +- After generation completes, re-run `scripts/validate-plan-blueprint.cjs <plan-id> planFile` (and the other fields) to refresh the resolved paths and counts. |
| 54 | + |
| 55 | +If generation still leaves the plan without tasks or a blueprint, stop and report failure. Do not attempt execution without a valid blueprint. |
| 56 | + |
| 57 | +### 5. Optionally create a feature branch |
| 58 | + |
| 59 | +Run `scripts/create-feature-branch.cjs <plan-id>`. The script creates a branch named after the plan and prints the branch name. Continue execution regardless of whether a branch is created (some projects may skip this step). |
| 60 | + |
| 61 | +### 6. Load project context and execution blueprint |
| 62 | + |
| 63 | +Read these files, in order: |
| 64 | + |
| 65 | +- `<root>/config/TASK_MANAGER.md` — directory conventions and project context. |
| 66 | +- The plan document at the path returned by step 2. |
| 67 | +- The plan's Execution Blueprint section — this defines the phase groupings and task dispatch order. |
| 68 | + |
| 69 | +### 7. Execute phases in order |
| 70 | + |
| 71 | +Use an internal task or todo tracker to monitor progress. For each phase defined in the Execution Blueprint: |
| 72 | + |
| 73 | +#### 7a. Phase pre-execution |
| 74 | +Read `<root>/config/hooks/PRE_PHASE.md` and execute its instructions before starting the phase. |
| 75 | + |
| 76 | +#### 7b. Task dispatch |
| 77 | +Identify all tasks scheduled for this phase whose dependencies are fully satisfied. Read `<root>/config/hooks/PRE_TASK_EXECUTION.md` and execute its instructions before starting any implementation work. |
| 78 | + |
| 79 | +Deploy all selected agents simultaneously using your internal Task tool. Each agent MUST: |
| 80 | + |
| 81 | +1. Read and execute `<root>/config/hooks/PRE_TASK_EXECUTION.md` before starting any implementation work. |
| 82 | +2. Execute the task according to its requirements. |
| 83 | +3. Monitor execution progress and capture outputs and artifacts. |
| 84 | +4. Update task status in real-time. |
| 85 | + |
| 86 | +Maximize parallelism within each phase. Run every task that is ready at the same time. |
| 87 | + |
| 88 | +#### 7c. Phase completion verification |
| 89 | +Ensure every task in the phase has status `completed`. Collect and review all task outputs. Document any issues or exceptions encountered. |
| 90 | + |
| 91 | +#### 7d. Phase post-execution |
| 92 | +Read `<root>/config/hooks/POST_PHASE.md` and execute its instructions. Do not proceed to the next phase until this hook succeeds. |
| 93 | + |
| 94 | +Update the phase status to `completed` in the plan's Execution Blueprint section. |
| 95 | + |
| 96 | +Repeat for the next phase until all phases are complete. |
| 97 | + |
| 98 | +### 8. Post-execution validation |
| 99 | + |
| 100 | +Read `<root>/config/hooks/POST_EXECUTION.md` and execute its instructions. If validation fails, halt execution. The plan remains in `plans/` for debugging. |
| 101 | + |
| 102 | +### 9. Append execution summary |
| 103 | + |
| 104 | +Append an execution summary section to the plan document using the format described in `<root>/config/templates/EXECUTION_SUMMARY_TEMPLATE.md`. Populate: |
| 105 | + |
| 106 | +- **Status**: Completed Successfully |
| 107 | +- **Completed Date**: current date |
| 108 | +- **Results**: brief summary of deliverables |
| 109 | +- **Noteworthy Events**: all decisions, issues, and outcomes encountered during execution. If none occurred, state "No significant issues encountered." |
| 110 | +- **Necessary follow-ups**: any follow-up actions or optimizations |
| 111 | + |
| 112 | +### 10. Archive the plan |
| 113 | + |
| 114 | +Move the completed plan directory from `<root>/plans/<plan-folder>` to `<root>/archive/<plan-folder>`. |
| 115 | + |
| 116 | +Preserve the entire folder structure (including all tasks and subdirectories) to maintain referential integrity. If the move fails, log the error but do not fail the overall execution — the implementation work is complete. |
| 117 | + |
| 118 | +## Failure Modes |
| 119 | + |
| 120 | +- **No task-manager root found.** Stop and instruct the user to initialize the project. Do not execute any tasks. |
| 121 | +- **Plan ID does not resolve.** Stop and surface the script's stderr to the user. Do not guess a different ID. |
| 122 | +- **Missing blueprint after auto-generation.** If the `task-generate-tasks` skill fails to produce tasks or a blueprint, stop and report failure. Do not attempt execution without a blueprint. |
| 123 | +- **Hook failure.** If `PRE_PHASE.md`, `POST_PHASE.md`, or `POST_EXECUTION.md` fails, halt execution. The plan remains in `plans/` for debugging and potential re-execution. |
| 124 | +- **Execution errors.** If a task fails, read `<root>/config/hooks/POST_ERROR_DETECTION.md`, document the error in Noteworthy Events, halt the phase, and request user direction before continuing. |
| 125 | + |
| 126 | +## Execution Summary |
| 127 | + |
| 128 | +Conclude with exactly this block as the final output: |
| 129 | + |
| 130 | +``` |
| 131 | +--- |
| 132 | +Execution Summary: |
| 133 | +- Plan ID: [numeric-id] |
| 134 | +- Status: Archived |
| 135 | +- Location: [absolute path to archive directory] |
| 136 | +--- |
| 137 | +``` |
| 138 | + |
| 139 | +The summary is consumed by downstream automation; keep the format exact. |
0 commit comments