-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrarian_session_start.py
More file actions
37 lines (29 loc) · 919 Bytes
/
librarian_session_start.py
File metadata and controls
37 lines (29 loc) · 919 Bytes
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
#!/usr/bin/env python3
"""SessionStart hook: check if there's unfiled scratch content from a previous session."""
import json
import sys
from pathlib import Path
SCRATCH = Path.home() / "NardoWorld/meta/scratch.md"
def main():
try:
json.load(sys.stdin)
except (json.JSONDecodeError, EOFError):
pass
if not SCRATCH.exists():
print("{}")
return
content = SCRATCH.read_text().strip()
if not content:
print("{}")
return
line_count = len(content.split("\n"))
print(json.dumps({
"systemMessage": (
f"NardoWorld: unfiled scratch log from previous session "
f"({line_count} lines at ~/NardoWorld/meta/scratch.md). "
f"Review it and file anything important to NardoWorld, "
f"then clear the file. Do this before starting new work."
)
}))
if __name__ == "__main__":
main()