Thank you for your interest in contributing to the Amigo Platform SDK! This guide covers development setup, testing, code generation, and the release process.
- Clone the repository
- Install dependencies:
npm install
npm run build— Full build: generate types → esbuild (ESM+CJS) → tsc declarationsnpm run typecheck— Run TypeScript compiler in check mode (tsc --noEmit)npm run gen-types— Regenerate TypeScript types from the OpenAPI spec
npm test— Run unit tests (Vitest)npm run test:dist— Verify the built ESM and CJS artifactsnpm run typecheck:examples— Typecheck the repo-local SDK examplesnpx vitest run— Run all tests including core utilitiesnpx vitest run tests/integration/— Run integration tests (requires API credentials)
npm run lint— ESLint with zero warnings policynpm run format— Check formatting with Prettiernpm run format:write— Auto-format with Prettier
When upgrading openapi-fetch, keep the direct openapi-typescript-helpers dependency aligned with the range declared by openapi-fetch. The SDK's published declarations import both packages directly, and npm run test:tarball enforces the range coupling.
npm run test:reviewer uses Python's standard unittest runner. Use the repository CI Python version when changing scripts/pr_review/; the workflow currently runs the reviewer tests on Python 3.12.
This project uses Vitest as the testing framework.
tests/
├── core/ # Core utility tests (rate-limit, webhooks)
├── dist/ # Built package compatibility tests (ESM + CJS)
├── integration/ # Integration tests (require real API credentials)
└── resources/ # Per-resource unit tests
npm test # Unit tests (fast)
npm run test:dist # Dist compatibility tests (run after build)
npm run typecheck:examples # Validate repo-local examples
npx vitest run # All tests
npx vitest run tests/integration/ # Integration tests (needs env vars)
npx vitest run --coverage # With coverage report- Place resource tests in
tests/resources/ - Use mock fetch for unit tests (no MSW needed — see existing tests for pattern)
- Integration tests skip automatically when
AMIGO_TEST_API_KEYis not set
Types are auto-generated from the committed OpenAPI spec in amigo-ai/platform.
scripts/gen-types.mjsreadsopenapi.json(local or from the platform repo)- Patches FastAPI's spec to add missing path parameters (
workspace_id, etc.) - Runs
openapi-typescriptto generatesrc/generated/api.ts - These types drive all SDK resource methods with full type safety
npm run gen-types # auto-detect local spec
npm run gen-types -- --spec path/to/openapi.json # explicit fileNever manually edit files in src/generated/ — they will be overwritten.
The build emits one TypeScript declaration graph and then creates a CJS entrypoint at dist/types/index.d.cts. Keep the internal relative .js specifiers intact: under TypeScript NodeNext, .d.cts selects the CommonJS declaration entrypoint while .js specifiers still match the emitted JavaScript filenames. npm run test:tarball verifies both ESM and CJS declaration resolution with skipLibCheck: false.
src/
├── core/ # Auth, errors, retry, rate-limit, webhooks, branded types
├── generated/ # Auto-generated OpenAPI types (DO NOT EDIT)
├── resources/ # API resource classes (one per domain)
└── index.ts # AmigoClient entry point, public exports
tests/
├── core/ # Core utility tests
├── integration/ # Integration tests (require credentials)
└── resources/ # Per-resource unit tests
scripts/
├── gen-types.mjs # OpenAPI → TypeScript codegen
├── build.mjs # esbuild bundler (ESM + CJS)
└── generate-changelog.sh # Conventional commit changelog generator
- Start:
npm install - Write code: Edit
src/resources/orsrc/core/ - Write tests: Add tests in
tests/ - Validate:
npm run lint && npm run typecheck && npm run typecheck:examples && npm test && npm run build && npm run test:dist - Submit PR: See Pull Request Guidelines below
- Ensure the platform-api endpoint exists and
openapi.jsonhas been regenerated - Check the generated types:
grep 'your-endpoint' src/generated/api.ts - Create
src/resources/your-resource.tsextendingWorkspaceScopedResource - Use
this.client.GET/POST/PUT/DELETEwith typed path strings - Use
extractData(await this.client.METHOD(...))for data-returning calls - Register in
src/index.tsconstructor - Add tests in
tests/resources/your-resource.test.ts - Export types from
src/index.ts
- Ensure all tests pass:
npm test - Ensure dist tests pass:
npm run test:dist - Ensure examples stay valid:
npm run typecheck:examples - Lint your code:
npm run lint - Typecheck passes:
npm run typecheck - Build succeeds:
npm run build - Add tests for new functionality
- Update README if adding new resources or features
Releases are handled by two GitHub Actions workflows:
release.ymlverifies the latest Test workflow passed for the target commit- Regenerates types from the committed OpenAPI spec and fails on generated drift
- Bumps the version (patch/minor/major)
- Generates
CHANGELOG.mdentries from conventional commits - Runs the full prepublish verification suite and packs the package
- Pushes the version commit and annotated
v*tag - Creates the GitHub Release with release notes and the tarball artifact
- The GitHub Release
publishedevent triggerspublish.ymlfrom the immutable release tag publish.ymlrebuilds from the tag and publishes to npm with provenance
Go to Actions → Release → Run workflow, select the version type, and run.
When the platform API spec changes on main, the spec-sync.yml workflow:
- Detects spec differences
- Opens a PR with regenerated types
- After that PR is merged,
spec-auto-release.ymlwaits for the Test workflow onmainto pass - Dispatches a minor release automatically
Maintainers: configure npm trusted publishing for publish.yml where possible. Keep NPM_TOKEN only as a temporary fallback and configure RELEASE_PUSH_TOKEN only when branch protection prevents the default GITHUB_TOKEN from pushing release commits and tags. See the internal runbook for CI secret configuration.