Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit 01ed2c8

Browse files
committed
feat(hooks): add UserPromptSubmit hook handler
- user_prompt_handler.py: Full handler with signal detection pipeline - AUTO capture for high-confidence signals (≥0.95) - SUGGEST for medium-confidence (0.7-0.95) - XML-formatted suggestions for additionalContext - Non-blocking error handling - hooks/user_prompt.py: Wrapper script delegating to handler
1 parent 598ef48 commit 01ed2c8

2 files changed

Lines changed: 410 additions & 0 deletions

File tree

hooks/user_prompt.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python3
2+
"""Hook: Detect memorable content in user prompts.
3+
4+
This hook detects signals indicating memorable content (decisions, learnings,
5+
blockers, etc.) in user prompts and either captures automatically or suggests
6+
capture to the user.
7+
8+
The hook uses pattern-based signal detection combined with novelty checking
9+
to avoid duplicate captures.
10+
11+
Environment Variables:
12+
HOOK_ENABLED: Master switch for hooks (default: true)
13+
HOOK_USER_PROMPT_ENABLED: Enable this hook (default: true)
14+
HOOK_DEBUG: Enable debug logging (default: false)
15+
16+
Exit codes:
17+
0 - Success (non-blocking)
18+
"""
19+
20+
from __future__ import annotations
21+
22+
import sys
23+
24+
25+
def main() -> None:
26+
"""Main hook entry point.
27+
28+
Delegates to the user_prompt_handler module for actual processing.
29+
Falls back gracefully if the library is not installed.
30+
"""
31+
try:
32+
from git_notes_memory.hooks.user_prompt_handler import main as handler_main
33+
34+
handler_main()
35+
except ImportError:
36+
# Library not installed, exit silently (non-blocking)
37+
import json
38+
39+
print(json.dumps({"continue": True}))
40+
sys.exit(0)
41+
except Exception:
42+
# Any unexpected error, exit silently (non-blocking)
43+
import json
44+
45+
print(json.dumps({"continue": True}))
46+
sys.exit(0)
47+
48+
49+
if __name__ == "__main__":
50+
main()

0 commit comments

Comments
 (0)