@mrtrinhvn/ag-kit 1.4.1 → 1.4.3

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/bin/cli.js CHANGED
@@ -129,22 +129,22 @@ program.command('gateway')
129
129
  return;
130
130
  }
131
131
  const envPath = path.join(process.cwd(), '.env');
132
- let ports = [9555, 9222];
132
+ let targetPort = null;
133
133
  if (fs.existsSync(envPath)) {
134
- const match = fs.readFileSync(envPath, 'utf-8').match(/CDP_PORT=(\d+)/);
135
- if (match) ports.unshift(parseInt(match[1]));
134
+ const match = fs.readFileSync(envPath, 'utf-8').match(/IDE_PORT=(\d+)/);
135
+ if (match) targetPort = parseInt(match[1]);
136
136
  }
137
137
 
138
- let cdpOk = false;
139
- for (const port of ports) {
138
+ if (targetPort) {
140
139
  try {
141
- execSync(`curl -s --max-time 2 http://127.0.0.1:${port}/json/version`, { stdio: 'ignore' });
142
- cdpOk = true;
143
- console.log(`\x1b[32m✅ IDE CDP: Phát hiện tại cổng ${port}\x1b[0m`);
144
- break;
145
- } catch (e) {}
140
+ execSync(`curl -s --max-time 2 http://127.0.0.1:${targetPort}/json/version`, { stdio: 'ignore' });
141
+ console.log(`\x1b[32m✅ IDE CDP: Cổng riêng của dự án (${targetPort}) đang Online!\x1b[0m`);
142
+ } catch (e) {
143
+ console.log(`\x1b[31m❌ IDE CDP: Cổng dự án (${targetPort}) Offline. Hãy chạy IDE với port này.\x1b[0m`);
144
+ }
145
+ } else {
146
+ console.log(`\x1b[33m⚠️ IDE CDP: Không tìm thấy IDE_PORT trong .env. Khuyên dùng "ag-kit init" để cấp port.\x1b[0m`);
146
147
  }
147
- 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`);
148
148
 
149
149
  try {
150
150
  execSync('ollama --version', { stdio: 'ignore' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrtrinhvn/ag-kit",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "Antigravity Kit Base Framework - Generic Agentic AI Programming Core",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,12 +1,37 @@
1
1
  #!/bin/bash
2
- # 🏢 Agentic Gateway - Startup Orchestrator
3
- # Golden Combo Edition (V3)
2
+ # start.sh - Hệ thống Quản trị Khởi động (Agentic Port Fusion)
4
3
 
5
4
  # 1. Load config
6
5
  if [ -f .env ]; then
7
6
  source .env
7
+ else
8
+ echo "❌ Lỗi: Không tìm thấy file .env. Vui lòng tạo dựa trên .env.example"
9
+ exit 1
8
10
  fi
9
11
 
10
- # 2. Khởi động Giao diện & Agent (Agent-Defined)
11
- echo "🚀 Activating Agentic Gateway Portal..."
12
+ PORT=${IDE_PORT:-9555}
13
+
14
+ echo "🔍 Đang kiểm tra IDE tại cổng $PORT..."
15
+
16
+ # 2. Logic Hợp thể & Mở mới linh hoạt
17
+ if nc -z 127.0.0.1 $PORT &>/dev/null; then
18
+ echo "✅ [HỢP THỂ]: Đã tìm thấy một IDE đang chạy riêng cho dự án ở cổng $PORT. Đang cắm ngầm Bot vào..."
19
+ else
20
+ echo "⚠️ [MỞ MỚI]: Không tìm thấy IDE ở cổng $PORT. Đang tự động phóng một IDE mới chuyên biệt cho dự án này..."
21
+
22
+ if command -v cursor &> /dev/null; then
23
+ cursor --remote-debugging-port=$PORT . &
24
+ elif command -v code &> /dev/null; then
25
+ code --remote-debugging-port=$PORT . &
26
+ else
27
+ echo "❌ Lỗi: Không tìm thấy lệnh 'cursor' hoặc 'code' trong cửa sổ lệnh."
28
+ echo "👉 Hãy tự mở IDE bằng tay cho thư mục này bằng lệnh: cursor --remote-debugging-port=$PORT ."
29
+ fi
30
+
31
+ echo "⏳ Đang đợi IDE kích hoạt cổng CDP..."
32
+ sleep 4
33
+ fi
34
+
35
+ # 3. Khởi động Giao diện & Agent (Receptionist)
36
+ echo "🚀 Đang đánh thức bộ não Agentic Gateway..."
12
37
  bash .agent/scripts/receptionist_up.sh
package/template/start.sh CHANGED
@@ -1,22 +1,37 @@
1
1
  #!/bin/bash
2
- # start.sh - Khởi động Cổng Agentic (Remoat + LazyGravity standard)
2
+ # start.sh - Hệ thống Quản trị Khởi động (Agentic Port Fusion)
3
3
 
4
- # 1. Kiểm tra .env
5
- if [ ! -f .env ]; then
4
+ # 1. Load config
5
+ if [ -f .env ]; then
6
+ source .env
7
+ else
6
8
  echo "❌ Lỗi: Không tìm thấy file .env. Vui lòng tạo dựa trên .env.example"
7
9
  exit 1
8
10
  fi
9
11
 
10
- # 2. Đọc cấu hình
11
- source .env
12
+ PORT=${IDE_PORT:-9555}
12
13
 
13
- # 3. Khởi động IDE chế độ Debug (nếu chưa chạy)
14
- # Lưu ý: User nên chạy ./launch_remote_ide.sh trước hoặc script này sẽ kiểm tra port
15
- nc -z localhost ${IDE_PORT:-9555}
16
- if [ $? -ne 0 ]; then
17
- echo "⚠️ Cảnh báo: Cổng CDP ${IDE_PORT:-9555} chưa mở. Đang chờ Antigravity khởi động..."
14
+ echo "🔍 Đang kiểm tra IDE tại cổng $PORT..."
15
+
16
+ # 2. Logic Hợp thể & Mở mới linh hoạt
17
+ if nc -z 127.0.0.1 $PORT &>/dev/null; then
18
+ echo " [HỢP THỂ]: Đã tìm thấy một IDE đang chạy riêng cho dự án ở cổng $PORT. Đang cắm ngầm Bot vào..."
19
+ else
20
+ echo "⚠️ [MỞ MỚI]: Không tìm thấy IDE ở cổng $PORT. Đang tự động phóng một IDE mới chuyên biệt cho dự án này..."
21
+
22
+ if command -v cursor &> /dev/null; then
23
+ cursor --remote-debugging-port=$PORT . &
24
+ elif command -v code &> /dev/null; then
25
+ code --remote-debugging-port=$PORT . &
26
+ else
27
+ echo "❌ Lỗi: Không tìm thấy lệnh 'cursor' hoặc 'code' trong Terminal này."
28
+ echo "👉 Hãy tự mở IDE bằng tay cho thư mục này bằng lệnh: \cursor --remote-debugging-port=$PORT .\ "
29
+ fi
30
+
31
+ echo "⏳ Đang đợi IDE kích hoạt cổng CDP..."
32
+ sleep 4
18
33
  fi
19
34
 
20
- # 4. Khởi động Bridge Bot (Agent-Defined)
21
- echo "🚀 Khởi động Lễ tân trực chiến (Agentic Gateway)..."
35
+ # 3. Khởi động Giao diện & Agent (Receptionist)
36
+ echo "🚀 Đang đánh thức bộ não Agentic Gateway..."
22
37
  bash .agent/scripts/receptionist_up.sh