oneie 3.6.26 → 3.6.27
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/.claude/agents/TROUBLESHOOTING.md +530 -0
- package/.claude/agents/agent-claude.md +645 -0
- package/.claude/agents/agent-frontend.md +162 -21
- package/.claude/commands/chat.md +504 -0
- package/.claude/commands/create.md +134 -18
- package/.claude/commands/fast.md +531 -0
- package/.claude/commands/one.md +12 -85
- package/.claude/commands/optimize.md +74 -0
- package/.claude/commands/plan.md +420 -373
- package/.claude/commands/review.md +99 -0
- package/.claude/commands/test.md +197 -0
- package/.claude/commands/validate.md +140 -0
- package/.claude/hooks/__pycache__/todo.cpython-312.pyc +0 -0
- package/.claude/hooks/auto-format.sh +106 -0
- package/.claude/hooks/formatting.py +187 -0
- package/.claude/hooks/ontology-validation.py +255 -0
- package/.claude/hooks/validate-imports.py +182 -0
- package/.claude/hooks/validate-ontology.py +140 -0
- package/one/knowledge/cascading-context-specification.md +1617 -0
- package/one/knowledge/claude-code-integration.md +1293 -0
- package/one/knowledge/development-commands.md +251 -0
- package/one/knowledge/guidelines.md +314 -0
- package/one/knowledge/parallel-agents.md +932 -0
- package/one/knowledge/performance.md +459 -0
- package/one/knowledge/troubleshooting.md +434 -0
- package/one/things/plans/dsl-claude-code.md +1011 -0
- package/package.json +1 -1
- package/.claude/agents/AUDIT-agent-ops-alignment.md +0 -379
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Ontology Validation Hook for ONE Platform
|
|
4
|
+
|
|
5
|
+
Validates that code changes adhere to the 6-dimension ontology:
|
|
6
|
+
1. groups - Multi-tenant isolation with hierarchical nesting
|
|
7
|
+
2. people - Authorization & governance (represented as things with role)
|
|
8
|
+
3. things - All entities (66+ types)
|
|
9
|
+
4. connections - All relationships (25+ types)
|
|
10
|
+
5. events - All actions and state changes (67+ types)
|
|
11
|
+
6. knowledge - Labels, embeddings, semantic search
|
|
12
|
+
|
|
13
|
+
Runs after Edit/Write operations to ensure ontology compliance.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import os
|
|
17
|
+
import sys
|
|
18
|
+
import re
|
|
19
|
+
import json
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
|
|
22
|
+
# ANSI color codes
|
|
23
|
+
GREEN = '\033[92m'
|
|
24
|
+
YELLOW = '\033[93m'
|
|
25
|
+
RED = '\033[91m'
|
|
26
|
+
BLUE = '\033[94m'
|
|
27
|
+
RESET = '\033[0m'
|
|
28
|
+
|
|
29
|
+
# Valid dimension tables (5 tables for 6 dimensions)
|
|
30
|
+
VALID_TABLES = ['groups', 'things', 'connections', 'events', 'knowledge']
|
|
31
|
+
|
|
32
|
+
# Regex patterns for validation
|
|
33
|
+
PATTERNS = {
|
|
34
|
+
'db_insert': r'ctx\.db\.insert\(["\'](\w+)["\']',
|
|
35
|
+
'db_query': r'ctx\.db\.query\(["\'](\w+)["\']',
|
|
36
|
+
'group_id': r'groupId\s*:\s*',
|
|
37
|
+
'thing_type': r'type\s*:\s*["\'](\w+)["\']',
|
|
38
|
+
'connection_type': r'type\s*:\s*["\'](\w+)["\']',
|
|
39
|
+
'event_type': r'type\s*:\s*["\'](\w+)["\']',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
def validate_file(file_path: str) -> dict:
|
|
43
|
+
"""Validate a single file for ontology compliance."""
|
|
44
|
+
|
|
45
|
+
if not os.path.exists(file_path):
|
|
46
|
+
return {'status': 'skip', 'reason': 'File does not exist'}
|
|
47
|
+
|
|
48
|
+
# Only validate TypeScript files in backend/convex
|
|
49
|
+
if not file_path.endswith(('.ts', '.tsx')) or 'backend/convex' not in file_path:
|
|
50
|
+
return {'status': 'skip', 'reason': 'Not a backend TypeScript file'}
|
|
51
|
+
|
|
52
|
+
# Skip generated files
|
|
53
|
+
if '_generated' in file_path:
|
|
54
|
+
return {'status': 'skip', 'reason': 'Generated file'}
|
|
55
|
+
|
|
56
|
+
with open(file_path, 'r', encoding='utf-8') as f:
|
|
57
|
+
content = f.read()
|
|
58
|
+
|
|
59
|
+
issues = []
|
|
60
|
+
warnings = []
|
|
61
|
+
|
|
62
|
+
# Check 1: Validate table names in db.insert and db.query
|
|
63
|
+
for match in re.finditer(PATTERNS['db_insert'], content):
|
|
64
|
+
table = match.group(1)
|
|
65
|
+
if table not in VALID_TABLES:
|
|
66
|
+
issues.append(f"Invalid table '{table}' in db.insert() - must be one of {VALID_TABLES}")
|
|
67
|
+
|
|
68
|
+
for match in re.finditer(PATTERNS['db_query'], content):
|
|
69
|
+
table = match.group(1)
|
|
70
|
+
if table not in VALID_TABLES:
|
|
71
|
+
issues.append(f"Invalid table '{table}' in db.query() - must be one of {VALID_TABLES}")
|
|
72
|
+
|
|
73
|
+
# Check 2: Ensure things/connections/events/knowledge have groupId
|
|
74
|
+
for table in ['things', 'connections', 'events', 'knowledge']:
|
|
75
|
+
if f'db.insert("{table}"' in content or f"db.insert('{table}'" in content:
|
|
76
|
+
# Look for groupId in the same logical block (rough heuristic)
|
|
77
|
+
insert_matches = list(re.finditer(rf'db\.insert\(["\']({table})["\']', content))
|
|
78
|
+
for insert_match in insert_matches:
|
|
79
|
+
# Check if groupId appears within next 500 chars
|
|
80
|
+
context = content[insert_match.start():insert_match.start() + 500]
|
|
81
|
+
if 'groupId' not in context:
|
|
82
|
+
warnings.append(f"db.insert('{table}') may be missing groupId for multi-tenant scoping")
|
|
83
|
+
|
|
84
|
+
# Check 3: Validate common entity types (basic check)
|
|
85
|
+
common_types = [
|
|
86
|
+
'user', 'agent', 'ai_clone', 'content', 'course', 'token',
|
|
87
|
+
'creator', 'fan', 'product', 'service', 'organization'
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
# Check 4: Look for people dimension (role-based access)
|
|
91
|
+
if 'things' in content and 'type:' in content:
|
|
92
|
+
if 'role' in content and 'platform_owner' not in content and 'org_owner' not in content:
|
|
93
|
+
# Has role but not using standard role types
|
|
94
|
+
warnings.append("Found 'role' field but no standard role types (platform_owner, org_owner, org_user, customer)")
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
'status': 'validated',
|
|
98
|
+
'issues': issues,
|
|
99
|
+
'warnings': warnings
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
def main():
|
|
103
|
+
"""Main hook entry point."""
|
|
104
|
+
|
|
105
|
+
# Get file path from environment or command line
|
|
106
|
+
file_path = os.environ.get('CLAUDE_EDIT_FILE') or (sys.argv[1] if len(sys.argv) > 1 else None)
|
|
107
|
+
|
|
108
|
+
if not file_path:
|
|
109
|
+
print(f"{YELLOW}⚠ Ontology Validation: No file path provided{RESET}")
|
|
110
|
+
return 0
|
|
111
|
+
|
|
112
|
+
result = validate_file(file_path)
|
|
113
|
+
|
|
114
|
+
if result['status'] == 'skip':
|
|
115
|
+
return 0
|
|
116
|
+
|
|
117
|
+
# Print results
|
|
118
|
+
file_name = os.path.basename(file_path)
|
|
119
|
+
|
|
120
|
+
if result['issues']:
|
|
121
|
+
print(f"\n{RED}✗ Ontology Validation Failed: {file_name}{RESET}")
|
|
122
|
+
for issue in result['issues']:
|
|
123
|
+
print(f" {RED}ERROR:{RESET} {issue}")
|
|
124
|
+
if result['warnings']:
|
|
125
|
+
print(f"\n{YELLOW}Warnings:{RESET}")
|
|
126
|
+
for warning in result['warnings']:
|
|
127
|
+
print(f" {YELLOW}⚠{RESET} {warning}")
|
|
128
|
+
return 1
|
|
129
|
+
|
|
130
|
+
if result['warnings']:
|
|
131
|
+
print(f"\n{YELLOW}⚠ Ontology Validation Warnings: {file_name}{RESET}")
|
|
132
|
+
for warning in result['warnings']:
|
|
133
|
+
print(f" {YELLOW}⚠{RESET} {warning}")
|
|
134
|
+
return 0
|
|
135
|
+
|
|
136
|
+
print(f"{GREEN}✓ Ontology Validation: {file_name} complies with 6-dimension model{RESET}")
|
|
137
|
+
return 0
|
|
138
|
+
|
|
139
|
+
if __name__ == '__main__':
|
|
140
|
+
sys.exit(main())
|