Skip to content

Commit 274a467

Browse files
committed
Update AGENTS.md
1 parent ccae0cd commit 274a467

1 file changed

Lines changed: 51 additions & 20 deletions

File tree

AGENTS.md

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,72 @@
11
# PROJECT KNOWLEDGE BASE
22

3-
**Generated:** 2026-01-13
3+
**Generated:** 2026-03-15
4+
**Commit:** b797332
5+
**Branch:** main
46

57
## OVERVIEW
6-
Python 3.8+ library for Capsolver service API. Supports both synchronous (`requests`) and asynchronous (`aiohttp`) operations. Uses `msgspec` for high-performance JSON serialization.
8+
Python 3.8+ library for Capsolver service API. Dual sync (`requests`) / async (`aiohttp`) support. `msgspec` for serialization, `tenacity` for retries.
79

810
## STRUCTURE
911
```
1012
./
11-
├── src/python3_capsolver/ # Main library package
12-
│ ├── core/ # Base classes, serializers, instruments
13-
│ └── *.py # Service-specific implementations (ReCaptcha, Cloudflare, etc.)
14-
├── tests/ # Pytest suite
15-
└── docs/ # Sphinx documentation
13+
├── src/python3_capsolver/ # Main library (service implementations)
14+
│ ├── core/ # Base classes, instruments, serializers
15+
│ └── *.py # Service-specific (ReCaptcha, Cloudflare, etc.)
16+
├── tests/ # Pytest suite (matches source structure)
17+
├── docs/ # Sphinx documentation
18+
├── ARCHITECTURE.md # System architecture (matklad-style)
19+
└── pyproject.toml # Build, uv, pytest, black/isort config
1620
```
1721

1822
## WHERE TO LOOK
1923
| Task | Location | Notes |
2024
|------|----------|-------|
21-
| **Base Logic** | `src/python3_capsolver/core/` | `base.py`, `serializer.py`, `enum.py` |
22-
| **Service Implementations** | `src/python3_capsolver/*.py` | `recaptcha.py`, `cloudflare.py`, etc. |
23-
| **Tests** | `tests/` | Matches source structure |
24-
| **Configuration** | `pyproject.toml` | Build, dependency, tool config |
25+
| **Architecture** | `ARCHITECTURE.md` | Layered design, invariants, life of a request |
26+
| **Base Logic** | `src/python3_capsolver/core/` | `base.py`, `serializer.py`, `enum.py`, instruments |
27+
| **Service Implementations** | `src/python3_capsolver/*.py` | `recaptcha.py`, `cloudflare.py`, `control.py` |
28+
| **Tests** | `tests/` | `conftest.py` (BaseTest, fixtures), per-service tests |
29+
| **Configuration** | `pyproject.toml` | uv, black (120), isort, pytest (asyncio auto) |
30+
| **Commands** | `Makefile` | `make tests`, `make build`, `make upload` |
2531

2632
## CONVENTIONS
27-
- **Formatter**: `black` (line-length 120), `isort` (profile "black").
28-
- **Serialization**: `msgspec` preferred over `json` for performance.
29-
- **Concurrency**: Dual support (Sync/Async) required for all instruments.
30-
- **Retries**: `tenacity` library used for resilience.
33+
- **Toolchain**: `uv` for package management (`uv sync`, `uv run`, `uv build`, `uv publish`)
34+
- **Formatter**: `black` (line-length 120), `isort` (profile "black")
35+
- **Cleanup**: `autoflake` (remove unused imports/variables)
36+
- **Serialization**: `msgspec` (not `json`) for performance
37+
- **Concurrency**: Dual sync/async required for all instruments
38+
- **Retries**: `tenacity` (async), `requests.Retry` (sync) — 5 attempts, exponential backoff
39+
- **Testing**: pytest 7.0+, `pytest-asyncio` (auto mode), rate-limiting fixtures (1s func, 2s class)
40+
41+
## ANTI-PATTERNS (THIS PROJECT)
42+
- **Empty `__init__.py` files**: `src/python3_capsolver/__init__.py` only exports `__version__`; `core/__init__.py` is completely empty. Users must import via full paths (`from python3_capsolver.recaptcha import ReCaptcha`)
43+
- **AGENTS.md in package dirs**: Will ship with distribution unless excluded in `pyproject.toml`
44+
- **No CLI entry points**: Library-only, no console_scripts defined
45+
46+
## UNIQUE STYLES
47+
- **Service Pattern**: Each captcha service inherits from `CaptchaParams` with `captcha_handler()` (sync) + `aio_captcha_handler()` (async)
48+
- **Task Payload**: Dict merged with internal params, passed to `create_task()` API
49+
- **Context Managers**: All services support `with` / `async with` for session cleanup
50+
- **Test Duplication**: Every sync test (`def test_*`) has async counterpart (`async def test_aio_*`)
3151

3252
## COMMANDS
3353
```bash
34-
make tests # Run test suite
35-
pip install . # Install package locally
54+
# Development
55+
uv sync --all-groups # Install all dependencies
56+
uv run pytest tests/ # Run tests
57+
uv run black src/ tests/ # Format
58+
uv run isort src/ tests/ # Sort imports
59+
60+
# Build & Publish
61+
uv build # Build wheel/sdist
62+
uv publish # Upload to PyPI
63+
64+
# Documentation
65+
cd docs/ && uv run --group docs make html -e
3666
```
3767

3868
## NOTES
39-
- Dependencies: `requests`, `aiohttp`, `msgspec`, `tenacity`.
40-
- Requires `API_KEY` in environment for tests.
41-
69+
- **API Key**: Tests require `API_KEY` environment variable
70+
- **Coverage**: HTML reports in `coverage/html/`, XML in `coverage/coverage.xml`
71+
- **Python Support**: 3.8–3.12 (tested via `target-version = ['py310']`)
72+
- **Dependencies**: `requests>=2.21.0`, `aiohttp>=3.9.2`, `msgspec>=0.18,<=0.21`, `tenacity>=8,<10`

0 commit comments

Comments
 (0)