Summary
Auto-memory hooks should not trigger unless the project has been initialized via /auto-memory:init. Running on uninitialized projects wastes resources and may cause confusion.
Problem
Currently, load_config() in post-tool-use.py returns a default config when no config file exists:
def load_config(project_dir: str) -> dict:
config_file = Path(project_dir) / ".claude" / "auto-memory" / "config.json"
if config_file.exists():
# ... load config
return {"triggerMode": "default"} # <-- defaults even when not initialized
This causes:
- Dirty files tracked on projects that have no auto-memory setup
- Stop hook may block and request memory-updater spawn on uninitialized projects
- Unnecessary file I/O and processing overhead
- Potential confusion when hooks fire unexpectedly
Proposed Solution
Treat missing config as "not enabled":
- post-tool-use.py: Exit early if config file doesn't exist
- stop.py: Exit early if config file doesn't exist
def load_config(project_dir: str) -> dict | None:
"""Load plugin configuration. Returns None if not initialized."""
config_file = Path(project_dir) / ".claude" / "auto-memory" / "config.json"
if not config_file.exists():
return None # Not initialized
# ... load and return config
# In main():
config = load_config(project_dir)
if config is None:
return # Project not initialized, skip
Affected Files
scripts/post-tool-use.py - add config existence check
scripts/stop.py - add config existence check (for consistency)
Summary
Auto-memory hooks should not trigger unless the project has been initialized via
/auto-memory:init. Running on uninitialized projects wastes resources and may cause confusion.Problem
Currently,
load_config()inpost-tool-use.pyreturns a default config when no config file exists:This causes:
Proposed Solution
Treat missing config as "not enabled":
Affected Files
scripts/post-tool-use.py- add config existence checkscripts/stop.py- add config existence check (for consistency)