drop turn_reaction.md: store_turn.py takes no args, outcome captured in next turn description

This commit is contained in:
Dejvino
2026-06-25 08:33:48 +02:00
parent 634e84b08b
commit 8a5072dcbd
3 changed files with 10 additions and 33 deletions
+8 -28
View File
@@ -1,12 +1,10 @@
#!/usr/bin/env python3
"""Append a turn to the story book and clear turn temp files.
"""Archive the current turn to the story book and clear turn temp files.
Usage:
python3 scripts/store_turn.py "Dillion stepped into the chamber..."
python3 scripts/store_turn.py < reaction.txt
python3 tools/store_turn.py
"""
import sys
from pathlib import Path
from datetime import date
@@ -14,39 +12,21 @@ SESSION = Path(__file__).resolve().parent.parent / 'session'
BOOK = SESSION / 'book.md'
TURN_DESC = SESSION / 'turn_description.md'
TURN_PROMPT = SESSION / 'turn_prompt.md'
TURN_REACTION = SESSION / 'turn_reaction.md'
CLEAR_FILES = [TURN_DESC, TURN_PROMPT, TURN_REACTION]
def get_reaction() -> str:
if len(sys.argv) > 1:
return sys.argv[1]
if not sys.stdin.isatty():
return sys.stdin.read().strip()
return ''
CLEAR_FILES = [TURN_DESC, TURN_PROMPT]
def main():
reaction = get_reaction()
if not reaction:
print("No reaction text provided. Pass as argument or pipe stdin.")
sys.exit(1)
description = TURN_DESC.read_text().strip() if TURN_DESC.exists() else ''
if not description:
print("Nothing to store — turn_description.md is empty.")
return
timestamp = date.today().isoformat()
entry_parts = []
if description:
entry_parts.append(description)
if reaction:
entry_parts.append(reaction)
entry = '\n\n'.join(entry_parts)
heading = f'\n\n## Turn — {timestamp}\n\n'
BOOK.parent.mkdir(parents=True, exist_ok=True)
with open(BOOK, 'a') as f:
f.write(heading + entry + '\n')
f.write(heading + description + '\n')
for fpath in CLEAR_FILES:
if fpath.exists():