@voodocs/cli 3.0.4 → 3.0.6
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/lib/cli/__init__.py
CHANGED
|
@@ -920,10 +920,13 @@ class AnnotationParser:
|
|
|
920
920
|
|
|
921
921
|
def _overlay_annotations(self, structure: ParsedAnnotations, annotations_by_line: Dict[int, Any]) -> ParsedAnnotations:
|
|
922
922
|
"""Overlay parsed annotations onto code structure by matching line numbers."""
|
|
923
|
+
# Find the first code element line number
|
|
924
|
+
first_code_line = self._get_first_code_line(structure)
|
|
925
|
+
|
|
923
926
|
# Match annotations to code elements by finding the closest following element
|
|
924
927
|
for line_num, annotation in annotations_by_line.items():
|
|
925
928
|
# Check if this is a module-level annotation (appears before any code)
|
|
926
|
-
if self._is_module_annotation(annotation):
|
|
929
|
+
if self._is_module_annotation(annotation, line_num, first_code_line):
|
|
927
930
|
self._apply_module_annotation_from_darkarts(structure.module, annotation)
|
|
928
931
|
continue
|
|
929
932
|
|
|
@@ -959,9 +962,31 @@ class AnnotationParser:
|
|
|
959
962
|
|
|
960
963
|
return structure
|
|
961
964
|
|
|
962
|
-
def
|
|
963
|
-
"""
|
|
964
|
-
|
|
965
|
+
def _get_first_code_line(self, structure: ParsedAnnotations) -> int:
|
|
966
|
+
"""Get the line number of the first code element (function or class)."""
|
|
967
|
+
min_line = float('inf')
|
|
968
|
+
|
|
969
|
+
# Check all functions
|
|
970
|
+
for func in structure.module.functions:
|
|
971
|
+
if func.line_number > 0 and func.line_number < min_line:
|
|
972
|
+
min_line = func.line_number
|
|
973
|
+
|
|
974
|
+
# Check all classes
|
|
975
|
+
for cls in structure.module.classes:
|
|
976
|
+
if cls.line_number > 0 and cls.line_number < min_line:
|
|
977
|
+
min_line = cls.line_number
|
|
978
|
+
|
|
979
|
+
return min_line if min_line != float('inf') else 999999
|
|
980
|
+
|
|
981
|
+
def _is_module_annotation(self, annotation: Any, line_num: int, first_code_line: int) -> bool:
|
|
982
|
+
"""Check if annotation is module-level (has ⊢{} and appears before first code element)."""
|
|
983
|
+
# Must have module purpose (⊢{})
|
|
984
|
+
if not (hasattr(annotation, 'module') and annotation.module):
|
|
985
|
+
return False
|
|
986
|
+
|
|
987
|
+
# Must appear before the first function/class
|
|
988
|
+
# Allow up to 5 lines before first code element for module annotation
|
|
989
|
+
return line_num < first_code_line
|
|
965
990
|
|
|
966
991
|
def _apply_module_annotation_from_darkarts(self, module: ModuleAnnotation, annotation: Any):
|
|
967
992
|
"""Apply @darkarts annotation to module."""
|
package/package.json
CHANGED
|
@@ -1,75 +1,112 @@
|
|
|
1
1
|
# Project-Level DarkArts Annotations
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @darkarts
|
|
4
|
+
# ⊢{distributed microservices platform}
|
|
5
|
+
# ⊨{∀service→isolated-db, ∀api→authenticated, ∀transaction→idempotent}
|
|
6
|
+
# ⊣{postgres≥14, redis≥7, kubernetes≥1.24}
|
|
7
|
+
# ⚠{kubernetes≥1.24, postgres≥14, redis≥7.0, node≥18}
|
|
4
8
|
|
|
5
|
-
##
|
|
9
|
+
## About This File
|
|
10
|
+
|
|
11
|
+
This file contains **project-wide annotations** that apply to the entire codebase.
|
|
6
12
|
|
|
7
13
|
Place this file in your project root as `PROJECT.darkarts.md` and it will be automatically detected by `voodocs context generate`.
|
|
8
14
|
|
|
9
|
-
##
|
|
15
|
+
## How to Use
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
**Important:** Annotations must use Python comment syntax (`#`) at the start of each line, not markdown code blocks.
|
|
12
18
|
|
|
19
|
+
### Correct Format:
|
|
13
20
|
```
|
|
14
|
-
@darkarts
|
|
15
|
-
⊢{project purpose}
|
|
16
|
-
⊨{global
|
|
17
|
-
⊣{
|
|
18
|
-
⚠{
|
|
21
|
+
# @darkarts
|
|
22
|
+
# ⊢{your project purpose}
|
|
23
|
+
# ⊨{global invariant 1, global invariant 2}
|
|
24
|
+
# ⊣{assumption 1, assumption 2}
|
|
25
|
+
# ⚠{requirement 1, requirement 2}
|
|
19
26
|
```
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## Example: Project-Level Annotations
|
|
24
|
-
|
|
28
|
+
### Incorrect Format (won't work):
|
|
25
29
|
```markdown
|
|
26
30
|
@darkarts
|
|
27
|
-
⊢{
|
|
28
|
-
|
|
29
|
-
⊨{
|
|
30
|
-
∀service→isolated-db,
|
|
31
|
-
∀api→authenticated,
|
|
32
|
-
∀transaction→idempotent,
|
|
33
|
-
∀data→encrypted-at-rest,
|
|
34
|
-
consistency:eventual
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
⊣{
|
|
38
|
-
postgres≥14 available,
|
|
39
|
-
redis cluster available,
|
|
40
|
-
kubernetes cluster available,
|
|
41
|
-
all services use UTC timestamps,
|
|
42
|
-
all APIs use JSON
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
⚠{
|
|
46
|
-
kubernetes≥1.24,
|
|
47
|
-
postgres≥14,
|
|
48
|
-
redis≥7.0,
|
|
49
|
-
node≥18,
|
|
50
|
-
python≥3.11
|
|
51
|
-
}
|
|
31
|
+
⊢{your project purpose}
|
|
52
32
|
```
|
|
53
33
|
|
|
54
|
-
|
|
34
|
+
## Symbolic Notation Reference
|
|
35
|
+
|
|
36
|
+
- `⊢{}` - Project purpose/description
|
|
37
|
+
- `⊨{}` - Global invariants (system-wide rules that must always hold)
|
|
38
|
+
- `⊣{}` - System-wide assumptions (what the system depends on)
|
|
39
|
+
- `⚠{}` - Technology requirements (versions, dependencies)
|
|
40
|
+
- `∂{}` - Dependencies (external systems, services)
|
|
41
|
+
|
|
42
|
+
## Example: Real Project Annotations
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
# @darkarts
|
|
46
|
+
# ⊢{3NS: Decentralized naming system with dual-layer resolution (on-chain + off-chain cache)}
|
|
47
|
+
#
|
|
48
|
+
# ⊨{
|
|
49
|
+
# UUTRegister contract is source of truth,
|
|
50
|
+
# PostgreSQL is cache only,
|
|
51
|
+
# All database access enforced by Supabase RLS,
|
|
52
|
+
# 3Pay is generic infrastructure - no domain logic,
|
|
53
|
+
# All domain-specific logic in plugins
|
|
54
|
+
# }
|
|
55
|
+
#
|
|
56
|
+
# ⊣{
|
|
57
|
+
# Supabase RLS policies enforce all access,
|
|
58
|
+
# PostgreSQL cache can be rebuilt from blockchain,
|
|
59
|
+
# UUTRegister contract is immutable,
|
|
60
|
+
# All services use UTC timestamps
|
|
61
|
+
# }
|
|
62
|
+
#
|
|
63
|
+
# ⚠{
|
|
64
|
+
# supabase-js≥2.0,
|
|
65
|
+
# postgres≥14,
|
|
66
|
+
# node≥18,
|
|
67
|
+
# typescript≥5.0
|
|
68
|
+
# }
|
|
69
|
+
```
|
|
55
70
|
|
|
56
71
|
## Architecture Decisions
|
|
57
72
|
|
|
58
|
-
You can also document architecture decisions in plain Markdown:
|
|
73
|
+
You can also document architecture decisions in plain Markdown below the annotations:
|
|
59
74
|
|
|
60
|
-
### Decision:
|
|
75
|
+
### Decision: Separated 3Pay as Generic Infrastructure (PRINCIPLE_6)
|
|
61
76
|
|
|
62
|
-
**
|
|
77
|
+
**Date:** 2024-12
|
|
63
78
|
|
|
64
|
-
**
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
**Rationale:** 3Pay should be reusable across different domain systems, not tied to 3NS-specific logic.
|
|
80
|
+
|
|
81
|
+
**What Changed:**
|
|
82
|
+
- Moved all domain-specific logic to plugins
|
|
83
|
+
- 3Pay now handles only: payments, subscriptions, credits
|
|
84
|
+
- Domain resolution logic stays in 3NS
|
|
67
85
|
|
|
68
86
|
**Trade-offs:**
|
|
69
|
-
- ✅
|
|
70
|
-
- ✅
|
|
71
|
-
- ❌
|
|
72
|
-
|
|
87
|
+
- ✅ 3Pay can be reused for other projects
|
|
88
|
+
- ✅ Cleaner separation of concerns
|
|
89
|
+
- ❌ Slightly more complex plugin system
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### Decision: PostgreSQL as Cache, UUTRegister as Source of Truth
|
|
94
|
+
|
|
95
|
+
**Date:** 2024-11
|
|
96
|
+
|
|
97
|
+
**Rationale:** Blockchain data is immutable and authoritative; PostgreSQL provides fast queries.
|
|
98
|
+
|
|
99
|
+
**Implementation:**
|
|
100
|
+
- UUTRegister contract stores all domain registrations
|
|
101
|
+
- PostgreSQL caches data for fast lookups
|
|
102
|
+
- Cache can be rebuilt from blockchain at any time
|
|
103
|
+
- Supabase RLS enforces access control
|
|
104
|
+
|
|
105
|
+
**Trade-offs:**
|
|
106
|
+
- ✅ Fast queries via PostgreSQL
|
|
107
|
+
- ✅ Authoritative data on blockchain
|
|
108
|
+
- ✅ Can rebuild cache if corrupted
|
|
109
|
+
- ❌ Requires cache synchronization logic
|
|
73
110
|
|
|
74
111
|
---
|
|
75
112
|
|
|
@@ -77,11 +114,11 @@ You can also document architecture decisions in plain Markdown:
|
|
|
77
114
|
|
|
78
115
|
Document system-wide invariants that must hold across all services:
|
|
79
116
|
|
|
80
|
-
- All
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
- All
|
|
117
|
+
- **Database Access:** All database access must go through Supabase RLS (no direct PostgreSQL access)
|
|
118
|
+
- **Source of Truth:** UUTRegister contract is the only source of truth for domain ownership
|
|
119
|
+
- **Cache Consistency:** PostgreSQL cache must be rebuildable from blockchain
|
|
120
|
+
- **Generic Infrastructure:** 3Pay must remain generic (no domain-specific logic)
|
|
121
|
+
- **Plugin Isolation:** All domain-specific logic must be in plugins, not core
|
|
85
122
|
|
|
86
123
|
---
|
|
87
124
|
|
|
@@ -89,23 +126,25 @@ Document system-wide invariants that must hold across all services:
|
|
|
89
126
|
|
|
90
127
|
Document assumptions that the entire system relies on:
|
|
91
128
|
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
129
|
+
- **Supabase RLS:** RLS policies correctly enforce all access control
|
|
130
|
+
- **Blockchain Availability:** UUTRegister contract is always accessible
|
|
131
|
+
- **Cache Rebuild:** PostgreSQL can be rebuilt from blockchain if needed
|
|
132
|
+
- **UTC Timestamps:** All services use UTC for timestamps
|
|
133
|
+
- **Immutable Contracts:** Smart contracts are immutable after deployment
|
|
97
134
|
|
|
98
135
|
---
|
|
99
136
|
|
|
100
137
|
## Technology Stack
|
|
101
138
|
|
|
102
|
-
Document the standard technology stack for the project:
|
|
103
|
-
|
|
104
139
|
**Backend:**
|
|
105
140
|
- Node.js 18+ (TypeScript)
|
|
106
|
-
-
|
|
107
|
-
-
|
|
108
|
-
|
|
141
|
+
- Supabase (PostgreSQL + Auth + RLS)
|
|
142
|
+
- Web3.js / Ethers.js (blockchain interaction)
|
|
143
|
+
|
|
144
|
+
**Smart Contracts:**
|
|
145
|
+
- Solidity 0.8+
|
|
146
|
+
- Hardhat (development)
|
|
147
|
+
- UUTRegister (domain registry)
|
|
109
148
|
|
|
110
149
|
**Frontend:**
|
|
111
150
|
- React 18+
|
|
@@ -113,16 +152,18 @@ Document the standard technology stack for the project:
|
|
|
113
152
|
- TailwindCSS 3+
|
|
114
153
|
|
|
115
154
|
**Infrastructure:**
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
-
|
|
155
|
+
- Supabase (hosted PostgreSQL)
|
|
156
|
+
- Vercel / Netlify (frontend hosting)
|
|
157
|
+
- Ethereum / Polygon (blockchain)
|
|
119
158
|
|
|
120
159
|
---
|
|
121
160
|
|
|
122
161
|
## Notes
|
|
123
162
|
|
|
124
|
-
- This file is parsed by `voodocs context generate`
|
|
125
|
-
- Annotations
|
|
126
|
-
- Global invariants from this file appear in
|
|
127
|
-
- Architecture decisions can be written in plain Markdown
|
|
128
|
-
- This file should be version controlled alongside your code
|
|
163
|
+
- ✅ This file is parsed by `voodocs context generate`
|
|
164
|
+
- ✅ Annotations must use `#` comment syntax (Python style)
|
|
165
|
+
- ✅ Global invariants from this file appear in `.voodocs.context`
|
|
166
|
+
- ✅ Architecture decisions can be written in plain Markdown
|
|
167
|
+
- ✅ This file should be version controlled alongside your code
|
|
168
|
+
- ❌ Don't use markdown code blocks for annotations (won't be parsed)
|
|
169
|
+
- ❌ Don't forget the `#` at the start of each annotation line
|