@timmeck/brain 3.36.27 → 3.36.29

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/README.md CHANGED
@@ -5,9 +5,9 @@
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
6
  [![GitHub stars](https://img.shields.io/github/stars/timmeck/brain-ecosystem?style=social)](https://github.com/timmeck/brain-ecosystem)
7
7
 
8
- **Autonomous Error Memory, Code Intelligence & Self-Improving AI for Claude Code — 134 MCP Tools, 60+ Engines**
8
+ **Autonomous Error Memory, Code Intelligence & Self-Improving AI for Claude Code — 162 MCP Tools, 72+ Engines**
9
9
 
10
- Brain is an MCP server that gives Claude Code a persistent, self-improving memory. It remembers errors, learns solutions, and runs 60+ autonomous engines in a 40-step feedback cycle. It observes itself, detects anomalies, forms and tests hypotheses, distills principles, reasons in chains, feels emotions, evolves strategies genetically, debates itself, challenges its own principles (Advocatus Diaboli), gets curious about knowledge gaps, syncs knowledge via Borg collective, loads community plugins, and modifies its own source code. Multi-provider LLM (Anthropic + Ollama). Autonomous web research missions. Live tech radar scanning. 137 MCP tools. 1407 tests.
10
+ Brain is an MCP server that gives Claude Code a persistent, self-improving memory. It remembers errors, learns solutions, and runs 72+ autonomous engines in a 49-step feedback cycle. It observes itself, detects anomalies, forms and tests hypotheses, distills principles, reasons in chains, feels emotions, evolves strategies genetically, debates itself, challenges its own principles (Advocatus Diaboli), gets curious about knowledge gaps, syncs knowledge via Borg collective, loads community plugins, absorbs code from GitHub repos, extracts reusable features, and modifies its own source code. Multi-provider LLM (Anthropic + Ollama). RAG vector search across all knowledge. Knowledge Graph with transitive inference. RLHF feedback learning. Tool-use learning. User modeling. Proactive suggestions. Code assimilation with feature extraction. Autonomous web research missions. Live tech radar scanning. 162 MCP tools. 1607 tests.
11
11
 
12
12
  ## Quick Start
13
13
 
@@ -28,7 +28,7 @@ Browser ────────HTTP──────► Mission Control (:778
28
28
 
29
29
  ┌───────────────┼───────────────┐
30
30
  ▼ ▼ ▼
31
- Error Memory Research Engine 60+ Engines
31
+ Error Memory Research Engine 72+ Engines
32
32
  Code Intel Mission Engine ResearchOrchestrator
33
33
  Synapse Net LLM Service 40-step feedback loop
34
34
  Prevention Web Research │
@@ -78,7 +78,7 @@ Cross-brain communication via IPC named pipes (trading-brain, marketing-brain).
78
78
  - **LLM Relevance Scoring** — AI judges how relevant each finding is to your stack
79
79
  - **Digest Generation** — Daily summaries of what's new and relevant
80
80
 
81
- ### 60+ Autonomous Engines
81
+ ### 72+ Autonomous Engines
82
82
 
83
83
  The ResearchOrchestrator runs a 40-step feedback cycle every 5 minutes:
84
84
 
@@ -208,7 +208,7 @@ Automatic anomaly response system:
208
208
 
209
209
  **Mission Control** — The Consciousness Entity visualization shows Brain's current emotional state, active thought streams, engine activity heatmap, and real-time thought generation. CodeGen tab shows pending code proposals. Self-Mod tab shows modification history with diffs.
210
210
 
211
- **Command Center** — Live overview of the entire ecosystem: all 3 brains, 60+ engines, error log, self-modification feed, research missions, knowledge growth chart, engine dependency flow, quick actions, animated Borg network, peer graph, debate history, Advocatus Diaboli challenges with resilience bars, watchdog daemon monitoring, LLM usage tracking.
211
+ **Command Center** — Live overview of the entire ecosystem: all 3 brains, 72+ engines, error log, self-modification feed, research missions, knowledge growth chart, engine dependency flow, quick actions, animated Borg network, peer graph, debate history, Advocatus Diaboli challenges with resilience bars, watchdog daemon monitoring, LLM usage tracking.
212
212
 
213
213
  ## MCP Tools (137 tools)
214
214
 
@@ -259,7 +259,7 @@ brain export Export Brain data as JSON
259
259
  | **Brain** (this) | Error memory, code intelligence, full autonomy & self-modification | **7777** / 7778 / 7788 / 7790 |
260
260
  | [Trading Brain](../trading-brain) | Adaptive trading intelligence with signal learning & paper trading | 7779 / 7780 |
261
261
  | [Marketing Brain](../marketing-brain) | Content strategy, social engagement & cross-platform optimization | 7781 / 7782 / 7783 |
262
- | [Brain Core](../brain-core) | Shared infrastructure — 60+ engines | — |
262
+ | [Brain Core](../brain-core) | Shared infrastructure — 72+ engines | — |
263
263
 
264
264
  ## Support
265
265
 
package/dist/brain.d.ts CHANGED
@@ -15,7 +15,6 @@ export declare class BrainCore {
15
15
  private orchestrator;
16
16
  private attentionEngine;
17
17
  private transferEngine;
18
- private unifiedServer;
19
18
  private commandCenter;
20
19
  private narrativeEngine;
21
20
  private curiosityEngine;
package/dist/brain.js CHANGED
@@ -56,8 +56,8 @@ import { McpHttpServer } from './mcp/http-server.js';
56
56
  // Embeddings
57
57
  import { EmbeddingEngine } from './embeddings/engine.js';
58
58
  // Cross-Brain
59
- import { CrossBrainClient, CrossBrainNotifier, CrossBrainSubscriptionManager, CrossBrainCorrelator, EcosystemService, WebhookService, ExportService, BackupService, AutonomousResearchScheduler, ResearchOrchestrator, DataMiner, BrainDataMinerAdapter, ScannerDataMinerAdapter, BootstrapService, DreamEngine, ThoughtStream, PredictionEngine, SignalScanner, CodeMiner, PatternExtractor, ContextBuilder, CodeGenerator, AttentionEngine, TransferEngine, UnifiedDashboardServer, NarrativeEngine, CuriosityEngine, EmergenceEngine, DebateEngine, ParameterRegistry, MetaCognitionLayer, AutoExperimentEngine, SelfTestEngine, TeachEngine, DataScout, runDataScoutMigration, GitHubTrendingAdapter, NpmStatsAdapter, HackerNewsAdapter, SimulationEngine, runSimulationMigration, MemoryPalace, GoalEngine, EvolutionEngine, runEvolutionMigration, ReasoningEngine, EmotionalModel, SelfScanner, SelfModificationEngine, ConceptAbstraction, PeerNetwork, LLMService, OllamaProvider, ResearchMissionEngine, runMissionMigration, BraveSearchAdapter, JinaReaderAdapter, PlaywrightAdapter, FirecrawlAdapter, TechRadarEngine, runTechRadarMigration, NotificationService as MultiChannelNotificationService, runNotificationMigration, DiscordProvider, TelegramProvider, EmailProvider, CommandCenterServer, WatchdogService, createDefaultWatchdogConfig, PluginRegistry, BorgSyncEngine } from '@timmeck/brain-core';
60
- import { RAGEngine, RAGIndexer, KnowledgeGraphEngine, FactExtractor, SemanticCompressor, FeedbackEngine, ToolTracker, ToolPatternAnalyzer, ProactiveEngine, UserModel, CodeHealthMonitor, TeachingProtocol, Curriculum, ConsensusEngine, ActiveLearner, RepoAbsorber, FeatureExtractor } from '@timmeck/brain-core';
59
+ import { CrossBrainClient, CrossBrainNotifier, CrossBrainSubscriptionManager, CrossBrainCorrelator, EcosystemService, WebhookService, ExportService, BackupService, AutonomousResearchScheduler, ResearchOrchestrator, DataMiner, BrainDataMinerAdapter, ScannerDataMinerAdapter, BootstrapService, DreamEngine, ThoughtStream, PredictionEngine, SignalScanner, CodeMiner, PatternExtractor, ContextBuilder, CodeGenerator, AttentionEngine, TransferEngine, NarrativeEngine, CuriosityEngine, EmergenceEngine, DebateEngine, ParameterRegistry, MetaCognitionLayer, AutoExperimentEngine, SelfTestEngine, TeachEngine, DataScout, runDataScoutMigration, GitHubTrendingAdapter, NpmStatsAdapter, HackerNewsAdapter, SimulationEngine, runSimulationMigration, MemoryPalace, GoalEngine, EvolutionEngine, runEvolutionMigration, ReasoningEngine, EmotionalModel, SelfScanner, SelfModificationEngine, ConceptAbstraction, PeerNetwork, LLMService, OllamaProvider, ResearchMissionEngine, runMissionMigration, BraveSearchAdapter, JinaReaderAdapter, PlaywrightAdapter, FirecrawlAdapter, TechRadarEngine, runTechRadarMigration, NotificationService as MultiChannelNotificationService, runNotificationMigration, DiscordProvider, TelegramProvider, EmailProvider, CommandCenterServer, WatchdogService, createDefaultWatchdogConfig, PluginRegistry, BorgSyncEngine } from '@timmeck/brain-core';
60
+ import { RAGEngine, RAGIndexer, KnowledgeGraphEngine, FactExtractor, SemanticCompressor, FeedbackEngine, ToolTracker, ToolPatternAnalyzer, ProactiveEngine, UserModel, CodeHealthMonitor, TeachingProtocol, Curriculum, ConsensusEngine, ActiveLearner, RepoAbsorber, FeatureExtractor, FeatureRecommender } from '@timmeck/brain-core';
61
61
  export class BrainCore {
62
62
  db = null;
63
63
  ipcServer = null;
@@ -75,7 +75,6 @@ export class BrainCore {
75
75
  orchestrator = null;
76
76
  attentionEngine = null;
77
77
  transferEngine = null;
78
- unifiedServer = null;
79
78
  commandCenter = null;
80
79
  narrativeEngine = null;
81
80
  curiosityEngine = null;
@@ -879,6 +878,13 @@ export class BrainCore {
879
878
  featureExtractor.setLLMService(services.llmService);
880
879
  services.featureExtractor = featureExtractor;
881
880
  repoAbsorber.setFeatureExtractor(featureExtractor);
881
+ // 68. FeatureRecommender — wishlist, connections, periodic need scanning
882
+ const featureRecommender = new FeatureRecommender(this.db);
883
+ featureRecommender.setFeatureExtractor(featureExtractor);
884
+ featureRecommender.setRAGEngine(ragEngine);
885
+ featureRecommender.setKnowledgeGraph(knowledgeGraph);
886
+ featureRecommender.setThoughtStream(thoughtStream);
887
+ services.featureRecommender = featureRecommender;
882
888
  // ── Wire intelligence engines into autonomous ResearchOrchestrator ──
883
889
  this.orchestrator.setFactExtractor(factExtractor);
884
890
  this.orchestrator.setKnowledgeGraph(knowledgeGraph);
@@ -889,6 +895,7 @@ export class BrainCore {
889
895
  this.orchestrator.setTeachingProtocol(teachingProtocol);
890
896
  this.orchestrator.setCodeHealthMonitor(codeHealthMonitor);
891
897
  this.orchestrator.setRepoAbsorber(repoAbsorber);
898
+ this.orchestrator.setFeatureRecommender(featureRecommender);
892
899
  logger.info('Intelligence upgrade active (RAG, KG, Compression, Feedback, Tool-Learning, Proactive, UserModel, CodeHealth, Teaching, Consensus, ActiveLearning, RepoAbsorber — all wired into orchestrator)');
893
900
  logger.info('Research orchestrator started (48+ steps, feedback loops active, DataMiner bootstrapped, Dream Mode active, Prediction Engine active)');
894
901
  // 11k. Signal Scanner — GitHub/HN/Crypto signal tracking
@@ -973,144 +980,6 @@ export class BrainCore {
973
980
  services.selfModificationEngine.setContextBuilder(selfmodCtx);
974
981
  }
975
982
  }
976
- // 11n. Unified Dashboard — single Mission Control UI on :7788
977
- const getNetworkState = () => {
978
- try {
979
- const nodes = [];
980
- const projects = this.db.prepare('SELECT id, name AS label FROM projects LIMIT 20').all();
981
- for (const p of projects)
982
- nodes.push({ id: `project:${p.id}`, label: p.label, type: 'project', importance: 1.0 });
983
- const errors = this.db.prepare('SELECT id, message AS label FROM errors LIMIT 50').all();
984
- for (const e of errors)
985
- nodes.push({ id: `error:${e.id}`, label: e.label.substring(0, 60), type: 'error', importance: 0.8 });
986
- const solutions = this.db.prepare('SELECT id, description AS label FROM solutions LIMIT 30').all();
987
- for (const s of solutions)
988
- nodes.push({ id: `solution:${s.id}`, label: s.label.substring(0, 60), type: 'solution', importance: 0.7 });
989
- const modules = this.db.prepare('SELECT id, name AS label FROM code_modules ORDER BY reusability_score DESC LIMIT 100').all();
990
- for (const m of modules)
991
- nodes.push({ id: `code_module:${m.id}`, label: m.label, type: 'code_module', importance: 0.5 });
992
- const insights = this.db.prepare('SELECT id, title AS label, type FROM insights WHERE active = 1 ORDER BY priority DESC LIMIT 50').all();
993
- for (const i of insights)
994
- nodes.push({ id: `insight:${i.id}`, label: i.label.substring(0, 60), type: 'insight', importance: 0.6 });
995
- const memories = this.db.prepare('SELECT id, content AS label, category AS type, importance FROM memories WHERE active = 1 LIMIT 50').all();
996
- for (const m of memories)
997
- nodes.push({ id: `memory:${m.id}`, label: m.label.substring(0, 60), type: m.type || 'memory', importance: m.importance });
998
- const edges = this.db.prepare('SELECT source_type, source_id, target_type, target_id, weight FROM synapses ORDER BY weight DESC LIMIT 500').all();
999
- const mappedEdges = edges.map(e => ({ source: `${e.source_type}:${e.source_id}`, target: `${e.target_type}:${e.target_id}`, weight: e.weight }));
1000
- return { nodes, edges: mappedEdges };
1001
- }
1002
- catch {
1003
- return { nodes: [], edges: [] };
1004
- }
1005
- };
1006
- this.unifiedServer = new UnifiedDashboardServer({
1007
- port: 7788,
1008
- thoughtStream,
1009
- getOverview: () => {
1010
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1011
- const summary = this.orchestrator?.getSummary();
1012
- const attStatus = this.attentionEngine?.getStatus();
1013
- return {
1014
- healthScore: typeof summary?.feedbackCycles === 'number' ? Math.min(100, 50 + summary.feedbackCycles) : null,
1015
- brains: {
1016
- brain: {
1017
- status: this.db ? 'running' : 'stopped',
1018
- cycle: summary?.feedbackCycles ?? 0,
1019
- principles: summary?.knowledge?.principles ?? 0,
1020
- hypotheses: summary?.hypotheses?.total ?? 0,
1021
- experiments: Array.isArray(summary?.experiments) ? summary.experiments.length : 0,
1022
- focus: attStatus?.currentContext ?? 'unknown',
1023
- },
1024
- },
1025
- transfer: this.transferEngine?.getStatus(),
1026
- attention: attStatus,
1027
- };
1028
- },
1029
- getTransferStatus: () => {
1030
- if (!this.transferEngine)
1031
- return null;
1032
- const status = this.transferEngine.getStatus();
1033
- return {
1034
- ...status,
1035
- analogies: this.transferEngine.getAnalogies(20),
1036
- rules: this.transferEngine.getRules(),
1037
- history: this.transferEngine.getTransferHistory(30),
1038
- transferScore: this.transferEngine.getTransferScore(),
1039
- };
1040
- },
1041
- getAttentionStatus: () => this.attentionEngine?.getStatus() ?? null,
1042
- getNotifications: () => thoughtStream.getRecent(100).filter((t) => t.significance === 'breakthrough' || t.significance === 'notable'),
1043
- onTriggerFeedback: () => { this.orchestrator?.runFeedbackCycle(); },
1044
- getNetworkState,
1045
- getEngineStatus: () => this.orchestrator?.getSummary(),
1046
- codeGenerator: services.codeGenerator ?? null,
1047
- codeMiner: services.codeMiner ?? null,
1048
- patternExtractor: patternExtractor ?? null,
1049
- selfModificationEngine: services.selfModificationEngine ?? null,
1050
- getEmotionalStatus: () => services.emotionalModel?.getMood?.() ?? null,
1051
- onChat: (question) => {
1052
- if (!this.narrativeEngine)
1053
- return { role: 'brain', content: 'NarrativeEngine not available yet.', timestamp: Date.now() };
1054
- try {
1055
- // Store user message as observation (Brain remembers conversations)
1056
- this.orchestrator?.selfObserver?.record({
1057
- event_type: 'user_chat',
1058
- category: 'query_quality',
1059
- metrics: { message: question, source: 'dashboard_chat' },
1060
- });
1061
- const explanation = this.narrativeEngine.explain(question);
1062
- const answer = this.narrativeEngine.ask(question);
1063
- const mood = services.emotionalModel?.getMood?.();
1064
- const parts = [];
1065
- if (answer.answer && answer.answer !== 'No relevant knowledge found.') {
1066
- parts.push(answer.answer);
1067
- }
1068
- if (explanation.details.length > 0) {
1069
- parts.push(explanation.details.slice(0, 5).join('\n'));
1070
- }
1071
- if (explanation.confidence > 0) {
1072
- parts.push(`\nConfidence: ${(explanation.confidence * 100).toFixed(0)}%`);
1073
- }
1074
- if (parts.length === 0) {
1075
- parts.push(`I don't have knowledge about "${question}" yet. This is now a research priority.`);
1076
- // Add to research agenda
1077
- this.orchestrator?.researchAgenda?.ask?.(`User asked: "${question}" — investigate and gather data`, 'knowledge_gap');
1078
- }
1079
- if (mood)
1080
- parts.push(`\n[Mood: ${mood.mood}]`);
1081
- return { role: 'brain', content: parts.join('\n'), timestamp: Date.now(), details: { explanation, answer } };
1082
- }
1083
- catch (err) {
1084
- return { role: 'brain', content: `Error: ${err.message}`, timestamp: Date.now() };
1085
- }
1086
- },
1087
- onIngest: (content, source) => {
1088
- let items = 0;
1089
- // Split content into lines/paragraphs and store as observations
1090
- const lines = content.split(/\n+/).filter(l => l.trim().length > 5);
1091
- for (const line of lines.slice(0, 100)) {
1092
- this.orchestrator?.selfObserver?.record({
1093
- event_type: 'data_ingest',
1094
- category: 'tool_usage',
1095
- metrics: { content: line.trim(), source },
1096
- });
1097
- items++;
1098
- }
1099
- // Also store as journal entry for narrative access
1100
- if (this.orchestrator?.journal) {
1101
- this.orchestrator.journal.recordDiscovery(`Data Ingested: ${source}`, content.slice(0, 2000), { source, items, timestamp: Date.now() }, 'routine');
1102
- }
1103
- // Emit thought about ingestion
1104
- thoughtStream.emit('knowledge_distiller', 'discovering', `Ingested ${items} data points from "${source}"`, items > 10 ? 'notable' : 'routine');
1105
- return { stored: true, items };
1106
- },
1107
- getLLMStats: () => services.llmService?.getStats() ?? null,
1108
- getLLMHistory: (hours) => services.llmService?.getUsageHistory(hours) ?? [],
1109
- getLLMByTemplate: () => services.llmService?.getUsageByTemplate() ?? [],
1110
- });
1111
- this.unifiedServer.start();
1112
- services.unifiedServer = this.unifiedServer;
1113
- logger.info('Unified Mission Control dashboard on :7788');
1114
983
  // 11c. Watchdog — monitoring only (detect peers via PID, run health checks)
1115
984
  const watchdogConfig = createDefaultWatchdogConfig();
1116
985
  const watchdog = new WatchdogService(watchdogConfig);
@@ -1198,6 +1067,10 @@ export class BrainCore {
1198
1067
  userModel: services.userModel?.getStatus() ?? null,
1199
1068
  userProfile: services.userModel?.getProfile() ?? null,
1200
1069
  }),
1070
+ getEmotionalStatus: () => {
1071
+ const mood = services.emotionalModel?.getMood?.();
1072
+ return mood ?? { mood: 'reflective', score: 0.5, valence: 0, arousal: 0, dimensions: {} };
1073
+ },
1201
1074
  getDebateStatus: () => this.debateEngine?.getStatus() ?? null,
1202
1075
  getDebateList: (limit = 10) => this.debateEngine?.listDebates(limit) ?? [],
1203
1076
  getChallengeHistory: (limit = 20) => this.debateEngine?.getChallengeHistory(limit) ?? [],
@@ -1215,11 +1088,14 @@ export class BrainCore {
1215
1088
  },
1216
1089
  });
1217
1090
  this.commandCenter.start();
1091
+ services.commandCenter = this.commandCenter;
1218
1092
  logger.info('Command Center dashboard on :7790');
1219
1093
  // 12. IPC Server
1220
1094
  const router = new IpcRouter(services);
1221
1095
  this.ipcServer = new IpcServer(router, config.ipc.pipeName, 'brain', 'brain');
1222
1096
  this.ipcServer.start();
1097
+ // Wire local handler so cross-brain self-queries resolve locally
1098
+ this.crossBrain.setLocalHandler((method, params) => router.handle(method, params));
1223
1099
  // Wire subscription manager into IPC router
1224
1100
  router.setSubscriptionManager(this.subscriptionManager, this.ipcServer);
1225
1101
  // 12c. Plugin Registry — load community plugins (registry created at 11d)
@@ -1442,7 +1318,6 @@ export class BrainCore {
1442
1318
  this.subscriptionManager?.disconnectAll();
1443
1319
  this.attentionEngine?.stop();
1444
1320
  this.commandCenter?.stop();
1445
- this.unifiedServer?.stop();
1446
1321
  this.orchestrator?.stop();
1447
1322
  this.researchScheduler?.stop();
1448
1323
  this.researchEngine?.stop();
@@ -1460,7 +1335,6 @@ export class BrainCore {
1460
1335
  this.learningEngine = null;
1461
1336
  this.researchEngine = null;
1462
1337
  this.orchestrator = null;
1463
- this.unifiedServer = null;
1464
1338
  this.commandCenter = null;
1465
1339
  this.narrativeEngine = null;
1466
1340
  this.curiosityEngine = null;