From e9a1187f34962e58ff3769e480ebf73107a8fb87 Mon Sep 17 00:00:00 2001 From: Dejvino Date: Tue, 30 Jun 2026 19:40:58 +0200 Subject: [PATCH] Refactor tools --- AGENTS.md | 4 ++-- pre-commit.sh | 8 +++++++- tools/{paths.py => config_paths.py} | 2 +- tools/{draw.py => draw_card.py} | 12 ++++++------ tools/prompts.py | 2 +- tools/{roll.py => roll_dice.py} | 14 +++++++------- tools/test_imports.py | 2 +- 7 files changed, 25 insertions(+), 19 deletions(-) rename tools/{paths.py => config_paths.py} (92%) rename tools/{draw.py => draw_card.py} (89%) rename tools/{roll.py => roll_dice.py} (89%) diff --git a/AGENTS.md b/AGENTS.md index 7592979..a380e78 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -28,9 +28,9 @@ the-chaos/ │ ├── engine.py # Game engine (prompt builder, LLM client, parser, state) │ ├── run.py # TUI (Textual app, game loop, narrative, input) │ ├── ambience.py # CLI shortcut for ambience switching -│ ├── draw.py # Card drawing tool +│ ├── draw_card.py # Card drawing tool │ ├── music-fetch.py # YouTube audio downloader -│ ├── roll.py # Dice rolling tool +│ ├── roll_dice.py # Dice rolling tool │ ├── store_turn.py # DEPRECATED — use engine.py archive_turn instead │ ├── test_imports.py # Import validation test │ └── test_runtime.py # Runtime import test diff --git a/pre-commit.sh b/pre-commit.sh index 57f151c..8ea292f 100755 --- a/pre-commit.sh +++ b/pre-commit.sh @@ -1,7 +1,13 @@ #!/bin/bash ERRORS=$(python3 -c "import os; [f for f in os.listdir('./tools') if f.endswith('.py') and os.path.getsize(os.path.join('./tools', f)) > 2048]") if [ -z "$ERRORS" ]; then - echo "OK" + echo "Compiling tools/*.py..." + if python3 -m compileall tools/*.py; then + echo "OK" + else + echo "Compilation failed" + exit 1 + fi else echo "You need to refactor this:" echo "$ERRORS" diff --git a/tools/paths.py b/tools/config_paths.py similarity index 92% rename from tools/paths.py rename to tools/config_paths.py index 3b71b26..334eb2c 100644 --- a/tools/paths.py +++ b/tools/config_paths.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -paths.py — Path constants for The Chaos game engine. +config_paths.py — Path constants for The Chaos game engine. Shared by engine.py, run.py, and all sub-modules. """ diff --git a/tools/draw.py b/tools/draw_card.py similarity index 89% rename from tools/draw.py rename to tools/draw_card.py index a367b3a..af28606 100755 --- a/tools/draw.py +++ b/tools/draw_card.py @@ -1,18 +1,18 @@ #!/usr/bin/env python3 """ -draw.py — Draw a card from The Chaos deck. +draw_card.py — Draw a card from The Chaos deck. Usage: - python3 draw.py [count] + python3 draw_card.py
[count] Decks: souls, cook, creatures, curiosities Tables: see the YAML files (e.g. traits, rumours, type, drink_or_drug) Examples: - python3 draw.py souls thing - python3 draw.py cook rumours 3 - python3 draw.py creatures type appearance - python3 draw.py curiosities creepy_vibe + python3 draw_card.py souls thing + python3 draw_card.py cook rumours 3 + python3 draw_card.py creatures type appearance + python3 draw_card.py curiosities creepy_v_vibe """ import sys diff --git a/tools/prompts.py b/tools/prompts.py index d34e048..59940ec 100644 --- a/tools/prompts.py +++ b/tools/prompts.py @@ -29,7 +29,7 @@ Wrap in ```tool to perform an action: - **world_update** — content: "full world" (if NPCs/locations/threads change) - **journal_update** — add: [...], done: [...] -You have the full state above — no need to look anything up. Just write the story and use tools when the player's action changes something. +You have the full state above — no need to look anything up. Just write the story and use tools when the player's action changes something. If a player action is impossible (e.g. they try to use an item they don't have), narrate the failure and DO NOT use any state-changing tools. ## State diff --git a/tools/roll.py b/tools/roll_dice.py similarity index 89% rename from tools/roll.py rename to tools/roll_dice.py index 2ea9efb..090dec8 100755 --- a/tools/roll.py +++ b/tools/roll_dice.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 """ -roll.py — Roll dice for The Chaos TTRPG. +roll_dice.py — Roll dice for The Chaos TTRPG. Usage: - python3 roll.py [modifier] + python3 roll_dice.py [modifier] Formulas: 1d6 Roll 1 six-sided die @@ -18,11 +18,11 @@ Modifier: +/- number added to total Examples: python3 roll.py 1d6 - python3 roll.py 3d6 - python3 roll.py 2d6x10 - python3 roll.py odds - python3 roll.py trait 9 - python3 roll.py 1d6 +1 + python3 roll_dice.py 3d6 + python3 roll_dice.py 2d6x10 + python3 roll_dice.py odds + python3 roll_dice.py trait 9 + python3 roll_dice.py 1d6 +1 """ import sys diff --git a/tools/test_imports.py b/tools/test_imports.py index d4d5b8c..af01b6a 100755 --- a/tools/test_imports.py +++ b/tools/test_imports.py @@ -7,7 +7,7 @@ import ast MODULES = [ 'engine.py', - 'paths.py', + 'config_paths.py', 'models.py', 'prompts.py', 'state.py',