基于trae-agent的微服务架构设计AI Agent
| Files | Last commit | Last update |
|---|---|---|
| 1 month ago | ||
| 1 month ago | ||
| 1 month ago | ||
| 1 month ago | ||
| 1 month ago | ||
| 1 month ago | ||
| 1 month ago |
🚀 Trae Agent Microservice
基于 trae-agent 的微服务架构设计专用 AI Agent
⭐ 支持这个项目,给个 Star 让更多人发现它!
📦 国内下载推荐使用 Gitee ⬇️
👉 立即克隆 |
📥 下载 ZIP
📌 快速导航
✨ 项目特点
🎯 专为架构师设计
- 🏗️ 架构设计 - 微服务拆分、技术选型、架构图生成
- 💻 代码生成 - Rust/Go/Java 微服务脚手架
- 🔍 智能分析 - 依赖分析、性能诊断、安全检查
🔧 技术栈全覆盖
- 语言: Rust, Go, Java, TypeScript, Python
- 中间件: Kafka, Redis, PostgreSQL, MongoDB
- 容器化: Docker, Kubernetes, Helm
- Service Mesh: Istio, Linkerd
- 云服务: AWS, Azure, 阿里云, 腾讯云
🤖 支持多种 LLM
- OpenAI (GPT-4, GPT-3.5)
- Anthropic (Claude 3/3.5)
- 豆包 (Doubao)
- Google (Gemini)
- 本地模型 (Ollama)
🚀 快速开始
前置条件
- ✅ Python 3.10+
- ✅ Git
- ✅ LLM API Key(支持多种模型提供商)
安装步骤
# 方式一:从 Gitee 克隆(推荐国内)
git clone https://gitee.com/Archive_Tom/trae-agent-microservice.git
cd trae-agent-microservice
# 方式二:从 GitHub 克隆
git clone https://github.com/stitchOvO/trae-agent-microservice.git
cd trae-agent-microservice
# 安装依赖(使用 uv,推荐)
uv venv
uv sync
# 或使用 pip
pip install -e .
配置 API Key
# 方式一:环境变量(推荐)
export OPENAI_API_KEY="your-api-key"
export ANTHROPIC_API_KEY="your-api-key"
export DOUBAO_API_KEY="your-api-key"
# 方式二:配置文件
cp configs/trae_config.yaml.example configs/trae_config.yaml
# 编辑配置文件,填入你的 API Key
运行示例
# 单次任务
trae-microservice run "设计一个高可用的电商系统微服务架构"
# 交互式模式
trae-microservice interactive
# 指定模型和提供商
trae-microservice run "优化用户服务性能" \
--provider doubao \
--model doubao-seed-1.6
📂 项目结构
trae-agent-microservice/
├── pyproject.toml # 项目配置
├── README.md # 项目说明
├── LICENSE # MIT 许可证
├── SECURITY.md # 安全说明
├── .gitignore
├── .env.example # 环境变量示例
│
├── src/ # 源代码
│ ├── __init__.py
│ ├── cli.py # CLI 入口
│ ├── agent.py # Agent 核心
│ ├── config.py # 配置管理
│ │
│ ├── tools/ # 自定义工具
│ │ ├── __init__.py
│ │ ├── architecture.py # 架构分析
│ │ ├── generator.py # 代码生成
│ │ └── analyzer.py # 系统分析
│ │
│ └── prompts/ # Prompt 模板
│ ├── architecture_design.md
│ ├── service_split.md
│ └── performance_optimization.md
│
├── configs/ # 配置文件
│ ├── trae_config.yaml.example
│ └── tools_config.yaml
│
├── examples/ # 使用示例
│ ├── basic_usage.py
│ └── custom_tools.py
│
├── tests/ # 测试
│ ├── test_agent.py
│ └── test_tools.py
│
└── docs/ # 文档
├── architecture.md
└── customization.md
📖 使用指南
Python API
from src.agent import MicroserviceAgent
# 创建 Agent
agent = MicroserviceAgent(
provider="doubao",
model="doubao-seed-1.6",
api_key="your-api-key"
)
# 执行架构设计任务
result = agent.run("设计一个订单服务的微服务架构")
print(result)
架构设计示例
task = """
设计一个外卖平台的核心微服务架构,要求:
1. 支持千万级用户
2. 订单 QPS 10000+
3. 平均延迟 < 100ms
4. 可用性 99.99%
"""
result = agent.run(task)
# 结果包含:
# - 系统架构图(Mermaid)
# - 服务列表和职责
# - 技术栈推荐及理由
# - 部署方案
# - 风险评估
代码生成示例
task = """
为用户服务生成 Rust 微服务代码,要求:
1. 使用 actix-web 框架
2. PostgreSQL 作为数据库
3. 包含健康检查端点
4. Prometheus 监控指标
"""
result = agent.run(task)
# 返回完整的项目代码
🛠️ 自定义工具
架构分析工具
from src.tools.architecture import ArchitectureAnalyzer
analyzer = ArchitectureAnalyzer()
# 分析依赖关系
deps = analyzer.analyze_dependencies("path/to/service")
# 生成架构图
diagram = analyzer.generate_diagram(
services=["user", "order", "payment"],
format="mermaid"
)
# 评估复杂度
complexity = analyzer.assess_complexity("path/to/project")
代码生成工具
from src.tools.generator import CodeGenerator
generator = CodeGenerator()
# 生成服务代码
code = generator.generate_service(
name="user-service",
language="rust",
framework="actix-web",
database="postgresql"
)
# 生成 Kubernetes 配置
k8s_config = generator.generate_kubernetes_config(
service_name="user-service",
replicas=3,
resources={"cpu": "500m", "memory": "256Mi"}
)
系统分析工具
from src.tools.analyzer import SystemAnalyzer
analyzer = SystemAnalyzer()
# 性能分析
performance = analyzer.analyze_performance("path/to/logs")
# 成本估算
cost = analyzer.estimate_cost(
services=7,
qps=10000,
region="cn-beijing"
)
# 安全检查
security = analyzer.security_audit("path/to/config")
⚙️ 配置说明
trae_config.yaml
# 模型配置
model:
provider: "doubao" # 提供商: openai/anthropic/doubao
model_name: "doubao-seed-1.6"
api_key: "${DOUBAO_API_KEY}"
base_url: "https://ark.cn-beijing.volces.com/api/v3"
# Agent 配置
agent:
max_steps: 50
temperature: 0.7
top_p: 0.9
# 工具配置
tools:
enabled:
- architecture_analyzer
- code_generator
- system_analyzer
custom_tools_path: "src/tools"
# Prompt 配置
prompts:
default: "src/prompts/architecture_design.md"
templates_path: "src/prompts"
# 输出配置
output:
format: "markdown"
save_path: "./output"
language: "zh-CN"
❓ 常见问题
Q1: 与原版 trae-agent 有什么区别?
本项目是基于 trae-agent 的二次开发:
✅ 保留 trae-agent 核心能力(MIT 协议)
✅ 添加微服务架构专用工具
✅ 架构设计专用 Prompt
✅ 针对架构师优化的默认配置
Q2: 支持哪些 LLM 提供商?
- OpenAI (GPT-4, GPT-3.5)
- Anthropic (Claude 3/3.5)
- 豆包 (Doubao)
- Google (Gemini)
- OpenRouter
- 本地模型 (Ollama)
Q3: 如何添加自定义工具?
1. 在
src/tools/ 下创建新工具类2. 继承 BaseTool,实现 run() 方法
3. 在
__init__.py 中导出4. 在配置文件中启用
Q4: 可以商用吗?
✅ 可以!本项目基于 MIT 协议,允许商用。
注意:trae-agent 本身也是 MIT 协议。
🤝 贡献
欢迎各种形式的贡献!
贡献流程
- 🍴 Fork 本仓库
- 🌿 创建特性分支
git checkout -b feature/amazing-feature - ✍️ 提交更改
git commit -m "feat: 添加新功能" - 📤 推送分支
git push origin feature/amazing-feature - 🎉 创建 Pull Request
贡献方向
- 🐛 Bug 修复
- ✨ 新工具开发
- 📝 文档优化
- 🧪 测试覆盖
- 🚀 性能优化
📄 许可证与知识产权
开源许可证
本项目基于 MIT License 开源。
MIT License
Copyright (c) 2026 Archive_Tom
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
🔗 第三方依赖
| 项目 | 许可证 | 说明 |
|---|---|---|
| trae-agent | MIT | 核心框架 |
| Python | PSF | 编程语言 |
🛡️ 知识产权声明
© 2026 Archive_Tom. All Rights Reserved.
本项目包含:
- 原始代码(MIT 协议)
- 二次开发的工具和 Prompt(MIT 协议)
- 项目设计文档(保留所有权)
使用要求:
✅ 允许商业使用
✅ 允许修改和分发
⚠️ 保留版权声明
⚠️ 注明项目来源
� 开发路线图
即将推出
进行中
已完成
�💝 支持与赞助
如果这个项目对你有帮助,欢迎:
-
⭐ Star 我们的项目
-
🍴 Fork 并参与开发
-
📢 分享 给你的同事和朋友
-
🐛 报告 Bug 或提出新功能
📈 项目数据
📊 仓库统计:
🔗 相关项目
| 项目 | 描述 | Gitee | GitHub |
|---|---|---|---|
| Skill 版本 | 轻量级 Skill | 链接 | 链接 |
| trae-agent 版本 | 完整 Python Agent | 🔗 本项目 | 链接 |
| OpenAgent 版本 | 标准 YAML | 链接 | 链接 |
📞 联系方式
- 🐙 Gitee: @Archive_Tom
- 🐱 GitHub: @stitchOvO
- 💬 Issues: 欢迎反馈问题和建议
- 📧 讨论: 在 Gitee/GitHub Discussions 交流
🙏 致谢
感谢以下项目的支持:
- trae-agent - 核心框架
- Trae IDE - AI 开发环境
- Gitee - 优秀的国内代码平台
Built with ❤️ by Archive_Tom
Happy Coding! 🚀