|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Commands |
| 6 | + |
| 7 | +```bash |
| 8 | +# Install dependencies |
| 9 | +poetry install |
| 10 | + |
| 11 | +# Run all tests |
| 12 | +poetry run pytest |
| 13 | + |
| 14 | +# Run a single test file |
| 15 | +poetry run pytest tests/test_language_detector.py |
| 16 | + |
| 17 | +# Run a single test function |
| 18 | +poetry run pytest tests/test_yepcode_run.py::test_run_python_code |
| 19 | + |
| 20 | +# Run with coverage |
| 21 | +poetry run pytest --cov=yepcode_run |
| 22 | + |
| 23 | +# Build the package |
| 24 | +poetry build |
| 25 | +``` |
| 26 | + |
| 27 | +Tests require a `YEPCODE_API_TOKEN` environment variable. Set it in `.env` or export it before running tests. Most tests are integration tests that hit the live YepCode cloud API. |
| 28 | + |
| 29 | +## Architecture |
| 30 | + |
| 31 | +The SDK is a thin Python client for executing code in YepCode's serverless runtime. |
| 32 | + |
| 33 | +**Layers:** |
| 34 | + |
| 35 | +1. **Public API** — `YepCodeRun`, `YepCodeEnv`, `YepCodeStorage` (in `yepcode_run/`) |
| 36 | +2. **Execution engine** — `yepcode_run/run/execution.py` handles polling loop, status transitions (`CREATED → RUNNING → FINISHED/ERROR`), and event callbacks (`onLog`, `onFinish`, `onError`) |
| 37 | +3. **API Manager** — `yepcode_run/api/api_manager.py` singleton keyed by config hash; merges env vars + constructor params |
| 38 | +4. **HTTP client** — `yepcode_run/api/yepcode_api.py` handles auth (API token or JWT with auto-refresh), all REST calls |
| 39 | + |
| 40 | +**Key design decisions:** |
| 41 | +- `YepCodeRun` hashes submitted code (SHA256) to reuse existing cloud processes rather than creating new ones each run |
| 42 | +- `YepCodeApiManager` uses a singleton per config hash, so multiple `YepCodeRun` instances with the same credentials share one API client |
| 43 | +- Language detection (`yepcode_run/utils/language_detector.py`) uses a score-based heuristic on stripped code (comments removed) when `language` is not specified |
| 44 | + |
| 45 | +**Config priority:** constructor params > environment variables > `.env` file. Key env vars: `YEPCODE_API_TOKEN`, `YEPCODE_API_HOST` (defaults to `https://cloud.yepcode.io`), `YEPCODE_TIMEOUT` (ms, default 60000). |
| 46 | + |
| 47 | +## OpenAPI spec |
| 48 | + |
| 49 | +The live spec is always available at `https://cloud.yepcode.io/api/rest/public/api-docs`. Fetch it with WebFetch to audit which endpoints are missing from `yepcode_run/api/yepcode_api.py` before adding new ones. New endpoints are deployed to that URL before this SDK is updated. |
0 commit comments