feat: implement ZCLAW Agent Intelligence Evolution Phase 1-3
Phase 1: Persistent Memory + Identity Dynamic Evolution - agent-memory.ts: MemoryManager with localStorage persistence, keyword search, deduplication, importance scoring, pruning, markdown export - agent-identity.ts: AgentIdentityManager with per-agent SOUL/AGENTS/USER.md, change proposals with approval workflow, snapshot rollback - memory-extractor.ts: Rule-based conversation memory extraction (Phase 1), LLM extraction prompt ready for Phase 2 - MemoryPanel.tsx: Memory browsing UI with search, type filter, delete, export (integrated as 4th tab in RightPanel) Phase 2: Context Governance - context-compactor.ts: Token estimation, threshold monitoring (soft/hard), memory flush before compaction, rule-based summarization - chatStore integration: auto-compact when approaching token limits Phase 3: Proactive Intelligence + Self-Reflection - heartbeat-engine.ts: Periodic checks (pending tasks, memory health, idle greeting), quiet hours, proactivity levels (silent/light/standard/autonomous) - reflection-engine.ts: Pattern analysis from memory corpus, improvement suggestions, identity change proposals, meta-memory creation Chat Flow Integration (chatStore.ts): - Pre-send: context compaction check -> memory search -> identity system prompt injection - Post-complete: async memory extraction -> reflection conversation tracking -> auto-trigger reflection Tests: 274 passing across 12 test files - agent-memory.test.ts: 42 tests - context-compactor.test.ts: 23 tests - heartbeat-reflection.test.ts: 28 tests - chatStore.test.ts: 11 tests (no regressions) Refs: ZCLAW_AGENT_INTELLIGENCE_EVOLUTION.md updated with implementation progress
This commit is contained in:
@@ -3,6 +3,18 @@
|
||||
> **文档日期**:2026-03-15
|
||||
> **定位**:`ZCLAW_NEXT_EVOLUTION_STRATEGY.md` 的**专题补充文档**,聚焦 Agent 智能层的深度差距分析与演化路径
|
||||
> **核心问题**:ZCLAW 当前的 Agent 只是"解决问题的帮手",而 OpenClaw 的 Agent 是"可持续成长的助手"——如何弥合这一差距?
|
||||
>
|
||||
> **后续升级路径**:[`ZCLAW_OPENVIKING_INTEGRATION_PLAN.md`](./ZCLAW_OPENVIKING_INTEGRATION_PLAN.md) 中规划了基于 **OpenViking**(火山引擎开源 AI 智能体上下文数据库)的升级方案,作为本文档 Phase 1 自建记忆系统的**后续增强**选项。当前优先按本文档方案实施。
|
||||
|
||||
### 📊 实施进度(2026-03-15 更新)
|
||||
|
||||
| Phase | 状态 | 交付物 | 测试覆盖 |
|
||||
|-------|------|--------|---------|
|
||||
| **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 | — |
|
||||
|
||||
---
|
||||
|
||||
@@ -1066,33 +1078,40 @@ interface SkillDiscovery {
|
||||
|
||||
## 十一、立即可执行的行动(本周)
|
||||
|
||||
### P0(本周必须启动)
|
||||
### P0(本周必须启动)— ✅ 全部完成
|
||||
|
||||
1. **确认记忆存储技术选型**
|
||||
- 推荐:SQLite + FTS5,在 Tauri 环境中验证可行性
|
||||
- 输出:技术 POC(Proof of Concept)
|
||||
1. ✅ **确认记忆存储技术选型**
|
||||
- Phase 1 采用 localStorage 持久化(无外部依赖),升级路径已预留 SQLite + FTS5
|
||||
- 输出:`agent-memory.ts` MemoryManager 实现 + 42 项单元测试
|
||||
|
||||
2. **设计 MemoryEntry schema 并评审**
|
||||
- 参考本文档 6.2.1 的 schema 设计
|
||||
- 输出:确认的 TypeScript 接口 + SQLite DDL
|
||||
2. ✅ **设计 MemoryEntry schema 并评审**
|
||||
- 完整 TypeScript 接口:id, agentId, content, type, importance, source, tags, createdAt, lastAccessedAt, accessCount, conversationId
|
||||
- 支持 5 种类型:fact, preference, lesson, context, task
|
||||
|
||||
3. **重构 Agent 工作空间目录结构**
|
||||
- 从全局共享 `config/` 改为每个 Agent 独立目录
|
||||
- 输出:迁移脚本 + 新目录结构
|
||||
3. ✅ **重构 Agent 工作空间目录结构**
|
||||
- 通过 `AgentIdentityManager` 实现每个 Agent 独立的 SOUL/AGENTS/USER.md
|
||||
- 支持快照、回滚、变更审批流
|
||||
|
||||
### P1(下周启动)
|
||||
### P1(下周启动)— ✅ 全部完成
|
||||
|
||||
4. **实现 MemoryManager 核心接口**
|
||||
- save / search / get / forget / prune
|
||||
- 输出:`src/lib/agent-memory.ts` + 单元测试
|
||||
4. ✅ **实现 MemoryManager 核心接口**
|
||||
- save / search / get / getAll / forget / prune / exportToMarkdown / stats
|
||||
- 输出:`desktop/src/lib/agent-memory.ts` + 42 项测试
|
||||
|
||||
5. **在 chatStore 中集成记忆注入**
|
||||
- 每次对话前注入相关记忆到系统提示
|
||||
- 输出:`buildContextWithMemory` 函数集成
|
||||
5. ✅ **在 chatStore 中集成记忆注入**
|
||||
- sendMessage 前自动搜索相关记忆 + 注入身份系统提示
|
||||
- 输出:chatStore.ts memory-enhanced 发送流程
|
||||
|
||||
6. **实现对话记忆自动提取**
|
||||
- 对话结束后 LLM 提取值得记忆的信息
|
||||
- 输出:`src/lib/memory-extractor.ts` + 测试
|
||||
6. ✅ **实现对话记忆自动提取**
|
||||
- Phase 1 规则匹配提取 + Phase 2 LLM 提取 prompt 已预留
|
||||
- 输出:`desktop/src/lib/memory-extractor.ts` + 测试
|
||||
|
||||
### P2(额外完成)— ✅
|
||||
|
||||
7. ✅ **上下文压缩引擎** — `desktop/src/lib/context-compactor.ts` (23 tests)
|
||||
8. ✅ **心跳巡检引擎** — `desktop/src/lib/heartbeat-engine.ts` (28 tests shared)
|
||||
9. ✅ **自我反思引擎** — `desktop/src/lib/reflection-engine.ts`
|
||||
10. ✅ **记忆浏览 UI** — `desktop/src/components/MemoryPanel.tsx` (RightPanel 第4个 tab)
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user