wogiflow 1.6.3 → 1.7.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 (199) hide show
  1. package/.claude/commands/wogi-compact.md +49 -0
  2. package/.claude/commands/wogi-eval.md +135 -0
  3. package/.claude/commands/wogi-morning.md +24 -1
  4. package/.claude/commands/wogi-onboard.md +46 -0
  5. package/.claude/commands/wogi-setup-stack.md +66 -0
  6. package/.claude/commands/wogi-start.md +71 -1
  7. package/.claude/rules/README.md +60 -0
  8. package/.claude/rules/architecture/component-reuse.md +38 -0
  9. package/.claude/rules/architecture/document-structure.md +76 -0
  10. package/.claude/rules/architecture/dual-repo-management.md +169 -0
  11. package/.claude/rules/architecture/feature-refactoring-cleanup.md +87 -0
  12. package/.claude/rules/architecture/model-management.md +35 -0
  13. package/.claude/rules/architecture/self-maintenance.md +87 -0
  14. package/.claude/rules/code-style/naming-conventions.md +55 -0
  15. package/.claude/rules/security/security-patterns.md +176 -0
  16. package/.claude/skills/figma-analyzer/knowledge/learnings.md +11 -0
  17. package/.workflow/specs/architecture.md.template +24 -0
  18. package/.workflow/specs/stack.md.template +33 -0
  19. package/.workflow/specs/testing.md.template +36 -0
  20. package/.workflow/templates/prompts/gemini-flash.yaml +42 -0
  21. package/.workflow/templates/prompts/gpt4o.yaml +44 -0
  22. package/.workflow/templates/prompts/haiku.yaml +42 -0
  23. package/.workflow/templates/prompts/opus.yaml +45 -0
  24. package/.workflow/templates/prompts/sonnet.yaml +44 -0
  25. package/package.json +1 -1
  26. package/scripts/flow +3 -0
  27. package/scripts/flow-best-of-n.js +432 -0
  28. package/scripts/flow-community-sync.js +469 -0
  29. package/scripts/flow-eval-judge.js +388 -0
  30. package/scripts/flow-eval.js +430 -0
  31. package/scripts/flow-model-router.js +10 -0
  32. package/scripts/flow-proactive-compact.js +341 -0
  33. package/scripts/flow-prompt-template.js +517 -0
  34. package/scripts/flow-revision-tracker.js +258 -0
  35. package/scripts/flow-skill-freshness.js +250 -0
  36. package/scripts/flow-skill-generator.js +237 -36
  37. package/scripts/flow-stack-wizard.js +17 -1
  38. package/scripts/flow-stats-collector.js +534 -0
  39. package/scripts/flow-sync-anonymizer.js +254 -0
  40. package/scripts/flow-task-checkpoint.js +497 -0
  41. package/scripts/flow-utils.js +47 -11
  42. package/scripts/hooks/core/session-context.js +12 -0
  43. package/scripts/hooks/core/session-end.js +12 -0
  44. package/scripts/hooks/core/task-completed.js +32 -0
  45. package/templates/skills/angular/knowledge/anti-patterns.md +34 -0
  46. package/templates/skills/angular/knowledge/conventions.md +15 -0
  47. package/templates/skills/angular/knowledge/learnings.md +5 -0
  48. package/templates/skills/angular/knowledge/patterns.md +35 -0
  49. package/templates/skills/angular/skill.md +60 -0
  50. package/templates/skills/cypress/knowledge/anti-patterns.md +20 -0
  51. package/templates/skills/cypress/knowledge/conventions.md +14 -0
  52. package/templates/skills/cypress/knowledge/learnings.md +5 -0
  53. package/templates/skills/cypress/knowledge/patterns.md +39 -0
  54. package/templates/skills/cypress/skill.md +59 -0
  55. package/templates/skills/django/knowledge/anti-patterns.md +20 -0
  56. package/templates/skills/django/knowledge/conventions.md +15 -0
  57. package/templates/skills/django/knowledge/learnings.md +5 -0
  58. package/templates/skills/django/knowledge/patterns.md +40 -0
  59. package/templates/skills/django/skill.md +59 -0
  60. package/templates/skills/docker/knowledge/anti-patterns.md +34 -0
  61. package/templates/skills/docker/knowledge/conventions.md +16 -0
  62. package/templates/skills/docker/knowledge/learnings.md +5 -0
  63. package/templates/skills/docker/knowledge/patterns.md +48 -0
  64. package/templates/skills/docker/skill.md +60 -0
  65. package/templates/skills/drizzle/knowledge/anti-patterns.md +20 -0
  66. package/templates/skills/drizzle/knowledge/conventions.md +14 -0
  67. package/templates/skills/drizzle/knowledge/learnings.md +5 -0
  68. package/templates/skills/drizzle/knowledge/patterns.md +38 -0
  69. package/templates/skills/drizzle/skill.md +59 -0
  70. package/templates/skills/eslint/knowledge/anti-patterns.md +20 -0
  71. package/templates/skills/eslint/knowledge/conventions.md +14 -0
  72. package/templates/skills/eslint/knowledge/learnings.md +5 -0
  73. package/templates/skills/eslint/knowledge/patterns.md +26 -0
  74. package/templates/skills/eslint/skill.md +58 -0
  75. package/templates/skills/express/knowledge/anti-patterns.md +34 -0
  76. package/templates/skills/express/knowledge/conventions.md +15 -0
  77. package/templates/skills/express/knowledge/learnings.md +5 -0
  78. package/templates/skills/express/knowledge/patterns.md +63 -0
  79. package/templates/skills/express/skill.md +61 -0
  80. package/templates/skills/fastapi/knowledge/anti-patterns.md +20 -0
  81. package/templates/skills/fastapi/knowledge/conventions.md +15 -0
  82. package/templates/skills/fastapi/knowledge/learnings.md +5 -0
  83. package/templates/skills/fastapi/knowledge/patterns.md +47 -0
  84. package/templates/skills/fastapi/skill.md +59 -0
  85. package/templates/skills/fastify/knowledge/anti-patterns.md +20 -0
  86. package/templates/skills/fastify/knowledge/conventions.md +14 -0
  87. package/templates/skills/fastify/knowledge/learnings.md +5 -0
  88. package/templates/skills/fastify/knowledge/patterns.md +42 -0
  89. package/templates/skills/fastify/skill.md +59 -0
  90. package/templates/skills/flask/knowledge/anti-patterns.md +20 -0
  91. package/templates/skills/flask/knowledge/conventions.md +15 -0
  92. package/templates/skills/flask/knowledge/learnings.md +5 -0
  93. package/templates/skills/flask/knowledge/patterns.md +41 -0
  94. package/templates/skills/flask/skill.md +59 -0
  95. package/templates/skills/graphql/knowledge/anti-patterns.md +19 -0
  96. package/templates/skills/graphql/knowledge/conventions.md +14 -0
  97. package/templates/skills/graphql/knowledge/learnings.md +5 -0
  98. package/templates/skills/graphql/knowledge/patterns.md +22 -0
  99. package/templates/skills/graphql/skill.md +58 -0
  100. package/templates/skills/hono/knowledge/anti-patterns.md +20 -0
  101. package/templates/skills/hono/knowledge/conventions.md +14 -0
  102. package/templates/skills/hono/knowledge/learnings.md +5 -0
  103. package/templates/skills/hono/knowledge/patterns.md +23 -0
  104. package/templates/skills/hono/skill.md +58 -0
  105. package/templates/skills/jest/knowledge/anti-patterns.md +35 -0
  106. package/templates/skills/jest/knowledge/conventions.md +15 -0
  107. package/templates/skills/jest/knowledge/learnings.md +5 -0
  108. package/templates/skills/jest/knowledge/patterns.md +42 -0
  109. package/templates/skills/jest/skill.md +60 -0
  110. package/templates/skills/mocha/knowledge/anti-patterns.md +20 -0
  111. package/templates/skills/mocha/knowledge/conventions.md +14 -0
  112. package/templates/skills/mocha/knowledge/learnings.md +5 -0
  113. package/templates/skills/mocha/knowledge/patterns.md +26 -0
  114. package/templates/skills/mocha/skill.md +58 -0
  115. package/templates/skills/mongoose/knowledge/anti-patterns.md +20 -0
  116. package/templates/skills/mongoose/knowledge/conventions.md +15 -0
  117. package/templates/skills/mongoose/knowledge/learnings.md +5 -0
  118. package/templates/skills/mongoose/knowledge/patterns.md +37 -0
  119. package/templates/skills/mongoose/skill.md +59 -0
  120. package/templates/skills/nestjs/knowledge/anti-patterns.md +33 -0
  121. package/templates/skills/nestjs/knowledge/conventions.md +15 -0
  122. package/templates/skills/nestjs/knowledge/learnings.md +5 -0
  123. package/templates/skills/nestjs/knowledge/patterns.md +45 -0
  124. package/templates/skills/nestjs/skill.md +60 -0
  125. package/templates/skills/next/knowledge/anti-patterns.md +47 -0
  126. package/templates/skills/next/knowledge/conventions.md +16 -0
  127. package/templates/skills/next/knowledge/learnings.md +5 -0
  128. package/templates/skills/next/knowledge/patterns.md +62 -0
  129. package/templates/skills/next/skill.md +62 -0
  130. package/templates/skills/playwright/knowledge/anti-patterns.md +34 -0
  131. package/templates/skills/playwright/knowledge/conventions.md +14 -0
  132. package/templates/skills/playwright/knowledge/learnings.md +5 -0
  133. package/templates/skills/playwright/knowledge/patterns.md +41 -0
  134. package/templates/skills/playwright/skill.md +60 -0
  135. package/templates/skills/prisma/knowledge/anti-patterns.md +34 -0
  136. package/templates/skills/prisma/knowledge/conventions.md +15 -0
  137. package/templates/skills/prisma/knowledge/learnings.md +5 -0
  138. package/templates/skills/prisma/knowledge/patterns.md +52 -0
  139. package/templates/skills/prisma/skill.md +61 -0
  140. package/templates/skills/pytest/knowledge/anti-patterns.md +20 -0
  141. package/templates/skills/pytest/knowledge/conventions.md +15 -0
  142. package/templates/skills/pytest/knowledge/learnings.md +5 -0
  143. package/templates/skills/pytest/knowledge/patterns.md +49 -0
  144. package/templates/skills/pytest/skill.md +59 -0
  145. package/templates/skills/react/knowledge/anti-patterns.md +48 -0
  146. package/templates/skills/react/knowledge/conventions.md +16 -0
  147. package/templates/skills/react/knowledge/learnings.md +5 -0
  148. package/templates/skills/react/knowledge/patterns.md +57 -0
  149. package/templates/skills/react/skill.md +62 -0
  150. package/templates/skills/sequelize/knowledge/anti-patterns.md +20 -0
  151. package/templates/skills/sequelize/knowledge/conventions.md +14 -0
  152. package/templates/skills/sequelize/knowledge/learnings.md +5 -0
  153. package/templates/skills/sequelize/knowledge/patterns.md +41 -0
  154. package/templates/skills/sequelize/skill.md +59 -0
  155. package/templates/skills/sqlalchemy/knowledge/anti-patterns.md +20 -0
  156. package/templates/skills/sqlalchemy/knowledge/conventions.md +14 -0
  157. package/templates/skills/sqlalchemy/knowledge/learnings.md +5 -0
  158. package/templates/skills/sqlalchemy/knowledge/patterns.md +40 -0
  159. package/templates/skills/sqlalchemy/skill.md +59 -0
  160. package/templates/skills/svelte/knowledge/anti-patterns.md +20 -0
  161. package/templates/skills/svelte/knowledge/conventions.md +14 -0
  162. package/templates/skills/svelte/knowledge/learnings.md +5 -0
  163. package/templates/skills/svelte/knowledge/patterns.md +38 -0
  164. package/templates/skills/svelte/skill.md +59 -0
  165. package/templates/skills/tailwindcss/knowledge/anti-patterns.md +34 -0
  166. package/templates/skills/tailwindcss/knowledge/conventions.md +15 -0
  167. package/templates/skills/tailwindcss/knowledge/learnings.md +5 -0
  168. package/templates/skills/tailwindcss/knowledge/patterns.md +39 -0
  169. package/templates/skills/tailwindcss/skill.md +60 -0
  170. package/templates/skills/terraform/knowledge/anti-patterns.md +36 -0
  171. package/templates/skills/terraform/knowledge/conventions.md +16 -0
  172. package/templates/skills/terraform/knowledge/learnings.md +5 -0
  173. package/templates/skills/terraform/knowledge/patterns.md +50 -0
  174. package/templates/skills/terraform/skill.md +60 -0
  175. package/templates/skills/typeorm/knowledge/anti-patterns.md +20 -0
  176. package/templates/skills/typeorm/knowledge/conventions.md +14 -0
  177. package/templates/skills/typeorm/knowledge/learnings.md +5 -0
  178. package/templates/skills/typeorm/knowledge/patterns.md +25 -0
  179. package/templates/skills/typeorm/skill.md +58 -0
  180. package/templates/skills/typescript/knowledge/anti-patterns.md +34 -0
  181. package/templates/skills/typescript/knowledge/conventions.md +15 -0
  182. package/templates/skills/typescript/knowledge/learnings.md +5 -0
  183. package/templates/skills/typescript/knowledge/patterns.md +41 -0
  184. package/templates/skills/typescript/skill.md +60 -0
  185. package/templates/skills/vitest/knowledge/anti-patterns.md +19 -0
  186. package/templates/skills/vitest/knowledge/conventions.md +14 -0
  187. package/templates/skills/vitest/knowledge/learnings.md +5 -0
  188. package/templates/skills/vitest/knowledge/patterns.md +40 -0
  189. package/templates/skills/vitest/skill.md +59 -0
  190. package/templates/skills/vue/knowledge/anti-patterns.md +34 -0
  191. package/templates/skills/vue/knowledge/conventions.md +15 -0
  192. package/templates/skills/vue/knowledge/learnings.md +5 -0
  193. package/templates/skills/vue/knowledge/patterns.md +40 -0
  194. package/templates/skills/vue/skill.md +60 -0
  195. package/templates/skills/zod/knowledge/anti-patterns.md +20 -0
  196. package/templates/skills/zod/knowledge/conventions.md +14 -0
  197. package/templates/skills/zod/knowledge/learnings.md +5 -0
  198. package/templates/skills/zod/knowledge/patterns.md +41 -0
  199. package/templates/skills/zod/skill.md +59 -0
@@ -123,6 +123,55 @@ With smart compaction enabled (`config.smartCompaction.enabled`), context is man
123
123
 
124
124
  This means fixed thresholds are less relevant - compaction happens when actually needed based on the specific task.
125
125
 
126
+ ### Proactive Phase-Boundary Compaction (v2.3)
127
+
128
+ With proactive compaction enabled (`config.proactiveCompaction.enabled`), WogiFlow compacts between task phases:
129
+
130
+ - **Phase boundaries**: After explore, spec, each scenario, criteria check, validation
131
+ - **Trigger threshold**: Default 75% context usage (configurable via `triggerThreshold`)
132
+ - **Task checkpoints**: Full task state saved to `.workflow/state/task-checkpoint.json` at every phase boundary
133
+ - **Auto-compact recovery**: If Claude's auto-compact fires, checkpoint enables lossless recovery
134
+
135
+ **How it works:**
136
+ 1. At each phase boundary, `/wogi-start` saves a task checkpoint (task ID, phase, scenarios, files changed)
137
+ 2. If context exceeds the trigger threshold, proactive compaction fires before the next phase
138
+ 3. If Claude auto-compacts (at ~95%), session resume reads the checkpoint and restores full state
139
+
140
+ **Recovery flow:**
141
+ ```
142
+ Auto-compact fires at ~95% → Session resumes with compressed context
143
+ → /wogi-start detects checkpoint exists → Reads task-checkpoint.json
144
+ → Displays: "Auto-compact detected. Restoring task state from checkpoint..."
145
+ → Continues from the exact phase where it left off
146
+ ```
147
+
148
+ **Config** (`config.proactiveCompaction`):
149
+ ```json
150
+ {
151
+ "enabled": true,
152
+ "triggerThreshold": 0.75,
153
+ "useHaiku": true,
154
+ "phases": ["exploring", "spec_review", "scenario", "criteria_check", "validating"]
155
+ }
156
+ ```
157
+
158
+ **CLI commands:**
159
+ ```bash
160
+ # Check if compaction needed at a phase
161
+ node scripts/flow-proactive-compact.js check exploring 0.78 wf-a1b2c3d4
162
+
163
+ # Show current config
164
+ node scripts/flow-proactive-compact.js config
165
+
166
+ # Generate compaction context from checkpoint
167
+ node scripts/flow-proactive-compact.js context
168
+
169
+ # View/manage checkpoints
170
+ node scripts/flow-task-checkpoint.js load
171
+ node scripts/flow-task-checkpoint.js check
172
+ node scripts/flow-task-checkpoint.js clear wf-a1b2c3d4
173
+ ```
174
+
126
175
  ### Legacy Fixed Thresholds
127
176
 
128
177
  If smart compaction is disabled, check context pressure status:
@@ -0,0 +1,135 @@
1
+ ---
2
+ description: "Evaluate WogiFlow task output quality with multi-judge scoring"
3
+ ---
4
+ Evaluate a completed task's output quality using multi-judge scoring (1 Opus + 2 Sonnet).
5
+
6
+ ## Usage
7
+
8
+ ```
9
+ /wogi-eval wf-XXXXXXXX Evaluate a specific task
10
+ /wogi-eval --batch --last 5 Evaluate the last 5 completed tasks
11
+ /wogi-eval --compare Show eval trend comparison
12
+ /wogi-eval --candidates Show tasks eligible for evaluation
13
+ ```
14
+
15
+ ## How It Works
16
+
17
+ 1. **Read the spec**: Load the task's acceptance criteria and requirements
18
+ 2. **Get the diff**: Find the commit and extract the implementation diff
19
+ 3. **Spawn 3 judge agents**: 1 Opus + 2 Sonnet (via Agent tool `model` parameter)
20
+ 4. **Score independently**: Each judge scores on 5 dimensions (1-10)
21
+ 5. **Take median**: Final score = median of 3 judges per dimension
22
+ 6. **Save results**: Store in `.workflow/evals/`
23
+
24
+ ## Scoring Dimensions
25
+
26
+ | Dimension | What It Measures |
27
+ |-----------|-----------------|
28
+ | Completeness | Did implementation address ALL acceptance criteria? |
29
+ | Accuracy | Is code correct, handling edge cases? |
30
+ | Workflow Compliance | Did it follow WogiFlow patterns (spec, criteria check, wiring, standards)? |
31
+ | Token Efficiency | How many tokens/iterations to reach passing state? |
32
+ | Quality | Code quality, readability, maintainability |
33
+
34
+ ## Execution Flow
35
+
36
+ ### Step 1: Prepare eval data
37
+
38
+ ```bash
39
+ node scripts/flow-eval.js prepare wf-XXXXXXXX
40
+ ```
41
+
42
+ This returns: spec content, implementation diff, iteration count, token estimate.
43
+
44
+ ### Step 2: Spawn judge agents
45
+
46
+ Launch 3 agents in parallel using the Agent tool:
47
+
48
+ ```
49
+ Agent(model: "opus", prompt: "<judge prompt with spec + diff>")
50
+ Agent(model: "sonnet", prompt: "<judge prompt with spec + diff>")
51
+ Agent(model: "sonnet", prompt: "<judge prompt with spec + diff>")
52
+ ```
53
+
54
+ Each judge receives the same prompt (from `buildJudgePrompt()` in `flow-eval-judge.js`) and scores independently.
55
+
56
+ ### Step 3: Aggregate scores
57
+
58
+ ```javascript
59
+ const { aggregateScores, parseJudgeResponse } = require('./scripts/flow-eval-judge');
60
+
61
+ // Parse each judge's response
62
+ const scores = judgeResponses.map(parseJudgeResponse).filter(Boolean);
63
+
64
+ // Take median per dimension
65
+ const result = aggregateScores(scores);
66
+ ```
67
+
68
+ ### Step 4: Save and display
69
+
70
+ ```javascript
71
+ const { saveEvalResult, formatEvalResults } = require('./scripts/flow-eval');
72
+ saveEvalResult({ taskId, aggregated: result, judgeResults: scores, model, taskType });
73
+ ```
74
+
75
+ ## Output Format
76
+
77
+ ```
78
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
79
+ 📊 EVAL RESULTS: wf-XXXXXXXX
80
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
81
+
82
+ Judges: 3 (1 Opus + 2 Sonnet) | Confidence: high
83
+
84
+ completeness ████████░░ 8/10
85
+ accuracy ███████░░░ 7/10
86
+ workflowCompliance █████████░ 9/10
87
+ tokenEfficiency ██████░░░░ 6/10
88
+ quality ████████░░ 8/10
89
+
90
+ Overall: 7.6/10 — PASS (threshold: 6)
91
+
92
+ Individual Judges:
93
+ Judge 1 (opus): Strong implementation, minor edge case gaps
94
+ Judge 2 (sonnet): Good workflow compliance, token usage could improve
95
+ Judge 3 (sonnet): Clean code, well-structured implementation
96
+
97
+ Saved: .workflow/evals/wf-XXXXXXXX-eval-2026-03-02T10-00-00.json
98
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
99
+ ```
100
+
101
+ ## Batch Mode
102
+
103
+ When running `--batch --last N`:
104
+ 1. Get the last N completed tasks from stats
105
+ 2. Evaluate each sequentially
106
+ 3. Display summary table
107
+
108
+ ```
109
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
110
+ 📊 BATCH EVAL RESULTS
111
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
112
+
113
+ Task Model Overall Comp Acc WF Tok Qual
114
+ wf-a1b2c3d4 opus-4-6 7.6 8 7 9 6 8
115
+ wf-e5f6a7b8 sonnet-4-6 6.8 7 7 8 5 7
116
+ wf-c9d0e1f2 opus-4-6 8.2 9 8 9 7 8
117
+
118
+ Average: 7.5/10
119
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
120
+ ```
121
+
122
+ ## Configuration
123
+
124
+ In `config.json`:
125
+ ```json
126
+ {
127
+ "eval": {
128
+ "judges": { "opus": 1, "sonnet": 2 },
129
+ "scoringDimensions": ["completeness", "accuracy", "workflowCompliance", "tokenEfficiency", "quality"],
130
+ "passingThreshold": 6
131
+ }
132
+ }
133
+ ```
134
+
135
+ ARGUMENTS: $ARGUMENTS
@@ -41,6 +41,11 @@ NEW RULES LEARNED (auto-promoted from patterns)
41
41
  → Fix now? Routes through /wogi-start with quality gates.
42
42
  → Dismiss? Grandfathers existing violations.
43
43
 
44
+ STALE SKILLS (documentation may be outdated)
45
+ 3 skills older than 90 days:
46
+ react (95 days), express (120 days), prisma (91 days)
47
+ → Run `/wogi-setup-stack --refresh-stale` to update.
48
+
44
49
  CHANGES SINCE LAST SESSION
45
50
  - 2 new commits
46
51
  - 1 new bug filed
@@ -141,8 +146,26 @@ Configuration in `.workflow/config.json`:
141
146
  "showBlockers": true,
142
147
  "showKeyContext": true,
143
148
  "showRuleViolations": true,
144
- "showAutoPromotedRules": true
149
+ "showAutoPromotedRules": true,
150
+ "showStaleSkills": true
145
151
  }
146
152
  ```
147
153
 
148
154
  Set `enabled: false` to disable this command.
155
+
156
+ ## Stale Skills Section (Implementation Details)
157
+
158
+ When `morningBriefing.showStaleSkills` is true, the morning briefing checks skill documentation freshness:
159
+
160
+ 1. Run `node scripts/flow-skill-freshness.js check` or call `getSkillFreshnessReport()` programmatically
161
+ 2. If any skills have `lastDocCheck` older than `config.skills.freshnessThreshold` days (default: 90):
162
+ - Display the skill names and ages
163
+ - Offer to run `/wogi-setup-stack --refresh-stale`
164
+ 3. If no stale skills, omit this section entirely
165
+
166
+ Configuration in `.workflow/config.json`:
167
+ ```json
168
+ "skills": {
169
+ "freshnessThreshold": 90
170
+ }
171
+ ```
@@ -655,6 +655,52 @@ Display:
655
655
  // Check for conventional commits, ticket prefixes, etc.
656
656
  ```
657
657
 
658
+ **Model Routing Configuration:**
659
+
660
+ Present the user with a model routing choice using `AskUserQuestion`:
661
+
662
+ ```
663
+ How should WogiFlow route sub-tasks to AI models?
664
+
665
+ 1. "Full Opus (Recommended)" — Maximum quality. All sub-agents use Opus.
666
+ Best for complex projects where quality matters most.
667
+
668
+ 2. "Smart Routing" — Opus orchestrates, Sonnet handles implementation/review,
669
+ Haiku handles searches/lookups. Best quality-to-cost balance.
670
+ Preserves context window by offloading sub-tasks to lighter models.
671
+
672
+ 3. "Custom" — Configure your own routing rules per task type.
673
+ ```
674
+
675
+ Based on choice:
676
+ - Option 1: Set `config.hybrid.enabled = false` (all tasks stay with current model)
677
+ - Option 2: Set `config.hybrid.enabled = true` with default routing table (already configured)
678
+ - Option 3: Set `config.hybrid.enabled = true` and guide user through per-task-type routing overrides
679
+
680
+ Display: ` Model routing... ✓ [Smart Routing | Full Opus | Custom]`
681
+
682
+ **Community Knowledge Sync:**
683
+
684
+ Present opt-in question using `AskUserQuestion`:
685
+
686
+ ```
687
+ Would you like to share anonymized model performance data with the WogiFlow community?
688
+
689
+ What's shared: model ID, task type, iteration count, token usage, wall clock time
690
+ What's NOT shared: file paths, code, project names, task descriptions
691
+
692
+ You'll receive back: community-optimized model routing rules and capability scores.
693
+
694
+ 1. "Enable (Recommended)" — Help improve WogiFlow for everyone
695
+ 2. "Disable" — Keep all data local only
696
+ ```
697
+
698
+ Based on choice:
699
+ - Option 1: Set `config.communitySync.enabled = true`
700
+ - Option 2: Set `config.communitySync.enabled = false` (default)
701
+
702
+ Display: ` Community sync... ✓ [Enabled | Disabled]`
703
+
658
704
  **Commit style detection:**
659
705
  ```bash
660
706
  git log --oneline -20 --format="%s"
@@ -201,6 +201,72 @@ Check the tech options in `flow-tech-options.js` for known `skillsShId` mappings
201
201
  }
202
202
  ```
203
203
 
204
+ ## Pre-Built Skills (v1.7)
205
+
206
+ WogiFlow ships with pre-built skill templates for the top 30 most common libraries. During skill generation:
207
+
208
+ 1. **Pre-built skills** are copied instantly (zero context cost, no network)
209
+ 2. **Unknown libraries** fall back to Context7 generation via sub-agent isolation
210
+
211
+ Pre-built libraries include: react, next, vue, angular, svelte, tailwindcss, express, nestjs, fastify, hono, prisma, sequelize, mongoose, drizzle, typeorm, jest, vitest, playwright, cypress, mocha, zod, typescript, graphql, eslint, django, flask, fastapi, sqlalchemy, pytest, docker, terraform.
212
+
213
+ ### Sub-Agent Isolation for Unknown Libraries
214
+
215
+ When `--fetch-docs` encounters libraries not in the pre-built set:
216
+
217
+ 1. **Skip Context7 in main context** — do NOT fetch docs directly
218
+ 2. **Spawn a sub-agent** using the Agent tool with `subagent_type=general-purpose`:
219
+ ```
220
+ Agent(subagent_type="general-purpose", prompt="Generate a WogiFlow skill for [library].
221
+
222
+ 1. Call mcp__MCP_DOCKER__resolve-library-id with libraryName='[library]'
223
+ 2. Call mcp__MCP_DOCKER__get-library-docs with the resolved ID, topic='best practices patterns common mistakes', tokens=8000
224
+ 3. Extract patterns, anti-patterns, and conventions from the docs
225
+ 4. Write skill files to .claude/skills/[library]/ using the skill template format
226
+ 5. Return ONLY the file paths created (not the doc content)
227
+ ")
228
+ ```
229
+ 3. **Main context receives only file paths** — the full docs stay in the sub-agent's context
230
+ 4. **If sub-agent fails**, create a stub skill with placeholder content
231
+
232
+ This prevents unknown libraries from consuming the main context window.
233
+
234
+ ## Documentation Freshness (`--check-freshness`)
235
+
236
+ Check if pre-built skills have stale documentation:
237
+
238
+ ```
239
+ /wogi-setup-stack --check-freshness
240
+ ```
241
+
242
+ This reads `lastDocCheck` from each skill's frontmatter and flags skills older than 90 days (configurable via `config.skills.freshnessThreshold`).
243
+
244
+ Output:
245
+ ```
246
+ Documentation Freshness Check:
247
+ 3 skills may have outdated documentation:
248
+ react (95 days since last check)
249
+ express (120 days)
250
+ prisma (91 days)
251
+
252
+ Run `/wogi-setup-stack --refresh-stale` to update.
253
+ ```
254
+
255
+ ## Refresh Stale Skills (`--refresh-stale`)
256
+
257
+ Update skills flagged as stale:
258
+
259
+ ```
260
+ /wogi-setup-stack --refresh-stale
261
+ ```
262
+
263
+ For each stale skill:
264
+ 1. Spawn a sub-agent to fetch latest docs via Context7
265
+ 2. Compare new docs against existing skill content
266
+ 3. If changes detected: update skill files and `lastDocCheck` date
267
+ 4. If no changes: bump `lastDocCheck` only
268
+ 5. Display summary of changes
269
+
204
270
  ## Re-running the Wizard
205
271
 
206
272
  You can run the wizard again to:
@@ -330,6 +330,34 @@ At each execution milestone, update the workflow phase. These are no-ops when ph
330
330
 
331
331
  If a transition fails (wrong current phase), it's non-blocking — log and continue.
332
332
 
333
+ ### Task Checkpoints (when `config.proactiveCompaction.enabled`)
334
+
335
+ At each phase boundary, save a task checkpoint and check if proactive compaction is needed. This enables lossless recovery after auto-compact.
336
+
337
+ **At EVERY phase transition listed above**, also:
338
+ 1. Save checkpoint: Record task ID, current phase, completed scenarios, changed files, verification results to `.workflow/state/task-checkpoint.json`
339
+ 2. Check compaction: If context usage >= `proactiveCompaction.triggerThreshold` (default 75%), display compaction message and run `/wogi-compact` before proceeding
340
+
341
+ **Checkpoint integration points:**
342
+ | When | Checkpoint Action |
343
+ |------|-------------------|
344
+ | After explore phase completes | Save exploration summary + related files |
345
+ | After spec is generated | Save spec path + acceptance criteria count |
346
+ | After each scenario completes | Update scenario progress (completed/pending) |
347
+ | After criteria check | Save verification results |
348
+ | Before final validation | Save all changed files list |
349
+ | After task completion | Clear checkpoint |
350
+
351
+ **Auto-compact recovery** (on session resume):
352
+ 1. Check `.workflow/state/task-checkpoint.json` for an active checkpoint
353
+ 2. If checkpoint exists with incomplete scenarios → display recovery message:
354
+ `Auto-compact detected. Restoring task state from checkpoint...`
355
+ 3. Reload: task ID, current phase, completed scenarios, spec path, changed files
356
+ 4. Continue execution from the next pending scenario
357
+
358
+ **Haiku-powered summaries** (when `proactiveCompaction.useHaiku: true`):
359
+ When compacting between phases, use the Agent tool with `model: "haiku"` to generate the compaction summary. This preserves Opus context for the actual implementation work.
360
+
333
361
  ### Execution Flow
334
362
 
335
363
  ```
@@ -804,6 +832,10 @@ Return a structured report:
804
832
 
805
833
  ```javascript
806
834
  // Launch all in parallel (single message, multiple Task tool calls)
835
+ // When hybrid mode is enabled (config.hybrid.enabled), use the model parameter
836
+ // to route sub-agents to the appropriate model tier.
837
+ // Routing is provided by getAgentModel() from flow-prompt-template.js:
838
+ // explore → sonnet, research → sonnet, search → haiku, judging → opus
807
839
  Task(subagent_type=Explore, prompt="Codebase Analyzer: ...")
808
840
  Task(subagent_type=Explore, prompt="Best Practices: ...")
809
841
  Task(subagent_type=Explore, prompt="Version Verifier: ...")
@@ -813,6 +845,21 @@ Task(subagent_type=Explore, prompt="Standards Preview: ...")
813
845
  Task(subagent_type=Explore, prompt="Consumer Impact Analyzer: ...")
814
846
  ```
815
847
 
848
+ **Hybrid Model Routing (S4):**
849
+
850
+ When `config.hybrid.enabled` is `true`, use the Agent tool's `model` parameter to route sub-agents:
851
+
852
+ | Sub-Agent Type | Agent `model` Parameter | Rationale |
853
+ |----------------|------------------------|-----------|
854
+ | Explore/Research | `"sonnet"` | Good analysis capability, saves Opus context |
855
+ | Code Review | `"sonnet"` | Balanced quality for review tasks |
856
+ | Simple Lookup/Search | `"haiku"` | Fast and cheap for file searches |
857
+ | Complex Reasoning | `"opus"` | Only for architecture/planning decisions |
858
+ | Compaction Summary | `"haiku"` | Summaries don't need premium models |
859
+ | Eval Judging | `"opus"` (1) + `"sonnet"` (2) | Multi-judge composition from eval config |
860
+
861
+ The routing table is configured in `scripts/flow-prompt-template.js` and can be overridden via `config.hybrid.routing.overrides`. Capability scores from `.workflow/models/capabilities/*.yaml` are consulted when `checkCapabilities` is true — if a model's score for the task type is below the `capabilityThreshold` (default: 5), the task is escalated to the next tier.
862
+
816
863
  **After all agents complete**, display a consolidated research summary:
817
864
 
818
865
  **Output Format:**
@@ -1801,9 +1848,32 @@ Phase commands:
1801
1848
  ### Scenario keeps failing after max retries
1802
1849
  - Stop and report: "Scenario X failed after N attempts. Issue: [description]"
1803
1850
  - Leave task in inProgress
1804
- - **Auto-suggest hypothesis debugging**: When a scenario fails 3+ times, suggest running `/wogi-debug-hypothesis "[failure description]"` to spawn parallel investigation agents that analyze competing theories about the root cause
1851
+ - **Best-of-N fallback (high-risk tasks)**: When a HIGH-RISK task (architecture, migration, refactor, or complexity HIGH + files > 10) fails 3+ times, auto-suggest Best-of-N:
1852
+ ```
1853
+ This high-risk task has failed 3 times. Would you like to try Best-of-N?
1854
+ → Spawn 2 alternative implementation approaches in isolated worktrees
1855
+ → Opus judges the best approach against the spec
1856
+ ```
1857
+ Use `checkFallbackTrigger()` from `flow-best-of-n.js` to determine if Best-of-N applies.
1858
+ If the task is NOT high-risk: suggest `/wogi-debug-hypothesis` instead (competing theories about root cause).
1859
+ - **Auto-suggest hypothesis debugging**: For non-high-risk tasks, when a scenario fails 3+ times, suggest running `/wogi-debug-hypothesis "[failure description]"` to spawn parallel investigation agents
1805
1860
  - User can investigate and re-run `/wogi-start TASK-XXX` to continue
1806
1861
 
1862
+ ### Best-of-N auto-suggestion (high-risk tasks)
1863
+
1864
+ When starting a task, if `config.bestOfN.enabled` is true:
1865
+ 1. Run `assessRisk()` from `flow-best-of-n.js` with the task's type, description, and file count
1866
+ 2. If `shouldSuggest` is true, display:
1867
+ ```
1868
+ This is a high-risk task. Would you like to use Best-of-N?
1869
+ → Spawn 3 approaches in parallel (isolated worktrees)
1870
+ → Opus selects the best implementation
1871
+ Options: [Yes, use Best-of-N] [No, proceed normally]
1872
+ ```
1873
+ 3. If user confirms: spawn N agents using `Agent(isolation: "worktree")` with variation strategy from `getVariationStrategy()`
1874
+ 4. After all complete: spawn Opus judge using `buildSelectionPrompt()` to select winner
1875
+ 5. Apply winner, clean up losing worktrees
1876
+
1807
1877
  ### Quality gate keeps failing
1808
1878
  - Report which gate is failing and why
1809
1879
  - Attempt to fix automatically
@@ -0,0 +1,60 @@
1
+ # Project Rules
2
+
3
+ This directory contains coding rules and patterns for this project, organized by category.
4
+
5
+ ## Structure
6
+
7
+ ```
8
+ .claude/rules/
9
+ ├── code-style/ # Naming conventions, formatting
10
+ │ └── naming-conventions.md
11
+ ├── security/ # Security patterns and practices
12
+ │ └── security-patterns.md
13
+ ├── architecture/ # Design decisions and patterns
14
+ │ ├── component-reuse.md
15
+ │ └── model-management.md
16
+ └── README.md
17
+ ```
18
+
19
+ ## How Rules Work
20
+
21
+ Rules are automatically loaded by Claude Code based on:
22
+ - **alwaysApply: true** - Rule is always loaded
23
+ - **alwaysApply: false** - Rule is loaded based on `globs` or `description` relevance
24
+ - **globs** - File patterns that trigger rule loading
25
+
26
+ ## Adding New Rules
27
+
28
+ 1. Choose the appropriate category subdirectory
29
+ 2. Create a `.md` file with frontmatter:
30
+
31
+ ```yaml
32
+ ---
33
+ alwaysApply: false
34
+ description: "Brief description for relevance matching"
35
+ globs: src/**/*.ts # Optional: only load for these files
36
+ ---
37
+ ```
38
+
39
+ 3. Write the rule content in markdown
40
+
41
+ ## Categories
42
+
43
+ | Category | Purpose |
44
+ |----------|---------|
45
+ | code-style | Naming conventions, formatting, file structure |
46
+ | security | Security patterns, input validation, safe practices |
47
+ | architecture | Design decisions, component patterns, system organization |
48
+
49
+ ## Auto-Generation
50
+
51
+ Some rules can be auto-generated from `.workflow/state/decisions.md`:
52
+
53
+ ```bash
54
+ node scripts/flow-rules-sync.js
55
+ ```
56
+
57
+ The sync script will route rules to appropriate category subdirectories.
58
+
59
+ ---
60
+ Last updated: 2026-01-12
@@ -0,0 +1,38 @@
1
+ ---
2
+ globs: src/components/**/*
3
+ alwaysApply: false
4
+ description: "Component reuse policy - always check app-map.md before creating components"
5
+ ---
6
+
7
+ # Component Reuse Policy
8
+
9
+ **Rule**: Always check `app-map.md` before creating any component.
10
+
11
+ ## Priority Order
12
+
13
+ 1. **Use existing** - Check if component already exists in app-map
14
+ 2. **Add variant** - Extend existing component with a new variant
15
+ 3. **Extend** - Create a wrapper/HOC around existing component
16
+ 4. **Create new** - Only as last resort
17
+
18
+ ## Before Creating Components
19
+
20
+ ```bash
21
+ # Check app-map first
22
+ cat .workflow/state/app-map.md | grep -i "button"
23
+
24
+ # Or search codebase
25
+ grep -r "Button" src/components/
26
+ ```
27
+
28
+ ## Variant vs New Component
29
+
30
+ Prefer variants when:
31
+ - Same base functionality, different appearance
32
+ - Same HTML structure, different styling
33
+ - Same component, different size/color/state
34
+
35
+ Create new component when:
36
+ - Fundamentally different functionality
37
+ - Different DOM structure
38
+ - Different state management
@@ -0,0 +1,76 @@
1
+ ---
2
+ alwaysApply: true
3
+ description: "All AI-context documents must use PIN markers for targeted context loading"
4
+ ---
5
+
6
+ # Document Structure for AI Context
7
+
8
+ All documents in `.workflow/` that are used as AI context MUST follow the PIN standard.
9
+
10
+ ## Required Structure
11
+
12
+ ### 1. Header with PIN List
13
+ Every document starts with a comment listing all pins in the document:
14
+ ```markdown
15
+ <!-- PINS: pin1, pin2, pin3 -->
16
+ ```
17
+
18
+ ### 2. Section PIN Markers
19
+ Each major section has a PIN marker comment:
20
+ ```markdown
21
+ ### Section Title
22
+ <!-- PIN: section-specific-pin -->
23
+ [Content]
24
+ ```
25
+
26
+ ### 3. PIN Naming Convention
27
+ - Use kebab-case: `user-authentication`, not `userAuthentication`
28
+ - Use semantic names: `error-handling`, not `eh`
29
+ - Use compound names for specificity: `json-parse-safety`
30
+
31
+ ## Why PINs Matter
32
+
33
+ The PIN system enables:
34
+ 1. **Targeted context loading**: Only load sections relevant to current task
35
+ 2. **Cheaper model routing**: Haiku can fetch only relevant sections for Opus
36
+ 3. **Change detection**: Hash sections independently for smart invalidation
37
+ 4. **Cross-reference**: Link sections by PIN across documents
38
+
39
+ ## Example Document
40
+
41
+ ```markdown
42
+ # Config Reference
43
+
44
+ <!-- PINS: database, authentication, api-keys, environment -->
45
+
46
+ ## Database Settings
47
+ <!-- PIN: database -->
48
+ | Setting | Default | Description |
49
+ |---------|---------|-------------|
50
+
51
+ ## Authentication
52
+ <!-- PIN: authentication -->
53
+ | Setting | Default | Description |
54
+ |---------|---------|-------------|
55
+ ```
56
+
57
+ ## Parsing
58
+
59
+ The PIN system automatically parses documents with:
60
+ - `flow-section-index.js` - Generates section index with pins
61
+ - `flow-section-resolver.js` - Resolves sections by PIN lookup
62
+ - `getSectionsByPins(['auth', 'security'])` - Fetch only relevant sections
63
+
64
+ ## Files That Must Have PINs
65
+
66
+ | File | Required PINs |
67
+ |------|---------------|
68
+ | `decisions.md` | Per coding rule/pattern |
69
+ | `app-map.md` | Per component/screen |
70
+ | `product.md` | Per product section |
71
+ | `stack.md` | Per technology |
72
+
73
+ ## Validation
74
+
75
+ Run `node scripts/flow-section-index.js --force` to regenerate the index.
76
+ Check `.workflow/state/section-index.json` for indexed sections and their pins.