@soulcraft/brainy 2.5.0 → 2.6.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
@@ -294,6 +294,66 @@ brainy chat
294
294
  brainy export --format json > backup.json
295
295
  ```
296
296
 
297
+ ## 🧠 Neural API - Advanced AI Features
298
+
299
+ Brainy includes a powerful Neural API for advanced semantic analysis:
300
+
301
+ ### Clustering & Analysis
302
+ ```javascript
303
+ // Access via brain.neural
304
+ const neural = brain.neural
305
+
306
+ // Automatic semantic clustering
307
+ const clusters = await neural.clusters()
308
+ // Returns groups of semantically similar items
309
+
310
+ // Cluster with options
311
+ const clusters = await neural.clusters({
312
+ algorithm: 'kmeans', // or 'hierarchical', 'sample'
313
+ maxClusters: 5, // Maximum number of clusters
314
+ threshold: 0.8 // Similarity threshold
315
+ })
316
+
317
+ // Calculate similarity between any items
318
+ const similarity = await neural.similar('item1', 'item2')
319
+ // Returns 0-1 score
320
+
321
+ // Find nearest neighbors
322
+ const neighbors = await neural.neighbors('item-id', 10)
323
+
324
+ // Build semantic hierarchy
325
+ const hierarchy = await neural.hierarchy('item-id')
326
+
327
+ // Detect outliers
328
+ const outliers = await neural.outliers(0.3)
329
+
330
+ // Generate visualization data for D3/Cytoscape
331
+ const vizData = await neural.visualize({
332
+ maxNodes: 100,
333
+ dimensions: 3,
334
+ algorithm: 'force'
335
+ })
336
+ ```
337
+
338
+ ### Real-World Examples
339
+ ```javascript
340
+ // Group customer feedback into themes
341
+ const feedbackClusters = await neural.clusters()
342
+ for (const cluster of feedbackClusters) {
343
+ console.log(`Theme: ${cluster.label}`)
344
+ console.log(`Items: ${cluster.members.length}`)
345
+ }
346
+
347
+ // Find related documents
348
+ const docId = await brain.addNoun("Machine learning guide")
349
+ const similar = await neural.neighbors(docId, 5)
350
+ // Returns 5 most similar documents
351
+
352
+ // Detect anomalies in data
353
+ const anomalies = await neural.outliers(0.2)
354
+ console.log(`Found ${anomalies.length} outliers`)
355
+ ```
356
+
297
357
  ## 🔌 Augmentations
298
358
 
299
359
  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.6.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",