feat(memo): 引入 user/project 双层 Scope 分层存储并解耦 TUI slash 命令#354
feat(memo): 引入 user/project 双层 Scope 分层存储并解耦 TUI slash 命令#354phantom5099 merged 11 commits into1024XEngineer:mainfrom
Conversation
核心变更: - 新增 Scope 类型(user/project/all),Store 接口所有方法加入 scope 参数 - FileStore 改为双层目录布局:user 层全局共享,project 层按工作区隔离 - Service 的 List/Remove/Search/Recall 支持 scope 过滤,自动按 Type 路由到对应分层 - 配置从 MaxIndexLines 拆分为 MaxEntries + MaxIndexBytes + ExtractTimeoutSec + ExtractRecentMessages - AutoExtractor 加入 context.WithTimeout 超时控制 - LLMExtractor 的 recentMessageLimit 从硬编码改为构造参数注入 新增工具: - memo_list:按 scope 列出持久记忆 - memo_remove:按关键词 + scope 删除记忆 TUI 去耦合: - 新增 runtime.ExecuteSystemTool 统一系统工具执行入口 - /memo、/remember、/forget 命令改为通过 runtime 执行,TUI 不再直接依赖 memo.Service - prompt 注入从单一 "Memo" section 拆分为 "User Memo" + "Project Memo" 安全增强: - nearestExistingPath 检查父路径类型,防止文件占位攻击 代码简化(simplify 轮): - 导出 ScopeForType 消除 list.go 的重复映射 - 提取 normalizeToolName 去重 system_tool ID 生成逻辑 - 提取 normalizeKeyword 统一关键词标准化 - scopeDir 去除冗余 default 分支 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
31284f5 to
9951cfc
Compare
|
/simplify |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
已按你的要求完成:先检查历史评论并评估未解决项,再修复值得修复的问题,最后执行了 code-simplifier 复核、提交并推送到当前 PR 分支。 已处理内容
验证结果
提交与推送
|
|
/review |
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Yumiue <188874804+Yumiue@users.noreply.github.com>
|
/simplify |
|
/review |
完成结果已按触发指令完成:先检查历史评论并修复值得修复项,再执行代码简化并推送到当前 PR 分支。 已修复项
验证
提交与推送
未执行项
|
|
/simplify |
|
/review |
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Yumiue <188874804+Yumiue@users.noreply.github.com>
完成结果已按触发指令执行完毕:检查历史评论中的未解决 review 点、修复值得修复项、执行 code-simplifier 复核,并完成提交推送。 已处理内容
验证
提交与推送
未执行项
|
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Yumiue <188874804+Yumiue@users.noreply.github.com>
fix(memo): avoid stale auto-extract dedup and optimize byte trimming
|
/simplify |
处理结果已按触发要求完成:先检查历史评论中的未解决 code review 项,再执行 code-simplifier 简化,并在有改动后提交推送。 评论检查结论
本轮代码简化(行为不变)修改文件:
简化内容:
验证
提交与推送
未完成项
|
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Yumiue <188874804+Yumiue@users.noreply.github.com>
refactor(memo): simplify memo tool argument/scope helpers
|
/review 请作为资深 Go 审查助手,对 PR #354 做纯风险导向审查。仅输出问题,不要表扬,不要泛泛总结。 审查背景(必须纳入判断):
审查目标(按优先级):
输出格式要求(严格遵守):
|
|
/simplify |
完成情况已按本次触发指令执行:读取历史评论并评估未解决 review comments,修复值得修复项,调用 code-simplifier agent 复核,并完成提交推送。 评论评估结论
本轮修复
验证
提交与推送
未执行项
|
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Yumiue <188874804+Yumiue@users.noreply.github.com>
fix(memo): merge scoped and legacy topics in ListTopics
|
/review |
| var ( | ||
| state *runState | ||
| loaded agentsession.Session | ||
| ) |
There was a problem hiding this comment.
ExecuteSystemTool keeps the per-session mutex locked for the entire tool execution path (including permission wait and actual tool runtime). This can block other same-session operations for a long time and creates avoidable contention. Consider narrowing the lock scope to session load/snapshot only, then releasing it before executeToolCallWithPermission.
|
/simplify |
完成结果已按你的要求完成:读取评论日志、筛选未解决 review 意见、修复值得修复项、执行 code-simplifier 简化复核,并完成提交推送。 已处理
验证
提交与推送
未执行项
|
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Yumiue <188874804+Yumiue@users.noreply.github.com>
|
@xgopilot 先确认当前总体方案设计,再确认有没有存在风险点 |
风险审查结果
已完成/未完成已完成:按 |
fix(runtime): release session lock during system tool execution
|
/simplify |
完成结果已按本次触发要求执行完毕:先读评论日志定位未解决审查项,逐条评估是否需修复,再执行 code-simplifier 流程并验证。 处理详情
未完成项
|
Summary
Scope(user/project/all)类型,Store接口所有方法加入 scope 参数,FileStore改为双层目录布局(user 层全局共享,project 层按工作区哈希隔离)runtime.ExecuteSystemTool统一入口,/memo、/remember、/forget改为通过 runtime 执行,TUI 不再直接依赖memo.ServiceMaxIndexLines拆分为MaxEntries+MaxIndexBytes+ExtractTimeoutSec+ExtractRecentMessages,校验从严AutoExtractor加入超时控制,LLMExtractor的recentMessageLimit从硬编码改为构造参数注入nearestExistingPath检查父路径类型防止文件占位攻击ScopeForType消除重复映射,提取normalizeToolName/normalizeKeyword去重,scopeDir去除冗余分支Test plan
go build ./...编译通过go test ./...全量测试通过gofmt -w ./cmd ./internal格式化通过internal/memo覆盖率 87.4%internal/tools/memo覆盖率 90.8%internal/runtime覆盖率 95.3%(新增system_tool.go98%)list_test.go(9 个测试)、remove_test.go(9 个测试 + 11 子用例)、system_tool_test.go(11 个测试)🤖 Generated with Claude Code