galaxy-code 0.1.5 → 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.
Files changed (222) hide show
  1. package/README.md +149 -600
  2. package/dist/cli.bundle.js +588 -0
  3. package/package.json +14 -12
  4. package/dist/app.d.ts +0 -7
  5. package/dist/app.js +0 -597
  6. package/dist/auto-updater.d.ts +0 -21
  7. package/dist/auto-updater.js +0 -144
  8. package/dist/cli.d.ts +0 -2
  9. package/dist/cli.js +0 -159
  10. package/dist/connections/claude.d.ts +0 -71
  11. package/dist/connections/claude.js +0 -303
  12. package/dist/connections/gemini.d.ts +0 -40
  13. package/dist/connections/gemini.js +0 -232
  14. package/dist/connections/index.d.ts +0 -11
  15. package/dist/connections/index.js +0 -11
  16. package/dist/connections/ollama.d.ts +0 -37
  17. package/dist/connections/ollama.js +0 -73
  18. package/dist/connections/types.d.ts +0 -22
  19. package/dist/connections/types.js +0 -7
  20. package/dist/env.d.ts +0 -1
  21. package/dist/env.js +0 -29
  22. package/dist/node_modules/@workspace/agent-core/connections/claude.d.ts +0 -72
  23. package/dist/node_modules/@workspace/agent-core/connections/claude.d.ts.map +0 -1
  24. package/dist/node_modules/@workspace/agent-core/connections/claude.js +0 -270
  25. package/dist/node_modules/@workspace/agent-core/connections/claude.js.map +0 -1
  26. package/dist/node_modules/@workspace/agent-core/connections/gemini.d.ts +0 -41
  27. package/dist/node_modules/@workspace/agent-core/connections/gemini.d.ts.map +0 -1
  28. package/dist/node_modules/@workspace/agent-core/connections/gemini.js +0 -203
  29. package/dist/node_modules/@workspace/agent-core/connections/gemini.js.map +0 -1
  30. package/dist/node_modules/@workspace/agent-core/connections/index.d.ts +0 -12
  31. package/dist/node_modules/@workspace/agent-core/connections/index.d.ts.map +0 -1
  32. package/dist/node_modules/@workspace/agent-core/connections/index.js +0 -12
  33. package/dist/node_modules/@workspace/agent-core/connections/index.js.map +0 -1
  34. package/dist/node_modules/@workspace/agent-core/connections/ollama.d.ts +0 -38
  35. package/dist/node_modules/@workspace/agent-core/connections/ollama.d.ts.map +0 -1
  36. package/dist/node_modules/@workspace/agent-core/connections/ollama.js +0 -64
  37. package/dist/node_modules/@workspace/agent-core/connections/ollama.js.map +0 -1
  38. package/dist/node_modules/@workspace/agent-core/connections/types.d.ts +0 -23
  39. package/dist/node_modules/@workspace/agent-core/connections/types.d.ts.map +0 -1
  40. package/dist/node_modules/@workspace/agent-core/connections/types.js +0 -8
  41. package/dist/node_modules/@workspace/agent-core/connections/types.js.map +0 -1
  42. package/dist/node_modules/@workspace/agent-core/index.d.ts +0 -13
  43. package/dist/node_modules/@workspace/agent-core/index.d.ts.map +0 -1
  44. package/dist/node_modules/@workspace/agent-core/index.js +0 -22
  45. package/dist/node_modules/@workspace/agent-core/index.js.map +0 -1
  46. package/dist/node_modules/@workspace/agent-core/package.json +0 -53
  47. package/dist/node_modules/@workspace/agent-core/prompts/ba-it-analyzer.d.ts +0 -2
  48. package/dist/node_modules/@workspace/agent-core/prompts/ba-it-analyzer.d.ts.map +0 -1
  49. package/dist/node_modules/@workspace/agent-core/prompts/ba-it-analyzer.js +0 -144
  50. package/dist/node_modules/@workspace/agent-core/prompts/ba-it-analyzer.js.map +0 -1
  51. package/dist/node_modules/@workspace/agent-core/prompts/index.d.ts +0 -12
  52. package/dist/node_modules/@workspace/agent-core/prompts/index.d.ts.map +0 -1
  53. package/dist/node_modules/@workspace/agent-core/prompts/index.js +0 -12
  54. package/dist/node_modules/@workspace/agent-core/prompts/index.js.map +0 -1
  55. package/dist/node_modules/@workspace/agent-core/prompts/orchestrator.d.ts +0 -9
  56. package/dist/node_modules/@workspace/agent-core/prompts/orchestrator.d.ts.map +0 -1
  57. package/dist/node_modules/@workspace/agent-core/prompts/orchestrator.js +0 -89
  58. package/dist/node_modules/@workspace/agent-core/prompts/orchestrator.js.map +0 -1
  59. package/dist/node_modules/@workspace/agent-core/prompts/planning-agent.d.ts +0 -9
  60. package/dist/node_modules/@workspace/agent-core/prompts/planning-agent.d.ts.map +0 -1
  61. package/dist/node_modules/@workspace/agent-core/prompts/planning-agent.js +0 -196
  62. package/dist/node_modules/@workspace/agent-core/prompts/planning-agent.js.map +0 -1
  63. package/dist/node_modules/@workspace/agent-core/prompts/universal-agent.d.ts +0 -8
  64. package/dist/node_modules/@workspace/agent-core/prompts/universal-agent.d.ts.map +0 -1
  65. package/dist/node_modules/@workspace/agent-core/prompts/universal-agent.js +0 -112
  66. package/dist/node_modules/@workspace/agent-core/prompts/universal-agent.js.map +0 -1
  67. package/dist/node_modules/@workspace/agent-core/providers/agent-selector.d.ts +0 -30
  68. package/dist/node_modules/@workspace/agent-core/providers/agent-selector.d.ts.map +0 -1
  69. package/dist/node_modules/@workspace/agent-core/providers/agent-selector.js +0 -76
  70. package/dist/node_modules/@workspace/agent-core/providers/agent-selector.js.map +0 -1
  71. package/dist/node_modules/@workspace/agent-core/providers/claude-agent.d.ts +0 -30
  72. package/dist/node_modules/@workspace/agent-core/providers/claude-agent.d.ts.map +0 -1
  73. package/dist/node_modules/@workspace/agent-core/providers/claude-agent.js +0 -107
  74. package/dist/node_modules/@workspace/agent-core/providers/claude-agent.js.map +0 -1
  75. package/dist/node_modules/@workspace/agent-core/providers/gemini-agent.d.ts +0 -37
  76. package/dist/node_modules/@workspace/agent-core/providers/gemini-agent.d.ts.map +0 -1
  77. package/dist/node_modules/@workspace/agent-core/providers/gemini-agent.js +0 -144
  78. package/dist/node_modules/@workspace/agent-core/providers/gemini-agent.js.map +0 -1
  79. package/dist/node_modules/@workspace/agent-core/providers/index.d.ts +0 -13
  80. package/dist/node_modules/@workspace/agent-core/providers/index.d.ts.map +0 -1
  81. package/dist/node_modules/@workspace/agent-core/providers/index.js +0 -13
  82. package/dist/node_modules/@workspace/agent-core/providers/index.js.map +0 -1
  83. package/dist/node_modules/@workspace/agent-core/providers/ollama-agent.d.ts +0 -54
  84. package/dist/node_modules/@workspace/agent-core/providers/ollama-agent.d.ts.map +0 -1
  85. package/dist/node_modules/@workspace/agent-core/providers/ollama-agent.js +0 -247
  86. package/dist/node_modules/@workspace/agent-core/providers/ollama-agent.js.map +0 -1
  87. package/dist/node_modules/@workspace/agent-core/providers/orchestrator.d.ts +0 -17
  88. package/dist/node_modules/@workspace/agent-core/providers/orchestrator.d.ts.map +0 -1
  89. package/dist/node_modules/@workspace/agent-core/providers/orchestrator.js +0 -62
  90. package/dist/node_modules/@workspace/agent-core/providers/orchestrator.js.map +0 -1
  91. package/dist/node_modules/@workspace/agent-core/tools/ba-it-analyzer.d.ts +0 -67
  92. package/dist/node_modules/@workspace/agent-core/tools/ba-it-analyzer.d.ts.map +0 -1
  93. package/dist/node_modules/@workspace/agent-core/tools/ba-it-analyzer.js +0 -81
  94. package/dist/node_modules/@workspace/agent-core/tools/ba-it-analyzer.js.map +0 -1
  95. package/dist/node_modules/@workspace/agent-core/tools/code-generate-agent.d.ts +0 -52
  96. package/dist/node_modules/@workspace/agent-core/tools/code-generate-agent.d.ts.map +0 -1
  97. package/dist/node_modules/@workspace/agent-core/tools/code-generate-agent.js +0 -150
  98. package/dist/node_modules/@workspace/agent-core/tools/code-generate-agent.js.map +0 -1
  99. package/dist/node_modules/@workspace/agent-core/tools/command-runner.d.ts +0 -15
  100. package/dist/node_modules/@workspace/agent-core/tools/command-runner.d.ts.map +0 -1
  101. package/dist/node_modules/@workspace/agent-core/tools/command-runner.js +0 -121
  102. package/dist/node_modules/@workspace/agent-core/tools/command-runner.js.map +0 -1
  103. package/dist/node_modules/@workspace/agent-core/tools/document-parser.d.ts +0 -12
  104. package/dist/node_modules/@workspace/agent-core/tools/document-parser.d.ts.map +0 -1
  105. package/dist/node_modules/@workspace/agent-core/tools/document-parser.js +0 -84
  106. package/dist/node_modules/@workspace/agent-core/tools/document-parser.js.map +0 -1
  107. package/dist/node_modules/@workspace/agent-core/tools/file-operations.d.ts +0 -18
  108. package/dist/node_modules/@workspace/agent-core/tools/file-operations.d.ts.map +0 -1
  109. package/dist/node_modules/@workspace/agent-core/tools/file-operations.js +0 -126
  110. package/dist/node_modules/@workspace/agent-core/tools/file-operations.js.map +0 -1
  111. package/dist/node_modules/@workspace/agent-core/tools/galaxy-ui-integration.d.ts +0 -95
  112. package/dist/node_modules/@workspace/agent-core/tools/galaxy-ui-integration.d.ts.map +0 -1
  113. package/dist/node_modules/@workspace/agent-core/tools/galaxy-ui-integration.js +0 -245
  114. package/dist/node_modules/@workspace/agent-core/tools/galaxy-ui-integration.js.map +0 -1
  115. package/dist/node_modules/@workspace/agent-core/tools/git-operations.d.ts +0 -12
  116. package/dist/node_modules/@workspace/agent-core/tools/git-operations.d.ts.map +0 -1
  117. package/dist/node_modules/@workspace/agent-core/tools/git-operations.js +0 -115
  118. package/dist/node_modules/@workspace/agent-core/tools/git-operations.js.map +0 -1
  119. package/dist/node_modules/@workspace/agent-core/tools/index.d.ts +0 -11
  120. package/dist/node_modules/@workspace/agent-core/tools/index.d.ts.map +0 -1
  121. package/dist/node_modules/@workspace/agent-core/tools/index.js +0 -11
  122. package/dist/node_modules/@workspace/agent-core/tools/index.js.map +0 -1
  123. package/dist/node_modules/@workspace/agent-core/tools/planning-agent.d.ts +0 -30
  124. package/dist/node_modules/@workspace/agent-core/tools/planning-agent.d.ts.map +0 -1
  125. package/dist/node_modules/@workspace/agent-core/tools/planning-agent.js +0 -125
  126. package/dist/node_modules/@workspace/agent-core/tools/planning-agent.js.map +0 -1
  127. package/dist/node_modules/@workspace/agent-core/tools/progress-reporter.d.ts +0 -20
  128. package/dist/node_modules/@workspace/agent-core/tools/progress-reporter.d.ts.map +0 -1
  129. package/dist/node_modules/@workspace/agent-core/tools/progress-reporter.js +0 -46
  130. package/dist/node_modules/@workspace/agent-core/tools/progress-reporter.js.map +0 -1
  131. package/dist/node_modules/@workspace/agent-core/tools/registry.d.ts +0 -22
  132. package/dist/node_modules/@workspace/agent-core/tools/registry.d.ts.map +0 -1
  133. package/dist/node_modules/@workspace/agent-core/tools/registry.js +0 -651
  134. package/dist/node_modules/@workspace/agent-core/tools/registry.js.map +0 -1
  135. package/dist/node_modules/@workspace/agent-core/tools/tool-event-emitter.d.ts +0 -25
  136. package/dist/node_modules/@workspace/agent-core/tools/tool-event-emitter.d.ts.map +0 -1
  137. package/dist/node_modules/@workspace/agent-core/tools/tool-event-emitter.js +0 -26
  138. package/dist/node_modules/@workspace/agent-core/tools/tool-event-emitter.js.map +0 -1
  139. package/dist/node_modules/@workspace/agent-core/tools/types.d.ts +0 -32
  140. package/dist/node_modules/@workspace/agent-core/tools/types.d.ts.map +0 -1
  141. package/dist/node_modules/@workspace/agent-core/tools/types.js +0 -2
  142. package/dist/node_modules/@workspace/agent-core/tools/types.js.map +0 -1
  143. package/dist/node_modules/@workspace/agent-core/types.d.ts +0 -40
  144. package/dist/node_modules/@workspace/agent-core/types.d.ts.map +0 -1
  145. package/dist/node_modules/@workspace/agent-core/types.js +0 -9
  146. package/dist/node_modules/@workspace/agent-core/types.js.map +0 -1
  147. package/dist/node_modules/@workspace/agent-core/utils/config-manager.d.ts +0 -103
  148. package/dist/node_modules/@workspace/agent-core/utils/config-manager.d.ts.map +0 -1
  149. package/dist/node_modules/@workspace/agent-core/utils/config-manager.js +0 -307
  150. package/dist/node_modules/@workspace/agent-core/utils/config-manager.js.map +0 -1
  151. package/dist/node_modules/@workspace/agent-core/utils/devtools.d.ts +0 -22
  152. package/dist/node_modules/@workspace/agent-core/utils/devtools.d.ts.map +0 -1
  153. package/dist/node_modules/@workspace/agent-core/utils/devtools.js +0 -62
  154. package/dist/node_modules/@workspace/agent-core/utils/devtools.js.map +0 -1
  155. package/dist/node_modules/@workspace/agent-core/utils/message-formatters.d.ts +0 -33
  156. package/dist/node_modules/@workspace/agent-core/utils/message-formatters.d.ts.map +0 -1
  157. package/dist/node_modules/@workspace/agent-core/utils/message-formatters.js +0 -591
  158. package/dist/node_modules/@workspace/agent-core/utils/message-formatters.js.map +0 -1
  159. package/dist/node_modules/@workspace/agent-core/utils/progress-tracker.d.ts +0 -60
  160. package/dist/node_modules/@workspace/agent-core/utils/progress-tracker.d.ts.map +0 -1
  161. package/dist/node_modules/@workspace/agent-core/utils/progress-tracker.js +0 -204
  162. package/dist/node_modules/@workspace/agent-core/utils/progress-tracker.js.map +0 -1
  163. package/dist/prompts/ba-it-analyzer.d.ts +0 -1
  164. package/dist/prompts/ba-it-analyzer.js +0 -143
  165. package/dist/prompts/index.d.ts +0 -11
  166. package/dist/prompts/index.js +0 -11
  167. package/dist/prompts/orchestrator.d.ts +0 -8
  168. package/dist/prompts/orchestrator.js +0 -88
  169. package/dist/prompts/planning-agent.d.ts +0 -8
  170. package/dist/prompts/planning-agent.js +0 -195
  171. package/dist/prompts/universal-agent.d.ts +0 -7
  172. package/dist/prompts/universal-agent.js +0 -111
  173. package/dist/providers/agent-selector.d.ts +0 -29
  174. package/dist/providers/agent-selector.js +0 -84
  175. package/dist/providers/claude-agent.d.ts +0 -29
  176. package/dist/providers/claude-agent.js +0 -121
  177. package/dist/providers/gemini-agent.d.ts +0 -36
  178. package/dist/providers/gemini-agent.js +0 -168
  179. package/dist/providers/index.d.ts +0 -12
  180. package/dist/providers/index.js +0 -12
  181. package/dist/providers/ollama-agent.d.ts +0 -53
  182. package/dist/providers/ollama-agent.js +0 -276
  183. package/dist/providers/orchestrator.d.ts +0 -16
  184. package/dist/providers/orchestrator.js +0 -76
  185. package/dist/tools/ba-it-analyzer.d.ts +0 -66
  186. package/dist/tools/ba-it-analyzer.js +0 -90
  187. package/dist/tools/code-generate-agent.d.ts +0 -51
  188. package/dist/tools/code-generate-agent.js +0 -159
  189. package/dist/tools/command-runner.d.ts +0 -14
  190. package/dist/tools/command-runner.js +0 -120
  191. package/dist/tools/document-parser.d.ts +0 -11
  192. package/dist/tools/document-parser.js +0 -83
  193. package/dist/tools/file-operations.d.ts +0 -17
  194. package/dist/tools/file-operations.js +0 -127
  195. package/dist/tools/galaxy-ui-integration.d.ts +0 -94
  196. package/dist/tools/galaxy-ui-integration.js +0 -244
  197. package/dist/tools/git-operations.d.ts +0 -11
  198. package/dist/tools/git-operations.js +0 -114
  199. package/dist/tools/index.d.ts +0 -10
  200. package/dist/tools/index.js +0 -10
  201. package/dist/tools/planning-agent.d.ts +0 -29
  202. package/dist/tools/planning-agent.js +0 -134
  203. package/dist/tools/progress-reporter.d.ts +0 -19
  204. package/dist/tools/progress-reporter.js +0 -52
  205. package/dist/tools/registry.d.ts +0 -21
  206. package/dist/tools/registry.js +0 -695
  207. package/dist/tools/tool-event-emitter.d.ts +0 -24
  208. package/dist/tools/tool-event-emitter.js +0 -25
  209. package/dist/tools/types.d.ts +0 -31
  210. package/dist/tools/types.js +0 -1
  211. package/dist/types.d.ts +0 -39
  212. package/dist/types.js +0 -8
  213. package/dist/update-checker.d.ts +0 -22
  214. package/dist/update-checker.js +0 -85
  215. package/dist/utils/config-manager.d.ts +0 -102
  216. package/dist/utils/config-manager.js +0 -326
  217. package/dist/utils/devtools.d.ts +0 -21
  218. package/dist/utils/devtools.js +0 -61
  219. package/dist/utils/message-formatters.d.ts +0 -32
  220. package/dist/utils/message-formatters.js +0 -590
  221. package/dist/utils/progress-tracker.d.ts +0 -59
  222. package/dist/utils/progress-tracker.js +0 -213
@@ -1,21 +0,0 @@
1
- export interface UpdateResult {
2
- success: boolean;
3
- error?: string;
4
- needsRestart?: boolean;
5
- }
6
- /**
7
- * Thực hiện update bằng npm install
8
- */
9
- export declare function performUpdate(version: string): Promise<UpdateResult>;
10
- /**
11
- * Restart CLI với arguments hiện tại
12
- */
13
- export declare function restartCLI(): void;
14
- /**
15
- * Hiển thị thông báo update thành công
16
- */
17
- export declare function showUpdateSuccess(version: string): void;
18
- /**
19
- * Hiển thị thông báo update failed
20
- */
21
- export declare function showUpdateError(error: string): void;
@@ -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
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import './env.js';
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
- })();
@@ -1,71 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2024-10-13
5
- * @modify 2024-10-13
6
- * @desc Claude API connection using Anthropic SDK
7
- */
8
- import Anthropic from '@anthropic-ai/sdk';
9
- import type { AgentConfig } from '../utils/config-manager.js';
10
- import type { MessageCallback } from './types.js';
11
- export type ClaudeModelId = 'claude-3-5-sonnet-20241022' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-20240229' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4.5-20250929';
12
- export interface ClaudeMessage {
13
- role: 'user' | 'assistant';
14
- content: string;
15
- }
16
- export interface ClaudeStreamChunk {
17
- type: 'content_block_delta' | 'message_delta' | 'message_stop';
18
- delta?: {
19
- text?: string;
20
- type?: string;
21
- };
22
- }
23
- export declare class ClaudeConnection {
24
- private client;
25
- private model;
26
- private conversationHistory;
27
- private conversationHistoryWithTools;
28
- private systemPrompt?;
29
- private toolsRegistry;
30
- constructor(config?: AgentConfig, systemPrompt?: string);
31
- /**
32
- * Send a message and get response
33
- */
34
- chat(userMessage: string): Promise<string>;
35
- /**
36
- * Stream response (for future implementation)
37
- */
38
- chatStream(userMessage: string): AsyncGenerator<string, void, unknown>;
39
- /**
40
- * Generate single response without conversation history
41
- */
42
- generate(prompt: string, systemPrompt?: string): Promise<string>;
43
- /**
44
- * Clear conversation history
45
- */
46
- clearHistory(): void;
47
- /**
48
- * Get conversation history
49
- */
50
- getHistory(): ClaudeMessage[];
51
- /**
52
- * Set system prompt
53
- */
54
- setSystemPrompt(prompt: string): void;
55
- /**
56
- * Get current model
57
- */
58
- getModel(): ClaudeModelId;
59
- /**
60
- * Change model
61
- */
62
- setModel(model: ClaudeModelId): void;
63
- /**
64
- * Chat with tools support - handles full tool loop
65
- */
66
- chatWithTools(userMessage: string, tools: Anthropic.Tool[], onMessage?: MessageCallback): Promise<string>;
67
- /**
68
- * Clear tool conversation history
69
- */
70
- clearToolHistory(): void;
71
- }
@@ -1,303 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2024-10-13
5
- * @modify 2024-10-13
6
- * @desc Claude API connection using Anthropic SDK
7
- */
8
- import Anthropic from '@anthropic-ai/sdk';
9
- import { ToolRegistry } from '../tools/index.js';
10
- export class ClaudeConnection {
11
- constructor(config, systemPrompt) {
12
- Object.defineProperty(this, "client", {
13
- enumerable: true,
14
- configurable: true,
15
- writable: true,
16
- value: void 0
17
- });
18
- Object.defineProperty(this, "model", {
19
- enumerable: true,
20
- configurable: true,
21
- writable: true,
22
- value: void 0
23
- });
24
- Object.defineProperty(this, "conversationHistory", {
25
- enumerable: true,
26
- configurable: true,
27
- writable: true,
28
- value: []
29
- });
30
- Object.defineProperty(this, "conversationHistoryWithTools", {
31
- enumerable: true,
32
- configurable: true,
33
- writable: true,
34
- value: []
35
- });
36
- Object.defineProperty(this, "systemPrompt", {
37
- enumerable: true,
38
- configurable: true,
39
- writable: true,
40
- value: void 0
41
- });
42
- Object.defineProperty(this, "toolsRegistry", {
43
- enumerable: true,
44
- configurable: true,
45
- writable: true,
46
- value: new ToolRegistry()
47
- });
48
- // Only get apiKey from config - no fallback to env
49
- const apiKey = config?.apiKey;
50
- // if (!apiKey) {
51
- // throw new Error(
52
- // 'Hiện tại bạn chưa thêm apikey cho model claude. Vui lòng thêm để dùng phần mềm'
53
- // );
54
- // }
55
- this.client = new Anthropic({
56
- apiKey,
57
- });
58
- this.model =
59
- config?.model || 'claude-sonnet-4.5-20250929';
60
- this.systemPrompt = systemPrompt;
61
- }
62
- /**
63
- * Send a message and get response
64
- */
65
- async chat(userMessage) {
66
- // Add user message to history
67
- this.conversationHistory.push({
68
- role: 'user',
69
- content: userMessage,
70
- });
71
- try {
72
- const response = await this.client.messages.create({
73
- model: this.model,
74
- max_tokens: 8192,
75
- system: this.systemPrompt,
76
- messages: this.conversationHistory,
77
- });
78
- // Extract assistant response
79
- const assistantMessage = response.content[0]?.type === 'text' ? response.content[0].text : '';
80
- // Add to history
81
- this.conversationHistory.push({
82
- role: 'assistant',
83
- content: assistantMessage,
84
- });
85
- return assistantMessage;
86
- }
87
- catch (error) {
88
- console.error('Claude API Error:', error);
89
- throw error;
90
- }
91
- }
92
- /**
93
- * Stream response (for future implementation)
94
- */
95
- async *chatStream(userMessage) {
96
- this.conversationHistory.push({
97
- role: 'user',
98
- content: userMessage,
99
- });
100
- try {
101
- const stream = await this.client.messages.create({
102
- model: this.model,
103
- max_tokens: 8192,
104
- system: this.systemPrompt,
105
- messages: this.conversationHistory,
106
- stream: true,
107
- });
108
- let fullResponse = '';
109
- for await (const chunk of stream) {
110
- if (chunk.type === 'content_block_delta' &&
111
- chunk.delta.type === 'text_delta') {
112
- const text = chunk.delta.text || '';
113
- fullResponse += text;
114
- yield text;
115
- }
116
- }
117
- // Add complete response to history
118
- this.conversationHistory.push({
119
- role: 'assistant',
120
- content: fullResponse,
121
- });
122
- }
123
- catch (error) {
124
- console.error('Claude Stream Error:', error);
125
- throw error;
126
- }
127
- }
128
- /**
129
- * Generate single response without conversation history
130
- */
131
- async generate(prompt, systemPrompt) {
132
- try {
133
- const response = await this.client.messages.create({
134
- model: this.model,
135
- max_tokens: 8192,
136
- system: systemPrompt || this.systemPrompt,
137
- messages: [
138
- {
139
- role: 'user',
140
- content: prompt,
141
- },
142
- ],
143
- });
144
- return response.content[0]?.type === 'text'
145
- ? response.content[0].text
146
- : '';
147
- }
148
- catch (error) {
149
- console.error('Claude Generate Error:', error);
150
- throw error;
151
- }
152
- }
153
- /**
154
- * Clear conversation history
155
- */
156
- clearHistory() {
157
- this.conversationHistory = [];
158
- }
159
- /**
160
- * Get conversation history
161
- */
162
- getHistory() {
163
- return [...this.conversationHistory];
164
- }
165
- /**
166
- * Set system prompt
167
- */
168
- setSystemPrompt(prompt) {
169
- this.systemPrompt = prompt;
170
- }
171
- /**
172
- * Get current model
173
- */
174
- getModel() {
175
- return this.model;
176
- }
177
- /**
178
- * Change model
179
- */
180
- setModel(model) {
181
- this.model = model;
182
- }
183
- /**
184
- * Chat with tools support - handles full tool loop
185
- */
186
- async chatWithTools(userMessage, tools, onMessage) {
187
- // Add user message to history
188
- this.conversationHistoryWithTools.push({
189
- role: 'user',
190
- content: userMessage,
191
- });
192
- let iteration = 0;
193
- const MAX_ITERATIONS = 100; // Safety limit
194
- while (iteration < MAX_ITERATIONS) {
195
- iteration++;
196
- // Call Claude API
197
- const response = await this.client.messages.create({
198
- model: this.model,
199
- max_tokens: 8192,
200
- system: this.systemPrompt,
201
- messages: this.conversationHistoryWithTools,
202
- tools: tools,
203
- });
204
- // Check stop reason
205
- if (response.stop_reason !== 'tool_use') {
206
- // No more tools to execute - add final response to history
207
- this.conversationHistoryWithTools.push({
208
- role: 'assistant',
209
- content: response.content,
210
- });
211
- // Extract text from response
212
- const textBlock = response.content.find((block) => block.type === 'text');
213
- return textBlock?.text || '';
214
- }
215
- // Add assistant response with tool_use to history
216
- this.conversationHistoryWithTools.push({
217
- role: 'assistant',
218
- content: response.content,
219
- });
220
- // Execute tools and collect results
221
- const toolResults = [];
222
- for (const block of response.content) {
223
- if (block.type === 'tool_use') {
224
- const toolUseBlock = block;
225
- const toolName = toolUseBlock.name;
226
- const toolInput = toolUseBlock.input;
227
- // Special handling for plan_task and progress_reporter
228
- if (toolName === 'plan_task' || toolName === 'progress_reporter') {
229
- try {
230
- const result = await this.toolsRegistry.executeTool(toolName, toolInput);
231
- const resultStr = typeof result === 'string' ? result : JSON.stringify(result);
232
- toolResults.push({
233
- type: 'tool_result',
234
- tool_use_id: toolUseBlock.id,
235
- content: resultStr,
236
- });
237
- }
238
- catch (error) {
239
- const errorMsg = error instanceof Error ? error.message : String(error);
240
- toolResults.push({
241
- type: 'tool_result',
242
- tool_use_id: toolUseBlock.id,
243
- content: `Error: ${errorMsg}`,
244
- is_error: true,
245
- });
246
- }
247
- }
248
- else {
249
- // Regular tool handling with notification
250
- try {
251
- const result = await this.toolsRegistry.executeTool(toolName, toolInput);
252
- const resultStr = typeof result === 'string' ? result : JSON.stringify(result);
253
- // Notify tool execution
254
- if (onMessage) {
255
- const success = !resultStr.startsWith('❌');
256
- onMessage('tool', resultStr, toolName, {
257
- success,
258
- output: resultStr,
259
- });
260
- }
261
- toolResults.push({
262
- type: 'tool_result',
263
- tool_use_id: toolUseBlock.id,
264
- content: resultStr,
265
- });
266
- }
267
- catch (error) {
268
- const errorMsg = error instanceof Error ? error.message : String(error);
269
- // Notify error
270
- if (onMessage) {
271
- onMessage('tool', `❌ Error: ${errorMsg}`, toolName, {
272
- success: false,
273
- error: errorMsg,
274
- });
275
- }
276
- toolResults.push({
277
- type: 'tool_result',
278
- tool_use_id: toolUseBlock.id,
279
- content: `Error: ${errorMsg}`,
280
- is_error: true,
281
- });
282
- }
283
- }
284
- }
285
- }
286
- // Add tool results to history
287
- this.conversationHistoryWithTools.push({
288
- role: 'user',
289
- content: toolResults,
290
- });
291
- // Loop continues to call API again with tool results
292
- }
293
- // Safety limit reached
294
- console.warn(`⚠️ Safety limit (${MAX_ITERATIONS}) reached in Claude tool loop.`);
295
- return 'Maximum iteration limit reached. Please try again.';
296
- }
297
- /**
298
- * Clear tool conversation history
299
- */
300
- clearToolHistory() {
301
- this.conversationHistoryWithTools = [];
302
- }
303
- }