@paths.design/caws-cli 5.0.1 → 6.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.
@@ -1,425 +0,0 @@
1
- ---
2
- description: Sophisticated TODO detection patterns and hidden implementation analysis
3
- globs:
4
- alwaysApply: true
5
- ---
6
-
7
- # Sophisticated TODO Detection & Analysis
8
-
9
- ## Core Principle
10
-
11
- **Detect hidden incomplete implementations beyond simple TODO comments.** Use context-aware analysis with confidence scoring to identify stub implementations, temporary solutions, and incomplete business logic.
12
-
13
- ## Advanced Detection Patterns
14
-
15
- ### High-Confidence Hidden TODO Patterns
16
-
17
- **Incomplete Implementation Patterns:**
18
-
19
- ```python
20
- incomplete_implementation_patterns = [
21
- r'\bnot\s+yet\s+implemented\b',
22
- r'\bmissing\s+implementation\b',
23
- r'\bincomplete\s+implementation\b',
24
- r'\bpartial\s+implementation\b',
25
- r'\bunimplemented\b',
26
- r'\bnot\s+done\b',
27
- r'\bpending\s+implementation\b',
28
- r'\bto\s+be\s+implemented\b',
29
- r'\bwill\s+be\s+implemented\b',
30
- r'\bcoming\s+soon\b',
31
- r'\bwork\s+in\s+progress\b',
32
- r'\bwip\b',
33
- ]
34
- ```
35
-
36
- **Placeholder Code Patterns:**
37
-
38
- ```python
39
- placeholder_code_patterns = [
40
- r'\bplaceholder\s+code\b',
41
- r'\bplaceholder\s+implementation\b',
42
- r'\bstub\s+implementation\b',
43
- r'\bdummy\s+implementation\b',
44
- r'\bfake\s+implementation\b',
45
- r'\bsimplified\s+.*?\s+implementation\b',
46
- r'\bfor\s+now\b.*?(just|simply|only)\s+(concatenate|return|use)',
47
- r'\btemporary\s+implementation\b',
48
- r'\bmock\s+implementation\b',
49
- r'\bsample\s+implementation\b',
50
- ]
51
- ```
52
-
53
- **Temporary Solution Patterns:**
54
-
55
- ```python
56
- temporary_solution_patterns = [
57
- r'\btemporary\s+solution\b',
58
- r'\btemporary\s+fix\b',
59
- r'\bquick\s+fix\b',
60
- r'\bworkaround\b',
61
- r'\bhack\b.*?(fix|solution)',
62
- r'\bband-aid\s+solution\b',
63
- r'\bkludge\b',
64
- r'\bcrude\s+solution\b',
65
- r'\brough\s+implementation\b',
66
- ]
67
- ```
68
-
69
- **Hardcoded Value Patterns:**
70
-
71
- ```python
72
- hardcoded_value_patterns = [
73
- r'\bhardcoded\s+value\b',
74
- r'\bmagic\s+number\b',
75
- r'\bmagic\s+string\b',
76
- r'\bconstant\s+value\b.*?(replace|change|make\s+configurable)',
77
- r'\bfixed\s+value\b',
78
- r'\bstatic\s+value\b',
79
- r'\bhardcoded\s+constant\b',
80
- ]
81
- ```
82
-
83
- **Future Improvement Patterns:**
84
-
85
- ```python
86
- future_improvement_patterns = [
87
- r'\bin\s+production\b.*?(implement|add|fix)',
88
- r'\bin\s+a\s+real\s+implementation\b',
89
- r'\beventually\b.*?(implement|add|fix)',
90
- r'\bshould\s+be\b.*?(implemented|added|fixed)',
91
- r'\bwould\s+be\b.*?(implemented|added|fixed)',
92
- r'\bmight\s+be\b.*?(implemented|added|fixed)',
93
- r'\bcould\s+be\b.*?(implemented|added|fixed)',
94
- r'\blater\b.*?(implement|add|fix)',
95
- r'\bsomeday\b.*?(implement|add|fix)',
96
- ]
97
- ```
98
-
99
- ## Language-Specific Code Stub Detection
100
-
101
- ### JavaScript/TypeScript Patterns
102
-
103
- ```python
104
- javascript_stub_patterns = {
105
- 'function_stub': re.compile(r'^\s*(async\s+)?function\s+\w+\(.*\)\s*{'),
106
- 'throw_not_impl': re.compile(r"^\s*throw\s+new\s+Error\((\"|')(TODO|Not\s+Implemented|Not\s+Yet\s+Implemented)"),
107
- 'return_todo': re.compile(r"^\s*return\s+(null|undefined);\s*//\s*(TODO|PLACEHOLDER)"),
108
- 'console_log_stub': re.compile(r"^\s*console\.log\(.*?\);\s*//\s*(TODO|PLACEHOLDER|STUB)"),
109
- 'empty_function': re.compile(r'^\s*(async\s+)?function\s+\w+\(.*\)\s*{\s*}\s*$'),
110
- 'return_mock': re.compile(r"^\s*return\s+\{.*?\};\s*//\s*(MOCK|FAKE|DUMMY)"),
111
- }
112
- ```
113
-
114
- ### Python Patterns
115
-
116
- ```python
117
- python_stub_patterns = {
118
- 'function_stub': re.compile(r'^\s*def\s+\w+\(.*\):'),
119
- 'pass_stmt': re.compile(r'^\s*pass\s*$'),
120
- 'ellipsis_stmt': re.compile(r'^\s*\.\.\.\s*$'),
121
- 'raise_not_impl': re.compile(r'^\s*raise\s+NotImplementedError'),
122
- 'return_none': re.compile(r"^\s*return\s+None\s*#\s*(TODO|PLACEHOLDER)"),
123
- 'print_stub': re.compile(r"^\s*print\(.*?\)\s*#\s*(TODO|PLACEHOLDER|STUB)"),
124
- 'empty_function': re.compile(r'^\s*def\s+\w+\(.*\):\s*pass\s*$'),
125
- }
126
- ```
127
-
128
- ### Rust Patterns
129
-
130
- ```python
131
- rust_stub_patterns = {
132
- 'function_stub': re.compile(r'^\s*(async\s+)?fn\s+\w+\(.*\)\s*->\s*\w+\s*{'),
133
- 'todo_macro': re.compile(r'^\s*todo!\(\)'),
134
- 'unimplemented_macro': re.compile(r'^\s*unimplemented!\(\)'),
135
- 'panic_stub': re.compile(r"^\s*panic!\(\"TODO\"\)"),
136
- 'return_default': re.compile(r"^\s*Default::default\(\)\s*//\s*(TODO|PLACEHOLDER)"),
137
- }
138
- ```
139
-
140
- ## Context-Aware Analysis
141
-
142
- ### Confidence Scoring
143
-
144
- ```python
145
- def calculate_confidence_score(comment: str, line_num: int, file_path: Path) -> float:
146
- score = 0.0
147
-
148
- # Check for documentation indicators (reduce score)
149
- if is_documentation_comment(comment):
150
- score -= 0.5
151
-
152
- # Check for TODO indicators (increase score)
153
- if has_todo_indicators(comment):
154
- score += 0.3
155
-
156
- # Check if it's in a generated file (reduce score)
157
- if is_generated_file(file_path):
158
- score -= 0.4
159
-
160
- # Check for implementation context (increase score)
161
- if is_implementation_context(comment):
162
- score += 0.2
163
-
164
- # Check for business logic context (increase score)
165
- if is_business_logic_context(comment):
166
- score += 0.3
167
-
168
- return max(-1.0, min(1.0, score))
169
- ```
170
-
171
- ### Exclusion Patterns
172
-
173
- ```python
174
- exclusion_patterns = [
175
- r'\bperformance\s+monitoring\b',
176
- r'\bperformance\s+optimization\b',
177
- r'\bfallback\s+mechanism\b',
178
- r'\bbasic\s+authentication\b',
179
- r'\bmock\s+object\b', # For testing
180
- r'\bcurrent\s+implementation\b.*?(uses|provides|supports)',
181
- r'\bexample\s+implementation\b',
182
- r'\bsample\s+code\b',
183
- r'\bdemo\s+implementation\b',
184
- r'\btest\s+implementation\b',
185
- ]
186
- ```
187
-
188
- ## Implementation Detection
189
-
190
- ### Fake Persistence Detection
191
-
192
- ```python
193
- fake_persistence_patterns = [
194
- r'private\s+\w+:\s*\w+\[\]\s*=\s*\[\]', # In-memory arrays
195
- r'const\s+\w+\s*=\s*\[\]', # Empty arrays
196
- r'let\s+\w+\s*=\s*\[\]', # Empty arrays
197
- r'mock.*database',
198
- r'fake.*persistence',
199
- r'in-memory.*storage',
200
- r'temporary.*storage',
201
- ]
202
- ```
203
-
204
- ### Mock API Detection
205
-
206
- ```python
207
- mock_api_patterns = [
208
- r'return\s+\{.*?\};\s*//\s*(MOCK|FAKE|DUMMY)',
209
- r'console\.log.*mock',
210
- r'hardcoded.*response',
211
- r'static.*response',
212
- r'fake.*api',
213
- r'mock.*endpoint',
214
- ]
215
- ```
216
-
217
- ### Stub Business Logic Detection
218
-
219
- ```python
220
- stub_business_logic_patterns = [
221
- r'return\s+\d+;\s*//\s*(TODO|PLACEHOLDER)',
222
- r'return\s+true;\s*//\s*(TODO|PLACEHOLDER)',
223
- r'return\s+false;\s*//\s*(TODO|PLACEHOLDER)',
224
- r'return\s+null;\s*//\s*(TODO|PLACEHOLDER)',
225
- r'throw\s+new\s+Error.*not\s+implemented',
226
- r'raise.*NotImplementedError',
227
- ]
228
- ```
229
-
230
- ## CAWS Integration
231
-
232
- ### Pre-Commit Analysis
233
-
234
- ```bash
235
- # Run sophisticated TODO analysis
236
- check-hidden-todos() {
237
- echo "🔍 Running sophisticated TODO analysis..."
238
-
239
- # Check for high-confidence hidden TODOs
240
- local hidden_todos=$(grep -r -E "(not yet implemented|missing implementation|incomplete implementation|partial implementation|unimplemented|not done|pending implementation|to be implemented|will be implemented)" src/ | wc -l)
241
- if [ "$hidden_todos" -gt 0 ]; then
242
- echo "❌ Found $hidden_todos hidden incomplete implementations"
243
- echo "All implementations must be complete"
244
- exit 1
245
- fi
246
-
247
- # Check for placeholder implementations
248
- local placeholders=$(grep -r -E "(placeholder code|placeholder implementation|stub implementation|dummy implementation|fake implementation)" src/ | wc -l)
249
- if [ "$placeholders" -gt 0 ]; then
250
- echo "❌ Found $placeholders placeholder implementations"
251
- echo "Replace with real implementations"
252
- exit 1
253
- fi
254
-
255
- # Check for temporary solutions
256
- local temp_solutions=$(grep -r -E "(temporary solution|temporary fix|quick fix|workaround|hack.*fix)" src/ | wc -l)
257
- if [ "$temp_solutions" -gt 0 ]; then
258
- echo "❌ Found $temp_solutions temporary solutions"
259
- echo "Implement proper solutions"
260
- exit 1
261
- fi
262
-
263
- echo "✅ No hidden incomplete implementations found"
264
- }
265
- ```
266
-
267
- ### CI/CD Integration
268
-
269
- ```yaml
270
- # Sophisticated TODO analysis in CI
271
- - name: Check Hidden TODOs
272
- run: |
273
- echo "🔍 Running sophisticated hidden TODO analysis..."
274
-
275
- # Check for incomplete implementations
276
- incomplete_count=$(grep -r -E "(not yet implemented|missing implementation|incomplete implementation|partial implementation|unimplemented|not done|pending implementation|to be implemented|will be implemented)" src/ | wc -l)
277
- if [ "$incomplete_count" -gt 0 ]; then
278
- echo "❌ Found $incomplete_count hidden incomplete implementations"
279
- echo "All implementations must be complete"
280
- exit 1
281
- fi
282
-
283
- # Check for placeholder implementations
284
- placeholder_count=$(grep -r -E "(placeholder code|placeholder implementation|stub implementation|dummy implementation|fake implementation)" src/ | wc -l)
285
- if [ "$placeholder_count" -gt 0 ]; then
286
- echo "❌ Found $placeholder_count placeholder implementations"
287
- echo "Replace with real implementations"
288
- exit 1
289
- fi
290
-
291
- # Check for temporary solutions
292
- temp_count=$(grep -r -E "(temporary solution|temporary fix|quick fix|workaround|hack.*fix)" src/ | wc -l)
293
- if [ "$temp_count" -gt 0 ]; then
294
- echo "❌ Found $temp_count temporary solutions"
295
- echo "Implement proper solutions"
296
- exit 1
297
- fi
298
-
299
- # Check for fake persistence
300
- fake_persistence_count=$(grep -r -E "(private.*\[\]|mock.*database|fake.*persistence|in-memory.*storage)" src/ | wc -l)
301
- if [ "$fake_persistence_count" -gt 0 ]; then
302
- echo "❌ Found $fake_persistence_count fake persistence patterns"
303
- echo "Use real database connections"
304
- exit 1
305
- fi
306
-
307
- echo "✅ No hidden incomplete implementations found"
308
-
309
- - name: Generate TODO Analysis Report
310
- run: |
311
- echo "📊 Generating comprehensive TODO analysis report..."
312
-
313
- # Generate detailed report
314
- echo "# Hidden TODO Analysis Report" > hidden-todos-report.md
315
- echo "" >> hidden-todos-report.md
316
- echo "## Incomplete Implementations" >> hidden-todos-report.md
317
- grep -r -E "(not yet implemented|missing implementation|incomplete implementation|partial implementation|unimplemented|not done|pending implementation|to be implemented|will be implemented)" src/ >> hidden-todos-report.md || echo "None found" >> hidden-todos-report.md
318
- echo "" >> hidden-todos-report.md
319
- echo "## Placeholder Implementations" >> hidden-todos-report.md
320
- grep -r -E "(placeholder code|placeholder implementation|stub implementation|dummy implementation|fake implementation)" src/ >> hidden-todos-report.md || echo "None found" >> hidden-todos-report.md
321
- echo "" >> hidden-todos-report.md
322
- echo "## Temporary Solutions" >> hidden-todos-report.md
323
- grep -r -E "(temporary solution|temporary fix|quick fix|workaround|hack.*fix)" src/ >> hidden-todos-report.md || echo "None found" >> hidden-todos-report.md
324
- echo "" >> hidden-todos-report.md
325
- echo "## Fake Persistence Patterns" >> hidden-todos-report.md
326
- grep -r -E "(private.*\[\]|mock.*database|fake.*persistence|in-memory.*storage)" src/ >> hidden-todos-report.md || echo "None found" >> hidden-todos-report.md
327
-
328
- echo "📊 TODO analysis report generated"
329
- ```
330
-
331
- ## CAWS Commands
332
-
333
- ### TODO Analysis Commands
334
-
335
- ```bash
336
- # Run comprehensive TODO analysis
337
- caws analyze-todos --confidence-threshold=0.7
338
-
339
- # Check for hidden incomplete implementations
340
- caws analyze-todos --pattern="incomplete_implementation" --confidence-threshold=0.8
341
-
342
- # Analyze placeholder implementations
343
- caws analyze-todos --pattern="placeholder_code" --confidence-threshold=0.6
344
-
345
- # Check for temporary solutions
346
- caws analyze-todos --pattern="temporary_solution" --confidence-threshold=0.7
347
-
348
- # Analyze fake persistence patterns
349
- caws analyze-todos --pattern="fake_persistence" --confidence-threshold=0.8
350
- ```
351
-
352
- ### Quality Monitoring
353
-
354
- ```bash
355
- # Track TODO resolution progress
356
- caws quality-monitor --action=code_edited --files="$(git diff --name-only)" --check-hidden-todos
357
-
358
- # Update progress with TODO resolution
359
- caws progress update --criterion-id="TODO-001" --status="completed" --tests-passing=1
360
-
361
- # Track implementation completeness metrics
362
- caws metrics track --metric="hidden_todos_count" --value=0
363
- caws metrics track --metric="placeholder_implementations" --value=0
364
- caws metrics track --metric="temporary_solutions" --value=0
365
- ```
366
-
367
- ## Quality Metrics
368
-
369
- ### Implementation Completeness Score
370
-
371
- ```python
372
- def calculate_completeness_score(analysis_results):
373
- total_files = analysis_results['total_files']
374
- files_with_todos = analysis_results['files_with_hidden_todos']
375
- high_conf_todos = analysis_results['high_confidence_todos']
376
-
377
- # Completeness score (higher is better)
378
- completeness_score = 1.0 - (files_with_todos / total_files) if total_files > 0 else 1.0
379
-
380
- # Quality score based on confidence levels
381
- quality_score = 1.0 - (high_conf_todos / total_files) if total_files > 0 else 1.0
382
-
383
- return {
384
- 'completeness_score': completeness_score,
385
- 'quality_score': quality_score,
386
- 'files_with_todos': files_with_todos,
387
- 'high_confidence_todos': high_conf_todos,
388
- 'total_files_analyzed': total_files
389
- }
390
- ```
391
-
392
- ### Anti-Pattern Detection Metrics
393
-
394
- - **Placeholder Density**: Number of high-confidence TODOs per 1000 lines
395
- - **Stub Implementation Rate**: % of functions with stub patterns detected
396
- - **Temporary Solution Rate**: % of code marked as temporary/workaround
397
- - **Hardcoded Value Rate**: % of magic numbers/strings detected
398
- - **Fake Persistence Rate**: % of code using in-memory storage patterns
399
-
400
- ## Continuous Improvement
401
-
402
- ### Monthly Audits
403
-
404
- ```bash
405
- # Generate monthly completeness report
406
- grep -r -E "(not yet implemented|missing implementation|incomplete implementation|partial implementation|unimplemented|not done|pending implementation|to be implemented|will be implemented)" src/ > monthly-hidden-todos.txt
407
- grep -r -E "(placeholder code|placeholder implementation|stub implementation|dummy implementation|fake implementation)" src/ > monthly-placeholders.txt
408
- grep -r -E "(temporary solution|temporary fix|quick fix|workaround|hack.*fix)" src/ > monthly-temp-solutions.txt
409
-
410
- # Track trends over time
411
- echo "Implementation completeness trends:" >> monthly-report.md
412
- echo "- Hidden incomplete implementations: $(wc -l < monthly-hidden-todos.txt)" >> monthly-report.md
413
- echo "- Placeholder implementations: $(wc -l < monthly-placeholders.txt)" >> monthly-report.md
414
- echo "- Temporary solutions: $(wc -l < monthly-temp-solutions.txt)" >> monthly-report.md
415
- ```
416
-
417
- ### Quarterly Reviews
418
-
419
- - Full implementation audit across entire codebase
420
- - Review integration reality and persistence patterns
421
- - Update quality gates based on project evolution
422
- - Refine detection patterns based on new anti-patterns
423
- - Analyze confidence threshold effectiveness
424
-
425
- This rule ensures sophisticated detection of hidden incomplete implementations beyond simple TODO comments, providing context-aware analysis with confidence scoring to maintain high code quality standards.