@soulcraft/brainy 3.19.0 → 3.20.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/CHANGELOG.md +2 -0
- package/bin/brainy-minimal.js +82 -0
- package/bin/brainy.js +9 -2335
- package/dist/api/DataAPI.d.ts +1 -1
- package/dist/augmentations/cacheAugmentation.d.ts +1 -1
- package/dist/augmentations/metricsAugmentation.d.ts +20 -20
- package/dist/brainy.d.ts +1 -1
- package/dist/brainyData.js +1 -2
- package/dist/cli/catalog.js +8 -12
- package/dist/cli/commands/conversation.d.ts +22 -0
- package/dist/cli/commands/conversation.js +528 -0
- package/dist/cli/commands/core.d.ts +14 -2
- package/dist/cli/commands/core.js +195 -35
- package/dist/cli/commands/data.d.ts +29 -0
- package/dist/cli/commands/data.js +139 -0
- package/dist/cli/commands/neural.d.ts +14 -0
- package/dist/cli/commands/neural.js +18 -8
- package/dist/cli/commands/types.d.ts +30 -0
- package/dist/cli/commands/types.js +194 -0
- package/dist/cli/commands/utility.js +39 -98
- package/dist/cli/commands/vfs.d.ts +73 -0
- package/dist/cli/commands/vfs.js +372 -0
- package/dist/cli/index.js +244 -7
- package/dist/cli/interactive.d.ts +8 -3
- package/dist/cli/interactive.js +35 -11
- package/dist/hnsw/hnswIndexOptimized.d.ts +1 -1
- package/dist/mcp/brainyMCPBroadcast.d.ts +2 -2
- package/dist/mcp/brainyMCPBroadcast.js +1 -1
- package/dist/mcp/brainyMCPClient.js +8 -4
- package/dist/neural/types.d.ts +2 -2
- package/dist/streaming/pipeline.d.ts +1 -1
- package/dist/universal/fs.d.ts +24 -66
- package/package.json +5 -2
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VFS CLI Commands - Virtual File System Operations
|
|
3
|
+
*
|
|
4
|
+
* Complete filesystem-like interface for Brainy's VFS
|
|
5
|
+
*/
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import ora from 'ora';
|
|
8
|
+
import Table from 'cli-table3';
|
|
9
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import { Brainy } from '../../brainy.js';
|
|
11
|
+
let brainyInstance = null;
|
|
12
|
+
const getBrainy = () => {
|
|
13
|
+
if (!brainyInstance) {
|
|
14
|
+
brainyInstance = new Brainy();
|
|
15
|
+
}
|
|
16
|
+
return brainyInstance;
|
|
17
|
+
};
|
|
18
|
+
const formatOutput = (data, options) => {
|
|
19
|
+
if (options.json) {
|
|
20
|
+
console.log(options.pretty ? JSON.stringify(data, null, 2) : JSON.stringify(data));
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const formatBytes = (bytes) => {
|
|
24
|
+
if (bytes === 0)
|
|
25
|
+
return '0 B';
|
|
26
|
+
const k = 1024;
|
|
27
|
+
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
28
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
29
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
30
|
+
};
|
|
31
|
+
const formatDate = (date) => {
|
|
32
|
+
return date.toLocaleString();
|
|
33
|
+
};
|
|
34
|
+
export const vfsCommands = {
|
|
35
|
+
/**
|
|
36
|
+
* Read file from VFS
|
|
37
|
+
*/
|
|
38
|
+
async read(path, options) {
|
|
39
|
+
const spinner = ora('Reading file...').start();
|
|
40
|
+
try {
|
|
41
|
+
const brain = getBrainy();
|
|
42
|
+
const vfs = brain.vfs();
|
|
43
|
+
await vfs.init();
|
|
44
|
+
const buffer = await vfs.readFile(path, {
|
|
45
|
+
encoding: options.encoding
|
|
46
|
+
});
|
|
47
|
+
spinner.succeed('File read successfully');
|
|
48
|
+
if (options.output) {
|
|
49
|
+
// Write to local filesystem
|
|
50
|
+
writeFileSync(options.output, buffer);
|
|
51
|
+
console.log(chalk.green(`✓ Saved to: ${options.output}`));
|
|
52
|
+
}
|
|
53
|
+
else if (!options.json) {
|
|
54
|
+
// Display content
|
|
55
|
+
console.log('\n' + buffer.toString());
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
formatOutput({ path, content: buffer.toString(), size: buffer.length }, options);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
spinner.fail('Failed to read file');
|
|
63
|
+
console.error(chalk.red(error.message));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* Write file to VFS
|
|
69
|
+
*/
|
|
70
|
+
async write(path, options) {
|
|
71
|
+
const spinner = ora('Writing file...').start();
|
|
72
|
+
try {
|
|
73
|
+
const brain = getBrainy();
|
|
74
|
+
const vfs = brain.vfs();
|
|
75
|
+
await vfs.init();
|
|
76
|
+
let data;
|
|
77
|
+
if (options.file) {
|
|
78
|
+
// Read from local file
|
|
79
|
+
data = readFileSync(options.file, 'utf-8');
|
|
80
|
+
}
|
|
81
|
+
else if (options.content) {
|
|
82
|
+
data = options.content;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
spinner.fail('Must provide --content or --file');
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
await vfs.writeFile(path, data, {
|
|
89
|
+
encoding: options.encoding
|
|
90
|
+
});
|
|
91
|
+
spinner.succeed('File written successfully');
|
|
92
|
+
if (!options.json) {
|
|
93
|
+
console.log(chalk.green(`✓ Written to: ${path}`));
|
|
94
|
+
console.log(chalk.dim(` Size: ${formatBytes(Buffer.byteLength(data))}`));
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
formatOutput({ path, size: Buffer.byteLength(data) }, options);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
spinner.fail('Failed to write file');
|
|
102
|
+
console.error(chalk.red(error.message));
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
/**
|
|
107
|
+
* List directory contents
|
|
108
|
+
*/
|
|
109
|
+
async ls(path, options) {
|
|
110
|
+
const spinner = ora('Listing directory...').start();
|
|
111
|
+
try {
|
|
112
|
+
const brain = getBrainy();
|
|
113
|
+
const vfs = brain.vfs();
|
|
114
|
+
await vfs.init();
|
|
115
|
+
const entries = await vfs.readdir(path, { withFileTypes: true });
|
|
116
|
+
spinner.succeed(`Found ${Array.isArray(entries) ? entries.length : 0} items`);
|
|
117
|
+
if (!options.json) {
|
|
118
|
+
if (!Array.isArray(entries) || entries.length === 0) {
|
|
119
|
+
console.log(chalk.yellow('Directory is empty'));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (options.long) {
|
|
123
|
+
// Long format with details
|
|
124
|
+
const table = new Table({
|
|
125
|
+
head: [chalk.cyan('Type'), chalk.cyan('Size'), chalk.cyan('Modified'), chalk.cyan('Name')],
|
|
126
|
+
style: { head: [], border: [] }
|
|
127
|
+
});
|
|
128
|
+
for (const entry of entries) {
|
|
129
|
+
if (!options.all && entry.name.startsWith('.'))
|
|
130
|
+
continue;
|
|
131
|
+
const stat = await vfs.stat(`${path}/${entry.name}`);
|
|
132
|
+
table.push([
|
|
133
|
+
entry.isDirectory() ? chalk.blue('DIR') : 'FILE',
|
|
134
|
+
entry.isDirectory() ? '-' : formatBytes(stat.size),
|
|
135
|
+
formatDate(stat.mtime),
|
|
136
|
+
entry.name
|
|
137
|
+
]);
|
|
138
|
+
}
|
|
139
|
+
console.log('\n' + table.toString());
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
// Simple format
|
|
143
|
+
console.log();
|
|
144
|
+
for (const entry of entries) {
|
|
145
|
+
if (!options.all && entry.name.startsWith('.'))
|
|
146
|
+
continue;
|
|
147
|
+
if (entry.isDirectory()) {
|
|
148
|
+
console.log(chalk.blue(entry.name + '/'));
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
console.log(entry.name);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
formatOutput(entries, options);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
spinner.fail('Failed to list directory');
|
|
162
|
+
console.error(chalk.red(error.message));
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
/**
|
|
167
|
+
* Get file/directory stats
|
|
168
|
+
*/
|
|
169
|
+
async stat(path, options) {
|
|
170
|
+
const spinner = ora('Getting file stats...').start();
|
|
171
|
+
try {
|
|
172
|
+
const brain = getBrainy();
|
|
173
|
+
const vfs = brain.vfs();
|
|
174
|
+
await vfs.init();
|
|
175
|
+
const stats = await vfs.stat(path);
|
|
176
|
+
spinner.succeed('Stats retrieved');
|
|
177
|
+
if (!options.json) {
|
|
178
|
+
console.log(chalk.cyan('\nFile Statistics:'));
|
|
179
|
+
console.log(` Path: ${path}`);
|
|
180
|
+
console.log(` Type: ${stats.isDirectory() ? chalk.blue('Directory') : 'File'}`);
|
|
181
|
+
console.log(` Size: ${formatBytes(stats.size)}`);
|
|
182
|
+
console.log(` Created: ${formatDate(stats.birthtime)}`);
|
|
183
|
+
console.log(` Modified: ${formatDate(stats.mtime)}`);
|
|
184
|
+
console.log(` Accessed: ${formatDate(stats.atime)}`);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
formatOutput(stats, options);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
spinner.fail('Failed to get stats');
|
|
192
|
+
console.error(chalk.red(error.message));
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
/**
|
|
197
|
+
* Create directory
|
|
198
|
+
*/
|
|
199
|
+
async mkdir(path, options) {
|
|
200
|
+
const spinner = ora('Creating directory...').start();
|
|
201
|
+
try {
|
|
202
|
+
const brain = getBrainy();
|
|
203
|
+
const vfs = brain.vfs();
|
|
204
|
+
await vfs.init();
|
|
205
|
+
await vfs.mkdir(path, { recursive: options.parents });
|
|
206
|
+
spinner.succeed('Directory created');
|
|
207
|
+
if (!options.json) {
|
|
208
|
+
console.log(chalk.green(`✓ Created: ${path}`));
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
formatOutput({ path, created: true }, options);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
spinner.fail('Failed to create directory');
|
|
216
|
+
console.error(chalk.red(error.message));
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
/**
|
|
221
|
+
* Remove file or directory
|
|
222
|
+
*/
|
|
223
|
+
async rm(path, options) {
|
|
224
|
+
const spinner = ora('Removing...').start();
|
|
225
|
+
try {
|
|
226
|
+
const brain = getBrainy();
|
|
227
|
+
const vfs = brain.vfs();
|
|
228
|
+
await vfs.init();
|
|
229
|
+
const stats = await vfs.stat(path);
|
|
230
|
+
if (stats.isDirectory()) {
|
|
231
|
+
await vfs.rmdir(path, { recursive: options.recursive });
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
await vfs.unlink(path);
|
|
235
|
+
}
|
|
236
|
+
spinner.succeed('Removed successfully');
|
|
237
|
+
if (!options.json) {
|
|
238
|
+
console.log(chalk.green(`✓ Removed: ${path}`));
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
formatOutput({ path, removed: true }, options);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
spinner.fail('Failed to remove');
|
|
246
|
+
console.error(chalk.red(error.message));
|
|
247
|
+
if (!options.force) {
|
|
248
|
+
process.exit(1);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
/**
|
|
253
|
+
* Search files by content
|
|
254
|
+
*/
|
|
255
|
+
async search(query, options) {
|
|
256
|
+
const spinner = ora('Searching files...').start();
|
|
257
|
+
try {
|
|
258
|
+
const brain = getBrainy();
|
|
259
|
+
const vfs = brain.vfs();
|
|
260
|
+
await vfs.init();
|
|
261
|
+
const results = await vfs.search(query, {
|
|
262
|
+
path: options.path,
|
|
263
|
+
limit: options.limit ? parseInt(options.limit) : 10
|
|
264
|
+
});
|
|
265
|
+
spinner.succeed(`Found ${results.length} results`);
|
|
266
|
+
if (!options.json) {
|
|
267
|
+
if (results.length === 0) {
|
|
268
|
+
console.log(chalk.yellow('No results found'));
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
console.log(chalk.cyan('\n📄 Search Results:\n'));
|
|
272
|
+
results.forEach((result, i) => {
|
|
273
|
+
console.log(chalk.bold(`${i + 1}. ${result.path}`));
|
|
274
|
+
if (result.score) {
|
|
275
|
+
console.log(chalk.dim(` Score: ${(result.score * 100).toFixed(1)}%`));
|
|
276
|
+
}
|
|
277
|
+
if (result.excerpt) {
|
|
278
|
+
console.log(chalk.dim(` ${result.excerpt}`));
|
|
279
|
+
}
|
|
280
|
+
console.log();
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
formatOutput(results, options);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
spinner.fail('Search failed');
|
|
290
|
+
console.error(chalk.red(error.message));
|
|
291
|
+
process.exit(1);
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
/**
|
|
295
|
+
* Find similar files
|
|
296
|
+
*/
|
|
297
|
+
async similar(path, options) {
|
|
298
|
+
const spinner = ora('Finding similar files...').start();
|
|
299
|
+
try {
|
|
300
|
+
const brain = getBrainy();
|
|
301
|
+
const vfs = brain.vfs();
|
|
302
|
+
await vfs.init();
|
|
303
|
+
const results = await vfs.findSimilar(path, {
|
|
304
|
+
limit: options.limit ? parseInt(options.limit) : 10,
|
|
305
|
+
threshold: options.threshold ? parseFloat(options.threshold) : 0.7
|
|
306
|
+
});
|
|
307
|
+
spinner.succeed(`Found ${results.length} similar files`);
|
|
308
|
+
if (!options.json) {
|
|
309
|
+
if (results.length === 0) {
|
|
310
|
+
console.log(chalk.yellow('No similar files found'));
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
console.log(chalk.cyan('\n🔗 Similar Files:\n'));
|
|
314
|
+
results.forEach((result, i) => {
|
|
315
|
+
console.log(chalk.bold(`${i + 1}. ${result.path}`));
|
|
316
|
+
if (result.score) {
|
|
317
|
+
console.log(chalk.green(` Similarity: ${(result.score * 100).toFixed(1)}%`));
|
|
318
|
+
}
|
|
319
|
+
console.log();
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
formatOutput(results, options);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
spinner.fail('Failed to find similar files');
|
|
329
|
+
console.error(chalk.red(error.message));
|
|
330
|
+
process.exit(1);
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
/**
|
|
334
|
+
* Get directory tree structure
|
|
335
|
+
*/
|
|
336
|
+
async tree(path, options) {
|
|
337
|
+
const spinner = ora('Building tree...').start();
|
|
338
|
+
try {
|
|
339
|
+
const brain = getBrainy();
|
|
340
|
+
const vfs = brain.vfs();
|
|
341
|
+
await vfs.init();
|
|
342
|
+
const tree = await vfs.getTreeStructure(path, {
|
|
343
|
+
maxDepth: options.depth ? parseInt(options.depth) : 3
|
|
344
|
+
});
|
|
345
|
+
spinner.succeed('Tree built');
|
|
346
|
+
if (!options.json) {
|
|
347
|
+
console.log(chalk.cyan(`\n📁 ${path}\n`));
|
|
348
|
+
displayTree(tree, '', true);
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
formatOutput(tree, options);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
spinner.fail('Failed to build tree');
|
|
356
|
+
console.error(chalk.red(error.message));
|
|
357
|
+
process.exit(1);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
function displayTree(node, prefix, isLast) {
|
|
362
|
+
const connector = isLast ? '└── ' : '├── ';
|
|
363
|
+
const name = node.isDirectory ? chalk.blue(node.name + '/') : node.name;
|
|
364
|
+
console.log(prefix + connector + name);
|
|
365
|
+
if (node.children && node.children.length > 0) {
|
|
366
|
+
const childPrefix = prefix + (isLast ? ' ' : '│ ');
|
|
367
|
+
node.children.forEach((child, i) => {
|
|
368
|
+
displayTree(child, childPrefix, i === node.children.length - 1);
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
//# sourceMappingURL=vfs.js.map
|
package/dist/cli/index.js
CHANGED
|
@@ -9,7 +9,15 @@ import chalk from 'chalk';
|
|
|
9
9
|
import { neuralCommands } from './commands/neural.js';
|
|
10
10
|
import { coreCommands } from './commands/core.js';
|
|
11
11
|
import { utilityCommands } from './commands/utility.js';
|
|
12
|
-
import {
|
|
12
|
+
import { vfsCommands } from './commands/vfs.js';
|
|
13
|
+
import { dataCommands } from './commands/data.js';
|
|
14
|
+
import conversationCommand from './commands/conversation.js';
|
|
15
|
+
import { readFileSync } from 'fs';
|
|
16
|
+
import { fileURLToPath } from 'url';
|
|
17
|
+
import { dirname, join } from 'path';
|
|
18
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, '..', '..', 'package.json'), 'utf8'));
|
|
20
|
+
const version = packageJson.version;
|
|
13
21
|
// CLI Configuration
|
|
14
22
|
const program = new Command();
|
|
15
23
|
program
|
|
@@ -28,12 +36,29 @@ program
|
|
|
28
36
|
.option('-m, --metadata <json>', 'Add metadata')
|
|
29
37
|
.option('-t, --type <type>', 'Specify noun type')
|
|
30
38
|
.action(coreCommands.add);
|
|
39
|
+
program
|
|
40
|
+
.command('find <query>')
|
|
41
|
+
.description('Simple NLP search (just like code: brain.find("query"))')
|
|
42
|
+
.option('-k, --limit <number>', 'Number of results', '10')
|
|
43
|
+
.action(coreCommands.search);
|
|
31
44
|
program
|
|
32
45
|
.command('search <query>')
|
|
33
|
-
.description('
|
|
46
|
+
.description('Advanced search with Triple Intelligence™ (vector + graph + field)')
|
|
34
47
|
.option('-k, --limit <number>', 'Number of results', '10')
|
|
35
|
-
.option('
|
|
36
|
-
.option('--
|
|
48
|
+
.option('--offset <number>', 'Skip N results (pagination)')
|
|
49
|
+
.option('-t, --threshold <number>', 'Similarity threshold (0-1)', '0.7')
|
|
50
|
+
.option('--type <types>', 'Filter by type(s) - comma separated')
|
|
51
|
+
.option('--where <json>', 'Metadata filters (JSON)')
|
|
52
|
+
.option('--near <id>', 'Find items near this ID')
|
|
53
|
+
.option('--connected-to <id>', 'Connected to this entity')
|
|
54
|
+
.option('--connected-from <id>', 'Connected from this entity')
|
|
55
|
+
.option('--via <verbs>', 'Via these relationships - comma separated')
|
|
56
|
+
.option('--explain', 'Show scoring breakdown')
|
|
57
|
+
.option('--include-relations', 'Include entity relationships')
|
|
58
|
+
.option('--fusion <strategy>', 'Fusion strategy (adaptive|weighted|progressive)')
|
|
59
|
+
.option('--vector-weight <n>', 'Vector search weight (0-1)')
|
|
60
|
+
.option('--graph-weight <n>', 'Graph search weight (0-1)')
|
|
61
|
+
.option('--field-weight <n>', 'Field search weight (0-1)')
|
|
37
62
|
.action(coreCommands.search);
|
|
38
63
|
program
|
|
39
64
|
.command('get <id>')
|
|
@@ -95,10 +120,14 @@ program
|
|
|
95
120
|
.action(neuralCommands.hierarchy);
|
|
96
121
|
program
|
|
97
122
|
.command('path <from> <to>')
|
|
98
|
-
.description('Find semantic path between items')
|
|
123
|
+
.description('Find semantic path between items (v3.21.0)')
|
|
99
124
|
.option('--steps', 'Show step-by-step path')
|
|
100
125
|
.option('--max-hops <number>', 'Maximum path length', '5')
|
|
101
|
-
.action(
|
|
126
|
+
.action(() => {
|
|
127
|
+
console.log(chalk.yellow('\n⚠️ Semantic path finding coming in v3.21.0'));
|
|
128
|
+
console.log(chalk.dim('This feature requires implementing graph traversal algorithms'));
|
|
129
|
+
console.log(chalk.dim('Use "brainy neighbors" and "brainy hierarchy" to explore connections'));
|
|
130
|
+
});
|
|
102
131
|
program
|
|
103
132
|
.command('outliers')
|
|
104
133
|
.alias('anomalies')
|
|
@@ -115,11 +144,219 @@ program
|
|
|
115
144
|
.option('--dimensions <number>', '2D or 3D', '2')
|
|
116
145
|
.option('-o, --output <file>', 'Output file')
|
|
117
146
|
.action(neuralCommands.visualize);
|
|
147
|
+
// ===== Conversation Commands (Infinite Memory) =====
|
|
148
|
+
program
|
|
149
|
+
.command('conversation')
|
|
150
|
+
.alias('conv')
|
|
151
|
+
.description('💬 Infinite agent memory and context management')
|
|
152
|
+
.addCommand(new Command('setup')
|
|
153
|
+
.description('Set up MCP server for Claude Code integration')
|
|
154
|
+
.action(async () => {
|
|
155
|
+
await conversationCommand.handler({ action: 'setup', _: [] });
|
|
156
|
+
}))
|
|
157
|
+
.addCommand(new Command('search')
|
|
158
|
+
.description('Search messages across conversations')
|
|
159
|
+
.requiredOption('-q, --query <query>', 'Search query')
|
|
160
|
+
.option('-c, --conversation-id <id>', 'Filter by conversation')
|
|
161
|
+
.option('-r, --role <role>', 'Filter by role')
|
|
162
|
+
.option('-l, --limit <number>', 'Maximum results', '10')
|
|
163
|
+
.action(async (options) => {
|
|
164
|
+
await conversationCommand.handler({ action: 'search', ...options, _: [] });
|
|
165
|
+
}))
|
|
166
|
+
.addCommand(new Command('context')
|
|
167
|
+
.description('Get relevant context for a query')
|
|
168
|
+
.requiredOption('-q, --query <query>', 'Context query')
|
|
169
|
+
.option('-l, --limit <number>', 'Maximum messages', '10')
|
|
170
|
+
.action(async (options) => {
|
|
171
|
+
await conversationCommand.handler({ action: 'context', ...options, _: [] });
|
|
172
|
+
}))
|
|
173
|
+
.addCommand(new Command('thread')
|
|
174
|
+
.description('Get full conversation thread')
|
|
175
|
+
.requiredOption('-c, --conversation-id <id>', 'Conversation ID')
|
|
176
|
+
.action(async (options) => {
|
|
177
|
+
await conversationCommand.handler({ action: 'thread', ...options, _: [] });
|
|
178
|
+
}))
|
|
179
|
+
.addCommand(new Command('stats')
|
|
180
|
+
.description('Show conversation statistics')
|
|
181
|
+
.action(async () => {
|
|
182
|
+
await conversationCommand.handler({ action: 'stats', _: [] });
|
|
183
|
+
}));
|
|
184
|
+
// ===== VFS Commands (Subcommand Group) =====
|
|
185
|
+
program
|
|
186
|
+
.command('vfs')
|
|
187
|
+
.description('📁 Virtual File System operations')
|
|
188
|
+
.addCommand(new Command('read')
|
|
189
|
+
.argument('<path>', 'File path')
|
|
190
|
+
.description('Read file from VFS')
|
|
191
|
+
.option('-o, --output <file>', 'Save to local file')
|
|
192
|
+
.option('--encoding <encoding>', 'File encoding', 'utf-8')
|
|
193
|
+
.action((path, options) => {
|
|
194
|
+
vfsCommands.read(path, options);
|
|
195
|
+
}))
|
|
196
|
+
.addCommand(new Command('write')
|
|
197
|
+
.argument('<path>', 'File path')
|
|
198
|
+
.description('Write file to VFS')
|
|
199
|
+
.option('-c, --content <content>', 'File content')
|
|
200
|
+
.option('-f, --file <file>', 'Read from local file')
|
|
201
|
+
.option('--encoding <encoding>', 'File encoding', 'utf-8')
|
|
202
|
+
.action((path, options) => {
|
|
203
|
+
vfsCommands.write(path, options);
|
|
204
|
+
}))
|
|
205
|
+
.addCommand(new Command('ls')
|
|
206
|
+
.alias('list')
|
|
207
|
+
.argument('<path>', 'Directory path')
|
|
208
|
+
.description('List directory contents')
|
|
209
|
+
.option('-l, --long', 'Long format with details')
|
|
210
|
+
.option('-a, --all', 'Show hidden files')
|
|
211
|
+
.action((path, options) => {
|
|
212
|
+
vfsCommands.ls(path, options);
|
|
213
|
+
}))
|
|
214
|
+
.addCommand(new Command('stat')
|
|
215
|
+
.argument('<path>', 'File/directory path')
|
|
216
|
+
.description('Get file/directory statistics')
|
|
217
|
+
.action((path, options) => {
|
|
218
|
+
vfsCommands.stat(path, options);
|
|
219
|
+
}))
|
|
220
|
+
.addCommand(new Command('mkdir')
|
|
221
|
+
.argument('<path>', 'Directory path')
|
|
222
|
+
.description('Create directory')
|
|
223
|
+
.option('-p, --parents', 'Create parent directories')
|
|
224
|
+
.action((path, options) => {
|
|
225
|
+
vfsCommands.mkdir(path, options);
|
|
226
|
+
}))
|
|
227
|
+
.addCommand(new Command('rm')
|
|
228
|
+
.argument('<path>', 'File/directory path')
|
|
229
|
+
.description('Remove file or directory')
|
|
230
|
+
.option('-r, --recursive', 'Remove recursively')
|
|
231
|
+
.option('-f, --force', 'Force removal')
|
|
232
|
+
.action((path, options) => {
|
|
233
|
+
vfsCommands.rm(path, options);
|
|
234
|
+
}))
|
|
235
|
+
.addCommand(new Command('search')
|
|
236
|
+
.argument('<query>', 'Search query')
|
|
237
|
+
.description('Search files by content')
|
|
238
|
+
.option('--path <path>', 'Search within path')
|
|
239
|
+
.option('-l, --limit <number>', 'Max results', '10')
|
|
240
|
+
.option('--type <type>', 'File type filter')
|
|
241
|
+
.action((query, options) => {
|
|
242
|
+
vfsCommands.search(query, options);
|
|
243
|
+
}))
|
|
244
|
+
.addCommand(new Command('similar')
|
|
245
|
+
.argument('<path>', 'File path')
|
|
246
|
+
.description('Find similar files')
|
|
247
|
+
.option('-l, --limit <number>', 'Max results', '10')
|
|
248
|
+
.option('-t, --threshold <number>', 'Similarity threshold', '0.7')
|
|
249
|
+
.action((path, options) => {
|
|
250
|
+
vfsCommands.similar(path, options);
|
|
251
|
+
}))
|
|
252
|
+
.addCommand(new Command('tree')
|
|
253
|
+
.argument('<path>', 'Directory path')
|
|
254
|
+
.description('Show directory tree')
|
|
255
|
+
.option('-d, --depth <number>', 'Max depth', '3')
|
|
256
|
+
.action((path, options) => {
|
|
257
|
+
vfsCommands.tree(path, options);
|
|
258
|
+
}));
|
|
259
|
+
// ===== VFS Commands (Backward Compatibility - Deprecated) =====
|
|
260
|
+
program
|
|
261
|
+
.command('vfs-read <path>')
|
|
262
|
+
.description('[DEPRECATED] Use: brainy vfs read <path>')
|
|
263
|
+
.option('-o, --output <file>', 'Save to local file')
|
|
264
|
+
.option('--encoding <encoding>', 'File encoding', 'utf-8')
|
|
265
|
+
.action((path, options) => {
|
|
266
|
+
console.log(chalk.yellow('⚠️ Command "vfs-read" is deprecated. Use: brainy vfs read'));
|
|
267
|
+
vfsCommands.read(path, options);
|
|
268
|
+
});
|
|
269
|
+
program
|
|
270
|
+
.command('vfs-write <path>')
|
|
271
|
+
.description('[DEPRECATED] Use: brainy vfs write <path>')
|
|
272
|
+
.option('-c, --content <content>', 'File content')
|
|
273
|
+
.option('-f, --file <file>', 'Read from local file')
|
|
274
|
+
.option('--encoding <encoding>', 'File encoding', 'utf-8')
|
|
275
|
+
.action((path, options) => {
|
|
276
|
+
console.log(chalk.yellow('⚠️ Command "vfs-write" is deprecated. Use: brainy vfs write'));
|
|
277
|
+
vfsCommands.write(path, options);
|
|
278
|
+
});
|
|
279
|
+
program
|
|
280
|
+
.command('vfs-ls <path>')
|
|
281
|
+
.alias('vfs-list')
|
|
282
|
+
.description('[DEPRECATED] Use: brainy vfs ls <path>')
|
|
283
|
+
.option('-l, --long', 'Long format with details')
|
|
284
|
+
.option('-a, --all', 'Show hidden files')
|
|
285
|
+
.action((path, options) => {
|
|
286
|
+
console.log(chalk.yellow('⚠️ Command "vfs-ls" is deprecated. Use: brainy vfs ls'));
|
|
287
|
+
vfsCommands.ls(path, options);
|
|
288
|
+
});
|
|
289
|
+
program
|
|
290
|
+
.command('vfs-stat <path>')
|
|
291
|
+
.description('[DEPRECATED] Use: brainy vfs stat <path>')
|
|
292
|
+
.action((path, options) => {
|
|
293
|
+
console.log(chalk.yellow('⚠️ Command "vfs-stat" is deprecated. Use: brainy vfs stat'));
|
|
294
|
+
vfsCommands.stat(path, options);
|
|
295
|
+
});
|
|
296
|
+
program
|
|
297
|
+
.command('vfs-mkdir <path>')
|
|
298
|
+
.description('[DEPRECATED] Use: brainy vfs mkdir <path>')
|
|
299
|
+
.option('-p, --parents', 'Create parent directories')
|
|
300
|
+
.action((path, options) => {
|
|
301
|
+
console.log(chalk.yellow('⚠️ Command "vfs-mkdir" is deprecated. Use: brainy vfs mkdir'));
|
|
302
|
+
vfsCommands.mkdir(path, options);
|
|
303
|
+
});
|
|
304
|
+
program
|
|
305
|
+
.command('vfs-rm <path>')
|
|
306
|
+
.description('[DEPRECATED] Use: brainy vfs rm <path>')
|
|
307
|
+
.option('-r, --recursive', 'Remove recursively')
|
|
308
|
+
.option('-f, --force', 'Force removal')
|
|
309
|
+
.action((path, options) => {
|
|
310
|
+
console.log(chalk.yellow('⚠️ Command "vfs-rm" is deprecated. Use: brainy vfs rm'));
|
|
311
|
+
vfsCommands.rm(path, options);
|
|
312
|
+
});
|
|
313
|
+
program
|
|
314
|
+
.command('vfs-search <query>')
|
|
315
|
+
.description('[DEPRECATED] Use: brainy vfs search <query>')
|
|
316
|
+
.option('--path <path>', 'Search within path')
|
|
317
|
+
.option('-l, --limit <number>', 'Max results', '10')
|
|
318
|
+
.option('--type <type>', 'File type filter')
|
|
319
|
+
.action((query, options) => {
|
|
320
|
+
console.log(chalk.yellow('⚠️ Command "vfs-search" is deprecated. Use: brainy vfs search'));
|
|
321
|
+
vfsCommands.search(query, options);
|
|
322
|
+
});
|
|
323
|
+
program
|
|
324
|
+
.command('vfs-similar <path>')
|
|
325
|
+
.description('[DEPRECATED] Use: brainy vfs similar <path>')
|
|
326
|
+
.option('-l, --limit <number>', 'Max results', '10')
|
|
327
|
+
.option('-t, --threshold <number>', 'Similarity threshold', '0.7')
|
|
328
|
+
.action((path, options) => {
|
|
329
|
+
console.log(chalk.yellow('⚠️ Command "vfs-similar" is deprecated. Use: brainy vfs similar'));
|
|
330
|
+
vfsCommands.similar(path, options);
|
|
331
|
+
});
|
|
332
|
+
program
|
|
333
|
+
.command('vfs-tree <path>')
|
|
334
|
+
.description('[DEPRECATED] Use: brainy vfs tree <path>')
|
|
335
|
+
.option('-d, --depth <number>', 'Max depth', '3')
|
|
336
|
+
.action((path, options) => {
|
|
337
|
+
console.log(chalk.yellow('⚠️ Command "vfs-tree" is deprecated. Use: brainy vfs tree'));
|
|
338
|
+
vfsCommands.tree(path, options);
|
|
339
|
+
});
|
|
340
|
+
// ===== Data Management Commands =====
|
|
341
|
+
program
|
|
342
|
+
.command('backup <file>')
|
|
343
|
+
.description('Create database backup')
|
|
344
|
+
.option('--compress', 'Compress backup')
|
|
345
|
+
.action(dataCommands.backup);
|
|
346
|
+
program
|
|
347
|
+
.command('restore <file>')
|
|
348
|
+
.description('Restore from backup')
|
|
349
|
+
.option('--merge', 'Merge with existing data (default: replace)')
|
|
350
|
+
.action(dataCommands.restore);
|
|
351
|
+
program
|
|
352
|
+
.command('data-stats')
|
|
353
|
+
.description('Show detailed database statistics')
|
|
354
|
+
.action(dataCommands.stats);
|
|
118
355
|
// ===== Utility Commands =====
|
|
119
356
|
program
|
|
120
357
|
.command('stats')
|
|
121
358
|
.alias('statistics')
|
|
122
|
-
.description('Show database statistics')
|
|
359
|
+
.description('Show quick database statistics')
|
|
123
360
|
.option('--by-service', 'Group by service')
|
|
124
361
|
.option('--detailed', 'Show detailed stats')
|
|
125
362
|
.action(utilityCommands.stats);
|