galaxy-code 0.1.8 → 0.1.9
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/README.md +351 -148
- package/dist/cli.bundle.js +1026 -311
- package/package.json +40 -77
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,228 +1,431 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Galaxy Code CLI
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Galaxy Code** là một AI Agent CLI đa nhà cung cấp, được xây dựng với giao diện TUI tương tác — tương tự Claude Code nhưng hỗ trợ nhiều AI provider và có các tính năng context engineering nâng cao.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
```
|
|
6
|
+
██████╗ █████╗ ██╗ █████╗ ██╗ ██╗██╗ ██╗
|
|
7
|
+
██╔════╝ ██╔══██╗██║ ██╔══██╗╚██╗██╔╝╚██╗ ██╔╝
|
|
8
|
+
██║ ███╗███████║██║ ███████║ ╚███╔╝ ╚████╔╝
|
|
9
|
+
██║ ██║██╔══██║██║ ██╔══██║ ██╔██╗ ╚██╔╝
|
|
10
|
+
╚██████╔╝██║ ██║███████╗██║ ██║██╔╝ ██╗ ██║
|
|
11
|
+
╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
|
|
12
|
+
C O D E
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Yêu cầu người dùng
|
|
18
|
+
|
|
19
|
+
| # | Yêu cầu | Trạng thái |
|
|
20
|
+
|---|---------|-----------|
|
|
21
|
+
| 1 | Giao diện TUI tương tác như Claude Code | ✅ Hoàn thành |
|
|
22
|
+
| 2 | Lệnh `galaxy-code` để khởi động CLI | ✅ Hoàn thành |
|
|
23
|
+
| 3 | Lệnh `galaxy-code config` mở folder `~/.galaxy` | ✅ Hoàn thành |
|
|
24
|
+
| 4 | Hỗ trợ 5 AI providers: Claude, Gemini, Ollama, Codex, Manual | ✅ Hoàn thành |
|
|
25
|
+
| 5 | Đọc file: PDF, DOCX, XLSX/XLS, CSV, MD, TXT và các file code | ✅ Hoàn thành |
|
|
26
|
+
| 6 | Sub AI Agent tóm tắt URD (User Requirements Document) | ✅ Hoàn thành |
|
|
27
|
+
| 7 | Sub AI Agent review code sau khi AI viết xong (`/review`) | ✅ Hoàn thành |
|
|
28
|
+
| 8 | Context Engineering: JIT Retrieval, Compaction, Structured Notes | ✅ Hoàn thành |
|
|
29
|
+
| 9 | Config lưu tại `~/.galaxy/config.json` (macOS) | ✅ Hoàn thành |
|
|
30
|
+
| 10 | Ba màn hình: Chat (F1), Plan (F2), Settings (F3) | ✅ Hoàn thành |
|
|
31
|
+
|
|
32
|
+
---
|
|
8
33
|
|
|
9
|
-
##
|
|
34
|
+
## Cài đặt
|
|
10
35
|
|
|
11
|
-
|
|
36
|
+
### Yêu cầu hệ thống
|
|
37
|
+
|
|
38
|
+
- Node.js >= 18
|
|
39
|
+
- pnpm >= 8
|
|
40
|
+
|
|
41
|
+
### Cài đặt toàn cục
|
|
12
42
|
|
|
13
43
|
```bash
|
|
14
|
-
|
|
44
|
+
# Clone hoặc tải về project
|
|
45
|
+
cd artifacts/galaxy-cli
|
|
46
|
+
|
|
47
|
+
# Cài đặt dependencies
|
|
48
|
+
pnpm install
|
|
49
|
+
|
|
50
|
+
# Link binary toàn cục
|
|
51
|
+
pnpm link --global
|
|
15
52
|
```
|
|
16
53
|
|
|
17
|
-
|
|
54
|
+
Sau khi link, bạn có thể gõ từ bất kỳ đâu:
|
|
18
55
|
|
|
19
56
|
```bash
|
|
20
|
-
|
|
57
|
+
galaxy-code # Khởi động TUI
|
|
58
|
+
galaxy-code config # Mở thư mục config
|
|
59
|
+
galaxy-code urd <file> # Phân tích URD
|
|
21
60
|
```
|
|
22
61
|
|
|
23
|
-
|
|
62
|
+
---
|
|
24
63
|
|
|
25
|
-
|
|
64
|
+
## Sử dụng
|
|
26
65
|
|
|
27
|
-
|
|
66
|
+
### Khởi động TUI
|
|
28
67
|
|
|
29
|
-
|
|
68
|
+
```bash
|
|
69
|
+
galaxy-code
|
|
70
|
+
```
|
|
30
71
|
|
|
31
|
-
|
|
32
|
-
- **Analyze existing projects** to understand codebase structure
|
|
33
|
-
- **Add features** to existing applications intelligently
|
|
34
|
-
- **Generate production-ready code** with best practices
|
|
35
|
-
- **Manage development workflow** with integrated tools
|
|
72
|
+
Giao diện TUI sẽ mở ra với ba màn hình điều hướng bằng phím tắt:
|
|
36
73
|
|
|
37
|
-
|
|
74
|
+
| Phím | Chức năng |
|
|
75
|
+
|------|-----------|
|
|
76
|
+
| `F1` hoặc `Alt+1` | Màn hình Chat |
|
|
77
|
+
| `F2` hoặc `Alt+2` | Màn hình Plan (các bước nhiệm vụ) |
|
|
78
|
+
| `F3` hoặc `Alt+3` | Màn hình Settings |
|
|
79
|
+
| `Ctrl+K` | Xóa lịch sử chat (reset cả session tracker) |
|
|
80
|
+
| `?` hoặc `H` | Bật/tắt Help |
|
|
81
|
+
| `Q` hoặc `Ctrl+C` | Thoát |
|
|
38
82
|
|
|
39
|
-
|
|
83
|
+
### Slash Commands
|
|
40
84
|
|
|
41
|
-
|
|
85
|
+
Gõ trực tiếp vào ô chat:
|
|
42
86
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
87
|
+
| Lệnh | Chức năng |
|
|
88
|
+
|------|-----------|
|
|
89
|
+
| `/review` | Kích hoạt thủ công Code Reviewer Sub Agent — AI sẽ review toàn bộ file đã được viết/sửa trong session hiện tại |
|
|
90
|
+
| `/diff` | Xem toàn bộ thay đổi của tất cả file AI đã sửa trong session (unified diff) |
|
|
91
|
+
| `/diff <file>` | Xem chi tiết thay đổi của một file cụ thể, ví dụ: `/diff src/auth.ts` |
|
|
92
|
+
| `/revert <file>` | Hoàn tác file về trạng thái trước khi AI sửa. Nếu AI tạo file mới → xóa file. Nếu AI sửa file cũ → khôi phục nội dung cũ |
|
|
47
93
|
|
|
48
|
-
###
|
|
49
|
-
- **Models**: Gemini 2.5 Flash and other Gemini models
|
|
50
|
-
- **Features**: Tool calling, planning capabilities
|
|
51
|
-
- **API Key**: `GOOGLE_AI_API_KEY` or `GEMINI_API_KEY` environment variable
|
|
94
|
+
### Mở thư mục cấu hình
|
|
52
95
|
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
- **Setup**: Install Ollama and pull required models
|
|
96
|
+
```bash
|
|
97
|
+
galaxy-code config
|
|
98
|
+
```
|
|
57
99
|
|
|
58
|
-
|
|
100
|
+
Lệnh này sẽ:
|
|
101
|
+
1. In ra đường dẫn thư mục config
|
|
102
|
+
2. Liệt kê các file trong thư mục
|
|
103
|
+
3. Tự động mở File Manager (nếu có GUI)
|
|
59
104
|
|
|
60
|
-
|
|
105
|
+
Vị trí config theo hệ điều hành:
|
|
106
|
+
- **macOS**: `~/.galaxy/`
|
|
107
|
+
- **Linux**: `~/.config/galaxy/`
|
|
108
|
+
- **Windows**: `%APPDATA%\galaxy\`
|
|
61
109
|
|
|
62
|
-
|
|
110
|
+
### Tóm tắt URD (User Requirements Document)
|
|
63
111
|
|
|
64
112
|
```bash
|
|
65
|
-
galaxy-code
|
|
113
|
+
galaxy-code urd ./requirements.pdf
|
|
114
|
+
galaxy-code urd ./spec.docx
|
|
115
|
+
galaxy-code urd ./requirements.md
|
|
66
116
|
```
|
|
67
117
|
|
|
68
|
-
|
|
118
|
+
Sub AI Agent sẽ:
|
|
119
|
+
1. Đọc và phân tích file tài liệu
|
|
120
|
+
2. Dùng AI provider đang cấu hình để tóm tắt
|
|
121
|
+
3. Xuất ra cấu trúc gồm: Overview, Functional Requirements, Non-Functional Requirements, Stakeholders, Acceptance Criteria, Risks, Priority Recommendations
|
|
122
|
+
4. Lưu kết quả tại `~/.galaxy/urd-summaries/<tên-file>-summary-<timestamp>.md`
|
|
123
|
+
5. Thêm key points vào `~/.galaxy/NOTE.md` để dùng trong session tiếp theo
|
|
69
124
|
|
|
70
|
-
|
|
71
|
-
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Cấu trúc thư mục `~/.galaxy/`
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
~/.galaxy/
|
|
131
|
+
├── config.json # Cấu hình agents, API keys
|
|
132
|
+
├── NOTE.md # Ghi chú ngữ cảnh persistent (Structured Notes)
|
|
133
|
+
└── urd-summaries/ # Các bản tóm tắt URD được lưu tự động
|
|
134
|
+
└── spec-summary-2026-03-11T10-30-00.md
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Cấu hình AI Providers
|
|
140
|
+
|
|
141
|
+
Chỉnh sửa `~/.galaxy/config.json`:
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"agent": [
|
|
146
|
+
{
|
|
147
|
+
"type": "manual",
|
|
148
|
+
"apiKey": ""
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"type": "claude",
|
|
152
|
+
"model": "claude-sonnet-4-5-20250929",
|
|
153
|
+
"apiKey": "sk-ant-..."
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"type": "gemini",
|
|
157
|
+
"model": "gemini-2.5-flash",
|
|
158
|
+
"apiKey": "AIza..."
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"type": "codex",
|
|
162
|
+
"model": "gpt-4o",
|
|
163
|
+
"apiKey": "sk-..."
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"type": "ollama",
|
|
167
|
+
"model": "llama3.2",
|
|
168
|
+
"baseUrl": "http://localhost:11434"
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
72
172
|
```
|
|
73
173
|
|
|
74
|
-
|
|
174
|
+
Hoặc chỉnh sửa trực tiếp trong Settings (F3) của TUI.
|
|
75
175
|
|
|
76
|
-
|
|
77
|
-
| ---------------- | ------------------------------------ | ----------- |
|
|
78
|
-
| `--help` | Show help information | - |
|
|
79
|
-
| `--version` | Display version | - |
|
|
80
|
-
| `--git` | Enable git operations | From config |
|
|
81
|
-
| `--test` | Enable test planning | From config |
|
|
82
|
-
| `--config` | Display current configuration | false |
|
|
83
|
-
| `--reset-config` | Reset configuration to defaults | false |
|
|
84
|
-
| `--dev` | Enable development mode with DevTools| false |
|
|
85
|
-
| `--no-auto-update`| Disable auto-update on startup | false |
|
|
176
|
+
### Các AI Provider hỗ trợ
|
|
86
177
|
|
|
87
|
-
|
|
178
|
+
| Provider | Mô tả | API Key |
|
|
179
|
+
|----------|--------|---------|
|
|
180
|
+
| **Manual** | Tự động kết nối Ollama tại `localhost:11434` | Không cần |
|
|
181
|
+
| **Claude** | Anthropic Claude (claude-sonnet-4-5, claude-opus) | `ANTHROPIC_API_KEY` |
|
|
182
|
+
| **Gemini** | Google Gemini (gemini-2.5-flash, gemini-pro) | `GOOGLE_API_KEY` |
|
|
183
|
+
| **Codex** | OpenAI GPT-4o, GPT-4 | `OPENAI_API_KEY` |
|
|
184
|
+
| **Ollama** | Local LLM (llama3.2, mistral, phi3, ...) | Không cần |
|
|
88
185
|
|
|
89
|
-
|
|
186
|
+
---
|
|
90
187
|
|
|
91
|
-
|
|
92
|
-
| -------------------- | ---------------------------------------------- |
|
|
93
|
-
| `/help` | Show available commands |
|
|
94
|
-
| `/exit` | Exit the application |
|
|
95
|
-
| `/clear` | Clear conversation history |
|
|
96
|
-
| `/history` | Show recent inputs (last 10) |
|
|
97
|
-
| `/pwd` | Show current working directory |
|
|
98
|
-
| `/information` | Display system information |
|
|
99
|
-
| `/git true/false` | Enable/disable git operations |
|
|
100
|
-
| `/test true/false` | Enable/disable test planning |
|
|
101
|
-
| `/mode claude/gemini/ollama/manual` | Switch agent mode |
|
|
102
|
-
| `/config` | Open configuration folder |
|
|
188
|
+
## Công nghệ sử dụng
|
|
103
189
|
|
|
104
|
-
###
|
|
190
|
+
### Core Framework
|
|
105
191
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
192
|
+
| Package | Phiên bản | Mục đích |
|
|
193
|
+
|---------|-----------|---------|
|
|
194
|
+
| **@rezi-ui/core** | 0.1.0-alpha.59 | TUI rendering engine core |
|
|
195
|
+
| **@rezi-ui/node** | 0.1.0-alpha.59 | Node.js backend cho Rezi |
|
|
196
|
+
| **@rezi-ui/native** | 0.1.0-alpha.59 | Native C++ addon cho terminal rendering |
|
|
197
|
+
|
|
198
|
+
**Rezi** (https://rezitui.dev) là framework TUI TypeScript hiện đại, tương tự React nhưng cho terminal. Sử dụng:
|
|
199
|
+
- Worker thread architecture (rendering trong worker thread riêng biệt)
|
|
200
|
+
- Native C++ addon cho hiệu suất cao
|
|
201
|
+
- Reactive state management
|
|
202
|
+
- Route-based navigation
|
|
109
203
|
|
|
110
|
-
|
|
111
|
-
$ galaxy-code --test
|
|
204
|
+
### Document Parsing
|
|
112
205
|
|
|
113
|
-
|
|
114
|
-
|
|
206
|
+
| Package | Phiên bản | Mục đích |
|
|
207
|
+
|---------|-----------|---------|
|
|
208
|
+
| **mammoth** | ^1.11.0 | Đọc file DOCX/DOC → plain text |
|
|
209
|
+
| **pdf-parse** | ^1.1.1 | Đọc file PDF → plain text |
|
|
210
|
+
| **xlsx** | ^0.18.5 | Đọc file Excel (XLSX/XLS/XLSM) → bảng markdown có cấu trúc |
|
|
115
211
|
|
|
116
|
-
|
|
117
|
-
$ galaxy-code --reset-config
|
|
212
|
+
### Runtime & Build
|
|
118
213
|
|
|
119
|
-
|
|
120
|
-
|
|
214
|
+
| Package | Phiên bản | Mục đích |
|
|
215
|
+
|---------|-----------|---------|
|
|
216
|
+
| **tsx** | ^4.21.0 | TypeScript execution (ts-node alternative) |
|
|
217
|
+
| **typescript** | ~5.9.2 | Ngôn ngữ chính |
|
|
218
|
+
| **Node.js** | >=18 | Runtime |
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Kiến trúc
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
artifacts/galaxy-cli/
|
|
226
|
+
├── src/
|
|
227
|
+
│ ├── cli.ts # Entry point: xử lý argv (config, urd, TUI)
|
|
228
|
+
│ ├── main.ts # TUI app khởi tạo (Rezi createNodeApp)
|
|
229
|
+
│ ├── types.ts # TypeScript types chung
|
|
230
|
+
│ ├── theme.ts # Themes: Nord, Dark, Light
|
|
231
|
+
│ │
|
|
232
|
+
│ ├── agents/
|
|
233
|
+
│ │ ├── runner.ts # Điều phối AI call + tool execution + track file writes
|
|
234
|
+
│ │ ├── claude.ts # Anthropic Claude driver (streaming)
|
|
235
|
+
│ │ ├── gemini.ts # Google Gemini driver (streaming)
|
|
236
|
+
│ │ ├── ollama.ts # Ollama local driver (streaming)
|
|
237
|
+
│ │ ├── codex.ts # OpenAI Codex/GPT driver (streaming)
|
|
238
|
+
│ │ ├── manual.ts # Manual/auto-Ollama driver
|
|
239
|
+
│ │ ├── urd-agent.ts # Sub Agent: phân tích URD document
|
|
240
|
+
│ │ ├── code-reviewer.ts # Sub Agent: review code sau khi AI viết xong
|
|
241
|
+
│ │ ├── session-tracker.ts # Ghi lại file được viết/sửa trong session
|
|
242
|
+
│ │ └── types.ts # AgentDriver interface + system prompt
|
|
243
|
+
│ │
|
|
244
|
+
│ ├── config/
|
|
245
|
+
│ │ ├── manager.ts # Load/save config + platform path detection
|
|
246
|
+
│ │ └── types.ts # GalaxyConfig, AgentConfig interfaces
|
|
247
|
+
│ │
|
|
248
|
+
│ ├── context/
|
|
249
|
+
│ │ ├── notes.ts # Structured Notes: load/save ~/.galaxy/NOTE.md
|
|
250
|
+
│ │ └── compaction.ts # Context Compaction: tóm tắt khi >40 messages
|
|
251
|
+
│ │
|
|
252
|
+
│ ├── helpers/
|
|
253
|
+
│ │ ├── keybindings.ts # Ánh xạ phím → lệnh
|
|
254
|
+
│ │ └── state.ts # State management + reducers
|
|
255
|
+
│ │
|
|
256
|
+
│ ├── screens/
|
|
257
|
+
│ │ ├── index.ts # Route definitions cho Rezi
|
|
258
|
+
│ │ ├── chat.ts # Màn hình Chat (F1)
|
|
259
|
+
│ │ ├── plan.ts # Màn hình Plan (F2)
|
|
260
|
+
│ │ ├── settings.ts # Màn hình Settings (F3)
|
|
261
|
+
│ │ └── shell.ts # Shell command execution helper
|
|
262
|
+
│ │
|
|
263
|
+
│ └── tools/
|
|
264
|
+
│ ├── file-tools.ts # File tools: read, write, edit, grep (cross-platform), head, tail
|
|
265
|
+
│ └── document-reader.ts # Document parser: PDF, DOCX, XLSX/XLS, CSV, MD, TXT
|
|
266
|
+
│
|
|
267
|
+
├── package.json
|
|
268
|
+
├── tsconfig.json
|
|
269
|
+
└── README.md
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Tính năng Context Engineering
|
|
275
|
+
|
|
276
|
+
### 1. Just-in-Time (JIT) Retrieval
|
|
277
|
+
|
|
278
|
+
Thay vì load toàn bộ file vào context, AI sử dụng các tool để chỉ lấy phần cần thiết:
|
|
121
279
|
|
|
122
|
-
# Disable auto-update
|
|
123
|
-
$ galaxy-code --no-auto-update
|
|
124
280
|
```
|
|
281
|
+
read_file(path, maxLines=200, offset=0) # Đọc từng phần (có offset + giới hạn dòng)
|
|
282
|
+
grep(pattern, path, contextLines=2) # Tìm kiếm regex (native grep macOS/Linux, Node.js trên Windows)
|
|
283
|
+
head(path, lines=50) # Đọc N dòng đầu
|
|
284
|
+
tail(path, lines=50) # Đọc N dòng cuối
|
|
285
|
+
list_dir(path) # Khám phá cấu trúc thư mục
|
|
286
|
+
edit_file(path, old_string, new_string) # Sửa phẫu thuật — chỉ thay đúng đoạn cần sửa
|
|
287
|
+
read_document(path) # Đọc PDF / DOCX / XLSX / CSV — trả về bảng markdown có cấu trúc
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### 2. Context Compaction
|
|
291
|
+
|
|
292
|
+
Khi hội thoại vượt quá **40 tin nhắn**, hệ thống tự động:
|
|
293
|
+
1. Tóm tắt 30 tin nhắn đầu thành một summary message
|
|
294
|
+
2. Giữ nguyên 10 tin nhắn gần nhất
|
|
295
|
+
3. Giải phóng context window cho tiếp tục
|
|
125
296
|
|
|
126
|
-
###
|
|
297
|
+
### 3. Structured Notes (`NOTE.md`)
|
|
298
|
+
|
|
299
|
+
AI có thể ghi lại các thông tin quan trọng vào `~/.galaxy/NOTE.md`:
|
|
300
|
+
- Ghi chú được load vào đầu mỗi session
|
|
301
|
+
- Persistent qua các lần khởi động
|
|
302
|
+
- URD summaries tự động append vào NOTE.md
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## Sub AI Agent: URD Analyzer
|
|
307
|
+
|
|
308
|
+
URD Agent là một sub-agent chuyên biệt, hoạt động độc lập với TUI:
|
|
127
309
|
|
|
128
310
|
```bash
|
|
129
|
-
|
|
130
|
-
|
|
311
|
+
galaxy-code urd ./requirements.pdf
|
|
312
|
+
```
|
|
131
313
|
|
|
132
|
-
|
|
133
|
-
|
|
314
|
+
**Luồng hoạt động:**
|
|
315
|
+
1. Đọc file (PDF/DOCX/MD/TXT) bằng document-reader
|
|
316
|
+
2. Truncate tối đa 60.000 ký tự cho context window
|
|
317
|
+
3. Tự động chọn AI provider tốt nhất đang có (theo thứ tự: Claude > Gemini > Ollama > Codex > Manual)
|
|
318
|
+
4. Gửi document với system prompt chuyên biệt của senior requirements analyst
|
|
319
|
+
5. Stream kết quả ra terminal
|
|
320
|
+
6. Lưu tóm tắt vào `~/.galaxy/urd-summaries/`
|
|
321
|
+
7. Append key points vào `NOTE.md` để dùng trong TUI session
|
|
134
322
|
|
|
135
|
-
|
|
136
|
-
|
|
323
|
+
**Output bao gồm:**
|
|
324
|
+
- Document Overview
|
|
325
|
+
- Key Functional Requirements
|
|
326
|
+
- Non-Functional Requirements
|
|
327
|
+
- Stakeholders
|
|
328
|
+
- Acceptance Criteria
|
|
329
|
+
- Risks & Assumptions
|
|
330
|
+
- Priority Recommendations (top 3)
|
|
137
331
|
|
|
138
|
-
|
|
139
|
-
> What are React hooks?
|
|
332
|
+
---
|
|
140
333
|
|
|
141
|
-
|
|
142
|
-
> /test true
|
|
334
|
+
## Sub AI Agent: Code Reviewer
|
|
143
335
|
|
|
144
|
-
|
|
145
|
-
> /mode claude
|
|
336
|
+
Code Reviewer là một sub-agent chuyên biệt, tự động kích hoạt sau khi AI viết hoặc chỉnh sửa code trong session.
|
|
146
337
|
|
|
147
|
-
|
|
148
|
-
> /information
|
|
338
|
+
### Cách hoạt động
|
|
149
339
|
|
|
150
|
-
|
|
151
|
-
> /history
|
|
340
|
+
Trong suốt một session, hệ thống **Session Tracker** âm thầm ghi lại mọi file được AI tạo ra hoặc sửa đổi (qua `write_file` hoặc `edit_file`). Khi AI hoàn thành xong công việc, Code Reviewer tự động đọc lại toàn bộ danh sách file đó và gửi cho một AI instance riêng biệt — đóng vai senior code reviewer — để phân tích.
|
|
152
341
|
|
|
153
|
-
|
|
154
|
-
|
|
342
|
+
```
|
|
343
|
+
AI viết/sửa file → Session Tracker ghi nhận
|
|
344
|
+
↓
|
|
345
|
+
AI hoàn thành nhiệm vụ / gõ /review
|
|
346
|
+
↓
|
|
347
|
+
Code Reviewer đọc tất cả file trong session
|
|
348
|
+
↓
|
|
349
|
+
Gửi cho AI (cùng provider) với prompt reviewer
|
|
350
|
+
↓
|
|
351
|
+
Kết quả hiển thị trực tiếp trong Chat
|
|
155
352
|
```
|
|
156
353
|
|
|
157
|
-
|
|
354
|
+
### Kích hoạt
|
|
158
355
|
|
|
159
|
-
|
|
356
|
+
| Cách | Mô tả |
|
|
357
|
+
|------|-------|
|
|
358
|
+
| **Tự động** | Sau mỗi lần AI viết file và hoàn thành nhiệm vụ |
|
|
359
|
+
| **Thủ công** | Gõ `/review` trong ô chat bất cứ lúc nào |
|
|
160
360
|
|
|
161
|
-
|
|
361
|
+
> Khi bạn gõ `Ctrl+K` để xóa chat, session tracker cũng được reset — file counter trở về 0.
|
|
162
362
|
|
|
163
|
-
|
|
164
|
-
- Technology stack in use
|
|
165
|
-
- Key features and components
|
|
166
|
-
- Potential improvement areas
|
|
363
|
+
### Định dạng kết quả
|
|
167
364
|
|
|
168
|
-
|
|
365
|
+
Code Reviewer trả về phân tích theo chuẩn sau, hiển thị ngay trong cửa sổ Chat:
|
|
169
366
|
|
|
170
|
-
|
|
367
|
+
```
|
|
368
|
+
🔍 Code Review Result (N files)
|
|
171
369
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
4. **Verification** - Optionally runs tests and code reviews
|
|
370
|
+
- [CRITICAL] `src/auth.ts:42` — Token không được hash trước khi lưu DB. Dùng bcrypt.hash() thay vì lưu plain text.
|
|
371
|
+
- [WARNING] `src/api.ts:88` — Thiếu xử lý trường hợp response.data là null, có thể gây crash runtime.
|
|
372
|
+
- [INFO] `src/utils.ts` — Hàm formatDate() có thể dùng Intl.DateTimeFormat thay vì xử lý thủ công.
|
|
176
373
|
|
|
177
|
-
|
|
374
|
+
⚠️ Issues found — 1 critical, 1 warning (cần sửa trước khi ship)
|
|
375
|
+
```
|
|
178
376
|
|
|
179
|
-
|
|
377
|
+
| Mức độ | Ý nghĩa |
|
|
378
|
+
|--------|---------|
|
|
379
|
+
| `[CRITICAL]` | Lỗi nghiêm trọng — bug, security hole, crash runtime. Phải sửa ngay |
|
|
380
|
+
| `[WARNING]` | Vấn đề cần chú ý — edge case, code quality, có thể gây lỗi sau |
|
|
381
|
+
| `[INFO]` | Gợi ý cải thiện — tùy chọn, không bắt buộc |
|
|
382
|
+
| `✅ LGTM` | Không có vấn đề gì, code sạch |
|
|
180
383
|
|
|
181
|
-
|
|
182
|
-
- Execute shell commands safely
|
|
183
|
-
- Track progress and report results
|
|
184
|
-
- Handle errors gracefully
|
|
384
|
+
### Đặc điểm
|
|
185
385
|
|
|
186
|
-
|
|
386
|
+
- Dùng **cùng AI provider** với agent chính (không cần cấu hình thêm)
|
|
387
|
+
- Hỗ trợ **mọi ngôn ngữ lập trình** — AI đọc được tất cả
|
|
388
|
+
- Phân tích **cross-file**: phát hiện mâu thuẫn giữa các file với nhau
|
|
389
|
+
- Giới hạn 8.000 ký tự/file để tránh vượt context window
|
|
187
390
|
|
|
188
|
-
|
|
391
|
+
---
|
|
189
392
|
|
|
190
|
-
|
|
191
|
-
2. **AI Provider API Keys** (at least one):
|
|
192
|
-
- **Anthropic Claude**: `ANTHROPIC_API_KEY` for Claude models
|
|
193
|
-
- **Google Gemini**: `GOOGLE_AI_API_KEY` or `GEMINI_API_KEY` for Gemini models
|
|
194
|
-
- **Ollama**: Local installation with required models
|
|
393
|
+
## Màn hình TUI
|
|
195
394
|
|
|
196
|
-
###
|
|
395
|
+
### Chat (F1)
|
|
396
|
+
- Nhập prompt và gửi đến AI agent đang active
|
|
397
|
+
- Hiển thị streaming response theo thời gian thực
|
|
398
|
+
- Hiển thị tool calls (read_file, grep, v.v.) và kết quả
|
|
399
|
+
- Cuộn lịch sử hội thoại
|
|
197
400
|
|
|
198
|
-
|
|
401
|
+
### Plan (F2)
|
|
402
|
+
- Hiển thị các task step được AI tự động extract từ response
|
|
403
|
+
- Tracking trạng thái: pending → running → done/failed
|
|
404
|
+
- Hỗ trợ hiển thị kế hoạch nhiều bước
|
|
199
405
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
GEMINI_API_KEY=your_gemini_api_key_here
|
|
406
|
+
### Settings (F3)
|
|
407
|
+
- Chuyển đổi giữa các AI provider
|
|
408
|
+
- Nhập/cập nhật API keys
|
|
409
|
+
- Chọn model cho từng provider
|
|
410
|
+
- Cài đặt auto-update
|
|
206
411
|
|
|
207
|
-
|
|
208
|
-
OLLAMA_HOST=http://localhost:11434
|
|
209
|
-
DEBUG=false
|
|
210
|
-
```
|
|
412
|
+
---
|
|
211
413
|
|
|
212
|
-
##
|
|
414
|
+
## Phát triển
|
|
213
415
|
|
|
214
|
-
|
|
416
|
+
```bash
|
|
417
|
+
# Chạy trong dev mode
|
|
418
|
+
pnpm dev
|
|
215
419
|
|
|
216
|
-
|
|
420
|
+
# Type check
|
|
421
|
+
pnpm typecheck
|
|
217
422
|
|
|
218
|
-
|
|
423
|
+
# Chạy CLI entry point
|
|
424
|
+
pnpm start
|
|
425
|
+
```
|
|
219
426
|
|
|
220
|
-
|
|
221
|
-
- GitHub: [@kevinbui](https://github.com/kevinbui)
|
|
427
|
+
---
|
|
222
428
|
|
|
223
|
-
##
|
|
429
|
+
## License
|
|
224
430
|
|
|
225
|
-
|
|
226
|
-
- [Anthropic Claude](https://www.anthropic.com/claude) - Advanced AI models
|
|
227
|
-
- [Google Gemini](https://ai.google.dev/) - AI orchestration
|
|
228
|
-
- [Ollama](https://ollama.com/) - Local AI model serving
|
|
431
|
+
MIT © Galaxy Code Project
|