galaxy-code 0.1.0
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/LICENSE +21 -0
- package/README.md +679 -0
- package/dist/app.d.ts +7 -0
- package/dist/app.js +596 -0
- package/dist/auto-updater.d.ts +21 -0
- package/dist/auto-updater.js +144 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +159 -0
- package/dist/env.d.ts +1 -0
- package/dist/env.js +29 -0
- package/dist/types.d.ts +39 -0
- package/dist/types.js +8 -0
- package/dist/update-checker.d.ts +22 -0
- package/dist/update-checker.js +85 -0
- package/package.json +102 -0
|
@@ -0,0 +1,144 @@
|
|
|
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
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
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 { configManager } from '@workspace/agent-core';
|
|
15
|
+
import { checkForUpdate, shouldSkipVersion } from './update-checker.js';
|
|
16
|
+
import { performUpdate, restartCLI, showUpdateSuccess, showUpdateError, } from './auto-updater.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
|
+
})();
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/env.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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 Loads environment variables from .env files.
|
|
7
|
+
*/
|
|
8
|
+
import { config } from 'dotenv';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { dirname, join } from 'node:path';
|
|
11
|
+
// Get the directory where this file is located
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
// Load .env from apps/galaxy-code directory (completely silent)
|
|
15
|
+
const originalStdout = process.stdout.write;
|
|
16
|
+
const originalStderr = process.stderr.write;
|
|
17
|
+
const originalConsoleLog = console.log;
|
|
18
|
+
const originalConsoleInfo = console.info;
|
|
19
|
+
// Suppress all possible output channels
|
|
20
|
+
process.stdout.write = () => true;
|
|
21
|
+
process.stderr.write = () => true;
|
|
22
|
+
console.log = () => { };
|
|
23
|
+
console.info = () => { };
|
|
24
|
+
config({ path: join(__dirname, '..', '.env'), debug: false, override: false });
|
|
25
|
+
// Restore output
|
|
26
|
+
process.stdout.write = originalStdout;
|
|
27
|
+
process.stderr.write = originalStderr;
|
|
28
|
+
console.log = originalConsoleLog;
|
|
29
|
+
console.info = originalConsoleInfo;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author Bùi Trọng Hiếu
|
|
3
|
+
* @email kevinbui210191@gmail.com
|
|
4
|
+
* @create 2024-10-08
|
|
5
|
+
* @modify 2025-10-21
|
|
6
|
+
* @desc Type definitions for Galaxy Code
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolExecutionInfo } from '@workspace/agent-core';
|
|
9
|
+
export type MessageAuthor = 'user' | 'assistant' | 'system' | 'tool' | 'plan';
|
|
10
|
+
export interface ConversationMessage {
|
|
11
|
+
id: string;
|
|
12
|
+
author: MessageAuthor;
|
|
13
|
+
content: string;
|
|
14
|
+
toolName?: string;
|
|
15
|
+
toolInfo?: ToolExecutionInfo;
|
|
16
|
+
timestamp: number;
|
|
17
|
+
}
|
|
18
|
+
export interface BannerMessage {
|
|
19
|
+
id: string;
|
|
20
|
+
type: 'banner';
|
|
21
|
+
}
|
|
22
|
+
export type AppMessage = ConversationMessage | BannerMessage | {
|
|
23
|
+
type: 'plan';
|
|
24
|
+
content: PlanningItem[];
|
|
25
|
+
};
|
|
26
|
+
export interface CommandItem {
|
|
27
|
+
command: string;
|
|
28
|
+
description: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PlanningItem {
|
|
31
|
+
step: number;
|
|
32
|
+
action: string;
|
|
33
|
+
featureName?: string;
|
|
34
|
+
featureDescription?: string;
|
|
35
|
+
priority?: string;
|
|
36
|
+
reasoning?: string;
|
|
37
|
+
tool?: string;
|
|
38
|
+
status?: 'pending' | 'in-progress' | 'completed' | 'failed';
|
|
39
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface UpdateInfo {
|
|
2
|
+
hasUpdate: boolean;
|
|
3
|
+
currentVersion: string;
|
|
4
|
+
latestVersion: string;
|
|
5
|
+
updateAvailable?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Lấy version hiện tại từ package.json
|
|
9
|
+
*/
|
|
10
|
+
export declare function getCurrentVersion(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Fetch latest version từ npm registry
|
|
13
|
+
*/
|
|
14
|
+
export declare function fetchLatestVersion(packageName?: string, timeout?: number): Promise<string | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Kiểm tra xem có version mới không
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkForUpdate(timeout?: number): Promise<UpdateInfo | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Kiểm tra xem version có trong skipVersions không
|
|
21
|
+
*/
|
|
22
|
+
export declare function shouldSkipVersion(version: string, skipVersions: string[]): boolean;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author Bùi Trọng Hiếu
|
|
3
|
+
* @email kevinbui210191@gmail.com
|
|
4
|
+
* @create 2025-11-17
|
|
5
|
+
* @desc Update checker - kiểm tra version mới từ npm registry
|
|
6
|
+
*/
|
|
7
|
+
import semver from 'semver';
|
|
8
|
+
import { readFileSync } from 'node:fs';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { dirname, join } from 'node:path';
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = dirname(__filename);
|
|
13
|
+
/**
|
|
14
|
+
* Lấy version hiện tại từ package.json
|
|
15
|
+
*/
|
|
16
|
+
export function getCurrentVersion() {
|
|
17
|
+
try {
|
|
18
|
+
const packagePath = join(__dirname, '../package.json');
|
|
19
|
+
const packageJson = JSON.parse(readFileSync(packagePath, 'utf-8'));
|
|
20
|
+
return packageJson.version;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return '0.1.0'; // Fallback version
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Fetch latest version từ npm registry
|
|
28
|
+
*/
|
|
29
|
+
export async function fetchLatestVersion(packageName = 'galaxy-code', timeout = 3000) {
|
|
30
|
+
try {
|
|
31
|
+
const controller = new AbortController();
|
|
32
|
+
const timeoutId = setTimeout(() => {
|
|
33
|
+
controller.abort();
|
|
34
|
+
}, timeout);
|
|
35
|
+
const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
|
|
36
|
+
signal: controller.signal,
|
|
37
|
+
headers: {
|
|
38
|
+
Accept: 'application/json',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
clearTimeout(timeoutId);
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const data = (await response.json());
|
|
46
|
+
return data.version;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
// Network error, timeout, or npm registry không available
|
|
50
|
+
if (error instanceof Error && error.name !== 'AbortError') {
|
|
51
|
+
console.debug('Failed to fetch latest version:', error.message);
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Kiểm tra xem có version mới không
|
|
58
|
+
*/
|
|
59
|
+
export async function checkForUpdate(timeout = 3000) {
|
|
60
|
+
try {
|
|
61
|
+
const currentVersion = getCurrentVersion();
|
|
62
|
+
const latestVersion = await fetchLatestVersion('galaxy-code', timeout);
|
|
63
|
+
if (!latestVersion) {
|
|
64
|
+
return null; // Không thể fetch được version mới
|
|
65
|
+
}
|
|
66
|
+
// So sánh version bằng semver
|
|
67
|
+
const hasUpdate = semver.gt(latestVersion, currentVersion);
|
|
68
|
+
return {
|
|
69
|
+
hasUpdate,
|
|
70
|
+
currentVersion,
|
|
71
|
+
latestVersion,
|
|
72
|
+
updateAvailable: hasUpdate,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.debug('Error checking for update:', error);
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Kiểm tra xem version có trong skipVersions không
|
|
82
|
+
*/
|
|
83
|
+
export function shouldSkipVersion(version, skipVersions) {
|
|
84
|
+
return skipVersions.includes(version);
|
|
85
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "galaxy-code",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Galaxy Code - AI-powered coding assistant with MCP integration",
|
|
6
|
+
"author": "Galaxy Agent <galaxy.ai.dev@gmail.com> (https://github.com/galaxy-agent)",
|
|
7
|
+
"homepage": "https://github.com/buikevin/galaxy-code#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/buikevin/galaxy-code.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/buikevin/galaxy-code/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"ai",
|
|
17
|
+
"assistant",
|
|
18
|
+
"cli",
|
|
19
|
+
"code-generation",
|
|
20
|
+
"mcp",
|
|
21
|
+
"productivity",
|
|
22
|
+
"galaxy"
|
|
23
|
+
],
|
|
24
|
+
"bin": {
|
|
25
|
+
"galaxy-code": "./dist/cli.js"
|
|
26
|
+
},
|
|
27
|
+
"type": "module",
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18.14.1"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"dev": "tsc --watch",
|
|
34
|
+
"test": "prettier --check . && xo && ava",
|
|
35
|
+
"docs:dev": "cd docs && astro dev",
|
|
36
|
+
"docs:build": "cd docs && astro build",
|
|
37
|
+
"devtools": "react-devtools",
|
|
38
|
+
"debug": "npm run build && NODE_ENV=development node dist/cli.js --dev",
|
|
39
|
+
"prepublish": "npm run build",
|
|
40
|
+
"publish:npm": "node scripts/publish-npm.js"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"README.md",
|
|
45
|
+
"LICENSE"
|
|
46
|
+
],
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public",
|
|
49
|
+
"registry": "https://registry.npmjs.org/"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@anthropic-ai/sdk": "^0.27.0",
|
|
53
|
+
"@google/genai": "^1.21.0",
|
|
54
|
+
"dotenv": "^17.2.3",
|
|
55
|
+
"figlet": "^1.9.3",
|
|
56
|
+
"ink": "^4.1.0",
|
|
57
|
+
"ink-spinner": "^5.0.0",
|
|
58
|
+
"ink-text-input": "^6.0.0",
|
|
59
|
+
"meow": "^11.0.0",
|
|
60
|
+
"ollama": "^0.6.0",
|
|
61
|
+
"react": "^18.2.0",
|
|
62
|
+
"semver": "^7.6.0"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@astrojs/starlight": "0.36.0",
|
|
66
|
+
"@sindresorhus/tsconfig": "^3.0.1",
|
|
67
|
+
"@types/react": "^18.0.32",
|
|
68
|
+
"@types/semver": "^7.5.6",
|
|
69
|
+
"@vdemedes/prettier-config": "^2.0.1",
|
|
70
|
+
"astro": "5.14.5",
|
|
71
|
+
"ava": "^5.2.0",
|
|
72
|
+
"chalk": "^5.2.0",
|
|
73
|
+
"eslint-config-xo-react": "^0.27.0",
|
|
74
|
+
"eslint-plugin-react": "^7.32.2",
|
|
75
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
76
|
+
"ink-testing-library": "^3.0.0",
|
|
77
|
+
"prettier": "^2.8.7",
|
|
78
|
+
"react-devtools": "^7.0.0",
|
|
79
|
+
"react-devtools-core": "^7.0.0",
|
|
80
|
+
"ts-node": "^10.9.1",
|
|
81
|
+
"typescript": "^5.0.3",
|
|
82
|
+
"xo": "^0.53.1"
|
|
83
|
+
},
|
|
84
|
+
"ava": {
|
|
85
|
+
"extensions": {
|
|
86
|
+
"ts": "module",
|
|
87
|
+
"tsx": "module"
|
|
88
|
+
},
|
|
89
|
+
"nodeArguments": [
|
|
90
|
+
"--loader=ts-node/esm"
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
"xo": {
|
|
94
|
+
"extends": "xo-react",
|
|
95
|
+
"prettier": true,
|
|
96
|
+
"rules": {
|
|
97
|
+
"react/prop-types": "off",
|
|
98
|
+
"unicorn/expiring-todo-comments": "off"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"prettier": "@vdemedes/prettier-config"
|
|
102
|
+
}
|