oneie 3.6.7 → 3.6.11

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 (165) hide show
  1. package/.claude/agents/agent-backend.md +83 -0
  2. package/.claude/agents/agent-designer.md +97 -0
  3. package/.claude/agents/agent-director.md +118 -7
  4. package/.claude/agents/agent-documenter.md +93 -0
  5. package/.claude/agents/agent-frontend.md +96 -0
  6. package/.claude/agents/agent-ops.md +182 -25
  7. package/.claude/agents/agent-problem-solver.md +166 -0
  8. package/.claude/agents/agent-quality.md +127 -0
  9. package/.claude/commands/build.md +293 -0
  10. package/.claude/commands/cascade.md +231 -127
  11. package/.claude/commands/mcp-toggle.md +93 -0
  12. package/.claude/commands/one.md +198 -116
  13. package/.claude/commands/plan.md +394 -80
  14. package/.claude/commands/release.md +41 -19
  15. package/.claude/commands/server.md +2 -0
  16. package/.claude/hooks/root-cleanup.py +75 -0
  17. package/.claude/skills/INDEX.md +523 -0
  18. package/.claude/skills/REGISTRY.md +529 -0
  19. package/.claude/skills/agent-backend-create-mutation.md +319 -0
  20. package/.claude/skills/agent-designer-create-wireframe.md +341 -0
  21. package/.claude/skills/agent-frontend-create-page.md +413 -0
  22. package/.claude/skills/agents/README.md +238 -0
  23. package/dist/clone-web.js +1 -1
  24. package/dist/clone-web.js.map +1 -1
  25. package/folders.yaml +1 -1
  26. package/one/.obsidian/workspace.json +38 -38
  27. package/one/connections/api/queries-reference.md +842 -0
  28. package/one/connections/api-reference.md +1011 -0
  29. package/one/connections/integration-examples.md +875 -0
  30. package/one/connections/integration-guide.md +869 -0
  31. package/one/connections/integration-phase2.md +736 -0
  32. package/one/events/API_ROUTES_FIXES_SUMMARY.md +262 -0
  33. package/one/events/ASTRO-INTEGRATION-EXAMPLES.md +636 -0
  34. package/one/events/BEFORE_AFTER_COMPARISON.md +960 -0
  35. package/one/events/CONNECTIONS_DEMO.md +501 -0
  36. package/one/events/DELIVERABLES.md +432 -0
  37. package/one/events/DEMO-GROUPS-PAGE.md +392 -0
  38. package/one/events/DEMO-TESTING-SUMMARY.md +518 -0
  39. package/one/events/DEMO_COMPONENTS.md +487 -0
  40. package/one/events/DEMO_HOOKS_INDEX.md +334 -0
  41. package/one/events/DEMO_INFRASTRUCTURE.md +905 -0
  42. package/one/events/DEMO_INFRASTRUCTURE_SUMMARY.md +570 -0
  43. package/one/events/DEMO_INTEGRATION_CHECKLIST.md +431 -0
  44. package/one/events/DEMO_QUICK_REFERENCE.md +441 -0
  45. package/one/events/DEMO_SETUP.md +476 -0
  46. package/one/events/EFFECT_TS_API_PATTERN.md +478 -0
  47. package/one/events/GROUPS_DEMO_IMPLEMENTATION.md +414 -0
  48. package/one/events/HOOKS-DEMO.md +441 -0
  49. package/one/events/ONTOLOGY-HOOKS-README.md +700 -0
  50. package/one/events/ONTOLOGY-INTEGRATION-MANIFEST.md +365 -0
  51. package/one/events/QA-CHECKLIST.md +674 -0
  52. package/one/events/QUICK-START-ONTOLOGY.md +408 -0
  53. package/one/events/SEARCH_DEMO_CODE_REFERENCE.md +639 -0
  54. package/one/events/SEARCH_DEMO_DELIVERY.md +415 -0
  55. package/one/events/SEARCH_DEMO_SUMMARY.md +303 -0
  56. package/one/events/SEARCH_DEMO_VISUAL_GUIDE.md +381 -0
  57. package/one/events/TEST-PLAN-INDEX.md +346 -0
  58. package/one/events/TEST-PLAN.md +1417 -0
  59. package/one/events/TESTING-DELIVERY.txt +372 -0
  60. package/one/events/TRANSITIONS-QUICK-START.md +141 -0
  61. package/one/events/TYPESCRIPT_FIXES.md +152 -0
  62. package/one/events/TYPESCRIPT_FIXES_COMPLETE.txt +412 -0
  63. package/one/events/TYPESCRIPT_FIXES_INDEX.md +341 -0
  64. package/one/events/VIEW-TRANSITIONS.md +428 -0
  65. package/one/events/backend-integration-tests.md +606 -0
  66. package/one/events/backend-structure-diagram.txt +393 -0
  67. package/one/events/backend-structure-summary.txt +269 -0
  68. package/one/events/cloudflare-pages-infrastructure-setup.md +264 -0
  69. package/one/events/convex-analysis-index.md +304 -0
  70. package/one/events/convex-structure-analysis.md +700 -0
  71. package/one/events/design-spec-complete.md +208 -0
  72. package/one/events/ontology-test-examples.md +562 -0
  73. package/one/events/phase1-backend-implementation-complete.md +518 -0
  74. package/one/events/test-dashboard.md +345 -0
  75. package/one/events/test-index.md +361 -0
  76. package/one/events/test-report-ontology.md +582 -0
  77. package/one/events/testing-summary.md +344 -0
  78. package/one/groups/features.md +2878 -0
  79. package/one/groups/strategy copy.md +869 -0
  80. package/one/knowledge/backend-api-reference.md +710 -0
  81. package/one/knowledge/documentation-summary.md +285 -0
  82. package/one/knowledge/lessons-learned.md +294 -4
  83. package/one/knowledge/ontology-visual-guide.md +360 -0
  84. package/one/knowledge/ontology.md +9 -17
  85. package/one/things/demo-accessibility-animations.md +999 -0
  86. package/one/things/demo-components.md +1304 -0
  87. package/one/things/demo-design-summary.md +629 -0
  88. package/one/things/demo-design-system.md +919 -0
  89. package/one/things/demo-page-layouts.md +989 -0
  90. package/one/things/designs/accessibility-audit.md +790 -0
  91. package/one/things/designs/component-specifications.md +757 -0
  92. package/one/things/designs/design-overview.md +318 -0
  93. package/one/things/designs/design-tokens.md +414 -0
  94. package/one/things/designs/wireframes-dashboard.md +653 -0
  95. package/one/things/docs/api-requests.md +923 -0
  96. package/one/things/features/0 All Features.md +2 -0
  97. package/one/things/implementation/backend-guide.md +412 -0
  98. package/one/things/plans/2-backend-agnostic-frontend.md +11 -8
  99. package/one/things/plans/ai-elements.md +1259 -0
  100. package/one/things/plans/ai-integration.md +947 -0
  101. package/one/things/plans/ai-sdk.md +761 -0
  102. package/one/things/plans/app.md +1 -1
  103. package/one/things/plans/architecture-summary.md +283 -0
  104. package/one/things/plans/async-ai-agents.md +215 -0
  105. package/one/things/plans/backend-agnostic-frontend.md +11 -6
  106. package/one/things/plans/backend-cleanup-quickstart.md +346 -0
  107. package/one/things/plans/backend-ontology-conformance.md +416 -0
  108. package/one/things/plans/backend-status.md +541 -0
  109. package/one/things/plans/backend-structure.md +799 -0
  110. package/one/things/plans/backend-target-structure.md +438 -0
  111. package/one/things/plans/backend.md +1133 -0
  112. package/one/things/plans/better-auth-any-backend.md +11 -11
  113. package/one/things/plans/cli-updates-required.md +280 -0
  114. package/one/things/plans/complete-step-by-step.md +1302 -0
  115. package/one/things/plans/convex-agents.md +1005 -0
  116. package/one/things/plans/deployment-architecture.md +426 -0
  117. package/one/things/plans/development-plan.md +1220 -0
  118. package/one/things/plans/effect.md +808 -48
  119. package/one/things/plans/integrate-frontend-and-backend.md +579 -0
  120. package/one/things/plans/mcp-clear-context-prompt.md +60 -0
  121. package/one/things/plans/mcp-simple.md +228 -0
  122. package/one/things/plans/one.md +8 -7
  123. package/one/things/plans/ontology-6-dimensions.md +20 -14
  124. package/one/things/plans/quick-wins.md +1273 -0
  125. package/one/things/plans/readme-backend-cleanup.md +361 -0
  126. package/one/things/plans/separate-demo.md +830 -0
  127. package/one/things/plans/separate.md +3 -3
  128. package/one/things/plans/sequence.md +1897 -0
  129. package/one/things/plans/sync-checklist.md +321 -0
  130. package/one/things/plans/unified-implementation-plan.md +3 -3
  131. package/one/things/plans/update-demos.md +513 -0
  132. package/package.json +1 -1
  133. package/.claude/agents/backend-specialist.md +0 -169
  134. package/.claude/agents/designer.md +0 -216
  135. package/.claude/agents/frontend-specialist.md +0 -236
  136. package/.claude/commands/done.md +0 -35
  137. package/.claude/commands/infer.md +0 -138
  138. package/.claude/commands/next.md +0 -53
  139. package/.claude/commands/one copy.md +0 -565
  140. package/.claude/commands/one-template.md +0 -106
  141. package/.claude/commands/one-v1.md +0 -609
  142. package/.claude/hooks/__pycache__/knowledge-post.cpython-313.pyc +0 -0
  143. package/.claude/hooks/__pycache__/knowledge-pre.cpython-313.pyc +0 -0
  144. package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
  145. package/one/groups/nine-padel-customers.md +0 -138
  146. package/one/groups/nine-padel-data-structure.md +0 -167
  147. package/one/groups/nine-padel-ontology-specification.md +0 -359
  148. package/one/groups/nine-padel-ontology.md +0 -143
  149. package/one/groups/nine-padel-strategy.md +0 -234
  150. package/one/groups/nine-padel.md +0 -211
  151. package/one/groups/nine-padle-contents.baked.md +0 -1252
  152. package/one/groups/nine-padle-contents.md +0 -6
  153. package/one/things/features/1-1-agent-prompts/design.md +0 -470
  154. package/one/things/features/1-1-agent-prompts/tests.md +0 -264
  155. package/one/things/features/1-2-yaml-orchestrator/design.md +0 -497
  156. package/one/things/features/1-2-yaml-orchestrator/tests.md +0 -227
  157. package/one/things/features/1-3-event-coordination/design.md +0 -544
  158. package/one/things/features/1-3-event-coordination/tests.md +0 -223
  159. package/one/things/features/1-4-knowledge-management/design.md +0 -609
  160. package/one/things/features/1-4-knowledge-management/tests.md +0 -195
  161. package/one/things/features/1-5-quality-loops/design.md +0 -797
  162. package/one/things/features/1-5-quality-loops/tests.md +0 -212
  163. package/one/things/features/1-6-numbering-structure/design.md +0 -610
  164. package/one/things/features/1-6-numbering-structure/tests.md +0 -213
  165. package/one/things/features/dataprovider-interface/1-tests.md +0 -1522
@@ -0,0 +1,636 @@
1
+ # Astro Integration Examples
2
+
3
+ This document provides practical examples of integrating the 6-dimension ontology with Astro pages and React components.
4
+
5
+ ## Directory Structure
6
+
7
+ ```
8
+ web/src/
9
+ ├── hooks/ontology/ # React hooks for all 6 dimensions
10
+ │ ├── useProvider.ts # Backend provider access
11
+ │ ├── useGroup.ts # Groups (organizations)
12
+ │ ├── usePerson.ts # People (users, roles)
13
+ │ ├── useThing.ts # Things (entities)
14
+ │ ├── useConnection.ts # Connections (relationships)
15
+ │ ├── useEvent.ts # Events (audit trail)
16
+ │ ├── useSearch.ts # Knowledge (search, embeddings)
17
+ │ └── index.ts # Barrel export
18
+ │
19
+ ├── lib/ontology/
20
+ │ ├── features.ts # Feature flags
21
+ │ ├── astro-helpers.ts # Astro SSR helpers
22
+ │ └── ...other ontology libs
23
+ │
24
+ └── pages/
25
+ ├── [group]/
26
+ │ ├── index.astro # Group overview
27
+ │ ├── things/
28
+ │ │ ├── index.astro # List things
29
+ │ │ └── [id].astro # Thing detail page
30
+ │ ├── connections.astro # Relationship viewer
31
+ │ ├── events.astro # Activity feed
32
+ │ └── members.astro # Group members (if auth enabled)
33
+ │
34
+ └── knowledge/
35
+ ├── search/
36
+ │ └── [query].astro # Search results page
37
+ └── labels/
38
+ └── [label].astro # Things by label
39
+ ```
40
+
41
+ ## Example 1: Entity Listing Page
42
+
43
+ **File:** `src/pages/things/index.astro`
44
+
45
+ ```astro
46
+ ---
47
+ // Server-side fetching with fallback
48
+ import { getThings } from '@/lib/ontology/astro-helpers';
49
+ import { isFeatureEnabled } from '@/lib/ontology/features';
50
+ import Layout from '@/layouts/Layout.astro';
51
+ import ThingCard from '@/components/ontology/ThingCard.tsx';
52
+
53
+ // Get query parameters
54
+ const type = Astro.url.searchParams.get('type');
55
+ const status = Astro.url.searchParams.get('status') || 'published';
56
+
57
+ // Fetch things (tries provider, falls back to empty)
58
+ const things = await getThings({
59
+ type: type || undefined,
60
+ status,
61
+ limit: 50
62
+ });
63
+
64
+ // Check if search is available
65
+ const hasSearch = isFeatureEnabled('search');
66
+ ---
67
+
68
+ <Layout title="Things">
69
+ <div class="container">
70
+ <h1>All Things</h1>
71
+
72
+ {/* Search box if available */}
73
+ {hasSearch && (
74
+ <SearchBox client:load type={type} />
75
+ )}
76
+
77
+ {/* Thing listing */}
78
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
79
+ {things.map(thing => (
80
+ <ThingCard
81
+ key={thing._id}
82
+ thing={thing}
83
+ client:load
84
+ />
85
+ ))}
86
+ </div>
87
+
88
+ {things.length === 0 && (
89
+ <div class="text-center py-12">
90
+ <p class="text-muted-foreground">No things found</p>
91
+ </div>
92
+ )}
93
+ </div>
94
+ </Layout>
95
+ ```
96
+
97
+ ## Example 2: Entity Detail Page with Dynamic Routing
98
+
99
+ **File:** `src/pages/things/[id].astro`
100
+
101
+ ```astro
102
+ ---
103
+ // Server-side data fetching
104
+ import { getThingWithFallback, getRelatedThings } from '@/lib/ontology/astro-helpers';
105
+ import { getEntry } from 'astro:content';
106
+ import Layout from '@/layouts/Layout.astro';
107
+ import RelatedThings from '@/components/ontology/RelatedThings.tsx';
108
+
109
+ const { id } = Astro.params;
110
+
111
+ if (!id) {
112
+ return Astro.redirect('/things');
113
+ }
114
+
115
+ // Try to get thing from provider, fall back to markdown
116
+ const thing = await getThingWithFallback(id);
117
+
118
+ if (!thing) {
119
+ // Try content collection as fallback
120
+ const post = await getEntry('blog', id);
121
+ if (!post) {
122
+ return Astro.redirect('/404');
123
+ }
124
+
125
+ // Use post data instead
126
+ const { Content } = await post.render();
127
+ const { title, description } = post.data;
128
+
129
+ return (
130
+ <Layout title={title}>
131
+ <article>
132
+ <h1>{title}</h1>
133
+ <p class="text-muted-foreground">{description}</p>
134
+ <Content />
135
+ </article>
136
+ </Layout>
137
+ );
138
+ }
139
+
140
+ // Validate thing status (only show published publicly)
141
+ if (thing.status !== 'published' && !isAdmin) {
142
+ return Astro.redirect('/404');
143
+ }
144
+
145
+ // Get related things
146
+ const related = await getRelatedThings(thing._id, 'references');
147
+ ---
148
+
149
+ <Layout title={thing.name}>
150
+ <article>
151
+ <header>
152
+ <h1>{thing.name}</h1>
153
+ <p class="text-muted-foreground">
154
+ {thing.properties.description}
155
+ </p>
156
+ </header>
157
+
158
+ <main>
159
+ {/* Render type-specific content */}
160
+ {thing.type === 'course' && (
161
+ <CourseContent course={thing} client:load />
162
+ )}
163
+
164
+ {thing.type === 'blog_post' && (
165
+ <div set:html={thing.properties.content} />
166
+ )}
167
+
168
+ {/* Generic fallback */}
169
+ {thing.type !== 'course' && thing.type !== 'blog_post' && (
170
+ <div>
171
+ <h2>Details</h2>
172
+ <pre>{JSON.stringify(thing.properties, null, 2)}</pre>
173
+ </div>
174
+ )}
175
+ </main>
176
+
177
+ {/* Related things */}
178
+ {related.length > 0 && (
179
+ <RelatedThings
180
+ items={related}
181
+ client:load
182
+ />
183
+ )}
184
+ </article>
185
+ </Layout>
186
+ ```
187
+
188
+ ## Example 3: Search Page with Results
189
+
190
+ **File:** `src/pages/search/[query].astro`
191
+
192
+ ```astro
193
+ ---
194
+ // Search results page
195
+ import { searchThings } from '@/lib/ontology/astro-helpers';
196
+ import { isFeatureEnabled } from '@/lib/ontology/features';
197
+ import Layout from '@/layouts/Layout.astro';
198
+ import SearchBox from '@/components/ontology/SearchBox.tsx';
199
+ import SearchResult from '@/components/ontology/SearchResult.tsx';
200
+
201
+ const { query } = Astro.params;
202
+ const type = Astro.url.searchParams.get('type');
203
+
204
+ if (!isFeatureEnabled('search')) {
205
+ return Astro.redirect('/');
206
+ }
207
+
208
+ const results = await searchThings(query, type || undefined);
209
+ ---
210
+
211
+ <Layout title={`Search Results for "${query}"`}>
212
+ <div class="container">
213
+ <h1>Search Results</h1>
214
+
215
+ {/* Search box (stick to top) */}
216
+ <div class="mb-8">
217
+ <SearchBox client:load defaultQuery={query} />
218
+ </div>
219
+
220
+ {/* Results */}
221
+ <div class="space-y-4">
222
+ {results.map(result => (
223
+ <SearchResult
224
+ key={result._id}
225
+ result={result}
226
+ />
227
+ ))}
228
+ </div>
229
+
230
+ {/* No results */}
231
+ {results.length === 0 && (
232
+ <div class="text-center py-12">
233
+ <p class="text-muted-foreground text-lg">
234
+ No results found for "{query}"
235
+ </p>
236
+ <p class="text-sm">Try a different search term</p>
237
+ </div>
238
+ )}
239
+ </div>
240
+ </Layout>
241
+ ```
242
+
243
+ ## Example 4: Group Overview with Multi-Tenant Support
244
+
245
+ **File:** `src/pages/groups/[id].astro`
246
+
247
+ ```astro
248
+ ---
249
+ // Group detail page with member management
250
+ import { getGroup, getThings } from '@/lib/ontology/astro-helpers';
251
+ import { isFeatureEnabled } from '@/lib/ontology/features';
252
+ import Layout from '@/layouts/Layout.astro';
253
+ import GroupHeader from '@/components/ontology/GroupHeader.tsx';
254
+ import GroupMembers from '@/components/ontology/GroupMembers.tsx';
255
+ import GroupThings from '@/components/ontology/GroupThings.tsx';
256
+
257
+ const { id: groupId } = Astro.params;
258
+
259
+ if (!isFeatureEnabled('groups')) {
260
+ return Astro.redirect('/');
261
+ }
262
+
263
+ const group = await getGroup(groupId);
264
+
265
+ if (!group) {
266
+ return Astro.redirect('/404');
267
+ }
268
+
269
+ // Get things in this group
270
+ const things = await getThings({
271
+ limit: 20
272
+ });
273
+ ---
274
+
275
+ <Layout title={group.name}>
276
+ <div>
277
+ {/* Group header */}
278
+ <GroupHeader group={group} client:load />
279
+
280
+ <div class="container grid grid-cols-1 lg:grid-cols-3 gap-8">
281
+ {/* Main content */}
282
+ <div class="lg:col-span-2">
283
+ <h2>Things in {group.name}</h2>
284
+ <GroupThings
285
+ things={things}
286
+ groupId={groupId}
287
+ client:load
288
+ />
289
+ </div>
290
+
291
+ {/* Sidebar */}
292
+ <div>
293
+ {/* Members (if auth enabled) */}
294
+ {isFeatureEnabled('permissions') && (
295
+ <GroupMembers
296
+ groupId={groupId}
297
+ client:load
298
+ />
299
+ )}
300
+
301
+ {/* Group details */}
302
+ <div class="bg-card p-6 rounded-lg">
303
+ <h3>Group Details</h3>
304
+ <dl class="space-y-2">
305
+ <div>
306
+ <dt class="font-semibold">Type</dt>
307
+ <dd>{group.type}</dd>
308
+ </div>
309
+ {group.properties.plan && (
310
+ <div>
311
+ <dt class="font-semibold">Plan</dt>
312
+ <dd>{group.properties.plan}</dd>
313
+ </div>
314
+ )}
315
+ {group.properties.description && (
316
+ <div>
317
+ <dt class="font-semibold">Description</dt>
318
+ <dd>{group.properties.description}</dd>
319
+ </div>
320
+ )}
321
+ </dl>
322
+ </div>
323
+ </div>
324
+ </div>
325
+ </div>
326
+ </Layout>
327
+ ```
328
+
329
+ ## Example 5: Activity Feed / Events Page
330
+
331
+ **File:** `src/pages/activity.astro`
332
+
333
+ ```astro
334
+ ---
335
+ // Activity/events feed
336
+ import { getRecentEvents } from '@/lib/ontology/astro-helpers';
337
+ import { isFeatureEnabled } from '@/lib/ontology/features';
338
+ import Layout from '@/layouts/Layout.astro';
339
+ import EventCard from '@/components/ontology/EventCard.tsx';
340
+
341
+ if (!isFeatureEnabled('events')) {
342
+ return Astro.redirect('/');
343
+ }
344
+
345
+ // Fetch recent events
346
+ const events = await getRecentEvents(50);
347
+ ---
348
+
349
+ <Layout title="Activity Feed">
350
+ <div class="container max-w-2xl">
351
+ <h1>Recent Activity</h1>
352
+
353
+ {/* Real-time updates via React island */}
354
+ <div class="space-y-4">
355
+ <ActivityFeed
356
+ initialEvents={events}
357
+ client:load
358
+ />
359
+ </div>
360
+ </div>
361
+ </Layout>
362
+
363
+ {/* Import client component for real-time updates */}
364
+ import ActivityFeed from '@/components/ontology/ActivityFeed.tsx';
365
+ ```
366
+
367
+ ## Example 6: React Component with Hooks
368
+
369
+ **File:** `src/components/ontology/ThingCard.tsx`
370
+
371
+ ```typescript
372
+ import { useThing } from '@/hooks/ontology';
373
+ import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card';
374
+ import { Button } from '@/components/ui/button';
375
+
376
+ interface ThingCardProps {
377
+ thing: {
378
+ _id: string;
379
+ name: string;
380
+ type: string;
381
+ properties: Record<string, any>;
382
+ };
383
+ }
384
+
385
+ export default function ThingCard({ thing }: ThingCardProps) {
386
+ const { update, remove, loading, error } = useThing();
387
+
388
+ const handleUpdate = async () => {
389
+ await update(thing._id as any, {
390
+ properties: {
391
+ ...thing.properties,
392
+ updatedAt: Date.now()
393
+ }
394
+ });
395
+ };
396
+
397
+ return (
398
+ <Card>
399
+ <CardHeader>
400
+ <CardTitle>{thing.name}</CardTitle>
401
+ </CardHeader>
402
+ <CardContent>
403
+ <p class="text-sm text-muted-foreground">
404
+ {thing.type}
405
+ </p>
406
+
407
+ <div class="mt-4 flex gap-2">
408
+ <Button
409
+ size="sm"
410
+ onClick={handleUpdate}
411
+ disabled={loading}
412
+ >
413
+ {loading ? 'Updating...' : 'Update'}
414
+ </Button>
415
+ <Button
416
+ size="sm"
417
+ variant="outline"
418
+ onClick={() => remove(thing._id as any)}
419
+ disabled={loading}
420
+ >
421
+ Delete
422
+ </Button>
423
+ </div>
424
+
425
+ {error && (
426
+ <div class="text-sm text-red-600 mt-2">
427
+ Error: {String(error)}
428
+ </div>
429
+ )}
430
+ </CardContent>
431
+ </Card>
432
+ );
433
+ }
434
+ ```
435
+
436
+ ## Example 7: Protected Route with Authentication
437
+
438
+ **File:** `src/pages/dashboard.astro`
439
+
440
+ ```astro
441
+ ---
442
+ // Protected dashboard page
443
+ import { getCurrentUser } from '@/lib/ontology/astro-helpers';
444
+ import { isFeatureEnabled, assertFeatureEnabled } from '@/lib/ontology/features';
445
+ import Layout from '@/layouts/Layout.astro';
446
+
447
+ // Assert auth is enabled
448
+ try {
449
+ assertFeatureEnabled('auth');
450
+ } catch (error) {
451
+ return Astro.redirect('/');
452
+ }
453
+
454
+ // Get current user
455
+ const user = await getCurrentUser(Astro.request);
456
+
457
+ // Redirect to login if not authenticated
458
+ if (!user) {
459
+ return Astro.redirect('/account/signin');
460
+ }
461
+ ---
462
+
463
+ <Layout title="Dashboard">
464
+ <div class="container">
465
+ <h1>Welcome, {user.name}!</h1>
466
+
467
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
468
+ {/* User stats */}
469
+ <DashboardCard
470
+ title="Courses"
471
+ value={user.properties.courseCount || 0}
472
+ client:load
473
+ />
474
+ <DashboardCard
475
+ title="Tokens"
476
+ value={user.properties.tokenBalance || 0}
477
+ client:load
478
+ />
479
+ <DashboardCard
480
+ title="Following"
481
+ value={user.properties.followingCount || 0}
482
+ client:load
483
+ />
484
+ </div>
485
+
486
+ {/* User content */}
487
+ <section class="mt-8">
488
+ <h2>My Courses</h2>
489
+ <UserCourses
490
+ userId={user._id}
491
+ client:load
492
+ />
493
+ </section>
494
+ </div>
495
+ </Layout>
496
+
497
+ import DashboardCard from '@/components/ontology/DashboardCard.tsx';
498
+ import UserCourses from '@/components/ontology/UserCourses.tsx';
499
+ ```
500
+
501
+ ## Example 8: Conditional Rendering Based on Features
502
+
503
+ **File:** `src/components/Navigation.astro`
504
+
505
+ ```astro
506
+ ---
507
+ // Navigation with conditional feature-based rendering
508
+ import { isFeatureEnabled } from '@/lib/ontology/features';
509
+ import NavLink from '@/components/NavLink.astro';
510
+ ---
511
+
512
+ <nav class="border-b">
513
+ <div class="container flex items-center gap-6">
514
+ <NavLink href="/">Home</NavLink>
515
+
516
+ {/* Blog (always visible) */}
517
+ <NavLink href="/blog">Blog</NavLink>
518
+
519
+ {/* Search (only if search enabled) */}
520
+ {isFeatureEnabled('search') && (
521
+ <NavLink href="/search">Search</NavLink>
522
+ )}
523
+
524
+ {/* Groups (only if multi-tenant enabled) */}
525
+ {isFeatureEnabled('groups') && (
526
+ <NavLink href="/groups">Organizations</NavLink>
527
+ )}
528
+
529
+ {/* Auth links (only if auth enabled) */}
530
+ {isFeatureEnabled('auth') && (
531
+ <>
532
+ <NavLink href="/account/signin" class="ml-auto">
533
+ Sign In
534
+ </NavLink>
535
+ <NavLink href="/account/signup">
536
+ Sign Up
537
+ </NavLink>
538
+ </>
539
+ )}
540
+ </div>
541
+ </nav>
542
+ ```
543
+
544
+ ## Feature Flag Configuration
545
+
546
+ ### Environment Variables
547
+
548
+ ```bash
549
+ # Frontend-only mode (no backend)
550
+ VITE_FEATURE_AUTH=false
551
+ VITE_FEATURE_GROUPS=false
552
+
553
+ # Enable specific features
554
+ VITE_FEATURE_SEARCH=true
555
+ VITE_FEATURE_EVENTS=true
556
+
557
+ # Or use JSON config
558
+ VITE_FEATURES='{"auth":true,"groups":true,"realtime":true}'
559
+ ```
560
+
561
+ ### Accessing Features in Components
562
+
563
+ ```typescript
564
+ import { features, isFeatureEnabled, getFeatureMode } from '@/lib/ontology/features';
565
+
566
+ // Direct check
567
+ if (features.auth) {
568
+ // Show auth UI
569
+ }
570
+
571
+ // Function check
572
+ if (isFeatureEnabled('groups')) {
573
+ // Show multi-tenant UI
574
+ }
575
+
576
+ // Get operating mode
577
+ const mode = getFeatureMode();
578
+ if (mode === 'full') {
579
+ // Use all features
580
+ }
581
+ ```
582
+
583
+ ## Error Handling & Fallbacks
584
+
585
+ ### Provider Fallback Pattern
586
+
587
+ ```astro
588
+ ---
589
+ // Graceful degradation when provider unavailable
590
+ import { getThingWithFallback } from '@/lib/ontology/astro-helpers';
591
+ import { getEntry } from 'astro:content';
592
+
593
+ const thing = await getThingWithFallback(id);
594
+
595
+ if (!thing) {
596
+ // Fall back to markdown
597
+ const post = await getEntry('blog', id);
598
+ if (!post) return Astro.redirect('/404');
599
+ // Use post data...
600
+ }
601
+ ---
602
+ ```
603
+
604
+ ### Feature Check Pattern
605
+
606
+ ```astro
607
+ ---
608
+ import { isFeatureEnabled, assertFeatureEnabled } from '@/lib/ontology/features';
609
+
610
+ // Soft check - continue with degradation
611
+ if (!isFeatureEnabled('search')) {
612
+ // Show limited UI without search
613
+ }
614
+
615
+ // Hard check - block if feature required
616
+ assertFeatureEnabled('auth'); // Throws if not enabled
617
+ ---
618
+ ```
619
+
620
+ ## Best Practices
621
+
622
+ 1. **Server-side Fetching**: Use Astro page frontmatter for data fetching
623
+ 2. **Fallback Content**: Always have markdown/content collection fallback
624
+ 3. **Feature Checks**: Use feature flags for conditional rendering
625
+ 4. **Client Components**: Use `client:load` only for interactive elements
626
+ 5. **Error Handling**: Gracefully degrade when provider unavailable
627
+ 6. **Caching**: Use appropriate cache headers for static/dynamic content
628
+ 7. **Type Safety**: Leverage TypeScript for type-safe queries
629
+
630
+ ## Performance Optimization
631
+
632
+ - Static generation: Generate common pages at build time
633
+ - Incremental Static Regeneration (ISR): Revalidate periodically
634
+ - Code splitting: Lazy load heavy components with `client:idle`
635
+ - Image optimization: Use Astro `<Image>` component
636
+ - Caching: Set appropriate cache headers per page type