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,24 +0,0 @@
1
- /**
2
- * Tool Event Emitter
3
- * Central event system for tool execution tracking
4
- */
5
- import { EventEmitter } from 'events';
6
- export interface ToolExecutionEvent {
7
- toolName: string;
8
- content: string;
9
- timestamp?: number;
10
- status?: 'start' | 'success' | 'error';
11
- error?: string;
12
- toolInfo?: {
13
- toolName: string;
14
- args?: any;
15
- result?: any;
16
- };
17
- }
18
- declare class ToolEventEmitter extends EventEmitter {
19
- constructor();
20
- emitToolExecution(event: ToolExecutionEvent): void;
21
- onToolExecution(callback: (event: ToolExecutionEvent) => void): () => void;
22
- }
23
- export declare const toolEventEmitter: ToolEventEmitter;
24
- export {};
@@ -1,25 +0,0 @@
1
- /**
2
- * Tool Event Emitter
3
- * Central event system for tool execution tracking
4
- */
5
- import { EventEmitter } from 'events';
6
- class ToolEventEmitter extends EventEmitter {
7
- constructor() {
8
- super();
9
- this.setMaxListeners(100); // Increase for multiple listeners
10
- }
11
- emitToolExecution(event) {
12
- const enrichedEvent = {
13
- ...event,
14
- timestamp: Date.now(),
15
- };
16
- this.emit('tool-execution', enrichedEvent);
17
- }
18
- onToolExecution(callback) {
19
- this.on('tool-execution', callback);
20
- // Return unsubscribe function
21
- return () => this.off('tool-execution', callback);
22
- }
23
- }
24
- // Singleton instance
25
- export const toolEventEmitter = new ToolEventEmitter();
@@ -1,31 +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 Shared typing for MCP-style tools.
7
- */
8
- export type ToolInputSchema = {
9
- readonly type: 'object';
10
- readonly properties: Record<string, {
11
- readonly type: 'string' | 'number' | 'boolean' | 'array' | 'object';
12
- readonly description?: string;
13
- readonly default?: string | boolean | number | Array<any> | object;
14
- readonly items?: {
15
- readonly type?: 'string' | 'number' | 'boolean' | 'object';
16
- readonly properties?: Record<string, any>;
17
- };
18
- }>;
19
- readonly required?: readonly string[];
20
- };
21
- export type ToolExecutionContext = {
22
- readonly abortSignal?: AbortSignal;
23
- };
24
- export type Tool<Input, Output> = {
25
- readonly name: string;
26
- readonly description: string;
27
- readonly inputSchema: ToolInputSchema;
28
- readonly execute: (input: Input, context: ToolExecutionContext) => Promise<Output>;
29
- };
30
- export type InferToolInput<T extends Tool<unknown, unknown>> = T extends Tool<infer Input, unknown> ? Input : never;
31
- export type InferToolOutput<T extends Tool<unknown, unknown>> = T extends Tool<unknown, infer Output> ? Output : never;
@@ -1 +0,0 @@
1
- export {};
package/dist/types.d.ts DELETED
@@ -1,39 +0,0 @@
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 { ToolExecutionInfo } from './connections/types.js';
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 DELETED
@@ -1,8 +0,0 @@
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
- export {};
@@ -1,22 +0,0 @@
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;
@@ -1,85 +0,0 @@
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
- }
@@ -1,102 +0,0 @@
1
- export type AgentType = 'claude' | 'gemini' | 'ollama' | 'manual';
2
- export interface AgentConfig {
3
- model?: string;
4
- type: AgentType;
5
- apiKey?: string;
6
- host?: string;
7
- }
8
- export interface AutoUpdateConfig {
9
- enabled: boolean;
10
- checkOnStartup: boolean;
11
- silent: boolean;
12
- maxAttempts: number;
13
- timeout: number;
14
- skipVersions: string[];
15
- lastChecked: number | null;
16
- lastAttemptedVersion: string | null;
17
- }
18
- export interface GalaxyConfig {
19
- agent: AgentConfig[];
20
- git: boolean;
21
- test: boolean;
22
- autoUpdate: AutoUpdateConfig;
23
- }
24
- export interface CLIFlags {
25
- git?: boolean;
26
- test?: boolean;
27
- }
28
- export interface MergedConfig {
29
- model: AgentType;
30
- git: boolean;
31
- test: boolean;
32
- agent: AgentConfig[];
33
- error?: string;
34
- }
35
- export declare class ConfigManager {
36
- private configPath;
37
- private config;
38
- constructor();
39
- /**
40
- * Get config directory path based on OS
41
- */
42
- private getConfigDir;
43
- /**
44
- * Get full config file path
45
- */
46
- private getConfigPath;
47
- /**
48
- * Get default configuration
49
- */
50
- private getDefaultConfig;
51
- /**
52
- * Load configuration from file or create default
53
- */
54
- private loadConfig;
55
- /**
56
- * Validate and merge config with defaults
57
- */
58
- private validateConfig;
59
- /**
60
- * Create default config file
61
- */
62
- private createDefaultConfig;
63
- /**
64
- * Save current config to file
65
- */
66
- saveConfig(): void;
67
- /**
68
- * Get merged config with CLI flags priority
69
- * Priority: CLI flags > config.json > defaults
70
- * Returns: { model: AgentType, git: boolean, test: boolean }
71
- */
72
- getMergedConfig(cliFlags?: CLIFlags): MergedConfig;
73
- /**
74
- * Validate agent configuration
75
- */
76
- private validateAgent;
77
- /**
78
- * Update config values
79
- */
80
- updateConfig(updates: Partial<GalaxyConfig>): void;
81
- /**
82
- * Get current config
83
- */
84
- getConfig(): GalaxyConfig;
85
- /**
86
- * Get config file path
87
- */
88
- getConfigFilePath(): string;
89
- /**
90
- * Reset config to defaults
91
- */
92
- resetConfig(): void;
93
- /**
94
- * Open config folder in file explorer
95
- */
96
- openConfigFolder(): void;
97
- /**
98
- * Display current config and open config folder
99
- */
100
- displayConfig(): void;
101
- }
102
- export declare const configManager: ConfigManager;
@@ -1,326 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2024-10-13
5
- * @desc Configuration manager for Galaxy CLI
6
- */
7
- import fs from 'node:fs';
8
- import path from 'node:path';
9
- import os from 'node:os';
10
- import { execSync } from 'node:child_process';
11
- export class ConfigManager {
12
- constructor() {
13
- Object.defineProperty(this, "configPath", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: void 0
18
- });
19
- Object.defineProperty(this, "config", {
20
- enumerable: true,
21
- configurable: true,
22
- writable: true,
23
- value: void 0
24
- });
25
- this.configPath = this.getConfigPath();
26
- this.config = this.loadConfig();
27
- }
28
- /**
29
- * Get config directory path based on OS
30
- */
31
- getConfigDir() {
32
- const homeDir = os.homedir();
33
- const platform = os.platform();
34
- switch (platform) {
35
- case 'darwin': // macOS
36
- case 'linux':
37
- return path.join(homeDir, '.galaxy');
38
- case 'win32': // Windows
39
- return path.join(homeDir, 'AppData', 'Local', 'Galaxy');
40
- default:
41
- return path.join(homeDir, '.galaxy');
42
- }
43
- }
44
- /**
45
- * Get full config file path
46
- */
47
- getConfigPath() {
48
- return path.join(this.getConfigDir(), 'config.json');
49
- }
50
- /**
51
- * Get default configuration
52
- */
53
- getDefaultConfig() {
54
- return {
55
- agent: [
56
- {
57
- type: 'manual',
58
- },
59
- ],
60
- git: true,
61
- test: true,
62
- autoUpdate: {
63
- enabled: true,
64
- checkOnStartup: true,
65
- silent: false,
66
- maxAttempts: 3,
67
- timeout: 3000,
68
- skipVersions: [],
69
- lastChecked: null,
70
- lastAttemptedVersion: null,
71
- },
72
- };
73
- }
74
- /**
75
- * Load configuration from file or create default
76
- */
77
- loadConfig() {
78
- try {
79
- // Check if config file exists
80
- if (!fs.existsSync(this.configPath)) {
81
- console.log('📝 Creating default config at:', this.configPath);
82
- return this.createDefaultConfig();
83
- }
84
- // Read and parse config file
85
- const configData = fs.readFileSync(this.configPath, 'utf-8');
86
- const config = JSON.parse(configData);
87
- // Validate config structure
88
- return this.validateConfig(config);
89
- }
90
- catch (error) {
91
- console.warn('⚠️ Failed to load config, using defaults:', error instanceof Error ? error.message : String(error));
92
- return this.getDefaultConfig();
93
- }
94
- }
95
- /**
96
- * Validate and merge config with defaults
97
- */
98
- validateConfig(config) {
99
- const defaults = this.getDefaultConfig();
100
- // Ensure agent is always an array
101
- let agent = defaults.agent;
102
- if (config.agent && Array.isArray(config.agent)) {
103
- agent = config.agent;
104
- }
105
- // Merge autoUpdate config with defaults
106
- const autoUpdate = {
107
- ...defaults.autoUpdate,
108
- ...(config.autoUpdate || {}),
109
- };
110
- return {
111
- agent: agent,
112
- git: config.git ?? defaults.git,
113
- test: config.test ?? defaults.test,
114
- autoUpdate,
115
- };
116
- }
117
- /**
118
- * Create default config file
119
- */
120
- createDefaultConfig() {
121
- const config = this.getDefaultConfig();
122
- try {
123
- // Ensure config directory exists
124
- const configDir = this.getConfigDir();
125
- if (!fs.existsSync(configDir)) {
126
- fs.mkdirSync(configDir, { recursive: true });
127
- }
128
- // Write default config
129
- fs.writeFileSync(this.configPath, JSON.stringify(config, null, 2), 'utf-8');
130
- console.log('✅ Created default config file');
131
- console.log('📁 Location:', this.configPath);
132
- console.log('');
133
- console.log('You can customize settings by editing this file.');
134
- console.log('');
135
- }
136
- catch (error) {
137
- console.error('❌ Failed to create config file:', error instanceof Error ? error.message : String(error));
138
- }
139
- return config;
140
- }
141
- /**
142
- * Save current config to file
143
- */
144
- saveConfig() {
145
- try {
146
- const configDir = this.getConfigDir();
147
- if (!fs.existsSync(configDir)) {
148
- fs.mkdirSync(configDir, { recursive: true });
149
- }
150
- fs.writeFileSync(this.configPath, JSON.stringify(this.config, null, 2), 'utf-8');
151
- }
152
- catch (error) {
153
- console.error('❌ Failed to save config:', error instanceof Error ? error.message : String(error));
154
- }
155
- }
156
- /**
157
- * Get merged config with CLI flags priority
158
- * Priority: CLI flags > config.json > defaults
159
- * Returns: { model: AgentType, git: boolean, test: boolean }
160
- */
161
- getMergedConfig(cliFlags = {}) {
162
- // Check if agent is array and not empty
163
- if (!this.config.agent || !Array.isArray(this.config.agent) || this.config.agent.length === 0) {
164
- return {
165
- model: 'manual',
166
- git: cliFlags.git ?? this.config.git,
167
- test: cliFlags.test ?? this.config.test,
168
- agent: [],
169
- error: 'Hiện tại chưa có agent nào được cấu hình. Vui lòng gõ "galaxy --config" để xem file config và thêm agent.',
170
- };
171
- }
172
- // Find manual agent first, otherwise get first agent
173
- let primaryAgent = this.config.agent.find(a => a.type === 'manual') ?? this.config.agent[0];
174
- // Check if primaryAgent is defined
175
- if (!primaryAgent) {
176
- return {
177
- model: 'manual',
178
- git: cliFlags.git ?? this.config.git,
179
- test: cliFlags.test ?? this.config.test,
180
- agent: this.config.agent,
181
- error: 'Không tìm thấy agent hợp lệ. Vui lòng kiểm tra lại file cấu hình.',
182
- };
183
- }
184
- // Validate agent configuration
185
- const validation = this.validateAgent(primaryAgent);
186
- if (validation.error) {
187
- return {
188
- model: primaryAgent.type,
189
- git: cliFlags.git ?? this.config.git,
190
- test: cliFlags.test ?? this.config.test,
191
- agent: this.config.agent,
192
- error: validation.error,
193
- };
194
- }
195
- return {
196
- model: primaryAgent.type,
197
- git: cliFlags.git ?? this.config.git,
198
- test: cliFlags.test ?? this.config.test,
199
- agent: this.config.agent,
200
- };
201
- }
202
- /**
203
- * Validate agent configuration
204
- */
205
- validateAgent(agent) {
206
- // Manual mode uses Ollama cloud, needs apiKey
207
- if (agent.type === 'manual') {
208
- if (!agent.apiKey) {
209
- return {
210
- valid: false,
211
- error: `Mode Manual cần API Key. Vui lòng:\n1. Gõ /config để mở folder cấu hình\n2. Thêm "apiKey": "your-api-key" vào agent type "manual"\n3. Thoát CLI và vào lại để nhận API Key.`,
212
- };
213
- }
214
- return { valid: true };
215
- }
216
- // Claude needs apiKey
217
- if (agent.type === 'claude') {
218
- if (!agent.apiKey) {
219
- return {
220
- valid: false,
221
- error: `Hiện tại bạn chưa thêm apikey cho model ${agent.type}. Vui lòng:\n1. Gõ /config để mở folder cấu hình\n2. Thêm "apiKey": "your-api-key" vào agent type "claude"\n3. Thoát CLI và vào lại để nhận API Key.`,
222
- };
223
- }
224
- }
225
- // Gemini needs apiKey
226
- if (agent.type === 'gemini') {
227
- if (!agent.apiKey) {
228
- return {
229
- valid: false,
230
- error: `Hiện tại bạn chưa thêm apikey cho model ${agent.type}. Vui lòng:\n1. Gõ /config để mở folder cấu hình\n2. Thêm "apiKey": "your-api-key" vào agent type "gemini"\n3. Thoát CLI và vào lại để nhận API Key.`,
231
- };
232
- }
233
- }
234
- // Ollama needs host and apiKey
235
- if (agent.type === 'ollama') {
236
- if (!agent.host) {
237
- return {
238
- valid: false,
239
- error: `Hiện tại bạn chưa cài đặt host cho Ollama. Vui lòng gõ "galaxy --config" để xem file config và thêm host (ví dụ: "http://localhost:11434").`,
240
- };
241
- }
242
- // Check if using cloud host
243
- if ((agent.host === 'https://ollama.com' || agent.host.includes('ollama.com')) &&
244
- !agent.apiKey) {
245
- return {
246
- valid: false,
247
- error: `Hiện tại bạn chưa thêm apikey cho model ollama. Vui lòng:\n1. Gõ /config để mở folder cấu hình\n2. Thêm "apiKey": "your-api-key" vào agent type "ollama"\n3. Thoát CLI và vào lại để nhận API Key.`,
248
- };
249
- }
250
- }
251
- return { valid: true };
252
- }
253
- /**
254
- * Update config values
255
- */
256
- updateConfig(updates) {
257
- this.config = { ...this.config, ...updates };
258
- this.saveConfig();
259
- }
260
- /**
261
- * Get current config
262
- */
263
- getConfig() {
264
- return { ...this.config };
265
- }
266
- /**
267
- * Get config file path
268
- */
269
- getConfigFilePath() {
270
- return this.configPath;
271
- }
272
- /**
273
- * Reset config to defaults
274
- */
275
- resetConfig() {
276
- this.config = this.getDefaultConfig();
277
- this.saveConfig();
278
- console.log('✅ Config reset to defaults');
279
- }
280
- /**
281
- * Open config folder in file explorer
282
- */
283
- openConfigFolder() {
284
- const configDir = path.dirname(this.configPath);
285
- try {
286
- const platform = os.platform();
287
- if (platform === 'darwin') {
288
- execSync(`open "${configDir}"`);
289
- }
290
- else if (platform === 'win32') {
291
- execSync(`start "" "${configDir}"`);
292
- }
293
- else {
294
- // Linux
295
- execSync(`xdg-open "${configDir}"`);
296
- }
297
- console.log('✅ Opened config folder');
298
- }
299
- catch (error) {
300
- console.log('❌ Could not open folder automatically. Please open it manually.');
301
- }
302
- }
303
- /**
304
- * Display current config and open config folder
305
- */
306
- displayConfig() {
307
- console.log('');
308
- console.log('📊 Current Galaxy Configuration:');
309
- console.log('━'.repeat(50));
310
- console.log('📁 Config file:', this.configPath);
311
- console.log('');
312
- console.log('Settings:');
313
- console.log(' Agents:');
314
- this.config.agent.forEach((agent, index) => {
315
- console.log(` ${index + 1}. Type: ${agent.type}${agent.model ? ` | Model: ${agent.model}` : ''}`);
316
- });
317
- console.log(' Git:', this.config.git ? 'ON' : 'OFF');
318
- console.log(' Test:', this.config.test ? 'ON' : 'OFF');
319
- console.log('━'.repeat(50));
320
- console.log('');
321
- // Open config folder
322
- this.openConfigFolder();
323
- }
324
- }
325
- // Singleton instance
326
- export const configManager = new ConfigManager();
@@ -1,21 +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 React DevTools integration for development
7
- */
8
- /**
9
- * Initialize React DevTools connection for debugging
10
- * Only runs in development mode
11
- *
12
- * Note: react-devtools-core requires browser globals that don't exist in Node.js
13
- * This may not work reliably in terminal environments
14
- */
15
- export declare function initDevTools(): Promise<void>;
16
- /**
17
- * Display component for DevTools status
18
- */
19
- export declare function DevToolsStatus({ connected }: {
20
- connected: boolean;
21
- }): "🔧 DevTools Đã Kết Nối" | "⚠️ DevTools Chưa Kết Nối" | null;