@rune-kit/rune 2.1.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.
Files changed (155) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +357 -0
  3. package/agents/.gitkeep +0 -0
  4. package/agents/architect.md +29 -0
  5. package/agents/asset-creator.md +11 -0
  6. package/agents/audit.md +11 -0
  7. package/agents/autopsy.md +11 -0
  8. package/agents/brainstorm.md +11 -0
  9. package/agents/browser-pilot.md +11 -0
  10. package/agents/coder.md +29 -0
  11. package/agents/completion-gate.md +11 -0
  12. package/agents/constraint-check.md +11 -0
  13. package/agents/context-engine.md +11 -0
  14. package/agents/cook.md +11 -0
  15. package/agents/db.md +11 -0
  16. package/agents/debug.md +11 -0
  17. package/agents/dependency-doctor.md +11 -0
  18. package/agents/deploy.md +11 -0
  19. package/agents/design.md +11 -0
  20. package/agents/docs-seeker.md +11 -0
  21. package/agents/fix.md +11 -0
  22. package/agents/hallucination-guard.md +11 -0
  23. package/agents/incident.md +11 -0
  24. package/agents/integrity-check.md +11 -0
  25. package/agents/journal.md +11 -0
  26. package/agents/launch.md +11 -0
  27. package/agents/logic-guardian.md +11 -0
  28. package/agents/marketing.md +11 -0
  29. package/agents/onboard.md +11 -0
  30. package/agents/perf.md +11 -0
  31. package/agents/plan.md +11 -0
  32. package/agents/preflight.md +11 -0
  33. package/agents/problem-solver.md +11 -0
  34. package/agents/rescue.md +11 -0
  35. package/agents/research.md +11 -0
  36. package/agents/researcher.md +29 -0
  37. package/agents/review-intake.md +11 -0
  38. package/agents/review.md +11 -0
  39. package/agents/reviewer.md +28 -0
  40. package/agents/safeguard.md +11 -0
  41. package/agents/sast.md +11 -0
  42. package/agents/scanner.md +28 -0
  43. package/agents/scope-guard.md +11 -0
  44. package/agents/scout.md +11 -0
  45. package/agents/sentinel.md +11 -0
  46. package/agents/sequential-thinking.md +11 -0
  47. package/agents/session-bridge.md +11 -0
  48. package/agents/skill-forge.md +11 -0
  49. package/agents/skill-router.md +11 -0
  50. package/agents/surgeon.md +11 -0
  51. package/agents/team.md +11 -0
  52. package/agents/test.md +11 -0
  53. package/agents/trend-scout.md +11 -0
  54. package/agents/verification.md +11 -0
  55. package/agents/video-creator.md +11 -0
  56. package/agents/watchdog.md +11 -0
  57. package/agents/worktree.md +11 -0
  58. package/commands/.gitkeep +0 -0
  59. package/commands/rune.md +168 -0
  60. package/compiler/__tests__/openclaw-adapter.test.js +140 -0
  61. package/compiler/__tests__/parser.test.js +55 -0
  62. package/compiler/adapters/antigravity.js +59 -0
  63. package/compiler/adapters/claude.js +37 -0
  64. package/compiler/adapters/cursor.js +67 -0
  65. package/compiler/adapters/generic.js +60 -0
  66. package/compiler/adapters/index.js +45 -0
  67. package/compiler/adapters/openclaw.js +150 -0
  68. package/compiler/adapters/windsurf.js +60 -0
  69. package/compiler/bin/rune.js +288 -0
  70. package/compiler/doctor.js +153 -0
  71. package/compiler/emitter.js +240 -0
  72. package/compiler/parser.js +208 -0
  73. package/compiler/transformer.js +69 -0
  74. package/compiler/transforms/branding.js +27 -0
  75. package/compiler/transforms/cross-references.js +29 -0
  76. package/compiler/transforms/frontmatter.js +38 -0
  77. package/compiler/transforms/hooks.js +68 -0
  78. package/compiler/transforms/subagents.js +36 -0
  79. package/compiler/transforms/tool-names.js +60 -0
  80. package/contexts/dev.md +34 -0
  81. package/contexts/research.md +43 -0
  82. package/contexts/review.md +55 -0
  83. package/extensions/ai-ml/PACK.md +517 -0
  84. package/extensions/analytics/PACK.md +557 -0
  85. package/extensions/backend/PACK.md +678 -0
  86. package/extensions/chrome-ext/PACK.md +995 -0
  87. package/extensions/content/PACK.md +381 -0
  88. package/extensions/devops/PACK.md +520 -0
  89. package/extensions/ecommerce/PACK.md +280 -0
  90. package/extensions/gamedev/PACK.md +393 -0
  91. package/extensions/mobile/PACK.md +273 -0
  92. package/extensions/saas/PACK.md +805 -0
  93. package/extensions/security/PACK.md +536 -0
  94. package/extensions/trading/PACK.md +597 -0
  95. package/extensions/ui/PACK.md +947 -0
  96. package/package.json +47 -0
  97. package/skills/.gitkeep +0 -0
  98. package/skills/adversary/SKILL.md +271 -0
  99. package/skills/asset-creator/SKILL.md +157 -0
  100. package/skills/audit/SKILL.md +466 -0
  101. package/skills/autopsy/SKILL.md +200 -0
  102. package/skills/ba/SKILL.md +279 -0
  103. package/skills/brainstorm/SKILL.md +266 -0
  104. package/skills/browser-pilot/SKILL.md +168 -0
  105. package/skills/completion-gate/SKILL.md +151 -0
  106. package/skills/constraint-check/SKILL.md +165 -0
  107. package/skills/context-engine/SKILL.md +176 -0
  108. package/skills/cook/SKILL.md +636 -0
  109. package/skills/db/SKILL.md +256 -0
  110. package/skills/debug/SKILL.md +240 -0
  111. package/skills/dependency-doctor/SKILL.md +235 -0
  112. package/skills/deploy/SKILL.md +174 -0
  113. package/skills/design/DESIGN-REFERENCE.md +365 -0
  114. package/skills/design/SKILL.md +462 -0
  115. package/skills/doc-processor/SKILL.md +254 -0
  116. package/skills/docs/SKILL.md +336 -0
  117. package/skills/docs-seeker/SKILL.md +166 -0
  118. package/skills/fix/SKILL.md +192 -0
  119. package/skills/git/SKILL.md +285 -0
  120. package/skills/hallucination-guard/SKILL.md +204 -0
  121. package/skills/incident/SKILL.md +241 -0
  122. package/skills/integrity-check/SKILL.md +169 -0
  123. package/skills/journal/SKILL.md +190 -0
  124. package/skills/launch/SKILL.md +330 -0
  125. package/skills/logic-guardian/SKILL.md +240 -0
  126. package/skills/marketing/SKILL.md +229 -0
  127. package/skills/mcp-builder/SKILL.md +311 -0
  128. package/skills/onboard/SKILL.md +298 -0
  129. package/skills/perf/SKILL.md +297 -0
  130. package/skills/plan/SKILL.md +520 -0
  131. package/skills/preflight/SKILL.md +231 -0
  132. package/skills/problem-solver/SKILL.md +284 -0
  133. package/skills/rescue/SKILL.md +434 -0
  134. package/skills/research/SKILL.md +122 -0
  135. package/skills/review/SKILL.md +354 -0
  136. package/skills/review-intake/SKILL.md +222 -0
  137. package/skills/safeguard/SKILL.md +188 -0
  138. package/skills/sast/SKILL.md +190 -0
  139. package/skills/scaffold/SKILL.md +276 -0
  140. package/skills/scope-guard/SKILL.md +150 -0
  141. package/skills/scout/SKILL.md +232 -0
  142. package/skills/sentinel/SKILL.md +320 -0
  143. package/skills/sentinel-env/SKILL.md +226 -0
  144. package/skills/sequential-thinking/SKILL.md +234 -0
  145. package/skills/session-bridge/SKILL.md +287 -0
  146. package/skills/skill-forge/SKILL.md +317 -0
  147. package/skills/skill-router/SKILL.md +267 -0
  148. package/skills/surgeon/SKILL.md +203 -0
  149. package/skills/team/SKILL.md +397 -0
  150. package/skills/test/SKILL.md +271 -0
  151. package/skills/trend-scout/SKILL.md +145 -0
  152. package/skills/verification/SKILL.md +201 -0
  153. package/skills/video-creator/SKILL.md +201 -0
  154. package/skills/watchdog/SKILL.md +166 -0
  155. package/skills/worktree/SKILL.md +140 -0
@@ -0,0 +1,520 @@
1
+ ---
2
+ name: plan
3
+ description: Create structured implementation plans from requirements. Produces master plan + phase files for enterprise-scale project management. Master plan = overview (<80 lines). Phase files = execution detail (<150 lines each). Each session handles 1 phase. Uses opus for deep reasoning.
4
+ metadata:
5
+ author: runedev
6
+ version: "0.4.0"
7
+ layer: L2
8
+ model: opus
9
+ group: creation
10
+ tools: "Read, Write, Edit, Glob, Grep"
11
+ ---
12
+
13
+ # plan
14
+
15
+ ## Purpose
16
+
17
+ Strategic planning engine for the Rune ecosystem. Produces a **master plan + phase files** architecture — NOT a single monolithic plan. The master plan is a concise overview (<80 lines) that references separate phase files, each containing enough detail (<150 lines) that ANY model can execute with high accuracy.
18
+
19
+ **Design principle: Plan for the weakest coder.** Phase files are designed so that even an Amateur-level model (Haiku) can execute them with minimal errors. When the plan satisfies the Amateur's needs, every model benefits — Junior (Sonnet) executes near-perfectly, Senior (Opus) executes flawlessly.
20
+
21
+ This is enterprise-grade project management: BA produces WHAT → Plan produces HOW (structured into phases) → ANY coder executes each phase with full context.
22
+
23
+ <HARD-GATE>
24
+ NEVER produce a single monolithic plan file for non-trivial tasks.
25
+ Non-trivial = 3+ phases OR 5+ files OR estimated > 100 LOC total change.
26
+ For non-trivial tasks: MUST produce master plan + separate phase files.
27
+ For trivial tasks (1-2 phases, < 5 files): inline plan is acceptable.
28
+ </HARD-GATE>
29
+
30
+ ## Architecture: Master Plan + Phase Files
31
+
32
+ ```
33
+ .rune/
34
+ plan-<feature>.md ← Master plan: phases overview, goals, status tracker (<80 lines)
35
+ plan-<feature>-phase1.md ← Phase 1 detail: tasks, acceptance criteria, files to touch (<150 lines)
36
+ plan-<feature>-phase2.md ← Phase 2 detail
37
+ ...
38
+ ```
39
+
40
+ ### Why This Architecture
41
+
42
+ - **Big context = even Opus misses details and makes mistakes**
43
+ - **Small context = Sonnet handles correctly, Opus has zero mistakes**
44
+ - Phase isolation prevents cross-contamination of concerns
45
+ - Each session starts clean with only the relevant phase loaded
46
+ - Coder (Sonnet/Haiku) can execute a phase file without needing the full plan
47
+
48
+ ### Size Constraints
49
+
50
+ | File | Max Lines | Content |
51
+ |------|-----------|---------|
52
+ | Master plan | 80 lines | Overview, phase table, key decisions, status |
53
+ | Phase file | 200 lines | Amateur-proof template: data flow, contracts, tasks, failures, NFRs, rejections, cross-phase |
54
+ | Total phases | Max 8 | If > 8 phases, split into sub-projects |
55
+
56
+ ## Modes
57
+
58
+ ### Implementation Mode (default)
59
+ Standard implementation planning — decompose task into phased steps with code details.
60
+
61
+ ### Feature Spec Mode
62
+ Product-oriented planning — write a feature specification before implementation.
63
+
64
+ **Triggers:**
65
+ - User says "spec", "feature spec", "write spec", "PRD"
66
+ - `/rune plan spec <feature>`
67
+
68
+ ### Roadmap Mode
69
+ High-level multi-feature planning — organize features into milestones.
70
+
71
+ **Triggers:**
72
+ - User says "roadmap", "milestone", "release plan", "what to build next"
73
+ - `/rune plan roadmap`
74
+
75
+ ## Triggers
76
+
77
+ - Called by `cook` when task scope > 1 file (Implementation Mode)
78
+ - Called by `team` for high-level task decomposition
79
+ - `/rune plan <task>` — manual planning
80
+ - `/rune plan spec <feature>` — feature specification
81
+ - `/rune plan roadmap` — roadmap planning
82
+ - Auto-trigger: when user says "implement", "build", "create" with complex scope
83
+
84
+ ## Calls (outbound)
85
+
86
+ - `scout` (L2): scan codebase for existing patterns, conventions, and structure
87
+ - `brainstorm` (L2): when multiple valid approaches exist
88
+ - `research` (L3): external knowledge lookup
89
+ - `sequential-thinking` (L3): complex architecture with many trade-offs
90
+ - L4 extension packs: domain-specific architecture patterns
91
+
92
+ ## Called By (inbound)
93
+
94
+ - `cook` (L1): Phase 2 PLAN
95
+ - `team` (L1): task decomposition into parallel workstreams
96
+ - `brainstorm` (L2): when idea needs structuring
97
+ - `rescue` (L1): plan refactoring strategy
98
+ - `ba` (L2): hand-off after requirements complete
99
+ - `scaffold` (L1): Phase 3 architecture planning
100
+ - `skill-forge` (L2): plan structure for new skill
101
+ - User: `/rune plan` direct invocation
102
+
103
+ ## Cross-Hub Connections
104
+
105
+ - `plan` ↔ `brainstorm` — bidirectional: plan asks brainstorm for options, brainstorm asks plan for structure
106
+ - `ba` → `plan` — BA produces Requirements Document, plan consumes it as primary input
107
+
108
+ ## Executable Steps (Implementation Mode)
109
+
110
+ ### Step 1 — Gather Context
111
+
112
+ **Check for Requirements Document first**: Use `Glob` to check for `.rune/features/*/requirements.md`. If a Requirements Document exists (produced by `rune:ba`), read it and use it as the primary input — it contains user stories, acceptance criteria, scope, and constraints. Do NOT re-gather requirements that BA already elicited.
113
+
114
+ Use findings from `rune:scout` if already available. If not, invoke `rune:scout` with the project root to scan directory structure, detect framework, identify key files, and extract existing patterns. Do NOT skip this step — plans without context produce wrong file paths.
115
+
116
+ ### Step 2 — Classify Complexity
117
+
118
+ Determine if the task needs master plan + phase files or inline plan:
119
+
120
+ | Criteria | Inline Plan | Master + Phase Files |
121
+ |----------|-------------|---------------------|
122
+ | Phases | 1-2 | 3+ |
123
+ | Files touched | < 5 | 5+ |
124
+ | Estimated LOC | < 100 | 100+ |
125
+ | Cross-module | No | Yes |
126
+ | Session span | Single session | Multi-session |
127
+
128
+ If ANY "Master + Phase Files" criterion is true → produce master plan + phase files.
129
+
130
+ ### Step 3 — Decompose into Phases
131
+
132
+ Group related work into phases. Each phase is a coherent unit that:
133
+ - Can be completed in one session
134
+ - Has a clear "done when" condition
135
+ - Produces testable output
136
+ - Is independent enough to execute without other phases loaded
137
+
138
+ <HARD-GATE>
139
+ Each phase MUST be completable by ANY coder model (including Haiku) with ONLY the phase file loaded.
140
+ If the coder would need to read the master plan or other phase files to execute → the phase file is missing detail.
141
+ Phase files are SELF-CONTAINED execution instructions — designed for the weakest model to succeed.
142
+ </HARD-GATE>
143
+
144
+ Phase decomposition rules:
145
+ - **Foundation first**: types, schemas, core engine
146
+ - **Dependencies before consumers**: create what's imported before the importer
147
+ - **Test alongside**: each phase includes its own test tasks
148
+ - **Max 5-7 tasks per phase**: if more, split the phase
149
+
150
+ ### Step 4 — Write Master Plan File
151
+
152
+ Save to `.rune/plan-<feature>.md`:
153
+
154
+ ```markdown
155
+ # Feature: <name>
156
+
157
+ ## Overview
158
+ <1-3 sentences: what and why>
159
+
160
+ ## Phases
161
+ | # | Name | Status | Plan File | Summary |
162
+ |---|------|--------|-----------|---------|
163
+ | 1 | Foundation | ⬚ Pending | plan-X-phase1.md | Types, core engine, basic UI |
164
+ | 2 | Interaction | ⬚ Pending | plan-X-phase2.md | Dialogue, combat, items |
165
+ | 3 | Polish | ⬚ Pending | plan-X-phase3.md | Effects, sounds, game over |
166
+
167
+ ## Key Decisions
168
+ - <decision 1 — chosen approach and why>
169
+ - <decision 2>
170
+
171
+ ## Architecture
172
+ <brief system diagram or component list — NOT implementation detail>
173
+
174
+ ## Dependencies
175
+ - <external dep>: <status>
176
+
177
+ ## Risks
178
+ - <risk>: <mitigation>
179
+ ```
180
+
181
+ **Max 80 lines.** No implementation details — that's what phase files are for.
182
+
183
+ ### Step 5 — Write Phase Files
184
+
185
+ For each phase, save to `.rune/plan-<feature>-phase<N>.md`.
186
+
187
+ Phase files follow the **Amateur-Proof Template** — designed so that even the weakest model can execute without guessing. Every section exists because an Amateur said "I need this to code correctly."
188
+
189
+ ```markdown
190
+ # Phase N: <name>
191
+
192
+ ## Goal
193
+ <What this phase delivers — 1-2 sentences>
194
+
195
+ ## Data Flow
196
+ <5-line ASCII diagram showing how data moves through this phase's components>
197
+ ```
198
+ User Input → validateInput() → calculateProfit() → formatResult() → API Response
199
+
200
+ TradeEntry[]
201
+ ```
202
+
203
+ ## Code Contracts
204
+ <Function signatures, interfaces, schemas that this phase MUST implement>
205
+ <This is the MOST IMPORTANT section — coder implements these contracts>
206
+
207
+ ```typescript
208
+ interface TradeEntry {
209
+ side: 'long' | 'short';
210
+ entryPrice: number;
211
+ exitPrice: number;
212
+ quantity: number;
213
+ }
214
+
215
+ interface ProfitResult {
216
+ netPnL: number;
217
+ totalFees: number;
218
+ winRate: number;
219
+ }
220
+
221
+ function calculateProfit(entries: TradeEntry[]): ProfitResult;
222
+ function validateInput(raw: unknown): TradeEntry[]; // throws ValidationError
223
+ ```
224
+
225
+ ## Tasks
226
+ - [ ] Task 1 — Create calculateProfit function
227
+ - File: `src/foo/bar.ts`
228
+ - Create: `function calculateProfit(entries: TradeEntry[]): ProfitResult`
229
+ - Logic: sum entries by side, apply fees (0.1% per trade), return net P&L
230
+ - Edge: empty array → return { netPnL: 0, totalFees: 0, winRate: 0 }
231
+ - [ ] Task 2 — Add input validation
232
+ - File: `src/foo/baz.ts`
233
+ - Modify: add `validateInput()` before processing
234
+ - Logic: check side is 'long'|'short', prices > 0, quantity > 0
235
+ - [ ] Task 3 — Write tests
236
+ - File: `tests/foo/bar.test.ts`
237
+ - Cases: happy path, empty input, negative values, overflow
238
+
239
+ ## Failure Scenarios
240
+ <What should happen when things go wrong — coder MUST implement these>
241
+
242
+ | When | Then | Error Type |
243
+ |------|------|-----------|
244
+ | entries is empty array | return zero-value ProfitResult | No error (valid edge case) |
245
+ | entry has negative price | throw ValidationError("price must be positive") | ValidationError |
246
+ | entry has quantity = 0 | throw ValidationError("quantity must be > 0") | ValidationError |
247
+ | calculation overflows Number.MAX_SAFE_INTEGER | use BigInt or throw OverflowError | OverflowError |
248
+
249
+ ## Performance Constraints
250
+ <Non-functional requirements — skip if not applicable>
251
+
252
+ | Metric | Requirement | Why |
253
+ |--------|-------------|-----|
254
+ | Input size | Must handle 10,000 entries | Production data volume |
255
+ | Response time | < 100ms for 10K entries | Real-time dashboard |
256
+ | Memory | < 50MB for 10K entries | Container memory limit |
257
+
258
+ ## Rejection Criteria (DO NOT)
259
+ <Anti-patterns the coder MUST avoid — things that seem right but are wrong>
260
+
261
+ - ❌ DO NOT use `toFixed()` for financial calculations — use Decimal.js or integer cents
262
+ - ❌ DO NOT mutate the input array — create new objects (immutability rule)
263
+ - ❌ DO NOT use `any` type — full TypeScript strict
264
+ - ❌ DO NOT import from Phase 2+ files — this phase is self-contained
265
+
266
+ ## Cross-Phase Context
267
+ <What this phase assumes from previous phases / what future phases expect from this one>
268
+
269
+ - **Assumes**: Phase 1 created `src/shared/types.ts` with base types
270
+ - **Exports for Phase 3**: `calculateProfit()` will be imported by `src/dashboard/PnLCard.tsx`
271
+ - **Interface contract**: ProfitResult shape MUST NOT change — Phase 3 depends on it
272
+
273
+ ## Acceptance Criteria
274
+ - [ ] All tasks marked done
275
+ - [ ] Tests pass with 80%+ coverage on new code
276
+ - [ ] No TypeScript errors (`tsc --noEmit` passes)
277
+ - [ ] Failure scenarios all handled (table above)
278
+ - [ ] Performance: calculateProfit(10K entries) < 100ms
279
+ - [ ] No `any` types, no mutation, no `toFixed()` for money
280
+
281
+ ## Files Touched
282
+ - `src/foo/bar.ts` — new
283
+ - `src/foo/baz.ts` — modify
284
+ - `tests/foo/bar.test.ts` — new
285
+ ```
286
+
287
+ **Max 200 lines per phase file.** Must be self-contained — coder should NOT need to read master plan or other phases to execute.
288
+
289
+ <HARD-GATE>
290
+ Every phase file MUST include ALL of these sections (Amateur-Proof Checklist):
291
+ 1. ✅ Data Flow — ASCII diagram of how data moves
292
+ 2. ✅ Code Contracts — function signatures, interfaces, types
293
+ 3. ✅ Tasks — with file paths, logic description, edge cases
294
+ 4. ✅ Failure Scenarios — table of when/then/error for each error case
295
+ 5. ✅ Rejection Criteria — explicit "DO NOT" anti-patterns
296
+ 6. ✅ Cross-Phase Context — what's assumed from prior phases, what's exported for future phases
297
+ 7. ✅ Acceptance Criteria — testable, includes performance if applicable
298
+ 8. ✅ Test tasks — every code task has corresponding tests
299
+
300
+ A phase missing ANY of sections 1-7 is INCOMPLETE — the weakest coder will guess wrong.
301
+ Performance Constraints section is optional (only when NFRs apply).
302
+ </HARD-GATE>
303
+
304
+ ### Step 6 — Present and Get Approval
305
+
306
+ Present the **master plan** to user (NOT all phase files). User reviews:
307
+ - Phase breakdown
308
+ - Key decisions
309
+ - Risks
310
+
311
+ Wait for explicit approval ("go", "proceed", "yes") before writing phase files.
312
+
313
+ If user requests changes → revise and re-present.
314
+
315
+ ### Step 7 — Execution Handoff
316
+
317
+ After approval, the execution flow is:
318
+
319
+ ```
320
+ 1. Cook loads master plan → identifies current phase (first ⬚ Pending)
321
+ 2. Cook loads ONLY that phase's file
322
+ 3. Coder executes tasks in the phase file
323
+ 4. Mark tasks done in phase file as completed
324
+ 5. When phase complete → update master plan status: ⬚ → ✅
325
+ 6. Next session: load master plan → find next ⬚ phase → load phase file → execute
326
+ ```
327
+
328
+ **Model selection for execution:**
329
+ - Opus plans phases (this skill)
330
+ - Sonnet/Haiku executes them (cook → fix)
331
+ - If Sonnet makes small errors → fix lightly (cheaper than using Opus for execution)
332
+
333
+ ## Inline Plan (Trivial Tasks)
334
+
335
+ For trivial tasks (1-2 phases, < 5 files, < 100 LOC):
336
+
337
+ Skip master plan + phase files. Produce inline plan directly:
338
+
339
+ ```
340
+ ## Plan: [Task Name]
341
+
342
+ ### Changes
343
+ 1. [file]: [what to change] — [function signature]
344
+ 2. [file]: [what to change]
345
+
346
+ ### Tests
347
+ - [test file]: [test cases]
348
+
349
+ ### Risks
350
+ - [risk]: [mitigation]
351
+
352
+ Awaiting approval.
353
+ ```
354
+
355
+ ## Re-Planning (Dynamic Adaptation)
356
+
357
+ When cook encounters unexpected conditions during execution:
358
+
359
+ ### Trigger Conditions
360
+ - Phase execution hits max debug-fix loops (3)
361
+ - New files discovered outside the plan scope
362
+ - Dependency change alters the approach
363
+ - User requests scope change
364
+
365
+ ### Re-Plan Protocol
366
+
367
+ 1. **Read the master plan** + **current phase file**
368
+ 2. **Read delta context**: what changed, what failed
369
+ 3. **Assess impact**: which remaining phases are affected?
370
+ 4. **Revise**:
371
+ - Mark completed phases as ✅ in master plan
372
+ - Modify affected phase files
373
+ - Add new phases if scope expanded
374
+ - **Do NOT rewrite completed phases**
375
+ 5. **Present revised master plan** with diff summary
376
+ 6. **Get approval** before resuming
377
+
378
+ ## Feature Spec Mode
379
+
380
+ When invoked in Feature Spec Mode, produce a structured specification.
381
+
382
+ ### Steps
383
+
384
+ **Step 1 — Problem Statement**
385
+ - What problem? Who has it? Current workaround?
386
+
387
+ **Step 2 — User Stories**
388
+ - Primary story, 2-3 secondary, edge cases
389
+ - Format: `As a [persona], I want to [action] so that [benefit]`
390
+
391
+ **Step 3 — Acceptance Criteria**
392
+ - `GIVEN [context] WHEN [action] THEN [result]`
393
+ - Happy path + error cases + performance criteria
394
+
395
+ **Step 4 — Scope Definition**
396
+ - In scope / Out of scope / Dependencies / Open questions
397
+
398
+ **Step 5 — Write Spec File**
399
+ Save to `.rune/features/<feature-name>/spec.md`
400
+
401
+ After spec approved → transition to Implementation Mode.
402
+
403
+ ## Roadmap Mode
404
+
405
+ When invoked in Roadmap Mode, produce a prioritized feature roadmap.
406
+
407
+ ### Steps
408
+
409
+ **Step 1 — Inventory**
410
+ Scan project for: open issues, TODO/FIXME comments, planned features.
411
+
412
+ **Step 2 — Prioritize (ICE Scoring)**
413
+ Impact × Confidence × Ease (each 1-10). Sort descending.
414
+
415
+ **Step 3 — Group into Milestones**
416
+ - Milestone 1: top 3-5 features by ICE
417
+ - Milestone 2: next 3-5
418
+ - Backlog: remaining
419
+
420
+ **Step 4 — Write Roadmap**
421
+ Save to `.rune/roadmap.md`
422
+
423
+ ## Output Format
424
+
425
+ ### Master Plan (`.rune/plan-<feature>.md`)
426
+ ```markdown
427
+ # Feature: <name>
428
+
429
+ ## Overview
430
+ <1-3 sentences: what and why>
431
+
432
+ ## Phases
433
+ | # | Name | Status | Plan File | Summary |
434
+ |---|------|--------|-----------|---------|
435
+ | 1 | [name] | ⬚ Pending | plan-X-phase1.md | [1-line summary] |
436
+
437
+ ## Key Decisions
438
+ - [decision — chosen approach and why]
439
+
440
+ ## Architecture
441
+ <brief system diagram — NOT implementation detail>
442
+
443
+ ## Dependencies / Risks
444
+ - [dep/risk]: [status/mitigation]
445
+ ```
446
+ Max 80 lines. No implementation details.
447
+
448
+ ### Phase File (`.rune/plan-<feature>-phase<N>.md`)
449
+ 7 mandatory sections (Amateur-Proof Template):
450
+ 1. **Goal** — 1-2 sentences
451
+ 2. **Data Flow** — 5-line ASCII diagram
452
+ 3. **Code Contracts** — function signatures, interfaces
453
+ 4. **Tasks** — file paths, logic, edge cases, tests
454
+ 5. **Failure Scenarios** — when/then/error table
455
+ 6. **Rejection Criteria** — explicit DO NOTs
456
+ 7. **Cross-Phase Context** — assumes from prior, exports for future
457
+ 8. **Acceptance Criteria** — testable conditions
458
+
459
+ Max 200 lines. Self-contained — coder needs ONLY this file.
460
+
461
+ ### Inline Plan (trivial tasks)
462
+ ```
463
+ ## Plan: [Task Name]
464
+ ### Changes
465
+ 1. [file]: [what] — [signature]
466
+ ### Tests
467
+ - [test file]: [cases]
468
+ ### Risks
469
+ - [risk]: [mitigation]
470
+ ```
471
+
472
+ ## Constraints
473
+
474
+ 1. MUST produce master plan + phase files for non-trivial tasks (3+ phases OR 5+ files OR 100+ LOC)
475
+ 2. MUST keep master plan under 80 lines — overview only, no implementation details
476
+ 3. MUST keep each phase file under 200 lines — self-contained, Amateur-proof
477
+ 4. MUST include exact file paths for every task — no vague "set up the database"
478
+ 5. MUST include test tasks for every phase that produces code
479
+ 6. MUST include ALL Amateur-Proof sections: data flow, code contracts, tasks, failure scenarios, rejection criteria, cross-phase context, acceptance criteria
480
+ 7. MUST order phases by dependency — don't plan phase 3 before phase 1's output exists
481
+ 8. MUST get user approval before writing phase files
482
+ 9. Phase files MUST be self-contained — coder should NOT need master plan to execute
483
+ 10. Max 8 phases per master plan — if more, split into sub-projects
484
+ 11. MUST include failure scenarios table — what happens when things go wrong
485
+ 12. MUST include rejection criteria — explicit "DO NOT" anti-patterns to prevent common mistakes
486
+ 13. MUST include cross-phase context — what's assumed from prior phases, what's exported for future
487
+
488
+ ## Sharp Edges
489
+
490
+ | Failure Mode | Severity | Mitigation |
491
+ |---|---|---|
492
+ | Monolithic plan file that overflows context | CRITICAL | HARD-GATE: non-trivial tasks MUST use master + phase files |
493
+ | Phase file too vague for Amateur to execute | CRITICAL | Amateur-Proof template: ALL 7 mandatory sections required |
494
+ | Coder uses wrong approach (toFixed for money, mutation) | CRITICAL | Rejection Criteria section: explicit "DO NOT" list prevents common traps |
495
+ | Coder doesn't handle errors properly | HIGH | Failure Scenarios table: when/then/error for EVERY error case |
496
+ | Coder doesn't know what other phases expect | HIGH | Cross-Phase Context: explicit imports/exports between phases |
497
+ | Coder over-engineers or under-engineers perf | HIGH | Performance Constraints: specific metrics with thresholds |
498
+ | Master plan contains implementation detail | HIGH | Max 80 lines, overview only — detail goes in phase files |
499
+ | Phase file references other phase files | HIGH | Phase files are self-contained — cross-phase section handles this |
500
+ | Plan without scout context — invented file paths | CRITICAL | Step 1: scout first, always |
501
+ | Phase with zero test tasks | CRITICAL | HARD-GATE rejects it |
502
+ | 10+ phases overwhelming the master plan | MEDIUM | Max 8 phases — split into sub-projects if more |
503
+
504
+ ## Done When
505
+
506
+ - Complexity classified (inline vs master + phase files)
507
+ - Scout output read and conventions/patterns identified
508
+ - BA requirements consumed (if available)
509
+ - Master plan written (< 80 lines) with phase table and key decisions
510
+ - Phase files written (< 200 lines each) with ALL Amateur-Proof sections:
511
+ - Data flow diagram, code contracts, tasks with edge cases
512
+ - Failure scenarios table, rejection criteria (DO NOTs)
513
+ - Cross-phase context (assumes/exports), acceptance criteria
514
+ - Every code-producing phase has test tasks
515
+ - Master plan presented to user with "Awaiting Approval"
516
+ - User has explicitly approved
517
+
518
+ ## Cost Profile
519
+
520
+ ~3000-8000 tokens input, ~2000-5000 tokens output (master + all phase files). Opus for architectural reasoning. Most expensive L2 skill but runs infrequently. Phase files are written once, executed by cheaper models (Sonnet/Haiku).