Skip to content

Repository files navigation

Capricorn-V

v0.2.2 | 自进化 Agent Runtime — Agent Teams + 角色化 Cron + 垂直领域一键扩展

轻量级 Agent Runtime:原生 FC 循环 + Agent Teams 多角色协作 + 自进化质量纠偏。


核心特性

  • 原生 FC 循环 — LLM → tool_calls → execute → repeat,无 ReAct / 无状态机
  • Agent Teams — Executor / Verifier 对抗协作,spawn 异步派发,文件交接
  • 角色化 Cron — cron 支持 role 参数(executor / verifier),身份模板 + 工具白名单 + 任务指令三层分离
  • 自进化机制 — verifier cron 自动检测质量问题 → bia_update / skill 编辑 → changelog 可追溯回滚
  • 垂直领域一键加载 — tools / MCP / skills / workflows / roles 按 vertical_hub 组织
  • 三层记忆系统 — JSONL 会话 + MEMORY.md 长期记忆 + HISTORY.md 历史摘要
  • Gateway HTTP API — aiohttp 轻量服务,SSE 实时推送
  • MCP 协议支持 — stdio / SSE / streamable_http 接入外部服务

架构总览

用户 ↔ Capricorn(决策中枢)
         │
         ├── spawn(role=executor)   → 异步执行任务
         ├── spawn(role=verifier)   → 独立验收产出
         ├── cron(role=executor)    → 持续批量执行
         └── cron(role=verifier)    → 定期质量验证 + 自进化纠偏

三层分离

定义位置 决定什么
身份 prompts/roles/executor.md WHO — 角色行为准则
权限 roles/executor.yaml tools 字段 WHAT — 可用工具白名单
指令 cron 的 prompt 参数 / spawn 的 brief.md HOW — 具体做什么

安装

git clone https://github.com/calderx4/Capricorn-V.git
cd Capricorn-V
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
# 编辑 .env 填入 API Key

快速开始

python run.py                                  # CLI 交互
python run.py --mode gateway                   # HTTP API + Cron
python run.py --mode gateway_with_webui        # HTTP API + Cron + Web 前端

工具清单

基础工具(所有垂类共享)

工具 文件 说明
read_file file_tools.py 读取文件内容
write_file file_tools.py 写入文件
edit_file file_tools.py 编辑文件(diff)
list_files file_tools.py 列出目录文件
exec exec_tools.py 执行 shell 命令
todo todo_tools.py 任务规划与追踪
cron cron_tools.py 定时任务(支持 role 参数)
skill_view skill_tool.py 按需加载技能说明
memory_update memory_tools.py 更新长期记忆
history_search memory_tools.py 搜索历史摘要
bia_update bia_tools.py 行为修正规则

Agent Teams 工具

工具 文件 说明
task team_tools.py 任务 CRUD(create/list/get/update)
spawn team_tools.py 派发子 Agent(role=executor/verifier)
check_status team_tools.py 查询任务状态
get_result team_tools.py 获取任务结果

质量 & 自进化工具

工具 文件 说明
quality_check quality_tools.py 按维度检查产出质量
quality_signal quality_tools.py 记录/查询质量信号
changelog changelog_tools.py 变更日志(可追溯、可回滚)

技能 & 工作流

技能 说明
self-evolution 自进化 — verifier cron 自动纠偏(bia / skill / workflow)
quality-check 质量检查 — 4 维度验收(structure / numbers / comparison / anomaly)
team-orchestration 团队编排 — spawn 使用指南和执行模式
project-guide 项目引导 — 三阶段循环(bootstrap → autonomous → intervention)

MCP 服务

服务器 说明
minimax MiniMax 多模态 MCP(联网搜索、图片/视频/语音/音乐生成)

项目结构

Capricorn-V/
├── run.py                      # 启动入口(3 种模式)
├── config/
│   ├── config.json             # 运行配置
│   └── settings.py             # Pydantic 配置模型
├── agent/
│   ├── executor.py             # CapricornAgent 工厂类
│   ├── agent.py                # CapricornGraph(FC 循环 + Agent Teams)
│   ├── scheduler.py            # CronScheduler(角色化 + 记忆隔离)
│   ├── gateway.py              # HTTP API 服务
│   └── notification.py         # 通知总线
├── capabilities/
│   ├── capability_registry.py  # 能力注册中心
│   ├── vertical_loader.py      # 垂类加载器
│   └── skills/manager.py       # 技能管理器
├── core/
│   ├── base_tool.py            # BaseTool 抽象基类
│   └── base_workflow.py        # BaseWorkflow 抽象基类
├── memory/
│   ├── session.py              # SessionManager(JSONL 会话)
│   ├── long_term.py            # LongTermMemory(MEMORY.md)
│   └── history.py              # HistoryLog(HISTORY.md)
├── vertical_hub/               # 垂类能力中心
│   ├── manifest.yaml           # 全局注册表
│   ├── default/                # 通用模版(用于创建新垂类)
│   │   ├── vertical.yaml
│   │   ├── roles/              # executor.yaml / verifier.yaml
│   │   ├── tools/              # 基础工具
│   │   ├── skills/             # self-evolution / project-guide
│   │   └── prompts/            # system.md / cron.md / bia.md / roles/
│   └── data-analysis/          # 数据分析垂类(首个独立垂类)
│       ├── vertical.yaml
│       ├── team.yaml           # Agent Teams 配置
│       ├── roles/              # executor.yaml / verifier.yaml
│       ├── tools/              # 领域工具(含 team_tools.py)
│       ├── skills/             # quality-check / team-orchestration / ...
│       └── prompts/            # bia.md(verifier 维护)
├── tests/                      # 测试(267 tests, all passing)
│   ├── test_team_cron/         # Agent Teams + Cron 测试
│   └── ...
├── workspace/                  # 运行时工作区
│   ├── main/<project>/         # 项目文件 + 报告
│   └── team/                   # Agent Teams 协作空间
│       ├── tasks/              # spawn 任务
│       ├── quality_signals/    # 质量信号
│       └── changelog/          # 变更日志
└── docs/
    ├── package/capricorn/      # 架构文档 + changelog
    ├── agent-teams&cron/       # Agent Teams 设计文档
    └── vertical-tips/          # 垂类实战复盘

Gateway HTTP API

端点 方法 说明
/chat POST 对话(支持 thread_id 多会话)
/task POST 异步任务
/task/{id} GET 查询任务状态
/jobs GET 列出 Cron 任务
/events GET SSE 实时推送
/notifications GET 查询通知
/notifications/read POST 标记已读
/health GET 健康检查

配置

添加新垂类

  1. cp -r vertical_hub/default vertical_hub/<name>
  2. 编辑 vertical.yaml,改 namedescription
  3. 定制领域内容(quality_tools.py 检查维度、skill 领域示例、roles 工具白名单)
  4. 注册到 manifest.yaml,配置 config.json

加工具

在垂类 tools/ 下新建 .py,继承 BaseTool

from typing import Any, Dict
from core.base_tool import BaseTool

class MyTool(BaseTool):
    @property
    def name(self) -> str:
        return "my_tool"

    @property
    def description(self) -> str:
        return "工具描述"

    @property
    def parameters(self) -> Dict[str, Any]:
        return {"type": "object", "properties": {...}, "required": [...]}

    async def execute(self, **kwargs: Any) -> Any:
        return result

加角色

  1. 创建 roles/<role>.yaml(定义 name / prompt 模板 / tools 白名单)
  2. 创建 prompts/roles/<role>.md(定义身份和行为准则,不写死路径)
  3. cron 或 spawn 时传 role: "<role>" 即可激活

配置

环境变量使用 ${VAR_NAME} 格式注入:

{
  "llm": {
    "provider": "openai",
    "model": "MiniMax-M2.7",
    "api_key": "${MINIMAX_API_KEY}",
    "api_base": "https://api.minimaxi.com/v1"
  },
  "workspace": {
    "sandbox": true
  },
  "verticals": ["data-analysis"]
}

日志

日志位于 gateway/logs/ 目录:

  • trace.log — 全量日志
  • cron.log — Cron 相关

原生 FC · Agent Teams · 自进化 · 垂直能力一键扩展

About

基于 Capricorn 的垂直领域扩展版:轻量级 Agent Runtime,垂直能力配置即用,tools / skills / workflows 一键扩展。

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages