Work with agents / Local workspaces
Bring a workspace up to date
Your default branch moved, and the work of the agent is behind it. src ws sync merges the changes of the agent onto the new tip, so src ws diff still shows only the work of the agent.
2 min read
1. Sync the workspace
src ws sync api
src ws sync api --onto release-2
sync saves a checkpoint, then merges the changes of the agent onto the tip of the default branch (origin/HEAD, else main, else master), or onto the revision of --onto.
- The new commit becomes the baseline of the workspace, so
src ws diffstill shows only the work of the agent. - If the lockfile changed,
srcmakes the layers again.
2. Fix the conflicts, if any
If the merge has conflicts, sync writes conflict markers into the files and marks the workspace sync-conflict:
Conflicts in 1 file of api:
src/login.ts
Fix the conflict markers, then run `src ws sync api --continue`. To undo the sync, run `src ws restore api@cp-4`.
- Fix the markers in the workspace, or let the agent fix them.
src ws execstill works. - Run
src ws sync api --continue. It refuses while a file still has markers.
Tip
To undo the sync, restore the checkpoint that it names. The files and the baseline go back.
Done
The workspace starts from the new tip, and src ws diff shows only the work of the agent. To bring that work into your checkout, see Review and accept agent work.
Auto-sync
When the tip of the default branch moves, each src ws command syncs the workspaces that started from that branch:
- It skips a workspace that runs a process of
src ws exec.listshows it aslive, behind main by 3, and the next command after the process stops syncs it. - It syncs only when the merge has no conflict. A workspace with a conflict stays as it is, and
srcnames it once. To sync it with conflict markers, runsrc ws sync <workspace>. - It skips a workspace in the state
sync-conflictorfailed. - It never runs a command of
.source/workspace.yamlthat you did not trust.
To turn auto-sync off, run:
src ws init --no-auto-sync
To turn it on again, run src ws init.