@voodocs/cli 0.1.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.
Files changed (52) hide show
  1. package/LICENSE +37 -0
  2. package/README.md +153 -0
  3. package/USAGE.md +314 -0
  4. package/cli.py +1340 -0
  5. package/examples/.cursorrules +437 -0
  6. package/examples/instructions/.claude/instructions.md +372 -0
  7. package/examples/instructions/.cursorrules +437 -0
  8. package/examples/instructions/.windsurfrules +437 -0
  9. package/examples/instructions/VOODOCS_INSTRUCTIONS.md +437 -0
  10. package/examples/math_example.py +41 -0
  11. package/examples/phase2_test.py +24 -0
  12. package/examples/test_compound_conditions.py +40 -0
  13. package/examples/test_math_example.py +186 -0
  14. package/lib/darkarts/README.md +115 -0
  15. package/lib/darkarts/__init__.py +16 -0
  16. package/lib/darkarts/annotations/__init__.py +34 -0
  17. package/lib/darkarts/annotations/parser.py +618 -0
  18. package/lib/darkarts/annotations/types.py +181 -0
  19. package/lib/darkarts/cli.py +128 -0
  20. package/lib/darkarts/core/__init__.py +32 -0
  21. package/lib/darkarts/core/interface.py +256 -0
  22. package/lib/darkarts/core/loader.py +231 -0
  23. package/lib/darkarts/core/plugin.py +215 -0
  24. package/lib/darkarts/core/registry.py +146 -0
  25. package/lib/darkarts/exceptions.py +51 -0
  26. package/lib/darkarts/parsers/typescript/dist/cli.d.ts +9 -0
  27. package/lib/darkarts/parsers/typescript/dist/cli.d.ts.map +1 -0
  28. package/lib/darkarts/parsers/typescript/dist/cli.js +69 -0
  29. package/lib/darkarts/parsers/typescript/dist/cli.js.map +1 -0
  30. package/lib/darkarts/parsers/typescript/dist/parser.d.ts +111 -0
  31. package/lib/darkarts/parsers/typescript/dist/parser.d.ts.map +1 -0
  32. package/lib/darkarts/parsers/typescript/dist/parser.js +365 -0
  33. package/lib/darkarts/parsers/typescript/dist/parser.js.map +1 -0
  34. package/lib/darkarts/parsers/typescript/package-lock.json +51 -0
  35. package/lib/darkarts/parsers/typescript/package.json +19 -0
  36. package/lib/darkarts/parsers/typescript/src/cli.ts +41 -0
  37. package/lib/darkarts/parsers/typescript/src/parser.ts +408 -0
  38. package/lib/darkarts/parsers/typescript/tsconfig.json +19 -0
  39. package/lib/darkarts/plugins/voodocs/__init__.py +379 -0
  40. package/lib/darkarts/plugins/voodocs/ai_native_plugin.py +151 -0
  41. package/lib/darkarts/plugins/voodocs/annotation_validator.py +280 -0
  42. package/lib/darkarts/plugins/voodocs/api_spec_generator.py +486 -0
  43. package/lib/darkarts/plugins/voodocs/documentation_generator.py +610 -0
  44. package/lib/darkarts/plugins/voodocs/html_exporter.py +260 -0
  45. package/lib/darkarts/plugins/voodocs/instruction_generator.py +706 -0
  46. package/lib/darkarts/plugins/voodocs/pdf_exporter.py +66 -0
  47. package/lib/darkarts/plugins/voodocs/test_generator.py +636 -0
  48. package/package.json +70 -0
  49. package/requirements.txt +13 -0
  50. package/templates/ci/github-actions.yml +73 -0
  51. package/templates/ci/gitlab-ci.yml +35 -0
  52. package/templates/ci/pre-commit-hook.sh +26 -0
@@ -0,0 +1,437 @@
1
+ # VooDocs Instructions for Cursor
2
+
3
+ **Project**: VooDocs Example Project
4
+ **Generated**: Automatically by VooDocs
5
+ **Purpose**: Guide AI assistants to document code using @voodocs annotations
6
+
7
+ ---
8
+
9
+ ## Overview
10
+
11
+ VooDocs is an AI-native documentation system that allows you to document code in **DarkArts language** - a mathematical and logical notation that AI naturally understands. Your annotations will be automatically translated into human-readable documentation, property-based tests, and API specifications.
12
+
13
+ **Key Benefits:**
14
+ - Document in AI's native language (mathematical notation)
15
+ - Automatic generation of comprehensive tests
16
+ - Property-based testing with Hypothesis
17
+ - OpenAPI/GraphQL spec generation
18
+ - Human-readable documentation output
19
+
20
+ **Your Role:**
21
+ As an AI coding assistant, you should add `@voodocs` annotations to **every significant function, class, and module** you write. Think of it as "documentation-driven development" where you specify the contract first.
22
+
23
+ ## Core Principles
24
+
25
+ When writing code with VooDocs annotations, follow these principles:
26
+
27
+ 1. **Annotate as you code** - Add `@voodocs` annotations immediately when creating functions/classes
28
+ 2. **Be precise** - Use mathematical notation for exact specifications
29
+ 3. **Think in contracts** - Define preconditions, postconditions, and invariants
30
+ 4. **Specify complexity** - Always include time/space complexity
31
+ 5. **Document security** - Note security implications and assumptions
32
+ 6. **Fail-safe design** - Specify error cases and how they're handled
33
+
34
+ ## Annotation Syntax (Python)
35
+
36
+ Place `@voodocs` annotations in docstrings:
37
+
38
+ ```python
39
+ def function_name(param1: type, param2: type) -> return_type:
40
+ """@voodocs
41
+ preconditions: ["param1 > 0", "param2 is not None"]
42
+ postconditions: ["result >= param1"]
43
+ complexity: "O(n)"
44
+ """
45
+ # Implementation
46
+ pass
47
+ ```
48
+
49
+ For classes:
50
+
51
+ ```python
52
+ class ClassName:
53
+ """@voodocs
54
+ class_invariants: ["∀ item ∈ self.items: item.is_valid()"]
55
+ state_transitions: ["IDLE → PROCESSING", "PROCESSING → COMPLETE"]
56
+ """
57
+ pass
58
+ ```
59
+
60
+ ## Annotation Fields Reference
61
+
62
+ ### For Functions/Methods
63
+
64
+ | Field | Required | Description | Example |
65
+ |-------|----------|-------------|---------|
66
+ | `preconditions` | Recommended | Conditions that must be true before execution | `["x > 0", "user is authenticated"]` |
67
+ | `postconditions` | Recommended | Conditions guaranteed after execution | `["result > 0", "database updated"]` |
68
+ | `complexity` | Recommended | Time/space complexity | `"O(n log n)"` or `"O(n)"` |
69
+ | `invariants` | Optional | Properties that remain unchanged | `["∀ x: x ∈ original_set ⇒ x ∈ result_set"]` |
70
+ | `error_cases` | Optional | Error conditions and exceptions | `["x < 0 → ValueError", "file not found → FileNotFoundError"]` |
71
+ | `side_effects` | Optional | External changes made | `["Writes to database", "Sends email"]` |
72
+ | `security_implications` | Optional | Security considerations | `["Requires admin role", "Rate limited"]` |
73
+ | `assumptions` | Optional | Environmental assumptions | `["Database is available", "Network is stable"]` |
74
+
75
+ ### For Classes
76
+
77
+ | Field | Description | Example |
78
+ |-------|-------------|---------|
79
+ | `class_invariants` | Properties that always hold | `["∀ item ∈ queue: item.status ∈ VALID_STATUSES"]` |
80
+ | `state_transitions` | Valid state changes | `["IDLE → PROCESSING", "PROCESSING → COMPLETE"]` |
81
+ | `thread_safety` | Concurrency safety | `"Thread-safe with mutex"` or `"Not thread-safe"` |
82
+
83
+ ### For Modules
84
+
85
+ | Field | Description | Example |
86
+ |-------|-------------|---------|
87
+ | `module_purpose` | High-level module description | `"User authentication and authorization"` |
88
+ | `dependencies` | External dependencies | `["@supabase/supabase-js", "bcrypt"]` |
89
+ | `assumptions` | Module-level assumptions | `["Database schema v2.0", "Redis available"]` |
90
+ | `security_model` | Overall security approach | `"Defense in depth - fails closed"` |
91
+
92
+ ## DarkArts Language Guide
93
+
94
+ DarkArts is a mathematical notation language for precise specifications. Use these symbols:
95
+
96
+ ### Logical Operators
97
+
98
+ | Symbol | Meaning | Example |
99
+ |--------|---------|---------|
100
+ | `∧` | AND | `x > 0 ∧ y > 0` |
101
+ | `∨` | OR | `x = 0 ∨ y = 0` |
102
+ | `¬` | NOT | `¬(x < 0)` |
103
+ | `⇒` | IMPLIES | `x > 0 ⇒ result > 0` |
104
+ | `⇔` | IF AND ONLY IF | `result = true ⇔ user.isAdmin` |
105
+
106
+ ### Quantifiers
107
+
108
+ | Symbol | Meaning | Example |
109
+ |--------|---------|---------|
110
+ | `∀` | FOR ALL | `∀ x ∈ items: x > 0` |
111
+ | `∃` | THERE EXISTS | `∃ x ∈ items: x = target` |
112
+
113
+ ### Set Operations
114
+
115
+ | Symbol | Meaning | Example |
116
+ |--------|---------|---------|
117
+ | `∈` | IN / ELEMENT OF | `x ∈ valid_values` |
118
+ | `∉` | NOT IN | `x ∉ blacklist` |
119
+ | `⊆` | SUBSET OF | `result ⊆ input` |
120
+ | `∪` | UNION | `result = set1 ∪ set2` |
121
+ | `∩` | INTERSECTION | `common = set1 ∩ set2` |
122
+
123
+ ### Comparisons
124
+
125
+ | Symbol | Meaning | Example |
126
+ |--------|---------|---------|
127
+ | `≥` | GREATER THAN OR EQUAL | `x ≥ 0` |
128
+ | `≤` | LESS THAN OR EQUAL | `x ≤ 100` |
129
+ | `≠` | NOT EQUAL | `x ≠ 0` |
130
+ | `≈` | APPROXIMATELY EQUAL | `result ≈ expected` |
131
+
132
+ ### Number Sets
133
+
134
+ | Symbol | Meaning | Example |
135
+ |--------|---------|---------|
136
+ | `ℕ` | Natural numbers (0, 1, 2, ...) | `n ∈ ℕ` |
137
+ | `ℤ` | Integers (..., -1, 0, 1, ...) | `x ∈ ℤ` |
138
+ | `ℝ` | Real numbers | `x ∈ ℝ` |
139
+
140
+ **Tip**: You can use plain English too! VooDocs understands both mathematical notation and natural language. Mix them for clarity.
141
+
142
+ ## Examples
143
+
144
+ ### Example 1: Simple Function
145
+
146
+ ```python
147
+ def calculate_discount(price: float, discount_percent: float) -> float:
148
+ """@voodocs
149
+ preconditions: [
150
+ "price > 0",
151
+ "discount_percent >= 0",
152
+ "discount_percent <= 100"
153
+ ]
154
+ postconditions: [
155
+ "result >= 0",
156
+ "result <= price",
157
+ "result = price * (1 - discount_percent/100)"
158
+ ]
159
+ complexity: "O(1)"
160
+ error_cases: [
161
+ "price <= 0 → ValueError",
162
+ "discount_percent < 0 → ValueError",
163
+ "discount_percent > 100 → ValueError"
164
+ ]
165
+ """
166
+ if price <= 0:
167
+ raise ValueError("Price must be positive")
168
+ if not 0 <= discount_percent <= 100:
169
+ raise ValueError("Discount must be between 0 and 100")
170
+
171
+ return price * (1 - discount_percent / 100)
172
+ ```
173
+
174
+ ### Example 2: Function with Security
175
+
176
+ ```python
177
+ def delete_user(user_id: str, admin_token: str) -> bool:
178
+ """@voodocs
179
+ preconditions: [
180
+ "user_id is valid UUID",
181
+ "admin_token is valid JWT",
182
+ "admin has 'delete_user' permission"
183
+ ]
184
+ postconditions: [
185
+ "returns true ⇔ user deleted successfully",
186
+ "returns false ⇔ user not found ∨ permission denied"
187
+ ]
188
+ security_implications: [
189
+ "Requires admin authentication",
190
+ "Logs deletion for audit trail",
191
+ "Soft delete - data retained for 30 days"
192
+ ]
193
+ side_effects: [
194
+ "Writes to audit log",
195
+ "Sends notification email",
196
+ "Invalidates user sessions"
197
+ ]
198
+ complexity: "O(1)"
199
+ """
200
+ # Implementation
201
+ pass
202
+ ```
203
+
204
+ ### Example 3: Class with Invariants
205
+
206
+ ```python
207
+ class BankAccount:
208
+ """@voodocs
209
+ class_invariants: [
210
+ "self.balance >= 0",
211
+ "len(self.transactions) >= 0",
212
+ "∀ tx ∈ self.transactions: tx.amount ≠ 0"
213
+ ]
214
+ state_transitions: [
215
+ "PENDING → ACTIVE: when KYC verified",
216
+ "ACTIVE → FROZEN: when suspicious activity detected",
217
+ "FROZEN → ACTIVE: when investigation cleared",
218
+ "ACTIVE → CLOSED: when user requests closure"
219
+ ]
220
+ thread_safety: "Thread-safe with account-level mutex"
221
+ """
222
+
223
+ def __init__(self, account_id: str):
224
+ self.balance = 0.0
225
+ self.transactions = []
226
+ self.status = "PENDING"
227
+
228
+ def deposit(self, amount: float) -> bool:
229
+ """@voodocs
230
+ preconditions: [
231
+ "amount > 0",
232
+ "self.status = ACTIVE"
233
+ ]
234
+ postconditions: [
235
+ "self.balance = old(self.balance) + amount",
236
+ "len(self.transactions) = old(len(self.transactions)) + 1"
237
+ ]
238
+ invariants: [
239
+ "self.balance >= 0"
240
+ ]
241
+ complexity: "O(1)"
242
+ """
243
+ # Implementation
244
+ pass
245
+ ```
246
+
247
+ ### Example 4: Algorithm with Complexity
248
+
249
+ ```python
250
+ def quicksort(arr: list[int]) -> list[int]:
251
+ """@voodocs
252
+ preconditions: [
253
+ "arr is list of integers"
254
+ ]
255
+ postconditions: [
256
+ "len(result) = len(arr)",
257
+ "∀ i, j: i < j ⇒ result[i] <= result[j]",
258
+ "result contains same elements as arr (permutation)"
259
+ ]
260
+ complexity: "O(n log n)"
261
+ invariants: [
262
+ "Partition maintains: ∀ x ∈ left: x <= pivot",
263
+ "∀ x ∈ right: x > pivot"
264
+ ]
265
+ """
266
+ # Implementation
267
+ pass
268
+ ```
269
+
270
+ ## Workflow Integration
271
+
272
+ ### When to Add Annotations
273
+
274
+ Add `@voodocs` annotations in these scenarios:
275
+
276
+ 1. **New Functions** - Annotate immediately after writing the function signature
277
+ 2. **New Classes** - Annotate class and all public methods
278
+ 3. **API Endpoints** - Always annotate with security and side effects
279
+ 4. **Complex Logic** - Annotate algorithms with complexity and invariants
280
+ 5. **Security-Critical Code** - Always annotate with security implications
281
+
282
+ ### Annotation Workflow
283
+
284
+ ```
285
+ 1. Write function signature
286
+
287
+ 2. Add @voodocs annotation with preconditions/postconditions
288
+
289
+ 3. Implement function body
290
+
291
+ 4. Verify implementation matches postconditions
292
+
293
+ 5. Run `voodocs generate` to create tests and docs
294
+ ```
295
+
296
+ ### Generated Outputs
297
+
298
+ When you annotate code with `@voodocs`, the following are automatically generated:
299
+
300
+ 1. **Property-Based Tests** - Hypothesis tests with inferred strategies
301
+ 2. **Documentation** - Human-readable Markdown docs
302
+ 3. **API Specs** - OpenAPI 3.0 or GraphQL schemas
303
+ 4. **Type Hints** - Enhanced type information
304
+
305
+ ### Example Generation
306
+
307
+ Given this annotation:
308
+
309
+ ```python
310
+ """@voodocs
311
+ preconditions: ["x > 0", "y > 0"]
312
+ postconditions: ["result > x", "result > y"]
313
+ complexity: "O(1)"
314
+ """
315
+ ```
316
+
317
+ VooDocs generates:
318
+
319
+ ```python
320
+ # Generated test
321
+ @given(x=st.integers(min_value=1), y=st.integers(min_value=1))
322
+ def test_property_based_add(x, y):
323
+ assume(x > 0)
324
+ assume(y > 0)
325
+ result = add(x, y)
326
+ assert result > x
327
+ assert result > y
328
+ ```
329
+
330
+ ## Best Practices
331
+
332
+ ### 1. Be Specific with Preconditions
333
+
334
+ **Good:**
335
+ ```python
336
+ preconditions: [
337
+ "amount > 0",
338
+ "amount <= account.balance",
339
+ "account.status = ACTIVE"
340
+ ]
341
+ ```
342
+
343
+ **Avoid:**
344
+ ```python
345
+ preconditions: ["valid input"] # Too vague
346
+ ```
347
+
348
+ ### 2. Use Mathematical Notation for Precision
349
+
350
+ **Good:**
351
+ ```python
352
+ postconditions: [
353
+ "∀ x ∈ result: x ∈ input", # All results are from input
354
+ "len(result) ≤ len(input)" # Result is subset
355
+ ]
356
+ ```
357
+
358
+ **Avoid:**
359
+ ```python
360
+ postconditions: ["returns filtered list"] # Imprecise
361
+ ```
362
+
363
+ ### 3. Always Specify Complexity
364
+
365
+ **Good:**
366
+ ```python
367
+ complexity: "O(n log n)"
368
+ ```
369
+
370
+ **Also Good:**
371
+ ```python
372
+ complexity: "O(n)" # VooDocs infers space as O(1)
373
+ ```
374
+
375
+ ### 4. Document Security Implications
376
+
377
+ **Good:**
378
+ ```python
379
+ security_implications: [
380
+ "Requires admin role",
381
+ "Rate limited to 100 requests/hour",
382
+ "Validates CSRF token"
383
+ ]
384
+ ```
385
+
386
+ ### 5. Specify Error Cases
387
+
388
+ **Good:**
389
+ ```python
390
+ error_cases: [
391
+ "amount <= 0 → ValueError",
392
+ "insufficient funds → InsufficientFundsError",
393
+ "account frozen → AccountFrozenError"
394
+ ]
395
+ ```
396
+
397
+ ### 6. Use Invariants for Loops and Recursion
398
+
399
+ **Good:**
400
+ ```python
401
+ invariants: [
402
+ "∀ iteration: 0 <= i < len(arr)",
403
+ "sorted(arr[0:i])" # First i elements are sorted
404
+ ]
405
+ ```
406
+
407
+ ### 7. Document Side Effects
408
+
409
+ **Good:**
410
+ ```python
411
+ side_effects: [
412
+ "Writes to database",
413
+ "Sends email notification",
414
+ "Updates cache"
415
+ ]
416
+ ```
417
+
418
+ **Avoid:**
419
+ ```python
420
+ side_effects: ["Does stuff"] # Too vague
421
+ ```
422
+
423
+ ---
424
+
425
+ ## Summary
426
+
427
+ **Remember**: Every time you write a function or class, ask yourself:
428
+
429
+ 1. What must be true before this runs? → **preconditions**
430
+ 2. What will be true after this runs? → **postconditions**
431
+ 3. How fast is this? → **complexity**
432
+ 4. What can go wrong? → **error_cases**
433
+ 5. Is this security-sensitive? → **security_implications**
434
+
435
+ By documenting in DarkArts language, you're not just writing comments - you're creating a **formal specification** that generates tests, documentation, and API specs automatically.
436
+
437
+ **Generated by VooDocs** - AI-native documentation for modern development.