@voodocs/cli 2.4.0 → 2.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [2.5.0] - 2024-12-24
4
+
5
+ ### Added
6
+ - **Priority Analyzer** - New `voodocs analyze` command to identify which files need annotations most urgently
7
+ - **Complexity Analysis**: LOC, cyclomatic complexity, function count
8
+ - **Security Keyword Detection**: auth, password, admin, crypto, SQL, payment, etc.
9
+ - **Dependency Analysis**: Import tracking and dependent file detection
10
+ - **Weighted Scoring**: Complexity (30%), Security (40%), Dependencies (20%), Annotations (10%)
11
+ - **Priority Levels**: CRITICAL (80-100), HIGH (60-79), MEDIUM (40-59), LOW (20-39), MINIMAL (0-19)
12
+ - **Multiple Output Formats**: text, JSON, CSV, Markdown
13
+ - **Filtering Options**: By priority level, minimum score, exclude patterns
14
+ - **Smart Suggestions**: Context-aware recommendations for each file
15
+ - **Priority Analyzer Modules**:
16
+ - `lib/darkarts/priority_analyzer/complexity.py` - Complexity analysis engine
17
+ - `lib/darkarts/priority_analyzer/security.py` - Security keyword detector
18
+ - `lib/darkarts/priority_analyzer/dependencies.py` - Dependency tracker
19
+ - `lib/darkarts/priority_analyzer/analyzer.py` - Main priority analyzer
20
+ - `lib/cli/analyze.py` - CLI command implementation
21
+ - **Comprehensive Test Suite** - 16 unit tests for priority analyzer functionality
22
+
23
+ ### Improved
24
+ - Heuristics for identifying security-sensitive code
25
+ - Dependency tracking for TypeScript, JavaScript, Python, and Solidity
26
+ - Annotation coverage detection and penalty calculation
27
+ - Priority scoring algorithm with empirical validation
28
+
29
+ ### Documentation
30
+ - Added Priority Analyzer section to README.md
31
+ - Added analyze command documentation with examples
32
+ - Added priority level definitions and scoring factors
33
+ - Added specification document for priority analyzer
34
+
35
+ ---
36
+
3
37
  ## [2.4.0] - 2025-12-24
4
38
 
5
39
  ### Added
package/README.md CHANGED
@@ -348,6 +348,32 @@ voodocs convert src/ --to lite --dry-run # Preview changes
348
348
  voodocs convert src/ --to lite --in-place # Modify files in-place
349
349
  ```
350
350
 
351
+ ### `voodocs analyze`
352
+
353
+ **NEW in v2.5.0!** Analyze files and suggest annotation priorities based on complexity, security, and dependencies:
354
+
355
+ ```bash
356
+ voodocs analyze src/ # Analyze directory
357
+ voodocs analyze src/ --top 20 # Show top 20 files
358
+ voodocs analyze src/ --priority critical # Filter by priority
359
+ voodocs analyze src/ --format json # JSON output
360
+ voodocs analyze src/ --min-score 60 # Only show files with score >= 60
361
+ voodocs analyze src/ --exclude node_modules,dist # Exclude patterns
362
+ ```
363
+
364
+ **Priority Levels:**
365
+ - 🔴 **CRITICAL** (80-100): Highly complex, security-sensitive, or widely-used files
366
+ - 🟠 **HIGH** (60-79): Complex or security-sensitive files
367
+ - 🟡 **MEDIUM** (40-59): Moderately complex files
368
+ - 🟢 **LOW** (20-39): Simple files with some complexity
369
+ - ⚪ **MINIMAL** (0-19): Very simple files
370
+
371
+ **Scoring Factors:**
372
+ - **Complexity** (30%): Lines of code, cyclomatic complexity, function count
373
+ - **Security** (40%): Security-sensitive keywords (auth, password, admin, etc.)
374
+ - **Dependencies** (20%): Import count and dependent files
375
+ - **Annotations** (10%): Penalty for missing VooDocs annotations
376
+
351
377
  ### `voodocs generate`
352
378
 
353
379
  Generate documentation from annotations:
@@ -0,0 +1,277 @@
1
+ """
2
+ CLI command for VooDocs Priority Analyzer
3
+
4
+ Usage: voodocs analyze [path] [options]
5
+ """
6
+
7
+ import os
8
+ import sys
9
+ from pathlib import Path
10
+
11
+ # Add parent directory to path for imports
12
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
13
+
14
+ from lib.darkarts.priority_analyzer.analyzer import PriorityAnalyzer
15
+
16
+
17
+ def cmd_analyze(args):
18
+ """Execute the analyze command."""
19
+ # Get path (default to current directory)
20
+ path = args.path if hasattr(args, 'path') and args.path else '.'
21
+ path = os.path.abspath(path)
22
+
23
+ # Check if path exists
24
+ if not os.path.exists(path):
25
+ print(f"❌ Error: Path not found: {path}")
26
+ return 1
27
+
28
+ # Determine if path is file or directory
29
+ is_file = os.path.isfile(path)
30
+
31
+ # Initialize analyzer
32
+ project_root = path if not is_file else str(Path(path).parent)
33
+ analyzer = PriorityAnalyzer(project_root=project_root)
34
+
35
+ # Analyze
36
+ if is_file:
37
+ scores = [analyzer.analyze_file(path)]
38
+ else:
39
+ recursive = getattr(args, 'recursive', True)
40
+ exclude = getattr(args, 'exclude', None)
41
+ exclude_patterns = exclude.split(',') if exclude else None
42
+
43
+ print(f"🔍 Analyzing files in: {path}")
44
+ if recursive:
45
+ print(" (recursive mode)")
46
+ print()
47
+
48
+ scores = analyzer.analyze_directory(path, recursive, exclude_patterns)
49
+
50
+ # Filter by priority level if specified
51
+ if hasattr(args, 'priority') and args.priority:
52
+ priority_filter = args.priority.upper()
53
+ scores = [s for s in scores if s.priority_level == priority_filter]
54
+
55
+ # Filter by minimum score
56
+ if hasattr(args, 'min_score') and args.min_score:
57
+ scores = [s for s in scores if s.priority_score >= args.min_score]
58
+
59
+ # Filter out fully annotated files (unless --include-annotated)
60
+ if not getattr(args, 'include_annotated', False):
61
+ scores = [s for s in scores if s.annotation_coverage < 1.0]
62
+
63
+ # Limit to top N
64
+ top_n = getattr(args, 'top', 10)
65
+ if top_n and top_n > 0:
66
+ scores = scores[:top_n]
67
+
68
+ # Output format
69
+ output_format = getattr(args, 'format', 'text')
70
+
71
+ if output_format == 'json':
72
+ _output_json(scores)
73
+ elif output_format == 'csv':
74
+ _output_csv(scores)
75
+ elif output_format == 'markdown':
76
+ _output_markdown(scores)
77
+ else:
78
+ _output_text(scores, path)
79
+
80
+ return 0
81
+
82
+
83
+ def _output_text(scores, path):
84
+ """Output results in human-readable text format."""
85
+ if not scores:
86
+ print("✅ No files need annotations!")
87
+ print(" All files are either fully annotated or below priority threshold.")
88
+ return
89
+
90
+ # Calculate statistics
91
+ total_files = len(scores)
92
+ priority_dist = {
93
+ 'CRITICAL': len([s for s in scores if s.priority_level == 'CRITICAL']),
94
+ 'HIGH': len([s for s in scores if s.priority_level == 'HIGH']),
95
+ 'MEDIUM': len([s for s in scores if s.priority_level == 'MEDIUM']),
96
+ 'LOW': len([s for s in scores if s.priority_level == 'LOW']),
97
+ 'MINIMAL': len([s for s in scores if s.priority_level == 'MINIMAL']),
98
+ }
99
+
100
+ annotated_count = sum(1 for s in scores if s.annotation_coverage > 0)
101
+ coverage_pct = (annotated_count / total_files * 100) if total_files > 0 else 0
102
+
103
+ # Header
104
+ print("━" * 70)
105
+ print("VooDocs Priority Analysis")
106
+ print("━" * 70)
107
+ print()
108
+ print(f"Project: {path}")
109
+ print(f"Files analyzed: {total_files}")
110
+ print(f"Annotations found: {annotated_count} ({coverage_pct:.0f}% coverage)")
111
+ print()
112
+
113
+ # Priority distribution
114
+ print("Priority Distribution:")
115
+ if priority_dist['CRITICAL'] > 0:
116
+ print(f"🔴 CRITICAL (80-100): {priority_dist['CRITICAL']} files")
117
+ if priority_dist['HIGH'] > 0:
118
+ print(f"🟠 HIGH (60-79): {priority_dist['HIGH']} files")
119
+ if priority_dist['MEDIUM'] > 0:
120
+ print(f"🟡 MEDIUM (40-59): {priority_dist['MEDIUM']} files")
121
+ if priority_dist['LOW'] > 0:
122
+ print(f"🟢 LOW (20-39): {priority_dist['LOW']} files")
123
+ if priority_dist['MINIMAL'] > 0:
124
+ print(f"⚪ MINIMAL (0-19): {priority_dist['MINIMAL']} files")
125
+ print()
126
+
127
+ # Top files
128
+ print("━" * 70)
129
+ print(f"Top {len(scores)} Files Needing Annotations")
130
+ print("━" * 70)
131
+ print()
132
+
133
+ for i, score in enumerate(scores, 1):
134
+ # Priority emoji
135
+ emoji = {
136
+ 'CRITICAL': '🔴',
137
+ 'HIGH': '🟠',
138
+ 'MEDIUM': '🟡',
139
+ 'LOW': '🟢',
140
+ 'MINIMAL': '⚪'
141
+ }.get(score.priority_level, '⚪')
142
+
143
+ # Relative path
144
+ rel_path = os.path.relpath(score.filepath, path) if not os.path.isfile(path) else score.filepath
145
+
146
+ print(f"{i}. {emoji} {rel_path} (Score: {score.priority_score:.0f})")
147
+ print(f" Complexity: {score.complexity_score} Security: {score.security_score} Dependencies: {score.dependency_score} Annotations: {score.annotation_penalty}")
148
+ print()
149
+
150
+ # Reasons
151
+ if score.reasons:
152
+ print(" Reasons:")
153
+ for reason in score.reasons:
154
+ print(f" • {reason}")
155
+ print()
156
+
157
+ # Suggestions
158
+ if score.suggestions:
159
+ print(" Suggestions:")
160
+ for suggestion in score.suggestions:
161
+ print(f" ✓ {suggestion}")
162
+ print()
163
+
164
+ # Footer
165
+ print("━" * 70)
166
+ print()
167
+ print("💡 Tip: Start with CRITICAL files first. Use:")
168
+ if scores:
169
+ first_file = scores[0].filepath
170
+ print(f" voodocs companion {first_file}")
171
+ print()
172
+ print(" Or convert to VooDocs Lite for faster annotation:")
173
+ print(f" voodocs convert {path} --to lite --in-place")
174
+ print()
175
+
176
+
177
+ def _output_json(scores):
178
+ """Output results in JSON format."""
179
+ import json
180
+
181
+ data = []
182
+ for score in scores:
183
+ data.append({
184
+ 'filepath': score.filepath,
185
+ 'priority_score': score.priority_score,
186
+ 'priority_level': score.priority_level,
187
+ 'complexity_score': score.complexity_score,
188
+ 'security_score': score.security_score,
189
+ 'dependency_score': score.dependency_score,
190
+ 'annotation_penalty': score.annotation_penalty,
191
+ 'annotation_coverage': score.annotation_coverage,
192
+ 'loc': score.loc,
193
+ 'functions': score.functions,
194
+ 'security_keywords': score.security_keywords,
195
+ 'dependent_count': score.dependent_count,
196
+ 'reasons': score.reasons,
197
+ 'suggestions': score.suggestions
198
+ })
199
+
200
+ print(json.dumps(data, indent=2))
201
+
202
+
203
+ def _output_csv(scores):
204
+ """Output results in CSV format."""
205
+ import csv
206
+ import sys
207
+
208
+ writer = csv.writer(sys.stdout)
209
+
210
+ # Header
211
+ writer.writerow([
212
+ 'filepath', 'priority_score', 'priority_level',
213
+ 'complexity_score', 'security_score', 'dependency_score',
214
+ 'annotation_penalty', 'annotation_coverage',
215
+ 'loc', 'functions', 'dependent_count'
216
+ ])
217
+
218
+ # Data
219
+ for score in scores:
220
+ writer.writerow([
221
+ score.filepath,
222
+ score.priority_score,
223
+ score.priority_level,
224
+ score.complexity_score,
225
+ score.security_score,
226
+ score.dependency_score,
227
+ score.annotation_penalty,
228
+ score.annotation_coverage,
229
+ score.loc,
230
+ score.functions,
231
+ score.dependent_count
232
+ ])
233
+
234
+
235
+ def _output_markdown(scores):
236
+ """Output results in Markdown format."""
237
+ print("# VooDocs Priority Analysis")
238
+ print()
239
+ print("## Summary")
240
+ print()
241
+ print(f"- **Files analyzed:** {len(scores)}")
242
+ print()
243
+ print("## Top Files")
244
+ print()
245
+
246
+ for i, score in enumerate(scores, 1):
247
+ emoji = {
248
+ 'CRITICAL': '🔴',
249
+ 'HIGH': '🟠',
250
+ 'MEDIUM': '🟡',
251
+ 'LOW': '🟢',
252
+ 'MINIMAL': '⚪'
253
+ }.get(score.priority_level, '⚪')
254
+
255
+ print(f"### {i}. {emoji} {score.filepath}")
256
+ print()
257
+ print(f"**Score:** {score.priority_score:.0f} ({score.priority_level})")
258
+ print()
259
+ print(f"- Complexity: {score.complexity_score}")
260
+ print(f"- Security: {score.security_score}")
261
+ print(f"- Dependencies: {score.dependency_score}")
262
+ print(f"- Annotation Coverage: {score.annotation_coverage * 100:.0f}%")
263
+ print()
264
+
265
+ if score.reasons:
266
+ print("**Reasons:**")
267
+ print()
268
+ for reason in score.reasons:
269
+ print(f"- {reason}")
270
+ print()
271
+
272
+ if score.suggestions:
273
+ print("**Suggestions:**")
274
+ print()
275
+ for suggestion in score.suggestions:
276
+ print(f"- {suggestion}")
277
+ print()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voodocs/cli",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "AI-Native Symbolic Documentation System - The world's first documentation tool using mathematical notation with semantic validation",
5
5
  "main": "voodocs_cli.py",
6
6
  "bin": {