diff --git a/README.md b/README.md index 41fdb75..15ab905 100644 --- a/README.md +++ b/README.md @@ -311,16 +311,36 @@ chmod +x install.sh && ./install.sh #### 启动 ```bash -# 终端 1:数据刷新循环 -bash scripts/run_loop.sh +# 方式 1:一键启动(推荐) +chmod +x start.sh && ./start.sh -# 终端 2:看板服务器 -python3 dashboard/server.py +# 方式 2:分别启动 +bash scripts/run_loop.sh & # 数据刷新循环 +python3 dashboard/server.py # 看板服务器 # 打开浏览器 open http://127.0.0.1:7891 ``` +
+🖥️ 生产环境部署(systemd) + +```bash +# 安装 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 指南](docs/getting-started.md) @@ -403,6 +423,9 @@ open http://127.0.0.1:7891 > ⚡ **状态转换受保护**:`kanban_update.py` 内置 `_VALID_TRANSITIONS` 状态机校验, > 非法跳转(如 Doing→Taizi)会被拒绝并记录日志,确保流程不可绕过。 +> +> 🔄 **异步事件驱动**:服务间通过 Redis Streams EventBus 解耦通信,Outbox Relay 保障事件可靠投递。 +> 所有状态变更自动写入审计日志(`audit.py`),支持完整追溯。 --- @@ -425,12 +448,32 @@ edict/ ├── 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/ +│ ├── /SOUL.md # 各省部 Agent 人格模板 +│ ├── GLOBAL.md # 全局 Agent 配置 +│ └── groups/ # Agent 分组(sansheng / liubu) ├── scripts/ │ ├── run_loop.sh # 数据刷新循环(每 15 秒) -│ ├── kanban_update.py # 看板 CLI(含旨意数据清洗 + 标题校验) +│ ├── 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 @@ -439,7 +482,8 @@ edict/ │ ├── apply_model_changes.py │ └── file_lock.py # 文件锁(防多 Agent 并发写入) ├── tests/ -│ └── test_e2e_kanban.py # 端到端测试(17 个断言) +│ ├── test_e2e_kanban.py # 端到端测试(17 个断言) +│ └── test_state_machine_consistency.py # 状态机一致性测试 ├── data/ # 运行时数据(gitignored) ├── docs/ │ ├── task-dispatch-architecture.md # 📚 详细架构文档:任务分发、流转、调度的完整设计(业务+技术) @@ -447,6 +491,9 @@ edict/ │ ├── wechat-article.md # 微信文章 │ └── screenshots/ # 功能截图(11 张) ├── install.sh # 一键安装脚本 +├── start.sh # 一键启动(Dashboard + 数据刷新) +├── edict.service # systemd 服务配置(生产部署) +├── edict.sh # 服务管理脚本(start/stop/restart/status) ├── CONTRIBUTING.md # 贡献指南 └── LICENSE # MIT License ``` @@ -560,9 +607,16 @@ curl http://localhost:7891/api/remote-skills-list |------|------| | **React 18 前端** | TypeScript + Vite + Zustand 状态管理,13 个功能组件 | | **纯 stdlib 后端** | `server.py` 基于 `http.server`,零依赖,同时提供 API + 静态文件服务 | +| **EventBus 事件总线** | Redis Streams 发布/订阅,服务间解耦通信 | +| **Outbox Relay** | 事务性 Outbox 模式,保障事件可靠投递(至少一次语义) | +| **状态机审计** | 严格生命周期状态转换 + 完整审计日志(`audit.py`) | +| **并行调度引擎** | Dispatch Worker 支持并行执行、指数退避重试、资源锁 | +| **DAG 编排器** | Orchestrator 基于 DAG 的任务分解与依赖解析 | | **Agent 思考可视** | 实时展示 Agent 的 thinking 过程、工具调用、返回结果 | -| **一键安装** | `install.sh` 自动完成全部配置 | +| **一键安装 / 一键启动** | `install.sh` 自动配置,`start.sh` 一条命令启动全部服务 | +| **systemd 生产部署** | `edict.service` 支持 systemd 守护进程,开机自启 | | **15 秒同步** | 数据自动刷新,看板倒计时显示 | +| **Dashboard 鉴权** | `auth.py` 提供看板登录认证 | | **每日仪式** | 首次打开播放上朝开场动画 | | **远程 Skills 生态** | 从 GitHub/URL 一键导入能力,支持版本管理 + CLI + API + UI | @@ -697,7 +751,14 @@ python3 scripts/skill_manager.py import-official-hub --agents zhongshu ### Phase 2 — 制度深化 🚧 - [ ] 御批模式(人工审批 + 一键准奏/封驳) -- [ ] 功过簿(Agent 绩效评分体系) +- [x] 功过簿(Agent 绩效评分 + 模型推荐 + 成本优化) +- [x] EventBus 事件总线(Redis Streams 解耦通信) +- [x] Outbox Relay(事务性事件投递) +- [x] 状态机审计(严格生命周期 + 审计日志) +- [x] 并行调度引擎(指数退避重试 + 资源锁) +- [x] DAG 编排器(任务分解 + 依赖解析) +- [x] Dashboard 鉴权(登录认证) +- [x] 一键启动 / systemd 生产部署 - [ ] 急递铺(Agent 间实时消息流可视化) - [ ] 国史馆(知识库检索 + 引用溯源) diff --git a/README_EN.md b/README_EN.md index 5754a44..28b5d3c 100644 --- a/README_EN.md +++ b/README_EN.md @@ -214,16 +214,36 @@ The installer automatically: ### Launch ```bash -# Terminal 1: Data sync loop (every 15s) -bash scripts/run_loop.sh +# Option 1: One-click launch (recommended) +chmod +x start.sh && ./start.sh -# Terminal 2: Dashboard server -python3 dashboard/server.py +# Option 2: Manual launch +bash scripts/run_loop.sh & # Data sync loop +python3 dashboard/server.py # Dashboard server # Open browser open http://127.0.0.1:7891 ``` +
+🖥️ Production deployment (systemd) + +```bash +# Install systemd service +sudo cp edict.service /etc/systemd/system/ +sudo systemctl daemon-reload +sudo systemctl enable edict +sudo systemctl start edict + +# Or use management script +bash edict.sh start # Start +bash edict.sh status # Check status +bash edict.sh restart # Restart +bash edict.sh stop # Stop +``` + +
+ > 📖 See [Getting Started Guide](docs/getting-started.md) for detailed walkthrough. --- @@ -318,15 +338,40 @@ edict/ ├── dashboard/ │ ├── dashboard.html # Dashboard (single file, zero deps, works out of the box) │ ├── dist/ # Pre-built React frontend (included in Docker image) +│ ├── auth.py # Dashboard login authentication +│ ├── court_discuss.py # Court discussion (multi-agent LLM debate engine) │ └── server.py # API server (stdlib, zero deps) +├── edict/backend/ # Async backend services (SQLAlchemy + Redis) +│ ├── app/models/ +│ │ ├── task.py # Task model + state machine +│ │ ├── audit.py # Audit log model +│ │ └── outbox.py # Outbox message model +│ ├── app/services/ +│ │ ├── event_bus.py # Redis Streams EventBus +│ │ └── task_service.py # Task service layer +│ └── app/workers/ +│ ├── dispatch_worker.py # Parallel dispatch + retry + resource lock +│ ├── orchestrator_worker.py # DAG orchestrator +│ └── outbox_relay.py # Transactional Outbox Relay +├── agents/ +│ ├── /SOUL.md # Agent personality templates +│ ├── GLOBAL.md # Global agent config +│ └── groups/ # Agent groups (sansheng / liubu) ├── scripts/ # Data sync & automation scripts -│ ├── kanban_update.py # Kanban CLI with data sanitization (~300 lines) -│ └── ... # fetch_morning_news, sync, screenshots, etc. -├── tests/ # E2E tests -│ └── test_e2e_kanban.py # Kanban sanitization tests (17 assertions) +│ ├── kanban_update.py # Kanban CLI with data sanitization + state machine +│ ├── agentrec_advisor.py # Agent model recommendation (merit + cost optimization) +│ ├── linucb_router.py # LinUCB smart routing +│ ├── refresh_watcher.py # Data change watcher +│ └── ... # fetch_morning_news, sync, etc. +├── tests/ +│ ├── test_e2e_kanban.py # Kanban sanitization tests (17 assertions) +│ └── test_state_machine_consistency.py # State machine consistency tests ├── data/ # Runtime data (gitignored) ├── docs/ # Documentation + screenshots ├── install.sh # One-click installer +├── start.sh # One-click launch (Dashboard + data sync) +├── edict.service # systemd service config (production deploy) +├── edict.sh # Service management (start/stop/restart/status) └── LICENSE # MIT ``` @@ -338,9 +383,16 @@ edict/ |---|---| | **React 18 Frontend** | TypeScript + Vite + Zustand, 13 components | | **stdlib Backend** | `server.py` on `http.server`, zero dependencies | +| **EventBus** | Redis Streams pub/sub for decoupled service communication | +| **Outbox Relay** | Transactional outbox pattern for reliable event delivery (at-least-once) | +| **State Machine Audit** | Strict lifecycle transitions + full audit logging (`audit.py`) | +| **Parallel Dispatch** | Dispatch Worker with parallel execution, exponential backoff retry, resource locking | +| **DAG Orchestrator** | Task decomposition and dependency resolution via DAG | | **Agent Thinking Visible** | Real-time display of agent thinking, tool calls, results | -| **One-click Install** | Workspace creation to Gateway restart | +| **One-click Install / Launch** | `install.sh` auto-configures, `start.sh` launches all services | +| **systemd Production Deploy** | `edict.service` for daemon process, auto-restart on boot | | **15s Auto-sync** | Live data refresh with countdown | +| **Dashboard Auth** | `auth.py` provides login authentication | | **Daily Ceremony** | Immersive opening animation | --- @@ -367,7 +419,14 @@ edict/ ### Phase 2 — Institutional Depth 🚧 - [ ] Imperial approval mode (human-in-the-loop) -- [ ] Merit/demerit ledger (agent scoring) +- [x] Merit/demerit ledger (agent scoring + model recommendation + cost optimization) +- [x] EventBus (Redis Streams decoupled communication) +- [x] Outbox Relay (transactional event delivery) +- [x] State machine audit (strict lifecycle + audit logging) +- [x] Parallel dispatch engine (exponential backoff retry + resource lock) +- [x] DAG orchestrator (task decomposition + dependency resolution) +- [x] Dashboard authentication (login auth) +- [x] One-click launch / systemd production deploy - [ ] Express courier (inter-agent message visualization) - [ ] Imperial Archives (knowledge base + citation) diff --git a/README_JA.md b/README_JA.md index 8fb02c9..5f41e90 100644 --- a/README_JA.md +++ b/README_JA.md @@ -214,16 +214,36 @@ chmod +x install.sh && ./install.sh ### 起動 ```bash -# ターミナル1:データ同期ループ(15秒間隔) -bash scripts/run_loop.sh +# 方法1:ワンクリック起動(推奨) +chmod +x start.sh && ./start.sh -# ターミナル2:ダッシュボードサーバー -python3 dashboard/server.py +# 方法2:手動起動 +bash scripts/run_loop.sh & # データ同期ループ +python3 dashboard/server.py # ダッシュボードサーバー # ブラウザを開く open http://127.0.0.1:7891 ``` +
+🖥️ 本番環境デプロイ(systemd) + +```bash +# 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 # 停止 +``` + +
+ > 📖 詳細なウォークスルーは[スタートガイド](docs/getting-started.md)をご覧ください。 --- @@ -318,15 +338,39 @@ edict/ ├── dashboard/ │ ├── dashboard.html # ダッシュボード(単一ファイル、依存関係ゼロ、すぐに使える) │ ├── dist/ # ビルド済みReactフロントエンド(Dockerイメージに含む) +│ ├── auth.py # ダッシュボードログイン認証 +│ ├── court_discuss.py # 朝堂議政(マルチエージェントLLM討論エンジン) │ └── server.py # APIサーバー(stdlib、依存関係ゼロ) +├── 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/ +│ ├── /SOUL.md # エージェントパーソナリティテンプレート +│ ├── GLOBAL.md # グローバルエージェント設定 +│ └── groups/ # エージェントグループ(sansheng / liubu) ├── scripts/ # データ同期&自動化スクリプト -│ ├── kanban_update.py # かんばんCLI(データサニタイズ付き、約300行) -│ └── ... # fetch_morning_news、sync、screenshotsなど -├── tests/ # E2Eテスト -│ └── test_e2e_kanban.py # かんばんサニタイズテスト(17アサーション) +│ ├── kanban_update.py # かんばんCLI(データサニタイズ + ステートマシン付き) +│ ├── agentrec_advisor.py # エージェントモデル推薦(功過簿 + コスト最適化) +│ ├── refresh_watcher.py # データ変更ウォッチャー +│ └── ... # fetch_morning_news、syncなど +├── tests/ +│ ├── test_e2e_kanban.py # かんばんサニタイズテスト(17アサーション) +│ └── test_state_machine_consistency.py # ステートマシン一貫性テスト ├── data/ # ランタイムデータ(gitignore対象) ├── docs/ # ドキュメント+スクリーンショット ├── install.sh # ワンクリックインストーラー +├── start.sh # ワンクリック起動(ダッシュボード + データ同期) +├── edict.service # systemdサービス設定(本番デプロイ) +├── edict.sh # サービス管理スクリプト(start/stop/restart/status) └── LICENSE # MIT ``` @@ -338,9 +382,16 @@ edict/ |---|---| | **React 18フロントエンド** | TypeScript + Vite + Zustand、13コンポーネント | | **stdlibバックエンド** | `server.py`(`http.server`ベース、依存関係ゼロ) | +| **EventBus** | Redis Streams Pub/Subによるサービス間疑結合通信 | +| **Outbox Relay** | トランザクショナルOutboxパターンによる信頼性の高いイベント配信(at-least-once) | +| **ステートマシン監査** | 厳格なライフサイクル状態遷移 + 完全な監査ログ(`audit.py`) | +| **並列ディスパッチ** | Dispatch Worker:並列実行、指数バックオフリトライ、リソースロック | +| **DAGオーケストレータ** | DAGベースのタスク分解と依存関係解決 | | **エージェント思考の可視化** | エージェントの思考、ツール呼び出し、結果をリアルタイム表示 | -| **ワンクリックインストール** | ワークスペース作成からGateway再起動まで | +| **ワンクリックインストール / 起動** | `install.sh`で自動設定、`start.sh`で全サービス起動 | +| **systemd本番デプロイ** | `edict.service`でデーモンプロセス、起動時自動開始 | | **15秒自動同期** | カウントダウン付きライブデータリフレッシュ | +| **ダッシュボード認証** | `auth.py`でログイン認証 | | **朝議セレモニー** | 没入型オープニングアニメーション | --- @@ -367,7 +418,14 @@ edict/ ### フェーズ2 — 制度的深化 🚧 - [ ] 御裁可モード(ヒューマン・イン・ザ・ループ) -- [ ] 功過簿(エージェントスコアリング) +- [x] 功過簿(エージェントスコアリング + モデル推薦 + コスト最適化) +- [x] EventBus(Redis Streams疑結合通信) +- [x] Outbox Relay(トランザクショナルイベント配信) +- [x] ステートマシン監査(厳格なライフサイクル + 監査ログ) +- [x] 並列ディスパッチエンジン(指数バックオフリトライ + リソースロック) +- [x] DAGオーケストレータ(タスク分解 + 依存関係解決) +- [x] ダッシュボード認証(ログイン認証) +- [x] ワンクリック起動 / systemd本番デプロイ - [ ] 急使(エージェント間メッセージ可視化) - [ ] 翰林院(ナレッジベース+引用)