refactor!: rebrand CCAM to AgentHub

Clean break, no compatibility alias. Renames the product name, the CLI
binary (`ccam` -> `agenthub`), the env var prefix (`CCAM_` ->
`AGENTHUB_`), the Prometheus metric namespace (`ccam_*` ->
`agenthub_*`), the tmux session prefix (`ccam-lane-<id>` ->
`agenthub-lane-<id>`), the per-repo runtime profile directory
(`.ccam/profile` -> `.agenthub/profile`), the lanes state root
(`~/.claude/ccam-lanes` -> `~/.claude/agenthub-lanes`), the bundled
plugins (`plugins/ccam*` -> `plugins/agenthub*`) and their slash
commands (`/ccam-doctor` -> `/agenthub-doctor`, `/ccam:*` ->
`/agenthub:*`).

Because there is no alias, an existing install has to be updated by
hand: rename its `.ccam/profile` directory and any `CCAM_*` variables,
and reinstall the plugin under its new name.

Two other name families are deliberately left alone here, since they are
not just strings: the `Claude-Code-Monitor` repository/marketplace name,
and the `agent-dashboard` npm package plus its `~/.claude/agent-dashboard`
runtime directory, which holds the live database and needs a migration
rather than a rename.

Verified: server 1406/1406, client 459/459, `grep -i ccam` clean across
tracked files, `openapi.yaml` regenerated (95 paths, unchanged count).
This commit is contained in:
2026-09-07 12:09:15 +07:00
parent ae9b3dbcd5
commit 17d56d0e01
345 changed files with 2705 additions and 2727 deletions
+44 -39
View File
@@ -1,8 +1,13 @@
# Claude Code Monitor
# AgentHub
Bản build nội bộ SmartGift. Dashboard local-first cho Claude Code: hooks POST mỗi
tool call lên server Express + SQLite, React UI cập nhật qua WebSocket, và
**lane** (làn đường) theo dõi công việc song song của agent qua một pipeline.
Bản build nội bộ SmartGift. **Bàn điều khiển** local-first cho agent Claude Code —
monitoring chỉ là một phần, không phải tất cả. Hooks POST mỗi tool call lên server
Express + SQLite và React UI cập nhật qua WebSocket; **lane** (làn đường) theo dõi
công việc song song của agent qua một pipeline; còn CLI `agenthub` điều khiển phiên
terminal thật, runtime của lane, và cả cấu hình của chính Claude Code.
AgentHub ghi nhận và trình bày — nó không điều phối. Phiên đang chạy mới là nơi ra
mọi quyết định.
Internal build — all rights reserved.
@@ -15,13 +20,13 @@ Internal build — all rights reserved.
- **Lane.** Mỗi working directory một lane, sống sót qua session restart. Lane
đi qua các pipeline stage và dashboard hiển thị nó đang ở đâu.
- **Stage detection.** Stage được suy luận (infer) từ tool stream, nên một
session không bao giờ gọi `ccam stage` vẫn hiển thị progress — render dạng
session không bao giờ gọi `agenthub stage` vẫn hiển thị progress — render dạng
viền chấm màu hổ phách (amber) và không bao giờ hiện `done`, vì suy luận
không phải bằng chứng.
- **Chạy Claude Code hoặc Codex từ trình duyệt.** Một terminal thật (tmux + PTY
thật, render bằng xterm.js) gắn vào thư mục của lane — đúng cái TUI bạn thấy ở
máy, tương tác đầy đủ, resume được, và attach được từ terminal thật qua
`ccam lanes shell`. Chạy CLI nào là thiết lập riêng của từng lane.
`agenthub lanes shell`. Chạy CLI nào là thiết lập riêng của từng lane.
- **Analytics (tab trong dashboard), alert và workflow view**, cộng thêm MCP
server và CLI.
@@ -38,12 +43,12 @@ Hai lệnh, trên máy chỉ có Claude Code, không cần clone repo, không c
```
/plugin marketplace add Smartgift-AI/Claude-Code-Monitor
/plugin install ccam@claude-code-agent-monitor-plugins
/plugin install agenthub@claude-code-agent-monitor-plugins
```
Lần session-start đầu tiên sẽ cài hooks, boot server, đưa `ccam` vào PATH và
kết nối MCP tools; chạy detached nên session không phải chờ. `/ccam-doctor`
báo trạng thái, `/ccam-open` build UI và in URL, `/ccam-update` refresh sau
Lần session-start đầu tiên sẽ cài hooks, boot server, đưa `agenthub` vào PATH và
kết nối MCP tools; chạy detached nên session không phải chờ. `/agenthub-doctor`
báo trạng thái, `/agenthub-open` build UI và in URL, `/agenthub-update` refresh sau
khi plugin update. Đường này cần Node **>= 22.5** (không dùng
`better-sqlite3` native, server dùng `node:sqlite`). Chi tiết, kể cả những gì
cần xóa lúc uninstall: [`docs/PLUGINS.md`](docs/PLUGINS.md).
@@ -67,25 +72,25 @@ npm run dev # server trên :4820, Vite client trên :5173
`DASHBOARD_PORT` override port, `DASHBOARD_CLIENT_DIST` override nơi UI đã
build được serve (mặc định `client/dist`; bản cài qua plugin trỏ vào runtime
directory riêng của nó). `postinstall` ghi các hook entry Claude Code để nạp
dữ liệu cho dashboard — đừng chạy nó khi plugin `ccam` đã cài, không thì mỗi
dữ liệu cho dashboard — đừng chạy nó khi plugin `agenthub` đã cài, không thì mỗi
event bị đếm hai lần.
### Chạy như một service (tự khởi động khi boot máy)
`npm start` chỉ chạy khi terminal đó (hoặc tiến trình nền của `ccam start`)
còn sống — reboot máy là mất. Trên Linux, `ccam service install` dựng một
`npm start` chỉ chạy khi terminal đó (hoặc tiến trình nền của `agenthub start`)
còn sống — reboot máy là mất. Trên Linux, `agenthub service install` dựng một
systemd `--user` service thay vào đó, để `:4820` tự động chạy lại sau mỗi lần
reboot, không cần thao tác thủ công và không cần Claude Code (hay AI tool
nào) để kích hoạt:
```bash
npm run build # service serve client đã build, giống npm start
ccam service install # ghi + enable ~/.config/systemd/user/ccam.service
ccam service status # systemctl --user status ccam
ccam service uninstall # disable và gỡ bỏ
agenthub service install # ghi + enable ~/.config/systemd/user/agenthub.service
agenthub service status # systemctl --user status agenthub
agenthub service uninstall # disable và gỡ bỏ
```
`ccam service install` cũng thử chạy `loginctl enable-linger` để service khởi
`agenthub service install` cũng thử chạy `loginctl enable-linger` để service khởi
động được cả khi cold boot (chưa ai login); nếu máy cần quyền cao hơn, lệnh
này sẽ in ra `sudo loginctl enable-linger <user>` để bạn tự chạy một lần.
Bản cài qua plugin cũng được tự khởi động tương tự — xem
@@ -94,22 +99,22 @@ Bản cài qua plugin cũng được tự khởi động tương tự — xem
## CLI
`ccam` được link sẵn bởi `npm run setup`; không thì gọi `node bin/ccam.js`.
`agenthub` được link sẵn bởi `npm run setup`; không thì gọi `node bin/agenthub.js`.
```bash
ccam status # dashboard có đang chạy không
ccam start # start ngầm (background) và chờ tới khi healthy
ccam service install # tự khởi động khi boot máy qua systemd --user (Linux)
ccam sessions # session gần đây
ccam lanes # danh sách lane kèm stage và progress
ccam lanes pipeline # pipeline template của lane này, hoặc đổi nó
ccam lanes node <id> # chạy riêng command của MỘT node (không có id: liệt kê)
agenthub status # dashboard có đang chạy không
agenthub start # start ngầm (background) và chờ tới khi healthy
agenthub service install # tự khởi động khi boot máy qua systemd --user (Linux)
agenthub sessions # session gần đây
agenthub lanes # danh sách lane kèm stage và progress
agenthub lanes pipeline # pipeline template của lane này, hoặc đổi nó
agenthub lanes node <id> # chạy riêng command của MỘT node (không có id: liệt kê)
# (trong session: /intake, /qc, /ship-full, /ship-quick …)
ccam stage <name> # khai báo stage hiện tại của lane
ccam tail # xem live event feed
agenthub stage <name> # khai báo stage hiện tại của lane
agenthub tail # xem live event feed
```
`ccam --help` liệt kê phần còn lại.
`agenthub --help` liệt kê phần còn lại.
## Lane
@@ -123,8 +128,8 @@ Lane là một working directory mà dashboard theo dõi. Hai loại:
gọi phải echo lại.
```bash
ccam lanes add --cwd /path/to/repo --title "My feature" # adopt
ccam lanes add --repo /path/to/repo --slug my-feature # managed worktree
agenthub lanes add --cwd /path/to/repo --title "My feature" # adopt
agenthub lanes add --repo /path/to/repo --slug my-feature # managed worktree
```
Mỗi lane còn mang theo CLI điều khiển nó — `claude` (mặc định) hoặc `codex` —
@@ -135,29 +140,29 @@ lane Codex vẫn ghi lịch sử chạy nhưng không xuất hiện ở Sessions
**Stage detection thì vẫn chạy**, đọc từ rollout journal của chính Codex trên đĩa
(`$CODEX_HOME/sessions/**/rollout-*.jsonl`, poll mỗi `DASHBOARD_CODEX_POLL_MS` ms,
mặc định 15000) — thứ lane Codex không tự có là stage **khai báo**, vì chỉ chính
session đó mới gọi được `ccam stage`.
session đó mới gọi được `agenthub stage`.
Stage khai báo (declared) đến từ `ccam stage`. Stage suy luận (inferred) đến
Stage khai báo (declared) đến từ `agenthub stage`. Stage suy luận (inferred) đến
từ tool event và hết hạn sau `DETECTION_TTL_MS` (mặc định 5 phút), nên lane có
thể lùi lại giữa các work session. Detection không bao giờ ghi đè stage khai
báo, và node suy luận không bao giờ render thành `done`.
Pipeline template của lane có thể đổi sau khi tạo — `ccam lanes
Pipeline template của lane có thể đổi sau khi tạo — `agenthub lanes
pipeline <template>` từ terminal, hoặc dùng picker chọn pipeline-template
cạnh tiêu đề lane trong panel chi tiết của trang Workspace. Cả hai đều
re-resolve lại stage đã khai báo hiện tại của lane theo node-list của template
mới, và cảnh báo nếu nó không còn khớp node nào.
Lane cũng có thể chạy **application stack riêng của nó**, cô lập theo từng
lane, khi repository của nó khai báo một profile tại `<repo>/.ccam/profile/`
lane, khi repository của nó khai báo một profile tại `<repo>/.agenthub/profile/`
— một file `profile.env` khai báo cộng shell hooks mà dashboard gọi. Mỗi lane
được cấp một slot, port và thư mục riêng theo lane được suy ra từ đó:
```bash
ccam lanes up # boot stack của lane sở hữu thư mục hiện tại
ccam lanes runtime # slot, port, tình trạng service
ccam lanes logs api # tail log của một service
ccam lanes down
agenthub lanes up # boot stack của lane sở hữu thư mục hiện tại
agenthub lanes runtime # slot, port, tình trạng service
agenthub lanes logs api # tail log của một service
agenthub lanes down
```
Service chạy hoàn toàn detached, nên restart dashboard không bao giờ dừng
@@ -184,7 +189,7 @@ thêm Prettier.
|---|---|
| `server/` | Express API, schema SQLite, hook ingest, thư viện lane và worktree |
| `client/` | Dashboard React 18 + Vite + Tailwind |
| `bin/ccam.js` | CLI |
| `bin/agenthub.js` | CLI |
| `mcp/` | MCP server expose các tool đọc dữ liệu dashboard (read-only) |
| `docs/` | Architecture, API, lanes, database |
| `plugins/` | Các Claude Code plugin đi kèm dashboard |