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.
- package/.env.example +78 -0
- package/README.md +282 -0
- package/dist/src/active-inference/actions.d.ts +75 -0
- package/dist/src/active-inference/actions.js +250 -0
- package/dist/src/active-inference/autonomous-loop.d.ts +103 -0
- package/dist/src/active-inference/autonomous-loop.js +289 -0
- package/dist/src/active-inference/core.d.ts +85 -0
- package/dist/src/active-inference/core.js +555 -0
- package/dist/src/active-inference/demo-autonomous-loop.d.ts +8 -0
- package/dist/src/active-inference/demo-autonomous-loop.js +338 -0
- package/dist/src/active-inference/demo-value-integration.d.ts +8 -0
- package/dist/src/active-inference/demo-value-integration.js +174 -0
- package/dist/src/active-inference/index.d.ts +32 -0
- package/dist/src/active-inference/index.js +88 -0
- package/dist/src/active-inference/integration.d.ts +114 -0
- package/dist/src/active-inference/integration.js +698 -0
- package/dist/src/active-inference/memory-integration.d.ts +51 -0
- package/dist/src/active-inference/memory-integration.js +232 -0
- package/dist/src/active-inference/observations.d.ts +67 -0
- package/dist/src/active-inference/observations.js +147 -0
- package/dist/src/active-inference/test-active-inference.d.ts +8 -0
- package/dist/src/active-inference/test-active-inference.js +320 -0
- package/dist/src/active-inference/test-value-integration.d.ts +6 -0
- package/dist/src/active-inference/test-value-integration.js +168 -0
- package/dist/src/active-inference/types.d.ts +150 -0
- package/dist/src/active-inference/types.js +59 -0
- package/dist/src/active-inference/value-integration.d.ts +164 -0
- package/dist/src/active-inference/value-integration.js +459 -0
- package/dist/src/agents/base-agent.d.ts +53 -0
- package/dist/src/agents/base-agent.js +178 -0
- package/dist/src/agents/builder.d.ts +67 -0
- package/dist/src/agents/builder.js +537 -0
- package/dist/src/agents/critic.d.ts +35 -0
- package/dist/src/agents/critic.js +322 -0
- package/dist/src/agents/ethicist.d.ts +54 -0
- package/dist/src/agents/ethicist.js +393 -0
- package/dist/src/agents/explorer.d.ts +26 -0
- package/dist/src/agents/explorer.js +216 -0
- package/dist/src/agents/feeling.d.ts +41 -0
- package/dist/src/agents/feeling.js +320 -0
- package/dist/src/agents/index.d.ts +111 -0
- package/dist/src/agents/index.js +222 -0
- package/dist/src/agents/memory.d.ts +69 -0
- package/dist/src/agents/memory.js +404 -0
- package/dist/src/agents/message-bus.d.ts +88 -0
- package/dist/src/agents/message-bus.js +267 -0
- package/dist/src/agents/narrator.d.ts +90 -0
- package/dist/src/agents/narrator.js +473 -0
- package/dist/src/agents/planner.d.ts +38 -0
- package/dist/src/agents/planner.js +341 -0
- package/dist/src/agents/predictor.d.ts +73 -0
- package/dist/src/agents/predictor.js +506 -0
- package/dist/src/agents/sensor.d.ts +88 -0
- package/dist/src/agents/sensor.js +377 -0
- package/dist/src/agents/test-agents.d.ts +6 -0
- package/dist/src/agents/test-agents.js +73 -0
- package/dist/src/agents/types.d.ts +194 -0
- package/dist/src/agents/types.js +7 -0
- package/dist/src/brain/index.d.ts +185 -0
- package/dist/src/brain/index.js +843 -0
- package/dist/src/brain/trace.d.ts +91 -0
- package/dist/src/brain/trace.js +327 -0
- package/dist/src/brain/types.d.ts +165 -0
- package/dist/src/brain/types.js +51 -0
- package/dist/src/cli/chat.d.ts +237 -0
- package/dist/src/cli/chat.js +1959 -0
- package/dist/src/cli/dispatcher.d.ts +182 -0
- package/dist/src/cli/dispatcher.js +718 -0
- package/dist/src/cli/human-loop.d.ts +170 -0
- package/dist/src/cli/human-loop.js +543 -0
- package/dist/src/cli/index.d.ts +12 -0
- package/dist/src/cli/index.js +28 -0
- package/dist/src/cli/interactive.d.ts +141 -0
- package/dist/src/cli/interactive.js +757 -0
- package/dist/src/cli/ui.d.ts +205 -0
- package/dist/src/cli/ui.js +632 -0
- package/dist/src/consciousness/attention-schema.d.ts +154 -0
- package/dist/src/consciousness/attention-schema.js +432 -0
- package/dist/src/consciousness/global-workspace.d.ts +149 -0
- package/dist/src/consciousness/global-workspace.js +422 -0
- package/dist/src/consciousness/index.d.ts +186 -0
- package/dist/src/consciousness/index.js +476 -0
- package/dist/src/consciousness/phi-calculator.d.ts +119 -0
- package/dist/src/consciousness/phi-calculator.js +445 -0
- package/dist/src/consciousness/phi-decisions.d.ts +169 -0
- package/dist/src/consciousness/phi-decisions.js +383 -0
- package/dist/src/consciousness/phi-monitor.d.ts +153 -0
- package/dist/src/consciousness/phi-monitor.js +465 -0
- package/dist/src/consciousness/types.d.ts +260 -0
- package/dist/src/consciousness/types.js +44 -0
- package/dist/src/daemon/dream-mode.d.ts +115 -0
- package/dist/src/daemon/dream-mode.js +470 -0
- package/dist/src/daemon/index.d.ts +162 -0
- package/dist/src/daemon/index.js +542 -0
- package/dist/src/daemon/maintenance.d.ts +139 -0
- package/dist/src/daemon/maintenance.js +549 -0
- package/dist/src/daemon/process.d.ts +82 -0
- package/dist/src/daemon/process.js +442 -0
- package/dist/src/daemon/scheduler.d.ts +90 -0
- package/dist/src/daemon/scheduler.js +494 -0
- package/dist/src/daemon/types.d.ts +213 -0
- package/dist/src/daemon/types.js +50 -0
- package/dist/src/epistemic/index.d.ts +74 -0
- package/dist/src/epistemic/index.js +225 -0
- package/dist/src/grounding/epistemic-stack.d.ts +100 -0
- package/dist/src/grounding/epistemic-stack.js +408 -0
- package/dist/src/grounding/feedback.d.ts +98 -0
- package/dist/src/grounding/feedback.js +276 -0
- package/dist/src/grounding/index.d.ts +123 -0
- package/dist/src/grounding/index.js +224 -0
- package/dist/src/grounding/verifier.d.ts +149 -0
- package/dist/src/grounding/verifier.js +484 -0
- package/dist/src/healing/detector.d.ts +110 -0
- package/dist/src/healing/detector.js +436 -0
- package/dist/src/healing/fixer.d.ts +138 -0
- package/dist/src/healing/fixer.js +572 -0
- package/dist/src/healing/index.d.ts +23 -0
- package/dist/src/healing/index.js +43 -0
- package/dist/src/hooks/index.d.ts +135 -0
- package/dist/src/hooks/index.js +317 -0
- package/dist/src/index.d.ts +23 -0
- package/dist/src/index.js +1266 -0
- package/dist/src/kernel/index.d.ts +155 -0
- package/dist/src/kernel/index.js +795 -0
- package/dist/src/kernel/invariants.d.ts +153 -0
- package/dist/src/kernel/invariants.js +355 -0
- package/dist/src/kernel/test-kernel.d.ts +6 -0
- package/dist/src/kernel/test-kernel.js +108 -0
- package/dist/src/kernel/test-real-mcp.d.ts +10 -0
- package/dist/src/kernel/test-real-mcp.js +295 -0
- package/dist/src/llm/index.d.ts +146 -0
- package/dist/src/llm/index.js +428 -0
- package/dist/src/llm/router.d.ts +136 -0
- package/dist/src/llm/router.js +510 -0
- package/dist/src/mcp/index.d.ts +85 -0
- package/dist/src/mcp/index.js +657 -0
- package/dist/src/mcp/resilient.d.ts +139 -0
- package/dist/src/mcp/resilient.js +417 -0
- package/dist/src/memory/cache.d.ts +118 -0
- package/dist/src/memory/cache.js +356 -0
- package/dist/src/memory/cognitive-workspace.d.ts +231 -0
- package/dist/src/memory/cognitive-workspace.js +521 -0
- package/dist/src/memory/consolidation.d.ts +99 -0
- package/dist/src/memory/consolidation.js +443 -0
- package/dist/src/memory/episodic.d.ts +114 -0
- package/dist/src/memory/episodic.js +394 -0
- package/dist/src/memory/forgetting.d.ts +134 -0
- package/dist/src/memory/forgetting.js +324 -0
- package/dist/src/memory/index.d.ts +211 -0
- package/dist/src/memory/index.js +367 -0
- package/dist/src/memory/indexer.d.ts +123 -0
- package/dist/src/memory/indexer.js +479 -0
- package/dist/src/memory/procedural.d.ts +136 -0
- package/dist/src/memory/procedural.js +479 -0
- package/dist/src/memory/semantic.d.ts +132 -0
- package/dist/src/memory/semantic.js +497 -0
- package/dist/src/memory/types.d.ts +193 -0
- package/dist/src/memory/types.js +15 -0
- package/dist/src/orchestrator.d.ts +65 -0
- package/dist/src/orchestrator.js +317 -0
- package/dist/src/persistence/index.d.ts +257 -0
- package/dist/src/persistence/index.js +763 -0
- package/dist/src/pipeline/executor.d.ts +51 -0
- package/dist/src/pipeline/executor.js +695 -0
- package/dist/src/pipeline/index.d.ts +7 -0
- package/dist/src/pipeline/index.js +11 -0
- package/dist/src/self-production.d.ts +67 -0
- package/dist/src/self-production.js +205 -0
- package/dist/src/subagents/executor.d.ts +58 -0
- package/dist/src/subagents/executor.js +283 -0
- package/dist/src/subagents/index.d.ts +37 -0
- package/dist/src/subagents/index.js +53 -0
- package/dist/src/subagents/registry.d.ts +23 -0
- package/dist/src/subagents/registry.js +167 -0
- package/dist/src/subagents/types.d.ts +79 -0
- package/dist/src/subagents/types.js +14 -0
- package/dist/src/tools/bash.d.ts +139 -0
- package/dist/src/tools/bash.js +583 -0
- package/dist/src/tools/edit.d.ts +125 -0
- package/dist/src/tools/edit.js +424 -0
- package/dist/src/tools/git.d.ts +179 -0
- package/dist/src/tools/git.js +504 -0
- package/dist/src/tools/index.d.ts +21 -0
- package/dist/src/tools/index.js +163 -0
- package/dist/src/types.d.ts +145 -0
- package/dist/src/types.js +7 -0
- package/dist/src/world-model/decoder.d.ts +163 -0
- package/dist/src/world-model/decoder.js +517 -0
- package/dist/src/world-model/digital-twin.d.ts +219 -0
- package/dist/src/world-model/digital-twin.js +695 -0
- package/dist/src/world-model/encoder.d.ts +141 -0
- package/dist/src/world-model/encoder.js +564 -0
- package/dist/src/world-model/index.d.ts +221 -0
- package/dist/src/world-model/index.js +772 -0
- package/dist/src/world-model/predictor.d.ts +161 -0
- package/dist/src/world-model/predictor.js +681 -0
- package/dist/src/world-model/test-value-jepa.d.ts +8 -0
- package/dist/src/world-model/test-value-jepa.js +430 -0
- package/dist/src/world-model/types.d.ts +341 -0
- package/dist/src/world-model/types.js +69 -0
- package/dist/src/world-model/value-jepa.d.ts +247 -0
- package/dist/src/world-model/value-jepa.js +622 -0
- package/dist/test/brain.test.d.ts +11 -0
- package/dist/test/brain.test.js +358 -0
- package/dist/test/cli/dispatcher.test.d.ts +4 -0
- package/dist/test/cli/dispatcher.test.js +332 -0
- package/dist/test/cli/human-loop.test.d.ts +4 -0
- package/dist/test/cli/human-loop.test.js +270 -0
- package/dist/test/grounding/feedback.test.d.ts +4 -0
- package/dist/test/grounding/feedback.test.js +462 -0
- package/dist/test/grounding/verifier.test.d.ts +4 -0
- package/dist/test/grounding/verifier.test.js +442 -0
- package/dist/test/grounding.test.d.ts +6 -0
- package/dist/test/grounding.test.js +246 -0
- package/dist/test/healing/detector.test.d.ts +4 -0
- package/dist/test/healing/detector.test.js +266 -0
- package/dist/test/healing/fixer.test.d.ts +4 -0
- package/dist/test/healing/fixer.test.js +369 -0
- package/dist/test/integration.test.d.ts +5 -0
- package/dist/test/integration.test.js +290 -0
- package/dist/test/tools/bash.test.d.ts +4 -0
- package/dist/test/tools/bash.test.js +348 -0
- package/dist/test/tools/edit.test.d.ts +4 -0
- package/dist/test/tools/edit.test.js +350 -0
- package/dist/test/tools/git.test.d.ts +4 -0
- package/dist/test/tools/git.test.js +350 -0
- package/package.json +60 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genesis - MCP Orchestrator
|
|
3
|
+
*
|
|
4
|
+
* Central hub that coordinates all 13 MCP servers for system creation.
|
|
5
|
+
*
|
|
6
|
+
* MCP Servers:
|
|
7
|
+
* - KNOWLEDGE: arxiv, semantic-scholar, context7, wolfram
|
|
8
|
+
* - RESEARCH: gemini, brave-search, exa, firecrawl
|
|
9
|
+
* - CREATION: openai, github
|
|
10
|
+
* - VISUAL: stability-ai
|
|
11
|
+
* - STORAGE: memory, filesystem
|
|
12
|
+
*/
|
|
13
|
+
import { MCPServerName, MCPCapability, SystemSpec, ResearchResult, Architecture, GeneratedCode, Visual, PipelineResult, KnowledgeEntity, KnowledgeRelation } from './types.js';
|
|
14
|
+
export declare const MCP_CAPABILITIES: Record<MCPServerName, MCPCapability>;
|
|
15
|
+
export declare class MCPOrchestrator {
|
|
16
|
+
private verbose;
|
|
17
|
+
constructor(options?: {
|
|
18
|
+
verbose?: boolean;
|
|
19
|
+
});
|
|
20
|
+
private log;
|
|
21
|
+
/**
|
|
22
|
+
* Get all MCPs for a category
|
|
23
|
+
*/
|
|
24
|
+
getMCPsByCategory(category: MCPCapability['category']): MCPServerName[];
|
|
25
|
+
/**
|
|
26
|
+
* Research a topic using all knowledge MCPs in parallel
|
|
27
|
+
*/
|
|
28
|
+
research(topic: string, spec?: SystemSpec): Promise<ResearchResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Generate system architecture using AI models
|
|
31
|
+
*/
|
|
32
|
+
design(spec: SystemSpec, research: ResearchResult): Promise<Architecture>;
|
|
33
|
+
/**
|
|
34
|
+
* Generate code from architecture
|
|
35
|
+
*/
|
|
36
|
+
generate(spec: SystemSpec, architecture: Architecture): Promise<GeneratedCode>;
|
|
37
|
+
/**
|
|
38
|
+
* Create visualizations
|
|
39
|
+
*/
|
|
40
|
+
visualize(spec: SystemSpec, architecture: Architecture): Promise<Visual[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Persist to knowledge graph
|
|
43
|
+
*/
|
|
44
|
+
persist(spec: SystemSpec, entities: KnowledgeEntity[], relations: KnowledgeRelation[]): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Publish to GitHub
|
|
47
|
+
*/
|
|
48
|
+
publish(spec: SystemSpec, code: GeneratedCode): Promise<string>;
|
|
49
|
+
buildResearchPrompt(topic: string, sources: MCPServerName[]): string;
|
|
50
|
+
buildArchitecturePrompt(spec: SystemSpec, research: ResearchResult): string;
|
|
51
|
+
buildCodePrompt(spec: SystemSpec, architecture: Architecture, language: 'typescript' | 'python' | 'rust'): string;
|
|
52
|
+
buildVisualPrompt(spec: SystemSpec, type: Visual['type']): string;
|
|
53
|
+
}
|
|
54
|
+
export declare class GenesisPipeline {
|
|
55
|
+
private orchestrator;
|
|
56
|
+
constructor(orchestrator: MCPOrchestrator);
|
|
57
|
+
/**
|
|
58
|
+
* Run the full system creation pipeline
|
|
59
|
+
*/
|
|
60
|
+
run(spec: SystemSpec): Promise<PipelineResult<any>[]>;
|
|
61
|
+
private getMCPsForStage;
|
|
62
|
+
}
|
|
63
|
+
export declare function createOrchestrator(options?: {
|
|
64
|
+
verbose?: boolean;
|
|
65
|
+
}): MCPOrchestrator;
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Genesis - MCP Orchestrator
|
|
4
|
+
*
|
|
5
|
+
* Central hub that coordinates all 13 MCP servers for system creation.
|
|
6
|
+
*
|
|
7
|
+
* MCP Servers:
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.GenesisPipeline = exports.MCPOrchestrator = exports.MCP_CAPABILITIES = void 0;
|
|
16
|
+
exports.createOrchestrator = createOrchestrator;
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// MCP Capability Map
|
|
19
|
+
// ============================================================================
|
|
20
|
+
exports.MCP_CAPABILITIES = {
|
|
21
|
+
// Knowledge MCPs
|
|
22
|
+
'arxiv': {
|
|
23
|
+
server: 'arxiv',
|
|
24
|
+
category: 'knowledge',
|
|
25
|
+
tools: ['search_arxiv', 'parse_paper_content', 'get_recent_ai_papers'],
|
|
26
|
+
description: 'Academic papers from arXiv',
|
|
27
|
+
},
|
|
28
|
+
'semantic-scholar': {
|
|
29
|
+
server: 'semantic-scholar',
|
|
30
|
+
category: 'knowledge',
|
|
31
|
+
tools: ['search_semantic_scholar', 'get_paper', 'get_citations'],
|
|
32
|
+
description: 'Academic paper search with citations',
|
|
33
|
+
},
|
|
34
|
+
'context7': {
|
|
35
|
+
server: 'context7',
|
|
36
|
+
category: 'knowledge',
|
|
37
|
+
tools: ['resolve-library-id', 'query-docs'],
|
|
38
|
+
description: 'Programming library documentation',
|
|
39
|
+
},
|
|
40
|
+
'wolfram': {
|
|
41
|
+
server: 'wolfram',
|
|
42
|
+
category: 'knowledge',
|
|
43
|
+
tools: ['wolfram_query'],
|
|
44
|
+
description: 'Mathematical and scientific computations',
|
|
45
|
+
},
|
|
46
|
+
// Research MCPs
|
|
47
|
+
'gemini': {
|
|
48
|
+
server: 'gemini',
|
|
49
|
+
category: 'research',
|
|
50
|
+
tools: ['web_search', 'web_search_batch'],
|
|
51
|
+
description: 'Web search with Gemini AI',
|
|
52
|
+
},
|
|
53
|
+
'brave-search': {
|
|
54
|
+
server: 'brave-search',
|
|
55
|
+
category: 'research',
|
|
56
|
+
tools: ['brave_web_search', 'brave_news_search', 'brave_image_search'],
|
|
57
|
+
description: 'Web, news, and image search',
|
|
58
|
+
},
|
|
59
|
+
'exa': {
|
|
60
|
+
server: 'exa',
|
|
61
|
+
category: 'research',
|
|
62
|
+
tools: ['web_search_exa', 'get_code_context_exa'],
|
|
63
|
+
description: 'Code-focused search',
|
|
64
|
+
},
|
|
65
|
+
'firecrawl': {
|
|
66
|
+
server: 'firecrawl',
|
|
67
|
+
category: 'research',
|
|
68
|
+
tools: ['firecrawl_scrape', 'firecrawl_search', 'firecrawl_extract'],
|
|
69
|
+
description: 'Web scraping and extraction',
|
|
70
|
+
},
|
|
71
|
+
// Creation MCPs
|
|
72
|
+
'openai': {
|
|
73
|
+
server: 'openai',
|
|
74
|
+
category: 'creation',
|
|
75
|
+
tools: ['openai_chat'],
|
|
76
|
+
description: 'GPT-4o, o1 for code generation',
|
|
77
|
+
},
|
|
78
|
+
'github': {
|
|
79
|
+
server: 'github',
|
|
80
|
+
category: 'creation',
|
|
81
|
+
tools: ['create_repository', 'push_files', 'create_pull_request'],
|
|
82
|
+
description: 'Repository management',
|
|
83
|
+
},
|
|
84
|
+
// Visual MCPs
|
|
85
|
+
'stability-ai': {
|
|
86
|
+
server: 'stability-ai',
|
|
87
|
+
category: 'visual',
|
|
88
|
+
tools: ['generate-image', 'generate-image-sd35'],
|
|
89
|
+
description: 'Image generation',
|
|
90
|
+
},
|
|
91
|
+
// Storage MCPs
|
|
92
|
+
'memory': {
|
|
93
|
+
server: 'memory',
|
|
94
|
+
category: 'storage',
|
|
95
|
+
tools: ['create_entities', 'create_relations', 'read_graph', 'search_nodes'],
|
|
96
|
+
description: 'Knowledge graph persistence',
|
|
97
|
+
},
|
|
98
|
+
'filesystem': {
|
|
99
|
+
server: 'filesystem',
|
|
100
|
+
category: 'storage',
|
|
101
|
+
tools: ['read_file', 'write_file', 'list_directory'],
|
|
102
|
+
description: 'Local file operations',
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
// ============================================================================
|
|
106
|
+
// Orchestrator Class
|
|
107
|
+
// ============================================================================
|
|
108
|
+
class MCPOrchestrator {
|
|
109
|
+
verbose;
|
|
110
|
+
constructor(options = {}) {
|
|
111
|
+
this.verbose = options.verbose ?? false;
|
|
112
|
+
}
|
|
113
|
+
log(message) {
|
|
114
|
+
if (this.verbose) {
|
|
115
|
+
console.log(`[Genesis] ${message}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get all MCPs for a category
|
|
120
|
+
*/
|
|
121
|
+
getMCPsByCategory(category) {
|
|
122
|
+
return Object.entries(exports.MCP_CAPABILITIES)
|
|
123
|
+
.filter(([_, cap]) => cap.category === category)
|
|
124
|
+
.map(([server]) => server);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Research a topic using all knowledge MCPs in parallel
|
|
128
|
+
*/
|
|
129
|
+
async research(topic, spec) {
|
|
130
|
+
this.log(`Researching: ${topic}`);
|
|
131
|
+
const result = {
|
|
132
|
+
papers: [],
|
|
133
|
+
documentation: [],
|
|
134
|
+
codeExamples: [],
|
|
135
|
+
webResults: [],
|
|
136
|
+
insights: [],
|
|
137
|
+
};
|
|
138
|
+
// This would be implemented by the MCP caller
|
|
139
|
+
// The orchestrator defines WHAT to call, the system executes
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Generate system architecture using AI models
|
|
144
|
+
*/
|
|
145
|
+
async design(spec, research) {
|
|
146
|
+
this.log(`Designing architecture for: ${spec.name}`);
|
|
147
|
+
// Architecture generation prompt template
|
|
148
|
+
const architecturePrompt = this.buildArchitecturePrompt(spec, research);
|
|
149
|
+
return {
|
|
150
|
+
components: [],
|
|
151
|
+
relations: [],
|
|
152
|
+
invariants: [],
|
|
153
|
+
operations: [],
|
|
154
|
+
events: [],
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Generate code from architecture
|
|
159
|
+
*/
|
|
160
|
+
async generate(spec, architecture) {
|
|
161
|
+
this.log(`Generating code for: ${spec.name}`);
|
|
162
|
+
return {
|
|
163
|
+
files: [],
|
|
164
|
+
language: 'typescript',
|
|
165
|
+
tests: [],
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Create visualizations
|
|
170
|
+
*/
|
|
171
|
+
async visualize(spec, architecture) {
|
|
172
|
+
this.log(`Creating visuals for: ${spec.name}`);
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Persist to knowledge graph
|
|
177
|
+
*/
|
|
178
|
+
async persist(spec, entities, relations) {
|
|
179
|
+
this.log(`Persisting ${entities.length} entities to knowledge graph`);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Publish to GitHub
|
|
183
|
+
*/
|
|
184
|
+
async publish(spec, code) {
|
|
185
|
+
this.log(`Publishing ${spec.name} to GitHub`);
|
|
186
|
+
return '';
|
|
187
|
+
}
|
|
188
|
+
// ============================================================================
|
|
189
|
+
// Prompt Builders
|
|
190
|
+
// ============================================================================
|
|
191
|
+
buildResearchPrompt(topic, sources) {
|
|
192
|
+
return `
|
|
193
|
+
Research the topic: "${topic}"
|
|
194
|
+
|
|
195
|
+
Use the following MCP sources in parallel:
|
|
196
|
+
${sources.map(s => `- ${s}: ${exports.MCP_CAPABILITIES[s].description}`).join('\n')}
|
|
197
|
+
|
|
198
|
+
Return:
|
|
199
|
+
1. Key papers (arxiv, semantic-scholar)
|
|
200
|
+
2. Relevant documentation (context7)
|
|
201
|
+
3. Code examples (exa, github)
|
|
202
|
+
4. Web insights (gemini, brave-search, firecrawl)
|
|
203
|
+
5. Synthesized insights
|
|
204
|
+
`.trim();
|
|
205
|
+
}
|
|
206
|
+
buildArchitecturePrompt(spec, research) {
|
|
207
|
+
return `
|
|
208
|
+
Design a system architecture for: "${spec.name}"
|
|
209
|
+
|
|
210
|
+
Description: ${spec.description}
|
|
211
|
+
Type: ${spec.type}
|
|
212
|
+
Features: ${spec.features.join(', ')}
|
|
213
|
+
${spec.constraints ? `Constraints: ${spec.constraints.join(', ')}` : ''}
|
|
214
|
+
|
|
215
|
+
Research insights:
|
|
216
|
+
${research.insights.join('\n')}
|
|
217
|
+
|
|
218
|
+
Generate:
|
|
219
|
+
1. Components with dependencies
|
|
220
|
+
2. Relations between components
|
|
221
|
+
3. Invariants the system must maintain
|
|
222
|
+
4. Operations the system can perform
|
|
223
|
+
5. Events the system emits
|
|
224
|
+
`.trim();
|
|
225
|
+
}
|
|
226
|
+
buildCodePrompt(spec, architecture, language) {
|
|
227
|
+
return `
|
|
228
|
+
Generate ${language} code for: "${spec.name}"
|
|
229
|
+
|
|
230
|
+
Architecture:
|
|
231
|
+
- Components: ${architecture.components.map(c => c.name).join(', ')}
|
|
232
|
+
- Operations: ${architecture.operations.map(o => o.id).join(', ')}
|
|
233
|
+
- Invariants: ${architecture.invariants.join('; ')}
|
|
234
|
+
|
|
235
|
+
Requirements:
|
|
236
|
+
1. Full implementation of all components
|
|
237
|
+
2. Type safety
|
|
238
|
+
3. Error handling
|
|
239
|
+
4. Unit tests for each component
|
|
240
|
+
5. CLI entry point
|
|
241
|
+
`.trim();
|
|
242
|
+
}
|
|
243
|
+
buildVisualPrompt(spec, type) {
|
|
244
|
+
const prompts = {
|
|
245
|
+
architecture: `Technical architecture diagram for "${spec.name}". Show components as nodes, relations as edges. Clean, professional style. Dark background, glowing connections.`,
|
|
246
|
+
concept: `Conceptual visualization of "${spec.name}". Abstract, artistic interpretation of: ${spec.description}. Ethereal, modern digital art style.`,
|
|
247
|
+
flow: `Data flow diagram for "${spec.name}". Show how data moves through the system. Arrows, pipelines, transformations. Technical illustration style.`,
|
|
248
|
+
logo: `Minimalist logo for "${spec.name}". Modern, tech-inspired. Simple geometric shapes. Can work on light and dark backgrounds.`,
|
|
249
|
+
};
|
|
250
|
+
return prompts[type];
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
exports.MCPOrchestrator = MCPOrchestrator;
|
|
254
|
+
// ============================================================================
|
|
255
|
+
// Pipeline Runner
|
|
256
|
+
// ============================================================================
|
|
257
|
+
class GenesisPipeline {
|
|
258
|
+
orchestrator;
|
|
259
|
+
constructor(orchestrator) {
|
|
260
|
+
this.orchestrator = orchestrator;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Run the full system creation pipeline
|
|
264
|
+
*/
|
|
265
|
+
async run(spec) {
|
|
266
|
+
const results = [];
|
|
267
|
+
const stages = [
|
|
268
|
+
'research',
|
|
269
|
+
'design',
|
|
270
|
+
'generate',
|
|
271
|
+
'visualize',
|
|
272
|
+
'persist',
|
|
273
|
+
'publish',
|
|
274
|
+
];
|
|
275
|
+
for (const stage of stages) {
|
|
276
|
+
const start = Date.now();
|
|
277
|
+
try {
|
|
278
|
+
// Each stage would be executed by the MCP caller
|
|
279
|
+
results.push({
|
|
280
|
+
stage,
|
|
281
|
+
success: true,
|
|
282
|
+
duration: Date.now() - start,
|
|
283
|
+
mcpsUsed: this.getMCPsForStage(stage),
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
results.push({
|
|
288
|
+
stage,
|
|
289
|
+
success: false,
|
|
290
|
+
error: String(error),
|
|
291
|
+
duration: Date.now() - start,
|
|
292
|
+
mcpsUsed: this.getMCPsForStage(stage),
|
|
293
|
+
});
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return results;
|
|
298
|
+
}
|
|
299
|
+
getMCPsForStage(stage) {
|
|
300
|
+
const stageToMCPs = {
|
|
301
|
+
research: ['arxiv', 'semantic-scholar', 'context7', 'gemini', 'brave-search', 'exa', 'firecrawl'],
|
|
302
|
+
design: ['openai', 'wolfram'],
|
|
303
|
+
generate: ['openai', 'context7'],
|
|
304
|
+
visualize: ['stability-ai'],
|
|
305
|
+
persist: ['memory', 'filesystem'],
|
|
306
|
+
publish: ['github'],
|
|
307
|
+
};
|
|
308
|
+
return stageToMCPs[stage];
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
exports.GenesisPipeline = GenesisPipeline;
|
|
312
|
+
// ============================================================================
|
|
313
|
+
// Export
|
|
314
|
+
// ============================================================================
|
|
315
|
+
function createOrchestrator(options) {
|
|
316
|
+
return new MCPOrchestrator(options);
|
|
317
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genesis 6.0 - State Persistence
|
|
3
|
+
*
|
|
4
|
+
* Save and load Genesis state to/from disk.
|
|
5
|
+
* Supports JSON format with optional compression.
|
|
6
|
+
*
|
|
7
|
+
* State includes:
|
|
8
|
+
* - Memory (episodic, semantic, procedural)
|
|
9
|
+
* - Conversation history
|
|
10
|
+
* - Session metadata
|
|
11
|
+
* - Configuration
|
|
12
|
+
*/
|
|
13
|
+
import { LLMMessage } from '../llm/index.js';
|
|
14
|
+
export interface GenesisState {
|
|
15
|
+
version: string;
|
|
16
|
+
created: Date;
|
|
17
|
+
lastModified: Date;
|
|
18
|
+
checksum: string;
|
|
19
|
+
memory: MemoryState;
|
|
20
|
+
conversation: ConversationState;
|
|
21
|
+
session: SessionState;
|
|
22
|
+
config: ConfigState;
|
|
23
|
+
}
|
|
24
|
+
export interface MemoryState {
|
|
25
|
+
episodic: any[];
|
|
26
|
+
semantic: any[];
|
|
27
|
+
procedural: any[];
|
|
28
|
+
stats: {
|
|
29
|
+
totalEpisodes: number;
|
|
30
|
+
totalFacts: number;
|
|
31
|
+
totalSkills: number;
|
|
32
|
+
lastConsolidation?: Date;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface ConversationState {
|
|
36
|
+
history: LLMMessage[];
|
|
37
|
+
totalMessages: number;
|
|
38
|
+
totalTokens: number;
|
|
39
|
+
}
|
|
40
|
+
export interface SessionState {
|
|
41
|
+
id: string;
|
|
42
|
+
startTime: Date;
|
|
43
|
+
interactions: number;
|
|
44
|
+
lastActivity: Date;
|
|
45
|
+
}
|
|
46
|
+
export interface ConfigState {
|
|
47
|
+
llm: {
|
|
48
|
+
provider?: string;
|
|
49
|
+
model?: string;
|
|
50
|
+
};
|
|
51
|
+
persistence: {
|
|
52
|
+
autoSaveInterval?: number;
|
|
53
|
+
maxBackups?: number;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export interface PersistenceOptions {
|
|
57
|
+
dataDir?: string;
|
|
58
|
+
autoSave?: boolean;
|
|
59
|
+
autoSaveIntervalMs?: number;
|
|
60
|
+
maxBackups?: number;
|
|
61
|
+
onSave?: (state: GenesisState) => void;
|
|
62
|
+
onLoad?: (state: GenesisState) => void;
|
|
63
|
+
onError?: (error: Error) => void;
|
|
64
|
+
}
|
|
65
|
+
export declare class StateStore {
|
|
66
|
+
private dataDir;
|
|
67
|
+
private statePath;
|
|
68
|
+
private backupDir;
|
|
69
|
+
private options;
|
|
70
|
+
private autoSaveTimer;
|
|
71
|
+
private dirty;
|
|
72
|
+
private state;
|
|
73
|
+
constructor(options?: PersistenceOptions);
|
|
74
|
+
/**
|
|
75
|
+
* Save state to disk
|
|
76
|
+
*/
|
|
77
|
+
save(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Save state synchronously
|
|
80
|
+
*/
|
|
81
|
+
saveSync(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Load state from disk
|
|
84
|
+
*/
|
|
85
|
+
load(): Promise<GenesisState>;
|
|
86
|
+
/**
|
|
87
|
+
* Load state synchronously
|
|
88
|
+
*/
|
|
89
|
+
loadSync(): GenesisState;
|
|
90
|
+
/**
|
|
91
|
+
* Get current state
|
|
92
|
+
*/
|
|
93
|
+
getState(): GenesisState;
|
|
94
|
+
/**
|
|
95
|
+
* Update state (partial update)
|
|
96
|
+
*/
|
|
97
|
+
update(updates: Partial<GenesisState>): void;
|
|
98
|
+
/**
|
|
99
|
+
* Check if state has unsaved changes
|
|
100
|
+
*/
|
|
101
|
+
isDirty(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Update memory state
|
|
104
|
+
*/
|
|
105
|
+
updateMemory(memory: Partial<MemoryState>): void;
|
|
106
|
+
/**
|
|
107
|
+
* Add episodic memory
|
|
108
|
+
*/
|
|
109
|
+
addEpisode(episode: any): void;
|
|
110
|
+
/**
|
|
111
|
+
* Add semantic memory
|
|
112
|
+
*/
|
|
113
|
+
addFact(fact: any): void;
|
|
114
|
+
/**
|
|
115
|
+
* Add procedural memory
|
|
116
|
+
*/
|
|
117
|
+
addSkill(skill: any): void;
|
|
118
|
+
/**
|
|
119
|
+
* Update conversation history
|
|
120
|
+
*/
|
|
121
|
+
updateConversation(messages: LLMMessage[], tokens?: number): void;
|
|
122
|
+
/**
|
|
123
|
+
* Add message to conversation
|
|
124
|
+
*/
|
|
125
|
+
addMessage(message: LLMMessage): void;
|
|
126
|
+
/**
|
|
127
|
+
* Clear conversation history
|
|
128
|
+
*/
|
|
129
|
+
clearConversation(): void;
|
|
130
|
+
/**
|
|
131
|
+
* Record an interaction
|
|
132
|
+
*/
|
|
133
|
+
recordInteraction(): void;
|
|
134
|
+
/**
|
|
135
|
+
* Start new session
|
|
136
|
+
*/
|
|
137
|
+
newSession(): void;
|
|
138
|
+
/**
|
|
139
|
+
* Create backup of current state
|
|
140
|
+
*/
|
|
141
|
+
backup(): Promise<string | null>;
|
|
142
|
+
/**
|
|
143
|
+
* Create backup synchronously
|
|
144
|
+
*/
|
|
145
|
+
backupSync(): string | null;
|
|
146
|
+
/**
|
|
147
|
+
* List available backups
|
|
148
|
+
*/
|
|
149
|
+
listBackups(): string[];
|
|
150
|
+
/**
|
|
151
|
+
* Restore from backup
|
|
152
|
+
*/
|
|
153
|
+
restoreBackup(backupName: string): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Export state to a portable format
|
|
156
|
+
*/
|
|
157
|
+
export(outputPath: string): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Import state from file
|
|
160
|
+
*/
|
|
161
|
+
import(inputPath: string, merge?: boolean): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Start auto-save timer
|
|
164
|
+
*/
|
|
165
|
+
startAutoSave(intervalMs: number): void;
|
|
166
|
+
/**
|
|
167
|
+
* Stop auto-save timer
|
|
168
|
+
*/
|
|
169
|
+
stopAutoSave(): void;
|
|
170
|
+
/**
|
|
171
|
+
* Reset state to empty
|
|
172
|
+
*/
|
|
173
|
+
reset(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Delete all persisted data
|
|
176
|
+
*/
|
|
177
|
+
purge(): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Close and cleanup
|
|
180
|
+
*/
|
|
181
|
+
close(): void;
|
|
182
|
+
private createEmptyState;
|
|
183
|
+
private mergeState;
|
|
184
|
+
private calculateChecksum;
|
|
185
|
+
private ensureDirectories;
|
|
186
|
+
private cleanOldBackups;
|
|
187
|
+
private cleanOldBackupsSync;
|
|
188
|
+
/**
|
|
189
|
+
* Get data directory path
|
|
190
|
+
*/
|
|
191
|
+
getDataDir(): string;
|
|
192
|
+
/**
|
|
193
|
+
* Get stats
|
|
194
|
+
*/
|
|
195
|
+
stats(): {
|
|
196
|
+
dataDir: string;
|
|
197
|
+
stateExists: boolean;
|
|
198
|
+
stateSize: number;
|
|
199
|
+
backupCount: number;
|
|
200
|
+
isDirty: boolean;
|
|
201
|
+
lastModified: Date;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
export declare function createStateStore(options?: PersistenceOptions): StateStore;
|
|
205
|
+
export declare function getStateStore(options?: PersistenceOptions): StateStore;
|
|
206
|
+
export declare function resetStateStore(): void;
|
|
207
|
+
export interface SessionInfo {
|
|
208
|
+
id: string;
|
|
209
|
+
name?: string;
|
|
210
|
+
created: Date;
|
|
211
|
+
lastModified: Date;
|
|
212
|
+
messageCount: number;
|
|
213
|
+
tokenCount: number;
|
|
214
|
+
summary?: string;
|
|
215
|
+
}
|
|
216
|
+
export interface SessionManagerOptions {
|
|
217
|
+
dataDir?: string;
|
|
218
|
+
maxSessions?: number;
|
|
219
|
+
}
|
|
220
|
+
export declare class SessionManager {
|
|
221
|
+
private dataDir;
|
|
222
|
+
private sessionsDir;
|
|
223
|
+
private options;
|
|
224
|
+
constructor(options?: SessionManagerOptions);
|
|
225
|
+
/**
|
|
226
|
+
* List all saved sessions
|
|
227
|
+
*/
|
|
228
|
+
listSessions(): SessionInfo[];
|
|
229
|
+
/**
|
|
230
|
+
* Get the most recent session ID
|
|
231
|
+
*/
|
|
232
|
+
getLastSessionId(): string | null;
|
|
233
|
+
/**
|
|
234
|
+
* Save current state as a session
|
|
235
|
+
*/
|
|
236
|
+
saveSession(state: GenesisState, name?: string): string;
|
|
237
|
+
/**
|
|
238
|
+
* Load a session by ID (or 'last' for most recent)
|
|
239
|
+
*/
|
|
240
|
+
loadSession(sessionIdOrLast: string): GenesisState | null;
|
|
241
|
+
/**
|
|
242
|
+
* Fork a session (create a copy with new ID)
|
|
243
|
+
*/
|
|
244
|
+
forkSession(sessionId: string, newName?: string): string | null;
|
|
245
|
+
/**
|
|
246
|
+
* Delete a session
|
|
247
|
+
*/
|
|
248
|
+
deleteSession(sessionId: string): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Rename a session
|
|
251
|
+
*/
|
|
252
|
+
renameSession(sessionId: string, newName: string): boolean;
|
|
253
|
+
private getSessionPath;
|
|
254
|
+
private ensureDirectory;
|
|
255
|
+
private cleanupOldSessions;
|
|
256
|
+
}
|
|
257
|
+
export declare function getSessionManager(options?: SessionManagerOptions): SessionManager;
|