|
1 | | -# AGENTS |
| 1 | +# Agents Guide for Sons of PHP Monorepo |
2 | 2 |
|
3 | | -This repository contains multiple projects and tools that are maintained here. |
| 3 | +This repository is a PHP monorepo containing many packages under `src/`. This guide provides consistent instructions for AI coding agents to work safely and effectively across the codebase. |
4 | 4 |
|
5 | 5 | - Use clear variable names and keep code well documented. |
6 | 6 | - Run tests relevant to the areas you change. |
7 | 7 | - For changes under `tools/chorale`, run `composer install` and `./vendor/bin/phpunit` in that directory before committing. |
8 | 8 | - Chorale is the monorepo management CLI using a plan/apply workflow; see `tools/chorale/AGENTS.md` for its roadmap and guidelines. |
9 | 9 |
|
| 10 | +## Repo Layout |
| 11 | + |
| 12 | +- Root: build tooling (`Makefile`, composer), shared configs, CI inputs. |
| 13 | +- Code: packages live under `src/SonsOfPHP/*`, typically with `src/` and `Tests/` subfolders. |
| 14 | +- Docs: developer documentation in `docs/` with a GitBook-style `SUMMARY.md`. |
| 15 | +- Tools: development tools vendored under `tools/` (phpunit, psalm, rector, php-cs-fixer, etc.). |
| 16 | + |
| 17 | +## Ground Rules |
| 18 | + |
| 19 | +- Prefer minimal, targeted changes; avoid refactors beyond the task scope. |
| 20 | +- Never edit anything under any `vendor/` directory or generated artifacts like `dist/`. |
| 21 | +- Maintain backward compatibility for public APIs unless explicitly instructed otherwise. |
| 22 | +- Update relevant docs under `docs/` when behavior or public APIs change. |
| 23 | +- Keep code style consistent; use provided tooling to format, lint, and check types. |
| 24 | + |
| 25 | +## Setup |
| 26 | + |
| 27 | +- Install dependencies once at the repo root: |
| 28 | + - `make install` |
| 29 | + |
| 30 | +## Common Tasks |
| 31 | + |
| 32 | +- Run tests (entire repo): |
| 33 | + - `make test` |
| 34 | +- Run tests (limit to a package): |
| 35 | + - `PHPUNIT_OPTIONS='path/to/package/Tests' make test` |
| 36 | +- Code style (dry-run): |
| 37 | + - `make php-cs-fixer` |
| 38 | +- Static analysis (Psalm): |
| 39 | + - `make psalm` |
| 40 | +- Rector & style upgrades (may modify files): |
| 41 | + - `make upgrade-code` |
| 42 | +- Lint PHP syntax: |
| 43 | + - `make lint` |
| 44 | +- Coverage report: |
| 45 | + - `make coverage` |
| 46 | + |
| 47 | +## When Editing a Package |
| 48 | + |
| 49 | +- Work inside that package directory (e.g. `src/SonsOfPHP/Component/Clock`). |
| 50 | +- Put new source under that package’s `src/`; add tests under its `Tests/`. |
| 51 | +- Use the package-focused test command above to tighten feedback cycles. |
| 52 | + |
| 53 | +## Documentation |
| 54 | + |
| 55 | +- Update `docs/` to reflect user-facing changes. |
| 56 | +- Add or modify the most relevant page (e.g., `docs/components/*.md`, `docs/contracts/*.md`, or `docs/symfony-bundles/*.md`). |
| 57 | +- If adding a new page, ensure it’s listed in `docs/SUMMARY.md`. |
| 58 | + |
| 59 | +## Pull Request Checklist |
| 60 | + |
| 61 | +- Build passes: `make test` (optionally with coverage). |
| 62 | +- Code quality passes: `make php-cs-fixer`, `make psalm`, and (if applicable) `make upgrade-code`. |
| 63 | +- Docs updated where needed. |
| 64 | +- No changes to `vendor/` or generated artifacts. |
0 commit comments