closed-loop-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of closed-loop-cli might be problematic. Click here for more details.

Files changed (86) hide show
  1. package/dist/dashboard/server.js +237 -0
  2. package/dist/index.js +272 -0
  3. package/dist/orchestrator/agent-prompts.js +42 -0
  4. package/dist/orchestrator/autogenesis.js +973 -0
  5. package/dist/orchestrator/dgm-archive.js +223 -0
  6. package/dist/orchestrator/event-stream.js +103 -0
  7. package/dist/orchestrator/fitness-evaluator.js +99 -0
  8. package/dist/orchestrator/meta-agent.js +421 -0
  9. package/dist/orchestrator/microagent-registry.js +134 -0
  10. package/dist/orchestrator/mutation-strategies.js +174 -0
  11. package/dist/orchestrator/prompt-benchmark.js +102 -0
  12. package/dist/orchestrator/prompt-optimizer.js +169 -0
  13. package/dist/orchestrator/refactor-scanner.js +222 -0
  14. package/dist/orchestrator/research-manager.js +104 -0
  15. package/dist/orchestrator/rulez.js +135 -0
  16. package/dist/orchestrator/sahoo-gateway.js +261 -0
  17. package/dist/orchestrator/state-manager.js +121 -0
  18. package/dist/orchestrator/task-agent.js +444 -0
  19. package/dist/orchestrator/telegram-bot.js +374 -0
  20. package/dist/orchestrator/types.js +2 -0
  21. package/dist/tests/dynamic/dependencies.test.js +37 -0
  22. package/dist/tests/dynamic/dummy.test.js +7 -0
  23. package/dist/tests/dynamic/fuzzy-patch.test.js +68 -0
  24. package/dist/tests/dynamic/indexer.test.js +60 -0
  25. package/dist/tests/dynamic/openhands.test.js +83 -0
  26. package/dist/tests/dynamic/skills.test.js +88 -0
  27. package/dist/tests/run-tests.js +294 -0
  28. package/dist/tools/diff-tools.js +24 -0
  29. package/dist/tools/file-tools.js +191 -0
  30. package/dist/tools/indexer.js +301 -0
  31. package/dist/tools/math-helper.js +6 -0
  32. package/dist/tools/repo-map.js +122 -0
  33. package/dist/tools/search-tools.js +271 -0
  34. package/dist/tools/shell-tools.js +75 -0
  35. package/dist/tools/skills.js +122 -0
  36. package/dist/tools/tui-tools.js +82 -0
  37. package/docs/AI_Arch_Opt_Anti_Gaming.md +227 -0
  38. package/docs/AI_Self_Improvement_Safety.md +457 -0
  39. package/docs/Anthropic AI Agents_ Capabilities and Concerns.md +134 -0
  40. package/docs/Auto_ClosedLoop_AI_Agent.md +415 -0
  41. package/docs/Autonomous AI Agents_ Closing the Loop.docx +0 -0
  42. package/docs/Secure_AI_Sandbox_Framework.md +358 -0
  43. package/docs/skills/add-file-existence-check-utility.json +9 -0
  44. package/docs/skills/add-utility-function-for-file-existence-check.json +9 -0
  45. package/docs/skills/add-utility-function-to-module.json +9 -0
  46. package/docs/skills/extract-command-runner-utility.json +9 -0
  47. package/docs/skills/file-existence-check-utility.json +9 -0
  48. package/package.json +36 -0
  49. package/src/dashboard/public/index.css +1334 -0
  50. package/src/dashboard/public/index.html +385 -0
  51. package/src/dashboard/public/index.js +1059 -0
  52. package/src/dashboard/server.ts +209 -0
  53. package/src/index.ts +256 -0
  54. package/src/orchestrator/agent-prompts.ts +43 -0
  55. package/src/orchestrator/autogenesis.ts +1078 -0
  56. package/src/orchestrator/dgm-archive.ts +257 -0
  57. package/src/orchestrator/event-stream.ts +90 -0
  58. package/src/orchestrator/fitness-evaluator.ts +154 -0
  59. package/src/orchestrator/meta-agent.ts +434 -0
  60. package/src/orchestrator/microagent-registry.ts +115 -0
  61. package/src/orchestrator/microagents/git-helper.md +11 -0
  62. package/src/orchestrator/microagents/test-fixer.md +10 -0
  63. package/src/orchestrator/microagents/typescript-expert.md +11 -0
  64. package/src/orchestrator/mutation-strategies.ts +214 -0
  65. package/src/orchestrator/research-manager.ts +88 -0
  66. package/src/orchestrator/rulez.ts +118 -0
  67. package/src/orchestrator/sahoo-gateway.ts +300 -0
  68. package/src/orchestrator/state-manager.ts +161 -0
  69. package/src/orchestrator/system-prompt.txt +1 -0
  70. package/src/orchestrator/task-agent.ts +461 -0
  71. package/src/orchestrator/telegram-bot.ts +358 -0
  72. package/src/tests/dynamic/dependencies.test.ts +48 -0
  73. package/src/tests/dynamic/dummy.test.ts +4 -0
  74. package/src/tests/dynamic/fuzzy-patch.test.ts +42 -0
  75. package/src/tests/dynamic/indexer.test.ts +31 -0
  76. package/src/tests/dynamic/openhands.test.ts +59 -0
  77. package/src/tests/dynamic/skills.test.ts +63 -0
  78. package/src/tests/run-tests.ts +296 -0
  79. package/src/tools/diff-tools.ts +27 -0
  80. package/src/tools/file-tools.ts +187 -0
  81. package/src/tools/indexer.ts +325 -0
  82. package/src/tools/repo-map.ts +96 -0
  83. package/src/tools/search-tools.ts +258 -0
  84. package/src/tools/shell-tools.ts +90 -0
  85. package/src/tools/skills.ts +101 -0
  86. package/src/tools/tui-tools.ts +87 -0
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.startDashboardServer = startDashboardServer;
37
+ const http = __importStar(require("http"));
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const PORT = 3000;
41
+ const PUBLIC_DIR = path.join(process.cwd(), 'src', 'dashboard', 'public');
42
+ function startDashboardServer() {
43
+ const server = http.createServer((req, res) => {
44
+ const url = req.url || '/';
45
+ // Enable CORS
46
+ res.setHeader('Access-Control-Allow-Origin', '*');
47
+ res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
48
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
49
+ if (req.method === 'OPTIONS') {
50
+ res.writeHead(200);
51
+ res.end();
52
+ return;
53
+ }
54
+ // API endpoints
55
+ if (url === '/api/state') {
56
+ const statePath = path.join(process.cwd(), 'evolution-state.json');
57
+ if (fs.existsSync(statePath)) {
58
+ res.writeHead(200, { 'Content-Type': 'application/json' });
59
+ fs.createReadStream(statePath).pipe(res);
60
+ }
61
+ else {
62
+ res.writeHead(200, { 'Content-Type': 'application/json' });
63
+ res.end(JSON.stringify({
64
+ status: 'idle',
65
+ currentCycle: 0,
66
+ tokensUsed: { input: 0, output: 0, total: 0 },
67
+ history: [],
68
+ message: 'Daemon state not yet initialized.'
69
+ }));
70
+ }
71
+ return;
72
+ }
73
+ if (url === '/api/learnings') {
74
+ const learningsPath = path.join(process.cwd(), 'Learnings.md');
75
+ if (fs.existsSync(learningsPath)) {
76
+ res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
77
+ fs.createReadStream(learningsPath).pipe(res);
78
+ }
79
+ else {
80
+ res.writeHead(404, { 'Content-Type': 'text/plain' });
81
+ res.end('Learnings.md not found.');
82
+ }
83
+ return;
84
+ }
85
+ if (url === '/api/logs') {
86
+ const logPath = path.join(process.cwd(), 'evolution.log');
87
+ if (fs.existsSync(logPath)) {
88
+ res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
89
+ // Return last 200 lines
90
+ fs.readFile(logPath, 'utf-8', (err, data) => {
91
+ if (err) {
92
+ res.writeHead(500);
93
+ res.end('Error reading logs.');
94
+ return;
95
+ }
96
+ const lines = data.split('\n');
97
+ const lastLines = lines.slice(-200).join('\n');
98
+ res.end(lastLines);
99
+ });
100
+ }
101
+ else {
102
+ res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
103
+ res.end('No evolution logs found. Start the evolution daemon to begin logging.');
104
+ }
105
+ return;
106
+ }
107
+ if (url === '/api/research') {
108
+ const researchPath = path.join(process.cwd(), 'research-log.json');
109
+ if (fs.existsSync(researchPath)) {
110
+ res.writeHead(200, { 'Content-Type': 'application/json' });
111
+ fs.createReadStream(researchPath).pipe(res);
112
+ }
113
+ else {
114
+ res.writeHead(200, { 'Content-Type': 'application/json' });
115
+ res.end(JSON.stringify([]));
116
+ }
117
+ return;
118
+ }
119
+ // DGM Archive endpoint — returns population of evolution snapshots
120
+ if (url === '/api/dgm-archive') {
121
+ const archivePath = path.join(process.cwd(), 'dgm-archive.json');
122
+ if (fs.existsSync(archivePath)) {
123
+ res.writeHead(200, { 'Content-Type': 'application/json' });
124
+ fs.createReadStream(archivePath).pipe(res);
125
+ }
126
+ else {
127
+ res.writeHead(200, { 'Content-Type': 'application/json' });
128
+ res.end(JSON.stringify({
129
+ version: '1.0.0',
130
+ entries: [],
131
+ message: 'DGM archive not yet initialized. Run --dgm to start.'
132
+ }));
133
+ }
134
+ return;
135
+ }
136
+ // DGM Fitness endpoint — returns current fitness metrics from state
137
+ if (url === '/api/fitness') {
138
+ const statePath = path.join(process.cwd(), 'evolution-state.json');
139
+ if (fs.existsSync(statePath)) {
140
+ try {
141
+ const state = JSON.parse(fs.readFileSync(statePath, 'utf-8'));
142
+ res.writeHead(200, { 'Content-Type': 'application/json' });
143
+ res.end(JSON.stringify({
144
+ currentFitness: state.currentFitness ?? 0,
145
+ bestFitness: state.bestFitness ?? 0,
146
+ dgmPopulationSize: state.dgmPopulationSize ?? 0,
147
+ dgmBestEntryId: state.dgmBestEntryId ?? null,
148
+ lastUpdated: state.lastUpdated
149
+ }));
150
+ }
151
+ catch {
152
+ res.writeHead(500, { 'Content-Type': 'application/json' });
153
+ res.end(JSON.stringify({ error: 'Failed to read state' }));
154
+ }
155
+ }
156
+ else {
157
+ res.writeHead(200, { 'Content-Type': 'application/json' });
158
+ res.end(JSON.stringify({ currentFitness: 0, bestFitness: 0, dgmPopulationSize: 0, dgmBestEntryId: null }));
159
+ }
160
+ return;
161
+ }
162
+ // Event stream API endpoint
163
+ if (url === '/api/event-stream') {
164
+ const streamPath = path.join(process.cwd(), 'event-stream-history.json');
165
+ if (fs.existsSync(streamPath)) {
166
+ res.writeHead(200, { 'Content-Type': 'application/json' });
167
+ fs.createReadStream(streamPath).pipe(res);
168
+ }
169
+ else {
170
+ res.writeHead(200, { 'Content-Type': 'application/json' });
171
+ res.end(JSON.stringify([]));
172
+ }
173
+ return;
174
+ }
175
+ // Microagents list endpoint
176
+ if (url === '/api/microagents') {
177
+ try {
178
+ const { MicroagentRegistry } = require('../orchestrator/microagent-registry');
179
+ const registry = MicroagentRegistry.getInstance();
180
+ registry.loadMicroagents();
181
+ const agents = registry.getMicroagents();
182
+ res.writeHead(200, { 'Content-Type': 'application/json' });
183
+ res.end(JSON.stringify(agents));
184
+ }
185
+ catch (e) {
186
+ res.writeHead(500, { 'Content-Type': 'application/json' });
187
+ res.end(JSON.stringify({ error: 'Failed to read microagents' }));
188
+ }
189
+ return;
190
+ }
191
+ // Static file serving
192
+ let filePath = path.join(PUBLIC_DIR, url === '/' ? 'index.html' : url);
193
+ // Safety check: ensure file path stays within PUBLIC_DIR
194
+ const resolvedPath = path.resolve(filePath);
195
+ if (!resolvedPath.startsWith(path.resolve(PUBLIC_DIR))) {
196
+ res.writeHead(403, { 'Content-Type': 'text/plain' });
197
+ res.end('Forbidden');
198
+ return;
199
+ }
200
+ const extname = path.extname(filePath);
201
+ let contentType = 'text/html';
202
+ switch (extname) {
203
+ case '.js':
204
+ contentType = 'text/javascript';
205
+ break;
206
+ case '.css':
207
+ contentType = 'text/css';
208
+ break;
209
+ case '.json':
210
+ contentType = 'application/json';
211
+ break;
212
+ case '.png':
213
+ contentType = 'image/png';
214
+ break;
215
+ case '.jpg':
216
+ contentType = 'image/jpg';
217
+ break;
218
+ }
219
+ fs.exists(filePath, (exists) => {
220
+ if (exists) {
221
+ res.writeHead(200, { 'Content-Type': contentType });
222
+ fs.createReadStream(filePath).pipe(res);
223
+ }
224
+ else {
225
+ res.writeHead(404, { 'Content-Type': 'text/plain' });
226
+ res.end('404 Not Found');
227
+ }
228
+ });
229
+ });
230
+ server.listen(PORT, () => {
231
+ console.log(`\n\x1b[36m[Dashboard Server] Web interface running at http://localhost:${PORT}\x1b[0m\n`);
232
+ });
233
+ }
234
+ // Support executing directly if run from CLI
235
+ if (require.main === module) {
236
+ startDashboardServer();
237
+ }
package/dist/index.js ADDED
@@ -0,0 +1,272 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const readline = __importStar(require("readline"));
40
+ const dotenv = __importStar(require("dotenv"));
41
+ const autogenesis_1 = require("./orchestrator/autogenesis");
42
+ const server_1 = require("./dashboard/server");
43
+ const telegram_bot_1 = require("./orchestrator/telegram-bot");
44
+ const task_agent_1 = require("./orchestrator/task-agent");
45
+ // Phase 3 is initialized
46
+ // Load environment variables
47
+ dotenv.config();
48
+ function printHeader() {
49
+ console.log('\x1b[35m%s\x1b[0m', '==================================================');
50
+ console.log('\x1b[36m%s\x1b[0m', ' Closed-Loop Self-Developing Coding CLI ');
51
+ console.log('\x1b[35m%s\x1b[0m', '==================================================');
52
+ console.log('Using endpoint: ' + (process.env.ANTHROPIC_BASE_URL || 'default anthropic'));
53
+ console.log('Main Model: ' + (process.env.ANTHROPIC_MODEL || 'mimo-v2.5-pro[1m]'));
54
+ console.log('Subagent Model: ' + (process.env.CLAUDE_CODE_SUBAGENT_MODEL || 'mimo-v2.5-pro'));
55
+ console.log('Type a task to begin, or type "exit" to quit.\n');
56
+ }
57
+ async function startInteractiveCLI(effort = 'standard', codeactMode = false) {
58
+ printHeader();
59
+ console.log('\x1b[33m%s\x1b[0m', '--- CLAUDE CODE INTERACTIVE MODE (Conversational CLI) ---');
60
+ console.log('Conversation history is maintained. Type "exit" or "quit" to leave.\n');
61
+ const rl = readline.createInterface({
62
+ input: process.stdin,
63
+ output: process.stdout,
64
+ prompt: '\x1b[35mClaudeCode > \x1b[0m'
65
+ });
66
+ const history = [];
67
+ rl.prompt();
68
+ rl.on('line', async (line) => {
69
+ const input = line.trim();
70
+ if (!input) {
71
+ rl.prompt();
72
+ return;
73
+ }
74
+ if (input.toLowerCase() === 'exit' || input.toLowerCase() === 'quit') {
75
+ console.log('Goodbye!');
76
+ process.exit(0);
77
+ }
78
+ rl.pause(); // Pause standard input while agent runs
79
+ try {
80
+ const response = await (0, task_agent_1.runTaskAgent)(input, {
81
+ role: 'coder_codeact', // Coder with command execution tools
82
+ effort,
83
+ history: history
84
+ });
85
+ // Update history
86
+ history.push({ role: 'user', content: input });
87
+ history.push({ role: 'assistant', content: response.result });
88
+ console.log(`\n\x1b[32m[Claude Code Response]:\x1b[0m\n${response.result}\n`);
89
+ }
90
+ catch (err) {
91
+ console.error('\n\x1b[31m[Agent Error]:\x1b[0m', err.message);
92
+ }
93
+ rl.resume();
94
+ rl.prompt();
95
+ }).on('close', () => {
96
+ console.log('\nGoodbye!');
97
+ process.exit(0);
98
+ });
99
+ }
100
+ function setupLogRedirection() {
101
+ const logFile = fs.createWriteStream(path.join(process.cwd(), 'evolution.log'), { flags: 'a' });
102
+ const originalLog = console.log;
103
+ const originalError = console.error;
104
+ console.log = function (...args) {
105
+ originalLog.apply(console, args);
106
+ logFile.write(args.join(' ') + '\n');
107
+ };
108
+ console.error = function (...args) {
109
+ originalError.apply(console, args);
110
+ logFile.write('ERROR: ' + args.join(' ') + '\n');
111
+ };
112
+ }
113
+ async function main() {
114
+ const args = process.argv.slice(2);
115
+ // Parse codeact option
116
+ let codeactMode = false;
117
+ const codeactIdx = args.findIndex(arg => arg === '--codeact' || arg === '--openhands');
118
+ if (codeactIdx !== -1) {
119
+ codeactMode = true;
120
+ args.splice(codeactIdx, 1);
121
+ }
122
+ // Parse effort option
123
+ let effort = 'standard';
124
+ const effortIdx = args.findIndex(arg => arg === '--effort' || arg === '-e');
125
+ if (effortIdx !== -1 && effortIdx + 1 < args.length) {
126
+ const val = args[effortIdx + 1].toLowerCase();
127
+ if (val === 'ultracode' || val === 'max') {
128
+ effort = 'ultracode';
129
+ }
130
+ // Remove --effort and its value from args
131
+ args.splice(effortIdx, 2);
132
+ }
133
+ else {
134
+ const envEffort = process.env.CLAUDE_CODE_EFFORT_LEVEL || 'standard';
135
+ if (envEffort === 'max' || envEffort === 'ultracode') {
136
+ effort = 'ultracode';
137
+ }
138
+ }
139
+ if (args.length > 0) {
140
+ if (args[0] === '--telegram') {
141
+ try {
142
+ console.log(`\n\x1b[33m[Running Standalone Telegram ChatOps Mode]\x1b[0m`);
143
+ (0, telegram_bot_1.startTelegramBot)();
144
+ return;
145
+ }
146
+ catch (err) {
147
+ console.error('\n\x1b[31m[Telegram ChatOps Failed]:\x1b[0m', err.message);
148
+ process.exit(1);
149
+ }
150
+ }
151
+ if (args[0] === '--dashboard') {
152
+ try {
153
+ console.log(`\n\x1b[33m[Running Standalone Dashboard Monitor Mode]\x1b[0m`);
154
+ (0, server_1.startDashboardServer)();
155
+ return;
156
+ }
157
+ catch (err) {
158
+ console.error('\n\x1b[31m[Dashboard Failed]:\x1b[0m', err.message);
159
+ process.exit(1);
160
+ }
161
+ }
162
+ const isContinuous = args.includes('--continuous') || args.includes('-c');
163
+ if (isContinuous) {
164
+ try {
165
+ let cycles = 0; // infinite
166
+ const cyclesIdx = args.indexOf('--cycles');
167
+ if (cyclesIdx !== -1 && cyclesIdx + 1 < args.length) {
168
+ cycles = parseInt(args[cyclesIdx + 1], 10) || 0;
169
+ }
170
+ let tokenBudget = 500000; // default 500k tokens
171
+ const budgetIdx = args.indexOf('--budget-tokens');
172
+ if (budgetIdx !== -1 && budgetIdx + 1 < args.length) {
173
+ tokenBudget = parseInt(args[budgetIdx + 1], 10) || 500000;
174
+ }
175
+ console.log(`\n\x1b[33m[Running Continuous Self-Evolution Daemon Mode]\x1b[0m`);
176
+ console.log(`- Cycle Limit: ${cycles === 0 ? 'Infinite' : cycles}`);
177
+ console.log(`- Token Budget: ${tokenBudget} tokens\n`);
178
+ setupLogRedirection();
179
+ (0, server_1.startDashboardServer)();
180
+ (0, telegram_bot_1.startTelegramBot)();
181
+ const engine = new autogenesis_1.AutogenesisEngine();
182
+ engine.setEffort(effort);
183
+ engine.codeactMode = codeactMode;
184
+ await engine.runContinuousEvolution(cycles, tokenBudget);
185
+ console.log('\n\x1b[32m[Continuous Self-Evolution Daemon Stopped Cleanly]\x1b[0m');
186
+ process.exit(0);
187
+ }
188
+ catch (err) {
189
+ console.error('\n\x1b[31m[Continuous Self-Evolution Daemon Failed]:\x1b[0m', err.message);
190
+ process.exit(1);
191
+ }
192
+ }
193
+ if (args[0] === '--refactor') {
194
+ try {
195
+ console.log(`\n\x1b[33m[Running Autonomous Refactoring Mode]\x1b[0m`);
196
+ const engine = new autogenesis_1.AutogenesisEngine();
197
+ engine.setEffort(effort);
198
+ engine.codeactMode = codeactMode;
199
+ await engine.runAutonomousRefactor();
200
+ console.log('\n\x1b[32m[Autonomous Refactoring Completed]\x1b[0m');
201
+ process.exit(0);
202
+ }
203
+ catch (err) {
204
+ console.error('\n\x1b[31m[Autonomous Refactoring Failed]:\x1b[0m', err.message);
205
+ process.exit(1);
206
+ }
207
+ }
208
+ if (args[0] === '--optimize-prompt') {
209
+ try {
210
+ console.log(`\n\x1b[33m[Running Prompt Optimization Benchmarking Mode]\x1b[0m`);
211
+ const engine = new autogenesis_1.AutogenesisEngine();
212
+ engine.setEffort(effort);
213
+ engine.codeactMode = codeactMode;
214
+ await engine.runPromptOptimization();
215
+ console.log('\n\x1b[32m[Prompt Optimization Completed]\x1b[0m');
216
+ process.exit(0);
217
+ }
218
+ catch (err) {
219
+ console.error('\n\x1b[31m[Prompt Optimization Failed]:\x1b[0m', err.message);
220
+ process.exit(1);
221
+ }
222
+ }
223
+ if (args[0] === '--dgm') {
224
+ try {
225
+ // Parse optional --generations N flag
226
+ let maxGenerations = 5;
227
+ const genIdx = args.indexOf('--generations');
228
+ if (genIdx !== -1 && genIdx + 1 < args.length) {
229
+ maxGenerations = parseInt(args[genIdx + 1], 10) || 5;
230
+ args.splice(genIdx, 2);
231
+ }
232
+ // Task is everything after --dgm flag
233
+ const dgmTask = args.slice(1).join(' ') || 'Improve the codebase using open-ended evolution';
234
+ console.log(`\n\x1b[33m[Running DGM (Darwin Gödel Machine) Evolution Mode]\x1b[0m`);
235
+ console.log(`Task: "${dgmTask}" | Generations: ${maxGenerations}\n`);
236
+ const engine = new autogenesis_1.AutogenesisEngine();
237
+ engine.setEffort(effort);
238
+ engine.codeactMode = codeactMode;
239
+ await engine.runDGMEvolution(dgmTask, maxGenerations);
240
+ console.log('\n\x1b[32m[DGM Evolution Completed]\x1b[0m');
241
+ process.exit(0);
242
+ }
243
+ catch (err) {
244
+ console.error('\n\x1b[31m[DGM Evolution Failed]:\x1b[0m', err.message);
245
+ process.exit(1);
246
+ }
247
+ }
248
+ // Direct command execution
249
+ const task = args.join(' ');
250
+ try {
251
+ console.log(`Running direct task: "${task}" (CodeAct=${codeactMode})`);
252
+ const engine = new autogenesis_1.AutogenesisEngine();
253
+ engine.setEffort(effort);
254
+ engine.codeactMode = codeactMode;
255
+ await engine.runEvolutionStep(task);
256
+ console.log('\n\x1b[32m[Evolution Step Completed]\x1b[0m');
257
+ process.exit(0);
258
+ }
259
+ catch (err) {
260
+ console.error('\n\x1b[31m[Evolution Failed]:\x1b[0m', err.message);
261
+ process.exit(1);
262
+ }
263
+ }
264
+ else {
265
+ // Start interactive session
266
+ await startInteractiveCLI(effort, codeactMode);
267
+ }
268
+ }
269
+ main().catch(err => {
270
+ console.error('Fatal error:', err);
271
+ process.exit(1);
272
+ });
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GATEKEEPER_PROMPT = exports.DEBUGGER_PROMPT = exports.CODEACT_CODER_PROMPT = exports.CODER_PROMPT = exports.ARCHITECT_PROMPT = void 0;
4
+ exports.ARCHITECT_PROMPT = `You are an elite Software Architect and Planner.
5
+ Your primary objective is to receive a coding task and design a comprehensive, step-by-step implementation plan.
6
+
7
+ Do NOT modify any files yourself or run commands. Your job is exclusively to analyze the requirements, inspect the codebase using indexing and search tools, and write a clear, structured markdown plan.
8
+
9
+ For each file to be modified, specify:
10
+ 1. The path to the file.
11
+ 2. The exact function, interface, or line range to change.
12
+ 3. The structural modification required (the blueprint of what needs to be written).
13
+
14
+ Be precise and ensure you have inspected all target files first.`;
15
+ exports.CODER_PROMPT = `You are an elite Coder.
16
+ Your primary objective is to receive an approved Implementation Plan/Blueprint and execute the exact code modifications specified in it.
17
+
18
+ You have access to file writing and editing tools. You do NOT have terminal command execution tools.
19
+ Focus on writing clean, type-safe TypeScript code without placeholders. Follow the coding style guidelines.
20
+ Use editFile instead of writeFile whenever possible to make minimal, precise changes.
21
+
22
+ If the compiler or tests fail, the Diagnostics agent will provide you with the error details. Use that feedback to edit and correct your code.`;
23
+ exports.CODEACT_CODER_PROMPT = `You are an elite Coder operating under the CodeAct (Code Action) paradigm.
24
+ Your primary objective is to execute code modifications and solve tasks by directly writing/editing code files or executing commands.
25
+
26
+ Unlike standard coders, you have access to terminal command execution (runCommand) alongside file writing and editing tools.
27
+ Use code execution (bash/PowerShell, writing Node.js scripts, compiling, and testing) as your main interface to verify and implement the plan.
28
+ Ensure you follow all workspace rules and ensure compiling/testing passes after your code actions.`;
29
+ exports.DEBUGGER_PROMPT = `You are an elite Diagnostics and Debugging Agent.
30
+ Your primary objective is to check the codebase compile and test status after a modification, analyze any failures, and pinpoint the exact issue.
31
+
32
+ You have command execution and file reading tools.
33
+ If a build or test fails, run appropriate commands to get stdout/stderr.
34
+ Locate the file and line number where the compilation error or failing test occurred.
35
+ Write a precise, actionable instruction for the Coder agent to resolve the issue (e.g. "Import is missing", "Type mismatch on parameter X").
36
+ Do NOT edit any source code files yourself.`;
37
+ exports.GATEKEEPER_PROMPT = `You are an elite Gatekeeper and Reviewer Agent.
38
+ Your primary objective is to perform a safety and quality audit on the completed changes before they are committed.
39
+
40
+ Review the git diff, check that the code compiles, and check that all unit tests pass.
41
+ Verify that the changes do not violate safety rules (e.g. no eval, no secrets, no sandbox escapes).
42
+ If any safety rules are violated or regression risk is high, explain the issue clearly.`;