galaxy-code 0.1.6 → 0.1.8
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 +317 -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,244 +0,0 @@
|
|
|
1
|
-
import { execa } from 'execa';
|
|
2
|
-
/**
|
|
3
|
-
* Galaxy UI CLI Integration
|
|
4
|
-
* Provides tools to discover, search, and install Galaxy UI components
|
|
5
|
-
*
|
|
6
|
-
* Data Sources:
|
|
7
|
-
* - Component Registry: npm CDN (https://unpkg.com/galaxy-design@latest/dist/registry.json)
|
|
8
|
-
* Alternative CDN: https://cdn.jsdelivr.net/npm/galaxy-design@latest/dist/registry.json
|
|
9
|
-
* - Documentation: https://galaxy-design.vercel.app
|
|
10
|
-
* - CLI Execution: npx galaxy-design@latest
|
|
11
|
-
*/
|
|
12
|
-
const GITHUB_REGISTRY_URL = 'https://unpkg.com/galaxy-design@latest/dist/registry.json';
|
|
13
|
-
const DOCS_BASE_URL = 'https://galaxy-design.vercel.app';
|
|
14
|
-
// Cache for registry data (5 minutes)
|
|
15
|
-
let registryCache = {
|
|
16
|
-
data: null,
|
|
17
|
-
timestamp: 0,
|
|
18
|
-
};
|
|
19
|
-
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
|
|
20
|
-
/**
|
|
21
|
-
* Fetch component registry from GitHub (supports private repos with GITHUB_TOKEN)
|
|
22
|
-
*/
|
|
23
|
-
async function fetchRegistry() {
|
|
24
|
-
const now = Date.now();
|
|
25
|
-
// Return cached data if still valid
|
|
26
|
-
if (registryCache.data && now - registryCache.timestamp < CACHE_TTL) {
|
|
27
|
-
return registryCache.data;
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
// Prepare headers with authentication if GITHUB_TOKEN is available
|
|
31
|
-
const headers = {
|
|
32
|
-
'Accept': 'application/vnd.github.v3.raw',
|
|
33
|
-
};
|
|
34
|
-
const githubToken = process.env['GITHUB_TOKEN'];
|
|
35
|
-
if (githubToken) {
|
|
36
|
-
headers['Authorization'] = `Bearer ${githubToken}`;
|
|
37
|
-
}
|
|
38
|
-
const response = await fetch(GITHUB_REGISTRY_URL, { headers });
|
|
39
|
-
if (!response.ok) {
|
|
40
|
-
throw new Error(`Failed to fetch registry: ${response.statusText}`);
|
|
41
|
-
}
|
|
42
|
-
const data = (await response.json());
|
|
43
|
-
// Update cache
|
|
44
|
-
registryCache = {
|
|
45
|
-
data,
|
|
46
|
-
timestamp: now,
|
|
47
|
-
};
|
|
48
|
-
return data;
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
throw new Error(`Failed to fetch Galaxy UI registry: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Tool 1: List all components
|
|
56
|
-
* Fetches from GitHub registry.json
|
|
57
|
-
*/
|
|
58
|
-
export async function galaxyUIListComponents(params) {
|
|
59
|
-
const registry = await fetchRegistry();
|
|
60
|
-
const components = Object.entries(registry.components).map(([name, config]) => ({
|
|
61
|
-
name,
|
|
62
|
-
description: config.description,
|
|
63
|
-
category: config.type,
|
|
64
|
-
docsUrl: `${DOCS_BASE_URL}/components/${name}`,
|
|
65
|
-
}));
|
|
66
|
-
// Filter by category if specified
|
|
67
|
-
const filtered = params?.category && params.category !== 'all'
|
|
68
|
-
? components.filter(c => c.category === params.category)
|
|
69
|
-
: components;
|
|
70
|
-
return {
|
|
71
|
-
total: filtered.length,
|
|
72
|
-
components: filtered,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Tool 2: Search components by keyword
|
|
77
|
-
* Searches in component name and description
|
|
78
|
-
*/
|
|
79
|
-
export async function galaxyUISearchComponents(params) {
|
|
80
|
-
const registry = await fetchRegistry();
|
|
81
|
-
const query = params.query.toLowerCase();
|
|
82
|
-
const results = Object.entries(registry.components)
|
|
83
|
-
.map(([name, config]) => {
|
|
84
|
-
const nameMatch = name.toLowerCase().includes(query);
|
|
85
|
-
const descMatch = config.description.toLowerCase().includes(query);
|
|
86
|
-
const categoryMatch = config.type.toLowerCase().includes(query);
|
|
87
|
-
// Calculate relevance
|
|
88
|
-
let relevance = 'low';
|
|
89
|
-
if (nameMatch)
|
|
90
|
-
relevance = 'high';
|
|
91
|
-
else if (categoryMatch)
|
|
92
|
-
relevance = 'medium';
|
|
93
|
-
else if (descMatch)
|
|
94
|
-
relevance = 'low';
|
|
95
|
-
const isMatch = nameMatch || descMatch || categoryMatch;
|
|
96
|
-
return {
|
|
97
|
-
name,
|
|
98
|
-
description: config.description,
|
|
99
|
-
category: config.type,
|
|
100
|
-
docsUrl: `${DOCS_BASE_URL}/components/${name}`,
|
|
101
|
-
relevance,
|
|
102
|
-
isMatch,
|
|
103
|
-
};
|
|
104
|
-
})
|
|
105
|
-
.filter(result => result.isMatch)
|
|
106
|
-
.sort((a, b) => {
|
|
107
|
-
// Sort by relevance: high > medium > low
|
|
108
|
-
const relevanceOrder = { high: 0, medium: 1, low: 2 };
|
|
109
|
-
return relevanceOrder[a.relevance] - relevanceOrder[b.relevance];
|
|
110
|
-
});
|
|
111
|
-
return {
|
|
112
|
-
total: results.length,
|
|
113
|
-
components: results,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Tool 3: Get component details
|
|
118
|
-
* Returns component info from registry + docs URL
|
|
119
|
-
*/
|
|
120
|
-
export async function galaxyUIGetComponent(params) {
|
|
121
|
-
const registry = await fetchRegistry();
|
|
122
|
-
const component = registry.components[params.name];
|
|
123
|
-
if (!component) {
|
|
124
|
-
throw new Error(`Component "${params.name}" not found. Use galaxy_ui_list_components or galaxy_ui_search_components to find available components.`);
|
|
125
|
-
}
|
|
126
|
-
const docsUrl = `${DOCS_BASE_URL}/components/${params.name}`;
|
|
127
|
-
const docsUrlFramework = params.framework ? `${docsUrl}?framework=${params.framework}` : undefined;
|
|
128
|
-
return {
|
|
129
|
-
name: params.name,
|
|
130
|
-
description: component.description,
|
|
131
|
-
category: component.type,
|
|
132
|
-
dependencies: component.dependencies || [],
|
|
133
|
-
peerDependencies: component.peerDependencies || [],
|
|
134
|
-
docsUrl,
|
|
135
|
-
docsUrlFramework,
|
|
136
|
-
installCommand: `npx galaxy-design add ${params.name}`,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Tool 4: Get component categories with counts
|
|
141
|
-
* Groups components by category from registry
|
|
142
|
-
*/
|
|
143
|
-
export async function galaxyUIGetCategories() {
|
|
144
|
-
const registry = await fetchRegistry();
|
|
145
|
-
// Group components by category
|
|
146
|
-
const categoryMap = new Map();
|
|
147
|
-
for (const [name, config] of Object.entries(registry.components)) {
|
|
148
|
-
const category = config.type;
|
|
149
|
-
if (!categoryMap.has(category)) {
|
|
150
|
-
categoryMap.set(category, []);
|
|
151
|
-
}
|
|
152
|
-
categoryMap.get(category).push(name);
|
|
153
|
-
}
|
|
154
|
-
const categories = Array.from(categoryMap.entries())
|
|
155
|
-
.map(([name, components]) => ({
|
|
156
|
-
name,
|
|
157
|
-
count: components.length,
|
|
158
|
-
components: components.sort(),
|
|
159
|
-
}))
|
|
160
|
-
.sort((a, b) => b.count - a.count); // Sort by count descending
|
|
161
|
-
return { categories };
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Tool 5: Add components to project
|
|
165
|
-
* Executes: npx galaxy-design add [components...] --cwd [path]
|
|
166
|
-
*/
|
|
167
|
-
export async function galaxyUIAddComponents(params) {
|
|
168
|
-
try {
|
|
169
|
-
const args = ['galaxy-design', 'add', ...params.components];
|
|
170
|
-
if (params.cwd) {
|
|
171
|
-
args.push('--cwd', params.cwd);
|
|
172
|
-
}
|
|
173
|
-
const result = await execa('npx', args, {
|
|
174
|
-
cwd: params.cwd || process.cwd(),
|
|
175
|
-
stderr: 'pipe',
|
|
176
|
-
stdout: 'pipe',
|
|
177
|
-
});
|
|
178
|
-
return {
|
|
179
|
-
success: true,
|
|
180
|
-
message: `Successfully added components: ${params.components.join(', ')}`,
|
|
181
|
-
output: result.stdout,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
const execError = error;
|
|
186
|
-
return {
|
|
187
|
-
success: false,
|
|
188
|
-
message: `Failed to add components: ${params.components.join(', ')}`,
|
|
189
|
-
output: execError.stderr || execError.stdout || 'Unknown error',
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Tool 6: Initialize Galaxy UI in project
|
|
195
|
-
* Executes: npx galaxy-design@latest init --yes --cwd [path]
|
|
196
|
-
*/
|
|
197
|
-
export async function galaxyUIInit(params) {
|
|
198
|
-
try {
|
|
199
|
-
const args = ['galaxy-design@latest', 'init'];
|
|
200
|
-
if (params?.skipPrompts) {
|
|
201
|
-
args.push('--yes');
|
|
202
|
-
}
|
|
203
|
-
if (params?.cwd) {
|
|
204
|
-
args.push('--cwd', params.cwd);
|
|
205
|
-
}
|
|
206
|
-
const result = await execa('npx', args, {
|
|
207
|
-
cwd: params?.cwd || process.cwd(),
|
|
208
|
-
stderr: 'pipe',
|
|
209
|
-
stdout: 'pipe',
|
|
210
|
-
});
|
|
211
|
-
return {
|
|
212
|
-
success: true,
|
|
213
|
-
message: 'Successfully initialized Galaxy UI',
|
|
214
|
-
output: result.stdout,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
catch (error) {
|
|
218
|
-
const execError = error;
|
|
219
|
-
return {
|
|
220
|
-
success: false,
|
|
221
|
-
message: 'Failed to initialize Galaxy UI',
|
|
222
|
-
output: execError.stderr || execError.stdout || 'Unknown error',
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Tool 7: Get documentation URL
|
|
228
|
-
* Returns direct link to component docs or main docs
|
|
229
|
-
*/
|
|
230
|
-
export function galaxyUIGetDocsUrl(params) {
|
|
231
|
-
if (params?.component) {
|
|
232
|
-
const lang = params.language === 'vi' ? '/vi' : '';
|
|
233
|
-
const url = `${DOCS_BASE_URL}${lang}/components/${params.component}`;
|
|
234
|
-
return {
|
|
235
|
-
url,
|
|
236
|
-
description: `Documentation for ${params.component} component`,
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
const lang = params?.language === 'vi' ? '/vi' : '';
|
|
240
|
-
return {
|
|
241
|
-
url: `${DOCS_BASE_URL}${lang}`,
|
|
242
|
-
description: 'Galaxy UI CLI Documentation',
|
|
243
|
-
};
|
|
244
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare class GitOperations {
|
|
2
|
-
getStatus(cwd: string): Promise<string>;
|
|
3
|
-
commit(cwd: string, message: string): Promise<string>;
|
|
4
|
-
push(cwd: string, remote?: string, branch?: string): Promise<string>;
|
|
5
|
-
pull(cwd: string, remote?: string, branch?: string): Promise<string>;
|
|
6
|
-
getDiff(cwd: string, file?: string): Promise<string>;
|
|
7
|
-
getLog(cwd: string, limit?: number): Promise<string>;
|
|
8
|
-
listBranches(cwd: string): Promise<string>;
|
|
9
|
-
createBranch(cwd: string, branchName: string): Promise<string>;
|
|
10
|
-
switchBranch(cwd: string, branchName: string): Promise<string>;
|
|
11
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { exec } from 'child_process';
|
|
2
|
-
import { promisify } from 'util';
|
|
3
|
-
const execAsync = promisify(exec);
|
|
4
|
-
export class GitOperations {
|
|
5
|
-
async getStatus(cwd) {
|
|
6
|
-
try {
|
|
7
|
-
const { stdout } = await execAsync('git status --short', {
|
|
8
|
-
cwd,
|
|
9
|
-
timeout: 5000,
|
|
10
|
-
});
|
|
11
|
-
return stdout || 'Working tree clean';
|
|
12
|
-
}
|
|
13
|
-
catch (error) {
|
|
14
|
-
return `Not a git repository: ${error.message}`;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
async commit(cwd, message) {
|
|
18
|
-
try {
|
|
19
|
-
await execAsync('git add .', { cwd, timeout: 5000 });
|
|
20
|
-
const { stdout } = await execAsync(`git commit -m "${message.replace(/"/g, '\\"')}"`, {
|
|
21
|
-
cwd,
|
|
22
|
-
timeout: 10000,
|
|
23
|
-
});
|
|
24
|
-
return stdout;
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
return `Commit failed: ${error.message}`;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async push(cwd, remote = 'origin', branch) {
|
|
31
|
-
try {
|
|
32
|
-
const branchArg = branch ? ` ${branch}` : '';
|
|
33
|
-
const { stdout } = await execAsync(`git push ${remote}${branchArg}`, {
|
|
34
|
-
cwd,
|
|
35
|
-
timeout: 30000,
|
|
36
|
-
});
|
|
37
|
-
return stdout;
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
return `Push failed: ${error.message}`;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async pull(cwd, remote = 'origin', branch) {
|
|
44
|
-
try {
|
|
45
|
-
const branchArg = branch ? ` ${branch}` : '';
|
|
46
|
-
const { stdout } = await execAsync(`git pull ${remote}${branchArg}`, {
|
|
47
|
-
cwd,
|
|
48
|
-
timeout: 30000,
|
|
49
|
-
});
|
|
50
|
-
return stdout;
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
return `Pull failed: ${error.message}`;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async getDiff(cwd, file) {
|
|
57
|
-
try {
|
|
58
|
-
const fileArg = file ? ` "${file}"` : '';
|
|
59
|
-
const { stdout } = await execAsync(`git diff${fileArg}`, {
|
|
60
|
-
cwd,
|
|
61
|
-
timeout: 10000,
|
|
62
|
-
});
|
|
63
|
-
return stdout || 'No changes';
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
return `Diff failed: ${error.message}`;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async getLog(cwd, limit = 10) {
|
|
70
|
-
try {
|
|
71
|
-
const { stdout } = await execAsync(`git log --oneline -${limit}`, {
|
|
72
|
-
cwd,
|
|
73
|
-
timeout: 5000,
|
|
74
|
-
});
|
|
75
|
-
return stdout;
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
return `Log failed: ${error.message}`;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
async listBranches(cwd) {
|
|
82
|
-
try {
|
|
83
|
-
const { stdout } = await execAsync('git branch -a', { cwd, timeout: 5000 });
|
|
84
|
-
return stdout;
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
return `Branch list failed: ${error.message}`;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
async createBranch(cwd, branchName) {
|
|
91
|
-
try {
|
|
92
|
-
const { stdout } = await execAsync(`git checkout -b "${branchName}"`, {
|
|
93
|
-
cwd,
|
|
94
|
-
timeout: 5000,
|
|
95
|
-
});
|
|
96
|
-
return stdout;
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
return `Branch creation failed: ${error.message}`;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
async switchBranch(cwd, branchName) {
|
|
103
|
-
try {
|
|
104
|
-
const { stdout } = await execAsync(`git checkout "${branchName}"`, {
|
|
105
|
-
cwd,
|
|
106
|
-
timeout: 5000,
|
|
107
|
-
});
|
|
108
|
-
return stdout;
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
return `Branch switch failed: ${error.message}`;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
package/dist/tools/index.d.ts
DELETED
|
@@ -1,10 +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-08
|
|
6
|
-
* @desc Barrel exports for tool layer.
|
|
7
|
-
*/
|
|
8
|
-
export * from './types.js';
|
|
9
|
-
export * from './registry.js';
|
|
10
|
-
export * from './tool-event-emitter.js';
|
package/dist/tools/index.js
DELETED
|
@@ -1,10 +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-08
|
|
6
|
-
* @desc Barrel exports for tool layer.
|
|
7
|
-
*/
|
|
8
|
-
export * from './types.js';
|
|
9
|
-
export * from './registry.js';
|
|
10
|
-
export * from './tool-event-emitter.js';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Planning Agent - Creates step-by-step execution plans
|
|
3
|
-
* Uses gemini-2.5-flash for intelligent planning
|
|
4
|
-
*/
|
|
5
|
-
import type { ProjectRequirement } from './ba-it-analyzer.js';
|
|
6
|
-
export interface PlanStep {
|
|
7
|
-
step: number;
|
|
8
|
-
action: string;
|
|
9
|
-
tool: string;
|
|
10
|
-
reasoning: string;
|
|
11
|
-
}
|
|
12
|
-
export interface ExecutionPlan {
|
|
13
|
-
summary: string;
|
|
14
|
-
steps: PlanStep[];
|
|
15
|
-
estimatedTime: 'quick' | 'medium' | 'long';
|
|
16
|
-
}
|
|
17
|
-
export declare class PlanningAgent {
|
|
18
|
-
private gemini;
|
|
19
|
-
private model;
|
|
20
|
-
constructor();
|
|
21
|
-
private getConnection;
|
|
22
|
-
generatePlan(userContext: string, baAnalysis?: {
|
|
23
|
-
ba_it_analyze_response: {
|
|
24
|
-
result: ProjectRequirement;
|
|
25
|
-
};
|
|
26
|
-
}): Promise<ExecutionPlan>;
|
|
27
|
-
private extractJSON;
|
|
28
|
-
private createFallbackPlan;
|
|
29
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/tools/registry.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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;
|