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,486 @@
1
+ # Runtime Ontology Discovery - Implementation Summary
2
+
3
+ ## Overview
4
+
5
+ Successfully implemented a runtime ontology query endpoint and frontend hooks that enable the UI to discover what features are enabled in the current ontology composition. This allows for dynamic, feature-conditional rendering without hardcoding feature flags.
6
+
7
+ ## What Was Created
8
+
9
+ ### 1. Backend Query Endpoint
10
+
11
+ **File:** `/Users/toc/Server/ONE/backend/convex/queries/ontology.ts`
12
+
13
+ Provides 7 query functions for ontology discovery:
14
+
15
+ ```typescript
16
+ // Get complete ontology information
17
+ api.queries.ontology.getOntology()
18
+
19
+ // Get metadata (counts, generation time)
20
+ api.queries.ontology.getMetadata()
21
+
22
+ // Get specific dimension types
23
+ api.queries.ontology.getThingTypes()
24
+ api.queries.ontology.getConnectionTypes()
25
+ api.queries.ontology.getEventTypes()
26
+
27
+ // Feature detection
28
+ api.queries.ontology.getEnabledFeatures()
29
+ api.queries.ontology.hasFeature({ feature: "blog" })
30
+
31
+ // Detailed feature breakdown
32
+ api.queries.ontology.getFeatureBreakdown()
33
+ ```
34
+
35
+ **Key Features:**
36
+
37
+ - Type-safe queries using Convex validators
38
+ - Auto-generated types from ontology composition
39
+ - Zero runtime overhead (queries are cached by Convex)
40
+ - Works with any ontology composition (core, blog, portfolio, shop, etc.)
41
+
42
+ ### 2. Frontend React Hooks
43
+
44
+ **File:** `/Users/toc/Server/ONE/web/src/hooks/useOntology.ts`
45
+
46
+ Provides 8 hooks for runtime feature discovery:
47
+
48
+ ```typescript
49
+ // Complete ontology with helpers
50
+ const { ontology, hasFeature, isLoading } = useOntology();
51
+
52
+ // Single feature check (efficient)
53
+ const hasBlog = useHasFeature('blog');
54
+
55
+ // Metadata only
56
+ const metadata = useOntologyMetadata();
57
+
58
+ // Specific type arrays
59
+ const thingTypes = useThingTypes();
60
+ const connectionTypes = useConnectionTypes();
61
+ const eventTypes = useEventTypes();
62
+ const features = useEnabledFeatures();
63
+
64
+ // Detailed breakdown
65
+ const breakdown = useFeatureBreakdown();
66
+ ```
67
+
68
+ **Key Features:**
69
+
70
+ - Type-safe with TypeScript
71
+ - Handles loading states
72
+ - Reactive (updates when ontology changes)
73
+ - Memoized for performance
74
+ - Backend-agnostic (uses Convex hooks but could work with any provider)
75
+
76
+ ### 3. Demo Component
77
+
78
+ **File:** `/Users/toc/Server/ONE/web/src/components/features/OntologyExplorer.tsx`
79
+
80
+ Comprehensive UI component showing:
81
+
82
+ - Ontology metadata (counts, generation time)
83
+ - Enabled features
84
+ - Feature breakdown (what each feature provides)
85
+ - All thing types
86
+ - All connection types
87
+ - All event types
88
+
89
+ **Usage:**
90
+
91
+ ```astro
92
+ ---
93
+ import { OntologyExplorer } from '@/components/features/OntologyExplorer';
94
+ ---
95
+
96
+ <Layout>
97
+ <OntologyExplorer client:load />
98
+ </Layout>
99
+ ```
100
+
101
+ ### 4. Documentation
102
+
103
+ **File:** `/Users/toc/Server/ONE/backend/ONTOLOGY_QUERIES_EXAMPLE.md`
104
+
105
+ Comprehensive usage guide with:
106
+
107
+ - 30+ code examples
108
+ - 7 common patterns
109
+ - Backend and frontend usage
110
+ - Astro SSR examples
111
+ - CLI/admin script examples
112
+ - Best practices
113
+ - Testing patterns
114
+
115
+ ### 5. Hook Exports
116
+
117
+ **Updated:** `/Users/toc/Server/ONE/web/src/hooks/index.ts`
118
+
119
+ All ontology hooks now exported from the main hooks index:
120
+
121
+ ```typescript
122
+ import {
123
+ useOntology,
124
+ useHasFeature,
125
+ useThingTypes,
126
+ // ... etc
127
+ } from '@/hooks';
128
+ ```
129
+
130
+ ## Current Ontology Composition
131
+
132
+ Based on the generated types, the system currently has:
133
+
134
+ **Features:** core, blog, portfolio, shop
135
+
136
+ **Thing Types (15):**
137
+
138
+ - Core: page, user, file, link, note
139
+ - Blog: blog_post, blog_category
140
+ - Portfolio: project, case_study
141
+ - Shop: product, product_variant, shopping_cart, order, discount_code, payment
142
+
143
+ **Connection Types (11):**
144
+
145
+ - Core: created_by, updated_by, viewed_by, favorited_by
146
+ - Blog: posted_in
147
+ - Portfolio: belongs_to_portfolio
148
+ - Shop: purchased, in_cart, variant_of, ordered, paid_for
149
+
150
+ **Event Types (18):**
151
+
152
+ - Core: thing_created, thing_updated, thing_deleted, thing_viewed
153
+ - Blog: blog_post_published, blog_post_viewed
154
+ - Portfolio: project_viewed
155
+ - Shop: product_added_to_cart, cart_updated, cart_abandoned, order_placed, order_fulfilled, order_shipped, order_delivered, payment_processed, payment_failed, product_viewed, discount_applied
156
+
157
+ ## Usage Examples
158
+
159
+ ### 1. Conditional Navigation
160
+
161
+ ```tsx
162
+ import { useHasFeature } from '@/hooks';
163
+
164
+ function Navigation() {
165
+ const hasBlog = useHasFeature('blog');
166
+ const hasShop = useHasFeature('shop');
167
+ const hasPortfolio = useHasFeature('portfolio');
168
+
169
+ return (
170
+ <nav>
171
+ <a href="/">Home</a>
172
+ {hasBlog && <a href="/blog">Blog</a>}
173
+ {hasPortfolio && <a href="/portfolio">Portfolio</a>}
174
+ {hasShop && <a href="/shop">Shop</a>}
175
+ </nav>
176
+ );
177
+ }
178
+ ```
179
+
180
+ ### 2. Dynamic Type Selector
181
+
182
+ ```tsx
183
+ import { useThingTypes } from '@/hooks';
184
+
185
+ function CreateThingForm() {
186
+ const thingTypes = useThingTypes();
187
+ const [type, setType] = useState('');
188
+
189
+ return (
190
+ <select value={type} onChange={(e) => setType(e.target.value)}>
191
+ <option value="">Select type...</option>
192
+ {thingTypes.map(type => (
193
+ <option key={type} value={type}>
194
+ {type.replace('_', ' ').toUpperCase()}
195
+ </option>
196
+ ))}
197
+ </select>
198
+ );
199
+ }
200
+ ```
201
+
202
+ ### 3. Feature-Based Dashboard
203
+
204
+ ```tsx
205
+ import { useOntology } from '@/hooks';
206
+
207
+ function Dashboard() {
208
+ const { features, metadata, isLoading } = useOntology();
209
+
210
+ if (isLoading) return <Skeleton />;
211
+
212
+ return (
213
+ <div>
214
+ <h1>Dashboard</h1>
215
+ <p>Ontology: {features.join(', ')}</p>
216
+ <p>Thing Types: {metadata.thingTypeCount}</p>
217
+
218
+ {features.includes('blog') && <BlogManagement />}
219
+ {features.includes('shop') && <OrderManagement />}
220
+ {features.includes('portfolio') && <ProjectShowcase />}
221
+ </div>
222
+ );
223
+ }
224
+ ```
225
+
226
+ ### 4. Astro SSR with Ontology
227
+
228
+ ```astro
229
+ ---
230
+ import { ConvexHttpClient } from 'convex/browser';
231
+ import { api } from '@/convex/_generated/api';
232
+
233
+ const convex = new ConvexHttpClient(import.meta.env.PUBLIC_CONVEX_URL);
234
+ const ontology = await convex.query(api.queries.ontology.getOntology);
235
+ ---
236
+
237
+ <Layout>
238
+ <h1>Ontology Configuration</h1>
239
+
240
+ <section>
241
+ <h2>Enabled Features</h2>
242
+ <ul>
243
+ {ontology.features.map(feature => (
244
+ <li>{feature}</li>
245
+ ))}
246
+ </ul>
247
+ </section>
248
+
249
+ <section>
250
+ <h2>Thing Types ({ontology.thingTypes.length})</h2>
251
+ <p>{ontology.thingTypes.join(', ')}</p>
252
+ </section>
253
+ </Layout>
254
+ ```
255
+
256
+ ### 5. CLI Admin Script
257
+
258
+ ```typescript
259
+ import { ConvexHttpClient } from 'convex/browser';
260
+ import { api } from '../backend/convex/_generated/api';
261
+
262
+ const convex = new ConvexHttpClient(process.env.CONVEX_URL!);
263
+
264
+ async function checkOntology() {
265
+ const metadata = await convex.query(api.queries.ontology.getMetadata);
266
+
267
+ console.log('Ontology Composition:');
268
+ console.log(` Features: ${metadata.features.join(', ')}`);
269
+ console.log(` Thing Types: ${metadata.thingTypeCount}`);
270
+ console.log(` Connection Types: ${metadata.connectionTypeCount}`);
271
+ console.log(` Event Types: ${metadata.eventTypeCount}`);
272
+ console.log(` Generated: ${metadata.generatedAt}`);
273
+ }
274
+
275
+ checkOntology();
276
+ ```
277
+
278
+ ## Integration with Existing System
279
+
280
+ ### How It Works with Ontology Composition
281
+
282
+ The system uses auto-generated types from YAML ontologies:
283
+
284
+ 1. **YAML Ontologies** define features (core, blog, portfolio, shop)
285
+ 2. **Script** generates TypeScript types from YAML (`scripts/generate-ontology-types.ts`)
286
+ 3. **Schema** uses generated types to create Convex validators
287
+ 4. **Queries** expose ontology metadata at runtime
288
+ 5. **Frontend** discovers features dynamically via hooks
289
+
290
+ ### Updating Ontology
291
+
292
+ When you add a new feature:
293
+
294
+ ```bash
295
+ # 1. Add feature YAML
296
+ echo "feature: new_feature" > backend/convex/ontologies/new_feature.yaml
297
+
298
+ # 2. Enable feature
299
+ export PUBLIC_FEATURES="core,blog,portfolio,shop,new_feature"
300
+
301
+ # 3. Regenerate types
302
+ bun run scripts/generate-ontology-types.ts
303
+
304
+ # 4. Schema automatically picks up new types
305
+ # 5. Frontend discovers new feature via useHasFeature('new_feature')
306
+ ```
307
+
308
+ ## Benefits
309
+
310
+ ### 1. Dynamic Feature Detection
311
+
312
+ Frontend automatically adapts to enabled features without code changes:
313
+
314
+ ```tsx
315
+ // No hardcoded feature flags needed
316
+ const hasBlog = useHasFeature('blog'); // Dynamically checks
317
+ ```
318
+
319
+ ### 2. Type Safety
320
+
321
+ TypeScript ensures correct usage:
322
+
323
+ ```tsx
324
+ const types = useThingTypes(); // ThingType[]
325
+ const selected: ThingType = types[0]; // Type-safe
326
+ ```
327
+
328
+ ### 3. Zero Configuration
329
+
330
+ Features are discovered at runtime - no frontend config needed:
331
+
332
+ ```tsx
333
+ // Automatically shows/hides based on ontology
334
+ {hasFeature('shop') && <ShopSection />}
335
+ ```
336
+
337
+ ### 4. Admin/Debug Tools
338
+
339
+ Easily build tools to inspect ontology:
340
+
341
+ ```tsx
342
+ <OntologyExplorer /> // Shows complete composition
343
+ ```
344
+
345
+ ### 5. Multi-Tenant Support
346
+
347
+ Different tenants can have different ontologies - frontend adapts automatically.
348
+
349
+ ## Best Practices
350
+
351
+ ### 1. Use Specific Hooks When Possible
352
+
353
+ ```tsx
354
+ // Good: Efficient single check
355
+ const hasBlog = useHasFeature('blog');
356
+
357
+ // Less efficient: Loading all ontology data
358
+ const { hasFeature } = useOntology();
359
+ const hasBlog = hasFeature('blog');
360
+ ```
361
+
362
+ ### 2. Handle Loading States
363
+
364
+ ```tsx
365
+ const { ontology, isLoading } = useOntology();
366
+
367
+ if (isLoading) return <Skeleton />;
368
+ // Safe to use ontology here
369
+ ```
370
+
371
+ ### 3. Memoize Feature Checks
372
+
373
+ ```tsx
374
+ const hasContentFeatures = useMemo(
375
+ () => features.some(f => ['blog', 'portfolio'].includes(f)),
376
+ [features]
377
+ );
378
+ ```
379
+
380
+ ### 4. Type Safety
381
+
382
+ ```tsx
383
+ import type { ThingType } from '@/convex/types/ontology';
384
+
385
+ const [selected, setSelected] = useState<ThingType | ''>('');
386
+ ```
387
+
388
+ ## Common Patterns
389
+
390
+ ### Conditional Navigation
391
+
392
+ ```tsx
393
+ const navItems = [
394
+ { label: 'Home', href: '/', show: true },
395
+ { label: 'Blog', href: '/blog', show: hasFeature('blog') },
396
+ { label: 'Shop', href: '/shop', show: hasFeature('shop') },
397
+ ].filter(item => item.show);
398
+ ```
399
+
400
+ ### Feature-Gated Components
401
+
402
+ ```tsx
403
+ function withFeature(feature: string, Component: React.ComponentType) {
404
+ return function FeatureGatedComponent(props: any) {
405
+ const hasFeature = useHasFeature(feature);
406
+ if (!hasFeature) return null;
407
+ return <Component {...props} />;
408
+ };
409
+ }
410
+
411
+ const BlogEditor = withFeature('blog', BlogEditorComponent);
412
+ ```
413
+
414
+ ### Dynamic Form Fields
415
+
416
+ ```tsx
417
+ const thingTypes = useThingTypes();
418
+ const connectionTypes = useConnectionTypes();
419
+
420
+ // Build form based on available types
421
+ ```
422
+
423
+ ## Testing
424
+
425
+ Mock ontology in tests:
426
+
427
+ ```typescript
428
+ vi.mock('@/hooks/useOntology', () => ({
429
+ useOntology: () => ({
430
+ features: ['core', 'blog'],
431
+ thingTypes: ['page', 'user', 'blog_post'],
432
+ hasFeature: (f: string) => ['core', 'blog'].includes(f),
433
+ isLoading: false,
434
+ }),
435
+ }));
436
+ ```
437
+
438
+ ## Next Steps
439
+
440
+ ### Potential Enhancements
441
+
442
+ 1. **Auto-generate feature breakdown** from YAML (currently manual)
443
+ 2. **Add feature dependencies** (e.g., "shop requires core")
444
+ 3. **Version tracking** (ontology version numbers)
445
+ 4. **Migration helpers** (upgrade from v1 to v2)
446
+ 5. **Feature flags per tenant** (enable/disable features per organization)
447
+
448
+ ### Usage in Real Features
449
+
450
+ 1. **Admin Dashboard** - Show available features to users
451
+ 2. **Navigation** - Conditional menu items
452
+ 3. **Forms** - Dynamic type selectors
453
+ 4. **Settings** - Enable/disable features per organization
454
+ 5. **Onboarding** - Guide users based on enabled features
455
+
456
+ ## Files Created
457
+
458
+ 1. `/Users/toc/Server/ONE/backend/convex/queries/ontology.ts` - Backend queries
459
+ 2. `/Users/toc/Server/ONE/web/src/hooks/useOntology.ts` - Frontend hooks
460
+ 3. `/Users/toc/Server/ONE/web/src/components/features/OntologyExplorer.tsx` - Demo component
461
+ 4. `/Users/toc/Server/ONE/backend/ONTOLOGY_QUERIES_EXAMPLE.md` - Usage documentation
462
+ 5. `/Users/toc/Server/ONE/ONTOLOGY_DISCOVERY_IMPLEMENTATION.md` - This file
463
+
464
+ ## Dependencies
465
+
466
+ Relies on existing infrastructure:
467
+
468
+ - **Ontology Types:** `/Users/toc/Server/ONE/backend/convex/types/ontology.ts` (auto-generated)
469
+ - **Schema:** `/Users/toc/Server/ONE/backend/convex/schema.ts` (uses ontology types)
470
+ - **Convex Hooks:** `convex/react` (useQuery)
471
+ - **Generation Script:** `scripts/generate-ontology-types.ts`
472
+
473
+ ## Summary
474
+
475
+ Successfully implemented a complete runtime ontology discovery system:
476
+
477
+ - **Backend:** 7 query functions for ontology metadata
478
+ - **Frontend:** 8 React hooks for feature detection
479
+ - **Demo:** Full-featured OntologyExplorer component
480
+ - **Docs:** 30+ usage examples and best practices
481
+
482
+ **Result:** Frontend can now dynamically discover and adapt to the current ontology composition without hardcoded feature flags or configuration files.
483
+
484
+ ---
485
+
486
+ **Built with the 6-dimension ontology. Runtime discovery enables composition-aware UIs.**
@@ -0,0 +1,203 @@
1
+ # Ontology Discovery - Quick Start
2
+
3
+ ## 30-Second Overview
4
+
5
+ Runtime ontology discovery lets your frontend automatically adapt to enabled features without hardcoded flags.
6
+
7
+ ## Quick Examples
8
+
9
+ ### Check if Feature is Enabled
10
+
11
+ ```tsx
12
+ import { useHasFeature } from '@/hooks';
13
+
14
+ function MyComponent() {
15
+ const hasBlog = useHasFeature('blog');
16
+
17
+ if (!hasBlog) return null;
18
+
19
+ return <BlogSection />;
20
+ }
21
+ ```
22
+
23
+ ### Get All Thing Types
24
+
25
+ ```tsx
26
+ import { useThingTypes } from '@/hooks';
27
+
28
+ function TypeSelector() {
29
+ const types = useThingTypes();
30
+
31
+ return (
32
+ <select>
33
+ {types.map(type => (
34
+ <option key={type} value={type}>{type}</option>
35
+ ))}
36
+ </select>
37
+ );
38
+ }
39
+ ```
40
+
41
+ ### Complete Ontology Info
42
+
43
+ ```tsx
44
+ import { useOntology } from '@/hooks';
45
+
46
+ function Dashboard() {
47
+ const { features, thingTypes, connectionTypes, eventTypes, isLoading } = useOntology();
48
+
49
+ if (isLoading) return <div>Loading...</div>;
50
+
51
+ return (
52
+ <div>
53
+ <h1>Features: {features.join(', ')}</h1>
54
+ <p>Thing Types: {thingTypes.length}</p>
55
+ <p>Connection Types: {connectionTypes.length}</p>
56
+ <p>Event Types: {eventTypes.length}</p>
57
+ </div>
58
+ );
59
+ }
60
+ ```
61
+
62
+ ### Feature-Based Navigation
63
+
64
+ ```tsx
65
+ import { useHasFeature } from '@/hooks';
66
+
67
+ function Nav() {
68
+ return (
69
+ <nav>
70
+ <a href="/">Home</a>
71
+ {useHasFeature('blog') && <a href="/blog">Blog</a>}
72
+ {useHasFeature('shop') && <a href="/shop">Shop</a>}
73
+ {useHasFeature('portfolio') && <a href="/portfolio">Portfolio</a>}
74
+ </nav>
75
+ );
76
+ }
77
+ ```
78
+
79
+ ### Server-Side (Astro)
80
+
81
+ ```astro
82
+ ---
83
+ import { ConvexHttpClient } from 'convex/browser';
84
+ import { api } from '@/convex/_generated/api';
85
+
86
+ const convex = new ConvexHttpClient(import.meta.env.PUBLIC_CONVEX_URL);
87
+ const ontology = await convex.query(api.queries.ontology.getOntology);
88
+ ---
89
+
90
+ <h1>Features: {ontology.features.join(', ')}</h1>
91
+ ```
92
+
93
+ ## Available Hooks
94
+
95
+ ```tsx
96
+ // Single feature check (most efficient)
97
+ useHasFeature('blog') // boolean
98
+
99
+ // Get specific type arrays
100
+ useThingTypes() // ThingType[]
101
+ useConnectionTypes() // ConnectionType[]
102
+ useEventTypes() // EventType[]
103
+ useEnabledFeatures() // string[]
104
+
105
+ // Get metadata
106
+ useOntologyMetadata() // { features, counts, generatedAt }
107
+
108
+ // Get feature breakdown (what each feature provides)
109
+ useFeatureBreakdown() // { core: {...}, blog: {...}, etc }
110
+
111
+ // Get everything
112
+ useOntology() // { ontology, features, thingTypes, ..., hasFeature(), isLoading }
113
+ ```
114
+
115
+ ## Backend Queries
116
+
117
+ ```typescript
118
+ // From CLI or server
119
+ import { api } from './convex/_generated/api';
120
+
121
+ await convex.query(api.queries.ontology.getOntology);
122
+ await convex.query(api.queries.ontology.getMetadata);
123
+ await convex.query(api.queries.ontology.hasFeature, { feature: 'blog' });
124
+ await convex.query(api.queries.ontology.getThingTypes);
125
+ await convex.query(api.queries.ontology.getConnectionTypes);
126
+ await convex.query(api.queries.ontology.getEventTypes);
127
+ await convex.query(api.queries.ontology.getEnabledFeatures);
128
+ await convex.query(api.queries.ontology.getFeatureBreakdown);
129
+ ```
130
+
131
+ ## Demo Component
132
+
133
+ ```tsx
134
+ import { OntologyExplorer } from '@/components/features/OntologyExplorer';
135
+
136
+ // Shows complete ontology breakdown
137
+ <OntologyExplorer client:load />
138
+ ```
139
+
140
+ ## Current Composition
141
+
142
+ **Features:** core, blog, portfolio, shop
143
+
144
+ **15 Thing Types:**
145
+ page, user, file, link, note, blog_post, blog_category, project, case_study, product, product_variant, shopping_cart, order, discount_code, payment
146
+
147
+ **11 Connection Types:**
148
+ created_by, updated_by, viewed_by, favorited_by, posted_in, belongs_to_portfolio, purchased, in_cart, variant_of, ordered, paid_for
149
+
150
+ **18 Event Types:**
151
+ thing_created, thing_updated, thing_deleted, thing_viewed, blog_post_published, blog_post_viewed, project_viewed, product_added_to_cart, cart_updated, cart_abandoned, order_placed, order_fulfilled, order_shipped, order_delivered, payment_processed, payment_failed, product_viewed, discount_applied
152
+
153
+ ## Files
154
+
155
+ **Backend:**
156
+ - `/backend/convex/queries/ontology.ts` - Query endpoint
157
+ - `/backend/convex/types/ontology.ts` - Generated types
158
+
159
+ **Frontend:**
160
+ - `/web/src/hooks/useOntology.ts` - React hooks
161
+ - `/web/src/components/features/OntologyExplorer.tsx` - Demo component
162
+
163
+ **Docs:**
164
+ - `/backend/ONTOLOGY_QUERIES_EXAMPLE.md` - 30+ examples
165
+ - `/ONTOLOGY_DISCOVERY_IMPLEMENTATION.md` - Complete guide
166
+
167
+ ## Best Practices
168
+
169
+ 1. Use `useHasFeature('blog')` for single checks
170
+ 2. Use `useOntology()` when you need multiple properties
171
+ 3. Always handle `isLoading` state
172
+ 4. Memoize feature checks in complex components
173
+ 5. Use type safety: `ThingType`, `ConnectionType`, `EventType`
174
+
175
+ ## Common Patterns
176
+
177
+ **Conditional Rendering:**
178
+ ```tsx
179
+ {hasFeature('blog') && <BlogSection />}
180
+ ```
181
+
182
+ **Dynamic Forms:**
183
+ ```tsx
184
+ const types = useThingTypes();
185
+ <select>{types.map(t => <option>{t}</option>)}</select>
186
+ ```
187
+
188
+ **Feature Gates:**
189
+ ```tsx
190
+ if (!hasFeature('shop')) return <UpgradePrompt />;
191
+ ```
192
+
193
+ **Multi-Feature Checks:**
194
+ ```tsx
195
+ const hasContent = useMemo(
196
+ () => features.some(f => ['blog', 'portfolio'].includes(f)),
197
+ [features]
198
+ );
199
+ ```
200
+
201
+ ---
202
+
203
+ **That's it! Your UI now discovers features at runtime. No hardcoded flags needed.**