@soulcraft/brainy 3.19.1 → 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/bin/brainy-minimal.js +82 -0
- package/dist/cli/commands/core.d.ts +14 -2
- package/dist/cli/commands/core.js +142 -26
- 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 +16 -5
- package/dist/cli/commands/utility.js +39 -97
- package/dist/cli/commands/vfs.d.ts +73 -0
- package/dist/cli/commands/vfs.js +372 -0
- package/dist/cli/index.js +201 -6
- package/dist/cli/interactive.d.ts +5 -0
- package/dist/cli/interactive.js +32 -8
- package/package.json +4 -1
package/dist/cli/index.js
CHANGED
|
@@ -9,6 +9,8 @@ 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 { vfsCommands } from './commands/vfs.js';
|
|
13
|
+
import { dataCommands } from './commands/data.js';
|
|
12
14
|
import conversationCommand from './commands/conversation.js';
|
|
13
15
|
import { readFileSync } from 'fs';
|
|
14
16
|
import { fileURLToPath } from 'url';
|
|
@@ -34,12 +36,29 @@ program
|
|
|
34
36
|
.option('-m, --metadata <json>', 'Add metadata')
|
|
35
37
|
.option('-t, --type <type>', 'Specify noun type')
|
|
36
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);
|
|
37
44
|
program
|
|
38
45
|
.command('search <query>')
|
|
39
|
-
.description('
|
|
46
|
+
.description('Advanced search with Triple Intelligence™ (vector + graph + field)')
|
|
40
47
|
.option('-k, --limit <number>', 'Number of results', '10')
|
|
41
|
-
.option('
|
|
42
|
-
.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)')
|
|
43
62
|
.action(coreCommands.search);
|
|
44
63
|
program
|
|
45
64
|
.command('get <id>')
|
|
@@ -101,10 +120,14 @@ program
|
|
|
101
120
|
.action(neuralCommands.hierarchy);
|
|
102
121
|
program
|
|
103
122
|
.command('path <from> <to>')
|
|
104
|
-
.description('Find semantic path between items')
|
|
123
|
+
.description('Find semantic path between items (v3.21.0)')
|
|
105
124
|
.option('--steps', 'Show step-by-step path')
|
|
106
125
|
.option('--max-hops <number>', 'Maximum path length', '5')
|
|
107
|
-
.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
|
+
});
|
|
108
131
|
program
|
|
109
132
|
.command('outliers')
|
|
110
133
|
.alias('anomalies')
|
|
@@ -158,11 +181,182 @@ program
|
|
|
158
181
|
.action(async () => {
|
|
159
182
|
await conversationCommand.handler({ action: 'stats', _: [] });
|
|
160
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);
|
|
161
355
|
// ===== Utility Commands =====
|
|
162
356
|
program
|
|
163
357
|
.command('stats')
|
|
164
358
|
.alias('statistics')
|
|
165
|
-
.description('Show database statistics')
|
|
359
|
+
.description('Show quick database statistics')
|
|
166
360
|
.option('--by-service', 'Group by service')
|
|
167
361
|
.option('--detailed', 'Show detailed stats')
|
|
168
362
|
.action(utilityCommands.stats);
|
|
@@ -207,3 +401,4 @@ catch (error) {
|
|
|
207
401
|
if (!process.argv.slice(2).length) {
|
|
208
402
|
program.outputHelp();
|
|
209
403
|
}
|
|
404
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -108,6 +108,10 @@ export declare function showWelcome(): void;
|
|
|
108
108
|
* Interactive command selector for beginners
|
|
109
109
|
*/
|
|
110
110
|
export declare function promptCommand(): Promise<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Start interactive REPL mode
|
|
113
|
+
*/
|
|
114
|
+
export declare function startInteractiveMode(): Promise<void>;
|
|
111
115
|
/**
|
|
112
116
|
* Export all interactive components
|
|
113
117
|
*/
|
|
@@ -160,5 +164,6 @@ declare const _default: {
|
|
|
160
164
|
ProgressTracker: typeof ProgressTracker;
|
|
161
165
|
showWelcome: typeof showWelcome;
|
|
162
166
|
promptCommand: typeof promptCommand;
|
|
167
|
+
startInteractiveMode: typeof startInteractiveMode;
|
|
163
168
|
};
|
|
164
169
|
export default _default;
|
package/dist/cli/interactive.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
import inquirer from 'inquirer';
|
|
9
|
-
import fuzzy from 'fuzzy'
|
|
9
|
+
// import fuzzy from 'fuzzy' // TODO: Install fuzzy package or remove dependency
|
|
10
10
|
import ora from 'ora';
|
|
11
11
|
import { getBrainyVersion } from '../utils/version.js';
|
|
12
12
|
// Professional color scheme
|
|
@@ -108,12 +108,12 @@ export async function promptItemId(action, brain, allowMultiple = false) {
|
|
|
108
108
|
let choices = [];
|
|
109
109
|
if (brain) {
|
|
110
110
|
try {
|
|
111
|
-
const recent = await brain.
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
const recent = await brain.find({
|
|
112
|
+
query: '*',
|
|
113
|
+
limit: 10
|
|
114
114
|
});
|
|
115
115
|
choices = recent.map(item => ({
|
|
116
|
-
name: `${item.id} - ${item.content?.substring(0, 50)}...`,
|
|
116
|
+
name: `${item.id} - ${item.content?.substring(0, 50) || 'No content'}...`,
|
|
117
117
|
value: item.id,
|
|
118
118
|
short: item.id
|
|
119
119
|
}));
|
|
@@ -420,8 +420,21 @@ export async function promptRelationship(brain) {
|
|
|
420
420
|
* Smart command suggestions when user types wrong command
|
|
421
421
|
*/
|
|
422
422
|
export function suggestCommand(input, availableCommands) {
|
|
423
|
-
|
|
424
|
-
|
|
423
|
+
// Simple fuzzy matching without external dependency
|
|
424
|
+
// Filter commands that start with or contain the input
|
|
425
|
+
const matches = availableCommands
|
|
426
|
+
.filter(cmd => cmd.toLowerCase().includes(input.toLowerCase()))
|
|
427
|
+
.sort((a, b) => {
|
|
428
|
+
// Prefer commands that start with the input
|
|
429
|
+
const aStarts = a.toLowerCase().startsWith(input.toLowerCase());
|
|
430
|
+
const bStarts = b.toLowerCase().startsWith(input.toLowerCase());
|
|
431
|
+
if (aStarts && !bStarts)
|
|
432
|
+
return -1;
|
|
433
|
+
if (!aStarts && bStarts)
|
|
434
|
+
return 1;
|
|
435
|
+
return 0;
|
|
436
|
+
});
|
|
437
|
+
return matches.slice(0, 3);
|
|
425
438
|
}
|
|
426
439
|
/**
|
|
427
440
|
* Beautiful error display with helpful context
|
|
@@ -519,6 +532,15 @@ export async function promptCommand() {
|
|
|
519
532
|
});
|
|
520
533
|
return command;
|
|
521
534
|
}
|
|
535
|
+
/**
|
|
536
|
+
* Start interactive REPL mode
|
|
537
|
+
*/
|
|
538
|
+
export async function startInteractiveMode() {
|
|
539
|
+
console.log(chalk.cyan('\n🧠 Brainy Interactive Mode\n'));
|
|
540
|
+
console.log(chalk.yellow('Interactive REPL mode coming in v3.20.0\n'));
|
|
541
|
+
console.log(chalk.dim('Use specific commands for now: brainy add, brainy search, etc.'));
|
|
542
|
+
process.exit(0);
|
|
543
|
+
}
|
|
522
544
|
/**
|
|
523
545
|
* Export all interactive components
|
|
524
546
|
*/
|
|
@@ -538,5 +560,7 @@ export default {
|
|
|
538
560
|
showError,
|
|
539
561
|
ProgressTracker,
|
|
540
562
|
showWelcome,
|
|
541
|
-
promptCommand
|
|
563
|
+
promptCommand,
|
|
564
|
+
startInteractiveMode
|
|
542
565
|
};
|
|
566
|
+
//# sourceMappingURL=interactive.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.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",
|
|
@@ -128,6 +128,9 @@
|
|
|
128
128
|
"README.md",
|
|
129
129
|
"CHANGELOG.md"
|
|
130
130
|
],
|
|
131
|
+
"overrides": {
|
|
132
|
+
"boolean": "3.2.0"
|
|
133
|
+
},
|
|
131
134
|
"devDependencies": {
|
|
132
135
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
133
136
|
"@rollup/plugin-node-resolve": "^16.0.1",
|