galaxy-code 0.1.2 → 0.1.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/dist/app.d.ts +1 -1
- package/dist/app.js +5 -5
- package/dist/cli.js +4 -4
- package/dist/connections/claude.d.ts +71 -0
- package/dist/connections/claude.js +303 -0
- package/dist/connections/gemini.d.ts +40 -0
- package/dist/connections/gemini.js +232 -0
- package/dist/connections/index.d.ts +11 -0
- package/dist/connections/index.js +11 -0
- package/dist/connections/ollama.d.ts +37 -0
- package/dist/connections/ollama.js +73 -0
- package/dist/connections/types.d.ts +22 -0
- package/dist/connections/types.js +7 -0
- package/dist/node_modules/@workspace/agent-core/providers/agent-selector.d.ts.map +1 -1
- package/dist/node_modules/@workspace/agent-core/providers/agent-selector.js +18 -18
- package/dist/node_modules/@workspace/agent-core/providers/agent-selector.js.map +1 -1
- package/dist/prompts/ba-it-analyzer.d.ts +1 -0
- package/dist/prompts/ba-it-analyzer.js +143 -0
- package/dist/prompts/index.d.ts +11 -0
- package/dist/prompts/index.js +11 -0
- package/dist/prompts/orchestrator.d.ts +8 -0
- package/dist/prompts/orchestrator.js +88 -0
- package/dist/prompts/planning-agent.d.ts +8 -0
- package/dist/prompts/planning-agent.js +195 -0
- package/dist/prompts/universal-agent.d.ts +7 -0
- package/dist/prompts/universal-agent.js +111 -0
- package/dist/providers/agent-selector.d.ts +29 -0
- package/dist/providers/agent-selector.js +84 -0
- package/dist/providers/claude-agent.d.ts +29 -0
- package/dist/providers/claude-agent.js +121 -0
- package/dist/providers/gemini-agent.d.ts +36 -0
- package/dist/providers/gemini-agent.js +168 -0
- package/dist/providers/index.d.ts +12 -0
- package/dist/providers/index.js +12 -0
- package/dist/providers/ollama-agent.d.ts +53 -0
- package/dist/providers/ollama-agent.js +276 -0
- package/dist/providers/orchestrator.d.ts +16 -0
- package/dist/providers/orchestrator.js +76 -0
- package/dist/tools/ba-it-analyzer.d.ts +66 -0
- package/dist/tools/ba-it-analyzer.js +90 -0
- package/dist/tools/code-generate-agent.d.ts +51 -0
- package/dist/tools/code-generate-agent.js +159 -0
- package/dist/tools/command-runner.d.ts +14 -0
- package/dist/tools/command-runner.js +120 -0
- package/dist/tools/document-parser.d.ts +11 -0
- package/dist/tools/document-parser.js +83 -0
- package/dist/tools/file-operations.d.ts +17 -0
- package/dist/tools/file-operations.js +127 -0
- package/dist/tools/galaxy-ui-integration.d.ts +94 -0
- package/dist/tools/galaxy-ui-integration.js +244 -0
- package/dist/tools/git-operations.d.ts +11 -0
- package/dist/tools/git-operations.js +114 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.js +10 -0
- package/dist/tools/planning-agent.d.ts +29 -0
- package/dist/tools/planning-agent.js +134 -0
- package/dist/tools/progress-reporter.d.ts +19 -0
- package/dist/tools/progress-reporter.js +52 -0
- package/dist/tools/registry.d.ts +21 -0
- package/dist/tools/registry.js +695 -0
- package/dist/tools/tool-event-emitter.d.ts +24 -0
- package/dist/tools/tool-event-emitter.js +25 -0
- package/dist/tools/types.d.ts +31 -0
- package/dist/tools/types.js +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/utils/config-manager.d.ts +102 -0
- package/dist/utils/config-manager.js +326 -0
- package/dist/utils/devtools.d.ts +21 -0
- package/dist/utils/devtools.js +61 -0
- package/dist/utils/message-formatters.d.ts +32 -0
- package/dist/utils/message-formatters.js +590 -0
- package/dist/utils/progress-tracker.d.ts +59 -0
- package/dist/utils/progress-tracker.js +213 -0
- package/package.json +3 -2
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planning Agent - Creates step-by-step execution plans
|
|
3
|
+
* Uses gemini-2.5-flash for intelligent planning
|
|
4
|
+
*/
|
|
5
|
+
import { GeminiConnection } from '../connections/gemini.js';
|
|
6
|
+
import { planningSystemPrompt } from '../prompts/planning-agent.js';
|
|
7
|
+
export class PlanningAgent {
|
|
8
|
+
constructor() {
|
|
9
|
+
Object.defineProperty(this, "gemini", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: null
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(this, "model", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: 'gemini-2.5-flash'
|
|
20
|
+
});
|
|
21
|
+
// Lazy initialization - only create connection when needed
|
|
22
|
+
}
|
|
23
|
+
getConnection(systemPrompt) {
|
|
24
|
+
if (!this.gemini) {
|
|
25
|
+
// Special case: PlanningAgent gets apiKey directly from process.env
|
|
26
|
+
const apiKey = process.env['GOOGLE_AI_API_KEY'] || process.env['GEMINI_API_KEY'];
|
|
27
|
+
if (!apiKey) {
|
|
28
|
+
throw new Error('PlanningAgent requires GOOGLE_AI_API_KEY or GEMINI_API_KEY in environment variables');
|
|
29
|
+
}
|
|
30
|
+
this.gemini = new GeminiConnection({
|
|
31
|
+
type: 'gemini',
|
|
32
|
+
model: this.model,
|
|
33
|
+
apiKey: apiKey,
|
|
34
|
+
}, systemPrompt);
|
|
35
|
+
}
|
|
36
|
+
return this.gemini;
|
|
37
|
+
}
|
|
38
|
+
async generatePlan(userContext, baAnalysis) {
|
|
39
|
+
try {
|
|
40
|
+
let userMessage = `User Context: ${userContext}`;
|
|
41
|
+
if (baAnalysis) {
|
|
42
|
+
const baResponse = baAnalysis.ba_it_analyze_response.result;
|
|
43
|
+
userMessage += `\n\nBA Analysis:\n${JSON.stringify({
|
|
44
|
+
type: baResponse.type,
|
|
45
|
+
projectName: baResponse.projectName,
|
|
46
|
+
coreFeatures: baResponse.coreFeatures.map(f => f.name),
|
|
47
|
+
technicalStack: baResponse.technicalStack,
|
|
48
|
+
}, null, 2)}`;
|
|
49
|
+
}
|
|
50
|
+
const systemPrompt = planningSystemPrompt();
|
|
51
|
+
const response = await this.getConnection(systemPrompt).generate({
|
|
52
|
+
prompt: userMessage,
|
|
53
|
+
});
|
|
54
|
+
// Extract and parse JSON from response
|
|
55
|
+
const jsonStr = this.extractJSON(response.text);
|
|
56
|
+
if (!jsonStr) {
|
|
57
|
+
// Fallback plan if parsing fails
|
|
58
|
+
return this.createFallbackPlan(userContext);
|
|
59
|
+
}
|
|
60
|
+
const plan = JSON.parse(jsonStr);
|
|
61
|
+
return plan;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
// Fallback plan on error
|
|
65
|
+
return this.createFallbackPlan(userContext);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
extractJSON(content) {
|
|
69
|
+
// Remove markdown code blocks
|
|
70
|
+
let cleanContent = content.trim();
|
|
71
|
+
cleanContent = cleanContent.replace(/```json\s*/g, '');
|
|
72
|
+
cleanContent = cleanContent.replace(/```\s*/g, '');
|
|
73
|
+
// Find JSON object with balanced braces
|
|
74
|
+
const startIdx = cleanContent.indexOf('{');
|
|
75
|
+
if (startIdx === -1)
|
|
76
|
+
return null;
|
|
77
|
+
let braceCount = 0;
|
|
78
|
+
let inString = false;
|
|
79
|
+
let escapeNext = false;
|
|
80
|
+
for (let i = startIdx; i < cleanContent.length; i++) {
|
|
81
|
+
const char = cleanContent[i];
|
|
82
|
+
if (escapeNext) {
|
|
83
|
+
escapeNext = false;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (char === '\\') {
|
|
87
|
+
escapeNext = true;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (char === '"' && !escapeNext) {
|
|
91
|
+
inString = !inString;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (!inString) {
|
|
95
|
+
if (char === '{') {
|
|
96
|
+
braceCount++;
|
|
97
|
+
}
|
|
98
|
+
else if (char === '}') {
|
|
99
|
+
braceCount--;
|
|
100
|
+
if (braceCount === 0) {
|
|
101
|
+
return cleanContent.substring(startIdx, i + 1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
createFallbackPlan(userContext) {
|
|
109
|
+
return {
|
|
110
|
+
summary: 'Basic implementation plan',
|
|
111
|
+
steps: [
|
|
112
|
+
{
|
|
113
|
+
step: 1,
|
|
114
|
+
action: 'Check project structure',
|
|
115
|
+
tool: 'file_tree',
|
|
116
|
+
reasoning: 'Understand existing codebase',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
step: 2,
|
|
120
|
+
action: `Implement: ${userContext}`,
|
|
121
|
+
tool: 'file_write',
|
|
122
|
+
reasoning: 'Create necessary files',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
step: 3,
|
|
126
|
+
action: 'Test implementation',
|
|
127
|
+
tool: 'test_run',
|
|
128
|
+
reasoning: 'Verify functionality',
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
estimatedTime: 'medium',
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress Reporter Tool
|
|
3
|
+
* Allows code-generate-agent to report task completion status
|
|
4
|
+
* Emits events via EventEmitter for UI tracking
|
|
5
|
+
*/
|
|
6
|
+
export interface ProgressReport {
|
|
7
|
+
step: number;
|
|
8
|
+
status: 'success' | 'error' | 'in_progress';
|
|
9
|
+
message?: string;
|
|
10
|
+
filesCreated?: string[];
|
|
11
|
+
commandsRun?: string[];
|
|
12
|
+
}
|
|
13
|
+
export declare class ProgressReporter {
|
|
14
|
+
private reports;
|
|
15
|
+
reportProgress(report: ProgressReport): string;
|
|
16
|
+
getReports(): ProgressReport[];
|
|
17
|
+
getAllSuccessful(): boolean;
|
|
18
|
+
clear(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress Reporter Tool
|
|
3
|
+
* Allows code-generate-agent to report task completion status
|
|
4
|
+
* Emits events via EventEmitter for UI tracking
|
|
5
|
+
*/
|
|
6
|
+
import { toolEventEmitter } from './tool-event-emitter.js';
|
|
7
|
+
export class ProgressReporter {
|
|
8
|
+
constructor() {
|
|
9
|
+
Object.defineProperty(this, "reports", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: []
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
reportProgress(report) {
|
|
17
|
+
this.reports.push(report);
|
|
18
|
+
const statusEmoji = report.status === 'success' ? '✅' : report.status === 'error' ? '❌' : '⏳';
|
|
19
|
+
let message = `${statusEmoji} Step ${report.step}: ${report.status.toUpperCase()}`;
|
|
20
|
+
if (report.message) {
|
|
21
|
+
message += `\n ${report.message}`;
|
|
22
|
+
}
|
|
23
|
+
if (report.filesCreated && report.filesCreated.length > 0) {
|
|
24
|
+
message += `\n 📝 Files created: ${report.filesCreated.join(', ')}`;
|
|
25
|
+
}
|
|
26
|
+
if (report.commandsRun && report.commandsRun.length > 0) {
|
|
27
|
+
message += `\n 🔧 Commands run: ${report.commandsRun.join(', ')}`;
|
|
28
|
+
}
|
|
29
|
+
// Emit event via EventEmitter
|
|
30
|
+
toolEventEmitter.emitToolExecution({
|
|
31
|
+
toolName: 'progress_reporter',
|
|
32
|
+
content: JSON.stringify({
|
|
33
|
+
step: report.step,
|
|
34
|
+
status: report.status,
|
|
35
|
+
message: report.message,
|
|
36
|
+
filesCreated: report.filesCreated,
|
|
37
|
+
commandsRun: report.commandsRun,
|
|
38
|
+
}),
|
|
39
|
+
status: report.status === 'success' ? 'success' : report.status === 'error' ? 'error' : 'success', // in_progress treated as success for event
|
|
40
|
+
});
|
|
41
|
+
return message;
|
|
42
|
+
}
|
|
43
|
+
getReports() {
|
|
44
|
+
return this.reports;
|
|
45
|
+
}
|
|
46
|
+
getAllSuccessful() {
|
|
47
|
+
return this.reports.every(r => r.status === 'success');
|
|
48
|
+
}
|
|
49
|
+
clear() {
|
|
50
|
+
this.reports = [];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Tool } from './types.js';
|
|
2
|
+
export declare class ToolRegistry {
|
|
3
|
+
private readonly tools;
|
|
4
|
+
private fileOps;
|
|
5
|
+
private gitOps;
|
|
6
|
+
private commandRunner;
|
|
7
|
+
private baAnalyzer;
|
|
8
|
+
private documentParser;
|
|
9
|
+
private planningAgent;
|
|
10
|
+
private codeGenerateAgent;
|
|
11
|
+
private progressReporter;
|
|
12
|
+
constructor();
|
|
13
|
+
private registerAllTools;
|
|
14
|
+
register<InputValue, OutputValue>(tool: Tool<InputValue, OutputValue>): void;
|
|
15
|
+
get(name: string): Tool<unknown, unknown> | undefined;
|
|
16
|
+
list(): Array<Tool<unknown, unknown>>;
|
|
17
|
+
getToolsContext(args: string[]): string;
|
|
18
|
+
getToolsByNames(names?: string[]): any[];
|
|
19
|
+
executeTool(name: string, args: any): Promise<any>;
|
|
20
|
+
}
|
|
21
|
+
export declare const globalToolRegistry: ToolRegistry;
|