|
| 1 | +# AGENTS.md — Agent Zero CLI |
| 2 | + |
| 3 | +## Purpose |
| 4 | + |
| 5 | +This file orients agentic coding assistants working in this repo. Keep edits small, follow existing conventions, and validate with tests/lint. |
| 6 | + |
| 7 | +## Repo Overview |
| 8 | + |
| 9 | +- Python 3.10+ CLI/TUI client for Agent Zero |
| 10 | +- Entry points: `a0cli` (CLI) and `a0tui` (TUI) |
| 11 | +- Core modules: `backend.py`, `cli/`, `ui/`, `observer/`, `llm_providers/` |
| 12 | +- Tests live in `tests/` |
| 13 | + |
| 14 | +## Quick Start (Dev) |
| 15 | + |
| 16 | +```bash |
| 17 | +python -m venv venv |
| 18 | +source venv/bin/activate # Windows: venv\Scripts\activate |
| 19 | +pip install -e ".[dev]" |
| 20 | +``` |
| 21 | + |
| 22 | +## Build / Run Commands |
| 23 | + |
| 24 | +- Run CLI: `a0cli` or `python -m cli` |
| 25 | +- Run TUI: `a0tui` or `python -m main_new` |
| 26 | +- Package build (optional): `python -m build` |
| 27 | + |
| 28 | +## Lint / Format |
| 29 | + |
| 30 | +- Lint: `ruff check .` |
| 31 | +- Format check: `black --check .` |
| 32 | +- Auto-format: `black .` |
| 33 | +- Optional autofix: `ruff check . --fix` |
| 34 | + |
| 35 | +## Tests |
| 36 | + |
| 37 | +- Run full suite: `pytest tests/` |
| 38 | +- Run with coverage: `pytest tests/ --cov=. --cov-report=html` |
| 39 | +- Run a single file: `pytest tests/test_backend_context.py` |
| 40 | +- Run a single test: `pytest tests/test_backend_context.py::TestContextBuilder::test_preview_redaction` |
| 41 | +- Run by keyword: `pytest -k "context"` |
| 42 | +- E2E (mock server): `scripts/run_e2e.sh` |
| 43 | + |
| 44 | +## Cursor / Copilot Rules |
| 45 | + |
| 46 | +- No `.cursor/rules`, `.cursorrules`, or `.github/copilot-instructions.md` found in this repo. |
| 47 | + |
| 48 | +## Code Style & Conventions |
| 49 | + |
| 50 | +### Python & Typing |
| 51 | + |
| 52 | +- Target Python 3.10+. |
| 53 | +- Use type hints for function signatures and public APIs. |
| 54 | +- Prefer `Optional[T]` or `T | None` over implicit `None`. |
| 55 | +- Keep functions small and focused; avoid side effects in helpers. |
| 56 | + |
| 57 | +### Formatting |
| 58 | + |
| 59 | +- Formatting is enforced by Black. |
| 60 | +- Line length is 100 characters (`[tool.black]` and `[tool.ruff]`). |
| 61 | +- Do not hand-format to a different width. |
| 62 | + |
| 63 | +### Imports |
| 64 | + |
| 65 | +- Follow Ruff import sorting (isort-style). |
| 66 | +- Group imports in this order: standard library, third-party, local. |
| 67 | +- Keep imports explicit; avoid `from x import *`. |
| 68 | + |
| 69 | +### Naming |
| 70 | + |
| 71 | +- Functions/variables: `snake_case`. |
| 72 | +- Classes: `PascalCase`. |
| 73 | +- Constants: `UPPER_SNAKE_CASE`. |
| 74 | +- Async functions: suffix with `_async` only if it clarifies intent. |
| 75 | + |
| 76 | +### Error Handling |
| 77 | + |
| 78 | +- Catch specific exceptions; avoid bare `except`. |
| 79 | +- Log with `logging.getLogger("agentzero.<module>")`. |
| 80 | +- Return safe, user-facing messages rather than raw stack traces. |
| 81 | +- Preserve original exceptions where helpful for debugging. |
| 82 | + |
| 83 | +### Async & IO |
| 84 | + |
| 85 | +- Prefer `async`/`await` with `aiohttp` where used. |
| 86 | +- Use timeouts and close sessions with context managers. |
| 87 | +- Avoid blocking calls in async paths; use `asyncio.to_thread` if needed. |
| 88 | + |
| 89 | +### Configuration & Secrets |
| 90 | + |
| 91 | +- Config lives in `config.yaml` / `config.example.yaml`. |
| 92 | +- Environment variables are prefixed with `AGENTZERO_`. |
| 93 | +- Never commit secrets or real API keys. |
| 94 | + |
| 95 | +### Logging & Output |
| 96 | + |
| 97 | +- Use `logging` instead of `print`. |
| 98 | +- Keep user-facing messages consistent with existing CLI/TUI output styles. |
| 99 | + |
| 100 | +### Tests |
| 101 | + |
| 102 | +- Use pytest and pytest-asyncio (`asyncio_mode = auto`). |
| 103 | +- Add tests for new behaviors; keep them deterministic. |
| 104 | +- Prefer unit tests in `tests/` over ad-hoc scripts. |
| 105 | + |
| 106 | +## Repo Layout |
| 107 | + |
| 108 | +- `backend.py` — Agent Zero client + context builder |
| 109 | +- `cli/` — CLI interface and slash commands |
| 110 | +- `ui/` — Textual-based TUI |
| 111 | +- `observer/` — Tool routing and observer logic |
| 112 | +- `llm_providers/` — LLM integration adapters |
| 113 | +- `docs/` — Project docs and specs |
| 114 | + |
| 115 | +## Change Hygiene |
| 116 | + |
| 117 | +- Keep diffs minimal and scoped to the task. |
| 118 | +- Do not add new dependencies without explicit approval. |
| 119 | +- Update docs when behavior or config changes. |
| 120 | +- Prefer tests + lint before requesting review. |
| 121 | + |
| 122 | +## Security Notes |
| 123 | + |
| 124 | +- Redact or exclude sensitive data in logs and previews. |
| 125 | +- Be careful with filesystem operations; avoid destructive defaults. |
| 126 | + |
| 127 | +## How to Add New Tests |
| 128 | + |
| 129 | +1. Place tests in `tests/` using `test_*.py` naming. |
| 130 | +2. Name test classes `TestSomething` and test functions `test_something`. |
| 131 | +3. For async tests, use `async def` + pytest-asyncio. |
| 132 | + |
| 133 | +## Definition of Done |
| 134 | + |
| 135 | +- Lint and format checks pass. |
| 136 | +- Relevant tests pass (or clearly noted). |
| 137 | +- No secrets added to git. |
| 138 | +- Documentation updated when needed. |
0 commit comments