|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Thanks for contributing to `runtimeuse`. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Git |
| 8 | +- Node.js 22 or newer |
| 9 | +- Python 3.11 or newer recommended |
| 10 | +- `npm` |
| 11 | + |
| 12 | +There is no root workspace setup in this repository today, so install dependencies separately in each package you want to work on. |
| 13 | + |
| 14 | +## Clone the Repository |
| 15 | + |
| 16 | +```bash |
| 17 | +git clone https://github.com/getlark/runtimeuse.git |
| 18 | +cd runtimeuse |
| 19 | +``` |
| 20 | + |
| 21 | +## Repository Layout |
| 22 | + |
| 23 | +- `packages/runtimeuse` is the TypeScript runtime that runs inside the sandbox. |
| 24 | +- `packages/runtimeuse-client-python` is the Python client used outside the sandbox. |
| 25 | +- `docs` is the documentation app. |
| 26 | + |
| 27 | +## Environment Files |
| 28 | + |
| 29 | +Two local env files are useful for advanced development flows. They are not required for the basic local test path: |
| 30 | + |
| 31 | +- `packages/runtimeuse/.env` for the runtime package's `npm run dev-publish` flow. Start from `packages/runtimeuse/.env.example`. |
| 32 | +- `packages/runtimeuse-client-python/.env` for sandbox and LLM tests. Start from `packages/runtimeuse-client-python/.env.example`. |
| 33 | + |
| 34 | +## TypeScript Runtime Development |
| 35 | + |
| 36 | +Install dependencies: |
| 37 | + |
| 38 | +```bash |
| 39 | +cd packages/runtimeuse |
| 40 | +npm install |
| 41 | +``` |
| 42 | + |
| 43 | +Useful commands: |
| 44 | + |
| 45 | +```bash |
| 46 | +npm run build |
| 47 | +npm run typecheck |
| 48 | +npm test |
| 49 | +npm run test:integration |
| 50 | +``` |
| 51 | + |
| 52 | +Notes: |
| 53 | + |
| 54 | +- `npm test` runs the main unit test suite. |
| 55 | +- `npm run test:integration` builds first and then runs the integration tests. |
| 56 | +- If you want to use the Claude handler locally, install the CLI with `npm install -g @anthropic-ai/claude-code`. |
| 57 | +- `npm run dev-publish` runs `scripts/dev-publish.sh`: it builds the runtime, uploads a zip to S3, and prints a presigned download URL plus a ready-to-use `curl ... && node runtimeuse/dist/cli.js` command. |
| 58 | +- `npm run dev-publish` reads `packages/runtimeuse/.env` for `S3_BUCKET` and optionally `S3_PREFIX` and `PRESIGN_EXPIRY`. |
| 59 | +- `npm run dev-publish` assumes the AWS CLI is installed and already authenticated with permission to upload to the configured S3 bucket and generate presigned URLs. |
| 60 | + |
| 61 | +## Python Client Development |
| 62 | + |
| 63 | +Create and activate a virtual environment, then install the package in editable mode: |
| 64 | + |
| 65 | +```bash |
| 66 | +cd packages/runtimeuse-client-python |
| 67 | +python -m venv .venv |
| 68 | +source .venv/bin/activate |
| 69 | +pip install -e ".[dev]" 2>/dev/null || pip install -e . |
| 70 | +pip install pytest pytest-asyncio |
| 71 | +``` |
| 72 | + |
| 73 | +Run the default test suite: |
| 74 | + |
| 75 | +```bash |
| 76 | +pytest test/ -m "not sandbox and not llm" |
| 77 | +``` |
| 78 | + |
| 79 | +Sandbox-only test flow: |
| 80 | + |
| 81 | +```bash |
| 82 | +pytest test/ -m sandbox |
| 83 | +``` |
| 84 | + |
| 85 | +LLM-only test flow: |
| 86 | + |
| 87 | +```bash |
| 88 | +pytest test/ -m llm |
| 89 | +``` |
| 90 | + |
| 91 | +Notes: |
| 92 | + |
| 93 | +- The Python package declares `python >=3.10`, but CI currently tests on Python 3.11 through 3.13. |
| 94 | +- If your change touches the runtime protocol or end-to-end behavior, build `packages/runtimeuse` before running Python tests: |
| 95 | + |
| 96 | +```bash |
| 97 | +cd packages/runtimeuse |
| 98 | +npm install |
| 99 | +npm run build |
| 100 | +``` |
| 101 | + |
| 102 | +- Copy `packages/runtimeuse-client-python/.env.example` to `.env` before running sandbox or LLM tests locally. |
| 103 | +- Sandbox tests create an E2B sandbox and require `E2B_API_KEY`. |
| 104 | +- LLM tests also create sandboxes by default and require `E2B_API_KEY` plus the relevant provider credentials such as `OPENAI_API_KEY` or `ANTHROPIC_API_KEY`. |
| 105 | +- If you already have a runtime server running, set `TEST_WS_URL` to reuse it instead of creating a fresh sandbox. |
| 106 | +- Some LLM tests also require `TEST_S3_BUCKET` for artifact upload verification. |
| 107 | +- If you want sandbox tests to run against a dev build instead of `npx -y runtimeuse`, set `RUNTIMEUSE_RUN_COMMAND`. A convenient way to get that command is `packages/runtimeuse` -> `npm run dev-publish`. |
| 108 | + |
| 109 | +## Docs Development |
| 110 | + |
| 111 | +Install and run the docs app: |
| 112 | + |
| 113 | +```bash |
| 114 | +cd docs |
| 115 | +npm install |
| 116 | +npm run dev |
| 117 | +``` |
| 118 | + |
| 119 | +Useful commands: |
| 120 | + |
| 121 | +```bash |
| 122 | +npm run build |
| 123 | +npm run types:check |
| 124 | +npm run lint |
| 125 | +``` |
| 126 | + |
| 127 | +## Before Opening a PR |
| 128 | + |
| 129 | +Run the checks relevant to the package you changed: |
| 130 | + |
| 131 | +- `packages/runtimeuse`: `npm run typecheck` and `npm test` |
| 132 | +- `packages/runtimeuse-client-python`: `pytest test/ -m "not sandbox and not llm"` |
| 133 | +- `docs`: `npm run types:check` and `npm run lint` |
| 134 | + |
| 135 | +If you changed behavior shared between the runtime and Python client, run both the TypeScript and Python checks. |
0 commit comments