Skip to content

fix(hooks): sync auto-remember/recall classifier with MemWal#706 - #5

Merged
ducnmm merged 2 commits into
mainfrom
sync/claude-code-auto-memory-hooks
Aug 20, 2026
Merged

ducnmm merged 2 commits into
mainfrom
sync/claude-code-auto-memory-hooks

Conversation

@ducnmm

@ducnmm ducnmm commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Sync the Claude Code lifecycle hooks with MystenLabs/MemWal#706.

The marketplace plugin still had the old UserPromptSubmit heuristic:

  • "What do you remember about how I like to work?" was classified as remember because "I like" matched
  • "Can you remember that I always use pnpm?" would have been inverted to recall-only after a naive question check

This copy now matches the monorepo plugin:

  • Recall phrases: what do you remember / what you remember / what's my / etc.
  • Questions about stored facts inject memwal_recall only
  • Explicit save requests stay memwal_remember

Also notes in the setup skill that MEMORY.md writes mean hooks are not loaded, and bumps the plugin to 0.0.8.

Cold-start tool descriptions stay in @mysten-incubation/memwal-mcp. This repo only npxs that package.

Test plan

  • node --test test/*.test.mjs — 12/12
  • node --check on hook scripts
    EOF

Mirror the UserPromptSubmit and signal updates from
MystenLabs/MemWal#706 so this marketplace plugin does not keep the
old heuristic. Recall questions such as "what do you remember about
how I like to work" now inject memwal_recall. Explicit save requests
such as "Can you remember that I always use pnpm?" stay remember.

Bump plugin to 0.0.8. Note in the setup skill that MEMORY.md writes
mean the plugin hooks are not loaded.
@ducnmm
ducnmm requested a review from harrymove-ctrl August 19, 2026 13:07
Drop keyword classification. Inject the full decision rubric once per
session, then a one-line nudge. Quiet gate is 8 chars. Setup skill
wraps the CLAUDE.md routing block in memwal start/end markers and
requires user go-ahead before writing the global file.
@ducnmm

ducnmm commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

Synced with the latest MemWal#706 hook review: decision rubric once per session then a one-line nudge, 8-char quiet gate, CLAUDE.md start/end markers. Tests 11/11.

@harrymove-ctrl harrymove-ctrl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. I ran the suite at d6f54d0 locally: 11/11 pass, including the new session-scoped rubric-then-nudge tests and the terse Vietnamese case.

This is a good adaptation rather than a blind port. Three things I checked and liked:

  • firstTime("rubric", sessionId) plus DECISION_RUBRIC_NUDGE keeps the full rubric once per session and drops to one line afterwards, so the per-turn context cost stays small.
  • The 8-char threshold with the reasoning in the comment is the right call. "Tui thích pnpm" gets through and "ok" / "yes" stay quiet.
  • The <!-- memwal:start --> / <!-- memwal:end --> markers in skills/setup/SKILL.md, plus "show this block, get the user's go-ahead", make the ~/.claude/CLAUDE.md merge idempotent and consenting. Exactly right for an edit to a global user file.

Non-blocking notes, none of which need to hold this PR:

1. detectRecall / detectRemember are now dead code. on_user_prompt.mjs dropped the import, and on_post_tool.mjs only uses detectError, so no hook calls either function any more. This PR widens RECALL_INTENT with what do you remember, what's my, and friends, and adds a "canary remember prompt still fires remember" test, all for code nothing invokes. The green test gives false confidence that the canary path is covered. Either delete both detectors with their tests, or say in the comment that they are kept as a fallback for a future hook.

2. Drift against MemWal#706. That PR deleted the detectors outright, kept a 20-char threshold, and injects the full rubric every turn with no nudge. This repo keeps the detectors, uses 8 chars, and adds the nudge. This version is the better one, so it is worth pushing the threshold and nudge back into packages/mcp/plugin/ rather than letting the installed plugin and the in-repo copy diverge. Long term one of the two should be the source of truth.

3. Tiny. "ok thanks" is 9 characters, so it now clears the 8-char gate and gets the nudge. Harmless given how short the nudge is, just noting the tests only cover "ok" and "yes".

Not merging, leaving that to you.

@ducnmm
ducnmm merged commit aec6055 into main Aug 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants