oneie 3.4.2 → 3.6.0
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-director.md +902 -22
- package/.claude/agents/agent-onboard-example-output.md +600 -0
- package/.claude/agents/agent-onboard.md +576 -0
- package/.claude/commands/ONBOARDING_ENHANCEMENT_SUMMARY.md +266 -0
- package/.claude/commands/one.md +411 -10
- package/.claude/commands/release.md +64 -3
- package/CLAUDE.md +55 -69
- package/dist/commands/init.d.ts +5 -6
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +101 -101
- package/dist/commands/init.js.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/utils/installation-setup.d.ts +24 -1
- package/dist/utils/installation-setup.d.ts.map +1 -1
- package/dist/utils/installation-setup.js +85 -1
- package/dist/utils/installation-setup.js.map +1 -1
- package/dist/utils/launch-claude.d.ts +6 -0
- package/dist/utils/launch-claude.d.ts.map +1 -0
- package/dist/utils/launch-claude.js +51 -0
- package/dist/utils/launch-claude.js.map +1 -0
- package/dist/utils/validation.d.ts +48 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +73 -0
- package/dist/utils/validation.js.map +1 -0
- package/folders.yaml +1 -1
- package/one/.obsidian/app.json +8 -0
- package/one/.obsidian/appearance.json +1 -0
- package/one/.obsidian/community-plugins.json +3 -0
- package/one/.obsidian/core-plugins.json +33 -0
- package/one/.obsidian/plugins/easy-bake/main.js +361 -0
- package/one/.obsidian/plugins/easy-bake/manifest.json +11 -0
- package/one/.obsidian/plugins/easy-bake/styles.css +10 -0
- package/one/.obsidian/workspace.json +240 -0
- package/one/connections/workflow-onboarding.md +683 -0
- package/one/events/CART-DRAWER-INTEGRATION-GUIDE.md +354 -0
- package/one/events/CRITICAL-FIXES-COMPLETE.md +504 -0
- package/one/events/DEPLOYMENT.md +178 -0
- package/one/events/ECOMMERCE-DEMO-PLAN.md +225 -0
- package/one/events/ECOMMERCE-LIVE-DEMO.md +363 -0
- package/one/events/ECOMMERCE-TEMPLATE-COMPLETE.md +735 -0
- package/one/events/ECOMMERCE-TEMPLATES-SUMMARY.md +923 -0
- package/one/events/GRADIENT-TEXT-PERMANENT-FIX.md +223 -0
- package/one/events/HANDOFF.md +313 -0
- package/one/events/IMPLEMENTATION-SUMMARY-FINAL.md +503 -0
- package/one/events/IMPLEMENTATION_SUMMARY.md +529 -0
- package/one/events/LANDING-PAGE-EXAMPLE-OUTPUT.md +666 -0
- package/one/events/LANDING-PAGE-IMPLEMENTATION.md +642 -0
- package/one/events/LANDING-PAGE-QUICKSTART.md +407 -0
- package/one/events/MULTI-ONTOLOGY-COMPLETE-GUIDE.md +1627 -0
- package/one/events/MULTI-ONTOLOGY-IMPLEMENTATION-COMPLETE.md +573 -0
- package/one/events/ONBOARDING-IMPLEMENTATION-COMPLETE copy.md +398 -0
- package/one/events/ONTOLOGY-TUTORIALS-SUMMARY.md +525 -0
- package/one/events/ONTOLOGY-TYPE-GENERATOR-SUMMARY.md +455 -0
- package/one/events/ONTOLOGY_DISCOVERY_IMPLEMENTATION.md +486 -0
- package/one/events/ONTOLOGY_DISCOVERY_QUICKSTART.md +203 -0
- package/one/events/SECURITY-AUDIT-FIXES.md +376 -0
- package/one/events/SECURITY-SCAN-COMPLETE.md +281 -0
- package/one/events/SHOP-BUILD-STATUS.md +114 -0
- package/one/events/SHOP-PREMIUM-UPDATE.md +149 -0
- package/one/events/SITE-WIDE-GRADIENT-FIX.md +299 -0
- package/one/events/STORE-PRODUCTION-READY-STATUS.md +359 -0
- package/one/events/STRIPE-PAYMENT-METHODS-GUIDE.md +429 -0
- package/one/events/agent-director-enhancement-summary.md +386 -0
- package/one/events/agent-onboard-implementation-summary.md +457 -0
- package/one/events/clean-agent-ontology-cleanup-report.md +353 -0
- package/one/events/landing-page-generator.md +458 -0
- package/one/events/onboarding-implementation-complete.md +505 -0
- package/one/events/release.md +254 -0
- package/one/events/separate-implementation-status.md +537 -0
- package/one/groups/nine-padle-contents.baked.md +1252 -0
- package/one/groups/nine-padle-contents.md +6 -0
- package/one/knowledge/100-inference-quick-reference.md +431 -0
- package/one/knowledge/agent-onboard-usage.md +612 -0
- package/one/knowledge/cli-claude-handoff.md +718 -0
- package/one/knowledge/installation-folders.md +45 -1
- package/one/knowledge/ontology-blog.yaml +31 -0
- package/one/knowledge/ontology-cheatsheet.md +591 -0
- package/one/knowledge/ontology-community.yaml +42 -0
- package/one/knowledge/ontology-core-universal.md +722 -0
- package/one/knowledge/ontology-core.yaml +50 -0
- package/one/knowledge/ontology-courses.yaml +53 -0
- package/one/knowledge/ontology-creator.md +376 -0
- package/one/knowledge/ontology-developer-guide.md +789 -0
- package/one/knowledge/ontology-education.md +920 -0
- package/one/knowledge/ontology-index.md +354 -0
- package/one/knowledge/ontology-migration-guide.md +811 -0
- package/one/knowledge/ontology-minimal.yaml +1 -1
- package/one/knowledge/ontology-portfolio.yaml +31 -0
- package/one/knowledge/ontology-quickstart.md +576 -0
- package/one/knowledge/ontology-shop.yaml +121 -0
- package/one/knowledge/ontology-tokens.yaml +32 -0
- package/one/knowledge/ontology-tutorial.md +434 -0
- package/one/knowledge/ontology-video-script.md +890 -0
- package/one/things/docs/ecommerce/ARCHITECTURE-DIAGRAM.md +467 -0
- package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-IMPLEMENTATION.md +408 -0
- package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-SUMMARY.md +369 -0
- package/one/things/docs/ecommerce/CONVERSION-UX-IMPLEMENTATION-SUMMARY.md +396 -0
- package/one/things/docs/ecommerce/FEATURE-SUMMARY.md +468 -0
- package/one/things/docs/ecommerce/IMPLEMENTATION-NOTES.md +582 -0
- package/one/things/docs/ecommerce/INTEGRATION-EXAMPLE.md +449 -0
- package/one/things/docs/ecommerce/QUICK-START.md +368 -0
- package/one/things/docs/ecommerce/URGENCY-IMPLEMENTATION-SUMMARY.md +498 -0
- package/one/things/docs/ecommerce/URGENCY-QUICK-REFERENCE.md +237 -0
- package/one/things/docs/ecommerce/USAGE-EXAMPLE.astro +171 -0
- package/one/things/docs/ecommerce/demo.astro +309 -0
- package/one/things/plans/agent-director-100-inference-plans.md +410 -0
- package/one/things/plans/dual-website-strategy.md +612 -0
- package/one/things/plans/feature-based-sites.md +821 -0
- package/one/things/plans/multi-ontology-architecture.md +836 -0
- package/one/things/plans/onboarding.md +32 -0
- package/one/things/plans/separate.md +15 -17
- package/one/things/plans/start-new.md +738 -0
- package/one/things/templates.md +254 -0
- package/one/things/todo.md +23 -5
- package/package.json +2 -2
- package/one/things/claude/hooks/agent-hook-manager.js +0 -525
- package/one/things/claude/hooks/agent-load-balancer.js +0 -271
- package/one/things/claude/hooks/agent-request-interceptor.js +0 -70
- package/one/things/claude/hooks/cascade-feedback.js +0 -297
- package/one/things/claude/hooks/cascade-integration-hooks.js +0 -648
- package/one/things/claude/hooks/continuous-improvement-monitor.js +0 -510
- package/one/things/claude/hooks/file-organization-engine.js +0 -427
- package/one/things/claude/hooks/file-organization-monitor.js +0 -269
- package/one/things/claude/hooks/hook-config-manager.js +0 -202
- package/one/things/claude/hooks/hook-orchestrator.js +0 -662
- package/one/things/claude/hooks/hook-performance-report.js +0 -120
- package/one/things/claude/hooks/mcp-cascade-integration.js +0 -816
- package/one/things/claude/hooks/memory-optimizer.js +0 -510
- package/one/things/claude/hooks/ontology-compliance.js +0 -394
- package/one/things/claude/hooks/ontology-hook-manager.js +0 -316
- package/one/things/claude/hooks/ontology-validation-engine.js +0 -317
- package/one/things/claude/hooks/performance-monitoring-hook.js +0 -422
- package/one/things/claude/hooks/quality-scoring-engine.js +0 -834
- package/one/things/claude/hooks/simple-load-balancer.js +0 -238
- package/one/things/claude/hooks/startup-optimizer.js +0 -625
- package/one/things/claude/hooks/story-scoring-system.js +0 -445
- package/one/things/claude/hooks/story-validation-engine.js +0 -473
- package/one/things/claude/hooks/structure-synchronizer.js +0 -194
- package/one/things/claude/hooks/sub-agent-output-validator.js +0 -647
- package/one/things/claude/hooks/sub-agent-validation-hook.js +0 -343
- package/one/things/claude/hooks/trinity-validation-system.js +0 -392
- package/one/things/plans/organizations-to-groups.md +0 -705
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
feature: portfolio
|
|
2
|
+
extends: core
|
|
3
|
+
description: Portfolio and project showcase
|
|
4
|
+
|
|
5
|
+
thingTypes:
|
|
6
|
+
- name: project
|
|
7
|
+
properties:
|
|
8
|
+
title: string
|
|
9
|
+
slug: string
|
|
10
|
+
description: string
|
|
11
|
+
images: string[]
|
|
12
|
+
client: string
|
|
13
|
+
completedAt: number
|
|
14
|
+
technologies: string[]
|
|
15
|
+
url: string
|
|
16
|
+
- name: case_study
|
|
17
|
+
properties:
|
|
18
|
+
title: string
|
|
19
|
+
problem: string
|
|
20
|
+
solution: string
|
|
21
|
+
results: string
|
|
22
|
+
metrics: object
|
|
23
|
+
|
|
24
|
+
connectionTypes:
|
|
25
|
+
- name: belongs_to_portfolio
|
|
26
|
+
fromType: project
|
|
27
|
+
toType: user
|
|
28
|
+
|
|
29
|
+
eventTypes:
|
|
30
|
+
- name: project_viewed
|
|
31
|
+
thingType: project
|
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
# Multi-Ontology Architecture: Quick Start Guide
|
|
2
|
+
|
|
3
|
+
**Version:** 1.0.0
|
|
4
|
+
**Last Updated:** 2025-10-20
|
|
5
|
+
**Status:** Complete
|
|
6
|
+
|
|
7
|
+
## What is the Multi-Ontology Architecture?
|
|
8
|
+
|
|
9
|
+
The Multi-Ontology Architecture lets you extend the ONE Platform's core 6-dimension ontology with **feature-specific types**. Instead of hardcoding all possible entity types, features bring their own data models that compose cleanly.
|
|
10
|
+
|
|
11
|
+
### Core Concept
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
┌─────────────────────────────────────────────────┐
|
|
15
|
+
│ ONE Platform (6-Dimension Ontology) │
|
|
16
|
+
│ Groups → People → Things → Connections │
|
|
17
|
+
│ → Events → Knowledge │
|
|
18
|
+
└─────────────────────────────────────────────────┘
|
|
19
|
+
↓
|
|
20
|
+
┌─────────────────────────────────────────────────┐
|
|
21
|
+
│ Feature Ontologies (Composable Extensions) │
|
|
22
|
+
├─────────────────────────────────────────────────┤
|
|
23
|
+
│ core → page, user, file, link │
|
|
24
|
+
│ blog → blog_post, blog_category │
|
|
25
|
+
│ shop → product, order, shopping_cart │
|
|
26
|
+
│ courses → course, lesson, enrollment │
|
|
27
|
+
│ custom → YOUR feature-specific types │
|
|
28
|
+
└─────────────────────────────────────────────────┘
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Key Benefits:**
|
|
32
|
+
|
|
33
|
+
- **No Schema Bloat:** Only load types you actually use
|
|
34
|
+
- **Type Safety:** Full TypeScript validation for all types
|
|
35
|
+
- **Feature Isolation:** Features don't interfere with each other
|
|
36
|
+
- **Easy Extension:** Add new features without touching core
|
|
37
|
+
- **Multi-Backend:** Run different backends with different feature sets
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 5-Minute Setup
|
|
42
|
+
|
|
43
|
+
### Step 1: Enable Features
|
|
44
|
+
|
|
45
|
+
Edit your environment configuration:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# .env.local
|
|
49
|
+
PUBLIC_FEATURES="blog,portfolio"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This tells the platform to load the `blog` and `portfolio` ontology extensions.
|
|
53
|
+
|
|
54
|
+
### Step 2: Generate Types
|
|
55
|
+
|
|
56
|
+
From the backend directory:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
cd backend
|
|
60
|
+
bun run scripts/generate-ontology-types.ts
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This script:
|
|
64
|
+
1. Reads all enabled feature ontologies from `/one/knowledge/ontology-*.yaml`
|
|
65
|
+
2. Generates TypeScript types in `convex/types/ontology.ts`
|
|
66
|
+
3. Creates validation functions and type guards
|
|
67
|
+
4. Outputs a summary of loaded types
|
|
68
|
+
|
|
69
|
+
**Expected output:**
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
✅ Loaded ontology: core (5 thing types, 4 connection types, 4 event types)
|
|
73
|
+
✅ Loaded ontology: blog (2 thing types, 1 connection type, 2 event types)
|
|
74
|
+
✅ Loaded ontology: portfolio (3 thing types, 2 connection types, 3 event types)
|
|
75
|
+
📦 Generated types: 10 thing types, 7 connection types, 9 event types
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Step 3: Deploy Schema
|
|
79
|
+
|
|
80
|
+
Start Convex development server:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npx convex dev
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Convex will automatically:
|
|
87
|
+
- Read the generated types
|
|
88
|
+
- Update schema validation
|
|
89
|
+
- Hot-reload with new types
|
|
90
|
+
|
|
91
|
+
**Done!** Your schema now validates blog and portfolio types.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Adding a New Feature
|
|
96
|
+
|
|
97
|
+
Let's add a custom "products" feature with inventory tracking.
|
|
98
|
+
|
|
99
|
+
### Step 1: Create Ontology YAML
|
|
100
|
+
|
|
101
|
+
Create `/one/knowledge/ontology-products.yaml`:
|
|
102
|
+
|
|
103
|
+
```yaml
|
|
104
|
+
feature: products
|
|
105
|
+
extends: core
|
|
106
|
+
description: Product catalog and inventory management
|
|
107
|
+
|
|
108
|
+
thingTypes:
|
|
109
|
+
- name: product
|
|
110
|
+
properties:
|
|
111
|
+
name: string
|
|
112
|
+
sku: string
|
|
113
|
+
price: number
|
|
114
|
+
inventory: number
|
|
115
|
+
description: string
|
|
116
|
+
images: string[]
|
|
117
|
+
|
|
118
|
+
- name: inventory_log
|
|
119
|
+
properties:
|
|
120
|
+
productId: string
|
|
121
|
+
quantity: number
|
|
122
|
+
action: string
|
|
123
|
+
timestamp: number
|
|
124
|
+
|
|
125
|
+
connectionTypes:
|
|
126
|
+
- name: in_stock
|
|
127
|
+
fromType: product
|
|
128
|
+
toType: warehouse
|
|
129
|
+
|
|
130
|
+
- name: supplied_by
|
|
131
|
+
fromType: product
|
|
132
|
+
toType: supplier
|
|
133
|
+
|
|
134
|
+
eventTypes:
|
|
135
|
+
- name: product_created
|
|
136
|
+
thingType: product
|
|
137
|
+
|
|
138
|
+
- name: inventory_updated
|
|
139
|
+
thingType: product
|
|
140
|
+
|
|
141
|
+
- name: product_sold
|
|
142
|
+
thingType: product
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Step 2: Enable Feature
|
|
146
|
+
|
|
147
|
+
Update your environment:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# .env.local
|
|
151
|
+
PUBLIC_FEATURES="blog,portfolio,products"
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Step 3: Regenerate Types
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
cd backend
|
|
158
|
+
bun run scripts/generate-ontology-types.ts
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Output:**
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
✅ Loaded ontology: core (5 thing types, 4 connection types, 4 event types)
|
|
165
|
+
✅ Loaded ontology: blog (2 thing types, 1 connection type, 2 event types)
|
|
166
|
+
✅ Loaded ontology: portfolio (3 thing types, 2 connection types, 3 event types)
|
|
167
|
+
✅ Loaded ontology: products (2 thing types, 2 connection types, 3 event types)
|
|
168
|
+
📦 Generated types: 12 thing types, 9 connection types, 12 event types
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Step 4: Use in Code
|
|
172
|
+
|
|
173
|
+
Now use your new types in Convex mutations:
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
// backend/convex/mutations/products.ts
|
|
177
|
+
import { mutation } from './_generated/server';
|
|
178
|
+
import { v } from 'convex/values';
|
|
179
|
+
import { isThingType } from './types/ontology';
|
|
180
|
+
|
|
181
|
+
export const createProduct = mutation({
|
|
182
|
+
args: {
|
|
183
|
+
name: v.string(),
|
|
184
|
+
sku: v.string(),
|
|
185
|
+
price: v.number(),
|
|
186
|
+
inventory: v.number(),
|
|
187
|
+
},
|
|
188
|
+
handler: async (ctx, args) => {
|
|
189
|
+
// Type validation happens automatically!
|
|
190
|
+
const productId = await ctx.db.insert('things', {
|
|
191
|
+
type: 'product', // ✅ Validated against ontology
|
|
192
|
+
name: args.name,
|
|
193
|
+
properties: {
|
|
194
|
+
sku: args.sku,
|
|
195
|
+
price: args.price,
|
|
196
|
+
inventory: args.inventory,
|
|
197
|
+
description: '',
|
|
198
|
+
images: [],
|
|
199
|
+
},
|
|
200
|
+
status: 'active',
|
|
201
|
+
createdAt: Date.now(),
|
|
202
|
+
updatedAt: Date.now(),
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// Log event
|
|
206
|
+
await ctx.db.insert('events', {
|
|
207
|
+
type: 'product_created', // ✅ Validated against ontology
|
|
208
|
+
actorId: ctx.auth.getUserIdentity()?.tokenIdentifier,
|
|
209
|
+
targetId: productId,
|
|
210
|
+
timestamp: Date.now(),
|
|
211
|
+
metadata: {
|
|
212
|
+
sku: args.sku,
|
|
213
|
+
price: args.price,
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
return productId;
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Common Tasks
|
|
225
|
+
|
|
226
|
+
### Check Available Types
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
import { THING_TYPES, CONNECTION_TYPES, EVENT_TYPES } from './types/ontology';
|
|
230
|
+
|
|
231
|
+
console.log('Available thing types:', THING_TYPES);
|
|
232
|
+
// Output: ['page', 'user', 'file', 'blog_post', 'product', ...]
|
|
233
|
+
|
|
234
|
+
console.log('Available connection types:', CONNECTION_TYPES);
|
|
235
|
+
// Output: ['created_by', 'posted_in', 'in_stock', ...]
|
|
236
|
+
|
|
237
|
+
console.log('Available event types:', EVENT_TYPES);
|
|
238
|
+
// Output: ['thing_created', 'blog_post_published', 'product_created', ...]
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Validate User Input
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
import { isThingType, isConnectionType, isEventType } from './types/ontology';
|
|
245
|
+
|
|
246
|
+
// Validate thing type
|
|
247
|
+
if (!isThingType(userInput)) {
|
|
248
|
+
throw new Error(`Invalid thing type: ${userInput}`);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Validate connection type
|
|
252
|
+
if (!isConnectionType(relationshipType)) {
|
|
253
|
+
throw new Error(`Invalid connection type: ${relationshipType}`);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Validate event type
|
|
257
|
+
if (!isEventType(eventType)) {
|
|
258
|
+
throw new Error(`Invalid event type: ${eventType}`);
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Feature-Conditional Logic
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
import { hasFeature, ENABLED_FEATURES } from './types/ontology';
|
|
266
|
+
|
|
267
|
+
// Check if feature is enabled
|
|
268
|
+
if (hasFeature('blog')) {
|
|
269
|
+
// Blog-specific logic
|
|
270
|
+
console.log('Blog feature is enabled');
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (hasFeature('products')) {
|
|
274
|
+
// Products-specific logic
|
|
275
|
+
console.log('Products feature is enabled');
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// List all enabled features
|
|
279
|
+
console.log('Enabled features:', ENABLED_FEATURES);
|
|
280
|
+
// Output: ['core', 'blog', 'products']
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Get Thing Type Schema
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
import { getThingTypeSchema } from './types/ontology';
|
|
287
|
+
|
|
288
|
+
const productSchema = getThingTypeSchema('product');
|
|
289
|
+
console.log(productSchema);
|
|
290
|
+
// Output:
|
|
291
|
+
// {
|
|
292
|
+
// name: 'product',
|
|
293
|
+
// properties: {
|
|
294
|
+
// name: 'string',
|
|
295
|
+
// sku: 'string',
|
|
296
|
+
// price: 'number',
|
|
297
|
+
// inventory: 'number',
|
|
298
|
+
// description: 'string',
|
|
299
|
+
// images: 'string[]'
|
|
300
|
+
// },
|
|
301
|
+
// feature: 'products'
|
|
302
|
+
// }
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Troubleshooting
|
|
308
|
+
|
|
309
|
+
### Problem: Type not found after adding feature
|
|
310
|
+
|
|
311
|
+
**Symptom:**
|
|
312
|
+
```
|
|
313
|
+
Error: Invalid thing type: "product"
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**Solution:**
|
|
317
|
+
1. Verify feature is in `PUBLIC_FEATURES` environment variable
|
|
318
|
+
2. Run `bun run scripts/generate-ontology-types.ts`
|
|
319
|
+
3. Restart Convex dev server (`npx convex dev`)
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
### Problem: Schema validation fails
|
|
324
|
+
|
|
325
|
+
**Symptom:**
|
|
326
|
+
```
|
|
327
|
+
Error: Validation failed for thing type "product"
|
|
328
|
+
Property "price" expected number, got string
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
**Solution:**
|
|
332
|
+
Check your ontology YAML file for correct property types:
|
|
333
|
+
|
|
334
|
+
```yaml
|
|
335
|
+
# ❌ Wrong
|
|
336
|
+
properties:
|
|
337
|
+
price: string # Should be number!
|
|
338
|
+
|
|
339
|
+
# ✅ Correct
|
|
340
|
+
properties:
|
|
341
|
+
price: number
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Supported property types: `string`, `number`, `boolean`, `object`, `string[]`, `number[]`
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
### Problem: Circular dependency error
|
|
349
|
+
|
|
350
|
+
**Symptom:**
|
|
351
|
+
```
|
|
352
|
+
Error: Circular dependency detected: blog → portfolio → blog
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**Solution:**
|
|
356
|
+
Check your `extends` fields - avoid circular references:
|
|
357
|
+
|
|
358
|
+
```yaml
|
|
359
|
+
# ❌ Wrong
|
|
360
|
+
# ontology-blog.yaml
|
|
361
|
+
extends: portfolio
|
|
362
|
+
|
|
363
|
+
# ontology-portfolio.yaml
|
|
364
|
+
extends: blog
|
|
365
|
+
|
|
366
|
+
# ✅ Correct
|
|
367
|
+
# ontology-blog.yaml
|
|
368
|
+
extends: core
|
|
369
|
+
|
|
370
|
+
# ontology-portfolio.yaml
|
|
371
|
+
extends: core
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
### Problem: Feature not loading
|
|
377
|
+
|
|
378
|
+
**Symptom:**
|
|
379
|
+
```
|
|
380
|
+
⚠️ Feature "products" not found, skipping
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
**Solution:**
|
|
384
|
+
1. Verify file exists: `/one/knowledge/ontology-products.yaml`
|
|
385
|
+
2. Check file naming convention: `ontology-{feature}.yaml`
|
|
386
|
+
3. Ensure YAML is valid (no syntax errors)
|
|
387
|
+
4. Feature name in YAML must match filename:
|
|
388
|
+
|
|
389
|
+
```yaml
|
|
390
|
+
# File: ontology-products.yaml
|
|
391
|
+
feature: products # ✅ Must match filename
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
## Example: Full CRUD Implementation
|
|
397
|
+
|
|
398
|
+
Here's a complete example showing how to implement CRUD operations with the multi-ontology architecture:
|
|
399
|
+
|
|
400
|
+
```typescript
|
|
401
|
+
// backend/convex/mutations/products.ts
|
|
402
|
+
import { mutation } from './_generated/server';
|
|
403
|
+
import { v } from 'convex/values';
|
|
404
|
+
import { isThingType } from './types/ontology';
|
|
405
|
+
|
|
406
|
+
// CREATE
|
|
407
|
+
export const createProduct = mutation({
|
|
408
|
+
args: {
|
|
409
|
+
name: v.string(),
|
|
410
|
+
sku: v.string(),
|
|
411
|
+
price: v.number(),
|
|
412
|
+
},
|
|
413
|
+
handler: async (ctx, args) => {
|
|
414
|
+
const productId = await ctx.db.insert('things', {
|
|
415
|
+
type: 'product',
|
|
416
|
+
name: args.name,
|
|
417
|
+
properties: {
|
|
418
|
+
sku: args.sku,
|
|
419
|
+
price: args.price,
|
|
420
|
+
inventory: 0,
|
|
421
|
+
description: '',
|
|
422
|
+
images: [],
|
|
423
|
+
},
|
|
424
|
+
status: 'active',
|
|
425
|
+
createdAt: Date.now(),
|
|
426
|
+
updatedAt: Date.now(),
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
await ctx.db.insert('events', {
|
|
430
|
+
type: 'product_created',
|
|
431
|
+
actorId: ctx.auth.getUserIdentity()?.tokenIdentifier,
|
|
432
|
+
targetId: productId,
|
|
433
|
+
timestamp: Date.now(),
|
|
434
|
+
metadata: args,
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
return productId;
|
|
438
|
+
},
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
// READ
|
|
442
|
+
export const getProduct = query({
|
|
443
|
+
args: { id: v.id('things') },
|
|
444
|
+
handler: async (ctx, { id }) => {
|
|
445
|
+
const product = await ctx.db.get(id);
|
|
446
|
+
if (!product || product.type !== 'product') {
|
|
447
|
+
throw new Error('Product not found');
|
|
448
|
+
}
|
|
449
|
+
return product;
|
|
450
|
+
},
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
// UPDATE
|
|
454
|
+
export const updateProduct = mutation({
|
|
455
|
+
args: {
|
|
456
|
+
id: v.id('things'),
|
|
457
|
+
price: v.optional(v.number()),
|
|
458
|
+
inventory: v.optional(v.number()),
|
|
459
|
+
},
|
|
460
|
+
handler: async (ctx, args) => {
|
|
461
|
+
const product = await ctx.db.get(args.id);
|
|
462
|
+
if (!product || product.type !== 'product') {
|
|
463
|
+
throw new Error('Product not found');
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
await ctx.db.patch(args.id, {
|
|
467
|
+
properties: {
|
|
468
|
+
...product.properties,
|
|
469
|
+
price: args.price ?? product.properties.price,
|
|
470
|
+
inventory: args.inventory ?? product.properties.inventory,
|
|
471
|
+
},
|
|
472
|
+
updatedAt: Date.now(),
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
await ctx.db.insert('events', {
|
|
476
|
+
type: 'product_updated',
|
|
477
|
+
actorId: ctx.auth.getUserIdentity()?.tokenIdentifier,
|
|
478
|
+
targetId: args.id,
|
|
479
|
+
timestamp: Date.now(),
|
|
480
|
+
metadata: {
|
|
481
|
+
changes: {
|
|
482
|
+
price: args.price,
|
|
483
|
+
inventory: args.inventory,
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
});
|
|
487
|
+
},
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
// DELETE
|
|
491
|
+
export const deleteProduct = mutation({
|
|
492
|
+
args: { id: v.id('things') },
|
|
493
|
+
handler: async (ctx, { id }) => {
|
|
494
|
+
await ctx.db.patch(id, {
|
|
495
|
+
status: 'deleted',
|
|
496
|
+
updatedAt: Date.now(),
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
await ctx.db.insert('events', {
|
|
500
|
+
type: 'product_deleted',
|
|
501
|
+
actorId: ctx.auth.getUserIdentity()?.tokenIdentifier,
|
|
502
|
+
targetId: id,
|
|
503
|
+
timestamp: Date.now(),
|
|
504
|
+
metadata: {},
|
|
505
|
+
});
|
|
506
|
+
},
|
|
507
|
+
});
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
## Next Steps
|
|
513
|
+
|
|
514
|
+
- **Read the Developer Guide** (`ontology-developer-guide.md`) for advanced patterns and architecture details
|
|
515
|
+
- **Explore example ontologies** in `/one/knowledge/ontology-*.yaml` to see real-world implementations
|
|
516
|
+
- **Join the community** for support and to share your custom ontologies
|
|
517
|
+
- **Contribute features** by submitting your ontology YAML files
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
## Quick Reference
|
|
522
|
+
|
|
523
|
+
### File Locations
|
|
524
|
+
|
|
525
|
+
- **Ontology Definitions:** `/one/knowledge/ontology-{feature}.yaml`
|
|
526
|
+
- **Generated Types:** `/backend/convex/types/ontology.ts`
|
|
527
|
+
- **Type Generator Script:** `/backend/scripts/generate-ontology-types.ts`
|
|
528
|
+
- **Environment Config:** `.env.local` (add `PUBLIC_FEATURES`)
|
|
529
|
+
|
|
530
|
+
### Commands
|
|
531
|
+
|
|
532
|
+
```bash
|
|
533
|
+
# Generate types
|
|
534
|
+
bun run scripts/generate-ontology-types.ts
|
|
535
|
+
|
|
536
|
+
# Start Convex dev server
|
|
537
|
+
npx convex dev
|
|
538
|
+
|
|
539
|
+
# Deploy to production
|
|
540
|
+
npx convex deploy
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
### YAML Structure
|
|
544
|
+
|
|
545
|
+
```yaml
|
|
546
|
+
feature: {feature-name}
|
|
547
|
+
extends: core | null
|
|
548
|
+
description: {human-readable description}
|
|
549
|
+
|
|
550
|
+
thingTypes:
|
|
551
|
+
- name: {type-name}
|
|
552
|
+
properties:
|
|
553
|
+
{field}: {type}
|
|
554
|
+
|
|
555
|
+
connectionTypes:
|
|
556
|
+
- name: {type-name}
|
|
557
|
+
fromType: {thing-type} | '*'
|
|
558
|
+
toType: {thing-type} | '*'
|
|
559
|
+
|
|
560
|
+
eventTypes:
|
|
561
|
+
- name: {event-name}
|
|
562
|
+
thingType: {thing-type} | '*'
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
### Property Types
|
|
566
|
+
|
|
567
|
+
- `string` - Text values
|
|
568
|
+
- `number` - Numeric values
|
|
569
|
+
- `boolean` - True/false values
|
|
570
|
+
- `object` - JSON objects
|
|
571
|
+
- `string[]` - Array of strings
|
|
572
|
+
- `number[]` - Array of numbers
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
**You're now ready to build with the Multi-Ontology Architecture!** 🚀
|