oneie 3.6.27 → 3.6.30
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-builder.md +88 -0
- package/.claude/agents/agent-clone.md +2 -0
- package/.claude/agents/agent-frontend.md +87 -0
- package/.claude/agents/agent-writer.md +722 -0
- package/.claude/commands/create.md +26 -1
- package/.claude/commands/one.md +70 -8
- package/.claude/commands/push.md +42 -24
- package/.claude/commands/server.md +97 -48
- package/.claude/commands/start.md +182 -0
- package/.claude/hooks/.last-news-context +1 -0
- package/.claude/hooks/README-news-generation.md +364 -0
- package/.claude/hooks/push.sh +64 -12
- package/.claude/hooks/write-news.sh +194 -0
- package/CLAUDE.md +150 -1057
- package/one/knowledge/ontology-cheatsheet.md +78 -70
- package/one/knowledge/ontology-developer-guide.md +94 -87
- package/one/knowledge/ontology-index.md +51 -26
- package/one/knowledge/ontology-quickstart.md +58 -50
- package/one/knowledge/ontology-tutorial.md +27 -24
- package/one/knowledge/ontology-video-script.md +90 -59
- package/one/things/plans/multi-ontology-architecture.md +8 -8
- package/one/things/plans/ontology-compliance-audit.md +36 -9
- package/one/things/plans/video-backend.md +638 -0
- package/one/things/plans/video-frontend.md +432 -0
- package/one/things/plans/video-old-archived.md +656 -0
- package/package.json +1 -1
|
@@ -11,12 +11,12 @@ version: 1.0.0
|
|
|
11
11
|
ai_context: |
|
|
12
12
|
This document is part of the knowledge dimension in the ontology-developer-guide.md category.
|
|
13
13
|
Location: one/knowledge/ontology-developer-guide.md
|
|
14
|
-
Purpose: Documents
|
|
14
|
+
Purpose: Documents ONE Ontology architecture: developer guide
|
|
15
15
|
Related dimensions: connections, events, people, things
|
|
16
16
|
For AI agents: Read this to understand ontology developer guide.
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
#
|
|
19
|
+
# ONE Ontology Architecture: Developer Guide
|
|
20
20
|
|
|
21
21
|
**Version:** 1.0.0
|
|
22
22
|
**Last Updated:** 2025-10-20
|
|
@@ -66,7 +66,7 @@ type EntityType =
|
|
|
66
66
|
|
|
67
67
|
### The Solution: Composable Ontologies
|
|
68
68
|
|
|
69
|
-
The
|
|
69
|
+
The ONE Ontology architecture uses **feature-specific YAML files** that compose at runtime:
|
|
70
70
|
|
|
71
71
|
```
|
|
72
72
|
┌─────────────────────────────────────┐
|
|
@@ -131,21 +131,25 @@ eventTypes: # OPTIONAL: Event types this feature adds
|
|
|
131
131
|
### Naming Conventions
|
|
132
132
|
|
|
133
133
|
**Feature Names:**
|
|
134
|
+
|
|
134
135
|
- Lowercase, no spaces
|
|
135
136
|
- Use hyphens for multi-word features
|
|
136
137
|
- Examples: `core`, `blog`, `shop`, `social-media`
|
|
137
138
|
|
|
138
139
|
**Thing Type Names:**
|
|
140
|
+
|
|
139
141
|
- Lowercase with underscores
|
|
140
142
|
- Singular nouns
|
|
141
143
|
- Examples: `blog_post`, `product`, `user`, `shopping_cart`
|
|
142
144
|
|
|
143
145
|
**Connection Type Names:**
|
|
146
|
+
|
|
144
147
|
- Lowercase with underscores
|
|
145
148
|
- Action verbs (present tense)
|
|
146
149
|
- Examples: `created_by`, `posted_in`, `purchased`, `in_stock`
|
|
147
150
|
|
|
148
151
|
**Event Type Names:**
|
|
152
|
+
|
|
149
153
|
- Lowercase with underscores
|
|
150
154
|
- Past tense verbs
|
|
151
155
|
- Examples: `blog_post_published`, `product_created`, `order_placed`
|
|
@@ -156,19 +160,19 @@ eventTypes: # OPTIONAL: Event types this feature adds
|
|
|
156
160
|
|
|
157
161
|
```yaml
|
|
158
162
|
properties:
|
|
159
|
-
name: string
|
|
160
|
-
age: number
|
|
161
|
-
active: boolean
|
|
162
|
-
metadata: object
|
|
163
|
+
name: string # Text
|
|
164
|
+
age: number # Integer or float
|
|
165
|
+
active: boolean # true/false
|
|
166
|
+
metadata: object # JSON object (any structure)
|
|
163
167
|
```
|
|
164
168
|
|
|
165
169
|
**Array Types:**
|
|
166
170
|
|
|
167
171
|
```yaml
|
|
168
172
|
properties:
|
|
169
|
-
tags: string[]
|
|
170
|
-
scores: number[]
|
|
171
|
-
items: object[]
|
|
173
|
+
tags: string[] # Array of strings
|
|
174
|
+
scores: number[] # Array of numbers
|
|
175
|
+
items: object[] # Array of objects (not validated)
|
|
172
176
|
```
|
|
173
177
|
|
|
174
178
|
**Complex Types:**
|
|
@@ -177,8 +181,8 @@ For complex nested structures, use `object`:
|
|
|
177
181
|
|
|
178
182
|
```yaml
|
|
179
183
|
properties:
|
|
180
|
-
address: object
|
|
181
|
-
settings: object
|
|
184
|
+
address: object # { street, city, zip, country }
|
|
185
|
+
settings: object # { theme, language, notifications }
|
|
182
186
|
```
|
|
183
187
|
|
|
184
188
|
> **Note:** Object properties are not validated by the type system. Validation happens at runtime in mutation handlers.
|
|
@@ -190,13 +194,13 @@ Features can inherit types from a base feature:
|
|
|
190
194
|
```yaml
|
|
191
195
|
# ontology-blog.yaml
|
|
192
196
|
feature: blog
|
|
193
|
-
extends: core
|
|
197
|
+
extends: core # Inherits: page, user, file, link, note
|
|
194
198
|
description: Blog and content publishing
|
|
195
199
|
|
|
196
200
|
thingTypes:
|
|
197
|
-
- name: blog_post
|
|
201
|
+
- name: blog_post # ✅ Can use inherited types
|
|
198
202
|
properties:
|
|
199
|
-
authorId: string
|
|
203
|
+
authorId: string # ✅ References 'user' from core
|
|
200
204
|
```
|
|
201
205
|
|
|
202
206
|
**Inheritance Rules:**
|
|
@@ -281,7 +285,7 @@ function resolveFeatureDependencies(features: string[]): string[] {
|
|
|
281
285
|
function visit(feature: string, path: string[] = []) {
|
|
282
286
|
// Detect circular dependencies
|
|
283
287
|
if (path.includes(feature)) {
|
|
284
|
-
throw new Error(`Circular dependency: ${path.join(
|
|
288
|
+
throw new Error(`Circular dependency: ${path.join(" → ")} → ${feature}`);
|
|
285
289
|
}
|
|
286
290
|
|
|
287
291
|
// Skip if already resolved
|
|
@@ -349,8 +353,8 @@ feature: blog
|
|
|
349
353
|
thingTypes:
|
|
350
354
|
- name: blog_post
|
|
351
355
|
- name: blog_category
|
|
352
|
-
- name: product
|
|
353
|
-
- name: shopping_cart
|
|
356
|
+
- name: product # ❌ Wrong feature!
|
|
357
|
+
- name: shopping_cart # ❌ Wrong feature!
|
|
354
358
|
```
|
|
355
359
|
|
|
356
360
|
**Guideline:** If a type doesn't make sense without the feature, it belongs in that feature.
|
|
@@ -364,7 +368,7 @@ thingTypes:
|
|
|
364
368
|
```yaml
|
|
365
369
|
# ontology-advanced-blog.yaml
|
|
366
370
|
feature: advanced-blog
|
|
367
|
-
extends: blog
|
|
371
|
+
extends: blog # ✅ Builds on top of blog
|
|
368
372
|
thingTypes:
|
|
369
373
|
- name: blog_series
|
|
370
374
|
- name: blog_newsletter
|
|
@@ -375,7 +379,7 @@ thingTypes:
|
|
|
375
379
|
```yaml
|
|
376
380
|
# ontology-products.yaml
|
|
377
381
|
feature: products
|
|
378
|
-
extends: blog
|
|
382
|
+
extends: blog # ❌ Products have nothing to do with blog!
|
|
379
383
|
```
|
|
380
384
|
|
|
381
385
|
**Guideline:** Only extend features that are semantically related.
|
|
@@ -407,7 +411,7 @@ thingTypes:
|
|
|
407
411
|
thingTypes:
|
|
408
412
|
- name: product
|
|
409
413
|
properties:
|
|
410
|
-
data: object
|
|
414
|
+
data: object # ❌ Too vague!
|
|
411
415
|
```
|
|
412
416
|
|
|
413
417
|
**Guideline:** Be explicit about properties. Use `object` only for truly dynamic data.
|
|
@@ -420,11 +424,11 @@ thingTypes:
|
|
|
420
424
|
|
|
421
425
|
```yaml
|
|
422
426
|
connectionTypes:
|
|
423
|
-
- name: purchased
|
|
427
|
+
- name: purchased # ✅ Clear action
|
|
424
428
|
fromType: user
|
|
425
429
|
toType: product
|
|
426
430
|
|
|
427
|
-
- name: in_cart
|
|
431
|
+
- name: in_cart # ✅ Clear state
|
|
428
432
|
fromType: user
|
|
429
433
|
toType: product
|
|
430
434
|
```
|
|
@@ -433,7 +437,7 @@ connectionTypes:
|
|
|
433
437
|
|
|
434
438
|
```yaml
|
|
435
439
|
connectionTypes:
|
|
436
|
-
- name: user_product
|
|
440
|
+
- name: user_product # ❌ Too vague!
|
|
437
441
|
fromType: user
|
|
438
442
|
toType: product
|
|
439
443
|
```
|
|
@@ -457,8 +461,8 @@ eventTypes:
|
|
|
457
461
|
|
|
458
462
|
```yaml
|
|
459
463
|
eventTypes:
|
|
460
|
-
- name: create_product
|
|
461
|
-
- name: place_order
|
|
464
|
+
- name: create_product # ❌ Present tense!
|
|
465
|
+
- name: place_order # ❌ Imperative!
|
|
462
466
|
```
|
|
463
467
|
|
|
464
468
|
**Guideline:** Events describe what **happened** (past tense).
|
|
@@ -489,18 +493,18 @@ Each backend generates types for only its enabled features!
|
|
|
489
493
|
### Pattern 2: Feature Flags with Runtime Checks
|
|
490
494
|
|
|
491
495
|
```typescript
|
|
492
|
-
import { hasFeature } from
|
|
496
|
+
import { hasFeature } from "./types/ontology";
|
|
493
497
|
|
|
494
498
|
export const createBlogPost = mutation({
|
|
495
499
|
handler: async (ctx, args) => {
|
|
496
500
|
// Runtime check
|
|
497
|
-
if (!hasFeature(
|
|
498
|
-
throw new Error(
|
|
501
|
+
if (!hasFeature("blog")) {
|
|
502
|
+
throw new Error("Blog feature not enabled");
|
|
499
503
|
}
|
|
500
504
|
|
|
501
505
|
// Type-safe (TypeScript knows 'blog_post' exists)
|
|
502
|
-
await ctx.db.insert(
|
|
503
|
-
type:
|
|
506
|
+
await ctx.db.insert("things", {
|
|
507
|
+
type: "blog_post",
|
|
504
508
|
// ...
|
|
505
509
|
});
|
|
506
510
|
},
|
|
@@ -541,9 +545,9 @@ PUBLIC_FEATURES="core,blog-v1,blog-v2"
|
|
|
541
545
|
|
|
542
546
|
```typescript
|
|
543
547
|
// Load types dynamically based on environment
|
|
544
|
-
const features = process.env.PUBLIC_FEATURES?.split(
|
|
548
|
+
const features = process.env.PUBLIC_FEATURES?.split(",") || ["core"];
|
|
545
549
|
|
|
546
|
-
if (features.includes(
|
|
550
|
+
if (features.includes("blog")) {
|
|
547
551
|
// Blog-specific initialization
|
|
548
552
|
}
|
|
549
553
|
```
|
|
@@ -562,7 +566,7 @@ description: Multi-vendor marketplace (combines shop + vendors)
|
|
|
562
566
|
|
|
563
567
|
thingTypes:
|
|
564
568
|
- name: vendor
|
|
565
|
-
- name: vendor_product
|
|
569
|
+
- name: vendor_product # Product with vendor info
|
|
566
570
|
|
|
567
571
|
connectionTypes:
|
|
568
572
|
- name: sold_by
|
|
@@ -587,6 +591,7 @@ PUBLIC_FEATURES="core,blog"
|
|
|
587
591
|
```
|
|
588
592
|
|
|
589
593
|
**Impact:**
|
|
594
|
+
|
|
590
595
|
- Smaller TypeScript bundle
|
|
591
596
|
- Faster type checking
|
|
592
597
|
- Fewer database indexes
|
|
@@ -617,9 +622,9 @@ The generated `ontology.ts` file is deterministic. Cache it:
|
|
|
617
622
|
|
|
618
623
|
```typescript
|
|
619
624
|
// Check if types are up-to-date
|
|
620
|
-
const hash = hashFile(
|
|
625
|
+
const hash = hashFile("/one/knowledge/ontology-*.yaml");
|
|
621
626
|
if (cachedHash === hash) {
|
|
622
|
-
console.log(
|
|
627
|
+
console.log("Types are up-to-date");
|
|
623
628
|
return;
|
|
624
629
|
}
|
|
625
630
|
|
|
@@ -635,18 +640,18 @@ Don't load validators for disabled features:
|
|
|
635
640
|
|
|
636
641
|
```typescript
|
|
637
642
|
// ❌ Load all validators upfront
|
|
638
|
-
import { validateBlogPost } from
|
|
639
|
-
import { validateProduct } from
|
|
643
|
+
import { validateBlogPost } from "./validators/blog";
|
|
644
|
+
import { validateProduct } from "./validators/shop";
|
|
640
645
|
|
|
641
646
|
// ✅ Lazy load only when needed
|
|
642
647
|
const validators = {
|
|
643
648
|
get blog_post() {
|
|
644
|
-
if (!hasFeature(
|
|
645
|
-
return require(
|
|
649
|
+
if (!hasFeature("blog")) throw new Error("Blog not enabled");
|
|
650
|
+
return require("./validators/blog").validateBlogPost;
|
|
646
651
|
},
|
|
647
652
|
get product() {
|
|
648
|
-
if (!hasFeature(
|
|
649
|
-
return require(
|
|
653
|
+
if (!hasFeature("shop")) throw new Error("Shop not enabled");
|
|
654
|
+
return require("./validators/shop").validateProduct;
|
|
650
655
|
},
|
|
651
656
|
};
|
|
652
657
|
```
|
|
@@ -658,26 +663,26 @@ const validators = {
|
|
|
658
663
|
### 1. Test Ontology Loading
|
|
659
664
|
|
|
660
665
|
```typescript
|
|
661
|
-
import { describe, it, expect } from
|
|
662
|
-
import { loadOntology } from
|
|
663
|
-
|
|
664
|
-
describe(
|
|
665
|
-
it(
|
|
666
|
-
const core = loadOntology(
|
|
667
|
-
expect(core.thingTypes).toContain(
|
|
668
|
-
expect(core.thingTypes).toContain(
|
|
666
|
+
import { describe, it, expect } from "bun:test";
|
|
667
|
+
import { loadOntology } from "./scripts/generate-ontology-types";
|
|
668
|
+
|
|
669
|
+
describe("Ontology Loading", () => {
|
|
670
|
+
it("should load core ontology", () => {
|
|
671
|
+
const core = loadOntology("core");
|
|
672
|
+
expect(core.thingTypes).toContain("page");
|
|
673
|
+
expect(core.thingTypes).toContain("user");
|
|
669
674
|
});
|
|
670
675
|
|
|
671
|
-
it(
|
|
672
|
-
const features = [
|
|
676
|
+
it("should resolve dependencies", () => {
|
|
677
|
+
const features = ["blog", "shop"];
|
|
673
678
|
const resolved = resolveFeatureDependencies(features);
|
|
674
|
-
expect(resolved).toEqual([
|
|
679
|
+
expect(resolved).toEqual(["core", "blog", "shop"]);
|
|
675
680
|
});
|
|
676
681
|
|
|
677
|
-
it(
|
|
682
|
+
it("should detect circular dependencies", () => {
|
|
678
683
|
expect(() => {
|
|
679
|
-
resolveFeatureDependencies([
|
|
680
|
-
}).toThrow(
|
|
684
|
+
resolveFeatureDependencies(["circular-a", "circular-b"]);
|
|
685
|
+
}).toThrow("Circular dependency");
|
|
681
686
|
});
|
|
682
687
|
});
|
|
683
688
|
```
|
|
@@ -687,20 +692,20 @@ describe('Ontology Loading', () => {
|
|
|
687
692
|
### 2. Test Type Guards
|
|
688
693
|
|
|
689
694
|
```typescript
|
|
690
|
-
describe(
|
|
691
|
-
it(
|
|
692
|
-
expect(isThingType(
|
|
693
|
-
expect(isThingType(
|
|
695
|
+
describe("Type Guards", () => {
|
|
696
|
+
it("should validate thing types", () => {
|
|
697
|
+
expect(isThingType("blog_post")).toBe(true);
|
|
698
|
+
expect(isThingType("invalid")).toBe(false);
|
|
694
699
|
});
|
|
695
700
|
|
|
696
|
-
it(
|
|
697
|
-
expect(isConnectionType(
|
|
698
|
-
expect(isConnectionType(
|
|
701
|
+
it("should validate connection types", () => {
|
|
702
|
+
expect(isConnectionType("created_by")).toBe(true);
|
|
703
|
+
expect(isConnectionType("invalid")).toBe(false);
|
|
699
704
|
});
|
|
700
705
|
|
|
701
|
-
it(
|
|
702
|
-
expect(isEventType(
|
|
703
|
-
expect(isEventType(
|
|
706
|
+
it("should validate event types", () => {
|
|
707
|
+
expect(isEventType("thing_created")).toBe(true);
|
|
708
|
+
expect(isEventType("invalid")).toBe(false);
|
|
704
709
|
});
|
|
705
710
|
});
|
|
706
711
|
```
|
|
@@ -710,16 +715,16 @@ describe('Type Guards', () => {
|
|
|
710
715
|
### 3. Test Feature Flags
|
|
711
716
|
|
|
712
717
|
```typescript
|
|
713
|
-
describe(
|
|
714
|
-
it(
|
|
715
|
-
process.env.PUBLIC_FEATURES =
|
|
716
|
-
expect(hasFeature(
|
|
717
|
-
expect(hasFeature(
|
|
718
|
+
describe("Feature Flags", () => {
|
|
719
|
+
it("should detect enabled features", () => {
|
|
720
|
+
process.env.PUBLIC_FEATURES = "core,blog";
|
|
721
|
+
expect(hasFeature("blog")).toBe(true);
|
|
722
|
+
expect(hasFeature("shop")).toBe(false);
|
|
718
723
|
});
|
|
719
724
|
|
|
720
|
-
it(
|
|
721
|
-
process.env.PUBLIC_FEATURES =
|
|
722
|
-
expect(ENABLED_FEATURES).toEqual([
|
|
725
|
+
it("should list all enabled features", () => {
|
|
726
|
+
process.env.PUBLIC_FEATURES = "core,blog,shop";
|
|
727
|
+
expect(ENABLED_FEATURES).toEqual(["core", "blog", "shop"]);
|
|
723
728
|
});
|
|
724
729
|
});
|
|
725
730
|
```
|
|
@@ -731,32 +736,34 @@ describe('Feature Flags', () => {
|
|
|
731
736
|
Test mutations with different feature sets:
|
|
732
737
|
|
|
733
738
|
```typescript
|
|
734
|
-
describe(
|
|
739
|
+
describe("Blog Mutations (blog enabled)", () => {
|
|
735
740
|
beforeAll(() => {
|
|
736
|
-
process.env.PUBLIC_FEATURES =
|
|
741
|
+
process.env.PUBLIC_FEATURES = "core,blog";
|
|
737
742
|
regenerateTypes();
|
|
738
743
|
});
|
|
739
744
|
|
|
740
|
-
it(
|
|
745
|
+
it("should create blog post", async () => {
|
|
741
746
|
const id = await createBlogPost({
|
|
742
|
-
title:
|
|
743
|
-
content:
|
|
747
|
+
title: "Test Post",
|
|
748
|
+
content: "Content",
|
|
744
749
|
});
|
|
745
750
|
expect(id).toBeDefined();
|
|
746
751
|
});
|
|
747
752
|
});
|
|
748
753
|
|
|
749
|
-
describe(
|
|
754
|
+
describe("Blog Mutations (blog disabled)", () => {
|
|
750
755
|
beforeAll(() => {
|
|
751
|
-
process.env.PUBLIC_FEATURES =
|
|
756
|
+
process.env.PUBLIC_FEATURES = "core";
|
|
752
757
|
regenerateTypes();
|
|
753
758
|
});
|
|
754
759
|
|
|
755
|
-
it(
|
|
756
|
-
await expect(
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
+
it("should reject blog post creation", async () => {
|
|
761
|
+
await expect(
|
|
762
|
+
createBlogPost({
|
|
763
|
+
title: "Test Post",
|
|
764
|
+
content: "Content",
|
|
765
|
+
})
|
|
766
|
+
).rejects.toThrow("Blog feature not enabled");
|
|
760
767
|
});
|
|
761
768
|
});
|
|
762
769
|
```
|
|
@@ -791,7 +798,7 @@ ONTOLOGY_DEBUG=true bun run scripts/generate-ontology-types.ts
|
|
|
791
798
|
|
|
792
799
|
## Summary
|
|
793
800
|
|
|
794
|
-
The
|
|
801
|
+
The ONE Ontology architecture provides:
|
|
795
802
|
|
|
796
803
|
✅ **Composability** - Features are independent and composable
|
|
797
804
|
✅ **Type Safety** - Full TypeScript validation
|