5.1 KiB
5.1 KiB
AGENTS.md
Project
Wrenn JavaScript SDK — a client library for the Wrenn microVM platform. e2b drop-in replacement.
Package name: @wrenn/sdk. Node.js 18+, TypeScript 5.5+, managed with pnpm.
Commands
pnpm install # install deps
make lint # biome check + format check (no auto-fix)
make test # unit tests only (vitest)
make test-integration # all tests including integration (needs live server)
make generate # regenerate types from OpenAPI spec (openapi-typescript)
make check # lint + unit test
make build # tsup build (CJS + ESM + DTS)
make testruns all non-integration tests. To run a specific test file:pnpm vitest run tests/commands.test.ts- No separate typecheck step —
vitestandtsuphandle type checking during test/build.tsc --noEmitis available but not wired up in CI.
Architecture
src/— the library packagecapsule.ts— high-levelCapsuleclass (main user-facing class)client.ts— low-levelWrennClientwithCapsulesResourceandSnapshotsResourcecommands.ts— command execution, streaming, and background process managementfiles.ts— filesystem operationspty.ts— interactive terminal (PTY) over WebSocketexceptions.ts— typed error hierarchy (WrennErrorbase)models/generated.ts— auto-generated from OpenAPI spec viaopenapi-typescript(never edit directly; runmake generate)git/— git operations inside capsules (clone, push, pull, status, branches, etc.)code-interpreter/— specialized capsule for stateful Jupyter kernel execution_shared/http.ts— thinfetchwrapper with auth headers, base URL, and error mapping_shared/websocket.ts— WebSocket helper wrappingwsconfig.ts— constants (DEFAULT_BASE_URL, env var names)
tests/— unit tests usemswto mock HTTP; integration tests are intests/integration/api/openapi.yaml— OpenAPI spec used for type generation
Key Conventions
- Generated types live in
src/models/generated.ts. Never edit them. Runmake generateto update. - No sync/async split — JS is naturally async. One
Capsuleclass, all methods returnPromise. Sandboxis a deprecated alias forCapsule. New code should useCapsule.- Uses native
fetchfor HTTP (Node 18+),wsfor WebSockets,zodfor runtime validation. - Resource disposal via
Symbol.asyncDispose(await using). Also supports manual.close(). - Streaming methods return
AsyncGenerator(e.g.commands.stream(),files.downloadStream()). - Static + instance method pattern:
capsule.destroy()(instance) andCapsule.destroy(id, opts)(static).
Testing
- Unit tests mock HTTP via
msw(Mock Service Worker for Node). - Integration tests require env vars:
WRENN_API_KEY(orWRENN_TOKEN), optionallyWRENN_BASE_URL. - Integration test fixtures in
tests/integration/setup.tscreate real capsules and clean them up. - Tests use
vitest— no@jestglobals. Useimport { describe, it, expect } from 'vitest'.
CI
Woodpecker CI (.woodpecker/check.yml) runs on push to main and dev:
make lintmake testmake test-integration
Dependencies
Runtime: ws (WebSocket), zod (validation). Everything else is dev-only.
MCP Tools: code-review-graph
IMPORTANT: This project has a knowledge graph. ALWAYS use the code-review-graph MCP tools BEFORE using Grep/Glob/Read to explore the codebase. The graph is faster, cheaper (fewer tokens), and gives you structural context (callers, dependents, test coverage) that file scanning cannot.
When to use graph tools FIRST
- Exploring code:
semantic_search_nodesorquery_graphinstead of Grep - Understanding impact:
get_impact_radiusinstead of manually tracing imports - Code review:
detect_changes+get_review_contextinstead of reading entire files - Finding relationships:
query_graphwith callers_of/callees_of/imports_of/tests_for - Architecture questions:
get_architecture_overview+list_communities
Fall back to Grep/Glob/Read only when the graph doesn't cover what you need.
Key Tools
| Tool | Use when |
|---|---|
detect_changes |
Reviewing code changes — gives risk-scored analysis |
get_review_context |
Need source snippets for review — token-efficient |
get_impact_radius |
Understanding blast radius of a change |
get_affected_flows |
Finding which execution paths are impacted |
query_graph |
Tracing callers, callees, imports, tests, dependencies |
semantic_search_nodes |
Finding functions/classes by name or keyword |
get_architecture_overview |
Understanding high-level codebase structure |
refactor_tool |
Planning renames, finding dead code |
Workflow
- The graph auto-updates on file changes (via hooks).
- Use
detect_changesfor code review. - Use
get_affected_flowsto understand impact. - Use
query_graphpattern="tests_for" to check coverage.