|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | +- `codex/` – Python package (public API in `__init__.py`, config, client, protocol models). |
| 5 | +- `crates/codex_native/` – PyO3 native extension built with maturin (pinned upstream deps). |
| 6 | +- `tests/` – `pytest` tests (`test_*.py`). |
| 7 | +- `scripts/` – codegen helpers (e.g., `generate_protocol_py.py`). |
| 8 | +- `.generated/ts/` – transient TypeScript protocol types. Do not commit hand edits. |
| 9 | +- Generated file: `codex/protocol/types.py` – do not edit; run `make gen-protocol`. |
| 10 | + |
| 11 | +## Build, Test, and Development Commands |
| 12 | +- Create venv: `make venv` then `. .venv/bin/activate`. |
| 13 | +- Format: `make fmt` (ruff format). |
| 14 | +- Lint: `make lint` (ruff check --fix + mypy). |
| 15 | +- Test: `make test` (pytest; skips if no native ext). |
| 16 | +- Build sdist/wheel: `make build` (uv build). |
| 17 | +- Native dev install: `make dev-native` (maturin develop or build+pip install). |
| 18 | +- Generate protocol: `make gen-protocol` (TS → Pydantic models). |
| 19 | +- Prebuild Linux wheels: `make wheelhouse-linux` (manylinux/musllinux via Docker). |
| 20 | + |
| 21 | +## Coding Style & Naming Conventions |
| 22 | +- Python 3.12+; type hints required. Line length target: 100. |
| 23 | +- Run `make fmt && make lint` before commits. |
| 24 | +- Ruff rules: `E,F,I,B,UP` (imports sorted). Mypy: strict-ish (no untyped defs). |
| 25 | +- Naming: modules `snake_case.py`, classes `PascalCase`, functions/vars `snake_case`. |
| 26 | +- Pydantic v2: prefer `BaseModel`; place `model_config = ConfigDict(extra='allow')` at class end. |
| 27 | + |
| 28 | +## Testing Guidelines |
| 29 | +- Framework: `pytest`. Test files: `tests/test_*.py`. |
| 30 | +- Write fast, deterministic tests; mock external I/O. Native-dependent tests already skip when the extension is unavailable. |
| 31 | +- Example: `uv run --group dev pytest -q` (or `make test`). |
| 32 | + |
| 33 | +## Commit & Pull Request Guidelines |
| 34 | +- Use Conventional Commits (e.g., `feat:`, `fix:`, `ci:`, `chore:`). Keep subject ≤72 chars. |
| 35 | +- PRs should include: clear description, linked issues, tests (or rationale), and docs/`CHANGELOG.md` updates when user‑visible. |
| 36 | +- Keep diffs focused; avoid touching generated files. |
| 37 | + |
| 38 | +## Security & Configuration Tips |
| 39 | +- Respect sandbox defaults; avoid introducing commands that assume unrestricted host access. |
| 40 | +- Publishing uses UV/PyPI tokens: `UV_PUBLISH_TOKEN` or `PYPI_API_TOKEN` (see `make publish`). |
| 41 | +- For local previews, you may set `CODEX_HOME` to a temp dir to isolate state. |
0 commit comments