### Install divicast Package Source: https://github.com/wangsquirrel/divicast/blob/main/README.md Install the library using pip or by cloning the repository and installing locally. ```bash pip install divicast ``` ```bash git clone https://github.com/wangsquirrel/divicast.git cd divicast pip install . ``` -------------------------------- ### Run Examples with uv Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Execute example scripts for Six-line divination and Eight-character birth charts using 'uv run python'. ```bash uv run python examples/sixline_example.py ``` ```bash uv run python examples/bazi_example.py ``` -------------------------------- ### Install and Run Dependencies with uv Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Use 'uv sync' to install dependencies and 'uv run' to execute Python commands, ensuring the correct environment is used. ```bash uv sync ``` ```bash uv run python ... ``` -------------------------------- ### Install Dependencies with uv Source: https://github.com/wangsquirrel/divicast/blob/main/CLAUDE.md Installs project dependencies using the uv package manager. Ensure uv is installed and configured. ```bash uv sync ``` -------------------------------- ### Refresh uv Dependencies Source: https://github.com/wangsquirrel/divicast/blob/main/CLAUDE.md Refreshes uv lock files and installs test dependencies. Run this after changes to pyproject.toml. ```bash uv sync --group test ``` -------------------------------- ### Create Divinatory Symbol Source: https://github.com/wangsquirrel/divicast/blob/main/docs/sixline_module.md Entry point for creating a divinatory symbol. Supports direct input of 6 yao results, automatic random generation, explicit start time, and explicit Bazi. If Bazi is not provided, it's generated from the start time. ```python DivinatorySymbol.create(cnts=None, now=None, bazi=None) ``` -------------------------------- ### Create Bazi (Four Pillars of Destiny) Chart Source: https://github.com/wangsquirrel/divicast/blob/main/README.md Example of creating a Bazi chart for a given birth date, time, and gender. The input datetime must be a naive datetime, representing the normalized charting time. ```python import datetime from divicast.birth_chart import BirthChart, Gender # Create a Bazi chart chart = BirthChart.create( datetime.datetime(1990, 8, 15, 14, 30, 0), gender=Gender.Male, ) # Output the Bazi chart in standardized JSON format print(chart.to_standard_output().model_dump_json(exclude_none=True)) ``` -------------------------------- ### Pydantic Data Model Example Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Shows the use of Pydantic for data validation, exemplified by the StandardBirthChartOutput schema. ```python # StandardBirthChartOutput: Main output schema with personal_info, natal_chart, luck_cycles, target_flow, relations # Uses Pydantic for validation ``` -------------------------------- ### Create and Draw Six Line Divination Symbol Source: https://github.com/wangsquirrel/divicast/blob/main/README.md Example of creating a Six Line divination symbol and displaying it in both rich text and JSON formats. Ensure time is normalized before passing to `DivinatorySymbol.create()`. ```python from divicast.sixline import DivinatorySymbol, rich_draw_divination, to_standard_format # Create a Six Line divination symbol d = DivinatorySymbol.create() # Output the divination symbol in text format rich_draw_divination(d) # Output the divination symbol in standardized JSON format print(to_standard_format(d).model_dump_json(exclude_none=True)) ``` -------------------------------- ### ValuedMultiton Base Class Example Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Illustrates the base class for creating enum-like divination symbols with Chinese names and values, located in base/symbol.py. ```python # Base ValuedMultiton class for enum-like divination symbols ``` -------------------------------- ### Rich Command-Line Divination Display Source: https://github.com/wangsquirrel/divicast/blob/main/docs/sixline_module.md Function to display divination results with rich formatting on the command line. Suitable for local debugging and example script demonstrations. ```python rich_draw_divination(ds) ``` -------------------------------- ### Build and Publish to PyPI with uv Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Commands for cleaning the uv cache, syncing dependencies, building the package, and uploading to PyPI. ```bash uv cache clean ``` ```bash uv sync --group test ``` ```bash uv build ``` ```bash twine upload dist/* ``` -------------------------------- ### Build Project Source: https://github.com/wangsquirrel/divicast/blob/main/CLAUDE.md Builds the source distribution and wheel packages for the project. The output is placed in the dist/ directory. ```bash uv build ``` -------------------------------- ### Run All Tests with uv Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Execute all unit tests using 'uv run python -m unittest'. CI uses the same command after syncing test dependencies. ```bash uv run python -m unittest ``` ```bash uv sync --group test && uv run python -m unittest ``` -------------------------------- ### GitHub Actions PyPI Publishing Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Notes on aligning GitHub Actions CI with local commands for building and publishing to PyPI, recommending Trusted Publishing. ```bash # Keep it aligned with CI: uv sync --group test, uv run python -m unittest, both examples, then uv build. PyPI should use Trusted Publishing for # the pypi environment instead of storing an API token secret in GitHub. ``` -------------------------------- ### Runtime Package Versioning Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Guidance on updating the runtime package version from package metadata in src/divicast/__init__.py, rather than hard-coding. ```python # Runtime package version is read from package metadata in `src/divicast/__init__.py`; update `pyproject.toml` rather than hard-coding `__version__`. ``` -------------------------------- ### Publish to PyPI Source: https://github.com/wangsquirrel/divicast/blob/main/CLAUDE.md Uploads the built project packages to the Python Package Index (PyPI). Requires PyPI credentials configured in ~/.pypirc. ```bash twine upload dist/* ``` -------------------------------- ### Run Specific Test File with uv Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md To run tests for a specific file, use 'uv run python -m unittest' followed by the test file path. ```bash uv run python -m unittest tests.test_geju ``` -------------------------------- ### Run All Tests with uv Source: https://github.com/wangsquirrel/divicast/blob/main/CLAUDE.md Executes all unit tests for the project using uv to manage the Python environment. This command is also used in CI. ```bash uv run python -m unittest ``` -------------------------------- ### Dependency Management Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Information on managing dependencies defined in pyproject.toml, ensuring compatibility with Python 3.12+. ```python # Dependencies are defined in `pyproject.toml`; keep versions compatible with Python 3.12+. ``` -------------------------------- ### Run Python with uv Source: https://github.com/wangsquirrel/divicast/blob/main/CLAUDE.md Executes Python scripts or snippets within the environment managed by uv. Always use this command instead of plain 'python' or 'python3' in this repository. ```bash uv run python ... ``` -------------------------------- ### Naming Conventions Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Details the naming conventions for classes (CapWords) and modules/files (snake_case), and test files/classes/methods. ```python # Use descriptive class names in `CapWords` and module/file names in `snake_case`. # Tests follow `tests/test_*.py` naming; test classes are `Test*` and methods are `test_*`. ``` -------------------------------- ### Factory Method Pattern Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Demonstrates the factory method pattern used for creating divination symbols and birth charts, involving assemble() and analyze() methods. ```python # BirthChart.create()DivinatorySymbol.create()/: Factory method that runs assemble() → analyze() ``` -------------------------------- ### CI Test Execution Source: https://github.com/wangsquirrel/divicast/blob/main/CLAUDE.md Command used in Continuous Integration to sync test dependencies and run unit tests. Ensures a consistent test environment. ```bash uv sync --group test && uv run python -m unittest ``` -------------------------------- ### Python Version and Indentation Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Specifies the required Python version (3.12+) and adherence to PEP 8 with 4-space indentation. ```python # Python 3.12+; follow standard PEP 8 with 4-space indentation. ``` -------------------------------- ### Tyme4py Calendar Calculations Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Highlights the use of the tyme4py library for calendar calculations, noting its importance for 八字 golden tests and the need for deliberate updates. ```python # tyme4py library for calendar calculations ``` -------------------------------- ### Create Birth Chart Source: https://github.com/wangsquirrel/divicast/blob/main/docs/bazi_module.md Use this function to create a Bazi birth chart object. It requires a naive datetime, gender, and optional calculation rules. The function automatically generates the four pillars, reads basic information like solar terms and zodiac signs, populates static fields, and executes the analysis process. ```python BirthChart.create(dt, gender, calc_rules=None) ``` -------------------------------- ### Clean uv Cache Source: https://github.com/wangsquirrel/divicast/blob/main/CLAUDE.md Clears the uv package cache. Use this command to free up disk space or resolve caching issues. ```bash uv cache clean ``` -------------------------------- ### Plain Command-Line Divination Display Source: https://github.com/wangsquirrel/divicast/blob/main/docs/sixline_module.md Function to display divination results with plain text formatting on the command line. Useful for basic command-line viewing and debugging. ```python plain_draw_divination(ds) ``` -------------------------------- ### Tyme4py Pinning Rationale Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Explains why tyme4py is pinned, due to its impact on 八字 golden tests and the requirement for deliberate updates to fixtures and boundary tests. ```python # `tyme4py` is pinned because 八字 golden tests depend on exact calendar/solar-term boundary behavior; update fixtures and boundary tests deliberately when changing it. ``` -------------------------------- ### Standard Divinatory Symbol Output Structure Source: https://github.com/wangsquirrel/divicast/blob/main/docs/sixline_module.md The unified output structure for the sixline module. It includes raw yao results, time information, Bazi, monthly/daily stems, empty stems, hexagram details, and detailed information for each of the 6 yaos. ```python StandardDivinatorySymbolOutput ``` -------------------------------- ### Draw Bazi Chart to Terminal Source: https://github.com/wangsquirrel/divicast/blob/main/docs/bazi_module.md This function renders a Bazi chart and its analysis to the terminal. It's useful for local debugging and quick checks. Pass a BirthChart object and an optional target datetime to see detailed output including basic info, chart face, analysis results, luck cycles, and target moment flow. ```python plain_draw_chart(birth_chart, target_dt=None) ``` -------------------------------- ### Schema and Data File Edits Source: https://github.com/wangsquirrel/divicast/blob/main/AGENTS.md Advises against editing schema/data files unless corresponding tests are also updated. ```python # Avoid editing schema/data files unless updating corresponding tests. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.