edict README

The project's README from github.com/cft0808/edict. As one markdown file: README.md.

⚔️ 三省六部 · Edict

我用 1300 年前的帝国制度,重新设计了 AI 多 Agent 协作架构。
结果发现,古人比现代 AI 框架更懂分权制衡。

12 个 AI Agent(11 个业务角色 + 1 个兼容角色)组成三省六部:太子分拣、中书省规划、门下省审核封驳、尚书省派发、六部+吏部并行执行。
比 CrewAI 多一层制度性审核,比 AutoGen 多一个实时看板。

🎬 看 Demo · 🚀 30 秒体验 · 🏛️ 架构 · 📋 看板功能 · 📚 架构文档 · English · 日本語 · 参与贡献

OpenClaw Python Agents Dashboard License React Zero Backend Dependencies

WeChat


🎬 Demo

您的浏览器不支持视频播放,请查看下方 GIF 或 下载视频。
🎥 三省六部 AI 多 Agent 协作全流程演示

📸 GIF 预览(加载更快)

三省六部 Demo
飞书下旨 → 太子分拣 → 中书省规划 → 门下省审议 → 六部并行执行 → 奏折回报(30 秒)

🐳 没有 OpenClaw? 跑一行 docker run -p 7891:7891 cft0808/edict 即可体验完整看板 Demo(预置模拟数据)。


🤔 为什么是三省六部?

大多数 Multi-Agent 框架的套路是:

"来,你们几个 AI 自己聊,聊完把结果给我。"

然后你拿到一坨不知道经过了什么处理的结果,无法复现,无法审计,无法干预。

三省六部的思路完全不同 —— 我们用了一个在中国存在 1400 年的制度架构:

你 (皇上) → 太子 (分拣) → 中书省 (规划) → 门下省 (审议) → 尚书省 (派发) → 六部 (执行) → 回奏

这不是花哨的 metaphor,这是真正的分权制衡:

CrewAI MetaGPT AutoGen 三省六部
审核机制 ❌ 无 ⚠️ 可选 ⚠️ Human-in-loop ✅ 门下省专职审核 · 可封驳
实时看板 ❌ ❌ ❌ ✅ 军机处 Kanban + 时间线
任务干预 ❌ ❌ ❌ ✅ 叫停 / 取消 / 恢复
流转审计 ⚠️ ⚠️ ❌ ✅ 完整奏折存档
Agent 健康监控 ❌ ❌ ❌ ✅ 心跳 + 活跃度检测
热切换模型 ❌ ❌ ❌ ✅ 看板内一键切换 LLM
技能管理 ❌ ❌ ❌ ✅ 查看 / 添加 Skills
新闻聚合推送 ❌ ❌ ❌ ✅ 天下要闻 + 飞书推送
部署难度 中 高 中 低 · 一键安装 / Docker

核心差异:制度性审核 + 完全可观测 + 实时可干预

🔍 为什么「门下省审核」是杀手锏?(点击展开)

CrewAI 和 AutoGen 的 Agent 协作模式是 "做完就交"——没有人检查产出质量。就像一个公司没有 QA 部门,工程师写完代码直接上线。

三省六部的 门下省 专门干这件事:

  • 📋 审查方案质量 —— 中书省的规划是否完备?子任务拆解是否合理?
  • 🚫 封驳不合格的产出 —— 不是 warning,是直接打回重做
  • 🔄 强制返工循环 —— 直到方案达标才放行

这不是可选的插件——它是架构的一部分。每一个旨意都必须经过门下省,没有例外。

这就是为什么三省六部能处理复杂任务而结果可靠:因为在送到执行层之前,有一个强制的质量关卡。1300 年前唐太宗就想明白了——不受制约的权力必然会出错。


✨ 功能全景

🏛️ 十二部制 Agent 架构

📋 军机处看板(10 个功能面板)

📋 旨意看板 · Kanban

  • 按状态列展示全部任务
  • 省部过滤 + 全文搜索
  • 心跳徽章(🟢活跃 🟡停滞 🔴告警)
  • 任务详情 + 完整流转链
  • 叫停 / 取消 / 恢复操作

🔭 省部调度 · Monitor

  • 可视化各状态任务数量
  • 部门分布横向条形图
  • Agent 健康状态实时卡片

📜 奏折阁 · Memorials

  • 已完成旨意自动归档为奏折
  • 五阶段时间线:圣旨→中书→门下→六部→回奏
  • 一键复制为 Markdown
  • 按状态筛选

📜 旨库 · Template Library

  • 9 个预设圣旨模板
  • 分类筛选 · 参数表单 · 预估时间和费用
  • 预览旨意 → 一键下旨

👥 官员总览 · Officials

  • Token 消耗排行榜
  • 活跃度 · 完成数 · 会话统计

📰 天下要闻 · News

  • 每日自动采集科技/财经资讯
  • 分类订阅管理 + 飞书推送

⚙️ 模型配置 · Models

  • 每个 Agent 独立切换 LLM
  • 应用后自动重启 Gateway(~5秒生效)

🛠️ 技能配置 · Skills

  • 各省部已安装 Skills 一览
  • 查看详情 + 添加新技能

💬 小任务 · Sessions

  • OC-* 会话实时监控
  • 来源渠道 · 心跳 · 消息预览

🎬 上朝仪式 · Ceremony

  • 每日首次打开播放开场动画
  • 今日统计 · 3.5秒自动消失

🏛️ 朝堂议政 · Court Discussion

  • 多官员围绕议题展开部门视角讨论
  • LLM 驱动的多角色辩论(各部依职责发表专业意见)
  • 支持多轮推进 · 总结结论 · 保留讨论记录

🖼️ 截图

旨意看板

旨意看板

📸 展开查看更多截图

省部调度

省部调度

任务流转详情

任务流转详情

模型配置

模型配置

技能配置

技能配置

官员总览

官员总览

会话记录

会话记录

奏折归档

奏折归档

圣旨模板

圣旨模板

天下要闻

天下要闻

上朝仪式

上朝仪式


🚀 30 秒快速体验

Docker 一键启动

docker run -p 7891:7891 cft0808/sansheng-demo

打开 http://localhost:7891 即可体验军机处看板。

⚠️ 遇到 exec format error?(点击展开)

如果你在 x86/amd64 机器(如 Ubuntu、WSL2)上看到:

exec /usr/local/bin/python3: exec format error

这是因为镜像架构不匹配。请使用 --platform 参数:

docker run --platform linux/amd64 -p 7891:7891 cft0808/sansheng-demo

或使用 docker-compose(已内置 platform: linux/amd64):

docker compose up

完整安装

前置条件

安装

git clone https://github.com/cft0808/edict.git
cd edict
chmod +x install.sh && ./install.sh

安装脚本自动完成:

⚠️ 首次安装:需先配置 API Key:openclaw agents add taizi,然后重新运行 ./install.sh 同步到所有 Agent。

启动

# 方式 1:一键启动(推荐)
chmod +x start.sh && ./start.sh

# 方式 2:分别启动
bash scripts/run_loop.sh &      # 数据刷新循环
python3 dashboard/server.py     # 看板服务器

# 打开浏览器
open http://127.0.0.1:7891
🖥️ 生产环境部署(systemd)
# 安装 systemd 服务
sudo cp edict.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable edict
sudo systemctl start edict

# 或使用管理脚本
bash edict.sh start    # 启动
bash edict.sh status   # 查看状态
bash edict.sh restart  # 重启
bash edict.sh stop     # 停止

💡 看板即开即用:server.py 内嵌 dashboard/dashboard.html,Docker 镜像包含预构建的 React 前端

💡 详细教程请看 Getting Started 指南


🏛️ 架构

                           ┌───────────────────────────────────┐
                           │          👑 皇上(你)              │
                           │     Feishu · Telegram · Signal     │
                           └─────────────────┬─────────────────┘
                                             │ 下旨
                           ┌─────────────────▼─────────────────┐
                           │          � 太子 (taizi)            │
                           │    分拣:闲聊直接回 / 旨意建任务      │
                           └─────────────────┬─────────────────┘
                                             │ 传旨
                           ┌─────────────────▼─────────────────┐
                           │          📜 中书省 (zhongshu)       │
                           │       接旨 → 规划 → 拆解子任务       │
                           └─────────────────┬─────────────────┘
                                             │ 提交审核
                           ┌─────────────────▼─────────────────┐
                           │          🔍 门下省 (menxia)         │
                           │       审议方案 → 准奏 / 封驳 🚫      │
                           └─────────────────┬─────────────────┘
                                             │ 准奏 ✅
                           ┌─────────────────▼─────────────────┐
                           │          📮 尚书省 (shangshu)       │
                           │     派发任务 → 协调六部 → 汇总回奏    │
                           └───┬──────┬──────┬──────┬──────┬───┘
                               │      │      │      │      │
                         ┌─────▼┐ ┌───▼───┐ ┌▼─────┐ ┌───▼─┐ ┌▼─────┐
                         │💰 户部│ │📝 礼部│ │⚔️ 兵部│ │⚖️ 刑部│ │🔧 工部│
                         │ 数据  │ │ 文档  │ │ 工程  │ │ 合规  │ │ 基建  │
                         └──────┘ └──────┘ └──────┘ └─────┘ └──────┘
                                                               ┌──────┐
                                                               │📋 吏部│
                                                               │ 人事  │
                                                               └──────┘

各省部职责

部门 Agent ID 职责 擅长领域
� 太子 taizi 消息分拣、需求整理 闲聊识别、旨意提炼、标题概括
📜 中书省 zhongshu 接旨、规划、拆解 需求理解、任务分解、方案设计
🔍 门下省 menxia 审议、把关、封驳 质量评审、风险识别、标准把控
📮 尚书省 shangshu 派发、协调、汇总 任务调度、进度跟踪、结果整合
💰 户部 hubu 数据、资源、核算 数据处理、报表生成、成本分析
📝 礼部 libu 文档、规范、报告 技术文档、API 文档、规范制定
⚔️ 兵部 bingbu 代码、算法、巡检 功能开发、Bug 修复、代码审查
⚖️ 刑部 xingbu 安全、合规、审计 安全扫描、合规检查、红线管控
🔧 工部 gongbu CI/CD、部署、工具 Docker 配置、流水线、自动化
📋 吏部 libu_hr 人事、Agent 管理 Agent 注册、权限维护、培训
🌅 早朝官 zaochao 每日早朝、新闻聚合 定时播报、数据汇总

权限矩阵

不是想发就能发 —— 真正的分权制衡

From ↓ \ To → 太子 中书 门下 尚书 户 礼 兵 刑 工 吏
太子 — ✅
中书省 ✅ — ✅ ✅
门下省 ✅ — ✅
尚书省 ✅ ✅ — ✅ ✅ ✅ ✅ ✅ ✅
六部+吏部 ✅

任务状态流转

皇上 → 太子分拣 → 中书规划 → 门下审议 → 已派发 → 执行中 → 待审查 → ✅ 已完成
                      ↑          │                              │
                      └──── 封驳 ─┘                    阻塞 Blocked

⚡ 状态转换受保护:kanban_update.py 内置 _VALID_TRANSITIONS 状态机校验, 非法跳转(如 Doing→Taizi)会被拒绝并记录日志,确保流程不可绕过。

🔄 异步事件驱动:服务间通过 Redis Streams EventBus 解耦通信,Outbox Relay 保障事件可靠投递。 所有状态变更自动写入审计日志(audit.py),支持完整追溯。


📁 项目结构

edict/
├── agents/                     # 12 个 Agent 的人格模板
│   ├── taizi/SOUL.md           # 太子 · 消息分拣(含旨意标题规范)
│   ├── zhongshu/SOUL.md        # 中书省 · 规划中枢
│   ├── menxia/SOUL.md          # 门下省 · 审议把关
│   ├── shangshu/SOUL.md        # 尚书省 · 调度大脑
│   ├── hubu/SOUL.md            # 户部 · 数据资源
│   ├── libu/SOUL.md            # 礼部 · 文档规范
│   ├── bingbu/SOUL.md          # 兵部 · 工程实现
│   ├── xingbu/SOUL.md          # 刑部 · 合规审计
│   ├── gongbu/SOUL.md          # 工部 · 基础设施
│   ├── libu_hr/                # 吏部 · 人事管理
│   └── zaochao/SOUL.md         # 早朝官 · 情报枢纽
├── dashboard/
│   ├── dashboard.html          # 军机处看板(单文件 · 零依赖 · ~2500 行)
│   ├── dist/                   # React 前端构建产物(Docker 镜像内包含,本地可选)
│   ├── auth.py                 # Dashboard 登录鉴权
│   ├── court_discuss.py        # 朝堂议政(多官员 LLM 讨论引擎)
│   └── server.py               # API 服务器(Python 标准库 · 零依赖 · ~2300 行)
├── edict/backend/              # 异步后端服务(SQLAlchemy + Redis)
│   ├── app/models/
│   │   ├── task.py             # 任务模型 + 状态机
│   │   ├── audit.py            # 审计日志模型
│   │   └── outbox.py           # Outbox 消息模型
│   ├── app/services/
│   │   ├── event_bus.py        # Redis Streams EventBus
│   │   └── task_service.py     # 任务服务层
│   └── app/workers/
│       ├── dispatch_worker.py  # 并行调度 + 重试 + 资源锁
│       ├── orchestrator_worker.py  # DAG 编排器
│       └── outbox_relay.py     # 事务性 Outbox Relay
├── agents/
│   ├── <agent_id>/SOUL.md      # 各省部 Agent 人格模板
│   ├── GLOBAL.md               # 全局 Agent 配置
│   └── groups/                 # Agent 分组(sansheng / liubu)
├── scripts/
│   ├── run_loop.sh             # 数据刷新循环(每 15 秒)
│   ├── kanban_update.py        # 看板 CLI(含旨意数据清洗 + 标题校验 + 状态机)
│   ├── skill_manager.py        # Skill 管理工具(远程/本地 Skills 添加、更新、移除)
│   ├── agentrec_advisor.py     # Agent 模型推荐(功过簿 + 成本优化)
│   ├── linucb_router.py        # LinUCB 智能路由
│   ├── refresh_watcher.py      # 数据变更监听
│   ├── sync_from_openclaw_runtime.py
│   ├── sync_agent_config.py
│   ├── sync_officials_stats.py
│   ├── fetch_morning_news.py
│   ├── refresh_live_data.py
│   ├── apply_model_changes.py
│  

edict (cft0808/edict)

Searching Database…

17K ·GitHub
What is this?Edict is a multi-agent orchestration system for OpenClaw: 12 AI agents (11 business roles plus one compatibility agent) work as an ancient Chinese imperial bureaucracy — planning, review, dispatch and parallel execution — with a real-time dashboard and full audit trails.
Is it a framework I code against, or a finished system I just run?A finished system you operate rather than a library you import: the installer creates 12 OpenClaw agent workspaces with persona files, a Python backend (SQLAlchemy + Redis) tracks task state, and a built-in web dashboard is the main interface.
How do I get it running?Quickest look: docker run -p 7891:7891 cft0808/edict, then open port 7891 — the dashboard loads with mock demo data. For real use, install OpenClaw and run ./install.sh; a systemd setup is documented for production.
What do I need installed for the full (non-demo) setup?OpenClaw, Python 3.10+ and macOS or Linux. Node.js 18+ is optional — the installer builds the React frontend with it and simply skips the build if it is missing.
Any install pitfalls I should know about?On x86/amd64 hosts (Ubuntu, WSL2) the image may fail with exec format error — rerun with --platform linux/amd64 or use the bundled docker-compose, which sets the platform. The first install also needs an API key configured (openclaw agents add taizi) before re-running ./install.sh.
Do I need to already be an OpenClaw user?Yes for real deployment — agents are registered into openclaw.json and each gets its own workspace, skills and model. Only the Docker demo runs standalone, serving the dashboard on mock data.
Why model AI agents on a 1300-year-old Chinese bureaucracy?The author's argument: most multi-agent frameworks let agents chat freely and hand back results nobody can reproduce, audit or intervene in. The Tang dynasty system builds in separation of powers — a dedicated reviewer department (Menxia) that can formally reject substandard plans and force rework before anything is executed.
How does a task actually flow through the system?Taizi (the crown-prince agent) triages incoming messages and only real edicts become tasks. Zhongshu plans and splits them, Menxia reviews and can reject plans into a rework loop, Shangshu dispatches subtasks to the six ministries in parallel, and finished work is archived as a memorial with a five-stage timeline.
What can I control from the dashboard?Ten panels: a Kanban with stop/cancel/resume actions and heartbeat badges, an agent health monitor, archived memorials, 9 preset edict templates with estimated time and cost, a token-consumption leaderboard, per-agent LLM hot-swapping, skills management, live session previews, a news feed with Feishu push, and an LLM-driven court debate panel.
Can agents just message and override each other freely?No. A strict permission matrix defines exactly who may send messages to whom, and kanbanupdate.py enforces a state machine for task transitions — illegal jumps like Doing→Taizi are rejected and logged, with every state change written to an audit log for full traceability.
What are similar projects?paperclip, turnstone, goclaw, evenfire, hive, ALTA, NodePilot, AutoGPT
Creator
cft0808
Size
63.7 MB
Stars
17K
Updated
CommitMay 06
Age
7mo
Commits · 90 Days