feat: implement Phase 4 - Multi-Agent Swarm + Skill Discovery

Phase 4a: Agent Swarm Collaboration Framework (agent-swarm.ts)
- AgentSwarm class with configurable coordinator + specialist agents
- Three collaboration modes: Sequential (chain), Parallel (concurrent), Debate (multi-round)
- Auto task decomposition based on specialist capabilities
- Debate consensus detection with keyword similarity heuristic
- Rule-based result aggregation with structured markdown output
- Specialist management (add/update/remove) and config updates
- History persistence to localStorage (last 25 tasks)
- Memory integration: saves task completion as lesson memories

Phase 4b: Skill Discovery Engine (skill-discovery.ts)
- SkillDiscoveryEngine with 12 built-in skill definitions from skills/ directory
- Multi-signal search: name, description, triggers, capabilities, category matching
- Conversation-based skill recommendation via topic extraction (CN + EN patterns)
- Memory-augmented confidence scoring for suggestions
- Skill registration, install status toggle, category filtering
- localStorage persistence for skill index and suggestion cache

Phase 4c: chatStore Integration
- dispatchSwarmTask(description, style): creates and executes swarm task, adds result as message
- searchSkills(query): exposes skill search to UI layer

Tests: 317 passing across 13 test files (43 new for swarm + skills)
- AgentSwarm: createTask, sequential/parallel/debate execution, history, specialist mgmt
- SkillDiscovery: search, suggest, register, persist, categories

Refs: ZCLAW_AGENT_INTELLIGENCE_EVOLUTION.md updated - all 4 phases complete
This commit is contained in:
iven
2026-03-15 22:44:18 +08:00
parent 04ddf94123
commit 137f1a32fa
5 changed files with 1555 additions and 7 deletions

View File

@@ -13,8 +13,8 @@
| **Phase 1: 持久记忆 + 身份演化** | ✅ 已完成 | `agent-memory.ts`, `agent-identity.ts`, `memory-extractor.ts`, `MemoryPanel.tsx` | 42 tests |
| **Phase 2: 上下文压缩** | ✅ 已完成 | `context-compactor.ts` + chatStore 集成 | 23 tests |
| **Phase 3: 主动智能 + 自我反思** | ✅ 已完成 | `heartbeat-engine.ts`, `reflection-engine.ts` | 28 tests |
| **Phase 4: 多 Agent 协作** | 📋 规划中 | — | — |
| **全量测试** | ✅ 274 passing | 12 test files | — |
| **Phase 4: 多 Agent 协作 + 技能生态** | ✅ 已完成 | `agent-swarm.ts`, `skill-discovery.ts` + chatStore 集成 | 43 tests |
| **全量测试** | ✅ 317 passing | 13 test files | — |
---
@@ -913,7 +913,7 @@ interface ReflectionResult {
---
### 6.5 Phase 4多 Agent 协作 + 技能生态(第 11-16 周)
### 6.5 Phase 4多 Agent 协作 + 技能生态(第 11-16 周) — ✅ 已完成
**目标**:构建 Agent 协作框架和技能自主发现能力
@@ -971,10 +971,12 @@ interface SkillDiscovery {
#### 6.5.3 Phase 4 交付物
- `src/lib/agent-swarm.ts` — 多 Agent 协作引擎
- `src/lib/skill-discovery.ts` — 技能发现与推荐
- `src/components/SwarmDashboard.tsx` — 协作任务面板
- `src/components/SkillMarket.tsx`技能市场 UI
- `desktop/src/lib/agent-swarm.ts` — 多 Agent 协作引擎Sequential/Parallel/Debate 三种模式)
- `desktop/src/lib/skill-discovery.ts` — 技能发现与推荐12 个内置技能,关键词搜索 + 对话模式推荐)
- `desktop/src/store/chatStore.ts``dispatchSwarmTask` + `searchSkills` 集成
- `tests/desktop/swarm-skills.test.ts`43 项单元测试
- 📋 `src/components/SwarmDashboard.tsx` — 协作任务面板UI 待实现)
- 📋 `src/components/SkillMarket.tsx` — 技能市场 UIUI 待实现)
---