@mrtrinhvn/ag-kit 1.1.1 → 1.1.4

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,78 +1,75 @@
1
1
  # Antigravity Kit Core (`@mrtrinhvn/ag-kit`) 🚀
2
2
 
3
- A generic, institutional-grade AI programming framework for automating scaffolding, architecture, and coding directly inside your software projects. Inspired by the principles of `.agent` systems, carefully stripped of domain-specific constraints to adapt to any software development lifecycle.
3
+ A generic, institutional-grade AI programming framework for automating scaffolding, architecture, and coding directly inside your software projects.
4
4
 
5
- ## 📦 Quick Install
5
+ ## 📦 Quick Start
6
6
 
7
- The best way to initialize the AG-Kit in a new project is using `npx`:
7
+ The best way to inject AG-Kit into any project is via `npx`:
8
8
 
9
9
  ```bash
10
- npx @mrtrinhvn/ag-kit init
11
- ```
12
-
13
- > **Note**: This is the **recommended** method for remote machines as it avoids all `EACCES` permission issues.
10
+ # 1. Khởi tạo bộ não (Inject .agent folder)
11
+ npx @mrtrinhvn/ag-kit@latest init
14
12
 
15
- ## 🛠 Global Usage & Commands
13
+ # 2. Kiểm tra sức khỏe hệ thống (CDP, Ollama, Models)
14
+ npx @mrtrinhvn/ag-kit@latest check
16
15
 
17
- You can also install it globally if you frequently create new projects:
18
-
19
- ```bash
20
- npm install -g @mrtrinhvn/ag-kit
16
+ # 3. Kiểm tra trạng thái phiên bản
17
+ npx @mrtrinhvn/ag-kit@latest status
21
18
  ```
22
19
 
23
- ### 🛠 Local Development (Linking)
20
+ ---
24
21
 
25
- If you are developing Ag-Kit locally and want to use it globally without publishing to NPM:
22
+ ## 🛠 Lệnh CLI & Cách sử dụng
26
23
 
27
- 1. Go to the Ag-Kit directory: `cd /home/tao/Projects/ag-kit`
28
- 2. Run: `npm link` (This creates a global symlink)
29
- 3. You can now use `ag-kit` anywhere!
24
+ | Lệnh | Ý nghĩa | Chi tiết |
25
+ |---|---|---|
26
+ | `ag-kit init` | **Khởi tạo** | Cài đặt tủy não `.agent` và tạo file `.env` mẫu. |
27
+ | `ag-kit check` | **Kiểm tra** | Quét cổng CDP (mặc định 9555), kiểm tra Ollama và AI Models. |
28
+ | `ag-kit update` | **Cập nhật** | Nâng cấp Agents/Skills/Workflows mới nhất mà không làm mất dữ liệu Ký ức. |
29
+ | `ag-kit status` | **Trạng thái** | Hiển thị rõ: Phiên bản Tool (CLI) và Phiên bản Core (Brain) đang dùng. |
30
30
 
31
- ### Troubleshooting: EACCES Permission Error
31
+ ### ⚙️ Cấu hình Cổng (Custom Port)
32
32
 
33
- If you see `npm error code EACCES` when installing globally via network (`npm install -g`), use one of these:
33
+ 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`:
34
34
 
35
- **Solution 1: Use sudo (For quick global install)**
36
- ```bash
37
- sudo npm install -g @mrtrinhvn/ag-kit
35
+ ```env
36
+ CDP_PORT=12345
38
37
  ```
38
+ Lệnh `ag-kit check` sẽ tự động ưu tiên cổng này để kết nối với IDE.
39
39
 
40
- **Solution 2: Use npx (Recommended - No sudo needed)**
41
- ```bash
42
- npx @mrtrinhvn/ag-kit <command>
43
- ```
44
- npx sẽ tự động tải và chạy mà không cần quyền ghi vào thư mục hệ thống.
40
+ ---
41
+
42
+ ## 🏗 Cấu trúc hệ thống (.agent)
45
43
 
46
- **Solution 3: Local Development (For this machine)**
47
- Follow [NPM's guide](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally) to change the global directory to your home folder.
44
+ Sau khi chạy `init`, dự án của bạn sẽ có bộ khung tiêu chuẩn:
45
+
46
+ - **`GEMINI.md`**: "Hiến pháp" tối cao của Agent, đảm bảo tư duy hệ thống và an toàn.
47
+ - **`agents/`**: Các đặc vụ chuyên trách (Orchestrator, Frontend, Backend, Debugger).
48
+ - **`skills/`**: Các thuật toán tác chiến (Clean code, TDD, React Expert, Rust Pro...).
49
+ - **`workflows/`**: Các lệnh gõ tắt (slash commands) như `/create`, `/plan`, `/debug`.
50
+ - **`knowledge/`**: Nơi lưu giữ giao thức v3 và các kiến thức tự chữa lành (`self-healing`).
48
51
 
49
52
  ---
50
53
 
51
- Then use the provided CLI anywhere:
54
+ ## 🔄 Cập nhật & Bảo trì
52
55
 
53
- | Command | Description |
54
- |---|---|
55
- | `ag-kit init` | Scaffolds the `.agent` framework (Agents, Skills, Workflows) into your current directory. |
56
- | `ag-kit check` | Verifies environment health (CDP, Tokens, Ollama, Models). |
57
- | `ag-kit update` | Pulls the latest rules and templates and safely overwrites the core `.agent` folders without breaking your custom `knowledge/` base. |
58
- | `ag-kit status` | Checks exactly which version of the AG-Kit is active in your current working directory. |
56
+ 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:
59
57
 
60
- ## 🧠 What's Inside the Brain?
58
+ ```bash
59
+ # Luôn dùng @latest để lấy những tinh hoa mới nhất từ NPM
60
+ npx @mrtrinhvn/ag-kit@latest update
61
+ ```
62
+
63
+ ---
61
64
 
62
- Running `ag-kit init` injects the following core architecture into your project:
65
+ ## Xử lỗi thường gặp (Troubleshooting)
63
66
 
64
- - **`GEMINI.md`**: The supreme constitution (Tier 0 Rules) ensuring the Agent always thinks systematically, acts safely, and never hallucinates code.
65
- - **`agents/`**: Core personas taking specialized roles (e.g., `orchestrator`, `frontend-specialist`, `backend-specialist`, `debugger`).
66
- - **`skills/`**: Tactical operational algorithms spanning from `clean-code` and `tdd-workflow` to `python-patterns` and `nextjs-react-expert`.
67
- - **`workflows/`**: Pre-defined step-by-step instructions (slash commands) like `/create`, `/plan`, `/brainstorm`, and `/debug`.
68
- - **`scripts/`**: CI/CD automation checkers like `lint_runner.py` and `security_scan.py`.
67
+ **1. Lỗi phiên bản không khớp (Version ghosting):**
68
+ Nếu `status` báo phiên bản hơn bản trên NPM, đó là do cache của `npx` hoặc bạn đã cài global.
69
+ - Cách giải quyết: Luôn thêm `@latest` sau tên gói hoặc chạy `sudo npm install -g @mrtrinhvn/ag-kit@latest`.
69
70
 
70
- ## ⚙️ How It Works
71
- The AG-Kit is designed to be injected into an AI IDE or a custom Agent workspace.
72
- 1. The AI reads `GEMINI.md` first.
73
- 2. It assumes the persona of the relevant specialist in `agents/`.
74
- 3. It selectively loads specific techniques from `skills/` based on context.
75
- 4. It continuously documents important technical learnings in `knowledge/`.
71
+ **2. Lỗi EACCES (Quyền truy cập):**
72
+ 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`.
76
73
 
77
74
  ---
78
75
  *Built with ❤️ to enforce Institutional-Grade Software Standards.*
package/bin/cli.js CHANGED
@@ -73,7 +73,22 @@ program.command('init')
73
73
  const srcAgent = path.join(TEMPLATE_DIR, '.agent');
74
74
  if (!fs.existsSync(TARGET_AGENT_DIR)) {
75
75
  copyRecursiveSync(srcAgent, TARGET_AGENT_DIR);
76
+ // Ghi lại version vào .agent/.version
77
+ fs.writeFileSync(path.join(TARGET_AGENT_DIR, '.version'), pkg.version);
76
78
  console.log('\x1b[32m✅ Đã cài ráp thành công thư mục .agent vào Project!\x1b[0m');
79
+
80
+ // Khởi tạo .env nếu chưa có
81
+ const envPath = path.join(process.cwd(), '.env');
82
+ if (!fs.existsSync(envPath)) {
83
+ fs.writeFileSync(envPath, 'CDP_PORT=9555\n');
84
+ console.log('\x1b[34mℹ️ Đã tạo file .env mẫu với CDP_PORT=9555\x1b[0m');
85
+ } else {
86
+ const envContent = fs.readFileSync(envPath, 'utf-8');
87
+ if (!envContent.includes('CDP_PORT=')) {
88
+ fs.appendFileSync(envPath, '\nCDP_PORT=9555\n');
89
+ console.log('\x1b[34mℹ️ Đã thêm cấu hình CDP_PORT=9555 vào file .env hiện tại\x1b[0m');
90
+ }
91
+ }
77
92
  } else {
78
93
  console.log('\x1b[33m⚠️ Thư mục .agent đã tồn tại. Hãy dùng lệnh "update" để cập nhật.\x1b[0m');
79
94
  }
@@ -102,6 +117,8 @@ program.command('update')
102
117
  });
103
118
 
104
119
  migrateLegacyMemories();
120
+ // Cập nhật version vào .agent/.version
121
+ fs.writeFileSync(path.join(TARGET_AGENT_DIR, '.version'), pkg.version);
105
122
  console.log('\x1b[32m✅ Cập nhật thành công 100% Cấu trúc kỹ năng siêu cấp!\x1b[0m');
106
123
  });
107
124
 
@@ -182,15 +199,22 @@ program.command('status')
182
199
  .action(() => {
183
200
  console.log('\x1b[36m📊 Trạng thái AG-Kit trong dự án hiện tại:\x1b[0m');
184
201
  if (fs.existsSync(TARGET_AGENT_DIR)) {
185
- console.log('\x1b[32m✅ Trạng thái: Đã Cài Đặt (Active)\x1b[0m');
186
- console.log(`📁 Đường dẫn : ${TARGET_AGENT_DIR}`);
202
+ console.log('\x1b[32m✅ Trạng thái : Đã Cài Đặt (Active)\x1b[0m');
203
+ console.log(`📁 Đường dẫn : ${TARGET_AGENT_DIR}`);
204
+
205
+ const vPath = path.join(TARGET_AGENT_DIR, '.version');
206
+ if (fs.existsSync(vPath)) {
207
+ const installedVersion = fs.readFileSync(vPath, 'utf-8').trim();
208
+ console.log(`🧠 Bản cài đặt : v${installedVersion}`);
209
+ } else {
210
+ console.log(`🧠 Bản cài đặt : Không rõ (Legacy)`);
211
+ }
212
+
213
+ console.log(`🏷 Bản Tool : v${pkg.version}`);
187
214
 
188
- try {
189
- const pJson = require('../package.json');
190
- console.log(`🏷 Phiên bản : v${pJson.version}`);
191
- } catch (e) {}
192
215
  } else {
193
- console.log('\x1b[31m❌ Trạng thái: Chưa có gì. Gõ "ag-kit init" để Setup.\x1b[0m');
216
+ console.log('\x1b[31m❌ Trạng thái : Chưa có gì. Gõ "ag-kit init" để Setup.\x1b[0m');
217
+ console.log(`🏷 Bản Tool : v${pkg.version}`);
194
218
  }
195
219
  });
196
220
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrtrinhvn/ag-kit",
3
- "version": "1.1.1",
3
+ "version": "1.1.4",
4
4
  "description": "Antigravity Kit Base Framework - Generic Agentic AI Programming Core",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -0,0 +1,22 @@
1
+ # Tiết Kiệm Token & Quản Lý Mô Hình (Model & VFS Knowledge)
2
+
3
+ ## 1. Cơ Chế Tiết Kiệm Token
4
+ Trong môi trường điều khiển từ xa (Telegram), việc tối ưu hóa token là cực kỳ quan trọng để duy trì hiệu suất và chi phí.
5
+
6
+ ### VFS (Virtual File System)
7
+ - **Tác dụng**: Giảm 98% lượng token khi khám phá mã nguồn.
8
+ - **Cách hoạt động**: Thay vì đọc toàn bộ file, AI sử dụng công cụ `vfs` để chỉ lấy chữ ký (signatures) của hàm và lớp.
9
+ - **Quy tắc**: Phải luôn sử dụng `vfs` trước khi dùng `grep` hoặc đọc file đầy đủ. (Xem `GEMINI.md`).
10
+
11
+ ## 2. Chiến Lược Lựa Chọn Mô Hình (Model Strategy)
12
+ Hệ thống sử dụng cơ chế "Phân tầng độ khó" để chọn model:
13
+
14
+ | Độ khó | Tác vụ | Mô hình khuyến nghị | Lý do |
15
+ | :--- | :--- | :--- | :--- |
16
+ | **Thấp** | Giải thích code, Refactor nhỏ, Chat thông thường | **Ollama (Local)** | Không tốn quota, phản hồi nhanh cho tác vụ đơn giản. |
17
+ | **Trung bình** | Fix lỗi, Thêm tính năng mới | **Gemini 3 Flash** | Cân bằng giữa chi phí và độ thông minh. |
18
+ | **Cao** | Thiết kế kiến trúc, Debug lỗi phức tạp | **Claude 3.5 Sonnet / Gemini 1.5 Pro** | Độ chính xác cao nhất cho các vấn đề hóc búa. |
19
+
20
+ ## 3. Tích Hợp Local Model (Ollama)
21
+ - Bot kết nối trực tiếp với Ollama API tại `http://localhost:11434`.
22
+ - Người dùng có thể chọn dùng model local qua lệnh `/model` để "đóng băng" quota Google khi không cần thiết.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: lazy-gravity
3
+ description: Cross-platform remote operation patterns for Antigravity, based on the LazyGravity project.
4
+ ---
5
+
6
+ # Vận Hành Đa Nền Tảng (LazyGravity Patterns)
7
+
8
+ LazyGravity tập trung vào việc quản lý nhiều dự án và phiên làm việc từ xa một cách an toàn và linh hoạt.
9
+
10
+ ## Các Đặc Điểm Chính
11
+
12
+ 1. **Project Discovery**: Tự động quét các thư mục trong Workspace để cho phép người dùng chuyển đổi dự án từ xa qua lệnh `/project`.
13
+ 2. **Session Management**: Quản lý lịch sử hội thoại (Past Conversations), cho phép chọn lại phiên cũ để tiếp tục làm việc.
14
+ 3. **Auto-Accept Flow**: Tích hợp cơ chế tự động nhấn "Accept" cho các file edit nếu người dùng bật chế độ `/autoaccept`.
15
+
16
+ ## Quản Lý Dự Án (Remote Switching)
17
+
18
+ - Sử dụng `WorkspaceService` để liệt kê các thư mục con.
19
+ - Khi người dùng chọn dự án, bot sẽ cung cấp thông tin hoặc tự động restart target sang dự án mới (nếu được cấp quyền).
20
+
21
+ ## Phân Loại Mô Hình (Model Categorization)
22
+ - Phân tách rõ ràng giữa **Cloud Models** (Google Gemini, Claude) và **Local Models** (Ollama).
23
+ - Ưu tiên Local Models cho các yêu cầu giải thích hoặc refactor nhỏ để tiết kiệm quota Cloud.
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: remoat-integration
3
+ description: Patterns for controlling AI code editors from Telegram, based on the Remoat project.
4
+ ---
5
+
6
+ # Kỹ Thuật Điều Khiển Editor Từ Xa (Remoat Integration)
7
+
8
+ Kỹ thuật này cho phép điều khiển Antigravity hoặc bất kỳ Editor nào hỗ trợ CDP (Chrome DevTools Protocol) thông qua Telegram.
9
+
10
+ ## Nguyên Tắc Cốt Lõi (Remoat Strategy)
11
+
12
+ 1. **Bridge qua CDP**: Không can thiệp vào mã nguồn của Editor. Sử dụng CDP để Inject Prompt và Monitor Response.
13
+ 2. **Single Brain Architecture**: Bot Telegram chỉ đóng vai trò "lễ tân", nhận lệnh và chuyển tiếp cho Editor. Editor là "bộ não" thực hiện công việc.
14
+ 3. **Wait for Generate**: Sử dụng DOM Observation để biết khi nào AI trong Editor đang suy nghĩ hoặc đã hoàn thành.
15
+
16
+ ## Các Tập Lệnh Đặc Trưng
17
+
18
+ - `/screenshot`: Chụp ảnh màn hình Editor để kiểm tra kết quả trực quan.
19
+ - `/stop`: Dừng khẩn cấp quá trình sinh code của AI.
20
+ - `/mode`: Chuyển đổi giữa chế độ `fast` (flash models) và `plan` (pro models).
21
+
22
+ ## Cấu Hình Hạ Tầng
23
+ - Yêu cầu Editor mở cổng debug: `--remote-debugging-port=9555`.
24
+ - Sử dụng `.env` để quản lý `IDE_PORT` đồng nhất với script khởi động.
@@ -61,20 +61,27 @@ Mỗi Topic/Chat trên Telegram sẽ sinh ra 1 File Ký ức lưu Context. Bắt
61
61
 
62
62
  ---
63
63
 
64
- ## PHẦN E: KIẾN TẠO HẠ TẦNG & HƯỚNG DẪN ÔNG CHỦ (User Setup Instructions)
65
- Khi bạn (AI) code xong cái `TelegramGateway` cho dự án, nghĩa vụ của bạn CƯƠNG QUYẾT phải xuất ra một bảng hướng dẫn `Markdown` dặn dò Ông Chủ (User) cách thiết lập Telegram để chọn 1 trong 2 chế độ chơi:
64
+ ## PHẦN E: GIAO DIỆN PREMIUM (awesome-grammY Aesthetics)
65
+ Một Gateway chuyên nghiệp phải UI/UX tinh tế:
66
+ 1. **Header & Divider**: Sử dụng các thẻ `<b>` và ký tự ngăn cách (e.g. `━━━━━`) để tạo khối thông tin rõ ràng.
67
+ 2. **Status Mapping**: Sử dụng emoji trực quan cho trạng thái (✅ Online, 🚨 Offline, 🛡️ Protected).
68
+ 3. **Categorized Menus**: Nhóm các nút bấm theo chức năng (Hệ thống, AI, Dự án).
69
+ 4. **Short Callback Data**: Vì Telegram giới hạn callback data là 64 bytes, hãy sử dụng `shortIdMap` để lưu trữ Title dài và map chúng với một mã ngắn (e.g. `sess_a1b2`).
66
70
 
67
- 1. **Chế Độ Bệnh Viện Đa Khoa (Group Multi-Topics - Khuyên dùng):**
68
- - Hướng dẫn User tạo 1 Group Telegram mới.
69
- - Thêm con Bot vào Group và cấp quyền Admin.
70
- - **ĐẶC BIỆT QUAN TRỌNG:** Nhắc User phải vào Cài đặt Group (Group Settings) -> Bật tính năng **"Topics"** (Diễn đàn).
71
- - Giải thích cho User: Mỗi khi có 1 "Bệnh nhân" (Lỗi/Tính năng mới), User tạo một cái Topic mới trong Group đó. Bot sẽ phân luồng Ký ức cực mượt theo từng Topic.
71
+ ---
72
72
 
73
- 2. **Chế Độ Phòng Khám (Private Single Chat):**
74
- - Hướng dẫn User chỉ cần nhấp vào Bot và nhắn tin trực tiếp (DM).
75
- - Nhắc User dùng lệnh `/forget` nếu muốn đổi chủ đề để tránh Bot bị chập Ký ức.
73
+ ## PHẦN F: KIẾN TẠO HẠ TẦNG & HƯỚNG DẪN (User Setup)
74
+ Khi triển khai, hãy hướng dẫn User:
75
+ 1. **Tạo Nhóm (Group with Topics)**:
76
+ - Tạo Group Telegram. Thêm Bot làm Admin.
77
+ - Bật **"Topics"** trong cài đặt nhóm.
78
+ - Mỗi dự án hoặc tính năng lớn nên là 1 Topic riêng để cô lập ký ức.
79
+ 2. **Cấu Hình .env**: Giải thích rõ các token:
80
+ - `TELEGRAM_BOT_TOKEN`: Lấy từ @BotFather.
81
+ - `ALLOWED_USER_IDS`: Bảo mật, chỉ cho phép chủ nhân điều khiển.
82
+ - `IDE_PORT`: Cổng CDP của Antigravity (thường là 9555).
76
83
 
77
84
  ---
78
85
 
79
86
  ## TỔNG KẾT TRIỂN KHAI
80
- *(Ghi chú cho AI)*: Khi code Node.js/Python cho bot, bạn TỰ ĐỘNG đăng ký toàn bộ 7 lệnh này vào Bot Menu (`bot.setMyCommands(...)` trong Telegram API) để User chỉ việc dấu `/` Menu gợi ý hiện ra đầy đủ và chuyên nghiệp!
87
+ *(Ghi chú cho AI)*: Luôn tích hợp VFS (`GEMINI.md`) để tiết kiệm token khi thực hiện code discovery từ xa thông qua Bot.
@@ -0,0 +1,35 @@
1
+ # 🚀 Antigravity Core Rules
2
+
3
+ > This file defines the core operational rules for the AI Agent in this workspace.
4
+
5
+ ---
6
+
7
+ ## 🛠️ TOKEN SAVING: VFS PROTOCOL (MANDATORY)
8
+
9
+ **You MUST use `vfs` for code discovery before using `grep` or reading entire files.**
10
+
11
+ ### Why use VFS?
12
+ `vfs` extracts logical signatures (functions, classes, types) without reading the bodies. This saves up to 98% of tokens compared to raw file reads.
13
+
14
+ ### Usage Protocol
15
+ 1. **Locate**: Use `vfs search` or `vfs <path>` to find the logical structure.
16
+ 2. **Review**: Analyze the signatures returned by `vfs`.
17
+ 3. **Read**: Only read the specific line ranges identified via `vfs`.
18
+
19
+ ### Commands
20
+ - **CLI**: `vfs . -f <function_name>`
21
+ - **MCP**: Use the `vfs` MCP tool if available.
22
+
23
+ ---
24
+
25
+ ## 🤖 MODEL SELECTION
26
+
27
+ - **Simple Tasks**: Prefer local Ollama models (e.g., `nemotron`, `llama3`) to save cloud budget.
28
+ - **Complex Tasks**: Use high-tier models (e.g., `Claude 3.5 Sonnet`, `Gemini 1.5 Pro`).
29
+
30
+ ---
31
+
32
+ ## 🧹 CLEAN CODE
33
+ - Write self-documenting code.
34
+ - Avoid over-engineering.
35
+ - Follow the patterns defined in `.agent/skills/clean-code`.