aiblueprint-cli 1.4.99 → 1.4.100

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.
Files changed (96) hide show
  1. package/agents-config/skills/agents-manager/SKILL.md +2 -2
  2. package/agents-config/skills/agents-manager/agents/openai.yaml +7 -0
  3. package/agents-config/skills/agents-manager/assets/codex-icon.svg +20 -0
  4. package/agents-config/skills/apex/SKILL.md +120 -118
  5. package/agents-config/skills/apex/agents/openai.yaml +10 -0
  6. package/agents-config/skills/apex/assets/codex-icon.svg +15 -0
  7. package/agents-config/skills/apex/scripts/apex-state.py +740 -0
  8. package/agents-config/skills/apex/scripts/setup-templates.sh +27 -145
  9. package/agents-config/skills/apex/scripts/test_apex_state.py +413 -0
  10. package/agents-config/skills/apex/scripts/update-progress.sh +17 -73
  11. package/agents-config/skills/apex/steps/step-00-init.md +85 -231
  12. package/agents-config/skills/apex/steps/step-00b-branch.md +10 -118
  13. package/agents-config/skills/apex/steps/step-00b-economy.md +12 -239
  14. package/agents-config/skills/apex/steps/step-00b-interactive.md +13 -162
  15. package/agents-config/skills/apex/steps/step-00b-save.md +13 -114
  16. package/agents-config/skills/apex/steps/step-01-analyze.md +40 -361
  17. package/agents-config/skills/apex/steps/step-02-plan.md +55 -562
  18. package/agents-config/skills/apex/steps/step-02b-tasks.md +15 -291
  19. package/agents-config/skills/apex/steps/step-03-execute-teams.md +47 -267
  20. package/agents-config/skills/apex/steps/step-03-execute.md +32 -212
  21. package/agents-config/skills/apex/steps/step-04-validate.md +42 -246
  22. package/agents-config/skills/apex/steps/step-05-examine.md +47 -371
  23. package/agents-config/skills/apex/steps/step-06-resolve.md +19 -221
  24. package/agents-config/skills/apex/steps/step-07-tests.md +19 -234
  25. package/agents-config/skills/apex/steps/step-08-run-tests.md +13 -300
  26. package/agents-config/skills/apex/steps/step-09-finish.md +36 -200
  27. package/agents-config/skills/apex/steps/step-10-verify.md +46 -264
  28. package/agents-config/skills/appstore-connect/agents/openai.yaml +7 -0
  29. package/agents-config/skills/appstore-connect/assets/codex-icon.svg +17 -0
  30. package/agents-config/skills/commit/agents/openai.yaml +10 -0
  31. package/agents-config/skills/commit/assets/codex-icon.svg +17 -0
  32. package/agents-config/skills/create-pr/agents/openai.yaml +10 -0
  33. package/agents-config/skills/create-pr/assets/codex-icon.svg +17 -0
  34. package/agents-config/skills/environments-manager/SKILL.md +1 -1
  35. package/agents-config/skills/environments-manager/agents/openai.yaml +7 -0
  36. package/agents-config/skills/environments-manager/assets/codex-icon.svg +16 -0
  37. package/agents-config/skills/environments-manager/examples/scripts/claude-worktree-remove.sh +19 -3
  38. package/agents-config/skills/environments-manager/examples/scripts/worktree-up.sh +1 -1
  39. package/agents-config/skills/environments-manager/references/claude.md +1 -1
  40. package/agents-config/skills/fix-pr-comments/agents/openai.yaml +10 -0
  41. package/agents-config/skills/fix-pr-comments/assets/codex-icon.svg +17 -0
  42. package/agents-config/skills/grill-me/SKILL.md +25 -4
  43. package/agents-config/skills/grill-me/agents/openai.yaml +8 -0
  44. package/agents-config/skills/grill-me/assets/codex-icon.svg +16 -0
  45. package/agents-config/skills/hooks-manager/SKILL.md +19 -9
  46. package/agents-config/skills/hooks-manager/assets/codex-icon.svg +15 -4
  47. package/agents-config/skills/hooks-manager/references/claude-code.md +32 -0
  48. package/agents-config/skills/hooks-manager/references/codex.md +23 -0
  49. package/agents-config/skills/hooks-manager/references/cursor.md +18 -0
  50. package/agents-config/skills/hooks-manager/references/hook-types.md +5 -3
  51. package/agents-config/skills/hooks-manager/references/input-output-schemas.md +2 -2
  52. package/agents-config/skills/hooks-manager/references/research-sources.md +25 -0
  53. package/agents-config/skills/hooks-manager/references/router.md +32 -0
  54. package/agents-config/skills/hooks-manager/references/troubleshooting.md +3 -3
  55. package/agents-config/skills/merge/agents/openai.yaml +10 -0
  56. package/agents-config/skills/merge/assets/codex-icon.svg +17 -0
  57. package/agents-config/skills/oneshot/SKILL.md +4 -0
  58. package/agents-config/skills/oneshot/agents/openai.yaml +10 -0
  59. package/agents-config/skills/oneshot/assets/codex-icon.svg +18 -0
  60. package/agents-config/skills/prompt-creator/agents/openai.yaml +7 -0
  61. package/agents-config/skills/prompt-creator/assets/codex-icon.svg +16 -0
  62. package/agents-config/skills/rules-manager/agents/openai.yaml +7 -0
  63. package/agents-config/skills/rules-manager/assets/codex-icon.svg +23 -0
  64. package/agents-config/skills/skill-manager/SKILL.md +45 -3
  65. package/agents-config/skills/skill-manager/agents/openai.yaml +7 -0
  66. package/agents-config/skills/skill-manager/assets/codex-icon.svg +23 -0
  67. package/agents-config/skills/skill-manager/references/skill-writing-glossary.md +201 -0
  68. package/agents-config/skills/skill-manager/scripts/setup-codex-icons.ts +143 -0
  69. package/agents-config/skills/ultrathink/agents/openai.yaml +10 -0
  70. package/agents-config/skills/ultrathink/assets/codex-icon.svg +20 -0
  71. package/agents-config/skills/use-artifacts/SKILL.md +102 -51
  72. package/agents-config/skills/use-artifacts/assets/local-runtime.js +299 -0
  73. package/agents-config/skills/use-artifacts/scripts/create_artifact.py +1 -1
  74. package/agents-config/skills/use-delegate/SKILL.md +4 -0
  75. package/agents-config/skills/use-delegate/agents/openai.yaml +10 -0
  76. package/agents-config/skills/use-delegate/assets/codex-icon.svg +20 -0
  77. package/agents-config/skills/use-goal/SKILL.md +70 -9
  78. package/agents-config/skills/use-goal/agents/openai.yaml +1 -1
  79. package/agents-config/skills/use-goal/assets/codex-icon.svg +17 -3
  80. package/agents-config/skills/use-goal/references/claude-code-goal.md +54 -6
  81. package/agents-config/skills/use-goal/references/codex-goal.md +59 -4
  82. package/agents-config/skills/use-goal/references/verification-harnesses.md +104 -3
  83. package/package.json +1 -1
  84. package/agents-config/skills/apex/templates/00-context.md +0 -55
  85. package/agents-config/skills/apex/templates/01-analyze.md +0 -10
  86. package/agents-config/skills/apex/templates/02-plan.md +0 -10
  87. package/agents-config/skills/apex/templates/03-execute.md +0 -10
  88. package/agents-config/skills/apex/templates/04-validate.md +0 -10
  89. package/agents-config/skills/apex/templates/05-examine.md +0 -10
  90. package/agents-config/skills/apex/templates/06-resolve.md +0 -10
  91. package/agents-config/skills/apex/templates/07-tests.md +0 -10
  92. package/agents-config/skills/apex/templates/08-run-tests.md +0 -10
  93. package/agents-config/skills/apex/templates/09-finish.md +0 -10
  94. package/agents-config/skills/apex/templates/10-verify.md +0 -9
  95. package/agents-config/skills/apex/templates/README.md +0 -195
  96. package/agents-config/skills/apex/templates/step-complete.md +0 -7
@@ -1,593 +1,86 @@
1
1
  ---
2
2
  name: step-02-plan
3
- description: Strategic planning - create detailed file-by-file implementation strategy
4
- prev_step: steps/step-01-analyze.md
5
- next_step: steps/step-03-execute.md
3
+ description: Build a revisable APEX task graph with dependencies, scope, side effects, validation, evidence, and re-plan triggers.
6
4
  ---
7
5
 
8
- # Step 2: Plan (Strategic Design)
6
+ # Step 2: Plan
9
7
 
10
- ## MANDATORY EXECUTION RULES (READ FIRST):
8
+ Create a plan detailed enough to execute and compact enough to revise.
11
9
 
12
- - 🛑 NEVER start implementing - that's step 3
13
- - 🛑 NEVER write or modify code in this step
14
- - 🛑 NEVER mark plan as "complete" BEFORE writing plan to `{output_dir}/02-plan.md` (if save_mode)
15
- - ✅ ALWAYS structure plan by FILE, not by feature
16
- - ✅ ALWAYS include specific line numbers from analysis
17
- - ✅ ALWAYS map acceptance criteria to file changes
18
- - ✅ ALWAYS create a TaskList using TaskCreate tool to track all planned file changes
19
- - ✅ IF save_mode: ALWAYS use Edit tool to write the full plan to `{output_dir}/02-plan.md` BEFORE showing summary
20
- - 📋 YOU ARE A PLANNER, not an implementer
21
- - 💬 FOCUS on "What changes need to be made where?"
22
- - 🚫 FORBIDDEN to use Edit/Write on source code files (only on output files if save_mode)
10
+ ## 1. Select the smallest coherent approach
23
11
 
24
- ## EXECUTION PROTOCOLS:
12
+ Follow existing repository patterns unless evidence supports a deliberate change. Prefer additive, reversible, and scope-preserving changes. Identify rollback or recovery for high-risk mutations.
25
13
 
26
- - 🎯 ULTRA THINK before creating the plan
27
- - 💾 IF save_mode: Use Edit tool to write the full plan to `{output_dir}/02-plan.md` AFTER creating the plan and BEFORE presenting summary
28
- - 📖 Reference patterns from step-01 analysis
29
- - 🚫 FORBIDDEN to proceed until user approves plan (unless auto_mode)
30
- - 🚫 FORBIDDEN to proceed to step-03 without saving plan first (if save_mode)
14
+ Ask the user only when multiple valid choices materially change product behavior, scope, authority, or irreversible outcomes. Otherwise record the selected assumption.
31
15
 
32
- ## CONTEXT BOUNDARIES:
16
+ ## 2. Build the task graph
33
17
 
34
- - Context from step-01 (files, patterns, utilities) is available
35
- - Implementation has NOT started
36
- - User has NOT approved any changes yet
37
- - Plan must be complete before execution
38
-
39
- ## YOUR TASK:
40
-
41
- Transform analysis findings into a comprehensive, executable, file-by-file implementation plan.
42
-
43
- ---
44
-
45
- <available_state>
46
- From previous steps:
47
-
48
- | Variable | Description |
49
- |----------|-------------|
50
- | `{task_description}` | What to implement |
51
- | `{task_id}` | Kebab-case identifier |
52
- | `{acceptance_criteria}` | Success criteria from step-01 |
53
- | `{auto_mode}` | Skip confirmations |
54
- | `{save_mode}` | Save outputs to files |
55
- | `{output_dir}` | Path to output (if save_mode) |
56
- | Files found | From step-01 codebase exploration |
57
- | Patterns | From step-01 pattern analysis |
58
- | Utilities | From step-01 utility discovery |
59
- </available_state>
60
-
61
- ---
62
-
63
- ## EXECUTION SEQUENCE:
64
-
65
- ### 1. Initialize Save Output (if save_mode)
66
-
67
- **If `{save_mode}` = true:**
68
-
69
- ```bash
70
- bash {skill_dir}/scripts/update-progress.sh "{task_id}" "02" "plan" "in_progress"
71
- ```
72
-
73
- Append plan to `{output_dir}/02-plan.md` as you work.
74
-
75
- ### 2. ULTRA THINK: Design Complete Strategy
76
-
77
- **CRITICAL: Think through ENTIRE implementation before writing any plan.**
78
-
79
- Mental simulation:
80
- - Walk through the implementation step by step
81
- - Identify all files that need changes
82
- - Determine logical order (dependencies first)
83
- - Consider edge cases and error handling
84
- - Plan test coverage
85
-
86
- ### 3. Clarify Ambiguities
87
-
88
- **If `{auto_mode}` = true:**
89
- → Use recommended option for any ambiguity, proceed automatically
90
-
91
- **If `{auto_mode}` = false AND multiple valid approaches exist:**
18
+ Create one task per independently verifiable unit, not automatically one per file. Every task must include:
92
19
 
93
20
  ```yaml
94
- questions:
95
- - header: "Approach"
96
- question: "Multiple approaches are possible. Which should we use?"
97
- options:
98
- - label: "Approach A (Recommended)"
99
- description: "Description and tradeoffs of A"
100
- - label: "Approach B"
101
- description: "Description and tradeoffs of B"
102
- - label: "Approach C"
103
- description: "Description and tradeoffs of C"
104
- multiSelect: false
105
- ```
106
-
107
- ### 4. Create Detailed Plan
108
-
109
- **Structure by FILE, not by feature:**
110
-
111
- ```markdown
112
- ## Implementation Plan: {task_description}
113
-
114
- ### Overview
115
- [1-2 sentences: High-level strategy and approach]
116
-
117
- ### Prerequisites
118
- - [ ] Prerequisite 1 (if any)
119
- - [ ] Prerequisite 2 (if any)
120
-
121
- ---
122
-
123
- ### File Changes
124
-
125
- #### `src/path/file1.ts`
126
- - Add `functionName` that handles X
127
- - Extract logic from Y (follow pattern in `example.ts:45`)
128
- - Handle error case: [specific scenario]
129
- - Consider: [edge case or important context]
130
-
131
- #### `src/path/file2.ts`
132
- - Update imports to include new module
133
- - Call `functionName` in existing flow at line ~42
134
- - Update types: Add `NewType` interface
135
-
136
- #### `src/path/file3.ts` (NEW FILE)
137
- - Create utility for Z
138
- - Export: `utilityFunction`, `HelperType`
139
- - Pattern: Follow `similar-util.ts` structure
140
-
141
- ---
142
-
143
- ### Testing Strategy
144
-
145
- **New tests:**
146
- - `src/path/file1.test.ts` - Test functionName with:
147
- - Happy path
148
- - Error case
149
- - Edge case
150
-
151
- **Update existing:**
152
- - `src/path/existing.test.ts` - Add test for new flow
153
-
154
- ---
155
-
156
- ### Acceptance Criteria Mapping
157
- - [ ] AC1: Satisfied by changes in `file1.ts`
158
- - [ ] AC2: Satisfied by changes in `file2.ts`
159
-
160
- ---
161
-
162
- ### Risks & Considerations
163
- - Risk 1: [potential issue and mitigation]
164
- ```
165
-
166
- **IF `{save_mode}` = true (MANDATORY - DO THIS NOW):**
167
-
168
- <critical>
169
- Use the **Edit tool** to write the FULL plan to `{output_dir}/02-plan.md`. Replace the placeholder content with the complete plan including all file changes, testing strategy, acceptance criteria mapping, and risks.
170
- </critical>
171
-
172
- ### 5. Create Team (if teams_mode - BEFORE TaskList)
173
-
174
- <critical>
175
- If `{teams_mode}` = true, you MUST create the team BEFORE creating any tasks.
176
- TeamCreate resets the task list - so the team must exist first, then tasks are added to it.
177
- Do NOT spawn any agents yet - that happens in step-03-execute-teams.
178
- </critical>
179
-
180
- **If `{teams_mode}` = true:**
181
-
182
- ```
183
- TeamCreate:
184
- team_name: "apex-{feature_name}"
185
- description: "APEX: {task_description}"
186
- ```
187
-
188
- → This creates the team and its empty task list.
189
- → All subsequent TaskCreate calls will use this team's task list.
190
- → Agents are spawned later in step-03-execute-teams.
191
-
192
- ### 6. Create Task List (MANDATORY)
193
-
194
- <critical>
195
- You MUST create a TaskList using TaskCreate for every planned change.
196
- This is NOT optional - the task list tracks progress through execution.
197
- If teams_mode is enabled, the team was already created in step 5 - tasks go into the team's task list.
198
- </critical>
199
-
200
- **Create one task per file change from the plan:**
201
-
202
- For each file in the plan, call `TaskCreate` with:
203
- - **subject**: `{action} {filepath}` (e.g., "Add validateToken to src/auth/handler.ts")
204
- - **description**: The full details of what changes are needed for this file, including specific functions, patterns to follow, and line references
205
- - **activeForm**: Present continuous form (e.g., "Adding validateToken to handler.ts")
206
-
207
- **Then set up dependencies using `TaskUpdate`:**
208
- - If file B depends on file A (e.g., B imports from A), use `addBlockedBy` to mark the dependency
209
- - This ensures execution follows the correct order
210
-
211
- **Example:**
212
- ```
213
- TaskCreate: "Create auth types in src/types/auth.ts"
214
- → description: "Create AuthToken interface, ValidateResult type. Follow pattern from src/types/user.ts"
215
- → activeForm: "Creating auth types"
216
-
217
- TaskCreate: "Add validateToken to src/auth/handler.ts"
218
- → description: "Add validateToken function that returns ValidateResult. Handle expired token error case."
219
- → activeForm: "Adding validateToken to handler"
220
- → Then: TaskUpdate with addBlockedBy: [auth-types-task-id]
21
+ id: stable-task-id
22
+ objective: measurable outcome
23
+ dependencies: []
24
+ read_set: []
25
+ write_set: []
26
+ side_effects: []
27
+ owner: coordinator | delegated-role
28
+ inputs: []
29
+ expected_outputs: []
30
+ validation: []
31
+ evidence_required: []
32
+ stop_condition: explicit completion or blocker condition
33
+ status: pending
221
34
  ```
222
35
 
223
- ### 7. Verify Plan Completeness
36
+ Mark exclusive resources such as shared databases, generated files, local servers, devices, provider accounts, and Git index operations. Two mutating tasks may run concurrently only when their writes and exclusive resources do not conflict and the harness can coordinate them safely.
224
37
 
225
- Checklist:
226
- - [ ] All files identified - nothing missing
227
- - [ ] Logical order - dependencies handled first
228
- - [ ] Clear actions - every step specific and actionable
229
- - [ ] Test coverage - all paths have test strategy
230
- - [ ] In scope - no scope creep
231
- - [ ] AC mapped - every criterion has implementation
232
- - [ ] **TaskList created with all file changes**
233
- - [ ] **Task dependencies set correctly**
38
+ ## 3. Map acceptance and risk
234
39
 
235
- ### 8. Brainstorm Uncertainty Points
40
+ Every acceptance criterion must map to one or more tasks and a final evidence source. Add specialist review or runtime/provider proof where risk requires it.
236
41
 
237
- <critical>
238
- Before proceeding, THINK about what you're NOT 100% certain about.
239
- DO NOT ask generic "is this plan good?" questions.
240
- Instead, identify SPECIFIC uncertainties and ask TARGETED questions.
241
- </critical>
42
+ ## 4. Define re-plan triggers
242
43
 
243
- **ULTRA THINK: Identify Uncertainties**
44
+ At minimum:
244
45
 
245
- For each aspect of the plan, rate your confidence (High/Medium/Low):
46
+ - repository state or scope changes;
47
+ - dependency output changes an interface;
48
+ - a task touches outside its declared boundary;
49
+ - a required capability, credential, service, or command is unavailable;
50
+ - validation fails for an unexpected reason;
51
+ - evidence contradicts an assumption;
52
+ - two tasks contend for the same resource.
246
53
 
247
- ```markdown
248
- ## Uncertainty Analysis
54
+ When triggered, record the observation, decision, affected tasks, and invalidated evidence. Update the graph before continuing.
249
55
 
250
- | Aspect | Confidence | Uncertainty |
251
- |--------|------------|-------------|
252
- | File locations correct? | High/Medium/Low | [What's unclear] |
253
- | Patterns match codebase? | High/Medium/Low | [What's unclear] |
254
- | Dependencies complete? | High/Medium/Low | [What's unclear] |
255
- | Error handling approach? | High/Medium/Low | [What's unclear] |
256
- | User expectations for X? | High/Medium/Low | [What's unclear] |
257
- | Technical approach for Y? | High/Medium/Low | [What's unclear] |
258
- ```
259
-
260
- **Identify TOP 1-4 uncertainties with Low or Medium confidence.**
261
-
262
- These are the ONLY things worth asking about.
263
-
264
- ---
56
+ ## 5. Choose orchestration
265
57
 
266
- ### 9. Ask Smart Questions (if not auto_mode)
58
+ - Keep tightly coupled or critical-path work with the coordinator.
59
+ - Delegate self-contained sidecars that can progress without blocking the next local action.
60
+ - Use parallelism only for genuinely independent work.
61
+ - Give every worker a bounded packet and no authority to expand the graph or accept its own evidence.
62
+ - Choose model and reasoning effort from task difficulty, cost, and local policy; do not encode transient model names in the plan.
267
63
 
268
- **If `{auto_mode}` = true:**
269
- → Skip questions, use your best judgment, proceed directly
64
+ Resolve and record `{execution_step}` before creating expanded task packets:
270
65
 
271
- **If `{auto_mode}` = false AND you have uncertainties:**
66
+ - `{orchestration_policy}=direct` → `step-03-execute.md`.
67
+ - `{orchestration_policy}=prefer-parallel` → `step-03-execute-teams.md` only when capability and conflict checks permit; otherwise `step-03-execute.md` with the reason recorded.
68
+ - `{orchestration_policy}=auto` → select one of those two steps from the graph, budget, and capability preflight.
272
69
 
273
- <critical>
274
- ONLY ask questions about things where:
275
- 1. Multiple valid approaches exist AND the choice significantly impacts implementation
276
- 2. User intent is genuinely ambiguous from the task description
277
- 3. A wrong assumption could cause significant rework
70
+ ## 6. Persist and present
278
71
 
279
- DO NOT ask about:
280
- - Implementation details you can decide yourself
281
- - Things you're "slightly unsure" about (just decide)
282
- - Generic plan approval (never ask "is this plan good?")
283
- </critical>
72
+ Write the graph to `{run_dir}/tasks.json` through the run-state script or as a validated JSON artifact. Present a concise plan with scope, dependency order, validation, proof, risk, and any assumptions.
284
73
 
285
- **Question Types to Use:**
286
-
287
- **Type 1: Behavior Clarification**
288
- When user intent is genuinely unclear:
289
- ```yaml
290
- questions:
291
- - header: "Behavior"
292
- question: "When [specific scenario], should the system [option A] or [option B]?"
293
- options:
294
- - label: "[Option A] (Recommended)"
295
- description: "[What A does and why it might be preferred]"
296
- - label: "[Option B]"
297
- description: "[What B does and when it's better]"
298
- multiSelect: false
299
- ```
300
-
301
- **Type 2: Scope Clarification**
302
- When scope boundaries are unclear:
303
- ```yaml
304
- questions:
305
- - header: "Scope"
306
- question: "Should we also [related thing] as part of this, or keep it focused on [core thing]?"
307
- options:
308
- - label: "Keep focused (Recommended)"
309
- description: "Only do [core thing], faster implementation"
310
- - label: "Include [related thing]"
311
- description: "More complete but expands scope"
312
- multiSelect: false
313
- ```
314
-
315
- **Type 3: Technical Choice**
316
- When multiple valid technical approaches exist:
317
- ```yaml
318
- questions:
319
- - header: "Approach"
320
- question: "For [specific technical decision], we can use [approach A] or [approach B]. Which fits your needs?"
321
- options:
322
- - label: "[Approach A] (Recommended)"
323
- description: "[Tradeoffs of A - e.g., simpler but less flexible]"
324
- - label: "[Approach B]"
325
- description: "[Tradeoffs of B - e.g., more complex but extensible]"
326
- multiSelect: false
327
- ```
74
+ The user's implementation request is approval for normal in-scope edits. Ask again only for a newly discovered material choice or action class outside that scope.
328
75
 
329
- **Type 4: Edge Case Handling**
330
- When edge case behavior is unclear:
331
- ```yaml
332
- questions:
333
- - header: "Edge case"
334
- question: "If [edge case scenario] occurs, should we [behavior A] or [behavior B]?"
335
- options:
336
- - label: "[Behavior A] (Recommended)"
337
- description: "[What happens with A]"
338
- - label: "[Behavior B]"
339
- description: "[What happens with B]"
340
- multiSelect: false
341
- ```
342
-
343
- **If you have 0 uncertainties worth asking about:**
344
- → Proceed directly to execution without asking anything
345
-
346
- **Example of GOOD questions:**
347
- - "When a user submits invalid email format, should we show inline validation or only validate on submit?"
348
- - "Should the loading state show a spinner on the button or a full-page skeleton?"
349
- - "For rate limiting, should we limit per user or per IP address?"
350
-
351
- **Example of BAD questions (NEVER ask these):**
352
- - ❌ "Does this plan look good to you?"
353
- - ❌ "Ready to proceed with implementation?"
354
- - ❌ "Should I use async/await or promises?" (just decide)
355
- - ❌ "Is the file structure correct?" (you already verified)
356
-
357
- ---
358
-
359
- ### 10. Present Plan Summary & Approve
360
-
361
- **Always show the full plan summary (both auto and non-auto):**
362
-
363
- ```
364
- **Implementation Plan Ready: {task_description}**
365
-
366
- **Overview:** [1 sentence summary]
367
-
368
- **Files to modify:** {count} files
369
- **New files:** {count} files
370
- **Tests:** {count} test files
371
-
372
- **Key decisions made:**
373
- - [Decision 1 from user responses or auto-decided]
374
- - [Decision 2 from user responses or auto-decided]
375
-
376
- **Estimated changes:**
377
- - `file1.ts` - Major changes (add function, handle errors)
378
- - `file2.ts` - Minor changes (imports, single call)
379
- - `file1.test.ts` - New test file
380
-
381
- **Acceptance Criteria Coverage:**
382
- - [ ] AC1: Satisfied by changes in `file1.ts`
383
- - [ ] AC2: Satisfied by changes in `file2.ts`
384
-
385
- **Risks & Considerations:**
386
- - [Risk 1 and mitigation]
387
- ```
388
-
389
- ---
390
-
391
- **If `{auto_mode}` = true:**
392
- → Show the full summary above, then proceed directly to next step
393
-
394
- **If `{auto_mode}` = false:**
395
-
396
- <critical>
397
- Use EnterPlanMode / ExitPlanMode for plan approval - NOT AskUserQuestion.
398
- This gives the user proper plan review UI and supports "Execute and clear context".
399
- </critical>
400
-
401
- **Step 10a: Call `EnterPlanMode`**
402
-
403
- This transitions into plan mode so the user can review and approve.
404
-
405
- **Step 10b: Write the plan to the plan file**
406
-
407
- The system will provide a plan file path. Write the FULL plan to it, including APEX state for context survival.
408
-
409
- <critical>
410
- The plan file must contain ALL details from step 4 - do NOT strip sections.
411
- Include everything: Overview, Prerequisites, File Changes, Testing Strategy, Acceptance Criteria Mapping, Risks & Considerations, Key Decisions.
412
- </critical>
413
-
414
- ```markdown
415
- # APEX Implementation Plan: {task_description}
416
-
417
- ## APEX Workflow Context
418
-
419
- > **IMPORTANT:** This is an APEX workflow plan. If you are reading this after
420
- > "Execute and clear context", continue the APEX workflow by loading the next
421
- > step file listed below.
422
-
423
- ### State Variables
424
- | Variable | Value |
425
- |----------|-------|
426
- | task_description | {task_description} |
427
- | task_id | {task_id} |
428
- | feature_name | {feature_name} |
429
- | auto_mode | {auto_mode} |
430
- | examine_mode | {examine_mode} |
431
- | save_mode | {save_mode} |
432
- | test_mode | {test_mode} |
433
- | economy_mode | {economy_mode} |
434
- | branch_mode | {branch_mode} |
435
- | pr_mode | {pr_mode} |
436
- | tasks_mode | {tasks_mode} |
437
- | teams_mode | {teams_mode} |
438
- | output_dir | {output_dir} |
439
- | branch_name | {branch_name} |
440
-
441
- ### Next Step After Approval
442
- {if tasks_mode or teams_mode:}
443
- Load `skills/workflow-apex/steps/step-02b-tasks.md`
444
- {else:}
445
- Load `skills/workflow-apex/steps/step-03-execute.md`
446
-
447
- ---
448
-
449
- ## Plan Overview
450
- [1-2 sentence high-level strategy and approach]
451
-
452
- ## Prerequisites
453
- - [ ] Prerequisite 1 (if any)
454
- - [ ] Prerequisite 2 (if any)
455
-
456
- ## File Changes
457
-
458
- [Full file-by-file plan from step 4 - every file with specific actions, line references, patterns to follow, edge cases]
459
-
460
- ## Testing Strategy
461
-
462
- **New tests:**
463
- - [test files to create with coverage details]
464
-
465
- **Update existing:**
466
- - [existing test files to modify]
467
-
468
- ## Acceptance Criteria Mapping
469
- - [ ] AC1: Satisfied by changes in `file1.ts`
470
- - [ ] AC2: Satisfied by changes in `file2.ts`
471
-
472
- ## Key Decisions
473
- - [Decision 1 from user responses or auto-decided]
474
- - [Decision 2 from user responses or auto-decided]
475
-
476
- ## Risks & Considerations
477
- - [Risk 1: potential issue and mitigation]
478
- - [Risk 2: potential issue and mitigation]
479
- ```
480
-
481
- **Step 10c: Call `ExitPlanMode`**
482
-
483
- Include appropriate allowedPrompts for execution:
484
-
485
- ```yaml
486
- allowedPrompts:
487
- - tool: Bash
488
- prompt: "run build, typecheck, lint, test, and format commands"
489
- - tool: Bash
490
- prompt: "run git operations for branch management and commits"
491
- - tool: Bash
492
- prompt: "run APEX workflow scripts for progress tracking"
493
- ```
494
-
495
- **Step 10d: Handle "Execute and clear context"**
496
-
497
- If the user chooses "Execute and clear context":
498
- - Context is cleared but the plan file survives
499
- - The agent re-reads the plan file on the next turn
500
- - The APEX Workflow Context section in the plan file tells the agent:
501
- 1. This is an APEX workflow - restore all state variables from the table
502
- 2. Load the next step file indicated in "Next Step After Approval"
503
- 3. Continue the workflow as normal
504
-
505
- <critical>
506
- The plan file MUST contain ALL state variables, the next step path, AND the full detailed plan.
507
- Without this, "Execute and clear context" breaks the APEX workflow.
508
- Never strip sections from the plan file - it must be the complete implementation reference.
509
- </critical>
510
-
511
- ### 11. Complete Save Output (if save_mode)
512
-
513
- **If `{save_mode}` = true:**
514
-
515
- Append to `{output_dir}/02-plan.md`:
516
- ```markdown
517
- ---
518
- ## Step Complete
519
- **Status:** ✓ Complete
520
- **Files planned:** {count}
521
- **Tests planned:** {count}
522
- **Uncertainties resolved:** {count}
523
- **Next:** step-03-execute.md
524
- **Timestamp:** {ISO timestamp}
76
+ ```bash
77
+ python3 "{skill_dir}/scripts/apex-state.py" event --root "$PWD" --run-id "{run_id}" --phase plan --status complete --message "Revisable task graph recorded"
78
+ python3 "{skill_dir}/scripts/apex-state.py" checkpoint --root "$PWD" --run-id "{run_id}" --phase plan --message "Ready to execute"
525
79
  ```
526
80
 
527
- ---
528
-
529
- ## SUCCESS METRICS:
530
-
531
- ✅ Complete file-by-file plan created
532
- ✅ Logical dependency order established
533
- ✅ All acceptance criteria mapped to changes
534
- ✅ Test strategy defined
535
- ✅ **Team created with TeamCreate BEFORE TaskList (if teams_mode)**
536
- ✅ **TaskList created with TaskCreate for every file change**
537
- ✅ **Task dependencies set with TaskUpdate (addBlockedBy)**
538
- ✅ Uncertainty points identified and addressed
539
- ✅ Smart, targeted questions asked (if not auto_mode and uncertainties exist)
540
- ✅ **Plan approved via EnterPlanMode/ExitPlanMode (if not auto_mode)**
541
- ✅ **Plan file contains APEX state variables for "Execute and clear context" survival**
542
- ✅ NO code written or modified
543
- ✅ Output saved (if save_mode)
544
-
545
- ## FAILURE MODES:
546
-
547
- ❌ **CRITICAL**: Skipping file save when save_mode is true (proceeding without writing to 02-plan.md)
548
- ❌ Organizing by feature instead of file
549
- ❌ Vague actions like "add feature" or "fix issue"
550
- ❌ Missing test strategy
551
- ❌ Not mapping to acceptance criteria
552
- ❌ Starting to write code (that's step 3!)
553
- ❌ **CRITICAL**: Not creating a TaskList with TaskCreate
554
- ❌ **CRITICAL**: Asking generic "is this plan good?" questions
555
- ❌ **CRITICAL**: Asking about implementation details you can decide yourself
556
- ❌ **CRITICAL**: Not brainstorming uncertainties before asking questions
557
- ❌ **CRITICAL**: Using AskUserQuestion for plan approval instead of EnterPlanMode/ExitPlanMode (when auto_mode=false)
558
- ❌ **CRITICAL**: Plan file missing APEX state variables (breaks "Execute and clear context")
559
-
560
- ## PLANNING PROTOCOLS:
561
-
562
- - Structure by FILE - each file is a section
563
- - Include line number references from analysis
564
- - Every action must be specific and actionable
565
- - Map every AC to specific file changes
566
- - Plan tests alongside implementation
567
-
568
- ---
569
-
570
- ## NEXT STEP:
571
-
572
- **If `{auto_mode}` = true:** Proceed directly after plan summary.
573
- **If `{auto_mode}` = false:** Proceed after user approves via ExitPlanMode.
574
-
575
- **If "Execute and clear context" was chosen:**
576
- → The agent re-reads the plan file, restores APEX state variables from the table, and loads the next step indicated in the plan file.
577
-
578
- **Routing:**
579
-
580
- **If `{tasks_mode}` = true OR `{teams_mode}` = true:**
581
- → Load `./step-02b-tasks.md` to generate task breakdown with dependencies
582
-
583
- **If `{teams_mode}` = true (after task breakdown):**
584
- → Flow continues to `./step-03-execute-teams.md` for Agent Team parallel execution
585
-
586
- **Otherwise:**
587
- → Load `./step-03-execute.md` to start implementation
81
+ ## Completion
588
82
 
589
- <critical>
590
- Remember: Planning is ONLY about designing the approach - save all implementation for step-03!
591
- When auto_mode=false, ALWAYS use EnterPlanMode/ExitPlanMode for approval - never AskUserQuestion.
592
- The plan file MUST contain APEX state variables so "Execute and clear context" works.
593
- </critical>
83
+ - If `{expanded_tasks}=on`, load `step-02b-tasks.md`.
84
+ - If `{expanded_tasks}=off`, do not create expanded task packets.
85
+ - If `{expanded_tasks}=auto`, create them only when complexity, delegation, or resume value justifies them.
86
+ - After any expanded task packets are complete, load the persisted `{execution_step}` exactly. Without expanded packets, load it directly from this step.