Work with agents / Local workspaces
Review and accept agent work
An agent finished a task in its workspace, and you want its changes in your checkout, next to your own edits. src ws accept merges and tests the changes in a separate folder first, then brings them in as unstaged changes.
4 min read
Your staged changes stay staged, and src never commits or pushes.
1. Look at the changes
src ws diff api
src ws accept api --dry-run
diffshows what the agent changed since the baseline of the workspace. Your own edits from beforecreateare not in it.accept --dry-runshows the files that an accept will change in your checkout, and any conflict. It writes nothing.
Would apply 2 files from api to /code/app as unstaged changes:
M src/login.ts
A src/login.test.ts
2. Accept the changes
src ws accept api
src does these steps:
- It saves a checkpoint of the workspace.
- It merges the changes of the agent into a copy of your checkout (your commits, your staged and your unstaged edits). The copy is the candidate, in
../.src-ws/<repository folder>/.candidate-api. - If you trusted a
validatehook, it makes the dependency layers of the candidate and runs the hook there. With no hook, it makes no layers, because nothing runs in the candidate. See Run hooks in workspaces. - It reads your checkout again. If you changed a file in the meantime, it merges and validates again.
- It writes the changed files into your checkout, then deletes the candidate.
Applied 2 files from api to /code/app as unstaged changes. Nothing is staged or committed.
M src/login.ts
A src/login.test.ts
Run git status and git diff to see them. The workspace stays open. When you are done, close it with src ws close api.
Tip
To accept several workspaces, name them in order: src ws accept api web. src merges them one after the other.
Done
The work of the agent is in your checkout as plain unstaged changes, next to your own edits, and you decide what to commit.
When your default branch moves on, see Bring a workspace up to date. To start one agent from the work of another, see Stack workspaces.
When accept stops
Accept stops before it writes anything to your checkout when:
- A change conflicts with your edits.
srcnames the files. In the candidate, a text file has conflict markers, so you can see the conflict. Change the file in the workspace or in your checkout, then accept again. - A new file of the agent has the name of an untracked file in your checkout. Move your file, or remove the file in the workspace.
- The agent changed a read-only path. See Protect files with read-only paths.
- A path goes through a link.
srcnever writes through a folder that is a link in your checkout. It also refuses a link of the agent whose target is absolute, outside the repository or in.git. This applies also when the target goes through other links. A relative link inside the repository applies as a link. - The validation or a layer fails in the candidate.
srcshows the output, and keeps the candidate for you to look at.
Note
A lockfile that both sides changed is not a stop. src takes the lockfile of your checkout, merges the manifests, and runs the lock command of the recipe in the candidate, for example pnpm install --lockfile-only --no-frozen-lockfile. The recipes of pnpm, yarn, bun, npm and uv have one.
Finish an accept that stopped in the middle
Before it writes a file, src saves the old and the new content of each file in a journal. A write of many files is not atomic. If src stops in the middle, for example because the computer shuts down, each src ws command names the accept that stopped.
src ws accept --resume
src ws accept --undo
--resumewrites the files that are not written yet.--undoputs back the old content of the files that the accept wrote.
Both leave a file that you changed since then as it is, and name it.