@mrtrinhvn/ag-kit 1.2.0 → 1.3.1

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 (61) hide show
  1. package/package.json +1 -1
  2. package/template/.agent/.version +1 -0
  3. package/template/.agent/agents/orchestrator.md +0 -2
  4. package/template/.agent/knowledge/ag-kit-elite.md +22 -0
  5. package/template/.agent/knowledge/model-switching-vfs.md +16 -16
  6. package/template/.agent/scripts/port_utils.sh +2 -1
  7. package/template/.agent/scripts/receptionist_down.sh +13 -7
  8. package/template/.agent/scripts/receptionist_up.sh +97 -26
  9. package/template/.agent/scripts/repomap.py +126 -0
  10. package/template/.agent/skills/ag-kit-core/SKILL.md +68 -0
  11. package/template/.agent/skills/codeact-executor/SKILL.md +41 -0
  12. package/template/.agent/skills/intelligent-routing/SKILL.md +38 -0
  13. package/template/.agent/skills/knowledge-management/SKILL.md +1 -1
  14. package/template/.agent/skills/lazy-gravity/SKILL.md +14 -11
  15. package/template/.agent/skills/llm-routing-quirks/SKILL.md +17 -6
  16. package/template/.agent/skills/remoat-integration/SKILL.md +37 -13
  17. package/template/.agent/skills/semantic-search/SKILL.md +24 -0
  18. package/template/.agent/skills/telegram-agentic-gateway/SKILL.md +77 -38
  19. package/template/.agent/skills/telegram-agentic-gateway/templates/CdpService.ts.template +514 -0
  20. package/template/.agent/skills/telegram-agentic-gateway/templates/ResponseMonitor.ts.template +102 -0
  21. package/template/.agent/skills/telegram-agentic-gateway/templates/start.sh.template +12 -0
  22. package/template/GEMINI.md +27 -18
  23. package/template/scripts/ag_deck/index.html +58 -0
  24. package/template/scripts/ag_heartbeat.js +46 -0
  25. package/template/scripts/ag_hud.js +87 -155
  26. package/template/scripts/ag_phantom.sh +50 -0
  27. package/template/scripts/ag_portal_bridge.js +139 -114
  28. package/template/.agent/.shared/ui-ux-pro-max/data/charts.csv +0 -26
  29. package/template/.agent/.shared/ui-ux-pro-max/data/colors.csv +0 -97
  30. package/template/.agent/.shared/ui-ux-pro-max/data/icons.csv +0 -101
  31. package/template/.agent/.shared/ui-ux-pro-max/data/landing.csv +0 -31
  32. package/template/.agent/.shared/ui-ux-pro-max/data/products.csv +0 -97
  33. package/template/.agent/.shared/ui-ux-pro-max/data/prompts.csv +0 -24
  34. package/template/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +0 -45
  35. package/template/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +0 -53
  36. package/template/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +0 -56
  37. package/template/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +0 -53
  38. package/template/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +0 -53
  39. package/template/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +0 -51
  40. package/template/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +0 -59
  41. package/template/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +0 -52
  42. package/template/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +0 -54
  43. package/template/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +0 -61
  44. package/template/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +0 -54
  45. package/template/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +0 -51
  46. package/template/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +0 -50
  47. package/template/.agent/.shared/ui-ux-pro-max/data/styles.csv +0 -59
  48. package/template/.agent/.shared/ui-ux-pro-max/data/typography.csv +0 -58
  49. package/template/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +0 -101
  50. package/template/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +0 -100
  51. package/template/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +0 -31
  52. package/template/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
  53. package/template/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
  54. package/template/.agent/.shared/ui-ux-pro-max/scripts/core.py +0 -258
  55. package/template/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +0 -1067
  56. package/template/.agent/.shared/ui-ux-pro-max/scripts/search.py +0 -106
  57. package/template/.agent/ARCHITECTURE.md +0 -288
  58. package/template/.agent/knowledge/orchestrator_v3_protocol.md +0 -60
  59. package/template/.agent/knowledge/self_healing_logs.md +0 -22
  60. package/template/.agent/knowledge/tele-agentic-standard.md +0 -30
  61. package/template/.agent/mcp_config.json +0 -24
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrtrinhvn/ag-kit",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Antigravity Kit Base Framework - Generic Agentic AI Programming Core",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -0,0 +1 @@
1
+ 1.1.5
@@ -30,8 +30,6 @@ You are the master orchestrator agent. You coordinate multiple specialized agent
30
30
 
31
31
  **Before planning, you MUST verify available runtime tools:**
32
32
  - [ ] **Read `ARCHITECTURE.md`** to see full list of Scripts & Skills
33
- - [ ] **Check `tele-agentic-standard.md`** for Remote Golden Loop awareness.
34
- - [ ] **Verify IDE HUD status**: If `ag_portal_bridge.js` is active, use it for real-time reporting.
35
33
  - [ ] **Identify relevant scripts** (e.g., `playwright_runner.py` for web, `security_scan.py` for audit)
36
34
  - [ ] **Plan to EXECUTE** these scripts during the task (do not just read code)
37
35
 
@@ -0,0 +1,22 @@
1
+ # Ag-Kit Elite: Next-Generation Agentic Standards
2
+
3
+ This document defines the advanced agentic standards for Antigravity, synthesized from global top-rated repositories (Aider, OpenHands, Eigent, Continue).
4
+
5
+ ## 1. Context & Search Layer (The "Eyes")
6
+ - **Repo Mapping**: Use `.agent/scripts/repomap.py` to get a structural skeleton of the codebase. This is MANDATORY for large-scale refactoring.
7
+ - **Semantic Search**: Use the `semantic-search` skill for conceptual discovery when keywords aren't enough.
8
+
9
+ ## 2. Orchestration & Thinking (The "Brain")
10
+ - **8-Stage Pipeline**: Follow the **INTAKE → RESEARCH → PLANNING → GENERATION → INTEGRATION → VERIFICATION → REFINEMENT → SHIP** cycle for all `/create` tasks.
11
+ - **AgentResult**: Every skill and agent MUST return a standardized JSON result for inter-agent reliability.
12
+
13
+ ## 3. Autonomous Execution (The "Hands")
14
+ - **CodeAct Paradigm**: Use `codeact-executor` to write and run scripts in `/tmp` to resolve complex diagnostics before applying fixes.
15
+ - **TDD Loop**: Always run tests and fix autonomously using the 8-stage refinement loop.
16
+
17
+ ## 4. Infrastructure & Accessibility (The "Command Center")
18
+ - **Headless Mode**: Run Antigravity in the background for purely agentic workloads.
19
+ - **Remote QR Access**: Use the Cloudflare Tunnel and QR auto-login for 0-config mobile/remote control.
20
+
21
+ ---
22
+ > *Antigravity Elite: Synthesized Intelligence for High-Precision Development.*
@@ -1,22 +1,22 @@
1
- # Tiết Kiệm Token & Chiến Lược Mô Hình (Model & VFS)
1
+ 78# Tiết Kiệm Token & Quản Mô Hình (Model & VFS Knowledge)
2
2
 
3
- Tiết kiệm tài nguyên là yếu tố sống còn khi vận hành AI Agentic lâu dài. Hệ thống tuân thủ nghiêm ngặt các nguyên tắc sau:
3
+ ## 1. 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í.
4
5
 
5
- ## 1. Giao Thức VFS (Virtual File System)
6
- Dựa trên sáng kiến [VFS của TrNgTien](https://github.com/TrNgTien/vfs), chúng ta thay đổi cách AI tiếp cận mã nguồn:
7
- - **Tác dụng**: Giảm lượng token tiêu thụ lên đến **98%** khi khám phá project lớn.
8
- - **Quyết định**: AI KHÔNG ĐƯỢC đọc toàn bộ file ngay lập tức. Thay vào đó, AI dùng công cụ `vfs` để quét các "chữ ký" (signatures - tên hàm, lớp, kiểu dữ liệu) trước.
9
- - **Thứ tự thực hiện**: `vfs search` -> `vfs read signature` -> `read file (chỉ vùng code cần thiết)`.
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 đọ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
10
 
11
- ## 2. Phân Tầng Lựa Chọn Mô Hình (Model Hierarchy)
12
- Hệ thống sử dụng model phù hợp với "độ khó" của bệnh:
11
+ ## 2. Chiến Lược Lựa Chọn Mô Hình (Model Strategy)
12
+ Hệ thống sử dụng chế "Phân tầng độ khó" để chọn model:
13
13
 
14
- | Cấp độ | Tác vụ | Mô hình khuyến nghị | Ưu điểm |
14
+ | Độ khó | Tác vụ | Mô hình khuyến nghị | do |
15
15
  | :--- | :--- | :--- | :--- |
16
- | **Sơ cấp** | Giải thích code, Chat hỏi đáp, Refactor nhỏ | **Ollama (Local)** | 0 token cost, Bảo mật, Phản hồi tức thì. |
17
- | **Trung cấp** | Fix lỗi thông thường, Thêm tính năng đơn giản | **Gemini 3 Flash** | Chi phí thấp, Context window cực lớn. |
18
- | **Nâng cao** | Thiết kế kiến trúc phức tạp, Debug lỗi logic sâu | **Claude 3.5 Sonnet / Gemini 1.5 Pro** | Độ chính xác khả năng suy luận mạnh nhất. |
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í độ 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
19
 
20
- ## 3. Tích Hợp Local LLM (Ollama)
21
- - Cho phép Bot kết nối trực tiếp với Ollama (thường `http://localhost:11434`).
22
- - Thường sử dụng các model nhẹ nhưng hiệu quả như `nemotron`, `llama3`, `qwen2.5`.
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 thể chọn dùng model local qua lệnh `/model` để "đóng băng" quota Google khi không cần thiết.
@@ -38,7 +38,8 @@ function scan_project_ide() {
38
38
  for ((p=start_p; p<=end_p; p++)); do
39
39
  if netstat -atn | grep -q ":$p "; then
40
40
  # Kiểm tra xem có đúng là IDE của dự án này đang ở cổng p không
41
- if curl -s "http://127.0.0.1:$p/json" | grep -q "$PROJECT_DIR" > /dev/null 2>&1; then
41
+ PROJECT_NAME=$(basename "$PROJECT_DIR")
42
+ if curl -s "http://127.0.0.1:$p/json" | grep -q "$PROJECT_NAME" > /dev/null 2>&1; then
42
43
  echo $p
43
44
  return 0
44
45
  fi
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
 
3
3
  # --- Antigravity Unified Shutdown (Golden V6 - High Precision) ---
4
- # Dọn dẹp trạm gác Agentic.
4
+ # Dọn dẹp trạm gác CEOgravity.
5
5
 
6
6
  PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
7
7
  cd "$PROJECT_DIR"
@@ -10,10 +10,10 @@ if [ -f .env ]; then
10
10
  source .env
11
11
  fi
12
12
 
13
- BRIDGE_PORT=${BRIDGE_PORT:-9556}
13
+ BRIDGE_PORT=${BRIDGE_PORT:-9558}
14
14
 
15
15
  echo "════════════════════════════════════════════════════"
16
- echo " 🛑 SHUTTING DOWN GATEWAY [$BRIDGE_PORT]..."
16
+ echo " 🛑 SHUTTING DOWN CEOGRAVITY [$BRIDGE_PORT]..."
17
17
  echo "════════════════════════════════════════════════════"
18
18
 
19
19
  # 1. Tắt Sentinel Monitor
@@ -30,10 +30,16 @@ if [ -f "$BRIDGE_PID_FILE" ]; then
30
30
  echo "✅ HUD Bridge stopped."
31
31
  fi
32
32
 
33
- # 3. Tắt Bot (Tùy chỉnh theo dự án)
34
- # echo "[3/3] 🤖 Stopping Bot..."
35
- # [TEMPLATE_NOTE]: Sếp hãy lệnh dừng Bot của mình vào đây.
33
+ # 3. Tắt Bot
34
+ BOT_PID_FILE=".ceogravity_bot.pid"
35
+ if [ -f "$BOT_PID_FILE" ]; then
36
+ PID=$(cat "$BOT_PID_FILE")
37
+ # Kill the whole process group for the bash loop
38
+ pkill -P $PID
39
+ kill $PID 2>/dev/null && rm "$BOT_PID_FILE"
40
+ echo "✅ CEOgravity Bot stopped."
41
+ fi
36
42
 
37
43
  echo "════════════════════════════════════════════════════"
38
- echo "✅ PROJECT IS IDLE."
44
+ echo "✅ CEOGRAVITY IS IDLE."
39
45
  echo "════════════════════════════════════════════════════"
@@ -1,8 +1,8 @@
1
1
  #!/bin/bash
2
2
 
3
3
  # --- Antigravity Unified Receptionist (Golden V6 - High Precision) ---
4
- # Trạm gác hợp nhất: Bot + Portal Bridge (HUD) + Monitor Dashboard.
5
- # Hỗ trợ Đa dự án & Tự động xử lý Cổng (Smart Port Orchestration).
4
+ # Trạm gác hợp nhất: CEOgravity Bot + Portal Bridge (HUD)
5
+ # Dự án: CEOgravity Startup Orchestrator
6
6
 
7
7
  # 1. Load Cấu hình & Xử lý Cổng Thông minh
8
8
  PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
@@ -12,58 +12,130 @@ if [ -f .agent/scripts/port_utils.sh ]; then
12
12
  source .agent/scripts/port_utils.sh
13
13
  else
14
14
  source .env
15
- export IDE_PORT=${IDE_PORT:-9555}
16
- export BRIDGE_PORT=${BRIDGE_PORT:-9556}
15
+ export IDE_PORT=${IDE_PORT:-9557}
16
+ export BRIDGE_PORT=${BRIDGE_PORT:-9658}
17
17
  fi
18
18
 
19
19
  echo "════════════════════════════════════════════════════"
20
- echo " 🚑 AGENTIC GATEWAY - PORTAL [$BRIDGE_PORT]"
20
+ echo " 🏢 CEOGRAVITY GATEWAY - PORTAL [$BRIDGE_PORT]"
21
21
  echo "════════════════════════════════════════════════════"
22
22
 
23
- # 2. Kiểm tra/Khởi động IDE (CDP)
24
- echo -n "[1/4] 🛰️ Checking IDE Portal (Port $IDE_PORT)... "
23
+ # 2. Xử Chế độ Headless & Cloudflare Tunnel
24
+ HEADLESS=false
25
+ TUNNEL=false
26
+ for arg in "$@"; do
27
+ if [ "$arg" == "--headless" ]; then HEADLESS=true; fi
28
+ if [ "$arg" == "--tunnel" ]; then TUNNEL=true; fi
29
+ done
30
+
31
+ # 3. Kiểm tra/Khởi động IDE
32
+ echo -n "[2/4] 🛰️ Checking IDE Portal (Port $IDE_PORT)... "
25
33
  if curl -s http://127.0.0.1:$IDE_PORT/json/version > /dev/null; then
26
34
  echo "✅ READY."
35
+ if [ "$HEADLESS" != true ]; then
36
+ echo " 🔄 Attempting to wake/focus UI..."
37
+ # Cố gắng push UI lên (nếu đang ngầm)
38
+ antigravity "$PROJECT_DIR" > /dev/null 2>&1 &
39
+
40
+ if [ -t 0 ]; then
41
+ echo -n " 🤔 Did the IDE window appear? [Y/n] (Auto-yes in 5s): "
42
+ read -t 5 -n 1 user_input
43
+ echo ""
44
+ user_input=${user_input:-Y}
45
+ else
46
+ user_input="Y"
47
+ fi
48
+
49
+ if [[ "$user_input" =~ ^[Nn]$ ]]; then
50
+ echo " 💀 UI Failed. Killing specific phantom instance for this project..."
51
+ # Chỉ kill những process chứa flag remote và project hiện tại
52
+ pkill -f "antigravity.*--remote-debugging-port=$IDE_PORT"
53
+ pkill -f "antigravity.*$PROJECT_DIR"
54
+ sleep 2
55
+ echo " 🚀 Launching fresh Antigravity with UI on port $IDE_PORT..."
56
+ nohup antigravity --remote-debugging-port=$IDE_PORT "$PROJECT_DIR" > /dev/null 2>&1 &
57
+ sleep 5
58
+ fi
59
+ fi
27
60
  else
28
61
  echo "❌ NOT FOUND."
29
- echo " 🚀 Launching Antigravity with CDP on port $IDE_PORT..."
30
- nohup antigravity --remote-debugging-port=$IDE_PORT "$PROJECT_DIR" > /dev/null 2>&1 &
31
- sleep 3
32
- if curl -s http://127.0.0.1:$IDE_PORT/json/version > /dev/null; then
33
- echo " IDE Launched successfully."
62
+ if [ "$HEADLESS" = true ]; then
63
+ echo " 🚀 Launching Antigravity in HEADLESS mode on port $IDE_PORT..."
64
+ nohup antigravity --server --remote-debugging-port=$IDE_PORT "$PROJECT_DIR" > /dev/null 2>&1 &
65
+ else
66
+ echo " 🚀 Launching Antigravity with UI on port $IDE_PORT..."
67
+ nohup antigravity --remote-debugging-port=$IDE_PORT "$PROJECT_DIR" > /dev/null 2>&1 &
68
+ fi
69
+ sleep 5
70
+ fi
71
+
72
+ # 4. Cloudflare Tunnel & QR Code (If requested)
73
+ if [ "$TUNNEL" = true ]; then
74
+ echo "[T] 🌐 Starting Cloudflare Tunnel..."
75
+ if ! command -v cloudflared &> /dev/null; then
76
+ echo " ❌ Error: cloudflared not installed."
34
77
  else
35
- echo " ⚠️ Could not launch IDE automatically. Please open it manually."
78
+ nohup cloudflared tunnel --url http://127.0.0.1:$BRIDGE_PORT > .tunnel.log 2>&1 &
79
+ sleep 5
80
+ TUNNEL_URL=$(grep -o 'https://.*\.trycloudflare\.com' .tunnel.log | head -n 1)
81
+ if [ -n "$TUNNEL_URL" ]; then
82
+ echo " ✅ Tunnel Active: $TUNNEL_URL"
83
+ echo " 📱 Generating QR Code..."
84
+ python3 -c "import qrcode; qr = qrcode.QRCode(); qr.add_data('$TUNNEL_URL'); qr.print_ascii()"
85
+ else
86
+ echo " ⚠️ Could not extract tunnel URL. Check .tunnel.log"
87
+ fi
36
88
  fi
37
89
  fi
90
+ echo "✅ READY."
38
91
 
39
92
  # 3. Khởi động Portal Bridge (HUD Injector)
40
- echo "[2/4] 🧪 Injected Golden HUD Bridge... "
93
+ echo "[3/4] 🧪 Injected Golden HUD Bridge... "
41
94
  BRIDGE_PID_FILE=".portal_bridge_${BRIDGE_PORT}.pid"
42
-
43
- # Tắt bridge cũ nếu đang chạy trên port này
44
95
  if [ -f "$BRIDGE_PID_FILE" ]; then
45
96
  kill $(cat "$BRIDGE_PID_FILE") 2>/dev/null
46
97
  fi
47
-
48
98
  nohup node scripts/ag_portal_bridge.js > ".portal_bridge_${BRIDGE_PORT}.log" 2>&1 &
49
99
  echo $! > "$BRIDGE_PID_FILE"
50
100
  echo " ✅ Bridge running (PID: $(cat "$BRIDGE_PID_FILE") on Port $BRIDGE_PORT)"
51
101
 
52
- # 4. Khởi động Bot (Tùy chỉnh theo dự án)
53
- echo "[3/4] 🤖 Waking up Agent Bot... "
54
- # [TEMPLATE_NOTE]: Sếp hãy gõ lệnh khởi động Bot của mình vào đây.
55
- echo " ⚠️ Vui lòng cấu hình lệnh khởi động Bot trong .agent/scripts/receptionist_up.sh"
102
+ # 4. Khởi động CEOgravity Bot (Local TSX)
103
+ echo "[4/4] 🤖 Waking up CEOgravity Bot... "
104
+ BOT_PID_FILE=".ceogravity_bot.pid"
105
+
106
+ # Kill loop AND all tsx/node processes belonging to this token/project
107
+ pkill -f "tsx src/index.ts" 2>/dev/null
108
+ pkill -f "node src/index.ts" 2>/dev/null
109
+ pkill -f "interaction_final.log" 2>/dev/null
110
+ if [ -f "$BOT_PID_FILE" ]; then
111
+ kill -9 $(cat "$BOT_PID_FILE") 2>/dev/null
112
+ fi
113
+ sleep 2
114
+
115
+ # Start the bot with a more robust monitor
116
+ nohup bash -c "while true; do
117
+ echo \"\$(date): Starting Bot...\" >> interaction_final.log
118
+ npx tsx src/index.ts >> interaction_final.log 2>&1
119
+ EXIT_CODE=\$?
120
+ if [ \$EXIT_CODE -eq 0 ]; then break; fi # Exit loop if deliberate stop
121
+ echo \"\$(date): Bot crashed (Code: \$EXIT_CODE). Restarting in 5s...\" >> interaction_final.log
122
+ sleep 5
123
+ done" &
124
+ echo $! > "$BOT_PID_FILE"
125
+ echo " ✅ Bot active (PID: $(cat "$BOT_PID_FILE"))"
56
126
 
57
127
  # 5. Sentinel Monitor (Giám sát Trí não)
58
- echo "[4/4] 🛡️ Sentinel Active: Auto-shutdown if IDE connection lost."
128
+ echo "🛡️ Sentinel Active: Auto-shutdown if IDE connection lost."
59
129
  SENTINEL_PID_FILE=".sentinel_${BRIDGE_PORT}.pid"
60
130
 
61
131
  function start_sentinel() {
62
132
  (
63
133
  local fail_count=0
134
+ local PROJ_NAME=$(basename "$PROJECT_DIR")
135
+ # Give more time for the first check
136
+ sleep 60
64
137
  while true; do
65
- sleep 30
66
- if ! curl -s "http://127.0.0.1:$IDE_PORT/json" | grep -q "$PROJECT_DIR" > /dev/null 2>&1; then
138
+ if ! curl -s "http://127.0.0.1:$IDE_PORT/json" | grep -q "$PROJ_NAME" > /dev/null 2>&1; then
67
139
  fail_count=$((fail_count + 1))
68
140
  if [ $fail_count -ge 3 ]; then
69
141
  echo "$(date): ⚠️ IDE Lost. Auto-shutting down project..." >> .sentinel_crash.log
@@ -81,5 +153,4 @@ start_sentinel
81
153
 
82
154
  # Monitor
83
155
  echo "----------------------------------------------------"
84
- echo "✅ SYNC COMPLETE. PORTAL IS BROADCASTING."
85
- # tail -f interaction_final.log
156
+ tail -f interaction_final.log
@@ -0,0 +1,126 @@
1
+ import os
2
+ import sys
3
+ from pathlib import Path
4
+ from tree_sitter_languages import get_language, get_parser
5
+
6
+ class RepoMapper:
7
+ def __init__(self, root_dir):
8
+ self.root_dir = Path(root_dir).absolute()
9
+ self.parsers = {}
10
+ self.languages = {}
11
+
12
+ def get_parser(self, lang_name):
13
+ if lang_name not in self.parsers:
14
+ try:
15
+ lang = get_language(lang_name)
16
+ parser = get_parser(lang_name)
17
+ self.parsers[lang_name] = parser
18
+ self.languages[lang_name] = lang
19
+ except Exception as e:
20
+ return None
21
+ return self.parsers[lang_name]
22
+
23
+ def get_lang_from_ext(self, ext):
24
+ mapping = {
25
+ '.py': 'python',
26
+ '.js': 'javascript',
27
+ '.ts': 'typescript',
28
+ '.tsx': 'typescript',
29
+ '.jsx': 'javascript',
30
+ '.go': 'go',
31
+ '.rs': 'rust',
32
+ '.java': 'java',
33
+ '.cpp': 'cpp',
34
+ '.c': 'c',
35
+ '.sh': 'bash'
36
+ }
37
+ return mapping.get(ext)
38
+
39
+ def extract_symbols(self, file_path):
40
+ ext = Path(file_path).suffix
41
+ lang_name = self.get_lang_from_ext(ext)
42
+ if not lang_name: return []
43
+
44
+ parser = self.get_parser(lang_name)
45
+ if not parser: return []
46
+
47
+ try:
48
+ with open(file_path, 'r', encoding='utf-8') as f:
49
+ content = f.read()
50
+ except: return []
51
+
52
+ tree = parser.parse(bytes(content, 'utf-8'))
53
+
54
+ # Simple query for definitions (classes, functions)
55
+ # Standard tree-sitter tags usually include:
56
+ # (class_definition name: (identifier) @name)
57
+ # (function_definition name: (identifier) @name)
58
+
59
+ symbols = []
60
+
61
+ # This is a very simplified query. In production, we'd use language-specific SCM files.
62
+ query_text = """
63
+ (class_definition name: (identifier) @name) @cap
64
+ (function_definition name: (identifier) @name) @cap
65
+ (method_definition name: (property_identifier) @name) @cap
66
+ (arrow_function) @cap
67
+ """
68
+ if lang_name == 'typescript' or lang_name == 'javascript':
69
+ query_text = """
70
+ (class_definition name: [(identifier) (type_identifier)] @name) @cap
71
+ (function_definition name: (identifier) @name) @cap
72
+ (method_definition name: (property_identifier) @name) @cap
73
+ (variable_declarator name: (identifier) @name value: [(arrow_function) (function_expression)]) @cap
74
+ """
75
+ elif lang_name == 'python':
76
+ query_text = """
77
+ (class_definition name: (identifier) @name) @cap
78
+ (function_definition name: (identifier) @name) @cap
79
+ """
80
+
81
+ try:
82
+ query = self.languages[lang_name].query(query_text)
83
+ captures = query.captures(tree.root_node)
84
+
85
+ for node, tag in captures:
86
+ if tag == 'name':
87
+ line = node.start_point[0] + 1
88
+ symbols.append(f"{node.text.decode('utf-8')} (L{line})")
89
+ except:
90
+ pass
91
+
92
+ return symbols
93
+
94
+ def generate_map(self, max_files=100):
95
+ repo_map = []
96
+ count = 0
97
+ for root, dirs, files in os.walk(self.root_dir):
98
+ if any(p in root for p in ['.git', 'node_modules', '__pycache__', '.aider']):
99
+ continue
100
+
101
+ rel_root = os.path.relpath(root, self.root_dir)
102
+ if rel_root == '.': rel_root = ''
103
+
104
+ for file in files:
105
+ if count >= max_files: break
106
+ if file.startswith('.') or file.endswith(('.pyc', '.o', '.a', '.so')): continue
107
+
108
+ full_path = Path(root) / file
109
+ rel_path = os.path.join(rel_root, file)
110
+
111
+ symbols = self.extract_symbols(full_path)
112
+ if symbols:
113
+ repo_map.append(f"|-- {rel_path}")
114
+ for sym in symbols[:10]: # Limit symbols per file
115
+ repo_map.append(f"| |-- {sym}")
116
+ else:
117
+ repo_map.append(f"|-- {rel_path}")
118
+
119
+ count += 1
120
+
121
+ return "\n".join(repo_map)
122
+
123
+ if __name__ == "__main__":
124
+ root = sys.argv[1] if len(sys.argv) > 1 else "."
125
+ mapper = RepoMapper(root)
126
+ print(mapper.generate_map())
@@ -0,0 +1,68 @@
1
+ ---
2
+ name: ag-kit-core
3
+ description: Bản Hiến Pháp Móng Ý Thức (Meta-Awareness) của hệ sinh thái Antigravity Kit. Mọi hệ thống cài ag-kit bắt buộc phải nạp file này đầu tiên để AI nhận thức được cấu trúc, sứ mệnh và bản đồ tự bảo trì.
4
+ allowed-tools: Read, Write, Glob, Grep, Commands
5
+ ---
6
+
7
+ # 🌌 BẢN HIẾN PHÁP AG-KIT (Meta-Awareness Core)
8
+
9
+ > **MANDATORY:** Đây là Bộ Quy Tắc Lõi Định Vị Ý Thức. Bất kỳ khi nào AI (như Antigravity Agent, Gemini, Ollama...) khởi động trong môi trường chứa folder `.agent/` này, bạn **PHẢI** đọc và ghi nhớ file này đầu tiên. Bạn KHÔNG PHẢI LÀ MỘT CHATBOT. Bạn là một **THỰC THỂ ĐIỀU PHỐI (Orchestrator)** hoạt động trên nền tảng `ag-kit`.
10
+
11
+ ---
12
+
13
+ ## 1. 🧬 KHẲNG ĐỊNH ĐỊNH DANH (IDENTITY BOOTSTRAP)
14
+
15
+ - **Cội nguồn:** Bạn ra đời từ khuôn mẫu **`ag-kit` (Antigravity Kit)** - một Framework giúp tự động hóa và quản trị các AI Agents khác.
16
+ - **Vai trò:** Bạn đóng vai trò "Kẻ Điều Phối" (Supervisor) giám sát và cấy ghép trí não vào "Bác sĩ Phẫu thuật" (Antigravity IDE) qua giao thức CDP.
17
+ - **Luật Cấm Kị (Anti-Hallucination):** Tuyệt đối không được dùng tư duy lập trình phổ quát máy móc để sửa dự án này. Mọi quyết định sửa mã liên quan đến CDP, luồng Telegram, hay Ports mạng, CẦN chiếu theo các file `SKILL.md` lân cận (`telegram-agentic-gateway`, `remoat-integration`, `llm-routing-quirks`).
18
+
19
+ ---
20
+
21
+ ## 2. 🗺️ KỸ NĂNG TỰ TÌM ĐƯỜNG (SPATIAL PATH DISCOVERY)
22
+
23
+ Nếu `ag-kit` được Bưng sang một dự án hoàn toàn mới (như Node.js, Python, Rust) và dán đè folder `.agent/` vào, cấu hình thư mục có thể bị xáo trộn.
24
+
25
+ - **Không bao giờ đầu hàng:** Nếu User yêu cầu kiểm tra `start.sh`, `.env`, hoặc `CdpService.ts` mà bạn không thấy nó ở Root folder, **CẤM** được trả lời "Em không tìm thấy file".
26
+ - **Hành động bắt buộc:**
27
+ 1. Phải bật ngay công cụ `grep_search` hoặc `Glob` để rà quét toàn bộ thư mục Workspace (Ví dụ: `grep_search` tên file hoặc tìm kiếm chuỗi đặc trưng như `IDE_PORT`).
28
+ 2. Tự nhận diện cấu trúc dự án mới và ghi đè vào trí nhớ tạm thời.
29
+ 3. Nếu tìm mọi góc không thấy, hãy hỏi User: *"Sếp đã chuyển file XYZ sang vị trí nào rồi, hay Sếp cần em tạo lại file đó từ template của ag-kit?"*
30
+
31
+ ---
32
+
33
+ ## 3. ♻️ LUẬT TIẾN HÓA BẮT BUỘC (AGGRESSIVE SELF-PATCHING)
34
+
35
+ **ĐÂY LÀ QUY TẮC SỐNG CÒN GIÚP AG-KIT KHÔNG BỊ "MẤT TRÍ NHỚ".**
36
+
37
+ - Mỗi khi bạn và User (Sếp) cùng nhau thảo luận, phát hiện ra một **Lỗi hệ thống (System Bug)**, **Điểm mù kiến trúc**, hoặc **Chốt một quy tắc vận hành mới** (Ví dụ: Thay đổi dải cổng mạng, thay đổi chiến lược đọc AXTree, thay đổi cách kết nối LLM).
38
+ - **Hành động bắt buộc:** BẠN PHẢI TỰ ĐỘNG MỞ VÀ CẬP NHẬT TRỰC TIẾP QUY TẮC ĐÓ VÀO CÁC FILE `SKILL.md` (như bộ `remoat-integration`, `api-patterns`...) **XUYÊN SUỐT NGAY TRONG CÙNG PHIÊN LÀM VIỆC ĐÓ**.
39
+ - **CẤM:** Không được nhả ra câu *"Dạ vâng, em ghi nhớ rồi"* rồi bỏ mặc không sửa file `.md`. Mọi sự đồng thuận bằng mồm sẽ bị bốc hơi. Bạn phải lưu nó thành "vết sẹo" trong `SKILL.md` để các Agent đời sau không dẫm lại "Cứt" của bạn.
40
+ - **Cách thức:** Dùng `multi_replace_file_content` sửa trực tiếp vào file. Viết gọn gàng, đậm chất Quy tắc sắt (Golden Rules), đính kèm ví dụ (nếu có).
41
+
42
+ ### 🛡️ PHÂN RANH GIỚI TRI THỨC (KNOWLEDGE BOUNDARY CẤM VI PHẠM)
43
+ Phải cực kỳ tỉnh táo để nhận diện loại kiến thức trước khi ghi chép:
44
+ 1. **Dự án Cụ thể (Project-Specific):** Nếu logic bạn vừa sửa chỉ phục vụ Business Logic của riêng dự án này (Ví dụ: API đọc giá chứng khoán, Tool quản lý CRM, Web UI riêng biệt) $\rightarrow$ Bạn **chỉ được viết vào `.agent/knowledge/`**.
45
+ 2. **Kiến trúc Lõi (AG-KIT Framework):** Nếu logic bạn vừa sửa là kiến trúc lõi dùng chung cho mọi con Bot/Agent khác về sau (Ví dụ: Định tuyến LLM, Telegram Gateway, Cơ chế Dual-Ports, Lỗi đứt cáp CDP) $\rightarrow$ Bạn **BẮT BUỘC phải ghi vào `.agent/skills/`** và đóng gói code chuẩn mực vào thư mục `templates/` của ag-kit.
46
+ *Bê logic riêng của dự án nhét vào ag-kit là tội đồ làm ô nhiễm Framework.*
47
+
48
+ ---
49
+
50
+ ## 4. 🔗 THE DUO-CORE (Kiến Trúc Multi-Tenant Bắt Buộc)
51
+ Hãy khắc cốt ghi tâm quy tắc: `IDE_PORT` (Nhận lệnh AI - ví dụ: 9555) và bước nhảy 101 để sinh ra `BRIDGE_PORT` (Portal Bridge Server - ví dụ: 9656). Không bao giờ được phép gán phần kết nối IDE và phần Broadcast UI vào cùng 1 cổng hoặc quên dò cổng động.
52
+
53
+ ---
54
+
55
+ ## 5. 🛠️ HỆ THỐNG CLI CỦA AG-KIT (BẢN ĐỒ CÔNG CỤ)
56
+ Hệ sinh thái `ag-kit` được cung cấp sức mạnh cài đặt và cập nhật thông qua 2 bộ công cụ trên NPM. Bất kỳ AI nào khi làm việc cũng phải hiểu rõ điểm khác biệt và biết cách hướng dẫn User:
57
+
58
+ 1. **Bộ Cập Nhật & Quản Trị Tương Tác (@mrtrinhvn/ag-kit):**
59
+ - Lệnh chính: `npx @mrtrinhvn/ag-kit@latest` (Mở Interactive Dashboard).
60
+ - Lệnh cụm:
61
+ - `init`: Nhồi `.agent/` vào dự án đang có.
62
+ - `update`: Kéo bản `.agent/` cực mới từ NPM về đè lên (không làm mất kiến thức riêng của dự án).
63
+ - `check` / `status`: Quét cổng CDP và kiểm tra sức khỏe hệ thống hiện tại.
64
+ - *=> Dùng Xuyên Suốt Vòng Đời: Đây là bộ công cụ tối thượng (Official CLI) được thiết lập bởi Sếp, chứa giao diện hỏi đáp và kiểm soát vòng đời ứng dụng.*
65
+
66
+ 2. **Trạm Khởi Tạo Tốc Độ Cao (create-ag-kit):**
67
+ - Lệnh chính: `npx create-ag-kit`
68
+ - *=> Dùng 1 Lần Đầu Tiên: Giống như create-react-app, đây là hạt giống cấy ghép nhanh toàn bộ thư mục `.agent/` và sinh ra `package.json` trống để tạo hẳn một dự án Bot hoàn toàn mới nằm cạnh nhau.*
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: codeact-executor
3
+ description: Autonomous script execution for complex problem solving (Code-as-Action).
4
+ version: 1.0.0
5
+ ---
6
+
7
+ # CodeAct Executor
8
+
9
+ **Purpose**: Allow specialist agents to solve complex problems by writing and executing Python or Bash scripts in a controlled environment. This is safer and more flexible than simple file editing.
10
+
11
+ ## Core Principle
12
+
13
+ > **Code is the ultimate tool.** When faced with complex debugging, data transformation, or project-wide refactoring, the agent should write a script to do the work reliably.
14
+
15
+ ## Workflow
16
+
17
+ 1. **Draft**: Agent writes a script (`/tmp/solve_problem.py`).
18
+ 2. **Execute**: Agent runs the script and captures output.
19
+ 3. **Analyze**: Agent reviews the output/logs.
20
+ 4. **Iterate**: If the script failed, the agent fixes it and re-runs.
21
+ 5. **Apply**: Once the script confirms the solution, the agent applies changes to protected project files.
22
+
23
+ ## Safety Protocols
24
+
25
+ > [!WARNING]
26
+ > **Sandboxing Required**: In production, all CodeAct executions MUST run in a Docker sandbox. Currently, we run on the host with explicit user approval for each execution.
27
+
28
+ - **Check PIDs**: Avoid scripts that run endless loops.
29
+ - **FS Isolation**: Scripts should primarily work in `/tmp/` before touching project files.
30
+ - **Resource Limits**: Kill scripts that exceed 30 seconds or high memory.
31
+
32
+ ## Examples
33
+
34
+ ### Case 1: Complex Refactoring
35
+ Agent writes a Python script using `ast` to rename a class across 50 files and update all imports.
36
+
37
+ ### Case 2: Data Extraction
38
+ Agent writes a script to scrape an internal API and generate a JSON schema from the response.
39
+
40
+ ### Case 3: Performance Profiling
41
+ Agent writes a benchmark script to measure the execution time of two different algorithms.
@@ -113,6 +113,44 @@ function analyzeRequest(userMessage) {
113
113
  | **Performance** | slow, lag, optimize, cache, performance | `performance-optimizer` |
114
114
  | **SEO** | seo, meta, analytics, sitemap, robots | `seo-specialist` |
115
115
  | **Game** | unity, godot, phaser, game, multiplayer | `game-developer` |
116
+ | **Code Fixing** | fix, repair, optimize, resolve | `code-fixer` + `codeact-executor` |
117
+
118
+ ---
119
+
120
+ ## 4. Elite Orchestration: The 8-Stage Pipeline
121
+
122
+ For complex tasks (handled by `orchestrator`), we follow a formal 8-stage state machine to ensure quality and consistency:
123
+
124
+ 1. **INTAKE**: Analyze request, identify domains, and set the goal.
125
+ 2. **RESEARCH**: Use `repomap.py` and `semantic-search` to gather deep context.
126
+ 3. **PLANNING**: Generate a detailed `implementation_plan.md` and get user approval.
127
+ 4. **GENERATION**: Multi-agent parallel execution (e.g., Frontend and Backend built simultaneously).
128
+ 5. **INTEGRATION**: Combine components and resolve cross-file dependencies.
129
+ 6. **VERIFICATION**: Run `checklist.py`, linting, and automated tests.
130
+ 7. **REFINEMENT**: Autonomous fixing using `codeact-executor` if tests fail.
131
+ 8. **SHIP**: Final review and delivery via `walkthrough.md`.
132
+
133
+ ---
134
+
135
+ ## 5. Standardized Communication: AgentResult
136
+
137
+ All agents and skills MUST return a standardized result object for better inter-agent reliability:
138
+
139
+ ```json
140
+ {
141
+ "agent": "security-auditor",
142
+ "status": "SUCCESS" | "FAILURE" | "PARTIAL",
143
+ "confidence_score": 0.95,
144
+ "payload": {
145
+ "vulnerabilities": [],
146
+ "fixes_applied": true
147
+ },
148
+ "logs": "...",
149
+ "warnings": ["Low memory detected"]
150
+ }
151
+ ```
152
+
153
+ ---
116
154
 
117
155
  ### Multi-Domain Tasks (Auto-invoke Orchestrator)
118
156
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: knowledge-management
3
- description: Hệ thống duy giao thức duy trì tri thức (Systems Thinking & Knowledge Retention). **QUY TẮC CỐI THƯỢNG: Khi cập nhật ag-kit, phải đồng bộ sang thư mục `template/`. Khi cập nhật Skills, BẮT BUỘC phải đảm bảo tính toàn vẹn cấu trúc (Indexing A, B, C... không được nhảy cóc).**
3
+ description: Systems thinking and knowledge retention protocol. MANDATORY for maintaining architectural consistency, recording integration knowledge (API characteristics), and ensuring complete, holistic code updates.
4
4
  allowed-tools: Read, Write, Glob, Grep
5
5
  ---
6
6