@voodocs/cli 1.0.1 → 1.0.4
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 +267 -0
- package/README.md +305 -137
- package/lib/cli/__init__.py +8 -2
- package/lib/cli/generate.py +55 -9
- package/lib/cli/init.py +228 -0
- package/lib/cli/instruct.py +108 -0
- package/lib/darkarts/annotations/parser.py +9 -9
- package/package.json +1 -1
- package/voodocs_cli.py +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,270 @@
|
|
|
1
|
+
## v1.0.4 (2024-12-21)
|
|
2
|
+
|
|
3
|
+
### 🐛 Critical Bug Fixes: Documentation Generation
|
|
4
|
+
|
|
5
|
+
This release fixes critical bugs that prevented documentation generation for TypeScript, JavaScript, and Solidity files.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
#### Issue 1: Annotation Parsing Failure
|
|
12
|
+
**Problem:** The generator failed to recognize valid `@voodocs` or `@darkarts` annotations in TypeScript/JavaScript files.
|
|
13
|
+
|
|
14
|
+
**Root Cause:** The `_extract_annotation` function only looked for Python docstring format (`"""@darkarts`), not TypeScript/JavaScript block comments (`/**@voodocs` or `/**@darkarts`).
|
|
15
|
+
|
|
16
|
+
**Fix:**
|
|
17
|
+
- Added regex pattern matching for TypeScript/JavaScript block comments
|
|
18
|
+
- Support both `/**@voodocs` and `/**@darkarts` tags
|
|
19
|
+
- Support both Python (`"""`) and JS/TS (`/**`) comment styles
|
|
20
|
+
|
|
21
|
+
#### Issue 2: File Discovery Limitations
|
|
22
|
+
**Problem:** When running `voodocs generate . ./docs` in a directory, the tool reported "No Python files found to process" even when TypeScript or Solidity files were present.
|
|
23
|
+
|
|
24
|
+
**Root Cause:** The file discovery logic only looked for `.py` files.
|
|
25
|
+
|
|
26
|
+
**Fix:**
|
|
27
|
+
- Extended file discovery to include: `.py`, `.ts`, `.js`, `.jsx`, `.tsx`, `.sol`
|
|
28
|
+
- Updated error message to list all supported extensions
|
|
29
|
+
|
|
30
|
+
#### Issue 3: Natural Language Format Parsing
|
|
31
|
+
**Problem:** YAML-style annotations (e.g., `module_purpose: "..."`, `dependencies: []`) were not being parsed correctly.
|
|
32
|
+
|
|
33
|
+
**Fix:**
|
|
34
|
+
- Added support for natural language format alongside symbolic format
|
|
35
|
+
- Properly handle YAML-style lists with `-` markers
|
|
36
|
+
- Clean up formatting and remove trailing comment markers
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### Improvements
|
|
41
|
+
|
|
42
|
+
- **Multi-language Support:** Now works with TypeScript, JavaScript, Solidity, and Python
|
|
43
|
+
- **Dual Format Support:** Accepts both natural language (`module_purpose:`) and symbolic (`⊢{}`) formats
|
|
44
|
+
- **Better Error Messages:** Clear indication of supported file extensions
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
### Testing
|
|
49
|
+
|
|
50
|
+
All reported issues have been tested and verified:
|
|
51
|
+
|
|
52
|
+
| Test Case | Status |
|
|
53
|
+
|-----------|--------|
|
|
54
|
+
| TypeScript file with `/**@voodocs` | ✅ Pass |
|
|
55
|
+
| TypeScript file with `/**@darkarts` | ✅ Pass |
|
|
56
|
+
| Natural language format | ✅ Pass |
|
|
57
|
+
| Symbolic format | ✅ Pass |
|
|
58
|
+
| Directory discovery (`.ts` files) | ✅ Pass |
|
|
59
|
+
| Multiple files in directory | ✅ Pass |
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
### Example: Now Working
|
|
64
|
+
|
|
65
|
+
**File: test.ts**
|
|
66
|
+
```typescript
|
|
67
|
+
/**@voodocs
|
|
68
|
+
module_purpose: Test module
|
|
69
|
+
dependencies: []
|
|
70
|
+
assumptions:
|
|
71
|
+
- Node.js environment
|
|
72
|
+
*/
|
|
73
|
+
export function hello(name: string): string {
|
|
74
|
+
return `Hello, ${name}`;
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Command:**
|
|
79
|
+
```bash
|
|
80
|
+
voodocs generate ./test.ts ./docs
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Result:**
|
|
84
|
+
```markdown
|
|
85
|
+
# test.ts
|
|
86
|
+
|
|
87
|
+
**Module:** `Test module`
|
|
88
|
+
|
|
89
|
+
## Assumptions
|
|
90
|
+
|
|
91
|
+
Node.js environment
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
### Upgrade Notes
|
|
97
|
+
|
|
98
|
+
No breaking changes. Simply upgrade:
|
|
99
|
+
```bash
|
|
100
|
+
npm install -g @voodocs/cli@1.0.4
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
All existing annotations continue to work. This release only adds support for previously unsupported file types and formats.
|
|
104
|
+
|
|
105
|
+
## v1.0.3 (2024-12-21)
|
|
106
|
+
|
|
107
|
+
### ✨ New Feature: AI Instruction Generation
|
|
108
|
+
|
|
109
|
+
This release adds the `voodocs instruct` command to automatically generate AI-specific instructions for writing symbolic DarkArts annotations.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
### Added
|
|
114
|
+
|
|
115
|
+
#### `voodocs instruct` Command
|
|
116
|
+
- **Auto-detects AI environment** (Cursor, Claude, Gemini, etc.)
|
|
117
|
+
- **Generates tailored instructions** for each AI assistant
|
|
118
|
+
- **Supports multiple output formats** (console or file)
|
|
119
|
+
- **Lists available templates** with `--list-templates` flag
|
|
120
|
+
|
|
121
|
+
**Usage:**
|
|
122
|
+
```bash
|
|
123
|
+
voodocs instruct # Auto-detect and print instructions
|
|
124
|
+
voodocs instruct --ai cursor # Generate for specific AI
|
|
125
|
+
voodocs instruct --output .cursorrules # Save to file
|
|
126
|
+
voodocs instruct --list-templates # List available templates
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Updated Instruction Templates
|
|
130
|
+
- **Symbolic DarkArts format** - All templates updated to use symbolic annotations
|
|
131
|
+
- **Cursor template** - Tailored for Cursor AI
|
|
132
|
+
- **Claude template** - Tailored for Claude AI
|
|
133
|
+
- **Default template** - Generic instructions for any AI
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
### Improved
|
|
138
|
+
|
|
139
|
+
- **AI Instructions** - Now guide AIs to write symbolic `@darkarts` annotations instead of natural language `@voodocs`
|
|
140
|
+
- **Documentation** - Added comprehensive AI instruction guide
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### What This Means
|
|
145
|
+
|
|
146
|
+
With `voodocs instruct`, you can now:
|
|
147
|
+
1. Run the command in your project
|
|
148
|
+
2. Get AI-specific instructions
|
|
149
|
+
3. Add them to your `.cursorrules` or Claude project settings
|
|
150
|
+
4. Have your AI assistant automatically write correct symbolic annotations
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
### Example Workflow
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Initialize project
|
|
158
|
+
voodocs init
|
|
159
|
+
|
|
160
|
+
# Generate AI instructions
|
|
161
|
+
voodocs instruct --output .cursorrules
|
|
162
|
+
|
|
163
|
+
# Now your AI will automatically write symbolic annotations!
|
|
164
|
+
# When you write code, your AI adds:
|
|
165
|
+
/**@darkarts
|
|
166
|
+
⊳{userId must be a valid UUID}
|
|
167
|
+
⊲{Returns user object or null}
|
|
168
|
+
⊨{Does ¬ modify database}
|
|
169
|
+
⚡{O(1)}
|
|
170
|
+
*/
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
### Upgrade Notes
|
|
176
|
+
|
|
177
|
+
No breaking changes. Simply upgrade:
|
|
178
|
+
```bash
|
|
179
|
+
npm install -g @voodocs/cli@1.0.3
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## v1.0.2 (2024-12-21)
|
|
183
|
+
|
|
184
|
+
### 🔧 Critical Bug Fixes
|
|
185
|
+
|
|
186
|
+
This patch release fixes critical issues that prevented @voodocs/cli from working out of the box in standard environments.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
### Fixed
|
|
191
|
+
|
|
192
|
+
#### 1. CLI Entry Point (ModuleNotFoundError)
|
|
193
|
+
- **Fixed:** CLI entry point now correctly resolves symlinks for npm global installs
|
|
194
|
+
- **Before:** `voodocs` command failed with `ModuleNotFoundError: No module named 'cli'`
|
|
195
|
+
- **After:** Works correctly when installed globally via npm
|
|
196
|
+
- **Root Cause:** `Path(__file__).parent` didn't resolve symlinks created by npm in `.bin/`
|
|
197
|
+
- **Solution:** Added `.resolve()` to follow symlinks to actual package location
|
|
198
|
+
|
|
199
|
+
#### 2. Missing `init` Command
|
|
200
|
+
- **Fixed:** Implemented and registered the `voodocs init` command
|
|
201
|
+
- **Before:** Command referenced in documentation but didn't exist
|
|
202
|
+
- **After:** `voodocs init` creates `.voodocs.json` config and example files
|
|
203
|
+
- **Features:**
|
|
204
|
+
- Creates configuration file with sensible defaults
|
|
205
|
+
- Generates example annotated files (TypeScript and Python)
|
|
206
|
+
- Supports both `@voodocs` and `@darkarts` formats
|
|
207
|
+
- `--config-only` flag to skip example generation
|
|
208
|
+
|
|
209
|
+
#### 3. Annotation Parsing Failure for TypeScript
|
|
210
|
+
- **Fixed:** TypeScript parser now correctly identifies `/**@voodocs` and `/**@darkarts` blocks
|
|
211
|
+
- **Before:** Parser looked for `/*@voodocs` (single asterisk) and failed to find annotations
|
|
212
|
+
- **After:** Correctly matches JSDoc-style comments with `/**@voodocs` (double asterisk)
|
|
213
|
+
- **Impact:** All TypeScript/JavaScript annotations now parse correctly
|
|
214
|
+
|
|
215
|
+
#### 4. Inconsistent Terminology
|
|
216
|
+
- **Fixed:** Standardized support for both `@voodocs` and `@darkarts` tags
|
|
217
|
+
- **Before:** README used `@voodocs`, but CLI complained about missing `@darkarts`
|
|
218
|
+
- **After:** Both tags are supported and documented
|
|
219
|
+
- **Changes:**
|
|
220
|
+
- Parser accepts both `/**@voodocs` and `/**@darkarts`
|
|
221
|
+
- CLI help text clarifies support for both formats
|
|
222
|
+
- README updated with current v1.0.2 functionality
|
|
223
|
+
- Outdated commands removed from documentation
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
### Added
|
|
228
|
+
|
|
229
|
+
- **DarkArts Symbolic Format Guide:** New comprehensive guide at `docs/darkarts/DARKARTS_SYMBOLIC_GUIDE.md`
|
|
230
|
+
- **Symbol Quick Reference:** Complete reference for all symbolic annotations
|
|
231
|
+
- **Updated README:** Matches current v1.0.2 functionality with correct commands
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
### Improved
|
|
236
|
+
|
|
237
|
+
- **Better Error Messages:** More helpful error messages when annotations are missing
|
|
238
|
+
- **Documentation Accuracy:** All documentation now matches actual CLI functionality
|
|
239
|
+
- **CI/CD Example:** Added GitHub Actions workflow example for validation
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
### Testing
|
|
244
|
+
|
|
245
|
+
All fixes have been tested and verified:
|
|
246
|
+
- ✅ CLI entry point works with global npm install
|
|
247
|
+
- ✅ `voodocs init` creates config and examples
|
|
248
|
+
- ✅ TypeScript annotation parsing works correctly
|
|
249
|
+
- ✅ Both `@voodocs` and `@darkarts` tags are recognized
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
### Upgrade Notes
|
|
254
|
+
|
|
255
|
+
If you're upgrading from v1.0.1:
|
|
256
|
+
|
|
257
|
+
1. **No breaking changes** - All existing annotations continue to work
|
|
258
|
+
2. **New `init` command** - Use `voodocs init` to set up new projects
|
|
259
|
+
3. **Better TypeScript support** - Annotations will now be detected correctly
|
|
260
|
+
4. **Both formats supported** - Use either `@voodocs` or `@darkarts` tags
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
### Known Issues
|
|
265
|
+
|
|
266
|
+
None - all critical issues from v1.0.1 have been resolved.
|
|
267
|
+
|
|
1
268
|
## v1.0.1 (2024-12-21)
|
|
2
269
|
|
|
3
270
|
### 🔧 Bug Fixes: DarkArts Convert Command
|
package/README.md
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
#
|
|
1
|
+
# VooDocs - AI-Native Documentation with Validation
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@voodocs/cli)
|
|
4
4
|
[](https://voodocs.com/terms)
|
|
5
5
|
[](https://voodocs.com/support)
|
|
6
6
|
|
|
7
|
-
**
|
|
7
|
+
**VooDocs** is the only documentation tool that validates your annotations and guarantees accuracy. It combines AI-native symbolic documentation with semantic validation, performance verification, and automatic error correction.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## What Makes VooDocs Unique?
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
✅ **Semantic Validation** - Verifies that your documentation matches your code
|
|
12
|
+
✅ **Performance Validation** - Checks that complexity claims are accurate
|
|
13
|
+
✅ **Auto-Fix** - Automatically corrects common documentation errors
|
|
14
|
+
✅ **Benchmarking** - Validates performance claims with real execution data
|
|
15
|
+
✅ **Two Formats** - Natural language (`@voodocs`) or symbolic (`@darkarts`)
|
|
16
|
+
✅ **CI/CD Ready** - Strict mode with exit codes for continuous integration
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
2. **Instruct**: Run `voodocs instruct` to generate AI instructions for your coding assistant
|
|
15
|
-
3. **Code**: Your AI assistant (Cursor, Claude Code, etc.) automatically adds `@voodocs` annotations as it writes code
|
|
16
|
-
4. **Generate**: Run `voodocs generate` to produce:
|
|
17
|
-
- **Markdown Documentation**: Beautiful, human-readable docs
|
|
18
|
-
- **Automated Tests**: Comprehensive test suites (pytest, unittest, Jest)
|
|
19
|
-
- **API Specifications**: OpenAPI 3.0 and GraphQL schemas
|
|
18
|
+
---
|
|
20
19
|
|
|
21
20
|
## Quick Start
|
|
22
21
|
|
|
23
22
|
### 1. Installation
|
|
24
23
|
|
|
25
|
-
Install the CLI globally using `npm
|
|
24
|
+
Install the CLI globally using `npm`:
|
|
26
25
|
|
|
27
26
|
```bash
|
|
28
27
|
npm install -g @voodocs/cli
|
|
@@ -30,179 +29,348 @@ npm install -g @voodocs/cli
|
|
|
30
29
|
|
|
31
30
|
### 2. Initialize Your Project
|
|
32
31
|
|
|
33
|
-
Navigate to your project directory and initialize
|
|
32
|
+
Navigate to your project directory and initialize VooDocs:
|
|
34
33
|
|
|
35
34
|
```bash
|
|
36
35
|
voodocs init
|
|
37
36
|
```
|
|
38
37
|
|
|
39
|
-
This
|
|
40
|
-
|
|
41
|
-
### 3. Generate AI Instructions
|
|
42
|
-
|
|
43
|
-
Create instructions for your AI coding assistant:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
voodocs instruct
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
This creates a `VOODOCS_INSTRUCTIONS.md` file. Provide this to your AI assistant (add to `.cursorrules`, Claude project instructions, etc.).
|
|
38
|
+
This creates a `.voodocs.json` configuration file and example annotated files.
|
|
50
39
|
|
|
51
|
-
###
|
|
40
|
+
### 3. Add Annotations to Your Code
|
|
52
41
|
|
|
53
|
-
|
|
42
|
+
#### Natural Language Format (`@voodocs`)
|
|
54
43
|
|
|
55
44
|
```typescript
|
|
56
45
|
/**@voodocs
|
|
57
46
|
module_purpose: "User authentication service with JWT token generation"
|
|
58
47
|
dependencies: [
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
"bcrypt: Password hashing",
|
|
49
|
+
"jsonwebtoken: JWT token generation"
|
|
61
50
|
]
|
|
62
51
|
assumptions: [
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
"Database connection is established",
|
|
53
|
+
"User model exists with email and password fields"
|
|
54
|
+
]
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**@voodocs
|
|
58
|
+
preconditions: [
|
|
59
|
+
"email must be a valid email format",
|
|
60
|
+
"password must be at least 8 characters"
|
|
61
|
+
]
|
|
62
|
+
postconditions: [
|
|
63
|
+
"Returns a JWT token",
|
|
64
|
+
"User is authenticated in the database"
|
|
65
65
|
]
|
|
66
|
-
|
|
66
|
+
invariants: [
|
|
67
|
+
"Does not modify existing user records"
|
|
68
|
+
]
|
|
69
|
+
side_effects: [
|
|
70
|
+
"Creates a new session in the database"
|
|
71
|
+
]
|
|
72
|
+
complexity: "O(1)"
|
|
73
|
+
*/
|
|
74
|
+
export async function login(email: string, password: string): Promise<string> {
|
|
75
|
+
// ...
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### Symbolic Format (`@darkarts`)
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
/**@darkarts
|
|
83
|
+
⊢{User authentication service with JWT token generation}
|
|
84
|
+
∂{
|
|
85
|
+
bcrypt: Password hashing
|
|
86
|
+
jsonwebtoken: JWT token generation
|
|
87
|
+
}
|
|
88
|
+
⚠{
|
|
89
|
+
Database connection is established
|
|
90
|
+
User model ∃ with email ∧ password fields
|
|
91
|
+
}
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/**@darkarts
|
|
95
|
+
⊳{
|
|
96
|
+
email must be a valid email format
|
|
97
|
+
password.length ≥ 8
|
|
98
|
+
}
|
|
99
|
+
⊲{
|
|
100
|
+
Returns a JWT token
|
|
101
|
+
User is authenticated ∈ database
|
|
102
|
+
}
|
|
103
|
+
⊨{
|
|
104
|
+
Does ¬ modify existing user records
|
|
105
|
+
}
|
|
106
|
+
⚡{
|
|
107
|
+
Creates a new session ∈ database
|
|
108
|
+
}
|
|
67
109
|
*/
|
|
110
|
+
export async function login(email: string, password: string): Promise<string> {
|
|
111
|
+
// ...
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 4. Validate Your Annotations
|
|
116
|
+
|
|
117
|
+
Run validation to ensure your documentation is accurate:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
voodocs validate ./src --recursive
|
|
68
121
|
```
|
|
69
122
|
|
|
70
|
-
|
|
123
|
+
This checks:
|
|
124
|
+
- **Semantic validation**: Dependencies match imports
|
|
125
|
+
- **Performance validation**: Complexity claims are accurate
|
|
126
|
+
- **Consistency**: All required fields are present
|
|
71
127
|
|
|
72
|
-
|
|
128
|
+
### 5. Auto-Fix Issues
|
|
129
|
+
|
|
130
|
+
Automatically fix common errors:
|
|
73
131
|
|
|
74
132
|
```bash
|
|
75
|
-
|
|
76
|
-
|
|
133
|
+
voodocs fix ./src --recursive
|
|
134
|
+
```
|
|
77
135
|
|
|
78
|
-
|
|
79
|
-
voodocs generate ./src --docs-only
|
|
136
|
+
### 6. Generate Documentation
|
|
80
137
|
|
|
81
|
-
|
|
82
|
-
|
|
138
|
+
Create beautiful documentation from your annotations:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
voodocs generate ./src ./docs --recursive
|
|
83
142
|
```
|
|
84
143
|
|
|
144
|
+
---
|
|
145
|
+
|
|
85
146
|
## Core Commands
|
|
86
147
|
|
|
87
|
-
###
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
- `voodocs status`: Check project status and statistics
|
|
92
|
-
|
|
93
|
-
### Context System (Enhanced in v0.3.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
|
|
101
|
-
|
|
102
|
-
### AI Integration (NEW in v0.3.0)
|
|
103
|
-
|
|
104
|
-
VooDocs now **natively integrates** with 5+ AI assistants! When you run `voodocs context init`, it automatically:
|
|
105
|
-
- Detects existing AI configurations (Claude, Cursor, Copilot, etc.)
|
|
106
|
-
- Prompts you to select your AI assistant(s)
|
|
107
|
-
- Generates native configuration files for each AI
|
|
108
|
-
|
|
109
|
-
**Supported AI Assistants:**
|
|
110
|
-
- **Claude Code** - `.claude/skills/voodocs-context/SKILL.md`
|
|
111
|
-
- **Cursor** - `.cursor/rules/voodocs-context.mdc`
|
|
112
|
-
- **GitHub Copilot** - `.github/copilot-instructions.md`
|
|
113
|
-
- **Windsurf** - `.windsurfrules`
|
|
114
|
-
- **Cline** - `.clinerules`
|
|
115
|
-
|
|
116
|
-
Your AI will automatically understand the VooDocs context system and:
|
|
117
|
-
- Check context before making changes
|
|
118
|
-
- Respect documented invariants
|
|
119
|
-
- Update context when adding features
|
|
120
|
-
- Generate architecture diagrams
|
|
121
|
-
- Follow best practices
|
|
122
|
-
|
|
123
|
-
## The DarkArts Language
|
|
124
|
-
|
|
125
|
-
Voodocs uses the **DarkArts language** - a mathematical and logical notation system that represents how AI naturally thinks about code. Instead of forcing AI to write verbose human documentation, Voodocs lets AI express concepts precisely using:
|
|
126
|
-
|
|
127
|
-
- **Mathematical notation**: ∀, ∃, ∈, ⇒, ⇔
|
|
128
|
-
- **Formal logic**: Preconditions, postconditions, invariants
|
|
129
|
-
- **Declarative relationships**: What IS, not what to DO
|
|
130
|
-
- **Conditional reasoning**: Case-based specifications
|
|
131
|
-
|
|
132
|
-
Voodocs then translates this precise, machine-readable format into natural language documentation that humans can easily understand.
|
|
133
|
-
|
|
134
|
-
## What's New in v0.2.0
|
|
135
|
-
|
|
136
|
-
### 🔍 Invariant Checking
|
|
137
|
-
Automatically validate that your code respects documented invariants:
|
|
148
|
+
### `voodocs init`
|
|
149
|
+
|
|
150
|
+
Initialize a new project with VooDocs configuration and example files.
|
|
151
|
+
|
|
138
152
|
```bash
|
|
139
|
-
voodocs
|
|
153
|
+
voodocs init # Initialize with @voodocs format
|
|
154
|
+
voodocs init --format darkarts # Initialize with symbolic @darkarts format
|
|
155
|
+
voodocs init --config-only # Only create config file
|
|
140
156
|
```
|
|
141
|
-
Detects security issues like SQL injection, unhashed passwords, and logged secrets.
|
|
142
157
|
|
|
143
|
-
###
|
|
144
|
-
|
|
158
|
+
### `voodocs validate`
|
|
159
|
+
|
|
160
|
+
Validate annotations against your code.
|
|
161
|
+
|
|
145
162
|
```bash
|
|
146
|
-
voodocs
|
|
163
|
+
voodocs validate <path> [options]
|
|
164
|
+
|
|
165
|
+
Options:
|
|
166
|
+
-r, --recursive Process directories recursively
|
|
167
|
+
-s, --strict Exit with error code if validation fails
|
|
168
|
+
-f, --format <format> Output format: text, json, html (default: text)
|
|
169
|
+
--semantic-only Only run semantic validation
|
|
170
|
+
--performance-only Only run performance validation
|
|
147
171
|
```
|
|
148
|
-
Supports module diagrams, dependency diagrams, and flow diagrams.
|
|
149
172
|
|
|
150
|
-
|
|
151
|
-
Smart validation with actionable suggestions:
|
|
173
|
+
**Example:**
|
|
152
174
|
```bash
|
|
153
|
-
voodocs
|
|
175
|
+
voodocs validate ./src --recursive --strict
|
|
154
176
|
```
|
|
155
|
-
Provides completeness checks, quality suggestions, and consistency validation.
|
|
156
177
|
|
|
157
|
-
|
|
178
|
+
### `voodocs fix`
|
|
158
179
|
|
|
159
|
-
|
|
160
|
-
- **Single Source of Truth**: Code annotations drive docs, tests, and specs - always in sync.
|
|
161
|
-
- **Massive Time Savings**: Eliminate manual documentation work entirely.
|
|
162
|
-
- **Higher Code Quality**: Formal specifications lead to more robust and reliable code.
|
|
163
|
-
- **Precision**: Mathematical notation is unambiguous - no more vague documentation.
|
|
164
|
-
- **Verification**: Automatically check that code respects documented invariants (v0.2.0)
|
|
165
|
-
- **Visualization**: Generate architecture diagrams from context (v0.2.0)
|
|
180
|
+
Automatically fix validation errors.
|
|
166
181
|
|
|
167
|
-
|
|
182
|
+
```bash
|
|
183
|
+
voodocs fix <path> [options]
|
|
168
184
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
Options:
|
|
186
|
+
-r, --recursive Process directories recursively
|
|
187
|
+
-d, --dry-run Show what would be fixed without making changes
|
|
188
|
+
-b, --backup Create backup files before fixing
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Example:**
|
|
192
|
+
```bash
|
|
193
|
+
voodocs fix ./src --recursive --backup
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### `voodocs generate`
|
|
197
|
+
|
|
198
|
+
Generate documentation from annotations.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
voodocs generate <input> <output> [options]
|
|
202
|
+
|
|
203
|
+
Options:
|
|
204
|
+
-r, --recursive Process directories recursively
|
|
205
|
+
-f, --format <format> Output format: markdown, html (default: markdown)
|
|
206
|
+
-v, --validate Validate annotations before generating
|
|
207
|
+
--include-toc Include table of contents
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Example:**
|
|
211
|
+
```bash
|
|
212
|
+
voodocs generate ./src ./docs --recursive --validate
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### `voodocs benchmark`
|
|
216
|
+
|
|
217
|
+
Run performance benchmarks to validate complexity claims.
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
voodocs benchmark <path> [options]
|
|
221
|
+
|
|
222
|
+
Options:
|
|
223
|
+
-r, --recursive Process directories recursively
|
|
224
|
+
-f, --format <format> Output format: text, json, html (default: text)
|
|
225
|
+
--iterations <n> Number of benchmark iterations (default: 100)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Example:**
|
|
229
|
+
```bash
|
|
230
|
+
voodocs benchmark ./src --recursive --format json
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Annotation Fields
|
|
236
|
+
|
|
237
|
+
### Module-Level Annotations
|
|
238
|
+
|
|
239
|
+
| Field | Symbol | Description |
|
|
240
|
+
|-------|--------|-------------|
|
|
241
|
+
| `module_purpose` | `⊢` | Concise statement of the module's responsibility |
|
|
242
|
+
| `dependencies` | `∂` | List of critical internal or external dependencies |
|
|
243
|
+
| `assumptions` | `⚠` | Key assumptions about environment or inputs |
|
|
244
|
+
| `invariants` | `⊨` | Properties that remain unchanged |
|
|
245
|
+
| `security_model` | `🔒` | Security considerations |
|
|
246
|
+
| `performance_model` | `⚡` | Performance characteristics |
|
|
247
|
+
|
|
248
|
+
### Function/Interface-Level Annotations
|
|
249
|
+
|
|
250
|
+
| Field | Symbol | Description |
|
|
251
|
+
|-------|--------|-------------|
|
|
252
|
+
| `preconditions` | `⊳` | Conditions that must be true before execution |
|
|
253
|
+
| `postconditions` | `⊲` | Conditions that will be true after execution |
|
|
254
|
+
| `invariants` | `⊨` | Properties that remain unchanged |
|
|
255
|
+
| `side_effects` | `⚡` | Observable effects outside the return value |
|
|
256
|
+
| `security_implications` | `🔒` | Security-related considerations |
|
|
257
|
+
| `complexity` | `⚡` | Computational complexity (e.g., O(n)) |
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Symbolic Format Reference
|
|
262
|
+
|
|
263
|
+
### Logic Symbols
|
|
264
|
+
|
|
265
|
+
| Symbol | Meaning | Example |
|
|
266
|
+
|--------|---------|---------|
|
|
267
|
+
| `∧` | and | `authenticated ∧ hasPermission` |
|
|
268
|
+
| `∨` | or | `isAdmin ∨ isOwner` |
|
|
269
|
+
| `¬` | not | `¬isGuest` |
|
|
270
|
+
| `∈` | in | `userId ∈ validIds` |
|
|
271
|
+
| `∃` | exists | `∃ user: user.id = userId` |
|
|
272
|
+
| `∀` | for all | `∀ item: item.price > 0` |
|
|
273
|
+
| `⇒` | implies | `isLoggedIn ⇒ hasSession` |
|
|
274
|
+
| `⇔` | if and only if | `isActive ⇔ lastLogin < 24h` |
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## CI/CD Integration
|
|
279
|
+
|
|
280
|
+
Use VooDocs in your continuous integration pipeline:
|
|
281
|
+
|
|
282
|
+
```yaml
|
|
283
|
+
# .github/workflows/validate-docs.yml
|
|
284
|
+
name: Validate Documentation
|
|
285
|
+
|
|
286
|
+
on: [push, pull_request]
|
|
287
|
+
|
|
288
|
+
jobs:
|
|
289
|
+
validate:
|
|
290
|
+
runs-on: ubuntu-latest
|
|
291
|
+
steps:
|
|
292
|
+
- uses: actions/checkout@v2
|
|
293
|
+
|
|
294
|
+
- name: Setup Node.js
|
|
295
|
+
uses: actions/setup-node@v2
|
|
296
|
+
with:
|
|
297
|
+
node-version: '18'
|
|
298
|
+
|
|
299
|
+
- name: Install VooDocs
|
|
300
|
+
run: npm install -g @voodocs/cli
|
|
301
|
+
|
|
302
|
+
- name: Validate Annotations
|
|
303
|
+
run: voodocs validate ./src --recursive --strict
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## Configuration
|
|
309
|
+
|
|
310
|
+
Create a `.voodocs.json` file in your project root:
|
|
311
|
+
|
|
312
|
+
```json
|
|
313
|
+
{
|
|
314
|
+
"version": "1.0",
|
|
315
|
+
"format": "voodocs",
|
|
316
|
+
"validation": {
|
|
317
|
+
"semantic": true,
|
|
318
|
+
"performance": true,
|
|
319
|
+
"strict": false
|
|
320
|
+
},
|
|
321
|
+
"generation": {
|
|
322
|
+
"output_format": "markdown",
|
|
323
|
+
"include_toc": true,
|
|
324
|
+
"include_examples": true
|
|
325
|
+
},
|
|
326
|
+
"exclude": [
|
|
327
|
+
"node_modules",
|
|
328
|
+
"dist",
|
|
329
|
+
"build",
|
|
330
|
+
"__pycache__",
|
|
331
|
+
".git"
|
|
332
|
+
]
|
|
189
333
|
}
|
|
190
334
|
```
|
|
191
335
|
|
|
192
|
-
|
|
336
|
+
---
|
|
193
337
|
|
|
194
|
-
|
|
338
|
+
## Documentation
|
|
195
339
|
|
|
196
|
-
- **
|
|
197
|
-
- **
|
|
198
|
-
- **
|
|
340
|
+
- **User Guide**: [docs/darkarts/USER_GUIDE.md](docs/darkarts/USER_GUIDE.md)
|
|
341
|
+
- **API Reference**: [docs/darkarts/API_REFERENCE.md](docs/darkarts/API_REFERENCE.md)
|
|
342
|
+
- **Tutorials**: [docs/darkarts/TUTORIALS.md](docs/darkarts/TUTORIALS.md)
|
|
343
|
+
- **Symbolic Format Guide**: [docs/darkarts/DARKARTS_SYMBOLIC_GUIDE.md](docs/darkarts/DARKARTS_SYMBOLIC_GUIDE.md)
|
|
199
344
|
|
|
200
|
-
|
|
345
|
+
---
|
|
201
346
|
|
|
202
347
|
## Support
|
|
203
348
|
|
|
204
|
-
|
|
349
|
+
- **Issues**: [GitHub Issues](https://github.com/3vilEnterprises/vooodooo-magic/issues)
|
|
350
|
+
- **Email**: contact@3vil.enterprises
|
|
351
|
+
- **Website**: [voodocs.com](https://voodocs.com)
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## License
|
|
356
|
+
|
|
357
|
+
Commercial - See [LICENSE](LICENSE) for details.
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
## What's New in v1.0.1
|
|
362
|
+
|
|
363
|
+
### Bug Fixes
|
|
364
|
+
- ✅ Fixed CLI entry point (ModuleNotFoundError)
|
|
365
|
+
- ✅ Added missing `init` command
|
|
366
|
+
- ✅ Fixed annotation parsing for TypeScript files
|
|
367
|
+
- ✅ Standardized terminology (@voodocs and @darkarts both supported)
|
|
368
|
+
|
|
369
|
+
### Improvements
|
|
370
|
+
- ✅ Better error messages
|
|
371
|
+
- ✅ Improved documentation
|
|
372
|
+
- ✅ Enhanced validation accuracy
|
|
205
373
|
|
|
206
374
|
---
|
|
207
375
|
|
|
208
|
-
**
|
|
376
|
+
**VooDocs - The only documentation tool that validates your annotations and guarantees accuracy.**
|
package/lib/cli/__init__.py
CHANGED
|
@@ -16,7 +16,7 @@ This module provides the command-line interface for VooDocs.
|
|
|
16
16
|
import click
|
|
17
17
|
from typing import Optional
|
|
18
18
|
|
|
19
|
-
__version__ = "1.0.
|
|
19
|
+
__version__ = "1.0.4"
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
@click.group()
|
|
@@ -26,18 +26,24 @@ def cli(ctx):
|
|
|
26
26
|
"""
|
|
27
27
|
VooDocs - AI-Native Documentation Generator with Validation
|
|
28
28
|
|
|
29
|
-
Generate and validate @darkarts annotations in your codebase.
|
|
29
|
+
Generate and validate @voodocs and @darkarts annotations in your codebase.
|
|
30
|
+
|
|
31
|
+
Supports both natural language (@voodocs) and symbolic (@darkarts) formats.
|
|
30
32
|
"""
|
|
31
33
|
ctx.ensure_object(dict)
|
|
32
34
|
|
|
33
35
|
|
|
34
36
|
# Import subcommands
|
|
37
|
+
from .init import init
|
|
38
|
+
from .instruct import instruct
|
|
35
39
|
from .validate import validate
|
|
36
40
|
from .generate import generate
|
|
37
41
|
from .benchmark import benchmark
|
|
38
42
|
from .fix import fix
|
|
39
43
|
|
|
40
44
|
# Register commands
|
|
45
|
+
cli.add_command(init)
|
|
46
|
+
cli.add_command(instruct)
|
|
41
47
|
cli.add_command(validate)
|
|
42
48
|
cli.add_command(generate)
|
|
43
49
|
cli.add_command(benchmark)
|
package/lib/cli/generate.py
CHANGED
|
@@ -78,11 +78,19 @@ def generate(
|
|
|
78
78
|
if source_path.is_file():
|
|
79
79
|
files_to_process = [source_path]
|
|
80
80
|
elif source_path.is_dir():
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
# Support multiple file extensions
|
|
82
|
+
extensions = ['*.py', '*.ts', '*.js', '*.jsx', '*.tsx', '*.sol']
|
|
83
|
+
files_to_process = []
|
|
84
|
+
|
|
85
|
+
if recursive:
|
|
86
|
+
for ext in extensions:
|
|
87
|
+
files_to_process.extend([f for f in source_path.glob(f"**/{ext}") if f.is_file()])
|
|
88
|
+
else:
|
|
89
|
+
for ext in extensions:
|
|
90
|
+
files_to_process.extend([f for f in source_path.glob(ext) if f.is_file()])
|
|
83
91
|
|
|
84
92
|
if not files_to_process:
|
|
85
|
-
click.secho("No
|
|
93
|
+
click.secho("No files found to process. Supported extensions: .py, .ts, .js, .jsx, .tsx, .sol", fg='yellow')
|
|
86
94
|
sys.exit(1)
|
|
87
95
|
|
|
88
96
|
click.echo(f"Found {len(files_to_process)} files to process")
|
|
@@ -214,20 +222,58 @@ def _generate_doc_for_file(file_path: Path, format: str, include_private: bool)
|
|
|
214
222
|
|
|
215
223
|
|
|
216
224
|
def _extract_annotation(content: str) -> str:
|
|
217
|
-
"""Extract @darkarts annotation from file content."""
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
225
|
+
"""Extract @darkarts or @voodocs annotation from file content."""
|
|
226
|
+
import re
|
|
227
|
+
|
|
228
|
+
# Try Python docstring format first ("""@darkarts or """@voodocs)
|
|
229
|
+
python_pattern = r'"""@(?:darkarts|voodocs)\s*(.*?)"""'
|
|
230
|
+
match = re.search(python_pattern, content, re.DOTALL)
|
|
231
|
+
if match:
|
|
232
|
+
return match.group(0)
|
|
233
|
+
|
|
234
|
+
# Try TypeScript/JavaScript block comment format (/**@darkarts or /**@voodocs)
|
|
235
|
+
js_pattern = r'/\*\*@(?:darkarts|voodocs)\s*(.*?)\*/'
|
|
236
|
+
match = re.search(js_pattern, content, re.DOTALL)
|
|
237
|
+
if match:
|
|
238
|
+
return match.group(0)
|
|
239
|
+
|
|
222
240
|
return ""
|
|
223
241
|
|
|
224
242
|
|
|
225
243
|
def _extract_section(annotation: str, symbol: str) -> str:
|
|
226
|
-
"""Extract a specific section from annotation."""
|
|
244
|
+
"""Extract a specific section from annotation (supports both symbolic and natural language)."""
|
|
245
|
+
import re
|
|
246
|
+
|
|
247
|
+
# Map symbols to natural language keys
|
|
248
|
+
symbol_to_key = {
|
|
249
|
+
'⊢': 'module_purpose',
|
|
250
|
+
'∂': 'dependencies',
|
|
251
|
+
'⚠': 'assumptions',
|
|
252
|
+
'⊨': 'invariants',
|
|
253
|
+
'🔒': 'security',
|
|
254
|
+
'⚡': 'complexity'
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
# Try symbolic format first
|
|
227
258
|
lines = annotation.split('\n')
|
|
228
259
|
for line in lines:
|
|
229
260
|
if line.strip().startswith(symbol):
|
|
230
261
|
return line.strip()[len(symbol):].strip('{}')
|
|
262
|
+
|
|
263
|
+
# Try natural language format
|
|
264
|
+
key = symbol_to_key.get(symbol)
|
|
265
|
+
if key:
|
|
266
|
+
# Match key: value or key: [list]
|
|
267
|
+
pattern = rf'{key}\s*:\s*(.+?)(?=\n[a-z_]+\s*:|\*/|$)'
|
|
268
|
+
match = re.search(pattern, annotation, re.DOTALL | re.IGNORECASE)
|
|
269
|
+
if match:
|
|
270
|
+
value = match.group(1).strip()
|
|
271
|
+
# Clean up list formatting and remove trailing comment markers
|
|
272
|
+
value = value.strip('[]').strip()
|
|
273
|
+
# Remove YAML list markers and join lines
|
|
274
|
+
lines = [line.strip().lstrip('-').strip() for line in value.split('\n') if line.strip()]
|
|
275
|
+
return ', '.join(lines)
|
|
276
|
+
|
|
231
277
|
return ""
|
|
232
278
|
|
|
233
279
|
|
package/lib/cli/init.py
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢{cli:init}
|
|
3
|
+
∂{click,pathlib,json}
|
|
4
|
+
⚠{write-access:cwd}
|
|
5
|
+
⊨{idempotent:config-creation}
|
|
6
|
+
🔒{read-write:filesystem}
|
|
7
|
+
⚡{O(1):file-creation}
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
"""
|
|
11
|
+
VooDocs Init Command
|
|
12
|
+
|
|
13
|
+
Initialize a new project with VooDocs configuration and example annotations.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import click
|
|
17
|
+
import json
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@click.command()
|
|
22
|
+
@click.option(
|
|
23
|
+
'--format',
|
|
24
|
+
type=click.Choice(['voodocs', 'darkarts'], case_sensitive=False),
|
|
25
|
+
default='voodocs',
|
|
26
|
+
help='Annotation format to use (voodocs or darkarts symbolic)'
|
|
27
|
+
)
|
|
28
|
+
@click.option(
|
|
29
|
+
'--config-only',
|
|
30
|
+
is_flag=True,
|
|
31
|
+
help='Only create configuration file, skip example files'
|
|
32
|
+
)
|
|
33
|
+
def init(format, config_only):
|
|
34
|
+
"""
|
|
35
|
+
Initialize a new project with VooDocs.
|
|
36
|
+
|
|
37
|
+
Creates a .voodocs.json configuration file and optionally generates
|
|
38
|
+
example annotated files to help you get started.
|
|
39
|
+
|
|
40
|
+
Examples:
|
|
41
|
+
voodocs init # Initialize with @voodocs format
|
|
42
|
+
voodocs init --format darkarts # Initialize with symbolic @darkarts format
|
|
43
|
+
voodocs init --config-only # Only create config file
|
|
44
|
+
"""
|
|
45
|
+
cwd = Path.cwd()
|
|
46
|
+
config_path = cwd / '.voodocs.json'
|
|
47
|
+
|
|
48
|
+
# Check if config already exists
|
|
49
|
+
if config_path.exists():
|
|
50
|
+
click.echo(click.style('⚠ .voodocs.json already exists', fg='yellow'))
|
|
51
|
+
if not click.confirm('Overwrite existing configuration?'):
|
|
52
|
+
click.echo('Aborted.')
|
|
53
|
+
return
|
|
54
|
+
|
|
55
|
+
# Create default configuration
|
|
56
|
+
config = {
|
|
57
|
+
"version": "1.0",
|
|
58
|
+
"format": format,
|
|
59
|
+
"validation": {
|
|
60
|
+
"semantic": True,
|
|
61
|
+
"performance": True,
|
|
62
|
+
"strict": False
|
|
63
|
+
},
|
|
64
|
+
"generation": {
|
|
65
|
+
"output_format": "markdown",
|
|
66
|
+
"include_toc": True,
|
|
67
|
+
"include_examples": True
|
|
68
|
+
},
|
|
69
|
+
"exclude": [
|
|
70
|
+
"node_modules",
|
|
71
|
+
"dist",
|
|
72
|
+
"build",
|
|
73
|
+
"__pycache__",
|
|
74
|
+
".git",
|
|
75
|
+
"*.min.js"
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# Write configuration
|
|
80
|
+
with open(config_path, 'w') as f:
|
|
81
|
+
json.dump(config, f, indent=2)
|
|
82
|
+
|
|
83
|
+
click.echo(click.style('✓ Created .voodocs.json', fg='green'))
|
|
84
|
+
|
|
85
|
+
if not config_only:
|
|
86
|
+
# Create example files
|
|
87
|
+
examples_dir = cwd / 'voodocs-examples'
|
|
88
|
+
examples_dir.mkdir(exist_ok=True)
|
|
89
|
+
|
|
90
|
+
if format == 'voodocs':
|
|
91
|
+
create_voodocs_example(examples_dir)
|
|
92
|
+
else:
|
|
93
|
+
create_darkarts_example(examples_dir)
|
|
94
|
+
|
|
95
|
+
click.echo(click.style(f'✓ Created example files in {examples_dir}/', fg='green'))
|
|
96
|
+
|
|
97
|
+
click.echo()
|
|
98
|
+
click.echo(click.style('🎉 VooDocs initialized successfully!', fg='green', bold=True))
|
|
99
|
+
click.echo()
|
|
100
|
+
click.echo('Next steps:')
|
|
101
|
+
click.echo(' 1. Review .voodocs.json configuration')
|
|
102
|
+
click.echo(' 2. Add annotations to your code')
|
|
103
|
+
click.echo(' 3. Run: voodocs validate .')
|
|
104
|
+
click.echo(' 4. Run: voodocs generate . ./docs')
|
|
105
|
+
click.echo()
|
|
106
|
+
click.echo('Documentation: https://voodocs.com/docs')
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def create_voodocs_example(examples_dir: Path):
|
|
110
|
+
"""Create example files with @voodocs annotations."""
|
|
111
|
+
|
|
112
|
+
# TypeScript example
|
|
113
|
+
ts_example = '''/**@voodocs
|
|
114
|
+
module_purpose: "Example TypeScript module demonstrating @voodocs annotations"
|
|
115
|
+
dependencies: []
|
|
116
|
+
assumptions: ["TypeScript environment available"]
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
/**@voodocs
|
|
120
|
+
preconditions: [
|
|
121
|
+
"name must be a non-empty string",
|
|
122
|
+
"age must be a positive number"
|
|
123
|
+
]
|
|
124
|
+
postconditions: [
|
|
125
|
+
"Returns a greeting message",
|
|
126
|
+
"Message includes the provided name"
|
|
127
|
+
]
|
|
128
|
+
invariants: [
|
|
129
|
+
"Does not modify input parameters"
|
|
130
|
+
]
|
|
131
|
+
side_effects: []
|
|
132
|
+
complexity: "O(1)"
|
|
133
|
+
*/
|
|
134
|
+
export function greet(name: string, age: number): string {
|
|
135
|
+
return `Hello, ${name}! You are ${age} years old.`;
|
|
136
|
+
}
|
|
137
|
+
'''
|
|
138
|
+
|
|
139
|
+
(examples_dir / 'example.ts').write_text(ts_example)
|
|
140
|
+
|
|
141
|
+
# Python example
|
|
142
|
+
py_example = '''"""@voodocs
|
|
143
|
+
module_purpose: "Example Python module demonstrating @voodocs annotations"
|
|
144
|
+
dependencies: []
|
|
145
|
+
assumptions: ["Python 3.7+"]
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
def calculate_total(prices: list[float], tax_rate: float) -> float:
|
|
149
|
+
"""@voodocs
|
|
150
|
+
preconditions: [
|
|
151
|
+
"prices is a non-empty list of positive numbers",
|
|
152
|
+
"tax_rate is between 0 and 1"
|
|
153
|
+
]
|
|
154
|
+
postconditions: [
|
|
155
|
+
"Returns the total with tax applied",
|
|
156
|
+
"Result is greater than or equal to sum of prices"
|
|
157
|
+
]
|
|
158
|
+
invariants: [
|
|
159
|
+
"Does not modify the prices list"
|
|
160
|
+
]
|
|
161
|
+
side_effects: []
|
|
162
|
+
complexity: "O(n) where n is the length of prices"
|
|
163
|
+
"""
|
|
164
|
+
subtotal = sum(prices)
|
|
165
|
+
return subtotal * (1 + tax_rate)
|
|
166
|
+
'''
|
|
167
|
+
|
|
168
|
+
(examples_dir / 'example.py').write_text(py_example)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def create_darkarts_example(examples_dir: Path):
|
|
172
|
+
"""Create example files with symbolic @darkarts annotations."""
|
|
173
|
+
|
|
174
|
+
# TypeScript example
|
|
175
|
+
ts_example = '''/**@darkarts
|
|
176
|
+
⊢{Example TypeScript module demonstrating symbolic @darkarts annotations}
|
|
177
|
+
∂{}
|
|
178
|
+
⚠{TypeScript environment available}
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
/**@darkarts
|
|
182
|
+
⊳{
|
|
183
|
+
name must be a non-empty string
|
|
184
|
+
age must be a positive number
|
|
185
|
+
}
|
|
186
|
+
⊲{
|
|
187
|
+
Returns a greeting message
|
|
188
|
+
Message includes the provided name
|
|
189
|
+
}
|
|
190
|
+
⊨{
|
|
191
|
+
Does ¬ modify input parameters
|
|
192
|
+
}
|
|
193
|
+
⚡{}
|
|
194
|
+
*/
|
|
195
|
+
export function greet(name: string, age: number): string {
|
|
196
|
+
return `Hello, ${name}! You are ${age} years old.`;
|
|
197
|
+
}
|
|
198
|
+
'''
|
|
199
|
+
|
|
200
|
+
(examples_dir / 'example.ts').write_text(ts_example)
|
|
201
|
+
|
|
202
|
+
# Python example
|
|
203
|
+
py_example = '''"""@darkarts
|
|
204
|
+
⊢{Example Python module demonstrating symbolic @darkarts annotations}
|
|
205
|
+
∂{}
|
|
206
|
+
⚠{Python 3.7+}
|
|
207
|
+
"""
|
|
208
|
+
|
|
209
|
+
def calculate_total(prices: list[float], tax_rate: float) -> float:
|
|
210
|
+
"""@darkarts
|
|
211
|
+
⊳{
|
|
212
|
+
prices is a non-empty list ∧ ∀ p ∈ prices: p > 0
|
|
213
|
+
tax_rate ∈ [0, 1]
|
|
214
|
+
}
|
|
215
|
+
⊲{
|
|
216
|
+
Returns the total with tax applied
|
|
217
|
+
result ≥ sum(prices)
|
|
218
|
+
}
|
|
219
|
+
⊨{
|
|
220
|
+
Does ¬ modify the prices list
|
|
221
|
+
}
|
|
222
|
+
⚡{O(n) where n = len(prices)}
|
|
223
|
+
"""
|
|
224
|
+
subtotal = sum(prices)
|
|
225
|
+
return subtotal * (1 + tax_rate)
|
|
226
|
+
'''
|
|
227
|
+
|
|
228
|
+
(examples_dir / 'example.py').write_text(py_example)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""@darkarts
|
|
2
|
+
⊢{cli:instruct}
|
|
3
|
+
∂{click,pathlib,darkarts.instruction_generator,darkarts.ai_detector}
|
|
4
|
+
⚠{write-access:cwd}
|
|
5
|
+
⊨{idempotent:instruction-generation}
|
|
6
|
+
🔒{read-write:filesystem}
|
|
7
|
+
⚡{O(1):file-creation}
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
"""
|
|
11
|
+
VooDocs Instruct Command
|
|
12
|
+
|
|
13
|
+
Generate AI-specific instructions for writing @darkarts annotations.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import click
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
import sys
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
# Add parent directory to path for imports
|
|
22
|
+
parent_dir = Path(__file__).parent.parent
|
|
23
|
+
sys.path.insert(0, str(parent_dir))
|
|
24
|
+
|
|
25
|
+
from darkarts.instruction_generator import InstructionGenerator
|
|
26
|
+
from darkarts.ai_detector import AIEnvironment, detect_ai_environment
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@click.command()
|
|
30
|
+
@click.option(
|
|
31
|
+
'--ai',
|
|
32
|
+
type=click.Choice([e.value for e in AIEnvironment], case_sensitive=False),
|
|
33
|
+
default=None,
|
|
34
|
+
help='Specify the AI environment (e.g., cursor, claude, gemini). Auto-detects if not provided.'
|
|
35
|
+
)
|
|
36
|
+
@click.option(
|
|
37
|
+
'--output',
|
|
38
|
+
type=click.Path(dir_okay=False, writable=True),
|
|
39
|
+
default=None,
|
|
40
|
+
help='Output file path. Prints to console if not provided.'
|
|
41
|
+
)
|
|
42
|
+
@click.option(
|
|
43
|
+
'--list-templates',
|
|
44
|
+
is_flag=True,
|
|
45
|
+
help='List all available AI instruction templates.'
|
|
46
|
+
)
|
|
47
|
+
def instruct(ai, output, list_templates):
|
|
48
|
+
"""
|
|
49
|
+
Generate AI instructions for writing symbolic @darkarts annotations.
|
|
50
|
+
|
|
51
|
+
Detects the AI environment (Cursor, Claude, etc.) and generates tailored
|
|
52
|
+
instructions to guide the AI in writing correct symbolic annotations.
|
|
53
|
+
|
|
54
|
+
Examples:
|
|
55
|
+
voodocs instruct # Auto-detect AI and print instructions
|
|
56
|
+
voodocs instruct --ai cursor # Generate instructions for Cursor
|
|
57
|
+
voodocs instruct --output .cursorrules # Save to .cursorrules file
|
|
58
|
+
voodocs instruct --list-templates # List available templates
|
|
59
|
+
"""
|
|
60
|
+
generator = InstructionGenerator()
|
|
61
|
+
|
|
62
|
+
if list_templates:
|
|
63
|
+
templates = generator.list_available_templates()
|
|
64
|
+
if not templates:
|
|
65
|
+
click.echo(click.style('No instruction templates found.', fg='yellow'))
|
|
66
|
+
return
|
|
67
|
+
|
|
68
|
+
click.echo(click.style('Available AI instruction templates:', fg='green', bold=True))
|
|
69
|
+
for template in templates:
|
|
70
|
+
click.echo(f'- {template}')
|
|
71
|
+
return
|
|
72
|
+
|
|
73
|
+
# Determine AI environment
|
|
74
|
+
if ai:
|
|
75
|
+
try:
|
|
76
|
+
environment = AIEnvironment(ai.lower())
|
|
77
|
+
except ValueError:
|
|
78
|
+
click.echo(click.style(f'Error: Invalid AI environment "{ai}"', fg='red'))
|
|
79
|
+
click.echo(f'Available options: {[e.value for e in AIEnvironment]}')
|
|
80
|
+
return
|
|
81
|
+
else:
|
|
82
|
+
environment = detect_ai_environment()
|
|
83
|
+
click.echo(click.style(f'Auto-detected AI environment: {environment.value}', fg='cyan'))
|
|
84
|
+
|
|
85
|
+
# Generate instructions
|
|
86
|
+
try:
|
|
87
|
+
instructions = generator.generate(environment)
|
|
88
|
+
except FileNotFoundError:
|
|
89
|
+
click.echo(click.style(f'Error: No instruction template found for {environment.value}', fg='red'))
|
|
90
|
+
click.echo(f'Defaulting to generic instructions...')
|
|
91
|
+
environment = AIEnvironment.DEFAULT
|
|
92
|
+
instructions = generator.generate(environment)
|
|
93
|
+
|
|
94
|
+
# Output instructions
|
|
95
|
+
if output:
|
|
96
|
+
output_path = Path(output)
|
|
97
|
+
output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
98
|
+
output_path.write_text(instructions, encoding='utf-8')
|
|
99
|
+
click.echo(click.style(f'✓ Instructions saved to {output_path}', fg='green'))
|
|
100
|
+
else:
|
|
101
|
+
click.echo('\n' + '-'*20 + ' AI Instructions ' + '-'*20 + '\n')
|
|
102
|
+
click.echo(instructions)
|
|
103
|
+
click.echo('\n' + '-'*58 + '\n')
|
|
104
|
+
|
|
105
|
+
if environment == AIEnvironment.CURSOR and not output:
|
|
106
|
+
click.echo(click.style('Tip: Save these instructions to a .cursorrules file in your project root.', fg='yellow'))
|
|
107
|
+
elif environment == AIEnvironment.CLAUDE and not output:
|
|
108
|
+
click.echo(click.style('Tip: Add these instructions to your Claude project settings.', fg='yellow'))
|
|
@@ -50,16 +50,16 @@ class AnnotationParser:
|
|
|
50
50
|
Language.PYTHON: r'"""@voodocs\s*(.*?)\s*"""',
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
# DarkArts patterns (symbolic annotations)
|
|
53
|
+
# DarkArts patterns (symbolic annotations) - support both @voodocs and @darkarts
|
|
54
54
|
DARKARTS_PATTERNS = {
|
|
55
|
-
Language.PYTHON: r'"""@darkarts\s*(.*?)\s*"""',
|
|
56
|
-
Language.TYPESCRIPT: r'
|
|
57
|
-
Language.JAVASCRIPT: r'
|
|
58
|
-
Language.JAVA: r'
|
|
59
|
-
Language.CPP: r'
|
|
60
|
-
Language.CSHARP: r'
|
|
61
|
-
Language.GO: r'
|
|
62
|
-
Language.RUST: r'
|
|
55
|
+
Language.PYTHON: r'"""@(?:darkarts|voodocs)\s*(.*?)\s*"""',
|
|
56
|
+
Language.TYPESCRIPT: r'/\*\*@(?:darkarts|voodocs)\s*(.*?)\s*\*/',
|
|
57
|
+
Language.JAVASCRIPT: r'/\*\*@(?:darkarts|voodocs)\s*(.*?)\s*\*/',
|
|
58
|
+
Language.JAVA: r'/\*\*@(?:darkarts|voodocs)\s*(.*?)\s*\*/',
|
|
59
|
+
Language.CPP: r'/\*\*@(?:darkarts|voodocs)\s*(.*?)\s*\*/',
|
|
60
|
+
Language.CSHARP: r'/\*\*@(?:darkarts|voodocs)\s*(.*?)\s*\*/',
|
|
61
|
+
Language.GO: r'/\*\*@(?:darkarts|voodocs)\s*(.*?)\s*\*/',
|
|
62
|
+
Language.RUST: r'/\*\*@(?:darkarts|voodocs)\s*(.*?)\s*\*/',
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
def __init__(self):
|
package/package.json
CHANGED
package/voodocs_cli.py
CHANGED
|
@@ -17,8 +17,9 @@ This is the main entry point for the voodocs command-line tool.
|
|
|
17
17
|
import sys
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
|
|
20
|
-
# Add lib to path
|
|
21
|
-
|
|
20
|
+
# Add lib to path - resolve symlinks for npm global installs
|
|
21
|
+
script_path = Path(__file__).resolve()
|
|
22
|
+
lib_path = script_path.parent / "lib"
|
|
22
23
|
sys.path.insert(0, str(lib_path))
|
|
23
24
|
|
|
24
25
|
# Import and run CLI
|