feat: complete VFS with Knowledge Layer integration

- Add importFile() method for single file imports
- Implement entity helper methods (linkEntities, findEntityOccurrences)
- Fix critical embedding tokenizer bug (char.charCodeAt error)
- Fix removeRelationship to actually remove using brain.unrelate()
- Add setMetadata/getMetadata methods
- Fix GitBridge to query real relationships and events
- Enable background Knowledge Layer processing
- Rewrite README to emphasize knowledge over files
- Add comprehensive VFS documentation (core, knowledge layer, examples)
- Add complete test suite covering all VFS methods

This completes the VFS implementation with full Knowledge Layer support,
enabling files as living knowledge that understand themselves, evolve
over time, and connect to everything related.
This commit is contained in:
David Snelling 2025-09-25 10:47:44 -07:00
parent b3c4f348ab
commit 581f9906fd
17 changed files with 2441 additions and 352 deletions

View file

@ -96,17 +96,30 @@ export class FileMutex implements MutexInterface {
private lockDir: string
private processLocks: Map<string, () => void> = new Map()
private lockTimers: Map<string, NodeJS.Timeout> = new Map()
private modulesLoaded: boolean = false
constructor(lockDir: string) {
this.lockDir = lockDir
// Lazy load Node.js modules
}
private async loadNodeModules(): Promise<void> {
if (this.modulesLoaded) return
if (typeof window === 'undefined') {
this.fs = require('fs')
this.path = require('path')
// Modern ESM-compatible dynamic imports
const [fs, path] = await Promise.all([
import('fs'),
import('path')
])
this.fs = fs
this.path = path
this.modulesLoaded = true
}
}
async acquire(key: string, timeout: number = 30000): Promise<() => void> {
await this.loadNodeModules()
if (!this.fs || !this.path) {
throw new Error('FileMutex is only available in Node.js environments')
}