@soulcraft/brainy 4.6.0 → 4.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/dist/brainy.d.ts CHANGED
@@ -545,18 +545,23 @@ export declare class Brainy<T = any> implements BrainyInterface<T> {
545
545
  * // Returns only knowledge entities, VFS files excluded
546
546
  *
547
547
  * @example
548
- * // Include VFS entities when needed
548
+ * // v4.7.0: VFS entities included by default
549
549
  * const everything = await brainy.find({
550
- * query: 'documentation',
551
- * includeVFS: true // Opt-in to include VFS files
550
+ * query: 'documentation'
552
551
  * })
553
552
  * // Returns both knowledge entities AND VFS files
554
553
  *
555
554
  * @example
556
555
  * // Search only VFS files
557
556
  * const files = await brainy.find({
558
- * where: { vfsType: 'file', extension: '.md' },
559
- * includeVFS: true // Required to find VFS entities
557
+ * where: { vfsType: 'file', extension: '.md' }
558
+ * })
559
+ *
560
+ * @example
561
+ * // Exclude VFS entities (if needed)
562
+ * const concepts = await brainy.find({
563
+ * query: 'machine learning',
564
+ * excludeVFS: true // v4.7.0: Exclude VFS files
560
565
  * })
561
566
  */
562
567
  find(query: string | FindParams<T>): Promise<Result<T>[]>;
package/dist/brainy.js CHANGED
@@ -852,13 +852,8 @@ export class Brainy {
852
852
  if (params.service) {
853
853
  filter.service = params.service;
854
854
  }
855
- // v4.5.1: Exclude VFS relationships by default (same pattern as brain.find())
856
- // VFS relationships have metadata.isVFS = true
857
- // Only include VFS relationships if explicitly requested
858
- if (params.includeVFS !== true) {
859
- filter.metadata = filter.metadata || {};
860
- filter.metadata.isVFS = { notEquals: true };
861
- }
855
+ // v4.7.0: VFS relationships are no longer filtered
856
+ // VFS is part of the knowledge graph - users can filter explicitly if needed
862
857
  // Fetch from storage with pagination at storage layer (efficient!)
863
858
  const result = await this.storage.getVerbs({
864
859
  pagination: {
@@ -1033,18 +1028,23 @@ export class Brainy {
1033
1028
  * // Returns only knowledge entities, VFS files excluded
1034
1029
  *
1035
1030
  * @example
1036
- * // Include VFS entities when needed
1031
+ * // v4.7.0: VFS entities included by default
1037
1032
  * const everything = await brainy.find({
1038
- * query: 'documentation',
1039
- * includeVFS: true // Opt-in to include VFS files
1033
+ * query: 'documentation'
1040
1034
  * })
1041
1035
  * // Returns both knowledge entities AND VFS files
1042
1036
  *
1043
1037
  * @example
1044
1038
  * // Search only VFS files
1045
1039
  * const files = await brainy.find({
1046
- * where: { vfsType: 'file', extension: '.md' },
1047
- * includeVFS: true // Required to find VFS entities
1040
+ * where: { vfsType: 'file', extension: '.md' }
1041
+ * })
1042
+ *
1043
+ * @example
1044
+ * // Exclude VFS entities (if needed)
1045
+ * const concepts = await brainy.find({
1046
+ * query: 'machine learning',
1047
+ * excludeVFS: true // v4.7.0: Exclude VFS files
1048
1048
  * })
1049
1049
  */
1050
1050
  async find(query) {
@@ -1090,11 +1090,10 @@ export class Brainy {
1090
1090
  Object.assign(filter, params.where);
1091
1091
  if (params.service)
1092
1092
  filter.service = params.service;
1093
- // v4.3.3: Exclude VFS entities by default (Option 3C architecture)
1094
- // Only include VFS if explicitly requested via includeVFS: true
1095
- // BUT: Don't add automatic exclusion if user explicitly queries isVFS in where clause
1096
- if (params.includeVFS !== true && !params.where?.hasOwnProperty('isVFS')) {
1097
- filter.isVFS = { notEquals: true };
1093
+ // v4.7.0: excludeVFS helper for cleaner UX
1094
+ // Use vfsType field (more semantic than isVFS)
1095
+ if (params.excludeVFS === true) {
1096
+ filter.vfsType = { exists: false };
1098
1097
  }
1099
1098
  if (params.type) {
1100
1099
  const types = Array.isArray(params.type) ? params.type : [params.type];
@@ -1137,12 +1136,12 @@ export class Brainy {
1137
1136
  if (!hasVectorSearchCriteria && !hasFilterCriteria && !hasGraphCriteria) {
1138
1137
  const limit = params.limit || 20;
1139
1138
  const offset = params.offset || 0;
1140
- // v4.3.3: Apply VFS filtering even for empty queries
1139
+ // v4.7.0: excludeVFS helper
1141
1140
  let filter = {};
1142
- if (params.includeVFS !== true) {
1143
- filter.isVFS = { notEquals: true };
1141
+ if (params.excludeVFS === true) {
1142
+ filter.vfsType = { exists: false };
1144
1143
  }
1145
- // Use metadata index if we need to filter VFS
1144
+ // Use metadata index if we need to filter
1146
1145
  if (Object.keys(filter).length > 0) {
1147
1146
  const filteredIds = await this.metadataIndex.getIdsForFilter(filter);
1148
1147
  const pageIds = filteredIds.slice(offset, offset + limit);
@@ -1197,7 +1196,7 @@ export class Brainy {
1197
1196
  results = Array.from(uniqueResults.values());
1198
1197
  }
1199
1198
  // Apply O(log n) metadata filtering using core MetadataIndexManager
1200
- if (params.where || params.type || params.service || params.includeVFS !== true) {
1199
+ if (params.where || params.type || params.service || params.excludeVFS) {
1201
1200
  // Build filter object for metadata index
1202
1201
  let filter = {};
1203
1202
  // Base filter from where and service
@@ -1205,10 +1204,9 @@ export class Brainy {
1205
1204
  Object.assign(filter, params.where);
1206
1205
  if (params.service)
1207
1206
  filter.service = params.service;
1208
- // v4.3.3: Exclude VFS entities by default (Option 3C architecture)
1209
- // BUT: Don't add automatic exclusion if user explicitly queries isVFS in where clause
1210
- if (params.includeVFS !== true && !params.where?.hasOwnProperty('isVFS')) {
1211
- filter.isVFS = { notEquals: true };
1207
+ // v4.7.0: excludeVFS helper for cleaner UX
1208
+ if (params.excludeVFS === true) {
1209
+ filter.vfsType = { exists: false };
1212
1210
  }
1213
1211
  if (params.type) {
1214
1212
  const types = Array.isArray(params.type) ? params.type : [params.type];
@@ -1480,7 +1478,7 @@ export class Brainy {
1480
1478
  type: params.type,
1481
1479
  where: params.where,
1482
1480
  service: params.service,
1483
- includeVFS: params.includeVFS // v4.4.0: Pass through VFS filtering
1481
+ excludeVFS: params.excludeVFS // v4.7.0: Pass through VFS filtering
1484
1482
  });
1485
1483
  }
1486
1484
  // ============= BATCH OPERATIONS =============
@@ -274,10 +274,8 @@ export const coreCommands = {
274
274
  if (options.includeRelations) {
275
275
  searchParams.includeRelations = true;
276
276
  }
277
- // Include VFS files (v4.4.0 - find excludes VFS by default)
278
- if (options.includeVfs) {
279
- searchParams.includeVFS = true;
280
- }
277
+ // v4.7.0: VFS is now part of the knowledge graph (included by default)
278
+ // Users can exclude VFS with --where vfsType exists:false if needed
281
279
  // Triple Intelligence Fusion - custom weighting
282
280
  if (options.fusion || options.vectorWeight || options.graphWeight || options.fieldWeight) {
283
281
  searchParams.fusion = {
@@ -148,7 +148,7 @@ export interface FindParams<T = any> {
148
148
  mode?: SearchMode;
149
149
  explain?: boolean;
150
150
  includeRelations?: boolean;
151
- includeVFS?: boolean;
151
+ excludeVFS?: boolean;
152
152
  service?: string;
153
153
  fusion?: {
154
154
  strategy?: 'adaptive' | 'weighted' | 'progressive';
@@ -186,7 +186,7 @@ export interface SimilarParams<T = any> {
186
186
  type?: NounType | NounType[];
187
187
  where?: Partial<T>;
188
188
  service?: string;
189
- includeVFS?: boolean;
189
+ excludeVFS?: boolean;
190
190
  }
191
191
  /**
192
192
  * Parameters for getting relationships
@@ -268,16 +268,6 @@ export interface GetRelationsParams {
268
268
  * Only return relationships belonging to this service.
269
269
  */
270
270
  service?: string;
271
- /**
272
- * Include VFS relationships (v4.5.1)
273
- *
274
- * By default, getRelations() excludes VFS relationships (since v4.4.0).
275
- * Set this to true when you need to traverse VFS structure.
276
- *
277
- * @default false
278
- * @since v4.5.1
279
- */
280
- includeVFS?: boolean;
281
271
  }
282
272
  /**
283
273
  * Batch add parameters
@@ -131,12 +131,11 @@ export class PathResolver {
131
131
  // Use cached knowledge to quickly find the child
132
132
  // Still need to verify it exists
133
133
  }
134
- // Use proper graph traversal to find children
135
- // Get all relationships where parentId contains other entities
134
+ // v4.7.0: Use proper graph traversal to find children
135
+ // VFS relationships are now part of the knowledge graph
136
136
  const relations = await this.brain.getRelations({
137
137
  from: parentId,
138
- type: VerbType.Contains,
139
- includeVFS: true // v4.5.1: Required to see VFS relationships
138
+ type: VerbType.Contains
140
139
  });
141
140
  // Find the child with matching name
142
141
  for (const relation of relations) {
@@ -157,11 +156,11 @@ export class PathResolver {
157
156
  * Uses proper graph relationships to traverse the tree
158
157
  */
159
158
  async getChildren(dirId) {
160
- // Production-ready: Use graph relationships (VFS creates these in mkdir/writeFile)
159
+ // v4.7.0: Use O(1) graph relationships (VFS creates these in mkdir/writeFile)
160
+ // VFS relationships are now part of the knowledge graph (no special filtering needed)
161
161
  const relations = await this.brain.getRelations({
162
162
  from: dirId,
163
- type: VerbType.Contains,
164
- includeVFS: true // v4.5.1: Required to see VFS relationships
163
+ type: VerbType.Contains
165
164
  });
166
165
  const validChildren = [];
167
166
  const childNames = new Set();
@@ -98,8 +98,7 @@ export class VirtualFileSystem {
98
98
  path: '/', // ✅ Correct field name
99
99
  vfsType: 'directory' // ✅ Correct field name
100
100
  },
101
- limit: 10,
102
- includeVFS: true // v4.4.0: CRITICAL - Must find VFS root entity!
101
+ limit: 10
103
102
  });
104
103
  if (existing.length > 0) {
105
104
  // Handle duplicate roots (Workshop team reported ~10 duplicates!)
@@ -780,9 +779,8 @@ export class VirtualFileSystem {
780
779
  limit: options?.limit || 10,
781
780
  offset: options?.offset,
782
781
  explain: options?.explain,
783
- includeVFS: true, // v4.4.0: VFS search must include VFS entities!
784
782
  where: {
785
- vfsType: 'file' // v4.4.0: Only search VFS files, not knowledge documents
783
+ vfsType: 'file' // v4.7.0: Search VFS files
786
784
  }
787
785
  };
788
786
  // Add path filter if specified
@@ -824,9 +822,8 @@ export class VirtualFileSystem {
824
822
  limit: options?.limit || 10,
825
823
  threshold: options?.threshold || 0.7,
826
824
  type: [NounType.File, NounType.Document, NounType.Media],
827
- includeVFS: true, // v4.4.0: VFS similarity search must include VFS entities!
828
825
  where: {
829
- vfsType: 'file' // v4.4.0: Only find similar VFS files, not knowledge documents
826
+ vfsType: 'file' // v4.7.0: Find similar VFS files
830
827
  }
831
828
  });
832
829
  return results.map(r => {
@@ -1969,8 +1966,7 @@ export class VirtualFileSystem {
1969
1966
  ...query.where,
1970
1967
  vfsType: 'entity'
1971
1968
  },
1972
- limit: query.limit || 100,
1973
- includeVFS: true // v4.4.0: VFS entity search must include VFS entities!
1969
+ limit: query.limit || 100
1974
1970
  };
1975
1971
  if (query.type) {
1976
1972
  searchQuery.where.entityType = query.type;
@@ -27,8 +27,7 @@ export class AuthorProjection extends BaseProjectionStrategy {
27
27
  vfsType: 'file',
28
28
  owner: authorName
29
29
  },
30
- limit: 1000,
31
- includeVFS: true // v4.4.0: Must include VFS entities!
30
+ limit: 1000
32
31
  };
33
32
  // Filter by filename if subpath specified
34
33
  if (subpath) {
@@ -46,14 +45,13 @@ export class AuthorProjection extends BaseProjectionStrategy {
46
45
  * Resolve author to entity IDs using REAL Brainy.find()
47
46
  */
48
47
  async resolve(brain, vfs, authorName) {
49
- // Use REAL Brainy metadata filtering
48
+ // v4.7.0: VFS entities are part of the knowledge graph
50
49
  const results = await brain.find({
51
50
  where: {
52
51
  vfsType: 'file',
53
52
  owner: authorName
54
53
  },
55
- limit: 1000,
56
- includeVFS: true // v4.4.0: Must include VFS entities!
54
+ limit: 1000
57
55
  });
58
56
  return this.extractIds(results);
59
57
  }
@@ -66,10 +64,9 @@ export class AuthorProjection extends BaseProjectionStrategy {
66
64
  const results = await brain.find({
67
65
  where: {
68
66
  vfsType: 'file',
69
- owner: { $exists: true }
67
+ owner: { exists: true }
70
68
  },
71
- limit,
72
- includeVFS: true // v4.4.0: Must include VFS entities!
69
+ limit
73
70
  });
74
71
  return results.map(r => r.entity);
75
72
  }
@@ -25,10 +25,9 @@ export class TagProjection extends BaseProjectionStrategy {
25
25
  const query = {
26
26
  where: {
27
27
  vfsType: 'file',
28
- tags: { contains: tagName } // BFO operator for array contains
28
+ tags: { contains: tagName } // contains operator for array search
29
29
  },
30
- limit: 1000,
31
- includeVFS: true // v4.4.0: Must include VFS entities!
30
+ limit: 1000
32
31
  };
33
32
  // Filter by filename if subpath specified
34
33
  if (subpath) {
@@ -46,14 +45,13 @@ export class TagProjection extends BaseProjectionStrategy {
46
45
  * Resolve tag to entity IDs using REAL Brainy.find()
47
46
  */
48
47
  async resolve(brain, vfs, tagName) {
49
- // Use REAL Brainy metadata filtering
48
+ // v4.7.0: VFS entities are part of the knowledge graph
50
49
  const results = await brain.find({
51
50
  where: {
52
51
  vfsType: 'file',
53
- tags: { contains: tagName } // BFO operator
52
+ tags: { contains: tagName }
54
53
  },
55
- limit: 1000,
56
- includeVFS: true // v4.4.0: Must include VFS entities!
54
+ limit: 1000
57
55
  });
58
56
  return this.extractIds(results);
59
57
  }
@@ -65,10 +63,9 @@ export class TagProjection extends BaseProjectionStrategy {
65
63
  const results = await brain.find({
66
64
  where: {
67
65
  vfsType: 'file',
68
- tags: { exists: true } // BFO operator
66
+ tags: { exists: true } // exists operator
69
67
  },
70
- limit,
71
- includeVFS: true // v4.4.0: Must include VFS entities!
68
+ limit
72
69
  });
73
70
  return results.map(r => r.entity);
74
71
  }
@@ -58,17 +58,16 @@ export class TemporalProjection extends BaseProjectionStrategy {
58
58
  startOfDay.setHours(0, 0, 0, 0);
59
59
  const endOfDay = new Date(date);
60
60
  endOfDay.setHours(23, 59, 59, 999);
61
- // Use REAL Brainy metadata filtering with range operators
61
+ // v4.7.0: VFS entities are part of the knowledge graph
62
62
  const results = await brain.find({
63
63
  where: {
64
64
  vfsType: 'file',
65
65
  modified: {
66
- greaterEqual: startOfDay.getTime(), // BFO operator
67
- lessEqual: endOfDay.getTime() // BFO operator
66
+ greaterEqual: startOfDay.getTime(),
67
+ lessEqual: endOfDay.getTime()
68
68
  }
69
69
  },
70
- limit: 1000,
71
- includeVFS: true // v4.4.0: Must include VFS entities!
70
+ limit: 1000
72
71
  });
73
72
  return this.extractIds(results);
74
73
  }
@@ -80,10 +79,9 @@ export class TemporalProjection extends BaseProjectionStrategy {
80
79
  const results = await brain.find({
81
80
  where: {
82
81
  vfsType: 'file',
83
- modified: { greaterEqual: oneDayAgo } // BFO operator
82
+ modified: { greaterEqual: oneDayAgo }
84
83
  },
85
- limit,
86
- includeVFS: true // v4.4.0: Must include VFS entities!
84
+ limit
87
85
  });
88
86
  return results.map(r => r.entity);
89
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "4.6.0",
3
+ "version": "4.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",