Skip to content

Commit 97021cf

Browse files
authored
Merge pull request #469 from Moustachauve/chore/add-agents-guidelines
Add AGENTS.md guidelines for AI coding assistants
2 parents 951817e + 78ed89c commit 97021cf

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

‎AGENTS.md‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Coding Assistant Instructions: python-hilo Library
2+
3+
This repository contains `pyhilo`, a standalone asynchronous Python client library for Hilo energy services (SignalR WebSocket, GraphQL, and REST APIs).
4+
5+
## Git Commit Guidelines
6+
7+
- **First line**: Short, specific imperative sentence (e.g. "Add abstract auth interface for token provider"). No emojis in titles.
8+
- **Commit description**: Focus on the **WHY** (problem, context, and architectural rationale). Keep it concise, factual, and proportional.
9+
- **Do NOT amend, squash, or rebase commits that have already been pushed to the PR branch after the PR is opened**: Reviewers need to follow the commit history and see what changed since their last review.
10+
11+
## Development Commands
12+
13+
- Install dependencies: `uv sync`
14+
- Run test suite: `uv run pytest`
15+
- Run a specific test: `uv run pytest tests/test_device.py`
16+
- Check linting and formatting: `uv run ruff check .` and `uv run ruff format --check .`
17+
18+
## Architecture & Boundaries
19+
20+
- **Strict Decoupling from Home Assistant**:
21+
- This library MUST NEVER import `homeassistant` or depend on Home Assistant Core modules, constants, or types.
22+
- The library must be 100% installable, testable, and runnable independently in any standard Python 3.12+ environment.
23+
- **Authentication Contract**:
24+
- Expose an abstract base class `AbstractAuth` (`pyhilo.auth`):
25+
```python
26+
class AbstractAuth(ABC):
27+
@abstractmethod
28+
async def async_get_access_token(self) -> str:
29+
"""Return a valid access token, refreshing if necessary."""
30+
```
31+
- The library calls this method whenever it needs a valid token, leaving token storage and refresh mechanisms to the consumer (such as the Hilo Home Assistant integration or CLI tools).
32+
- **Backwards Compatibility**: When modifying public API signatures, provide temporary shims with deprecation warnings for at least 1–2 minor versions to prevent breaking downstream consumers.
33+
- **Credential Protection**: Never log raw access tokens, refresh tokens, passwords, or decoded JWT claims in `DEBUG` or `INFO` logs.
34+
35+
## Testing Standards
36+
37+
- Verify library protocol behavior, event decoding, device mapping, and error handling.
38+
- When writing tests or implementation code, ensure all parameters have precise type annotations. **The use of `Any` is strictly forbidden in new code.**
39+
- **Single purpose tests**: Each test function must verify only one specific behavior or outcome. Avoid testing multiple unrelated scenarios in a single test; split them into focused tests or use parametrization.
40+
- Prefer standard library `unittest.mock` (`AsyncMock`, `MagicMock`) over large bespoke stub classes.
41+
- Prefer `@pytest.mark.usefixtures` over unused fixture arguments.
42+
- Avoid branching (`if`/`else`) in tests; use `@pytest.mark.parametrize` with `pytest.param(..., id="...")` for table-driven testing.
43+
- Tests must execute cleanly with `uv run pytest` without requiring network access.
44+
45+
## Good practices
46+
47+
- Built with `asyncio`, `aiohttp`, `pysignalr`, and `gql`.
48+
- Non-blocking I/O: avoid any synchronous disk reads/writes on active event loops. Accept explicit file paths when managing state.
49+
- Keep `try` clauses as small as possible.
50+
- When validation guarantees a dict key exists, prefer direct key access (`data["key"]`) instead of `.get("key")`.
51+
- Keep comments concise and explain only the WHY. Do not restate code or use divider comments (`# --- XYZ ---`).
52+
- CalVer format: Versions follow `vYYYY.MM.MICRO` (e.g. `v2026.10.1`).
53+
54+
## AI policy
55+
56+
Autonomous contributions are not accepted. Every change must be reviewed and understood by a human contributor before submission. Never open pull requests, create release tags, or post comments autonomously without explicit contributor instruction.

0 commit comments

Comments
 (0)