@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,372 @@
1
+ # VooDocs Instructions for Claude Code / Cline
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 (TypeScript/JavaScript)
35
+
36
+ Place `@voodocs` annotations in JSDoc-style comments:
37
+
38
+ ```typescript
39
+ /**@voodocs
40
+ preconditions: ["amount > 0", "account.isActive()"]
41
+ postconditions: ["account.balance decreased by amount"]
42
+ complexity: "O(1)"
43
+ security_implications: ["Requires authentication", "Validates account ownership"]
44
+ */
45
+ function withdraw(account: Account, amount: number): boolean {
46
+ // Implementation
47
+ }
48
+ ```
49
+
50
+ For classes:
51
+
52
+ ```typescript
53
+ /**@voodocs
54
+ class_invariants: ["this.balance >= 0", "this.transactions.length >= 0"]
55
+ state_transitions: ["PENDING → ACTIVE", "ACTIVE → SUSPENDED", "SUSPENDED → CLOSED"]
56
+ */
57
+ class BankAccount {
58
+ // Implementation
59
+ }
60
+ ```
61
+
62
+ ## Annotation Fields Reference
63
+
64
+ ### For Functions/Methods
65
+
66
+ | Field | Required | Description | Example |
67
+ |-------|----------|-------------|---------|
68
+ | `preconditions` | Recommended | Conditions that must be true before execution | `["x > 0", "user is authenticated"]` |
69
+ | `postconditions` | Recommended | Conditions guaranteed after execution | `["result > 0", "database updated"]` |
70
+ | `complexity` | Recommended | Time/space complexity | `"O(n log n)"` or `"O(n)"` |
71
+ | `invariants` | Optional | Properties that remain unchanged | `["∀ x: x ∈ original_set ⇒ x ∈ result_set"]` |
72
+ | `error_cases` | Optional | Error conditions and exceptions | `["x < 0 → ValueError", "file not found → FileNotFoundError"]` |
73
+ | `side_effects` | Optional | External changes made | `["Writes to database", "Sends email"]` |
74
+ | `security_implications` | Optional | Security considerations | `["Requires admin role", "Rate limited"]` |
75
+ | `assumptions` | Optional | Environmental assumptions | `["Database is available", "Network is stable"]` |
76
+
77
+ ### For Classes
78
+
79
+ | Field | Description | Example |
80
+ |-------|-------------|---------|
81
+ | `class_invariants` | Properties that always hold | `["∀ item ∈ queue: item.status ∈ VALID_STATUSES"]` |
82
+ | `state_transitions` | Valid state changes | `["IDLE → PROCESSING", "PROCESSING → COMPLETE"]` |
83
+ | `thread_safety` | Concurrency safety | `"Thread-safe with mutex"` or `"Not thread-safe"` |
84
+
85
+ ### For Modules
86
+
87
+ | Field | Description | Example |
88
+ |-------|-------------|---------|
89
+ | `module_purpose` | High-level module description | `"User authentication and authorization"` |
90
+ | `dependencies` | External dependencies | `["@supabase/supabase-js", "bcrypt"]` |
91
+ | `assumptions` | Module-level assumptions | `["Database schema v2.0", "Redis available"]` |
92
+ | `security_model` | Overall security approach | `"Defense in depth - fails closed"` |
93
+
94
+ ## DarkArts Language Guide
95
+
96
+ DarkArts is a mathematical notation language for precise specifications. Use these symbols:
97
+
98
+ ### Logical Operators
99
+
100
+ | Symbol | Meaning | Example |
101
+ |--------|---------|---------|
102
+ | `∧` | AND | `x > 0 ∧ y > 0` |
103
+ | `∨` | OR | `x = 0 ∨ y = 0` |
104
+ | `¬` | NOT | `¬(x < 0)` |
105
+ | `⇒` | IMPLIES | `x > 0 ⇒ result > 0` |
106
+ | `⇔` | IF AND ONLY IF | `result = true ⇔ user.isAdmin` |
107
+
108
+ ### Quantifiers
109
+
110
+ | Symbol | Meaning | Example |
111
+ |--------|---------|---------|
112
+ | `∀` | FOR ALL | `∀ x ∈ items: x > 0` |
113
+ | `∃` | THERE EXISTS | `∃ x ∈ items: x = target` |
114
+
115
+ ### Set Operations
116
+
117
+ | Symbol | Meaning | Example |
118
+ |--------|---------|---------|
119
+ | `∈` | IN / ELEMENT OF | `x ∈ valid_values` |
120
+ | `∉` | NOT IN | `x ∉ blacklist` |
121
+ | `⊆` | SUBSET OF | `result ⊆ input` |
122
+ | `∪` | UNION | `result = set1 ∪ set2` |
123
+ | `∩` | INTERSECTION | `common = set1 ∩ set2` |
124
+
125
+ ### Comparisons
126
+
127
+ | Symbol | Meaning | Example |
128
+ |--------|---------|---------|
129
+ | `≥` | GREATER THAN OR EQUAL | `x ≥ 0` |
130
+ | `≤` | LESS THAN OR EQUAL | `x ≤ 100` |
131
+ | `≠` | NOT EQUAL | `x ≠ 0` |
132
+ | `≈` | APPROXIMATELY EQUAL | `result ≈ expected` |
133
+
134
+ ### Number Sets
135
+
136
+ | Symbol | Meaning | Example |
137
+ |--------|---------|---------|
138
+ | `ℕ` | Natural numbers (0, 1, 2, ...) | `n ∈ ℕ` |
139
+ | `ℤ` | Integers (..., -1, 0, 1, ...) | `x ∈ ℤ` |
140
+ | `ℝ` | Real numbers | `x ∈ ℝ` |
141
+
142
+ **Tip**: You can use plain English too! VooDocs understands both mathematical notation and natural language. Mix them for clarity.
143
+
144
+ ## Examples
145
+
146
+ ### Example 1: API Route Handler
147
+
148
+ ```typescript
149
+ /**@voodocs
150
+ preconditions: [
151
+ "request.user is authenticated",
152
+ "request.body.amount > 0",
153
+ "request.body.recipientId exists in database"
154
+ ]
155
+ postconditions: [
156
+ "returns 200 ⇔ transfer successful",
157
+ "returns 400 ⇔ invalid input",
158
+ "returns 403 ⇔ insufficient funds",
159
+ "sender.balance decreased by amount",
160
+ "recipient.balance increased by amount"
161
+ ]
162
+ security_implications: [
163
+ "Requires authentication",
164
+ "Rate limited to 10 transfers/minute",
165
+ "Validates account ownership"
166
+ ]
167
+ side_effects: [
168
+ "Updates database (2 accounts)",
169
+ "Creates transaction record",
170
+ "Sends notification emails"
171
+ ]
172
+ complexity: "O(1)"
173
+ */
174
+ async function transferMoney(
175
+ request: Request,
176
+ response: Response
177
+ ): Promise<void> {
178
+ // Implementation
179
+ }
180
+ ```
181
+
182
+ ### Example 2: React Component
183
+
184
+ ```typescript
185
+ /**@voodocs
186
+ preconditions: [
187
+ "props.items is non-empty array",
188
+ "props.onSelect is function"
189
+ ]
190
+ postconditions: [
191
+ "renders list with props.items.length elements",
192
+ "clicking item calls props.onSelect with item"
193
+ ]
194
+ assumptions: [
195
+ "items have unique 'id' property",
196
+ "items have 'name' property for display"
197
+ ]
198
+ complexity: "O(n) where n = props.items.length"
199
+ */
200
+ function ItemList({ items, onSelect }: ItemListProps) {
201
+ // Implementation
202
+ }
203
+ ```
204
+
205
+ ## Workflow Integration
206
+
207
+ ### When to Add Annotations
208
+
209
+ Add `@voodocs` annotations in these scenarios:
210
+
211
+ 1. **New Functions** - Annotate immediately after writing the function signature
212
+ 2. **New Classes** - Annotate class and all public methods
213
+ 3. **API Endpoints** - Always annotate with security and side effects
214
+ 4. **Complex Logic** - Annotate algorithms with complexity and invariants
215
+ 5. **Security-Critical Code** - Always annotate with security implications
216
+
217
+ ### Annotation Workflow
218
+
219
+ ```
220
+ 1. Write function signature
221
+
222
+ 2. Add @voodocs annotation with preconditions/postconditions
223
+
224
+ 3. Implement function body
225
+
226
+ 4. Verify implementation matches postconditions
227
+
228
+ 5. Run `voodocs generate` to create tests and docs
229
+ ```
230
+
231
+ ### Generated Outputs
232
+
233
+ When you annotate code with `@voodocs`, the following are automatically generated:
234
+
235
+ 1. **Property-Based Tests** - Hypothesis tests with inferred strategies
236
+ 2. **Documentation** - Human-readable Markdown docs
237
+ 3. **API Specs** - OpenAPI 3.0 or GraphQL schemas
238
+ 4. **Type Hints** - Enhanced type information
239
+
240
+ ### Example Generation
241
+
242
+ Given this annotation:
243
+
244
+ ```python
245
+ """@voodocs
246
+ preconditions: ["x > 0", "y > 0"]
247
+ postconditions: ["result > x", "result > y"]
248
+ complexity: "O(1)"
249
+ """
250
+ ```
251
+
252
+ VooDocs generates:
253
+
254
+ ```python
255
+ # Generated test
256
+ @given(x=st.integers(min_value=1), y=st.integers(min_value=1))
257
+ def test_property_based_add(x, y):
258
+ assume(x > 0)
259
+ assume(y > 0)
260
+ result = add(x, y)
261
+ assert result > x
262
+ assert result > y
263
+ ```
264
+
265
+ ## Best Practices
266
+
267
+ ### 1. Be Specific with Preconditions
268
+
269
+ **Good:**
270
+ ```python
271
+ preconditions: [
272
+ "amount > 0",
273
+ "amount <= account.balance",
274
+ "account.status = ACTIVE"
275
+ ]
276
+ ```
277
+
278
+ **Avoid:**
279
+ ```python
280
+ preconditions: ["valid input"] # Too vague
281
+ ```
282
+
283
+ ### 2. Use Mathematical Notation for Precision
284
+
285
+ **Good:**
286
+ ```python
287
+ postconditions: [
288
+ "∀ x ∈ result: x ∈ input", # All results are from input
289
+ "len(result) ≤ len(input)" # Result is subset
290
+ ]
291
+ ```
292
+
293
+ **Avoid:**
294
+ ```python
295
+ postconditions: ["returns filtered list"] # Imprecise
296
+ ```
297
+
298
+ ### 3. Always Specify Complexity
299
+
300
+ **Good:**
301
+ ```python
302
+ complexity: "O(n log n)"
303
+ ```
304
+
305
+ **Also Good:**
306
+ ```python
307
+ complexity: "O(n)" # VooDocs infers space as O(1)
308
+ ```
309
+
310
+ ### 4. Document Security Implications
311
+
312
+ **Good:**
313
+ ```python
314
+ security_implications: [
315
+ "Requires admin role",
316
+ "Rate limited to 100 requests/hour",
317
+ "Validates CSRF token"
318
+ ]
319
+ ```
320
+
321
+ ### 5. Specify Error Cases
322
+
323
+ **Good:**
324
+ ```python
325
+ error_cases: [
326
+ "amount <= 0 → ValueError",
327
+ "insufficient funds → InsufficientFundsError",
328
+ "account frozen → AccountFrozenError"
329
+ ]
330
+ ```
331
+
332
+ ### 6. Use Invariants for Loops and Recursion
333
+
334
+ **Good:**
335
+ ```python
336
+ invariants: [
337
+ "∀ iteration: 0 <= i < len(arr)",
338
+ "sorted(arr[0:i])" # First i elements are sorted
339
+ ]
340
+ ```
341
+
342
+ ### 7. Document Side Effects
343
+
344
+ **Good:**
345
+ ```python
346
+ side_effects: [
347
+ "Writes to database",
348
+ "Sends email notification",
349
+ "Updates cache"
350
+ ]
351
+ ```
352
+
353
+ **Avoid:**
354
+ ```python
355
+ side_effects: ["Does stuff"] # Too vague
356
+ ```
357
+
358
+ ---
359
+
360
+ ## Summary
361
+
362
+ **Remember**: Every time you write a function or class, ask yourself:
363
+
364
+ 1. What must be true before this runs? → **preconditions**
365
+ 2. What will be true after this runs? → **postconditions**
366
+ 3. How fast is this? → **complexity**
367
+ 4. What can go wrong? → **error_cases**
368
+ 5. Is this security-sensitive? → **security_implications**
369
+
370
+ 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.
371
+
372
+ **Generated by VooDocs** - AI-native documentation for modern development.