Skip to content
Source
Sign inSign up

Configure workspaces

Work with agents / Local workspaces

Configure workspaces

An agent in a new workspace needs dependencies, its own ports and its .env values to run a test or a dev server. You change how src ws gives each workspace these things in one file in your repository, .source/workspace.yaml.

3 min read

Pick what to configure

You want toRead
Install dependencies once, and share build caches between workspacesInstall dependencies and share caches
Give each workspace its own ports, so that two dev servers never take the same portGive each workspace its own ports
Give your commands the .env values of the vault, or copy env files into each workspaceGive each workspace its env values
Run a command when a workspace is made, accepted or closed, and repair a workspaceRun hooks in workspaces
Keep agents from changing some filesProtect files with read-only paths

How src reads the config

  • src reads the file from your checkout, never from a workspace, so an agent cannot change it for its own workspace.
  • If the file is not correct, create stops before it makes a workspace, and names the field.
  • src ws prepare reads the config from the commit that it prepares, not from your working tree. An uncommitted change of the config does not change what a prepare runs.

Trust the commands of the config

The config comes with the repository, so a git pull can change its commands. src runs a command or sets a variable from .source/workspace.yaml only after you allow it:

src ws trust
  1. src shows each command and variable of the config, for example layers.tools.install: node scripts/fetch-tools.mjs. The hooks and the variables of the named ports are in this list.
  2. It also shows the vault files that src ws exec reads, with the names of their variables. It never shows a value. See Give each workspace its env values.
  3. It asks you to trust them. In a script, add --yes.
  4. src keeps your approval in its data folder, never in the repository.

Each approval is bound to what it allowed:

  • The approval of the commands is bound to their exact list. If a command changes, src asks again.
  • The approval of the vault is bound to the repository, the names of its vault files and the names of their variables. A new vault file or a new variable needs a new approval. A new value of a variable does not.

Until you trust the config, src skips its commands:

  • create, restore, prepare, sync and accept print a line that names the skipped commands and points at src ws trust.
  • A built-in recipe that the config changes uses its built-in command. A layer that only the config defines is marked skipped, not trusted.
  • The hooks do not run, and src ws exec sets no variable of a named port.
  • A prepare that a git hook starts never runs an untrusted command, and never asks.

Note

The built-in recipes need no trust. src ws init turns on auto-prepare, and that is your consent: a prepare then runs the built-in install of your lockfile, for example pnpm install. That install runs the install scripts of your packages, the same as when you run it by hand.

Check your config

src ws trust
src ws create try-config
src ws exec try-config -- node -p "process.env.TURBO_CACHE_DIR"
src ws close try-config

create lists each layer with its strategy, and exec prints the ports of the workspace. A second create with the same lockfile says cloned from the cache, or says that the layers were ready in its folder from the pool.