@mrtrinhvn/ag-kit 1.1.9 → 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.
- package/package.json +2 -2
- package/template/.agent/.version +1 -0
- package/template/.agent/agents/orchestrator.md +0 -2
- package/template/.agent/knowledge/ag-kit-elite.md +22 -0
- package/template/.agent/knowledge/model-switching-vfs.md +16 -16
- package/template/.agent/scripts/port_utils.sh +69 -30
- package/template/.agent/scripts/receptionist_down.sh +24 -16
- package/template/.agent/scripts/receptionist_up.sh +124 -21
- package/template/.agent/scripts/repomap.py +126 -0
- package/template/.agent/skills/ag-kit-core/SKILL.md +68 -0
- package/template/.agent/skills/codeact-executor/SKILL.md +41 -0
- package/template/.agent/skills/intelligent-routing/SKILL.md +38 -0
- package/template/.agent/skills/knowledge-management/SKILL.md +1 -1
- package/template/.agent/skills/lazy-gravity/SKILL.md +14 -11
- package/template/.agent/skills/llm-routing-quirks/SKILL.md +17 -6
- package/template/.agent/skills/remoat-integration/SKILL.md +37 -13
- package/template/.agent/skills/semantic-search/SKILL.md +24 -0
- package/template/.agent/skills/telegram-agentic-gateway/SKILL.md +77 -38
- package/template/.agent/skills/telegram-agentic-gateway/templates/CdpService.ts.template +514 -0
- package/template/.agent/skills/telegram-agentic-gateway/templates/ResponseMonitor.ts.template +102 -0
- package/template/.agent/skills/telegram-agentic-gateway/templates/start.sh.template +12 -0
- package/template/GEMINI.md +27 -18
- package/template/scripts/ag_deck/index.html +58 -0
- package/template/scripts/ag_heartbeat.js +46 -0
- package/template/scripts/ag_hud.js +87 -155
- package/template/scripts/ag_phantom.sh +50 -0
- package/template/scripts/ag_portal_bridge.js +139 -114
- package/template/start.sh +0 -0
- package/template/stop_bot.sh +0 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/charts.csv +0 -26
- package/template/.agent/.shared/ui-ux-pro-max/data/colors.csv +0 -97
- package/template/.agent/.shared/ui-ux-pro-max/data/icons.csv +0 -101
- package/template/.agent/.shared/ui-ux-pro-max/data/landing.csv +0 -31
- package/template/.agent/.shared/ui-ux-pro-max/data/products.csv +0 -97
- package/template/.agent/.shared/ui-ux-pro-max/data/prompts.csv +0 -24
- package/template/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +0 -45
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +0 -53
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +0 -56
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +0 -53
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +0 -53
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +0 -51
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +0 -59
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +0 -52
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +0 -54
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +0 -61
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +0 -54
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +0 -51
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +0 -50
- package/template/.agent/.shared/ui-ux-pro-max/data/styles.csv +0 -59
- package/template/.agent/.shared/ui-ux-pro-max/data/typography.csv +0 -58
- package/template/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +0 -101
- package/template/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +0 -100
- package/template/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +0 -31
- package/template/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/template/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/template/.agent/.shared/ui-ux-pro-max/scripts/core.py +0 -258
- package/template/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +0 -1067
- package/template/.agent/.shared/ui-ux-pro-max/scripts/search.py +0 -106
- package/template/.agent/ARCHITECTURE.md +0 -288
- package/template/.agent/knowledge/orchestrator_v3_protocol.md +0 -60
- package/template/.agent/knowledge/self_healing_logs.md +0 -22
- package/template/.agent/knowledge/tele-agentic-standard.md +0 -30
- 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.1
|
|
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": {
|
|
@@ -32,4 +32,4 @@
|
|
|
32
32
|
"commander": "^14.0.3",
|
|
33
33
|
"inquirer": "^8.2.5"
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
}
|
|
@@ -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 &
|
|
1
|
+
78# Tiết Kiệm Token & Quản Lý Mô Hình (Model & VFS Knowledge)
|
|
2
2
|
|
|
3
|
-
|
|
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í.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
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 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
10
|
|
|
11
|
-
## 2.
|
|
12
|
-
Hệ thống sử dụng
|
|
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
13
|
|
|
14
|
-
|
|
|
14
|
+
| Độ khó | Tác vụ | Mô hình khuyến nghị | Lý do |
|
|
15
15
|
| :--- | :--- | :--- | :--- |
|
|
16
|
-
| **
|
|
17
|
-
| **Trung
|
|
18
|
-
| **
|
|
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
19
|
|
|
20
|
-
## 3. Tích Hợp Local
|
|
21
|
-
-
|
|
22
|
-
-
|
|
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.
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
# --- Port Management Utility (Golden
|
|
4
|
-
#
|
|
3
|
+
# --- Port Management Utility (Golden V6 - High Precision) ---
|
|
4
|
+
# Tự động quét và thu nạp cổng IDE theo từng dự án.
|
|
5
|
+
# Đảm bảo "Chính chủ" mới dùng, "Người lạ" thì né.
|
|
5
6
|
|
|
6
7
|
ENV_FILE=".env"
|
|
8
|
+
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
7
9
|
|
|
8
|
-
#
|
|
10
|
+
# 1. Tìm cổng trống dựa trên netstat
|
|
9
11
|
function find_free_port() {
|
|
10
12
|
local port=$1
|
|
11
13
|
while netstat -atn | grep -q ":$port "; do
|
|
@@ -14,13 +16,11 @@ function find_free_port() {
|
|
|
14
16
|
echo $port
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
# Cập nhật
|
|
19
|
+
# 2. Cập nhật .env (Dùng sed tương thích đa hệ điều hành)
|
|
18
20
|
function update_env_port() {
|
|
19
21
|
local key=$1
|
|
20
22
|
local value=$2
|
|
21
|
-
|
|
22
23
|
if grep -q "^${key}=" "$ENV_FILE"; then
|
|
23
|
-
# OS-compatible sed (Linux/macOS)
|
|
24
24
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
25
25
|
sed -i '' "s/^${key}=.*/${key}=${value}/" "$ENV_FILE"
|
|
26
26
|
else
|
|
@@ -31,37 +31,76 @@ function update_env_port() {
|
|
|
31
31
|
fi
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
# 3. Quét dải cổng để tìm IDE của chính dự án này
|
|
35
|
+
function scan_project_ide() {
|
|
36
|
+
local start_p=$1
|
|
37
|
+
local end_p=$2
|
|
38
|
+
for ((p=start_p; p<=end_p; p++)); do
|
|
39
|
+
if netstat -atn | grep -q ":$p "; then
|
|
40
|
+
# Kiểm tra xem có đúng là IDE của dự án này đang ở cổng p không
|
|
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
|
|
43
|
+
echo $p
|
|
44
|
+
return 0
|
|
45
|
+
fi
|
|
46
|
+
fi
|
|
47
|
+
done
|
|
48
|
+
echo ""
|
|
49
|
+
return 1
|
|
50
|
+
}
|
|
51
|
+
|
|
34
52
|
# --- Main Logic ---
|
|
35
|
-
|
|
53
|
+
|
|
54
|
+
# Nạp config cũ
|
|
36
55
|
if [ -f "$ENV_FILE" ]; then
|
|
37
56
|
source "$ENV_FILE"
|
|
38
57
|
fi
|
|
39
58
|
|
|
40
|
-
|
|
41
|
-
|
|
59
|
+
DEFAULT_IDE_START=9555
|
|
60
|
+
IDE_RANGE_END=9655
|
|
61
|
+
BRIDGE_OFFSET=101 # IDE 9555 -> Bridge 9656
|
|
42
62
|
|
|
43
|
-
|
|
44
|
-
# Nếu cổng IDE bận, và không phải là do IDE của chính dự án này chiếm giữ (kiểm tra qua /json endpoint)
|
|
45
|
-
PORT_TAKEN=false
|
|
46
|
-
if netstat -atn | grep -q ":$ORIGINAL_IDE_PORT "; then
|
|
47
|
-
# Kiểm tra xem folder dự án hiện tại có nằm trong danh sách tab/window của IDE không
|
|
48
|
-
if ! curl -s "http://127.0.0.1:$ORIGINAL_IDE_PORT/json" | grep -q "$PROJECT_DIR" > /dev/null 2>&1; then
|
|
49
|
-
PORT_TAKEN=true
|
|
50
|
-
fi
|
|
51
|
-
fi
|
|
63
|
+
CURRENT_CONFIG_IDE=${IDE_PORT:-$DEFAULT_IDE_START}
|
|
52
64
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
echo "🔍 Đang rà soát "Brain Portal" (Dải 100 cổng) cho dự án: $(basename "$PROJECT_DIR")..."
|
|
66
|
+
|
|
67
|
+
# Bước 1: Quét xem có IDE nào đang mở dự án này không (Dải 9555 - 9655)
|
|
68
|
+
FOUND_PORT=$(scan_project_ide $DEFAULT_IDE_START $IDE_RANGE_END)
|
|
69
|
+
|
|
70
|
+
if [ ! -z "$FOUND_PORT" ]; then
|
|
71
|
+
echo "✅ Phát hiện IDE đang chạy tại cổng: $FOUND_PORT"
|
|
72
|
+
export IDE_PORT=$FOUND_PORT
|
|
73
|
+
export BRIDGE_PORT=$((FOUND_PORT + BRIDGE_OFFSET))
|
|
60
74
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
# Cập nhật .env nếu có thay đổi
|
|
76
|
+
if [ "$FOUND_PORT" != "$CURRENT_CONFIG_IDE" ]; then
|
|
77
|
+
echo "📝 Cập nhật cổng mới vào .env..."
|
|
78
|
+
update_env_port "IDE_PORT" "$FOUND_PORT"
|
|
79
|
+
update_env_port "BRIDGE_PORT" "$BRIDGE_PORT"
|
|
80
|
+
fi
|
|
64
81
|
else
|
|
65
|
-
|
|
66
|
-
|
|
82
|
+
# Bước 2: Không thấy IDE cũ, kiểm tra cổng trong .env có bị "người lạ" chiếm không
|
|
83
|
+
echo "❓ Không tìm thấy IDE đang chạy. Tiến hành rà soát cổng khả dụng..."
|
|
84
|
+
|
|
85
|
+
# Nếu cổng hiện tại bị "người lạ" chiếm
|
|
86
|
+
if netstat -atn | grep -q ":$CURRENT_CONFIG_IDE "; then
|
|
87
|
+
echo "⚠️ Cổng mặc định $CURRENT_CONFIG_IDE đã bị dự án khác chiếm."
|
|
88
|
+
# Tìm IDE trống trong dải
|
|
89
|
+
FREE_IDE=$(find_free_port $DEFAULT_IDE_START)
|
|
90
|
+
FREE_BRIDGE=$(find_free_port $((FREE_IDE + BRIDGE_OFFSET)))
|
|
91
|
+
|
|
92
|
+
echo "🚀 Đã phân bổ cặp cổng trống mới: IDE=$FREE_IDE, BRIDGE=$FREE_BRIDGE"
|
|
93
|
+
update_env_port "IDE_PORT" "$FREE_IDE"
|
|
94
|
+
update_env_port "BRIDGE_PORT" "$FREE_BRIDGE"
|
|
95
|
+
|
|
96
|
+
export IDE_PORT=$FREE_IDE
|
|
97
|
+
export BRIDGE_PORT=$FREE_BRIDGE
|
|
98
|
+
else
|
|
99
|
+
# Cổng trong .env vẫn trống, dùng luôn
|
|
100
|
+
export IDE_PORT=$CURRENT_CONFIG_IDE
|
|
101
|
+
# Đảm bảo BRIDGE_PORT tương ứng
|
|
102
|
+
export BRIDGE_PORT=$((CURRENT_CONFIG_IDE + BRIDGE_OFFSET))
|
|
103
|
+
update_env_port "BRIDGE_PORT" "$BRIDGE_PORT"
|
|
104
|
+
echo "✅ Sử dụng cổng cấu hình: $IDE_PORT (Bridge: $BRIDGE_PORT)"
|
|
105
|
+
fi
|
|
67
106
|
fi
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
# --- Antigravity Unified Shutdown (
|
|
4
|
-
# Dọn dẹp trạm gác
|
|
3
|
+
# --- Antigravity Unified Shutdown (Golden V6 - High Precision) ---
|
|
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,28 +10,36 @@ if [ -f .env ]; then
|
|
|
10
10
|
source .env
|
|
11
11
|
fi
|
|
12
12
|
|
|
13
|
-
BRIDGE_PORT=${BRIDGE_PORT:-
|
|
13
|
+
BRIDGE_PORT=${BRIDGE_PORT:-9558}
|
|
14
14
|
|
|
15
15
|
echo "════════════════════════════════════════════════════"
|
|
16
|
-
echo "
|
|
16
|
+
echo " 🛑 SHUTTING DOWN CEOGRAVITY [$BRIDGE_PORT]..."
|
|
17
17
|
echo "════════════════════════════════════════════════════"
|
|
18
18
|
|
|
19
|
-
# 1. Tắt
|
|
19
|
+
# 1. Tắt Sentinel Monitor
|
|
20
|
+
SENTINEL_PID_FILE=".sentinel_${BRIDGE_PORT}.pid"
|
|
21
|
+
if [ -f "$SENTINEL_PID_FILE" ]; then
|
|
22
|
+
kill $(cat "$SENTINEL_PID_FILE") 2>/dev/null && rm "$SENTINEL_PID_FILE"
|
|
23
|
+
echo "✅ Sentinel stopped."
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
# 2. Tắt Portal Bridge
|
|
20
27
|
BRIDGE_PID_FILE=".portal_bridge_${BRIDGE_PORT}.pid"
|
|
21
28
|
if [ -f "$BRIDGE_PID_FILE" ]; then
|
|
22
|
-
|
|
23
|
-
echo "
|
|
24
|
-
kill $PID 2>/dev/null && rm "$BRIDGE_PID_FILE"
|
|
25
|
-
echo " ✅ Bridge stopped."
|
|
26
|
-
else
|
|
27
|
-
echo "[1/2] 🧪 Portal Bridge on port $BRIDGE_PORT not running."
|
|
29
|
+
kill $(cat "$BRIDGE_PID_FILE") 2>/dev/null && rm "$BRIDGE_PID_FILE"
|
|
30
|
+
echo "✅ HUD Bridge stopped."
|
|
28
31
|
fi
|
|
29
32
|
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
34
42
|
|
|
35
43
|
echo "════════════════════════════════════════════════════"
|
|
36
|
-
echo "✅
|
|
44
|
+
echo "✅ CEOGRAVITY IS IDLE."
|
|
37
45
|
echo "════════════════════════════════════════════════════"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
# --- Antigravity Unified Receptionist (
|
|
4
|
-
# Trạm gác hợp nhất: Bot + Portal Bridge (HUD)
|
|
5
|
-
#
|
|
3
|
+
# --- Antigravity Unified Receptionist (Golden V6 - High Precision) ---
|
|
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,42 +12,145 @@ 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:-
|
|
16
|
-
export BRIDGE_PORT=${BRIDGE_PORT:-
|
|
15
|
+
export IDE_PORT=${IDE_PORT:-9557}
|
|
16
|
+
export BRIDGE_PORT=${BRIDGE_PORT:-9658}
|
|
17
17
|
fi
|
|
18
18
|
|
|
19
19
|
echo "════════════════════════════════════════════════════"
|
|
20
|
-
echo "
|
|
20
|
+
echo " 🏢 CEOGRAVITY GATEWAY - PORTAL [$BRIDGE_PORT]"
|
|
21
21
|
echo "════════════════════════════════════════════════════"
|
|
22
22
|
|
|
23
|
-
#
|
|
24
|
-
|
|
23
|
+
# 2. Xử lý 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
|
-
|
|
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
|
|
30
70
|
fi
|
|
31
71
|
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
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."
|
|
77
|
+
else
|
|
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
|
|
88
|
+
fi
|
|
89
|
+
fi
|
|
90
|
+
echo "✅ READY."
|
|
35
91
|
|
|
36
|
-
#
|
|
92
|
+
# 3. Khởi động Portal Bridge (HUD Injector)
|
|
93
|
+
echo "[3/4] 🧪 Injected Golden HUD Bridge... "
|
|
94
|
+
BRIDGE_PID_FILE=".portal_bridge_${BRIDGE_PORT}.pid"
|
|
37
95
|
if [ -f "$BRIDGE_PID_FILE" ]; then
|
|
38
96
|
kill $(cat "$BRIDGE_PID_FILE") 2>/dev/null
|
|
39
97
|
fi
|
|
40
|
-
|
|
41
98
|
nohup node scripts/ag_portal_bridge.js > ".portal_bridge_${BRIDGE_PORT}.log" 2>&1 &
|
|
42
99
|
echo $! > "$BRIDGE_PID_FILE"
|
|
43
100
|
echo " ✅ Bridge running (PID: $(cat "$BRIDGE_PID_FILE") on Port $BRIDGE_PORT)"
|
|
44
101
|
|
|
45
|
-
#
|
|
46
|
-
echo "[
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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"))"
|
|
126
|
+
|
|
127
|
+
# 5. Sentinel Monitor (Giám sát Trí não)
|
|
128
|
+
echo "🛡️ Sentinel Active: Auto-shutdown if IDE connection lost."
|
|
129
|
+
SENTINEL_PID_FILE=".sentinel_${BRIDGE_PORT}.pid"
|
|
130
|
+
|
|
131
|
+
function start_sentinel() {
|
|
132
|
+
(
|
|
133
|
+
local fail_count=0
|
|
134
|
+
local PROJ_NAME=$(basename "$PROJECT_DIR")
|
|
135
|
+
# Give more time for the first check
|
|
136
|
+
sleep 60
|
|
137
|
+
while true; do
|
|
138
|
+
if ! curl -s "http://127.0.0.1:$IDE_PORT/json" | grep -q "$PROJ_NAME" > /dev/null 2>&1; then
|
|
139
|
+
fail_count=$((fail_count + 1))
|
|
140
|
+
if [ $fail_count -ge 3 ]; then
|
|
141
|
+
echo "$(date): ⚠️ IDE Lost. Auto-shutting down project..." >> .sentinel_crash.log
|
|
142
|
+
bash .agent/scripts/receptionist_down.sh
|
|
143
|
+
exit 0
|
|
144
|
+
fi
|
|
145
|
+
else
|
|
146
|
+
fail_count=0
|
|
147
|
+
fi
|
|
148
|
+
done
|
|
149
|
+
) &
|
|
150
|
+
echo $! > "$SENTINEL_PID_FILE"
|
|
151
|
+
}
|
|
152
|
+
start_sentinel
|
|
50
153
|
|
|
51
|
-
#
|
|
52
|
-
echo "[4/4] 📊 Ready."
|
|
154
|
+
# Monitor
|
|
53
155
|
echo "----------------------------------------------------"
|
|
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())
|