feat: MEMORY.md 访问保护、格式简化及预存问题修复

MEMORY.md 保护: 新建 file-guard.ts 共享守卫模块; read_file/write_file/search_files/run_command 禁止访问根目录 MEMORY.md; permissions.ts 增加 deniedPatterns 深度防御。格式简化: 元数据从 # 注释改为 > 引用语法; 校验规则从 6 条简化为 3 条; context-builder extractContent 适配。预存问题: 修复路径遍历前缀碰撞漏洞; 移除 browser_extract 内容截断; SearXNG 配置实时读取; web_search/web_fetch 移除截断; 侧边栏动态获取工具列表; 版本号 0.1.1
This commit is contained in:
thzxx
2026-07-05 21:24:22 +08:00
parent f4532a2bb2
commit 8cdb93f8bf
29 changed files with 2472 additions and 353 deletions
+10 -4
View File
@@ -209,7 +209,7 @@ Use tools when needed to gather information or perform actions. Think step by st
}
/**
* 提取 Markdown 文件内容(跳过标题行和元数据注释
* 提取 Markdown 文件内容(跳过标题行和 > 引用元数据)
*/
private extractContent(fileContent: string): string {
if (!fileContent) return '';
@@ -219,9 +219,15 @@ Use tools when needed to gather information or perform actions. Think step by st
let skipMeta = true;
for (const line of lines) {
// 跳过元数据注释行(以 # 开头且不跟另一个 # 的行,即只跳过一级标题)
if (skipMeta && line.match(/^#[^#]/)) {
continue;
// 跳过文件头部的标题行(# 开头)和 > 引用元数据行
if (skipMeta) {
if (line.match(/^#[^#]/) || line.match(/^>/)) {
continue;
}
// 空行在元数据区域中也跳过
if (line.trim() === '') {
continue;
}
}
skipMeta = false;
contentLines.push(line);