### Install AddressablesToolsPy Source: https://github.com/anosu/addressablestoolspy/blob/main/README.md Use pip to install the library. ```shell pip install addressablestools ``` -------------------------------- ### Implement Compatibility Adapter Class Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Example of an adapter class mapping internal snake_case attributes to public PascalCase properties. ```python class CompatResourceLocation: def __init__(self, location: ResourceLocation) -> None: self._location = location @property def InternalId(self) -> str | None: return self._location.internal_id @property def ProviderId(self) -> str | None: return self._location.provider_id @property def Data(self) -> object: return wrap_legacy(self._location.data) ``` -------------------------------- ### Run test suite Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Execute the full test suite using uv. ```bash uv run pytest -q ``` -------------------------------- ### Run local release checks Source: https://github.com/anosu/addressablestoolspy/blob/main/PUBLISHING.md Execute these commands to verify the project state, update dependencies, and build the distribution before tagging a release. ```shell uv lock uv run python -m pytest -q uv run python -m ruff check . uv run python -m mypy uv build ``` -------------------------------- ### Execute Compatibility Tests Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Command to run the compatibility test suite using uv. ```bash uv run pytest tests/test_compat_api.py -q ``` -------------------------------- ### Run JSON parser tests Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Execute the test suite using uv. ```bash uv run pytest tests/test_json_parser.py -q ``` -------------------------------- ### List Obsolete Implementation Files Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Paths to be removed after verifying the compatibility layer. ```text src/AddressablesTools/Binary/ src/AddressablesTools/Catalog/ src/AddressablesTools/Classes/ src/AddressablesTools/JSON/ src/AddressablesTools/Reader/ src/AddressablesTools/constants.py src/AddressablesTools/parser.py ``` -------------------------------- ### Update Package Initialization Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Expose compatibility functions in the package root. ```python from AddressablesTools._compat import parse, parse_binary, parse_json Parser = None __version__ = "0.1.7" __all__ = ["classes", "parse", "parse_json", "parse_binary", "Parser"] ``` -------------------------------- ### Run Full Verification Suite Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Command to run the full test suite including legacy and new parser tests. ```bash uv run pytest tests/test_compat_api.py tests/test_json_parser.py tests/test_binary_parser.py -q ``` -------------------------------- ### Initialize Package Exports Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Exposes the primary parsing functions and types at the package level. ```python from addressablestools.parser import Handler, Patcher, parse, parse_binary, parse_json __version__ = "0.1.7" __all__ = [ "Handler", "Patcher", "parse", "parse_binary", "parse_json", ] ``` -------------------------------- ### Tag and push release Source: https://github.com/anosu/addressablestoolspy/blob/main/PUBLISHING.md Create a git tag matching the version and push it to the repository to trigger the publishing workflow. ```shell VERSION=X.Y.Z git tag "v${VERSION}" git push origin "v${VERSION}" ``` -------------------------------- ### Run verification tests Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Execute tests to verify the JSON parser implementation. ```bash uv run pytest tests/test_json_parser.py tests/test_public_api.py::test_parse_dispatches_json_text -q ``` -------------------------------- ### Commit packaging and documentation updates Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Stage and commit the removal of orjson and updated documentation. ```bash git add pyproject.toml uv.lock README.md tests/test_packaging.py tests/test_parse.py git commit -m "chore: remove orjson and document new package" ``` -------------------------------- ### Verify packaging and dependency removal Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Test suite to ensure orjson is removed and documentation reflects the new package structure. ```python from pathlib import Path def test_orjson_is_removed_from_project_files() -> None: root = Path(__file__).parents[1] searchable = [ root / "pyproject.toml", root / "src" / "addressablestools", root / "src" / "AddressablesTools", ] text = "\n".join( path.read_text(encoding="utf-8") for item in searchable for path in ([item] if item.is_file() else item.rglob("*.py")) ) assert "orjson" not in text def test_readme_documents_new_package_first() -> None: readme = Path("README.md").read_text(encoding="utf-8") assert "from addressablestools import parse" in readme assert "Legacy compatibility" in readme ``` -------------------------------- ### Commit changes to repository Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Stage and commit the compatibility layer implementation. ```bash git add src/AddressablesTools tests/test_compat_api.py git add -u src/AddressablesTools git commit -m "feat: replace legacy package with compatibility layer" ``` -------------------------------- ### Legacy compatibility Source: https://github.com/anosu/addressablestoolspy/blob/main/README.md Use the deprecated import path for existing projects during migration. ```python from pathlib import Path import AddressablesTools from AddressablesTools.classes import AssetBundleRequestOptions catalog = AddressablesTools.parse_json(Path("tests/samples/catalog.json").read_text("utf-8")) for key, locations in catalog.Resources.items(): if isinstance(key, str) and key.endswith(".bundle"): assert isinstance(locations[0].Data.Object, AssetBundleRequestOptions) print(locations[0].Data.Object.Crc) ``` -------------------------------- ### Parse binary catalogs Source: https://github.com/anosu/addressablestoolspy/blob/main/README.md Read and parse a binary-formatted catalog file. ```python from pathlib import Path from addressablestools import parse_binary catalog = parse_binary(Path("tests/samples/catalog.bin").read_bytes()) location = catalog.resources["Anim/Network"][0] print(location.primary_key) print(location.internal_id) print(location.provider_id) print(location.type.class_name if location.type else None) ``` -------------------------------- ### Verify legacy imports Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Search for remaining legacy imports or forbidden dependencies. ```bash rg "from \.|AddressablesTools\.(Binary|Catalog|Classes|JSON|Reader)|orjson|type: ignore" src tests pyproject.toml README.md ``` -------------------------------- ### Commit implementation changes Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Git commands to stage and commit the new binary reader implementation and its corresponding tests. ```bash git add src/addressablestools/binary.py tests/test_binary_reader.py git commit -m "feat: add safe binary catalog reader" ``` -------------------------------- ### Run linting check Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Run ruff to ensure code quality and linting standards. ```bash uv run ruff check . ``` -------------------------------- ### Configure Pytest Options Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Sets the source directory for pytest to ensure correct module resolution. ```toml [tool.pytest.ini_options] pythonpath = ["src"] testpaths = ["tests"] ``` -------------------------------- ### Define binary catalog parser tests Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Test suite for verifying binary catalog parsing, including bundle request options and custom patcher support. ```python from addressablestools import parse_binary, parse_json from addressablestools.models import AssetBundleRequestOptions, ContentCatalogData, WrappedSerializedObject def first_bundle(catalog: ContentCatalogData) -> tuple[str, WrappedSerializedObject[AssetBundleRequestOptions]]: for key, locations in catalog.resources.items(): if isinstance(key, str) and key.endswith(".bundle"): data = locations[0].data assert isinstance(data, WrappedSerializedObject) assert isinstance(data.object, AssetBundleRequestOptions) return key, data raise AssertionError("sample catalog must contain at least one bundle") def test_parse_binary_returns_pythonic_catalog(catalog_binary_bytes: bytes) -> None: catalog = parse_binary(catalog_binary_bytes) assert isinstance(catalog, ContentCatalogData) assert catalog.version in {1, 2} assert catalog.resources def test_parse_binary_decodes_bundle_request_options(catalog_binary_bytes: bytes) -> None: key, wrapped = first_bundle(parse_binary(catalog_binary_bytes)) assert key.endswith(".bundle") assert wrapped.object.crc > 0 assert wrapped.object.hash assert wrapped.object.bundle_name assert wrapped.object.bundle_size > 0 def test_json_and_binary_catalogs_agree_on_first_bundle(catalog_json_text: str, catalog_binary_bytes: bytes) -> None: json_key, json_wrapped = first_bundle(parse_json(catalog_json_text)) binary_key, binary_wrapped = first_bundle(parse_binary(catalog_binary_bytes)) assert binary_key == json_key assert binary_wrapped.object.crc == json_wrapped.object.crc assert binary_wrapped.object.hash == json_wrapped.object.hash assert binary_wrapped.object.bundle_name == json_wrapped.object.bundle_name assert binary_wrapped.object.bundle_size == json_wrapped.object.bundle_size def test_parse_binary_accepts_custom_patcher_and_handler(catalog_binary_bytes: bytes) -> None: calls: list[str] = [] def patcher(match_name: str) -> str | None: calls.append(match_name) return match_name catalog = parse_binary(catalog_binary_bytes, patcher=patcher) assert catalog.resources assert calls ``` -------------------------------- ### Implement binary string decoding logic Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Logic for determining string encoding and handling dynamic string reversal for catalog versions. ```python unicode = (encoded_offset & 0x80000000) != 0 dynamic = (encoded_offset & 0x40000000) != 0 and dynamic_separator != "\0" offset = encoded_offset & 0x3FFFFFFF ``` ```python if len(parts) > 1 and self.version > 1: parts.reverse() ``` -------------------------------- ### Commit Typed Catalog Models Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Git commands to stage and commit the newly implemented model files. ```bash git add src/addressablestools/models.py tests/test_models.py git commit -m "feat: add typed catalog models" ``` -------------------------------- ### Auto-detect catalog format Source: https://github.com/anosu/addressablestoolspy/blob/main/README.md Use the generic parse function to handle both JSON and binary inputs automatically. ```python from pathlib import Path from addressablestools import parse json_catalog = parse(Path("tests/samples/catalog.json").read_text(encoding="utf-8")) binary_catalog = parse(Path("tests/samples/catalog.bin").read_bytes()) print(len(json_catalog.resources)) print(len(binary_catalog.resources)) ``` -------------------------------- ### Update project configuration Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Updated pyproject.toml configuration for the addressablestools package. ```toml [project] name = "addressablestools" version = "0.1.7" authors = [{ name = "Jitsu", email = "jitsu233@gmail.com" }] description = "Python library for reading Unity Addressables catalog files" readme = "README.md" license = { file = "LICENSE" } requires-python = ">=3.12" dependencies = [] [dependency-groups] dev = ["pytest>=8.3.5", "ruff>=0.11.7"] [tool.pytest.ini_options] pythonpath = ["src"] testpaths = ["tests"] [tool.ruff] target-version = "py312" line-length = 100 ``` -------------------------------- ### Import New AddressablesTools API Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/specs/2026-07-04-addressablestools-rewrite-design.md Use these imports to access the updated, snake_case compliant API. ```python from addressablestools import parse, parse_json, parse_binary from addressablestools.models import ContentCatalogData, ResourceLocation ``` -------------------------------- ### Test Suite Directory Structure Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/specs/2026-07-04-addressablestools-rewrite-design.md The reorganized test directory structure for the AddressablesTools project. ```text tests/ test_public_api.py test_json_parser.py test_binary_parser.py test_decoder.py test_binary_reader.py test_compat_api.py samples/ ``` -------------------------------- ### Commit Changes Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Stages and commits the new files to the repository. ```bash git add pyproject.toml src/addressablestools tests/conftest.py tests/test_public_api.py git commit -m "test: add new public api contract" ``` -------------------------------- ### Parse JSON catalogs Source: https://github.com/anosu/addressablestoolspy/blob/main/README.md Read and parse a JSON-formatted catalog file. ```python from pathlib import Path from addressablestools import AssetBundleRequestOptions, parse_json data = Path("tests/samples/catalog.json").read_text(encoding="utf-8") catalog = parse_json(data) for key, locations in catalog.resources.items(): if not isinstance(key, str) or not key.endswith(".bundle"): continue options = locations[0].data_as(AssetBundleRequestOptions) print(f"Bundle {key}, Crc: {options.crc}, Hash: {options.hash}") ``` -------------------------------- ### Define JSON catalog parser tests Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Unit tests for verifying JSON catalog parsing and resource decoding. ```python from addressablestools import parse_json from addressablestools.models import AssetBundleRequestOptions, ContentCatalogData, WrappedSerializedObject def first_bundle(catalog: ContentCatalogData) -> tuple[str, WrappedSerializedObject[AssetBundleRequestOptions]]: for key, locations in catalog.resources.items(): if isinstance(key, str) and key.endswith(".bundle"): data = locations[0].data assert isinstance(data, WrappedSerializedObject) assert isinstance(data.object, AssetBundleRequestOptions) return key, data raise AssertionError("sample catalog must contain at least one bundle") def test_parse_json_returns_pythonic_catalog(catalog_json_text: str) -> None: catalog = parse_json(catalog_json_text) assert isinstance(catalog, ContentCatalogData) assert catalog.locator_id assert catalog.provider_ids assert catalog.internal_ids assert catalog.resource_types assert catalog.resources def test_parse_json_decodes_bundle_request_options(catalog_json_text: str) -> None: key, wrapped = first_bundle(parse_json(catalog_json_text)) assert key.endswith(".bundle") assert wrapped.object.crc > 0 assert wrapped.object.hash assert wrapped.object.bundle_name assert wrapped.object.bundle_size > 0 def test_parse_json_expands_internal_id_prefixes(catalog_json_text: str) -> None: catalog = parse_json(catalog_json_text) key, _wrapped = first_bundle(catalog) location = catalog.resources[key][0] assert location.internal_id is not None assert "#" not in location.internal_id[:3] assert location.provider_id is not None assert location.primary_key is not None ``` -------------------------------- ### Query resource locations Source: https://github.com/anosu/addressablestoolspy/blob/main/README.md Locate specific assets within a parsed catalog. ```python from pathlib import Path from addressablestools import parse_json catalog = parse_json(Path("tests/samples/catalog.json").read_text(encoding="utf-8")) asset_key = "Assets/Paripari/AddressableAssets/VFX Texture Assets/ParticleTextures/sparkle.png" asset_location = catalog.locate(asset_key)[0] print(asset_location.primary_key) print(asset_location.internal_id) print(asset_location.provider_id) if asset_location.dependency_key is not None: dependency_location = catalog.locate(asset_location.dependency_key)[0] print(dependency_location.primary_key) print(dependency_location.internal_id) ``` -------------------------------- ### Access Legacy PascalCase Attributes Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/specs/2026-07-04-addressablestools-rewrite-design.md Legacy attributes remain accessible for source compatibility. ```python catalog.Resources resource_location.Data.Object.Crc resource_location.ProviderId resource_location.InternalId ``` -------------------------------- ### Run Model Tests Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Command to execute the model tests using pytest. ```bash uv run pytest tests/test_models.py -q ``` -------------------------------- ### Define Binary Customization Callbacks Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/specs/2026-07-04-addressablestools-rewrite-design.md Type aliases for the patcher and handler functions used to customize binary catalog processing. ```python type Patcher = Callable[[str], str | None] type Handler = Callable[[CatalogBinaryReader, int, bool], object] ``` -------------------------------- ### Implement Parsing Stubs Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Provides the core parsing logic that dispatches to JSON or binary handlers based on input type. ```python from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING from addressablestools.exceptions import CatalogParseError if TYPE_CHECKING: from addressablestools.binary import CatalogBinaryReader from addressablestools.models import ContentCatalogData type Patcher = Callable[[str], str | None] type Handler = Callable[["CatalogBinaryReader", int, bool], object] def parse(data: str | bytes, patcher: Patcher | None = None, handler: Handler | None = None) -> "ContentCatalogData": if isinstance(data, str): return parse_json(data) if isinstance(data, bytes): return parse_binary(data, patcher=patcher, handler=handler) raise CatalogParseError(f"catalog input must be str or bytes, got {type(data).__name__}") def parse_json(data: str) -> "ContentCatalogData": from addressablestools.catalog import parse_json_catalog return parse_json_catalog(data) def parse_binary(data: bytes, patcher: Patcher | None = None, handler: Handler | None = None) -> "ContentCatalogData": from addressablestools.catalog import parse_binary_catalog return parse_binary_catalog(data, patcher=patcher, handler=handler) ``` -------------------------------- ### Custom binary object handling Source: https://github.com/anosu/addressablestoolspy/blob/main/README.md Register custom decoders or aliases for serialized object types in binary catalogs. ```python from pathlib import Path from addressablestools import DecoderRegistry, parse_binary from addressablestools.decoder import SerializedObjectDecoder registry = DecoderRegistry() registry.alias( "Custom.Assembly; Custom.AssetBundleRequestOptions", SerializedObjectDecoder.ASSET_BUNDLE_REQUEST_OPTIONS_MATCH_NAME, ) catalog = parse_binary(Path("catalog.bin").read_bytes(), registry=registry) ``` ```python from dataclasses import dataclass from pathlib import Path from addressablestools import BinaryDecodeContext, DecoderRegistry, parse_binary @dataclass(frozen=True) class CustomInt32Value: value: int registry = DecoderRegistry() @registry.register("Custom.Assembly; Custom.Int32Value") def decode_custom_int32(context: BinaryDecodeContext) -> CustomInt32Value: if context.is_default: return CustomInt32Value(0) context.reader.seek(context.offset) return CustomInt32Value(context.reader.read_int32()) catalog = parse_binary(Path("catalog.bin").read_bytes(), registry=registry) ``` -------------------------------- ### Import Compatibility AddressablesTools API Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/specs/2026-07-04-addressablestools-rewrite-design.md Use these imports to maintain compatibility with legacy codebases. ```python import AddressablesTools from AddressablesTools.classes import ContentCatalogData, AssetBundleRequestOptions ``` -------------------------------- ### Commit serialized object decoder Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Stage and commit the initial decoder files. ```bash git add src/addressablestools/decoder.py tests/test_decoder.py git commit -m "feat: add serialized object decoder" ``` -------------------------------- ### Commit JSON catalog parser Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Stage and commit the completed JSON catalog parser files. ```bash git add src/addressablestools/catalog.py tests/test_json_parser.py git commit -m "feat: parse json addressables catalogs" ``` -------------------------------- ### Define Legacy Compatibility Tests Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Tests to verify that the legacy API correctly returns PascalCase properties and dispatches to the new parser implementation. ```python import AddressablesTools from AddressablesTools.classes import AssetBundleRequestOptions, ContentCatalogData, CatalogBinaryReader def test_legacy_parse_json_returns_pascal_case_catalog(catalog_json_text: str) -> None: catalog = AddressablesTools.parse_json(catalog_json_text) assert isinstance(catalog, ContentCatalogData) assert catalog.Resources assert catalog.ProviderIds assert catalog.InternalIds def test_legacy_parse_binary_returns_pascal_case_bundle_data(catalog_binary_bytes: bytes) -> None: catalog = AddressablesTools.parse_binary(catalog_binary_bytes) for key, locations in catalog.Resources.items(): if isinstance(key, str) and key.endswith(".bundle"): location = locations[0] assert location.InternalId assert location.ProviderId assert isinstance(location.Data.Object, AssetBundleRequestOptions) assert location.Data.Object.Crc > 0 assert location.Data.Object.Hash return raise AssertionError("sample catalog must contain at least one bundle") def test_legacy_parse_dispatches_to_new_parser(catalog_json_text: str, catalog_binary_bytes: bytes) -> None: assert AddressablesTools.parse(catalog_json_text).Resources assert AddressablesTools.parse(catalog_binary_bytes).Resources def test_legacy_classes_exports_catalog_binary_reader() -> None: assert CatalogBinaryReader.__name__ == "CatalogBinaryReader" ``` -------------------------------- ### Test Public API Contract Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Verifies that the package exports the expected parsing functions and handles input types correctly. ```python import pytest import addressablestools from addressablestools import parse, parse_binary, parse_json from addressablestools.exceptions import CatalogParseError from addressablestools.models import ContentCatalogData def test_new_package_exports_parse_functions() -> None: assert addressablestools.parse is parse assert addressablestools.parse_json is parse_json assert addressablestools.parse_binary is parse_binary def test_parse_dispatches_json_text(catalog_json_text: str) -> None: catalog = parse(catalog_json_text) assert isinstance(catalog, ContentCatalogData) assert catalog.resources def test_parse_dispatches_binary_bytes(catalog_binary_bytes: bytes) -> None: catalog = parse(catalog_binary_bytes) assert isinstance(catalog, ContentCatalogData) assert catalog.resources def test_parse_rejects_unsupported_input_type() -> None: with pytest.raises(CatalogParseError, match="str or bytes"): parse({"not": "supported"}) # type: ignore[arg-type] ``` -------------------------------- ### Define Pytest Fixtures for Catalog Testing Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Provides session-scoped fixtures for loading sample catalog files from the tests directory. ```python from pathlib import Path import pytest @pytest.fixture(scope="session") def samples_dir() -> Path: return Path(__file__).parent / "samples" @pytest.fixture(scope="session") def catalog_json_text(samples_dir: Path) -> str: return (samples_dir / "catalog.json").read_text(encoding="utf-8") @pytest.fixture(scope="session") def catalog_binary_bytes(samples_dir: Path) -> bytes: return (samples_dir / "catalog.bin").read_bytes() ``` -------------------------------- ### Define Custom Exceptions Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Establishes a hierarchy of exceptions for catalog parsing and binary reading errors. ```python class AddressablesToolsError(Exception): """Base exception for addressablestools failures.""" class CatalogParseError(AddressablesToolsError): """Raised when catalog input cannot be parsed.""" class UnsupportedCatalogVersionError(CatalogParseError): """Raised when a binary catalog version is not supported.""" class UnsupportedSerializedObjectError(CatalogParseError): """Raised when a serialized object type is not supported.""" class BinaryReadError(CatalogParseError): """Raised when binary catalog data cannot be read safely.""" ``` -------------------------------- ### Export Compatibility Classes Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Update the classes module to export compatibility-wrapped classes. ```python from AddressablesTools._compat import ( CompatAssetBundleRequestOptions as AssetBundleRequestOptions, CompatCatalog as ContentCatalogData, CompatClassJsonObject as ClassJsonObject, CompatHash128 as Hash128, CompatObjectInitializationData as ObjectInitializationData, CompatResourceLocation as ResourceLocation, CompatSerializedType as SerializedType, CompatTypeReference as TypeReference, CompatWrappedSerializedObject as WrappedSerializedObject, ) from addressablestools.binary import CatalogBinaryReader from addressablestools.decoder import SerializedObjectDecoder __all__ = [ "WrappedSerializedObject", "ContentCatalogData", "ClassJsonObject", "SerializedType", "ResourceLocation", "ObjectInitializationData", "TypeReference", "Hash128", "AssetBundleRequestOptions", "SerializedObjectDecoder", "CatalogBinaryReader", ] ``` -------------------------------- ### Check worktree status Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Verify that the git worktree is clean. ```bash git status --short ``` -------------------------------- ### Commit binary parser changes Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Git commands to stage and commit the implemented binary parser files. ```bash git add src/addressablestools/binary.py src/addressablestools/catalog.py src/addressablestools/decoder.py tests/test_binary_parser.py git commit -m "feat: parse binary addressables catalogs" ``` -------------------------------- ### Unit tests for SerializedObjectDecoder Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Test suite for verifying v1 and v2 decoding logic and JSON parsing for AssetBundleRequestOptions. ```python from io import BytesIO import json import struct import pytest from addressablestools.binary import BinaryReader, CatalogBinaryReader, UINT32_MAX from addressablestools.decoder import SerializedObjectDecoder from addressablestools.exceptions import UnsupportedSerializedObjectError from addressablestools.models import AssetBundleRequestOptions, Hash128, TypeReference, WrappedSerializedObject def test_decode_v1_ascii_string() -> None: payload = bytes([SerializedObjectDecoder.ObjectType.ASCII_STRING.value]) payload += struct.pack(" None: payload = bytes([SerializedObjectDecoder.ObjectType.HASH128.value]) payload += bytes([4]) + b"abcd" assert SerializedObjectDecoder.decode_v1(BinaryReader(BytesIO(payload))) == Hash128("abcd") def test_decode_v1_type_reference() -> None: payload = bytes([SerializedObjectDecoder.ObjectType.TYPE.value]) payload += bytes([5]) + b"clsid" assert SerializedObjectDecoder.decode_v1(BinaryReader(BytesIO(payload))) == TypeReference("clsid") def test_asset_bundle_request_options_json_decodes_standard_library_json() -> None: options_json = json.dumps( { "m_Hash": "hash", "m_Crc": 123, "m_BundleName": "bundle", "m_BundleSize": 456, "m_Timeout": 1, "m_RedirectLimit": 2, "m_RetryCount": 3, "m_ChunkedTransfer": False, "m_AssetLoadMode": 1, "m_UseCrcForCachedBundle": True, "m_UseUWRForLocalBundles": False, "m_ClearOtherCachedVersionsWhenLoaded": True, } ) options = SerializedObjectDecoder.decode_asset_bundle_request_options_json(options_json) assert isinstance(options, AssetBundleRequestOptions) assert options.hash == "hash" assert options.crc == 123 assert options.bundle_name == "bundle" assert options.bundle_size == 456 assert options.common_info is not None assert options.common_info.version == 3 def test_decode_v2_calls_handler_when_patcher_returns_none() -> None: reader = CatalogBinaryReader(BytesIO(b"\x00" * 32), patcher=lambda _: None, handler=lambda _reader, offset, is_default: (offset, is_default)) reader.read_custom = lambda _offset, fetch: fetch() # type: ignore[method-assign] reader.seek = lambda _offset, _whence=0: None # type: ignore[method-assign] reader.read_uint32 = iter([8, UINT32_MAX]).__next__ # type: ignore[method-assign] reader.read_serialized_type = lambda _offset: type("FakeType", (), {"match_name": "Custom; System.Int32"})() # type: ignore[attr-defined, method-assign] assert SerializedObjectDecoder.decode_v2(reader, 0) == (UINT32_MAX, True) def test_decode_v2_raises_for_unsupported_type() -> None: reader = CatalogBinaryReader(BytesIO(b"\x00" * 32)) reader.read_custom = lambda _offset, fetch: fetch() # type: ignore[method-assign] reader.seek = lambda _offset, _whence=0: None # type: ignore[method-assign] reader.read_uint32 = iter([8, UINT32_MAX]).__next__ # type: ignore[method-assign] reader.read_serialized_type = lambda _offset: type("FakeType", (), {"match_name": "Custom; Unsupported"})() # type: ignore[attr-defined, method-assign] with pytest.raises(UnsupportedSerializedObjectError, match="Custom; Unsupported"): SerializedObjectDecoder.decode_v2(reader, 0) ``` -------------------------------- ### Test Typed Models Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Unit tests for verifying the behavior of various data models including SerializedType, Hash128, and ResourceLocation. ```python from addressablestools.models import ( AssetBundleRequestOptions, AssetLoadMode, ClassJsonObject, Hash128, ObjectInitializationData, ResourceLocation, SerializedType, TypeReference, WrappedSerializedObject, ) def test_serialized_type_match_name_uses_short_assembly_name() -> None: serialized_type = SerializedType( assembly_name="Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", class_name="UnityEngine.ResourceManagement.ResourceProviders.AssetBundleRequestOptions", ) assert serialized_type.assembly_short_name == "Unity.ResourceManager" assert serialized_type.match_name == ( "Unity.ResourceManager; " "UnityEngine.ResourceManagement.ResourceProviders.AssetBundleRequestOptions" ) def test_hash128_from_four_uint32_values_matches_existing_byte_order() -> None: value = Hash128.from_uint32s(0x11223344, 0x55667788, 0x99AABBCC, 0xDDEEFF00) assert value.value == "4433221188776655ccbbaa9900ffeedd" def test_resource_location_uses_pythonic_fields() -> None: resource_type = SerializedType("Assembly, Version=1.0.0.0", "ClassName") location = ResourceLocation( internal_id="bundle/path", provider_id="provider", dependency_key="dependency", dependencies=None, data=None, hash_code=123, dependency_hash_code=456, primary_key="primary", type=resource_type, ) assert location.internal_id == "bundle/path" assert location.provider_id == "provider" assert location.primary_key == "primary" assert location.type == resource_type def test_asset_bundle_request_options_defaults_are_typed() -> None: options = AssetBundleRequestOptions() assert options.hash == "" assert options.crc == 0 assert options.bundle_name is None assert options.bundle_size == 0 assert options.common_info is None def test_wrapped_serialized_object_keeps_type_and_object() -> None: serialized_type = SerializedType("Assembly, Version=1.0.0.0", "ClassName") wrapped = WrappedSerializedObject(type=serialized_type, object=TypeReference("clsid")) assert wrapped.type is serialized_type assert wrapped.object == TypeReference("clsid") def test_catalog_related_models_are_importable() -> None: serialized_type = SerializedType("Assembly, Version=1.0.0.0", "ClassName") obj = ObjectInitializationData(id="id", object_type=serialized_type, data=None) json_obj = ClassJsonObject(type=serialized_type, json_text="{}") assert obj.id == "id" assert json_obj.type == serialized_type assert AssetLoadMode.ALL_PACKED_ASSETS_AND_DEPENDENCIES.value == 1 ``` -------------------------------- ### Finalize rewrite commit Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Commit cleanup changes if verification steps required modifications. ```bash git add . git commit -m "chore: finalize addressablestools rewrite" ``` -------------------------------- ### Define Project Exception Hierarchy Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/specs/2026-07-04-addressablestools-rewrite-design.md The custom exception classes used to replace generic exceptions during catalog parsing and binary reading. ```python AddressablesToolsError CatalogParseError UnsupportedCatalogVersionError UnsupportedSerializedObjectError BinaryReadError ``` -------------------------------- ### Define binary reader unit tests Source: https://github.com/anosu/addressablestoolspy/blob/main/docs/superpowers/plans/2026-07-04-addressablestools-rewrite.md Tests for validating binary reading operations, including error handling for short reads and unsupported catalog versions. ```python from io import BytesIO import struct import pytest from addressablestools.binary import BinaryReader, CatalogBinaryHeader, CatalogBinaryReader, UINT32_MAX from addressablestools.exceptions import BinaryReadError, UnsupportedCatalogVersionError def test_binary_reader_raises_binary_read_error_on_short_read() -> None: reader = BinaryReader(BytesIO(b"\x01\x02")) with pytest.raises(BinaryReadError, match="expected 4 bytes"): reader.read_int32() def test_catalog_reader_rejects_invalid_offset_array_byte_size() -> None: data = struct.pack(" None: reader = CatalogBinaryReader(BytesIO(b"")) assert reader.read_offset_array(UINT32_MAX) == [] def test_binary_header_rejects_unsupported_version() -> None: header_bytes = struct.pack(" str: if self.assembly_name is None: raise ValueError("assembly_name is required") return self.assembly_name.split(",", 1)[0] @property def match_name(self) -> str: if self.class_name is None: raise ValueError("class_name is required") return f"{self.assembly_short_name}; {self.class_name}" @dataclass(frozen=True, slots=True) class TypeReference: clsid: str @dataclass(frozen=True, slots=True) class Hash128: value: str @classmethod def from_uint32s(cls, first: int, second: int, third: int, fourth: int) -> "Hash128": return cls(struct.pack("