v0.1.5
This release introduces significant improvements to the wzrdbrain project by externalizing trick data, enhancing data validation, and automating the translation of core logic from Python to JavaScript. The changes increase maintainability, enable cross-language consistency, and streamline the build process with new CI automation. Below are the most important changes grouped by theme:
Data Externalization and Validation
- Trick definitions and rules have been moved from hardcoded Python constants to a new
tricks.jsonfile, which is now loaded and validated at runtime using Pydantic models inwzrdbrain.py. This makes the data easier to maintain and update. - The Python code now uses Pydantic for schema validation and type safety, ensuring that the trick data structure matches expectations and reducing runtime errors.
Cross-Language Consistency and Automation
- Introduced a new workflow job in
.github/workflows/ci.ymlto automatically translate the Python logic to JavaScript using a script (utils/translate2js.py). The generated JS file (wzrdbrain.src.js) is committed back to the branch if changes are detected, ensuring the JS version stays in sync with Python. - Added
google-genaias a development dependency and set up the necessary environment for the translation automation.
JavaScript Implementation
- Added a new
src/wzrdbrain/wzrdbrain.src.jsfile that mirrors the Python logic, including data structures, rules, and theTrickclass, as well as thegenerateCombofunction. The JS code is generated to closely match the Python version for consistency and maintainability.
Codebase and Packaging Improvements
- Updated
pyproject.tomlto include new dependencies, configure package data to includetricks.json, and exclude generated JS files from packaging. - Improved the logic for generating combos in Python to use the new data-driven approach and ensure only valid tricks are selected for each position in the combo.
These changes collectively modernize the codebase, improve reliability, and set the foundation for multi-language support and easier future enhancements.