Skip to content

feat: add hooks.auto_save config toggle (silent mode)#711

Open
sha2fiddy wants to merge 5 commits intoMemPalace:developfrom
sha2fiddy:feature/494-silent-mode-auto-save-toggle
Open

feat: add hooks.auto_save config toggle (silent mode)#711
sha2fiddy wants to merge 5 commits intoMemPalace:developfrom
sha2fiddy:feature/494-silent-mode-auto-save-toggle

Conversation

@sha2fiddy
Copy link
Copy Markdown
Contributor

@sha2fiddy sha2fiddy commented Apr 12, 2026

Closes #494

Summary

  • Adds hooks.auto_save config toggle (default: true) to cleanly disable auto-save hook blocking without uninstalling hooks
  • Configurable via ~/.mempalace/config.json ({"hooks": {"auto_save": false}}) or MEMPALACE_HOOKS_AUTO_SAVE=false env var
  • Shortens block reason text from verbose 6-line instructions to concise single-line prompts — reduces UI noise while still naming the exact MemPalace tools to use and explicitly warning against native auto-memory files

Changes

File What
mempalace/config.py New hooks_auto_save property with env var override
mempalace/hooks_cli.py Checks config before blocking in hook_stop and hook_precompact; shortened STOP_BLOCK_REASON and PRECOMPACT_BLOCK_REASON
hooks/mempal_save_hook.sh Reads env var / config.json before blocking; shortened reason
hooks/mempal_precompact_hook.sh Same toggle + shortened reason
hooks/README.md Documents the new "Silent Mode" config option
tests/test_config.py 6 new tests for hooks_auto_save property + env var overrides
tests/test_hooks_cli.py 4 new tests for hooks respecting the config toggle

Test plan

  • All 598 existing tests pass
  • 10 new tests cover: config default, config file override, env var override (false, 0, no, true), stop hook disabled, stop hook enabled, precompact hook disabled, precompact hook enabled
  • Manual: set MEMPALACE_HOOKS_AUTO_SAVE=false, verify stop hook passes through
  • Manual: set config.json hooks.auto_save: false, verify precompact hook passes through

@sha2fiddy sha2fiddy marked this pull request as ready for review April 12, 2026 15:55
@sha2fiddy sha2fiddy force-pushed the feature/494-silent-mode-auto-save-toggle branch 2 times, most recently from 7b72200 to 2666a7b Compare April 13, 2026 23:55
@igorls igorls added area/hooks Claude Code hook scripts (Stop, PreCompact, SessionStart) area/install pip/uv/pipx/plugin install and packaging enhancement New feature or request labels Apr 14, 2026
@sha2fiddy sha2fiddy force-pushed the feature/494-silent-mode-auto-save-toggle branch from 2666a7b to 920f5e1 Compare April 14, 2026 13:06
@sha2fiddy sha2fiddy force-pushed the feature/494-silent-mode-auto-save-toggle branch from f4cc33d to 496a955 Compare April 20, 2026 13:38
@sha2fiddy sha2fiddy force-pushed the feature/494-silent-mode-auto-save-toggle branch 2 times, most recently from c2a419c to eace0ee Compare April 22, 2026 12:53
@sha2fiddy
Copy link
Copy Markdown
Contributor Author

Rebased on develop (9b35d9f); fixup commit eace0ee retargets the auto_save toggle at the new silent-save path. 1076/1076 tests pass.

@sha2fiddy sha2fiddy force-pushed the feature/494-silent-mode-auto-save-toggle branch 2 times, most recently from 0de2a6e to 68d3df5 Compare April 29, 2026 21:26
Add a clean opt-out for auto-save hook blocking (closes MemPalace#494).

- New `hooks.auto_save` config option (default: true) in
  ~/.mempalace/config.json and MEMPALACE_HOOKS_AUTO_SAVE env var
- When disabled, stop and precompact hooks pass through without blocking
- Shorten block reason text from 6-line instructions to single-line
  prompts — reduces UI noise while keeping tool names explicit
- Both Python (hooks_cli.py) and standalone shell scripts respect the
  toggle via config file or env var

# Conflicts:
#	mempalace/hooks_cli.py
#	tests/test_hooks_cli.py
- Add parenthetical hints to block reasons so AI knows what each tool
  saves (session summary, quotes/decisions/code)
- Remove dead config file creation from test_stop_hook_disabled_by_config
- Add missing test for MEMPALACE_HOOKS_AUTO_SAVE=no env var
- Replace bare except: with except Exception: in shell scripts
test_precompact_hook_enabled_by_default asserted
result["decision"] == "block", but hook_precompact has never emitted
decision — it mines synchronously and returns {}. Assertion was
copy-pasted from the stop-hook test. Fix to assert result == {} with
_mine_sync mocked so the test verifies the real contract (enabled →
mine + pass through) without actually mining.

Plus ruff format on 6 test files the CI pin flagged.
@sha2fiddy sha2fiddy force-pushed the feature/494-silent-mode-auto-save-toggle branch from 68d3df5 to e4a8352 Compare April 29, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/hooks Claude Code hook scripts (Stop, PreCompact, SessionStart) area/install pip/uv/pipx/plugin install and packaging enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add a "Silent Mode" / Background Processing for the Stop Hook (Auto-save)

2 participants