anvil-dev-framework 0.1.6

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 (190) hide show
  1. package/README.md +719 -0
  2. package/VERSION +1 -0
  3. package/docs/ANVIL-REPO-IMPLEMENTATION-PLAN.md +441 -0
  4. package/docs/FIRST-SKILL-TUTORIAL.md +408 -0
  5. package/docs/INSTALLATION-RETRO-NOTES.md +458 -0
  6. package/docs/INSTALLATION.md +984 -0
  7. package/docs/anvil-hud.md +469 -0
  8. package/docs/anvil-init.md +255 -0
  9. package/docs/anvil-state.md +210 -0
  10. package/docs/boris-cherny-ralph-wiggum-insights.md +608 -0
  11. package/docs/command-reference.md +2022 -0
  12. package/docs/hooks-tts.md +368 -0
  13. package/docs/implementation-guide.md +810 -0
  14. package/docs/linear-github-integration.md +247 -0
  15. package/docs/local-issues.md +677 -0
  16. package/docs/patterns/README.md +419 -0
  17. package/docs/planning-responsibilities.md +139 -0
  18. package/docs/session-workflow.md +573 -0
  19. package/docs/simplification-plan-template.md +297 -0
  20. package/docs/simplification-principles.md +129 -0
  21. package/docs/specifications/CCS-RALPH-INTEGRATION-DESIGN.md +633 -0
  22. package/docs/specifications/CCS-RESEARCH-REPORT.md +169 -0
  23. package/docs/specifications/PLAN-ANV-verification-ralph-wiggum.md +403 -0
  24. package/docs/specifications/PLAN-parallel-tracks-anvil-memory-ccs.md +494 -0
  25. package/docs/specifications/SPEC-ANV-VRW/component-01-verify.md +208 -0
  26. package/docs/specifications/SPEC-ANV-VRW/component-02-stop-gate.md +226 -0
  27. package/docs/specifications/SPEC-ANV-VRW/component-03-posttooluse.md +209 -0
  28. package/docs/specifications/SPEC-ANV-VRW/component-04-ralph-wiggum.md +604 -0
  29. package/docs/specifications/SPEC-ANV-VRW/component-05-atomic-actions.md +311 -0
  30. package/docs/specifications/SPEC-ANV-VRW/component-06-verify-subagent.md +264 -0
  31. package/docs/specifications/SPEC-ANV-VRW/component-07-claude-md.md +363 -0
  32. package/docs/specifications/SPEC-ANV-VRW/index.md +182 -0
  33. package/docs/specifications/SPEC-ANV-anvil-memory.md +573 -0
  34. package/docs/specifications/SPEC-ANV-context-checkpoints.md +781 -0
  35. package/docs/specifications/SPEC-ANV-verification-ralph-wiggum.md +789 -0
  36. package/docs/sync.md +122 -0
  37. package/global/CLAUDE.md +140 -0
  38. package/global/agents/verify-app.md +164 -0
  39. package/global/commands/anvil-settings.md +527 -0
  40. package/global/commands/anvil-sync.md +121 -0
  41. package/global/commands/change.md +197 -0
  42. package/global/commands/clarify.md +252 -0
  43. package/global/commands/cleanup.md +292 -0
  44. package/global/commands/commit-push-pr.md +207 -0
  45. package/global/commands/decay-review.md +127 -0
  46. package/global/commands/discover.md +158 -0
  47. package/global/commands/doc-coverage.md +122 -0
  48. package/global/commands/evidence.md +307 -0
  49. package/global/commands/explore.md +121 -0
  50. package/global/commands/force-exit.md +135 -0
  51. package/global/commands/handoff.md +191 -0
  52. package/global/commands/healthcheck.md +302 -0
  53. package/global/commands/hud.md +84 -0
  54. package/global/commands/insights.md +319 -0
  55. package/global/commands/linear-setup.md +184 -0
  56. package/global/commands/lint-fix.md +198 -0
  57. package/global/commands/orient.md +510 -0
  58. package/global/commands/plan.md +228 -0
  59. package/global/commands/ralph.md +346 -0
  60. package/global/commands/ready.md +182 -0
  61. package/global/commands/release.md +305 -0
  62. package/global/commands/retro.md +96 -0
  63. package/global/commands/shard.md +166 -0
  64. package/global/commands/spec.md +227 -0
  65. package/global/commands/sprint.md +184 -0
  66. package/global/commands/tasks.md +228 -0
  67. package/global/commands/test-and-commit.md +151 -0
  68. package/global/commands/validate.md +132 -0
  69. package/global/commands/verify.md +251 -0
  70. package/global/commands/weekly-review.md +156 -0
  71. package/global/hooks/__pycache__/ralph_context_monitor.cpython-314.pyc +0 -0
  72. package/global/hooks/__pycache__/statusline_agent_sync.cpython-314.pyc +0 -0
  73. package/global/hooks/anvil_memory_observe.ts +322 -0
  74. package/global/hooks/anvil_memory_session.ts +166 -0
  75. package/global/hooks/anvil_memory_stop.ts +187 -0
  76. package/global/hooks/parse_transcript.py +116 -0
  77. package/global/hooks/post_merge_cleanup.sh +132 -0
  78. package/global/hooks/post_tool_format.sh +215 -0
  79. package/global/hooks/ralph_context_monitor.py +240 -0
  80. package/global/hooks/ralph_stop.sh +502 -0
  81. package/global/hooks/statusline.sh +1110 -0
  82. package/global/hooks/statusline_agent_sync.py +224 -0
  83. package/global/hooks/stop_gate.sh +250 -0
  84. package/global/lib/.claude/anvil-state.json +21 -0
  85. package/global/lib/__pycache__/agent_registry.cpython-314.pyc +0 -0
  86. package/global/lib/__pycache__/claim_service.cpython-314.pyc +0 -0
  87. package/global/lib/__pycache__/coderabbit_service.cpython-314.pyc +0 -0
  88. package/global/lib/__pycache__/config_service.cpython-314.pyc +0 -0
  89. package/global/lib/__pycache__/coordination_service.cpython-314.pyc +0 -0
  90. package/global/lib/__pycache__/doc_coverage_service.cpython-314.pyc +0 -0
  91. package/global/lib/__pycache__/gate_logger.cpython-314.pyc +0 -0
  92. package/global/lib/__pycache__/github_service.cpython-314.pyc +0 -0
  93. package/global/lib/__pycache__/hygiene_service.cpython-314.pyc +0 -0
  94. package/global/lib/__pycache__/issue_models.cpython-314.pyc +0 -0
  95. package/global/lib/__pycache__/issue_provider.cpython-314.pyc +0 -0
  96. package/global/lib/__pycache__/linear_data_service.cpython-314.pyc +0 -0
  97. package/global/lib/__pycache__/linear_provider.cpython-314.pyc +0 -0
  98. package/global/lib/__pycache__/local_provider.cpython-314.pyc +0 -0
  99. package/global/lib/__pycache__/quality_service.cpython-314.pyc +0 -0
  100. package/global/lib/__pycache__/ralph_state.cpython-314.pyc +0 -0
  101. package/global/lib/__pycache__/state_manager.cpython-314.pyc +0 -0
  102. package/global/lib/__pycache__/transcript_parser.cpython-314.pyc +0 -0
  103. package/global/lib/__pycache__/verification_runner.cpython-314.pyc +0 -0
  104. package/global/lib/__pycache__/verify_iteration.cpython-314.pyc +0 -0
  105. package/global/lib/__pycache__/verify_subagent.cpython-314.pyc +0 -0
  106. package/global/lib/agent_registry.py +995 -0
  107. package/global/lib/anvil-state.sh +435 -0
  108. package/global/lib/claim_service.py +515 -0
  109. package/global/lib/coderabbit_service.py +314 -0
  110. package/global/lib/config_service.py +423 -0
  111. package/global/lib/coordination_service.py +331 -0
  112. package/global/lib/doc_coverage_service.py +1305 -0
  113. package/global/lib/gate_logger.py +316 -0
  114. package/global/lib/github_service.py +310 -0
  115. package/global/lib/handoff_generator.py +775 -0
  116. package/global/lib/hygiene_service.py +712 -0
  117. package/global/lib/issue_models.py +257 -0
  118. package/global/lib/issue_provider.py +339 -0
  119. package/global/lib/linear_data_service.py +210 -0
  120. package/global/lib/linear_provider.py +987 -0
  121. package/global/lib/linear_provider.py.backup +671 -0
  122. package/global/lib/local_provider.py +486 -0
  123. package/global/lib/orient_fast.py +457 -0
  124. package/global/lib/quality_service.py +470 -0
  125. package/global/lib/ralph_prompt_generator.py +563 -0
  126. package/global/lib/ralph_state.py +1202 -0
  127. package/global/lib/state_manager.py +417 -0
  128. package/global/lib/transcript_parser.py +597 -0
  129. package/global/lib/verification_runner.py +557 -0
  130. package/global/lib/verify_iteration.py +490 -0
  131. package/global/lib/verify_subagent.py +250 -0
  132. package/global/skills/README.md +155 -0
  133. package/global/skills/quality-gates/SKILL.md +252 -0
  134. package/global/skills/skill-template/SKILL.md +109 -0
  135. package/global/skills/testing-strategies/SKILL.md +337 -0
  136. package/global/templates/CHANGE-template.md +105 -0
  137. package/global/templates/HANDOFF-template.md +63 -0
  138. package/global/templates/PLAN-template.md +111 -0
  139. package/global/templates/SPEC-template.md +93 -0
  140. package/global/templates/ralph/PROMPT.md.template +89 -0
  141. package/global/templates/ralph/fix_plan.md.template +31 -0
  142. package/global/templates/ralph/progress.txt.template +23 -0
  143. package/global/tests/__pycache__/test_doc_coverage.cpython-314.pyc +0 -0
  144. package/global/tests/test_doc_coverage.py +520 -0
  145. package/global/tests/test_issue_models.py +299 -0
  146. package/global/tests/test_local_provider.py +323 -0
  147. package/global/tools/README.md +178 -0
  148. package/global/tools/__pycache__/anvil-hud.cpython-314.pyc +0 -0
  149. package/global/tools/anvil-hud.py +3622 -0
  150. package/global/tools/anvil-hud.py.bak +3318 -0
  151. package/global/tools/anvil-issue.py +432 -0
  152. package/global/tools/anvil-memory/CLAUDE.md +49 -0
  153. package/global/tools/anvil-memory/README.md +42 -0
  154. package/global/tools/anvil-memory/bun.lock +25 -0
  155. package/global/tools/anvil-memory/bunfig.toml +9 -0
  156. package/global/tools/anvil-memory/package.json +23 -0
  157. package/global/tools/anvil-memory/src/__tests__/ccs/context-monitor.test.ts +535 -0
  158. package/global/tools/anvil-memory/src/__tests__/ccs/edge-cases.test.ts +645 -0
  159. package/global/tools/anvil-memory/src/__tests__/ccs/fixtures.ts +363 -0
  160. package/global/tools/anvil-memory/src/__tests__/ccs/index.ts +8 -0
  161. package/global/tools/anvil-memory/src/__tests__/ccs/integration.test.ts +417 -0
  162. package/global/tools/anvil-memory/src/__tests__/ccs/prompt-generator.test.ts +571 -0
  163. package/global/tools/anvil-memory/src/__tests__/ccs/ralph-stop.test.ts +440 -0
  164. package/global/tools/anvil-memory/src/__tests__/ccs/test-utils.ts +252 -0
  165. package/global/tools/anvil-memory/src/__tests__/commands.test.ts +657 -0
  166. package/global/tools/anvil-memory/src/__tests__/db.test.ts +641 -0
  167. package/global/tools/anvil-memory/src/__tests__/hooks.test.ts +272 -0
  168. package/global/tools/anvil-memory/src/__tests__/performance.test.ts +427 -0
  169. package/global/tools/anvil-memory/src/__tests__/test-utils.ts +113 -0
  170. package/global/tools/anvil-memory/src/commands/checkpoint.ts +197 -0
  171. package/global/tools/anvil-memory/src/commands/get.ts +115 -0
  172. package/global/tools/anvil-memory/src/commands/init.ts +94 -0
  173. package/global/tools/anvil-memory/src/commands/observe.ts +163 -0
  174. package/global/tools/anvil-memory/src/commands/search.ts +112 -0
  175. package/global/tools/anvil-memory/src/db.ts +638 -0
  176. package/global/tools/anvil-memory/src/index.ts +205 -0
  177. package/global/tools/anvil-memory/src/types.ts +122 -0
  178. package/global/tools/anvil-memory/tsconfig.json +29 -0
  179. package/global/tools/ralph-loop.sh +359 -0
  180. package/package.json +45 -0
  181. package/scripts/anvil +822 -0
  182. package/scripts/extract_patterns.py +222 -0
  183. package/scripts/init-project.sh +541 -0
  184. package/scripts/install.sh +229 -0
  185. package/scripts/postinstall.js +41 -0
  186. package/scripts/rollback.sh +188 -0
  187. package/scripts/sync.sh +623 -0
  188. package/scripts/test-statusline.sh +248 -0
  189. package/scripts/update_claude_md.py +224 -0
  190. package/scripts/verify.sh +255 -0
@@ -0,0 +1,494 @@
1
+ ---
2
+ plan_id: PLAN-ANV-PARALLEL
3
+ title: Parallel Tracks - Anvil Memory + CCS + Ralph Integration
4
+ status: draft
5
+ created: 2026-01-07
6
+ tracks: 2
7
+ duration: 4 weeks
8
+ ---
9
+
10
+ # Parallel Tracks Implementation Plan
11
+
12
+ ## Overview
13
+
14
+ Two parallel work streams that converge at Week 3:
15
+
16
+ ```
17
+ Week 1 Week 2 Week 3 Week 4
18
+ ───────────────────────────────────────────────────────────
19
+ TRACK A: Anvil Memory
20
+ [Core DB+CLI] → [Hooks] ──────→ [Integration] → [Polish]
21
+
22
+ │ MERGE
23
+
24
+ TRACK B: CCS + Ralph
25
+ [Alerts+UI] ──→ [Handoff Gen] → [Integration] → [Testing]
26
+ ───────────────────────────────────────────────────────────
27
+ ```
28
+
29
+ ---
30
+
31
+ ## Track A: Anvil Memory System
32
+
33
+ ### A1: Core Database and CLI (Week 1)
34
+
35
+ **Goal**: Functional CLI with SQLite persistence
36
+
37
+ #### A1.1: Project Setup
38
+ - [ ] Create `global/tools/anvil-memory/` directory structure
39
+ - [ ] Initialize Bun project (`bun init`)
40
+ - [ ] Configure TypeScript (`tsconfig.json`)
41
+ - [ ] Set up build scripts in `package.json`
42
+
43
+ **Files to create**:
44
+ ```
45
+ global/tools/anvil-memory/
46
+ ├── src/
47
+ │ ├── index.ts # CLI entry point
48
+ │ ├── db.ts # Database operations
49
+ │ ├── types.ts # Type definitions
50
+ │ └── commands/
51
+ │ ├── init.ts # anvil-memory init
52
+ │ ├── observe.ts # anvil-memory observe
53
+ │ └── search.ts # anvil-memory search
54
+ ├── package.json
55
+ ├── tsconfig.json
56
+ └── bunfig.toml
57
+ ```
58
+
59
+ #### A1.2: Database Schema
60
+ - [ ] Create SQLite schema with all tables:
61
+ - `observations` (main records)
62
+ - `observations_fts` (full-text search)
63
+ - `sessions` (conversation boundaries)
64
+ - `sessions_fts`
65
+ - `checkpoints` (CCS events)
66
+ - `ralph_iterations` (Ralph tracking)
67
+ - `prompts` (user messages)
68
+ - `prompts_fts`
69
+ - [ ] Implement migration system (version tracking)
70
+ - [ ] Create indexes for common queries
71
+
72
+ **Acceptance Criteria**:
73
+ - `anvil-memory init` creates `.anvil/memory.db`
74
+ - Schema matches spec exactly
75
+ - FTS5 tables sync via triggers
76
+
77
+ #### A1.3: Core CLI Commands
78
+ - [ ] `anvil-memory init` - Initialize database
79
+ - [ ] `anvil-memory observe` - Create observation
80
+ - [ ] `anvil-memory search` - Query with FTS5
81
+ - [ ] `anvil-memory get` - Fetch by ID
82
+
83
+ **Acceptance Criteria**:
84
+ - Commands work from any project directory
85
+ - JSON output for programmatic use
86
+ - Human-readable output for interactive use
87
+ - Error handling with clear messages
88
+
89
+ #### A1.4: Observation Types
90
+ - [ ] Implement all 10+ observation types
91
+ - [ ] Type validation on create
92
+ - [ ] Concept tag support (array field)
93
+
94
+ **Observation Types**:
95
+ | Type | Description |
96
+ |------|-------------|
97
+ | bugfix | Bug fixes |
98
+ | feature | New features |
99
+ | refactor | Code restructuring |
100
+ | discovery | Things found |
101
+ | decision | Design choices |
102
+ | change | General changes |
103
+ | checkpoint | CCS checkpoints |
104
+ | ralph_iteration | Ralph loops |
105
+ | handoff | Session continuity |
106
+ | shard | Task breakdown |
107
+ | linear_sync | Issue updates |
108
+
109
+ ---
110
+
111
+ ### A2: Hooks Integration (Week 2)
112
+
113
+ **Goal**: Claude Code hooks that auto-capture observations
114
+
115
+ #### A2.1: SessionStart Hook
116
+ - [ ] Create `global/hooks/anvil_memory_session.ts`
117
+ - [ ] Query recent context from database
118
+ - [ ] Format for Claude Code injection
119
+ - [ ] Register in hooks configuration
120
+
121
+ **Behavior**:
122
+ ```typescript
123
+ // Input: Claude Code session start event
124
+ // Output: { additionalContext: "## Recent Context\n..." }
125
+ ```
126
+
127
+ #### A2.2: PostToolUse Hook
128
+ - [ ] Create `global/hooks/anvil_memory_observe.ts`
129
+ - [ ] Analyze tool output for significance
130
+ - [ ] Classify observation type automatically
131
+ - [ ] Create observation in database
132
+ - [ ] Skip low-value tools (TodoWrite, etc.)
133
+
134
+ **Tools to skip**:
135
+ - TodoWrite
136
+ - AskUserQuestion
137
+ - ListMcpResourcesTool
138
+ - SlashCommand
139
+ - Skill
140
+
141
+ #### A2.3: Stop Hook
142
+ - [ ] Create `global/hooks/anvil_memory_stop.ts`
143
+ - [ ] Generate session summary
144
+ - [ ] Save to sessions table
145
+ - [ ] Calculate context peak percentage
146
+
147
+ #### A2.4: Hook Configuration
148
+ - [ ] Add hooks to `.claude/settings.local.json`
149
+ - [ ] Ensure hooks don't conflict with existing
150
+ - [ ] Test hook chain execution order
151
+
152
+ ---
153
+
154
+ ### A3: Context Generation (Week 3 - Merge Point)
155
+
156
+ **Goal**: Generate useful resume context for sessions
157
+
158
+ #### A3.1: Recent Context Command
159
+ - [ ] `anvil-memory context` - Generate session context
160
+ - [ ] Progressive disclosure (index first)
161
+ - [ ] Token budget awareness
162
+ - [ ] Format options (inject, markdown, json)
163
+
164
+ #### A3.2: Timeline Command
165
+ - [ ] `anvil-memory timeline` - Events around anchor
166
+ - [ ] Support depth_before/depth_after
167
+ - [ ] Include all record types interleaved
168
+
169
+ #### A3.3: Checkpoint Context
170
+ - [ ] Query checkpoints for resume
171
+ - [ ] Include handoff file reference
172
+ - [ ] Format for PROMPT.md injection
173
+
174
+ ---
175
+
176
+ ### A4: Polish and Optimization (Week 4)
177
+
178
+ #### A4.1: Performance
179
+ - [ ] Query optimization with EXPLAIN
180
+ - [ ] Connection pooling (if needed)
181
+ - [ ] Index tuning based on usage
182
+
183
+ #### A4.2: Export/Import
184
+ - [ ] `anvil-memory export` - JSON backup
185
+ - [ ] `anvil-memory import` - Restore from backup
186
+ - [ ] Claude-Mem migration (optional)
187
+
188
+ #### A4.3: Documentation
189
+ - [ ] Usage guide in `docs/guides/anvil-memory.md`
190
+ - [ ] Skill file for Claude Code (`/memory` command)
191
+ - [ ] Integration examples
192
+
193
+ ---
194
+
195
+ ## Track B: Context Checkpoint System + Ralph
196
+
197
+ ### B1: Statusline Alerts and UI (Week 1)
198
+
199
+ **Goal**: Visual indicators for context thresholds
200
+
201
+ #### B1.1: Enhance Statusline Hook
202
+ - [ ] Update `global/hooks/statusline.sh` with L1/L2/L3 indicators
203
+ - [ ] Add checkpoint readiness indicator
204
+ - [ ] Show context trend (rising/stable)
205
+
206
+ **Display format**:
207
+ ```
208
+ Before: [CTX: ████████░░ 82%]
209
+ After: [CTX: ████████░░ 82% ⚠️ L2] [CKPT: Ready]
210
+ ```
211
+
212
+ #### B1.2: Alert Messages
213
+ - [ ] Create alert templates for L1, L2, L3
214
+ - [ ] Implement alert display mechanism
215
+ - [ ] Add suppression for repeated alerts
216
+
217
+ **Alert Templates**:
218
+ ```
219
+ L1 (70%): ⚠️ Context at 70% - Consider completing current task
220
+ L2 (85%): 🔶 Context at 85% - Initiating checkpoint sequence
221
+ L3 (95%): 🔴 Context at 95% - Emergency checkpoint!
222
+ ```
223
+
224
+ #### B1.3: Context Percentage Tracking
225
+ - [ ] Parse context from Claude Code input
226
+ - [ ] Track trend (tokens/minute)
227
+ - [ ] Predict time-to-threshold
228
+
229
+ ---
230
+
231
+ ### B2: Handoff Generation (Week 2)
232
+
233
+ **Goal**: Automated structured handoff documents
234
+
235
+ #### B2.1: Handoff Document Generator
236
+ - [ ] Create `global/lib/handoff_generator.py` (or .ts)
237
+ - [ ] Collect session state:
238
+ - Git status and branch
239
+ - Modified files
240
+ - Linear issue state
241
+ - Current task progress
242
+ - [ ] Generate markdown document
243
+
244
+ **Handoff Template**:
245
+ ```markdown
246
+ ---
247
+ checkpoint_trigger: L2 (context at 86%)
248
+ context_at_checkpoint: 86%
249
+ ---
250
+
251
+ # Session Handoff: [Issue] [Title]
252
+
253
+ ## Checkpoint Reason
254
+ [Why checkpoint was triggered]
255
+
256
+ ## Context to Reload
257
+ - CLAUDE.md sections: [list]
258
+ - Active Spec: [path]
259
+
260
+ ## In Progress
261
+ - File: [path] (lines X-Y)
262
+ - Task: [description]
263
+ - Progress: [percentage]
264
+
265
+ ## Git State
266
+ - Branch: [branch]
267
+ - Uncommitted: [yes/no]
268
+ - Modified files: [list]
269
+
270
+ ## Next Steps
271
+ 1. [specific action]
272
+ 2. [specific action]
273
+ ```
274
+
275
+ #### B2.2: WIP Commit Creation
276
+ - [ ] Create function to generate WIP commit
277
+ - [ ] Commit message format: `[WIP] {issue} - checkpoint (L2 at 85%)`
278
+ - [ ] Only commit if there are changes
279
+
280
+ #### B2.3: Linear Integration
281
+ - [ ] Update issue with checkpoint comment
282
+ - [ ] Add "context-checkpointed" label (if exists)
283
+ - [ ] Link handoff document in comment
284
+
285
+ ---
286
+
287
+ ### B3: Ralph Integration (Week 2-3)
288
+
289
+ **Goal**: CCS integrated into Ralph autonomous loop
290
+
291
+ #### B3.1: Ralph State Enhancement
292
+ - [ ] Add `context_checkpoint` fields to `ralph_state.py`
293
+ - [ ] Track context percentage per iteration
294
+ - [ ] Record checkpoint events
295
+
296
+ **New fields in RalphState**:
297
+ ```python
298
+ @dataclass
299
+ class ContextCheckpoint:
300
+ active: bool = False
301
+ level: str = "" # L1, L2, L3
302
+ percent_at_checkpoint: int = 0
303
+ timestamp: str = ""
304
+ handoff_file: str = ""
305
+ resume_summary: str = ""
306
+ files_in_progress: List[Dict] = field(default_factory=list)
307
+ current_todo_item: str = ""
308
+ progress_on_item: str = ""
309
+
310
+ @dataclass
311
+ class RalphState:
312
+ # ... existing fields ...
313
+ context_checkpoint: Optional[ContextCheckpoint] = None
314
+ context_history: List[Dict] = field(default_factory=list)
315
+ ```
316
+
317
+ #### B3.2: Context Monitor Hook
318
+ - [ ] Create `global/hooks/ralph_context_monitor.py`
319
+ - [ ] Monitor context during Ralph iterations
320
+ - [ ] Trigger checkpoint at L2/L3 thresholds
321
+ - [ ] Update ralph-state.json
322
+
323
+ #### B3.3: Ralph Stop Hook Enhancement
324
+ - [ ] Modify `global/hooks/ralph_stop.sh` to handle checkpoints
325
+ - [ ] Regenerate PROMPT.md with resume context
326
+ - [ ] Decide: continue (exit 1) or stop (exit 0)
327
+
328
+ **Checkpoint flow in ralph_stop.sh**:
329
+ ```bash
330
+ # Check if checkpoint was triggered
331
+ if checkpoint_active; then
332
+ # Regenerate PROMPT.md with resume context
333
+ regenerate_prompt_with_resume
334
+ # Continue loop (fresh context)
335
+ exit 1
336
+ fi
337
+ ```
338
+
339
+ #### B3.4: PROMPT.md Resume Template
340
+ - [ ] Create template for checkpoint resume
341
+ - [ ] Include Anvil Memory query instructions
342
+ - [ ] Reference handoff document
343
+
344
+ ---
345
+
346
+ ### B4: Integration and Testing (Week 3-4)
347
+
348
+ **Goal**: Full CCS + Anvil Memory + Ralph integration
349
+
350
+ #### B4.1: CCS → Anvil Memory Integration
351
+ - [ ] CCS checkpoint → `anvil-memory checkpoint` command
352
+ - [ ] Store checkpoints in Anvil Memory database
353
+ - [ ] Query checkpoints for resume context
354
+
355
+ #### B4.2: Ralph → Anvil Memory Integration
356
+ - [ ] Ralph iteration → `anvil-memory ralph-iteration` command
357
+ - [ ] Store iteration data in database
358
+ - [ ] Query iteration history for patterns
359
+
360
+ #### B4.3: End-to-End Testing
361
+ - [ ] Test L1 → L2 → L3 progression
362
+ - [ ] Test checkpoint → resume cycle
363
+ - [ ] Test Ralph overnight run simulation
364
+ - [ ] Test handoff document quality
365
+
366
+ #### B4.4: Performance Testing
367
+ - [ ] Measure hook latency (<100ms target)
368
+ - [ ] Measure context generation time (<500ms target)
369
+ - [ ] Test with large databases (10k+ observations)
370
+
371
+ ---
372
+
373
+ ## Merge Points and Dependencies
374
+
375
+ ### Week 3 Merge: Integration Point
376
+
377
+ Track A (Anvil Memory) and Track B (CCS/Ralph) merge when:
378
+
379
+ | Track A Deliverable | Track B Needs |
380
+ |---------------------|---------------|
381
+ | `anvil-memory checkpoint` | CCS stores checkpoints |
382
+ | `anvil-memory ralph-iteration` | Ralph stores iterations |
383
+ | `anvil-memory context` | Resume context generation |
384
+ | SessionStart hook | Context injection |
385
+
386
+ ### Dependency Graph
387
+
388
+ ```
389
+ A1.1 Project Setup
390
+
391
+ A1.2 Database Schema
392
+
393
+ A1.3 Core CLI ←──────────────┐
394
+ ↓ │
395
+ A2.1-4 Hooks │
396
+ ↓ │
397
+ A3.1-3 Context Gen ←─────────┼──── B3.4 Resume Template
398
+
399
+ B1.1-3 Statusline ───────────┤
400
+ ↓ │
401
+ B2.1-3 Handoff Gen ──────────┤
402
+ ↓ │
403
+ B3.1-4 Ralph Integration ────┘
404
+
405
+ B4.1-4 Integration Testing
406
+ ```
407
+
408
+ ---
409
+
410
+ ## Task Summary by Track
411
+
412
+ ### Track A: Anvil Memory (Can be worked by Agent 1)
413
+
414
+ | Week | Tasks | Estimated Effort |
415
+ |------|-------|------------------|
416
+ | 1 | A1.1-A1.4: Core DB + CLI | 3-4 days |
417
+ | 2 | A2.1-A2.4: Hooks | 2-3 days |
418
+ | 3 | A3.1-A3.3: Context Gen | 2-3 days |
419
+ | 4 | A4.1-A4.3: Polish | 2-3 days |
420
+
421
+ ### Track B: CCS + Ralph (Can be worked by Agent 2)
422
+
423
+ | Week | Tasks | Estimated Effort |
424
+ |------|-------|------------------|
425
+ | 1 | B1.1-B1.3: Statusline | 2-3 days |
426
+ | 2 | B2.1-B2.3: Handoff + B3.1-B3.2: Ralph State | 3-4 days |
427
+ | 3 | B3.3-B3.4: Ralph Integration | 2-3 days |
428
+ | 4 | B4.1-B4.4: Integration Testing | 2-3 days |
429
+
430
+ ---
431
+
432
+ ## Linear Issues to Create
433
+
434
+ ### Track A Issues
435
+
436
+ | Issue | Title | Priority | Labels |
437
+ |-------|-------|----------|--------|
438
+ | ANV-MEM-1 | Anvil Memory: Project setup and Bun configuration | P0 | feature |
439
+ | ANV-MEM-2 | Anvil Memory: SQLite schema and migrations | P0 | feature |
440
+ | ANV-MEM-3 | Anvil Memory: Core CLI commands (init, observe, search) | P0 | feature |
441
+ | ANV-MEM-4 | Anvil Memory: Observation types and validation | P1 | feature |
442
+ | ANV-MEM-5 | Anvil Memory: SessionStart hook | P0 | feature |
443
+ | ANV-MEM-6 | Anvil Memory: PostToolUse observation hook | P0 | feature |
444
+ | ANV-MEM-7 | Anvil Memory: Stop hook for session summary | P1 | feature |
445
+ | ANV-MEM-8 | Anvil Memory: Context generation command | P0 | feature |
446
+ | ANV-MEM-9 | Anvil Memory: Timeline query command | P1 | feature |
447
+ | ANV-MEM-10 | Anvil Memory: Export/import functionality | P2 | feature |
448
+
449
+ ### Track B Issues
450
+
451
+ | Issue | Title | Priority | Labels |
452
+ |-------|-------|----------|--------|
453
+ | ANV-CCS-1 | CCS: Statusline L1/L2/L3 threshold indicators | P0 | feature |
454
+ | ANV-CCS-2 | CCS: Alert message templates and display | P1 | feature |
455
+ | ANV-CCS-3 | CCS: Context percentage tracking and trend | P1 | feature |
456
+ | ANV-CCS-4 | CCS: Handoff document generator | P0 | feature |
457
+ | ANV-CCS-5 | CCS: WIP commit creation on checkpoint | P0 | feature |
458
+ | ANV-CCS-6 | CCS: Linear issue checkpoint comments | P1 | feature |
459
+ | ANV-RLP-1 | Ralph: Add context_checkpoint to state | P0 | feature |
460
+ | ANV-RLP-2 | Ralph: Context monitor hook | P0 | feature |
461
+ | ANV-RLP-3 | Ralph: Stop hook checkpoint handling | P0 | feature |
462
+ | ANV-RLP-4 | Ralph: PROMPT.md resume template | P0 | feature |
463
+ | ANV-INT-1 | Integration: CCS → Anvil Memory checkpoint storage | P0 | feature |
464
+ | ANV-INT-2 | Integration: Ralph → Anvil Memory iteration storage | P0 | feature |
465
+ | ANV-INT-3 | Integration: End-to-end testing | P0 | chore |
466
+
467
+ ---
468
+
469
+ ## Coordination Notes
470
+
471
+ ### For Parallel Agents
472
+
473
+ 1. **Track A agent** should NOT modify:
474
+ - `global/hooks/statusline.sh`
475
+ - `global/hooks/ralph_stop.sh`
476
+ - `global/lib/ralph_state.py`
477
+
478
+ 2. **Track B agent** should NOT modify:
479
+ - `global/tools/anvil-memory/*`
480
+ - `.anvil/memory.db` schema
481
+
482
+ 3. **Merge coordination at Week 3**:
483
+ - Both agents sync before integration
484
+ - Track A provides CLI interface spec
485
+ - Track B uses CLI to store data
486
+
487
+ ### Git Branching
488
+
489
+ ```
490
+ main
491
+ ├── feature/anvil-memory-core (Track A)
492
+ ├── feature/ccs-statusline (Track B)
493
+ └── feature/integration (Week 3 merge)
494
+ ```
@@ -0,0 +1,208 @@
1
+ ---
2
+ shard_id: SPEC-ANV-VRW/component-01
3
+ parent: SPEC-ANV-VRW
4
+ title: Verification Command (/verify)
5
+ status: draft
6
+ linear_issue: ANV-141
7
+ priority: P0
8
+ estimated_hours: 4-6
9
+ dependencies: none
10
+ ---
11
+
12
+ # Component 1: Verification Command (`/verify`)
13
+
14
+ ## Overview
15
+
16
+ A new slash command that runs verification checks with automatic iteration on failure. This is the **highest-impact** feature from Boris Cherny's methodology.
17
+
18
+ > Boris Cherny: "Verification is #1... 2-3x quality improvement"
19
+
20
+ ---
21
+
22
+ ## Requirements
23
+
24
+ | ID | Requirement | Priority | Acceptance Criteria |
25
+ |----|-------------|----------|---------------------|
26
+ | REQ-V-100 | Run configurable verification suite (tests, lint, types) | P0 | All configured commands execute |
27
+ | REQ-V-101 | On failure, re-read failing files and attempt fix | P0 | Failing file paths extracted and read |
28
+ | REQ-V-102 | Maximum 3 automatic fix attempts before escalating | P0 | Counter limits iterations |
29
+ | REQ-V-103 | Track verification state (pass/fail/iterations) | P0 | State persisted across iterations |
30
+ | REQ-V-104 | Integrate with stop hook for exit gating | P1 | Stop hook respects verification state |
31
+ | REQ-V-105 | Support custom verification commands per project | P1 | Config overrides defaults |
32
+ | REQ-V-106 | Report verification results in statusline | P2 | Statusline shows pass/fail |
33
+
34
+ ---
35
+
36
+ ## Behavior Flow
37
+
38
+ ```
39
+ User: /verify
40
+
41
+ Claude:
42
+ 1. Run verification suite:
43
+ - npm test (or configured test command)
44
+ - npm run lint
45
+ - npm run typecheck
46
+
47
+ 2. If ALL pass:
48
+ ✅ Verification passed (tests: 47, lint: clean, types: clean)
49
+ [Mark task ready for completion]
50
+
51
+ 3. If ANY fail:
52
+ ❌ Verification failed - 3 test failures
53
+
54
+ Analyzing failures...
55
+ - src/auth/login.test.ts:45 - Expected 200, got 401
56
+ - src/auth/login.test.ts:67 - Timeout
57
+
58
+ Attempting fix (iteration 1/3)...
59
+ [Re-read failing files]
60
+ [Apply targeted fix]
61
+ [Re-run verification]
62
+
63
+ 4. After 3 failed iterations:
64
+ ⚠️ Verification failed after 3 attempts
65
+
66
+ Remaining issues:
67
+ - [List of unfixed issues]
68
+
69
+ Manual intervention required.
70
+ ```
71
+
72
+ ---
73
+
74
+ ## Configuration
75
+
76
+ ```yaml
77
+ # .claude/settings.yaml
78
+ verification:
79
+ commands:
80
+ test: "npm test"
81
+ lint: "npm run lint"
82
+ types: "npm run typecheck"
83
+ max_iterations: 3
84
+ required_for_completion: true
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Implementation Tasks
90
+
91
+ ### Task 1: Create Skill File
92
+ **File**: `global/commands/verify.md`
93
+ **Estimated**: 1 hour
94
+
95
+ - [ ] Define skill frontmatter with metadata
96
+ - [ ] Document execution steps
97
+ - [ ] Add argument parsing (custom commands)
98
+ - [ ] Include anti-patterns section
99
+ - [ ] Add examples
100
+
101
+ ### Task 2: Create Verification Runner
102
+ **File**: `global/lib/verification_runner.py`
103
+ **Estimated**: 2 hours
104
+
105
+ - [ ] Load config from `.claude/settings.yaml`
106
+ - [ ] Execute test suite with output capture
107
+ - [ ] Execute lint with output parsing
108
+ - [ ] Execute typecheck with error extraction
109
+ - [ ] Return structured results (pass/fail/errors)
110
+ - [ ] Parse file paths and line numbers from errors
111
+
112
+ ### Task 3: Create Iteration Logic
113
+ **File**: `global/lib/verify_iteration.py`
114
+ **Estimated**: 1.5 hours
115
+
116
+ - [ ] Parse verification failures into structured data
117
+ - [ ] Identify failing files and line numbers
118
+ - [ ] Track iteration count (read/write from state file)
119
+ - [ ] Generate fix context for Claude
120
+ - [ ] Re-run verification after fix attempts
121
+ - [ ] Determine when to escalate
122
+
123
+ ### Task 4: Add Configuration Schema
124
+ **File**: `.claude/settings.yaml` (schema update)
125
+ **Estimated**: 0.5 hours
126
+
127
+ - [ ] Define verification config schema
128
+ - [ ] Support project-specific command overrides
129
+ - [ ] Add `max_iterations` setting
130
+ - [ ] Add `required_for_completion` flag
131
+ - [ ] Document configuration options
132
+
133
+ ---
134
+
135
+ ## Skill Implementation
136
+
137
+ ```markdown
138
+ # /verify - Verification Feedback Loop
139
+
140
+ > Run verification suite with automatic iteration on failure.
141
+
142
+ ## Arguments
143
+ - (none) - Run full verification suite
144
+ - `--test-only` - Run tests only
145
+ - `--quick` - Skip type checking (faster)
146
+
147
+ ## Execution Steps
148
+
149
+ ### Step 1: Run Verification Suite
150
+ Execute all configured verification commands:
151
+ - Test suite (npm test / pytest / etc.)
152
+ - Linter (eslint / ruff / etc.)
153
+ - Type checker (tsc / mypy / etc.)
154
+
155
+ ### Step 2: Analyze Results
156
+ If all pass → Report success, allow completion
157
+ If any fail → Parse errors, identify failing files
158
+
159
+ ### Step 3: Iterate on Failures (max 3 times)
160
+ 1. Re-read each failing file
161
+ 2. Analyze the specific error
162
+ 3. Apply targeted fix
163
+ 4. Re-run failing command only
164
+ 5. Repeat until pass or max iterations
165
+
166
+ ### Step 4: Report Final State
167
+ - Success: List all passing checks with counts
168
+ - Failure: List remaining issues, request manual help
169
+
170
+ ## Anti-Patterns
171
+ - ❌ Making broad changes instead of targeted fixes
172
+ - ❌ Continuing past max iterations
173
+ - ❌ Ignoring failing checks
174
+ - ❌ Changing unrelated code during fix
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Test Cases
180
+
181
+ | Test Case | Input | Expected Output |
182
+ |-----------|-------|-----------------|
183
+ | All pass | Clean codebase | `✅ Verification passed` |
184
+ | Single test failure | 1 failing test | Fix attempted, re-run |
185
+ | Multiple failures | 3 errors | All 3 addressed in order |
186
+ | Max iterations | Unfixable error | Escalate after 3 attempts |
187
+ | Custom commands | Project config | Uses project commands |
188
+ | Missing config | No settings.yaml | Uses sensible defaults |
189
+
190
+ ---
191
+
192
+ ## Error Handling
193
+
194
+ | Error | Response |
195
+ |-------|----------|
196
+ | Test command not found | Report missing, suggest install |
197
+ | Lint timeout | Skip lint, warn user |
198
+ | Parse failure | Log raw output, continue |
199
+ | Permission denied | Report, suggest `chmod` |
200
+
201
+ ---
202
+
203
+ ## Integration Points
204
+
205
+ - **Input**: User invokes `/verify`
206
+ - **Output**: Verification state for stop hook
207
+ - **Consumers**: Stop hook gate, Ralph Wiggum mode
208
+ - **State File**: `.claude/verification-state.json`