Set up a project

A setup script, a run script and actions, so every workspace comes up ready to work and easy to try.

A fresh worktree has your code but nothing else: no node_modules, no .env, no build. Three kinds of commands take care of that. You set them per project under Settings, on the project's Scripts page, and they apply to every workspace of the project.

Setup script

Runs in a new workspace before the agent starts, and again when you restore an archived one. Use it to install dependencies and copy what git doesn't track:

npm ci
cp "$COMPAGNION_ROOT_PATH/.env" .env

The Setup tab at the bottom of the right panel shows its output while it runs, whether it succeeded, and Rerun. A setup script that asks a question fails instead of hanging, since nobody is there to answer.

Run script

Starts the workspace so you can try your changes: a dev server, the app, a watcher.

npm run dev

Start and stop it from the Run tab. When its output mentions a local address, such as http://localhost:5173, a Preview :5173 button appears next to the tabs and opens it in your browser. Starting it again stops the previous run first, so a dev server frees its port.

Actions

Named commands you start from the right panel, each in a terminal tab of its own:

Name Command
Test npm test
Lint npm run lint
Storybook npm run storybook

Add them with Add action… on the same Scripts page.

Environment

Every script runs in the workspace's folder with /bin/sh, and gets:

Variable What
COMPAGNION_ROOT_PATH The project's own checkout
COMPAGNION_WORKSPACE_PATH This workspace's worktree
COMPAGNION_WORKSPACE_NAME The workspace's name

Stopping a script stops everything it started. While a setup script, run script or action is running, Compagnion won't restart itself for an update.

From the command line

compagnion repo set my-app --setup 'npm ci' --run 'npm run dev'
compagnion repo action add my-app Test 'npm test'