项目结构
受众: 开发者、贡献者
前提: 已完成开发环境搭建
目标: 理解 CocoCat 仓库的目录组织方式
顶层目录
CocoCat/
├── cococat/ Python 主包
│ ├── __main__.py 入口点 (uvicorn)
│ ├── app.py FastAPI 应用工厂
│ ├── auth.py 认证中间件 (JWT + API Key)
│ ├── context.py AppContext 依赖注入
│ ├── config_store.py 集中化配置管理 (auth, env, defaults, channels...)
│ ├── prompt.py 系统提示词构建
│ ├── profile.py Agent 身份加载
│ ├── skills.py 技能加载
│ ├── worker.py 后台任务 Worker
│ ├── channel_types.py 频道类型定义 (兼容导出)
│ │
│ ├── core/ 核心引擎
│ │ ├── agent.py Agent 类 (ReAct 循环)
│ │ ├── agent_pool.py Agent 池管理
│ │ ├── bootstrap.py 启动装配
│ │ ├── channel_manager.py 频道生命周期管理 (connect/disconnect/auto-reconnect)
│ │ ├── event_bus.py 事件总线
│ │ ├── session.py 会话管理 (JSONL) + auto-dream 触发
│ │ ├── sub_agent.py 子代理执行器
│ │ ├── scene_keeper.py 场景路由器
│ │ ├── scheduler.py 定时调度
│ │ ├── cron_worker.py Cron 任务 Worker
│ │ ├── dag_store.py DAG 持久化
│ │ ├── sandbox_path.py 路径沙箱
│ │ ├── sandbox/ 沙箱执行环境
│ │ ├── channels/ 频道适配器 (微信/飞书/Discord/Telegram)
│ │ └── tools/ 26 个 Agent 工具 (ToolCatalog 统一装配)
│ │
│ ├── db/ 数据库层
│ │ ├── database.py SQLite 连接 + 迁移
│ │ ├── agent_store.py Agent 存储
│ │ ├── task_store.py 任务存储
│ │ ├── scene_store.py 场景存储
│ │ ├── message_store.py 消息存储
│ │ ├── fact_store.py 事实存储
│ │ ├── todo_store.py 待办存储
│ │ └── dag_run_store.py DAG 运行存储
│ │
│ ├── providers/ LLM 提供商 (30+)
│ ├── routes/ FastAPI 路由
│ ├── memory/ 记忆系统
│ ├── ingest/ 知识库摄入管道
│ ├── kb/ 知识库工具
│ ├── scene/ 场景配置
│ └── tests/ 内部测试
│
├── web-ui/ React 前端
├── agents/ Agent 运行时数据
├── scenes/ 场景定义
├── skills/ 技能定义
├── knowledge/ 知识库
├── config/ 配置文件
├── docs/ 文档
├── tests/ 集成测试
├── tools/ 工具脚本
├── pyproject.toml 项目配置
└── .env.example 环境变量模板数据流
用户 → 频道 (微信/飞书/Web) → FastAPI → Agent Pool
│
├── LLM 调用 (30+ 提供商)
├── 工具执行 (26 个工具)
├── 沙箱 (本地/CubeSandbox)
└── 记忆读写 (FTS5 + 文件)