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.
Files changed (143) hide show
  1. package/.claude/agents/agent-director.md +902 -22
  2. package/.claude/agents/agent-onboard-example-output.md +600 -0
  3. package/.claude/agents/agent-onboard.md +576 -0
  4. package/.claude/commands/ONBOARDING_ENHANCEMENT_SUMMARY.md +266 -0
  5. package/.claude/commands/one.md +411 -10
  6. package/.claude/commands/release.md +64 -3
  7. package/CLAUDE.md +55 -69
  8. package/dist/commands/init.d.ts +5 -6
  9. package/dist/commands/init.d.ts.map +1 -1
  10. package/dist/commands/init.js +101 -101
  11. package/dist/commands/init.js.map +1 -1
  12. package/dist/index.js +6 -5
  13. package/dist/index.js.map +1 -1
  14. package/dist/utils/installation-setup.d.ts +24 -1
  15. package/dist/utils/installation-setup.d.ts.map +1 -1
  16. package/dist/utils/installation-setup.js +85 -1
  17. package/dist/utils/installation-setup.js.map +1 -1
  18. package/dist/utils/launch-claude.d.ts +6 -0
  19. package/dist/utils/launch-claude.d.ts.map +1 -0
  20. package/dist/utils/launch-claude.js +51 -0
  21. package/dist/utils/launch-claude.js.map +1 -0
  22. package/dist/utils/validation.d.ts +48 -0
  23. package/dist/utils/validation.d.ts.map +1 -0
  24. package/dist/utils/validation.js +73 -0
  25. package/dist/utils/validation.js.map +1 -0
  26. package/folders.yaml +1 -1
  27. package/one/.obsidian/app.json +8 -0
  28. package/one/.obsidian/appearance.json +1 -0
  29. package/one/.obsidian/community-plugins.json +3 -0
  30. package/one/.obsidian/core-plugins.json +33 -0
  31. package/one/.obsidian/plugins/easy-bake/main.js +361 -0
  32. package/one/.obsidian/plugins/easy-bake/manifest.json +11 -0
  33. package/one/.obsidian/plugins/easy-bake/styles.css +10 -0
  34. package/one/.obsidian/workspace.json +240 -0
  35. package/one/connections/workflow-onboarding.md +683 -0
  36. package/one/events/CART-DRAWER-INTEGRATION-GUIDE.md +354 -0
  37. package/one/events/CRITICAL-FIXES-COMPLETE.md +504 -0
  38. package/one/events/DEPLOYMENT.md +178 -0
  39. package/one/events/ECOMMERCE-DEMO-PLAN.md +225 -0
  40. package/one/events/ECOMMERCE-LIVE-DEMO.md +363 -0
  41. package/one/events/ECOMMERCE-TEMPLATE-COMPLETE.md +735 -0
  42. package/one/events/ECOMMERCE-TEMPLATES-SUMMARY.md +923 -0
  43. package/one/events/GRADIENT-TEXT-PERMANENT-FIX.md +223 -0
  44. package/one/events/HANDOFF.md +313 -0
  45. package/one/events/IMPLEMENTATION-SUMMARY-FINAL.md +503 -0
  46. package/one/events/IMPLEMENTATION_SUMMARY.md +529 -0
  47. package/one/events/LANDING-PAGE-EXAMPLE-OUTPUT.md +666 -0
  48. package/one/events/LANDING-PAGE-IMPLEMENTATION.md +642 -0
  49. package/one/events/LANDING-PAGE-QUICKSTART.md +407 -0
  50. package/one/events/MULTI-ONTOLOGY-COMPLETE-GUIDE.md +1627 -0
  51. package/one/events/MULTI-ONTOLOGY-IMPLEMENTATION-COMPLETE.md +573 -0
  52. package/one/events/ONBOARDING-IMPLEMENTATION-COMPLETE copy.md +398 -0
  53. package/one/events/ONTOLOGY-TUTORIALS-SUMMARY.md +525 -0
  54. package/one/events/ONTOLOGY-TYPE-GENERATOR-SUMMARY.md +455 -0
  55. package/one/events/ONTOLOGY_DISCOVERY_IMPLEMENTATION.md +486 -0
  56. package/one/events/ONTOLOGY_DISCOVERY_QUICKSTART.md +203 -0
  57. package/one/events/SECURITY-AUDIT-FIXES.md +376 -0
  58. package/one/events/SECURITY-SCAN-COMPLETE.md +281 -0
  59. package/one/events/SHOP-BUILD-STATUS.md +114 -0
  60. package/one/events/SHOP-PREMIUM-UPDATE.md +149 -0
  61. package/one/events/SITE-WIDE-GRADIENT-FIX.md +299 -0
  62. package/one/events/STORE-PRODUCTION-READY-STATUS.md +359 -0
  63. package/one/events/STRIPE-PAYMENT-METHODS-GUIDE.md +429 -0
  64. package/one/events/agent-director-enhancement-summary.md +386 -0
  65. package/one/events/agent-onboard-implementation-summary.md +457 -0
  66. package/one/events/clean-agent-ontology-cleanup-report.md +353 -0
  67. package/one/events/landing-page-generator.md +458 -0
  68. package/one/events/onboarding-implementation-complete.md +505 -0
  69. package/one/events/release.md +254 -0
  70. package/one/events/separate-implementation-status.md +537 -0
  71. package/one/groups/nine-padle-contents.baked.md +1252 -0
  72. package/one/groups/nine-padle-contents.md +6 -0
  73. package/one/knowledge/100-inference-quick-reference.md +431 -0
  74. package/one/knowledge/agent-onboard-usage.md +612 -0
  75. package/one/knowledge/cli-claude-handoff.md +718 -0
  76. package/one/knowledge/installation-folders.md +45 -1
  77. package/one/knowledge/ontology-blog.yaml +31 -0
  78. package/one/knowledge/ontology-cheatsheet.md +591 -0
  79. package/one/knowledge/ontology-community.yaml +42 -0
  80. package/one/knowledge/ontology-core-universal.md +722 -0
  81. package/one/knowledge/ontology-core.yaml +50 -0
  82. package/one/knowledge/ontology-courses.yaml +53 -0
  83. package/one/knowledge/ontology-creator.md +376 -0
  84. package/one/knowledge/ontology-developer-guide.md +789 -0
  85. package/one/knowledge/ontology-education.md +920 -0
  86. package/one/knowledge/ontology-index.md +354 -0
  87. package/one/knowledge/ontology-migration-guide.md +811 -0
  88. package/one/knowledge/ontology-minimal.yaml +1 -1
  89. package/one/knowledge/ontology-portfolio.yaml +31 -0
  90. package/one/knowledge/ontology-quickstart.md +576 -0
  91. package/one/knowledge/ontology-shop.yaml +121 -0
  92. package/one/knowledge/ontology-tokens.yaml +32 -0
  93. package/one/knowledge/ontology-tutorial.md +434 -0
  94. package/one/knowledge/ontology-video-script.md +890 -0
  95. package/one/things/docs/ecommerce/ARCHITECTURE-DIAGRAM.md +467 -0
  96. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-IMPLEMENTATION.md +408 -0
  97. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-SUMMARY.md +369 -0
  98. package/one/things/docs/ecommerce/CONVERSION-UX-IMPLEMENTATION-SUMMARY.md +396 -0
  99. package/one/things/docs/ecommerce/FEATURE-SUMMARY.md +468 -0
  100. package/one/things/docs/ecommerce/IMPLEMENTATION-NOTES.md +582 -0
  101. package/one/things/docs/ecommerce/INTEGRATION-EXAMPLE.md +449 -0
  102. package/one/things/docs/ecommerce/QUICK-START.md +368 -0
  103. package/one/things/docs/ecommerce/URGENCY-IMPLEMENTATION-SUMMARY.md +498 -0
  104. package/one/things/docs/ecommerce/URGENCY-QUICK-REFERENCE.md +237 -0
  105. package/one/things/docs/ecommerce/USAGE-EXAMPLE.astro +171 -0
  106. package/one/things/docs/ecommerce/demo.astro +309 -0
  107. package/one/things/plans/agent-director-100-inference-plans.md +410 -0
  108. package/one/things/plans/dual-website-strategy.md +612 -0
  109. package/one/things/plans/feature-based-sites.md +821 -0
  110. package/one/things/plans/multi-ontology-architecture.md +836 -0
  111. package/one/things/plans/onboarding.md +32 -0
  112. package/one/things/plans/separate.md +15 -17
  113. package/one/things/plans/start-new.md +738 -0
  114. package/one/things/templates.md +254 -0
  115. package/one/things/todo.md +23 -5
  116. package/package.json +2 -2
  117. package/one/things/claude/hooks/agent-hook-manager.js +0 -525
  118. package/one/things/claude/hooks/agent-load-balancer.js +0 -271
  119. package/one/things/claude/hooks/agent-request-interceptor.js +0 -70
  120. package/one/things/claude/hooks/cascade-feedback.js +0 -297
  121. package/one/things/claude/hooks/cascade-integration-hooks.js +0 -648
  122. package/one/things/claude/hooks/continuous-improvement-monitor.js +0 -510
  123. package/one/things/claude/hooks/file-organization-engine.js +0 -427
  124. package/one/things/claude/hooks/file-organization-monitor.js +0 -269
  125. package/one/things/claude/hooks/hook-config-manager.js +0 -202
  126. package/one/things/claude/hooks/hook-orchestrator.js +0 -662
  127. package/one/things/claude/hooks/hook-performance-report.js +0 -120
  128. package/one/things/claude/hooks/mcp-cascade-integration.js +0 -816
  129. package/one/things/claude/hooks/memory-optimizer.js +0 -510
  130. package/one/things/claude/hooks/ontology-compliance.js +0 -394
  131. package/one/things/claude/hooks/ontology-hook-manager.js +0 -316
  132. package/one/things/claude/hooks/ontology-validation-engine.js +0 -317
  133. package/one/things/claude/hooks/performance-monitoring-hook.js +0 -422
  134. package/one/things/claude/hooks/quality-scoring-engine.js +0 -834
  135. package/one/things/claude/hooks/simple-load-balancer.js +0 -238
  136. package/one/things/claude/hooks/startup-optimizer.js +0 -625
  137. package/one/things/claude/hooks/story-scoring-system.js +0 -445
  138. package/one/things/claude/hooks/story-validation-engine.js +0 -473
  139. package/one/things/claude/hooks/structure-synchronizer.js +0 -194
  140. package/one/things/claude/hooks/sub-agent-output-validator.js +0 -647
  141. package/one/things/claude/hooks/sub-agent-validation-hook.js +0 -343
  142. package/one/things/claude/hooks/trinity-validation-system.js +0 -392
  143. package/one/things/plans/organizations-to-groups.md +0 -705
@@ -0,0 +1,836 @@
1
+ # Multi-Ontology Architecture: Feature-Specific Ontologies
2
+
3
+ **Status:** 🎯 Active Plan
4
+ **Created:** 2025-10-19
5
+ **Ontology:** Things (Infrastructure Planning)
6
+
7
+ ---
8
+
9
+ ## Vision
10
+
11
+ Each feature extends the **core 6-dimension ontology** with its own specialized types, allowing features to be self-contained modules with their own data models.
12
+
13
+ ### Core Insight
14
+
15
+ ```
16
+ Core Ontology (Universal)
17
+ ├─ groups, people, things, connections, events, knowledge
18
+ │
19
+ └─ Feature Ontologies (Specialized Extensions)
20
+ ├─ Blog Ontology → adds blog_post, blog_category things
21
+ ├─ Shop Ontology → adds product, order, cart things
22
+ ├─ Courses Ontology → adds course, lesson, quiz things
23
+ ├─ Community Ontology → adds forum_topic, message things
24
+ └─ Tokens Ontology → adds token, holder things
25
+ ```
26
+
27
+ **Key Principle:** Features don't break the ontology - they **extend** it with new thing types, connection types, and event types.
28
+
29
+ ---
30
+
31
+ ## The Core 6-Dimension Ontology (Universal)
32
+
33
+ ### Always Present (Every Site Has This)
34
+
35
+ ```yaml
36
+ dimensions:
37
+ 1. groups: # Who owns what (multi-tenant isolation)
38
+ 2. people: # Who can do what (authorization)
39
+ 3. things: # What exists (base types)
40
+ 4. connections: # How they relate (base relationships)
41
+ 5. events: # What happened (base actions)
42
+ 6. knowledge: # What it means (vectors, RAG)
43
+ ```
44
+
45
+ ### Core Thing Types (Minimal)
46
+
47
+ ```typescript
48
+ // Always available
49
+ type CoreThingType =
50
+ | 'page' // Static pages
51
+ | 'user' // User profiles
52
+ | 'file' // Uploaded files
53
+ | 'link' // External links
54
+ | 'note'; // Simple notes
55
+ ```
56
+
57
+ ### Core Connection Types (Minimal)
58
+
59
+ ```typescript
60
+ // Always available
61
+ type CoreConnectionType =
62
+ | 'created_by'
63
+ | 'updated_by'
64
+ | 'viewed_by'
65
+ | 'favorited_by';
66
+ ```
67
+
68
+ ### Core Event Types (Minimal)
69
+
70
+ ```typescript
71
+ // Always available
72
+ type CoreEventType =
73
+ | 'thing_created'
74
+ | 'thing_updated'
75
+ | 'thing_deleted'
76
+ | 'thing_viewed';
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Feature Ontologies (Extensions)
82
+
83
+ Each feature adds its own specialized types to the core ontology.
84
+
85
+ ### 1. Blog Ontology
86
+
87
+ **File:** `one/knowledge/ontology-blog.md`
88
+
89
+ ```yaml
90
+ feature: blog
91
+ extends: core-ontology
92
+
93
+ thing_types:
94
+ - blog_post:
95
+ properties:
96
+ title: string
97
+ slug: string
98
+ content: string
99
+ excerpt: string
100
+ featuredImage: string
101
+ publishedAt: number
102
+ tags: string[]
103
+ category: string
104
+
105
+ - blog_category:
106
+ properties:
107
+ name: string
108
+ slug: string
109
+ description: string
110
+
111
+ connection_types:
112
+ - posted_in: # blog_post → blog_category
113
+ fromType: blog_post
114
+ toType: blog_category
115
+
116
+ event_types:
117
+ - blog_post_published:
118
+ thingType: blog_post
119
+ metadata:
120
+ title: string
121
+ category: string
122
+
123
+ - blog_post_viewed:
124
+ thingType: blog_post
125
+ metadata:
126
+ viewDuration: number
127
+ ```
128
+
129
+ **Routes Enabled:**
130
+ - `/blog`
131
+ - `/blog/[slug]`
132
+ - `/blog/category/[category]`
133
+
134
+ ---
135
+
136
+ ### 2. Portfolio Ontology
137
+
138
+ **File:** `one/knowledge/ontology-portfolio.md`
139
+
140
+ ```yaml
141
+ feature: portfolio
142
+ extends: core-ontology
143
+
144
+ thing_types:
145
+ - project:
146
+ properties:
147
+ title: string
148
+ slug: string
149
+ description: string
150
+ images: string[]
151
+ client: string
152
+ completedAt: number
153
+ technologies: string[]
154
+ url: string
155
+
156
+ - case_study:
157
+ properties:
158
+ title: string
159
+ problem: string
160
+ solution: string
161
+ results: string
162
+ metrics: Record<string, number>
163
+
164
+ connection_types:
165
+ - belongs_to_portfolio: # project → user
166
+ fromType: project
167
+ toType: user
168
+
169
+ event_types:
170
+ - project_viewed:
171
+ thingType: project
172
+ metadata:
173
+ viewDuration: number
174
+ ```
175
+
176
+ **Routes Enabled:**
177
+ - `/portfolio`
178
+ - `/portfolio/[slug]`
179
+
180
+ ---
181
+
182
+ ### 3. Shop Ontology (Ecommerce)
183
+
184
+ **File:** `one/knowledge/ontology-shop.md` (already exists as `ontology-ecommerce.md`)
185
+
186
+ ```yaml
187
+ feature: shop
188
+ extends: core-ontology
189
+
190
+ thing_types:
191
+ - product:
192
+ properties:
193
+ name: string
194
+ slug: string
195
+ description: string
196
+ price: number
197
+ compareAtPrice: number
198
+ images: string[]
199
+ inventory: number
200
+ sku: string
201
+ variants: ProductVariant[]
202
+
203
+ - product_variant:
204
+ properties:
205
+ name: string
206
+ sku: string
207
+ price: number
208
+ inventory: number
209
+ options: Record<string, string>
210
+
211
+ - shopping_cart:
212
+ properties:
213
+ items: CartItem[]
214
+ subtotal: number
215
+ tax: number
216
+ shipping: number
217
+ total: number
218
+
219
+ - order:
220
+ properties:
221
+ orderNumber: string
222
+ items: OrderItem[]
223
+ subtotal: number
224
+ tax: number
225
+ shipping: number
226
+ total: number
227
+ status: OrderStatus
228
+ shippingAddress: Address
229
+ billingAddress: Address
230
+ paymentId: string
231
+
232
+ connection_types:
233
+ - purchased: # user → product
234
+ fromType: user
235
+ toType: product
236
+ metadata:
237
+ orderId: string
238
+ quantity: number
239
+ price: number
240
+
241
+ - in_cart: # user → product
242
+ fromType: user
243
+ toType: product
244
+ metadata:
245
+ quantity: number
246
+
247
+ event_types:
248
+ - product_added_to_cart:
249
+ - order_placed:
250
+ - order_fulfilled:
251
+ - payment_processed:
252
+ ```
253
+
254
+ **Routes Enabled:**
255
+ - `/shop`
256
+ - `/shop/[slug]`
257
+ - `/cart`
258
+ - `/checkout`
259
+ - `/orders`
260
+
261
+ ---
262
+
263
+ ### 4. Courses Ontology (E-learning)
264
+
265
+ **File:** `one/knowledge/ontology-courses.md`
266
+
267
+ ```yaml
268
+ feature: courses
269
+ extends: core-ontology
270
+
271
+ thing_types:
272
+ - course:
273
+ properties:
274
+ title: string
275
+ slug: string
276
+ description: string
277
+ price: number
278
+ duration: string
279
+ level: 'beginner' | 'intermediate' | 'advanced'
280
+ thumbnail: string
281
+ status: 'draft' | 'published' | 'archived'
282
+
283
+ - lesson:
284
+ properties:
285
+ title: string
286
+ slug: string
287
+ content: string
288
+ videoUrl: string
289
+ duration: number
290
+ order: number
291
+ courseId: string
292
+
293
+ - quiz:
294
+ properties:
295
+ title: string
296
+ questions: Question[]
297
+ passingScore: number
298
+
299
+ - certificate:
300
+ properties:
301
+ studentId: string
302
+ courseId: string
303
+ issuedAt: number
304
+ certificateUrl: string
305
+
306
+ connection_types:
307
+ - enrolled_in: # user → course
308
+ fromType: user
309
+ toType: course
310
+ metadata:
311
+ enrolledAt: number
312
+ progress: number
313
+ completedAt: number?
314
+
315
+ - part_of: # lesson → course
316
+ fromType: lesson
317
+ toType: course
318
+ metadata:
319
+ order: number
320
+
321
+ event_types:
322
+ - enrolled_in_course:
323
+ metadata:
324
+ courseId: string
325
+ price: number
326
+
327
+ - lesson_completed:
328
+ metadata:
329
+ lessonId: string
330
+ courseId: string
331
+ timeSpent: number
332
+
333
+ - quiz_submitted:
334
+ metadata:
335
+ quizId: string
336
+ score: number
337
+ passed: boolean
338
+
339
+ - certificate_earned:
340
+ metadata:
341
+ courseId: string
342
+ certificateId: string
343
+ ```
344
+
345
+ **Routes Enabled:**
346
+ - `/courses`
347
+ - `/courses/[slug]`
348
+ - `/courses/[slug]/lessons/[lesson]`
349
+ - `/dashboard` (student progress)
350
+
351
+ ---
352
+
353
+ ### 5. Community Ontology
354
+
355
+ **File:** `one/knowledge/ontology-community.md`
356
+
357
+ ```yaml
358
+ feature: community
359
+ extends: core-ontology
360
+
361
+ thing_types:
362
+ - forum_topic:
363
+ properties:
364
+ title: string
365
+ slug: string
366
+ content: string
367
+ isPinned: boolean
368
+ isLocked: boolean
369
+ viewCount: number
370
+ replyCount: number
371
+
372
+ - forum_reply:
373
+ properties:
374
+ content: string
375
+ topicId: string
376
+ replyToId: string?
377
+
378
+ - direct_message:
379
+ properties:
380
+ content: string
381
+ recipientId: string
382
+ readAt: number?
383
+
384
+ connection_types:
385
+ - follows: # user → user
386
+ fromType: user
387
+ toType: user
388
+
389
+ - member_of: # user → community
390
+ fromType: user
391
+ toType: group
392
+ metadata:
393
+ role: 'admin' | 'moderator' | 'member'
394
+ joinedAt: number
395
+
396
+ event_types:
397
+ - topic_created:
398
+ - topic_replied:
399
+ - message_sent:
400
+ - user_followed:
401
+ ```
402
+
403
+ **Routes Enabled:**
404
+ - `/community`
405
+ - `/community/topics/[topic]`
406
+ - `/community/members`
407
+ - `/community/messages`
408
+
409
+ ---
410
+
411
+ ### 6. Tokens Ontology (Creator Economy)
412
+
413
+ **File:** `one/knowledge/ontology-tokens.md`
414
+
415
+ ```yaml
416
+ feature: tokens
417
+ extends: core-ontology
418
+
419
+ thing_types:
420
+ - token:
421
+ properties:
422
+ name: string
423
+ symbol: string
424
+ totalSupply: number
425
+ circulatingSupply: number
426
+ priceUSD: number
427
+ contractAddress: string
428
+ chain: 'ethereum' | 'polygon' | 'solana'
429
+
430
+ - token_holder:
431
+ properties:
432
+ walletAddress: string
433
+ balance: number
434
+ lockedBalance: number
435
+
436
+ connection_types:
437
+ - holds_tokens: # user → token
438
+ fromType: user
439
+ toType: token
440
+ metadata:
441
+ balance: number
442
+ acquiredAt: number
443
+ avgPrice: number
444
+
445
+ event_types:
446
+ - tokens_purchased:
447
+ metadata:
448
+ tokenId: string
449
+ amount: number
450
+ priceUSD: number
451
+ paymentId: string
452
+
453
+ - tokens_sold:
454
+ metadata:
455
+ tokenId: string
456
+ amount: number
457
+ priceUSD: number
458
+
459
+ - tokens_transferred:
460
+ metadata:
461
+ fromUserId: string
462
+ toUserId: string
463
+ amount: number
464
+ ```
465
+
466
+ **Routes Enabled:**
467
+ - `/tokens`
468
+ - `/tokens/buy`
469
+ - `/tokens/holders`
470
+
471
+ ---
472
+
473
+ ## Ontology Composition
474
+
475
+ ### How Features Extend the Core
476
+
477
+ ```typescript
478
+ // Core ontology (always present)
479
+ const coreOntology = {
480
+ thingTypes: ['page', 'user', 'file', 'link', 'note'],
481
+ connectionTypes: ['created_by', 'updated_by', 'viewed_by', 'favorited_by'],
482
+ eventTypes: ['thing_created', 'thing_updated', 'thing_deleted', 'thing_viewed'],
483
+ };
484
+
485
+ // Feature ontologies (conditionally added)
486
+ const blogOntology = {
487
+ thingTypes: ['blog_post', 'blog_category'],
488
+ connectionTypes: ['posted_in'],
489
+ eventTypes: ['blog_post_published', 'blog_post_viewed'],
490
+ };
491
+
492
+ const shopOntology = {
493
+ thingTypes: ['product', 'product_variant', 'shopping_cart', 'order'],
494
+ connectionTypes: ['purchased', 'in_cart'],
495
+ eventTypes: ['product_added_to_cart', 'order_placed', 'order_fulfilled'],
496
+ };
497
+
498
+ // Compose based on enabled features
499
+ const compositeOntology = composeOntologies(
500
+ coreOntology,
501
+ hasFeature('blog') ? blogOntology : null,
502
+ hasFeature('shop') ? shopOntology : null,
503
+ hasFeature('courses') ? coursesOntology : null
504
+ );
505
+
506
+ // Result: TypeScript types are generated for enabled features only
507
+ type ThingType = CoreThingType | BlogThingType | ShopThingType | CoursesThingType;
508
+ ```
509
+
510
+ ---
511
+
512
+ ## Backend Schema Generation
513
+
514
+ ### Dynamic Schema Based on Enabled Features
515
+
516
+ ```typescript
517
+ // backend/convex/schema.ts
518
+ import { defineSchema, defineTable } from 'convex/server';
519
+ import { v } from 'convex/values';
520
+ import { loadOntologies } from './ontology-loader';
521
+
522
+ // Load ontologies based on PUBLIC_FEATURES env var
523
+ const ontologies = loadOntologies(process.env.PUBLIC_FEATURES);
524
+
525
+ export default defineSchema({
526
+ // Core tables (always present)
527
+ groups: defineTable({ /* ... */ }),
528
+ people: defineTable({ /* ... */ }),
529
+
530
+ // Things table with dynamic type validation
531
+ things: defineTable({
532
+ groupId: v.id('groups'),
533
+ type: v.union(...ontologies.thingTypes.map(t => v.literal(t))),
534
+ name: v.string(),
535
+ properties: v.any(),
536
+ status: v.union(v.literal('draft'), v.literal('active'), v.literal('archived')),
537
+ createdAt: v.number(),
538
+ updatedAt: v.number(),
539
+ }).index('by_group_and_type', ['groupId', 'type']),
540
+
541
+ // Connections table with dynamic type validation
542
+ connections: defineTable({
543
+ groupId: v.id('groups'),
544
+ fromThingId: v.id('things'),
545
+ toThingId: v.id('things'),
546
+ relationshipType: v.union(...ontologies.connectionTypes.map(t => v.literal(t))),
547
+ metadata: v.optional(v.any()),
548
+ createdAt: v.number(),
549
+ }).index('by_group_and_type', ['groupId', 'relationshipType']),
550
+
551
+ // Events table with dynamic type validation
552
+ events: defineTable({
553
+ groupId: v.id('groups'),
554
+ eventType: v.union(...ontologies.eventTypes.map(t => v.literal(t))),
555
+ actorId: v.id('people'),
556
+ targetId: v.optional(v.id('things')),
557
+ timestamp: v.number(),
558
+ metadata: v.optional(v.any()),
559
+ }).index('by_group_and_type', ['groupId', 'eventType']),
560
+
561
+ // Knowledge table (always present)
562
+ knowledge: defineTable({ /* ... */ }),
563
+ });
564
+ ```
565
+
566
+ ---
567
+
568
+ ## Type Safety with Feature-Specific Types
569
+
570
+ ### Generated Types Based on Enabled Features
571
+
572
+ ```typescript
573
+ // Generated by ontology composition
574
+ type ThingType =
575
+ | CoreThingType
576
+ | (hasFeature('blog') ? BlogThingType : never)
577
+ | (hasFeature('shop') ? ShopThingType : never)
578
+ | (hasFeature('courses') ? CoursesThingType : never);
579
+
580
+ type ConnectionType =
581
+ | CoreConnectionType
582
+ | (hasFeature('blog') ? BlogConnectionType : never)
583
+ | (hasFeature('shop') ? ShopConnectionType : never)
584
+ | (hasFeature('courses') ? CoursesConnectionType : never);
585
+
586
+ type EventType =
587
+ | CoreEventType
588
+ | (hasFeature('blog') ? BlogEventType : never)
589
+ | (hasFeature('shop') ? ShopEventType : never)
590
+ | (hasFeature('courses') ? CoursesEventType : never);
591
+
592
+ // Usage
593
+ const createBlogPost = (title: string, content: string) => {
594
+ // TypeScript knows 'blog_post' is valid only if blog feature is enabled
595
+ return db.insert('things', {
596
+ type: 'blog_post' as ThingType, // Type-safe!
597
+ properties: { title, content },
598
+ });
599
+ };
600
+ ```
601
+
602
+ ---
603
+
604
+ ## Ontology Validation
605
+
606
+ ### Compile-Time Validation
607
+
608
+ ```typescript
609
+ // tools/validate-ontology.ts
610
+ import { FEATURES } from '../src/config/features';
611
+ import { loadOntologies } from '../backend/convex/ontology-loader';
612
+
613
+ const validateOntology = () => {
614
+ const ontologies = loadOntologies(FEATURES.join(','));
615
+
616
+ // Check for type conflicts
617
+ const thingTypes = new Set();
618
+ for (const type of ontologies.thingTypes) {
619
+ if (thingTypes.has(type)) {
620
+ throw new Error(`Duplicate thing type: ${type}`);
621
+ }
622
+ thingTypes.add(type);
623
+ }
624
+
625
+ // Check for connection type conflicts
626
+ const connectionTypes = new Set();
627
+ for (const type of ontologies.connectionTypes) {
628
+ if (connectionTypes.has(type)) {
629
+ throw new Error(`Duplicate connection type: ${type}`);
630
+ }
631
+ connectionTypes.add(type);
632
+ }
633
+
634
+ console.log('✓ Ontology validated successfully');
635
+ console.log(` Thing types: ${ontologies.thingTypes.length}`);
636
+ console.log(` Connection types: ${ontologies.connectionTypes.length}`);
637
+ console.log(` Event types: ${ontologies.eventTypes.length}`);
638
+ };
639
+
640
+ validateOntology();
641
+ ```
642
+
643
+ ---
644
+
645
+ ## NPX OneIE Integration
646
+
647
+ ### Ontology Initialization
648
+
649
+ ```bash
650
+ npx oneie init
651
+
652
+ ✓ What's your name? Jane Doe
653
+ ✓ Select features: blog, portfolio, courses, shop, tokens
654
+
655
+ # Creates ontology configuration
656
+ 📝 Composing ontology from selected features...
657
+
658
+ Core Ontology:
659
+ ├─ 5 thing types
660
+ ├─ 4 connection types
661
+ └─ 4 event types
662
+
663
+ Blog Ontology:
664
+ ├─ +2 thing types (blog_post, blog_category)
665
+ ├─ +1 connection type (posted_in)
666
+ └─ +2 event types (blog_post_published, blog_post_viewed)
667
+
668
+ Shop Ontology:
669
+ ├─ +4 thing types (product, product_variant, shopping_cart, order)
670
+ ├─ +2 connection types (purchased, in_cart)
671
+ └─ +4 event types (product_added_to_cart, order_placed, ...)
672
+
673
+ Courses Ontology:
674
+ ├─ +4 thing types (course, lesson, quiz, certificate)
675
+ ├─ +2 connection types (enrolled_in, part_of)
676
+ └─ +4 event types (enrolled_in_course, lesson_completed, ...)
677
+
678
+ Tokens Ontology:
679
+ ├─ +2 thing types (token, token_holder)
680
+ ├─ +1 connection type (holds_tokens)
681
+ └─ +3 event types (tokens_purchased, tokens_sold, ...)
682
+
683
+ Total Ontology:
684
+ ├─ 17 thing types
685
+ ├─ 10 connection types
686
+ └─ 17 event types
687
+
688
+ ✅ Ontology composition complete!
689
+ ```
690
+
691
+ ---
692
+
693
+ ## Benefits
694
+
695
+ ### 1. Feature Isolation
696
+
697
+ Each feature's ontology is self-contained:
698
+
699
+ ```
700
+ blog/
701
+ ├─ ontology.md # Blog-specific types
702
+ ├─ pages/ # Blog pages
703
+ ├─ components/ # Blog components
704
+ └─ services/ # Blog services
705
+ ```
706
+
707
+ ### 2. Type Safety
708
+
709
+ TypeScript knows which types are available:
710
+
711
+ ```typescript
712
+ // ✅ Valid if blog feature enabled
713
+ const post = await db.insert('things', {
714
+ type: 'blog_post',
715
+ properties: { title, content }
716
+ });
717
+
718
+ // ❌ Error if shop feature NOT enabled
719
+ const product = await db.insert('things', {
720
+ type: 'product', // TypeScript error: Type 'product' not in ThingType union
721
+ properties: { name, price }
722
+ });
723
+ ```
724
+
725
+ ### 3. Efficient Schema
726
+
727
+ Database only validates types that exist:
728
+
729
+ ```typescript
730
+ // If only blog feature enabled
731
+ type ThingType = 'page' | 'user' | 'file' | 'blog_post' | 'blog_category';
732
+
733
+ // Not: 'product' | 'course' | 'token' | etc.
734
+ ```
735
+
736
+ ### 4. Clear Dependencies
737
+
738
+ Features declare their ontology dependencies:
739
+
740
+ ```yaml
741
+ # ontology-community.md
742
+ dependencies:
743
+ - core-ontology
744
+ - user (thing type from core)
745
+ ```
746
+
747
+ ### 5. Composability
748
+
749
+ Mix any features - ontologies compose cleanly:
750
+
751
+ ```bash
752
+ # Creator + educator + merchant
753
+ PUBLIC_FEATURES=blog,portfolio,courses,shop,community,tokens
754
+
755
+ # Ontology = Core + Blog + Portfolio + Courses + Shop + Community + Tokens
756
+ ```
757
+
758
+ ---
759
+
760
+ ## Implementation Plan
761
+
762
+ ### Week 1: Core Infrastructure
763
+ 1. Create ontology loader system
764
+ 2. Update schema generator
765
+ 3. Test core + blog ontology
766
+
767
+ ### Week 2: Feature Ontologies
768
+ 1. Extract blog ontology spec
769
+ 2. Extract shop ontology spec (already exists!)
770
+ 3. Create courses ontology spec
771
+ 4. Create community ontology spec
772
+
773
+ ### Week 3: Type Generation
774
+ 1. Generate TypeScript types from ontology
775
+ 2. Validate ontology composition
776
+ 3. Test type safety
777
+
778
+ ### Week 4: CLI Integration
779
+ 1. Update `npx oneie` to compose ontologies
780
+ 2. Add ontology validation
781
+ 3. Generate schema.ts automatically
782
+
783
+ ---
784
+
785
+ ## File Structure
786
+
787
+ ```
788
+ /one/knowledge/
789
+ ├─ ontology.md # Core ontology (always loaded)
790
+ ├─ ontology.yaml # Core ontology (YAML)
791
+ ├─ ontology-blog.md # Blog feature ontology
792
+ ├─ ontology-portfolio.md # Portfolio feature ontology
793
+ ├─ ontology-shop.md # Shop feature ontology (exists!)
794
+ ├─ ontology-courses.md # Courses feature ontology
795
+ ├─ ontology-community.md # Community feature ontology
796
+ ├─ ontology-tokens.md # Tokens feature ontology
797
+ ├─ ontology-events.md # Events feature ontology
798
+ ├─ ontology-booking.md # Booking feature ontology
799
+ ├─ ontology-membership.md # Membership feature ontology
800
+ └─ ontology-analytics.md # Analytics feature ontology
801
+
802
+ /backend/convex/
803
+ ├─ schema.ts # Generated from composed ontology
804
+ ├─ ontology-loader.ts # Loads & composes ontologies
805
+ └─ ontology-validator.ts # Validates composition
806
+ ```
807
+
808
+ ---
809
+
810
+ ## Success Metrics
811
+
812
+ - [ ] Core ontology defined (5 thing types, 4 connection types, 4 event types)
813
+ - [ ] Blog ontology extends core cleanly
814
+ - [ ] Shop ontology extracted from existing ecommerce ontology
815
+ - [ ] Ontology composition generates correct TypeScript types
816
+ - [ ] Schema.ts validates only enabled feature types
817
+ - [ ] No type conflicts when features combine
818
+ - [ ] `npx oneie` shows ontology composition summary
819
+ - [ ] Type safety enforced at compile time
820
+
821
+ ---
822
+
823
+ ## Next Steps
824
+
825
+ 1. **Extract core ontology** (minimal thing/connection/event types)
826
+ 2. **Create blog ontology** (blog_post, blog_category types)
827
+ 3. **Refactor shop ontology** (already exists - just reorganize)
828
+ 4. **Build ontology loader** (composes based on features)
829
+ 5. **Generate schema.ts** (dynamic based on composition)
830
+ 6. **Test type safety** (ensure TypeScript catches invalid types)
831
+
832
+ ---
833
+
834
+ **This makes features truly modular!** 🚀
835
+
836
+ Each feature brings its own data model (ontology extension), and the system composes them into a unified schema. No rigid templates - just composable ontology modules that extend the universal 6-dimension core.