@voodocs/cli 2.5.3 → 3.0.1

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.
@@ -22,6 +22,11 @@ File naming convention:
22
22
  import re
23
23
  from pathlib import Path
24
24
  from typing import Dict, List, Optional, Tuple
25
+ import sys
26
+
27
+ # Import expansion functionality
28
+ sys.path.insert(0, str(Path(__file__).parent))
29
+ from companion_files_expansion import expand_symbol_content, expand_companion_content
25
30
 
26
31
 
27
32
  class CompanionFileScanner:
@@ -137,9 +142,10 @@ class CompanionFileScanner:
137
142
  # Extract ⊢{} notation
138
143
  purpose_symbol = re.search(r'⊢\{([^}]+)\}', purpose_text)
139
144
  if purpose_symbol:
140
- sections['purpose'] = purpose_symbol.group(1).strip()
145
+ # Expand abbreviations for human readability
146
+ sections['purpose'] = expand_symbol_content(purpose_symbol.group(1).strip())
141
147
  else:
142
- sections['purpose'] = purpose_text
148
+ sections['purpose'] = expand_companion_content(purpose_text)
143
149
 
144
150
  # Extract Architecture section
145
151
  arch_match = re.search(r'##\s+Architecture\s*\n(.*?)(?=\n##|\Z)', content, re.DOTALL)
@@ -272,28 +278,75 @@ class CompanionFileScanner:
272
278
 
273
279
  template = f"""# {stem}.voodocs.md
274
280
 
281
+ Companion documentation for `{filename}` using DarkArts v3.0.0 mathematical notation.
282
+
275
283
  ## Purpose
276
- ⊢{{[Describe the module's primary purpose and responsibilities]}}
284
+ ⊢{{[Describe module's primary purpose - use abbreviations like 'svc', 'auth', 'db']}}
285
+
286
+ ## Dependencies
287
+ ∂{{[List external dependencies - e.g., bcrypt,jsonwebtoken,db]}}
277
288
 
278
289
  ## Architecture
279
- - **Depends On**: [List dependencies]
290
+ - **Depends On**: [List internal module dependencies]
280
291
  - **Depended By**: [List modules that depend on this]
281
292
  - **Storage**: [Data storage information if applicable]
282
293
 
294
+ ## Preconditions
295
+ ⊳{{[Input validation - use patterns like email:email, pw≥8, id:uuid]}}
296
+
297
+ ## Postconditions
298
+ ⊲{{[Output guarantees - e.g., ret JWT tok|null]}}
299
+
283
300
  ## Invariants
284
- ⊨{{[Invariant 1: Describe a condition that must always hold]}}
301
+ ⊨{{[Invariant 1: Condition that must always hold - e.g., no pw log]}}
285
302
  ⊨{{[Invariant 2: Another invariant]}}
286
303
 
304
+ ## Side Effects
305
+ ⊕{{[Side effects - e.g., logs auth, updates last_login]}}
306
+
307
+ ## Forbidden Operations
308
+ ⊗{{[Operations that must not happen - e.g., no pw in logs]}}
309
+
310
+ ## Security
311
+ 🔒{{[Security requirements - e.g., pw:hash, tok:enc]}}
312
+
313
+ ## Complexity
314
+ ⚡{{[Time/space complexity - e.g., O(1), O(n)]}}
315
+
316
+ ## Bidirectional Relationships
317
+ ⇄{{[Related operations - e.g., login↔logout]}}
318
+
319
+ ## Logical Consequences
320
+ ∴{{[Implications - e.g., invalid→null]}}
321
+
322
+ ## Universal Quantifiers
323
+ ∀{{[Statements that apply to all - e.g., users have unique email]}}
324
+
325
+ ## Existential Quantifiers
326
+ ∃{{[Existence requirements - e.g., admin required]}}
327
+
328
+ ## Approximations
329
+ ≈{{[Performance targets - e.g., ~50ms]}}
330
+
287
331
  ## Assumptions
288
- {{[Assumption 1: Describe assumptions about inputs, environment, etc.]}}
332
+ {{[Environmental assumptions - e.g., db conn established]}}
289
333
 
290
334
  ## Critical Sections
291
335
  - `functionName()` - [Description of why this is critical]
292
336
 
293
- ## Security Considerations
294
- ⊨{{[Security-specific invariant or requirement]}}
295
-
296
337
  ## Notes
297
338
  [Any additional notes, diagrams, or references]
339
+
340
+ ---
341
+
342
+ **DarkArts v3.0.0 Symbols:**
343
+ - ⊢ Purpose | ∂ Dependencies | ⊳ Preconditions | ⊲ Postconditions
344
+ - ⊨ Invariants | ⊕ Side Effects | ⊗ Forbidden | 🔒 Security
345
+ - ⚡ Complexity | ⇄ Bidirectional | ∴ Consequences | ∀ Universal
346
+ - ∃ Existential | ≈ Approximation | ⚠ Assumptions
347
+
348
+ **Pattern Shortcuts:**
349
+ - :uuid, :email, :url, :json, :jwt, :hash, :enc
350
+ - ≥N, ≤N, >N, <N, [N,M], ∈{{...}}
298
351
  """
299
352
  return template
@@ -0,0 +1,138 @@
1
+ """
2
+ ⊢companion_files:expansion
3
+ ∂{re,typing}
4
+ ⚠{python≥3.7}
5
+ ⊨{∀abbrev→expanded}
6
+ 🔒{read-only}
7
+ ⚡{O(n)|n=text-length}
8
+ """
9
+
10
+ """
11
+ DarkArts v3.0.0 - Abbreviation Expansion for Companion Files
12
+
13
+ Expands abbreviated text in companion files to full human-readable form.
14
+ """
15
+
16
+ import re
17
+ from typing import Dict
18
+
19
+ # Import abbreviation dictionary from v3.0.0
20
+ import sys
21
+ from pathlib import Path
22
+ sys.path.insert(0, str(Path(__file__).parent))
23
+ from darkarts_abbreviations import ABBREVIATIONS
24
+
25
+
26
+ def expand_abbreviations(text: str) -> str:
27
+ """
28
+ Expand abbreviations in text to full human-readable form.
29
+
30
+ Args:
31
+ text: Text containing abbreviations (e.g., "u auth svc w/ JWT tok gen")
32
+
33
+ Returns:
34
+ Expanded text (e.g., "user authentication service with JWT token generation")
35
+
36
+ Examples:
37
+ >>> expand_abbreviations("u auth svc")
38
+ 'user authentication service'
39
+ >>> expand_abbreviations("ret JWT tok|null")
40
+ 'return JWT token or null'
41
+ """
42
+ # Sort by length (longest first) to avoid partial matches
43
+ sorted_abbrevs = sorted(ABBREVIATIONS.keys(), key=len, reverse=True)
44
+
45
+ expanded = text
46
+ for abbrev in sorted_abbrevs:
47
+ full = ABBREVIATIONS[abbrev]
48
+ # Use word boundaries to avoid partial replacements
49
+ pattern = r'\b' + re.escape(abbrev) + r'\b'
50
+ expanded = re.sub(pattern, full, expanded, flags=re.IGNORECASE)
51
+
52
+ return expanded
53
+
54
+
55
+ def expand_pattern_shortcuts(text: str) -> str:
56
+ """
57
+ Expand pattern shortcuts to human-readable descriptions.
58
+
59
+ Args:
60
+ text: Text containing pattern shortcuts (e.g., "id:uuid, pw≥8")
61
+
62
+ Returns:
63
+ Expanded text (e.g., "id must be valid UUID, password must be at least 8 characters")
64
+
65
+ Examples:
66
+ >>> expand_pattern_shortcuts("email:email")
67
+ 'email must be valid email address'
68
+ >>> expand_pattern_shortcuts("pw≥8")
69
+ 'password must be at least 8 characters'
70
+ """
71
+ pattern_expansions = {
72
+ r':uuid': ' must be valid UUID',
73
+ r':email': ' must be valid email address',
74
+ r':url': ' must be valid URL',
75
+ r':json': ' must be valid JSON',
76
+ r':jwt': ' must be valid JWT token',
77
+ r':hash': ' must be cryptographic hash',
78
+ r':enc': ' must be encrypted',
79
+ r'≥(\d+)': r' must be at least \1 characters',
80
+ r'≤(\d+)': r' must be at most \1 characters',
81
+ r'>(\d+)': r' must be greater than \1',
82
+ r'<(\d+)': r' must be less than \1',
83
+ r'\[(\d+),(\d+)\]': r' must be between \1 and \2',
84
+ r'∈\{([^}]+)\}': r' must be one of: \1'
85
+ }
86
+
87
+ expanded = text
88
+ for pattern, replacement in pattern_expansions.items():
89
+ expanded = re.sub(pattern, replacement, expanded)
90
+
91
+ return expanded
92
+
93
+
94
+ def expand_companion_content(content: str, expand_patterns: bool = True, expand_abbrevs: bool = True) -> str:
95
+ """
96
+ Expand all abbreviations and patterns in companion file content.
97
+
98
+ Args:
99
+ content: Raw companion file content
100
+ expand_patterns: Whether to expand pattern shortcuts
101
+ expand_abbrevs: Whether to expand abbreviations
102
+
103
+ Returns:
104
+ Fully expanded human-readable content
105
+
106
+ Examples:
107
+ >>> content = "⊢{u auth svc}\\n⊳{email:email,pw≥8}"
108
+ >>> expand_companion_content(content)
109
+ '⊢{user authentication service}\\n⊳{email must be valid email address, password must be at least 8 characters}'
110
+ """
111
+ expanded = content
112
+
113
+ if expand_patterns:
114
+ expanded = expand_pattern_shortcuts(expanded)
115
+
116
+ if expand_abbrevs:
117
+ expanded = expand_abbreviations(expanded)
118
+
119
+ return expanded
120
+
121
+
122
+ def expand_symbol_content(symbol_text: str) -> str:
123
+ """
124
+ Expand content within a specific symbol notation (e.g., ⊢{...}, ∂{...}).
125
+
126
+ Args:
127
+ symbol_text: Text inside symbol braces
128
+
129
+ Returns:
130
+ Expanded text
131
+
132
+ Examples:
133
+ >>> expand_symbol_content("u auth svc w/ JWT tok gen")
134
+ 'user authentication service with JWT token generation'
135
+ """
136
+ expanded = expand_abbreviations(symbol_text)
137
+ expanded = expand_pattern_shortcuts(expanded)
138
+ return expanded