@soulcraft/brainy 3.14.1 → 3.15.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.
@@ -247,6 +247,20 @@ export class VirtualFileSystem {
247
247
  data: entityData,
248
248
  metadata
249
249
  });
250
+ // Ensure Contains relationship exists (fix for missing relationships)
251
+ const existingRelations = await this.brain.getRelations({
252
+ from: parentId,
253
+ to: existingId,
254
+ type: VerbType.Contains
255
+ });
256
+ // Create relationship if it doesn't exist
257
+ if (existingRelations.length === 0) {
258
+ await this.brain.relate({
259
+ from: parentId,
260
+ to: existingId,
261
+ type: VerbType.Contains
262
+ });
263
+ }
250
264
  }
251
265
  else {
252
266
  // Create new file entity
@@ -716,7 +730,11 @@ export class VirtualFileSystem {
716
730
  // ============= Helper Methods =============
717
731
  async ensureInitialized() {
718
732
  if (!this.initialized) {
719
- throw new Error('VFS not initialized. Call init() first.');
733
+ throw new Error('VFS not initialized. You must call await vfs.init() after getting the VFS instance.\n' +
734
+ 'Example:\n' +
735
+ ' const vfs = brain.vfs() // Note: vfs() is a method, not a property\n' +
736
+ ' await vfs.init() // This creates the root directory\n' +
737
+ 'See docs: https://github.com/Brainy-Technologies/brainy/blob/main/docs/vfs/QUICK_START.md');
720
738
  }
721
739
  }
722
740
  async ensureDirectory(path) {
@@ -732,9 +750,13 @@ export class VirtualFileSystem {
732
750
  return entityId;
733
751
  }
734
752
  catch (err) {
735
- // Directory doesn't exist, create it recursively
736
- await this.mkdir(path, { recursive: true });
737
- return await this.pathResolver.resolve(path);
753
+ // Only create directory if it doesn't exist (ENOENT error)
754
+ if (err instanceof VFSError && err.code === VFSErrorCode.ENOENT) {
755
+ await this.mkdir(path, { recursive: true });
756
+ return await this.pathResolver.resolve(path);
757
+ }
758
+ // Re-throw other errors (like ENOTDIR)
759
+ throw err;
738
760
  }
739
761
  }
740
762
  async getEntityById(id) {
@@ -2012,7 +2034,13 @@ export class VirtualFileSystem {
2012
2034
  path = `${from}/${path}`;
2013
2035
  }
2014
2036
  // Normalize path
2015
- return path.replace(/\/+/g, '/').replace(/\/$/, '') || '/';
2037
+ const normalizedPath = path.replace(/\/+/g, '/').replace(/\/$/, '') || '/';
2038
+ // Special case for root
2039
+ if (normalizedPath === '/') {
2040
+ return this.rootEntityId;
2041
+ }
2042
+ // Resolve the path to an entity ID
2043
+ return await this.pathResolver.resolve(normalizedPath);
2016
2044
  }
2017
2045
  }
2018
2046
  //# sourceMappingURL=VirtualFileSystem.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "3.14.1",
3
+ "version": "3.15.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",