Repository navigation
feat(desktop): 记忆写满改为搬入遗忘区,并补取回 / 合并 / 体检三件配套工具 - #63
Merged
sqfcyily merged 1 commit intoNov 17, 2026
Merged
Conversation
moxuyio1024
force-pushed
the
feat/memory-archive
branch
from
November 16, 2026 11:37
83cdee9 to
0b18fa8
Compare
memory.json 的条目会随消息注入上下文,有总字数预算(全局 4000 / 项目 3000)。写满时原先直接拒写, 于是最早期不再使用的条目永远占着位置,新经验反而写不进去。改成:写满时把最久未用的条目原文整条 搬进遗忘区(~/.deva/memory-archive*.json,与 memory.json 分开,故不吃注入预算),主记忆里只留一行索引。 - 淘汰排序用真实使用信号:listing.ts 在清单真正产出时记 lastSeenAt / seenCount,先淘汰最久未被注入的。 - memory_recall 按关键词或归档 id 前缀查遗忘区并返回完整原文;界面「记忆」页加遗忘区列表与取回按钮。 - memory_merge 把 2~5 条相近记忆合成一条,原文全部先搬进遗忘区,合并不丢信息。 - memory_check 只出建议不动手;memory_tidy 按用量阈值自动搬久未使用的、并按顺序无损拼接重复条目 (不做语义改写,故允许无人值守)。 - 工具目录同步分类:recall / check 归读类可并发;merge / write / delete 归写类且排除在无人值守之外。 验证:corepack pnpm typecheck / build 通过;与胶囊补丁互不依赖,可单独应用。
moxuyio1024
force-pushed
the
feat/memory-archive
branch
from
November 16, 2026 11:41
0b18fa8 to
447ddb3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
记忆写满时只会拒写,旧条目永远不会消失——长时间用下来,主记忆里堆的都是最早期那些不再用的内容,真正新的经验反而写不进去。这个补丁把「写满」从拒写改成搬家,并补上取回、合并、体检三件配套的事。
改动
~/.deva/memory-archive.json,项目记忆在同目录的memory-archive-<key>.json),主记忆里只留一行索引m_archive/p_archive。归档区不吃注入预算,所以主文件体积恒定、上下文里只有那一行。lastSeenAt/seenCount(listing.ts在真正产出清单时记一次,diff 为 null 不记)。淘汰先按「最久没被注入」挑,同分按条数/字数。memory_recall按关键词或归档 id 前缀查遗忘区,返回完整原文;界面「记忆」页新增遗忘区列表与「取回」按钮(memory:archive/memory:restore两个 IPC)。memory_merge把 2~5 条相近记忆合成一条,原文全部先进遗忘区(不丢),主记忆只留合并后的那句。memory_check只出建议不动手;memory_tidy按用量阈值自动搬走久未使用的、并按顺序无损拼接重复条目(不做语义改写,故允许无人值守)。memory_recall/memory_check归读类可并发,memory_merge/memory_write/memory_delete归写类且排除在无人值守之外(防止定时任务抓取的外部内容污染记忆)。为什么不删原文
记忆是跨会话累积的经验,删掉就不可恢复。把「满了」变成「搬家」,旧条目仍在磁盘上、可随时取回,代价只是主记忆里多一行索引(约 40 字)。这是这个补丁唯一的设计取舍。
验证
corepack pnpm typecheck与corepack pnpm build通过(与 CI 同两步)。main工作树上应用成功、编译通过。