@thierrynakoa/fire-flow 10.0.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.
Files changed (215) hide show
  1. package/.claude-plugin/plugin.json +64 -0
  2. package/ARCHITECTURE-DIAGRAM.md +440 -0
  3. package/COMMAND-REFERENCE.md +172 -0
  4. package/DOMINION-FLOW-OVERVIEW.md +421 -0
  5. package/LICENSE +21 -0
  6. package/QUICK-START.md +351 -0
  7. package/README.md +398 -0
  8. package/TROUBLESHOOTING.md +264 -0
  9. package/agents/fire-codebase-mapper.md +484 -0
  10. package/agents/fire-debugger.md +535 -0
  11. package/agents/fire-executor.md +949 -0
  12. package/agents/fire-fact-checker.md +276 -0
  13. package/agents/fire-learncoding-explainer.md +237 -0
  14. package/agents/fire-learncoding-walker.md +147 -0
  15. package/agents/fire-planner.md +675 -0
  16. package/agents/fire-project-researcher.md +155 -0
  17. package/agents/fire-research-synthesizer.md +166 -0
  18. package/agents/fire-researcher.md +723 -0
  19. package/agents/fire-reviewer.md +499 -0
  20. package/agents/fire-roadmapper.md +203 -0
  21. package/agents/fire-verifier.md +880 -0
  22. package/bin/cli.js +208 -0
  23. package/commands/fire-0-orient.md +476 -0
  24. package/commands/fire-1-new.md +281 -0
  25. package/commands/fire-1a-discuss.md +455 -0
  26. package/commands/fire-2-plan.md +527 -0
  27. package/commands/fire-3-execute.md +1303 -0
  28. package/commands/fire-4-verify.md +845 -0
  29. package/commands/fire-5-handoff.md +515 -0
  30. package/commands/fire-6-resume.md +501 -0
  31. package/commands/fire-7-review.md +409 -0
  32. package/commands/fire-add-new-skill.md +598 -0
  33. package/commands/fire-analytics.md +499 -0
  34. package/commands/fire-assumptions.md +78 -0
  35. package/commands/fire-autonomous.md +528 -0
  36. package/commands/fire-brainstorm.md +413 -0
  37. package/commands/fire-complete-milestone.md +270 -0
  38. package/commands/fire-dashboard.md +375 -0
  39. package/commands/fire-debug.md +663 -0
  40. package/commands/fire-discover.md +616 -0
  41. package/commands/fire-double-check.md +460 -0
  42. package/commands/fire-execute-plan.md +182 -0
  43. package/commands/fire-learncoding.md +242 -0
  44. package/commands/fire-loop-resume.md +272 -0
  45. package/commands/fire-loop-stop.md +198 -0
  46. package/commands/fire-loop.md +1168 -0
  47. package/commands/fire-map-codebase.md +313 -0
  48. package/commands/fire-new-milestone.md +356 -0
  49. package/commands/fire-reflect.md +235 -0
  50. package/commands/fire-research.md +246 -0
  51. package/commands/fire-search.md +330 -0
  52. package/commands/fire-security-audit-repo.md +293 -0
  53. package/commands/fire-security-scan.md +484 -0
  54. package/commands/fire-session-summary.md +252 -0
  55. package/commands/fire-skills-diff.md +506 -0
  56. package/commands/fire-skills-history.md +388 -0
  57. package/commands/fire-skills-rollback.md +408 -0
  58. package/commands/fire-skills-sync.md +470 -0
  59. package/commands/fire-test.md +520 -0
  60. package/commands/fire-todos.md +335 -0
  61. package/commands/fire-transition.md +186 -0
  62. package/commands/fire-update.md +312 -0
  63. package/commands/fire-verify-uat.md +146 -0
  64. package/commands/fire-vuln-scan.md +493 -0
  65. package/hooks/hooks.json +16 -0
  66. package/hooks/run-hook.cmd +69 -0
  67. package/hooks/run-hook.sh +8 -0
  68. package/hooks/run-session-end.cmd +49 -0
  69. package/hooks/run-session-end.sh +7 -0
  70. package/hooks/session-end.sh +90 -0
  71. package/hooks/session-start.sh +111 -0
  72. package/package.json +52 -0
  73. package/plugin.json +7 -0
  74. package/references/auto-skill-extraction.md +136 -0
  75. package/references/behavioral-directives.md +365 -0
  76. package/references/blocker-tracking.md +155 -0
  77. package/references/checkpoints.md +165 -0
  78. package/references/circuit-breaker.md +410 -0
  79. package/references/context-engineering.md +587 -0
  80. package/references/decision-time-guidance.md +289 -0
  81. package/references/error-classification.md +326 -0
  82. package/references/execution-mode-intelligence.md +242 -0
  83. package/references/git-integration.md +217 -0
  84. package/references/honesty-protocols.md +304 -0
  85. package/references/integration-architecture.md +470 -0
  86. package/references/issue-to-pr-pipeline.md +150 -0
  87. package/references/metrics-and-trends.md +234 -0
  88. package/references/playwright-e2e-testing.md +326 -0
  89. package/references/questioning.md +125 -0
  90. package/references/research-improvements.md +110 -0
  91. package/references/skills-usage-guide.md +429 -0
  92. package/references/tdd.md +131 -0
  93. package/references/testing-enforcement.md +192 -0
  94. package/references/ui-brand.md +383 -0
  95. package/references/validation-checklist.md +456 -0
  96. package/references/verification-patterns.md +187 -0
  97. package/references/warrior-principles.md +173 -0
  98. package/skills-library/SKILLS-INDEX.md +588 -0
  99. package/skills-library/_general/frontend/html-visual-reports.md +292 -0
  100. package/skills-library/_general/methodology/debug-swarm-researcher-escape-hatch.md +240 -0
  101. package/skills-library/_general/methodology/learncoding-agentic-pattern.md +114 -0
  102. package/skills-library/_general/methodology/shell-autonomous-loop-fixplan.md +238 -0
  103. package/skills-library/basics/api-rest-basics.md +162 -0
  104. package/skills-library/basics/env-variables.md +96 -0
  105. package/skills-library/basics/error-handling-basics.md +125 -0
  106. package/skills-library/basics/git-commit-conventions.md +106 -0
  107. package/skills-library/basics/readme-template.md +108 -0
  108. package/skills-library/common-tasks/async-await-patterns.md +157 -0
  109. package/skills-library/common-tasks/auth-jwt-basics.md +164 -0
  110. package/skills-library/common-tasks/database-schema-design.md +166 -0
  111. package/skills-library/common-tasks/file-upload-basics.md +166 -0
  112. package/skills-library/common-tasks/form-validation.md +159 -0
  113. package/skills-library/debugging/FAILURE_TAXONOMY_CLASSIFICATION.md +117 -0
  114. package/skills-library/debugging/THREE_AGENT_HYPOTHESIS_DEBUGGING.md +86 -0
  115. package/skills-library/methodology/BREATH_BASED_PARALLEL_EXECUTION.md +678 -0
  116. package/skills-library/methodology/CONFIDENCE_GATED_EXECUTION.md +243 -0
  117. package/skills-library/methodology/EVIDENCE_BASED_VALIDATION.md +308 -0
  118. package/skills-library/methodology/MULTI_PERSPECTIVE_CODE_REVIEW.md +330 -0
  119. package/skills-library/methodology/PATH_VERIFICATION_GATE.md +211 -0
  120. package/skills-library/methodology/REFLEXION_MEMORY_PATTERN.md +183 -0
  121. package/skills-library/methodology/RESEARCH_BACKED_WORKFLOW_UPGRADE.md +263 -0
  122. package/skills-library/methodology/SABBATH_REST_PATTERN.md +267 -0
  123. package/skills-library/methodology/STONE_AND_SCAFFOLD.md +220 -0
  124. package/skills-library/performance/cache-augmented-generation.md +172 -0
  125. package/skills-library/quality-safety/debugging-steps.md +147 -0
  126. package/skills-library/quality-safety/deployment-checklist.md +155 -0
  127. package/skills-library/quality-safety/security-checklist.md +204 -0
  128. package/skills-library/quality-safety/testing-basics.md +180 -0
  129. package/skills-library/security/agent-security-scanner.md +445 -0
  130. package/skills-library/specialists/api-architecture/api-designer.md +49 -0
  131. package/skills-library/specialists/api-architecture/graphql-architect.md +49 -0
  132. package/skills-library/specialists/api-architecture/mcp-developer.md +51 -0
  133. package/skills-library/specialists/api-architecture/microservices-architect.md +50 -0
  134. package/skills-library/specialists/api-architecture/websocket-engineer.md +48 -0
  135. package/skills-library/specialists/backend/django-expert.md +52 -0
  136. package/skills-library/specialists/backend/fastapi-expert.md +52 -0
  137. package/skills-library/specialists/backend/laravel-specialist.md +52 -0
  138. package/skills-library/specialists/backend/nestjs-expert.md +51 -0
  139. package/skills-library/specialists/backend/rails-expert.md +53 -0
  140. package/skills-library/specialists/backend/spring-boot-engineer.md +56 -0
  141. package/skills-library/specialists/data-ml/fine-tuning-expert.md +48 -0
  142. package/skills-library/specialists/data-ml/ml-pipeline.md +47 -0
  143. package/skills-library/specialists/data-ml/pandas-pro.md +47 -0
  144. package/skills-library/specialists/data-ml/rag-architect.md +51 -0
  145. package/skills-library/specialists/data-ml/spark-engineer.md +47 -0
  146. package/skills-library/specialists/frontend/angular-architect.md +52 -0
  147. package/skills-library/specialists/frontend/flutter-expert.md +51 -0
  148. package/skills-library/specialists/frontend/nextjs-developer.md +54 -0
  149. package/skills-library/specialists/frontend/react-native-expert.md +50 -0
  150. package/skills-library/specialists/frontend/vue-expert.md +51 -0
  151. package/skills-library/specialists/infrastructure/chaos-engineer.md +74 -0
  152. package/skills-library/specialists/infrastructure/cloud-architect.md +70 -0
  153. package/skills-library/specialists/infrastructure/database-optimizer.md +64 -0
  154. package/skills-library/specialists/infrastructure/devops-engineer.md +70 -0
  155. package/skills-library/specialists/infrastructure/kubernetes-specialist.md +52 -0
  156. package/skills-library/specialists/infrastructure/monitoring-expert.md +70 -0
  157. package/skills-library/specialists/infrastructure/sre-engineer.md +70 -0
  158. package/skills-library/specialists/infrastructure/terraform-engineer.md +51 -0
  159. package/skills-library/specialists/languages/cpp-pro.md +74 -0
  160. package/skills-library/specialists/languages/csharp-developer.md +69 -0
  161. package/skills-library/specialists/languages/dotnet-core-expert.md +54 -0
  162. package/skills-library/specialists/languages/golang-pro.md +51 -0
  163. package/skills-library/specialists/languages/java-architect.md +49 -0
  164. package/skills-library/specialists/languages/javascript-pro.md +68 -0
  165. package/skills-library/specialists/languages/kotlin-specialist.md +68 -0
  166. package/skills-library/specialists/languages/php-pro.md +49 -0
  167. package/skills-library/specialists/languages/python-pro.md +52 -0
  168. package/skills-library/specialists/languages/react-expert.md +51 -0
  169. package/skills-library/specialists/languages/rust-engineer.md +50 -0
  170. package/skills-library/specialists/languages/sql-pro.md +56 -0
  171. package/skills-library/specialists/languages/swift-expert.md +69 -0
  172. package/skills-library/specialists/languages/typescript-pro.md +51 -0
  173. package/skills-library/specialists/platform/atlassian-mcp.md +52 -0
  174. package/skills-library/specialists/platform/embedded-systems.md +53 -0
  175. package/skills-library/specialists/platform/game-developer.md +53 -0
  176. package/skills-library/specialists/platform/salesforce-developer.md +53 -0
  177. package/skills-library/specialists/platform/shopify-expert.md +49 -0
  178. package/skills-library/specialists/platform/wordpress-pro.md +49 -0
  179. package/skills-library/specialists/quality/code-documenter.md +51 -0
  180. package/skills-library/specialists/quality/code-reviewer.md +67 -0
  181. package/skills-library/specialists/quality/debugging-wizard.md +51 -0
  182. package/skills-library/specialists/quality/fullstack-guardian.md +51 -0
  183. package/skills-library/specialists/quality/legacy-modernizer.md +50 -0
  184. package/skills-library/specialists/quality/playwright-expert.md +65 -0
  185. package/skills-library/specialists/quality/spec-miner.md +56 -0
  186. package/skills-library/specialists/quality/test-master.md +65 -0
  187. package/skills-library/specialists/security/secure-code-guardian.md +55 -0
  188. package/skills-library/specialists/security/security-reviewer.md +53 -0
  189. package/skills-library/specialists/workflow/architecture-designer.md +53 -0
  190. package/skills-library/specialists/workflow/cli-developer.md +70 -0
  191. package/skills-library/specialists/workflow/feature-forge.md +65 -0
  192. package/skills-library/specialists/workflow/prompt-engineer.md +54 -0
  193. package/skills-library/specialists/workflow/the-fool.md +62 -0
  194. package/templates/ASSUMPTIONS.md +125 -0
  195. package/templates/BLOCKERS.md +73 -0
  196. package/templates/DECISION_LOG.md +116 -0
  197. package/templates/UAT.md +96 -0
  198. package/templates/blueprint.md +94 -0
  199. package/templates/brainstorm.md +185 -0
  200. package/templates/conscience.md +92 -0
  201. package/templates/fire-handoff.md +159 -0
  202. package/templates/metrics.md +67 -0
  203. package/templates/phase-prompt.md +142 -0
  204. package/templates/record.md +131 -0
  205. package/templates/review-report.md +117 -0
  206. package/templates/skills-index.md +157 -0
  207. package/templates/verification.md +149 -0
  208. package/templates/vision.md +79 -0
  209. package/validation-config.yml +793 -0
  210. package/version.json +7 -0
  211. package/workflows/execute-phase.md +732 -0
  212. package/workflows/handoff-session.md +678 -0
  213. package/workflows/new-project.md +578 -0
  214. package/workflows/plan-phase.md +592 -0
  215. package/workflows/verify-phase.md +874 -0
@@ -0,0 +1,587 @@
1
+ # Context Engineering
2
+
3
+ > Techniques for maximizing context window effectiveness — recitation pattern, cache optimization, and context exclusion. Inspired by Manus AI's context engineering and Bolt.new's .bolt/ignore system.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ Context is the most precious resource in agentic execution. Every byte of context consumed by irrelevant information is a byte unavailable for reasoning. Context Engineering applies three strategies:
10
+
11
+ 1. **Recitation Pattern** — Rewrite critical state into context each iteration to keep it in the attention window
12
+ 2. **Cache-Friendly Ordering** — Structure prompts for maximum KV-cache reuse
13
+ 3. **Context Exclusion** — Actively exclude irrelevant content from context
14
+
15
+ ---
16
+
17
+ ## 1. Recitation Pattern
18
+
19
+ ### Problem
20
+
21
+ In long-running loops and multi-step execution, earlier context gets pushed out of the attention window. The agent "forgets" its plan, progress, and decisions — leading to circular behavior.
22
+
23
+ ### Solution
24
+
25
+ At each iteration/step, **recite** (rewrite) the current state into the context. This keeps critical information in the active attention window.
26
+
27
+ ```
28
+ BEFORE each iteration:
29
+
30
+ recitation_block = compose_recitation(
31
+ current_plan: extract_current_tasks(BLUEPRINT.md),
32
+ progress: extract_completed_tasks(loop_file or SUMMARY),
33
+ active_blockers: extract_open_blockers(BLOCKERS.md),
34
+ key_decisions: extract_recent_decisions(CONSCIENCE.md),
35
+ approach: current_approach_description
36
+ )
37
+
38
+ inject_into_context(recitation_block)
39
+ ```
40
+
41
+ ### Recitation Block Format
42
+
43
+ ```markdown
44
+ ---
45
+ DOMINION FLOW RECITATION — Iteration {N}
46
+ ---
47
+
48
+ ## Current Task
49
+ {task description from BLUEPRINT.md}
50
+
51
+ ## Progress So Far
52
+ - [x] Task 1: {description} (commit: abc123)
53
+ - [x] Task 2: {description} (commit: def456)
54
+ - [ ] Task 3: {description} ← CURRENT
55
+ - [ ] Task 4: {description}
56
+
57
+ ## Active Approach
58
+ {what we're currently trying and why}
59
+
60
+ ## Key Decisions
61
+ - {decision 1}: {rationale}
62
+ - {decision 2}: {rationale}
63
+
64
+ ## Open Blockers
65
+ - {blocker if any}
66
+
67
+ ## Circuit Breaker
68
+ - State: {HEALTHY/WARNING/etc}
69
+ - Iterations without progress: {N}
70
+ - Error repeat count: {N}
71
+ ---
72
+ ```
73
+
74
+ ### When to Recite
75
+
76
+ | Context | Frequency | Content |
77
+ |---------|-----------|---------|
78
+ | `/fire-loop` | Every iteration | Task + progress + approach + health state |
79
+ | `/fire-execute-plan` | Every task boundary | Plan progress + current task + deviations |
80
+ | `/fire-3-execute` | Every breath boundary | Phase progress + breath status + executor results |
81
+ | `/fire-debug` | Every debug cycle | Hypothesis + test results + evidence collected |
82
+
83
+ ### Recitation Size Budget
84
+
85
+ Keep recitation blocks **under 30 lines**. If state is larger, summarize:
86
+
87
+ ```
88
+ MAX_RECITATION_LINES = 30
89
+
90
+ compose_recitation():
91
+ block = []
92
+ block += current_task (max 5 lines)
93
+ block += progress_checklist (max 8 lines)
94
+ block += active_approach (max 5 lines)
95
+ block += key_decisions (max 5 lines, last 3 only)
96
+ block += blockers (max 3 lines)
97
+ block += health_state (max 4 lines)
98
+
99
+ IF block.lines > 30:
100
+ compress: combine completed tasks into "X/Y tasks complete"
101
+ compress: keep only most recent 2 decisions
102
+ ```
103
+
104
+ ---
105
+
106
+ ## 2. Cache-Friendly Ordering
107
+
108
+ ### Problem
109
+
110
+ LLM inference uses KV-cache to avoid recomputing attention for unchanged prefix tokens. If the prompt structure changes between iterations, the cache is invalidated and costs increase.
111
+
112
+ ### Solution
113
+
114
+ Structure the context so that **stable content comes first** (system prompt, project context, skills) and **dynamic content comes last** (current iteration state, recitation block).
115
+
116
+ ### Optimal Context Layout
117
+
118
+ ```
119
+ ┌────────────────────────────────────────────────────┐
120
+ │ STABLE PREFIX (rarely changes — high cache hit) │
121
+ │ │
122
+ │ 1. System prompt / CLAUDE.md │
123
+ │ 2. Project context (VISION.md summary) │
124
+ │ 3. Skills library references (loaded at start) │
125
+ │ 4. Plan context (BLUEPRINT.md — stable during execution) │
126
+ │ │
127
+ ├────────────────────────────────────────────────────┤
128
+ │ SEMI-STABLE MIDDLE (changes less frequently) │
129
+ │ │
130
+ │ 5. CONSCIENCE.md snapshot │
131
+ │ 6. DTG micro-instructions (change per task) │
132
+ │ 7. Error classification state │
133
+ │ │
134
+ ├────────────────────────────────────────────────────┤
135
+ │ DYNAMIC SUFFIX (changes every iteration) │
136
+ │ │
137
+ │ 8. Recitation block (rewritten each iteration) │
138
+ │ 9. Current iteration output │
139
+ │ 10. Error messages / test results │
140
+ │ 11. User messages │
141
+ │ │
142
+ └────────────────────────────────────────────────────┘
143
+ ```
144
+
145
+ ### Cache-Friendly Practices
146
+
147
+ | Practice | Benefit |
148
+ |----------|---------|
149
+ | Load skills at start, don't re-search | Stable prefix |
150
+ | Use append-only loop file | New data at end only |
151
+ | Don't reformat unchanged sections | Preserves token sequence |
152
+ | Put recitation block at consistent position | Predictable structure |
153
+
154
+ ### Anti-Patterns (Cache-Hostile)
155
+
156
+ | Anti-Pattern | Problem |
157
+ |-------------|---------|
158
+ | Re-reading entire files each iteration | Bloats context with duplicate data |
159
+ | Changing prompt structure between iterations | Invalidates cache |
160
+ | Inserting new content in the middle | Shifts all subsequent tokens |
161
+ | Including full file contents when only a section changed | Wastes context space |
162
+
163
+ ---
164
+
165
+ ## 3. Context Exclusion (.powerignore)
166
+
167
+ ### Problem
168
+
169
+ Large codebases contain many files irrelevant to the current task. Reading them wastes context. Build artifacts, node_modules, generated files, and large data files are especially wasteful.
170
+
171
+ ### Solution
172
+
173
+ A `.powerignore` file (similar to `.gitignore`) tells Dominion Flow which files and directories to exclude from context when exploring the codebase.
174
+
175
+ ### .powerignore Format
176
+
177
+ ```gitignore
178
+ # Build artifacts
179
+ dist/
180
+ build/
181
+ .next/
182
+ out/
183
+
184
+ # Dependencies
185
+ node_modules/
186
+ vendor/
187
+ .venv/
188
+
189
+ # Generated files
190
+ *.min.js
191
+ *.min.css
192
+ *.map
193
+ *.lock
194
+ package-lock.json
195
+ yarn.lock
196
+
197
+ # Large data
198
+ *.sql.bak
199
+ *.dump
200
+ seeds/
201
+ fixtures/large-*
202
+
203
+ # IDE and OS
204
+ .vscode/
205
+ .idea/
206
+ .DS_Store
207
+ Thumbs.db
208
+
209
+ # Documentation (unless specifically needed)
210
+ docs/api-reference/
211
+ CHANGELOG.md
212
+
213
+ # Test snapshots (read only when testing)
214
+ __snapshots__/
215
+
216
+ # Dominion Flow artifacts (don't read our own tracking files during execution)
217
+ .planning/loops/
218
+ .planning/research/
219
+ ```
220
+
221
+ ### How .powerignore Is Used
222
+
223
+ ```
224
+ WHEN Dominion Flow reads files (in any command):
225
+
226
+ IF .powerignore exists in project root:
227
+ exclusions = parse_powerignore(".powerignore")
228
+
229
+ APPLY exclusions to:
230
+ - /fire-map-codebase (exclude from initial scan)
231
+ - /fire-discover (exclude from pattern search)
232
+ - /fire-execute-plan (exclude from context loading)
233
+ - /fire-loop (exclude from iteration file reads)
234
+ - Any glob/grep operations during execution
235
+
236
+ NEVER exclude:
237
+ - Files explicitly listed in BLUEPRINT.md task files
238
+ - Files referenced in error messages
239
+ - Files the user specifically asks about
240
+ ```
241
+
242
+ ### Dynamic Exclusion
243
+
244
+ During execution, Dominion Flow can dynamically exclude files that aren't relevant:
245
+
246
+ ```
247
+ dynamic_exclude(task):
248
+ IF task.type == "frontend":
249
+ exclude: src/api/**, prisma/**, src/models/**
250
+ reason: "Backend files not relevant to frontend task"
251
+
252
+ IF task.type == "backend":
253
+ exclude: src/components/**, src/app/**, public/**
254
+ reason: "Frontend files not relevant to backend task"
255
+
256
+ IF task.type == "testing":
257
+ include everything (tests may touch any file)
258
+ ```
259
+
260
+ ---
261
+
262
+ ## Context Budget Tracking
263
+
264
+ ### Awareness of Context Usage
265
+
266
+ ```
267
+ track_context_usage():
268
+ estimated_tokens = {
269
+ system_prompt: ~2000 tokens (stable),
270
+ project_context: ~1000 tokens (stable),
271
+ plan_context: ~500 tokens (stable per plan),
272
+ skills_loaded: ~300 tokens per skill,
273
+ recitation_block: ~200 tokens (controlled),
274
+ iteration_history: ~100 tokens per iteration,
275
+ file_contents: variable (biggest consumer),
276
+ error_messages: variable
277
+ }
278
+
279
+ total_estimate = sum(estimated_tokens)
280
+ context_limit = 200000 # approximate
281
+
282
+ IF total_estimate > context_limit * 0.7:
283
+ WARNING: "Context 70% full — consider Sabbath Rest"
284
+
285
+ IF total_estimate > context_limit * 0.85:
286
+ CRITICAL: "Context 85% full — trigger Sabbath Rest"
287
+ ```
288
+
289
+ ### Context Hygiene Rules
290
+
291
+ | Rule | Purpose |
292
+ |------|---------|
293
+ | Don't re-read files already in context | Prevents duplication |
294
+ | Summarize large file reads (extract relevant section) | Reduces token usage |
295
+ | Clear iteration history older than 5 iterations | Keeps history manageable |
296
+ | Use recitation instead of keeping full history | Fixed-size state summary |
297
+ | Exclude build artifacts and generated files | Removes noise |
298
+
299
+ ---
300
+
301
+ ## Integration with Dominion Flow
302
+
303
+ ### /fire-loop Integration
304
+
305
+ ```markdown
306
+ Step 6.5 (NEW): Context Engineering Setup
307
+
308
+ 1. Load .powerignore if present
309
+ 2. Set up recitation template for the task
310
+ 3. Search skills library once (cache the results)
311
+ 4. Establish baseline output volume for circuit breaker
312
+
313
+ Step 7 (Execute Task) — Enhanced:
314
+
315
+ BEFORE each iteration:
316
+ 1. Compose recitation block from loop state
317
+ 2. Inject recitation into context
318
+ 3. Apply .powerignore to any file reads
319
+ 4. Track context usage estimate
320
+ ```
321
+
322
+ ### /fire-execute-plan Integration
323
+
324
+ ```markdown
325
+ Step 4.5 (NEW): Context Setup
326
+
327
+ 1. Load .powerignore
328
+ 2. Pre-load plan-specific skills (DTG)
329
+ 3. Set up recitation template for task tracking
330
+
331
+ Per-task execution:
332
+ 1. Recite plan progress before each task
333
+ 2. Apply dynamic exclusion based on task type
334
+ 3. Monitor context usage
335
+ ```
336
+
337
+ ---
338
+
339
+ ## 4. Compaction Stop-Signal Preservation
340
+
341
+ > **Research basis (v6.0):** JetBrains "Cutting Through the Noise" (Dec 2025) found that LLM summarization during compaction smooths over stop signals — errors, BLOCKED indicators, and failure counts get lost. This extends agent runs by ~15%, often past the point where they should have stopped.
342
+
343
+ ### Problem
344
+
345
+ When context approaches its limit, the system compacts (summarizes) earlier messages. Standard summarization optimizes for coherence, which means it:
346
+ - **Softens error messages** — "the build failed with 3 errors" becomes "there were some issues"
347
+ - **Drops failure counts** — "attempted 5 times, all failed" becomes "multiple attempts were made"
348
+ - **Smooths BLOCKED indicators** — explicit stop signals get paraphrased into continuable-sounding text
349
+ - **Loses verbatim error strings** — the exact error that would trigger pattern matching disappears
350
+
351
+ ### Solution: Preserve Before Compact
352
+
353
+ ```
354
+ WHEN compaction triggers (context > 85% full):
355
+
356
+ BEFORE compaction:
357
+ 1. Extract and tag for preservation:
358
+ - All error messages (verbatim, in code blocks)
359
+ - All "BLOCKED" or "STUCK" indicators
360
+ - Failed attempt count per approach
361
+ - Explicit "should stop" signals
362
+ - Circuit breaker state (WARNING/TRIPPED)
363
+ - Approaches already tried (prevent re-investigation)
364
+
365
+ 2. Format as preservation block:
366
+ ```
367
+ ## Preserved Stop Signals (DO NOT SUMMARIZE)
368
+ - ERROR: "{exact error message}"
369
+ - BLOCKED: {reason}
370
+ - FAILED ATTEMPTS: {count} — approaches: {list}
371
+ - CIRCUIT BREAKER: {state}
372
+ - TRIED AND FAILED: {approach 1}, {approach 2}, ...
373
+ ```
374
+
375
+ AFTER compaction:
376
+ 3. Verify preserved signals exist in compacted context
377
+ 4. If any signals were lost: re-inject the preservation block
378
+ 5. The preservation block must appear AFTER the summary, not inside it
379
+ ```
380
+
381
+ ### Integration Points
382
+
383
+ | Command | How to Apply |
384
+ |---------|-------------|
385
+ | `/fire-loop` | Before Sabbath Rest snapshot, extract stop signals |
386
+ | `/fire-debug` | Before checkpoint, preserve eliminated hypotheses verbatim |
387
+ | `/fire-3-execute` | Before breath summary, preserve blocker details |
388
+ | Any long session | If compaction triggers mid-task, preserve current error state |
389
+
390
+ ### Anti-Pattern: The Smooth Summary
391
+
392
+ ```
393
+ BAD (after compaction):
394
+ "The authentication system was explored with several approaches.
395
+ Some challenges were encountered but progress was made."
396
+
397
+ GOOD (after compaction):
398
+ "Auth explored. 3 approaches tried, all failed:
399
+ 1. JWT middleware — TypeError: jwt.verify is not a function
400
+ 2. Session-based — BLOCKED: Redis not available in test env
401
+ 3. OAuth — 401 from provider, credentials expired
402
+ CIRCUIT BREAKER: WARNING (stall_count: 3)
403
+ DO NOT retry these approaches without new information."
404
+ ```
405
+
406
+ ### Actionable Error Preservation Protocol (v10.0)
407
+
408
+ > **Research basis (v10.0):** Manus AI "Context Engineering for AI Agents" (Feb 2026) —
409
+ > error preservation during context compaction improved recovery rate by preventing
410
+ > repeated failed approaches. Errors are the most valuable context — they tell you
411
+ > what NOT to do.
412
+
413
+ **MANDATORY: Before any compaction event (Sabbath Rest, /compact, auto-compact):**
414
+
415
+ ```
416
+ 1. SCAN current context for:
417
+ a. Error messages (grep for ERROR, FAIL, TypeError, etc.)
418
+ b. Approach descriptions that were tried
419
+ c. Circuit breaker state and counters
420
+ d. Confidence scores from last 3 iterations
421
+ e. Files that were modified (git diff --name-only)
422
+
423
+ 2. WRITE preservation block to loop file or .planning/context-preserved.md:
424
+
425
+ ## Context Preservation Block (auto-generated)
426
+ timestamp: {ISO timestamp}
427
+ trigger: {compaction | sabbath_rest | manual}
428
+
429
+ ### Errors (verbatim, do NOT paraphrase)
430
+ ```
431
+ {exact error message 1}
432
+ {exact error message 2}
433
+ ```
434
+
435
+ ### Failed Approaches (DO NOT RETRY without new information)
436
+ 1. {approach} — {why it failed}
437
+ 2. {approach} — {why it failed}
438
+
439
+ ### Circuit Breaker State
440
+ stall: {N}/{threshold} | spin: {N}/{threshold} | decline: {N}%
441
+
442
+ ### Working State
443
+ - Last successful change: {file:line}
444
+ - Current hypothesis: {what was being tried}
445
+ - Confidence: {score}/100
446
+
447
+ 3. VERIFY the preservation block is included in the compacted context
448
+ IF missing: re-inject it as the first thing after compaction
449
+ ```
450
+
451
+ **Key principle:** Errors are more valuable than successes for context. A success
452
+ tells you what worked (which you can rediscover). An error tells you what NOT to do
453
+ (which you'll waste iterations rediscovering without preservation).
454
+
455
+ ---
456
+
457
+ ## 5. Difficulty-Aware Routing Tiers (v7.0)
458
+
459
+ > **Research basis:** Difficulty-Aware Agent Orchestration (Sep 2025) — +11.21% accuracy at 64% cost
460
+
461
+ Not every task needs the full pipeline. Routing by difficulty saves context and time:
462
+
463
+ | Tier | Steps Skipped | Token Savings | Example Tasks |
464
+ |------|--------------|---------------|---------------|
465
+ | SIMPLE | 7.1 (episodic), 8.5 (directives), 8.8 (rewards) | ~500 tokens/iter | Typos, renames, config changes |
466
+ | MODERATE | None | 0 | Multi-file features, partial skill match |
467
+ | COMPLEX | None + adds double-check | +200 tokens/iter | Architecture changes, security, 6+ files |
468
+
469
+ **Classification signals:**
470
+ - File count estimate (1 = SIMPLE, 2-5 = MODERATE, 6+ = COMPLEX)
471
+ - Skill match quality (exact = SIMPLE, partial = MODERATE, none = COMPLEX)
472
+ - Security/architecture implications → always COMPLEX
473
+ - Cross-cutting concerns → always COMPLEX
474
+
475
+ **Cost analysis:** ~60% of tasks in typical sessions are SIMPLE. Skipping 3 steps saves ~500 tokens per iteration, which compounds across 5-10 iterations per task.
476
+
477
+ ---
478
+
479
+ ---
480
+
481
+ ## 6. Active Context Compression (v10.0 — ACON)
482
+
483
+ > **Research basis (v10.0):** ACON "Active Context Compression" (2025-2026, score 4.85) —
484
+ > 26-54% token reduction via selective compression. Instead of treating all context equally,
485
+ > ACON scores each context segment by relevance to the current task and compresses
486
+ > low-relevance segments aggressively while preserving high-relevance segments verbatim.
487
+ > Focus (ACL 2025) adds "active forgetting" — proactively dropping irrelevant context
488
+ > rather than waiting for the window to fill.
489
+
490
+ ### Problem
491
+
492
+ Current context management (recitation + .powerignore + cache ordering) is passive — it
493
+ controls what enters context but doesn't compress what's already there. As iterations
494
+ accumulate, even well-structured context fills the window with diminishing-relevance content.
495
+
496
+ ### Solution: Relevance-Scored Compression
497
+
498
+ ```
499
+ EVERY 3 iterations (not every iteration — compression has overhead):
500
+
501
+ 1. SCORE each context segment by relevance to current task:
502
+ - Current task description → CRITICAL (never compress)
503
+ - Error messages from last 2 iterations → HIGH (preserve verbatim)
504
+ - Recitation block → HIGH (preserve verbatim)
505
+ - Skills loaded for current task → MEDIUM (compress to key points)
506
+ - File contents read >3 iterations ago → LOW (compress to summary)
507
+ - Iteration history older than 5 iterations → LOW (compress to one line each)
508
+ - Successful approach details (already committed) → LOW (compress to commit hash)
509
+
510
+ 2. COMPRESS based on score:
511
+ - CRITICAL: keep 100% — do not touch
512
+ - HIGH: keep 100% — preserve verbatim
513
+ - MEDIUM: keep ~50% — extract key patterns, drop examples
514
+ - LOW: keep ~15% — one-line summary per segment
515
+
516
+ 3. INJECT compressed context as replacement recitation block
517
+
518
+ Token savings formula:
519
+ savings = sum(segment_tokens * (1 - keep_percentage))
520
+ Expected: 26-54% reduction per compression pass
521
+ ```
522
+
523
+ ### Active Forgetting Triggers (Focus)
524
+
525
+ Don't wait for context to fill — proactively drop content when:
526
+
527
+ ```
528
+ FORGET when:
529
+ - A file was read but never referenced again for 3+ iterations
530
+ - A skill was loaded but not applied (no citation in code)
531
+ - An error was resolved (committed fix exists) — compress to one-line summary
532
+ - An approach was tried and abandoned — keep only the failure reason, drop details
533
+
534
+ NEVER forget:
535
+ - Current task description
536
+ - Error messages from current/last iteration
537
+ - Circuit breaker state
538
+ - Approaches that FAILED (what NOT to do is more valuable than what succeeded)
539
+ - Files actively being edited in current iteration
540
+ ```
541
+
542
+ ### Integration with Sabbath Rest
543
+
544
+ ACON compression extends the useful life of a context window before Sabbath Rest triggers:
545
+
546
+ ```
547
+ WITHOUT ACON: ~15 iterations before context rot → Sabbath Rest
548
+ WITH ACON: ~25 iterations before context rot → Sabbath Rest
549
+
550
+ Mechanism: ACON compression at iterations 3, 6, 9, 12, 15, 18, 21, 24...
551
+ Each pass recovers 26-54% of accumulated low-value context.
552
+ The Sabbath Rest threshold (output decline >70%) is reached later because
553
+ the output quality degrades more slowly with compressed context.
554
+ ```
555
+
556
+ ### PAACE Integration (Plan-Aware Context)
557
+
558
+ > **Research basis (v10.0):** PAACE "Plan-Aware Agent Context Engineering" (2025, score 4.70) —
559
+ > context compression should be plan-aware. Segments related to upcoming plan tasks should
560
+ > be preserved even if not currently relevant, because they'll be needed soon.
561
+
562
+ ```
563
+ WHEN compressing context, check BLUEPRINT.md for upcoming tasks:
564
+
565
+ upcoming_tasks = extract_next_3_tasks(BLUEPRINT.md)
566
+ upcoming_keywords = extract_keywords(upcoming_tasks)
567
+
568
+ FOR each context segment scored LOW:
569
+ IF segment contains keywords matching upcoming tasks:
570
+ → Upgrade to MEDIUM (keep ~50%) — will be needed soon
571
+ → Tag: "Preserved for upcoming Task {N}"
572
+ ```
573
+
574
+ ---
575
+
576
+ ## References
577
+
578
+ - **Recitation:** Manus AI "todo.md rewrite" pattern (restate plan each iteration)
579
+ - **Cache optimization:** Manus AI KV-cache strategy (87% cache hit rate, append-only)
580
+ - **Context exclusion:** Bolt.new `.bolt/ignore` pattern
581
+ - **Compaction safety:** JetBrains "Cutting Through the Noise" (Dec 2025) — summarization hides stop signals
582
+ - **Difficulty routing:** Difficulty-Aware Agent Orchestration (Sep 2025) — route by complexity
583
+ - **Active compression:** ACON (2025-2026) — 26-54% token reduction via relevance-scored compression
584
+ - **Plan-aware context:** PAACE (2025) — preserve upcoming-task-relevant context during compression
585
+ - **Active forgetting:** Focus (ACL 2025) — proactively drop irrelevant context
586
+ - **Related:** `references/circuit-breaker.md` — output decline threshold uses context awareness
587
+ - **Related:** `references/error-classification.md` — DEGRADED state is context-rot driven