fix: Hook无法自动更新 - #574
Open
Orsted290 wants to merge 2 commits into
Open
fix: Hook无法自动更新#574Orsted290 wants to merge 2 commits into
Orsted290 wants to merge 2 commits into
Conversation
App updates left previously installed Cursor, Claude Code, and Codex hooks on the first-install script. Startup now compares the stored hook fingerprint and reinstalls when it is missing or stale. Co-authored-by: Cursor <cursoragent@cursor.com>
syzsunshine219
changed the base branch from
memmy_1031/v1.2.0
to
release/v1.2.0
September 30, 2026 09:21
Keep the hook revision test beside the Cursor resume test renamed on v1.2.1. Co-authored-by: Cursor <cursoragent@cursor.com>
This branch has not been deployed
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.
这次修的是:Memmy 更新后,已经接入的 Hook 仍停在首次安装时的脚本。分支
fix-hook-auto-update,提交32c34374,基线是upstream/memmy_1031/v1.2.0。尚未推送,也没有建 PR。问题定位
截图版本是 1.1.5。新版本里的 Hook 不会写进用户已经接入的 Agent,除非手动卸载再安装。
桌面端启动、打开或激活主窗口时,只会调用自动接入。
agent-source-auto-inject-service.ts里,状态不是not_connected就直接跳过。第一次安装会把memmy-resume-hook.mjs和memmy-workspace-bridge.mjs写到 Agent 目录,并把状态记成plugin_installed。之后应用更新只换包内模板,不会再调用installPlugin。installPlugin本身可以覆盖这两个文件,缺的是更新后的检查。修复方案
用当前包会写出的 Hook 脚本和桥接文件计算 SHA-256,安装时写入旁边的
memmy-memory-config.json,字段是hook_revision。服务地址和 token 不参与计算。启动时对已经安装 Hook 的 Cursor、Claude Code、Codex 做比较。指纹缺失、不一致,或脚本文件不在,就直接再执行
installPlugin,不必先卸载。指纹相同则跳过。「发现新 Agent 时自动接入」关闭时,这次检查仍然会做。检查发生在窗口创建之后,不挡启动。自测样例
这是代表性样例,不是原用户环境的复现。后端 7 个文件、88 项测试通过,
npm run lint和npm run typecheck通过。合入集成分支后树没有变化,同一组测试再跑了一次,仍是 88 项通过。hook_revision、指纹被改成过期值,或 Hook 脚本被删掉时,判定为需要更新。再次安装后判定为当前版本。Cursor、Claude Code、Codex 都测了。本地打包安装自测
安装包:
/Users/haoyang/Documents/ChatGPT/memmy debug/memmy-agent/App/shell/desktop/release/Memmy-1.1.8-darwin-arm64-cn-unsigned.dmg约 375MB,Apple 芯片、中国区、未签名,版本号 1.1.8。包内包含这次的
hook_revision检查。本机「应用程序」里原来是 9 月 23 日的 Memmy,Cursor 和 Codex 的 Hook 没有指纹。Claude Code 没有已安装的 Hook。退出旧应用后换成今天的包,并把这两份配置的
hook_revision改成stale。第一次启动后,两份 Hook 都被重写,配置里的指纹与磁盘上的脚本、桥接文件一致:
88c2a7de405de42e57742829446a8e617563a44bd4549d59fa096bd160aaa8bde2d12413a5fc101aa94ad1a5889e68e2a66c63397d8e74de5dd2cb05e619e6f5退出后再打开一次,这 6 个文件的修改时间都没有变。