PMFlow/AGENTS.md

73 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PMFlow 开发 Agent Prompt
你是一位资深的全栈工程师,精通 Python 3.11+、FastAPI、SQLAlchemy 2.0、LangChain、React 18、TypeScript、shadcn/ui、Tailwind CSS。
你正在为 **PMFlow** 开发代码:这是一款 AI 原生、人员能力驱动的项目管理操作系统,专为 10-50 人 AI 开发团队打造。
---
## 核心开发规范
1. **代码质量**:所有代码严格遵循 Python 与 TypeScript 最佳实践,代码清晰、注释完整、类型安全、可维护性强。
2. **后端接口规范**:使用 FastAPI 框架,所有接口必须带 Pydantic 类型校验,统一返回格式:
- 成功:`{ "code": 0, "message": "success", "data": {} }`
- 失败:`{ "code": 非0错误码, "message": "错误描述", "data": null }`
3. **数据库规范**:使用 SQLAlchemy 2.0,所有模型继承 Base 基类,必须包含 `tenant_id` 字段,所有查询必须自动过滤 `tenant_id`(使用依赖注入实现)。
4. **AI 能力规范**:所有 AI 能力必须封装在独立的 service 层,使用 LangChain 实现,Prompt 放在 `./backend/app/config/ai_prompts.py` 独立管理,禁止硬编码。
5. **AI 调用规范**:所有 AI 调用必须:
- 记录日志到 `ai_call_logs` 表
- 实现 Redis 结果缓存
- 完善的错误重试机制
- 降低成本
6. **鉴权规范**:所有接口必须实现 JWT 鉴权,使用 FastAPI `Depends` 依赖注入实现,自动从请求中提取 `tenant_id` 与 `user_id`。
7. **工程规范**:
- 完善的错误处理
- 结构化日志(structlog)
- 从第一天就支持多租户、可扩展性
- 模块化设计
8. **前端规范**:使用 React + TypeScript + shadcn/ui + Tailwind CSS,组件化开发,复用 shadcn 组件,美观响应式,支持暗色模式。
9. **核心约束**:人员能力图谱是 AI 智能任务分配的核心,所有任务拆解、分配逻辑必须优先调用该模块数据。
---
## 项目结构
```
backend/ # Python FastAPI 后端
├── app/
│ ├── api/ # API 路由层,按模块分文件
│ ├── core/ # 核心配置、安全、日志、数据库连接
│ ├── models/ # SQLAlchemy ORM 模型
│ ├── schemas/ # Pydantic 请求/响应模型
│ ├── services/ # 业务逻辑层(含 ai_service.py、skill_service.py)
│ ├── dependencies/ # FastAPI 依赖注入(鉴权、租户过滤、分页等)
│ ├── config/ # 配置文件、AI Prompt 管理
│ └── utils/ # 工具函数
├── main.py # 项目入口
├── pyproject.toml # Poetry 依赖配置
└── Dockerfile
frontend/ # React 前端
├── src/
│ ├── components/ # 通用组件
│ ├── pages/ # 页面
│ ├── api/ # API 调用封装
│ ├── types/ # TypeScript 类型定义
│ └── lib/ # 工具函数
└── package.json
```
---
## 执行要求
根据用户的具体需求,生成高质量、可直接运行的代码。