# agent-craft **Repository Path**: mkwchecking/agent-craft ## Basic Information - **Project Name**: agent-craft - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: develop - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-02-26 - **Last Updated**: 2026-03-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # AutoCraft 基于 AgentScope 框架的自动项目交付系统,通过多 Agent 协作实现项目的自动化规划、执行和交付。 ## 特性 - **Plan + Handoffs 模式**: 项目经理 Agent 负责规划和协调,通过任务分发实现多 Agent 协作 - **动态工具注入**: Agent 的工具列表通过占位符动态注入,灵活可扩展 - **项目管理**: 每个项目独立的工作目录和记忆存储 - **多模型支持**: 支持 OpenAI、Anthropic、DashScope、Gemini、Ollama 等多种模型 ## 安装 ```bash # 克隆项目 git clone https://gitee.com/mkwchecking/agent-craft.git cd autocraft # 创建虚拟环境 python -m venv venv source venv/bin/activate # Linux/macOS # 或 venv\Scripts\activate # Windows # 安装依赖 pip install -r requirements.txt ``` ## 快速开始 ### 1. 配置 创建 `config/config.yaml` 文件: ```yaml workspace: root_dir: "./data" model: type: "anthropic" model: "glm-5" api_key: "your-api-key" base_url: "https://api.example.com" ``` ### 2. 运行 ```bash # 基本用法 python cmd/server.py -m "创建一个 Python Hello World 程序" # 完整参数 python cmd/server.py \ -m "需求描述" \ -n "任务名称" \ -c "./config/config.yaml" \ -p "项目ID" ``` ### 3. 命令行参数 | 参数 | 说明 | 必填 | | --------------- | ------------ | -------------------------------- | | `-m, --message` | 需求描述 | 是 | | `-n, --name` | 任务名称 | 否(默认: AutoCraft Task) | | `-c, --config` | 配置文件路径 | 否(默认: ./config/config.yaml) | | `-p, --project` | 项目 ID | 否(不指定则自动创建新项目) | ## 项目结构 ``` autocraft/ ├── __init__.py # 主入口 ├── _core.py # AutoCraft 核心类 ├── config/ # 配置模块 │ ├── __init__.py │ └── _config.py # 配置加载 ├── llm/ # LLM 模块 │ ├── __init__.py │ └── _factory.py # 模型工厂 ├── tools/ # 工具模块 │ ├── __init__.py │ ├── _registry.py # 工具注册表 │ └── builtin/ # 内置工具 │ ├── __init__.py │ └── _file_tools.py ├── agents/ # Agent 模块 │ ├── __init__.py │ ├── _base.py # BaseAgent 基类 │ └── builtin/ # 内置 Agent │ ├── __init__.py │ ├── project_manager.py │ ├── developer.py │ ├── tester.py │ ├── architect.py │ ├── code_reviewer.py │ ├── devops.py │ ├── data_analyst.py │ ├── technical_writer.py │ └── security.py ├── memory/ # 记忆模块 │ ├── __init__.py │ └── _factory.py ├── workspace/ # 工作区模块 │ ├── __init__.py │ └── _workspace.py └── task/ # 任务模块 ├── __init__.py ├── _scheduler.py └── prompts.py ``` ## 内置 Agent | Agent | 名称 | 职责 | | -------------------- | ---------------- | ------------------------ | | ProjectManagerAgent | project_manager | 项目规划、任务分解、协调 | | DeveloperAgent | developer | 代码编写、技术实现 | | TesterAgent | tester | 质量保证、测试 | | ArchitectAgent | architect | 架构设计、技术决策 | | CodeReviewerAgent | code_reviewer | 代码审查 | | DevOpsAgent | devops | 运维部署 | | DataAnalystAgent | data_analyst | 数据分析 | | TechnicalWriterAgent | technical_writer | 技术文档 | | SecurityAgent | security | 安全审计 | ## 工作流程 ``` 用户输入 → ProjectManager Agent ↓ create_plan (创建计划) ↓ dispatch_task (分发任务给其他 Agent) ↓ finish_subtask / finish_plan (跟踪进度) ↓ 返回结果 ``` ## 项目目录结构 ``` data/ ├── projects/ │ └── {project_id}/ │ ├── config.json # 项目配置 │ ├── workspace/ # 项目工作目录 │ │ ├── *.py # 生成的代码文件 │ │ └── *.md # 文档文件 │ └── memory/ # Agent 记忆存储 │ ├── developer_memory.db │ └── tester_memory.db └── global_memory/ └── global_memory.db ``` ## 扩展 ### 添加自定义 Agent 在 `autocraft/agents/builtin/` 目录下创建新文件: ```python from .._base import BaseAgent class MyCustomAgent(BaseAgent): NAME = "custom_agent" SYS_PROMPT = """你的系统提示词 你可以使用以下工具: {{AVAILABLE_TOOLS}}""" DESCRIPTION = "Agent 描述" ``` 然后在 `__init__.py` 中导入,并在 `_core.py` 中注册。 ### 添加自定义工具 ```python from autocraft import register_tool from agentscope.tool import ToolResponse from agentscope.message import TextBlock @register_tool def my_custom_tool(param: str) -> ToolResponse: """工具描述 Args: param (str): 参数描述 """ return ToolResponse( content=[TextBlock(type="text", text="结果")] ) ``` ### 添加新的模型类型 ```python from autocraft.llm import register_model_type register_model_type( model_type="my_model", model_class=MyModelClass, formatter_class=MyFormatterClass, ) ``` ## API 使用 ```python from autocraft import AutoCraft # 初始化 app = AutoCraft.initialize('./config/config.yaml') # 创建项目 project = app.create_project("my-project", "项目描述") # 运行任务 result = await app.run( name="任务名称", description="任务描述", user_input="用户需求", project=project, ) # 查看结果 print(result["plan"]) # 计划详情 print(result["results"]) # 各任务执行结果 ``` ## 依赖 - agentscope: Agent 框架 - pyyaml: YAML 配置解析 - sqlalchemy: 数据库 ORM - aiosqlite: 异步 SQLite ## 许可证 MIT License