refactor: 修复 any 滥用 & 拆分 tool-handlers.ts & 记忆数据治理 (v5.1.3)

Fix 2 - 类型安全:
- (window as any).metonaDesktop → window.metonaDesktop
- any[] → Record<string, unknown>[]
- 回调 :any → ChatSession | null
- 78 处 → 38 处(减少 51%)

Fix 3 - 架构拆分:
- tool-handlers.ts (1308行) → 4 个模块:
  - tool-handlers-shared.ts: 共享工具函数
  - tool-handlers-fs.ts: 15 个文件系统操作
  - tool-handlers-system.ts: 6 个系统网络操作
  - tool-handlers-git.ts: 1 个 Git 操作

Fix 4 - 记忆数据治理:
- 90 天未使用自动降低 importance
- 清理评分新增 agePenalty
- 向量错误日志增强(记忆ID、内容摘要、模型、栈)
- 去重增强(前缀匹配)
This commit is contained in:
Metona Build
2026-04-19 18:38:31 +08:00
parent 212f14adf5
commit 69a28a8500
19 changed files with 1483 additions and 1363 deletions
+22
View File
@@ -10,6 +10,28 @@
---
## 桌面版(Desktop
### Desktop v5.1.3 — 代码质量 & 架构优化 & 记忆数据治理
- 🔧 **修复 any 滥用**(类型安全)
- `(window as any).metonaDesktop``window.metonaDesktop`(已有类型声明)
- IndexedDB 迁移代码 `any[]``Record<string, unknown>[]`
- 回调函数 `: any` → 具体类型 `ChatSession | null`
- 全局函数 `(window as any).__toggleCron``WindowWithCron` 接口
- 消除 78 处 → 38 处(减少 51%)(保留 API 参数构造等合理场景)
- ♻️ **拆分 tool-handlers.ts**(架构优化)
- 1308 行单文件 → 4 个模块:
- `tool-handlers-shared.ts`:共享工具函数和类型
- `tool-handlers-fs.ts`15 个文件系统操作(591 行)
- `tool-handlers-system.ts`6 个系统网络操作(530 行)
- `tool-handlers-git.ts`1 个 Git 操作(226 行)
-`tool-handlers.ts` 改为纯 re-exportipc.ts 无需修改
-**记忆数据治理**(借鉴 Hermes Agent
- 记忆过期衰减:90 天未使用的记忆自动降低 importancerule 受保护)
- 清理评分新增 agePenalty:创建超 90 天扣分
- 向量存储错误日志增强:包含记忆 ID、内容摘要、嵌入模型、错误栈
- 去重增强:新增前缀匹配(前 50 字符相同视为重复)
- 📝 **版本号更新至 5.1.3**7 个文件同步更新)
### Desktop v5.1.2 — 预算警告 & Shadowing 防护 & 记忆容量管理