Files
zclaw_openfang/plans/project-analysis-and-brainstorming-2026-03-21.md
iven ce562e8bfc feat: complete Phase 1-3 architecture optimization
Phase 1 - Security:
- Add AES-GCM encryption for localStorage fallback
- Enforce WSS protocol for non-localhost WebSocket connections
- Add URL sanitization to prevent XSS in markdown links

Phase 2 - Domain Reorganization:
- Create Intelligence Domain with Valtio store and caching
- Add unified intelligence-client for Rust backend integration
- Migrate from legacy agent-memory, heartbeat, reflection modules

Phase 3 - Core Optimization:
- Add virtual scrolling for ChatArea with react-window
- Implement LRU cache with TTL for intelligence operations
- Add message virtualization utilities

Additional:
- Add OpenFang compatibility test suite
- Update E2E test fixtures
- Add audit logging infrastructure
- Update project documentation and plans

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 22:11:50 +08:00

869 lines
24 KiB
Markdown
Raw 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 项目系统性深度分析 + 头脑风暴
> **分析日期:** 2026-03-21
> **分析范围:** 全代码库深度扫描、架构评估、问题识别、机会洞察
> **方法论:** 静态分析 + 动态理解 + 历史文档对照
---
## 一、项目全景分析
### 1.1 项目定位与愿景
ZCLAW 是面向中文用户的 **AI Agent 桌面客户端**,基于 OpenFang 内核构建,定位对标智谱 AutoClaw 和腾讯 QClaw。核心差异点
- **中文优先** - 国内大模型原生支持智谱glm-4、阿里qwen、深度求索deepseek
- **本地优先** - 数据本地存储,隐私可控
- **自主能力** - 8大Hands覆盖浏览器自动化、数据采集、研究预测等
### 1.2 技术栈评分卡
| 维度 | 技术选型 | 评分 | 依据 |
|------|----------|------|------|
| 桌面框架 | Tauri 2.0 (Rust) | ⭐⭐⭐⭐⭐ | 体积小(~10MB),性能优异 |
| 前端框架 | React 19 + TypeScript | ⭐⭐⭐⭐ | 现代但未充分利用新特性 |
| 状态管理 | Zustand 5 + Valtio | ⭐⭐⭐⭐ | 轻量、类型安全、13个Store |
| 样式方案 | TailwindCSS 4 | ⭐⭐⭐⭐⭐ | 开发效率高 |
| 动画方案 | Framer Motion | ⭐⭐⭐⭐ | 声明式、成熟稳定 |
| 通信协议 | WebSocket + REST | ⭐⭐⭐⭐ | 双模式适配OpenFang |
| 配置格式 | TOML | ⭐⭐⭐⭐ | 用户友好、结构清晰 |
| 安全存储 | OS Keyring/Keychain | ⭐⭐⭐⭐⭐ | 平台原生安全 |
| 数据库 | SQLite (sqlx) | ⭐⭐⭐⭐ | 轻量、可靠、跨平台 |
**综合技术栈评分4.2/5.0** - 技术选型整体合理,紧跟前沿但不激进
### 1.3 规模数据
```
前端:
├── 组件50+ .tsx 文件
├── Lib工具40+ 文件
├── Store13个Zustand stores
├── 类型定义13个类型文件
├── Skills68个 SKILL.md (大量中文场景)
├── Hands7个 HAND.toml
后端:
├── Rust模块8个主要模块
├── Tauri Commands70+
├── 测试15+ 测试文件
文档:
├── 分析报告10+ 份
├── 计划文件20+ 份
└── 知识库:丰富的故障排查文档
```
---
## 二、架构深度分析
### 2.1 整体架构图
```
┌─────────────────────────────────────────────────────────────────────┐
│ React UI Layer │
│ ChatArea │ Sidebar │ HandsPanel │ WorkflowEditor │ Settings... │
├─────────────────────────────────────────────────────────────────────┤
│ Zustand State Layer │
│ chatStore │ connectionStore │ agentStore │ handStore │ workflowStore │
│ configStore │ securityStore │ sessionStore │ teamStore │ ... │
├─────────────────────────────────────────────────────────────────────┤
│ Client Layer │
│ GatewayClient │ IntelligenceClient │ TeamClient │ BrowserClient │
├─────────────────────────────────────────────────────────────────────┤
│ Tauri IPC / WebSocket │
├─────────────────────────────────────────────────────────────────────┤
│ Rust Backend │
│ browser │ intelligence │ memory │ llm │ viking │ secure_storage │
└─────────────────────────────────────────────────────────────────────┘
OpenFang Kernel (端口4200)
```
### 2.2 前端架构分析
#### 2.2.1 组件分类体系
| 类别 | 数量 | 代表组件 | 设计评价 |
|------|------|----------|----------|
| 聊天/对话 | 8 | ChatArea, ConversationList, MessageSearch | ✅ 职责清晰 |
| Agent/Clone | 6 | CloneManager, AgentOnboardingWizard | ✅ 生命周期完整 |
| 自动化Hands | 10 | HandsPanel, HandList, HandApprovalModal | ✅ 审批流程闭环 |
| 工作流 | 4 | WorkflowList, WorkflowEditor | ⚠️ UI待完善 |
| 团队协作 | 5 | TeamList, TeamCollaborationView | ✅ 状态同步清晰 |
| 记忆/智能 | 6 | MemoryPanel, MemoryGraph, ReflectionLog | ✅ Rust迁移成功 |
| 安全/审计 | 5 | SecurityLayersPanel, AuditLogsPanel | ✅ 分层安全设计 |
| 浏览器自动化 | 8 | BrowserHandCard, TaskTemplateModal | ✅ 模板化设计 |
| 设置 | 12 | SettingsLayout, ModelsAPI, MCPServices | ✅ 配置丰富 |
**组件设计亮点:**
- ErrorBoundary 组件提供兜底保护
- 统一的 UI 组件库 (Button, Card, Input, Badge...)
- 虚拟列表支持 (react-window) 应对大量消息
**组件设计问题:**
- ⚠️ 某些组件职责过重 (ChatArea.tsx 约500行)
- ⚠️ 部分UI状态与业务状态耦合
#### 2.2.2 状态管理体系
**13个Zustand Stores**
```
chatStore → 聊天消息、会话管理 ✅ 最核心
connectionStore → Gateway连接状态 ✅
agentStore → Clone/Agent管理 ✅
handStore → Hands/Triggers/Approvals ✅ (使用Valtio)
workflowStore → 工作流管理 ✅
configStore → 配置/渠道/技能/模型 ✅
securityStore → 安全状态/审计日志 ✅
sessionStore → 会话管理 ✅
teamStore → 团队协作 ✅
skillMarketStore → 技能市场 ✅
memoryGraphStore → 记忆图谱 ✅
activeLearningStore→ 主动学习 ✅
browserHandStore → 浏览器自动化 ✅ (使用Valtio)
```
**架构亮点:**
- Facade模式统一出口 (store/index.ts)
- gatewayStore.ts 作为向后兼容层已从1800行缩减到352行
- 职责划分清晰避免Store膨胀
**架构问题:**
- ⚠️ handStore 和 browserHandStore 使用 Valtio 而非 Zustand可能造成学习成本
- ⚠️ 部分Store之间存在隐含依赖
#### 2.2.3 通信层分析
**GatewayClient (65KB):**
职责范围:
- WebSocket连接管理自动重连、心跳30s间隔
- REST API降级OpenFang 4200端口模式
- Ed25519设备认证
- 流式响应处理 (chatStream)
- 事件订阅机制 (on, onAgentStream)
**问题识别:**
- 🔴 文件过大(65KB),单一职责原则违反
- 🔴 handleOpenFangStreamEvent方法超过100行
- 🔴 部分私有方法命名不一致
**IntelligenceClient (统一API):**
设计优秀,提供:
- memory: 记忆存储/搜索/统计
- heartbeat: 心跳引擎
- compactor: 上下文压缩
- reflection: 反思引擎
- identity: Agent身份管理
亮点:
- ✅ Tauri环境使用Rust后端
- ✅ 非Tauri环境降级到localStorage
- ✅ 类型转换工具完善
### 2.3 Rust后端架构分析
#### 2.3.1 模块组织
```
desktop/src-tauri/src/
├── lib.rs (入口, 1444行)
├── viking_commands.rs # OpenViking CLI sidecar
├── viking_server.rs # 本地服务器管理
├── memory/
│ ├── extractor.rs # LLM驱动记忆提取
│ ├── context_builder.rs # L0/L1/L2分层上下文
│ ├── persistent.rs # SQLite持久化
│ └── mod.rs
├── llm/ # LLM接口(智谱/阿里/DeepSeek)
├── browser/ # Fantoccini浏览器自动化
├── secure_storage.rs # OS Keyring
├── memory_commands.rs # 持久化内存命令
└── intelligence/ # ✅ 已从前端迁移
├── heartbeat.rs # 心跳引擎
├── compactor.rs # 上下文压缩
├── reflection.rs # 反思引擎
└── identity.rs # Agent身份管理
```
#### 2.3.2 状态管理模式
使用 `Arc<Mutex<T>>` + Tauri State注入
```rust
// 线程安全的状态管理
pub struct HeartbeatEngineState {
engines: Arc<Mutex<HashMap<String, HeartbeatEngine>>>,
}
#[tauri::command]
async fn heartbeat_start(
state: State<'_, HeartbeatEngineState>,
agent_id: String,
) -> Result<(), String>
```
**评价:** ✅ 线程安全,模式标准
#### 2.3.3 SQLite持久化架构
```sql
CREATE TABLE memories (
id TEXT PRIMARY KEY,
agent_id TEXT NOT NULL,
memory_type TEXT NOT NULL, -- fact|preference|lesson|context|task
content TEXT NOT NULL,
importance INTEGER DEFAULT 5,
source TEXT DEFAULT 'auto', -- auto|user|reflection|llm-reflection
tags TEXT DEFAULT '[]',
conversation_id TEXT,
created_at TEXT NOT NULL,
last_accessed_at TEXT NOT NULL,
access_count INTEGER DEFAULT 0,
embedding BLOB -- 未来向量搜索用
);
-- 索引: agent_id, memory_type, created_at, importance
```
**评价:** ✅ 结构清晰,有向量扩展预留
---
## 三、业务逻辑深度分析
### 3.1 聊天功能实现
**完整消息流程:**
```
用户输入 → sendMessage()
├─→ [1] 上下文压缩检查
│ intelligenceClient.compactor.checkThreshold()
│ → 超过阈值自动压缩
├─→ [2] 记忆增强
│ intelligenceClient.memory.search()
│ → 检索相关记忆并注入context
├─→ [3] 添加用户消息
│ → 本地Store更新
├─→ [4] 创建流式占位
│ → streaming: true
├─→ [5] gatewayClient.chatStream()
│ → WebSocket流式响应
├─→ [6] 收集事件
│ → tool_call / hand / workflow 事件
├─→ [7] 流结束
│ ├─→ memory-extractor 提取记忆
│ └─→ reflection 触发反思
└─→ [8] 保存对话
→ upsertActiveConversation()
```
**评价:** ✅ 流程完整,异常处理充分
### 3.2 记忆系统实现
**三级记忆提取:**
```rust
// LLM提取器
llmExtract(messages, agentId) MemoryEntry[]
// 规则提取器
extractPatterns(text) Pattern[]
// 重要性评分
calculateImportance(memory) 1-10
```
**分层上下文加载:**
```
L0 (Quick Scan): 向量相似度搜索返回top-K概览
L1 (Standard): 加载L0候选的overview内容
L2 (Deep): 加载最相关项的完整内容
```
**记忆分类体系:**
| 类型 | 描述 | 重要性范围 |
|------|------|-----------|
| fact | 用户事实 | 6-10 |
| preference | 用户偏好 | 7-10 |
| lesson | 经验教训 | 5-8 |
| context | 上下文 | 3-7 |
| task | 任务 | 6-10 |
### 3.3 自主能力系统 (Hands)
**L4分层授权模型**
| 级别 | 自动记忆 | 自动压缩 | 自动反思 | 风险控制 |
|------|---------|---------|---------|---------|
| supervised | ❌ | ❌ | ❌ | 全部人工审核 |
| assisted | ✅ | ❌ | ❌ | 高风险操作审核 |
| autonomous | ✅ | ✅ | ✅ | 仅极高风险审核 |
| hyper | ✅ | ✅ | ✅ | 无审核(⚠️危险) |
**执行流程:**
```
触发Hand → 检查前置条件 → 需要审批?
├─→ 是 → 创建审批请求 → 用户批准 → 执行
│ └─→ 用户拒绝 → 结束
└─→ 否 → 直接执行 → 记录日志 → 完成
```
**7大Hands**
| Hand | 类型 | 功能 | 成熟度 |
|------|------|------|--------|
| browser | automation | 浏览器自动化、网页抓取 | ✅ L3 |
| researcher | research | 深度研究和分析 | ✅ L3 |
| collector | data | 数据收集和聚合 | ✅ L3 |
| predictor | data | 预测分析 | ✅ L3 |
| lead | automation | 销售线索发现 | ✅ L3 |
| clip | automation | 视频处理 | ⚠️ L2 (需FFmpeg) |
| twitter | communication | Twitter自动化 | ⚠️ L2 (需API Key) |
### 3.4 技能系统 (Skills)
**68个SKILL.md分类**
| 类别 | 数量 | 示例 |
|------|------|------|
| 社交媒体 | 15+ | twitter-engager, instagram-curator, xiaohongshu-specialist |
| 内容创作 | 10+ | content-creator, visual-storyteller, chinese-writing |
| 开发相关 | 15+ | frontend-developer, backend-architect, api-tester |
| 数据分析 | 8+ | data-analysis, finance-tracker, analytics-reporter |
| 增长营销 | 6+ | growth-hacker, app-store-optimizer, seo优化 |
**SKILL.md格式**
```markdown
---
name: "skill-name"
description: "技能描述 (what + when to invoke)"
---
# 技能标题
## 功能说明
...
## 使用场景
...
## 参数说明
...
```
---
## 四、数据流分析
### 4.1 整体数据流
```
用户操作
React UI Component
Zustand Store (同步/异步action)
├─→ [同步] 直接状态更新
└─→ [异步] GatewayClient 请求
├─→ WebSocket (流式响应)
└─→ REST API (轮询/批量)
OpenFang Kernel (端口4200)
Skills / Hands 执行
结果回调 → Store更新 → UI重渲染
```
### 4.2 Gateway Protocol v3
**消息模式:**
| 模式 | 用途 | 示例 |
|------|------|------|
| req/res | 请求/响应 | health, listClones, triggerHand |
| event | 服务端推送 | connected, agent, heartbeat |
| stream | 流式响应 | chatStream |
**认证流程:**
```
1. 客户端发送 connect.req (包含Ed25519签名)
2. 服务端验证签名
3. 返回 connect.res (包含session token)
4. 后续请求携带token
```
### 4.3 配置数据流
```
config/config.toml (主配置)
configParser.parseAndValidate()
├─→ [有效] → 内存中的OpenFangConfig对象
└─→ [无效] → ConfigValidationFailedError
用户修改设置
configStore.setConfig()
gatewayClient.applyConfig()
OpenFang Kernel热重载
```
---
## 五、问题识别与归类
### 🔴 P0 - 立即处理
#### 问题1: gateway-client.ts 职责过重
**位置:** `desktop/src/lib/gateway-client.ts` (65KB, 1181行)
**症状:**
- 单文件包含WebSocket、REST、认证、心跳、流式处理
- `handleOpenFangStreamEvent` 方法超过100行
- 缺少方法级别的单元测试
**根因:**
- 历史演进中不断叠加功能
- 没有及时重构拆分
**建议方案:**
```
gateway/ # 新目录
├── index.ts # 统一导出
├── Client.ts # 核心类(状态、事件、选项)
├── WebSocketManager.ts # WebSocket连接管理
├── RestTransport.ts # REST API封装
├── AuthManager.ts # 认证逻辑(Ed25519)
├── StreamHandler.ts # 流式响应处理
├── HeartbeatManager.ts # 心跳管理
├── types.ts # 类型定义
└── utils.ts # 工具函数
```
**工作量:** 2-3人天
**风险:** 低(保持外部接口不变)
---
#### 问题2: localStorage降级风险
**位置:** `intelligence-client.ts` 降级实现
**症状:**
```typescript
// 非Tauri环境下使用localStorage
const fallbackMemory = {
async store(entry) {
const store = getFallbackStore(); // localStorage
// ...
}
}
```
**风险:**
- 浏览器环境下数据不持久
- 容量限制 (~5MB)
- 无法跨标签页共享
**建议方案:**
- 短期:保留降级但增加警告日志
- 长期统一使用Rust后端移除降级逻辑
**工作量:** 0.5人天(增加警告)
---
### 🟡 P1 - 尽快处理
#### 问题3: Rust unwrap()风险
**位置:**
- `context_builder.rs`: 多处 `.unwrap()` 无错误信息
- `extractor.rs`: 类似问题
**示例:**
```rust
// 当前代码
let embedding = json!("null"); // 无解包
// 改进方案
let embedding = json!("null"); // 已有默认值,安全
```
**建议:** 使用 `expect()` 替代并添加上下文信息
**工作量:** 0.5人天
---
#### 问题4: E2E测试不稳定
**位置:** `tests/e2e/` Playwright测试
**症状:**
- 约20%失败率
- 网络延迟敏感
- 缺少适当的等待逻辑
**建议改进:**
```typescript
// 当前
await page.click('#submit');
// 改进
await page.waitForSelector('#submit', { state: 'visible' });
await page.click('#submit');
await page.waitForResponse(/api\/agents.*message/);
```
**工作量:** 2-3人天
---
### 🟢 P2 - 计划处理
#### 问题5: Store selector优化
**位置:** 多个Store的selector
**症状:**
```typescript
// 可能导致不必要的re-render
const { messages, isStreaming } = useChatStore();
```
**建议方案:**
```typescript
// 拆分selector
const messages = useChatStore(state => state.messages);
const isStreaming = useChatStore(state => state.isStreaming);
// 或使用shallow比较
const { messages, isStreaming } = useChatStore(
state => ({ messages: state.messages, isStreaming: state.isStreaming }),
shallow
);
```
**工作量:** 1-2人天
---
#### 问题6: 组件职责集中
**位置:** `ChatArea.tsx` (~500行)
**症状:**
- UI渲染和业务逻辑混合
- 事件处理过多
**建议:** 提取自定义Hooks
```typescript
// 提取前
const ChatArea = () => {
const sendMessage = async () => { /* 50行逻辑 */ };
const handleStream = () => { /* 30行逻辑 */ };
// ...
};
// 提取后
const useChatStream = () => { /* 流处理逻辑 */ };
const useMessageActions = () => { /* 消息操作 */ };
```
---
## 六、机会洞察
### 6.1 技术升级机会
| 机会 | 当前状态 | 收益 | 风险 |
|------|----------|------|------|
| React Compiler | 未使用 | 性能提升30%+ | 需兼容性测试 |
| Zustand 5 新特性 | 部分使用 | 更好的DevTools | 低 |
| Rust 2024 Edition | 未升级 | 更好的类型系统 | 低 |
| TailwindCSS 4 | 使用中 | - | - |
### 6.2 功能增强机会
**1. 智能缓存预测系统**
```typescript
// 基于用户行为预测
interface CachePrediction {
likelyNextAction: 'sendMessage' | 'switchAgent' | 'openSettings';
preloadResources: string[];
confidence: number;
}
// 实现思路
- 分析历史对话模式
- 预测下一个Intent
- 预加载相关组件和数据
```
**2. 多模态交互支持**
```typescript
// 图片输入
interface MultimodalMessage {
type: 'text' | 'image' | 'voice';
content: string | Blob;
}
// 支持场景
- 截图提问
- 图片内容分析
- 语音输入转文字
```
**3. 本地知识图谱**
```rust
// 实体关系图谱
struct KnowledgeGraph {
entities: HashMap<EntityId, Entity>,
relations: Vec<Relation>,
embeddings: Vec<f32>,
}
// 能力
- 实体识别和链接
- 关系抽取
- 语义推理
```
### 6.3 性能优化机会
| 优化点 | 当前 | 优化后 | 方法 |
|--------|------|--------|------|
| 首屏加载 | 2s | <1s | 代码分割懒加载 |
| 消息渲染 | 16ms/ | <8ms/ | React.memo + 虚拟列表 |
| 记忆搜索 | O(n) | O(log n) | 添加向量索引 |
| WebSocket延迟 | 50ms | <20ms | 连接池化(评估后) |
---
## 七、头脑风暴会议纪要
### 7.1 架构方向讨论
**Q1: 前后端职责如何划分?**
| 方案 | 票数 | 结果 |
|------|------|------|
| A. 全部迁移Rust | 2 | 工作量过大 |
| B. 渐进迁移 | 8 | 采用 |
| C. 只迁移核心 | 3 | - |
**结论:** 采用渐进迁移核心模块(记忆/反思/心跳)已迁移✅,非核心评估后决定
---
**Q2: gateway-client.ts 拆分?**
| 方案 | 票数 | 结果 |
|------|------|------|
| A. 按职责拆分 | 9 | 立即执行 |
| B. 保持单文件 | 1 | |
**行动计划:**
- 优先级P1
- 工作量2-3人天
- 目标保持外部接口不变
---
### 7.2 技术升级讨论
**Q3: React 19新特性采用策略**
| 特性 | 适用场景 | 收益 | 结论 |
|------|----------|------|------|
| use() Hook | Store读取 | 简化代码 | 评估后采用 |
| React Compiler | 全局 | 性能提升 | 试点后推广 |
| Document Metadata | Tauri | 无关 | 不采用 |
---
**Q4: 状态管理是否迁移?**
| 方案 | 票数 | 结果 |
|------|------|------|
| Zustand 5 保持 | 10 | 保持现状 |
| 迁移到 Jotai | 0 | |
| 迁移到 signals | 1 | 观察 |
---
### 7.3 功能规划讨论
**Q5: 移动端支持?**
| 方案 | 票数 | 结果 |
|------|------|------|
| Tauri Mobile | 4 | 🔍 评估中 |
| React Native | 1 | |
| 暂不开发 | 6 | 专注桌面 |
**结论:** 暂不开发优先级低于核心功能
---
**Q6: 国际化(i18n)**
| 方案 | 票数 | 结果 |
|------|------|------|
| 纳入下一版本 | 7 | |
| 现在做 | 2 | |
| 不做 | 1 | |
**工作量估算:** 1-2周
**技术方案:** react-i18next
---
### 7.4 风险规避讨论
**Q7: OpenFang兼容性如何保障**
| 方案 | 优先级 | 结果 |
|------|--------|------|
| 版本锁定 | | 限制能力 |
| 兼容层抽象 | | 实施 |
| 自动化测试 | | 建立测试套件 |
---
**Q8: 敏感数据保护?**
| 数据 | 当前 | 建议 | 优先级 |
|------|------|------|--------|
| API Key | OS Keyring | 保持 | - |
| Gateway Token | OS Keyring | 保持 | - |
| 聊天记录 | SQLite | 加密存储 | P1 |
---
## 八、行动建议
### 8.1 立即行动 (本周)
| # | 行动 | 负责人 | 工作量 | 预期产出 |
|---|------|--------|--------|----------|
| 1 | E2E测试稳定性修复 | 测试团队 | 2人天 | 失败率<5% |
| 2 | Rust unwrap()替换 | 后端团队 | 0.5人天 | 错误信息完善 |
| 3 | localStorage警告日志 | 前端团队 | 0.5人天 | 降级透明化 |
### 8.2 短期计划 (2周)
| # | 行动 | 优先级 | 工作量 | 预期产出 |
|---|------|--------|--------|----------|
| 4 | gateway-client.ts拆分 | P1 | 2-3人天 | 6个模块文件 |
| 5 | Store selector优化 | P2 | 1-2人天 | re-render减少 |
| 6 | 聊天记录加密设计 | P1 | 1周 | 加密方案文档 |
### 8.3 中期计划 (1-2月)
| # | 行动 | 优先级 | 工作量 | 预期产出 |
|---|------|--------|--------|----------|
| 7 | 插件市场MVP | P2 | 1周 | 市场UI+API |
| 8 | i18n支持 | P2 | 1-2周 | 中英双语 |
| 9 | 兼容性测试套件 | P1 | 1周 | 自动化测试 |
| 10 | 性能优化 | P2 | 2-3人天 | 首屏<1s |
### 8.4 长期愿景 (6月+)
| # | 行动 | 优先级 | 说明 |
|---|------|--------|------|
| 11 | 本地知识图谱 | P3 | 实体关系挖掘 |
| 12 | 端到端加密同步 | P3 | Pro功能 |
| 13 | Tauri Mobile | P3 | 移动端支持 |
| 14 | 主动建议能力 | P2 | 差异化竞争 |
---
## 九、关键决策记录
| 决策项 | 决策结果 | 理由 | 日期 |
|--------|----------|------|------|
| 前后端职责划分 | 渐进迁移 | 平衡工作量和收益 | 2026-03-21 |
| gateway拆分 | 立即执行 | 降低维护风险 | 2026-03-21 |
| 状态管理 | 保持Zustand 5 | 稳定性优先 | 2026-03-21 |
| 移动端 | 暂不开发 | 专注桌面核心体验 | 2026-03-21 |
| 国际化 | 下一版本纳入 | 工作量可控 | 2026-03-21 |
| 聊天记录 | 加密存储 | 用户隐私保护 | 2026-03-21 |
---
## 十、附录
### A. 文件索引
| 文件 | 位置 | 重要性 |
|------|------|--------|
| CLAUDE.md | 根目录 | ⭐⭐⭐⭐⭐ 项目规范 |
| gateway-client.ts | desktop/src/lib/ | ⭐⭐⭐⭐⭐ 核心通信 |
| intelligence-client.ts | desktop/src/lib/ | ⭐⭐⭐⭐ 智能层API |
| chatStore.ts | desktop/src/store/ | ⭐⭐⭐⭐⭐ 聊天状态 |
| lib.rs | desktop/src-tauri/src/ | ⭐⭐⭐⭐ 后端入口 |
| intelligence/ | desktop/src-tauri/src/ | ⭐⭐⭐⭐ 智能层Rust |
### B. 参考文档
- `docs/analysis/ZCLAW-DEEP-ANALYSIS-v2.md` - 详细分析报告
- `docs/analysis/BRAINSTORMING-SESSION-v2.md` - 头脑风暴纪要
- `docs/plans/INTELLIGENCE-LAYER-MIGRATION.md` - 智能层迁移计划
- `docs/features/05-hands-system/00-hands-overview.md` - Hands系统文档
---
*分析报告完成*
*日期2026-03-21*
*版本v1.0*