@mrtrinhvn/ag-kit 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,83 +1,69 @@
1
- # Antigravity Kit Core (`@mrtrinhvn/ag-kit`) 🚀
1
+ # Antigravity Kit (`@mrtrinhvn/ag-kit`) 🧠
2
2
 
3
- A generic, institutional-grade AI programming framework for automating scaffolding, architecture, and coding directly inside your software projects.
3
+ **Universal Memory System** - Trái tim nhận thức ghi nhớ cho mọi dự án AI Agentic.
4
+ Cấy ghép Lõi Bộ Nhớ 3 Tầng (.agent) vào bất kỳ dự án nào để cung cấp khả năng lưu trữ Context, cấu trúc Codebase, và Vector Semantic Search (nhờ `Ollama` + `nomic-embed-text`) cho các tác tử AI.
4
5
 
5
6
  ## 📦 Quick Start
6
7
 
7
- The best way to inject AG-Kit into any project is via `npx`. Bạn thể chạy trực tiếp để vào **Menu tương tác**:
8
+ Cách tốt nhất để cấy ghép AG-Kit vào dự án dùng `npx`. Chạy lệnh sau để mở **Bảng điều khiển Tương tác**:
8
9
 
9
10
  ```bash
10
- # DASHBOARD - Menu chọn tất cả tác vụ (Khuyên dùng)
11
11
  npx @mrtrinhvn/ag-kit@latest
12
12
  ```
13
13
 
14
- Hoặc chạy các lệnh đơn lẻ:
14
+ Hoặc chạy các lệnh đơn lẻ nếu bạn đã nhớ cú pháp:
15
15
  ```bash
16
- # 1. Khởi tạo bộ não (Inject .agent folder)
16
+ # 1. Khởi tạo / Cấy ghép Lõi (.agent folder)
17
17
  npx @mrtrinhvn/ag-kit@latest init
18
18
 
19
- # 2. Kiểm tra sức khỏe hệ thống (CDP, Ollama, Models)
20
- npx @mrtrinhvn/ag-kit@latest check
19
+ # 2. Xây dựng Bộ não (Quét Codebase & Vector hóa ký ức)
20
+ npx @mrtrinhvn/ag-kit@latest brain
21
21
 
22
- # 3. Kiểm tra trạng thái phiên bản
23
- npx @mrtrinhvn/ag-kit@latest status
22
+ # 3. Tra cứu Vector Memory (Xem các node đã lưu)
23
+ npx @mrtrinhvn/ag-kit@latest memory
24
24
  ```
25
25
 
26
26
  ---
27
27
 
28
- ## 🛠 Lệnh CLI & Cách sử dụng
28
+ ## 🛠 Lệnh CLI & Hệ sinh thái Bộ Não
29
29
 
30
- | Lệnh | Ý nghĩa | Chi tiết |
30
+ | Lệnh | Ý nghĩa | Chi tiết tác vụ |
31
31
  |---|---|---|
32
- | `ag-kit` | **Dashboard** | (Không tham số) Mở menu chọn tương tác cực kỳ tiện lợi. |
33
- | `ag-kit init` | **Khởi tạo** | Cài đặt tủy não `.agent` tạo file `.env` mẫu. |
34
- | `ag-kit check` | **Kiểm tra** | Quét cổng CDP (mặc định 9555), kiểm tra OllamaAI Models. |
35
- | `ag-kit update` | **Cập nhật** | Nâng cấp Agents/Skills/Workflows mới nhất không làm mất dữ liệu Ký ức. |
36
- | `ag-kit status` | **Trạng thái** | Hiển thị rõ: Phiên bản Tool (CLI) Phiên bản Core (Brain) đang dùng. |
32
+ | `ag-kit` | **Dashboard** | Mở menu tương tác trực quan. Khuyên dùng. |
33
+ | `ag-kit init` | **Khởi tạo** | Cấy ghép toàn bộ tủy não `.agent` vào dự án trắng. |
34
+ | `ag-kit brain` | **Bộ Não** | Tự động gọi `brain_builder.py` để quét Codebase, trích xuất Vector Memory viết Báo cáo Nhận thức `summary.md`. |
35
+ | `ag-kit memory` | ** ức** | Hiển thị các Mảnh ký ức (Hot/Cold Nodes) đang được lưu trong Không gian Vector `graph.db`. |
36
+ | `ag-kit update` | **Cập nhật** | Nâng cấp Agents/Skills/Workflows mới nhất từ NPM không làm mất dữ liệu Ký ức hoặc Knowledge của dự án. |
37
+ | `ag-kit status` | **Trạng thái** | Hiển thị phiên bản Tool và kiểm tra xem Bộ Não (`summary.md`) đã được hình thành chưa. |
37
38
 
38
- ### ⚙️ Cấu hình Cổng (Custom Port)
39
+ ---
39
40
 
40
- Mặc định AG-Kit quét cổng **9555** **9222**. Nếu bạn muốn dùng một cổng riêng cho từng dự án (để tránh xung đột khi mở nhiều IDE), hãy sửa file `.env`:
41
+ ## 🏗 Kiến trúc Trí nhớ 3 Tầng (3-Tier Memory)
41
42
 
42
- ```env
43
- CDP_PORT=12345
44
- ```
45
- Lệnh `ag-kit check` sẽ tự động ưu tiên cổng này để kết nối với IDE.
43
+ Sau khi chạy `init` và `brain`, dự án của bạn sẽ vận hành theo mô hình:
46
44
 
47
- ---
45
+ 1. **Lớp L1 (Working Index):** `repomap.json` - Sơ đồ hàm, class của toàn bộ codebase.
46
+ 2. **Lớp L2 (Graph Vector Memory):** `graph.db` - Cơ sở dữ liệu đồ thị + Vector Embeddings. Hệ thống ngầm gọi **Ollama (nomic-embed-text)** để mã hóa mọi lệnh `memory_save` thành toán học, cho phép RAG tìm kiếm theo ý nghĩa (Semantic Search) với độ trễ 0ms và chi phí API $0.
47
+ 3. **Lớp L3 (Knowledge Base):** Báo cáo `summary.md` + file markdown gốc của dự án.
48
48
 
49
- ## 🏗 Cấu trúc hệ thống (.agent)
49
+ ## 🤖 Dual-Model Coordination
50
50
 
51
- Sau khi chạy `init`, dự án của bạn sẽ bộ khung tiêu chuẩn:
51
+ Gói `ag-kit` khuyến khích nguyên kết hợp 2 AI:
52
+ - **Local AI (Ollama):** Đảm nhiệm việc đánh chỉ mục Vector (Embedding) lặng lẽ ở background.
53
+ - **Cloud AI (Gemini/Claude):** Dùng để suy luận logic và viết code dựa trên Context mớm từ Local AI.
52
54
 
53
- - **`GEMINI.md`**: "Hiến pháp" tối cao của Agent, đảm bảo duy hệ thống an toàn.
54
- - **`agents/`**: Các đặc vụ chuyên trách (Orchestrator, Frontend, Backend, Debugger).
55
- - **`skills/`**: Các thuật toán tác chiến (Clean code, TDD, React Expert, Rust Pro...).
56
- - **`workflows/`**: Các lệnh gõ tắt (slash commands) như `/create`, `/plan`, `/debug`.
57
- - **`knowledge/`**: Nơi lưu giữ giao thức v3 và các kiến thức tự chữa lành (`self-healing`).
55
+ > Vui lòng tải model: `ollama pull nomic-embed-text` để kích hoạt tính năng Semantic Search của `ag-kit`.
58
56
 
59
57
  ---
60
58
 
61
59
  ## 🔄 Cập nhật & Bảo trì
62
60
 
63
- Chúng tôi liên tục cập nhật các kỹ năng mới từ dự án `ag-orchestrator`. Để đảm bảo "bộ não" của bạn luôn thông minh nhất:
61
+ Chúng tôi liên tục nâng cấp kỹ năng cho Agent (Skills, Workflows). Để bộ não dự án của bạn luôn thông minh nhất:
64
62
 
65
63
  ```bash
66
- # Luôn dùng @latest để lấy những tinh hoa mới nhất từ NPM
64
+ # Luôn dùng @latest để lấy bộ kỹ năng mới nhất
67
65
  npx @mrtrinhvn/ag-kit@latest update
68
66
  ```
69
67
 
70
68
  ---
71
-
72
- ## ❌ Xử lý lỗi thường gặp (Troubleshooting)
73
-
74
- **1. Lỗi phiên bản không khớp (Version ghosting):**
75
- Nếu `status` báo phiên bản cũ hơn bản trên NPM, đó là do cache của `npx` hoặc bạn đã cài global.
76
- - Cách giải quyết: Luôn thêm `@latest` sau tên gói (`npx @mrtrinhvn/ag-kit@latest`) hoặc cập nhật bộ não bằng lệnh `ag-kit update`.
77
- - Giờ đây, các lệnh `init` và `status` sẽ tự động phát hiện và nhắc bạn chạy `update` nếu phát hiện lệch phiên bản.
78
-
79
- **2. Lỗi EACCES (Quyền truy cập):**
80
- Nếu cài global bị báo lỗi quyền, hãy dùng `npx` (Khuyên dùng) hoặc dùng `sudo`.
81
-
82
- ---
83
- *Built with ❤️ to enforce Institutional-Grade Software Standards.*
69
+ *Built with ❤️ to enforce Institutional-Grade AI Memory Standards.*
package/bin/cli.js CHANGED
@@ -2,31 +2,11 @@
2
2
  const { program } = require('commander');
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
- const net = require('net');
5
+ const { execSync } = require('child_process');
6
6
 
7
7
  const TEMPLATE_DIR = path.join(__dirname, '..', 'template');
8
8
  const TARGET_AGENT_DIR = path.join(process.cwd(), '.agent');
9
9
 
10
- function isPortAvailable(port) {
11
- return new Promise((resolve) => {
12
- const server = net.createServer();
13
- server.once('error', () => resolve(false));
14
- server.once('listening', () => {
15
- server.close();
16
- resolve(true);
17
- });
18
- server.listen(port, '127.0.0.1');
19
- });
20
- }
21
-
22
- async function findNextAvailablePort(startPort) {
23
- let port = startPort;
24
- while (!(await isPortAvailable(port))) {
25
- port++;
26
- }
27
- return port;
28
- }
29
-
30
10
  // Helper copy đệ quy
31
11
  function copyRecursiveSync(src, dest) {
32
12
  const exists = fs.existsSync(src);
@@ -44,108 +24,42 @@ function copyRecursiveSync(src, dest) {
44
24
  }
45
25
  }
46
26
 
47
-
48
- function migrateLegacyMemories() {
49
- const legacyDir = path.join(process.cwd(), 'data', 'memories');
50
- if (!fs.existsSync(legacyDir)) return;
51
-
52
- let migratedCount = 0;
53
- try {
54
- const files = fs.readdirSync(legacyDir).filter(f => f.endsWith('.jsonl'));
55
- for (const file of files) {
56
- const filePath = path.join(legacyDir, file);
57
- const lines = fs.readFileSync(filePath, 'utf-8').split('\n');
58
- let changed = false;
59
- const newLines = lines.map(line => {
60
- if (!line.trim()) return line;
61
- try {
62
- const item = JSON.parse(line);
63
- if (item.content && !item.content.includes('[Node:')) {
64
- item.content = `[Node:Legacy_Knowledge] => ${item.content}`;
65
- changed = true;
66
- return JSON.stringify(item);
67
- }
68
- } catch(e) {}
69
- return line;
70
- });
71
- if (changed) {
72
- fs.writeFileSync(filePath, newLines.join('\n'));
73
- migratedCount++;
74
- }
75
- }
76
- if (migratedCount > 0) {
77
- console.log(`\x1b[35m🧠 TỰ ĐỘNG: Đã băm ${migratedCount} tệp Ký ức cũ thành Tiền-Đồ-Thị (Pseudo-Graph) để tương thích chuẩn mới!\x1b[0m`);
78
- }
79
- } catch(e) { /* ignore errors during migration */ }
80
- }
81
-
82
27
  const pkg = require('../package.json');
83
28
  program
84
29
  .name('ag-kit')
85
- .description('Trí khôn Lập trình Phổ quát - AI Agent Initialization Framework')
30
+ .description('Antigravity Kit - Hệ thống Trí nhớ và Nhận thức AI Phổ quát')
86
31
  .version(pkg.version);
87
32
 
88
33
  program.command('init')
89
- .description('Install .agent folder into your project')
34
+ .description('Cấy ghép Lõi Trí Nhớ (.agent) vào dự án này')
90
35
  .action(() => {
91
36
  console.log('\x1b[36m🚀 Đang khởi tạo bộ Tủy Não Lập Trình AI (AG-Kit)...\x1b[0m');
92
37
 
93
38
  const srcAgent = path.join(TEMPLATE_DIR, '.agent');
94
39
  if (!fs.existsSync(TARGET_AGENT_DIR)) {
95
40
  copyRecursiveSync(srcAgent, TARGET_AGENT_DIR);
96
- // Ghi lại version vào .agent/.version
97
41
  fs.writeFileSync(path.join(TARGET_AGENT_DIR, '.version'), pkg.version);
98
- console.log(`\x1b[32m✅ Đã cài ráp thành công thư mục .agent (phiên bản v${pkg.version}) vào Project!\x1b[0m`);
42
+ console.log(`\x1b[32m✅ Đã cấy ghép thành công thư mục .agent (v${pkg.version}) vào Project!\x1b[0m`);
99
43
 
100
- // Khởi động .env nếu chưa
101
- const envPath = path.join(process.cwd(), '.env');
102
- (async () => {
103
- const idePort = await findNextAvailablePort(9555);
104
- const bridgePort = await findNextAvailablePort(idePort + 1);
105
-
106
- if (!fs.existsSync(envPath)) {
107
- const envTemplate = `# --- Remote Orchestration (Golden Combo) ---\nIDE_PORT=${idePort}\nBRIDGE_PORT=${bridgePort}\n\nPROJECT_NAME=ag-project\n`;
108
- fs.writeFileSync(envPath, envTemplate);
109
- console.log(`\x1b[34mℹ️ Đã tạo .env với IDE_PORT=${idePort} và BRIDGE_PORT=${bridgePort}\x1b[0m`);
110
- } else {
111
- let envContent = fs.readFileSync(envPath, 'utf-8');
112
- let changed = false;
113
- if (!envContent.includes('IDE_PORT=')) {
114
- envContent += `\nIDE_PORT=${idePort}\n`;
115
- changed = true;
116
- }
117
- if (!envContent.includes('BRIDGE_PORT=')) {
118
- envContent += `BRIDGE_PORT=${bridgePort}\n`;
119
- changed = true;
120
- }
121
- if (changed) {
122
- fs.writeFileSync(envPath, envContent);
123
- console.log(`\x1b[34mℹ️ Đã bổ sung cổng tự động: IDE_PORT=${idePort}, BRIDGE_PORT=${bridgePort}\x1b[0m`);
124
- }
125
- }
126
- })();
44
+ console.log('\x1b[35m👉 Bước tiếp theo: Hãy chọn menu "Build Bộ Não" để quét dự án.\x1b[0m');
127
45
  } else {
128
46
  console.log('\x1b[33m⚠️ Thư mục .agent đã tồn tại.\x1b[0m');
129
47
  const vPath = path.join(TARGET_AGENT_DIR, '.version');
130
48
  if (fs.existsSync(vPath)) {
131
49
  const installedVersion = fs.readFileSync(vPath, 'utf-8').trim();
132
50
  if (installedVersion !== pkg.version) {
133
- console.log(`\x1b[35m👉 Phát hiện phiên bản cũ (v${installedVersion}). Hãy dùng lệnh "ag-kit update" để cập nhật lên v${pkg.version}.\x1b[0m`);
51
+ console.log(`\x1b[35m👉 Phát hiện phiên bản cũ (v${installedVersion}). Hãy dùng lệnh "ag-kit update".\x1b[0m`);
134
52
  } else {
135
53
  console.log(`\x1b[34mℹ️ Bạn đang sử dụng phiên bản khớp với bộ công cụ (v${pkg.version}).\x1b[0m`);
136
54
  }
137
- } else {
138
- console.log('\x1b[35m👉 Hãy dùng lệnh "ag-kit update" để đồng bộ cấu trúc mới.\x1b[0m');
139
55
  }
140
56
  }
141
-
142
- console.log('\x1b[35m\n🎉 Hoàn tất! Vui lòng copy luật GEMINI vào file GEMINI.md của dự án nếu chưa có.\x1b[0m');
143
57
  });
144
58
 
145
59
  program.command('update')
146
- .description('Update to the latest version')
60
+ .description('Nâng cấp các kỹ năng AI lên phiên bản mới nhất')
147
61
  .action(() => {
148
- console.log('\x1b[36m🔄 Đang cập nhật siêu luân xa Lập trình (AG-Kit)...\x1b[0m');
62
+ console.log('\x1b[36m🔄 Đang nâng cấp Kỹ năng AI (AG-Kit)...\x1b[0m');
149
63
  const srcAgent = path.join(TEMPLATE_DIR, '.agent');
150
64
  const vPath = path.join(TARGET_AGENT_DIR, '.version');
151
65
  let oldVersion = '0.0.0';
@@ -153,9 +67,8 @@ program.command('update')
153
67
  oldVersion = fs.readFileSync(vPath, 'utf-8').trim();
154
68
  }
155
69
 
156
- // Chỉ cập nhật não bộ chuẩn (Agents, Skills, Workflows, Scripts, Rules)
157
- // Tôn trọng dữ liệu Knowledge của dự án đang có
158
- ['agents', 'skills', 'workflows', 'scripts', 'rules'].forEach(folder => {
70
+ // Chỉ cập nhật các thư mục chuẩn, KHÔNG chạm vào .agent/brain, .agent/cache, .agent/memory
71
+ ['agents', 'skills', 'workflows', 'scripts', 'rules', 'knowledge'].forEach(folder => {
159
72
  const src = path.join(srcAgent, folder);
160
73
  const dest = path.join(TARGET_AGENT_DIR, folder);
161
74
  if (fs.existsSync(src)) {
@@ -163,119 +76,73 @@ program.command('update')
163
76
  }
164
77
  });
165
78
 
166
- migrateLegacyMemories();
167
- // Cập nhật version vào .agent/.version
168
79
  fs.writeFileSync(vPath, pkg.version);
169
- console.log(`\x1b[32m✅ Cập nhật thành công! Phiên bản hiện tại: v${oldVersion} -> v${pkg.version}\x1b[0m`);
170
- console.log('\x1b[34m⚡️ Toàn bộ cấu trúc kỹ năng đã được đồng bộ.\x1b[0m');
80
+ console.log(`\x1b[32m✅ Nâng cấp thành công! Phiên bản hiện tại: v${oldVersion} -> v${pkg.version}\x1b[0m`);
171
81
  });
172
82
 
173
- program.command('check')
174
- .description('Verify environment health (CDP, Tokens, Ollama)')
175
- .action(async () => {
176
- const { execSync } = require('child_process');
177
- console.log('\x1b[36m🔍 Đang kiểm tra hệ sinh thái Antigravity...\x1b[0m');
178
-
83
+ program.command('brain')
84
+ .description('Quét Repo Xây dựng/Cập nhật Bộ não (3-Tier Memory)')
85
+ .action(() => {
86
+ console.log('\x1b[36m🧠 Đang khởi động tiến trình Tổng hợp Bộ Não...\x1b[0m');
179
87
  if (!fs.existsSync(TARGET_AGENT_DIR)) {
180
- console.log('\x1b[31m❌ Hệ thống chưa được khởi tạo. Thư mục .agent không tồn tại.\x1b[0m');
181
- console.log('\x1b[35m👉 Hãy chạy "ag-kit init" trước khi thực hiện kiểm tra này.\x1b[0m');
88
+ console.log('\x1b[31m❌ Chưa cấy ghép .agent. Hãy chạy "ag-kit init" trước.\x1b[0m');
182
89
  return;
183
90
  }
184
91
 
185
- // 1. Check .env
186
- const envPath = path.join(process.cwd(), '.env');
187
- if (fs.existsSync(envPath)) {
188
- console.log('\x1b[32m✅ .env: OK\x1b[0m');
189
- } else {
190
- console.log('\x1b[33m⚠️ .env: Không tìm thấy. Hãy tạo file .env từ template.\x1b[0m');
191
- }
192
-
193
- // 2. Check CDP Port (Prioritize CDP_PORT from .env)
194
- let ports = [9555, 9222];
195
- if (fs.existsSync(envPath)) {
196
- const content = fs.readFileSync(envPath, 'utf-8');
197
- const match = content.match(/CDP_PORT=(\d+)/);
198
- if (match) {
199
- const customPort = parseInt(match[1]);
200
- ports = [customPort, ...ports.filter(p => p !== customPort)];
201
- console.log(`\x1b[34mℹ️ Sử dụng cổng CDP tùy chỉnh từ .env: ${customPort}\x1b[0m`);
202
- }
92
+ try {
93
+ // Gọi Python script brain_builder với cờ --update
94
+ console.log('\x1b[35m[1/3] Quét cấu trúc Codebase...\x1b[0m');
95
+ console.log('\x1b[35m[2/3] Trích xuất Vector Memory...\x1b[0m');
96
+ console.log('\x1b[35m[3/3] Viết báo cáo Nhận thức...\x1b[0m\n');
97
+
98
+ const scriptPath = path.join(TARGET_AGENT_DIR, 'scripts', 'brain_builder.py');
99
+ execSync(`python3 ${scriptPath} --update`, { stdio: 'inherit' });
100
+
101
+ console.log('\n\x1b[32m✅ Bộ Não đã được tổng hợp thành công tại .agent/brain/summary.md!\x1b[0m');
102
+ } catch (e) {
103
+ console.log('\n\x1b[31m❌ Lỗi khi xây dựng Bộ Não. Hãy chắc chắn máy bạn có Python 3.\x1b[0m');
203
104
  }
105
+ });
204
106
 
205
- let cdpOk = false;
206
- for (const port of ports) {
207
- try {
208
- execSync(`curl -s --max-time 2 http://127.0.0.1:${port}/json/version`, { stdio: 'ignore' });
209
- console.log(`\x1b[32m✅ IDE CDP: Phát hiện tại cổng ${port}\x1b[0m`);
210
- cdpOk = true;
211
- break;
212
- } catch (e) {}
107
+ program.command('memory')
108
+ .description('Tra cứu Bộ nhớ Thực (Vector Memory)')
109
+ .action(() => {
110
+ console.log('\x1b[36m🕸️ Tra cứu Trí nhớ Semantic (graph.db)...\x1b[0m');
111
+ if (!fs.existsSync(TARGET_AGENT_DIR)) {
112
+ console.log('\x1b[31m❌ Chưa cấy ghép .agent. Hãy chạy "ag-kit init" trước.\x1b[0m');
113
+ return;
213
114
  }
214
- if (!cdpOk) console.log(`\x1b[31m❌ IDE CDP: Không tìm thấy IDE đang chạy ở các cổng: ${ports.join(', ')}\x1b[0m`);
215
-
216
- // 3. Check Ollama
217
115
  try {
218
- execSync('ollama --version', { stdio: 'ignore' });
219
- console.log('\x1b[32m✅ Ollama: Đã cài đặt\x1b[0m');
220
- try {
221
- execSync('curl -s --max-time 2 http://127.0.0.1:11434/api/tags', { stdio: 'ignore' });
222
- console.log('\x1b[32m✅ Ollama Service: Online\x1b[0m');
223
-
224
- // Kiểm tra model mặc định
225
- const models = execSync('curl -s http://127.0.0.1:11434/api/tags').toString();
226
- if (models.includes('nvidia_Orchestrator')) {
227
- console.log('\x1b[32m✅ Default Model: nvidia_Orchestrator (Sẵn sàng)\x1b[0m');
228
- } else {
229
- console.log('\x1b[33m⚠️ Default Model: nvidia_Orchestrator (Chưa tải - Khuyên dùng "ollama run hf.co/bartowski/nvidia_Orchestrator-8B-GGUF:Q4_K_M")\x1b[0m');
230
- }
231
- } catch (e) {
232
- console.log('\x1b[31m❌ Ollama Service: Offline (Gõ "ollama serve")\x1b[0m');
233
- }
116
+ const scriptPath = path.join(TARGET_AGENT_DIR, 'scripts', 'memory_tool.py');
117
+ execSync(`python3 ${scriptPath} list --limit 10`, { stdio: 'inherit' });
234
118
  } catch (e) {
235
- console.log('\x1b[33m⚠️ Ollama: Chưa cài đặt. Khuyên dùng để chạy model local.\x1b[0m');
119
+ console.log('\n\x1b[31m❌ Không thể đọc memory. Đã build brain chưa?\x1b[0m');
236
120
  }
237
-
238
- // 4. Check Telegram Token (if in .env)
239
- if (fs.existsSync(envPath)) {
240
- const content = fs.readFileSync(envPath, 'utf-8');
241
- if (content.includes('TELEGRAM_BOT_TOKEN') && !content.includes('YOUR_TOKEN_HERE')) {
242
- console.log('\x1b[32m✅ Telegram Token: Đã cấu hình\x1b[0m');
243
- } else {
244
- console.log('\x1b[33m⚠️ Telegram Token: Chưa cấu hình hoặc dùng giá trị mặc định.\x1b[0m');
245
- }
246
- }
247
-
248
- console.log('\n\x1b[35m✨ Kiểm tra hoàn tất. Hãy đảm bảo IDE và Bot cùng tần số!\x1b[0m');
249
121
  });
250
122
 
251
123
  program.command('status')
252
- .description('Check installation status')
124
+ .description('Xem trạng thái cài đặt')
253
125
  .action(() => {
254
- console.log('\x1b[36m📊 Trạng thái AG-Kit trong dự án hiện tại:\x1b[0m');
126
+ console.log('\x1b[36m📊 Trạng thái AG-Kit:\x1b[0m');
255
127
  if (fs.existsSync(TARGET_AGENT_DIR)) {
256
128
  console.log('\x1b[32m✅ Trạng thái : Đã Cài Đặt (Active)\x1b[0m');
257
- console.log(`📁 Đường dẫn : ${TARGET_AGENT_DIR}`);
258
129
 
259
130
  const vPath = path.join(TARGET_AGENT_DIR, '.version');
260
131
  let installedVersion = '0.0.0';
261
132
  if (fs.existsSync(vPath)) {
262
133
  installedVersion = fs.readFileSync(vPath, 'utf-8').trim();
263
134
  console.log(`🧠 Bản cài đặt : v${installedVersion}`);
264
- } else {
265
- console.log(`🧠 Bản cài đặt : Không rõ (Legacy)`);
266
135
  }
267
-
268
- console.log(`🏷 Bản Tool : v${pkg.version}`);
269
136
 
270
- if (installedVersion !== pkg.version) {
271
- console.log('\n\x1b[33m⚠️ CẢNH BÁO: Phiên bản bộ não (.agent) đang lệch với bộ công cụ (ag-kit)!\x1b[0m');
272
- console.log(`\x1b[35m👉 Hãy chạy "ag-kit update" để đồng bộ ngay.\x1b[0m`);
137
+ const brainPath = path.join(TARGET_AGENT_DIR, 'brain', 'summary.md');
138
+ if (fs.existsSync(brainPath)) {
139
+ console.log(`📚 Nhận thức : Đã não (summary.md)`);
140
+ } else {
141
+ console.log(`📚 Nhận thức : \x1b[33mChưa có não. Gõ "ag-kit brain" để tạo.\x1b[0m`);
273
142
  }
274
143
 
275
144
  } else {
276
- console.log('\x1b[31m❌ Trạng thái : Chưa gì.\x1b[0m');
277
- console.log('\x1b[35m👉 Gõ "ag-kit init" để biến thư mục này thành một Agentic Workspace!\x1b[0m');
278
- console.log(`🏷 Bản Tool : v${pkg.version}`);
145
+ console.log('\x1b[31m❌ Trạng thái : Dự án Trắng.\x1b[0m');
279
146
  }
280
147
  });
281
148
 
@@ -283,38 +150,49 @@ program.command('status')
283
150
  async function runInteractiveMenu() {
284
151
  const inquirer = require('inquirer');
285
152
  console.clear();
286
- console.log('\x1b[35m\n🧠 ANTIGRAVITY KIT - BẢNG ĐIỀU KHIỂN TÁC VỤ\x1b[0m');
153
+ console.log('\x1b[35m\n🧠 AG-KIT - BẢNG ĐIỀU KHIỂN HỆ SINH THÁI AI\x1b[0m');
287
154
  console.log('\x1b[34m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m');
288
155
 
156
+ const hasAgent = fs.existsSync(TARGET_AGENT_DIR);
157
+ const vPath = path.join(TARGET_AGENT_DIR, '.version');
158
+ let updateTag = '';
159
+ if (hasAgent && fs.existsSync(vPath)) {
160
+ const installed = fs.readFileSync(vPath, 'utf-8').trim();
161
+ if (installed !== pkg.version) {
162
+ updateTag = `\x1b[31m(Có bản mới: v${pkg.version})\x1b[0m `;
163
+ }
164
+ }
165
+
166
+ const choices = hasAgent ? [
167
+ { name: `🧠 Xây dựng / Cập nhật Bộ Não (build brain) - Thu thập Context`, value: 'brain' },
168
+ { name: `🕸️ Khám phá Ký ức (memory) - Xem dữ liệu Vector`, value: 'memory' },
169
+ { name: `🔄 Nâng cấp Kiến thức (update) ${updateTag}`, value: 'update' },
170
+ { name: '📊 Trạng thái (status) - Xem version & độ nhận thức', value: 'status' },
171
+ new inquirer.Separator(),
172
+ { name: '❌ Thoát', value: 'exit' }
173
+ ] : [
174
+ { name: '🚀 Khởi tạo (init) - Cấy ghép Tủy Não .agent vào thư mục này', value: 'init' },
175
+ new inquirer.Separator(),
176
+ { name: '❌ Thoát', value: 'exit' }
177
+ ];
178
+
289
179
  const { action } = await inquirer.prompt([
290
180
  {
291
- type: 'list',
292
- name: 'action',
293
- message: 'Chọn một tác vụ để thực hiện:',
294
- choices: [
295
- { name: '🚀 Khởi tạo (init) - Cài đặt .agent', value: 'init' },
296
- { name: '🔄 Cập nhật (update) - Nâng cấp bộ não', value: 'update' },
297
- { name: '🔍 Kiểm tra (check) - Test môi trường', value: 'check' },
298
- { name: '📊 Trạng thái (status) - Xem version', value: 'status' },
299
- new inquirer.Separator(),
300
- { name: '❌ Thoát', value: 'exit' }
301
- ]
181
+ type: 'list',
182
+ name: 'action',
183
+ message: hasAgent ? 'Lõi .agent đã sẵn sàng. Bạn muốn làm gì?' : 'Thư mục trống. Hãy chọn thao tác:',
184
+ choices: choices
302
185
  }
303
186
  ]);
304
187
 
305
188
  if (action === 'exit') {
306
- console.log('\x1b[36m👋 Tạm biệt! Hợp tác vui vẻ.\x1b[0m\n');
189
+ console.log('\x1b[36m👋 Tạm biệt!\x1b[0m\n');
307
190
  process.exit(0);
308
191
  }
309
192
 
310
- // Thực thi command
311
- console.log('\n\x1b[34m--- ĐANG THỰC THI ---\x1b[0m');
312
-
313
- // Chúng ta parse lại command với action đã chọn
314
- // Lưu ý: commander parse() trả về promise với parseAsync
193
+ console.log('\n\x1b[34m--- ĐANG THỰC THI ---\x1b[0m\n');
315
194
  await program.parseAsync([process.argv[0], process.argv[1], action]);
316
-
317
- console.log('\n\x1b[34m--- HOÀN TẤT TÁC VỤ ---\x1b[0m');
195
+ console.log('\n\x1b[34m--- HOÀN TẤT ---\x1b[0m\n');
318
196
 
319
197
  const { resume } = await inquirer.prompt([
320
198
  {
@@ -329,7 +207,7 @@ async function runInteractiveMenu() {
329
207
 
330
208
  if (process.argv.length <= 2) {
331
209
  runInteractiveMenu().catch(err => {
332
- console.error('\x1b[31m❌ Lỗi thực thi Menu:\x1b[0m', err);
210
+ console.error('\x1b[31m❌ Lỗi:\x1b[0m', err);
333
211
  process.exit(1);
334
212
  });
335
213
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrtrinhvn/ag-kit",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Antigravity Kit Base Framework - Generic Agentic AI Programming Core",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -0,0 +1,4 @@
1
+ # Shared User Identity & Preferences
2
+
3
+ This file contains shared knowledge across all projects (coding style, hardware, UI preferences).
4
+