# AGENTS.md ## ๐Ÿง  Project Overview This project is a Python-based application. Agents working in this directory must adhere to Python 3.11+ best practices, with clear module separation, test coverage, security hygiene, and readable documentation. --- ## ๐Ÿ“ Project Structure Agents must follow the directory structure below: ``` project-root/ โ”‚ โ”œโ”€โ”€ src/ # Application source code โ”‚ โ””โ”€โ”€ / # Python modules/packages โ”‚ โ”œโ”€โ”€ tests/ # Unit + integration tests โ”‚ โ””โ”€โ”€ __init__.py โ”‚ โ”œโ”€โ”€ scripts/ # Utility and CLI scripts โ”‚ โ”œโ”€โ”€ docs/ # Documentation (Markdown or reStructuredText) โ”‚ โ”œโ”€โ”€ .github/ # GitHub Actions workflows โ”‚ โ”œโ”€โ”€ pyproject.toml # Project metadata & tool configs (preferred) โ”œโ”€โ”€ requirements.txt # Legacy dependency spec (optional) โ”œโ”€โ”€ .env.example # Environment variable template โ””โ”€โ”€ AGENTS.md # Agent configuration (this file) ``` Do not create files outside this structure unless explicitly instructed. --- ## ๐Ÿงช Testing & Validation Before submitting changes, agents **must** ensure all tests and linters pass: ```bash # Set up environment (once) python3 -m venv .venv source .venv/bin/activate pip install -e .[dev] # Run unit tests pytest --cov=src --cov-report=term --cov-report=xml # Run linters ruff check src/ tests/ mypy src/ black --check src/ ``` ### โœ… Required Quality Gates - Code coverage: โ‰ฅ 90% - Type coverage: 100% via `mypy` - No linter errors (ruff + mypy) - No black formatting issues Agents must **not** commit code that fails these checks. --- ## ๐Ÿงน Code Style - Use **PEP8 + PEP257** standards. - Prefer `pyproject.toml` for tool configuration (Black, Ruff, Mypy, etc.). - Function names: `snake_case` - Class names: `PascalCase` - Constant names: `UPPER_SNAKE_CASE` - Use f-strings, not `%` or `.format()` for string interpolation. - Keep function length under 50 lines where possible. --- ## ๐Ÿ”’ Security Guidelines Agents must: - Never commit `.env` files, secrets, or tokens. - Use `dotenv` to load secrets during local execution. - Avoid using `eval()`, `exec()`, or subprocess calls unless sandboxed and essential. - Avoid external internet access during execution unless configured via API keys. --- ## ๐Ÿงช Testing Philosophy - Use `pytest` with fixtures, mocking (`unittest.mock` or `pytest-mock`), and parameterized tests. - Aim for 1:1 parity between modules and test modules. - Include boundary cases and exception tests. --- ## ๐Ÿงพ Commit & PR Conventions Agents must format commits using **Conventional Commits**: ``` feat: add user authentication module fix: correct path handling in file parser docs: update README with usage example ``` Pull Requests should include: - A concise title (โ‰ค 72 chars) - A summary of what changed and why - Before/after behavior (if applicable) - Testing evidence (CI, screenshots, coverage) --- ## ๐Ÿ“ฆ Dependency Management - Use **`pyproject.toml`** (via Poetry or PEP 621 standard) - Prefer `pip install .[dev]` over `requirements.txt` - Dev dependencies go under `[tool.poetry.group.dev.dependencies]` or similar - Avoid `pip freeze` output for lockfiles โ€” use `poetry.lock` or `requirements.lock` if necessary --- ## ๐Ÿค– Agent Behavior Summary - Respect the file and folder structure - Never break existing tests - Follow Pythonic style and formatting - Automate validation where possible - Explain large changes via commit messages and PR descriptions - Use comments where logic is non-obvious --- Happy coding! ๐Ÿ --- ## โš™๏ธ Setup Script Requirement Every project must include a `setup.sh` script at the root level that ensures: - Python 3.11+ is installed - Poetry is installed (via `install.python-poetry.org`) - All dependencies are installed using `poetry install` If this script does not exist, the agent must create it. It should be idempotent and safe to re-run. Run it like this: ```bash chmod +x setup.sh ./setup.sh ``` --- ## ๐Ÿ–ฅ OS-Specific Setup Scripts (Expanded) Agents must maintain the following OS-specific setup scripts: - `setup_linux.sh` - `setup_mac.sh` - `setup_windows.ps1` These scripts must: - Ensure Python 3.11+ is present (install if missing) - Install Poetry (if not already installed) - Run `poetry install` to install dependencies - Be idempotent and safe to re-run A user must be able to simply clone the repo, run the appropriate script, and be ready to work. Refer to `README.md` for user-friendly execution instructions. --- ## ๐Ÿ–ฅ OS-Specific Setup Scripts (Expanded) Agents must maintain the following **OS-specific setup scripts** in the project root: - `setup_linux.sh` โ€“ for Ubuntu, Debian, Fedora, Arch, etc. - `setup_mac.sh` โ€“ for macOS (Intel/ARM); must auto-install Homebrew if missing - `setup_windows.ps1` โ€“ for Windows 10+ using PowerShell Each script must: - Ensure Python 3.11+ is installed - Install Poetry if missing - Run `poetry install` to fetch dependencies - Be idempotent and safe to re-run - Provide clear terminal output These scripts should allow a contributor to clone the project, run one script, and be ready to develop. --- ### ๐Ÿง setup_linux.sh ```bash #!/bin/bash set -e echo "๐Ÿ” Checking Python 3.11+..." if ! python3 --version | grep -q "3.11"; then echo "Installing Python 3.11..." if command -v apt &>/dev/null; then sudo apt update sudo apt install -y python3.11 python3.11-venv python3.11-dev sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 elif command -v dnf &>/dev/null; then sudo dnf install -y python3.11 elif command -v pacman &>/dev/null; then sudo pacman -S --noconfirm python else echo "โŒ Unsupported Linux package manager." exit 1 fi fi echo "โœ… Python version: $(python3 --version)" echo "๐Ÿ” Checking for Poetry..." if ! command -v poetry &>/dev/null; then echo "๐Ÿ“ฆ Installing Poetry..." curl -sSL https://install.python-poetry.org | python3 - export PATH="$HOME/.local/bin:$PATH" else echo "โœ… Poetry is installed: $(poetry --version)" fi echo "๐Ÿ“ฆ Installing dependencies..." poetry install echo "โœ… Linux setup complete. Use 'poetry shell' to activate environment." ``` --- ### ๐ŸŽ setup_mac.sh ```bash #!/bin/bash set -e echo "๐Ÿ” Checking Python 3.11+..." if ! python3 --version | grep -q "3.11"; then echo "Installing Python 3.11 using Homebrew..." if ! command -v brew &>/dev/null; then echo "๐Ÿ“ฆ Installing Homebrew..." /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" export PATH="/opt/homebrew/bin:$PATH" fi brew install python@3.11 brew link python@3.11 --force fi echo "โœ… Python version: $(python3 --version)" echo "๐Ÿ” Checking for Poetry..." if ! command -v poetry &>/dev/null; then echo "๐Ÿ“ฆ Installing Poetry..." curl -sSL https://install.python-poetry.org | python3 - export PATH="$HOME/.local/bin:$PATH" else echo "โœ… Poetry is installed: $(poetry --version)" fi echo "๐Ÿ“ฆ Installing dependencies..." poetry install echo "โœ… macOS setup complete. Use 'poetry shell' to activate environment." ``` --- ### ๐ŸชŸ setup_windows.ps1 ```powershell # PowerShell script Write-Host "๐Ÿ” Checking Python 3.11+..." $pythonVersion = python --version if (-not ($pythonVersion -like "*3.11*")) { Write-Host "Installing Python 3.11..." Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.11.5/python-3.11.5-amd64.exe" -OutFile "python_installer.exe" Start-Process -Wait -FilePath "./python_installer.exe" -ArgumentList "/quiet InstallAllUsers=1 PrependPath=1" Remove-Item "python_installer.exe" } Write-Host "โœ… Python version: $(python --version)" Write-Host "๐Ÿ” Checking for Poetry..." if (-not (Get-Command poetry -ErrorAction SilentlyContinue)) { Write-Host "๐Ÿ“ฆ Installing Poetry..." (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python - $env:Path += ";$env:USERPROFILE\.poetry\bin" } Write-Host "๐Ÿ“ฆ Installing dependencies..." poetry install Write-Host "โœ… Windows setup complete. Run 'poetry shell' to activate environment." ``` --- ### ๐Ÿ“˜ Instructing Users in README.md Also ensure `README.md` includes this section: ```markdown ## ๐Ÿ–ฅ Setup Instructions Run the setup script for your operating system: **Linux:** ```bash chmod +x setup_linux.sh ./setup_linux.sh ``` **macOS:** ```bash chmod +x setup_mac.sh ./setup_mac.sh ``` **Windows (PowerShell):** ```powershell .\setup_windows.ps1 ``` After installation: ```bash poetry shell ``` ```