@voodocs/cli 0.1.2 → 0.2.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,3 +1,80 @@
1
+ ## [0.2.0] - 2025-12-19
2
+
3
+ ### Added
4
+
5
+ #### Context System - Phase 4: Verification & Visualization
6
+
7
+ **Invariant Checking (`voodocs context check`)**
8
+ - Automatically validate code against documented invariants
9
+ - Pattern-based detection for 6 common security issues (SQL injection, unhashed passwords, logged secrets, etc.)
10
+ - File and line number reporting for violations
11
+ - JSON output format for CI/CD integration
12
+ - Module and invariant filtering options
13
+ - Severity levels (error, warning, info)
14
+
15
+ **Architecture Diagram Generation (`voodocs context diagram`)**
16
+ - Auto-generate visual diagrams from context files
17
+ - 3 diagram types: modules, dependencies, flow
18
+ - Supports Mermaid and D2 formats
19
+ - Auto-renders to PNG using manus-render-diagram
20
+ - Console output or file export
21
+
22
+ **Enhanced Validation (`voodocs context validate`)**
23
+ - Smart suggestions for missing sections
24
+ - Integrated invariant checking with `--check-invariants` flag
25
+ - Completeness, quality, and consistency checks
26
+ - Actionable recommendations for improvement
27
+
28
+ #### Context System - Phase 3: Auto-Generation & Query
29
+
30
+ **Auto-Generation (`voodocs context generate`)**
31
+ - Automatically extract context from @voodocs annotations
32
+ - Recursively scans codebase for annotations
33
+ - Extracts global invariants, assumptions, and modules
34
+ - Supports multiple languages (Python, TypeScript, JavaScript, Java, C++, Go, Rust)
35
+
36
+ **Query System (`voodocs context query`)**
37
+ - Query context like a database using regex patterns
38
+ - Section filtering and multiple output formats (text, JSON, YAML)
39
+
40
+ **Git Integration**
41
+ - Auto-detects Git commit hash and author
42
+ - Integrated into `update` and `sync` commands
43
+
44
+ #### Context System - Phase 2: Versioning & History
45
+
46
+ **Version Management**
47
+ - `voodocs context update`: Update context and increment version
48
+ - `voodocs context sync`: Sync context with code version
49
+ - `voodocs context history`: Show version history
50
+ - `voodocs context diff`: Compare context versions
51
+
52
+ #### Context System - Phase 1: Foundation
53
+
54
+ **Core Commands**
55
+ - `voodocs context init`: Initialize .voodocs.context file
56
+ - `voodocs context view`: View context as Markdown
57
+ - `voodocs context status`: Show context file status
58
+
59
+ ### Changed
60
+ - Enhanced `voodocs context validate` with smart suggestions
61
+ - Improved error messages and user feedback
62
+
63
+ ### Documentation
64
+ - Added comprehensive Phase 3 and Phase 4 implementation guides
65
+ - Updated README with new context system commands
66
+ - Added example architecture diagram
67
+
68
+ ### Performance
69
+ - Invariant checking: < 1 second for 15 files
70
+ - Diagram generation: < 100ms + 1-2s for PNG rendering
71
+ - Enhanced validation: < 50ms
72
+
73
+ ### Code Statistics
74
+ - Total Context System: 3,060 lines across 4 phases
75
+ - 12 context commands implemented
76
+ - 980 lines added in Phase 4
77
+
1
78
  ## [0.1.2] - 2025-12-19
2
79
 
3
80
  ### Fixed
package/README.md CHANGED
@@ -84,11 +84,20 @@ voodocs generate ./src --tests-only
84
84
 
85
85
  ## Core Commands
86
86
 
87
- - `voodocs init`: Configure your API key and activate your license
87
+ ### Documentation & Generation
88
+ - `voodocs init`: Initialize VooDocs in your project
88
89
  - `voodocs instruct`: Generate instructions for your AI assistant
89
90
  - `voodocs generate <path>`: Generate docs, tests, and API specs from annotations
90
- - `voodocs status`: Check your current license status and usage
91
- - `voodocs upgrade`: Get information on upgrading your plan
91
+ - `voodocs status`: Check project status and statistics
92
+
93
+ ### Context System (NEW in v0.2.0)
94
+ - `voodocs context init`: Initialize project context file
95
+ - `voodocs context generate`: Auto-generate context from code annotations
96
+ - `voodocs context check`: Validate code against documented invariants
97
+ - `voodocs context diagram`: Generate architecture diagrams
98
+ - `voodocs context validate`: Validate context file with smart suggestions
99
+ - `voodocs context query`: Query context like a database
100
+ - `voodocs context view`: View context as Markdown
92
101
 
93
102
  ## The DarkArts Language
94
103
 
@@ -101,6 +110,29 @@ Voodocs uses the **DarkArts language** - a mathematical and logical notation sys
101
110
 
102
111
  Voodocs then translates this precise, machine-readable format into natural language documentation that humans can easily understand.
103
112
 
113
+ ## What's New in v0.2.0
114
+
115
+ ### 🔍 Invariant Checking
116
+ Automatically validate that your code respects documented invariants:
117
+ ```bash
118
+ voodocs context check
119
+ ```
120
+ Detects security issues like SQL injection, unhashed passwords, and logged secrets.
121
+
122
+ ### 📊 Architecture Diagrams
123
+ Auto-generate visual diagrams from your context:
124
+ ```bash
125
+ voodocs context diagram --type modules --output arch.png --png
126
+ ```
127
+ Supports module diagrams, dependency diagrams, and flow diagrams.
128
+
129
+ ### ✅ Enhanced Validation
130
+ Smart validation with actionable suggestions:
131
+ ```bash
132
+ voodocs context validate --check-invariants
133
+ ```
134
+ Provides completeness checks, quality suggestions, and consistency validation.
135
+
104
136
  ## Why Voodocs?
105
137
 
106
138
  - **AI-First Workflow**: Designed for modern AI-assisted development. Your AI documents as it codes.
@@ -108,6 +140,8 @@ Voodocs then translates this precise, machine-readable format into natural langu
108
140
  - **Massive Time Savings**: Eliminate manual documentation work entirely.
109
141
  - **Higher Code Quality**: Formal specifications lead to more robust and reliable code.
110
142
  - **Precision**: Mathematical notation is unambiguous - no more vague documentation.
143
+ - **Verification**: Automatically check that code respects documented invariants (v0.2.0)
144
+ - **Visualization**: Generate architecture diagrams from context (v0.2.0)
111
145
 
112
146
  ## Example Annotation
113
147
 
package/cli.py CHANGED
@@ -137,7 +137,7 @@ Documentation: https://github.com/3vilEnterprises/vooodooo-magic/tree/main/packa
137
137
  parser.add_argument(
138
138
  "--version",
139
139
  action="version",
140
- version="VooDocs 0.1.2"
140
+ version="VooDocs 0.2.0"
141
141
  )
142
142
 
143
143
  subparsers = parser.add_subparsers(dest="command", help="Available commands")
@@ -372,6 +372,197 @@ Documentation: https://github.com/3vilEnterprises/vooodooo-magic/tree/main/packa
372
372
  help="Telemetry action"
373
373
  )
374
374
 
375
+ # context command
376
+ context_parser = subparsers.add_parser(
377
+ "context",
378
+ help="Manage project context for AI assistants"
379
+ )
380
+ context_subparsers = context_parser.add_subparsers(dest="context_action", help="Context actions")
381
+
382
+ # context init
383
+ context_init_parser = context_subparsers.add_parser(
384
+ "init",
385
+ help="Initialize a new .voodocs.context file"
386
+ )
387
+ context_init_parser.add_argument(
388
+ "--force",
389
+ action="store_true",
390
+ help="Overwrite existing context file"
391
+ )
392
+
393
+ # context view
394
+ context_view_parser = context_subparsers.add_parser(
395
+ "view",
396
+ help="View context as human-readable Markdown"
397
+ )
398
+ context_view_parser.add_argument(
399
+ "--output",
400
+ "-o",
401
+ help="Output file path (default: print to console)"
402
+ )
403
+
404
+ # context status
405
+ context_status_parser = context_subparsers.add_parser(
406
+ "status",
407
+ help="Show context file status"
408
+ )
409
+
410
+ # context update
411
+ context_update_parser = context_subparsers.add_parser(
412
+ "update",
413
+ help="Update context and increment version"
414
+ )
415
+ context_update_parser.add_argument(
416
+ "--description",
417
+ "-d",
418
+ help="Description of the changes"
419
+ )
420
+
421
+ # context sync
422
+ context_sync_parser = context_subparsers.add_parser(
423
+ "sync",
424
+ help="Sync context with code version"
425
+ )
426
+ context_sync_parser.add_argument(
427
+ "--code-version",
428
+ "-v",
429
+ help="New code version (e.g., 2.0.0)"
430
+ )
431
+ context_sync_parser.add_argument(
432
+ "--force",
433
+ action="store_true",
434
+ help="Skip confirmation prompts"
435
+ )
436
+
437
+ # context history
438
+ context_history_parser = context_subparsers.add_parser(
439
+ "history",
440
+ help="Show version history"
441
+ )
442
+
443
+ # context diff
444
+ context_diff_parser = context_subparsers.add_parser(
445
+ "diff",
446
+ help="Compare context versions"
447
+ )
448
+ context_diff_parser.add_argument(
449
+ "version1",
450
+ nargs="?",
451
+ help="First version (older)"
452
+ )
453
+ context_diff_parser.add_argument(
454
+ "version2",
455
+ nargs="?",
456
+ help="Second version (newer, default: current)"
457
+ )
458
+
459
+ # context validate
460
+ context_validate_parser = context_subparsers.add_parser(
461
+ "validate",
462
+ help="Validate context file"
463
+ )
464
+ context_validate_parser.add_argument(
465
+ "--check-version",
466
+ action="store_true",
467
+ help="Check if code version matches detected version"
468
+ )
469
+ context_validate_parser.add_argument(
470
+ "--check-invariants",
471
+ action="store_true",
472
+ help="Check if code respects documented invariants"
473
+ )
474
+
475
+ # context generate
476
+ context_generate_parser = context_subparsers.add_parser(
477
+ "generate",
478
+ help="Generate context from code annotations"
479
+ )
480
+ context_generate_parser.add_argument(
481
+ "source_dir",
482
+ nargs="?",
483
+ help="Directory to scan (default: current directory)"
484
+ )
485
+ context_generate_parser.add_argument(
486
+ "--update",
487
+ action="store_true",
488
+ help="Update existing context file"
489
+ )
490
+
491
+ # context query
492
+ context_query_parser = context_subparsers.add_parser(
493
+ "query",
494
+ help="Query context like a database"
495
+ )
496
+ context_query_parser.add_argument(
497
+ "query",
498
+ help="Search query (keyword or regex)"
499
+ )
500
+ context_query_parser.add_argument(
501
+ "--section",
502
+ "-s",
503
+ help="Specific section to search"
504
+ )
505
+ context_query_parser.add_argument(
506
+ "--format",
507
+ "-f",
508
+ choices=["text", "json", "yaml"],
509
+ default="text",
510
+ help="Output format (default: text)"
511
+ )
512
+
513
+ # context check
514
+ context_check_parser = context_subparsers.add_parser(
515
+ "check",
516
+ help="Check that code respects documented invariants"
517
+ )
518
+ context_check_parser.add_argument(
519
+ "--module",
520
+ "-m",
521
+ help="Filter by module name"
522
+ )
523
+ context_check_parser.add_argument(
524
+ "--invariant",
525
+ "-i",
526
+ help="Filter by invariant text"
527
+ )
528
+ context_check_parser.add_argument(
529
+ "--format",
530
+ "-f",
531
+ choices=["text", "json"],
532
+ default="text",
533
+ help="Output format (default: text)"
534
+ )
535
+
536
+ # context diagram
537
+ context_diagram_parser = context_subparsers.add_parser(
538
+ "diagram",
539
+ help="Generate architecture diagrams from context"
540
+ )
541
+ context_diagram_parser.add_argument(
542
+ "--type",
543
+ "-t",
544
+ choices=["modules", "dependencies", "flow", "all"],
545
+ default="modules",
546
+ help="Diagram type (default: modules)"
547
+ )
548
+ context_diagram_parser.add_argument(
549
+ "--format",
550
+ "-f",
551
+ choices=["mermaid", "d2"],
552
+ default="mermaid",
553
+ help="Output format (default: mermaid)"
554
+ )
555
+ context_diagram_parser.add_argument(
556
+ "--output",
557
+ "-o",
558
+ help="Output file path (default: print to console)"
559
+ )
560
+ context_diagram_parser.add_argument(
561
+ "--png",
562
+ action="store_true",
563
+ help="Render to PNG (requires output file)"
564
+ )
565
+
375
566
  args = parser.parse_args()
376
567
 
377
568
  # Execute command
@@ -393,6 +584,8 @@ Documentation: https://github.com/3vilEnterprises/vooodooo-magic/tree/main/packa
393
584
  cmd_export(args)
394
585
  elif args.command == "telemetry":
395
586
  cmd_telemetry(args)
587
+ elif args.command == "context":
588
+ cmd_context(args)
396
589
  else:
397
590
  parser.print_help()
398
591
  sys.exit(1)
@@ -435,7 +628,7 @@ def cmd_init(args):
435
628
  config = {
436
629
  "project_name": project_name,
437
630
  "language": language,
438
- "version": "0.1.2",
631
+ "version": "0.2.0",
439
632
  "output_dir": "./voodocs-output",
440
633
  "test_framework": "pytest",
441
634
  "api_format": "openapi",
@@ -1353,5 +1546,72 @@ def cmd_telemetry(args):
1353
1546
  client.status()
1354
1547
 
1355
1548
 
1549
+ def cmd_context(args):
1550
+ """Manage project context."""
1551
+ from darkarts.context import (
1552
+ cmd_context_init,
1553
+ cmd_context_view,
1554
+ cmd_context_status,
1555
+ cmd_context_update,
1556
+ cmd_context_sync,
1557
+ cmd_context_history,
1558
+ cmd_context_diff,
1559
+ cmd_context_validate,
1560
+ cmd_context_generate,
1561
+ cmd_context_query,
1562
+ cmd_context_check,
1563
+ cmd_context_diagram
1564
+ )
1565
+
1566
+ if args.context_action == "init":
1567
+ force = getattr(args, 'force', False)
1568
+ sys.exit(cmd_context_init(force=force))
1569
+ elif args.context_action == "view":
1570
+ output_file = getattr(args, 'output', None)
1571
+ sys.exit(cmd_context_view(output_file=output_file))
1572
+ elif args.context_action == "status":
1573
+ sys.exit(cmd_context_status())
1574
+ elif args.context_action == "update":
1575
+ description = getattr(args, 'description', None)
1576
+ sys.exit(cmd_context_update(description=description))
1577
+ elif args.context_action == "sync":
1578
+ code_version = getattr(args, 'code_version', None)
1579
+ force = getattr(args, 'force', False)
1580
+ sys.exit(cmd_context_sync(code_version=code_version, force=force))
1581
+ elif args.context_action == "history":
1582
+ sys.exit(cmd_context_history())
1583
+ elif args.context_action == "diff":
1584
+ version1 = getattr(args, 'version1', None)
1585
+ version2 = getattr(args, 'version2', None)
1586
+ sys.exit(cmd_context_diff(version1=version1, version2=version2))
1587
+ elif args.context_action == "validate":
1588
+ check_version = getattr(args, 'check_version', False)
1589
+ check_invariants = getattr(args, 'check_invariants', False)
1590
+ sys.exit(cmd_context_validate(check_version=check_version, check_invariants=check_invariants))
1591
+ elif args.context_action == "generate":
1592
+ source_dir = getattr(args, 'source_dir', None)
1593
+ update_existing = getattr(args, 'update', False)
1594
+ sys.exit(cmd_context_generate(source_dir=source_dir, update_existing=update_existing))
1595
+ elif args.context_action == "query":
1596
+ query = getattr(args, 'query', '')
1597
+ section = getattr(args, 'section', None)
1598
+ format_type = getattr(args, 'format', 'text')
1599
+ sys.exit(cmd_context_query(query=query, section=section, format=format_type))
1600
+ elif args.context_action == "check":
1601
+ module_filter = getattr(args, 'module', None)
1602
+ invariant_filter = getattr(args, 'invariant', None)
1603
+ format_type = getattr(args, 'format', 'text')
1604
+ sys.exit(cmd_context_check(module_filter=module_filter, invariant_filter=invariant_filter, output_format=format_type))
1605
+ elif args.context_action == "diagram":
1606
+ diagram_type = getattr(args, 'type', 'modules')
1607
+ output_format = getattr(args, 'format', 'mermaid')
1608
+ output_file = getattr(args, 'output', None)
1609
+ render_png = getattr(args, 'png', False)
1610
+ sys.exit(cmd_context_diagram(diagram_type=diagram_type, output_format=output_format, output_file=output_file, render_png=render_png))
1611
+ else:
1612
+ print("Usage: voodocs context {init|view|status|update|sync|history|diff|validate|generate|query|check|diagram}")
1613
+ sys.exit(1)
1614
+
1615
+
1356
1616
  if __name__ == "__main__":
1357
1617
  main()
@@ -340,6 +340,17 @@ class AnnotationParser:
340
340
  if text.startswith('{'):
341
341
  return self._parse_object(text)
342
342
 
343
+ # Check if it's a YAML-style list (multiple lines starting with -)
344
+ if any(line.strip().startswith('-') for line in value_lines):
345
+ items = []
346
+ for line in value_lines:
347
+ line = line.strip()
348
+ if line.startswith('-'):
349
+ item = line[1:].strip()
350
+ if item: # Only add non-empty items
351
+ items.append(item)
352
+ return items if items else text
353
+
343
354
  return text
344
355
 
345
356
  def _parse_list(self, text: str) -> List[str]:
@@ -616,3 +627,56 @@ class AnnotationParser:
616
627
  func.complexity = self._parse_complexity(annotations['complexity'])
617
628
  if 'side_effects' in annotations:
618
629
  func.side_effects = annotations['side_effects'] if isinstance(annotations['side_effects'], list) else [annotations['side_effects']]
630
+
631
+ def parse_directory(self, directory: Path) -> List[ParsedAnnotations]:
632
+ """
633
+ Parse all source files in a directory recursively.
634
+
635
+ Args:
636
+ directory: Path to the directory to scan
637
+
638
+ Returns:
639
+ List of ParsedAnnotations objects, one per file with annotations
640
+ """
641
+ results = []
642
+
643
+ # Supported file extensions
644
+ extensions = {'.py', '.ts', '.tsx', '.js', '.jsx', '.java', '.cpp', '.cc',
645
+ '.cxx', '.h', '.hpp', '.cs', '.go', '.rs'}
646
+
647
+ # Directories to skip
648
+ skip_dirs = {'node_modules', '.git', '__pycache__', 'venv', '.venv',
649
+ 'dist', 'build', 'target', '.next', '.nuxt'}
650
+
651
+ # Recursively find all source files
652
+ for path in directory.rglob('*'):
653
+ # Skip directories
654
+ if path.is_dir():
655
+ continue
656
+
657
+ # Skip if in excluded directory
658
+ if any(skip_dir in path.parts for skip_dir in skip_dirs):
659
+ continue
660
+
661
+ # Check if file has supported extension
662
+ if path.suffix.lower() not in extensions:
663
+ continue
664
+
665
+ try:
666
+ # Parse the file
667
+ parsed = self.parse_file(str(path))
668
+
669
+ # Only include if it has annotations
670
+ if (parsed.module.module_purpose or
671
+ parsed.module.dependencies or
672
+ parsed.module.assumptions or
673
+ parsed.module.classes or
674
+ parsed.module.functions):
675
+ results.append(parsed)
676
+
677
+ except Exception as e:
678
+ # Skip files that fail to parse
679
+ print(f" ⚠️ Skipped {path.relative_to(directory)}: {str(e)}")
680
+ continue
681
+
682
+ return results
@@ -0,0 +1,84 @@
1
+ """
2
+ VooDocs Context System
3
+
4
+ A structured, machine-readable knowledge base for software projects.
5
+ """
6
+
7
+ from .models import (
8
+ ContextFile,
9
+ Versioning,
10
+ Project,
11
+ Architecture,
12
+ ArchitectureDecision,
13
+ Module,
14
+ CriticalPath,
15
+ KnownIssue,
16
+ Assumption,
17
+ Change,
18
+ RoadmapItem,
19
+ create_minimal_context
20
+ )
21
+
22
+ from .yaml_utils import (
23
+ write_context_yaml,
24
+ read_context_yaml,
25
+ parse_context_file,
26
+ add_to_gitignore,
27
+ format_context_as_markdown
28
+ )
29
+
30
+ from .commands import (
31
+ cmd_context_init,
32
+ cmd_context_view,
33
+ cmd_context_status,
34
+ cmd_context_update,
35
+ cmd_context_sync,
36
+ cmd_context_history,
37
+ cmd_context_diff,
38
+ cmd_context_validate,
39
+ cmd_context_generate,
40
+ cmd_context_query,
41
+ cmd_context_check,
42
+ cmd_context_diagram,
43
+ get_context_file_path,
44
+ context_file_exists
45
+ )
46
+
47
+ __all__ = [
48
+ # Models
49
+ 'ContextFile',
50
+ 'Versioning',
51
+ 'Project',
52
+ 'Architecture',
53
+ 'ArchitectureDecision',
54
+ 'Module',
55
+ 'CriticalPath',
56
+ 'KnownIssue',
57
+ 'Assumption',
58
+ 'Change',
59
+ 'RoadmapItem',
60
+ 'create_minimal_context',
61
+
62
+ # YAML utilities
63
+ 'write_context_yaml',
64
+ 'read_context_yaml',
65
+ 'parse_context_file',
66
+ 'add_to_gitignore',
67
+ 'format_context_as_markdown',
68
+
69
+ # Commands
70
+ 'cmd_context_init',
71
+ 'cmd_context_view',
72
+ 'cmd_context_status',
73
+ 'cmd_context_update',
74
+ 'cmd_context_sync',
75
+ 'cmd_context_history',
76
+ 'cmd_context_diff',
77
+ 'cmd_context_validate',
78
+ 'cmd_context_generate',
79
+ 'cmd_context_query',
80
+ 'cmd_context_check',
81
+ 'cmd_context_diagram',
82
+ 'get_context_file_path',
83
+ 'context_file_exists',
84
+ ]