fix: 全面审查修复 - 日志/死代码/工具卡片/技能描述

- sqlite.ts: 移除 console.warn,改用状态变量跟踪 FTS5 可用性
- tool-handlers.ts: download_file/append_file/edit_file 补充 sendLog 执行日志
- chat-area.ts: 工具卡片补齐 29 个工具的图标/名称/参数/结果渲染
- main.ts: 移除未使用的 stopAllMCPServers 导入
- skill-manager.ts: 修复 /** 注释语法错误,补充 browser*/spawn_task 工具描述
This commit is contained in:
Metona Dev
2026-04-18 10:47:38 +08:00
parent a6d38ed9cb
commit 8ffba1a857
5 changed files with 85 additions and 8 deletions
+9
View File
@@ -641,11 +641,14 @@ export async function handleAppendFile(params: { path: string; content: string;
if (!allowed.ok) return { success: false, error: allowed.reason };
const prefix = params.newline !== false ? '\n' : '';
sendLog('info', ` append_file`, `${filePath} (${params.content.length} chars)`);
await fs.appendFile(filePath, prefix + params.content, 'utf-8');
const stat = await fs.stat(filePath);
sendLog('success', ` append_file 完成`, `${stat.size}B`);
return { success: true, path: filePath, newSize: stat.size };
} catch (err) {
sendLog('error', ` append_file 失败`, (err as Error).message);
return { success: false, error: (err as Error).message };
}
}
@@ -674,9 +677,12 @@ export async function handleEditFile(params: { path: string; old_text: string; n
newContent = content.replace(params.old_text, params.new_text);
}
sendLog('info', `✂️ edit_file`, `${filePath} (${replaceCount} 处替换)`);
await fs.writeFile(filePath, newContent, 'utf-8');
sendLog('success', `✂️ edit_file 完成`, `${newContent.length}B`);
return { success: true, path: filePath, replaceCount, newSize: newContent.length };
} catch (err) {
sendLog('error', `✂️ edit_file 失败`, (err as Error).message);
return { success: false, error: (err as Error).message };
}
}
@@ -770,6 +776,7 @@ export async function handleDownloadFile(params: { url: string; destination: str
return { success: false, error: '仅支持 http/https 协议' };
}
sendLog('info', `⬇️ download_file`, `${params.url}${destPath}`);
const resp = await fetch(params.url, {
signal: AbortSignal.timeout(60000)
});
@@ -784,6 +791,7 @@ export async function handleDownloadFile(params: { url: string; destination: str
await fs.mkdir(destDir, { recursive: true });
await fs.writeFile(destPath, buf);
sendLog('success', `⬇️ download_file 完成`, `${buf.length} bytes`);
return {
success: true,
url: params.url,
@@ -792,6 +800,7 @@ export async function handleDownloadFile(params: { url: string; destination: str
content_type: resp.headers.get('content-type') || 'unknown'
};
} catch (err) {
sendLog('error', `⬇️ download_file 失败`, (err as Error).message);
return { success: false, error: (err as Error).message };
}
}