Skip to content

v0.1.5

Choose a tag to compare

@nazroll nazroll released this 16 Sep 02:39
· 6 commits to main since this release
c589243

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.json file, which is now loaded and validated at runtime using Pydantic models in wzrdbrain.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.yml to 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-genai as a development dependency and set up the necessary environment for the translation automation.

JavaScript Implementation

  • Added a new src/wzrdbrain/wzrdbrain.src.js file that mirrors the Python logic, including data structures, rules, and the Trick class, as well as the generateCombo function. The JS code is generated to closely match the Python version for consistency and maintainability.

Codebase and Packaging Improvements

  • Updated pyproject.toml to include new dependencies, configure package data to include tricks.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.