@theihtisham/agent-shadow-brain 5.0.0 → 5.0.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/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // src/cli.ts — CLI entry point for Shadow Brain v5.0.0
2
+ // src/cli.ts — CLI entry point for Shadow Brain v5.0.1
3
3
  import { Command } from 'commander';
4
4
  import chalk from 'chalk';
5
5
  import Conf from 'conf';
@@ -7,7 +7,7 @@ import * as fs from 'fs';
7
7
  import * as path from 'path';
8
8
  import { Orchestrator } from './brain/orchestrator.js';
9
9
  import { detectRunningAgents, createAdapter } from './adapters/index.js';
10
- const VERSION = '5.0.0';
10
+ const VERSION = '5.0.1';
11
11
  const config = new Conf({
12
12
  projectName: 'shadow-brain',
13
13
  defaults: {
@@ -2428,7 +2428,7 @@ const v5Cmd = new Command('v5')
2428
2428
  const program = new Command();
2429
2429
  program
2430
2430
  .name('shadow-brain')
2431
- .description('Shadow Brain v5.0.0 — Infinite Intelligence Layer for AI Coding Agents with Hierarchical Memory, Context Recall, Consensus & Collective Learning')
2431
+ .description('Shadow Brain v5.0.1 — Infinite Intelligence Layer for AI Coding Agents with Zero-Config Setup, MCP Server, Rich Dashboard, Hierarchical Memory, Context Recall, Consensus & Collective Learning')
2432
2432
  .version(VERSION);
2433
2433
  program.addCommand(startCmd);
2434
2434
  program.addCommand(reviewCmd);
@@ -2488,5 +2488,181 @@ program.addCommand(recallCmd);
2488
2488
  program.addCommand(consensusCmd);
2489
2489
  program.addCommand(collectiveCmd);
2490
2490
  program.addCommand(v5Cmd);
2491
+ // ─── v5.0.1 COMMANDS ────────────────────────────────────────────────────────────
2492
+ // off — Stop Shadow Brain (alias for killing the process, clean shutdown)
2493
+ const offCmd = new Command('off')
2494
+ .description('Stop Shadow Brain and clean up')
2495
+ .action(async () => {
2496
+ console.log(chalk.magenta.bold('\n SHADOW BRAIN v' + VERSION + ' — Shutting down'));
2497
+ try {
2498
+ const { default: execaDefault } = await import('execa');
2499
+ const exec = execaDefault;
2500
+ try {
2501
+ if (process.platform === 'win32') {
2502
+ await exec('taskkill', ['/F', '/IM', 'node.exe', '/FI', 'WINDOWTITLE eq shadow-brain*'], { reject: false });
2503
+ }
2504
+ else {
2505
+ await exec('pkill', ['-f', 'shadow-brain'], { reject: false });
2506
+ }
2507
+ }
2508
+ catch { /* no process found */ }
2509
+ console.log(chalk.green(' Shadow Brain stopped successfully.'));
2510
+ }
2511
+ catch {
2512
+ console.log(chalk.yellow(' No running Shadow Brain instance found.'));
2513
+ }
2514
+ process.exit(0);
2515
+ });
2516
+ // ask — Natural language query against brain state
2517
+ const askCmd = new Command('ask')
2518
+ .description('Ask Shadow Brain a question about your project')
2519
+ .argument('<question>', 'Natural language question')
2520
+ .option('-p, --provider <provider>', 'LLM provider')
2521
+ .option('-m, --model <model>', 'LLM model')
2522
+ .action(async (question, opts) => {
2523
+ console.log(chalk.magenta.bold(`\n SHADOW BRAIN v${VERSION} — Ask`));
2524
+ console.log(chalk.dim(' Question: ') + chalk.cyan(question));
2525
+ try {
2526
+ const brainConfig = mergeConfig({ ...opts, projectDir: process.cwd() });
2527
+ const orchestrator = new Orchestrator(brainConfig);
2528
+ await orchestrator.start();
2529
+ // Get project context and build a prompt
2530
+ const status = orchestrator.getStatus();
2531
+ const prompt = `You are Shadow Brain, an expert AI coding intelligence layer. Based on the following project context, answer the user's question concisely.\n\nProject: ${status.projectDir}\nProvider: ${status.provider}\nHealth Score: ${status.healthScore || 'N/A'}\nInsights Generated: ${status.insightsGenerated}\nFiles Reviewed: ${status.filesReviewed}\n\nQuestion: ${question}\n\nAnswer:`;
2532
+ // Use the LLM client directly via the analyzer's prompt builder
2533
+ const llm = new (await import('./brain/llm-client.js')).LLMClient({
2534
+ provider: brainConfig.provider,
2535
+ apiKey: brainConfig.apiKey,
2536
+ model: brainConfig.model,
2537
+ });
2538
+ const answer = await llm.complete(prompt);
2539
+ console.log(chalk.green('\n ' + answer));
2540
+ await orchestrator.stop();
2541
+ }
2542
+ catch (err) {
2543
+ console.error(chalk.red(' Error:'), err.message);
2544
+ process.exit(1);
2545
+ }
2546
+ });
2547
+ // export — Export brain state
2548
+ const exportCmd = new Command('export')
2549
+ .description('Export full brain state to a portable JSON file')
2550
+ .option('-o, --output <dir>', 'Output directory for the export')
2551
+ .action(async (opts) => {
2552
+ console.log(chalk.magenta.bold(`\n SHADOW BRAIN v${VERSION} — Export`));
2553
+ try {
2554
+ const { BrainPortability } = await import('./brain/brain-portability.js');
2555
+ const portability = new BrainPortability(process.cwd(), opts.output);
2556
+ const result = await portability.exportBrain();
2557
+ console.log(chalk.green(' Brain state exported successfully!'));
2558
+ console.log(chalk.dim(' File: ') + chalk.cyan(result.filePath));
2559
+ console.log(chalk.dim(' Size: ') + chalk.cyan((result.sizeBytes / 1024).toFixed(1) + ' KB'));
2560
+ console.log(chalk.dim(' SHA-256: ') + chalk.dim(result.checksum.slice(0, 16) + '...'));
2561
+ }
2562
+ catch (err) {
2563
+ console.error(chalk.red(' Error:'), err.message);
2564
+ process.exit(1);
2565
+ }
2566
+ });
2567
+ // import — Import brain state
2568
+ const importCmd = new Command('import')
2569
+ .description('Import brain state from an export file')
2570
+ .argument('<file>', 'Path to the export JSON file')
2571
+ .option('--merge', 'Merge with existing state instead of replacing')
2572
+ .option('--skip <modules>', 'Comma-separated list of modules to skip')
2573
+ .action(async (file, opts) => {
2574
+ console.log(chalk.magenta.bold(`\n SHADOW BRAIN v${VERSION} — Import`));
2575
+ try {
2576
+ const { BrainPortability } = await import('./brain/brain-portability.js');
2577
+ const portability = new BrainPortability(process.cwd());
2578
+ const result = await portability.importBrain(file, {
2579
+ merge: opts.merge || false,
2580
+ skipModules: opts.skip?.split(',') || [],
2581
+ });
2582
+ console.log(chalk.green(' Brain state imported successfully!'));
2583
+ console.log(chalk.dim(' Imported: ') + chalk.green(result.imported.join(', ') || 'none'));
2584
+ console.log(chalk.dim(' Skipped: ') + chalk.yellow(result.skipped.join(', ') || 'none'));
2585
+ if (result.errors.length > 0) {
2586
+ console.log(chalk.dim(' Errors: ') + chalk.red(result.errors.join('; ')));
2587
+ }
2588
+ }
2589
+ catch (err) {
2590
+ console.error(chalk.red(' Error:'), err.message);
2591
+ process.exit(1);
2592
+ }
2593
+ });
2594
+ // plugin — Manage plugins
2595
+ const pluginCmd = new Command('plugin')
2596
+ .description('Manage Shadow Brain plugins')
2597
+ .addCommand(new Command('list')
2598
+ .description('List installed plugins')
2599
+ .action(async () => {
2600
+ console.log(chalk.magenta.bold(`\n SHADOW BRAIN v${VERSION} — Plugins`));
2601
+ try {
2602
+ const { PluginSystem } = await import('./brain/plugin-system.js');
2603
+ const ps = new PluginSystem(process.cwd());
2604
+ await ps.loadAll();
2605
+ const plugins = ps.getPlugins();
2606
+ if (plugins.length === 0) {
2607
+ console.log(chalk.dim(' No plugins found.'));
2608
+ console.log(chalk.dim(' Add plugins to: ') + chalk.cyan('shadow-brain-plugins/'));
2609
+ return;
2610
+ }
2611
+ for (const p of plugins) {
2612
+ const status = p.enabled ? chalk.green('active') : chalk.red('disabled');
2613
+ console.log(` ${status} ${chalk.bold(p.manifest.name)} v${p.manifest.version} — ${chalk.dim(p.manifest.description)}`);
2614
+ }
2615
+ }
2616
+ catch (err) {
2617
+ console.error(chalk.red(' Error:'), err.message);
2618
+ }
2619
+ }))
2620
+ .addCommand(new Command('create')
2621
+ .description('Create a new plugin from template')
2622
+ .argument('<name>', 'Plugin name')
2623
+ .action(async (name) => {
2624
+ console.log(chalk.magenta.bold(`\n SHADOW BRAIN v${VERSION} — Create Plugin`));
2625
+ try {
2626
+ const { PluginSystem } = await import('./brain/plugin-system.js');
2627
+ const ps = new PluginSystem(process.cwd());
2628
+ const dir = ps.createTemplate(name);
2629
+ console.log(chalk.green(' Plugin template created!'));
2630
+ console.log(chalk.dim(' Directory: ') + chalk.cyan(dir));
2631
+ console.log(chalk.dim(' Edit manifest.json and index.js to customize.'));
2632
+ }
2633
+ catch (err) {
2634
+ console.error(chalk.red(' Error:'), err.message);
2635
+ process.exit(1);
2636
+ }
2637
+ }))
2638
+ .addCommand(new Command('stats')
2639
+ .description('Show plugin system statistics')
2640
+ .action(async () => {
2641
+ console.log(chalk.magenta.bold(`\n SHADOW BRAIN v${VERSION} — Plugin Stats`));
2642
+ try {
2643
+ const { PluginSystem } = await import('./brain/plugin-system.js');
2644
+ const ps = new PluginSystem(process.cwd());
2645
+ await ps.loadAll();
2646
+ const stats = ps.getStats();
2647
+ console.log(chalk.dim(' Total plugins: ') + chalk.cyan(String(stats.totalPlugins)));
2648
+ console.log(chalk.dim(' Enabled: ') + chalk.green(String(stats.enabledPlugins)));
2649
+ console.log(chalk.dim(' Disabled: ') + chalk.red(String(stats.disabledPlugins)));
2650
+ console.log(chalk.dim(' Total hooks: ') + chalk.cyan(String(stats.totalHooks)));
2651
+ if (Object.keys(stats.hooksByEvent).length > 0) {
2652
+ console.log(chalk.dim(' Hooks by event:'));
2653
+ for (const [event, count] of Object.entries(stats.hooksByEvent)) {
2654
+ console.log(` ${chalk.cyan(event)}: ${count}`);
2655
+ }
2656
+ }
2657
+ }
2658
+ catch (err) {
2659
+ console.error(chalk.red(' Error:'), err.message);
2660
+ }
2661
+ }));
2662
+ program.addCommand(offCmd);
2663
+ program.addCommand(askCmd);
2664
+ program.addCommand(exportCmd);
2665
+ program.addCommand(importCmd);
2666
+ program.addCommand(pluginCmd);
2491
2667
  program.parse();
2492
2668
  //# sourceMappingURL=cli.js.map