erosolar-cli 2.1.288 → 2.1.289
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/bin/agi-cli.d.ts +15 -0
- package/dist/bin/agi-cli.d.ts.map +1 -0
- package/dist/bin/agi-cli.js +175 -0
- package/dist/bin/agi-cli.js.map +1 -0
- package/dist/capabilities/metaCapability.d.ts +22 -0
- package/dist/capabilities/metaCapability.d.ts.map +1 -0
- package/dist/capabilities/metaCapability.js +33 -0
- package/dist/capabilities/metaCapability.js.map +1 -0
- package/dist/core/agiCore.d.ts +149 -0
- package/dist/core/agiCore.d.ts.map +1 -0
- package/dist/core/agiCore.js +1085 -0
- package/dist/core/agiCore.js.map +1 -0
- package/dist/core/hooks.d.ts.map +1 -1
- package/dist/core/hooks.js +101 -8
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/realAGI.d.ts +113 -0
- package/dist/core/realAGI.d.ts.map +1 -0
- package/dist/core/realAGI.js +899 -0
- package/dist/core/realAGI.js.map +1 -0
- package/dist/core/toolEmbeddings.d.ts +64 -0
- package/dist/core/toolEmbeddings.d.ts.map +1 -0
- package/dist/core/toolEmbeddings.js +471 -0
- package/dist/core/toolEmbeddings.js.map +1 -0
- package/dist/core/unifiedAGI.d.ts +158 -0
- package/dist/core/unifiedAGI.d.ts.map +1 -0
- package/dist/core/unifiedAGI.js +685 -0
- package/dist/core/unifiedAGI.js.map +1 -0
- package/dist/plugins/tools/agi/agiPlugin.d.ts +24 -0
- package/dist/plugins/tools/agi/agiPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/agi/agiPlugin.js +511 -0
- package/dist/plugins/tools/agi/agiPlugin.js.map +1 -0
- package/dist/plugins/tools/meta/metaPlugin.d.ts +12 -0
- package/dist/plugins/tools/meta/metaPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/meta/metaPlugin.js +19 -0
- package/dist/plugins/tools/meta/metaPlugin.js.map +1 -0
- package/dist/plugins/tools/nodeDefaults.d.ts +2 -0
- package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
- package/dist/plugins/tools/nodeDefaults.js +6 -0
- package/dist/plugins/tools/nodeDefaults.js.map +1 -1
- package/dist/plugins/tools/unified/unifiedAGIPlugin.d.ts +25 -0
- package/dist/plugins/tools/unified/unifiedAGIPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/unified/unifiedAGIPlugin.js +479 -0
- package/dist/plugins/tools/unified/unifiedAGIPlugin.js.map +1 -0
- package/dist/skills/skillRepository.d.ts.map +1 -1
- package/dist/skills/skillRepository.js +15 -6
- package/dist/skills/skillRepository.js.map +1 -1
- package/dist/tools/metaTools.d.ts +62 -0
- package/dist/tools/metaTools.d.ts.map +1 -0
- package/dist/tools/metaTools.js +3201 -0
- package/dist/tools/metaTools.js.map +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,1085 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AGI Core - Unified Autonomous General Intelligence for Software Engineering
|
|
3
|
+
*
|
|
4
|
+
* This is the central intelligence module that provides:
|
|
5
|
+
* 1. Unified prompt understanding and routing
|
|
6
|
+
* 2. Real task decomposition and planning
|
|
7
|
+
* 3. Persistent learning and memory
|
|
8
|
+
* 4. Autonomous execution with verification
|
|
9
|
+
*
|
|
10
|
+
* NO SIMULATIONS - All operations execute real tools
|
|
11
|
+
*/
|
|
12
|
+
import * as fs from 'fs';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import { EventEmitter } from 'events';
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// AGI CORE CLASS
|
|
17
|
+
// ============================================================================
|
|
18
|
+
export class AGICore extends EventEmitter {
|
|
19
|
+
context;
|
|
20
|
+
memoryPath;
|
|
21
|
+
constructor(workingDir) {
|
|
22
|
+
super();
|
|
23
|
+
const dir = workingDir || process.cwd();
|
|
24
|
+
this.memoryPath = path.join(dir, '.erosolar', 'agi-memory.json');
|
|
25
|
+
this.context = {
|
|
26
|
+
workingDir: dir,
|
|
27
|
+
sessionId: `agi-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
28
|
+
startTime: Date.now(),
|
|
29
|
+
memory: this.loadMemory(),
|
|
30
|
+
};
|
|
31
|
+
// Analyze project on initialization
|
|
32
|
+
this.analyzeProject();
|
|
33
|
+
}
|
|
34
|
+
// ==========================================================================
|
|
35
|
+
// MEMORY MANAGEMENT - Real Persistent Learning
|
|
36
|
+
// ==========================================================================
|
|
37
|
+
loadMemory() {
|
|
38
|
+
try {
|
|
39
|
+
if (fs.existsSync(this.memoryPath)) {
|
|
40
|
+
const data = fs.readFileSync(this.memoryPath, 'utf-8');
|
|
41
|
+
return JSON.parse(data);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Start fresh if memory is corrupted
|
|
46
|
+
}
|
|
47
|
+
return this.createEmptyMemory();
|
|
48
|
+
}
|
|
49
|
+
createEmptyMemory() {
|
|
50
|
+
return {
|
|
51
|
+
patterns: [],
|
|
52
|
+
recentOps: [],
|
|
53
|
+
projectKnowledge: {
|
|
54
|
+
type: 'unknown',
|
|
55
|
+
buildSystem: null,
|
|
56
|
+
testCommand: null,
|
|
57
|
+
lintCommand: null,
|
|
58
|
+
entryPoints: [],
|
|
59
|
+
dependencies: {},
|
|
60
|
+
lastAnalyzed: 0,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
saveMemory() {
|
|
65
|
+
try {
|
|
66
|
+
const dir = path.dirname(this.memoryPath);
|
|
67
|
+
if (!fs.existsSync(dir)) {
|
|
68
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
69
|
+
}
|
|
70
|
+
fs.writeFileSync(this.memoryPath, JSON.stringify(this.context.memory, null, 2));
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
this.emit('warning', `Failed to save memory: ${error}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Learn from a successful operation
|
|
78
|
+
*/
|
|
79
|
+
learnFromSuccess(prompt, approach, tools) {
|
|
80
|
+
const existingPattern = this.context.memory.patterns.find(p => this.normalizePrompt(p.trigger) === this.normalizePrompt(prompt));
|
|
81
|
+
if (existingPattern) {
|
|
82
|
+
existingPattern.successCount++;
|
|
83
|
+
existingPattern.lastUsed = Date.now();
|
|
84
|
+
existingPattern.successfulApproach = approach;
|
|
85
|
+
existingPattern.tools = tools;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.context.memory.patterns.push({
|
|
89
|
+
id: `pattern-${Date.now()}`,
|
|
90
|
+
trigger: prompt,
|
|
91
|
+
successfulApproach: approach,
|
|
92
|
+
tools,
|
|
93
|
+
successCount: 1,
|
|
94
|
+
lastUsed: Date.now(),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// Keep only most useful patterns (limit to 100)
|
|
98
|
+
this.context.memory.patterns = this.context.memory.patterns
|
|
99
|
+
.sort((a, b) => (b.successCount * 0.7 + (b.lastUsed - a.lastUsed) / 86400000 * 0.3) -
|
|
100
|
+
(a.successCount * 0.7 + (a.lastUsed - b.lastUsed) / 86400000 * 0.3))
|
|
101
|
+
.slice(0, 100);
|
|
102
|
+
this.saveMemory();
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Record an operation for context
|
|
106
|
+
*/
|
|
107
|
+
recordOperation(op) {
|
|
108
|
+
this.context.memory.recentOps.unshift(op);
|
|
109
|
+
// Keep last 50 operations
|
|
110
|
+
this.context.memory.recentOps = this.context.memory.recentOps.slice(0, 50);
|
|
111
|
+
this.saveMemory();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get learned approach for similar prompts
|
|
115
|
+
*/
|
|
116
|
+
getLearnedApproach(prompt) {
|
|
117
|
+
const normalized = this.normalizePrompt(prompt);
|
|
118
|
+
return this.context.memory.patterns.find(p => this.normalizePrompt(p.trigger) === normalized ||
|
|
119
|
+
this.promptSimilarity(p.trigger, prompt) > 0.7) || null;
|
|
120
|
+
}
|
|
121
|
+
normalizePrompt(prompt) {
|
|
122
|
+
return prompt.toLowerCase().trim().replace(/[^\w\s]/g, '');
|
|
123
|
+
}
|
|
124
|
+
promptSimilarity(a, b) {
|
|
125
|
+
const wordsA = new Set(this.normalizePrompt(a).split(/\s+/));
|
|
126
|
+
const wordsB = new Set(this.normalizePrompt(b).split(/\s+/));
|
|
127
|
+
const intersection = new Set([...wordsA].filter(x => wordsB.has(x)));
|
|
128
|
+
const union = new Set([...wordsA, ...wordsB]);
|
|
129
|
+
return intersection.size / union.size;
|
|
130
|
+
}
|
|
131
|
+
// ==========================================================================
|
|
132
|
+
// PROJECT ANALYSIS - Understand the Codebase
|
|
133
|
+
// ==========================================================================
|
|
134
|
+
analyzeProject() {
|
|
135
|
+
const knowledge = this.context.memory.projectKnowledge;
|
|
136
|
+
const dir = this.context.workingDir;
|
|
137
|
+
// Check for package.json (Node.js)
|
|
138
|
+
const packageJsonPath = path.join(dir, 'package.json');
|
|
139
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
140
|
+
try {
|
|
141
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
142
|
+
knowledge.type = 'node';
|
|
143
|
+
knowledge.dependencies = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
144
|
+
if (pkg.scripts) {
|
|
145
|
+
knowledge.testCommand = pkg.scripts.test ? 'npm test' : null;
|
|
146
|
+
knowledge.lintCommand = pkg.scripts.lint ? 'npm run lint' : null;
|
|
147
|
+
knowledge.buildSystem = pkg.scripts.build ? 'npm run build' : null;
|
|
148
|
+
}
|
|
149
|
+
if (pkg.main) {
|
|
150
|
+
knowledge.entryPoints.push(pkg.main);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
// Ignore parse errors
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Check for pyproject.toml or setup.py (Python)
|
|
158
|
+
if (fs.existsSync(path.join(dir, 'pyproject.toml')) ||
|
|
159
|
+
fs.existsSync(path.join(dir, 'setup.py'))) {
|
|
160
|
+
knowledge.type = 'python';
|
|
161
|
+
knowledge.testCommand = 'pytest';
|
|
162
|
+
knowledge.lintCommand = 'ruff check .';
|
|
163
|
+
}
|
|
164
|
+
// Check for Cargo.toml (Rust)
|
|
165
|
+
if (fs.existsSync(path.join(dir, 'Cargo.toml'))) {
|
|
166
|
+
knowledge.type = 'rust';
|
|
167
|
+
knowledge.testCommand = 'cargo test';
|
|
168
|
+
knowledge.lintCommand = 'cargo clippy';
|
|
169
|
+
knowledge.buildSystem = 'cargo build';
|
|
170
|
+
}
|
|
171
|
+
// Check for go.mod (Go)
|
|
172
|
+
if (fs.existsSync(path.join(dir, 'go.mod'))) {
|
|
173
|
+
knowledge.type = 'go';
|
|
174
|
+
knowledge.testCommand = 'go test ./...';
|
|
175
|
+
knowledge.lintCommand = 'golangci-lint run';
|
|
176
|
+
knowledge.buildSystem = 'go build';
|
|
177
|
+
}
|
|
178
|
+
knowledge.lastAnalyzed = Date.now();
|
|
179
|
+
this.saveMemory();
|
|
180
|
+
}
|
|
181
|
+
// ==========================================================================
|
|
182
|
+
// PROMPT UNDERSTANDING - Parse and Interpret User Requests
|
|
183
|
+
// ==========================================================================
|
|
184
|
+
/**
|
|
185
|
+
* Analyze a user prompt and produce a comprehensive execution plan
|
|
186
|
+
*/
|
|
187
|
+
analyzePrompt(prompt) {
|
|
188
|
+
const lower = prompt.toLowerCase().trim();
|
|
189
|
+
// Check for learned patterns first
|
|
190
|
+
const learned = this.getLearnedApproach(prompt);
|
|
191
|
+
if (learned && learned.successCount >= 2) {
|
|
192
|
+
return this.createFromLearnedPattern(prompt, learned);
|
|
193
|
+
}
|
|
194
|
+
// Determine intent
|
|
195
|
+
const intent = this.determineIntent(lower);
|
|
196
|
+
const category = this.determineCategory(intent);
|
|
197
|
+
// Generate tasks based on intent
|
|
198
|
+
const tasks = this.generateTasks(prompt, intent);
|
|
199
|
+
// Check for ambiguity
|
|
200
|
+
const clarificationNeeded = this.checkAmbiguity(prompt, intent);
|
|
201
|
+
return {
|
|
202
|
+
originalPrompt: prompt,
|
|
203
|
+
interpretation: this.generateInterpretation(prompt, intent),
|
|
204
|
+
intent,
|
|
205
|
+
category,
|
|
206
|
+
confidence: clarificationNeeded.length === 0 ? 0.9 : 0.6,
|
|
207
|
+
tasks,
|
|
208
|
+
clarificationNeeded,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
determineIntent(lower) {
|
|
212
|
+
// Order matters! More specific patterns first.
|
|
213
|
+
// =========================================================================
|
|
214
|
+
// NON-SWE DOMAINS (check first for domain-specific keywords)
|
|
215
|
+
// =========================================================================
|
|
216
|
+
// Legal/Litigation (sue, lawsuit, court, legal action)
|
|
217
|
+
if (/\bsue\b|lawsuit|litigation|legal\s+action|\bcourt\b|attorney|lawyer|complaint|motion|brief/i.test(lower)) {
|
|
218
|
+
return 'legal_research';
|
|
219
|
+
}
|
|
220
|
+
// Financial/Accounting (accounting, bookkeeping, tax, financial)
|
|
221
|
+
if (/accounting|bookkeeping|financ|tax\b|ledger|balance\s*sheet|invoice|payroll|budget|forecast/i.test(lower)) {
|
|
222
|
+
return 'financial_analysis';
|
|
223
|
+
}
|
|
224
|
+
// Scientific Research (cure, research, experiment, hypothesis, study)
|
|
225
|
+
if (/\bcure\b|research|experiment|hypothesis|scientific|laboratory|clinical|biomedical|genome|molecular/i.test(lower)) {
|
|
226
|
+
return 'research';
|
|
227
|
+
}
|
|
228
|
+
// Data Analysis/Science (data analysis, ML, statistics, visualization)
|
|
229
|
+
if (/data\s+(?:analysis|science|engineer)|statistic|machine\s+learning|\bml\b|\bai\b|neural|dataset/i.test(lower)) {
|
|
230
|
+
return 'data_analysis';
|
|
231
|
+
}
|
|
232
|
+
// Engineering/Science (engineering, physics, chemistry, simulation)
|
|
233
|
+
if (/engineer(?:ing)?|physic|chemist|simulat|cad\b|finite\s+element|signal\s+process/i.test(lower)) {
|
|
234
|
+
return 'scientific_computing';
|
|
235
|
+
}
|
|
236
|
+
// Business Analysis (business, strategy, market, competitor)
|
|
237
|
+
if (/business|strateg|\bmarket\b|competitor|swot|business\s+plan/i.test(lower)) {
|
|
238
|
+
return 'business_analysis';
|
|
239
|
+
}
|
|
240
|
+
// Automation/Operations (automate, workflow, schedule, cron)
|
|
241
|
+
// Note: "pipeline" without "CI" or "CD" context - those go to setup
|
|
242
|
+
if (/\bautomat|\bworkflow|\bschedule|\bcron\b|batch\s+process/i.test(lower)) {
|
|
243
|
+
return 'automate';
|
|
244
|
+
}
|
|
245
|
+
// Data pipeline (ETL, data pipeline) - separate from CI/CD
|
|
246
|
+
if (/(?:data|etl)\s+pipeline/i.test(lower)) {
|
|
247
|
+
return 'automate';
|
|
248
|
+
}
|
|
249
|
+
// Monitoring (monitor, alert, dashboard, metrics, observability)
|
|
250
|
+
if (/\bmonitor|alert|dashboard|metric|observab|logging|trace/i.test(lower)) {
|
|
251
|
+
return 'monitor';
|
|
252
|
+
}
|
|
253
|
+
// =========================================================================
|
|
254
|
+
// SOFTWARE ENGINEERING DOMAINS
|
|
255
|
+
// =========================================================================
|
|
256
|
+
// Security audit (check before general 'audit')
|
|
257
|
+
if (/security|vulnerab|pentest|secure/i.test(lower)) {
|
|
258
|
+
return 'security_audit';
|
|
259
|
+
}
|
|
260
|
+
// Optimization (check before 'improve' which could be refactor)
|
|
261
|
+
if (/optim|faster|performance|speed\s*up|slow/i.test(lower)) {
|
|
262
|
+
return 'optimize';
|
|
263
|
+
}
|
|
264
|
+
// Explanation (check before 'document' - "explain" is for understanding, not writing docs)
|
|
265
|
+
if (/\bwhat\b|\bhow\b.*work|\bwhy\b|\bexplain\b|\bunderstand/i.test(lower)) {
|
|
266
|
+
return 'explain';
|
|
267
|
+
}
|
|
268
|
+
// Bug fixing
|
|
269
|
+
if (/fix|bug|error|issue|broken|crash|fail/i.test(lower)) {
|
|
270
|
+
return 'fix_bugs';
|
|
271
|
+
}
|
|
272
|
+
// Setup/Configuration (check before 'add' - configure is setup, not adding)
|
|
273
|
+
if (/setup|install|configure|init/i.test(lower)) {
|
|
274
|
+
return 'setup';
|
|
275
|
+
}
|
|
276
|
+
// Feature addition
|
|
277
|
+
if (/add|create|implement|build|new|feature/i.test(lower)) {
|
|
278
|
+
return 'add_feature';
|
|
279
|
+
}
|
|
280
|
+
// Refactoring (check 'improve' here after optimization is handled)
|
|
281
|
+
if (/refactor|clean|improve|reorganize|restructure/i.test(lower)) {
|
|
282
|
+
return 'refactor';
|
|
283
|
+
}
|
|
284
|
+
// Testing
|
|
285
|
+
if (/test|spec|coverage|verify/i.test(lower)) {
|
|
286
|
+
return 'test';
|
|
287
|
+
}
|
|
288
|
+
// Documentation
|
|
289
|
+
if (/document|readme|comment|doc\b/i.test(lower)) {
|
|
290
|
+
return 'document';
|
|
291
|
+
}
|
|
292
|
+
// Deployment
|
|
293
|
+
if (/deploy|release|publish|ship/i.test(lower)) {
|
|
294
|
+
return 'deploy';
|
|
295
|
+
}
|
|
296
|
+
// Analysis (general analysis, after security)
|
|
297
|
+
if (/analyze|review|audit|check|inspect/i.test(lower)) {
|
|
298
|
+
return 'analyze';
|
|
299
|
+
}
|
|
300
|
+
// Migration
|
|
301
|
+
if (/migrate|upgrade|update|version/i.test(lower)) {
|
|
302
|
+
return 'migrate';
|
|
303
|
+
}
|
|
304
|
+
return 'generic_task';
|
|
305
|
+
}
|
|
306
|
+
determineCategory(intent) {
|
|
307
|
+
const mapping = {
|
|
308
|
+
// Software Engineering
|
|
309
|
+
'fix_bugs': 'code_modification',
|
|
310
|
+
'add_feature': 'code_modification',
|
|
311
|
+
'refactor': 'code_modification',
|
|
312
|
+
'test': 'testing',
|
|
313
|
+
'document': 'documentation',
|
|
314
|
+
'deploy': 'infrastructure',
|
|
315
|
+
'analyze': 'code_analysis',
|
|
316
|
+
'explain': 'research',
|
|
317
|
+
'optimize': 'code_modification',
|
|
318
|
+
'security_audit': 'code_analysis',
|
|
319
|
+
'setup': 'infrastructure',
|
|
320
|
+
'migrate': 'code_modification',
|
|
321
|
+
// Research & Science
|
|
322
|
+
'research': 'scientific',
|
|
323
|
+
'data_analysis': 'scientific',
|
|
324
|
+
'scientific_computing': 'scientific',
|
|
325
|
+
// Business & Legal
|
|
326
|
+
'legal_research': 'legal',
|
|
327
|
+
'business_analysis': 'business',
|
|
328
|
+
'financial_analysis': 'financial',
|
|
329
|
+
// Automation & Operations
|
|
330
|
+
'automate': 'automation',
|
|
331
|
+
'monitor': 'operations',
|
|
332
|
+
// Generic
|
|
333
|
+
'generic_task': 'automation',
|
|
334
|
+
};
|
|
335
|
+
return mapping[intent];
|
|
336
|
+
}
|
|
337
|
+
generateInterpretation(prompt, intent) {
|
|
338
|
+
const interpretations = {
|
|
339
|
+
// Software Engineering
|
|
340
|
+
'fix_bugs': `Identify and fix bugs/errors in the codebase based on: "${prompt}"`,
|
|
341
|
+
'add_feature': `Implement new functionality: "${prompt}"`,
|
|
342
|
+
'refactor': `Improve code structure and quality: "${prompt}"`,
|
|
343
|
+
'test': `Create or run tests: "${prompt}"`,
|
|
344
|
+
'document': `Create or update documentation: "${prompt}"`,
|
|
345
|
+
'deploy': `Prepare and execute deployment: "${prompt}"`,
|
|
346
|
+
'analyze': `Analyze and review: "${prompt}"`,
|
|
347
|
+
'explain': `Explain and clarify: "${prompt}"`,
|
|
348
|
+
'optimize': `Improve performance: "${prompt}"`,
|
|
349
|
+
'security_audit': `Security review and hardening: "${prompt}"`,
|
|
350
|
+
'setup': `Set up and configure: "${prompt}"`,
|
|
351
|
+
'migrate': `Migrate or upgrade: "${prompt}"`,
|
|
352
|
+
// Research & Science
|
|
353
|
+
'research': `Build research tools and analysis pipeline for: "${prompt}"`,
|
|
354
|
+
'data_analysis': `Create data analysis pipeline and visualizations for: "${prompt}"`,
|
|
355
|
+
'scientific_computing': `Build scientific computing tools for: "${prompt}"`,
|
|
356
|
+
// Business & Legal
|
|
357
|
+
'legal_research': `Legal research and document automation for: "${prompt}"`,
|
|
358
|
+
'business_analysis': `Business analysis and strategy tools for: "${prompt}"`,
|
|
359
|
+
'financial_analysis': `Financial analysis and reporting tools for: "${prompt}"`,
|
|
360
|
+
// Automation & Operations
|
|
361
|
+
'automate': `Build automation workflow for: "${prompt}"`,
|
|
362
|
+
'monitor': `Create monitoring and alerting system for: "${prompt}"`,
|
|
363
|
+
// Generic
|
|
364
|
+
'generic_task': `Execute task: "${prompt}"`,
|
|
365
|
+
};
|
|
366
|
+
return interpretations[intent];
|
|
367
|
+
}
|
|
368
|
+
generateTasks(prompt, intent) {
|
|
369
|
+
const tasks = [];
|
|
370
|
+
const knowledge = this.context.memory.projectKnowledge;
|
|
371
|
+
switch (intent) {
|
|
372
|
+
case 'fix_bugs':
|
|
373
|
+
// First: analyze the codebase
|
|
374
|
+
tasks.push({
|
|
375
|
+
id: 'analyze-errors',
|
|
376
|
+
description: 'Run type checker and linter to identify issues',
|
|
377
|
+
category: 'execution',
|
|
378
|
+
tools: ['Bash'],
|
|
379
|
+
dependencies: [],
|
|
380
|
+
status: 'pending',
|
|
381
|
+
});
|
|
382
|
+
if (knowledge.testCommand) {
|
|
383
|
+
tasks.push({
|
|
384
|
+
id: 'run-tests',
|
|
385
|
+
description: 'Run test suite to find failing tests',
|
|
386
|
+
category: 'execution',
|
|
387
|
+
tools: ['Bash'],
|
|
388
|
+
dependencies: [],
|
|
389
|
+
status: 'pending',
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
tasks.push({
|
|
393
|
+
id: 'search-issues',
|
|
394
|
+
description: 'Search for TODO/FIXME comments and known issues',
|
|
395
|
+
category: 'search',
|
|
396
|
+
tools: ['Grep'],
|
|
397
|
+
dependencies: [],
|
|
398
|
+
status: 'pending',
|
|
399
|
+
});
|
|
400
|
+
tasks.push({
|
|
401
|
+
id: 'analyze-findings',
|
|
402
|
+
description: 'Analyze all findings and prioritize fixes',
|
|
403
|
+
category: 'analysis',
|
|
404
|
+
tools: ['Read'],
|
|
405
|
+
dependencies: ['analyze-errors', 'search-issues'],
|
|
406
|
+
status: 'pending',
|
|
407
|
+
});
|
|
408
|
+
tasks.push({
|
|
409
|
+
id: 'fix-issues',
|
|
410
|
+
description: 'Apply fixes to identified issues',
|
|
411
|
+
category: 'modification',
|
|
412
|
+
tools: ['Edit'],
|
|
413
|
+
dependencies: ['analyze-findings'],
|
|
414
|
+
status: 'pending',
|
|
415
|
+
});
|
|
416
|
+
tasks.push({
|
|
417
|
+
id: 'verify-fixes',
|
|
418
|
+
description: 'Verify fixes by re-running checks',
|
|
419
|
+
category: 'verification',
|
|
420
|
+
tools: ['Bash'],
|
|
421
|
+
dependencies: ['fix-issues'],
|
|
422
|
+
status: 'pending',
|
|
423
|
+
});
|
|
424
|
+
break;
|
|
425
|
+
case 'add_feature':
|
|
426
|
+
tasks.push({
|
|
427
|
+
id: 'understand-codebase',
|
|
428
|
+
description: 'Analyze existing code structure',
|
|
429
|
+
category: 'analysis',
|
|
430
|
+
tools: ['Glob', 'Read'],
|
|
431
|
+
dependencies: [],
|
|
432
|
+
status: 'pending',
|
|
433
|
+
});
|
|
434
|
+
tasks.push({
|
|
435
|
+
id: 'plan-implementation',
|
|
436
|
+
description: 'Plan the implementation approach',
|
|
437
|
+
category: 'analysis',
|
|
438
|
+
tools: ['Read'],
|
|
439
|
+
dependencies: ['understand-codebase'],
|
|
440
|
+
status: 'pending',
|
|
441
|
+
});
|
|
442
|
+
tasks.push({
|
|
443
|
+
id: 'implement-feature',
|
|
444
|
+
description: 'Write the feature code',
|
|
445
|
+
category: 'modification',
|
|
446
|
+
tools: ['Edit', 'Write'],
|
|
447
|
+
dependencies: ['plan-implementation'],
|
|
448
|
+
status: 'pending',
|
|
449
|
+
});
|
|
450
|
+
tasks.push({
|
|
451
|
+
id: 'add-tests',
|
|
452
|
+
description: 'Add tests for the new feature',
|
|
453
|
+
category: 'modification',
|
|
454
|
+
tools: ['Edit', 'Write'],
|
|
455
|
+
dependencies: ['implement-feature'],
|
|
456
|
+
status: 'pending',
|
|
457
|
+
});
|
|
458
|
+
tasks.push({
|
|
459
|
+
id: 'verify-feature',
|
|
460
|
+
description: 'Run tests and verify feature works',
|
|
461
|
+
category: 'verification',
|
|
462
|
+
tools: ['Bash'],
|
|
463
|
+
dependencies: ['add-tests'],
|
|
464
|
+
status: 'pending',
|
|
465
|
+
});
|
|
466
|
+
break;
|
|
467
|
+
case 'analyze':
|
|
468
|
+
case 'explain':
|
|
469
|
+
tasks.push({
|
|
470
|
+
id: 'explore-structure',
|
|
471
|
+
description: 'Explore project structure',
|
|
472
|
+
category: 'search',
|
|
473
|
+
tools: ['Glob', 'Bash'],
|
|
474
|
+
dependencies: [],
|
|
475
|
+
status: 'pending',
|
|
476
|
+
});
|
|
477
|
+
tasks.push({
|
|
478
|
+
id: 'read-key-files',
|
|
479
|
+
description: 'Read and understand key files',
|
|
480
|
+
category: 'analysis',
|
|
481
|
+
tools: ['Read'],
|
|
482
|
+
dependencies: ['explore-structure'],
|
|
483
|
+
status: 'pending',
|
|
484
|
+
});
|
|
485
|
+
tasks.push({
|
|
486
|
+
id: 'summarize-findings',
|
|
487
|
+
description: 'Summarize and explain findings',
|
|
488
|
+
category: 'communication',
|
|
489
|
+
tools: [],
|
|
490
|
+
dependencies: ['read-key-files'],
|
|
491
|
+
status: 'pending',
|
|
492
|
+
});
|
|
493
|
+
break;
|
|
494
|
+
case 'test':
|
|
495
|
+
if (knowledge.testCommand) {
|
|
496
|
+
tasks.push({
|
|
497
|
+
id: 'run-existing-tests',
|
|
498
|
+
description: 'Run existing test suite',
|
|
499
|
+
category: 'execution',
|
|
500
|
+
tools: ['Bash'],
|
|
501
|
+
dependencies: [],
|
|
502
|
+
status: 'pending',
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
tasks.push({
|
|
506
|
+
id: 'analyze-coverage',
|
|
507
|
+
description: 'Analyze test coverage',
|
|
508
|
+
category: 'analysis',
|
|
509
|
+
tools: ['Bash', 'Read'],
|
|
510
|
+
dependencies: [],
|
|
511
|
+
status: 'pending',
|
|
512
|
+
});
|
|
513
|
+
tasks.push({
|
|
514
|
+
id: 'identify-gaps',
|
|
515
|
+
description: 'Identify testing gaps',
|
|
516
|
+
category: 'analysis',
|
|
517
|
+
tools: ['Grep', 'Read'],
|
|
518
|
+
dependencies: ['analyze-coverage'],
|
|
519
|
+
status: 'pending',
|
|
520
|
+
});
|
|
521
|
+
tasks.push({
|
|
522
|
+
id: 'write-tests',
|
|
523
|
+
description: 'Write new tests for uncovered code',
|
|
524
|
+
category: 'modification',
|
|
525
|
+
tools: ['Edit', 'Write'],
|
|
526
|
+
dependencies: ['identify-gaps'],
|
|
527
|
+
status: 'pending',
|
|
528
|
+
});
|
|
529
|
+
break;
|
|
530
|
+
case 'security_audit':
|
|
531
|
+
tasks.push({
|
|
532
|
+
id: 'dependency-audit',
|
|
533
|
+
description: 'Audit dependencies for known vulnerabilities',
|
|
534
|
+
category: 'execution',
|
|
535
|
+
tools: ['Bash'],
|
|
536
|
+
dependencies: [],
|
|
537
|
+
status: 'pending',
|
|
538
|
+
});
|
|
539
|
+
tasks.push({
|
|
540
|
+
id: 'code-patterns',
|
|
541
|
+
description: 'Search for insecure code patterns',
|
|
542
|
+
category: 'search',
|
|
543
|
+
tools: ['Grep'],
|
|
544
|
+
dependencies: [],
|
|
545
|
+
status: 'pending',
|
|
546
|
+
});
|
|
547
|
+
tasks.push({
|
|
548
|
+
id: 'analyze-security',
|
|
549
|
+
description: 'Analyze security findings',
|
|
550
|
+
category: 'analysis',
|
|
551
|
+
tools: ['Read'],
|
|
552
|
+
dependencies: ['dependency-audit', 'code-patterns'],
|
|
553
|
+
status: 'pending',
|
|
554
|
+
});
|
|
555
|
+
tasks.push({
|
|
556
|
+
id: 'report-findings',
|
|
557
|
+
description: 'Report security findings with recommendations',
|
|
558
|
+
category: 'communication',
|
|
559
|
+
tools: [],
|
|
560
|
+
dependencies: ['analyze-security'],
|
|
561
|
+
status: 'pending',
|
|
562
|
+
});
|
|
563
|
+
break;
|
|
564
|
+
// =====================================================================
|
|
565
|
+
// NON-SWE DOMAIN TASKS
|
|
566
|
+
// =====================================================================
|
|
567
|
+
case 'research':
|
|
568
|
+
// Scientific/Medical Research (e.g., "cure cancer")
|
|
569
|
+
tasks.push({
|
|
570
|
+
id: 'define-scope',
|
|
571
|
+
description: 'Define research scope and objectives',
|
|
572
|
+
category: 'analysis',
|
|
573
|
+
tools: ['Read'],
|
|
574
|
+
dependencies: [],
|
|
575
|
+
status: 'pending',
|
|
576
|
+
});
|
|
577
|
+
tasks.push({
|
|
578
|
+
id: 'gather-data',
|
|
579
|
+
description: 'Gather relevant data and research materials',
|
|
580
|
+
category: 'research',
|
|
581
|
+
tools: ['Bash', 'Read'],
|
|
582
|
+
dependencies: ['define-scope'],
|
|
583
|
+
status: 'pending',
|
|
584
|
+
});
|
|
585
|
+
tasks.push({
|
|
586
|
+
id: 'build-pipeline',
|
|
587
|
+
description: 'Build data processing and analysis pipeline',
|
|
588
|
+
category: 'generation',
|
|
589
|
+
tools: ['Edit', 'Write', 'Bash'],
|
|
590
|
+
dependencies: ['gather-data'],
|
|
591
|
+
status: 'pending',
|
|
592
|
+
});
|
|
593
|
+
tasks.push({
|
|
594
|
+
id: 'implement-analysis',
|
|
595
|
+
description: 'Implement analysis algorithms and models',
|
|
596
|
+
category: 'generation',
|
|
597
|
+
tools: ['Edit', 'Write'],
|
|
598
|
+
dependencies: ['build-pipeline'],
|
|
599
|
+
status: 'pending',
|
|
600
|
+
});
|
|
601
|
+
tasks.push({
|
|
602
|
+
id: 'generate-report',
|
|
603
|
+
description: 'Generate analysis report with findings',
|
|
604
|
+
category: 'communication',
|
|
605
|
+
tools: ['Edit', 'Write'],
|
|
606
|
+
dependencies: ['implement-analysis'],
|
|
607
|
+
status: 'pending',
|
|
608
|
+
});
|
|
609
|
+
break;
|
|
610
|
+
case 'data_analysis':
|
|
611
|
+
tasks.push({
|
|
612
|
+
id: 'explore-data',
|
|
613
|
+
description: 'Explore and understand the data',
|
|
614
|
+
category: 'analysis',
|
|
615
|
+
tools: ['Read', 'Bash'],
|
|
616
|
+
dependencies: [],
|
|
617
|
+
status: 'pending',
|
|
618
|
+
});
|
|
619
|
+
tasks.push({
|
|
620
|
+
id: 'clean-data',
|
|
621
|
+
description: 'Clean and preprocess data',
|
|
622
|
+
category: 'execution',
|
|
623
|
+
tools: ['Bash', 'Edit'],
|
|
624
|
+
dependencies: ['explore-data'],
|
|
625
|
+
status: 'pending',
|
|
626
|
+
});
|
|
627
|
+
tasks.push({
|
|
628
|
+
id: 'analyze-patterns',
|
|
629
|
+
description: 'Analyze patterns and statistics',
|
|
630
|
+
category: 'computation',
|
|
631
|
+
tools: ['Bash', 'Edit'],
|
|
632
|
+
dependencies: ['clean-data'],
|
|
633
|
+
status: 'pending',
|
|
634
|
+
});
|
|
635
|
+
tasks.push({
|
|
636
|
+
id: 'create-visualizations',
|
|
637
|
+
description: 'Create visualizations and charts',
|
|
638
|
+
category: 'generation',
|
|
639
|
+
tools: ['Edit', 'Bash'],
|
|
640
|
+
dependencies: ['analyze-patterns'],
|
|
641
|
+
status: 'pending',
|
|
642
|
+
});
|
|
643
|
+
tasks.push({
|
|
644
|
+
id: 'summarize-insights',
|
|
645
|
+
description: 'Summarize insights and recommendations',
|
|
646
|
+
category: 'communication',
|
|
647
|
+
tools: ['Edit'],
|
|
648
|
+
dependencies: ['create-visualizations'],
|
|
649
|
+
status: 'pending',
|
|
650
|
+
});
|
|
651
|
+
break;
|
|
652
|
+
case 'scientific_computing':
|
|
653
|
+
tasks.push({
|
|
654
|
+
id: 'define-problem',
|
|
655
|
+
description: 'Define the scientific problem and requirements',
|
|
656
|
+
category: 'analysis',
|
|
657
|
+
tools: ['Read'],
|
|
658
|
+
dependencies: [],
|
|
659
|
+
status: 'pending',
|
|
660
|
+
});
|
|
661
|
+
tasks.push({
|
|
662
|
+
id: 'design-algorithm',
|
|
663
|
+
description: 'Design computational algorithm',
|
|
664
|
+
category: 'analysis',
|
|
665
|
+
tools: ['Read', 'Edit'],
|
|
666
|
+
dependencies: ['define-problem'],
|
|
667
|
+
status: 'pending',
|
|
668
|
+
});
|
|
669
|
+
tasks.push({
|
|
670
|
+
id: 'implement-computation',
|
|
671
|
+
description: 'Implement computational solution',
|
|
672
|
+
category: 'generation',
|
|
673
|
+
tools: ['Edit', 'Write'],
|
|
674
|
+
dependencies: ['design-algorithm'],
|
|
675
|
+
status: 'pending',
|
|
676
|
+
});
|
|
677
|
+
tasks.push({
|
|
678
|
+
id: 'validate-results',
|
|
679
|
+
description: 'Validate and verify results',
|
|
680
|
+
category: 'verification',
|
|
681
|
+
tools: ['Bash', 'Read'],
|
|
682
|
+
dependencies: ['implement-computation'],
|
|
683
|
+
status: 'pending',
|
|
684
|
+
});
|
|
685
|
+
break;
|
|
686
|
+
case 'legal_research':
|
|
687
|
+
// Legal/Litigation (e.g., "sue google in fed court")
|
|
688
|
+
tasks.push({
|
|
689
|
+
id: 'identify-claims',
|
|
690
|
+
description: 'Identify legal claims and causes of action',
|
|
691
|
+
category: 'research',
|
|
692
|
+
tools: ['Read'],
|
|
693
|
+
dependencies: [],
|
|
694
|
+
status: 'pending',
|
|
695
|
+
});
|
|
696
|
+
tasks.push({
|
|
697
|
+
id: 'research-law',
|
|
698
|
+
description: 'Research applicable laws and precedents',
|
|
699
|
+
category: 'research',
|
|
700
|
+
tools: ['Read', 'Bash'],
|
|
701
|
+
dependencies: ['identify-claims'],
|
|
702
|
+
status: 'pending',
|
|
703
|
+
});
|
|
704
|
+
tasks.push({
|
|
705
|
+
id: 'gather-evidence',
|
|
706
|
+
description: 'Gather and organize evidence',
|
|
707
|
+
category: 'search',
|
|
708
|
+
tools: ['Glob', 'Grep', 'Read'],
|
|
709
|
+
dependencies: [],
|
|
710
|
+
status: 'pending',
|
|
711
|
+
});
|
|
712
|
+
tasks.push({
|
|
713
|
+
id: 'draft-documents',
|
|
714
|
+
description: 'Draft legal documents (complaint, motion, brief)',
|
|
715
|
+
category: 'generation',
|
|
716
|
+
tools: ['Edit', 'Write'],
|
|
717
|
+
dependencies: ['research-law', 'gather-evidence'],
|
|
718
|
+
status: 'pending',
|
|
719
|
+
});
|
|
720
|
+
tasks.push({
|
|
721
|
+
id: 'prepare-filing',
|
|
722
|
+
description: 'Prepare filing package and procedures',
|
|
723
|
+
category: 'generation',
|
|
724
|
+
tools: ['Edit', 'Write'],
|
|
725
|
+
dependencies: ['draft-documents'],
|
|
726
|
+
status: 'pending',
|
|
727
|
+
});
|
|
728
|
+
break;
|
|
729
|
+
case 'business_analysis':
|
|
730
|
+
tasks.push({
|
|
731
|
+
id: 'gather-business-data',
|
|
732
|
+
description: 'Gather business data and market information',
|
|
733
|
+
category: 'research',
|
|
734
|
+
tools: ['Read', 'Bash'],
|
|
735
|
+
dependencies: [],
|
|
736
|
+
status: 'pending',
|
|
737
|
+
});
|
|
738
|
+
tasks.push({
|
|
739
|
+
id: 'analyze-market',
|
|
740
|
+
description: 'Analyze market and competitive landscape',
|
|
741
|
+
category: 'analysis',
|
|
742
|
+
tools: ['Read', 'Edit'],
|
|
743
|
+
dependencies: ['gather-business-data'],
|
|
744
|
+
status: 'pending',
|
|
745
|
+
});
|
|
746
|
+
tasks.push({
|
|
747
|
+
id: 'build-models',
|
|
748
|
+
description: 'Build financial/business models',
|
|
749
|
+
category: 'computation',
|
|
750
|
+
tools: ['Edit', 'Write'],
|
|
751
|
+
dependencies: ['analyze-market'],
|
|
752
|
+
status: 'pending',
|
|
753
|
+
});
|
|
754
|
+
tasks.push({
|
|
755
|
+
id: 'generate-strategy',
|
|
756
|
+
description: 'Generate strategy recommendations',
|
|
757
|
+
category: 'communication',
|
|
758
|
+
tools: ['Edit'],
|
|
759
|
+
dependencies: ['build-models'],
|
|
760
|
+
status: 'pending',
|
|
761
|
+
});
|
|
762
|
+
break;
|
|
763
|
+
case 'financial_analysis':
|
|
764
|
+
// Accounting/Finance (e.g., "do accounting")
|
|
765
|
+
tasks.push({
|
|
766
|
+
id: 'gather-financial-data',
|
|
767
|
+
description: 'Gather financial data and records',
|
|
768
|
+
category: 'search',
|
|
769
|
+
tools: ['Glob', 'Read'],
|
|
770
|
+
dependencies: [],
|
|
771
|
+
status: 'pending',
|
|
772
|
+
});
|
|
773
|
+
tasks.push({
|
|
774
|
+
id: 'organize-transactions',
|
|
775
|
+
description: 'Organize and categorize transactions',
|
|
776
|
+
category: 'analysis',
|
|
777
|
+
tools: ['Read', 'Edit'],
|
|
778
|
+
dependencies: ['gather-financial-data'],
|
|
779
|
+
status: 'pending',
|
|
780
|
+
});
|
|
781
|
+
tasks.push({
|
|
782
|
+
id: 'calculate-financials',
|
|
783
|
+
description: 'Calculate financial metrics and statements',
|
|
784
|
+
category: 'computation',
|
|
785
|
+
tools: ['Edit', 'Bash'],
|
|
786
|
+
dependencies: ['organize-transactions'],
|
|
787
|
+
status: 'pending',
|
|
788
|
+
});
|
|
789
|
+
tasks.push({
|
|
790
|
+
id: 'generate-reports',
|
|
791
|
+
description: 'Generate financial reports',
|
|
792
|
+
category: 'generation',
|
|
793
|
+
tools: ['Edit', 'Write'],
|
|
794
|
+
dependencies: ['calculate-financials'],
|
|
795
|
+
status: 'pending',
|
|
796
|
+
});
|
|
797
|
+
tasks.push({
|
|
798
|
+
id: 'prepare-tax',
|
|
799
|
+
description: 'Prepare tax calculations and filings',
|
|
800
|
+
category: 'generation',
|
|
801
|
+
tools: ['Edit', 'Write'],
|
|
802
|
+
dependencies: ['calculate-financials'],
|
|
803
|
+
status: 'pending',
|
|
804
|
+
});
|
|
805
|
+
break;
|
|
806
|
+
case 'automate':
|
|
807
|
+
tasks.push({
|
|
808
|
+
id: 'analyze-workflow',
|
|
809
|
+
description: 'Analyze current workflow and processes',
|
|
810
|
+
category: 'analysis',
|
|
811
|
+
tools: ['Read', 'Glob'],
|
|
812
|
+
dependencies: [],
|
|
813
|
+
status: 'pending',
|
|
814
|
+
});
|
|
815
|
+
tasks.push({
|
|
816
|
+
id: 'design-automation',
|
|
817
|
+
description: 'Design automation solution',
|
|
818
|
+
category: 'analysis',
|
|
819
|
+
tools: ['Read'],
|
|
820
|
+
dependencies: ['analyze-workflow'],
|
|
821
|
+
status: 'pending',
|
|
822
|
+
});
|
|
823
|
+
tasks.push({
|
|
824
|
+
id: 'implement-automation',
|
|
825
|
+
description: 'Implement automation scripts',
|
|
826
|
+
category: 'generation',
|
|
827
|
+
tools: ['Edit', 'Write', 'Bash'],
|
|
828
|
+
dependencies: ['design-automation'],
|
|
829
|
+
status: 'pending',
|
|
830
|
+
});
|
|
831
|
+
tasks.push({
|
|
832
|
+
id: 'test-automation',
|
|
833
|
+
description: 'Test automation workflow',
|
|
834
|
+
category: 'verification',
|
|
835
|
+
tools: ['Bash'],
|
|
836
|
+
dependencies: ['implement-automation'],
|
|
837
|
+
status: 'pending',
|
|
838
|
+
});
|
|
839
|
+
break;
|
|
840
|
+
case 'monitor':
|
|
841
|
+
tasks.push({
|
|
842
|
+
id: 'identify-metrics',
|
|
843
|
+
description: 'Identify key metrics to monitor',
|
|
844
|
+
category: 'analysis',
|
|
845
|
+
tools: ['Read'],
|
|
846
|
+
dependencies: [],
|
|
847
|
+
status: 'pending',
|
|
848
|
+
});
|
|
849
|
+
tasks.push({
|
|
850
|
+
id: 'setup-collection',
|
|
851
|
+
description: 'Set up metric collection',
|
|
852
|
+
category: 'execution',
|
|
853
|
+
tools: ['Edit', 'Bash'],
|
|
854
|
+
dependencies: ['identify-metrics'],
|
|
855
|
+
status: 'pending',
|
|
856
|
+
});
|
|
857
|
+
tasks.push({
|
|
858
|
+
id: 'create-dashboard',
|
|
859
|
+
description: 'Create monitoring dashboard',
|
|
860
|
+
category: 'generation',
|
|
861
|
+
tools: ['Edit', 'Write'],
|
|
862
|
+
dependencies: ['setup-collection'],
|
|
863
|
+
status: 'pending',
|
|
864
|
+
});
|
|
865
|
+
tasks.push({
|
|
866
|
+
id: 'configure-alerts',
|
|
867
|
+
description: 'Configure alerting rules',
|
|
868
|
+
category: 'generation',
|
|
869
|
+
tools: ['Edit', 'Write'],
|
|
870
|
+
dependencies: ['create-dashboard'],
|
|
871
|
+
status: 'pending',
|
|
872
|
+
});
|
|
873
|
+
break;
|
|
874
|
+
default:
|
|
875
|
+
// Generic task decomposition
|
|
876
|
+
tasks.push({
|
|
877
|
+
id: 'understand-request',
|
|
878
|
+
description: 'Understand the request and context',
|
|
879
|
+
category: 'analysis',
|
|
880
|
+
tools: ['Glob', 'Read'],
|
|
881
|
+
dependencies: [],
|
|
882
|
+
status: 'pending',
|
|
883
|
+
});
|
|
884
|
+
tasks.push({
|
|
885
|
+
id: 'execute-task',
|
|
886
|
+
description: 'Execute the requested task',
|
|
887
|
+
category: 'execution',
|
|
888
|
+
tools: ['Bash', 'Edit'],
|
|
889
|
+
dependencies: ['understand-request'],
|
|
890
|
+
status: 'pending',
|
|
891
|
+
});
|
|
892
|
+
tasks.push({
|
|
893
|
+
id: 'verify-completion',
|
|
894
|
+
description: 'Verify task completion',
|
|
895
|
+
category: 'verification',
|
|
896
|
+
tools: ['Bash', 'Read'],
|
|
897
|
+
dependencies: ['execute-task'],
|
|
898
|
+
status: 'pending',
|
|
899
|
+
});
|
|
900
|
+
break;
|
|
901
|
+
}
|
|
902
|
+
return tasks;
|
|
903
|
+
}
|
|
904
|
+
checkAmbiguity(prompt, intent) {
|
|
905
|
+
const questions = [];
|
|
906
|
+
const lower = prompt.toLowerCase();
|
|
907
|
+
// Vague scope
|
|
908
|
+
if (/all|everything|entire|whole/i.test(lower)) {
|
|
909
|
+
questions.push('The request has broad scope. Should I focus on specific areas first?');
|
|
910
|
+
}
|
|
911
|
+
// Missing target
|
|
912
|
+
if (intent === 'fix_bugs' && !/specific|file|function|module/i.test(lower)) {
|
|
913
|
+
questions.push('Are there specific files or modules to prioritize?');
|
|
914
|
+
}
|
|
915
|
+
// Unclear priority
|
|
916
|
+
if (/important|priority|critical/i.test(lower) && !/high|low|medium/i.test(lower)) {
|
|
917
|
+
questions.push('What priority level should I focus on?');
|
|
918
|
+
}
|
|
919
|
+
return questions;
|
|
920
|
+
}
|
|
921
|
+
createFromLearnedPattern(prompt, pattern) {
|
|
922
|
+
return {
|
|
923
|
+
originalPrompt: prompt,
|
|
924
|
+
interpretation: `Using learned approach: ${pattern.successfulApproach}`,
|
|
925
|
+
intent: 'generic_task',
|
|
926
|
+
category: 'automation',
|
|
927
|
+
confidence: 0.95,
|
|
928
|
+
tasks: pattern.tools.map((tool, i) => ({
|
|
929
|
+
id: `learned-${i}`,
|
|
930
|
+
description: `Execute ${tool} based on learned pattern`,
|
|
931
|
+
category: 'execution',
|
|
932
|
+
tools: [tool],
|
|
933
|
+
dependencies: i > 0 ? [`learned-${i - 1}`] : [],
|
|
934
|
+
status: 'pending',
|
|
935
|
+
})),
|
|
936
|
+
clarificationNeeded: [],
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
// ==========================================================================
|
|
940
|
+
// EXECUTION - Run Tasks with Real Tools
|
|
941
|
+
// ==========================================================================
|
|
942
|
+
/**
|
|
943
|
+
* Generate tool calls for a given analysis
|
|
944
|
+
* Returns explicit tool call specifications ready for execution
|
|
945
|
+
*/
|
|
946
|
+
generateToolCalls(analysis) {
|
|
947
|
+
const calls = [];
|
|
948
|
+
const knowledge = this.context.memory.projectKnowledge;
|
|
949
|
+
for (const task of analysis.tasks) {
|
|
950
|
+
switch (task.category) {
|
|
951
|
+
case 'execution':
|
|
952
|
+
if (task.tools.includes('Bash')) {
|
|
953
|
+
// Generate appropriate commands based on task
|
|
954
|
+
if (task.id.includes('lint') || task.id.includes('errors')) {
|
|
955
|
+
if (knowledge.lintCommand) {
|
|
956
|
+
calls.push({
|
|
957
|
+
tool: 'Bash',
|
|
958
|
+
args: { command: knowledge.lintCommand + ' 2>&1 || true', description: task.description },
|
|
959
|
+
description: task.description,
|
|
960
|
+
taskId: task.id,
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
if (knowledge.type === 'node') {
|
|
964
|
+
calls.push({
|
|
965
|
+
tool: 'Bash',
|
|
966
|
+
args: { command: 'npx tsc --noEmit 2>&1 || true', description: 'Type check' },
|
|
967
|
+
description: 'Run TypeScript type checker',
|
|
968
|
+
taskId: task.id,
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
if (task.id.includes('test')) {
|
|
973
|
+
if (knowledge.testCommand) {
|
|
974
|
+
calls.push({
|
|
975
|
+
tool: 'Bash',
|
|
976
|
+
args: { command: knowledge.testCommand + ' 2>&1 || true', description: task.description },
|
|
977
|
+
description: task.description,
|
|
978
|
+
taskId: task.id,
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
if (task.id.includes('dependency') || task.id.includes('audit')) {
|
|
983
|
+
if (knowledge.type === 'node') {
|
|
984
|
+
calls.push({
|
|
985
|
+
tool: 'Bash',
|
|
986
|
+
args: { command: 'npm audit 2>&1 || true', description: 'Security audit' },
|
|
987
|
+
description: 'Audit npm dependencies for vulnerabilities',
|
|
988
|
+
taskId: task.id,
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
break;
|
|
994
|
+
case 'search':
|
|
995
|
+
if (task.tools.includes('Grep')) {
|
|
996
|
+
if (task.id.includes('issues') || task.id.includes('todo')) {
|
|
997
|
+
calls.push({
|
|
998
|
+
tool: 'Grep',
|
|
999
|
+
args: { pattern: 'TODO|FIXME|BUG|HACK|XXX', output_mode: 'content' },
|
|
1000
|
+
description: 'Find TODO/FIXME comments',
|
|
1001
|
+
taskId: task.id,
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
if (task.id.includes('security') || task.id.includes('patterns')) {
|
|
1005
|
+
calls.push({
|
|
1006
|
+
tool: 'Grep',
|
|
1007
|
+
args: { pattern: 'eval\\(|exec\\(|innerHTML|dangerouslySetInnerHTML', output_mode: 'content' },
|
|
1008
|
+
description: 'Find potentially unsafe patterns',
|
|
1009
|
+
taskId: task.id,
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
if (task.tools.includes('Glob')) {
|
|
1014
|
+
calls.push({
|
|
1015
|
+
tool: 'Glob',
|
|
1016
|
+
args: { pattern: 'src/**/*.{ts,js,tsx,jsx}' },
|
|
1017
|
+
description: 'Find source files',
|
|
1018
|
+
taskId: task.id,
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
break;
|
|
1022
|
+
case 'analysis':
|
|
1023
|
+
// Analysis typically involves reading files
|
|
1024
|
+
if (task.tools.includes('Read')) {
|
|
1025
|
+
calls.push({
|
|
1026
|
+
tool: 'Read',
|
|
1027
|
+
args: { file_path: 'package.json' },
|
|
1028
|
+
description: 'Read project configuration',
|
|
1029
|
+
taskId: task.id,
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
break;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
return calls;
|
|
1036
|
+
}
|
|
1037
|
+
// ==========================================================================
|
|
1038
|
+
// PUBLIC API
|
|
1039
|
+
// ==========================================================================
|
|
1040
|
+
/**
|
|
1041
|
+
* Get the current AGI context
|
|
1042
|
+
*/
|
|
1043
|
+
getContext() {
|
|
1044
|
+
return this.context;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Get project knowledge
|
|
1048
|
+
*/
|
|
1049
|
+
getProjectKnowledge() {
|
|
1050
|
+
return this.context.memory.projectKnowledge;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Get recent operations
|
|
1054
|
+
*/
|
|
1055
|
+
getRecentOperations(limit = 10) {
|
|
1056
|
+
return this.context.memory.recentOps.slice(0, limit);
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Get learned patterns
|
|
1060
|
+
*/
|
|
1061
|
+
getLearnedPatterns() {
|
|
1062
|
+
return this.context.memory.patterns;
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Force project re-analysis
|
|
1066
|
+
*/
|
|
1067
|
+
refreshProjectKnowledge() {
|
|
1068
|
+
this.analyzeProject();
|
|
1069
|
+
return this.context.memory.projectKnowledge;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
// ============================================================================
|
|
1073
|
+
// SINGLETON EXPORT
|
|
1074
|
+
// ============================================================================
|
|
1075
|
+
let agiInstance = null;
|
|
1076
|
+
export function getAGI(workingDir) {
|
|
1077
|
+
if (!agiInstance || (workingDir && workingDir !== agiInstance.getContext().workingDir)) {
|
|
1078
|
+
agiInstance = new AGICore(workingDir);
|
|
1079
|
+
}
|
|
1080
|
+
return agiInstance;
|
|
1081
|
+
}
|
|
1082
|
+
export function resetAGI() {
|
|
1083
|
+
agiInstance = null;
|
|
1084
|
+
}
|
|
1085
|
+
//# sourceMappingURL=agiCore.js.map
|