Skip to content

Commit bcb6b23

Browse files
committed
Enhance typed-holes-refactor skill: Complete validation suite, examples, and frameworks
Major improvements based on comprehensive efficacy review: ## New Scripts (7 total) - check_discovery.py: Validate Phase 0 completeness (Gate 1) - check_foundation.py: Validate Phase 1 with architecture holes (Gate 2) - check_implementation.py: Validate Phase 2 with all holes resolved (Gate 3) - check_production.py: Validate Phase 3 production readiness (Gate 4) - check_completeness.py: Progress dashboard with visual indicators - visualize_graph.py: Dependency visualization (ASCII/Mermaid/DOT) with analysis - holes_to_beads.py: Automated sync between holes and beads issues ## New Documentation - references/EXAMPLES.md: Complete worked examples - Simple example: File reorganization (2h, 3 holes) - Detailed example: API parser consolidation (3d, 8 holes) with full code ## SKILL.md Enhancements - Hole Quality Framework: SMART criteria for well-defined holes - Estimation Framework: 5-tier sizing (Nano to Epic) with splitting guidelines - Claude-Assisted Workflow: Phase-by-phase LLM/human role delineation - Beads Integration: Complete workflow with cross-session continuity - Conflict Resolution: Comprehensive troubleshooting for 6 common scenarios - Contradictory constraints with negotiation framework - Circular dependencies with 3 resolution strategies - Estimation failures with recalibration guidance - No progress checklist-based recovery ## Key Improvements - All referenced scripts now implemented (was 0/7, now 7/7) - Production-ready validation gates at each phase - Practical examples demonstrating full methodology - Clear human/AI collaboration patterns - Strengthened beads integration for multi-session work - Prevents common failure modes (epic holes, stuck progress, conflicts) All scripts support --json output and --help documentation.
1 parent 6965d5c commit bcb6b23

9 files changed

Lines changed: 3585 additions & 18 deletions

File tree

skills/typed-holes-refactor/SKILL.md

Lines changed: 430 additions & 18 deletions
Large diffs are not rendered by default.

skills/typed-holes-refactor/references/EXAMPLES.md

Lines changed: 956 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 297 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Check Overall Refactor Completeness
4+
5+
Provides a dashboard view of refactoring progress across all phases.
6+
"""
7+
8+
import argparse
9+
import json
10+
import re
11+
import sys
12+
from pathlib import Path
13+
from typing import Dict, List, Tuple
14+
from dataclasses import dataclass, field
15+
16+
17+
@dataclass
18+
class HoleStatus:
19+
total: int = 0
20+
pending: int = 0
21+
in_progress: int = 0
22+
resolved: int = 0
23+
24+
25+
@dataclass
26+
class RefactorStatus:
27+
current_state: HoleStatus = field(default_factory=HoleStatus)
28+
architecture: HoleStatus = field(default_factory=HoleStatus)
29+
implementation: HoleStatus = field(default_factory=HoleStatus)
30+
quality: HoleStatus = field(default_factory=HoleStatus)
31+
migration: HoleStatus = field(default_factory=HoleStatus)
32+
33+
@property
34+
def total_holes(self) -> int:
35+
return (self.current_state.total + self.architecture.total +
36+
self.implementation.total + self.quality.total +
37+
self.migration.total)
38+
39+
@property
40+
def total_resolved(self) -> int:
41+
return (self.current_state.resolved + self.architecture.resolved +
42+
self.implementation.resolved + self.quality.resolved +
43+
self.migration.resolved)
44+
45+
@property
46+
def completion_percent(self) -> float:
47+
if self.total_holes == 0:
48+
return 0.0
49+
return (self.total_resolved / self.total_holes) * 100
50+
51+
52+
class CompletenessChecker:
53+
def __init__(self, refactor_ir: Path):
54+
self.refactor_ir = refactor_ir
55+
self.status = RefactorStatus()
56+
57+
def analyze(self) -> RefactorStatus:
58+
"""Analyze REFACTOR_IR.md and return status"""
59+
if not self.refactor_ir.exists():
60+
print(f"❌ REFACTOR_IR.md not found at {self.refactor_ir}")
61+
return self.status
62+
63+
content = self.refactor_ir.read_text()
64+
65+
# Find all holes
66+
hole_pattern = r'####\s+([HRM]\d+_\w+).*?\*\*Status\*\*:\s*(\w+)'
67+
matches = re.findall(hole_pattern, content, re.DOTALL)
68+
69+
for hole_id, status in matches:
70+
status_lower = status.lower()
71+
hole_type = self._categorize_hole(hole_id)
72+
73+
# Get the appropriate status object
74+
hole_status = getattr(self.status, hole_type)
75+
hole_status.total += 1
76+
77+
if status_lower in ['resolved', 'complete', 'done']:
78+
hole_status.resolved += 1
79+
elif status_lower in ['in_progress', 'active', 'working']:
80+
hole_status.in_progress += 1
81+
else:
82+
hole_status.pending += 1
83+
84+
return self.status
85+
86+
def _categorize_hole(self, hole_id: str) -> str:
87+
"""Categorize hole by ID prefix"""
88+
if hole_id.startswith('H0_'):
89+
return 'current_state'
90+
elif hole_id.startswith('R1_') or hole_id.startswith('R2_') or hole_id.startswith('R3_'):
91+
return 'architecture'
92+
elif hole_id.startswith('R4_') or hole_id.startswith('R5_') or hole_id.startswith('R6_'):
93+
return 'implementation'
94+
elif hole_id.startswith('R7_') or hole_id.startswith('R8_') or hole_id.startswith('R9_'):
95+
return 'quality'
96+
elif hole_id.startswith('M'):
97+
return 'migration'
98+
elif hole_id.startswith('R'):
99+
return 'implementation' # Default for other R* holes
100+
else:
101+
return 'current_state'
102+
103+
def display_dashboard(self):
104+
"""Display progress dashboard"""
105+
print("=" * 60)
106+
print(" TYPED HOLES REFACTORING - PROGRESS DASHBOARD")
107+
print("=" * 60)
108+
print()
109+
110+
# Overall progress
111+
completion = self.status.completion_percent
112+
total = self.status.total_holes
113+
resolved = self.status.total_resolved
114+
115+
print(f"📊 Overall Progress: {resolved}/{total} holes ({completion:.1f}%)")
116+
self._print_progress_bar(completion)
117+
print()
118+
119+
# Phase breakdown
120+
phases = [
121+
("Current State (H0_*)", self.status.current_state, "🔍"),
122+
("Architecture (R1-R3)", self.status.architecture, "🏗️"),
123+
("Implementation (R4-R6)", self.status.implementation, "⚙️"),
124+
("Quality (R7-R9)", self.status.quality, "✨"),
125+
("Migration (M*)", self.status.migration, "🚀"),
126+
]
127+
128+
print("Phase Breakdown:")
129+
print("-" * 60)
130+
131+
for name, hole_status, emoji in phases:
132+
if hole_status.total == 0:
133+
continue
134+
135+
pct = (hole_status.resolved / hole_status.total * 100) if hole_status.total > 0 else 0
136+
print(f"\n{emoji} {name}")
137+
print(f" Total: {hole_status.total} | "
138+
f"Resolved: {hole_status.resolved} | "
139+
f"In Progress: {hole_status.in_progress} | "
140+
f"Pending: {hole_status.pending}")
141+
print(f" ", end="")
142+
self._print_progress_bar(pct, width=40)
143+
144+
print()
145+
print("-" * 60)
146+
147+
# Determine current phase
148+
current_phase = self._determine_phase()
149+
print(f"\n🎯 Current Phase: {current_phase}")
150+
151+
# Next steps
152+
print(f"\n📋 Next Steps:")
153+
self._suggest_next_steps()
154+
155+
print()
156+
print("=" * 60)
157+
158+
def _print_progress_bar(self, percent: float, width: int = 50):
159+
"""Print a visual progress bar"""
160+
filled = int(width * percent / 100)
161+
bar = "█" * filled + "░" * (width - filled)
162+
print(f"[{bar}] {percent:.1f}%")
163+
164+
def _determine_phase(self) -> str:
165+
"""Determine which phase we're currently in"""
166+
if self.status.current_state.pending > 0:
167+
return "Phase 0: Discovery (analyzing current state)"
168+
169+
if self.status.architecture.pending > 0 or self.status.architecture.in_progress > 0:
170+
return "Phase 1: Foundation (resolving architecture holes)"
171+
172+
if self.status.implementation.pending > 0 or self.status.implementation.in_progress > 0:
173+
return "Phase 2: Implementation (resolving implementation holes)"
174+
175+
if self.status.quality.pending > 0 or self.status.quality.in_progress > 0:
176+
return "Phase 3: Quality (resolving quality holes)"
177+
178+
if self.status.migration.pending > 0 or self.status.migration.in_progress > 0:
179+
return "Phase 4: Migration (preparing for production)"
180+
181+
if self.status.total_resolved == self.status.total_holes:
182+
return "Phase 5: Complete (ready for deployment)"
183+
184+
return "Unknown phase"
185+
186+
def _suggest_next_steps(self):
187+
"""Suggest what to do next"""
188+
suggestions = []
189+
190+
# Discovery phase
191+
if self.status.current_state.pending > 0:
192+
suggestions.append(" • Complete current state analysis (H0_ holes)")
193+
suggestions.append(" • Run: python scripts/next_hole.py")
194+
195+
# Foundation phase
196+
elif self.status.architecture.pending > 0 or self.status.architecture.in_progress > 0:
197+
suggestions.append(" • Resolve architecture holes (R1-R3)")
198+
suggestions.append(" • Write characterization tests")
199+
suggestions.append(" • Run: python scripts/check_foundation.py")
200+
201+
# Implementation phase
202+
elif self.status.implementation.pending > 0 or self.status.implementation.in_progress > 0:
203+
suggestions.append(" • Resolve implementation holes (R4-R6)")
204+
suggestions.append(" • Write resolution tests for each hole")
205+
suggestions.append(" • Run: python scripts/validate_resolution.py {HOLE_ID}")
206+
207+
# Quality phase
208+
elif self.status.quality.pending > 0 or self.status.quality.in_progress > 0:
209+
suggestions.append(" • Resolve quality holes (R7-R9)")
210+
suggestions.append(" • Document test strategy and migration plan")
211+
suggestions.append(" • Run: python scripts/check_implementation.py")
212+
213+
# Migration phase
214+
elif self.status.migration.pending > 0 or self.status.migration.in_progress > 0:
215+
suggestions.append(" • Define migration and rollback strategy")
216+
suggestions.append(" • Test rollback mechanism")
217+
suggestions.append(" • Run: python scripts/check_production.py")
218+
219+
# Complete
220+
elif self.status.total_resolved == self.status.total_holes:
221+
suggestions.append(" • Generate final report: python scripts/generate_report.py")
222+
suggestions.append(" • Review all constraints satisfied")
223+
suggestions.append(" • Prepare PR for review")
224+
225+
else:
226+
suggestions.append(" • Run: python scripts/next_hole.py")
227+
228+
for suggestion in suggestions:
229+
print(suggestion)
230+
231+
232+
def main():
233+
parser = argparse.ArgumentParser(
234+
description="Check overall refactor completeness and display dashboard"
235+
)
236+
parser.add_argument(
237+
"--ir",
238+
type=Path,
239+
default=Path("REFACTOR_IR.md"),
240+
help="Path to REFACTOR_IR.md"
241+
)
242+
parser.add_argument(
243+
"--json",
244+
action="store_true",
245+
help="Output results as JSON"
246+
)
247+
248+
args = parser.parse_args()
249+
250+
checker = CompletenessChecker(args.ir)
251+
status = checker.analyze()
252+
253+
if args.json:
254+
result = {
255+
"total_holes": status.total_holes,
256+
"total_resolved": status.total_resolved,
257+
"completion_percent": status.completion_percent,
258+
"current_state": {
259+
"total": status.current_state.total,
260+
"resolved": status.current_state.resolved,
261+
"in_progress": status.current_state.in_progress,
262+
"pending": status.current_state.pending,
263+
},
264+
"architecture": {
265+
"total": status.architecture.total,
266+
"resolved": status.architecture.resolved,
267+
"in_progress": status.architecture.in_progress,
268+
"pending": status.architecture.pending,
269+
},
270+
"implementation": {
271+
"total": status.implementation.total,
272+
"resolved": status.implementation.resolved,
273+
"in_progress": status.implementation.in_progress,
274+
"pending": status.implementation.pending,
275+
},
276+
"quality": {
277+
"total": status.quality.total,
278+
"resolved": status.quality.resolved,
279+
"in_progress": status.quality.in_progress,
280+
"pending": status.quality.pending,
281+
},
282+
"migration": {
283+
"total": status.migration.total,
284+
"resolved": status.migration.resolved,
285+
"in_progress": status.migration.in_progress,
286+
"pending": status.migration.pending,
287+
}
288+
}
289+
print(json.dumps(result, indent=2))
290+
else:
291+
checker.display_dashboard()
292+
293+
sys.exit(0)
294+
295+
296+
if __name__ == "__main__":
297+
main()

0 commit comments

Comments
 (0)