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
package/dist/auto-updater.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author Bùi Trọng Hiếu
|
|
3
|
-
* @email kevinbui210191@gmail.com
|
|
4
|
-
* @create 2025-11-17
|
|
5
|
-
* @desc Auto updater - tự động cập nhật CLI khi có version mới
|
|
6
|
-
*/
|
|
7
|
-
import { execSync, spawn } from 'node:child_process';
|
|
8
|
-
import { existsSync, writeFileSync, unlinkSync } from 'node:fs';
|
|
9
|
-
import { tmpdir } from 'node:os';
|
|
10
|
-
import { join } from 'node:path';
|
|
11
|
-
/**
|
|
12
|
-
* Tạo lock file để tránh concurrent updates
|
|
13
|
-
*/
|
|
14
|
-
function createLockFile() {
|
|
15
|
-
const lockPath = join(tmpdir(), 'galaxy-code-update.lock');
|
|
16
|
-
writeFileSync(lockPath, Date.now().toString());
|
|
17
|
-
return lockPath;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Xóa lock file
|
|
21
|
-
*/
|
|
22
|
-
function removeLockFile(lockPath) {
|
|
23
|
-
try {
|
|
24
|
-
if (existsSync(lockPath)) {
|
|
25
|
-
unlinkSync(lockPath);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
// Ignore errors
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Kiểm tra xem có process khác đang update không
|
|
34
|
-
*/
|
|
35
|
-
function isUpdateInProgress() {
|
|
36
|
-
const lockPath = join(tmpdir(), 'galaxy-code-update.lock');
|
|
37
|
-
if (!existsSync(lockPath)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
// Kiểm tra xem lock file có quá cũ không (> 5 phút)
|
|
41
|
-
try {
|
|
42
|
-
const lockTime = Number.parseInt(existsSync(lockPath) ? '' : '0', 10);
|
|
43
|
-
const now = Date.now();
|
|
44
|
-
const fiveMinutes = 5 * 60 * 1000;
|
|
45
|
-
if (now - lockTime > fiveMinutes) {
|
|
46
|
-
// Lock file quá cũ, xóa đi
|
|
47
|
-
removeLockFile(lockPath);
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Kiểm tra xem có phải permission error không
|
|
58
|
-
*/
|
|
59
|
-
function isPermissionError(error) {
|
|
60
|
-
const message = error.message.toLowerCase();
|
|
61
|
-
return (message.includes('eacces')
|
|
62
|
-
|| message.includes('permission')
|
|
63
|
-
|| message.includes('eperm'));
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Thực hiện update bằng npm install
|
|
67
|
-
*/
|
|
68
|
-
export async function performUpdate(version) {
|
|
69
|
-
// Kiểm tra concurrent update
|
|
70
|
-
if (isUpdateInProgress()) {
|
|
71
|
-
return {
|
|
72
|
-
success: false,
|
|
73
|
-
error: 'Đang có process khác đang cập nhật...',
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const lockPath = createLockFile();
|
|
77
|
-
try {
|
|
78
|
-
// Thử update bằng npm install -g
|
|
79
|
-
const command = `npm install -g galaxy-code@${version}`;
|
|
80
|
-
execSync(command, {
|
|
81
|
-
stdio: 'pipe',
|
|
82
|
-
timeout: 60000, // 60s timeout
|
|
83
|
-
});
|
|
84
|
-
// Update thành công
|
|
85
|
-
removeLockFile(lockPath);
|
|
86
|
-
return {
|
|
87
|
-
success: true,
|
|
88
|
-
needsRestart: true,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
removeLockFile(lockPath);
|
|
93
|
-
if (error instanceof Error) {
|
|
94
|
-
// Kiểm tra permission error
|
|
95
|
-
if (isPermissionError(error)) {
|
|
96
|
-
return {
|
|
97
|
-
success: false,
|
|
98
|
-
error: `Cần quyền admin để cập nhật. Vui lòng chạy:\n sudo npm install -g galaxy-code@${version}`,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
success: false,
|
|
103
|
-
error: `Cập nhật thất bại: ${error.message}`,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
success: false,
|
|
108
|
-
error: 'Cập nhật thất bại với lỗi không xác định',
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Restart CLI với arguments hiện tại
|
|
114
|
-
*/
|
|
115
|
-
export function restartCLI() {
|
|
116
|
-
const args = process.argv.slice(2);
|
|
117
|
-
// Spawn new process
|
|
118
|
-
const child = spawn('galaxy-code', args, {
|
|
119
|
-
detached: true,
|
|
120
|
-
stdio: 'inherit',
|
|
121
|
-
});
|
|
122
|
-
child.unref();
|
|
123
|
-
// Exit current process
|
|
124
|
-
process.exit(0);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Hiển thị thông báo update thành công
|
|
128
|
-
*/
|
|
129
|
-
export function showUpdateSuccess(version) {
|
|
130
|
-
console.log('');
|
|
131
|
-
console.log(`✅ Đã cập nhật lên phiên bản ${version} thành công!`);
|
|
132
|
-
console.log('');
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Hiển thị thông báo update failed
|
|
136
|
-
*/
|
|
137
|
-
export function showUpdateError(error) {
|
|
138
|
-
console.log('');
|
|
139
|
-
console.log('⚠️ Không thể cập nhật tự động');
|
|
140
|
-
console.log(error);
|
|
141
|
-
console.log('');
|
|
142
|
-
console.log('Đang tiếp tục với phiên bản hiện tại...');
|
|
143
|
-
console.log('');
|
|
144
|
-
}
|
package/dist/cli.d.ts
DELETED
package/dist/cli.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* @author Bùi Trọng Hiếu
|
|
4
|
-
* @email kevinbui210191@gmail.com
|
|
5
|
-
* @create 2024-10-08
|
|
6
|
-
* @modify 2025-11-17
|
|
7
|
-
* @desc CLI entrypoint with config management, agent routing, DevTools, and auto-update.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import { render } from 'ink';
|
|
11
|
-
import meow from 'meow';
|
|
12
|
-
import './env.js';
|
|
13
|
-
import App from './app.js';
|
|
14
|
-
import { checkForUpdate, shouldSkipVersion } from './update-checker.js';
|
|
15
|
-
import { performUpdate, restartCLI, showUpdateSuccess, showUpdateError, } from './auto-updater.js';
|
|
16
|
-
import { configManager } from './utils/config-manager.js';
|
|
17
|
-
const cli = meow(`
|
|
18
|
-
Cách sử dụng
|
|
19
|
-
$ galaxy [tùy chọn]
|
|
20
|
-
|
|
21
|
-
Tùy chọn
|
|
22
|
-
--help Hiển thị trợ giúp
|
|
23
|
-
--version Hiển thị phiên bản
|
|
24
|
-
--git Bật git operations (mặc định: từ config)
|
|
25
|
-
--test Bật test planning (mặc định: từ config)
|
|
26
|
-
--config Hiển thị cấu hình hiện tại
|
|
27
|
-
--reset-config Đặt lại cấu hình về mặc định
|
|
28
|
-
--dev Bật chế độ phát triển với DevTools
|
|
29
|
-
--no-auto-update Tắt auto-update khi khởi động
|
|
30
|
-
|
|
31
|
-
Ví dụ
|
|
32
|
-
$ galaxy
|
|
33
|
-
$ galaxy --test
|
|
34
|
-
$ galaxy --config
|
|
35
|
-
$ galaxy --reset-config
|
|
36
|
-
$ galaxy --dev # Bật DevTools
|
|
37
|
-
|
|
38
|
-
Cấu hình
|
|
39
|
-
Vị trí file cấu hình theo hệ điều hành:
|
|
40
|
-
- macOS/Linux: ~/.galaxy/config.json
|
|
41
|
-
- Windows: %LOCALAPPDATA%\\Galaxy\\config.json
|
|
42
|
-
|
|
43
|
-
Thứ tự ưu tiên: Tham số CLI > config.json > mặc định
|
|
44
|
-
|
|
45
|
-
`, {
|
|
46
|
-
importMeta: import.meta,
|
|
47
|
-
flags: {
|
|
48
|
-
git: {
|
|
49
|
-
type: 'boolean',
|
|
50
|
-
},
|
|
51
|
-
test: {
|
|
52
|
-
type: 'boolean',
|
|
53
|
-
},
|
|
54
|
-
config: {
|
|
55
|
-
type: 'boolean',
|
|
56
|
-
default: false,
|
|
57
|
-
},
|
|
58
|
-
resetConfig: {
|
|
59
|
-
type: 'boolean',
|
|
60
|
-
default: false,
|
|
61
|
-
},
|
|
62
|
-
dev: {
|
|
63
|
-
type: 'boolean',
|
|
64
|
-
default: false,
|
|
65
|
-
},
|
|
66
|
-
noAutoUpdate: {
|
|
67
|
-
type: 'boolean',
|
|
68
|
-
default: false,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
/**
|
|
73
|
-
* Handle auto-update logic
|
|
74
|
-
*/
|
|
75
|
-
async function handleAutoUpdate() {
|
|
76
|
-
// Get config
|
|
77
|
-
const config = configManager.getConfig();
|
|
78
|
-
const autoUpdateConfig = config.autoUpdate;
|
|
79
|
-
// Check if auto-update is disabled
|
|
80
|
-
if (!autoUpdateConfig.enabled ||
|
|
81
|
-
!autoUpdateConfig.checkOnStartup ||
|
|
82
|
-
cli.flags.noAutoUpdate) {
|
|
83
|
-
return false; // Skip update
|
|
84
|
-
}
|
|
85
|
-
try {
|
|
86
|
-
// Check for update (với timeout từ config)
|
|
87
|
-
const updateInfo = await checkForUpdate(autoUpdateConfig.timeout);
|
|
88
|
-
if (!updateInfo || !updateInfo.hasUpdate) {
|
|
89
|
-
return false; // Không có update
|
|
90
|
-
}
|
|
91
|
-
// Check if version is in skipVersions
|
|
92
|
-
if (shouldSkipVersion(updateInfo.latestVersion, autoUpdateConfig.skipVersions)) {
|
|
93
|
-
return false; // Skip version này
|
|
94
|
-
}
|
|
95
|
-
// Có update - hiển thị thông báo
|
|
96
|
-
if (!autoUpdateConfig.silent) {
|
|
97
|
-
console.log('');
|
|
98
|
-
console.log(`🚀 Phát hiện phiên bản mới ${updateInfo.latestVersion}, đang cập nhật...`);
|
|
99
|
-
console.log('');
|
|
100
|
-
}
|
|
101
|
-
// Thực hiện update
|
|
102
|
-
const updateResult = await performUpdate(updateInfo.latestVersion);
|
|
103
|
-
if (updateResult.success) {
|
|
104
|
-
// Update thành công
|
|
105
|
-
showUpdateSuccess(updateInfo.latestVersion);
|
|
106
|
-
// Update lastChecked
|
|
107
|
-
configManager.updateConfig({
|
|
108
|
-
...config,
|
|
109
|
-
autoUpdate: {
|
|
110
|
-
...autoUpdateConfig,
|
|
111
|
-
lastChecked: Date.now(),
|
|
112
|
-
lastAttemptedVersion: updateInfo.latestVersion,
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
// Restart CLI
|
|
116
|
-
if (updateResult.needsRestart) {
|
|
117
|
-
restartCLI();
|
|
118
|
-
return true; // CLI sẽ restart, return true để không render App
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
// Update failed
|
|
123
|
-
if (updateResult.error) {
|
|
124
|
-
showUpdateError(updateResult.error);
|
|
125
|
-
}
|
|
126
|
-
// Increment maxAttempts counter nếu cần
|
|
127
|
-
// TODO: Implement attempt counter logic
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
// Silent fail - tiếp tục chạy CLI với version hiện tại
|
|
132
|
-
console.debug('Auto-update failed:', error);
|
|
133
|
-
}
|
|
134
|
-
return false; // Không update được, tiếp tục chạy CLI
|
|
135
|
-
}
|
|
136
|
-
// Main async function
|
|
137
|
-
(async () => {
|
|
138
|
-
// Handle special commands
|
|
139
|
-
if (cli.flags.config) {
|
|
140
|
-
configManager.displayConfig();
|
|
141
|
-
process.exit(0);
|
|
142
|
-
}
|
|
143
|
-
if (cli.flags.resetConfig) {
|
|
144
|
-
configManager.resetConfig();
|
|
145
|
-
process.exit(0);
|
|
146
|
-
}
|
|
147
|
-
// Handle auto-update (nếu có update thì sẽ restart, không chạy tiếp)
|
|
148
|
-
const didUpdate = await handleAutoUpdate();
|
|
149
|
-
if (didUpdate) {
|
|
150
|
-
return; // CLI đã restart, không cần render App
|
|
151
|
-
}
|
|
152
|
-
// Get merged config (CLI flags override config file)
|
|
153
|
-
const config = configManager.getMergedConfig({
|
|
154
|
-
git: cli.flags.git,
|
|
155
|
-
test: cli.flags.test,
|
|
156
|
-
});
|
|
157
|
-
// Render app with config object
|
|
158
|
-
render(React.createElement(App, { config: config }));
|
|
159
|
-
})();
|