|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | + |
| 5 | +- This directory (`openhands-sdk/openhands/sdk/`) contains the core Python SDK under the `openhands.sdk.*` namespace. |
| 6 | +- Keep new modules within the closest existing subpackage (e.g., `llm/`, `tool/`, `event/`, `agent/`) and follow local naming patterns. |
| 7 | +- Add/adjust unit tests under `tests/sdk/` mirroring the SDK path (for example, changes to `openhands-sdk/openhands/sdk/tool/tool.py` should be covered in `tests/sdk/tool/test_tool.py`). |
| 8 | + |
| 9 | +## Build, Test, and Development Commands |
| 10 | + |
| 11 | +- `make build`: sets up the dev environment (runs `uv sync --dev` and installs pre-commit hooks). |
| 12 | +- `make lint` / `make format`: run Ruff linting and formatting. |
| 13 | +- `uv run pre-commit run --files <path>`: run the pre-commit checks for files you changed. |
| 14 | +- `uv run pytest tests/sdk -k <pattern>`: run targeted SDK tests; prefer running the smallest relevant test set first. |
| 15 | + |
| 16 | +## Coding Style & Naming Conventions |
| 17 | + |
| 18 | +- Python target is 3.12; keep code Ruff-compliant (line length 88). |
| 19 | +- Prefer explicit, accurate type annotations; use Pyright for type checking (do not add mypy). |
| 20 | +- Avoid `# type: ignore` unless there is no reasonable typing fix. |
| 21 | +- Keep imports at the top of files; avoid `sys.path` hacks and in-line imports unless required for circular dependencies. |
| 22 | +- When changing Pydantic models or serialized event shapes, preserve backward compatibility so older persisted data can still load. |
| 23 | + |
| 24 | +## Testing Guidelines |
| 25 | + |
| 26 | +- Prefer real code paths over mocks; introduce fixtures in `tests/conftest.py` when setup is repeated. |
| 27 | +- Keep tests minimal and focused on the changed behavior; avoid adding broad integration tests unless required. |
| 28 | + |
| 29 | +## Commit & Pull Request Guidelines |
| 30 | + |
| 31 | +- Follow the repository’s existing commit style (short, imperative subjects; use scope prefixes like `fix(sdk):` when helpful). |
| 32 | +- Keep PRs focused; update docs and tests when changing public APIs or user-facing behavior. |
0 commit comments