@soulcraft/brainy 2.5.0 → 2.7.0

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/README.md CHANGED
@@ -71,6 +71,18 @@ const filtered = await brain.find({
71
71
  })
72
72
  ```
73
73
 
74
+ ## 📋 System Requirements
75
+
76
+ **Node.js Version:** 22 LTS or later (recommended)
77
+
78
+ - ✅ **Node.js 22 LTS** - Fully supported and recommended for production
79
+ - ✅ **Node.js 20 LTS** - Compatible (maintenance mode)
80
+ - ❌ **Node.js 24** - Not supported (known ONNX runtime compatibility issues)
81
+
82
+ > **Important:** Brainy uses ONNX runtime for AI embeddings. Node.js 24 has known compatibility issues that cause crashes during inference operations. We recommend Node.js 22 LTS for maximum stability.
83
+
84
+ If using nvm: `nvm use` (we provide a `.nvmrc` file)
85
+
74
86
  ## 🚀 Key Features
75
87
 
76
88
  ### World's First Triple Intelligence™ Engine
@@ -294,6 +306,66 @@ brainy chat
294
306
  brainy export --format json > backup.json
295
307
  ```
296
308
 
309
+ ## 🧠 Neural API - Advanced AI Features
310
+
311
+ Brainy includes a powerful Neural API for advanced semantic analysis:
312
+
313
+ ### Clustering & Analysis
314
+ ```javascript
315
+ // Access via brain.neural
316
+ const neural = brain.neural
317
+
318
+ // Automatic semantic clustering
319
+ const clusters = await neural.clusters()
320
+ // Returns groups of semantically similar items
321
+
322
+ // Cluster with options
323
+ const clusters = await neural.clusters({
324
+ algorithm: 'kmeans', // or 'hierarchical', 'sample'
325
+ maxClusters: 5, // Maximum number of clusters
326
+ threshold: 0.8 // Similarity threshold
327
+ })
328
+
329
+ // Calculate similarity between any items
330
+ const similarity = await neural.similar('item1', 'item2')
331
+ // Returns 0-1 score
332
+
333
+ // Find nearest neighbors
334
+ const neighbors = await neural.neighbors('item-id', 10)
335
+
336
+ // Build semantic hierarchy
337
+ const hierarchy = await neural.hierarchy('item-id')
338
+
339
+ // Detect outliers
340
+ const outliers = await neural.outliers(0.3)
341
+
342
+ // Generate visualization data for D3/Cytoscape
343
+ const vizData = await neural.visualize({
344
+ maxNodes: 100,
345
+ dimensions: 3,
346
+ algorithm: 'force'
347
+ })
348
+ ```
349
+
350
+ ### Real-World Examples
351
+ ```javascript
352
+ // Group customer feedback into themes
353
+ const feedbackClusters = await neural.clusters()
354
+ for (const cluster of feedbackClusters) {
355
+ console.log(`Theme: ${cluster.label}`)
356
+ console.log(`Items: ${cluster.members.length}`)
357
+ }
358
+
359
+ // Find related documents
360
+ const docId = await brain.addNoun("Machine learning guide")
361
+ const similar = await neural.neighbors(docId, 5)
362
+ // Returns 5 most similar documents
363
+
364
+ // Detect anomalies in data
365
+ const anomalies = await neural.outliers(0.2)
366
+ console.log(`Found ${anomalies.length} outliers`)
367
+ ```
368
+
297
369
  ## 🔌 Augmentations
298
370
 
299
371
  Extend Brainy with powerful augmentations:
@@ -130,6 +130,9 @@ export declare abstract class BaseAugmentation implements BrainyAugmentation {
130
130
  abstract metadata: 'none' | 'readonly' | MetadataAccess;
131
131
  abstract operations: ('add' | 'addNoun' | 'addVerb' | 'saveNoun' | 'saveVerb' | 'updateMetadata' | 'delete' | 'deleteVerb' | 'clear' | 'get' | 'search' | 'searchText' | 'searchByNounTypes' | 'findSimilar' | 'searchWithCursor' | 'relate' | 'getConnections' | 'storage' | 'backup' | 'restore' | 'all')[];
132
132
  abstract priority: number;
133
+ category: 'internal' | 'core' | 'premium' | 'community' | 'external';
134
+ description: string;
135
+ enabled: boolean;
133
136
  protected context?: AugmentationContext;
134
137
  protected isInitialized: boolean;
135
138
  initialize(context: AugmentationContext): Promise<void>;
@@ -199,6 +202,17 @@ export declare class AugmentationRegistry {
199
202
  * Get all registered augmentations
200
203
  */
201
204
  getAll(): BrainyAugmentation[];
205
+ /**
206
+ * Get augmentation info for listing
207
+ */
208
+ getInfo(): Array<{
209
+ name: string;
210
+ type: string;
211
+ enabled: boolean;
212
+ description: string;
213
+ category: string;
214
+ priority: number;
215
+ }>;
202
216
  /**
203
217
  * Get augmentations by name
204
218
  */
@@ -16,6 +16,10 @@
16
16
  */
17
17
  export class BaseAugmentation {
18
18
  constructor() {
19
+ // Metadata for augmentation listing and management
20
+ this.category = 'core';
21
+ this.description = '';
22
+ this.enabled = true;
19
23
  this.isInitialized = false;
20
24
  }
21
25
  async initialize(context) {
@@ -124,6 +128,22 @@ export class AugmentationRegistry {
124
128
  getAll() {
125
129
  return [...this.augmentations];
126
130
  }
131
+ /**
132
+ * Get augmentation info for listing
133
+ */
134
+ getInfo() {
135
+ return this.augmentations.map(aug => {
136
+ const baseAug = aug;
137
+ return {
138
+ name: aug.name,
139
+ type: baseAug.category || 'core',
140
+ enabled: baseAug.enabled !== false,
141
+ description: baseAug.description || `${aug.name} augmentation`,
142
+ category: baseAug.category || 'core',
143
+ priority: aug.priority
144
+ };
145
+ });
146
+ }
127
147
  /**
128
148
  * Get augmentations by name
129
149
  */
@@ -31,6 +31,8 @@ export declare class CacheAugmentation extends BaseAugmentation {
31
31
  readonly metadata: "none";
32
32
  operations: ("search" | "add" | "delete" | "clear" | "all")[];
33
33
  readonly priority = 50;
34
+ readonly category: "core";
35
+ readonly description = "Transparent search result caching with automatic invalidation";
34
36
  private searchCache;
35
37
  private config;
36
38
  constructor(config?: CacheConfig);
@@ -26,6 +26,9 @@ export class CacheAugmentation extends BaseAugmentation {
26
26
  this.metadata = 'none'; // Cache doesn't access metadata
27
27
  this.operations = ['search', 'add', 'delete', 'clear', 'all'];
28
28
  this.priority = 50; // Mid-priority, runs after data operations
29
+ // Augmentation metadata
30
+ this.category = 'core';
31
+ this.description = 'Transparent search result caching with automatic invalidation';
29
32
  this.searchCache = null;
30
33
  this.config = {
31
34
  maxSize: 1000,
@@ -32,6 +32,8 @@ export declare class IndexAugmentation extends BaseAugmentation {
32
32
  readonly timing: "after";
33
33
  operations: ("add" | "updateMetadata" | "delete" | "clear" | "all")[];
34
34
  readonly priority = 60;
35
+ readonly category: "core";
36
+ readonly description = "Fast metadata field indexing for O(1) filtering and lookups";
35
37
  private metadataIndex;
36
38
  private config;
37
39
  private flushTimer;
@@ -26,6 +26,9 @@ export class IndexAugmentation extends BaseAugmentation {
26
26
  this.timing = 'after';
27
27
  this.operations = ['add', 'updateMetadata', 'delete', 'clear', 'all'];
28
28
  this.priority = 60; // Run after data operations
29
+ // Augmentation metadata
30
+ this.category = 'core';
31
+ this.description = 'Fast metadata field indexing for O(1) filtering and lookups';
29
32
  this.metadataIndex = null;
30
33
  this.flushTimer = null;
31
34
  this.config = {
@@ -57,7 +57,8 @@ export declare class IntelligentVerbScoringAugmentation extends BaseAugmentation
57
57
  };
58
58
  operations: ("addVerb" | "relate")[];
59
59
  priority: number;
60
- get enabled(): boolean;
60
+ readonly category: "core";
61
+ readonly description = "AI-powered intelligent scoring for relationship strength analysis";
61
62
  private config;
62
63
  private relationshipStats;
63
64
  private metrics;
@@ -12,10 +12,6 @@
12
12
  */
13
13
  import { BaseAugmentation } from './brainyAugmentation.js';
14
14
  export class IntelligentVerbScoringAugmentation extends BaseAugmentation {
15
- // Add enabled property for backward compatibility
16
- get enabled() {
17
- return this.config.enabled;
18
- }
19
15
  constructor(config = {}) {
20
16
  super();
21
17
  this.name = 'IntelligentVerbScoring';
@@ -26,6 +22,9 @@ export class IntelligentVerbScoringAugmentation extends BaseAugmentation {
26
22
  }; // Adds scoring metadata to verbs
27
23
  this.operations = ['addVerb', 'relate'];
28
24
  this.priority = 10; // Enhancement feature - runs after core operations
25
+ // Augmentation metadata
26
+ this.category = 'core';
27
+ this.description = 'AI-powered intelligent scoring for relationship strength analysis';
29
28
  this.relationshipStats = new Map();
30
29
  this.metrics = {
31
30
  relationshipsScored: 0,
@@ -59,6 +58,8 @@ export class IntelligentVerbScoringAugmentation extends BaseAugmentation {
59
58
  maxWeight: config.maxWeight ?? 1.0,
60
59
  baseWeight: config.baseWeight ?? 0.5
61
60
  };
61
+ // Set enabled property based on config
62
+ this.enabled = this.config.enabled;
62
63
  }
63
64
  async onInitialize() {
64
65
  if (this.config.enabled) {
@@ -39,6 +39,8 @@ export declare class UniversalDisplayAugmentation extends BaseAugmentation {
39
39
  readonly priority = 50;
40
40
  readonly metadata: MetadataAccess;
41
41
  operations: any;
42
+ readonly category: "core";
43
+ readonly description = "AI-powered intelligent display fields for enhanced data visualization";
42
44
  computedFields: {
43
45
  display: {
44
46
  title: {
@@ -45,6 +45,9 @@ export class UniversalDisplayAugmentation extends BaseAugmentation {
45
45
  writes: ['_display'] // Cache computed fields in isolated namespace
46
46
  };
47
47
  this.operations = ['get', 'search', 'findSimilar', 'getVerb', 'addNoun', 'addVerb'];
48
+ // Augmentation metadata
49
+ this.category = 'core';
50
+ this.description = 'AI-powered intelligent display fields for enhanced data visualization';
48
51
  // Computed fields declaration for TypeScript support and discovery
49
52
  this.computedFields = {
50
53
  display: {
@@ -27,6 +27,8 @@ export declare class WALAugmentation extends BaseAugmentation {
27
27
  metadata: "readonly";
28
28
  operations: ("addNoun" | "addVerb" | "saveNoun" | "saveVerb" | "updateMetadata" | "delete" | "deleteVerb" | "clear")[];
29
29
  priority: number;
30
+ readonly category: "internal";
31
+ readonly description = "Write-ahead logging for durability and crash recovery";
30
32
  private config;
31
33
  private currentLogId;
32
34
  private operationCounter;
@@ -20,6 +20,9 @@ export class WALAugmentation extends BaseAugmentation {
20
20
  this.metadata = 'readonly'; // Reads metadata for logging/recovery
21
21
  this.operations = ['addNoun', 'addVerb', 'saveNoun', 'saveVerb', 'updateMetadata', 'delete', 'deleteVerb', 'clear'];
22
22
  this.priority = 100; // Critical system operation - highest priority
23
+ // Augmentation metadata
24
+ this.category = 'internal';
25
+ this.description = 'Write-ahead logging for durability and crash recovery';
23
26
  this.operationCounter = 0;
24
27
  this.isRecovering = false;
25
28
  this.config = {
@@ -332,7 +332,7 @@ export interface BrainyDataConfig {
332
332
  intelligentVerbScoring?: {
333
333
  /**
334
334
  * Whether to enable intelligent verb scoring
335
- * Default: false (off by default)
335
+ * Default: true (enabled by default for better relationship quality)
336
336
  */
337
337
  enabled?: boolean;
338
338
  /**
@@ -296,11 +296,11 @@ export class BrainyData {
296
296
  ttl: 5000,
297
297
  maxSize: 1000
298
298
  }));
299
- // Priority 10: Enhancement features
300
- const intelligentVerbAugmentation = new IntelligentVerbScoringAugmentation(this.config.intelligentVerbScoring || { enabled: false });
299
+ // Priority 10: Core relationship quality features
300
+ const intelligentVerbAugmentation = new IntelligentVerbScoringAugmentation(this.config.intelligentVerbScoring || { enabled: true });
301
301
  this.augmentations.register(intelligentVerbAugmentation);
302
- // Store reference if intelligent verb scoring is enabled
303
- if (this.config.intelligentVerbScoring?.enabled) {
302
+ // Store reference if intelligent verb scoring is enabled (enabled by default)
303
+ if (this.config.intelligentVerbScoring?.enabled !== false) {
304
304
  this.intelligentVerbScoring = intelligentVerbAugmentation.getScoring();
305
305
  }
306
306
  }
@@ -6166,7 +6166,13 @@ export class BrainyData {
6166
6166
  * @returns Array of augmentations with name, type, and enabled status
6167
6167
  */
6168
6168
  listAugmentations() {
6169
- return augmentationPipeline.listAugmentationsWithStatus();
6169
+ // Use the real augmentation registry instead of deprecated pipeline
6170
+ return this.augmentations.getInfo().map(aug => ({
6171
+ name: aug.name,
6172
+ type: aug.category, // Map category to type for backward compatibility
6173
+ enabled: aug.enabled,
6174
+ description: aug.description
6175
+ }));
6170
6176
  }
6171
6177
  /**
6172
6178
  * Enable all augmentations of a specific type
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "2.5.0",
3
+ "version": "2.7.0",
4
4
  "description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. 31 nouns × 40 verbs for infinite expressiveness.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -55,7 +55,7 @@
55
55
  }
56
56
  },
57
57
  "engines": {
58
- "node": ">=18.0.0"
58
+ "node": ">=22.0.0"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "npm run build:patterns:if-needed && tsc",