oneie 2.0.3 → 2.0.6

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 (84) hide show
  1. package/CLAUDE.md +220 -29
  2. package/LICENSE.md +84 -0
  3. package/README.md +489 -931
  4. package/dist/copy-claude-config.d.ts.map +1 -1
  5. package/dist/copy-claude-config.js +3 -1
  6. package/dist/copy-claude-config.js.map +1 -1
  7. package/dist/sync-agents.d.ts.map +1 -1
  8. package/dist/sync-agents.js +3 -1
  9. package/dist/sync-agents.js.map +1 -1
  10. package/dist/sync-ontology.d.ts.map +1 -1
  11. package/dist/sync-ontology.js +9 -7
  12. package/dist/sync-ontology.js.map +1 -1
  13. package/folders.yaml +78 -17
  14. package/one/.obsidian/workspace.json +6 -6
  15. package/one/events/CASCADE-2-BACKEND-AGNOSTIC.md +412 -0
  16. package/one/events/FEATURE-2-4-COMPLETE.md +302 -0
  17. package/one/events/FEATURE_2_3_COMPLETE.md +575 -0
  18. package/one/events/GROUPS-MIGRATION.md +625 -0
  19. package/one/events/INSTALL-TESTS.md +293 -0
  20. package/one/events/INTEGRATION-ARCHITECTURE.md +561 -0
  21. package/one/events/INTEGRATION-CHECKLIST.md +1234 -0
  22. package/one/events/INTEGRATION-ORCHESTRATION.md +2623 -0
  23. package/one/events/INTEGRATION-SUMMARY.md +653 -0
  24. package/one/events/MIGRATION-REPORT.md +435 -0
  25. package/one/events/MIGRATION.md +69 -0
  26. package/one/events/README-archived.md +519 -0
  27. package/one/events/TEST-SUMMARY.md +393 -0
  28. package/one/events/TESTS-QUICK-REF.md +262 -0
  29. package/one/groups/groups.md +543 -0
  30. package/one/knowledge/CLOUDFLARE_ENV_SETUP.md +49 -0
  31. package/one/knowledge/architecture-any-backend.md +1366 -0
  32. package/one/knowledge/docs/flow.md +0 -0
  33. package/one/knowledge/ontology-documentation.md +18 -18
  34. package/one/knowledge/ontology.md +154 -143
  35. package/one/knowledge/ontology.md.backup +2822 -0
  36. package/one/knowledge/ontology.yaml +87 -87
  37. package/one/knowledge/provider-creation-guide.md +1064 -0
  38. package/one/knowledge/todo.md +251 -0
  39. package/one/license.md +84 -0
  40. package/one/things/CHECKLIST.md +356 -0
  41. package/one/things/ONE.md +510 -0
  42. package/one/things/{cli.md → cli/cli.md} +27 -4
  43. package/one/things/features/2-1-dataprovider-interface.md +2358 -0
  44. package/one/things/features/2-2-config-system.md +3075 -0
  45. package/one/things/features/2-3-effectts-services.md +1498 -0
  46. package/one/things/features/2-4-react-hooks.md +2120 -0
  47. package/one/things/features/2-5-auth-migration.md +2046 -0
  48. package/one/things/features/2-6-dashboard-migration.md +1985 -0
  49. package/one/things/features/2-7-alternative-providers.md +2505 -0
  50. package/one/things/features/2-7-implementation-report.md +680 -0
  51. package/one/things/features/2-cli.md +39 -39
  52. package/one/things/features/2-design.md +1738 -0
  53. package/one/things/features/2-tests.md +520 -0
  54. package/one/things/features/AUTH_HOOKS_IMPLEMENTATION.md +521 -0
  55. package/one/things/features/DECOUPLING.md +272 -0
  56. package/one/things/features/DEPLOYMENT.md +452 -0
  57. package/one/things/features/IMPLEMENTATION_SUMMARY.md +316 -0
  58. package/one/things/features/dataprovider-interface/1-tests.md +1522 -0
  59. package/one/things/features/improve.md +843 -0
  60. package/one/things/features/remove-convex-deps.md +45 -0
  61. package/one/things/features/top-features.md +79 -0
  62. package/one/things/ideas/2-backend-agnostic-frontend.md +384 -0
  63. package/one/things/plans/2-backend-agnostic-frontend.md +543 -0
  64. package/one/things/plans/3-groups.md +502 -0
  65. package/one/things/plans/backend-agnostic-frontend.md +323 -0
  66. package/one/things/plans/deploy-to-cloudflare.md +581 -0
  67. package/one/things/plans/organizations-to-groups.md +705 -0
  68. package/one/things/plans/release.md +432 -0
  69. package/one/things/products/ontology.md +1 -1
  70. package/one/things/system.md +600 -0
  71. package/one/things/tests/2-1-dataprovider-interface.md +1144 -0
  72. package/one/things/tests/2-1-test-analysis.md +496 -0
  73. package/one/things/vision/elegant-interface.md +214 -0
  74. package/package.json +1 -1
  75. package/one/organisation/organisation.md +0 -438
  76. package/one/repomix-output.md +0 -92634
  77. /package/one/{things → connections}/agentkit.md +0 -0
  78. /package/one/{things → connections}/copilotkit.md +0 -0
  79. /package/one/{organisation → groups}/one.md +0 -0
  80. /package/one/{organisation → groups}/revenue.md +0 -0
  81. /package/one/{organisation → groups}/strategy.md +0 -0
  82. /package/one/{organisation → groups}/vision.md +0 -0
  83. /package/one/things/{cli-code.md → cli/cli-code.md} +0 -0
  84. /package/one/things/{cli-compiler-code.md → cli/cli-compiler-code.md} +0 -0
@@ -0,0 +1,502 @@
1
+ # 3. Groups - Organizations ARE Groups
2
+
3
+ **Key Insight:** Organizations don't disappear. They become a **type** of group.
4
+
5
+ ---
6
+
7
+ ## The Concept
8
+
9
+ ```typescript
10
+ // Organizations are just one type of group
11
+ type GroupType =
12
+ | "friend_circle" // Emma's Friends
13
+ | "business" // Startup Inc
14
+ | "community" // Crypto Enthusiasts
15
+ | "dao" // CoolDAO
16
+ | "government" // City Council
17
+ | "organization"; // ← Legacy "organizations" = group type
18
+ ```
19
+
20
+ **Everything that was an "organization" becomes a group with `type: "organization"`.**
21
+
22
+ Multi-tenancy preserved. Data isolation identical. Just more flexible.
23
+
24
+ ---
25
+
26
+ ## Schema Evolution
27
+
28
+ ### Before (4 tables scoped to organizations)
29
+
30
+ ```typescript
31
+ organizations: defineTable({ name, plan, limits, status })
32
+ entities: defineTable({ organizationId, type, name, properties })
33
+ connections: defineTable({ organizationId, fromId, toId, type })
34
+ events: defineTable({ organizationId, type, actorId, targetId })
35
+ knowledge: defineTable({ organizationId, type, text, embedding })
36
+ ```
37
+
38
+ ### After (5 tables scoped to groups)
39
+
40
+ ```typescript
41
+ groups: defineTable({
42
+ slug, // NEW: URL identifier
43
+ name,
44
+ type, // NEW: 6 types (including "organization")
45
+ parentGroupId, // NEW: Hierarchical nesting!
46
+ description,
47
+ metadata,
48
+ settings: {
49
+ visibility, // NEW: public/private
50
+ joinPolicy, // NEW: open/invite/approval
51
+ plan, // Same as before
52
+ limits // Same as before
53
+ },
54
+ status
55
+ })
56
+
57
+ entities: defineTable({ groupId, type, name, properties }) // organizationId → groupId
58
+ connections: defineTable({ groupId, fromId, toId, type }) // organizationId → groupId
59
+ events: defineTable({ groupId, type, actorId, targetId }) // organizationId → groupId
60
+ knowledge: defineTable({ groupId, type, text, embedding }) // organizationId → groupId
61
+ ```
62
+
63
+ **Key changes:**
64
+ 1. `organizations` → `groups` (new table with 6 types)
65
+ 2. `organizationId` → `groupId` (everywhere)
66
+ 3. Add `parentGroupId` (enables nesting)
67
+ 4. Add `slug` (enables URL-based creation)
68
+ 5. Add type-specific settings
69
+
70
+ ---
71
+
72
+ ## Parallel Execution Strategy
73
+
74
+ ### Phase 0: Schema (Sequential - Must Complete First)
75
+
76
+ **1 inference** - Schema update blocks everything else.
77
+
78
+ ```bash
79
+ ✅ Update backend/convex/schema.ts
80
+ - Add groups table
81
+ - Add groupId to entities, connections, events, knowledge
82
+ - Add indexes: by_group, group_type, by_slug, by_parent
83
+ ```
84
+
85
+ **Duration:** 1 inference
86
+ **Blocks:** All other work
87
+
88
+ ---
89
+
90
+ ### Phase 1: Backend (Parallel After Schema)
91
+
92
+ Run all backend updates **simultaneously** - no dependencies between files.
93
+
94
+ #### Track A: Mutations (5 agents in parallel)
95
+
96
+ ```bash
97
+ Agent 1: mutations/entities.ts (organizationId → groupId)
98
+ Agent 2: mutations/connections.ts (organizationId → groupId)
99
+ Agent 3: mutations/events.ts (organizationId → groupId)
100
+ Agent 4: mutations/knowledge.ts (organizationId → groupId)
101
+ Agent 5: mutations/groups.ts (NEW: create, update, archive)
102
+ ```
103
+
104
+ **Duration:** 1 inference elapsed (5 running in parallel)
105
+
106
+ #### Track B: Queries (5 agents in parallel)
107
+
108
+ ```bash
109
+ Agent 1: queries/entities.ts (organizationId → groupId)
110
+ Agent 2: queries/connections.ts (organizationId → groupId)
111
+ Agent 3: queries/events.ts (organizationId → groupId)
112
+ Agent 4: queries/knowledge.ts (organizationId → groupId)
113
+ Agent 5: queries/groups.ts (NEW: getBySlug, getSubgroups, getHierarchy)
114
+ ```
115
+
116
+ **Duration:** 1 inference elapsed (5 running in parallel)
117
+
118
+ **Total Phase 1:** 1 inference (both tracks run simultaneously)
119
+
120
+ ---
121
+
122
+ ### Phase 2: Frontend (Parallel After Backend)
123
+
124
+ Run all frontend updates **simultaneously** - components are independent.
125
+
126
+ #### Track C: Components (10+ agents in parallel)
127
+
128
+ ```bash
129
+ Agent 1: src/components/features/EntityList.tsx
130
+ Agent 2: src/components/features/ConnectionGraph.tsx
131
+ Agent 3: src/components/features/EventTimeline.tsx
132
+ Agent 4: src/components/features/KnowledgeSearch.tsx
133
+ Agent 5: src/components/ui/OrgSelector.tsx → GroupSelector.tsx
134
+ Agent 6-10: All other components using organizationId
135
+ ```
136
+
137
+ **Pattern:** Simple find/replace in each file:
138
+ ```typescript
139
+ - const data = useQuery(api.queries.entities.list, { organizationId });
140
+ + const data = useQuery(api.queries.entities.list, { groupId });
141
+ ```
142
+
143
+ **Duration:** 1 inference elapsed (all components in parallel)
144
+
145
+ #### Track D: Routes (4 inferences sequential, runs parallel with Track C)
146
+
147
+ ```bash
148
+ Infer 1: src/pages/group/[slug].astro (URL-based routing)
149
+ Infer 2: src/pages/group/[slug]/create.astro (Creation flow)
150
+ Infer 3: src/components/GroupHierarchy.tsx (Nested navigation)
151
+ Infer 4: src/components/GroupTypeSelector.tsx (Type picker UI)
152
+ ```
153
+
154
+ **Duration:** 4 inferences (sequential within track)
155
+
156
+ **Total Phase 2:** 4 inferences (Track C + Track D run in parallel)
157
+
158
+ ---
159
+
160
+ ### Phase 3: Documentation (Parallel - Can Start Immediately!)
161
+
162
+ Documentation has **no dependencies** - can update any time.
163
+
164
+ #### Track E: Core Docs (3 agents in parallel)
165
+
166
+ ```bash
167
+ Agent 1: CLAUDE.md (organizations → groups, Version 2.0.0)
168
+ Agent 2: README.md (update examples with groups)
169
+ Agent 3: one/knowledge/ontology.md (Dimension 1: Groups)
170
+ ```
171
+
172
+ #### Track F: All Other Docs (41 agents in parallel!)
173
+
174
+ ```bash
175
+ # Global find/replace in all one/ files:
176
+ # "organizations" → "groups"
177
+ # "organizationId" → "groupId"
178
+
179
+ Agent 4-44: Update all 41 files in one/ directory
180
+ ```
181
+
182
+ **Pattern:** Automated find/replace, then human review.
183
+
184
+ **Duration:** 1 inference elapsed (all docs in parallel)
185
+
186
+ ---
187
+
188
+ ### Phase 4: Data Migration (Parallel with Phase 3)
189
+
190
+ Migration script can be developed while docs update.
191
+
192
+ ```typescript
193
+ // migrations/orgsToGroups.ts
194
+ export const migrate = mutation({
195
+ handler: async (ctx) => {
196
+ // 1. Get all organizations
197
+ const orgs = await ctx.db.query("organizations").collect();
198
+
199
+ // 2. Create groups (type: "organization")
200
+ for (const org of orgs) {
201
+ const groupId = await ctx.db.insert("groups", {
202
+ slug: slugify(org.name),
203
+ name: org.name,
204
+ type: "organization", // Legacy type
205
+ parentGroupId: undefined,
206
+ description: undefined,
207
+ metadata: {},
208
+ settings: {
209
+ visibility: "private",
210
+ joinPolicy: "invite_only",
211
+ plan: org.plan,
212
+ limits: org.limits
213
+ },
214
+ status: org.status === "active" ? "active" : "archived",
215
+ createdAt: org.createdAt,
216
+ updatedAt: org.updatedAt
217
+ });
218
+
219
+ // 3. Update all entities, connections, events, knowledge
220
+ // Replace organizationId with groupId
221
+ }
222
+
223
+ return { migrated: orgs.length };
224
+ }
225
+ });
226
+ ```
227
+
228
+ **Duration:** 1 inference
229
+
230
+ ---
231
+
232
+ ## Timeline Summary
233
+
234
+ | Phase | What | Duration | Parallel? |
235
+ |-------|------|----------|-----------|
236
+ | 0 | Schema update | 1 inference | No (blocks all) |
237
+ | 1 | Backend (mutations + queries) | 1 inference | Yes (10 agents) |
238
+ | 2 | Frontend (components + routes) | 4 inferences | Partial (components parallel) |
239
+ | 3 | Documentation | 1 inference | Yes (44 agents) |
240
+ | 4 | Migration script | 1 inference | Yes (with Phase 3) |
241
+
242
+ **Total: ~7 inferences** (vs 100+ if sequential)
243
+
244
+ **Speed increase: 14x faster**
245
+
246
+ ---
247
+
248
+ ## Hierarchical Groups (New Capability)
249
+
250
+ Once groups are live, you can nest them:
251
+
252
+ ### Example 1: Company with Teams
253
+
254
+ ```typescript
255
+ // Parent: Acme Corporation
256
+ const acme = await createGroup({
257
+ slug: "acme-corp",
258
+ name: "Acme Corporation",
259
+ type: "business"
260
+ });
261
+
262
+ // Child: Engineering team
263
+ const engineering = await createGroup({
264
+ slug: "acme-corp-engineering",
265
+ name: "Engineering",
266
+ type: "business",
267
+ parentGroupId: acme._id // ← Nested!
268
+ });
269
+
270
+ // Grandchild: Backend team
271
+ const backend = await createGroup({
272
+ slug: "acme-corp-engineering-backend",
273
+ name: "Backend Team",
274
+ type: "business",
275
+ parentGroupId: engineering._id // ← Deeply nested!
276
+ });
277
+ ```
278
+
279
+ ### Example 2: DAO with Committees
280
+
281
+ ```typescript
282
+ // Parent: Main DAO
283
+ const dao = await createGroup({
284
+ slug: "cooldao",
285
+ name: "Cool DAO",
286
+ type: "dao"
287
+ });
288
+
289
+ // Children: Specialized committees
290
+ const treasury = await createGroup({
291
+ slug: "cooldao-treasury",
292
+ name: "Treasury Multisig",
293
+ type: "dao",
294
+ parentGroupId: dao._id
295
+ });
296
+
297
+ const governance = await createGroup({
298
+ slug: "cooldao-governance",
299
+ name: "Governance Committee",
300
+ type: "dao",
301
+ parentGroupId: dao._id
302
+ });
303
+ ```
304
+
305
+ **Query hierarchy:**
306
+ ```typescript
307
+ // Get all subgroups recursively
308
+ const allSubgroups = await getGroupHierarchy({ rootGroupId: dao._id });
309
+
310
+ // Get all entities across hierarchy
311
+ const allEntities = await getEntitiesInHierarchy({ rootGroupId: dao._id });
312
+ ```
313
+
314
+ ---
315
+
316
+ ## URL-Based Creation (New Capability)
317
+
318
+ Users can create groups just by visiting a URL:
319
+
320
+ ### Flow
321
+
322
+ 1. **User visits:** `one.ie/group/my-cool-dao`
323
+ 2. **Check if exists:** Query by slug
324
+ 3. **If not exists:** Show creation flow with slug pre-filled
325
+ 4. **User confirms:** Select type, add description, choose settings
326
+ 5. **Group created:** User becomes `org_owner`, redirected to group page
327
+ 6. **Share URL:** "Join my DAO at one.ie/group/my-cool-dao"
328
+
329
+ ### Implementation
330
+
331
+ ```typescript
332
+ // src/pages/group/[slug].astro
333
+ const { slug } = Astro.params;
334
+ const group = await convex.query(api.queries.groups.getBySlug, { slug });
335
+
336
+ if (!group) {
337
+ // Doesn't exist - redirect to creation
338
+ return Astro.redirect(`/group/${slug}/create`);
339
+ }
340
+
341
+ // Exists - show group page
342
+ return <GroupPage group={group} />;
343
+ ```
344
+
345
+ ---
346
+
347
+ ## Migration Path: Zero Downtime
348
+
349
+ ### Strategy
350
+
351
+ 1. **Deploy schema changes** (adds groups table, keeps organizations temporarily)
352
+ 2. **Deploy backend updates** (new code uses groupId, old code still works)
353
+ 3. **Run migration script** (creates groups from organizations)
354
+ 4. **Deploy frontend updates** (UI switches to groups terminology)
355
+ 5. **Monitor for 7 days** (keep organizations table as backup)
356
+ 6. **Archive organizations table** (after verification)
357
+
358
+ ### Backward Compatibility (1 version)
359
+
360
+ ```typescript
361
+ // Support both organizationId and groupId temporarily
362
+ export const create = mutation({
363
+ args: {
364
+ organizationId: v.optional(v.id("organizations")), // Deprecated
365
+ groupId: v.optional(v.id("groups")),
366
+ // ... other args
367
+ },
368
+ handler: async (ctx, args) => {
369
+ // Use groupId if provided, fallback to organizationId
370
+ const actualGroupId = args.groupId || args.organizationId;
371
+ // ... rest of implementation
372
+ }
373
+ });
374
+ ```
375
+
376
+ Remove backward compatibility in next major version.
377
+
378
+ ---
379
+
380
+ ## Key Differences: Organizations vs Groups
381
+
382
+ | Aspect | Organizations | Groups |
383
+ |--------|---------------|--------|
384
+ | **Scope** | Business-oriented | Universal (friends, DAOs, communities, etc.) |
385
+ | **Nesting** | Flat (no hierarchy) | Hierarchical (groups within groups) |
386
+ | **Creation** | Manual only | URL-based + manual |
387
+ | **Types** | One type | 6 types (friend_circle, business, community, dao, government, organization) |
388
+ | **Visibility** | Always private | Public or private |
389
+ | **Join Policy** | Always invite-only | Open, invite-only, or approval-required |
390
+ | **URL** | `/org/:id` | `/group/:slug` |
391
+ | **Multi-tenancy** | Perfect isolation | Perfect isolation (same guarantee) |
392
+
393
+ ---
394
+
395
+ ## Examples: Before & After
396
+
397
+ ### Before (Organizations)
398
+
399
+ ```typescript
400
+ // Emma's Lemonade Stand
401
+ const myStand = await createOrganization({
402
+ name: "Emma's Lemonade Stand",
403
+ plan: "starter"
404
+ });
405
+
406
+ const lemonade = await createThing({
407
+ type: "product",
408
+ name: "Fresh Lemonade",
409
+ organizationId: myStand._id
410
+ });
411
+ ```
412
+
413
+ ### After (Groups)
414
+
415
+ ```typescript
416
+ // Emma's Lemonade Stand (same functionality, more flexible)
417
+ const myStand = await createGroup({
418
+ slug: "emmas-lemonade",
419
+ name: "Emma's Lemonade Stand",
420
+ type: "business",
421
+ settings: {
422
+ visibility: "public", // NEW: Can be discovered
423
+ joinPolicy: "open" // NEW: Anyone can join
424
+ }
425
+ });
426
+
427
+ const lemonade = await createThing({
428
+ type: "product",
429
+ name: "Fresh Lemonade",
430
+ groupId: myStand._id // organizationId → groupId
431
+ });
432
+
433
+ // NEW: Emma can now create subgroups
434
+ const summerPromo = await createGroup({
435
+ slug: "emmas-lemonade-summer-2025",
436
+ name: "Summer 2025 Promotion",
437
+ type: "business",
438
+ parentGroupId: myStand._id // Nested under main business!
439
+ });
440
+ ```
441
+
442
+ ---
443
+
444
+ ## Validation: Multi-Tenancy Preserved
445
+
446
+ **Critical:** Groups maintain identical multi-tenant isolation as organizations.
447
+
448
+ ### Before (Organizations)
449
+
450
+ ```typescript
451
+ // All data scoped to organizationId
452
+ const myEntities = await ctx.db
453
+ .query("entities")
454
+ .withIndex("by_org", (q) => q.eq("organizationId", myOrg))
455
+ .collect();
456
+
457
+ // Perfect isolation - can't see other orgs' data
458
+ ```
459
+
460
+ ### After (Groups)
461
+
462
+ ```typescript
463
+ // All data scoped to groupId (same isolation!)
464
+ const myEntities = await ctx.db
465
+ .query("entities")
466
+ .withIndex("by_group", (q) => q.eq("groupId", myGroup))
467
+ .collect();
468
+
469
+ // Perfect isolation - can't see other groups' data
470
+ ```
471
+
472
+ **Plus hierarchical queries (new!):**
473
+
474
+ ```typescript
475
+ // Get entities across group hierarchy
476
+ const allEntities = await getEntitiesInHierarchy({
477
+ rootGroupId: myGroup
478
+ });
479
+ // Returns: myGroup entities + all subgroup entities
480
+ ```
481
+
482
+ ---
483
+
484
+ ## Summary
485
+
486
+ **The Big Idea:** Organizations → Groups = Same multi-tenancy + Hierarchical nesting + URL-based creation + Universal applicability
487
+
488
+ **The Change:**
489
+ - Table: `organizations` → `groups` (with 6 types)
490
+ - Field: `organizationId` → `groupId` (everywhere)
491
+ - New fields: `slug`, `type`, `parentGroupId`, `settings`
492
+
493
+ **The Strategy:** Maximize parallelization (7 inferences vs 100+)
494
+
495
+ **The Result:**
496
+ - ✅ Multi-tenancy preserved (same isolation guarantees)
497
+ - ✅ Hierarchical groups enabled (teams, committees, subgroups)
498
+ - ✅ URL-based creation unlocked (viral growth)
499
+ - ✅ Universal applicability (friends, businesses, DAOs, communities, governments)
500
+ - ✅ Backward compatible (organizations become group type)
501
+
502
+ **Organizations don't disappear. They evolve into groups.**