agent-tower-dev
Skill399 starsChanged 7 days agoApache-2.0View on GitHub
Agent Tower 项目开发指南。在 Agent Tower 项目中进行任何开发工作时自动加载:添加 REST API 路由、编写 Service、 创建前端 TanStack Query hooks、添加 Socket.IO 事件、修改 Prisma schema、实现新的 Agent Executor/Parser、 或扩展 MCP tools。涵盖后端(Fastify + Prisma + Socket.IO)、前端(React + TanStack Query + Zustand)、 Pipeline(PTY + Parser + MsgStore)三层架构的开发模式与约定。
- Installs packages
In this repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-tower-devSkill
- convert-skill-to-teamrun-membersSkill
- github-desktop-releaseSkill
- publishSkill
- publishSkill
The file
Files
Agent Tower 开发指南
架构概览
Project → Task → Workspace (git worktree) → Session (AI agent) → ExecutionProcess三层分包:packages/shared(类型)、packages/server(后端)、packages/web(前端)。
开发命令
pnpm install # 安装依赖
pnpm --filter @agent-tower/shared build # 构建共享包(改类型后必须先构建)
pnpm --filter @agent-tower/server dev # 后端开发
pnpm --filter web dev # 前端开发后端开发
后端分层:Routes → Services → Prisma/EventBus。详见 references/backend-patterns.md。
添加新 API 端点
- 在
packages/server/src/services/创建{resource}.service.ts,注入EventBus/SessionManager - 在
packages/server/src/routes/创建路由文件,使用 Zod 校验 +handleError()统一错误处理 - 在
packages/server/src/routes/index.ts的registerRoutes()中注册路由 - 如需实时推送,在
EventBus的EventMap中添加事件类型
关键约定
- 服务通过
packages/server/src/core/container.ts单例获取:getEventBus(),getSessionManager()等 - 错误使用
packages/server/src/errors.ts中的ServiceError子类:NotFoundError,ValidationError,InvalidStateTransitionError - 数据库操作直接使用
prisma全局实例(从../utils/index.js导入) - 数据库 status/agentType 等使用
String类型,由 TypeScript enum 控制(不用 Prisma enum)
前端开发
前端分层:Pages → Components → Hooks → Stores → API。详见 references/frontend-patterns.md。
添加新数据查询/操作
- 在
packages/web/src/hooks/query-keys.ts添加 query key - 在
packages/web/src/hooks/use-{resource}.ts编写useQuery/useMutationhooks - API 调用通过
apiClient(@/lib/api-client)
关键约定
- Query hooks 用
enabled: !!id控制条件查询 - Mutation 成功后通过
queryClient.invalidateQueries()刷新缓存 - 共享类型从
@agent-tower/shared导入 - UI 组件使用 shadcn/ui(Radix UI),样式用 TailwindCSS v4
- 客户端状态用 Zustand(
packages/web/src/stores/)
Socket.IO 事件
命名空间 /events,通过 room 订阅区分 topic。详见 references/backend-patterns.md 的 Socket.IO 部分。
添加新事件:
- 在
packages/server/src/core/event-bus.ts的EventMap添加事件类型 - 在
packages/shared/src/socket/events.ts添加事件常量 - 在
packages/server/src/socket/socket-gateway.ts添加 EventBus → Socket.IO 转发
Pipeline 与 Executor
添加新的 Agent 类型或修改 Parser。详见 references/pipeline-patterns.md。
Pipeline 生命周期
PTY.onData → MsgStore.pushStdout + Parser.processData()
PTY.onExit → Parser.finish() + MsgStore.pushFinished()
MsgStore.onPatch → EventBus.emit('session:patch')添加新 Agent Executor
- 在
packages/server/src/executors/创建{agent}.executor.ts,继承BaseExecutor - 实现
getAvailabilityInfo(),getCapabilities(),spawn(),spawnFollowUp() - 在
packages/server/src/executors/index.ts注册到 factory
数据库变更
# 修改 packages/server/prisma/schema.prisma 后
cd packages/server && npx prisma migrate dev --name <migration-name>共享类型
修改 packages/shared/src/ 下的类型后,必须先构建共享包:
pnpm --filter @agent-tower/shared build导出路径:@agent-tower/shared, @agent-tower/shared/socket, @agent-tower/shared/types, @agent-tower/shared/log-adapter。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

