| # AGENTS.md |
|
|
| ## Build, Lint, and Test Commands |
|
|
| ### Running Tests |
| ```bash |
| # No explicit test framework found - the project consists mainly of asset configuration files. |
| ``` |
|
|
| ### Code Style and Conventions |
|
|
| ### Python Code Style |
| - **Formatting**: Use standard PEP 8 style with 4-space indentation |
| - **Naming Conventions**: |
| - `ITEM` dictionary for object metadata (lowercase with underscores) |
| - `find_all_items()` and `extract_item_dict()` for function names (snake_case) |
| - `usda_path`, `desc_path`, `combined_dict` for variable names (snake_case) |
| - `ASSETS_PATH`, `CHROMA_DB_PATH`, `ASSETS_INDEX` for constants (uppercase_with_underscores) |
| - **Data Structure Style**: |
| - Use dictionary definitions with `ITEM = { ... }` format in `item.py` files |
| - Keep dictionaries nested with clear keys for objects, shapes, properties |
| - Use list format `["name", "position", "quaternion", "scale", "size", "type"]` consistently |
| - Include `description` key as empty dict `{}` when no description present |
| |
| ### Python Imports |
| - Import standard library modules at top of file: `os`, `ast`, `hashlib` |
| - Import pathlib for path operations: `from pathlib import Path` |
| - Use absolute imports for core functions |
| - No external library imports in asset files (only dictionaries) |
| |
| ### File Organization |
| - Asset files: `objects/{category}/{category}_{id}/{id}/item.py` |
| - Background files: `background/common/{category}/{category}_{id}/item.py` |
| - Keep `.usda`, `.usd`, `.json`, and texture files in same directory as corresponding item |
| - Organize by object category with unique identifiers |
|
|
| ### Code Organization Principles |
| ```python |
| # Dictionary-based configuration files |
| ITEM = { |
| "description": {}, # Optional description dict |
| "id": "{object_id}", # Unique identifier |
| "shapes": [ # List of mesh definitions |
| { |
| "name": "{shape_name}", # e.g., "bbox", "origin" |
| "position": [x, y, z], # Float position coordinates |
| "quaternion": [w, x, y, z],# Quaternion for rotation |
| "scale": [x, y, z], # Scale multipliers |
| "size": [x, y, z], # Physical dimensions |
| "type": "{geometry_type}", # e.g., "cube", "sphere" |
| } |
| ], |
| "size": [], # Additional size specification |
| "url": "path/to/object.usda" # Path to USD file |
| } |
| ``` |
|
|
| ### Error Handling |
| - Use try-except for file reading operations |
| - Print informational messages for warnings and errors |
| - Skip files with errors instead of raising exceptions |
| - Provide meaningful error messages with file paths |
|
|
| ### Type Hints |
| - Use standard Python types in function signatures |
| - Path objects with `Path` type hint |
| - Dictionary types with `dict` hint |
| - List types with `list` hint |
| - Number types with `float` or use `number` from typing |
|
|
| ### Documentation |
| - Document complex functions with docstrings |
| - Use descriptive comments for special cases |
| - Add error messages inline for critical operations |
| - Include WARN and ERROR prefixes for important messages |
|
|
| ### Asset Tools (Scripts) |
| The `tools/` directory contains helper scripts for validating and batch-updating asset USD. |
|
|
| **Detailed tool behavior (especially `compile.py`):** see [`tools/AGENTS.md`](tools/AGENTS.md). |
|
|
| - `tools/cleanup.py`: remove generated/cache files inside `assets/` subfolders. |
| - `tools/compile.py`: compile `Aligned.usda` + `item.py` from `object_parameters.json` / `Aligned.usd` (requires `--dir`; see `tools/AGENTS.md`). |
| - `tools/review_physics.py`: validate and update `PhysicsMaterial` friction parameters in `.usda` files. |
|
|
| ### Agent Docs (synced from tools/) |
| - `.agent/MODULE.CLEANUP_PY.md`: documentation for `tools/cleanup.py` |
| - `.agent/MODULE.REVIEW_PY.md`: documentation for `tools/review.py` |
|
|
| ### Agent Docs Sync Rules |
| - Whenever you change `tools/cleanup.py` or `tools/review.py`, update the corresponding module docs under `./.agent/`: |
| - `./.agent/MODULE.CLEANUP_PY.md` (for `tools/cleanup.py`) |
| - `./.agent/MODULE.REVIEW_PY.md` (for `tools/review.py`) |
|
|
| Recommendation for the agent: |
| - Re-generate/update the doc content based on `python3 tools/cleanup.py --help` and `python3 tools/review.py --help`. |
|
|
| Examples (run from `assets/` folder): |
| ```bash |
| python3 tools/review.py --func check --skip-omni6dpose --limit 100 |
| python3 tools/review.py --func check_update --static-friction 0.5 --dynamic-friction 0.3 --limit 100 |
| python3 tools/review.py --func print --limit 50 > physics_material_friction.txt |
| ``` |