docs: fix HOOKS_TUTORIAL.md paths, matcher, and missing timeout

Fixes four issues causing silent hook failures:

1. **Relative paths** → Absolute paths (/absolute/path/to/hooks/...)
   Claude Code resolves hooks from working directory, not repo root.

2. **Wrong matcher** → Stop uses *, PreCompact has no matcher
   PreCompact doesn't use matcher (only Stop hooks do).

3. **Missing timeout** → Added timeout: 30 to both hooks
   Matches hooks/README.md specification.

4. **Ambiguous target** → Specified ~/.claude/settings.local.json
   Clarified global vs project-scoped config.

Also added executable chmod instructions and path replacement note.

Fixes #1037
This commit is contained in:
wahajahmed010
2026-04-22 11:31:40 +02:00
parent 9b35d9f760
commit b595cb3978
+21 -6
View File
@@ -7,27 +7,42 @@ MemPalace hooks act as an "Auto-Save" feature. They help your AI keep a permanen
* **PreCompact Hook** (`mempal_precompact_hook.sh`): Saves your context right before the AI's memory window fills up. * **PreCompact Hook** (`mempal_precompact_hook.sh`): Saves your context right before the AI's memory window fills up.
### 2. Setup for Claude Code ### 2. Setup for Claude Code
Add this to your configuration file to enable automatic background saving: Add this to `~/.claude/settings.local.json` (global) or `.claude/settings.local.json` (project-scoped) to enable automatic background saving:
```json ```json
{ {
"hooks": { "hooks": {
"Stop": [ "Stop": [
{ {
"matcher": "", "matcher": "*",
"hooks": [{"type": "command", "command": "./hooks/mempal_save_hook.sh"}] "hooks": [{
"type": "command",
"command": "/absolute/path/to/hooks/mempal_save_hook.sh",
"timeout": 30
}]
} }
], ],
"PreCompact": [ "PreCompact": [
{ {
"matcher": "", "hooks": [{
"hooks": [{"type": "command", "command": "./hooks/mempal_precompact_hook.sh"}] "type": "command",
"command": "/absolute/path/to/hooks/mempal_precompact_hook.sh",
"timeout": 30
}]
} }
] ]
} }
} }
``` ```
Make the hooks executable:
```bash
chmod +x /absolute/path/to/hooks/mempal_save_hook.sh
chmod +x /absolute/path/to/hooks/mempal_precompact_hook.sh
```
**Note:** Replace `/absolute/path/to/hooks/` with the actual path where you cloned the MemPalace repository (e.g., `~/projects/mempalace/hooks/`).
### 3. What changed (v3.1.0+) ### 3. What changed (v3.1.0+)
Both hooks now have **two-layer capture**: Both hooks now have **two-layer capture**:
@@ -48,4 +63,4 @@ mempalace mine ~/.claude/projects/ --mode convos
- **`SAVE_INTERVAL=15`** — How many human messages between saves - **`SAVE_INTERVAL=15`** — How many human messages between saves
- **`MEMPALACE_PYTHON`** — Python interpreter with mempalace + chromadb. Auto-detects: env var → repo venv → system python3 - **`MEMPALACE_PYTHON`** — Python interpreter with mempalace + chromadb. Auto-detects: env var → repo venv → system python3
- **`MEMPAL_DIR`** — Optional directory for auto-ingest via `mempalace mine` - **`MEMPAL_DIR`** — Optional directory for auto-ingest via `mempalace mine`