oneie 3.6.23 → 3.6.25
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-backend.md +2 -2
- package/.claude/agents/agent-designer.md +1 -0
- package/.claude/agents/agent-director.md +71 -71
- package/.claude/agents/agent-onboard.md +1 -1
- package/.claude/agents/agent-ontology.md +2 -2
- package/.claude/agents/agent-ops.md +58 -38
- package/.claude/agents/agent-sales.md +3 -3
- package/.claude/commands/cascade.md +21 -21
- package/.claude/commands/create.md +19 -19
- package/.claude/commands/deploy.md +82 -104
- package/.claude/commands/mcp-on.md +191 -0
- package/.claude/commands/one.md +267 -92
- package/.claude/commands/plan.md +17 -17
- package/.claude/commands/release.md +65 -14
- package/.claude/hooks/PULL-BEFORE-PUSH-GUIDE.md +473 -0
- package/.claude/hooks/README-knowledge-hooks.md +451 -0
- package/.claude/hooks/README-root-cleanup.md +200 -0
- package/.claude/hooks/README.md +284 -0
- 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 +177 -0
- package/.claude/hooks/clean-post.py +468 -0
- package/.claude/hooks/clean-pre.py +393 -0
- package/.claude/hooks/clean-root-markdown.sh +73 -0
- package/.claude/hooks/commit-push.sh +95 -0
- package/.claude/hooks/done.py +236 -0
- package/.claude/hooks/format-hook.sh +163 -0
- package/.claude/hooks/hook-logger.sh +173 -0
- package/.claude/hooks/knowledge-post.py +355 -0
- package/.claude/hooks/knowledge-pre.py +245 -0
- package/.claude/hooks/mcp-on.sh +134 -0
- package/.claude/hooks/notification-hook.sh +279 -0
- package/.claude/hooks/push.sh +101 -0
- package/.claude/hooks/release-cli.sh +16 -8
- package/.claude/hooks/root-cleanup.py +217 -0
- package/.claude/hooks/security-hook.sh +397 -0
- package/.claude/hooks/tag-all-docs.py +464 -0
- package/.claude/hooks/test-validate-ontology.sh +170 -0
- package/.claude/hooks/todo.py +368 -0
- package/.claude/hooks/track-changes.sh +101 -0
- package/.claude/hooks/validate-ontology-structure-summary.md +243 -0
- package/.claude/hooks/validate-ontology-structure.py +518 -0
- package/.claude/skills/INDEX.md +1 -1
- package/.claude/skills/ontology/README.md +1 -1
- package/package.json +1 -1
- package/.claude/commands/mcp-toggle.md +0 -93
- package/.claude/commands/npx.md +0 -84
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Ontology Structure Validator for ONE Platform
|
|
4
|
+
Ensures all files in /one follow the 6-dimension ontology structure
|
|
5
|
+
|
|
6
|
+
The 6-Dimension Ontology:
|
|
7
|
+
1. groups - Hierarchical containers (friend circles → governments)
|
|
8
|
+
2. people - Authorization & governance (who can do what)
|
|
9
|
+
3. things - All entities (66 types: user, agent, content, etc.)
|
|
10
|
+
4. connections - All relationships (25 types: owns, purchased, etc.)
|
|
11
|
+
5. events - All actions (67 types: created, updated, logged, etc.)
|
|
12
|
+
6. knowledge - AI understanding (embeddings, search, RAG)
|
|
13
|
+
|
|
14
|
+
Database Implementation (5 tables):
|
|
15
|
+
- groups table → groups dimension
|
|
16
|
+
- things table → things dimension (includes people as type: 'creator')
|
|
17
|
+
- connections table → connections dimension
|
|
18
|
+
- events table → events dimension
|
|
19
|
+
- knowledge table → knowledge dimension
|
|
20
|
+
|
|
21
|
+
Directory Structure:
|
|
22
|
+
/one/
|
|
23
|
+
groups/ - Group definitions and hierarchies
|
|
24
|
+
people/ - Roles, governance, organization (people are things with role metadata)
|
|
25
|
+
things/ - Entity specifications, plans, agent definitions
|
|
26
|
+
connections/ - Protocols, workflows, integrations
|
|
27
|
+
events/ - Deployment plans, release notes, test results
|
|
28
|
+
knowledge/ - Architecture, patterns, rules, guides
|
|
29
|
+
"""
|
|
30
|
+
import json
|
|
31
|
+
import sys
|
|
32
|
+
import os
|
|
33
|
+
import re
|
|
34
|
+
from pathlib import Path
|
|
35
|
+
|
|
36
|
+
# ONE Platform 6-Dimension Ontology
|
|
37
|
+
VALID_DIMENSIONS = {
|
|
38
|
+
"groups": {
|
|
39
|
+
"aliases": ["groups", "group"],
|
|
40
|
+
"description": "Hierarchical containers - friend circles → DAOs → governments",
|
|
41
|
+
"example_files": ["groups.md", "revenue.md", "vision.md", "strategy.md", "features.md"]
|
|
42
|
+
},
|
|
43
|
+
"people": {
|
|
44
|
+
"aliases": ["people", "person"],
|
|
45
|
+
"description": "Authorization & governance - roles, permissions, organization",
|
|
46
|
+
"example_files": ["people.md", "roles.md", "governance.md", "team.md"],
|
|
47
|
+
"note": "People are stored as things (type: 'creator') with role metadata"
|
|
48
|
+
},
|
|
49
|
+
"things": {
|
|
50
|
+
"aliases": ["things", "thing"],
|
|
51
|
+
"description": "All entities - users, agents, content, tokens, courses (66 types)",
|
|
52
|
+
"example_files": ["agents/", "plans/", "specifications/", "components.md"],
|
|
53
|
+
"types": [
|
|
54
|
+
# Core (People as Things)
|
|
55
|
+
"creator", "ai_clone", "audience_member", "organization",
|
|
56
|
+
# Business Agents
|
|
57
|
+
"strategy_agent", "research_agent", "marketing_agent", "sales_agent",
|
|
58
|
+
"service_agent", "design_agent", "engineering_agent", "finance_agent",
|
|
59
|
+
"legal_agent", "intelligence_agent",
|
|
60
|
+
# Content
|
|
61
|
+
"blog_post", "video", "podcast", "social_post", "email", "course", "lesson",
|
|
62
|
+
# Products
|
|
63
|
+
"digital_product", "membership", "consultation", "nft",
|
|
64
|
+
# Community
|
|
65
|
+
"community", "conversation", "message",
|
|
66
|
+
# Token
|
|
67
|
+
"token", "token_contract",
|
|
68
|
+
# Knowledge
|
|
69
|
+
"knowledge_item", "embedding",
|
|
70
|
+
# Platform
|
|
71
|
+
"website", "landing_page", "template", "livestream", "recording", "media_asset",
|
|
72
|
+
# Business
|
|
73
|
+
"payment", "subscription", "invoice", "metric", "insight", "prediction", "report",
|
|
74
|
+
# Auth Session
|
|
75
|
+
"session", "oauth_account", "verification_token", "password_reset_token",
|
|
76
|
+
# UI Preferences
|
|
77
|
+
"ui_preferences",
|
|
78
|
+
# Marketing
|
|
79
|
+
"notification", "email_campaign", "announcement", "referral", "campaign", "lead",
|
|
80
|
+
# External
|
|
81
|
+
"external_agent", "external_workflow", "external_connection",
|
|
82
|
+
# Protocol
|
|
83
|
+
"mandate", "product",
|
|
84
|
+
# Workflow
|
|
85
|
+
"idea", "plan", "feature", "test", "design", "task", "lesson"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"connections": {
|
|
89
|
+
"aliases": ["connections", "connection"],
|
|
90
|
+
"description": "All relationships - owns, purchased, enrolled_in (25 types)",
|
|
91
|
+
"example_files": ["protocols.md", "workflow.md", "integrations/", "patterns.md"],
|
|
92
|
+
"types": [
|
|
93
|
+
# Ownership
|
|
94
|
+
"owns", "created_by",
|
|
95
|
+
# AI Relationships
|
|
96
|
+
"clone_of", "trained_on", "powers",
|
|
97
|
+
# Content Relationships
|
|
98
|
+
"authored", "generated_by", "published_to", "part_of", "references",
|
|
99
|
+
# Community Relationships
|
|
100
|
+
"member_of", "following", "moderates", "participated_in",
|
|
101
|
+
# Business Relationships
|
|
102
|
+
"manages", "reports_to", "collaborates_with",
|
|
103
|
+
# Token Relationships
|
|
104
|
+
"holds_tokens", "staked_in", "earned_from",
|
|
105
|
+
# Product Relationships
|
|
106
|
+
"purchased", "enrolled_in", "completed", "teaching",
|
|
107
|
+
# Consolidated (7 connection families)
|
|
108
|
+
"transacted", "notified", "referred", "communicated", "delegated", "approved", "fulfilled"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"events": {
|
|
112
|
+
"aliases": ["events", "event"],
|
|
113
|
+
"description": "All actions - created, updated, purchased, completed (67 types)",
|
|
114
|
+
"example_files": ["deployment/", "releases/", "test-results/", "agent-summaries/"],
|
|
115
|
+
"types": [
|
|
116
|
+
# Entity Lifecycle
|
|
117
|
+
"entity_created", "entity_updated", "entity_deleted", "entity_archived",
|
|
118
|
+
# User Events
|
|
119
|
+
"user_registered", "user_verified", "user_login", "user_logout", "profile_updated",
|
|
120
|
+
# Authentication Events
|
|
121
|
+
"password_reset_requested", "password_reset_completed",
|
|
122
|
+
"email_verification_sent", "email_verified",
|
|
123
|
+
"two_factor_enabled", "two_factor_disabled",
|
|
124
|
+
# Organization Events
|
|
125
|
+
"organization_created", "organization_updated",
|
|
126
|
+
"user_invited_to_org", "user_joined_org", "user_removed_from_org",
|
|
127
|
+
# Dashboard UI Events
|
|
128
|
+
"dashboard_viewed", "settings_updated", "theme_changed", "preferences_updated",
|
|
129
|
+
# AI Clone Events
|
|
130
|
+
"clone_created", "clone_updated", "voice_cloned", "appearance_cloned",
|
|
131
|
+
# Agent Events
|
|
132
|
+
"agent_created", "agent_executed", "agent_completed", "agent_failed",
|
|
133
|
+
# Token Events
|
|
134
|
+
"token_created", "token_minted", "token_burned",
|
|
135
|
+
"tokens_purchased", "tokens_staked", "tokens_unstaked", "tokens_transferred",
|
|
136
|
+
# Course Events
|
|
137
|
+
"course_created", "course_enrolled", "lesson_completed", "course_completed", "certificate_earned",
|
|
138
|
+
# Analytics Events
|
|
139
|
+
"metric_calculated", "insight_generated", "prediction_made", "optimization_applied", "report_generated",
|
|
140
|
+
# Cycle Events
|
|
141
|
+
"cycle_request", "cycle_completed", "cycle_failed",
|
|
142
|
+
"cycle_quota_exceeded", "cycle_revenue_collected",
|
|
143
|
+
"org_revenue_generated", "revenue_share_distributed",
|
|
144
|
+
# Blockchain Events
|
|
145
|
+
"nft_minted", "nft_transferred", "tokens_bridged", "contract_deployed", "treasury_withdrawal",
|
|
146
|
+
# Consolidated Events (protocol-specific via metadata.protocol)
|
|
147
|
+
"content_event", "payment_event", "subscription_event", "commerce_event",
|
|
148
|
+
"livestream_event", "notification_event", "referral_event",
|
|
149
|
+
"communication_event", "task_event", "mandate_event", "price_event",
|
|
150
|
+
# Workflow Events
|
|
151
|
+
"plan_started", "feature_assigned", "tasks_created",
|
|
152
|
+
"feature_started", "implementation_complete", "task_started", "task_completed",
|
|
153
|
+
"quality_check_started", "quality_check_complete", "test_started", "test_passed", "test_failed",
|
|
154
|
+
"problem_analysis_started", "solution_proposed", "fix_started", "fix_complete",
|
|
155
|
+
"documentation_started", "documentation_complete", "lesson_learned_added",
|
|
156
|
+
"feature_complete", "plan_complete"
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
"knowledge": {
|
|
160
|
+
"aliases": ["knowledge"],
|
|
161
|
+
"description": "AI understanding - embeddings, search, RAG (labels, chunks, vectors)",
|
|
162
|
+
"example_files": ["ontology.md", "architecture.md", "patterns/", "rules.md", "guides/"],
|
|
163
|
+
"types": ["label", "document", "chunk", "vector_only"]
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
# Expected directory structure for /one
|
|
168
|
+
EXPECTED_STRUCTURE = {
|
|
169
|
+
"groups": "Group definitions, hierarchies, vision, strategy, revenue",
|
|
170
|
+
"people": "Roles, governance, team structure, organization (people are things with type: 'creator')",
|
|
171
|
+
"things": "Entity specifications, agent definitions, plans, components",
|
|
172
|
+
"connections": "Protocols, workflows, integrations, relationships, patterns",
|
|
173
|
+
"events": "Deployment plans, release notes, test results, agent execution summaries",
|
|
174
|
+
"knowledge": "Architecture docs, implementation guides, patterns, rules, tutorials"
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
# Protocol identifiers that should be in metadata
|
|
178
|
+
PROTOCOLS = ["a2a", "acp", "ap2", "x402", "ag-ui"]
|
|
179
|
+
|
|
180
|
+
def get_dimension_from_path(file_path):
|
|
181
|
+
"""Extract dimension from file path"""
|
|
182
|
+
parts = Path(file_path).parts
|
|
183
|
+
|
|
184
|
+
# Find 'one' in path and get next part
|
|
185
|
+
try:
|
|
186
|
+
one_index = parts.index('one')
|
|
187
|
+
if one_index + 1 < len(parts):
|
|
188
|
+
return parts[one_index + 1]
|
|
189
|
+
except ValueError:
|
|
190
|
+
return None
|
|
191
|
+
|
|
192
|
+
return None
|
|
193
|
+
|
|
194
|
+
def normalize_dimension(dimension):
|
|
195
|
+
"""Normalize dimension name to canonical form"""
|
|
196
|
+
if not dimension:
|
|
197
|
+
return None
|
|
198
|
+
|
|
199
|
+
dimension_lower = dimension.lower()
|
|
200
|
+
|
|
201
|
+
for canonical, config in VALID_DIMENSIONS.items():
|
|
202
|
+
if dimension_lower in [alias.lower() for alias in config["aliases"]]:
|
|
203
|
+
return canonical
|
|
204
|
+
|
|
205
|
+
return None
|
|
206
|
+
|
|
207
|
+
def to_kebab_case(filename):
|
|
208
|
+
"""Convert filename to kebab-case"""
|
|
209
|
+
# Split filename and extension
|
|
210
|
+
name, ext = os.path.splitext(filename)
|
|
211
|
+
|
|
212
|
+
# Convert to lowercase
|
|
213
|
+
name = name.lower()
|
|
214
|
+
|
|
215
|
+
# Replace spaces, underscores, and multiple hyphens with single hyphen
|
|
216
|
+
name = re.sub(r'[_\s]+', '-', name)
|
|
217
|
+
name = re.sub(r'-+', '-', name)
|
|
218
|
+
|
|
219
|
+
# Remove leading/trailing hyphens
|
|
220
|
+
name = name.strip('-')
|
|
221
|
+
|
|
222
|
+
# Keep extension lowercase
|
|
223
|
+
ext = ext.lower()
|
|
224
|
+
|
|
225
|
+
return name + ext
|
|
226
|
+
|
|
227
|
+
def validate_file_path(file_path):
|
|
228
|
+
"""Validate that file path follows ontology structure"""
|
|
229
|
+
issues = []
|
|
230
|
+
|
|
231
|
+
# Check if file is in /one directory
|
|
232
|
+
if '/one/' not in file_path:
|
|
233
|
+
return issues # Not in /one, skip validation
|
|
234
|
+
|
|
235
|
+
# Allow certain root-level files in /one
|
|
236
|
+
parts = Path(file_path).parts
|
|
237
|
+
try:
|
|
238
|
+
one_index = parts.index('one')
|
|
239
|
+
# If this is a direct child of /one (not in a subdirectory)
|
|
240
|
+
if one_index + 2 == len(parts):
|
|
241
|
+
# Allow specific root-level files
|
|
242
|
+
allowed_root_files = ['LICENSE.md', 'README.md', 'CONTRIBUTING.md', 'CHANGELOG.md', '.gitignore']
|
|
243
|
+
filename = Path(file_path).name
|
|
244
|
+
if filename in allowed_root_files:
|
|
245
|
+
return issues # Valid root-level file
|
|
246
|
+
except ValueError:
|
|
247
|
+
pass
|
|
248
|
+
|
|
249
|
+
# Extract dimension from path
|
|
250
|
+
dimension = get_dimension_from_path(file_path)
|
|
251
|
+
|
|
252
|
+
if not dimension:
|
|
253
|
+
issues.append("File is in /one but not in a dimension directory")
|
|
254
|
+
return issues
|
|
255
|
+
|
|
256
|
+
# Normalize and validate dimension
|
|
257
|
+
canonical_dimension = normalize_dimension(dimension)
|
|
258
|
+
|
|
259
|
+
if not canonical_dimension:
|
|
260
|
+
valid_dims = []
|
|
261
|
+
for dim_config in VALID_DIMENSIONS.values():
|
|
262
|
+
valid_dims.extend(dim_config["aliases"])
|
|
263
|
+
issues.append(
|
|
264
|
+
f"Invalid dimension '{dimension}'. Must be one of: {', '.join(valid_dims)}"
|
|
265
|
+
)
|
|
266
|
+
return issues
|
|
267
|
+
|
|
268
|
+
# Check file extension
|
|
269
|
+
valid_extensions = ['.md', '.yaml', '.yml', '.json']
|
|
270
|
+
if not any(file_path.endswith(ext) for ext in valid_extensions):
|
|
271
|
+
issues.append(
|
|
272
|
+
f"Invalid file extension. Files in /one must be: {', '.join(valid_extensions)}"
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
# Check for valid naming conventions
|
|
276
|
+
filename = Path(file_path).name
|
|
277
|
+
|
|
278
|
+
# Files should use kebab-case
|
|
279
|
+
if not re.match(r'^[a-z0-9]+(-[a-z0-9]+)*\.(md|yaml|yml|json)$', filename):
|
|
280
|
+
correct_name = to_kebab_case(filename)
|
|
281
|
+
issues.append(
|
|
282
|
+
f"Filename '{filename}' should use kebab-case (lowercase with hyphens). Suggested: '{correct_name}'"
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
return issues
|
|
286
|
+
|
|
287
|
+
def validate_file_content(file_path, content=None):
|
|
288
|
+
"""Validate file content follows ontology patterns"""
|
|
289
|
+
issues = []
|
|
290
|
+
|
|
291
|
+
# Only validate markdown files
|
|
292
|
+
if not file_path.endswith('.md'):
|
|
293
|
+
return issues
|
|
294
|
+
|
|
295
|
+
# Read content if not provided
|
|
296
|
+
if content is None:
|
|
297
|
+
try:
|
|
298
|
+
with open(file_path, 'r', encoding='utf-8') as f:
|
|
299
|
+
content = f.read()
|
|
300
|
+
except Exception as e:
|
|
301
|
+
issues.append(f"Could not read file: {e}")
|
|
302
|
+
return issues
|
|
303
|
+
|
|
304
|
+
dimension = normalize_dimension(get_dimension_from_path(file_path))
|
|
305
|
+
|
|
306
|
+
if not dimension:
|
|
307
|
+
return issues
|
|
308
|
+
|
|
309
|
+
# Check for dimension-specific patterns
|
|
310
|
+
if dimension == "things":
|
|
311
|
+
# Things should reference type
|
|
312
|
+
config = VALID_DIMENSIONS["things"]
|
|
313
|
+
if "type:" in content.lower() or "## type" in content.lower():
|
|
314
|
+
# Extract type mentions
|
|
315
|
+
type_pattern = r'\btype:\s*(\w+)'
|
|
316
|
+
types_found = re.findall(type_pattern, content, re.IGNORECASE)
|
|
317
|
+
|
|
318
|
+
for found_type in types_found:
|
|
319
|
+
if found_type not in config.get("types", []):
|
|
320
|
+
issues.append(
|
|
321
|
+
f"Unknown thing type '{found_type}'. "
|
|
322
|
+
f"Must be one of the 66 defined thing types"
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
elif dimension == "connections":
|
|
326
|
+
# Connections should reference relationship types
|
|
327
|
+
config = VALID_DIMENSIONS["connections"]
|
|
328
|
+
if "relationship" in content.lower() or "type:" in content.lower():
|
|
329
|
+
# Look for relationship type mentions
|
|
330
|
+
for rel_type in config.get("types", []):
|
|
331
|
+
if rel_type in content.lower():
|
|
332
|
+
break
|
|
333
|
+
else:
|
|
334
|
+
# No valid relationship type found, might be okay
|
|
335
|
+
pass
|
|
336
|
+
|
|
337
|
+
elif dimension == "events":
|
|
338
|
+
# Events should reference event types
|
|
339
|
+
config = VALID_DIMENSIONS["events"]
|
|
340
|
+
if "type:" in content.lower() or "event:" in content.lower():
|
|
341
|
+
# Look for event type mentions
|
|
342
|
+
for event_type in config.get("types", []):
|
|
343
|
+
if event_type in content.lower():
|
|
344
|
+
break
|
|
345
|
+
else:
|
|
346
|
+
# No valid event type found, might be okay
|
|
347
|
+
pass
|
|
348
|
+
|
|
349
|
+
# Check for protocol references
|
|
350
|
+
protocol_mentions = []
|
|
351
|
+
for protocol in PROTOCOLS:
|
|
352
|
+
if protocol.lower() in content.lower():
|
|
353
|
+
protocol_mentions.append(protocol)
|
|
354
|
+
|
|
355
|
+
if protocol_mentions and "metadata.protocol" not in content.lower():
|
|
356
|
+
issues.append(
|
|
357
|
+
f"Protocol references found ({', '.join(protocol_mentions)}) "
|
|
358
|
+
f"but no 'metadata.protocol' field mentioned. "
|
|
359
|
+
f"Protocols should be stored in metadata.protocol field"
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
return issues
|
|
363
|
+
|
|
364
|
+
def auto_fix_filename(file_path):
|
|
365
|
+
"""Automatically fix filename to kebab-case if needed"""
|
|
366
|
+
filename = Path(file_path).name
|
|
367
|
+
|
|
368
|
+
# Check if filename needs fixing
|
|
369
|
+
if re.match(r'^[a-z0-9]+(-[a-z0-9]+)*\.(md|yaml|yml|json)$', filename):
|
|
370
|
+
return None # Already valid
|
|
371
|
+
|
|
372
|
+
# Generate correct filename
|
|
373
|
+
correct_name = to_kebab_case(filename)
|
|
374
|
+
|
|
375
|
+
if correct_name == filename:
|
|
376
|
+
return None # No change needed
|
|
377
|
+
|
|
378
|
+
# Build new path
|
|
379
|
+
directory = os.path.dirname(file_path)
|
|
380
|
+
new_path = os.path.join(directory, correct_name)
|
|
381
|
+
|
|
382
|
+
# Rename the file
|
|
383
|
+
try:
|
|
384
|
+
if os.path.exists(file_path):
|
|
385
|
+
os.rename(file_path, new_path)
|
|
386
|
+
return {
|
|
387
|
+
'old_name': filename,
|
|
388
|
+
'new_name': correct_name,
|
|
389
|
+
'old_path': file_path,
|
|
390
|
+
'new_path': new_path
|
|
391
|
+
}
|
|
392
|
+
except Exception as e:
|
|
393
|
+
return {'error': str(e)}
|
|
394
|
+
|
|
395
|
+
return None
|
|
396
|
+
|
|
397
|
+
def main():
|
|
398
|
+
"""Main hook execution"""
|
|
399
|
+
try:
|
|
400
|
+
# Read hook input from stdin
|
|
401
|
+
hook_input = json.load(sys.stdin)
|
|
402
|
+
|
|
403
|
+
hook_event = hook_input.get("hook_event_name")
|
|
404
|
+
tool_name = hook_input.get("tool_name")
|
|
405
|
+
tool_input = hook_input.get("tool_input", {})
|
|
406
|
+
|
|
407
|
+
# Only validate Edit and Write operations
|
|
408
|
+
if tool_name not in ["Edit", "Write", "MultiEdit"]:
|
|
409
|
+
sys.exit(0)
|
|
410
|
+
|
|
411
|
+
file_path = tool_input.get("file_path")
|
|
412
|
+
if not file_path:
|
|
413
|
+
sys.exit(0)
|
|
414
|
+
|
|
415
|
+
# Skip validation for non-/one files
|
|
416
|
+
if '/one/' not in file_path:
|
|
417
|
+
sys.exit(0)
|
|
418
|
+
|
|
419
|
+
# For PostToolUse, try to auto-fix filename first
|
|
420
|
+
if hook_event == "PostToolUse":
|
|
421
|
+
fix_result = auto_fix_filename(file_path)
|
|
422
|
+
if fix_result:
|
|
423
|
+
if 'error' in fix_result:
|
|
424
|
+
print(f"⚠️ Could not auto-fix filename: {fix_result['error']}", file=sys.stderr)
|
|
425
|
+
else:
|
|
426
|
+
print(f"🔧 Auto-fixed filename: '{fix_result['old_name']}' → '{fix_result['new_name']}'")
|
|
427
|
+
# Update file_path for subsequent validation
|
|
428
|
+
file_path = fix_result['new_path']
|
|
429
|
+
|
|
430
|
+
issues = []
|
|
431
|
+
|
|
432
|
+
# Validate file path structure
|
|
433
|
+
path_issues = validate_file_path(file_path)
|
|
434
|
+
issues.extend(path_issues)
|
|
435
|
+
|
|
436
|
+
# For PostToolUse, also validate content
|
|
437
|
+
if hook_event == "PostToolUse":
|
|
438
|
+
content = tool_input.get("content") or tool_input.get("new_string")
|
|
439
|
+
content_issues = validate_file_content(file_path, content)
|
|
440
|
+
issues.extend(content_issues)
|
|
441
|
+
|
|
442
|
+
if issues:
|
|
443
|
+
# Build error message
|
|
444
|
+
dimension = get_dimension_from_path(file_path)
|
|
445
|
+
canonical = normalize_dimension(dimension)
|
|
446
|
+
|
|
447
|
+
error_msg = f"⚠️ Ontology Validation Failed for {file_path}\n\n"
|
|
448
|
+
error_msg += "Issues found:\n"
|
|
449
|
+
for i, issue in enumerate(issues, 1):
|
|
450
|
+
error_msg += f"{i}. {issue}\n"
|
|
451
|
+
|
|
452
|
+
error_msg += f"\n{'='*70}\n"
|
|
453
|
+
error_msg += "ONE Platform - 6-Dimension Ontology Structure\n"
|
|
454
|
+
error_msg += f"{'='*70}\n\n"
|
|
455
|
+
error_msg += "Files in /one MUST be organized by these 6 dimensions:\n\n"
|
|
456
|
+
|
|
457
|
+
for dim_name, dim_config in VALID_DIMENSIONS.items():
|
|
458
|
+
error_msg += f"📁 /one/{dim_name}/\n"
|
|
459
|
+
error_msg += f" {dim_config['description']}\n"
|
|
460
|
+
|
|
461
|
+
if dim_config.get('example_files'):
|
|
462
|
+
error_msg += f" Examples: {', '.join(dim_config['example_files'][:3])}\n"
|
|
463
|
+
|
|
464
|
+
if dim_config.get('types'):
|
|
465
|
+
count = len(dim_config['types'])
|
|
466
|
+
error_msg += f" ({count} defined types in schema)\n"
|
|
467
|
+
|
|
468
|
+
if dim_config.get('note'):
|
|
469
|
+
error_msg += f" Note: {dim_config['note']}\n"
|
|
470
|
+
|
|
471
|
+
error_msg += "\n"
|
|
472
|
+
|
|
473
|
+
error_msg += f"Current file location: {file_path}\n"
|
|
474
|
+
if dimension:
|
|
475
|
+
error_msg += f"Detected dimension: {dimension}"
|
|
476
|
+
if canonical and canonical != dimension:
|
|
477
|
+
error_msg += f" (normalized to: {canonical})"
|
|
478
|
+
error_msg += "\n"
|
|
479
|
+
|
|
480
|
+
error_msg += f"\n{'='*70}\n"
|
|
481
|
+
error_msg += "Database Implementation (5 tables):\n"
|
|
482
|
+
error_msg += "• groups table → groups dimension\n"
|
|
483
|
+
error_msg += "• things table → things + people dimensions (people have type: 'creator')\n"
|
|
484
|
+
error_msg += "• connections table → connections dimension\n"
|
|
485
|
+
error_msg += "• events table → events dimension\n"
|
|
486
|
+
error_msg += "• knowledge table → knowledge dimension\n"
|
|
487
|
+
error_msg += f"{'='*70}\n"
|
|
488
|
+
|
|
489
|
+
# For PreToolUse, block with exit code 2
|
|
490
|
+
if hook_event == "PreToolUse":
|
|
491
|
+
print(error_msg, file=sys.stderr)
|
|
492
|
+
sys.exit(2) # Block the operation
|
|
493
|
+
else:
|
|
494
|
+
# For PostToolUse, just warn
|
|
495
|
+
print(error_msg, file=sys.stdout)
|
|
496
|
+
sys.exit(0)
|
|
497
|
+
|
|
498
|
+
# Success - show dimension info
|
|
499
|
+
dimension = get_dimension_from_path(file_path)
|
|
500
|
+
canonical = normalize_dimension(dimension)
|
|
501
|
+
|
|
502
|
+
if canonical:
|
|
503
|
+
success_msg = f"✅ Ontology structure validated: {canonical}/"
|
|
504
|
+
dim_config = VALID_DIMENSIONS[canonical]
|
|
505
|
+
success_msg += f" - {dim_config['description']}"
|
|
506
|
+
print(success_msg)
|
|
507
|
+
|
|
508
|
+
sys.exit(0)
|
|
509
|
+
|
|
510
|
+
except json.JSONDecodeError as e:
|
|
511
|
+
print(f"Error: Invalid JSON input: {e}", file=sys.stderr)
|
|
512
|
+
sys.exit(1)
|
|
513
|
+
except Exception as e:
|
|
514
|
+
print(f"Error validating ontology structure: {e}", file=sys.stderr)
|
|
515
|
+
sys.exit(1)
|
|
516
|
+
|
|
517
|
+
if __name__ == "__main__":
|
|
518
|
+
main()
|
package/.claude/skills/INDEX.md
CHANGED
|
@@ -244,7 +244,7 @@ Generate design tokens from brand guidelines:
|
|
|
244
244
|
### Director Agent Skills (Planned)
|
|
245
245
|
- `agent-director:plan-feature` - Feature planning and sequencing
|
|
246
246
|
- `agent-director:coordinate-agents` - Agent orchestration
|
|
247
|
-
- `agent-director:manage-
|
|
247
|
+
- `agent-director:manage-cycle` - Cycle workflow management
|
|
248
248
|
|
|
249
249
|
### Operations Agent Skills (Planned)
|
|
250
250
|
- `agent-ops:deploy-web` - Cloudflare Pages deployment
|
|
@@ -228,7 +228,7 @@ If creating custom entity or connection types, document in ontology.
|
|
|
228
228
|
|
|
229
229
|
### v1.2.0 (Planned)
|
|
230
230
|
- ML-based entity type suggestions
|
|
231
|
-
- Relationship
|
|
231
|
+
- Relationship cycle from descriptions
|
|
232
232
|
- Schema optimization recommendations
|
|
233
233
|
|
|
234
234
|
## Contributing
|
package/package.json
CHANGED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
# MCP Management Commands
|
|
2
|
-
|
|
3
|
-
Manage MCP context usage - enable/disable MCPs on demand to save tokens.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# Show current MCP status and token usage
|
|
9
|
-
./scripts/mcp-toggle.sh status
|
|
10
|
-
|
|
11
|
-
# Switch to minimal config (only shadcn) - saves ~10k tokens
|
|
12
|
-
./scripts/mcp-toggle.sh minimal
|
|
13
|
-
|
|
14
|
-
# Restore all MCPs
|
|
15
|
-
./scripts/mcp-toggle.sh full
|
|
16
|
-
|
|
17
|
-
# Backup current config
|
|
18
|
-
./scripts/mcp-toggle.sh backup
|
|
19
|
-
|
|
20
|
-
# Restore from backup
|
|
21
|
-
./scripts/mcp-toggle.sh restore
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Available MCPs
|
|
25
|
-
|
|
26
|
-
- **shadcn**: 4.7k tokens (component registry)
|
|
27
|
-
- **cloudflare-docs**: 1.4k tokens (documentation search)
|
|
28
|
-
- **cloudflare-builds**: 5.7k tokens (Workers builds)
|
|
29
|
-
- **figma**: 2.0k tokens (design data)
|
|
30
|
-
- **ide**: 1.3k tokens (VS Code integration)
|
|
31
|
-
|
|
32
|
-
**Total:** ~15.1k tokens when all enabled
|
|
33
|
-
|
|
34
|
-
## Quick Commands
|
|
35
|
-
|
|
36
|
-
### Daily Development (Recommended)
|
|
37
|
-
```bash
|
|
38
|
-
./scripts/mcp-toggle.sh minimal
|
|
39
|
-
# Only shadcn enabled, saves ~10k tokens
|
|
40
|
-
# Restart Claude Code
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### When Deploying to Cloudflare
|
|
44
|
-
```bash
|
|
45
|
-
./scripts/mcp-toggle.sh full
|
|
46
|
-
# Enable all MCPs
|
|
47
|
-
# Restart Claude Code
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### When Designing with Figma
|
|
51
|
-
```bash
|
|
52
|
-
# Manually add figma to minimal config
|
|
53
|
-
# Or use full config temporarily
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Important Notes
|
|
57
|
-
|
|
58
|
-
1. **Restart Required**: After changing .mcp.json, restart Claude Code
|
|
59
|
-
2. **Backup Created**: Script automatically backs up before changes
|
|
60
|
-
3. **Token Savings**: Minimal config saves ~10k tokens (66% reduction)
|
|
61
|
-
4. **Default Minimal**: Use minimal config for daily work, switch to full only when needed
|
|
62
|
-
|
|
63
|
-
## Workflow
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
# Start of day: Go minimal
|
|
67
|
-
./scripts/mcp-toggle.sh minimal
|
|
68
|
-
# Restart Claude Code
|
|
69
|
-
# Work with ~5k MCP tokens instead of 15k
|
|
70
|
-
|
|
71
|
-
# When you need Cloudflare tools:
|
|
72
|
-
./scripts/mcp-toggle.sh full
|
|
73
|
-
# Restart Claude Code
|
|
74
|
-
# All MCPs available
|
|
75
|
-
|
|
76
|
-
# End of day: Back to minimal
|
|
77
|
-
./scripts/mcp-toggle.sh minimal
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Manual Override
|
|
81
|
-
|
|
82
|
-
Edit `.mcp.json` directly to enable specific MCPs:
|
|
83
|
-
|
|
84
|
-
```json
|
|
85
|
-
{
|
|
86
|
-
"mcpServers": {
|
|
87
|
-
"shadcn": { ... }, // Always keep
|
|
88
|
-
"cloudflare-docs": { ... } // Add when needed
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Restart Claude Code after editing.
|