🤖 QA自动化代理
基于代理的质量保证自动化框架 由Notion MCP+Claude Agent SDK提供支持
从Notion数据库自动检测、分析和修复QA问题——从错误检测到PR提交——完全自动化!
______________________________________________________________________
✨ 特性
- 🔍 自动QA检测 -Notion QA数据库的实时监控
- 🧠 AI驱动的分析 -Claude分析文本+图像(OCR+Vision API)
- 🤔 智能分类 -确定可操作性和工作复杂性
- 💻 自动代码修复 -自动生成错误修复和功能
- ✅ 测试生成 -创建全面的测试套件
- 🔀 公共关系管理 -创建带有详细描述的GitHub Pull请求
- 💬 Slack集成 -实时通知团队可见性
- 📊 多项目支持 -处理多个存储库(路线图)
______________________________________________________________________
🏗️ 建筑
Notion QA (Not Started)
↓
QA Analyzer Agent
├─ Text Analysis (Claude)
├─ Image OCR (Tesseract.js)
└─ Vision Analysis (Claude Vision)
↓
Action Classifier Agent
├─ Actionability Check
├─ Work Type Classification
└─ Complexity Estimation
↓
Code Agent
├─ Codebase Analysis
├─ Bug Fix Implementation
└─ Test Generation
↓
PR Manager Agent
├─ Branch Creation
├─ Code Commit
└─ Pull Request
↓
✅ Done + Slack Notification______________________________________________________________________
🚀 快速开始
先决条件
- Node.js 20+
- 集成概念工作空间
- GitHub存储库访问
- 无烟煤API键
- Slack工作空间(可选)
安装
# Clone the repository
git clone
cd quality-assurance-agent
# Install dependencies
npm install
# Setup environment variables
cp .env.example .env
# Edit .env with your credentials
# Build the project
npm run build
# Run the agent
npm start______________________________________________________________________
⚙️ 配置
环境变量
创建 .env 文件包含以下内容:
# Anthropic API
ANTHROPIC_API_KEY=sk-ant-api03-xxxxx
# Notion
NOTION_TOKEN=secret_xxxxx
NOTION_DATABASE_ID=your-database-id
# GitHub
GITHUB_TOKEN=ghp_xxxxx
GITHUB_OWNER=your-org
GITHUB_REPO=your-repo
GITHUB_DEFAULT_BRANCH=main
# Slack (Optional)
SLACK_BOT_TOKEN=xoxb-xxxxx
SLACK_CHANNEL_QA=#qa-automation
# Agent Configuration
MAX_CONCURRENT_AGENTS=3
SESSION_TIMEOUT=3600
LOG_LEVEL=info看 .env.example 了解完整的配置选项。
______________________________________________________________________
📖 用法
1.设置概念数据库
创建具有以下属性的Notion数据库:
- 标题 (title):QA问题标题
- 状态 (选择):未开始、正在进行、已完成、不可操作
- 描述 (富格文本):问题描述
- 记者 (人):谁报告了这个问题
- 优先级 (选择,可选):严重、高、中、低
- PR网址 (url,可选):由代理自动填充
2.创建概念集成
- 首选https://www.notion.so/my-integrations
- 创建新的集成
- 复制集成令牌→
NOTION_TOKEN - 通过集成共享您的数据库
3.设置GitHub Token
- 转到GitHub设置→ 开发人员设置→ 个人访问令牌
- 生成新令牌(细粒度)
- 授予权限:
- 内容:读写 - 拉取请求:读写
- 复制令牌→
GITHUB_TOKEN
4.获取Anthropic API密钥
- 首选https://console.anthropic.com
- 创建API密钥
- Copy →
ANTHROPIC_API_KEY
5.运行代理
# Development mode (hot reload)
npm run dev
# Production mode
npm start6.在概念中创建QA项
- 将新项目添加到您的Notion数据库
- 将状态设置为“未启动”
- 看魔术发生! 🎩✨
______________________________________________________________________
🎬 工作流示例
1. QA Reported in Notion
Title: "Login button not working on mobile"
Description: "When I tap login on iOS, nothing happens"
Status: Not Started
2. Agent Detects QA
📥 New QA detected: "Login button not working..."
3. Analysis Phase
🔍 Analyzing text and images...
Issue Type: bug
Severity: high
Affected Components: [auth, mobile-ui]
4. Classification Phase
🤔 Determining actionability...
Decision: Actionable
Work Type: bug_fix
Complexity: moderate
5. Implementation Phase
💻 Generating code fix...
Files Changed:
- src/components/LoginButton.tsx
- tests/LoginButton.test.tsx
6. PR Creation
🔀 Creating pull request...
PR #123 created: "fix: Login button not working on mobile"
7. Completion
✅ QA completed!
Notion updated: Status → Done, PR URL added
Slack notification sent: "QA #123 completed! Review PR"______________________________________________________________________
🛠️ 发展
项目结构
quality-assurance-agent/
├── src/
│ ├── agents/ # Agent implementations
│ │ ├── base.ts # Base agent class
│ │ ├── qa-analyzer.ts # QA analysis
│ │ ├── action-classifier.ts
│ │ ├── code-agent.ts # Code implementation
│ │ └── pr-manager.ts # PR management
│ │
│ ├── orchestrator/ # Main orchestration
│ │ ├── main.ts # Main orchestrator
│ │ └── session-manager.ts
│ │
│ ├── services/ # External integrations
│ │ ├── notion-mcp.ts # Notion MCP client
│ │ ├── github-client.ts # GitHub API
│ │ ├── slack-notifier.ts
│ │ └── ocr-service.ts
│ │
│ ├── types/ # TypeScript types
│ ├── utils/ # Utilities
│ └── index.ts # Entry point
│
├── config/ # Configuration files
├── tests/ # Test suites
├── docs/ # Documentation
└── logs/ # Application logs可用脚本
# Development
npm run dev # Run with hot reload
npm run build # Build TypeScript
npm start # Run production build
# Code Quality
npm run lint # Run ESLint
npm run format # Format with Prettier
npm test # Run tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Coverage report
# Type Checking
npm run typecheck # TypeScript type check添加新代理
- 创建新的代理类扩展
BaseAgent:
import { BaseAgent } from './base.js';
import type { AgentConfig, AgentContext } from '../types/index.js';
export class MyCustomAgent extends BaseAgent {
constructor(config: AgentConfig, context: AgentContext) {
super(
{
...config,
agentType: 'my-custom-agent',
timeout: 120000,
},
context
);
}
protected async run(input?: InputType): Promise {
// Your implementation
}
}- 添加到编排器工作流
- 更新类型定义
- 编写测试
______________________________________________________________________
📚 文档
______________________________________________________________________
🧪 测试
# Run all tests
npm test
# Unit tests only
npm run test:unit
# Integration tests
npm run test:integration
# End-to-end tests
npm run test:e2e
# Coverage report
npm run test:coverage______________________________________________________________________
🐛 故障排除
常见问题
问题:MCP连接失败
Error: Not connected to Notion MCP解决方案:检查NOTION_TOKEN并确保集成可以访问数据库
问题:GitHub身份验证失败
Error: Bad credentials解决方案:验证GITHUB_TOKEN是否有效并且具有正确的权限
问题:人类API错误
Error: Invalid API key解决方案:检查ANTHROPIC_API_KEY格式(应以开头 sk-ant-)
问题:代理超时
Error: Agent timeout after 300000ms解决方案:增加代理配置超时或检查API连接
______________________________________________________________________
🔐 安全
- ✅ 存储在中的所有API密钥
.env(未承诺) - ✅ 细粒度GitHub令牌(最低权限)
- ✅ Notion集成仅限于特定数据库
- ✅ 代码代理限制文件访问
- ✅ 全面的审计日志记录
永不承诺 .env 或公开API密钥!
______________________________________________________________________
📊 监控
日志将写入:
logs/qa-automation.log-所有日志logs/error.log-仅错误logs/exceptions.log-无异常
监控代理活动:
# Tail logs
tail -f logs/qa-automation.log
# Filter by session
tail -f logs/qa-automation.log | grep "Session:session-123"
# Filter by agent type
tail -f logs/qa-automation.log | grep "\[qa-analyzer\]"______________________________________________________________________
🚦 路线图
第一阶段:单一项目(✅ 当前)
- \[x\] 完整的代理架构
- \[x\] MCP集成概念
- \[x\] GitHub公关自动化
- \[x\] 松弛通知
- \[x\] 完整文档
第二阶段:多项目
- \[\]项目配置系统
- \[\]资源管理
- \[\]跨项目分析
- \[\]管理仪表板
第三阶段:智力与学习
- \[\]跟踪PR批准率
- \[\]从反馈中学习
- \[\]模式识别
- \[\]自定义代理插件
______________________________________________________________________
🤝 贡献
欢迎投稿!请阅读 贡献.md 作为指导方针。
- 分叉存储库
- 创建特征分支(
git checkout -b feature/amazing-feature) - 提交更改(
git commit -m 'Add amazing feature') - 推送到分支(
git push origin feature/amazing-feature) - 打开拉取请求
______________________________________________________________________
📜 许可证
MIT许可证-请参阅 许可证 详细信息文件
______________________________________________________________________
🙏 致谢
- Anthropic -API克劳德
- 概念 -MCP服务器
- @模型上下文协议/sdk -MCP-SDK
- @奥克托基特/休息 -GitHub API
- Tesseract.js -OCR
______________________________________________________________________
📞 支持
- GitHub 问题: https://github.com/ssh00n/quality-assurance-agent/issues
- 文档:参见
/docs目录 - 例子:参见
/samples目录
______________________________________________________________________
内置❤️ 使用TypeScript、Claude和Notion MCP
🤖 自动化快乐!
