@soulcraft/brainy 3.20.2 → 3.20.3

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/bin/brainy-interactive.js +2 -2
  3. package/dist/brainy.d.ts +1 -1
  4. package/dist/mcp/brainyMCPAdapter.d.ts +1 -1
  5. package/dist/mcp/brainyMCPService.d.ts +1 -1
  6. package/dist/neural/embeddedPatterns.d.ts +1 -1
  7. package/dist/neural/embeddedPatterns.js +1 -1
  8. package/dist/shared/default-augmentations.d.ts +1 -1
  9. package/dist/types/{brainyDataInterface.js → brainyInterface.js} +1 -1
  10. package/package.json +1 -1
  11. package/dist/augmentationFactory.d.ts +0 -86
  12. package/dist/augmentationFactory.js +0 -342
  13. package/dist/augmentationRegistry.d.ts +0 -38
  14. package/dist/augmentationRegistry.js +0 -54
  15. package/dist/augmentationRegistryLoader.d.ts +0 -146
  16. package/dist/augmentationRegistryLoader.js +0 -213
  17. package/dist/augmentations/KnowledgeAugmentation.d.ts +0 -40
  18. package/dist/augmentations/KnowledgeAugmentation.js +0 -251
  19. package/dist/augmentations/intelligentVerbScoring.d.ts +0 -158
  20. package/dist/augmentations/intelligentVerbScoring.js +0 -377
  21. package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +0 -168
  22. package/dist/augmentations/marketplace/AugmentationMarketplace.js +0 -329
  23. package/dist/augmentations/marketplace/cli.d.ts +0 -47
  24. package/dist/augmentations/marketplace/cli.js +0 -265
  25. package/dist/augmentations/memoryAugmentations.d.ts +0 -72
  26. package/dist/augmentations/memoryAugmentations.js +0 -280
  27. package/dist/augmentations/serverSearchAugmentations.d.ts +0 -190
  28. package/dist/augmentations/serverSearchAugmentations.js +0 -586
  29. package/dist/brainy-unified.d.ts +0 -106
  30. package/dist/brainy-unified.js +0 -327
  31. package/dist/brainyData.d.ts +0 -1832
  32. package/dist/brainyData.js +0 -6443
  33. package/dist/brainyDataV3.d.ts +0 -186
  34. package/dist/brainyDataV3.js +0 -337
  35. package/dist/config/distributedPresets-new.d.ts +0 -118
  36. package/dist/config/distributedPresets-new.js +0 -318
  37. package/dist/config/modelPrecisionManager.d.ts +0 -42
  38. package/dist/config/modelPrecisionManager.js +0 -98
  39. package/dist/connectors/interfaces/IConnector.d.ts +0 -143
  40. package/dist/connectors/interfaces/IConnector.js +0 -8
  41. package/dist/demo.d.ts +0 -106
  42. package/dist/demo.js +0 -201
  43. package/dist/embeddings/SingletonModelManager.d.ts +0 -95
  44. package/dist/embeddings/SingletonModelManager.js +0 -220
  45. package/dist/embeddings/lightweight-embedder.d.ts +0 -22
  46. package/dist/embeddings/lightweight-embedder.js +0 -128
  47. package/dist/embeddings/model-manager.d.ts +0 -39
  48. package/dist/embeddings/model-manager.js +0 -245
  49. package/dist/embeddings/universal-memory-manager.d.ts +0 -38
  50. package/dist/embeddings/universal-memory-manager.js +0 -166
  51. package/dist/embeddings/worker-embedding.d.ts +0 -7
  52. package/dist/embeddings/worker-embedding.js +0 -73
  53. package/dist/embeddings/worker-manager.d.ts +0 -28
  54. package/dist/embeddings/worker-manager.js +0 -162
  55. package/dist/examples/basicUsage.d.ts +0 -4
  56. package/dist/examples/basicUsage.js +0 -121
  57. package/dist/indices/fieldIndex.d.ts +0 -76
  58. package/dist/indices/fieldIndex.js +0 -357
  59. package/dist/mcp/brainyMCPBroadcast.d.ts +0 -82
  60. package/dist/mcp/brainyMCPBroadcast.js +0 -303
  61. package/dist/mcp/brainyMCPClient.d.ts +0 -92
  62. package/dist/mcp/brainyMCPClient.js +0 -258
  63. package/dist/scripts/precomputePatternEmbeddings.d.ts +0 -19
  64. package/dist/scripts/precomputePatternEmbeddings.js +0 -100
  65. package/dist/utils/cacheAutoConfig.d.ts +0 -63
  66. package/dist/utils/cacheAutoConfig.js +0 -261
  67. package/dist/utils/hybridModelManager.d.ts +0 -64
  68. package/dist/utils/hybridModelManager.js +0 -95
  69. package/dist/utils/statistics.d.ts +0 -28
  70. package/dist/utils/statistics.js +0 -25
  71. package/dist/vfs/ConceptSystem.d.ts +0 -203
  72. package/dist/vfs/ConceptSystem.js +0 -545
  73. package/dist/vfs/EntityManager.d.ts +0 -75
  74. package/dist/vfs/EntityManager.js +0 -216
  75. package/dist/vfs/EventRecorder.d.ts +0 -84
  76. package/dist/vfs/EventRecorder.js +0 -269
  77. package/dist/vfs/GitBridge.d.ts +0 -167
  78. package/dist/vfs/GitBridge.js +0 -537
  79. package/dist/vfs/KnowledgeAugmentation.d.ts +0 -104
  80. package/dist/vfs/KnowledgeAugmentation.js +0 -146
  81. package/dist/vfs/KnowledgeLayer.d.ts +0 -35
  82. package/dist/vfs/KnowledgeLayer.js +0 -443
  83. package/dist/vfs/PersistentEntitySystem.d.ts +0 -165
  84. package/dist/vfs/PersistentEntitySystem.js +0 -503
  85. package/dist/vfs/SemanticVersioning.d.ts +0 -105
  86. package/dist/vfs/SemanticVersioning.js +0 -309
  87. package/dist/vfs/VFSHealthCheck.d.ts +0 -78
  88. package/dist/vfs/VFSHealthCheck.js +0 -299
  89. /package/dist/types/{brainyDataInterface.d.ts → brainyInterface.d.ts} +0 -0
@@ -1,146 +0,0 @@
1
- /**
2
- * Augmentation Registry Loader
3
- *
4
- * This module provides functionality for loading augmentation registrations
5
- * at build time. It's designed to be used with build tools like webpack or rollup
6
- * to automatically discover and register augmentations.
7
- */
8
- import { IAugmentation } from './types/augmentations.js';
9
- /**
10
- * Options for the augmentation registry loader
11
- */
12
- export interface AugmentationRegistryLoaderOptions {
13
- /**
14
- * Whether to automatically initialize the augmentations after loading
15
- * @default false
16
- */
17
- autoInitialize?: boolean;
18
- /**
19
- * Whether to log debug information during loading
20
- * @default false
21
- */
22
- debug?: boolean;
23
- }
24
- /**
25
- * Result of loading augmentations
26
- */
27
- export interface AugmentationLoadResult {
28
- /**
29
- * The augmentations that were loaded
30
- */
31
- augmentations: IAugmentation[];
32
- /**
33
- * Any errors that occurred during loading
34
- */
35
- errors: Error[];
36
- }
37
- /**
38
- * Loads augmentations from the specified modules
39
- *
40
- * This function is designed to be used with build tools like webpack or rollup
41
- * to automatically discover and register augmentations.
42
- *
43
- * @param modules An object containing modules with augmentations to register
44
- * @param options Options for the loader
45
- * @returns A promise that resolves with the result of loading the augmentations
46
- *
47
- * @example
48
- * ```typescript
49
- * // webpack.config.js
50
- * const { AugmentationRegistryPlugin } = require('brainy/dist/webpack');
51
- *
52
- * module.exports = {
53
- * // ... other webpack config
54
- * plugins: [
55
- * new AugmentationRegistryPlugin({
56
- * // Pattern to match files containing augmentations
57
- * pattern: /augmentation\.js$/,
58
- * // Options for the loader
59
- * options: {
60
- * autoInitialize: true,
61
- * debug: true
62
- * }
63
- * })
64
- * ]
65
- * };
66
- * ```
67
- */
68
- export declare function loadAugmentationsFromModules(modules: Record<string, any>, options?: AugmentationRegistryLoaderOptions): Promise<AugmentationLoadResult>;
69
- /**
70
- * Creates a webpack plugin for automatically loading augmentations
71
- *
72
- * @param options Options for the plugin
73
- * @returns A webpack plugin
74
- *
75
- * @example
76
- * ```typescript
77
- * // webpack.config.js
78
- * const { createAugmentationRegistryPlugin } = require('brainy/dist/webpack');
79
- *
80
- * module.exports = {
81
- * // ... other webpack config
82
- * plugins: [
83
- * createAugmentationRegistryPlugin({
84
- * pattern: /augmentation\.js$/,
85
- * options: {
86
- * autoInitialize: true,
87
- * debug: true
88
- * }
89
- * })
90
- * ]
91
- * };
92
- * ```
93
- */
94
- export declare function createAugmentationRegistryPlugin(options: {
95
- /**
96
- * Pattern to match files containing augmentations
97
- */
98
- pattern: RegExp;
99
- /**
100
- * Options for the loader
101
- */
102
- options?: AugmentationRegistryLoaderOptions;
103
- }): {
104
- name: string;
105
- pattern: RegExp;
106
- options: AugmentationRegistryLoaderOptions;
107
- };
108
- /**
109
- * Creates a rollup plugin for automatically loading augmentations
110
- *
111
- * @param options Options for the plugin
112
- * @returns A rollup plugin
113
- *
114
- * @example
115
- * ```typescript
116
- * // rollup.config.js
117
- * import { createAugmentationRegistryRollupPlugin } from 'brainy/dist/rollup';
118
- *
119
- * export default {
120
- * // ... other rollup config
121
- * plugins: [
122
- * createAugmentationRegistryRollupPlugin({
123
- * pattern: /augmentation\.js$/,
124
- * options: {
125
- * autoInitialize: true,
126
- * debug: true
127
- * }
128
- * })
129
- * ]
130
- * };
131
- * ```
132
- */
133
- export declare function createAugmentationRegistryRollupPlugin(options: {
134
- /**
135
- * Pattern to match files containing augmentations
136
- */
137
- pattern: RegExp;
138
- /**
139
- * Options for the loader
140
- */
141
- options?: AugmentationRegistryLoaderOptions;
142
- }): {
143
- name: string;
144
- pattern: RegExp;
145
- options: AugmentationRegistryLoaderOptions;
146
- };
@@ -1,213 +0,0 @@
1
- /**
2
- * Augmentation Registry Loader
3
- *
4
- * This module provides functionality for loading augmentation registrations
5
- * at build time. It's designed to be used with build tools like webpack or rollup
6
- * to automatically discover and register augmentations.
7
- */
8
- import { registerAugmentation } from './augmentationRegistry.js';
9
- /**
10
- * Default options for the augmentation registry loader
11
- */
12
- const DEFAULT_OPTIONS = {
13
- autoInitialize: false,
14
- debug: false
15
- };
16
- /**
17
- * Loads augmentations from the specified modules
18
- *
19
- * This function is designed to be used with build tools like webpack or rollup
20
- * to automatically discover and register augmentations.
21
- *
22
- * @param modules An object containing modules with augmentations to register
23
- * @param options Options for the loader
24
- * @returns A promise that resolves with the result of loading the augmentations
25
- *
26
- * @example
27
- * ```typescript
28
- * // webpack.config.js
29
- * const { AugmentationRegistryPlugin } = require('brainy/dist/webpack');
30
- *
31
- * module.exports = {
32
- * // ... other webpack config
33
- * plugins: [
34
- * new AugmentationRegistryPlugin({
35
- * // Pattern to match files containing augmentations
36
- * pattern: /augmentation\.js$/,
37
- * // Options for the loader
38
- * options: {
39
- * autoInitialize: true,
40
- * debug: true
41
- * }
42
- * })
43
- * ]
44
- * };
45
- * ```
46
- */
47
- export async function loadAugmentationsFromModules(modules, options = {}) {
48
- const opts = { ...DEFAULT_OPTIONS, ...options };
49
- const result = {
50
- augmentations: [],
51
- errors: []
52
- };
53
- if (opts.debug) {
54
- console.log(`[AugmentationRegistryLoader] Loading augmentations from ${Object.keys(modules).length} modules`);
55
- }
56
- // Process each module
57
- for (const [modulePath, module] of Object.entries(modules)) {
58
- try {
59
- if (opts.debug) {
60
- console.log(`[AugmentationRegistryLoader] Processing module: ${modulePath}`);
61
- }
62
- // Extract augmentations from the module
63
- const augmentations = extractAugmentationsFromModule(module);
64
- if (augmentations.length === 0) {
65
- if (opts.debug) {
66
- console.log(`[AugmentationRegistryLoader] No augmentations found in module: ${modulePath}`);
67
- }
68
- continue;
69
- }
70
- // Register each augmentation
71
- for (const augmentation of augmentations) {
72
- try {
73
- const registered = registerAugmentation(augmentation);
74
- result.augmentations.push(registered);
75
- if (opts.debug) {
76
- console.log(`[AugmentationRegistryLoader] Registered augmentation: ${registered.name}`);
77
- }
78
- }
79
- catch (error) {
80
- const err = error instanceof Error ? error : new Error(String(error));
81
- result.errors.push(err);
82
- if (opts.debug) {
83
- console.error(`[AugmentationRegistryLoader] Failed to register augmentation: ${err.message}`);
84
- }
85
- }
86
- }
87
- }
88
- catch (error) {
89
- const err = error instanceof Error ? error : new Error(String(error));
90
- result.errors.push(err);
91
- if (opts.debug) {
92
- console.error(`[AugmentationRegistryLoader] Error processing module ${modulePath}: ${err.message}`);
93
- }
94
- }
95
- }
96
- if (opts.debug) {
97
- console.log(`[AugmentationRegistryLoader] Loaded ${result.augmentations.length} augmentations with ${result.errors.length} errors`);
98
- }
99
- return result;
100
- }
101
- /**
102
- * Extracts augmentations from a module
103
- *
104
- * @param module The module to extract augmentations from
105
- * @returns An array of augmentations found in the module
106
- */
107
- function extractAugmentationsFromModule(module) {
108
- const augmentations = [];
109
- // If the module itself is an augmentation, add it
110
- if (isAugmentation(module)) {
111
- augmentations.push(module);
112
- }
113
- // Check for exported augmentations
114
- if (module && typeof module === 'object') {
115
- for (const key of Object.keys(module)) {
116
- const exported = module[key];
117
- // Skip non-objects and null
118
- if (!exported || typeof exported !== 'object') {
119
- continue;
120
- }
121
- // If the exported value is an augmentation, add it
122
- if (isAugmentation(exported)) {
123
- augmentations.push(exported);
124
- }
125
- // If the exported value is an array of augmentations, add them
126
- if (Array.isArray(exported) && exported.every(isAugmentation)) {
127
- augmentations.push(...exported);
128
- }
129
- }
130
- }
131
- return augmentations;
132
- }
133
- /**
134
- * Checks if an object is an augmentation
135
- *
136
- * @param obj The object to check
137
- * @returns True if the object is an augmentation
138
- */
139
- function isAugmentation(obj) {
140
- return (obj &&
141
- typeof obj === 'object' &&
142
- typeof obj.name === 'string' &&
143
- typeof obj.initialize === 'function' &&
144
- typeof obj.shutDown === 'function' &&
145
- typeof obj.getStatus === 'function');
146
- }
147
- /**
148
- * Creates a webpack plugin for automatically loading augmentations
149
- *
150
- * @param options Options for the plugin
151
- * @returns A webpack plugin
152
- *
153
- * @example
154
- * ```typescript
155
- * // webpack.config.js
156
- * const { createAugmentationRegistryPlugin } = require('brainy/dist/webpack');
157
- *
158
- * module.exports = {
159
- * // ... other webpack config
160
- * plugins: [
161
- * createAugmentationRegistryPlugin({
162
- * pattern: /augmentation\.js$/,
163
- * options: {
164
- * autoInitialize: true,
165
- * debug: true
166
- * }
167
- * })
168
- * ]
169
- * };
170
- * ```
171
- */
172
- export function createAugmentationRegistryPlugin(options) {
173
- // This is just a placeholder - the actual implementation would depend on the build tool
174
- return {
175
- name: 'AugmentationRegistryPlugin',
176
- pattern: options.pattern,
177
- options: options.options || {}
178
- };
179
- }
180
- /**
181
- * Creates a rollup plugin for automatically loading augmentations
182
- *
183
- * @param options Options for the plugin
184
- * @returns A rollup plugin
185
- *
186
- * @example
187
- * ```typescript
188
- * // rollup.config.js
189
- * import { createAugmentationRegistryRollupPlugin } from 'brainy/dist/rollup';
190
- *
191
- * export default {
192
- * // ... other rollup config
193
- * plugins: [
194
- * createAugmentationRegistryRollupPlugin({
195
- * pattern: /augmentation\.js$/,
196
- * options: {
197
- * autoInitialize: true,
198
- * debug: true
199
- * }
200
- * })
201
- * ]
202
- * };
203
- * ```
204
- */
205
- export function createAugmentationRegistryRollupPlugin(options) {
206
- // This is just a placeholder - the actual implementation would depend on the build tool
207
- return {
208
- name: 'augmentation-registry-rollup-plugin',
209
- pattern: options.pattern,
210
- options: options.options || {}
211
- };
212
- }
213
- //# sourceMappingURL=augmentationRegistryLoader.js.map
@@ -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