oneie 3.6.17 → 3.6.20
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/agent-ops.md +63 -2
- package/.claude/commands/commit.md +95 -0
- package/.claude/commands/npx.md +2 -2
- package/.claude/commands/one.md +7 -1
- package/.claude/commands/push.md +113 -21
- package/.claude/commands/release.md +2 -2
- package/.claude/hooks/release-cli.sh +195 -0
- package/CLAUDE.md +119 -0
- package/README.md +778 -497
- package/package.json +1 -1
- package/.claude/agents/NEWS-QUICKSTART.md +0 -321
- package/.claude/agents/NEWS-README.md +0 -353
- package/.claude/hooks/README-knowledge-hooks.md +0 -451
- package/.claude/hooks/README-root-cleanup.md +0 -200
- package/.claude/hooks/README.md +0 -284
- package/.claude/hooks/__pycache__/done.cpython-313.pyc +0 -0
- package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
- package/.claude/hooks/check-filenames.py +0 -177
- package/.claude/hooks/clean-post.py +0 -468
- package/.claude/hooks/clean-pre.py +0 -393
- package/.claude/hooks/clean-root-markdown.sh +0 -73
- package/.claude/hooks/done.py +0 -236
- package/.claude/hooks/format-hook.sh +0 -163
- package/.claude/hooks/hook-logger.sh +0 -173
- package/.claude/hooks/knowledge-post.py +0 -355
- package/.claude/hooks/knowledge-pre.py +0 -245
- package/.claude/hooks/notification-hook.sh +0 -279
- package/.claude/hooks/root-cleanup.py +0 -217
- package/.claude/hooks/security-hook.sh +0 -397
- package/.claude/hooks/tag-all-docs.py +0 -464
- package/.claude/hooks/test-validate-ontology.sh +0 -170
- package/.claude/hooks/todo.py +0 -368
- package/.claude/hooks/track-changes.sh +0 -101
- package/.claude/hooks/validate-ontology-structure-summary.md +0 -243
- package/.claude/hooks/validate-ontology-structure.py +0 -518
- package/TESTING-ONBOARDING.md +0 -185
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
ONE Platform - Knowledge Tagging Post-Hook
|
|
4
|
-
Tags created/modified artifacts in the 6-dimension ontology.
|
|
5
|
-
|
|
6
|
-
This hook runs on PostToolUse to:
|
|
7
|
-
- Create knowledge entries for new artifacts
|
|
8
|
-
- Tag with semantic labels based on ontology dimensions
|
|
9
|
-
- Link knowledge to related things (features, tasks, designs)
|
|
10
|
-
- Track inference context and lessons learned
|
|
11
|
-
- Build searchable knowledge base for AI agents
|
|
12
|
-
|
|
13
|
-
6-Dimension Ontology:
|
|
14
|
-
1. GROUPS - Multi-tenant isolation (/one/groups/)
|
|
15
|
-
2. PEOPLE - Authorization & governance (/one/people/)
|
|
16
|
-
3. THINGS - Entities (66+ types) (/one/things/)
|
|
17
|
-
4. CONNECTIONS - Relationships (25+ types) (/one/connections/)
|
|
18
|
-
5. EVENTS - Actions & state changes (/one/events/)
|
|
19
|
-
6. KNOWLEDGE - Labels, embeddings, RAG (/one/knowledge/)
|
|
20
|
-
|
|
21
|
-
Reference: /one/knowledge/ontology.md (Version 3.0.0)
|
|
22
|
-
"""
|
|
23
|
-
import json
|
|
24
|
-
import sys
|
|
25
|
-
import os
|
|
26
|
-
import hashlib
|
|
27
|
-
from pathlib import Path
|
|
28
|
-
from datetime import datetime
|
|
29
|
-
from typing import Dict, Any, Optional, List
|
|
30
|
-
|
|
31
|
-
# Knowledge artifact types
|
|
32
|
-
KNOWLEDGE_ARTIFACT_TYPES = {
|
|
33
|
-
"code": ["py", "ts", "tsx", "js", "jsx", "astro", "json", "yaml", "yml"],
|
|
34
|
-
"documentation": ["md", "mdx", "txt"],
|
|
35
|
-
"design": ["fig", "sketch", "svg", "png", "jpg"],
|
|
36
|
-
"test": ["test.ts", "test.tsx", "spec.ts", "spec.tsx"],
|
|
37
|
-
"config": ["json", "yaml", "yml", "toml", "ini"],
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
# 6-Dimension Ontology Mapping
|
|
41
|
-
ONTOLOGY_DIMENSION_LABELS = {
|
|
42
|
-
# Dimension 1: GROUPS (multi-tenant isolation)
|
|
43
|
-
"/one/groups": ["dimension:groups", "ontology", "multi-tenancy", "isolation"],
|
|
44
|
-
|
|
45
|
-
# Dimension 2: PEOPLE (authorization & governance)
|
|
46
|
-
"/one/people": ["dimension:people", "ontology", "authorization", "governance", "roles"],
|
|
47
|
-
|
|
48
|
-
# Dimension 3: THINGS (entities)
|
|
49
|
-
"/one/things": ["dimension:things", "ontology", "entities", "specifications"],
|
|
50
|
-
"/backend/convex/schema": ["dimension:things", "schema", "entities", "backend"],
|
|
51
|
-
"/backend/convex/mutations": ["dimension:things", "mutations", "write-operations", "backend"],
|
|
52
|
-
"/backend/convex/queries": ["dimension:things", "queries", "read-operations", "backend"],
|
|
53
|
-
"/backend/convex/services": ["dimension:things", "services", "business-logic", "backend"],
|
|
54
|
-
"/web/src/components": ["dimension:things", "components", "ui", "frontend"],
|
|
55
|
-
"/web/src/pages": ["dimension:things", "pages", "routing", "frontend"],
|
|
56
|
-
|
|
57
|
-
# Dimension 4: CONNECTIONS (relationships)
|
|
58
|
-
"/one/connections": ["dimension:connections", "ontology", "relationships", "patterns"],
|
|
59
|
-
|
|
60
|
-
# Dimension 5: EVENTS (actions & state changes)
|
|
61
|
-
"/one/events": ["dimension:events", "ontology", "actions", "audit-trail"],
|
|
62
|
-
|
|
63
|
-
# Dimension 6: KNOWLEDGE (labels, embeddings, RAG)
|
|
64
|
-
"/one/knowledge": ["dimension:knowledge", "ontology", "documentation", "patterns"],
|
|
65
|
-
|
|
66
|
-
# Testing (quality validation across all dimensions)
|
|
67
|
-
"/test": ["dimension:knowledge", "testing", "quality", "validation"],
|
|
68
|
-
|
|
69
|
-
# Installation-specific (organization customization)
|
|
70
|
-
"/acme": ["dimension:groups", "installation", "organization", "customization"],
|
|
71
|
-
"/groups/": ["dimension:groups", "group-specific", "team", "department"],
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
def get_artifact_type(file_path: str) -> Optional[str]:
|
|
75
|
-
"""Determine artifact type from file path"""
|
|
76
|
-
path = Path(file_path)
|
|
77
|
-
ext = path.suffix.lstrip(".")
|
|
78
|
-
|
|
79
|
-
# Check for test files first
|
|
80
|
-
if "test" in path.name or "spec" in path.name:
|
|
81
|
-
return "test"
|
|
82
|
-
|
|
83
|
-
# Check by extension
|
|
84
|
-
for artifact_type, extensions in KNOWLEDGE_ARTIFACT_TYPES.items():
|
|
85
|
-
if any(path.name.endswith(e) for e in extensions):
|
|
86
|
-
return artifact_type
|
|
87
|
-
|
|
88
|
-
return None
|
|
89
|
-
|
|
90
|
-
def get_ontology_dimension(file_path: str) -> Optional[str]:
|
|
91
|
-
"""Determine which of the 6 dimensions this artifact belongs to"""
|
|
92
|
-
# Check path patterns
|
|
93
|
-
if "/one/groups" in file_path or "/groups/" in file_path:
|
|
94
|
-
return "groups"
|
|
95
|
-
elif "/one/people" in file_path:
|
|
96
|
-
return "people"
|
|
97
|
-
elif "/one/things" in file_path or "/backend/" in file_path or "/web/" in file_path:
|
|
98
|
-
return "things"
|
|
99
|
-
elif "/one/connections" in file_path:
|
|
100
|
-
return "connections"
|
|
101
|
-
elif "/one/events" in file_path:
|
|
102
|
-
return "events"
|
|
103
|
-
elif "/one/knowledge" in file_path or "/test/" in file_path:
|
|
104
|
-
return "knowledge"
|
|
105
|
-
|
|
106
|
-
# Check for installation folders (map to groups dimension)
|
|
107
|
-
parts = Path(file_path).parts
|
|
108
|
-
if len(parts) > 1 and parts[0] != "one" and parts[0] != "web" and parts[0] != "backend":
|
|
109
|
-
# This is an installation folder
|
|
110
|
-
return "groups"
|
|
111
|
-
|
|
112
|
-
return None
|
|
113
|
-
|
|
114
|
-
def get_knowledge_labels(file_path: str) -> List[str]:
|
|
115
|
-
"""Generate semantic labels based on 6-dimension ontology"""
|
|
116
|
-
labels = []
|
|
117
|
-
|
|
118
|
-
# Add dimension-specific labels based on path patterns
|
|
119
|
-
for path_pattern, path_labels in ONTOLOGY_DIMENSION_LABELS.items():
|
|
120
|
-
if path_pattern in file_path:
|
|
121
|
-
labels.extend(path_labels)
|
|
122
|
-
|
|
123
|
-
# Add artifact type label
|
|
124
|
-
artifact_type = get_artifact_type(file_path)
|
|
125
|
-
if artifact_type:
|
|
126
|
-
labels.append(f"artifact:{artifact_type}")
|
|
127
|
-
|
|
128
|
-
# Add ontology dimension label
|
|
129
|
-
dimension = get_ontology_dimension(file_path)
|
|
130
|
-
if dimension and f"dimension:{dimension}" not in labels:
|
|
131
|
-
labels.append(f"dimension:{dimension}")
|
|
132
|
-
|
|
133
|
-
return list(set(labels)) # Remove duplicates
|
|
134
|
-
|
|
135
|
-
def get_inference_context() -> Dict[str, Any]:
|
|
136
|
-
"""Load current inference context from state file"""
|
|
137
|
-
try:
|
|
138
|
-
# Try project-specific state first
|
|
139
|
-
state_file = Path("/Users/toc/Server/ONE/.claude/state/inference.json")
|
|
140
|
-
if state_file.exists():
|
|
141
|
-
with open(state_file, 'r') as f:
|
|
142
|
-
state = json.load(f)
|
|
143
|
-
return {
|
|
144
|
-
"inference_number": state.get("current_inference", 0),
|
|
145
|
-
"feature": state.get("feature_name", "New Feature"),
|
|
146
|
-
"organization": state.get("organization", "Default Org"),
|
|
147
|
-
"person_role": state.get("person_role", "platform_owner"),
|
|
148
|
-
}
|
|
149
|
-
except Exception:
|
|
150
|
-
pass
|
|
151
|
-
|
|
152
|
-
# Try global todo state
|
|
153
|
-
try:
|
|
154
|
-
todo_state_path = Path.home() / ".claude" / "todo-state.json"
|
|
155
|
-
if todo_state_path.exists():
|
|
156
|
-
with open(todo_state_path, 'r') as f:
|
|
157
|
-
state = json.load(f)
|
|
158
|
-
return {
|
|
159
|
-
"inference_number": state.get("current_inference", 0),
|
|
160
|
-
"feature": state.get("feature", "New Feature"),
|
|
161
|
-
"organization": state.get("organization", "Default Org"),
|
|
162
|
-
"person_role": state.get("person_role", "platform_owner"),
|
|
163
|
-
}
|
|
164
|
-
except Exception:
|
|
165
|
-
pass
|
|
166
|
-
|
|
167
|
-
return {
|
|
168
|
-
"inference_number": 0,
|
|
169
|
-
"feature": "New Feature",
|
|
170
|
-
"organization": "Default Org",
|
|
171
|
-
"person_role": "platform_owner",
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
def should_tag_as_knowledge(file_path: str, tool_name: str) -> bool:
|
|
175
|
-
"""Determine if artifact should be tagged as knowledge"""
|
|
176
|
-
# Only tag Write and Edit operations
|
|
177
|
-
if tool_name not in ["Write", "Edit", "MultiEdit"]:
|
|
178
|
-
return False
|
|
179
|
-
|
|
180
|
-
# Don't tag temporary files
|
|
181
|
-
if "/tmp/" in file_path or "/.temp/" in file_path:
|
|
182
|
-
return False
|
|
183
|
-
|
|
184
|
-
# Don't tag generated files
|
|
185
|
-
if "/_generated/" in file_path or "/node_modules/" in file_path:
|
|
186
|
-
return False
|
|
187
|
-
|
|
188
|
-
# Only tag known artifact types
|
|
189
|
-
artifact_type = get_artifact_type(file_path)
|
|
190
|
-
if not artifact_type:
|
|
191
|
-
return False
|
|
192
|
-
|
|
193
|
-
return True
|
|
194
|
-
|
|
195
|
-
def generate_content_hash(file_path: str) -> str:
|
|
196
|
-
"""Generate SHA256 hash of file content"""
|
|
197
|
-
try:
|
|
198
|
-
with open(file_path, 'rb') as f:
|
|
199
|
-
return hashlib.sha256(f.read()).hexdigest()[:16]
|
|
200
|
-
except Exception:
|
|
201
|
-
return ""
|
|
202
|
-
|
|
203
|
-
def create_knowledge_entry(file_path: str, content: Optional[str] = None) -> Dict[str, Any]:
|
|
204
|
-
"""Create knowledge entry for artifact mapped to 6-dimension ontology"""
|
|
205
|
-
path = Path(file_path)
|
|
206
|
-
artifact_type = get_artifact_type(file_path)
|
|
207
|
-
labels = get_knowledge_labels(file_path)
|
|
208
|
-
dimension = get_ontology_dimension(file_path)
|
|
209
|
-
inference_ctx = get_inference_context()
|
|
210
|
-
content_hash = generate_content_hash(file_path)
|
|
211
|
-
|
|
212
|
-
# Build knowledge entry
|
|
213
|
-
entry = {
|
|
214
|
-
"type": "knowledge_item",
|
|
215
|
-
"artifact_type": artifact_type,
|
|
216
|
-
"ontology_dimension": dimension, # NEW: Maps to 6-dimension ontology
|
|
217
|
-
"file_path": str(path.absolute()),
|
|
218
|
-
"file_name": path.name,
|
|
219
|
-
"labels": labels,
|
|
220
|
-
"content_hash": content_hash,
|
|
221
|
-
"created_at": datetime.now().isoformat(),
|
|
222
|
-
"inference_number": inference_ctx["inference_number"],
|
|
223
|
-
"feature": inference_ctx["feature"],
|
|
224
|
-
"organization": inference_ctx["organization"],
|
|
225
|
-
"created_by_role": inference_ctx["person_role"],
|
|
226
|
-
"metadata": {
|
|
227
|
-
"file_size": path.stat().st_size if path.exists() else 0,
|
|
228
|
-
"directory": str(path.parent),
|
|
229
|
-
"extension": path.suffix,
|
|
230
|
-
"ontology_version": "3.0.0", # Track ontology version
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
# Add content preview if available
|
|
235
|
-
if content:
|
|
236
|
-
entry["content_preview"] = content[:500] if len(content) > 500 else content
|
|
237
|
-
elif path.exists():
|
|
238
|
-
try:
|
|
239
|
-
with open(path, 'r', encoding='utf-8') as f:
|
|
240
|
-
preview = f.read(500)
|
|
241
|
-
entry["content_preview"] = preview
|
|
242
|
-
except Exception:
|
|
243
|
-
pass
|
|
244
|
-
|
|
245
|
-
return entry
|
|
246
|
-
|
|
247
|
-
def save_knowledge_entry(entry: Dict[str, Any]) -> str:
|
|
248
|
-
"""Save knowledge entry to knowledge log"""
|
|
249
|
-
# Create knowledge log directory
|
|
250
|
-
knowledge_log_dir = Path.home() / ".claude" / "knowledge-log"
|
|
251
|
-
knowledge_log_dir.mkdir(parents=True, exist_ok=True)
|
|
252
|
-
|
|
253
|
-
# Create daily log file
|
|
254
|
-
log_date = datetime.now().strftime("%Y-%m-%d")
|
|
255
|
-
log_file = knowledge_log_dir / f"knowledge-{log_date}.jsonl"
|
|
256
|
-
|
|
257
|
-
# Append entry
|
|
258
|
-
with open(log_file, 'a') as f:
|
|
259
|
-
f.write(json.dumps(entry) + "\n")
|
|
260
|
-
|
|
261
|
-
return str(log_file)
|
|
262
|
-
|
|
263
|
-
def display_ontology_context(dimension: Optional[str]) -> str:
|
|
264
|
-
"""Display the 6-dimension ontology with current dimension highlighted"""
|
|
265
|
-
if not dimension:
|
|
266
|
-
return ""
|
|
267
|
-
|
|
268
|
-
ontology = """
|
|
269
|
-
6-Dimension Ontology:
|
|
270
|
-
┌────────────────────────────────────────┐
|
|
271
|
-
│ 1. GROUPS - Multi-tenant │{}
|
|
272
|
-
│ 2. PEOPLE - Authorization │{}
|
|
273
|
-
│ 3. THINGS - Entities │{}
|
|
274
|
-
│ 4. CONNECTIONS - Relationships │{}
|
|
275
|
-
│ 5. EVENTS - Actions │{}
|
|
276
|
-
│ 6. KNOWLEDGE - Labels & embeddings │{}
|
|
277
|
-
└────────────────────────────────────────┘
|
|
278
|
-
""".format(
|
|
279
|
-
" ✓ Captured" if dimension == "groups" else "",
|
|
280
|
-
" ✓ Captured" if dimension == "people" else "",
|
|
281
|
-
" ✓ Captured" if dimension == "things" else "",
|
|
282
|
-
" ✓ Captured" if dimension == "connections" else "",
|
|
283
|
-
" ✓ Captured" if dimension == "events" else "",
|
|
284
|
-
" ✓ Captured" if dimension == "knowledge" else ""
|
|
285
|
-
)
|
|
286
|
-
return ontology
|
|
287
|
-
|
|
288
|
-
def main():
|
|
289
|
-
"""Main hook execution"""
|
|
290
|
-
try:
|
|
291
|
-
# Read hook input from stdin
|
|
292
|
-
hook_input = json.load(sys.stdin)
|
|
293
|
-
|
|
294
|
-
hook_event = hook_input.get("hook_event_name")
|
|
295
|
-
tool_name = hook_input.get("tool_name")
|
|
296
|
-
tool_input = hook_input.get("tool_input", {})
|
|
297
|
-
|
|
298
|
-
# Only process PostToolUse for Write/Edit operations
|
|
299
|
-
if hook_event != "PostToolUse":
|
|
300
|
-
sys.exit(0)
|
|
301
|
-
|
|
302
|
-
file_path = tool_input.get("file_path")
|
|
303
|
-
if not file_path:
|
|
304
|
-
sys.exit(0)
|
|
305
|
-
|
|
306
|
-
# Check if should be tagged as knowledge
|
|
307
|
-
if not should_tag_as_knowledge(file_path, tool_name):
|
|
308
|
-
sys.exit(0)
|
|
309
|
-
|
|
310
|
-
# Create knowledge entry
|
|
311
|
-
content = tool_input.get("content") or tool_input.get("new_string")
|
|
312
|
-
entry = create_knowledge_entry(file_path, content)
|
|
313
|
-
|
|
314
|
-
# Save to knowledge log
|
|
315
|
-
log_file = save_knowledge_entry(entry)
|
|
316
|
-
|
|
317
|
-
# Output post-hook message
|
|
318
|
-
artifact_type = entry["artifact_type"]
|
|
319
|
-
labels = entry["labels"]
|
|
320
|
-
inference_num = entry["inference_number"]
|
|
321
|
-
dimension = entry["ontology_dimension"]
|
|
322
|
-
|
|
323
|
-
msg = f"✨ Knowledge Tagged - 6-Dimension Ontology\n"
|
|
324
|
-
msg += f" Artifact: {entry['file_name']}\n"
|
|
325
|
-
msg += f" Type: {artifact_type}\n"
|
|
326
|
-
|
|
327
|
-
if dimension:
|
|
328
|
-
msg += f" Dimension: {dimension.upper()}\n"
|
|
329
|
-
|
|
330
|
-
msg += f" Labels: {', '.join(labels[:5])}"
|
|
331
|
-
if len(labels) > 5:
|
|
332
|
-
msg += f" (+{len(labels) - 5} more)"
|
|
333
|
-
|
|
334
|
-
if inference_num > 0:
|
|
335
|
-
msg += f"\n Inference: {inference_num}/100"
|
|
336
|
-
|
|
337
|
-
msg += f"\n Hash: {entry['content_hash']}"
|
|
338
|
-
msg += f"\n → Logged to: {Path(log_file).name}"
|
|
339
|
-
|
|
340
|
-
# Show ontology context if dimension is known
|
|
341
|
-
if dimension:
|
|
342
|
-
msg += display_ontology_context(dimension)
|
|
343
|
-
|
|
344
|
-
print(msg)
|
|
345
|
-
sys.exit(0)
|
|
346
|
-
|
|
347
|
-
except json.JSONDecodeError as e:
|
|
348
|
-
print(f"Error: Invalid JSON input: {e}", file=sys.stderr)
|
|
349
|
-
sys.exit(1)
|
|
350
|
-
except Exception as e:
|
|
351
|
-
print(f"Error in knowledge post-hook: {e}", file=sys.stderr)
|
|
352
|
-
sys.exit(1)
|
|
353
|
-
|
|
354
|
-
if __name__ == "__main__":
|
|
355
|
-
main()
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
ONE Platform - Knowledge Tagging Pre-Hook
|
|
4
|
-
Validates that artifacts created will be tagged in the 6-dimension ontology.
|
|
5
|
-
|
|
6
|
-
This hook runs on PreToolUse to:
|
|
7
|
-
- Map artifacts to the correct dimension (groups, people, things, connections, events, knowledge)
|
|
8
|
-
- Guide agents to proper documentation paths
|
|
9
|
-
- Prepare semantic labels for the knowledge dimension
|
|
10
|
-
- Display the ontology structure for context
|
|
11
|
-
|
|
12
|
-
6-Dimension Ontology:
|
|
13
|
-
1. GROUPS - Multi-tenant isolation (/one/groups/)
|
|
14
|
-
2. PEOPLE - Authorization & governance (/one/people/)
|
|
15
|
-
3. THINGS - Entities (66+ types) (/one/things/)
|
|
16
|
-
4. CONNECTIONS - Relationships (25+ types) (/one/connections/)
|
|
17
|
-
5. EVENTS - Actions & state changes (/one/events/)
|
|
18
|
-
6. KNOWLEDGE - Labels, embeddings, RAG (/one/knowledge/)
|
|
19
|
-
|
|
20
|
-
Reference: /one/knowledge/ontology.md (Version 3.0.0)
|
|
21
|
-
"""
|
|
22
|
-
import json
|
|
23
|
-
import sys
|
|
24
|
-
import os
|
|
25
|
-
from pathlib import Path
|
|
26
|
-
from typing import Dict, Any, Optional, List
|
|
27
|
-
|
|
28
|
-
# Knowledge artifact types
|
|
29
|
-
KNOWLEDGE_ARTIFACT_TYPES = {
|
|
30
|
-
"code": ["py", "ts", "tsx", "js", "jsx", "astro", "json", "yaml", "yml"],
|
|
31
|
-
"documentation": ["md", "mdx", "txt"],
|
|
32
|
-
"design": ["fig", "sketch", "svg", "png", "jpg"],
|
|
33
|
-
"test": ["test.ts", "test.tsx", "spec.ts", "spec.tsx"],
|
|
34
|
-
"config": ["json", "yaml", "yml", "toml", "ini"],
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
# 6-Dimension Ontology Mapping
|
|
38
|
-
# Maps file paths to dimensions and semantic labels
|
|
39
|
-
ONTOLOGY_DIMENSION_LABELS = {
|
|
40
|
-
# Dimension 1: GROUPS (multi-tenant isolation)
|
|
41
|
-
"/one/groups": ["dimension:groups", "ontology", "multi-tenancy", "isolation"],
|
|
42
|
-
|
|
43
|
-
# Dimension 2: PEOPLE (authorization & governance)
|
|
44
|
-
"/one/people": ["dimension:people", "ontology", "authorization", "governance", "roles"],
|
|
45
|
-
|
|
46
|
-
# Dimension 3: THINGS (entities)
|
|
47
|
-
"/one/things": ["dimension:things", "ontology", "entities", "specifications"],
|
|
48
|
-
"/backend/convex/schema": ["dimension:things", "schema", "entities", "backend"],
|
|
49
|
-
"/backend/convex/mutations": ["dimension:things", "mutations", "write-operations", "backend"],
|
|
50
|
-
"/backend/convex/queries": ["dimension:things", "queries", "read-operations", "backend"],
|
|
51
|
-
"/backend/convex/services": ["dimension:things", "services", "business-logic", "backend"],
|
|
52
|
-
"/web/src/components": ["dimension:things", "components", "ui", "frontend"],
|
|
53
|
-
"/web/src/pages": ["dimension:things", "pages", "routing", "frontend"],
|
|
54
|
-
|
|
55
|
-
# Dimension 4: CONNECTIONS (relationships)
|
|
56
|
-
"/one/connections": ["dimension:connections", "ontology", "relationships", "patterns"],
|
|
57
|
-
|
|
58
|
-
# Dimension 5: EVENTS (actions & state changes)
|
|
59
|
-
"/one/events": ["dimension:events", "ontology", "actions", "audit-trail"],
|
|
60
|
-
|
|
61
|
-
# Dimension 6: KNOWLEDGE (labels, embeddings, RAG)
|
|
62
|
-
"/one/knowledge": ["dimension:knowledge", "ontology", "documentation", "patterns"],
|
|
63
|
-
|
|
64
|
-
# Testing (quality validation across all dimensions)
|
|
65
|
-
"/test": ["dimension:knowledge", "testing", "quality", "validation"],
|
|
66
|
-
|
|
67
|
-
# Installation-specific (organization customization)
|
|
68
|
-
"/acme": ["dimension:groups", "installation", "organization", "customization"],
|
|
69
|
-
"/groups/": ["dimension:groups", "group-specific", "team", "department"],
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
def get_artifact_type(file_path: str) -> Optional[str]:
|
|
73
|
-
"""Determine artifact type from file path"""
|
|
74
|
-
path = Path(file_path)
|
|
75
|
-
ext = path.suffix.lstrip(".")
|
|
76
|
-
|
|
77
|
-
# Check for test files first
|
|
78
|
-
if "test" in path.name or "spec" in path.name:
|
|
79
|
-
return "test"
|
|
80
|
-
|
|
81
|
-
# Check by extension
|
|
82
|
-
for artifact_type, extensions in KNOWLEDGE_ARTIFACT_TYPES.items():
|
|
83
|
-
if any(path.name.endswith(e) for e in extensions):
|
|
84
|
-
return artifact_type
|
|
85
|
-
|
|
86
|
-
return None
|
|
87
|
-
|
|
88
|
-
def get_ontology_dimension(file_path: str) -> Optional[str]:
|
|
89
|
-
"""Determine which of the 6 dimensions this artifact belongs to"""
|
|
90
|
-
# Check path patterns
|
|
91
|
-
if "/one/groups" in file_path or "/groups/" in file_path:
|
|
92
|
-
return "groups"
|
|
93
|
-
elif "/one/people" in file_path:
|
|
94
|
-
return "people"
|
|
95
|
-
elif "/one/things" in file_path or "/backend/" in file_path or "/web/" in file_path:
|
|
96
|
-
return "things"
|
|
97
|
-
elif "/one/connections" in file_path:
|
|
98
|
-
return "connections"
|
|
99
|
-
elif "/one/events" in file_path:
|
|
100
|
-
return "events"
|
|
101
|
-
elif "/one/knowledge" in file_path or "/test/" in file_path:
|
|
102
|
-
return "knowledge"
|
|
103
|
-
|
|
104
|
-
# Check for installation folders (map to groups dimension)
|
|
105
|
-
parts = Path(file_path).parts
|
|
106
|
-
if len(parts) > 1 and parts[0] != "one" and parts[0] != "web" and parts[0] != "backend":
|
|
107
|
-
# This is an installation folder
|
|
108
|
-
return "groups"
|
|
109
|
-
|
|
110
|
-
return None
|
|
111
|
-
|
|
112
|
-
def get_knowledge_labels(file_path: str) -> List[str]:
|
|
113
|
-
"""Generate semantic labels based on 6-dimension ontology"""
|
|
114
|
-
labels = []
|
|
115
|
-
|
|
116
|
-
# Add dimension-specific labels based on path patterns
|
|
117
|
-
for path_pattern, path_labels in ONTOLOGY_DIMENSION_LABELS.items():
|
|
118
|
-
if path_pattern in file_path:
|
|
119
|
-
labels.extend(path_labels)
|
|
120
|
-
|
|
121
|
-
# Add artifact type label
|
|
122
|
-
artifact_type = get_artifact_type(file_path)
|
|
123
|
-
if artifact_type:
|
|
124
|
-
labels.append(f"artifact:{artifact_type}")
|
|
125
|
-
|
|
126
|
-
# Add ontology dimension label
|
|
127
|
-
dimension = get_ontology_dimension(file_path)
|
|
128
|
-
if dimension and f"dimension:{dimension}" not in labels:
|
|
129
|
-
labels.append(f"dimension:{dimension}")
|
|
130
|
-
|
|
131
|
-
return list(set(labels)) # Remove duplicates
|
|
132
|
-
|
|
133
|
-
def get_dimension_docs(dimension: str) -> str:
|
|
134
|
-
"""Get documentation path for a dimension"""
|
|
135
|
-
dimension_docs = {
|
|
136
|
-
"groups": "/one/groups/README.md or /one/knowledge/ontology.md#groups",
|
|
137
|
-
"people": "/one/people/README.md or /one/knowledge/ontology.md#people",
|
|
138
|
-
"things": "/one/things/ or /one/knowledge/ontology.md#things",
|
|
139
|
-
"connections": "/one/connections/ or /one/knowledge/ontology.md#connections",
|
|
140
|
-
"events": "/one/events/ or /one/knowledge/ontology.md#events",
|
|
141
|
-
"knowledge": "/one/knowledge/ or /one/knowledge/ontology.md#knowledge",
|
|
142
|
-
}
|
|
143
|
-
return dimension_docs.get(dimension, "/one/knowledge/ontology.md")
|
|
144
|
-
|
|
145
|
-
def should_tag_as_knowledge(file_path: str, tool_name: str) -> bool:
|
|
146
|
-
"""Determine if artifact should be tagged as knowledge"""
|
|
147
|
-
# Only tag Write and Edit operations
|
|
148
|
-
if tool_name not in ["Write", "Edit", "MultiEdit"]:
|
|
149
|
-
return False
|
|
150
|
-
|
|
151
|
-
# Don't tag temporary files
|
|
152
|
-
if "/tmp/" in file_path or "/.temp/" in file_path:
|
|
153
|
-
return False
|
|
154
|
-
|
|
155
|
-
# Don't tag generated files
|
|
156
|
-
if "/_generated/" in file_path or "/node_modules/" in file_path:
|
|
157
|
-
return False
|
|
158
|
-
|
|
159
|
-
# Only tag known artifact types
|
|
160
|
-
artifact_type = get_artifact_type(file_path)
|
|
161
|
-
if not artifact_type:
|
|
162
|
-
return False
|
|
163
|
-
|
|
164
|
-
return True
|
|
165
|
-
|
|
166
|
-
def display_ontology_context(dimension: Optional[str], labels: List[str]) -> str:
|
|
167
|
-
"""Display the 6-dimension ontology with current dimension highlighted"""
|
|
168
|
-
ontology = """
|
|
169
|
-
6-Dimension Ontology:
|
|
170
|
-
┌────────────────────────────────────────┐
|
|
171
|
-
│ 1. GROUPS - Multi-tenant │{}
|
|
172
|
-
│ 2. PEOPLE - Authorization │{}
|
|
173
|
-
│ 3. THINGS - Entities │{}
|
|
174
|
-
│ 4. CONNECTIONS - Relationships │{}
|
|
175
|
-
│ 5. EVENTS - Actions │{}
|
|
176
|
-
│ 6. KNOWLEDGE - Labels & embeddings │{}
|
|
177
|
-
└────────────────────────────────────────┘
|
|
178
|
-
""".format(
|
|
179
|
-
" ← HERE" if dimension == "groups" else "",
|
|
180
|
-
" ← HERE" if dimension == "people" else "",
|
|
181
|
-
" ← HERE" if dimension == "things" else "",
|
|
182
|
-
" ← HERE" if dimension == "connections" else "",
|
|
183
|
-
" ← HERE" if dimension == "events" else "",
|
|
184
|
-
" ← HERE" if dimension == "knowledge" else ""
|
|
185
|
-
)
|
|
186
|
-
return ontology
|
|
187
|
-
|
|
188
|
-
def main():
|
|
189
|
-
"""Main hook execution"""
|
|
190
|
-
try:
|
|
191
|
-
# Read hook input from stdin
|
|
192
|
-
hook_input = json.load(sys.stdin)
|
|
193
|
-
|
|
194
|
-
hook_event = hook_input.get("hook_event_name")
|
|
195
|
-
tool_name = hook_input.get("tool_name")
|
|
196
|
-
tool_input = hook_input.get("tool_input", {})
|
|
197
|
-
|
|
198
|
-
# Only process PreToolUse for Write/Edit operations
|
|
199
|
-
if hook_event != "PreToolUse":
|
|
200
|
-
sys.exit(0)
|
|
201
|
-
|
|
202
|
-
file_path = tool_input.get("file_path")
|
|
203
|
-
if not file_path:
|
|
204
|
-
sys.exit(0)
|
|
205
|
-
|
|
206
|
-
# Check if should be tagged as knowledge
|
|
207
|
-
if not should_tag_as_knowledge(file_path, tool_name):
|
|
208
|
-
sys.exit(0)
|
|
209
|
-
|
|
210
|
-
# Prepare knowledge metadata
|
|
211
|
-
artifact_type = get_artifact_type(file_path)
|
|
212
|
-
labels = get_knowledge_labels(file_path)
|
|
213
|
-
dimension = get_ontology_dimension(file_path)
|
|
214
|
-
|
|
215
|
-
# Output pre-hook message
|
|
216
|
-
msg = f"📚 Knowledge Pre-Hook - 6-Dimension Ontology\n"
|
|
217
|
-
msg += f" Artifact: {Path(file_path).name}\n"
|
|
218
|
-
msg += f" Type: {artifact_type}\n"
|
|
219
|
-
|
|
220
|
-
if dimension:
|
|
221
|
-
msg += f" Dimension: {dimension.upper()}\n"
|
|
222
|
-
msg += f" Docs: {get_dimension_docs(dimension)}\n"
|
|
223
|
-
|
|
224
|
-
msg += f" Labels: {', '.join(labels[:5])}"
|
|
225
|
-
if len(labels) > 5:
|
|
226
|
-
msg += f" (+{len(labels) - 5} more)"
|
|
227
|
-
|
|
228
|
-
msg += f"\n → Will be tagged in knowledge dimension after creation"
|
|
229
|
-
|
|
230
|
-
# Show ontology context if dimension is known
|
|
231
|
-
if dimension:
|
|
232
|
-
msg += display_ontology_context(dimension, labels)
|
|
233
|
-
|
|
234
|
-
print(msg)
|
|
235
|
-
sys.exit(0)
|
|
236
|
-
|
|
237
|
-
except json.JSONDecodeError as e:
|
|
238
|
-
print(f"Error: Invalid JSON input: {e}", file=sys.stderr)
|
|
239
|
-
sys.exit(1)
|
|
240
|
-
except Exception as e:
|
|
241
|
-
print(f"Error in knowledge pre-hook: {e}", file=sys.stderr)
|
|
242
|
-
sys.exit(1)
|
|
243
|
-
|
|
244
|
-
if __name__ == "__main__":
|
|
245
|
-
main()
|