-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrarian_realtime.py
More file actions
42 lines (32 loc) · 1.13 KB
/
librarian_realtime.py
File metadata and controls
42 lines (32 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
"""Stop hook: nudge Claude to file anything worth keeping to NardoWorld.
Fires after Claude's full response so it can capture atoms from the
complete exchange (user input + Claude's response), not just user input.
Tracks last_filed timestamp so /s synthesis knows what's already been filed.
"""
import json
import sys
import time
from pathlib import Path
LAST_FILED = Path.home() / "NardoWorld/meta/last_filed"
def main():
try:
hook_input = json.load(sys.stdin)
except (json.JSONDecodeError, EOFError):
hook_input = {}
# Don't fire if stop was due to error
stop_reason = hook_input.get("stop_reason", "")
if stop_reason in ("error", "api_error"):
print("{}")
return
# Update last_filed timestamp
try:
LAST_FILED.parent.mkdir(parents=True, exist_ok=True)
LAST_FILED.write_text(str(int(time.time())))
except OSError:
pass
# Per-turn filing removed — now handled by /s batch scan of transcript JSONL.
# This hook only updates last_filed timestamp for /s to know what's fresh.
print("{}")
if __name__ == "__main__":
main()