# Development

> Set up Visto AI locally, run its tests, typecheck and lint, work on the UI package, and open a pull request.

Web page: https://visto-ai.com/docs/development/

Visto AI is written in TypeScript and runs on Node directly, with no build step for the service. This page covers working on it locally and sending a change.

## Set up

You need Node 26 or later.

```bash
npm ci
npm test
npm run typecheck
npm run lint
```

Tests need no database and no network. Database tests run against an in-process Postgres (PGlite). The test setup blocks sockets and `fetch` and clears credential variables from the environment, so a test that tries to reach GitHub or a model fails.

## The UI package

The web UI lives in `ui/`, a package of its own: React, TypeScript, Vite and Tailwind CSS, tested with Vitest and Testing Library. It has its own exact versions, lock file, lint config and `node_modules`. The root lint ignores it, and nothing in `src/` imports from it; the one file it shares with the service is `src/ui/api-types.ts`, read as types.

It needs its own install, which reaches the network once:

```bash
npm --prefix ui ci
npm --prefix ui run lint
npm --prefix ui run typecheck
npm --prefix ui test
npm --prefix ui run build
```

Its tests stub the API and block `fetch`, `XMLHttpRequest`, `WebSocket` and `EventSource`. `build` writes `ui/dist`, which git ignores and the service serves at `/ui/`.

## Try it against a running service

With the service running locally, `npm run dev:send-webhook` sends a signed sample delivery to it:

```bash
npm run dev:send-webhook -- --url http://localhost:8080/webhooks/github --secret-env WEBHOOK_SECRET --kind pull_request
```

`--kind` is `pull_request`, `review` or `comment`. To measure a change to the engine on real pull requests, use the [replay](https://visto-ai.com/docs/replay/) and the [backtest](https://visto-ai.com/docs/backtest/).

## Send a change

- **Branch from `dev` and open the pull request against `dev`.** `dev` is the default branch. `main` holds releases: merging `dev` into `main` cuts a release and publishes the image.
- **Use conventional commits** for every commit and for the pull request title: `type(scope)!: subject`, where the scope and `!` are optional and `type` is one of `feat`, `fix`, `docs`, `test`, `chore`, `refactor`, `perf`, `build`, `ci`, `style` or `revert`. A check on each pull request enforces it.
- **The version follows the commits.** `feat` bumps the minor version, anything else the patch version. A breaking change (`!` or a `BREAKING CHANGE:` footer) bumps the major version, or the minor one while the version is below 1.0.

CI runs the root checks (lint, typecheck, tests) and the UI's (lint, typecheck, tests, build) on every pull request. Run them locally before you push.

See [Repository layout](https://visto-ai.com/docs/repository-layout/) for where things live.
