@soulcraft/brainy 6.3.0 → 6.3.1
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/CHANGELOG.md +21 -0
- package/dist/brainy.d.ts +55 -0
- package/dist/brainy.js +86 -0
- package/dist/versioning/VersionIndex.d.ts +42 -47
- package/dist/versioning/VersionIndex.js +141 -166
- package/dist/versioning/VersionManager.d.ts +12 -6
- package/dist/versioning/VersionManager.js +26 -8
- package/dist/versioning/VersionStorage.d.ts +25 -15
- package/dist/versioning/VersionStorage.js +49 -65
- package/package.json +1 -1
- package/dist/augmentations/KnowledgeAugmentation.d.ts +0 -40
- package/dist/augmentations/KnowledgeAugmentation.js +0 -251
- package/dist/importManager.d.ts +0 -78
- package/dist/importManager.js +0 -267
- package/dist/query/typeInference.d.ts +0 -158
- package/dist/query/typeInference.js +0 -760
- package/dist/storage/adapters/typeAwareStorageAdapter.d.ts +0 -252
- package/dist/storage/adapters/typeAwareStorageAdapter.js +0 -814
- package/dist/types/brainyDataInterface.d.ts +0 -52
- package/dist/types/brainyDataInterface.js +0 -10
- package/dist/vfs/ConceptSystem.d.ts +0 -203
- package/dist/vfs/ConceptSystem.js +0 -545
- package/dist/vfs/EntityManager.d.ts +0 -75
- package/dist/vfs/EntityManager.js +0 -216
- package/dist/vfs/EventRecorder.d.ts +0 -84
- package/dist/vfs/EventRecorder.js +0 -269
- package/dist/vfs/GitBridge.d.ts +0 -167
- package/dist/vfs/GitBridge.js +0 -537
- package/dist/vfs/KnowledgeLayer.d.ts +0 -35
- package/dist/vfs/KnowledgeLayer.js +0 -443
- package/dist/vfs/PersistentEntitySystem.d.ts +0 -165
- package/dist/vfs/PersistentEntitySystem.js +0 -503
- package/dist/vfs/SemanticVersioning.d.ts +0 -105
- package/dist/vfs/SemanticVersioning.js +0 -309
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* VersionStorage - Hybrid Storage for Entity Versions (v5.3.0)
|
|
2
|
+
* VersionStorage - Hybrid Storage for Entity Versions (v5.3.0, v6.3.0 fix)
|
|
3
3
|
*
|
|
4
4
|
* Implements content-addressable storage for entity versions:
|
|
5
5
|
* - SHA-256 content hashing for deduplication
|
|
6
|
-
* -
|
|
6
|
+
* - Uses BaseStorage.saveMetadata/getMetadata for storage (v6.3.0)
|
|
7
7
|
* - Integrates with COW commit system
|
|
8
8
|
* - Space-efficient: Only stores unique content
|
|
9
9
|
*
|
|
10
|
-
* Storage structure:
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* └── {entityId}.json # Version index (managed by VersionIndex)
|
|
10
|
+
* Storage structure (v6.3.0):
|
|
11
|
+
* Version content is stored using system metadata keys:
|
|
12
|
+
* __system_version_{entityId}_{contentHash}
|
|
13
|
+
*
|
|
14
|
+
* This integrates with BaseStorage's routing which places system keys
|
|
15
|
+
* in the _system/ directory, keeping version data separate from entities.
|
|
17
16
|
*
|
|
18
17
|
* NO MOCKS - Production implementation
|
|
19
18
|
*/
|
|
@@ -118,31 +117,34 @@ export class VersionStorage {
|
|
|
118
117
|
await this.deleteVersionData(versionPath);
|
|
119
118
|
}
|
|
120
119
|
/**
|
|
121
|
-
* Get version storage
|
|
120
|
+
* Get version storage key
|
|
121
|
+
*
|
|
122
|
+
* Uses __system_ prefix so BaseStorage routes to system storage (_system/ directory)
|
|
123
|
+
* This keeps version data separate from entity data.
|
|
122
124
|
*
|
|
123
125
|
* @param entityId Entity ID
|
|
124
126
|
* @param contentHash Content hash
|
|
125
|
-
* @returns Storage
|
|
127
|
+
* @returns Storage key for version content
|
|
126
128
|
*/
|
|
127
129
|
getVersionPath(entityId, contentHash) {
|
|
128
|
-
|
|
130
|
+
// v6.3.0: Use system-prefixed key for BaseStorage.saveMetadata/getMetadata
|
|
131
|
+
// BaseStorage recognizes __system_ prefix and routes to _system/ directory
|
|
132
|
+
return `__system_version_${entityId}_${contentHash}`;
|
|
129
133
|
}
|
|
130
134
|
/**
|
|
131
135
|
* Check if content exists in storage
|
|
132
136
|
*
|
|
133
|
-
* @param
|
|
137
|
+
* @param key Storage key
|
|
134
138
|
* @returns True if exists
|
|
135
139
|
*/
|
|
136
|
-
async contentExists(
|
|
140
|
+
async contentExists(key) {
|
|
137
141
|
try {
|
|
138
|
-
// Use
|
|
142
|
+
// v6.3.0: Use getMetadata to check existence
|
|
139
143
|
const adapter = this.brain.storageAdapter;
|
|
140
|
-
if (adapter
|
|
141
|
-
return
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
await this.readVersionData(path);
|
|
145
|
-
return true;
|
|
144
|
+
if (!adapter)
|
|
145
|
+
return false;
|
|
146
|
+
const data = await adapter.getMetadata(key);
|
|
147
|
+
return data !== null;
|
|
146
148
|
}
|
|
147
149
|
catch {
|
|
148
150
|
return false;
|
|
@@ -151,72 +153,54 @@ export class VersionStorage {
|
|
|
151
153
|
/**
|
|
152
154
|
* Write version data to storage
|
|
153
155
|
*
|
|
154
|
-
* @param
|
|
156
|
+
* @param key Storage key
|
|
155
157
|
* @param entity Entity data
|
|
156
158
|
*/
|
|
157
|
-
async writeVersionData(
|
|
159
|
+
async writeVersionData(key, entity) {
|
|
158
160
|
const adapter = this.brain.storageAdapter;
|
|
159
161
|
if (!adapter) {
|
|
160
162
|
throw new Error('Storage adapter not available');
|
|
161
163
|
}
|
|
162
|
-
//
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (typeof adapter.writeFile === 'function') {
|
|
166
|
-
await adapter.writeFile(path, data);
|
|
167
|
-
}
|
|
168
|
-
else if (typeof adapter.set === 'function') {
|
|
169
|
-
await adapter.set(path, data);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
throw new Error('Storage adapter does not support write operations');
|
|
173
|
-
}
|
|
164
|
+
// v6.3.0: Use saveMetadata for storing version content
|
|
165
|
+
// The key is system-prefixed so it routes to _system/ directory
|
|
166
|
+
await adapter.saveMetadata(key, entity);
|
|
174
167
|
}
|
|
175
168
|
/**
|
|
176
169
|
* Read version data from storage
|
|
177
170
|
*
|
|
178
|
-
* @param
|
|
171
|
+
* @param key Storage key
|
|
179
172
|
* @returns Entity data
|
|
180
173
|
*/
|
|
181
|
-
async readVersionData(
|
|
174
|
+
async readVersionData(key) {
|
|
182
175
|
const adapter = this.brain.storageAdapter;
|
|
183
176
|
if (!adapter) {
|
|
184
177
|
throw new Error('Storage adapter not available');
|
|
185
178
|
}
|
|
186
|
-
//
|
|
187
|
-
|
|
188
|
-
if (
|
|
189
|
-
data
|
|
190
|
-
}
|
|
191
|
-
else if (typeof adapter.get === 'function') {
|
|
192
|
-
data = await adapter.get(path);
|
|
179
|
+
// v6.3.0: Use getMetadata for reading version content
|
|
180
|
+
const entity = await adapter.getMetadata(key);
|
|
181
|
+
if (!entity) {
|
|
182
|
+
throw new Error(`Version data not found: ${key}`);
|
|
193
183
|
}
|
|
194
|
-
|
|
195
|
-
throw new Error('Storage adapter does not support read operations');
|
|
196
|
-
}
|
|
197
|
-
// Parse entity data
|
|
198
|
-
return JSON.parse(data);
|
|
184
|
+
return entity;
|
|
199
185
|
}
|
|
200
186
|
/**
|
|
201
187
|
* Delete version data from storage
|
|
202
188
|
*
|
|
203
|
-
*
|
|
189
|
+
* Note: Version content is content-addressed and immutable.
|
|
190
|
+
* Deleting the version index entry (via VersionIndex.removeVersion) is sufficient.
|
|
191
|
+
* The content may be shared with other versions (same contentHash).
|
|
192
|
+
*
|
|
193
|
+
* v6.3.0: We don't actually delete version content to avoid breaking
|
|
194
|
+
* other versions that may reference the same content hash.
|
|
195
|
+
* A separate garbage collection process could clean up unreferenced content.
|
|
196
|
+
*
|
|
197
|
+
* @param key Storage key (unused - kept for API compatibility)
|
|
204
198
|
*/
|
|
205
|
-
async deleteVersionData(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
// Delete from storage using adapter
|
|
211
|
-
if (typeof adapter.deleteFile === 'function') {
|
|
212
|
-
await adapter.deleteFile(path);
|
|
213
|
-
}
|
|
214
|
-
else if (typeof adapter.delete === 'function') {
|
|
215
|
-
await adapter.delete(path);
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
throw new Error('Storage adapter does not support delete operations');
|
|
219
|
-
}
|
|
199
|
+
async deleteVersionData(_key) {
|
|
200
|
+
// v6.3.0: Version content is content-addressed and may be shared.
|
|
201
|
+
// We don't delete it here to prevent breaking other versions.
|
|
202
|
+
// The version INDEX is deleted via VersionIndex.removeVersion().
|
|
203
|
+
// A GC process could clean up unreferenced content in the future.
|
|
220
204
|
}
|
|
221
205
|
}
|
|
222
206
|
//# sourceMappingURL=VersionStorage.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.1",
|
|
4
4
|
"description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. Stage 3 CANONICAL: 42 nouns × 127 verbs covering 96-97% of all human knowledge.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Knowledge Layer Augmentation for VFS
|
|
3
|
-
*
|
|
4
|
-
* Adds intelligent features to VFS without modifying core functionality:
|
|
5
|
-
* - Event recording for all operations
|
|
6
|
-
* - Semantic versioning based on content changes
|
|
7
|
-
* - Entity and concept extraction
|
|
8
|
-
* - Git bridge for import/export
|
|
9
|
-
*
|
|
10
|
-
* This is a TRUE augmentation - VFS works perfectly without it
|
|
11
|
-
*/
|
|
12
|
-
import { Brainy } from '../brainy.js';
|
|
13
|
-
import { BaseAugmentation } from './brainyAugmentation.js';
|
|
14
|
-
export declare class KnowledgeAugmentation extends BaseAugmentation {
|
|
15
|
-
name: string;
|
|
16
|
-
timing: 'after';
|
|
17
|
-
metadata: 'none';
|
|
18
|
-
operations: any;
|
|
19
|
-
priority: number;
|
|
20
|
-
constructor(config?: any);
|
|
21
|
-
execute<T = any>(operation: string, params: any, next: () => Promise<T>): Promise<T>;
|
|
22
|
-
private eventRecorder?;
|
|
23
|
-
private semanticVersioning?;
|
|
24
|
-
private entitySystem?;
|
|
25
|
-
private conceptSystem?;
|
|
26
|
-
private gitBridge?;
|
|
27
|
-
private originalMethods;
|
|
28
|
-
initialize(context: any): Promise<void>;
|
|
29
|
-
augment(brain: Brainy): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Wrap a VFS method to add Knowledge Layer functionality
|
|
32
|
-
*/
|
|
33
|
-
private wrapMethod;
|
|
34
|
-
/**
|
|
35
|
-
* Add Knowledge Layer methods to VFS
|
|
36
|
-
*/
|
|
37
|
-
private addKnowledgeMethods;
|
|
38
|
-
private isSemanticChange;
|
|
39
|
-
cleanup(brain: Brainy): Promise<void>;
|
|
40
|
-
}
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Knowledge Layer Augmentation for VFS
|
|
3
|
-
*
|
|
4
|
-
* Adds intelligent features to VFS without modifying core functionality:
|
|
5
|
-
* - Event recording for all operations
|
|
6
|
-
* - Semantic versioning based on content changes
|
|
7
|
-
* - Entity and concept extraction
|
|
8
|
-
* - Git bridge for import/export
|
|
9
|
-
*
|
|
10
|
-
* This is a TRUE augmentation - VFS works perfectly without it
|
|
11
|
-
*/
|
|
12
|
-
import { BaseAugmentation } from './brainyAugmentation.js';
|
|
13
|
-
import { EventRecorder } from '../vfs/EventRecorder.js';
|
|
14
|
-
import { SemanticVersioning } from '../vfs/SemanticVersioning.js';
|
|
15
|
-
import { PersistentEntitySystem } from '../vfs/PersistentEntitySystem.js';
|
|
16
|
-
import { ConceptSystem } from '../vfs/ConceptSystem.js';
|
|
17
|
-
import { GitBridge } from '../vfs/GitBridge.js';
|
|
18
|
-
export class KnowledgeAugmentation extends BaseAugmentation {
|
|
19
|
-
constructor(config = {}) {
|
|
20
|
-
super(config);
|
|
21
|
-
this.name = 'knowledge';
|
|
22
|
-
this.timing = 'after'; // Process after VFS operations
|
|
23
|
-
this.metadata = 'none'; // No metadata access needed
|
|
24
|
-
this.operations = []; // VFS-specific augmentation, no operation interception
|
|
25
|
-
this.priority = 100; // Run last
|
|
26
|
-
this.originalMethods = new Map();
|
|
27
|
-
}
|
|
28
|
-
async execute(operation, params, next) {
|
|
29
|
-
// Pass through - this augmentation works at VFS level, not operation level
|
|
30
|
-
return await next();
|
|
31
|
-
}
|
|
32
|
-
async initialize(context) {
|
|
33
|
-
await this.augment(context.brain);
|
|
34
|
-
}
|
|
35
|
-
async augment(brain) {
|
|
36
|
-
// Only augment if VFS exists
|
|
37
|
-
const vfs = brain.vfs?.();
|
|
38
|
-
if (!vfs) {
|
|
39
|
-
console.warn('KnowledgeAugmentation: VFS not found, skipping');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
// Initialize Knowledge Layer components
|
|
43
|
-
this.eventRecorder = new EventRecorder(brain);
|
|
44
|
-
this.semanticVersioning = new SemanticVersioning(brain);
|
|
45
|
-
this.entitySystem = new PersistentEntitySystem(brain);
|
|
46
|
-
this.conceptSystem = new ConceptSystem(brain);
|
|
47
|
-
this.gitBridge = new GitBridge(vfs, brain);
|
|
48
|
-
// Wrap VFS methods to add intelligence WITHOUT slowing them down
|
|
49
|
-
this.wrapMethod(vfs, 'writeFile', async (original, path, data, options) => {
|
|
50
|
-
// Call original first (stays fast)
|
|
51
|
-
const result = await original.call(vfs, path, data, options);
|
|
52
|
-
// Knowledge processing in background (non-blocking)
|
|
53
|
-
setImmediate(async () => {
|
|
54
|
-
try {
|
|
55
|
-
// Record event
|
|
56
|
-
if (this.eventRecorder) {
|
|
57
|
-
await this.eventRecorder.recordEvent({
|
|
58
|
-
type: 'write',
|
|
59
|
-
path,
|
|
60
|
-
content: data,
|
|
61
|
-
size: data.length,
|
|
62
|
-
author: options?.author || 'system'
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
// Check for semantic versioning
|
|
66
|
-
if (this.semanticVersioning) {
|
|
67
|
-
const existingContent = await vfs.readFile(path).catch(() => null);
|
|
68
|
-
const shouldVersion = existingContent && this.isSemanticChange(existingContent, data);
|
|
69
|
-
if (shouldVersion) {
|
|
70
|
-
await this.semanticVersioning.createVersion(path, data, {
|
|
71
|
-
message: 'Automatic semantic version'
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// Extract concepts
|
|
76
|
-
if (this.conceptSystem && options?.extractConcepts !== false) {
|
|
77
|
-
await this.conceptSystem.extractAndLinkConcepts(path, data);
|
|
78
|
-
}
|
|
79
|
-
// Extract entities
|
|
80
|
-
if (this.entitySystem && options?.extractEntities !== false) {
|
|
81
|
-
await this.entitySystem.extractEntities(data.toString('utf8'), data);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
// Knowledge Layer errors should not affect VFS operations
|
|
86
|
-
console.debug('KnowledgeLayer background processing error:', error);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return result;
|
|
90
|
-
});
|
|
91
|
-
this.wrapMethod(vfs, 'unlink', async (original, path) => {
|
|
92
|
-
const result = await original.call(vfs, path);
|
|
93
|
-
// Record deletion event
|
|
94
|
-
setImmediate(async () => {
|
|
95
|
-
if (this.eventRecorder) {
|
|
96
|
-
await this.eventRecorder.recordEvent({
|
|
97
|
-
type: 'delete',
|
|
98
|
-
path,
|
|
99
|
-
author: 'system'
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
return result;
|
|
104
|
-
});
|
|
105
|
-
this.wrapMethod(vfs, 'rename', async (original, oldPath, newPath) => {
|
|
106
|
-
const result = await original.call(vfs, oldPath, newPath);
|
|
107
|
-
// Record rename event
|
|
108
|
-
setImmediate(async () => {
|
|
109
|
-
if (this.eventRecorder) {
|
|
110
|
-
await this.eventRecorder.recordEvent({
|
|
111
|
-
type: 'rename',
|
|
112
|
-
path: oldPath,
|
|
113
|
-
metadata: { newPath },
|
|
114
|
-
author: 'system'
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
return result;
|
|
119
|
-
});
|
|
120
|
-
// Add Knowledge Layer methods to VFS
|
|
121
|
-
this.addKnowledgeMethods(vfs);
|
|
122
|
-
console.log('✨ Knowledge Layer augmentation enabled');
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Wrap a VFS method to add Knowledge Layer functionality
|
|
126
|
-
*/
|
|
127
|
-
wrapMethod(vfs, methodName, wrapper) {
|
|
128
|
-
const original = vfs[methodName];
|
|
129
|
-
if (!original)
|
|
130
|
-
return;
|
|
131
|
-
// Store original for cleanup
|
|
132
|
-
this.originalMethods.set(methodName, original);
|
|
133
|
-
// Replace with wrapped version
|
|
134
|
-
vfs[methodName] = async (...args) => {
|
|
135
|
-
return await wrapper(original, ...args);
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Add Knowledge Layer methods to VFS
|
|
140
|
-
*/
|
|
141
|
-
addKnowledgeMethods(vfs) {
|
|
142
|
-
// Event history
|
|
143
|
-
vfs.getHistory = async (path, options) => {
|
|
144
|
-
if (!this.eventRecorder)
|
|
145
|
-
throw new Error('Knowledge Layer not initialized');
|
|
146
|
-
return await this.eventRecorder.getHistory(path, options);
|
|
147
|
-
};
|
|
148
|
-
vfs.reconstructAtTime = async (path, timestamp) => {
|
|
149
|
-
if (!this.eventRecorder)
|
|
150
|
-
throw new Error('Knowledge Layer not initialized');
|
|
151
|
-
return await this.eventRecorder.reconstructFileAtTime(path, timestamp);
|
|
152
|
-
};
|
|
153
|
-
// Semantic versioning
|
|
154
|
-
vfs.getVersions = async (path) => {
|
|
155
|
-
if (!this.semanticVersioning)
|
|
156
|
-
throw new Error('Knowledge Layer not initialized');
|
|
157
|
-
return await this.semanticVersioning.getVersions(path);
|
|
158
|
-
};
|
|
159
|
-
vfs.restoreVersion = async (path, versionId) => {
|
|
160
|
-
if (!this.semanticVersioning)
|
|
161
|
-
throw new Error('Knowledge Layer not initialized');
|
|
162
|
-
const version = await this.semanticVersioning.getVersion(path, versionId);
|
|
163
|
-
if (version) {
|
|
164
|
-
await vfs.writeFile(path, version);
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
// Entities
|
|
168
|
-
vfs.findEntity = async (query) => {
|
|
169
|
-
if (!this.entitySystem)
|
|
170
|
-
throw new Error('Knowledge Layer not initialized');
|
|
171
|
-
return await this.entitySystem.findEntity(query);
|
|
172
|
-
};
|
|
173
|
-
vfs.getEntityAppearances = async (entityId) => {
|
|
174
|
-
if (!this.entitySystem)
|
|
175
|
-
throw new Error('Knowledge Layer not initialized');
|
|
176
|
-
return await this.entitySystem.getEvolution(entityId);
|
|
177
|
-
};
|
|
178
|
-
// Concepts
|
|
179
|
-
vfs.getConcepts = async (path) => {
|
|
180
|
-
if (!this.conceptSystem)
|
|
181
|
-
throw new Error('Knowledge Layer not initialized');
|
|
182
|
-
const concepts = await this.conceptSystem.findConcepts({ manifestedIn: path });
|
|
183
|
-
return concepts;
|
|
184
|
-
};
|
|
185
|
-
vfs.getConceptGraph = async (options) => {
|
|
186
|
-
if (!this.conceptSystem)
|
|
187
|
-
throw new Error('Knowledge Layer not initialized');
|
|
188
|
-
return await this.conceptSystem.getConceptGraph(options);
|
|
189
|
-
};
|
|
190
|
-
// Git bridge
|
|
191
|
-
vfs.exportToGit = async (vfsPath, gitPath) => {
|
|
192
|
-
if (!this.gitBridge)
|
|
193
|
-
throw new Error('Knowledge Layer not initialized');
|
|
194
|
-
return await this.gitBridge.exportToGit(vfsPath, gitPath);
|
|
195
|
-
};
|
|
196
|
-
vfs.importFromGit = async (gitPath, vfsPath) => {
|
|
197
|
-
if (!this.gitBridge)
|
|
198
|
-
throw new Error('Knowledge Layer not initialized');
|
|
199
|
-
return await this.gitBridge.importFromGit(gitPath, vfsPath);
|
|
200
|
-
};
|
|
201
|
-
// Temporal coupling
|
|
202
|
-
vfs.findTemporalCoupling = async (path, windowMs) => {
|
|
203
|
-
if (!this.eventRecorder)
|
|
204
|
-
throw new Error('Knowledge Layer not initialized');
|
|
205
|
-
return await this.eventRecorder.findTemporalCoupling(path, windowMs);
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
isSemanticChange(oldContent, newContent) {
|
|
209
|
-
// Simple heuristic - significant size change or different content
|
|
210
|
-
const oldStr = oldContent.toString('utf8');
|
|
211
|
-
const newStr = newContent.toString('utf8');
|
|
212
|
-
// Check for significant size change (>10%)
|
|
213
|
-
const sizeDiff = Math.abs(oldStr.length - newStr.length) / oldStr.length;
|
|
214
|
-
if (sizeDiff > 0.1)
|
|
215
|
-
return true;
|
|
216
|
-
// Check for structural changes (simplified)
|
|
217
|
-
const oldLines = oldStr.split('\n').filter(l => l.trim());
|
|
218
|
-
const newLines = newStr.split('\n').filter(l => l.trim());
|
|
219
|
-
// Different number of non-empty lines
|
|
220
|
-
return Math.abs(oldLines.length - newLines.length) > 5;
|
|
221
|
-
}
|
|
222
|
-
async cleanup(brain) {
|
|
223
|
-
const vfs = brain.vfs?.();
|
|
224
|
-
if (!vfs)
|
|
225
|
-
return;
|
|
226
|
-
// Restore original methods
|
|
227
|
-
for (const [methodName, original] of this.originalMethods) {
|
|
228
|
-
vfs[methodName] = original;
|
|
229
|
-
}
|
|
230
|
-
// Remove added methods
|
|
231
|
-
delete vfs.getHistory;
|
|
232
|
-
delete vfs.reconstructAtTime;
|
|
233
|
-
delete vfs.getVersions;
|
|
234
|
-
delete vfs.restoreVersion;
|
|
235
|
-
delete vfs.findEntity;
|
|
236
|
-
delete vfs.getEntityAppearances;
|
|
237
|
-
delete vfs.getConcepts;
|
|
238
|
-
delete vfs.getConceptGraph;
|
|
239
|
-
delete vfs.exportToGit;
|
|
240
|
-
delete vfs.importFromGit;
|
|
241
|
-
delete vfs.findTemporalCoupling;
|
|
242
|
-
// Clean up components
|
|
243
|
-
this.eventRecorder = undefined;
|
|
244
|
-
this.semanticVersioning = undefined;
|
|
245
|
-
this.entitySystem = undefined;
|
|
246
|
-
this.conceptSystem = undefined;
|
|
247
|
-
this.gitBridge = undefined;
|
|
248
|
-
console.log('Knowledge Layer augmentation removed');
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
//# sourceMappingURL=KnowledgeAugmentation.js.map
|
package/dist/importManager.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Import Manager - Comprehensive data import with intelligent type detection
|
|
3
|
-
*
|
|
4
|
-
* Handles multiple data sources:
|
|
5
|
-
* - Direct data (objects, arrays)
|
|
6
|
-
* - Files (JSON, CSV, text)
|
|
7
|
-
* - URLs (fetch and parse)
|
|
8
|
-
* - Streams (for large files)
|
|
9
|
-
*
|
|
10
|
-
* Uses NeuralImportAugmentation for intelligent processing
|
|
11
|
-
*/
|
|
12
|
-
import { NounType } from './types/graphTypes.js';
|
|
13
|
-
export interface ImportOptions {
|
|
14
|
-
source?: 'data' | 'file' | 'url' | 'auto';
|
|
15
|
-
format?: 'json' | 'csv' | 'text' | 'yaml' | 'auto';
|
|
16
|
-
batchSize?: number;
|
|
17
|
-
autoDetect?: boolean;
|
|
18
|
-
typeHint?: NounType;
|
|
19
|
-
extractRelationships?: boolean;
|
|
20
|
-
csvDelimiter?: string;
|
|
21
|
-
csvHeaders?: boolean;
|
|
22
|
-
parallel?: boolean;
|
|
23
|
-
maxConcurrency?: number;
|
|
24
|
-
}
|
|
25
|
-
export interface ImportResult {
|
|
26
|
-
success: boolean;
|
|
27
|
-
nouns: string[];
|
|
28
|
-
verbs: string[];
|
|
29
|
-
errors: string[];
|
|
30
|
-
stats: {
|
|
31
|
-
total: number;
|
|
32
|
-
imported: number;
|
|
33
|
-
failed: number;
|
|
34
|
-
relationships: number;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
export declare class ImportManager {
|
|
38
|
-
private neuralImport;
|
|
39
|
-
private typeMatcher;
|
|
40
|
-
private brain;
|
|
41
|
-
constructor(brain: any);
|
|
42
|
-
/**
|
|
43
|
-
* Initialize the import manager
|
|
44
|
-
*/
|
|
45
|
-
init(): Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* Main import method - handles all sources
|
|
48
|
-
*/
|
|
49
|
-
import(source: string | Buffer | any[] | any, options?: ImportOptions): Promise<ImportResult>;
|
|
50
|
-
/**
|
|
51
|
-
* Import from file
|
|
52
|
-
*/
|
|
53
|
-
importFile(filePath: string, options?: ImportOptions): Promise<ImportResult>;
|
|
54
|
-
/**
|
|
55
|
-
* Import from URL
|
|
56
|
-
*/
|
|
57
|
-
importUrl(url: string, options?: ImportOptions): Promise<ImportResult>;
|
|
58
|
-
/**
|
|
59
|
-
* Detect source type
|
|
60
|
-
*/
|
|
61
|
-
private detectSourceType;
|
|
62
|
-
/**
|
|
63
|
-
* Detect format from file path
|
|
64
|
-
*/
|
|
65
|
-
private detectFormatFromPath;
|
|
66
|
-
/**
|
|
67
|
-
* Read file
|
|
68
|
-
*/
|
|
69
|
-
private readFile;
|
|
70
|
-
/**
|
|
71
|
-
* Fetch from URL
|
|
72
|
-
*/
|
|
73
|
-
private fetchFromUrl;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Create an import manager instance
|
|
77
|
-
*/
|
|
78
|
-
export declare function createImportManager(brain: any): ImportManager;
|