galaxy-code 0.1.6 → 0.1.7
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/cli.bundle.js +588 -0
- package/package.json +6 -6
- package/dist/app.d.ts +0 -7
- package/dist/app.js +0 -597
- package/dist/auto-updater.d.ts +0 -21
- package/dist/auto-updater.js +0 -144
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -159
- package/dist/cli.min.js +0 -589
- package/dist/connections/claude.d.ts +0 -71
- package/dist/connections/claude.js +0 -303
- package/dist/connections/gemini.d.ts +0 -40
- package/dist/connections/gemini.js +0 -232
- package/dist/connections/index.d.ts +0 -11
- package/dist/connections/index.js +0 -11
- package/dist/connections/ollama.d.ts +0 -37
- package/dist/connections/ollama.js +0 -73
- package/dist/connections/types.d.ts +0 -22
- package/dist/connections/types.js +0 -7
- package/dist/env.d.ts +0 -1
- package/dist/env.js +0 -29
- package/dist/prompts/ba-it-analyzer.d.ts +0 -1
- package/dist/prompts/ba-it-analyzer.js +0 -143
- package/dist/prompts/index.d.ts +0 -11
- package/dist/prompts/index.js +0 -11
- package/dist/prompts/orchestrator.d.ts +0 -8
- package/dist/prompts/orchestrator.js +0 -88
- package/dist/prompts/planning-agent.d.ts +0 -8
- package/dist/prompts/planning-agent.js +0 -195
- package/dist/prompts/universal-agent.d.ts +0 -7
- package/dist/prompts/universal-agent.js +0 -111
- package/dist/providers/agent-selector.d.ts +0 -29
- package/dist/providers/agent-selector.js +0 -84
- package/dist/providers/claude-agent.d.ts +0 -29
- package/dist/providers/claude-agent.js +0 -121
- package/dist/providers/gemini-agent.d.ts +0 -36
- package/dist/providers/gemini-agent.js +0 -168
- package/dist/providers/index.d.ts +0 -12
- package/dist/providers/index.js +0 -12
- package/dist/providers/ollama-agent.d.ts +0 -53
- package/dist/providers/ollama-agent.js +0 -276
- package/dist/providers/orchestrator.d.ts +0 -16
- package/dist/providers/orchestrator.js +0 -76
- package/dist/tools/ba-it-analyzer.d.ts +0 -66
- package/dist/tools/ba-it-analyzer.js +0 -90
- package/dist/tools/code-generate-agent.d.ts +0 -51
- package/dist/tools/code-generate-agent.js +0 -159
- package/dist/tools/command-runner.d.ts +0 -14
- package/dist/tools/command-runner.js +0 -120
- package/dist/tools/document-parser.d.ts +0 -11
- package/dist/tools/document-parser.js +0 -83
- package/dist/tools/file-operations.d.ts +0 -17
- package/dist/tools/file-operations.js +0 -127
- package/dist/tools/galaxy-ui-integration.d.ts +0 -94
- package/dist/tools/galaxy-ui-integration.js +0 -244
- package/dist/tools/git-operations.d.ts +0 -11
- package/dist/tools/git-operations.js +0 -114
- package/dist/tools/index.d.ts +0 -10
- package/dist/tools/index.js +0 -10
- package/dist/tools/planning-agent.d.ts +0 -29
- package/dist/tools/planning-agent.js +0 -134
- package/dist/tools/progress-reporter.d.ts +0 -19
- package/dist/tools/progress-reporter.js +0 -52
- package/dist/tools/registry.d.ts +0 -21
- package/dist/tools/registry.js +0 -695
- package/dist/tools/tool-event-emitter.d.ts +0 -24
- package/dist/tools/tool-event-emitter.js +0 -25
- package/dist/tools/types.d.ts +0 -31
- package/dist/tools/types.js +0 -1
- package/dist/types.d.ts +0 -39
- package/dist/types.js +0 -8
- package/dist/update-checker.d.ts +0 -22
- package/dist/update-checker.js +0 -85
- package/dist/utils/config-manager.d.ts +0 -102
- package/dist/utils/config-manager.js +0 -326
- package/dist/utils/devtools.d.ts +0 -21
- package/dist/utils/devtools.js +0 -61
- package/dist/utils/message-formatters.d.ts +0 -32
- package/dist/utils/message-formatters.js +0 -590
- package/dist/utils/progress-tracker.d.ts +0 -59
- package/dist/utils/progress-tracker.js +0 -213
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author Bùi Trọng Hiếu
|
|
3
|
-
* @email kevinbui210191@gmail.com
|
|
4
|
-
* @create 2025-10-22
|
|
5
|
-
* @modify 2025-10-22
|
|
6
|
-
* @desc Ollama Agent - Self-contained AI orchestrator
|
|
7
|
-
*/
|
|
8
|
-
import { OllamaConnection } from '../connections/ollama.js';
|
|
9
|
-
import { ToolRegistry } from '../tools/index.js';
|
|
10
|
-
import { buildUniversalAgentPrompt } from '../prompts/index.js';
|
|
11
|
-
export class OllamaAgent {
|
|
12
|
-
constructor(config) {
|
|
13
|
-
Object.defineProperty(this, "connection", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: void 0
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(this, "model", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true,
|
|
23
|
-
value: void 0
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(this, "toolsRegistry", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: new ToolRegistry()
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(this, "conversationHistory", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
configurable: true,
|
|
34
|
-
writable: true,
|
|
35
|
-
value: []
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(this, "systemPrompt", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
configurable: true,
|
|
40
|
-
writable: true,
|
|
41
|
-
value: void 0
|
|
42
|
-
});
|
|
43
|
-
// Low-level tools for Ollama to build software
|
|
44
|
-
Object.defineProperty(this, "toolNames", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
configurable: true,
|
|
47
|
-
writable: true,
|
|
48
|
-
value: [
|
|
49
|
-
'file_read',
|
|
50
|
-
'file_write',
|
|
51
|
-
'file_tree',
|
|
52
|
-
'file_list',
|
|
53
|
-
'file_search',
|
|
54
|
-
'git_status',
|
|
55
|
-
'git_commit',
|
|
56
|
-
'git_push',
|
|
57
|
-
'git_pull',
|
|
58
|
-
'git_diff',
|
|
59
|
-
'git_log',
|
|
60
|
-
'git_branches',
|
|
61
|
-
'command_run',
|
|
62
|
-
'install_dependencies',
|
|
63
|
-
'test_run',
|
|
64
|
-
'plan_task',
|
|
65
|
-
'progress_reporter',
|
|
66
|
-
// Galaxy UI Integration
|
|
67
|
-
'galaxy_ui_list',
|
|
68
|
-
'galaxy_ui_search',
|
|
69
|
-
'galaxy_ui_get_component',
|
|
70
|
-
'galaxy_ui_categories',
|
|
71
|
-
'galaxy_ui_add',
|
|
72
|
-
'galaxy_ui_init',
|
|
73
|
-
'galaxy_ui_docs',
|
|
74
|
-
]
|
|
75
|
-
});
|
|
76
|
-
this.model = config?.model || 'deepseek-v3.1:671b-cloud';
|
|
77
|
-
this.connection = new OllamaConnection(config);
|
|
78
|
-
// Build system prompt using shared universal prompt
|
|
79
|
-
const toolsContext = this.toolsRegistry.getToolsContext(this.toolNames);
|
|
80
|
-
this.systemPrompt = buildUniversalAgentPrompt(toolsContext);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Convert tool registry format to Ollama tool format
|
|
84
|
-
*/
|
|
85
|
-
getOllamaTools() {
|
|
86
|
-
const tools = this.toolsRegistry.getToolsByNames(this.toolNames);
|
|
87
|
-
return tools.map(tool => ({
|
|
88
|
-
type: 'function',
|
|
89
|
-
function: {
|
|
90
|
-
name: tool.name,
|
|
91
|
-
description: tool.description,
|
|
92
|
-
parameters: tool.inputSchema,
|
|
93
|
-
},
|
|
94
|
-
}));
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Handle user input and orchestrate tool calls
|
|
98
|
-
*/
|
|
99
|
-
async handleUserInput(input, options, onMessage, retryCount = 0) {
|
|
100
|
-
const MAX_RETRIES = 3;
|
|
101
|
-
try {
|
|
102
|
-
// Add system context to input
|
|
103
|
-
const contextMessage = options
|
|
104
|
-
? `[System Context: Git=${options.gitEnabled ? 'ON' : 'OFF'}, Test Planning=${options.testEnabled ? 'ON' : 'OFF'}]\n\n${input}`
|
|
105
|
-
: input;
|
|
106
|
-
// Add user message to history
|
|
107
|
-
this.conversationHistory.push({
|
|
108
|
-
role: 'user',
|
|
109
|
-
content: contextMessage,
|
|
110
|
-
});
|
|
111
|
-
// Start conversation loop
|
|
112
|
-
let response = await this.connection.chatWithTools({
|
|
113
|
-
model: this.model,
|
|
114
|
-
messages: [{ role: 'system', content: this.systemPrompt }, ...this.conversationHistory],
|
|
115
|
-
tools: this.getOllamaTools(),
|
|
116
|
-
stream: false,
|
|
117
|
-
});
|
|
118
|
-
// Handle tool use loop until completion
|
|
119
|
-
// Using a high safety limit to prevent infinite loops while allowing full plan execution
|
|
120
|
-
const SAFETY_LIMIT = 100;
|
|
121
|
-
let iteration = 0;
|
|
122
|
-
while (response.message.tool_calls && iteration < SAFETY_LIMIT) {
|
|
123
|
-
iteration++;
|
|
124
|
-
const toolCalls = response.message.tool_calls;
|
|
125
|
-
// Add assistant response to history
|
|
126
|
-
this.conversationHistory.push({
|
|
127
|
-
role: 'assistant',
|
|
128
|
-
content: response.message.content || '',
|
|
129
|
-
tool_calls: toolCalls,
|
|
130
|
-
});
|
|
131
|
-
// Execute tools and collect results
|
|
132
|
-
for (const toolCall of toolCalls) {
|
|
133
|
-
const toolName = toolCall.function.name;
|
|
134
|
-
const toolInput = toolCall.function.arguments;
|
|
135
|
-
// Special handling for plan_task and progress_reporter
|
|
136
|
-
if (toolName === 'plan_task' || toolName === 'progress_reporter') {
|
|
137
|
-
try {
|
|
138
|
-
// Execute tool (it will emit event internally)
|
|
139
|
-
const result = await this.toolsRegistry.executeTool(toolName, toolInput);
|
|
140
|
-
// Convert result to string if needed
|
|
141
|
-
const resultStr = typeof result === 'string' ? result : JSON.stringify(result);
|
|
142
|
-
// Add tool result to history (but don't notify - event already emitted)
|
|
143
|
-
this.conversationHistory.push({
|
|
144
|
-
role: 'tool',
|
|
145
|
-
content: resultStr,
|
|
146
|
-
});
|
|
147
|
-
// After plan_task, remind AI to start executing with progress reporting
|
|
148
|
-
if (toolName === 'plan_task') {
|
|
149
|
-
this.conversationHistory.push({
|
|
150
|
-
role: 'user',
|
|
151
|
-
content: '⚠️ CRITICAL: Now execute EACH step in the plan. After completing EACH step, you MUST call progress_reporter({step: N, status: "success"|"error"}). Start with step 1.',
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
157
|
-
// Add error result to history
|
|
158
|
-
this.conversationHistory.push({
|
|
159
|
-
role: 'tool',
|
|
160
|
-
content: `Error: ${errorMsg}`,
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
// Regular tool handling
|
|
166
|
-
try {
|
|
167
|
-
// Execute tool
|
|
168
|
-
const result = await this.toolsRegistry.executeTool(toolName, toolInput);
|
|
169
|
-
// Convert result to string if needed
|
|
170
|
-
const resultStr = typeof result === 'string' ? result : JSON.stringify(result);
|
|
171
|
-
// Add tool result to history
|
|
172
|
-
this.conversationHistory.push({
|
|
173
|
-
role: 'tool',
|
|
174
|
-
content: resultStr,
|
|
175
|
-
});
|
|
176
|
-
// CRITICAL: Force reminder for progress reporting after each tool execution
|
|
177
|
-
// This ensures AI calls progress_reporter after completing each step
|
|
178
|
-
this.conversationHistory.push({
|
|
179
|
-
role: 'user',
|
|
180
|
-
content: '⚠️ MANDATORY: If the tool you just executed was part of a plan step, you MUST immediately call progress_reporter with the step number and status (success/error). Do NOT skip this step.',
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
185
|
-
// Add error result to history
|
|
186
|
-
this.conversationHistory.push({
|
|
187
|
-
role: 'tool',
|
|
188
|
-
content: `Error: ${errorMsg}`,
|
|
189
|
-
});
|
|
190
|
-
// Force reminder even on error
|
|
191
|
-
this.conversationHistory.push({
|
|
192
|
-
role: 'user',
|
|
193
|
-
content: '⚠️ MANDATORY: The tool execution failed. You MUST call progress_reporter with status="error" for this step.',
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
// Continue conversation
|
|
199
|
-
response = await this.connection.chatWithTools({
|
|
200
|
-
model: this.model,
|
|
201
|
-
messages: [{ role: 'system', content: this.systemPrompt }, ...this.conversationHistory],
|
|
202
|
-
tools: this.getOllamaTools(),
|
|
203
|
-
stream: false,
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
// Check if we hit the safety limit (likely an issue)
|
|
207
|
-
if (iteration >= SAFETY_LIMIT) {
|
|
208
|
-
// Safety limit reached - agent should complete naturally
|
|
209
|
-
}
|
|
210
|
-
// Extract final text response
|
|
211
|
-
const finalResponse = response.message.content || '';
|
|
212
|
-
// Add final response to history
|
|
213
|
-
this.conversationHistory.push({
|
|
214
|
-
role: 'assistant',
|
|
215
|
-
content: finalResponse,
|
|
216
|
-
});
|
|
217
|
-
// Notify final response
|
|
218
|
-
// if (onMessage) {
|
|
219
|
-
// onMessage('assistant', finalResponse);
|
|
220
|
-
// }
|
|
221
|
-
return { content: finalResponse };
|
|
222
|
-
}
|
|
223
|
-
catch (error) {
|
|
224
|
-
// Silent auto-retry with exponential backoff
|
|
225
|
-
if (retryCount < MAX_RETRIES) {
|
|
226
|
-
// Remove last user message from history to avoid duplication
|
|
227
|
-
if (this.conversationHistory.length > 0 &&
|
|
228
|
-
this.conversationHistory[this.conversationHistory.length - 1]?.role === 'user') {
|
|
229
|
-
this.conversationHistory.pop();
|
|
230
|
-
}
|
|
231
|
-
// Wait before retry (exponential backoff: 1s, 2s, 4s)
|
|
232
|
-
// const delayMs = Math.pow(2, retryCount) * 1000;
|
|
233
|
-
await new Promise(resolve => setTimeout(resolve, 100000));
|
|
234
|
-
// Silent retry - continue with "Continued" message
|
|
235
|
-
return await this.handleUserInput('Continued', options, onMessage, retryCount + 1);
|
|
236
|
-
}
|
|
237
|
-
// Max retries exceeded - throw error to app.tsx
|
|
238
|
-
throw new Error(`Đang bị lỗi. Hãy thử lại sau: `);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Clear conversation history
|
|
243
|
-
*/
|
|
244
|
-
clearHistory() {
|
|
245
|
-
this.conversationHistory = [];
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Get conversation history
|
|
249
|
-
*/
|
|
250
|
-
getHistory() {
|
|
251
|
-
return [...this.conversationHistory];
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Change model
|
|
255
|
-
*/
|
|
256
|
-
setModel(model) {
|
|
257
|
-
this.model = model;
|
|
258
|
-
this.connection = new OllamaConnection({ model });
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Get current model
|
|
262
|
-
*/
|
|
263
|
-
getModel() {
|
|
264
|
-
return this.model;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
// Singleton instance with lazy initialization
|
|
268
|
-
let _ollamaAgent = null;
|
|
269
|
-
export const ollamaAgent = {
|
|
270
|
-
get instance() {
|
|
271
|
-
if (!_ollamaAgent) {
|
|
272
|
-
_ollamaAgent = new OllamaAgent();
|
|
273
|
-
}
|
|
274
|
-
return _ollamaAgent;
|
|
275
|
-
},
|
|
276
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ToolExecutionInfo } from '../connections/types.js';
|
|
2
|
-
export interface OrchestratorOptions {
|
|
3
|
-
gitEnabled: boolean;
|
|
4
|
-
testEnabled: boolean;
|
|
5
|
-
}
|
|
6
|
-
export type MessageCallback = (author: 'user' | 'assistant' | 'system' | 'tool', content: string, toolName?: string, toolInfo?: ToolExecutionInfo) => void;
|
|
7
|
-
export declare class OrchestratorAgent {
|
|
8
|
-
private toolsRegistry;
|
|
9
|
-
private connection;
|
|
10
|
-
private tools;
|
|
11
|
-
constructor();
|
|
12
|
-
private getConnection;
|
|
13
|
-
handleUserInput(input: string, options?: OrchestratorOptions, onMessage?: MessageCallback): Promise<{
|
|
14
|
-
content: string;
|
|
15
|
-
}>;
|
|
16
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author Bùi Trọng Hiếu
|
|
3
|
-
* @email kevinbui210191@gmail.com
|
|
4
|
-
* @create 2024-10-08
|
|
5
|
-
* @modify 2024-10-13
|
|
6
|
-
* @desc Orchestrator agent leveraging Gemini and registered tools.
|
|
7
|
-
*/
|
|
8
|
-
import { GeminiConnection } from '../connections/gemini.js';
|
|
9
|
-
import { ToolRegistry } from '../tools/index.js';
|
|
10
|
-
import { orchestratorSystemPrompt } from '../prompts/orchestrator.js';
|
|
11
|
-
export class OrchestratorAgent {
|
|
12
|
-
constructor() {
|
|
13
|
-
Object.defineProperty(this, "toolsRegistry", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: new ToolRegistry()
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(this, "connection", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true,
|
|
23
|
-
value: null
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(this, "tools", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: [
|
|
30
|
-
'ba_it_analyze',
|
|
31
|
-
'code_generate',
|
|
32
|
-
'file_list',
|
|
33
|
-
'file_search',
|
|
34
|
-
'file_tree',
|
|
35
|
-
'command_run',
|
|
36
|
-
'file_read',
|
|
37
|
-
'file_write',
|
|
38
|
-
'plan_task',
|
|
39
|
-
'git_status',
|
|
40
|
-
'git_commit',
|
|
41
|
-
'git_push',
|
|
42
|
-
]
|
|
43
|
-
});
|
|
44
|
-
// Lazy initialization - only create connection when needed
|
|
45
|
-
}
|
|
46
|
-
getConnection() {
|
|
47
|
-
if (!this.connection) {
|
|
48
|
-
// Special case: OrchestratorAgent gets apiKey directly from process.env
|
|
49
|
-
const apiKey = process.env['GOOGLE_AI_API_KEY'] || process.env['GEMINI_API_KEY'];
|
|
50
|
-
if (!apiKey) {
|
|
51
|
-
throw new Error('OrchestratorAgent requires GOOGLE_AI_API_KEY or GEMINI_API_KEY in environment variables');
|
|
52
|
-
}
|
|
53
|
-
const systemPrompt = orchestratorSystemPrompt(this.toolsRegistry.getToolsContext(this.tools));
|
|
54
|
-
this.connection = new GeminiConnection({
|
|
55
|
-
type: 'gemini',
|
|
56
|
-
model: 'gemini-2.5-flash',
|
|
57
|
-
apiKey: apiKey,
|
|
58
|
-
}, systemPrompt);
|
|
59
|
-
}
|
|
60
|
-
return this.connection;
|
|
61
|
-
}
|
|
62
|
-
async handleUserInput(input, options, onMessage) {
|
|
63
|
-
try {
|
|
64
|
-
// Pass options to plan_task via context
|
|
65
|
-
const contextMessage = options
|
|
66
|
-
? `[System Context: Git=${options.gitEnabled ? 'ON' : 'OFF'}, Test Planning=${options.testEnabled ? 'ON' : 'OFF'}]\n\n${input}`
|
|
67
|
-
: input;
|
|
68
|
-
const result = await this.getConnection().chat(contextMessage, onMessage);
|
|
69
|
-
const content = result?.trim() || '(No response)';
|
|
70
|
-
return { content };
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
}
|
|
74
|
-
return { content: '(Error occurred)' }; // Fallback in case of error
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BA IT Analyzer - Business Analyst for IT Projects
|
|
3
|
-
* Analyzes user requirements and creates detailed functional specifications
|
|
4
|
-
* NOW WITH DEEP THINK INTEGRATION for complex technical decisions!
|
|
5
|
-
*/
|
|
6
|
-
export interface ProjectRequirement {
|
|
7
|
-
type: 'create_project' | 'update_project';
|
|
8
|
-
projectName: string;
|
|
9
|
-
projectType: string;
|
|
10
|
-
description: string;
|
|
11
|
-
coreFeatures: Feature[];
|
|
12
|
-
technicalStack: TechnicalStack;
|
|
13
|
-
userStories: UserStory[];
|
|
14
|
-
dataModel: DataEntity[];
|
|
15
|
-
apiEndpoints?: APIEndpoint[];
|
|
16
|
-
estimatedComplexity: 'simple' | 'medium' | 'complex';
|
|
17
|
-
estimatedTime: string;
|
|
18
|
-
recommendations: string[];
|
|
19
|
-
questionsForUser: string[];
|
|
20
|
-
deepAnalysis?: {
|
|
21
|
-
question: string;
|
|
22
|
-
insights: string;
|
|
23
|
-
considerations: string[];
|
|
24
|
-
}[];
|
|
25
|
-
}
|
|
26
|
-
export interface Feature {
|
|
27
|
-
name: string;
|
|
28
|
-
description: string;
|
|
29
|
-
priority: 'must-have' | 'should-have' | 'nice-to-have';
|
|
30
|
-
userStory: string;
|
|
31
|
-
acceptanceCriteria: string[];
|
|
32
|
-
}
|
|
33
|
-
export interface TechnicalStack {
|
|
34
|
-
frontend?: string[];
|
|
35
|
-
backend?: string[];
|
|
36
|
-
database?: string[];
|
|
37
|
-
infrastructure?: string[];
|
|
38
|
-
thirdParty?: string[];
|
|
39
|
-
}
|
|
40
|
-
export interface UserStory {
|
|
41
|
-
as: string;
|
|
42
|
-
iWant: string;
|
|
43
|
-
soThat: string;
|
|
44
|
-
acceptanceCriteria: string[];
|
|
45
|
-
}
|
|
46
|
-
export interface DataEntity {
|
|
47
|
-
name: string;
|
|
48
|
-
description: string;
|
|
49
|
-
attributes: string[];
|
|
50
|
-
relationships: string[];
|
|
51
|
-
}
|
|
52
|
-
export interface APIEndpoint {
|
|
53
|
-
method: string;
|
|
54
|
-
path: string;
|
|
55
|
-
description: string;
|
|
56
|
-
requestBody?: string;
|
|
57
|
-
response: string;
|
|
58
|
-
}
|
|
59
|
-
export declare class BAITAnalyzer {
|
|
60
|
-
private ollama;
|
|
61
|
-
private model;
|
|
62
|
-
constructor();
|
|
63
|
-
private getConnection;
|
|
64
|
-
analyze(userRequest: string, context?: string): Promise<ProjectRequirement>;
|
|
65
|
-
private extractJSON;
|
|
66
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BA IT Analyzer - Business Analyst for IT Projects
|
|
3
|
-
* Analyzes user requirements and creates detailed functional specifications
|
|
4
|
-
* NOW WITH DEEP THINK INTEGRATION for complex technical decisions!
|
|
5
|
-
*/
|
|
6
|
-
import { OllamaConnection } from '../connections/ollama.js';
|
|
7
|
-
import { systemBAITAnalyzerPrompt } from '../prompts/ba-it-analyzer.js';
|
|
8
|
-
export class BAITAnalyzer {
|
|
9
|
-
constructor() {
|
|
10
|
-
Object.defineProperty(this, "ollama", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
writable: true,
|
|
14
|
-
value: null
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(this, "model", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true,
|
|
20
|
-
value: 'gpt-oss:120b-cloud'
|
|
21
|
-
});
|
|
22
|
-
// Lazy initialization - only create connection when needed
|
|
23
|
-
}
|
|
24
|
-
getConnection() {
|
|
25
|
-
if (!this.ollama) {
|
|
26
|
-
this.ollama = new OllamaConnection({
|
|
27
|
-
model: this.model,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return this.ollama;
|
|
31
|
-
}
|
|
32
|
-
async analyze(userRequest, context) {
|
|
33
|
-
let userMessage = `User Request: ${userRequest}`;
|
|
34
|
-
if (context) {
|
|
35
|
-
userMessage += `\n\nAdditional Context:\n${context}`;
|
|
36
|
-
}
|
|
37
|
-
const response = await this.getConnection().generate({
|
|
38
|
-
prompt: userMessage,
|
|
39
|
-
system: systemBAITAnalyzerPrompt,
|
|
40
|
-
model: this.model,
|
|
41
|
-
});
|
|
42
|
-
// Extract and clean JSON from response
|
|
43
|
-
const jsonStr = this.extractJSON(response.response);
|
|
44
|
-
if (!jsonStr) {
|
|
45
|
-
throw new Error('Failed to extract JSON from BA analysis response');
|
|
46
|
-
}
|
|
47
|
-
const projectRequirement = JSON.parse(jsonStr);
|
|
48
|
-
return projectRequirement;
|
|
49
|
-
}
|
|
50
|
-
extractJSON(content) {
|
|
51
|
-
// Remove markdown code blocks if present
|
|
52
|
-
let cleanContent = content.trim();
|
|
53
|
-
cleanContent = cleanContent.replace(/```json\s*/g, '');
|
|
54
|
-
cleanContent = cleanContent.replace(/```\s*/g, '');
|
|
55
|
-
// Try to find JSON object with balanced braces
|
|
56
|
-
const startIdx = cleanContent.indexOf('{');
|
|
57
|
-
if (startIdx === -1)
|
|
58
|
-
return null;
|
|
59
|
-
let braceCount = 0;
|
|
60
|
-
let inString = false;
|
|
61
|
-
let escapeNext = false;
|
|
62
|
-
for (let i = startIdx; i < cleanContent.length; i++) {
|
|
63
|
-
const char = cleanContent[i];
|
|
64
|
-
if (escapeNext) {
|
|
65
|
-
escapeNext = false;
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (char === '\\') {
|
|
69
|
-
escapeNext = true;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (char === '"' && !escapeNext) {
|
|
73
|
-
inString = !inString;
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
if (!inString) {
|
|
77
|
-
if (char === '{') {
|
|
78
|
-
braceCount++;
|
|
79
|
-
}
|
|
80
|
-
else if (char === '}') {
|
|
81
|
-
braceCount--;
|
|
82
|
-
if (braceCount === 0) {
|
|
83
|
-
return cleanContent.substring(startIdx, i + 1);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Code Generate Agent - Planning only (no execution)
|
|
3
|
-
* Receives feature spec → Plans actions → Returns action list
|
|
4
|
-
* Orchestrator will execute the actions
|
|
5
|
-
*/
|
|
6
|
-
import type { ProjectRequirement } from './ba-it-analyzer.js';
|
|
7
|
-
export interface CodeGenerateInput {
|
|
8
|
-
step: number;
|
|
9
|
-
featureName: string;
|
|
10
|
-
featureDescription: string;
|
|
11
|
-
priority: string;
|
|
12
|
-
technicalStack: ProjectRequirement['technicalStack'];
|
|
13
|
-
userStories?: Array<{
|
|
14
|
-
as: string;
|
|
15
|
-
want: string;
|
|
16
|
-
so: string;
|
|
17
|
-
}>;
|
|
18
|
-
dataModel?: Array<{
|
|
19
|
-
entity: string;
|
|
20
|
-
attributes: any;
|
|
21
|
-
relationships: any;
|
|
22
|
-
}>;
|
|
23
|
-
apiEndpoints?: Array<{
|
|
24
|
-
path: string;
|
|
25
|
-
method: string;
|
|
26
|
-
description: string;
|
|
27
|
-
}>;
|
|
28
|
-
acceptanceCriteria?: string[];
|
|
29
|
-
}
|
|
30
|
-
export interface CodeGenerateAction {
|
|
31
|
-
action: 'read_file' | 'write_file' | 'run_command' | 'search_files';
|
|
32
|
-
path?: string;
|
|
33
|
-
content?: string;
|
|
34
|
-
command?: string;
|
|
35
|
-
pattern?: string;
|
|
36
|
-
}
|
|
37
|
-
export interface CodeGenerateOutput {
|
|
38
|
-
step: number;
|
|
39
|
-
featureName: string;
|
|
40
|
-
actions: CodeGenerateAction[];
|
|
41
|
-
}
|
|
42
|
-
export declare class CodeGenerateAgent {
|
|
43
|
-
private ollama;
|
|
44
|
-
private model;
|
|
45
|
-
constructor();
|
|
46
|
-
private getConnection;
|
|
47
|
-
execute(input: CodeGenerateInput): Promise<CodeGenerateOutput>;
|
|
48
|
-
private buildSystemPrompt;
|
|
49
|
-
private buildUserPrompt;
|
|
50
|
-
private parseActionPlan;
|
|
51
|
-
}
|