From 791cacc6c0ce5979e5e23854459b4af6d4dbda9b Mon Sep 17 00:00:00 2001 From: David Snelling Date: Thu, 19 Feb 2026 17:46:18 -0800 Subject: [PATCH] docs: convert code examples to TypeScript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All code examples in installation.md and quick-start.md were tagged as javascript — converted to typescript throughout. quick-start.md also gets explicit type annotations: - reactId/nextId declared as string (return type of brain.add) - results declared as FindResult[] - results[0].data and results[0].score shown in console.log example --- docs/guides/installation.md | 6 +++--- docs/guides/quick-start.md | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/docs/guides/installation.md b/docs/guides/installation.md index 62d2690b..4a528a67 100644 --- a/docs/guides/installation.md +++ b/docs/guides/installation.md @@ -34,7 +34,7 @@ pnpm add @soulcraft/brainy ## Verify -```javascript +```typescript import { Brainy } from '@soulcraft/brainy' const brain = new Brainy() @@ -51,7 +51,7 @@ For production workloads, add Cortex for Rust-accelerated SIMD distance calculat npm install @soulcraft/cortex ``` -```javascript +```typescript import { Brainy } from '@soulcraft/brainy' import { registerCortex } from '@soulcraft/cortex' @@ -67,7 +67,7 @@ Cortex delivers a **5.2x geometric mean speedup** — see [Brainy vs Cortex](/do Brainy works in the browser using the Origin Private File System: -```javascript +```typescript import { Brainy } from '@soulcraft/brainy' const brain = new Brainy({ storage: 'opfs' }) diff --git a/docs/guides/quick-start.md b/docs/guides/quick-start.md index 7f871df2..61c1a2b1 100644 --- a/docs/guides/quick-start.md +++ b/docs/guides/quick-start.md @@ -23,7 +23,7 @@ npm install @soulcraft/brainy ## 2. Initialize -```javascript +```typescript import { Brainy, NounType, VerbType } from '@soulcraft/brainy' const brain = new Brainy() @@ -34,15 +34,15 @@ That's it. Brainy auto-configures storage, loads the embedding model, and builds ## 3. Add Knowledge -```javascript +```typescript // Text is automatically embedded into 384-dim vectors -const reactId = await brain.add({ +const reactId: string = await brain.add({ data: 'React is a JavaScript library for building user interfaces', type: NounType.Concept, metadata: { category: 'frontend', year: 2013 } }) -const nextId = await brain.add({ +const nextId: string = await brain.add({ data: 'Next.js framework for React with server-side rendering', type: NounType.Concept, metadata: { category: 'framework', year: 2016 } @@ -51,7 +51,7 @@ const nextId = await brain.add({ ## 4. Create Relationships -```javascript +```typescript // Typed graph relationships await brain.relate({ from: nextId, @@ -62,16 +62,18 @@ await brain.relate({ ## 5. Query with Triple Intelligence -```javascript +```typescript +import type { FindResult } from '@soulcraft/brainy' + // All three search paradigms in one call -const results = await brain.find({ +const results: FindResult[] = await brain.find({ query: 'modern frontend frameworks', // Vector similarity search where: { year: { greaterThan: 2015 } }, // Metadata filtering connected: { to: reactId, depth: 2 } // Graph traversal }) -console.log(results.items) -// [{ id: nextId, data: 'Next.js...', score: 0.94, ... }] +console.log(results[0].data) // 'Next.js framework for React...' +console.log(results[0].score) // 0.94 ``` ## What Just Happened @@ -90,7 +92,7 @@ Every entity you `add()` lives in three indexes simultaneously: Brainy understands 220+ natural language patterns: -```javascript +```typescript // These all work without any configuration await brain.find({ query: 'recent documents about machine learning' }) await brain.find({ query: 'articles created this week' })