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:
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Tool Handlers Shared - 共享工具函数和类型
|
||||
*/
|
||||
|
||||
import * as path from 'path';
|
||||
import { mainWindow } from './main.js';
|
||||
import { getWorkspaceDir } from './workspace.js';
|
||||
|
||||
/** 发送日志到渲染进程日志面板 */
|
||||
export function sendLog(level: 'info' | 'success' | 'warn' | 'error' | 'debug', message: string, detail?: string): void {
|
||||
mainWindow?.webContents.send('main:log', { level, message, detail });
|
||||
}
|
||||
|
||||
/** 解析路径:相对路径基于工作空间目录 */
|
||||
export function resolvePath(inputPath: string): string {
|
||||
if (path.isAbsolute(inputPath)) return path.resolve(inputPath);
|
||||
return path.resolve(getWorkspaceDir(), inputPath);
|
||||
}
|
||||
|
||||
export interface ToolResult {
|
||||
success: boolean;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
Reference in New Issue
Block a user