# Development setup

> The tools you need to build, test and lint the repository, and how to run the checks.

Source: https://stuarty.com/docs/contributing/setup/

## You will learn

- which tools to install;
- how to build and run the program from a clone;
- the commands that check your change before you push.

## The idea

The repository is one Go module with a front end in `web/` and the documentation site in `site/`. [Task](https://taskfile.dev) is the single entry point: the commands you run on your machine are the ones the pull request pipeline runs. Indentation is a tab of width 4 (`.editorconfig`), except in files whose format needs spaces, and Git expects LF line endings.

## Quick start

Install these tools:

| Tool | Used for |
| --- | --- |
| Go, the version in `go.mod` | the core, the engine, the service and the program |
| Task | the commands below |
| golangci-lint | `task lint` for Go |
| Bun 1.4.5 | `web/` and `site/` (the project uses Bun, not npm) |
| Node.js 24 | one test of `site/` (`scripts/api-reference.test.ts`), whose syntax check needs `node --check` |
| FFmpeg 9 | the tests that encode; the container image carries a pinned one |

Then, from the root of the clone:

```bash
task setup
task ci
```

`task setup` checks the tools and activates the hooks of `.githooks/`: the pre-commit hook checks staged Go and Markdown files, and the pre-push hook refreshes the "Last updated" dates of the site. `task ci` runs `task lint`, `task vet`, `task test`, `task tidy:check` and `task notices:check`.

To run the program from the clone, build the front end with `bun install` and `bun run build` in `web/` (the program embeds the files that the build writes), then `go run ./web/cmd/app serve` from the root. It behaves as [the binary](/docs/self-hosting/binary), with one difference: a build from the clone is not a release, so it does not open the default workspace `~/.stuarty`, which belongs to the installed application. Set `STUARTY_HOME` to a folder of its own, or `STUARTY_ALLOW_DEFAULT_HOME=1` to open the default one on purpose; `go test` follows the same rule.

| Command | Does |
| --- | --- |
| `task lint` | Go, Markdown, the web front end and the site |
| `task test` | the Go tests (`go test -short`) |
| `task codegen` | regenerates the contracts, the TypeScript types and the FFmpeg pins |
| `task site:build` | builds the site and runs its checks |
| `bun run check:thin-client` (in `web/`) | the rules of the thin client |

### The agent harness

`internal/tools/agentharness` is a release-checklist tool that runs a live agent against the recipes of the agent documents and counts how often it finishes them. It costs money, so it never runs by itself and never in CI, and no shipped binary contains it. It refuses to start unless `STUARTY_HARNESS=1` is set and `--runs` is given, and `--estimate` prints the estimated cost and exits. In the `first-flow` scenario the agent signs in to a local account, and the password of that account is read from `STUARTY_HARNESS_PASSWORD`, so that it is never on the command line. The `stuarty` process that the harness starts gets only an allow-list of variables: never the key of the model.

## Common mistakes

- Running `npm install` in `web/` or in `site/`. Both folders use Bun and have one lockfile, `bun.lock`.
- Skipping `task codegen` after changing a registry or schema: the `Generated files` check fails with a diff. Run it and commit the result.
- Changing `go.mod`, `web/package.json` or a lockfile without `task notices`: `task notices:check` fails until the notices are regenerated.
- Building the site with a Bun version other than the one the pipeline uses (1.4.5): a different version can change the output of the build checks.

## Next steps

- [Repository layout](/docs/contributing/repository-layout)
- [Commits and pull requests](/docs/contributing/commits-and-prs)
