Develop localspace
This page is for people who change the code of localspace. It tells how to set up the repository, which make commands to use, and where the parts of the code are. To learn how the parts work together, read architecture.
Set up
Section titled “Set up”Install these tools:
| Tool | Version | Use |
|---|---|---|
| Go | 1.27.4 or newer | Build and test lo |
| golangci-lint | 2.15 (brew install golangci-lint) |
Format and lint the Go code |
| Node and pnpm | Node 24, pnpm 12 | Build the dashboard and the documentation site |
| Docker | OrbStack, Docker Desktop, or any docker CLI context |
Containers and integration tests |
| pm2 | npm install -g pm2 |
Integration tests of the pm2 plugin |
| Vale | 3.29 (brew install vale) |
Check the documentation |
sqlc and protoc |
Current | Only to make the generated code again |
Then install the git hooks. Do this one time for each clone:
make hooksThe hooks use lefthook. The commit hook runs the format, lint, copy and prose checks, only for the files that you changed. The push hook runs make check for the side that changed.
Make commands
Section titled “Make commands”Run make help to list the targets. These are the targets that you use most:
| Command | Action |
|---|---|
make build |
Build the dashboard, then bin/localspace, the link bin/lo and the pm2 plugin bin/lo-plugin-pm2. |
make fmt |
Format the Go code with gofumpt, goimports and golines, and the dashboard with prettier. |
make check |
Run all that CI runs: check-go, check-dashboard, check-docs and dupes. |
make check-go |
Check the Go format, lint the code (also as built for Windows) and run the tests with -race, for the two Go modules. |
make check-dashboard |
Run prettier, oxlint and tsc on the dashboard. |
make check-docs |
Run Vale and prettier on the documentation, and build the site to check its links. |
make dupes |
Find code that is copied in Go and in the dashboard (jscpd, .jscpd.json). |
make test |
Run the unit tests with the race detector, in the main module and in sdk/. |
make test-integration |
Run all tests, with the tests that use Docker or pm2 and the acceptance suite in test/acceptance. |
make vuln |
Report known vulnerabilities in the code that lo calls (govulncheck). It uses the network, so make check does not run it. |
make types |
Make the TypeScript types of the dashboard from internal/contract (tygo). |
make generate |
Make the typed state queries again (sqlc). |
make proto |
Make the Go code of the plugin protocol again (protoc). |
make tidy |
Tidy go.mod and go.sum of the two modules. |
make release |
Build lo and the official plugins for all platforms into dist/, with checksums.txt. |
The documentation has special targets:
| Command | Action |
|---|---|
make docs |
Build the site into docs/dist. The build fails on a link to a page or a heading that is not there. |
make docs-dev |
Serve the site at http://localhost:4321/localspace/. It updates the site when you save a file. |
make docs-cli |
Write the command reference in docs/src/content/docs/reference/cli from the commands of lo and their help text. |
make docs-lint |
Check the prose against Simplified Technical English with Vale. |
make check-docs fails if the command reference and the help text are different. Run make docs-cli to make the reference again. To learn the writing rules, read write documentation.
Integration tests
Section titled “Integration tests”Start Docker before you run make test-integration. Each test uses a temporary localspace home. The Docker objects of a test carry a suffix of that home, and the test removes them when it ends. Your workspaces do not collide with them.
Layout
Section titled “Layout”| Path | Contents |
|---|---|
cmd/localspace |
The lo binary: the kernel with all the built-in modules |
cmd/lo-plugin-pm2 |
The official pm2 engine plugin |
internal/kernel |
The command tree and the injector that modules connect to |
internal/contract |
The interfaces, the data and the errors that the core, the modules, the CLI and the API of the dashboard share |
internal/core |
Templates, sources, ports, references, environment variables, state and the commands that use them |
internal/config |
The machine settings and the localspace home |
internal/modules |
The engines (docker, native), the resources, the Caddy proxy, the file secret store, the plugin host, MCP and the dashboard (ui) |
internal/modules/ui/dashboard |
The source of the dashboard. The ui module embeds its build |
sdk |
The Go module that plugins use. sdk/pluginv1 has the gRPC code |
api |
The protocol file of the plugins (plugin.proto) |
test/acceptance |
End-to-end tests with the lo binary, real git repositories and Docker |
docs |
The documentation site, with the Vale rules in docs/vale |
assets |
The logo and the screenshot |
Dashboard
Section titled “Dashboard”The dashboard is a Vite and React application in internal/modules/ui/dashboard/. To work on it with a live reload:
- Run
lo ui serve. - Run
pnpm devininternal/modules/ui/dashboard/. It proxies/apito port 7090. - Open
http://localhost:5173/#token=<token>. Replace<token>with the text in~/.localspace/ui.token.
After you change a type in internal/contract, run make types. The command writes src/types/api.ts.
Plugins
Section titled “Plugins”By default, lo runs host processes with the native engine. To run them with pm2, install pm2 and the plugin, and set engines: {process: pm2} in ~/.localspace/config.yaml.
go build -o bin/lo-plugin-pm2 ./cmd/lo-plugin-pm2lo plugin install ./bin/lo-plugin-pm2To write a new plugin, read write a plugin.
Release
Section titled “Release”A release has these steps:
- Make sure that
make checkpasses onmain. - Push a tag
v<semver>, for examplev0.2.0. - The release workflow runs the checks. It runs
make releaseto buildloand the official plugins for all platforms. It then makes the GitHub release withchecksums.txt.
The version of lo comes from the tag. Versions are v0.x.y until the first stable release.