Co-creation-projects/yangyousan123-CodePlanAgent/README.md
基于HelloAgents框架的智能代码计划工具
一个基于HelloAgents框架的智能代码计划工具 CodePlanAgent ,具备Reflection反思功能。
flowchart TD
subgraph 用户层[用户层]
User[用户需求输入]
end
subgraph 核心智能体[CodePlanAgent]
direction TB
PlanGenerator[代码计划生成器\nCode Plan Generator]
Reflector[反思评估器\nReflection Evaluator]
Refiner[计划优化器\nPlan Refiner]
Memory[计划记忆模块\nPlanMemory]
PlanGenerator -->|生成计划| Memory
Reflector -->|反思记录| Memory
Memory -->|读取历史| Reflector
Refiner -->|优化记录| Memory
Memory -->|读取历史| Refiner
end
subgraph 反思维度[反思维度]
Completeness[完整性]
Feasibility[可行性]
Architecture[架构合理性]
Maintainability[可维护性]
Performance[性能考虑]
Security[安全性]
Testing[测试覆盖]
end
subgraph HelloAgents框架[HelloAgents框架]
AgentBase[Agent基类]
LLM[HelloAgentsLLM]
Config[Config配置]
Message[Message消息]
ToolRegistry[ToolRegistry工具注册]
end
subgraph 输出格式[输出格式]
Project[项目概述]
TechStack[技术栈]
Directory[目录结构]
Steps[实现步骤]
Design[关键设计]
Notes[注意事项]
end
User --> PlanGenerator
PlanGenerator -->|调用| LLM
Reflector -->|调用| LLM
Refiner -->|调用| LLM
Reflector --> Completeness
Reflector --> Feasibility
Reflector --> Architecture
Reflector --> Maintainability
Reflector --> Performance
Reflector --> Security
Reflector --> Testing
PlanGenerator --> Project
PlanGenerator --> TechStack
PlanGenerator --> Directory
PlanGenerator --> Steps
PlanGenerator --> Design
PlanGenerator --> Notes
CodePlanAgent -.->|继承| AgentBase
CodePlanAgent -->|使用| Config
CodePlanAgent -->|使用| Message
CodePlanAgent -->|可选| ToolRegistry
style User fill:#E3F2FD,stroke:#1976D2,stroke-width:2px
style CodePlanAgent fill:#E8F5E9,stroke:#388E3C,stroke-width:2px
style HelloAgents框架 fill:#FFF3E0,stroke:#F57C00,stroke-width:2px
style 反思维度 fill:#FCE4EC,stroke:#C2185B,stroke-width:2px
style 输出格式 fill:#F3E5F5,stroke:#7B1FA2,stroke-width:2px
核心功能:
反思维度:
输出格式:
## 项目概述
[项目目标和核心功能]
## 技术栈
- 语言、框架、数据库等
## 目录结构
[项目目录结构]
## 实现步骤
1. [步骤描述]
- 实现要点
- 文件路径
- 预期输出
...
## 关键设计
## 注意事项
演示如何使用CodePlanAgent生成代码计划,包含两个示例:
包含常用LLM服务的配置模板(OpenAI、DeepSeek、Qwen、Kimi、Zhipu、Ollama)
from hello_agents.core.llm import HelloAgentsLLM
from code_plan_agent import create_code_plan_agent
# 初始化LLM
llm = HelloAgentsLLM(
model="your-model",
api_key="your-api-key",
base_url="https://api.example.com/v1"
)
# 创建CodePlanAgent
agent = create_code_plan_agent(llm)
# 生成代码计划
requirements = """创建一个待办事项应用..."""
plan = agent.run(requirements)
print(plan)
安装依赖
pip install -r requirements.txt
复制 .env.example 为 .env
配置LLM环境变量
运行 demo.py 查看效果
│ .env.example
│ code_plan_agent.py
│ demo.py
│ README.md
│ requirements.txt
│
├─memory
│ └─traces
│ trace-s-20260604-154913-a988.html
│ trace-s-20260604-154913-a988.jsonl
│
└─outputs
todo_app_plan.md
## 项目概述
本项目旨在构建一个**高内聚、低耦合**的 Python Flask 待办事项(Todo)管理 API。基于评审反馈,我们修正了架构描述与实际目录的一致性,...
## 技术栈
- 语言:Python 3.9+
- 框架:Flask (Web 框架)
- 数据库:SQLite (开发/测试), PostgreSQL (生产推荐)
- ...
## 目录结构
(略)
## 实现步骤
1. **项目初始化与安全配置**
- 实现要点:创建虚拟环境;安装依赖...
- 文件路径:`requirements.txt`, `config.py`, `.env.example`
- 预期输出:基础工程结构搭建完成,启动时自动加载安全配置,...
2. ...
## 关键设计
- **架构一致性 (Controller-Service-Model)**:修正了原计划中提及“Repository”但无对应目录的问题。Service 层直接封装 ORM 操作,...
## 注意事项
- **架构复杂度权衡**:本计划采用了企业级实践(Pydantic, Alembic, 分层),对于“简单 Todo"需求属于适度超前。若项目周期极短,...
感谢Datawhale社区和Hello-Agents项目!
本项目采用MIT许可证。