add Gitea Bot interface: webhook server, API tool, Caddy ingress
- Add src/gitea.rs: axum webhook server on :9800, handles @mention in issues and PRs, spawns claude -p for review, posts result as comment - Add call_gitea_api tool: LLM can directly call Gitea REST API with pre-configured admin token (noc_bot identity) - Add Caddy to Docker image as ingress layer (subdomain/path routing) - Config: add gitea section with token_file support for auto-provisioned token - Update suite.md: VPS-first deployment, SubAgent architecture, Caddy role
This commit is contained in:
76
doc/suite.md
76
doc/suite.md
@@ -77,9 +77,36 @@ AI 在后台安静地干活,做完了才来找你。
|
||||
| Memory | 跨会话的持久记忆 |
|
||||
| Context | 对话历史、summary、scratch |
|
||||
| Tools | 统一的工具注册表,各界面按需可见 |
|
||||
| SubAgent | Claude Code (`claude -p`) 作为可调度的执行引擎 |
|
||||
|
||||
所有界面的交互最终都流经同一个 LLM 调用路径,共享 persona 和 inner_state——无论 AI 是在回复聊天、review 代码还是自言自语,它都是同一个"人"。
|
||||
|
||||
### SubAgent — Claude Code 作为执行引擎
|
||||
|
||||
Suite 的 AI Core 通过 OpenAI-compatible API 做对话和决策,但**复杂任务的执行交给 Claude Code**。这是当下 agent 生态的主流模式:一个轻量的调度层 + 重量级的 coding agent 做实际工作。
|
||||
|
||||
```
|
||||
AI Core (决策层)
|
||||
│
|
||||
├─ 简单任务:直接用 tools(bash、文件操作、API 调用)
|
||||
│
|
||||
└─ 复杂任务:spawn claude -p(subagent)
|
||||
├─ 代码编写、重构、debug
|
||||
├─ 多文件修改、跨项目操作
|
||||
├─ 调研、分析、生成报告
|
||||
└─ 结果异步回传给 AI Core
|
||||
```
|
||||
|
||||
**noc 是调度层和人格层,Claude Code 是执行层。** noc 不重复造 coding agent 的轮子,直接站在巨人肩膀上。
|
||||
|
||||
这意味着 suite 的 VPS 上需要安装 Claude Code CLI。noc 不需要自己实现 coding agent 的能力——它负责理解意图、管理上下文、协调界面,把"脏活"交给 Claude Code。
|
||||
|
||||
场景举例:
|
||||
- Chat: "帮我写个脚本分析日志" → spawn claude -p,完成后把结果发回聊天
|
||||
- Gitea Bot: PR 来了 → claude -p review 代码,结果写成 comment
|
||||
- Worker: 定时任务要更新一个 dashboard → claude -p 生成代码,部署到 /data/www/
|
||||
- Self: 反思时发现某个 tool 有 bug → 自己 spawn claude -p 去修
|
||||
|
||||
## 界面之间的联动
|
||||
|
||||
界面不是孤立的,它们之间会互相触发:
|
||||
@@ -93,10 +120,20 @@ Self ──"Fam 今天还没动过代码"──→ Chat(主动关心)
|
||||
|
||||
## 部署架构
|
||||
|
||||
Suite 是自包含的——不依赖外部服务,自己带齐所有组件:
|
||||
Suite 跑在一台专属 VPS / EC2 上——一台小机器(2C4G 足够),完整拥有整个环境:
|
||||
|
||||
```
|
||||
┌─ suite 部署 ─────────────────────────────────┐
|
||||
┌─ VPS (suite 专属) ───────────────────────────┐
|
||||
│ │
|
||||
│ Caddy (ingress) │
|
||||
│ ├─ git.example.com → Gitea :3000 │
|
||||
│ ├─ app1.example.com → /data/www/app1 │
|
||||
│ └─ ...按需扩展 │
|
||||
│ │
|
||||
│ Gitea (self-hosted, AI 专属) │
|
||||
│ ├─ noc 持有 admin token,完全控制 │
|
||||
│ ├─ webhook → noc http server │
|
||||
│ └─ noc 通过 REST API 读写一切 │
|
||||
│ │
|
||||
│ noc (Rust binary) │
|
||||
│ ├─ telegram loop (Chat) │
|
||||
@@ -104,25 +141,42 @@ Suite 是自包含的——不依赖外部服务,自己带齐所有组件:
|
||||
│ ├─ life loop (Self) │
|
||||
│ └─ worker loop (Worker) │
|
||||
│ │
|
||||
│ Gitea (self-hosted, AI 专属) │
|
||||
│ ├─ noc 持有 admin token,完全控制 │
|
||||
│ ├─ webhook → noc http server │
|
||||
│ └─ noc 通过 REST API 读写一切 │
|
||||
│ │
|
||||
│ SQLite (共享状态) │
|
||||
│ │
|
||||
│ LLM backend (外部,OpenAI-compatible) │
|
||||
│ │
|
||||
└───────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
Gitea 是 noc 的"专属地盘"——admin token 意味着 noc 可以:
|
||||
### 为什么是裸机而不是 Docker
|
||||
|
||||
- Caddy 要绑 80/443,容器里搞端口映射反而多一层
|
||||
- noc 需要 spawn 子进程、读写磁盘、跑工具脚本,容器限制多
|
||||
- 一台机器就是给 suite 独占的,不需要隔离
|
||||
- Worker 以后可能跑 CI、生成 web app,直接操作文件系统最自然
|
||||
|
||||
Docker image 保留用于本地开发和测试。
|
||||
|
||||
### Caddy 的角色
|
||||
|
||||
不只是反向代理——是 suite 的**统一入口**:
|
||||
|
||||
- 子域名路由:不同服务用不同子域名
|
||||
- 静态站点托管:Worker 生成的 web app 放到 `/data/www/<name>/`,加一条路由即可对外
|
||||
- 自动 HTTPS:Let's Encrypt 证书自动申请和续期
|
||||
- 未来 noc 自己的 HTTP API 也从这里暴露
|
||||
|
||||
### Gitea 的角色
|
||||
|
||||
noc 的"专属地盘"——admin token 意味着 noc 可以:
|
||||
- 创建/删除 repo 和 branch
|
||||
- 读写任意 PR、issue、comment
|
||||
- 管理 webhook、CI、用户
|
||||
- 不用操心权限,想干嘛干嘛
|
||||
|
||||
部署方式:docker-compose 或 systemd 同机编排,一键拉起。
|
||||
### 部署方式
|
||||
|
||||
- 主线:`deploy/setup.sh` 在 VPS 上一键安装 Caddy + Gitea + noc,systemd 管理
|
||||
- 开发:`make docker` 构建 all-in-one image,本地测试用
|
||||
|
||||
## 现状 → 目标
|
||||
|
||||
@@ -132,4 +186,4 @@ Gitea 是 noc 的"专属地盘"——admin token 意味着 noc 可以:
|
||||
| Gitea Bot | ❌ 不存在 | webhook 接收 + PR review |
|
||||
| Worker | 🟡 SubAgent 雏形 | 独立任务队列 + 结果路由 |
|
||||
| Self | 🟡 life loop + reflect | 更丰富的自主行为 |
|
||||
| Gitea | ❌ 外部依赖 | 纳入 suite 部署,self-hosted |
|
||||
| Infra | ✅ Docker all-in-one | VPS setup 脚本 + systemd |
|
||||
|
||||
Reference in New Issue
Block a user