@voodocs/cli 0.4.1 → 1.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.
- package/CHANGELOG.md +322 -0
- package/lib/cli/__init__.py +53 -0
- package/lib/cli/benchmark.py +311 -0
- package/lib/cli/fix.py +244 -0
- package/lib/cli/generate.py +310 -0
- package/lib/cli/test_cli.py +215 -0
- package/lib/cli/validate.py +364 -0
- package/lib/darkarts/__init__.py +11 -5
- package/lib/darkarts/annotations/__init__.py +11 -3
- package/lib/darkarts/annotations/darkarts_parser.py +1 -1
- package/lib/darkarts/annotations/types.py +16 -3
- package/lib/darkarts/cli_darkarts.py +385 -0
- package/lib/darkarts/context/__init__.py +11 -3
- package/lib/darkarts/context/ai_integrations.py +7 -21
- package/lib/darkarts/context/commands.py +1 -1
- package/lib/darkarts/context/diagram.py +8 -22
- package/lib/darkarts/context/models.py +7 -22
- package/lib/darkarts/context/module_utils.py +1 -1
- package/lib/darkarts/context/ui.py +1 -1
- package/lib/darkarts/context/validation.py +1 -1
- package/lib/darkarts/context/yaml_utils.py +8 -23
- package/lib/darkarts/core/__init__.py +12 -2
- package/lib/darkarts/core/interface.py +16 -2
- package/lib/darkarts/core/loader.py +17 -2
- package/lib/darkarts/core/plugin.py +16 -3
- package/lib/darkarts/core/registry.py +17 -2
- package/lib/darkarts/exceptions.py +17 -3
- package/lib/darkarts/plugins/voodocs/__init__.py +12 -2
- package/lib/darkarts/plugins/voodocs/ai_native_plugin.py +16 -5
- package/lib/darkarts/plugins/voodocs/annotation_validator.py +16 -3
- package/lib/darkarts/plugins/voodocs/api_spec_generator.py +16 -3
- package/lib/darkarts/plugins/voodocs/documentation_generator.py +16 -3
- package/lib/darkarts/plugins/voodocs/html_exporter.py +16 -3
- package/lib/darkarts/plugins/voodocs/instruction_generator.py +1 -1
- package/lib/darkarts/plugins/voodocs/pdf_exporter.py +16 -3
- package/lib/darkarts/plugins/voodocs/test_generator.py +16 -3
- package/lib/darkarts/telemetry.py +16 -3
- package/lib/darkarts/validation/README.md +147 -0
- package/lib/darkarts/validation/__init__.py +91 -0
- package/lib/darkarts/validation/autofix.py +297 -0
- package/lib/darkarts/validation/benchmark.py +426 -0
- package/lib/darkarts/validation/benchmark_wrapper.py +22 -0
- package/lib/darkarts/validation/config.py +257 -0
- package/lib/darkarts/validation/performance.py +412 -0
- package/lib/darkarts/validation/performance_wrapper.py +37 -0
- package/lib/darkarts/validation/semantic.py +461 -0
- package/lib/darkarts/validation/semantic_wrapper.py +77 -0
- package/lib/darkarts/validation/test_validation.py +160 -0
- package/lib/darkarts/validation/types.py +97 -0
- package/lib/darkarts/validation/watch.py +239 -0
- package/package.json +20 -6
- package/voodocs_cli.py +28 -0
- package/cli.py +0 -1646
- package/lib/darkarts/cli.py +0 -128
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢registry:core.plugin-management
|
|
3
|
+
∂{typing,darkarts.core.plugin}
|
|
4
|
+
⚠{python≥3.7,plugins:valid-metadata}
|
|
5
|
+
⊨{∀register→unique-name|PluginError,∀get→plugin|None,∀unregister→removed,¬duplicate-names,∀deps→satisfied-before-register,thread-safe:dict-ops}
|
|
6
|
+
🔒{read-write:registry-only,¬file-io,¬network,in-memory-only}
|
|
7
|
+
⚡{O(1):register-get-unregister,O(n):list|n=plugin-count,dict-based}
|
|
8
|
+
|
|
2
9
|
Plugin registry for managing and discovering plugins.
|
|
3
|
-
|
|
10
|
+
|
|
11
|
+
Central registry for plugin lifecycle management with:
|
|
12
|
+
- Plugin registration with uniqueness enforcement
|
|
13
|
+
- Dependency validation (plugins must register dependencies first)
|
|
14
|
+
- Plugin lookup by name or capability
|
|
15
|
+
- Plugin enumeration and discovery
|
|
16
|
+
- Thread-safe operations (dict-based)
|
|
17
|
+
- Global singleton registry pattern
|
|
18
|
+
""""
|
|
4
19
|
|
|
5
20
|
from typing import Dict, List, Optional
|
|
6
21
|
from .plugin import DarkArtsPlugin, PluginMetadata, PluginError
|
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢exceptions:errors.hierarchy
|
|
3
|
+
∂{}
|
|
4
|
+
⚠{python≥3.7}
|
|
5
|
+
⊨{∀exception:VooDocsError-subclass,∀error→informative-message,hierarchy:base→specific,catchable:by-type}
|
|
6
|
+
🔒{pure-exceptions,¬io,¬side-effects,¬exec}
|
|
7
|
+
⚡{O(1):exception-creation}
|
|
8
|
+
|
|
2
9
|
VooDocs Custom Exceptions
|
|
3
10
|
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
Structured exception hierarchy for error handling with:
|
|
12
|
+
- Base exception (VooDocsError for all VooDocs errors)
|
|
13
|
+
- Parser errors (ParserError, ParserNotBuiltError, AnnotationError)
|
|
14
|
+
- Validation errors (InvalidAnnotationError, ValidationError)
|
|
15
|
+
- Generator errors (GeneratorError)
|
|
16
|
+
- Configuration errors (ConfigurationError)
|
|
17
|
+
- File errors (FileNotFoundError)
|
|
18
|
+
- Informative messages (clear guidance for users)
|
|
19
|
+
""""
|
|
6
20
|
|
|
7
21
|
|
|
8
22
|
class VooDocsError(Exception):
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢init:plugins.voodocs.package
|
|
3
|
+
∂{}
|
|
4
|
+
⚠{python≥3.7}
|
|
5
|
+
⊨{∀import→exports-available,namespace:clean,¬side-effects-on-import}
|
|
6
|
+
🔒{pure-init,¬io,¬network,¬exec}
|
|
7
|
+
⚡{O(n²):plugin-initialization|10-loops,depth=2}
|
|
8
|
+
|
|
9
|
+
Package initialization for plugins.voodocs.
|
|
10
|
+
|
|
11
|
+
Module exports and namespace configuration.
|
|
1
12
|
"""
|
|
2
|
-
|
|
3
|
-
"""
|
|
13
|
+
|
|
4
14
|
|
|
5
15
|
import ast
|
|
6
16
|
import re
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢ai-voodocs-plugin:plugins.documentation
|
|
3
|
+
∂{darkarts.core,darkarts.annotations,darkarts.plugins.voodocs.documentation_generator,darkarts.plugins.voodocs.test_generator,darkarts.plugins.voodocs.api_spec_generator}
|
|
4
|
+
⚠{python≥3.7,source-code:parseable,annotations:@voodocs-format}
|
|
5
|
+
⊨{∀parse→annotations-extracted,∀execute→docs-generated,∀analyze→insights,¬modify-source,idempotent:same-input→same-output}
|
|
6
|
+
🔒{read-only:source,write:docs-output,¬network,¬arbitrary-exec}
|
|
7
|
+
⚡{O(n)|n=source-lines,ast-parsing:linear}
|
|
8
|
+
|
|
2
9
|
AI-Native VooDocs Plugin for DarkArts
|
|
3
10
|
|
|
4
|
-
Enhanced
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
Enhanced documentation plugin supporting:
|
|
12
|
+
- @voodocs annotation parsing (AI-native documentation)
|
|
13
|
+
- Traditional AST-based documentation (fallback)
|
|
14
|
+
- Automatic documentation generation (Markdown, HTML, PDF)
|
|
15
|
+
- Test generation from annotations (preconditions/postconditions → tests)
|
|
16
|
+
- API specification generation (OpenAPI from annotations)
|
|
17
|
+
- Multi-format output (docs, tests, specs)
|
|
18
|
+
""""
|
|
8
19
|
|
|
9
20
|
from darkarts.core import (
|
|
10
21
|
DarkArtsPlugin,
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢validator:plugins.quality-assurance
|
|
3
|
+
∂{typing,darkarts.annotations.types,re}
|
|
4
|
+
⚠{python≥3.7,annotations:parsed}
|
|
5
|
+
⊨{∀validate→issues-list,∀issue:categorized,∀severity:error|warning|info,¬modify-annotations,comprehensive:all-rules-checked}
|
|
6
|
+
🔒{read-only:annotations,¬file-io,¬network,¬exec}
|
|
7
|
+
⚡{O(n)|n=annotations,validation:linear}
|
|
8
|
+
|
|
2
9
|
VooDocs Annotation Validator
|
|
3
10
|
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
Quality assurance for @voodocs annotations with:
|
|
12
|
+
- Syntax validation (correct format and structure)
|
|
13
|
+
- Completeness checking (required fields present)
|
|
14
|
+
- Consistency verification (invariants don't contradict postconditions)
|
|
15
|
+
- Complexity notation validation (Big-O format)
|
|
16
|
+
- Security model checking (valid security declarations)
|
|
17
|
+
- Best practice recommendations (suggestions for improvement)
|
|
18
|
+
""""
|
|
6
19
|
|
|
7
20
|
from typing import List, Dict, Any, Optional
|
|
8
21
|
from darkarts.annotations.types import ParsedAnnotations, FunctionAnnotation, ClassAnnotation
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢api-spec-generator:plugins.api-documentation
|
|
3
|
+
∂{typing,pathlib,json,yaml,darkarts.annotations.types}
|
|
4
|
+
⚠{python≥3.7,annotations:parsed,format:supported}
|
|
5
|
+
⊨{∀generate→api-spec,∀function→endpoint,∀annotation→schema,¬modify-annotations,valid-spec:parseable}
|
|
6
|
+
🔒{read-only:annotations,write:spec-files,¬network,¬exec}
|
|
7
|
+
⚡{O(n)|n=functions,spec-generation:linear}
|
|
8
|
+
|
|
2
9
|
DarkArts API Specification Generator
|
|
3
10
|
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
Automatic API specification generation from @voodocs annotations with:
|
|
12
|
+
- OpenAPI 3.0 generation (industry-standard REST API specs)
|
|
13
|
+
- Swagger support (compatible with Swagger UI)
|
|
14
|
+
- GraphQL schema generation (type-safe API definitions)
|
|
15
|
+
- Parameter extraction (from preconditions)
|
|
16
|
+
- Response schema generation (from postconditions)
|
|
17
|
+
- Error documentation (from error_cases)
|
|
18
|
+
""""
|
|
6
19
|
|
|
7
20
|
from typing import List, Optional, Dict, Any
|
|
8
21
|
from pathlib import Path
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢doc-generator:plugins.translation
|
|
3
|
+
∂{typing,pathlib,re,darkarts.annotations.types}
|
|
4
|
+
⚠{python≥3.7,annotations:parsed,output-dir:writable}
|
|
5
|
+
⊨{∀generate→markdown-docs,∀translate→natural-language,∀symbol→readable,¬modify-annotations,idempotent:same-input→same-output}
|
|
6
|
+
🔒{read-only:annotations,write:docs-dir,¬network,¬exec}
|
|
7
|
+
⚡{O(n)|n=annotations,translation:linear}
|
|
8
|
+
|
|
2
9
|
VooDocs Documentation Generator
|
|
3
10
|
|
|
4
|
-
Translates @voodocs annotations (
|
|
5
|
-
|
|
11
|
+
Translates @voodocs annotations (DarkArts language) into human-readable documentation with:
|
|
12
|
+
- Mathematical symbol translation (∀, ∃, ∈, → natural language)
|
|
13
|
+
- Markdown generation (structured documentation)
|
|
14
|
+
- Multi-section output (module, classes, functions)
|
|
15
|
+
- Complexity notation explanation (Big-O → plain English)
|
|
16
|
+
- Security model documentation (clear security implications)
|
|
17
|
+
- Cross-reference generation (links between related items)
|
|
18
|
+
""""
|
|
6
19
|
|
|
7
20
|
from typing import List, Optional, Dict
|
|
8
21
|
from pathlib import Path
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢html-exporter:plugins.export
|
|
3
|
+
∂{pathlib,typing}
|
|
4
|
+
⚠{python≥3.7,markdown:optional,input-file:exists}
|
|
5
|
+
⊨{∀export→html-file,∀markdown→html,¬modify-source,fallback:basic-conversion,styled:css-included}
|
|
6
|
+
🔒{read:markdown-files,write:html-files,¬network,¬exec}
|
|
7
|
+
⚡{O(n)|n=markdown-length,conversion:linear}
|
|
8
|
+
|
|
2
9
|
VooDocs HTML Exporter
|
|
3
10
|
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
Markdown to HTML conversion with styling:
|
|
12
|
+
- Markdown parsing (markdown library or fallback)
|
|
13
|
+
- Syntax highlighting (code blocks with CodeHilite)
|
|
14
|
+
- Table support (GitHub-flavored Markdown tables)
|
|
15
|
+
- Responsive CSS (mobile-friendly styling)
|
|
16
|
+
- Full HTML document wrapping (complete pages)
|
|
17
|
+
- Graceful degradation (basic conversion if markdown lib unavailable)
|
|
18
|
+
""""
|
|
6
19
|
|
|
7
20
|
from pathlib import Path
|
|
8
21
|
from typing import Optional
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
⚠{ai∈{cursor,claude,copilot,windsurf},format:markdown,@voodocs:taught}
|
|
5
5
|
⊨{∀gen→valid-format,∀gen→assistant-specific,∀gen→include-examples}
|
|
6
6
|
🔒{write:config-files}
|
|
7
|
-
⚡{O(
|
|
7
|
+
⚡{O(n):instruction-generation|template-based}
|
|
8
8
|
|
|
9
9
|
VooDocs AI Instruction Generator
|
|
10
10
|
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢pdf-exporter:plugins.export
|
|
3
|
+
∂{pathlib,typing,subprocess,weasyprint,darkarts.plugins.voodocs.html_exporter}
|
|
4
|
+
⚠{python≥3.7,weasyprint|markdown-pdf:installed,input-file:exists}
|
|
5
|
+
⊨{∀export→pdf-file,∀markdown→pdf,¬modify-source,fallback-chain:weasyprint→markdown-pdf,print-ready:formatted}
|
|
6
|
+
🔒{read:markdown-files,write:pdf-files,¬network,¬exec}
|
|
7
|
+
⚡{O(n)|n=markdown-length,pdf-rendering:depends-on-lib}
|
|
8
|
+
|
|
2
9
|
VooDocs PDF Exporter
|
|
3
10
|
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
Markdown to PDF conversion with print-ready formatting:
|
|
12
|
+
- WeasyPrint support (HTML → PDF with CSS)
|
|
13
|
+
- Markdown-PDF fallback (alternative PDF generation)
|
|
14
|
+
- Print-optimized layout (page breaks, margins)
|
|
15
|
+
- Embedded fonts and styling (professional appearance)
|
|
16
|
+
- Multi-method fallback (tries multiple libraries)
|
|
17
|
+
- Error handling (clear messages if dependencies missing)
|
|
18
|
+
""""
|
|
6
19
|
|
|
7
20
|
from pathlib import Path
|
|
8
21
|
from typing import Optional
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢test-generator:plugins.test-automation
|
|
3
|
+
∂{typing,pathlib,re,darkarts.annotations.types}
|
|
4
|
+
⚠{python≥3.7,annotations:parsed,framework:supported}
|
|
5
|
+
⊨{∀generate→test-code,∀precondition→test-case,∀postcondition→assertion,¬modify-annotations,executable:valid-syntax}
|
|
6
|
+
🔒{read-only:annotations,write:test-files,¬network,¬exec}
|
|
7
|
+
⚡{O(n)|n=functions,codegen:linear}
|
|
8
|
+
|
|
2
9
|
VooDocs Test Generator
|
|
3
10
|
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
Automatic test generation from @voodocs annotations with:
|
|
12
|
+
- Precondition tests (validate inputs match declared constraints)
|
|
13
|
+
- Postcondition tests (verify outputs satisfy guarantees)
|
|
14
|
+
- Invariant tests (check state consistency)
|
|
15
|
+
- Error case tests (ensure proper error handling)
|
|
16
|
+
- Property-based tests (Hypothesis/QuickCheck-style)
|
|
17
|
+
- Multi-framework support (pytest, unittest, jest, junit)
|
|
18
|
+
""""
|
|
6
19
|
|
|
7
20
|
from typing import List, Optional, Dict, Any, Tuple
|
|
8
21
|
from pathlib import Path
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢telemetry:analytics.privacy-first
|
|
3
|
+
∂{os,sys,json,uuid,platform,datetime,pathlib,typing,urllib}
|
|
4
|
+
⚠{python≥3.7,network:optional,config-dir:writable}
|
|
5
|
+
⊨{∀track→async-send,∀event:anonymous,∀user:opt-out-respected,¬pii,fail-silent:network-errors}
|
|
6
|
+
🔒{⚠️NETWORK:supabase-api,write:config-dir,¬sensitive-data,anonymous-only}
|
|
7
|
+
⚡{O(1):event-creation,network:async-non-blocking}
|
|
8
|
+
|
|
2
9
|
VooDocs Telemetry Client
|
|
3
10
|
|
|
4
|
-
Privacy-respecting anonymous
|
|
5
|
-
|
|
11
|
+
Privacy-respecting anonymous usage analytics with:
|
|
12
|
+
- Anonymous session IDs (UUID-based, no PII)
|
|
13
|
+
- Opt-out support (VOODOCS_TELEMETRY_DISABLED env var)
|
|
14
|
+
- Event tracking (command usage, errors, performance)
|
|
15
|
+
- Supabase backend (anonymous data storage)
|
|
16
|
+
- Fail-silent network (no impact on user experience if offline)
|
|
17
|
+
- First-run notice (transparent disclosure to users)
|
|
18
|
+
""""
|
|
6
19
|
|
|
7
20
|
import os
|
|
8
21
|
import sys
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# DarkArts Validation Module
|
|
2
|
+
|
|
3
|
+
**Phase 1: Foundation - Complete** ✅
|
|
4
|
+
|
|
5
|
+
This module provides validation tools for @darkarts annotations.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The validation module ensures that @darkarts annotations are accurate and up-to-date by:
|
|
10
|
+
- **Semantic Validation**: Verifying dependencies match actual imports
|
|
11
|
+
- **Performance Validation**: Checking complexity claims match code structure
|
|
12
|
+
- **Benchmarking**: Measuring actual performance to validate claims
|
|
13
|
+
- **Auto-fix**: Automatically correcting validation issues
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
The validation module is part of the VooDocs package:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install voodocs
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Semantic Validation
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from darkarts.validation import SemanticValidator
|
|
29
|
+
|
|
30
|
+
validator = SemanticValidator()
|
|
31
|
+
|
|
32
|
+
# Validate a single file
|
|
33
|
+
result = validator.validate_file("myfile.py")
|
|
34
|
+
if not result.is_valid:
|
|
35
|
+
print(f"Missing dependencies: {result.missing_deps}")
|
|
36
|
+
print(f"Extra dependencies: {result.extra_deps}")
|
|
37
|
+
|
|
38
|
+
# Validate a directory
|
|
39
|
+
results = validator.validate_directory("lib/", recursive=True)
|
|
40
|
+
valid_count = sum(1 for r in results if r.is_valid)
|
|
41
|
+
print(f"Valid: {valid_count}/{len(results)}")
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Performance Validation
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from darkarts.validation import PerformanceTracker
|
|
48
|
+
|
|
49
|
+
tracker = PerformanceTracker()
|
|
50
|
+
|
|
51
|
+
# Analyze a file
|
|
52
|
+
result = tracker.analyze_file("myfile.py")
|
|
53
|
+
print(f"Claimed: {result.claimed_complexity}")
|
|
54
|
+
print(f"Actual: {result.actual_complexity}")
|
|
55
|
+
print(f"Valid: {result.is_valid}")
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Benchmarking
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from darkarts.validation import BenchmarkSuite
|
|
62
|
+
|
|
63
|
+
suite = BenchmarkSuite()
|
|
64
|
+
|
|
65
|
+
# Run benchmarks
|
|
66
|
+
config = {
|
|
67
|
+
"critical_paths": ["mymodule.core.process"],
|
|
68
|
+
"sizes": [10, 100, 1000],
|
|
69
|
+
}
|
|
70
|
+
results = suite.run_benchmarks(config)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## API Reference
|
|
74
|
+
|
|
75
|
+
### SemanticValidator
|
|
76
|
+
|
|
77
|
+
- `validate_file(file_path)` - Validate a single file
|
|
78
|
+
- `validate_directory(directory, recursive=True)` - Validate all files in directory
|
|
79
|
+
- `validate_path(path, recursive=False)` - Validate file or directory
|
|
80
|
+
|
|
81
|
+
### PerformanceTracker
|
|
82
|
+
|
|
83
|
+
- `analyze_file(file_path)` - Analyze a single file
|
|
84
|
+
- `analyze_directory(directory, recursive=True)` - Analyze all files in directory
|
|
85
|
+
|
|
86
|
+
### BenchmarkSuite
|
|
87
|
+
|
|
88
|
+
- `run_benchmarks(config)` - Run benchmarks based on configuration
|
|
89
|
+
|
|
90
|
+
## Module Structure
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
validation/
|
|
94
|
+
├── __init__.py # Public API
|
|
95
|
+
├── semantic.py # Semantic validation (functional)
|
|
96
|
+
├── semantic_wrapper.py # SemanticValidator class
|
|
97
|
+
├── performance.py # Performance tracking (functional)
|
|
98
|
+
├── performance_wrapper.py # PerformanceTracker class
|
|
99
|
+
├── benchmark.py # Benchmarking (functional)
|
|
100
|
+
├── benchmark_wrapper.py # BenchmarkSuite class
|
|
101
|
+
├── autofix.py # Auto-fix functionality
|
|
102
|
+
├── config.py # Configuration management
|
|
103
|
+
├── watch.py # Watch mode
|
|
104
|
+
├── types.py # Shared type definitions
|
|
105
|
+
├── test_validation.py # Unit tests
|
|
106
|
+
└── README.md # This file
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Design Principles
|
|
110
|
+
|
|
111
|
+
1. **Functional Core**: Core validation logic is functional (pure functions)
|
|
112
|
+
2. **OOP Wrapper**: Object-oriented API for ease of use
|
|
113
|
+
3. **No CLI**: CLI removed - use `voodocs` CLI instead
|
|
114
|
+
4. **Lazy Loading**: Modules loaded on-demand for fast startup
|
|
115
|
+
5. **Type Safety**: Full type hints for better IDE support
|
|
116
|
+
|
|
117
|
+
## Next Steps
|
|
118
|
+
|
|
119
|
+
**Phase 2**: CLI Integration (Week 2)
|
|
120
|
+
- Integrate into `voodocs` CLI
|
|
121
|
+
- Add `voodocs validate` command
|
|
122
|
+
- Add `--validate` flag to `voodocs generate`
|
|
123
|
+
|
|
124
|
+
**Phase 3**: Advanced Features (Week 3)
|
|
125
|
+
- Watch mode integration
|
|
126
|
+
- Configuration file support
|
|
127
|
+
- HTML/JSON reports
|
|
128
|
+
|
|
129
|
+
## Testing
|
|
130
|
+
|
|
131
|
+
Run tests:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Unit tests
|
|
135
|
+
python3 -m pytest lib/darkarts/validation/test_validation.py
|
|
136
|
+
|
|
137
|
+
# With coverage
|
|
138
|
+
python3 -m pytest lib/darkarts/validation/test_validation.py --cov=darkarts.validation
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Contributing
|
|
142
|
+
|
|
143
|
+
See `../../docs/darkarts/CODE_REVIEW_PROCESS.md` for contribution guidelines.
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
Part of VooDocs - see repository root for license.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢ validation:api
|
|
3
|
+
∂{typing}
|
|
4
|
+
⚠{
|
|
5
|
+
- Python ≥3.7
|
|
6
|
+
- Validation modules available
|
|
7
|
+
}
|
|
8
|
+
⊨{
|
|
9
|
+
- Public API is stable
|
|
10
|
+
- All validators are importable
|
|
11
|
+
- Version compatibility maintained
|
|
12
|
+
}
|
|
13
|
+
🔒{
|
|
14
|
+
- Read-only validation operations
|
|
15
|
+
- No side effects except file writes in fix mode
|
|
16
|
+
- Safe for concurrent use
|
|
17
|
+
}
|
|
18
|
+
⚡{O(n):import-time|n=lazy-loaded-modules}
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
"""
|
|
22
|
+
DarkArts Validation Module
|
|
23
|
+
|
|
24
|
+
This module provides validation tools for @darkarts annotations:
|
|
25
|
+
- SemanticValidator: Validates dependencies match imports
|
|
26
|
+
- PerformanceTracker: Validates complexity claims
|
|
27
|
+
- BenchmarkSuite: Benchmarks performance with real data
|
|
28
|
+
- AutoFix: Automatically fixes validation issues
|
|
29
|
+
- Config: Configuration management
|
|
30
|
+
|
|
31
|
+
Public API:
|
|
32
|
+
from darkarts.validation import (
|
|
33
|
+
SemanticValidator,
|
|
34
|
+
PerformanceTracker,
|
|
35
|
+
BenchmarkSuite,
|
|
36
|
+
AutoFix,
|
|
37
|
+
Config,
|
|
38
|
+
)
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
from typing import TYPE_CHECKING
|
|
42
|
+
|
|
43
|
+
__version__ = "1.0.0"
|
|
44
|
+
__all__ = [
|
|
45
|
+
"SemanticValidator",
|
|
46
|
+
"PerformanceTracker",
|
|
47
|
+
"BenchmarkSuite",
|
|
48
|
+
"AutoFix",
|
|
49
|
+
"Config",
|
|
50
|
+
"ValidationResult",
|
|
51
|
+
"PerformanceResult",
|
|
52
|
+
"BenchmarkResult",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
# Lazy imports to avoid circular dependencies and improve startup time
|
|
56
|
+
if TYPE_CHECKING:
|
|
57
|
+
from .semantic import SemanticValidator
|
|
58
|
+
from .performance import PerformanceTracker
|
|
59
|
+
from .benchmark import BenchmarkSuite
|
|
60
|
+
from .autofix import AutoFix
|
|
61
|
+
from .config import Config
|
|
62
|
+
from .types import ValidationResult, PerformanceResult, BenchmarkResult
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def __getattr__(name: str):
|
|
66
|
+
"""Lazy import for better startup performance."""
|
|
67
|
+
if name == "SemanticValidator":
|
|
68
|
+
from .semantic_wrapper import SemanticValidator
|
|
69
|
+
return SemanticValidator
|
|
70
|
+
elif name == "PerformanceTracker":
|
|
71
|
+
from .performance_wrapper import PerformanceTracker
|
|
72
|
+
return PerformanceTracker
|
|
73
|
+
elif name == "BenchmarkSuite":
|
|
74
|
+
from .benchmark_wrapper import BenchmarkSuite
|
|
75
|
+
return BenchmarkSuite
|
|
76
|
+
elif name == "AutoFix":
|
|
77
|
+
from .autofix import AutoFix
|
|
78
|
+
return AutoFix
|
|
79
|
+
elif name == "Config":
|
|
80
|
+
from .config import Config
|
|
81
|
+
return Config
|
|
82
|
+
elif name == "ValidationResult":
|
|
83
|
+
from .types import ValidationResult
|
|
84
|
+
return ValidationResult
|
|
85
|
+
elif name == "PerformanceResult":
|
|
86
|
+
from .types import PerformanceResult
|
|
87
|
+
return PerformanceResult
|
|
88
|
+
elif name == "BenchmarkResult":
|
|
89
|
+
from .types import BenchmarkResult
|
|
90
|
+
return BenchmarkResult
|
|
91
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|