feat: 升级至 v0.3.16 — 工单修复 51 项 + 审查修复 30 项(安全加固/适配器/工具系统/数据层/前端)

This commit is contained in:
2026-07-22 10:31:13 +08:00
parent 516d8a728f
commit 2c2ca4a692
43 changed files with 1454 additions and 301 deletions
+21 -3
View File
@@ -94,12 +94,17 @@ export class ContextBuilder {
// v0.3.14: 注入当前系统日期时间(每次构建时获取最新时间)
// 用于让 AI 准确理解"今天"、"昨天"等相对时间表达
// #43 修复: 时区硬编码 Asia/Shanghai 改为使用系统本地时区,跨时区用户显示正确
const now = new Date();
const localTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone ?? 'Asia/Shanghai';
// 审查修复: 恢复 UTC 偏移显示,在时区名后附加 UTC 偏移,避免丢失时区偏移信息
const offset = -now.getTimezoneOffset() / 60;
const offsetStr = offset >= 0 ? `UTC+${offset}` : `UTC${offset}`;
const dateTimeStr = now.toLocaleString('zh-CN', {
timeZone: 'Asia/Shanghai',
timeZone: localTimezone,
hour12: false,
});
dynamicParts.push(`## Current Date & Time\n${dateTimeStr} (Asia/Shanghai, UTC+8)`);
dynamicParts.push(`## Current Date & Time\n${dateTimeStr} (${localTimezone}, ${offsetStr})`);
// 注入当前工作空间路径(动态区,路径可能切换故不放入静态区)
if (workspacePath) {
@@ -277,7 +282,20 @@ For multi-step complex tasks (3+ steps), proactively use \`task_manager\` to bre
for (const mem of memories) total += estimateStringTokens(mem.content);
// 工具定义
for (const tool of tools) total += estimateStringTokens(tool.name + tool.description);
// #31 修复: 之前仅累加 tool.name + tool.description,忽略 tool.parametersJSON Schema),
// 而 parameters schema 通常占工具 token 的 70%+,导致估算严重偏低、压缩阈值判断错误
for (const tool of tools) {
total += estimateStringTokens(tool.name);
total += estimateStringTokens(tool.description);
// 审查修复: 用 try-catch 包裹 JSON.stringify,防止循环引用等异常导致估算中断
if (tool.parameters) {
try {
total += estimateStringTokens(JSON.stringify(tool.parameters));
} catch {
total += estimateStringTokens(String(tool.parameters));
}
}
}
// 用户输入
total += estimateStringTokens(userInput);