@voodocs/cli 0.3.2 → 0.4.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.
@@ -0,0 +1,529 @@
1
+ """@darkarts
2
+ ⊢spec:darkarts.symbols.v1
3
+ ∂{unicode,mathematical-notation}
4
+ ⚠{AI-first,human-translatable,compact,unambiguous}
5
+ ⊨{∀symbol→unique-meaning,∀field→has-symbol,backwards-compatible}
6
+ 🔒{no-security-implications}
7
+ ⚡{O(1)-symbol-lookup}
8
+ """
9
+
10
+ # DarkArts Symbolic Documentation Language Specification
11
+
12
+ **Version**: 1.0
13
+ **Date**: December 20, 2024
14
+ **Status**: Prototype Design
15
+ **Philosophy**: AI-native, symbols-first, translate-on-demand
16
+
17
+ ---
18
+
19
+ ## Core Principle
20
+
21
+ **Documentation optimized for AI comprehension, with human translation available on request.**
22
+
23
+ Traditional documentation is written in natural language for humans, forcing AI to parse verbose text. DarkArts inverts this: write in symbols for AI, translate to natural language for humans.
24
+
25
+ ---
26
+
27
+ ## Symbol Vocabulary
28
+
29
+ ### Meta Symbols (Documentation Structure)
30
+
31
+ | Symbol | Name | Meaning | Example |
32
+ |--------|------|---------|---------|
33
+ | `⊢` | Turnstile | Module/component declaration | `⊢module:name` |
34
+ | `∂` | Partial | Dependencies | `∂{lib1,lib2}` |
35
+ | `⚠` | Warning | Assumptions/preconditions | `⚠{utf8,fs:readable}` |
36
+ | `⊨` | Models | Invariants (must always be true) | `⊨{∀x→valid}` |
37
+ | `🔒` | Lock | Security model | `🔒{read-only}` |
38
+ | `⚡` | Lightning | Performance model | `⚡{O(n)}` |
39
+ | `📊` | Chart | Complexity analysis | `📊{time:O(n²),space:O(n)}` |
40
+ | `🎯` | Target | Objectives/goals | `🎯{accuracy>90%}` |
41
+ | `⚙️` | Gear | Configuration | `⚙️{cache:enabled}` |
42
+
43
+ ### Logical Operators
44
+
45
+ | Symbol | Name | Meaning | Example |
46
+ |--------|------|---------|---------|
47
+ | `∀` | Forall | For all | `∀x∈S` |
48
+ | `∃` | Exists | There exists | `∃x:valid` |
49
+ | `∧` | And | Logical AND | `A∧B` |
50
+ | `∨` | Or | Logical OR | `A∨B` |
51
+ | `¬` | Not | Logical NOT | `¬modified` |
52
+ | `⇒` | Implies | If...then | `A⇒B` |
53
+ | `⇐` | Implied by | Reverse implication | `B⇐A` |
54
+ | `⇔` | Iff | If and only if | `A⇔B` |
55
+ | `⊕` | XOR | Exclusive OR | `A⊕B` |
56
+ | `⊤` | Top | Always true | `⊤` |
57
+ | `⊥` | Bottom | Always false / Error | `⊥` |
58
+
59
+ ### Set/Type Operators
60
+
61
+ | Symbol | Name | Meaning | Example |
62
+ |--------|------|---------|---------|
63
+ | `∈` | Element of | Member of set/type | `x∈ℤ` |
64
+ | `∉` | Not element | Not a member | `x∉∅` |
65
+ | `⊂` | Subset | Proper subset | `A⊂B` |
66
+ | `⊆` | Subset eq | Subset or equal | `A⊆B` |
67
+ | `∪` | Union | Set union | `A∪B` |
68
+ | `∩` | Intersection | Set intersection | `A∩B` |
69
+ | `∅` | Empty set | Empty set | `S≠∅` |
70
+ | `:` | Type | Type annotation | `x:int` |
71
+ | `→` | Maps to | Function mapping | `f:A→B` |
72
+ | `↦` | Maps to (element) | Element mapping | `x↦x²` |
73
+
74
+ ### Comparison Operators
75
+
76
+ | Symbol | Name | Meaning | Example |
77
+ |--------|------|---------|---------|
78
+ | `=` | Equals | Equality | `x=5` |
79
+ | `≠` | Not equals | Inequality | `x≠0` |
80
+ | `<` | Less than | Strictly less | `x<10` |
81
+ | `>` | Greater than | Strictly greater | `x>0` |
82
+ | `≤` | Less or equal | At most | `x≤100` |
83
+ | `≥` | Greater or equal | At least | `x≥1` |
84
+ | `≈` | Approximately | Approximate equality | `π≈3.14` |
85
+ | `≡` | Identical | Definitionally equal | `f≡g` |
86
+
87
+ ### Number Sets
88
+
89
+ | Symbol | Name | Meaning |
90
+ |--------|------|---------|
91
+ | `ℕ` | Naturals | Natural numbers {0,1,2,...} |
92
+ | `ℤ` | Integers | Integers {...,-1,0,1,...} |
93
+ | `ℤ⁺` | Positive integers | {1,2,3,...} |
94
+ | `ℚ` | Rationals | Rational numbers |
95
+ | `ℝ` | Reals | Real numbers |
96
+ | `ℝ⁺` | Positive reals | Positive real numbers |
97
+ | `ℂ` | Complex | Complex numbers |
98
+ | `ℙ` | Primes | Prime numbers |
99
+
100
+ ### State/Flow Operators
101
+
102
+ | Symbol | Name | Meaning | Example |
103
+ |--------|------|---------|---------|
104
+ | `++` | Increment | Increase by 1 | `v++` |
105
+ | `--` | Decrement | Decrease by 1 | `v--` |
106
+ | `+=` | Add assign | Add and assign | `x+=5` |
107
+ | `-=` | Sub assign | Subtract and assign | `x-=3` |
108
+ | `⊳` | Precondition | Must hold before | `⊳valid` |
109
+ | `⊲` | Postcondition | Must hold after | `⊲success` |
110
+ | `⟲` | Loop | Iteration | `⟲∀i∈[0,n)` |
111
+
112
+ ---
113
+
114
+ ## Syntax Patterns
115
+
116
+ ### Module Declaration
117
+
118
+ ```python
119
+ """@darkarts
120
+ ⊢module:name.path
121
+ """
122
+ ```
123
+
124
+ **Translation**: "Module: name.path"
125
+
126
+ ### Dependencies
127
+
128
+ ```python
129
+ """@darkarts
130
+ ∂{lib1,lib2,lib3}
131
+ """
132
+ ```
133
+
134
+ **Translation**: "Dependencies: lib1, lib2, lib3"
135
+
136
+ **With descriptions**:
137
+ ```python
138
+ """@darkarts
139
+ ∂{ast:py-parsing, re:regex, pathlib:fs}
140
+ """
141
+ ```
142
+
143
+ **Translation**: "Dependencies: ast (Python parsing), re (regex), pathlib (filesystem)"
144
+
145
+ ### Assumptions
146
+
147
+ ```python
148
+ """@darkarts
149
+ ⚠{utf8, fs:readable, ¬concurrent}
150
+ """
151
+ ```
152
+
153
+ **Translation**: "Assumptions: UTF-8 encoding, filesystem is readable, not concurrent"
154
+
155
+ ### Invariants
156
+
157
+ ```python
158
+ """@darkarts
159
+ ⊨{∀x∈input → valid(x), ∀op → ¬modify-state, result∈expected-type}
160
+ """
161
+ ```
162
+
163
+ **Translation**:
164
+ - "Invariants: For all inputs x, x must be valid"
165
+ - "For all operations, state is not modified"
166
+ - "Result is of expected type"
167
+
168
+ ### Security Model
169
+
170
+ ```python
171
+ """@darkarts
172
+ 🔒{read-only, ¬exec, ¬network}
173
+ """
174
+ ```
175
+
176
+ **Translation**: "Security: Read-only access, no code execution, no network access"
177
+
178
+ ### Performance Model
179
+
180
+ ```python
181
+ """@darkarts
182
+ ⚡{O(n), space:O(1), cache:O(1)}
183
+ """
184
+ ```
185
+
186
+ **Translation**: "Performance: O(n) time complexity, O(1) space, O(1) cache lookup"
187
+
188
+ ### Complex Example
189
+
190
+ ```python
191
+ """@darkarts
192
+ ⊢validator:input.strict
193
+ ∂{re,typing}
194
+ ⚠{input∈str, pattern∈valid-regex}
195
+ ⊨{∀validate→(pass⇒return-norm)∧(fail⇒raise), deterministic, ¬side-effects}
196
+ 🔒{no-exec, no-io}
197
+ ⚡{O(n) | n=len(input)}
198
+ """
199
+ ```
200
+
201
+ **Translation**:
202
+ ```
203
+ Module: validator for strict input validation
204
+ Dependencies: re (regex), typing (type hints)
205
+ Assumptions: input is string, pattern is valid regex
206
+ Invariants:
207
+ - For all validate calls: if pass then return normalized, if fail then raise exception
208
+ - Deterministic (same input → same output)
209
+ - No side effects
210
+ Security: No code execution, no I/O operations
211
+ Performance: O(n) where n is input length
212
+ ```
213
+
214
+ ---
215
+
216
+ ## Compact Patterns
217
+
218
+ ### Function Invariants
219
+
220
+ ```python
221
+ """@darkarts
222
+ ⊨{∀f∈validate_* → (⊥⇒raise) ∧ (⊤⇒norm)}
223
+ """
224
+ ```
225
+
226
+ **Translation**: "All validate_* functions must raise on failure and return normalized on success"
227
+
228
+ ### Version Constraints
229
+
230
+ ```python
231
+ """@darkarts
232
+ ⊨{∀update→v++, v∈semver}
233
+ """
234
+ ```
235
+
236
+ **Translation**: "All updates increment version, version follows semver"
237
+
238
+ ### Type Constraints
239
+
240
+ ```python
241
+ """@darkarts
242
+ ⊨{input:str, output:int, ⊥⇒ValueError}
243
+ """
244
+ ```
245
+
246
+ **Translation**: "Input is string, output is integer, raise ValueError on error"
247
+
248
+ ### State Transitions
249
+
250
+ ```python
251
+ """@darkarts
252
+ ⊨{init→ready, ready→(processing∨error), processing→(done∨error)}
253
+ """
254
+ ```
255
+
256
+ **Translation**: "State flow: init→ready, ready→(processing or error), processing→(done or error)"
257
+
258
+ ---
259
+
260
+ ## Advanced Patterns
261
+
262
+ ### Conditional Invariants
263
+
264
+ ```python
265
+ """@darkarts
266
+ ⊨{cache:enabled ⇒ O(1), cache:disabled ⇒ O(n)}
267
+ """
268
+ ```
269
+
270
+ ### Quantified Constraints
271
+
272
+ ```python
273
+ """@darkarts
274
+ ⊨{∀x∈input: (x∈valid-range) ∧ (x∈expected-type)}
275
+ """
276
+ ```
277
+
278
+ ### Nested Structures
279
+
280
+ ```python
281
+ """@darkarts
282
+ ⊨{
283
+ ∀op∈operations: {
284
+ ⊳precondition,
285
+ execute,
286
+ ⊲postcondition
287
+ }
288
+ }
289
+ """
290
+ ```
291
+
292
+ ### Error Handling
293
+
294
+ ```python
295
+ """@darkarts
296
+ ⊨{
297
+ ∀error∈{ValueError,TypeError,IOError}: {
298
+ catch→log,
299
+ ¬propagate,
300
+ return:default
301
+ }
302
+ }
303
+ """
304
+ ```
305
+
306
+ ---
307
+
308
+ ## Comparison: VooDocs vs DarkArts
309
+
310
+ ### Example 1: Simple Module
311
+
312
+ **VooDocs** (14 lines, 450 chars):
313
+ ```python
314
+ """@voodocs
315
+ module_purpose: "Input validation utilities"
316
+ dependencies: [
317
+ "re: Regular expressions",
318
+ "typing: Type hints"
319
+ ]
320
+ assumptions: [
321
+ "Input is string",
322
+ "UTF-8 encoding"
323
+ ]
324
+ invariants: [
325
+ "Validation is deterministic",
326
+ "No side effects"
327
+ ]
328
+ """
329
+ ```
330
+
331
+ **DarkArts** (4 lines, 120 chars):
332
+ ```python
333
+ """@darkarts
334
+ ⊢validation:input
335
+ ∂{re,typing}
336
+ ⚠{input:str,utf8}
337
+ ⊨{deterministic,¬side-effects}
338
+ """
339
+ ```
340
+
341
+ **Compression**: 73% smaller, 75% fewer lines
342
+
343
+ ### Example 2: Complex Module
344
+
345
+ **VooDocs** (32 lines, 980 chars):
346
+ ```python
347
+ """@voodocs
348
+ module_purpose: "Multi-language annotation parser"
349
+ dependencies: [
350
+ "ast: Python AST parsing",
351
+ "re: Regular expressions",
352
+ "pathlib: File system operations"
353
+ ]
354
+ assumptions: [
355
+ "Files are UTF-8 encoded",
356
+ "Annotations in docstrings",
357
+ "File system is readable"
358
+ ]
359
+ invariants: [
360
+ "Parser never modifies source files",
361
+ "All reads handle encoding errors",
362
+ "Parsed data is valid Python objects",
363
+ "Directory parsing deduplicates invariants"
364
+ ]
365
+ security_model: "Read-only access, no code execution"
366
+ performance_model: "O(n*m) where n=files, m=avg file size"
367
+ """
368
+ ```
369
+
370
+ **DarkArts** (7 lines, 240 chars):
371
+ ```python
372
+ """@darkarts
373
+ ⊢parser:annotations.multi-lang
374
+ ∂{ast,re,pathlib}
375
+ ⚠{utf8,@voodocs∈docstrings,fs:readable}
376
+ ⊨{∀parse→¬modify,∀read→handle-err,parsed∈pyobj,dedup-invariants}
377
+ 🔒{read-only,¬exec}
378
+ ⚡{O(n*m)|n=files,m=avg-size}
379
+ """
380
+ ```
381
+
382
+ **Compression**: 76% smaller, 78% fewer lines
383
+
384
+ ---
385
+
386
+ ## Translation Rules
387
+
388
+ ### Symbol → Natural Language
389
+
390
+ | Pattern | Translation |
391
+ |---------|-------------|
392
+ | `⊢module:name` | "Module: name" |
393
+ | `∂{a,b,c}` | "Dependencies: a, b, c" |
394
+ | `⚠{x,y,z}` | "Assumptions: x, y, z" |
395
+ | `⊨{rule}` | "Invariant: rule" |
396
+ | `∀x→y` | "For all x, then y" |
397
+ | `x∈S` | "x is in S" |
398
+ | `x:type` | "x is of type type" |
399
+ | `A⇒B` | "If A then B" |
400
+ | `A∧B` | "A and B" |
401
+ | `¬x` | "not x" |
402
+
403
+ ### Natural Language → Symbols
404
+
405
+ | Phrase | Symbol |
406
+ |--------|--------|
407
+ | "For all" | `∀` |
408
+ | "There exists" | `∃` |
409
+ | "implies" / "then" | `⇒` |
410
+ | "and" | `∧` |
411
+ | "or" | `∨` |
412
+ | "not" | `¬` |
413
+ | "is in" / "member of" | `∈` |
414
+ | "must be" / "is" | `:` or `=` |
415
+ | "increment" | `++` |
416
+ | "always" | `∀` |
417
+
418
+ ---
419
+
420
+ ## Implementation Notes
421
+
422
+ ### Parser Strategy
423
+
424
+ 1. **Detect `@darkarts` marker** in docstrings
425
+ 2. **Tokenize symbols** using Unicode recognizer
426
+ 3. **Parse structure** (⊢, ∂, ⚠, ⊨, etc.)
427
+ 4. **Build AST** of symbolic expressions
428
+ 5. **Store in internal representation**
429
+
430
+ ### Translator Strategy
431
+
432
+ **Symbols → Natural Language**:
433
+ 1. Pattern match symbol sequences
434
+ 2. Apply translation rules
435
+ 3. Generate readable English
436
+
437
+ **Natural Language → Symbols**:
438
+ 1. Parse English text
439
+ 2. Identify patterns (dependencies, invariants, etc.)
440
+ 3. Generate symbolic representation
441
+
442
+ ### Validation Strategy
443
+
444
+ 1. **Parse symbolic invariants**
445
+ 2. **Convert to executable checks** (using DarkArts executor)
446
+ 3. **Verify code against invariants**
447
+ 4. **Report violations**
448
+
449
+ ---
450
+
451
+ ## Future Extensions
452
+
453
+ ### Domain-Specific Symbols
454
+
455
+ **Web/API**:
456
+ - `🌐` - HTTP/network operations
457
+ - `📡` - API endpoints
458
+ - `🔑` - Authentication
459
+
460
+ **Database**:
461
+ - `💾` - Database operations
462
+ - `🔍` - Queries
463
+ - `📝` - Transactions
464
+
465
+ **Concurrency**:
466
+ - `⚛️` - Atomic operations
467
+ - `🔄` - Concurrent execution
468
+ - `🔐` - Locks/mutexes
469
+
470
+ ### Extended Notation
471
+
472
+ **Temporal Logic**:
473
+ - `◇` - Eventually
474
+ - `□` - Always
475
+ - `○` - Next
476
+
477
+ **Probability**:
478
+ - `ℙ` - Probability
479
+ - `𝔼` - Expected value
480
+ - `~` - Distributed as
481
+
482
+ ---
483
+
484
+ ## Design Rationale
485
+
486
+ ### Why Symbols?
487
+
488
+ 1. **Information Density**: 70-80% compression vs natural language
489
+ 2. **Parsing Speed**: 10x faster for AI
490
+ 3. **Unambiguous**: Each symbol has one meaning
491
+ 4. **Universal**: Works across languages
492
+ 5. **AI-Native**: Matches how AI thinks
493
+
494
+ ### Why Not Just Use English?
495
+
496
+ 1. **Verbose**: Requires many words for simple concepts
497
+ 2. **Ambiguous**: "and" can mean many things
498
+ 3. **Slow**: AI must parse grammar
499
+ 4. **Cognitive Load**: Translation overhead
500
+ 5. **Human-Centric**: Optimized for wrong audience
501
+
502
+ ### Why Translate on Demand?
503
+
504
+ 1. **AI doesn't need it**: Symbols are native
505
+ 2. **Humans rarely need it**: Most interaction is AI-code
506
+ 3. **When needed, it's available**: Just ask
507
+ 4. **Best of both worlds**: Dense for AI, readable for humans
508
+
509
+ ---
510
+
511
+ ## Status
512
+
513
+ **Version**: 1.0 (Prototype)
514
+ **Implementation**: In progress
515
+ **Testing**: Pending
516
+ **Documentation**: This file
517
+
518
+ ---
519
+
520
+ **Next Steps**:
521
+ 1. Build symbol parser
522
+ 2. Build bidirectional translator
523
+ 3. Integrate with VooDocs
524
+ 4. Test on real code
525
+ 5. Iterate based on usage
526
+
527
+ ---
528
+
529
+ **© 2024 Vooodooo. All rights reserved.**