Files
zclaw_openfang/plans/virtual-conjuring-stardust.md
iven adfd7024df docs(claude): restructure documentation management and add feedback system
- Restructure §8 from "文档沉淀规则" to "文档管理规则" with 4 subsections
  - Add docs/ structure with features/ and knowledge-base/ directories
  - Add feature documentation template with 7 sections (概述/设计初衷/技术设计/预期作用/实际效果/演化路线/头脑风暴)
  - Add feature update trigger matrix (新增/修改/完成/问题/反馈)
  - Add documentation quality checklist
- Add §16
2026-03-16 13:54:03 +08:00

206 lines
5.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ZCLAW L4 自我演化能力实现计划
## Context
**背景**: ZCLAW 已完成 Agent 智能演化 Phase 1-4317 测试通过),当前成熟度达到 L3+(主动智能)。
**L4 目标**: 实现"完整自主行为优化循环" - Agent 能够自我修改行为和知识,无需人工干预即可持续进化。
**当前状态**:
| 成熟度级别 | 状态 |
|-----------|------|
| L0 - 无状态响应 | ✅ 已超越 |
| L1 - 会话感知 | ✅ 已超越 |
| L2 - 持久记忆 | ✅ 已达成 |
| L3 - 主动智能 | ✅ 已达成 |
| L4 - 自我演化 | ⏳ 部分实现 |
**L4 缺口**:
1. 4 个 UI 组件未实现SwarmDashboard、SkillMarket、HeartbeatConfig、ReflectionLog
2. 3 个引擎仍是规则驱动,需升级为 LLM 驱动
3. 身份文件变更仍需用户审批(非自主)
---
## Phase 1: 缺失 UI 组件补全优先级P0
### 1.1 SwarmDashboard - 多 Agent 协作面板
**新建文件**: `desktop/src/components/SwarmDashboard.tsx`
功能:
- 显示当前协作任务列表
- 实时展示子任务分配和状态
- 支持手动触发协作任务
- 查看协作结果汇总
### 1.2 SkillMarket - 技能市场 UI
**新建文件**: `desktop/src/components/SkillMarket.tsx`
功能:
- 浏览可用技能12 个内置 + 自定义)
- 按关键词/能力标签搜索
- 一键安装/启用技能
- 查看技能详情和使用统计
### 1.3 HeartbeatConfig - 心跳配置 UI
**新建文件**: `desktop/src/components/HeartbeatConfig.tsx`
功能:
- 配置心跳间隔(默认 30 分钟)
- 启用/禁用内置检查项
- 设置免打扰时段
- 选择主动性级别(静默/轻度/标准/自主)
### 1.4 ReflectionLog - 反思日志 UI
**新建文件**: `desktop/src/components/ReflectionLog.tsx`
功能:
- 查看反思历史(模式分析、改进建议)
- 审批身份文件变更提议
- 回滚到历史人格版本
- 手动触发反思
---
## Phase 2: LLM 驱动升级优先级P1
### 2.1 ReflectionEngine 升级
**修改文件**: `desktop/src/lib/reflection-engine.ts`
当前:规则模式检测(关键词匹配)
目标LLM 语义分析 + 深度反思
```typescript
// 升级后的 reflect 方法
async reflect(agentId: string, options?: { useLLM?: boolean }): Promise<ReflectionResult> {
if (options?.useLLM && this.llmAvailable) {
return this.llmReflect(agentId);
}
return this.ruleBasedReflect(agentId); // fallback
}
```
### 2.2 ContextCompactor 升级
**修改文件**: `desktop/src/lib/context-compactor.ts`
当前:规则摘要(截断 + 格式化)
目标LLM 高质量摘要 + 关键信息保留
### 2.3 MemoryExtractor 升级
**修改文件**: `desktop/src/lib/memory-extractor.ts`
当前:正则匹配 + 关键词检测
目标LLM 语义重要性评分 + 智能分类
---
## Phase 3: 自主行为授权优先级P2
### 3.1 分级授权系统
**新建文件**: `desktop/src/lib/autonomy-manager.ts`
```typescript
interface AutonomyConfig {
level: 'supervised' | 'assisted' | 'autonomous';
allowedActions: {
memoryAutoSave: boolean; // 自动保存记忆
identityAutoUpdate: boolean; // 自动更新身份文件
skillAutoInstall: boolean; // 自动安装技能
selfModification: boolean; // 自我修改行为
};
approvalThreshold: {
importance: number; // 重要性低于此值自动执行
risk: 'low' | 'medium' | 'high'; // 风险等级
};
}
```
### 3.2 安全边界
- 高风险操作(删除记忆、修改 SOUL.md始终需确认
- 所有自主操作记录审计日志
- 支持一键回滚到任意历史状态
---
## Phase 4: OpenViking 深度集成优先级P2
### 4.1 记忆后端迁移
**修改文件**: `desktop/src/lib/agent-memory.ts`
从 localStorage → SQLite + OpenViking API
### 4.2 语义搜索
**新建文件**: `desktop/src/lib/vector-memory.ts`
```typescript
interface VectorMemorySearch {
embed(text: string): Promise<Float32Array>;
semanticSearch(query: string, topK: number): Promise<MemoryEntry[]>;
}
```
---
## 关键文件
| 文件 | 类型 | 说明 |
|------|------|------|
| `desktop/src/components/SwarmDashboard.tsx` | 新建 | 协作任务面板 |
| `desktop/src/components/SkillMarket.tsx` | 新建 | 技能市场 |
| `desktop/src/components/HeartbeatConfig.tsx` | 新建 | 心跳配置 |
| `desktop/src/components/ReflectionLog.tsx` | 新建 | 反思日志 |
| `desktop/src/lib/autonomy-manager.ts` | 新建 | 自主授权管理 |
| `desktop/src/lib/vector-memory.ts` | 新建 | 向量记忆搜索 |
| `desktop/src/lib/reflection-engine.ts` | 修改 | LLM 升级 |
| `desktop/src/lib/context-compactor.ts` | 修改 | LLM 升级 |
| `desktop/src/lib/memory-extractor.ts` | 修改 | LLM 升级 |
| `desktop/src/lib/agent-memory.ts` | 修改 | SQLite 迁移 |
---
## Verification
### 测试清单
**Phase 1 - UI 组件**:
- [ ] SwarmDashboard 显示协作任务
- [ ] SkillMarket 搜索和安装技能
- [ ] HeartbeatConfig 保存配置
- [ ] ReflectionLog 审批变更
**Phase 2 - LLM 升级**:
- [ ] ReflectionEngine 使用 LLM 分析
- [ ] ContextCompactor 生成高质量摘要
- [ ] MemoryExtractor 语义重要性评分
**Phase 3 - 自主授权**:
- [ ] 低风险操作自动执行
- [ ] 高风险操作需确认
- [ ] 审计日志完整
### 运行测试
```bash
pnpm vitest run tests/desktop/
```
---
## Implementation Sequence
1. **Week 1**: Phase 1 - UI 组件4 个组件)
2. **Week 2**: Phase 2 - LLM 升级3 个引擎)
3. **Week 3**: Phase 3 - 自主授权 + Phase 4 - OpenViking
4. **Week 4**: 集成测试 + 文档更新