genesis-ai-cli 7.4.5

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 (227) hide show
  1. package/.env.example +78 -0
  2. package/README.md +282 -0
  3. package/dist/src/active-inference/actions.d.ts +75 -0
  4. package/dist/src/active-inference/actions.js +250 -0
  5. package/dist/src/active-inference/autonomous-loop.d.ts +103 -0
  6. package/dist/src/active-inference/autonomous-loop.js +289 -0
  7. package/dist/src/active-inference/core.d.ts +85 -0
  8. package/dist/src/active-inference/core.js +555 -0
  9. package/dist/src/active-inference/demo-autonomous-loop.d.ts +8 -0
  10. package/dist/src/active-inference/demo-autonomous-loop.js +338 -0
  11. package/dist/src/active-inference/demo-value-integration.d.ts +8 -0
  12. package/dist/src/active-inference/demo-value-integration.js +174 -0
  13. package/dist/src/active-inference/index.d.ts +32 -0
  14. package/dist/src/active-inference/index.js +88 -0
  15. package/dist/src/active-inference/integration.d.ts +114 -0
  16. package/dist/src/active-inference/integration.js +698 -0
  17. package/dist/src/active-inference/memory-integration.d.ts +51 -0
  18. package/dist/src/active-inference/memory-integration.js +232 -0
  19. package/dist/src/active-inference/observations.d.ts +67 -0
  20. package/dist/src/active-inference/observations.js +147 -0
  21. package/dist/src/active-inference/test-active-inference.d.ts +8 -0
  22. package/dist/src/active-inference/test-active-inference.js +320 -0
  23. package/dist/src/active-inference/test-value-integration.d.ts +6 -0
  24. package/dist/src/active-inference/test-value-integration.js +168 -0
  25. package/dist/src/active-inference/types.d.ts +150 -0
  26. package/dist/src/active-inference/types.js +59 -0
  27. package/dist/src/active-inference/value-integration.d.ts +164 -0
  28. package/dist/src/active-inference/value-integration.js +459 -0
  29. package/dist/src/agents/base-agent.d.ts +53 -0
  30. package/dist/src/agents/base-agent.js +178 -0
  31. package/dist/src/agents/builder.d.ts +67 -0
  32. package/dist/src/agents/builder.js +537 -0
  33. package/dist/src/agents/critic.d.ts +35 -0
  34. package/dist/src/agents/critic.js +322 -0
  35. package/dist/src/agents/ethicist.d.ts +54 -0
  36. package/dist/src/agents/ethicist.js +393 -0
  37. package/dist/src/agents/explorer.d.ts +26 -0
  38. package/dist/src/agents/explorer.js +216 -0
  39. package/dist/src/agents/feeling.d.ts +41 -0
  40. package/dist/src/agents/feeling.js +320 -0
  41. package/dist/src/agents/index.d.ts +111 -0
  42. package/dist/src/agents/index.js +222 -0
  43. package/dist/src/agents/memory.d.ts +69 -0
  44. package/dist/src/agents/memory.js +404 -0
  45. package/dist/src/agents/message-bus.d.ts +88 -0
  46. package/dist/src/agents/message-bus.js +267 -0
  47. package/dist/src/agents/narrator.d.ts +90 -0
  48. package/dist/src/agents/narrator.js +473 -0
  49. package/dist/src/agents/planner.d.ts +38 -0
  50. package/dist/src/agents/planner.js +341 -0
  51. package/dist/src/agents/predictor.d.ts +73 -0
  52. package/dist/src/agents/predictor.js +506 -0
  53. package/dist/src/agents/sensor.d.ts +88 -0
  54. package/dist/src/agents/sensor.js +377 -0
  55. package/dist/src/agents/test-agents.d.ts +6 -0
  56. package/dist/src/agents/test-agents.js +73 -0
  57. package/dist/src/agents/types.d.ts +194 -0
  58. package/dist/src/agents/types.js +7 -0
  59. package/dist/src/brain/index.d.ts +185 -0
  60. package/dist/src/brain/index.js +843 -0
  61. package/dist/src/brain/trace.d.ts +91 -0
  62. package/dist/src/brain/trace.js +327 -0
  63. package/dist/src/brain/types.d.ts +165 -0
  64. package/dist/src/brain/types.js +51 -0
  65. package/dist/src/cli/chat.d.ts +237 -0
  66. package/dist/src/cli/chat.js +1959 -0
  67. package/dist/src/cli/dispatcher.d.ts +182 -0
  68. package/dist/src/cli/dispatcher.js +718 -0
  69. package/dist/src/cli/human-loop.d.ts +170 -0
  70. package/dist/src/cli/human-loop.js +543 -0
  71. package/dist/src/cli/index.d.ts +12 -0
  72. package/dist/src/cli/index.js +28 -0
  73. package/dist/src/cli/interactive.d.ts +141 -0
  74. package/dist/src/cli/interactive.js +757 -0
  75. package/dist/src/cli/ui.d.ts +205 -0
  76. package/dist/src/cli/ui.js +632 -0
  77. package/dist/src/consciousness/attention-schema.d.ts +154 -0
  78. package/dist/src/consciousness/attention-schema.js +432 -0
  79. package/dist/src/consciousness/global-workspace.d.ts +149 -0
  80. package/dist/src/consciousness/global-workspace.js +422 -0
  81. package/dist/src/consciousness/index.d.ts +186 -0
  82. package/dist/src/consciousness/index.js +476 -0
  83. package/dist/src/consciousness/phi-calculator.d.ts +119 -0
  84. package/dist/src/consciousness/phi-calculator.js +445 -0
  85. package/dist/src/consciousness/phi-decisions.d.ts +169 -0
  86. package/dist/src/consciousness/phi-decisions.js +383 -0
  87. package/dist/src/consciousness/phi-monitor.d.ts +153 -0
  88. package/dist/src/consciousness/phi-monitor.js +465 -0
  89. package/dist/src/consciousness/types.d.ts +260 -0
  90. package/dist/src/consciousness/types.js +44 -0
  91. package/dist/src/daemon/dream-mode.d.ts +115 -0
  92. package/dist/src/daemon/dream-mode.js +470 -0
  93. package/dist/src/daemon/index.d.ts +162 -0
  94. package/dist/src/daemon/index.js +542 -0
  95. package/dist/src/daemon/maintenance.d.ts +139 -0
  96. package/dist/src/daemon/maintenance.js +549 -0
  97. package/dist/src/daemon/process.d.ts +82 -0
  98. package/dist/src/daemon/process.js +442 -0
  99. package/dist/src/daemon/scheduler.d.ts +90 -0
  100. package/dist/src/daemon/scheduler.js +494 -0
  101. package/dist/src/daemon/types.d.ts +213 -0
  102. package/dist/src/daemon/types.js +50 -0
  103. package/dist/src/epistemic/index.d.ts +74 -0
  104. package/dist/src/epistemic/index.js +225 -0
  105. package/dist/src/grounding/epistemic-stack.d.ts +100 -0
  106. package/dist/src/grounding/epistemic-stack.js +408 -0
  107. package/dist/src/grounding/feedback.d.ts +98 -0
  108. package/dist/src/grounding/feedback.js +276 -0
  109. package/dist/src/grounding/index.d.ts +123 -0
  110. package/dist/src/grounding/index.js +224 -0
  111. package/dist/src/grounding/verifier.d.ts +149 -0
  112. package/dist/src/grounding/verifier.js +484 -0
  113. package/dist/src/healing/detector.d.ts +110 -0
  114. package/dist/src/healing/detector.js +436 -0
  115. package/dist/src/healing/fixer.d.ts +138 -0
  116. package/dist/src/healing/fixer.js +572 -0
  117. package/dist/src/healing/index.d.ts +23 -0
  118. package/dist/src/healing/index.js +43 -0
  119. package/dist/src/hooks/index.d.ts +135 -0
  120. package/dist/src/hooks/index.js +317 -0
  121. package/dist/src/index.d.ts +23 -0
  122. package/dist/src/index.js +1266 -0
  123. package/dist/src/kernel/index.d.ts +155 -0
  124. package/dist/src/kernel/index.js +795 -0
  125. package/dist/src/kernel/invariants.d.ts +153 -0
  126. package/dist/src/kernel/invariants.js +355 -0
  127. package/dist/src/kernel/test-kernel.d.ts +6 -0
  128. package/dist/src/kernel/test-kernel.js +108 -0
  129. package/dist/src/kernel/test-real-mcp.d.ts +10 -0
  130. package/dist/src/kernel/test-real-mcp.js +295 -0
  131. package/dist/src/llm/index.d.ts +146 -0
  132. package/dist/src/llm/index.js +428 -0
  133. package/dist/src/llm/router.d.ts +136 -0
  134. package/dist/src/llm/router.js +510 -0
  135. package/dist/src/mcp/index.d.ts +85 -0
  136. package/dist/src/mcp/index.js +657 -0
  137. package/dist/src/mcp/resilient.d.ts +139 -0
  138. package/dist/src/mcp/resilient.js +417 -0
  139. package/dist/src/memory/cache.d.ts +118 -0
  140. package/dist/src/memory/cache.js +356 -0
  141. package/dist/src/memory/cognitive-workspace.d.ts +231 -0
  142. package/dist/src/memory/cognitive-workspace.js +521 -0
  143. package/dist/src/memory/consolidation.d.ts +99 -0
  144. package/dist/src/memory/consolidation.js +443 -0
  145. package/dist/src/memory/episodic.d.ts +114 -0
  146. package/dist/src/memory/episodic.js +394 -0
  147. package/dist/src/memory/forgetting.d.ts +134 -0
  148. package/dist/src/memory/forgetting.js +324 -0
  149. package/dist/src/memory/index.d.ts +211 -0
  150. package/dist/src/memory/index.js +367 -0
  151. package/dist/src/memory/indexer.d.ts +123 -0
  152. package/dist/src/memory/indexer.js +479 -0
  153. package/dist/src/memory/procedural.d.ts +136 -0
  154. package/dist/src/memory/procedural.js +479 -0
  155. package/dist/src/memory/semantic.d.ts +132 -0
  156. package/dist/src/memory/semantic.js +497 -0
  157. package/dist/src/memory/types.d.ts +193 -0
  158. package/dist/src/memory/types.js +15 -0
  159. package/dist/src/orchestrator.d.ts +65 -0
  160. package/dist/src/orchestrator.js +317 -0
  161. package/dist/src/persistence/index.d.ts +257 -0
  162. package/dist/src/persistence/index.js +763 -0
  163. package/dist/src/pipeline/executor.d.ts +51 -0
  164. package/dist/src/pipeline/executor.js +695 -0
  165. package/dist/src/pipeline/index.d.ts +7 -0
  166. package/dist/src/pipeline/index.js +11 -0
  167. package/dist/src/self-production.d.ts +67 -0
  168. package/dist/src/self-production.js +205 -0
  169. package/dist/src/subagents/executor.d.ts +58 -0
  170. package/dist/src/subagents/executor.js +283 -0
  171. package/dist/src/subagents/index.d.ts +37 -0
  172. package/dist/src/subagents/index.js +53 -0
  173. package/dist/src/subagents/registry.d.ts +23 -0
  174. package/dist/src/subagents/registry.js +167 -0
  175. package/dist/src/subagents/types.d.ts +79 -0
  176. package/dist/src/subagents/types.js +14 -0
  177. package/dist/src/tools/bash.d.ts +139 -0
  178. package/dist/src/tools/bash.js +583 -0
  179. package/dist/src/tools/edit.d.ts +125 -0
  180. package/dist/src/tools/edit.js +424 -0
  181. package/dist/src/tools/git.d.ts +179 -0
  182. package/dist/src/tools/git.js +504 -0
  183. package/dist/src/tools/index.d.ts +21 -0
  184. package/dist/src/tools/index.js +163 -0
  185. package/dist/src/types.d.ts +145 -0
  186. package/dist/src/types.js +7 -0
  187. package/dist/src/world-model/decoder.d.ts +163 -0
  188. package/dist/src/world-model/decoder.js +517 -0
  189. package/dist/src/world-model/digital-twin.d.ts +219 -0
  190. package/dist/src/world-model/digital-twin.js +695 -0
  191. package/dist/src/world-model/encoder.d.ts +141 -0
  192. package/dist/src/world-model/encoder.js +564 -0
  193. package/dist/src/world-model/index.d.ts +221 -0
  194. package/dist/src/world-model/index.js +772 -0
  195. package/dist/src/world-model/predictor.d.ts +161 -0
  196. package/dist/src/world-model/predictor.js +681 -0
  197. package/dist/src/world-model/test-value-jepa.d.ts +8 -0
  198. package/dist/src/world-model/test-value-jepa.js +430 -0
  199. package/dist/src/world-model/types.d.ts +341 -0
  200. package/dist/src/world-model/types.js +69 -0
  201. package/dist/src/world-model/value-jepa.d.ts +247 -0
  202. package/dist/src/world-model/value-jepa.js +622 -0
  203. package/dist/test/brain.test.d.ts +11 -0
  204. package/dist/test/brain.test.js +358 -0
  205. package/dist/test/cli/dispatcher.test.d.ts +4 -0
  206. package/dist/test/cli/dispatcher.test.js +332 -0
  207. package/dist/test/cli/human-loop.test.d.ts +4 -0
  208. package/dist/test/cli/human-loop.test.js +270 -0
  209. package/dist/test/grounding/feedback.test.d.ts +4 -0
  210. package/dist/test/grounding/feedback.test.js +462 -0
  211. package/dist/test/grounding/verifier.test.d.ts +4 -0
  212. package/dist/test/grounding/verifier.test.js +442 -0
  213. package/dist/test/grounding.test.d.ts +6 -0
  214. package/dist/test/grounding.test.js +246 -0
  215. package/dist/test/healing/detector.test.d.ts +4 -0
  216. package/dist/test/healing/detector.test.js +266 -0
  217. package/dist/test/healing/fixer.test.d.ts +4 -0
  218. package/dist/test/healing/fixer.test.js +369 -0
  219. package/dist/test/integration.test.d.ts +5 -0
  220. package/dist/test/integration.test.js +290 -0
  221. package/dist/test/tools/bash.test.d.ts +4 -0
  222. package/dist/test/tools/bash.test.js +348 -0
  223. package/dist/test/tools/edit.test.d.ts +4 -0
  224. package/dist/test/tools/edit.test.js +350 -0
  225. package/dist/test/tools/git.test.d.ts +4 -0
  226. package/dist/test/tools/git.test.js +350 -0
  227. package/package.json +60 -0
@@ -0,0 +1,1266 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * Genesis - System Creator CLI
5
+ *
6
+ * Create systems powered by 13 MCP servers:
7
+ *
8
+ * KNOWLEDGE: arxiv, semantic-scholar, context7, wolfram
9
+ * RESEARCH: gemini, brave-search, exa, firecrawl
10
+ * CREATION: openai, github
11
+ * VISUAL: stability-ai
12
+ * STORAGE: memory, filesystem
13
+ *
14
+ * Usage:
15
+ * genesis create <name> [options] Create a new system
16
+ * genesis research <topic> Research a topic
17
+ * genesis design <spec-file> Design architecture
18
+ * genesis generate <spec-file> Generate code
19
+ * genesis visualize <spec-file> Create visuals
20
+ * genesis publish <spec-file> Publish to GitHub
21
+ * genesis status Show MCP status
22
+ * genesis help Show help
23
+ */
24
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ var desc = Object.getOwnPropertyDescriptor(m, k);
27
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
+ desc = { enumerable: true, get: function() { return m[k]; } };
29
+ }
30
+ Object.defineProperty(o, k2, desc);
31
+ }) : (function(o, m, k, k2) {
32
+ if (k2 === undefined) k2 = k;
33
+ o[k2] = m[k];
34
+ }));
35
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
36
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
37
+ }) : function(o, v) {
38
+ o["default"] = v;
39
+ });
40
+ var __importStar = (this && this.__importStar) || (function () {
41
+ var ownKeys = function(o) {
42
+ ownKeys = Object.getOwnPropertyNames || function (o) {
43
+ var ar = [];
44
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
45
+ return ar;
46
+ };
47
+ return ownKeys(o);
48
+ };
49
+ return function (mod) {
50
+ if (mod && mod.__esModule) return mod;
51
+ var result = {};
52
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
53
+ __setModuleDefault(result, mod);
54
+ return result;
55
+ };
56
+ })();
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ // v7.3: Load environment variables from .env files BEFORE anything else
59
+ const dotenv_1 = require("dotenv");
60
+ const path = __importStar(require("path"));
61
+ const fs = __importStar(require("fs"));
62
+ // Load .env files in priority order (later files override earlier ones)
63
+ const envFiles = [
64
+ '.env', // Base config
65
+ '.env.local', // Local overrides (gitignored)
66
+ ];
67
+ for (const file of envFiles) {
68
+ const envPath = path.join(process.cwd(), file);
69
+ if (fs.existsSync(envPath)) {
70
+ (0, dotenv_1.config)({ path: envPath });
71
+ }
72
+ }
73
+ const orchestrator_js_1 = require("./orchestrator.js");
74
+ const chat_js_1 = require("./cli/chat.js");
75
+ const index_js_1 = require("./llm/index.js");
76
+ const index_js_2 = require("./mcp/index.js");
77
+ const process_js_1 = require("./daemon/process.js");
78
+ const index_js_3 = require("./pipeline/index.js");
79
+ const index_js_4 = require("./active-inference/index.js");
80
+ const index_js_5 = require("./brain/index.js");
81
+ // ============================================================================
82
+ // CLI Colors
83
+ // ============================================================================
84
+ const colors = {
85
+ reset: '\x1b[0m',
86
+ bold: '\x1b[1m',
87
+ dim: '\x1b[2m',
88
+ cyan: '\x1b[36m',
89
+ green: '\x1b[32m',
90
+ yellow: '\x1b[33m',
91
+ red: '\x1b[31m',
92
+ magenta: '\x1b[35m',
93
+ blue: '\x1b[34m',
94
+ };
95
+ function c(text, color) {
96
+ return `${colors[color]}${text}${colors.reset}`;
97
+ }
98
+ // ============================================================================
99
+ // Banner
100
+ // ============================================================================
101
+ function printBanner() {
102
+ // Box width: 65 chars total (╔ + 63×═ + ╗)
103
+ // Content: 63 chars between ║...║
104
+ const line1 = ' GENESIS - System Creator';
105
+ const line2 = ' Powered by 13 MCP Servers';
106
+ const width = 63;
107
+ console.log();
108
+ console.log(c('╔' + '═'.repeat(width) + '╗', 'cyan'));
109
+ console.log(c('║', 'cyan') + ' ' + c('GENESIS', 'bold') + ' - System Creator' + ' '.repeat(width - line1.length) + c('║', 'cyan'));
110
+ console.log(c('║', 'cyan') + ' ' + c('Powered by 13 MCP Servers', 'dim') + ' '.repeat(width - line2.length) + c('║', 'cyan'));
111
+ console.log(c('╚' + '═'.repeat(width) + '╝', 'cyan'));
112
+ console.log();
113
+ }
114
+ // ============================================================================
115
+ // Commands
116
+ // ============================================================================
117
+ async function cmdStatus() {
118
+ console.log(c('\n=== MCP SERVERS STATUS ===\n', 'bold'));
119
+ const categories = ['knowledge', 'research', 'creation', 'visual', 'storage'];
120
+ const categoryColors = {
121
+ knowledge: 'blue',
122
+ research: 'yellow',
123
+ creation: 'green',
124
+ visual: 'magenta',
125
+ storage: 'cyan',
126
+ };
127
+ for (const category of categories) {
128
+ const mcps = Object.entries(orchestrator_js_1.MCP_CAPABILITIES)
129
+ .filter(([_, cap]) => cap.category === category);
130
+ console.log(c(`[${category.toUpperCase()}]`, categoryColors[category]));
131
+ for (const [server, cap] of mcps) {
132
+ console.log(` ${c('●', 'green')} ${server.padEnd(18)} ${c(cap.description, 'dim')}`);
133
+ console.log(` ${c('Tools:', 'dim')} ${cap.tools.join(', ')}`);
134
+ }
135
+ console.log();
136
+ }
137
+ console.log(c(`Total: 13 MCP servers, 5 categories`, 'bold'));
138
+ }
139
+ async function cmdCreate(name, options) {
140
+ console.log(c(`\nCreating system: ${name}\n`, 'bold'));
141
+ const spec = {
142
+ name,
143
+ description: options.description || `A system named ${name}`,
144
+ type: options.type || 'agent',
145
+ features: options.features?.split(',') || [],
146
+ inspirations: options.inspirations?.split(','),
147
+ };
148
+ console.log(c('Specification:', 'cyan'));
149
+ console.log(` Name: ${spec.name}`);
150
+ console.log(` Type: ${spec.type}`);
151
+ console.log(` Description: ${spec.description}`);
152
+ console.log(` Features: ${spec.features.join(', ') || 'none'}`);
153
+ // Save spec for reference
154
+ const specPath = path.join(process.cwd(), `${name}.genesis.json`);
155
+ fs.writeFileSync(specPath, JSON.stringify(spec, null, 2));
156
+ console.log(c(`\nSpec saved to: ${specPath}`, 'dim'));
157
+ // Check if --execute flag is set
158
+ if (options.execute === 'true') {
159
+ await cmdPipeline(spec, options);
160
+ }
161
+ else {
162
+ console.log(c('\nPipeline stages:', 'cyan'));
163
+ const stages = ['research', 'design', 'generate', 'persist'];
164
+ for (const stage of stages) {
165
+ console.log(` ${c('○', 'yellow')} ${stage}`);
166
+ }
167
+ console.log(c('\nTo execute pipeline, run:', 'dim'));
168
+ console.log(c(`\n GENESIS_MCP_MODE=real genesis create "${name}" --execute\n`, 'green'));
169
+ }
170
+ }
171
+ async function cmdPipeline(specOrFile, options) {
172
+ let spec;
173
+ if (typeof specOrFile === 'string') {
174
+ // Load from file
175
+ if (!fs.existsSync(specOrFile)) {
176
+ console.error(c(`Error: Spec file not found: ${specOrFile}`, 'red'));
177
+ process.exit(1);
178
+ }
179
+ spec = JSON.parse(fs.readFileSync(specOrFile, 'utf-8'));
180
+ }
181
+ else {
182
+ spec = specOrFile;
183
+ }
184
+ console.log(c('\n=== Executing Pipeline ===\n', 'bold'));
185
+ (0, index_js_2.logMCPMode)();
186
+ // Parse stages if provided
187
+ const stageList = options.stages
188
+ ? options.stages.split(',')
189
+ : ['research', 'design', 'generate', 'persist'];
190
+ const executor = (0, index_js_3.createPipelineExecutor)({
191
+ verbose: true,
192
+ stages: stageList,
193
+ outputDir: process.cwd(),
194
+ skipPublish: options.publish !== 'true',
195
+ });
196
+ const results = await executor.execute(spec, {
197
+ verbose: true,
198
+ stages: stageList,
199
+ });
200
+ // Print summary
201
+ console.log(c('\n=== Pipeline Summary ===\n', 'bold'));
202
+ let allSuccess = true;
203
+ for (const result of results) {
204
+ const icon = result.success ? c('✓', 'green') : c('✗', 'red');
205
+ const time = `${result.duration}ms`;
206
+ const mcps = result.mcpsUsed.join(', ');
207
+ console.log(` ${icon} ${result.stage.padEnd(12)} ${c(time, 'dim')} [${mcps}]`);
208
+ if (!result.success) {
209
+ allSuccess = false;
210
+ console.log(c(` Error: ${result.error}`, 'red'));
211
+ }
212
+ }
213
+ console.log();
214
+ if (allSuccess) {
215
+ console.log(c('Pipeline completed successfully!', 'green'));
216
+ // Show output location
217
+ const outputDir = `${process.cwd()}/${spec.name.toLowerCase()}-generated`;
218
+ console.log(c(`\nOutput: ${outputDir}`, 'cyan'));
219
+ }
220
+ else {
221
+ console.log(c('Pipeline failed. Check errors above.', 'red'));
222
+ process.exit(1);
223
+ }
224
+ }
225
+ async function cmdResearch(topic) {
226
+ console.log(c(`\nResearch topic: ${topic}\n`, 'bold'));
227
+ const orchestrator = (0, orchestrator_js_1.createOrchestrator)({ verbose: true });
228
+ const prompt = orchestrator.buildResearchPrompt(topic, [
229
+ 'arxiv',
230
+ 'semantic-scholar',
231
+ 'context7',
232
+ 'gemini',
233
+ 'brave-search',
234
+ 'exa',
235
+ 'firecrawl',
236
+ ]);
237
+ console.log(c('Research prompt for MCP execution:', 'cyan'));
238
+ console.log(c('─'.repeat(60), 'dim'));
239
+ console.log(prompt);
240
+ console.log(c('─'.repeat(60), 'dim'));
241
+ console.log(c('\nMCPs to use:', 'cyan'));
242
+ console.log(' KNOWLEDGE: arxiv, semantic-scholar, context7');
243
+ console.log(' RESEARCH: gemini, brave-search, exa, firecrawl');
244
+ }
245
+ async function cmdDesign(specFile) {
246
+ if (!fs.existsSync(specFile)) {
247
+ console.error(c(`Error: Spec file not found: ${specFile}`, 'red'));
248
+ process.exit(1);
249
+ }
250
+ const spec = JSON.parse(fs.readFileSync(specFile, 'utf-8'));
251
+ console.log(c(`\nDesigning architecture for: ${spec.name}\n`, 'bold'));
252
+ const orchestrator = (0, orchestrator_js_1.createOrchestrator)({ verbose: true });
253
+ const prompt = orchestrator.buildArchitecturePrompt(spec, {
254
+ papers: [],
255
+ documentation: [],
256
+ codeExamples: [],
257
+ webResults: [],
258
+ insights: ['Based on autopoiesis principles', 'Event-sourced architecture'],
259
+ });
260
+ console.log(c('Architecture prompt for MCP execution:', 'cyan'));
261
+ console.log(c('─'.repeat(60), 'dim'));
262
+ console.log(prompt);
263
+ console.log(c('─'.repeat(60), 'dim'));
264
+ console.log(c('\nMCPs to use:', 'cyan'));
265
+ console.log(' CREATION: openai (GPT-4o/o1 for design)');
266
+ console.log(' KNOWLEDGE: wolfram (for any computations)');
267
+ }
268
+ async function cmdGenerate(specFile) {
269
+ if (!fs.existsSync(specFile)) {
270
+ console.error(c(`Error: Spec file not found: ${specFile}`, 'red'));
271
+ process.exit(1);
272
+ }
273
+ const spec = JSON.parse(fs.readFileSync(specFile, 'utf-8'));
274
+ console.log(c(`\nGenerating code for: ${spec.name}\n`, 'bold'));
275
+ const orchestrator = (0, orchestrator_js_1.createOrchestrator)({ verbose: true });
276
+ const prompt = orchestrator.buildCodePrompt(spec, { components: [], relations: [], invariants: [], operations: [], events: [] }, 'typescript');
277
+ console.log(c('Code generation prompt for MCP execution:', 'cyan'));
278
+ console.log(c('─'.repeat(60), 'dim'));
279
+ console.log(prompt);
280
+ console.log(c('─'.repeat(60), 'dim'));
281
+ console.log(c('\nMCPs to use:', 'cyan'));
282
+ console.log(' CREATION: openai (GPT-4o for code generation)');
283
+ console.log(' KNOWLEDGE: context7 (for library docs)');
284
+ console.log(' STORAGE: filesystem (to write files)');
285
+ }
286
+ async function cmdVisualize(specFile) {
287
+ if (!fs.existsSync(specFile)) {
288
+ console.error(c(`Error: Spec file not found: ${specFile}`, 'red'));
289
+ process.exit(1);
290
+ }
291
+ const spec = JSON.parse(fs.readFileSync(specFile, 'utf-8'));
292
+ console.log(c(`\nCreating visuals for: ${spec.name}\n`, 'bold'));
293
+ const orchestrator = (0, orchestrator_js_1.createOrchestrator)({ verbose: true });
294
+ const visualTypes = ['architecture', 'concept', 'logo'];
295
+ for (const type of visualTypes) {
296
+ const prompt = orchestrator.buildVisualPrompt(spec, type);
297
+ console.log(c(`[${type.toUpperCase()}]`, 'magenta'));
298
+ console.log(` ${prompt.substring(0, 80)}...`);
299
+ console.log();
300
+ }
301
+ console.log(c('MCPs to use:', 'cyan'));
302
+ console.log(' VISUAL: stability-ai (image generation)');
303
+ }
304
+ async function cmdPublish(specFile) {
305
+ if (!fs.existsSync(specFile)) {
306
+ console.error(c(`Error: Spec file not found: ${specFile}`, 'red'));
307
+ process.exit(1);
308
+ }
309
+ const spec = JSON.parse(fs.readFileSync(specFile, 'utf-8'));
310
+ console.log(c(`\nPublishing: ${spec.name}\n`, 'bold'));
311
+ console.log(c('Steps:', 'cyan'));
312
+ console.log(' 1. Create GitHub repository');
313
+ console.log(' 2. Push generated code');
314
+ console.log(' 3. Create README with architecture');
315
+ console.log(' 4. Add visuals to repo');
316
+ console.log(' 5. Persist to knowledge graph');
317
+ console.log(c('\nMCPs to use:', 'cyan'));
318
+ console.log(' CREATION: github (repo management)');
319
+ console.log(' STORAGE: memory (knowledge persistence)');
320
+ }
321
+ async function cmdChat(options, promptArg) {
322
+ // Ollama models - if any of these is specified, use Ollama
323
+ const ollamaModels = ['mistral', 'mistral-small', 'qwen2.5-coder', 'phi3.5', 'deepseek-coder', 'llama3', 'codellama'];
324
+ // --local flag forces Ollama, or if model is an Ollama model
325
+ const isLocal = options.local === 'true';
326
+ const isOllamaModel = options.model && ollamaModels.some(m => options.model.startsWith(m));
327
+ let provider;
328
+ if (isLocal || isOllamaModel) {
329
+ provider = 'ollama';
330
+ }
331
+ else if (options.provider) {
332
+ provider = options.provider;
333
+ }
334
+ const model = options.model || (provider === 'ollama' ? 'qwen2.5-coder' : undefined);
335
+ const verbose = options.verbose === 'true';
336
+ // v7.4: Headless mode with -p/--print flag
337
+ const isHeadless = options.print === 'true' || options.p === 'true';
338
+ const outputFormat = (options.format || options.output || 'text');
339
+ // v7.4: Session resume
340
+ const resume = options.resume || options.r;
341
+ const sessionName = options.name;
342
+ if (isHeadless) {
343
+ // Get prompt from argument or stdin
344
+ let prompt = promptArg || '';
345
+ // If no prompt argument, try reading from stdin
346
+ if (!prompt) {
347
+ prompt = await (0, chat_js_1.readStdin)();
348
+ }
349
+ if (!prompt) {
350
+ console.error(c('Error: No prompt provided. Use: genesis chat -p "your prompt" or pipe input.', 'red'));
351
+ process.exit(1);
352
+ }
353
+ // Run headless (no banner, no interactive UI)
354
+ await (0, chat_js_1.runHeadless)(prompt, { provider, model, verbose, outputFormat });
355
+ return;
356
+ }
357
+ // Interactive mode - show provider info
358
+ if (provider === 'ollama' || (!provider && !process.env.OPENAI_API_KEY && !process.env.ANTHROPIC_API_KEY)) {
359
+ console.log(c(`\n[LLM] Using Ollama (local, free) - model: ${model || 'qwen2.5-coder'}`, 'cyan'));
360
+ console.log(c('[LLM] If Ollama unavailable, will fallback to cloud API\n', 'dim'));
361
+ }
362
+ // v7.4: Pass resume option (true for --resume, string for --resume <id>)
363
+ const resumeOption = resume === 'true' ? true : resume;
364
+ await (0, chat_js_1.startChat)({
365
+ provider,
366
+ model,
367
+ verbose,
368
+ resume: resumeOption,
369
+ sessionName,
370
+ });
371
+ }
372
+ async function cmdMCP(subcommand, options) {
373
+ const client = (0, index_js_2.getMCPClient)({ logCalls: true });
374
+ (0, index_js_2.logMCPMode)();
375
+ if (!subcommand || subcommand === 'status') {
376
+ // Show MCP mode and registered servers
377
+ console.log(c('\n=== MCP Client Status ===\n', 'bold'));
378
+ console.log(`Mode: ${client.getMode()}`);
379
+ console.log(`\nRegistered servers:`);
380
+ for (const [name, info] of Object.entries(index_js_2.MCP_SERVER_REGISTRY)) {
381
+ console.log(` ${c('●', 'green')} ${name.padEnd(18)} ${c(info.tools.join(', '), 'dim')}`);
382
+ }
383
+ return;
384
+ }
385
+ if (subcommand === 'test') {
386
+ // Test a specific server
387
+ // Usage: genesis mcp test --server memory --tool read_graph --args '{}'
388
+ const server = (options.server || 'memory');
389
+ const tool = options.tool || 'read_graph';
390
+ // Parse args - can be JSON or simple key=value
391
+ let args = {};
392
+ if (options.args) {
393
+ try {
394
+ args = JSON.parse(options.args);
395
+ }
396
+ catch {
397
+ // Try key=value format
398
+ args = { query: options.args };
399
+ }
400
+ }
401
+ console.log(c(`\n=== Testing MCP: ${server}.${tool} ===\n`, 'bold'));
402
+ if (Object.keys(args).length > 0) {
403
+ console.log(`Args: ${JSON.stringify(args)}\n`);
404
+ }
405
+ const result = await client.call(server, tool, args);
406
+ if (result.success) {
407
+ console.log(c('✓ Success', 'green'));
408
+ console.log(` Mode: ${result.mode}`);
409
+ console.log(` Latency: ${result.latency}ms`);
410
+ console.log(` Data:`, JSON.stringify(result.data, null, 2).slice(0, 500));
411
+ }
412
+ else {
413
+ console.log(c('✗ Failed', 'red'));
414
+ console.log(` Error: ${result.error}`);
415
+ }
416
+ return;
417
+ }
418
+ if (subcommand === 'list') {
419
+ // List tools for a server
420
+ const server = (options.server || 'memory');
421
+ console.log(c(`\n=== Tools for ${server} ===\n`, 'bold'));
422
+ try {
423
+ const tools = await client.listTools(server);
424
+ for (const tool of tools) {
425
+ console.log(` ${c('●', 'cyan')} ${tool}`);
426
+ }
427
+ }
428
+ catch (error) {
429
+ console.log(c(`Error: ${error}`, 'red'));
430
+ }
431
+ return;
432
+ }
433
+ console.log(c('Unknown MCP subcommand. Use: status, test, list', 'red'));
434
+ }
435
+ // ============================================================================
436
+ // Daemon Command
437
+ // ============================================================================
438
+ async function cmdDaemon(subcommand, options) {
439
+ const pm = (0, process_js_1.getProcessManager)();
440
+ // Special case: 'run' is called by spawned background process
441
+ if (subcommand === 'run') {
442
+ pm.startDaemon();
443
+ // Keep process alive
444
+ setInterval(() => { }, 1000 * 60 * 60);
445
+ return;
446
+ }
447
+ printBanner();
448
+ if (!subcommand || subcommand === 'status') {
449
+ // Show daemon status
450
+ const info = pm.getInfo();
451
+ console.log(c('\n=== Daemon Status ===\n', 'bold'));
452
+ if (info.running) {
453
+ console.log(` ${c('Status:', 'cyan')} ${c('Running', 'green')}`);
454
+ console.log(` ${c('PID:', 'cyan')} ${info.pid}`);
455
+ console.log(` ${c('Socket:', 'cyan')} ${info.socketPath}`);
456
+ // Get detailed status via IPC
457
+ try {
458
+ const response = await pm.ipcCall('status');
459
+ if (response.success && response.data) {
460
+ const status = response.data;
461
+ console.log(` ${c('State:', 'cyan')} ${status.state}`);
462
+ console.log(` ${c('Uptime:', 'cyan')} ${Math.floor(status.uptime / 1000)}s`);
463
+ console.log(` ${c('Tasks:', 'cyan')} ${status.completedTasks} completed, ${status.failedTasks} failed`);
464
+ console.log(` ${c('Dreams:', 'cyan')} ${status.dreamCycles} cycles`);
465
+ }
466
+ }
467
+ catch {
468
+ // IPC may fail
469
+ }
470
+ }
471
+ else {
472
+ console.log(` ${c('Status:', 'cyan')} ${c('Stopped', 'yellow')}`);
473
+ console.log(` ${c('Hint:', 'dim')} Use 'genesis daemon start' to start`);
474
+ }
475
+ console.log();
476
+ return;
477
+ }
478
+ if (subcommand === 'start') {
479
+ const info = pm.getInfo();
480
+ if (info.running) {
481
+ console.log(c(`\nDaemon already running (PID: ${info.pid})`, 'yellow'));
482
+ return;
483
+ }
484
+ console.log(c('\nStarting daemon in background...', 'cyan'));
485
+ const result = await pm.spawn();
486
+ if (result.success) {
487
+ console.log(c(`Daemon started (PID: ${result.pid})`, 'green'));
488
+ console.log(c(`Log file: ${process_js_1.LOG_FILE}`, 'dim'));
489
+ }
490
+ else {
491
+ console.log(c(`Failed to start daemon: ${result.error}`, 'red'));
492
+ }
493
+ return;
494
+ }
495
+ if (subcommand === 'stop') {
496
+ const info = pm.getInfo();
497
+ if (!info.running) {
498
+ console.log(c('\nDaemon is not running', 'yellow'));
499
+ return;
500
+ }
501
+ console.log(c('\nStopping daemon...', 'cyan'));
502
+ const result = await pm.kill();
503
+ if (result.success) {
504
+ console.log(c('Daemon stopped', 'green'));
505
+ }
506
+ else {
507
+ console.log(c(`Failed to stop daemon: ${result.error}`, 'red'));
508
+ }
509
+ return;
510
+ }
511
+ if (subcommand === 'restart') {
512
+ const info = pm.getInfo();
513
+ if (info.running) {
514
+ console.log(c('\nStopping daemon...', 'cyan'));
515
+ await pm.kill();
516
+ await new Promise((r) => setTimeout(r, 1000));
517
+ }
518
+ console.log(c('Starting daemon...', 'cyan'));
519
+ const result = await pm.spawn();
520
+ if (result.success) {
521
+ console.log(c(`Daemon restarted (PID: ${result.pid})`, 'green'));
522
+ }
523
+ else {
524
+ console.log(c(`Failed to restart daemon: ${result.error}`, 'red'));
525
+ }
526
+ return;
527
+ }
528
+ if (subcommand === 'logs') {
529
+ // Show recent logs
530
+ const lines = parseInt(options.lines || '50', 10);
531
+ if (!fs.existsSync(process_js_1.LOG_FILE)) {
532
+ console.log(c('\nNo log file found', 'yellow'));
533
+ return;
534
+ }
535
+ const content = fs.readFileSync(process_js_1.LOG_FILE, 'utf-8');
536
+ const allLines = content.split('\n');
537
+ const recentLines = allLines.slice(-lines);
538
+ console.log(c(`\n=== Daemon Logs (last ${lines} lines) ===\n`, 'bold'));
539
+ for (const line of recentLines) {
540
+ if (line.includes('ERROR')) {
541
+ console.log(c(line, 'red'));
542
+ }
543
+ else if (line.includes('WARN')) {
544
+ console.log(c(line, 'yellow'));
545
+ }
546
+ else {
547
+ console.log(line);
548
+ }
549
+ }
550
+ console.log();
551
+ return;
552
+ }
553
+ if (subcommand === 'tasks') {
554
+ const info = pm.getInfo();
555
+ if (!info.running) {
556
+ console.log(c('\nDaemon is not running', 'yellow'));
557
+ return;
558
+ }
559
+ console.log(c('\n=== Scheduled Tasks ===\n', 'bold'));
560
+ try {
561
+ const response = await pm.ipcCall('tasks');
562
+ if (response.success && response.data?.tasks) {
563
+ for (const task of response.data.tasks) {
564
+ const statusColor = task.state === 'running' ? 'green' : task.state === 'failed' ? 'red' : 'dim';
565
+ console.log(` ${c('●', statusColor)} ${task.name}`);
566
+ console.log(` Schedule: ${JSON.stringify(task.schedule)}`);
567
+ if (task.lastRun) {
568
+ console.log(` Last run: ${new Date(task.lastRun).toLocaleString()}`);
569
+ }
570
+ if (task.nextRun) {
571
+ console.log(` Next run: ${new Date(task.nextRun).toLocaleString()}`);
572
+ }
573
+ }
574
+ }
575
+ else {
576
+ console.log(c(`Error: ${response.error}`, 'red'));
577
+ }
578
+ }
579
+ catch (err) {
580
+ console.log(c(`IPC error: ${err}`, 'red'));
581
+ }
582
+ console.log();
583
+ return;
584
+ }
585
+ if (subcommand === 'dream') {
586
+ const info = pm.getInfo();
587
+ if (!info.running) {
588
+ console.log(c('\nDaemon is not running', 'yellow'));
589
+ return;
590
+ }
591
+ console.log(c('\nTriggering dream cycle...', 'cyan'));
592
+ try {
593
+ const response = await pm.ipcCall('dream');
594
+ if (response.success) {
595
+ console.log(c('Dream cycle completed', 'green'));
596
+ console.log(`Results: ${JSON.stringify(response.data, null, 2)}`);
597
+ }
598
+ else {
599
+ console.log(c(`Error: ${response.error}`, 'red'));
600
+ }
601
+ }
602
+ catch (err) {
603
+ console.log(c(`IPC error: ${err}`, 'red'));
604
+ }
605
+ return;
606
+ }
607
+ console.log(c('Unknown daemon subcommand. Use: start, stop, restart, status, logs, tasks, dream', 'red'));
608
+ }
609
+ // ============================================================================
610
+ // Infer Command (Active Inference / Autonomous Mode)
611
+ // ============================================================================
612
+ async function cmdInfer(subcommand, options) {
613
+ if (subcommand === 'help' || options.help === 'true') {
614
+ console.log(`
615
+ ${c('Active Inference - Autonomous Decision Making', 'bold')}
616
+
617
+ ${c('Usage:', 'cyan')}
618
+ genesis infer [subcommand] [options]
619
+
620
+ ${c('Subcommands:', 'cyan')}
621
+ run Run autonomous inference cycles (default)
622
+ integrated Run with Kernel & Daemon integration
623
+ mcp Run with REAL MCP observations
624
+ beliefs Show current beliefs
625
+ step Run a single inference cycle
626
+ stats Show inference statistics
627
+
628
+ ${c('Options:', 'cyan')}
629
+ --cycles <n> Number of cycles to run (default: 10)
630
+ --interval <ms> Interval between cycles in ms (default: 1000)
631
+ --verbose Show detailed output
632
+ --interactive Pause after each cycle
633
+ --integrated Connect to Kernel & Daemon (real system state)
634
+
635
+ ${c('Examples:', 'cyan')}
636
+ genesis infer Run 10 inference cycles
637
+ genesis infer --cycles 100 Run 100 cycles
638
+ genesis infer beliefs Show current beliefs
639
+ genesis infer step Run single cycle
640
+ genesis infer --verbose Verbose output
641
+ genesis infer integrated Run with full system integration
642
+ genesis infer mcp Run with real MCP observations
643
+ `);
644
+ return;
645
+ }
646
+ const cycles = parseInt(options.cycles || '10', 10);
647
+ const interval = parseInt(options.interval || '1000', 10);
648
+ const verbose = options.verbose === 'true';
649
+ const interactive = options.interactive === 'true';
650
+ const integrated = options.integrated === 'true' || subcommand === 'integrated';
651
+ // Integrated mode: connect to real Kernel & Daemon
652
+ if (integrated) {
653
+ console.log(c('\n=== Integrated Active Inference Mode ===\n', 'bold'));
654
+ console.log(` ${c('Status:', 'cyan')} Starting Kernel and Daemon...`);
655
+ try {
656
+ const system = await (0, index_js_4.createIntegratedSystem)({
657
+ cycleInterval: interval,
658
+ maxCycles: cycles,
659
+ verbose,
660
+ enableDaemonTask: false, // We'll run manually
661
+ });
662
+ // Start the system
663
+ await system.start();
664
+ console.log(` ${c('Kernel:', 'green')} Started`);
665
+ console.log(` ${c('Daemon:', 'green')} Started`);
666
+ const kernelStatus = system.status().kernel;
667
+ console.log(` ${c('Agents:', 'cyan')} ${kernelStatus.agents.total} (${kernelStatus.agents.healthy} healthy)`);
668
+ console.log(` ${c('Energy:', 'cyan')} ${(kernelStatus.energy * 100).toFixed(0)}%`);
669
+ console.log();
670
+ // Subscribe to cycle events
671
+ system.loop.onCycle((cycle, action, beliefs) => {
672
+ const status = system.status();
673
+ const line = `[${cycle.toString().padStart(4)}] ${action.padEnd(15)} | ` +
674
+ `E:${(status.kernel.energy * 100).toFixed(0)}% ` +
675
+ `K:${status.kernel.state.padEnd(10)} ` +
676
+ `A:${status.kernel.agents.healthy}/${status.kernel.agents.total}`;
677
+ console.log(line);
678
+ });
679
+ // Subscribe to stop event
680
+ system.loop.onStop((reason, stats) => {
681
+ console.log(c(`\n=== Stopped: ${reason} ===\n`, 'bold'));
682
+ console.log(` Cycles: ${stats.cycles}`);
683
+ console.log(` Avg Surprise: ${stats.avgSurprise.toFixed(3)}`);
684
+ console.log(` Final Energy: ${(system.status().kernel.energy * 100).toFixed(0)}%`);
685
+ console.log(` Actions taken:`);
686
+ for (const [action, count] of Object.entries(stats.actions)) {
687
+ const pct = (count / stats.cycles * 100).toFixed(1);
688
+ console.log(` ${action}: ${count} (${pct}%)`);
689
+ }
690
+ console.log();
691
+ });
692
+ // Run the integrated loop
693
+ console.log(c(`Running ${cycles} integrated cycles...\n`, 'dim'));
694
+ await system.loop.run(cycles);
695
+ // Stop the system
696
+ await system.stop();
697
+ console.log(c('System stopped.\n', 'dim'));
698
+ }
699
+ catch (error) {
700
+ console.error(c(`Error: ${error}`, 'red'));
701
+ }
702
+ return;
703
+ }
704
+ // MCP mode: connect to real MCP servers for observations
705
+ const mcpMode = subcommand === 'mcp' || options.mcp === 'true';
706
+ if (mcpMode) {
707
+ console.log(c('\n=== Active Inference with Real MCPs ===\n', 'bold'));
708
+ console.log(` ${c('Mode:', 'cyan')} Real MCP observations`);
709
+ console.log(` ${c('Cycles:', 'cyan')} ${cycles}`);
710
+ console.log(` ${c('Interval:', 'cyan')} ${interval}ms`);
711
+ console.log();
712
+ try {
713
+ const { loop: mcpLoop, mcpBridge } = await (0, index_js_4.createMCPInferenceLoop)({
714
+ cycleInterval: interval,
715
+ maxCycles: 0,
716
+ verbose,
717
+ });
718
+ // Initial MCP probe
719
+ console.log(` ${c('Probing MCPs...', 'dim')}`);
720
+ const initialObs = await mcpLoop.getComponents().observations.gather();
721
+ console.log(` ${c('Initial Observation:', 'green')} E:${initialObs.energy} Φ:${initialObs.phi} T:${initialObs.tool} C:${initialObs.coherence}`);
722
+ const mcpResults = mcpBridge.lastMCPResults();
723
+ if (Object.keys(mcpResults.latencies).length > 0) {
724
+ console.log(` ${c('MCP Latencies:', 'cyan')}`);
725
+ for (const [mcp, lat] of Object.entries(mcpResults.latencies)) {
726
+ console.log(` ${mcp}: ${lat}ms`);
727
+ }
728
+ }
729
+ console.log();
730
+ // Subscribe to cycle events
731
+ mcpLoop.onCycle((cycle, action, beliefs) => {
732
+ const state = mcpLoop.getMostLikelyState();
733
+ const mcpInfo = mcpBridge.lastMCPResults();
734
+ const avgLat = Object.values(mcpInfo.latencies).reduce((a, b) => a + b, 0) /
735
+ Math.max(1, Object.keys(mcpInfo.latencies).length);
736
+ const line = `[${cycle.toString().padStart(4)}] ${action.padEnd(15)} | ` +
737
+ `V:${state.viability.padEnd(8)} Lat:${avgLat.toFixed(0)}ms`;
738
+ console.log(line);
739
+ if (verbose) {
740
+ console.log(` Beliefs: W=${state.worldState} C=${state.coupling} G=${state.goalProgress}`);
741
+ }
742
+ });
743
+ // Subscribe to stop event
744
+ mcpLoop.onStop((reason, stats) => {
745
+ const mcpInfo = mcpBridge.lastMCPResults();
746
+ console.log(c(`\n=== Stopped: ${reason} ===\n`, 'bold'));
747
+ console.log(` Cycles: ${stats.cycles}`);
748
+ console.log(` Avg Surprise: ${stats.avgSurprise.toFixed(3)}`);
749
+ console.log(` MCP Connections:`);
750
+ for (const [mcp, lat] of Object.entries(mcpInfo.latencies)) {
751
+ console.log(` ${mcp}: ${lat}ms`);
752
+ }
753
+ console.log(` Actions taken:`);
754
+ for (const [action, count] of Object.entries(stats.actions)) {
755
+ const pct = (count / stats.cycles * 100).toFixed(1);
756
+ console.log(` ${action}: ${count} (${pct}%)`);
757
+ }
758
+ console.log();
759
+ });
760
+ // Run the loop
761
+ console.log(c(`Running ${cycles} MCP-connected cycles...\n`, 'dim'));
762
+ await mcpLoop.run(cycles);
763
+ }
764
+ catch (error) {
765
+ console.error(c(`MCP Inference Error: ${error}`, 'red'));
766
+ }
767
+ return;
768
+ }
769
+ // Standard mode (no Kernel/Daemon integration)
770
+ const loop = (0, index_js_4.createAutonomousLoop)({
771
+ cycleInterval: interval,
772
+ maxCycles: 0,
773
+ verbose,
774
+ stopOnGoalAchieved: true,
775
+ stopOnEnergyCritical: true,
776
+ });
777
+ // Handle subcommands
778
+ if (subcommand === 'beliefs') {
779
+ const state = loop.getMostLikelyState();
780
+ console.log(c('\n=== Current Beliefs ===\n', 'bold'));
781
+ console.log(` ${c('Viability:', 'cyan')} ${state.viability}`);
782
+ console.log(` ${c('World State:', 'cyan')} ${state.worldState}`);
783
+ console.log(` ${c('Coupling:', 'cyan')} ${state.coupling}`);
784
+ console.log(` ${c('Goal Progress:', 'cyan')} ${state.goalProgress}`);
785
+ console.log();
786
+ return;
787
+ }
788
+ if (subcommand === 'stats') {
789
+ const stats = loop.getStats();
790
+ console.log(c('\n=== Inference Statistics ===\n', 'bold'));
791
+ console.log(` ${c('Cycles:', 'cyan')} ${stats.cycles}`);
792
+ console.log(` ${c('Avg Surprise:', 'cyan')} ${stats.avgSurprise.toFixed(3)}`);
793
+ console.log(` ${c('Actions:', 'cyan')}`);
794
+ for (const [action, count] of Object.entries(stats.actions)) {
795
+ console.log(` ${action}: ${count}`);
796
+ }
797
+ console.log();
798
+ return;
799
+ }
800
+ if (subcommand === 'step') {
801
+ console.log(c('\n=== Single Inference Cycle ===\n', 'bold'));
802
+ const action = await loop.cycle();
803
+ const state = loop.getMostLikelyState();
804
+ console.log(` ${c('Action:', 'green')} ${action}`);
805
+ console.log(` ${c('Beliefs:', 'cyan')}`);
806
+ console.log(` Viability: ${state.viability}`);
807
+ console.log(` World: ${state.worldState}`);
808
+ console.log(` Coupling: ${state.coupling}`);
809
+ console.log(` Goal: ${state.goalProgress}`);
810
+ console.log();
811
+ return;
812
+ }
813
+ // Default: run cycles
814
+ console.log(c(`\n=== Active Inference - Running ${cycles} cycles ===\n`, 'bold'));
815
+ console.log(` Interval: ${interval}ms`);
816
+ console.log(` Verbose: ${verbose}`);
817
+ console.log();
818
+ // Subscribe to cycle events
819
+ loop.onCycle((cycle, action, beliefs) => {
820
+ if (!verbose) {
821
+ // Compact output
822
+ const state = loop.getMostLikelyState();
823
+ const line = `[${cycle.toString().padStart(4)}] ${action.padEnd(15)} | ` +
824
+ `V:${state.viability.padEnd(8)} W:${state.worldState.padEnd(8)} ` +
825
+ `C:${state.coupling.padEnd(8)} G:${state.goalProgress}`;
826
+ console.log(line);
827
+ }
828
+ if (interactive) {
829
+ // In interactive mode, we'd pause here
830
+ // For now, just show the action more prominently
831
+ console.log(c(` → Action: ${action}`, 'yellow'));
832
+ }
833
+ });
834
+ // Subscribe to stop event
835
+ loop.onStop((reason, stats) => {
836
+ console.log(c(`\n=== Stopped: ${reason} ===\n`, 'bold'));
837
+ console.log(` Cycles: ${stats.cycles}`);
838
+ console.log(` Avg Surprise: ${stats.avgSurprise.toFixed(3)}`);
839
+ console.log(` Actions taken:`);
840
+ for (const [action, count] of Object.entries(stats.actions)) {
841
+ const pct = (count / stats.cycles * 100).toFixed(1);
842
+ console.log(` ${action}: ${count} (${pct}%)`);
843
+ }
844
+ console.log();
845
+ });
846
+ // Run the loop
847
+ await loop.run(cycles);
848
+ }
849
+ // ============================================================================
850
+ // Brain Command (Phase 10: Neural Integration)
851
+ // ============================================================================
852
+ async function cmdBrain(subcommand, options) {
853
+ const brain = (0, index_js_5.getBrain)();
854
+ if (!subcommand || subcommand === 'status') {
855
+ const metrics = brain.getMetrics();
856
+ const running = brain.isRunning();
857
+ console.log(c('\n=== BRAIN STATUS (Phase 10) ===\n', 'bold'));
858
+ console.log(` ${c('Running:', 'cyan')} ${running ? c('Yes', 'green') : c('No', 'yellow')}`);
859
+ console.log();
860
+ console.log(c('Consciousness (φ):', 'cyan'));
861
+ console.log(` Level: ${metrics.avgPhi.toFixed(3)}`);
862
+ console.log(` Violations: ${metrics.phiViolations}`);
863
+ console.log(` Broadcasts: ${metrics.broadcasts}`);
864
+ console.log();
865
+ console.log(c('Processing:', 'cyan'));
866
+ console.log(` Total Cycles: ${metrics.totalCycles}`);
867
+ console.log(` Successful: ${metrics.successfulCycles}`);
868
+ console.log(` Failed: ${metrics.failedCycles}`);
869
+ console.log(` Avg Time: ${metrics.avgCycleTime.toFixed(0)}ms`);
870
+ console.log();
871
+ console.log(c('Memory (Cognitive Workspace):', 'cyan'));
872
+ console.log(` Recalls: ${metrics.memoryRecalls}`);
873
+ console.log(` Reuse Rate: ${(metrics.memoryReuseRate * 100).toFixed(1)}% (target: 54-60%)`);
874
+ console.log(` Anticipation: ${metrics.anticipationHits} hits, ${metrics.anticipationMisses} misses`);
875
+ console.log();
876
+ console.log(c('Grounding:', 'cyan'));
877
+ console.log(` Checks: ${metrics.groundingChecks}`);
878
+ console.log(` Passes: ${metrics.groundingPasses}`);
879
+ console.log(` Failures: ${metrics.groundingFailures}`);
880
+ console.log(` Human Consults: ${metrics.humanConsultations}`);
881
+ console.log();
882
+ console.log(c('Healing (Darwin-Gödel):', 'cyan'));
883
+ console.log(` Attempts: ${metrics.healingAttempts}`);
884
+ console.log(` Successes: ${metrics.healingSuccesses}`);
885
+ console.log(` Failures: ${metrics.healingFailures}`);
886
+ console.log();
887
+ console.log(c('Tools:', 'cyan'));
888
+ console.log(` Executions: ${metrics.toolExecutions}`);
889
+ console.log(` Successes: ${metrics.toolSuccesses}`);
890
+ console.log(` Failures: ${metrics.toolFailures}`);
891
+ console.log();
892
+ // Module transitions
893
+ if (Object.keys(metrics.moduleTransitions).length > 0) {
894
+ console.log(c('Module Transitions:', 'cyan'));
895
+ for (const [transition, count] of Object.entries(metrics.moduleTransitions)) {
896
+ console.log(` ${transition}: ${count}`);
897
+ }
898
+ console.log();
899
+ }
900
+ return;
901
+ }
902
+ if (subcommand === 'phi') {
903
+ const metrics = brain.getMetrics();
904
+ const phi = metrics.avgPhi;
905
+ console.log(c('\n=== CONSCIOUSNESS LEVEL (φ) ===\n', 'bold'));
906
+ // Visual bar
907
+ const width = 30;
908
+ const filled = Math.round(phi * width);
909
+ const empty = width - filled;
910
+ const bar = '█'.repeat(filled) + '░'.repeat(empty);
911
+ console.log(` Current φ: ${phi.toFixed(3)}`);
912
+ if (phi >= 0.7) {
913
+ console.log(` Level: ${c(bar, 'green')} HIGH`);
914
+ console.log(` Status: ${c('Global Workspace active - full broadcasting', 'green')}`);
915
+ }
916
+ else if (phi >= 0.3) {
917
+ console.log(` Level: ${c(bar, 'yellow')} MEDIUM`);
918
+ console.log(` Status: ${c('Ignition threshold - selective broadcasting', 'yellow')}`);
919
+ }
920
+ else {
921
+ console.log(` Level: ${c(bar, 'dim')} LOW`);
922
+ console.log(` Status: ${c('Local processing - no broadcasting', 'dim')}`);
923
+ }
924
+ console.log();
925
+ console.log(c('Theory:', 'dim'));
926
+ console.log(' φ (phi) measures integrated information (IIT 4.0)');
927
+ console.log(' Values: 0 = no integration, 1 = maximum integration');
928
+ console.log(' Ignition (φ > 0.3): Information broadcasts globally (GWT)');
929
+ console.log();
930
+ return;
931
+ }
932
+ if (subcommand === 'start') {
933
+ if (brain.isRunning()) {
934
+ console.log(c('\nBrain is already running', 'yellow'));
935
+ return;
936
+ }
937
+ brain.start();
938
+ console.log(c('\nBrain started', 'green'));
939
+ console.log(c(' Neural Integration Layer is now active', 'dim'));
940
+ return;
941
+ }
942
+ if (subcommand === 'stop') {
943
+ if (!brain.isRunning()) {
944
+ console.log(c('\nBrain is not running', 'yellow'));
945
+ return;
946
+ }
947
+ brain.stop();
948
+ console.log(c('\nBrain stopped', 'yellow'));
949
+ return;
950
+ }
951
+ if (subcommand === 'reset') {
952
+ (0, index_js_5.resetBrain)();
953
+ console.log(c('\nBrain reset to initial state', 'yellow'));
954
+ console.log(c(' All metrics cleared', 'dim'));
955
+ return;
956
+ }
957
+ if (subcommand === 'cycle') {
958
+ const query = options.query || 'Test query for brain cycle';
959
+ console.log(c('\n=== RUNNING BRAIN CYCLE ===\n', 'bold'));
960
+ console.log(` Query: "${query}"`);
961
+ console.log();
962
+ if (!brain.isRunning()) {
963
+ brain.start();
964
+ console.log(c(' [Starting brain...]', 'dim'));
965
+ }
966
+ try {
967
+ const start = Date.now();
968
+ const response = await brain.process(query);
969
+ const duration = Date.now() - start;
970
+ console.log(c('Response:', 'cyan'));
971
+ console.log(` ${response.substring(0, 500)}${response.length > 500 ? '...' : ''}`);
972
+ console.log();
973
+ const metrics = brain.getMetrics();
974
+ console.log(c('Metrics:', 'cyan'));
975
+ console.log(` Duration: ${duration}ms`);
976
+ console.log(` φ Level: ${metrics.avgPhi.toFixed(3)}`);
977
+ console.log(` Memory Reuse: ${(metrics.memoryReuseRate * 100).toFixed(1)}%`);
978
+ console.log();
979
+ }
980
+ catch (error) {
981
+ console.log(c(` Error: ${error}`, 'red'));
982
+ }
983
+ return;
984
+ }
985
+ console.log(c(`Unknown brain subcommand: ${subcommand}`, 'red'));
986
+ console.log('Use: status, phi, start, stop, reset, cycle');
987
+ }
988
+ async function cmdHardware() {
989
+ console.log(c('\n=== HARDWARE PROFILE ===\n', 'bold'));
990
+ const hw = (0, index_js_1.detectHardware)();
991
+ const router = (0, index_js_1.getHybridRouter)({ logDecisions: false });
992
+ // Hardware info
993
+ console.log(c('Detected:', 'cyan'));
994
+ console.log(` CPU: ${hw.cpu}`);
995
+ console.log(` Apple Silicon: ${hw.isAppleSilicon ? c('Yes', 'green') : 'No'}`);
996
+ console.log(` Cores: ${hw.cores}`);
997
+ console.log(` Memory: ${hw.memoryGB} GB`);
998
+ console.log(` Performance Tier: ${c(hw.tier.toUpperCase(), hw.tier === 'ultra' ? 'green' : hw.tier === 'high' ? 'cyan' : 'yellow')}`);
999
+ console.log();
1000
+ // Router config
1001
+ const config = router.getConfig();
1002
+ console.log(c('Router Configuration:', 'cyan'));
1003
+ console.log(` Cloud Threshold: ${config.cloudThreshold} (tasks ≥ ${config.cloudThreshold} → cloud)`);
1004
+ console.log(` Local Max Tokens: ${config.localMaxTokens}`);
1005
+ console.log(` Prefer Local: ${config.preferLocal ? c('Yes', 'green') : 'No'}`);
1006
+ console.log(` Auto Fallback: ${config.autoFallback ? 'Yes' : 'No'}`);
1007
+ console.log();
1008
+ // Recommendations
1009
+ console.log(c('Recommendations:', 'cyan'));
1010
+ if (hw.tier === 'ultra') {
1011
+ console.log(` ${c('✓', 'green')} Excellent hardware - local LLM will handle most tasks`);
1012
+ console.log(` ${c('✓', 'green')} Only creative/complex generation needs cloud`);
1013
+ console.log(` ${c('✓', 'green')} Can use larger models (mistral-small 24B)`);
1014
+ }
1015
+ else if (hw.tier === 'high') {
1016
+ console.log(` ${c('✓', 'green')} Good hardware - local LLM for routine tasks`);
1017
+ console.log(` ${c('✓', 'green')} Cloud for complex architecture/design`);
1018
+ }
1019
+ else if (hw.tier === 'medium') {
1020
+ console.log(` ${c('●', 'yellow')} Medium hardware - balance local/cloud`);
1021
+ console.log(` ${c('●', 'yellow')} Use local for simple tasks, cloud for complex`);
1022
+ }
1023
+ else {
1024
+ console.log(` ${c('●', 'yellow')} Limited hardware - prefer cloud for quality`);
1025
+ console.log(` ${c('●', 'yellow')} Use --provider openai or anthropic`);
1026
+ }
1027
+ console.log();
1028
+ // Test Ollama latency
1029
+ console.log(c('Testing Ollama latency...', 'dim'));
1030
+ try {
1031
+ const start = Date.now();
1032
+ const response = await fetch('http://localhost:11434/api/tags', {
1033
+ signal: AbortSignal.timeout(2000),
1034
+ });
1035
+ if (response.ok) {
1036
+ const latency = Date.now() - start;
1037
+ console.log(` Ollama Status: ${c('Running', 'green')} (${latency}ms)`);
1038
+ const data = await response.json();
1039
+ const models = data.models?.map((m) => m.name).join(', ') || 'none';
1040
+ console.log(` Available Models: ${models}`);
1041
+ }
1042
+ else {
1043
+ console.log(` Ollama Status: ${c('Error', 'red')}`);
1044
+ }
1045
+ }
1046
+ catch {
1047
+ console.log(` Ollama Status: ${c('Not running', 'yellow')} (start with: ollama serve)`);
1048
+ }
1049
+ console.log();
1050
+ }
1051
+ function cmdHelp() {
1052
+ printBanner();
1053
+ console.log(`${c('Usage:', 'bold')}
1054
+ genesis <command> [options]
1055
+
1056
+ ${c('Commands:', 'bold')}
1057
+ ${c('chat', 'green')} ${c('Interactive chat with Genesis', 'bold')}
1058
+ --local Use Ollama (free, local) - DEFAULT
1059
+ --provider <p> LLM provider: ollama, openai, anthropic
1060
+ --model <m> Model name (e.g., mistral, gpt-4o, claude-sonnet-4-20250514)
1061
+ --verbose Show latency and token usage
1062
+ -p, --print "text" ${c('Headless mode: process prompt and exit', 'yellow')}
1063
+ --format <f> Output format: text (default), json
1064
+ -r, --resume [id] ${c('Resume previous session (default: last)', 'yellow')}
1065
+ --name <name> Name for the current session
1066
+
1067
+ ${c('create', 'green')} <name> Create a new system
1068
+ --type <type> System type: autopoietic, agent, multi-agent, service
1069
+ --description <desc> System description
1070
+ --features <f1,f2> Comma-separated features
1071
+ --inspirations <i> Papers/projects to draw from
1072
+ --execute Execute pipeline with real MCPs
1073
+
1074
+ ${c('pipeline', 'green')} <spec.json> Run pipeline from spec file
1075
+ --stages <s1,s2> Stages: research,design,generate,persist,publish
1076
+ --publish Also publish to GitHub
1077
+
1078
+ ${c('research', 'green')} <topic> Research a topic using all knowledge MCPs
1079
+ ${c('design', 'green')} <spec-file> Design architecture from spec
1080
+ ${c('generate', 'green')} <spec-file> Generate code from spec
1081
+ ${c('visualize', 'green')} <spec-file> Create visual assets
1082
+ ${c('publish', 'green')} <spec-file> Publish to GitHub
1083
+
1084
+ ${c('mcp', 'green')} [subcommand] MCP client control
1085
+ status Show MCP mode and servers
1086
+ test Test MCP server call
1087
+ --server <s> Server name (default: arxiv)
1088
+ --tool <t> Tool name (default: search_arxiv)
1089
+ --query <q> Query string
1090
+ list --server <s> List tools for a server
1091
+
1092
+ ${c('infer', 'green')} [cycles] Run autonomous inference loop
1093
+ --cycles <n> Number of cycles (default: 10, 0=unlimited)
1094
+ --interval <ms> Interval between cycles (default: 1000)
1095
+ --verbose Show detailed output
1096
+
1097
+ ${c('brain', 'green')} [subcommand] Phase 10: Neural Integration Layer
1098
+ status Show brain status and metrics
1099
+ phi Show consciousness level (φ)
1100
+ start Start the brain
1101
+ stop Stop the brain
1102
+ reset Reset brain to initial state
1103
+ cycle --query <q> Run a brain processing cycle
1104
+
1105
+ ${c('phi', 'green')} Shortcut for 'brain phi'
1106
+
1107
+ ${c('status', 'green')} Show MCP servers status
1108
+ ${c('hardware', 'green')} Show hardware profile & router config
1109
+ ${c('help', 'green')} Show this help
1110
+
1111
+ ${c('MCP Servers (13):', 'bold')}
1112
+ ${c('KNOWLEDGE:', 'blue')} arxiv, semantic-scholar, context7, wolfram
1113
+ ${c('RESEARCH:', 'yellow')} gemini, brave-search, exa, firecrawl
1114
+ ${c('CREATION:', 'green')} openai, github
1115
+ ${c('VISUAL:', 'magenta')} stability-ai
1116
+ ${c('STORAGE:', 'cyan')} memory, filesystem
1117
+
1118
+ ${c('Examples:', 'bold')}
1119
+ genesis chat ${c('Interactive chat with Mistral (local)', 'dim')}
1120
+ genesis chat --provider openai ${c('Chat with GPT-4o (cloud)', 'dim')}
1121
+ genesis chat --resume ${c('Resume last session', 'dim')}
1122
+ genesis chat --resume abc123 ${c('Resume specific session by ID', 'dim')}
1123
+ genesis chat -p "Explain recursion" ${c('Headless: single prompt, output, exit', 'dim')}
1124
+ echo "What is 2+2?" | genesis chat -p ${c('Headless: read from stdin', 'dim')}
1125
+ genesis chat -p "..." --format json ${c('Headless: JSON output for scripting', 'dim')}
1126
+ genesis infer mcp --cycles 10 ${c('Autonomous inference with MCPs', 'dim')}
1127
+ genesis create my-agent --type agent --features "state-machine,events"
1128
+
1129
+ ${c('# Run full pipeline with real MCPs:', 'dim')}
1130
+ GENESIS_MCP_MODE=real genesis create my-system --type agent --execute
1131
+ GENESIS_MCP_MODE=real genesis pipeline my-system.genesis.json
1132
+ `);
1133
+ }
1134
+ // ============================================================================
1135
+ // Main
1136
+ // ============================================================================
1137
+ async function main() {
1138
+ const args = process.argv.slice(2);
1139
+ const command = args[0];
1140
+ if (!command || command === 'help' || command === '--help' || command === '-h') {
1141
+ cmdHelp();
1142
+ return;
1143
+ }
1144
+ // Chat command has its own banner, skip main banner
1145
+ if (command !== 'chat') {
1146
+ printBanner();
1147
+ }
1148
+ // Parse options (handles both --flag and -f short flags)
1149
+ const options = {};
1150
+ for (let i = 1; i < args.length; i++) {
1151
+ if (args[i].startsWith('--')) {
1152
+ const key = args[i].slice(2);
1153
+ // Check if next arg is a value or another flag
1154
+ const nextArg = args[i + 1];
1155
+ if (nextArg && !nextArg.startsWith('-')) {
1156
+ options[key] = nextArg;
1157
+ i++;
1158
+ }
1159
+ else {
1160
+ options[key] = 'true';
1161
+ }
1162
+ }
1163
+ else if (args[i].startsWith('-') && args[i].length === 2) {
1164
+ // Short flag: -p, -v, etc.
1165
+ const key = args[i].slice(1);
1166
+ const nextArg = args[i + 1];
1167
+ if (nextArg && !nextArg.startsWith('-')) {
1168
+ options[key] = nextArg;
1169
+ i++;
1170
+ }
1171
+ else {
1172
+ options[key] = 'true';
1173
+ }
1174
+ }
1175
+ }
1176
+ // Get positional arg after command
1177
+ const positional = args.find((a, i) => i > 0 && !a.startsWith('--') && !Object.values(options).includes(a));
1178
+ try {
1179
+ switch (command) {
1180
+ case 'chat':
1181
+ // v7.4: Pass positional arg as prompt for headless mode (-p "prompt")
1182
+ await cmdChat(options, positional);
1183
+ break;
1184
+ case 'status':
1185
+ await cmdStatus();
1186
+ break;
1187
+ case 'create':
1188
+ if (!positional) {
1189
+ console.error(c('Error: Name required for create command', 'red'));
1190
+ process.exit(1);
1191
+ }
1192
+ await cmdCreate(positional, options);
1193
+ break;
1194
+ case 'research':
1195
+ if (!positional) {
1196
+ console.error(c('Error: Topic required for research command', 'red'));
1197
+ process.exit(1);
1198
+ }
1199
+ await cmdResearch(positional);
1200
+ break;
1201
+ case 'design':
1202
+ if (!positional) {
1203
+ console.error(c('Error: Spec file required for design command', 'red'));
1204
+ process.exit(1);
1205
+ }
1206
+ await cmdDesign(positional);
1207
+ break;
1208
+ case 'generate':
1209
+ if (!positional) {
1210
+ console.error(c('Error: Spec file required for generate command', 'red'));
1211
+ process.exit(1);
1212
+ }
1213
+ await cmdGenerate(positional);
1214
+ break;
1215
+ case 'visualize':
1216
+ if (!positional) {
1217
+ console.error(c('Error: Spec file required for visualize command', 'red'));
1218
+ process.exit(1);
1219
+ }
1220
+ await cmdVisualize(positional);
1221
+ break;
1222
+ case 'publish':
1223
+ if (!positional) {
1224
+ console.error(c('Error: Spec file required for publish command', 'red'));
1225
+ process.exit(1);
1226
+ }
1227
+ await cmdPublish(positional);
1228
+ break;
1229
+ case 'mcp':
1230
+ await cmdMCP(positional, options);
1231
+ break;
1232
+ case 'daemon':
1233
+ await cmdDaemon(positional, options);
1234
+ break;
1235
+ case 'pipeline':
1236
+ if (!positional) {
1237
+ console.error(c('Error: Spec file required for pipeline command', 'red'));
1238
+ process.exit(1);
1239
+ }
1240
+ await cmdPipeline(positional, options);
1241
+ break;
1242
+ case 'infer':
1243
+ await cmdInfer(positional, options);
1244
+ break;
1245
+ case 'hardware':
1246
+ await cmdHardware();
1247
+ break;
1248
+ case 'brain':
1249
+ await cmdBrain(positional, options);
1250
+ break;
1251
+ case 'phi':
1252
+ // Shortcut for brain phi
1253
+ await cmdBrain('phi', options);
1254
+ break;
1255
+ default:
1256
+ console.error(c(`Unknown command: ${command}`, 'red'));
1257
+ console.log('Use "genesis help" for usage information');
1258
+ process.exit(1);
1259
+ }
1260
+ }
1261
+ catch (error) {
1262
+ console.error(c(`Error: ${error}`, 'red'));
1263
+ process.exit(1);
1264
+ }
1265
+ }
1266
+ main();