oneie 3.6.6 → 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.
- package/.claude/agents/agent-backend.md +83 -0
- package/.claude/agents/agent-designer.md +97 -0
- package/.claude/agents/agent-director.md +118 -7
- package/.claude/agents/agent-documenter.md +93 -0
- package/.claude/agents/agent-frontend.md +96 -0
- package/.claude/agents/agent-ops.md +182 -25
- package/.claude/agents/agent-problem-solver.md +166 -0
- package/.claude/agents/agent-quality.md +127 -0
- package/.claude/commands/build.md +293 -0
- package/.claude/commands/cascade.md +231 -127
- package/.claude/commands/mcp-toggle.md +93 -0
- package/.claude/commands/onboard.md +179 -0
- package/.claude/commands/one.md +236 -516
- package/.claude/commands/plan.md +394 -80
- package/.claude/commands/release.md +41 -19
- package/.claude/commands/server.md +335 -0
- package/.claude/hooks/root-cleanup.py +75 -0
- package/.claude/skills/INDEX.md +523 -0
- package/.claude/skills/REGISTRY.md +529 -0
- package/.claude/skills/agent-backend-create-mutation.md +319 -0
- package/.claude/skills/agent-designer-create-wireframe.md +341 -0
- package/.claude/skills/agent-frontend-create-page.md +413 -0
- package/.claude/skills/agents/README.md +238 -0
- package/dist/clone-web.js +1 -1
- package/dist/clone-web.js.map +1 -1
- package/folders.yaml +1 -1
- package/one/.obsidian/workspace.json +38 -38
- package/one/connections/api/queries-reference.md +842 -0
- package/one/connections/api-reference.md +1011 -0
- package/one/connections/integration-examples.md +875 -0
- package/one/connections/integration-guide.md +869 -0
- package/one/connections/integration-phase2.md +736 -0
- package/one/events/API_ROUTES_FIXES_SUMMARY.md +262 -0
- package/one/events/ASTRO-INTEGRATION-EXAMPLES.md +636 -0
- package/one/events/BEFORE_AFTER_COMPARISON.md +960 -0
- package/one/events/CONNECTIONS_DEMO.md +501 -0
- package/one/events/DELIVERABLES.md +432 -0
- package/one/events/DEMO-GROUPS-PAGE.md +392 -0
- package/one/events/DEMO-TESTING-SUMMARY.md +518 -0
- package/one/events/DEMO_COMPONENTS.md +487 -0
- package/one/events/DEMO_HOOKS_INDEX.md +334 -0
- package/one/events/DEMO_INFRASTRUCTURE.md +905 -0
- package/one/events/DEMO_INFRASTRUCTURE_SUMMARY.md +570 -0
- package/one/events/DEMO_INTEGRATION_CHECKLIST.md +431 -0
- package/one/events/DEMO_QUICK_REFERENCE.md +441 -0
- package/one/events/DEMO_SETUP.md +476 -0
- package/one/events/EFFECT_TS_API_PATTERN.md +478 -0
- package/one/events/GROUPS_DEMO_IMPLEMENTATION.md +414 -0
- package/one/events/HOOKS-DEMO.md +441 -0
- package/one/events/ONTOLOGY-HOOKS-README.md +700 -0
- package/one/events/ONTOLOGY-INTEGRATION-MANIFEST.md +365 -0
- package/one/events/QA-CHECKLIST.md +674 -0
- package/one/events/QUICK-START-ONTOLOGY.md +408 -0
- package/one/events/SEARCH_DEMO_CODE_REFERENCE.md +639 -0
- package/one/events/SEARCH_DEMO_DELIVERY.md +415 -0
- package/one/events/SEARCH_DEMO_SUMMARY.md +303 -0
- package/one/events/SEARCH_DEMO_VISUAL_GUIDE.md +381 -0
- package/one/events/TEST-PLAN-INDEX.md +346 -0
- package/one/events/TEST-PLAN.md +1417 -0
- package/one/events/TESTING-DELIVERY.txt +372 -0
- package/one/events/TRANSITIONS-QUICK-START.md +141 -0
- package/one/events/TYPESCRIPT_FIXES.md +152 -0
- package/one/events/TYPESCRIPT_FIXES_COMPLETE.txt +412 -0
- package/one/events/TYPESCRIPT_FIXES_INDEX.md +341 -0
- package/one/events/VIEW-TRANSITIONS.md +428 -0
- package/one/events/backend-integration-tests.md +606 -0
- package/one/events/backend-structure-diagram.txt +393 -0
- package/one/events/backend-structure-summary.txt +269 -0
- package/one/events/cloudflare-pages-infrastructure-setup.md +264 -0
- package/one/events/convex-analysis-index.md +304 -0
- package/one/events/convex-structure-analysis.md +700 -0
- package/one/events/design-spec-complete.md +208 -0
- package/one/events/ontology-test-examples.md +562 -0
- package/one/events/phase1-backend-implementation-complete.md +518 -0
- package/one/events/test-dashboard.md +345 -0
- package/one/events/test-index.md +361 -0
- package/one/events/test-report-ontology.md +582 -0
- package/one/events/testing-summary.md +344 -0
- package/one/groups/features.md +2878 -0
- package/one/groups/strategy copy.md +869 -0
- package/one/knowledge/backend-api-reference.md +710 -0
- package/one/knowledge/documentation-summary.md +285 -0
- package/one/knowledge/lessons-learned.md +294 -4
- package/one/knowledge/ontology-visual-guide.md +360 -0
- package/one/knowledge/ontology.md +9 -17
- package/one/things/demo-accessibility-animations.md +999 -0
- package/one/things/demo-components.md +1304 -0
- package/one/things/demo-design-summary.md +629 -0
- package/one/things/demo-design-system.md +919 -0
- package/one/things/demo-page-layouts.md +989 -0
- package/one/things/designs/accessibility-audit.md +790 -0
- package/one/things/designs/component-specifications.md +757 -0
- package/one/things/designs/design-overview.md +318 -0
- package/one/things/designs/design-tokens.md +414 -0
- package/one/things/designs/wireframes-dashboard.md +653 -0
- package/one/things/docs/api-requests.md +923 -0
- package/one/things/features/0 All Features.md +2 -0
- package/one/things/implementation/backend-guide.md +412 -0
- package/one/things/plans/2-backend-agnostic-frontend.md +11 -8
- package/one/things/plans/ai-elements.md +1259 -0
- package/one/things/plans/ai-integration.md +947 -0
- package/one/things/plans/ai-sdk.md +761 -0
- package/one/things/plans/app.md +1 -1
- package/one/things/plans/architecture-summary.md +283 -0
- package/one/things/plans/async-ai-agents.md +215 -0
- package/one/things/plans/backend-agnostic-frontend.md +11 -6
- package/one/things/plans/backend-cleanup-quickstart.md +346 -0
- package/one/things/plans/backend-ontology-conformance.md +416 -0
- package/one/things/plans/backend-status.md +541 -0
- package/one/things/plans/backend-structure.md +799 -0
- package/one/things/plans/backend-target-structure.md +438 -0
- package/one/things/plans/backend.md +1133 -0
- package/one/things/plans/better-auth-any-backend.md +11 -11
- package/one/things/plans/cli-updates-required.md +280 -0
- package/one/things/plans/complete-step-by-step.md +1302 -0
- package/one/things/plans/convex-agents.md +1005 -0
- package/one/things/plans/deployment-architecture.md +426 -0
- package/one/things/plans/development-plan.md +1220 -0
- package/one/things/plans/effect.md +808 -48
- package/one/things/plans/integrate-frontend-and-backend.md +579 -0
- package/one/things/plans/mcp-clear-context-prompt.md +60 -0
- package/one/things/plans/mcp-simple.md +228 -0
- package/one/things/plans/one.md +8 -7
- package/one/things/plans/ontology-6-dimensions.md +20 -14
- package/one/things/plans/quick-wins.md +1273 -0
- package/one/things/plans/readme-backend-cleanup.md +361 -0
- package/one/things/plans/separate-demo.md +830 -0
- package/one/things/plans/separate.md +3 -3
- package/one/things/plans/sequence.md +1897 -0
- package/one/things/plans/sync-checklist.md +321 -0
- package/one/things/plans/unified-implementation-plan.md +3 -3
- package/one/things/plans/update-demos.md +513 -0
- package/package.json +1 -1
- package/.claude/agents/backend-specialist.md +0 -169
- package/.claude/agents/designer.md +0 -216
- package/.claude/agents/frontend-specialist.md +0 -236
- package/.claude/commands/done.md +0 -35
- package/.claude/commands/infer.md +0 -138
- package/.claude/commands/next.md +0 -53
- package/.claude/commands/one copy.md +0 -565
- package/.claude/commands/one-template.md +0 -106
- package/.claude/commands/one-v1.md +0 -609
- package/.claude/hooks/__pycache__/knowledge-post.cpython-313.pyc +0 -0
- package/.claude/hooks/__pycache__/knowledge-pre.cpython-313.pyc +0 -0
- package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
- package/one/groups/nine-padel-customers.md +0 -138
- package/one/groups/nine-padel-data-structure.md +0 -167
- package/one/groups/nine-padel-ontology-specification.md +0 -359
- package/one/groups/nine-padel-ontology.md +0 -143
- package/one/groups/nine-padel-strategy.md +0 -234
- package/one/groups/nine-padel.md +0 -211
- package/one/groups/nine-padle-contents.baked.md +0 -1252
- package/one/groups/nine-padle-contents.md +0 -6
- package/one/things/features/1-1-agent-prompts/design.md +0 -470
- package/one/things/features/1-1-agent-prompts/tests.md +0 -264
- package/one/things/features/1-2-yaml-orchestrator/design.md +0 -497
- package/one/things/features/1-2-yaml-orchestrator/tests.md +0 -227
- package/one/things/features/1-3-event-coordination/design.md +0 -544
- package/one/things/features/1-3-event-coordination/tests.md +0 -223
- package/one/things/features/1-4-knowledge-management/design.md +0 -609
- package/one/things/features/1-4-knowledge-management/tests.md +0 -195
- package/one/things/features/1-5-quality-loops/design.md +0 -797
- package/one/things/features/1-5-quality-loops/tests.md +0 -212
- package/one/things/features/1-6-numbering-structure/design.md +0 -610
- package/one/things/features/1-6-numbering-structure/tests.md +0 -213
- package/one/things/features/dataprovider-interface/1-tests.md +0 -1522
|
@@ -0,0 +1,579 @@
|
|
|
1
|
+
# Integration Plan: Frontend & Backend Separation with Effect-TS
|
|
2
|
+
|
|
3
|
+
**Status:** In Progress
|
|
4
|
+
**Version:** 1.0.0
|
|
5
|
+
**Date Created:** 2025-10-25
|
|
6
|
+
**Owner:** Engineering Team
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Executive Summary
|
|
11
|
+
|
|
12
|
+
This document outlines the architecture for complete separation of frontend (Astro + React) and backend (Convex) using Effect-TS as the integration layer. The design allows:
|
|
13
|
+
|
|
14
|
+
1. **Backend independence:** Swap Convex for any other backend (Firebase, Supabase, custom HTTP API, etc.)
|
|
15
|
+
2. **Frontend-only mode:** Run standalone without backend (Stripe, Notion, markdown-based, etc.)
|
|
16
|
+
3. **Optional features:** Auth, groups, permissions only activate when backend is available
|
|
17
|
+
4. **Ontology compliance:** All APIs follow the 6-dimension ontology structure
|
|
18
|
+
5. **Multiple data sources:** Markdown, Notion, WordPress, Stripe, custom HTTP APIs
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Architecture Layers
|
|
23
|
+
|
|
24
|
+
### Layer 1: Data Providers (Backend Agnostic)
|
|
25
|
+
|
|
26
|
+
Each provider implements a unified interface:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
// web/src/lib/ontology/types.ts
|
|
30
|
+
export interface IOntologyProvider {
|
|
31
|
+
// Groups
|
|
32
|
+
groups: {
|
|
33
|
+
list(filter?: Filter): Promise<Group[]>;
|
|
34
|
+
get(id: string): Promise<Group>;
|
|
35
|
+
create(data: CreateGroupInput): Promise<Group>;
|
|
36
|
+
update(id: string, data: UpdateGroupInput): Promise<Group>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// People
|
|
40
|
+
people: {
|
|
41
|
+
list(groupId?: string): Promise<Person[]>;
|
|
42
|
+
get(id: string): Promise<Person>;
|
|
43
|
+
create(data: CreatePersonInput): Promise<Person>;
|
|
44
|
+
current(): Promise<Person | null>;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Things (Entities)
|
|
48
|
+
things: {
|
|
49
|
+
list(filter?: ThingFilter): Promise<Thing[]>;
|
|
50
|
+
get(id: string): Promise<Thing>;
|
|
51
|
+
create(data: CreateThingInput): Promise<Thing>;
|
|
52
|
+
update(id: string, data: UpdateThingInput): Promise<Thing>;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Connections (Relationships)
|
|
56
|
+
connections: {
|
|
57
|
+
list(filter?: ConnectionFilter): Promise<Connection[]>;
|
|
58
|
+
get(id: string): Promise<Connection>;
|
|
59
|
+
create(data: CreateConnectionInput): Promise<Connection>;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Events (Actions)
|
|
63
|
+
events: {
|
|
64
|
+
list(filter?: EventFilter): Promise<Event[]>;
|
|
65
|
+
record(data: CreateEventInput): Promise<Event>;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Knowledge (Vectors/Search)
|
|
69
|
+
knowledge: {
|
|
70
|
+
search(query: string, limit?: number): Promise<Knowledge[]>;
|
|
71
|
+
embed(text: string): Promise<number[]>;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Layer 2: Provider Implementations
|
|
77
|
+
|
|
78
|
+
**Available Providers:**
|
|
79
|
+
|
|
80
|
+
1. **ConvexProvider** - Headless Convex backend (production)
|
|
81
|
+
2. **NotionProvider** - Notion database as backend
|
|
82
|
+
3. **WordPressProvider** - WordPress REST API
|
|
83
|
+
4. **MarkdownProvider** - Local markdown files
|
|
84
|
+
5. **StripeProvider** - Stripe checkout + products
|
|
85
|
+
6. **HTTPProvider** - Generic HTTP REST API
|
|
86
|
+
7. **CompositeProvider** - Combine multiple providers
|
|
87
|
+
|
|
88
|
+
### Layer 3: Effect-TS Integration
|
|
89
|
+
|
|
90
|
+
Use Effect-TS for:
|
|
91
|
+
|
|
92
|
+
- **Service composition:** Build features from ontology services
|
|
93
|
+
- **Error handling:** Typed errors per operation
|
|
94
|
+
- **Dependency injection:** Swap providers without code changes
|
|
95
|
+
- **Async operations:** Real-time subscriptions via Convex
|
|
96
|
+
- **Type safety:** Full TypeScript inference
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
// web/src/lib/ontology/effects.ts
|
|
100
|
+
import * as Effect from 'effect';
|
|
101
|
+
import { IOntologyProvider } from './types';
|
|
102
|
+
|
|
103
|
+
export class OntologyService extends Effect.Service<OntologyService>()('OntologyService', {
|
|
104
|
+
dependencies: () => [Effect.Tag<IOntologyProvider>()],
|
|
105
|
+
accessors: {
|
|
106
|
+
provider: (self) => self._tag,
|
|
107
|
+
},
|
|
108
|
+
}) {
|
|
109
|
+
// Service methods build on provider
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Layer 4: Astro Content Layer Integration
|
|
114
|
+
|
|
115
|
+
Astro can source data from multiple locations:
|
|
116
|
+
|
|
117
|
+
```astro
|
|
118
|
+
---
|
|
119
|
+
// src/pages/[group]/things/[slug].astro
|
|
120
|
+
import { getProvider } from '@/lib/ontology/factory';
|
|
121
|
+
import type { Thing } from '@/lib/ontology/types';
|
|
122
|
+
|
|
123
|
+
// Support multiple backends
|
|
124
|
+
const provider = await getProvider();
|
|
125
|
+
const thing = await provider.things.get(Astro.params.slug);
|
|
126
|
+
|
|
127
|
+
// Fall back to markdown if backend unavailable
|
|
128
|
+
if (!thing) {
|
|
129
|
+
return Astro.redirect(`/blog/${Astro.params.slug}`);
|
|
130
|
+
}
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
<Layout title={thing.name}>
|
|
134
|
+
<h1>{thing.name}</h1>
|
|
135
|
+
<Content data={thing} />
|
|
136
|
+
</Layout>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Implementation Strategy
|
|
142
|
+
|
|
143
|
+
### Phase 1: Foundation (Infer 1-10)
|
|
144
|
+
|
|
145
|
+
**Objective:** Create the Effect-TS ontology layer
|
|
146
|
+
|
|
147
|
+
1. **Define Core Interfaces**
|
|
148
|
+
- `IOntologyProvider` - Unified provider interface
|
|
149
|
+
- `CreateXXXInput`, `UpdateXXXInput` types for each dimension
|
|
150
|
+
- Error types: `EntityNotFound`, `ValidationError`, `UnauthorizedError`
|
|
151
|
+
|
|
152
|
+
2. **Create Effect Services**
|
|
153
|
+
- `OntologyService` - Main service class
|
|
154
|
+
- Service for each dimension (Groups, People, Things, Connections, Events, Knowledge)
|
|
155
|
+
- Error handler middleware
|
|
156
|
+
|
|
157
|
+
3. **Update Project Structure**
|
|
158
|
+
```
|
|
159
|
+
web/src/lib/ontology/
|
|
160
|
+
├── types.ts # Core interfaces
|
|
161
|
+
├── effects.ts # Effect-TS service definitions
|
|
162
|
+
├── errors.ts # Typed error definitions
|
|
163
|
+
├── factory.ts # Provider factory
|
|
164
|
+
└── adapters/ # Adapter layer
|
|
165
|
+
├── markdown.ts
|
|
166
|
+
├── notion.ts
|
|
167
|
+
└── http.ts
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Phase 2: Provider Implementations (Infer 11-20)
|
|
171
|
+
|
|
172
|
+
**Objective:** Implement each provider following the unified interface
|
|
173
|
+
|
|
174
|
+
1. **ConvexProvider Enhancement**
|
|
175
|
+
- Add type-safe Convex API wrapper
|
|
176
|
+
- Implement real-time subscriptions via `useQuery()`
|
|
177
|
+
- Add optimistic updates
|
|
178
|
+
|
|
179
|
+
2. **NotionProvider**
|
|
180
|
+
- Notion API integration
|
|
181
|
+
- Map Notion databases to ontology dimensions
|
|
182
|
+
- Caching and rate limiting
|
|
183
|
+
|
|
184
|
+
3. **MarkdownProvider**
|
|
185
|
+
- Parse frontmatter for metadata
|
|
186
|
+
- Directory structure mapping to groups/things
|
|
187
|
+
- Watch mode for development
|
|
188
|
+
|
|
189
|
+
4. **HTTPProvider**
|
|
190
|
+
- Generic REST API adapter
|
|
191
|
+
- Query string builder
|
|
192
|
+
- Error translation
|
|
193
|
+
|
|
194
|
+
5. **CompositeProvider**
|
|
195
|
+
- Chain multiple providers (fallback pattern)
|
|
196
|
+
- Priority-based selection
|
|
197
|
+
|
|
198
|
+
### Phase 3: Astro Integration (Infer 21-30)
|
|
199
|
+
|
|
200
|
+
**Objective:** Connect Astro content layer to providers
|
|
201
|
+
|
|
202
|
+
1. **Content Collections**
|
|
203
|
+
- Define schemas for blog, products, courses
|
|
204
|
+
- Auto-generate from provider data
|
|
205
|
+
- Handle missing/fallback data
|
|
206
|
+
|
|
207
|
+
2. **Dynamic Routes**
|
|
208
|
+
- `/[group]/things/[slug]` - Entity pages
|
|
209
|
+
- `/[group]/connections` - Relationship views
|
|
210
|
+
- `/[group]/events` - Activity feeds
|
|
211
|
+
- `/[group]/knowledge` - Search/discovery
|
|
212
|
+
|
|
213
|
+
3. **Static Generation**
|
|
214
|
+
- Pre-build common pages
|
|
215
|
+
- Incremental static regeneration (ISR)
|
|
216
|
+
- Fallback for dynamic content
|
|
217
|
+
|
|
218
|
+
### Phase 4: Feature-Specific Integration (Infer 31-40)
|
|
219
|
+
|
|
220
|
+
**Objective:** Integrate 6 ontology dimensions with features
|
|
221
|
+
|
|
222
|
+
#### Groups Integration
|
|
223
|
+
```typescript
|
|
224
|
+
// web/src/lib/ontology/services/groups.ts
|
|
225
|
+
export const listGroups = Effect.fn(
|
|
226
|
+
async (ctx: OntologyContext) => {
|
|
227
|
+
const provider = ctx.provider;
|
|
228
|
+
const groups = await provider.groups.list();
|
|
229
|
+
return groups;
|
|
230
|
+
},
|
|
231
|
+
{ concurrency: 5 }
|
|
232
|
+
);
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### People Integration
|
|
236
|
+
```typescript
|
|
237
|
+
// web/src/lib/ontology/services/people.ts
|
|
238
|
+
export const getCurrentUser = Effect.fn(
|
|
239
|
+
async (ctx: OntologyContext) => {
|
|
240
|
+
const provider = ctx.provider;
|
|
241
|
+
const user = await provider.people.current();
|
|
242
|
+
if (!user) throw new UnauthorizedError();
|
|
243
|
+
return user;
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
#### Things Integration
|
|
249
|
+
```typescript
|
|
250
|
+
// web/src/lib/ontology/services/things.ts
|
|
251
|
+
export const listThings = Effect.fn(
|
|
252
|
+
async (filter: ThingFilter, ctx: OntologyContext) => {
|
|
253
|
+
const things = await ctx.provider.things.list(filter);
|
|
254
|
+
return Effect.all(things.map(t => validateThing(t)));
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
#### Connections Integration
|
|
260
|
+
```typescript
|
|
261
|
+
// web/src/lib/ontology/services/connections.ts
|
|
262
|
+
export const getConnections = Effect.fn(
|
|
263
|
+
async (thingId: string, ctx: OntologyContext) => {
|
|
264
|
+
const connections = await ctx.provider.connections.list({
|
|
265
|
+
sourceId: thingId
|
|
266
|
+
});
|
|
267
|
+
return connections;
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
#### Events Integration
|
|
273
|
+
```typescript
|
|
274
|
+
// web/src/lib/ontology/services/events.ts
|
|
275
|
+
export const recordEvent = Effect.fn(
|
|
276
|
+
async (event: CreateEventInput, ctx: OntologyContext) => {
|
|
277
|
+
const recorded = await ctx.provider.events.record(event);
|
|
278
|
+
return recorded;
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
#### Knowledge Integration
|
|
284
|
+
```typescript
|
|
285
|
+
// web/src/lib/ontology/services/knowledge.ts
|
|
286
|
+
export const search = Effect.fn(
|
|
287
|
+
async (query: string, ctx: OntologyContext) => {
|
|
288
|
+
const results = await ctx.provider.knowledge.search(query, 10);
|
|
289
|
+
return results;
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Phase 5: Optional Features (Infer 41-50)
|
|
295
|
+
|
|
296
|
+
**Objective:** Make auth, groups, permissions optional
|
|
297
|
+
|
|
298
|
+
#### Feature Flags
|
|
299
|
+
```typescript
|
|
300
|
+
// web/src/lib/ontology/features.ts
|
|
301
|
+
export interface FeatureFlags {
|
|
302
|
+
auth: boolean; // Require authentication
|
|
303
|
+
groups: boolean; // Multi-tenant groups
|
|
304
|
+
permissions: boolean; // Role-based access
|
|
305
|
+
realtime: boolean; // WebSocket subscriptions
|
|
306
|
+
search: boolean; // Vector search
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export const defaultFeatures: FeatureFlags = {
|
|
310
|
+
auth: false, // Disabled by default
|
|
311
|
+
groups: false,
|
|
312
|
+
permissions: false,
|
|
313
|
+
realtime: false, // Only if Convex
|
|
314
|
+
search: false,
|
|
315
|
+
};
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
#### Conditional Routes
|
|
319
|
+
```astro
|
|
320
|
+
---
|
|
321
|
+
// src/pages/account/login.astro
|
|
322
|
+
import { features } from '@/lib/ontology/features';
|
|
323
|
+
|
|
324
|
+
// Hide if auth disabled
|
|
325
|
+
if (!features.auth) {
|
|
326
|
+
return Astro.redirect('/');
|
|
327
|
+
}
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
<LoginForm />
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Phase 6: API Endpoints (Infer 51-60)
|
|
334
|
+
|
|
335
|
+
**Objective:** Create API routes following ontology structure
|
|
336
|
+
|
|
337
|
+
```
|
|
338
|
+
/api/groups/ # Group operations
|
|
339
|
+
/api/people/ # Person operations
|
|
340
|
+
/api/things/ # Entity operations
|
|
341
|
+
/api/connections/ # Relationship operations
|
|
342
|
+
/api/events/ # Event recording
|
|
343
|
+
/api/knowledge/search/ # Search operations
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
#### Example API Route
|
|
347
|
+
```typescript
|
|
348
|
+
// web/src/pages/api/things/[id].ts
|
|
349
|
+
import type { APIRoute } from 'astro';
|
|
350
|
+
import { getProvider } from '@/lib/ontology/factory';
|
|
351
|
+
|
|
352
|
+
export const GET: APIRoute = async ({ params }) => {
|
|
353
|
+
const provider = await getProvider();
|
|
354
|
+
const thing = await provider.things.get(params.id);
|
|
355
|
+
return new Response(JSON.stringify(thing), {
|
|
356
|
+
headers: { 'Content-Type': 'application/json' }
|
|
357
|
+
});
|
|
358
|
+
};
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Phase 7: Testing (Infer 61-70)
|
|
362
|
+
|
|
363
|
+
**Objective:** Verify all providers work correctly
|
|
364
|
+
|
|
365
|
+
1. **Provider Tests**
|
|
366
|
+
- Each provider implements full interface
|
|
367
|
+
- Mock data validation
|
|
368
|
+
- Error handling
|
|
369
|
+
|
|
370
|
+
2. **Integration Tests**
|
|
371
|
+
- Frontend → Provider flows
|
|
372
|
+
- Fallback behavior
|
|
373
|
+
- Feature flag combinations
|
|
374
|
+
|
|
375
|
+
3. **E2E Tests**
|
|
376
|
+
- Astro page rendering
|
|
377
|
+
- Dynamic routes
|
|
378
|
+
- API endpoints
|
|
379
|
+
|
|
380
|
+
### Phase 8: Documentation (Infer 71-80)
|
|
381
|
+
|
|
382
|
+
**Objective:** Document architecture and usage
|
|
383
|
+
|
|
384
|
+
1. **Provider Guide**
|
|
385
|
+
- How to implement custom provider
|
|
386
|
+
- Configuration options
|
|
387
|
+
- Examples
|
|
388
|
+
|
|
389
|
+
2. **Feature Toggles**
|
|
390
|
+
- Which features require which backend
|
|
391
|
+
- Trade-offs
|
|
392
|
+
- Performance considerations
|
|
393
|
+
|
|
394
|
+
3. **Migration Guide**
|
|
395
|
+
- Switching backends
|
|
396
|
+
- Data mapping
|
|
397
|
+
- Rollback procedures
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## Key Design Decisions
|
|
402
|
+
|
|
403
|
+
### 1. Effect-TS Over Direct Calls
|
|
404
|
+
|
|
405
|
+
**Why:** Type-safe composition, error handling, dependency injection
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
// ❌ Direct (tightly coupled)
|
|
409
|
+
const thing = await convex.query(api.things.get, { id: '123' });
|
|
410
|
+
|
|
411
|
+
// ✅ Effect-TS (loosely coupled)
|
|
412
|
+
const getThing = Effect.fn(
|
|
413
|
+
async (id: string, ctx: OntologyContext) => {
|
|
414
|
+
return ctx.provider.things.get(id);
|
|
415
|
+
}
|
|
416
|
+
);
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### 2. Unified Interface Over Adapter Pattern
|
|
420
|
+
|
|
421
|
+
**Why:** Simpler to understand, easier to add new providers
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
// All providers implement same interface
|
|
425
|
+
interface IOntologyProvider {
|
|
426
|
+
groups: GroupService;
|
|
427
|
+
people: PeopleService;
|
|
428
|
+
things: ThingService;
|
|
429
|
+
// etc.
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### 3. Feature Flags Over Branching
|
|
434
|
+
|
|
435
|
+
**Why:** Cleaner code, easier to test combinations
|
|
436
|
+
|
|
437
|
+
```typescript
|
|
438
|
+
// Instead of: if (isConvex) { ... }
|
|
439
|
+
// Use: if (features.auth) { ... }
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### 4. Astro Content Layer as Primary Source
|
|
443
|
+
|
|
444
|
+
**Why:** Static generation, SEO, performance
|
|
445
|
+
|
|
446
|
+
- Markdown files for documentation
|
|
447
|
+
- Astro collections for structured data
|
|
448
|
+
- Provider queries for dynamic content
|
|
449
|
+
- Fallback to content layer if provider fails
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## File Structure After Implementation
|
|
454
|
+
|
|
455
|
+
```
|
|
456
|
+
web/src/
|
|
457
|
+
├── lib/ontology/
|
|
458
|
+
│ ├── types.ts # Core interfaces
|
|
459
|
+
│ ├── errors.ts # Error definitions
|
|
460
|
+
│ ├── effects.ts # Effect-TS services
|
|
461
|
+
│ ├── factory.ts # Provider factory
|
|
462
|
+
│ ├── features.ts # Feature flags
|
|
463
|
+
│ ├── providers/
|
|
464
|
+
│ │ ├── index.ts
|
|
465
|
+
│ │ ├── convex.ts # Convex provider
|
|
466
|
+
│ │ ├── notion.ts # Notion provider
|
|
467
|
+
│ │ ├── markdown.ts # Markdown provider
|
|
468
|
+
│ │ ├── http.ts # Generic HTTP
|
|
469
|
+
│ │ ├── stripe.ts # Stripe provider
|
|
470
|
+
│ │ └── composite.ts # Provider chaining
|
|
471
|
+
│ ├── services/
|
|
472
|
+
│ │ ├── groups.ts # Groups service
|
|
473
|
+
│ │ ├── people.ts # People service
|
|
474
|
+
│ │ ├── things.ts # Things service
|
|
475
|
+
│ │ ├── connections.ts # Connections service
|
|
476
|
+
│ │ ├── events.ts # Events service
|
|
477
|
+
│ │ └── knowledge.ts # Knowledge service
|
|
478
|
+
│ └── adapters/
|
|
479
|
+
│ ├── notion-adapter.ts # Map Notion → ontology
|
|
480
|
+
│ ├── markdown-adapter.ts # Map markdown → ontology
|
|
481
|
+
│ └── stripe-adapter.ts # Map Stripe → ontology
|
|
482
|
+
├── pages/api/
|
|
483
|
+
│ ├── groups/[id].ts
|
|
484
|
+
│ ├── people/[id].ts
|
|
485
|
+
│ ├── things/[id].ts
|
|
486
|
+
│ ├── connections/[id].ts
|
|
487
|
+
│ ├── events/[id].ts
|
|
488
|
+
│ └── knowledge/search/[q].ts
|
|
489
|
+
├── components/
|
|
490
|
+
│ ├── ontology/ # Reusable components
|
|
491
|
+
│ │ ├── GroupList.tsx
|
|
492
|
+
│ │ ├── ThingCard.tsx
|
|
493
|
+
│ │ ├── ConnectionViewer.tsx
|
|
494
|
+
│ │ └── EventTimeline.tsx
|
|
495
|
+
│ └── features/ # Feature-specific
|
|
496
|
+
├── hooks/
|
|
497
|
+
│ ├── useProvider.ts # Access current provider
|
|
498
|
+
│ ├── useGroup.ts # Group operations
|
|
499
|
+
│ ├── useThing.ts # Thing operations
|
|
500
|
+
│ └── useSearch.ts # Search operations
|
|
501
|
+
└── stores/
|
|
502
|
+
└── ontology.ts # State management
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## Configuration Examples
|
|
508
|
+
|
|
509
|
+
### Standalone Frontend (No Backend)
|
|
510
|
+
|
|
511
|
+
```env
|
|
512
|
+
# .env.local
|
|
513
|
+
VITE_PROVIDER=markdown
|
|
514
|
+
VITE_FEATURES='{"auth":false,"groups":false,"permissions":false}'
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### Stripe Checkout Only
|
|
518
|
+
|
|
519
|
+
```env
|
|
520
|
+
VITE_PROVIDER=stripe
|
|
521
|
+
STRIPE_PUBLIC_KEY=pk_live_...
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### Full Backend (Convex + Auth)
|
|
525
|
+
|
|
526
|
+
```env
|
|
527
|
+
VITE_PROVIDER=convex
|
|
528
|
+
PUBLIC_CONVEX_URL=https://shocking-falcon-870.convex.cloud
|
|
529
|
+
VITE_FEATURES='{"auth":true,"groups":true,"permissions":true}'
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
### Multi-Source (Notion + Markdown)
|
|
533
|
+
|
|
534
|
+
```env
|
|
535
|
+
VITE_PROVIDER=composite
|
|
536
|
+
VITE_COMPOSITE_PROVIDERS='["notion","markdown"]'
|
|
537
|
+
NOTION_API_KEY=ntn_...
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
---
|
|
541
|
+
|
|
542
|
+
## Success Criteria
|
|
543
|
+
|
|
544
|
+
- [ ] Effect-TS ontology layer fully typed
|
|
545
|
+
- [ ] All 7 providers implement unified interface
|
|
546
|
+
- [ ] Astro static generation works with all providers
|
|
547
|
+
- [ ] Feature flags allow opt-in for auth/groups/permissions
|
|
548
|
+
- [ ] API endpoints follow ontology naming structure
|
|
549
|
+
- [ ] All tests passing (unit, integration, e2e)
|
|
550
|
+
- [ ] Documentation complete with examples
|
|
551
|
+
- [ ] Zero breaking changes to existing frontend
|
|
552
|
+
- [ ] Can switch backends without code changes
|
|
553
|
+
- [ ] Frontend runs standalone without backend
|
|
554
|
+
|
|
555
|
+
---
|
|
556
|
+
|
|
557
|
+
## Fallback Strategy
|
|
558
|
+
|
|
559
|
+
When provider is unavailable:
|
|
560
|
+
|
|
561
|
+
```typescript
|
|
562
|
+
// 1. Try primary provider
|
|
563
|
+
// 2. Fall back to markdown/content layer
|
|
564
|
+
// 3. Show cached version
|
|
565
|
+
// 4. Show offline message
|
|
566
|
+
// 5. Queue for sync when online
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
---
|
|
570
|
+
|
|
571
|
+
## Next Steps
|
|
572
|
+
|
|
573
|
+
1. **Phase 1-2:** Parallel work on Effect-TS layer and provider implementations
|
|
574
|
+
2. **Phase 3:** Integrate with Astro content layer
|
|
575
|
+
3. **Phase 4:** Implement 6-dimension services
|
|
576
|
+
4. **Phase 5:** Add feature flags for optional auth
|
|
577
|
+
5. **Phase 6:** Create API endpoints
|
|
578
|
+
6. **Phase 7:** Comprehensive testing
|
|
579
|
+
7. **Phase 8:** Documentation and release
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# MCP Context Clearing Prompt
|
|
2
|
+
|
|
3
|
+
**Purpose:** Run this once to permanently clear MCP documentation from context until needed
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## The Prompt
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Claude, from now on and for all future conversations in this project:
|
|
11
|
+
|
|
12
|
+
AUTOMATICALLY clear all MCP documentation from your active context
|
|
13
|
+
unless I'm actually using an MCP tool.
|
|
14
|
+
|
|
15
|
+
Rules:
|
|
16
|
+
1. Default: NO MCP docs loaded (saves ~15,000 tokens)
|
|
17
|
+
2. When I use an MCP tool: Load ONLY that MCP's docs
|
|
18
|
+
3. After using tool: Clear those docs from context
|
|
19
|
+
4. Apply this behavior permanently for this project
|
|
20
|
+
|
|
21
|
+
Available MCPs (currently using 15.1k tokens):
|
|
22
|
+
- shadcn: 7 tools (~4.7k tokens)
|
|
23
|
+
- cloudflare-docs: 2 tools (~1.4k tokens)
|
|
24
|
+
- cloudflare-builds: 9 tools (~5.7k tokens)
|
|
25
|
+
- Framelink_Figma_MCP: 2 tools (~2.0k tokens)
|
|
26
|
+
- ide: 2 tools (~1.3k tokens)
|
|
27
|
+
|
|
28
|
+
Confirm you'll automatically apply this context management going forward
|
|
29
|
+
and that MCP docs are now cleared from active context.
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Expected Result
|
|
35
|
+
|
|
36
|
+
**Before:**
|
|
37
|
+
```
|
|
38
|
+
MCP tools: 15.1k tokens (7.5%)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**After:**
|
|
42
|
+
```
|
|
43
|
+
MCP tools: ~0-1k tokens (signatures only)
|
|
44
|
+
Savings: ~14k tokens
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Verification Command
|
|
50
|
+
|
|
51
|
+
After running the prompt, check context usage:
|
|
52
|
+
```
|
|
53
|
+
/context
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Look for "MCP tools" - should be dramatically reduced or minimal.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
**Run once. Saves 14k tokens forever.**
|