Skip to content

Commit 507b20a

Browse files
authored
Merge pull request #8 from warpdotdev/ben/warp-md
docs(dev): Add WARP.md file
2 parents dd7a9b7 + 7f1b835 commit 507b20a

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

WARP.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# WARP.md
2+
3+
This file provides guidance to WARP (warp.dev) when working with code in this repository.
4+
5+
## Repository Overview
6+
7+
This is the official Python SDK for the Warp API, providing convenient access to the Warp API REST API. The SDK is **generated code** created using [Stainless](https://www.stainless.com/) from an OpenAPI specification. Most files are auto-generated, with exceptions for `src/warp_agent_sdk/lib/` and `examples/` directories which are manually maintained.
8+
9+
## Development Commands
10+
11+
### Setup
12+
```bash
13+
# Bootstrap the development environment (installs uv, Python, and dependencies)
14+
./scripts/bootstrap
15+
```
16+
17+
### Testing
18+
```bash
19+
# Run full test suite (tests with both Pydantic v1 and v2, multiple Python versions)
20+
./scripts/test
21+
22+
# Run specific tests
23+
uv run pytest tests/test_client.py
24+
25+
# Tests require a mock Prism server running on port 4010
26+
# The test script will automatically start one if not running
27+
# To manually start: ./scripts/mock --daemon
28+
```
29+
30+
### Linting and Type Checking
31+
```bash
32+
# Run all linters (ruff, pyright, mypy)
33+
./scripts/lint
34+
35+
# Run with auto-fix
36+
./scripts/lint --fix
37+
38+
# Format code
39+
./scripts/format
40+
```
41+
42+
### Building
43+
```bash
44+
# Build distribution packages (.tar.gz and .whl)
45+
uv build
46+
```
47+
48+
## Code Architecture
49+
50+
### Generated vs Manual Code
51+
52+
**Generated code** (DO NOT manually edit - changes will be overwritten):
53+
- `src/warp_agent_sdk/_client.py` - Main client classes (WarpAPI, AsyncWarpAPI)
54+
- `src/warp_agent_sdk/resources/` - API resource classes
55+
- `src/warp_agent_sdk/types/` - Type definitions and models
56+
- Most utility files in `src/warp_agent_sdk/_utils/`
57+
58+
**Manual code** (safe to edit):
59+
- `src/warp_agent_sdk/lib/` - Custom library code
60+
- `examples/` - Example scripts
61+
- `tests/` - Test files
62+
63+
### Core Components
64+
65+
**Client Architecture**:
66+
- `WarpAPI` (sync) and `AsyncWarpAPI` (async) are the main entry points
67+
- Both inherit from `SyncAPIClient` and `AsyncAPIClient` base classes
68+
- Support for both `httpx` (default) and `aiohttp` (optional) HTTP backends
69+
- API key authentication via `Authorization: Bearer` header
70+
- Default base URL: `https://app.warp.dev/api/v1`
71+
72+
**Resource Structure**:
73+
- Resources are organized hierarchically (e.g., `client.agent.tasks.retrieve()`)
74+
- Each resource has sync/async variants and raw/streaming response wrappers
75+
- Main resource: `AgentResource` with `run()` method and nested `TasksResource`
76+
77+
**Type System**:
78+
- Uses Pydantic models for request/response validation
79+
- TypedDict for nested parameters
80+
- Custom types: `NotGiven`, `Omit` for optional parameters
81+
- Supports both Pydantic v1 and v2
82+
83+
## Environment Variables
84+
85+
- `WARP_API_KEY` - API key for authentication (required)
86+
- `WARP_API_BASE_URL` - Override default base URL
87+
- `WARP_API_LOG` - Enable logging (`info` or `debug`)
88+
- `TEST_API_BASE_URL` - Use custom API endpoint for tests
89+
90+
## Testing Conventions
91+
92+
- Tests use `pytest` with `pytest-asyncio` for async tests
93+
- Both sync and async variants must be tested
94+
- Tests run against a mock Prism server based on OpenAPI spec
95+
- Tests run with both Pydantic v1 and v2 on Python 3.9 and 3.14+
96+
- Use `respx` for mocking HTTP requests in tests
97+
98+
## Development Workflow
99+
100+
1. **Making changes**:
101+
- Only edit files in `lib/` and `examples/` directories
102+
- Other changes should be made to the OpenAPI spec and regenerated
103+
104+
2. **Adding examples**:
105+
- Create executable Python scripts in `examples/`
106+
- Use shebang: `#!/usr/bin/env -S uv run python`
107+
- Make executable: `chmod +x examples/<your-example>.py`
108+
109+
3. **Code quality**:
110+
- Run `./scripts/format` before committing
111+
- Ensure `./scripts/lint` passes
112+
- Run `./scripts/test` to verify changes
113+
114+
## Package Management
115+
116+
- Uses [uv](https://docs.astral.sh/uv/) for fast, reliable dependency management
117+
- `pyproject.toml` defines project metadata and dependencies
118+
- `uv.lock` pins exact versions for reproducibility
119+
- `requirements-dev.lock` exported for pip compatibility

0 commit comments

Comments
 (0)