You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add run and skip setup choices to the automation CLI - #36543
Automations that create a new worktree for each run can't choose from the CLI whether the repository's setup script runs. The app's automation editor can save that choice, and hosts already honor it on every run, but orca automations create and edit had no way to send it. So an automation made from the CLI (often by an agent) always skipped setup, even in a repository that needs its setup script before work can start.
What this PR does for users
orca automations create ... --setup run (or skip) and orca automations edit <id> --setup run|skip save the setup choice for new-per-run automations. Both Terminal and Chat automation runs use it.
Leaving the flag out works as before: on create no choice is saved (current Orca skips setup); on edit the saved choice is kept.
--setup on an automation that runs in an existing worktree is refused before anything is saved, with a message that says why and what to pass (--workspace-mode new-per-run, or drop --setup). That includes a create with no target run from inside an Orca worktree, which targets the current worktree.
If the host that would store the automation runs an Orca too old to keep the choice, --setup is refused before anything is saved: "This host's Orca is too old for --setup on automations. Update Orca on that host, or run the command without --setup." Commands without --setup are unchanged on every host.
If another client switches the automation to an existing worktree while an edit --setup is in flight, the whole edit is refused and nothing is changed, instead of applying the other edits and silently dropping the setup choice.
The text output of automations show, create and edit now has a setup: run, setup: skip or setup: not set line for new-per-run automations. JSON output is unchanged.
Help and the bundled CLI skill guide document the flag.
How it works
The CLI accepts only run or skip and sends it on the existing setupDecision field of automation.create / automation.update. It never sends inherit.
Hosts now advertise a capability, automations.setup-choice.v1. When --setup is given, the CLI checks the receiving host's status.get for it before writing, the same way it already checks extra agent arguments. Hosts older than the field (v1.4.104 and earlier) would silently drop the choice and run setup by the repository's own policy, so refusing up front is the only way the user's explicit choice is never contradicted.
An edit whose --setup relies on the automation still being new-per-run sends an optional expectedWorkspaceMode: 'new_per_run' precondition. It travels with the update to the store, which checks it against the saved record in the same step that writes, beside the existing owner and destination preconditions. It is not saved. An explicit --workspace-mode new-per-run switch sends no precondition.
Differences from the common pattern
The common pattern puts a per-request setup choice on the request and lets the host that provisions the worktree run setup. This PR does the same, with these labelled differences:
Intended: the choice is saved on the automation instead of sent per request, because a scheduled automation replays it on every run after restarts.
Intended: an omitted choice keeps today's skip on current hosts, per the owner's ruling for this ticket and the shipped compatibility behavior for existing automations.
Intended: the capability gate and the mode precondition, because client and host update independently (paired and SSH hosts), and a host that can't keep the choice must not accept it.
Intended: hosts from v1.4.105 up to the release before this PR can store the field but don't advertise the capability, so they also refuse --setup until updated. They could not take it from the CLI before either, and their no-flag behavior is unchanged.
Whether setup finishes before the agent starts, and reporting what setup did, are owned by the separate setup-ordering work; this PR only carries the choice.
N/A: CLI flags, CLI text output and help only; no application UI changes.
Testing
The real CLI entry point (main()) covers create and edit with run and skip, omitted choices, invalid values, existing-workspace refusals (no target inside a worktree, explicit --workspace, explicit --workspace-mode existing, edits), switching an automation to new-per-run with a choice, help, owner/destination fencing, and hosts without the capability (refused with no create or update call; no capability check when --setup is omitted).
The store and controller tests cover the mode precondition: refused with nothing changed after a switch to existing, still refused when the switch lands while the controller is resolving a repository move, a successful setup edit saved through the controller and reloaded, and unchanged behavior for updates without the precondition.
Terminal, Chat and app-open Terminal launch tests cover saved run and skip reaching worktree creation, and a missing choice skipping setup even with run-by-default or Ask repository policies.
CI supplies lint and typecheck. No running-app run: this is a CLI and host-contract change, covered by integration tests that run the real CLI command.
Review
Full path:
Small: no; CLI plus an optional wire precondition, a host capability and a store check.
Risky areas: yes; saved launch choice across the CLI/host wire, with independently updated hosts.
Repeat: the legacy skip default and setup-choice persistence are kept as constraints, not changed.
Local effect: no; crosses CLI, host RPC, store and both automation launch surfaces.
Agent skill upstream boundary
Not applicable; no upstream skill-installer material copied.
Notes
No setup-ordering, automation service or run-writer files are changed.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Walkthrough
Automation create and edit commands now accept --setup run|skip for new-per-run automations. The CLI validates the choice, checks host capability, and displays the saved choice. Updates can include a workspace-mode precondition, which the persistence path checks before applying changes. Tests cover CLI validation, persistence, displayed values, and forwarding setup choices to worktree launch paths.
Merge Risk: Minimal · up to 8c991
Explicit setup choices are saved for new-worktree automations. No merge-blocking risk was established.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title "Add run and skip setup choices to the automation CLI" names the main change: the CLI gains a --setup run|skip option for automation create and edit. The changeset matches this. It adds th…
Description check
The description follows the repository template closely. It has a Problem section, a What this PR does for users section, a How it works section, a Differences section, a Linked Issue (STA-10576), a V…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "Add run and skip setup choices to the automation CLI" names the main change: the CLI gains a --setup run|skip option for automation create and edit. The changeset matches this. It adds the flag, the host capability gate, the mode precondition, text output, and tests. The title is specific and concise, and it fits the PR objectives.
Full details: Description check
Explanation
The description follows the repository template closely. It has a Problem section, a What this PR does for users section, a How it works section, a Differences section, a Linked Issue (STA-10576), a Visual Proof marked N/A with a reason, a Testing section with coverage details, a Review section, an Agent skill upstream boundary checkbox, and Notes. The template's ELI5 section is absent, and the testing checklist items are not ticked. The template's 'What Changed' and 'Why' headings are replaced by Problem and How it works sections. The linked issue is not a 'Fixes #' reference, but it links an actual Linear issue. Overall the description is mostly complete, so this check passes. The author could add an ELI5 section and tick the manual-testing and automated-test items, and could make the linked-issue format match the template.
Full details: Docstring Coverage
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 23 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Name why --setup is refused and what to pass, show the setup choice in
text output, document --setup in the CLI guide, fail when a host drops
the choice, and cover the app-open Terminal dispatch.
The edit test does not check the failure path for an older host that drops an explicit --setup choice. Create covers the shared "did not keep --setup" error. Edit calls the same helper at src/cli/handlers/automations.ts:259, but every edit fixture returns the requested decision. A regression that removes this check from edit would pass the suite.
Add one edit case. Return automation: { id: 'a1' } from automation.update for edit a1 --setup run. Assert that process.exitCode is 1 and that the error message matches the create case.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 80edfae8-c3fb-4db9-92b4-629c59c9dbf5
Commits
Reviewing files that changed from the base of the PR and between 9758224 and 49932b0.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
…edit's mode
Explicit --setup now needs the host's new setup-choice capability, checked
before any write; commands without --setup are unchanged. An edit whose
setup choice relies on the current new-per-run mode sends a mode
precondition the store checks against the saved record, so a concurrent
switch to an existing worktree refuses the whole edit. Text output shows
the saved choice or "not set", the existing-workspace refusal offers a
remedy that works for every input, and the after-write readback is gone.
…p edit
Omitting --setup on edit keeps the saved choice, so the refusal now says
to run the command without --setup. A new test saves a --setup run edit
through the controller into the store and reads it back after reload.
Keep both the workspace-mode precondition and main's internal resolvedRepo
option on automation updates, and check the precondition before main's
host-reselection context retention.
The problem. Automations that make a new worktree for each run couldn't choose from the CLI whether the repository's setup script runs. The host and the app's editor already supported a saved run/skip choice, but orca automations create / edit couldn't send it, so CLI-made automations (often made by agents) always skipped setup.
What users get.--setup run|skip on automations create and edit for new-per-run automations. Leaving it out behaves as before (create saves no choice, which current Orca treats as skip; edit keeps the saved choice). --setup is refused before anything is saved when the automation runs in an existing worktree, when the receiving host's Orca is too old to keep the choice, and when another client switches the automation to an existing worktree mid-edit. Text output shows setup: run|skip|not set.
What review changed. Four rounds, two single deciders and one three-seat design panel.
Old hosts (v1.4.104 and earlier) silently drop the choice and run setup by the repository's own policy, so an early version of this PR could save an enabled automation that contradicted an explicit --setup skip and then exit with an error. Per the lane coordinator's ruling and the panel, hosts now advertise a capability (automations.setup-choice.v1) and the CLI refuses --setup before any write when the host lacks it. Hosts from v1.4.105 until this release can store the field but don't advertise the capability, so they also refuse --setup until updated. Commands without the flag are unchanged everywhere.
A concurrent switch to an existing worktree during an edit --setup used to apply the other edits and drop the choice. The edit now sends an optional expectedWorkspaceMode precondition, checked by the store in the same step as the write. It isn't saved.
Refusal messages now say why and what to pass; help, text output and the bundled CLI skill guide document the flag; CI lint fixes in two tests.
Verified. CI green on 3986202 (one macOS-intel persistence job failed when the runner couldn't download a GitHub action because of a DNS error; it was rerun with no code change). Named test files pass locally, including real-CLI integration tests (create/edit run and skip, omitted choices, refusals, hosts without the capability making no create/update call), store and controller tests (precondition refusal, including a switch that lands while the controller is resolving a repository move, plus a successful edit saved and reloaded), and Terminal, Chat and app-open Terminal launch tests for saved run/skip and missing choices. The one main sync (conflicts with #31617 in the automation store) was reviewed: both sides were kept and nothing was dropped. The readiness checklist passed with no findings.
Not verified. No running-app run: this is a CLI and host-contract change, and integration tests that run the real CLI command cover it. Whether setup finishes before the agent starts isn't proven here; that belongs to the separate setup-ordering work.
Deferred (minor). The CLI saves run without the editor's script-trust prompt, matching orca worktree create --setup run. runtime-automation-controller.ts sits at its 300-line limit. One controller comment is slightly loose after the merge.
For Brennan's list (outside this PR, on main):
The CLI can't set an automation's Chat vs Terminal surface.
Orca migration (orcad) checks the destination's extra-arguments support but not setup-choice support.
The app's automation editor sends a setup choice to hosts v1.4.104 and older with no check, and they drop it.
Since review. Main merge 8c9915c (main removed automations.test.ts; its workspace-mode precondition RPC test now lives in automation-update-precondition-rpc.test.ts). CI is green on the merged head.
No screenshots: there is no app screen in this change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Automations that create a new worktree for each run can't choose from the CLI whether the repository's setup script runs. The app's automation editor can save that choice, and hosts already honor it on every run, but
orca automations createandedithad no way to send it. So an automation made from the CLI (often by an agent) always skipped setup, even in a repository that needs its setup script before work can start.What this PR does for users
orca automations create ... --setup run(orskip) andorca automations edit <id> --setup run|skipsave the setup choice for new-per-run automations. Both Terminal and Chat automation runs use it.--setupon an automation that runs in an existing worktree is refused before anything is saved, with a message that says why and what to pass (--workspace-mode new-per-run, or drop--setup). That includes a create with no target run from inside an Orca worktree, which targets the current worktree.--setupis refused before anything is saved: "This host's Orca is too old for --setup on automations. Update Orca on that host, or run the command without --setup." Commands without--setupare unchanged on every host.edit --setupis in flight, the whole edit is refused and nothing is changed, instead of applying the other edits and silently dropping the setup choice.automations show,createandeditnow has asetup: run,setup: skiporsetup: not setline for new-per-run automations. JSON output is unchanged.How it works
runorskipand sends it on the existingsetupDecisionfield ofautomation.create/automation.update. It never sendsinherit.automations.setup-choice.v1. When--setupis given, the CLI checks the receiving host'sstatus.getfor it before writing, the same way it already checks extra agent arguments. Hosts older than the field (v1.4.104 and earlier) would silently drop the choice and run setup by the repository's own policy, so refusing up front is the only way the user's explicit choice is never contradicted.--setuprelies on the automation still being new-per-run sends an optionalexpectedWorkspaceMode: 'new_per_run'precondition. It travels with the update to the store, which checks it against the saved record in the same step that writes, beside the existing owner and destination preconditions. It is not saved. An explicit--workspace-mode new-per-runswitch sends no precondition.Differences from the common pattern
The common pattern puts a per-request setup choice on the request and lets the host that provisions the worktree run setup. This PR does the same, with these labelled differences:
--setupuntil updated. They could not take it from the CLI before either, and their no-flag behavior is unchanged.Linked Issue
Tracked in STA-10576.
Visual Proof
N/A: CLI flags, CLI text output and help only; no application UI changes.
Testing
main()) covers create and edit with run and skip, omitted choices, invalid values, existing-workspace refusals (no target inside a worktree, explicit--workspace, explicit--workspace-mode existing, edits), switching an automation to new-per-run with a choice, help, owner/destination fencing, and hosts without the capability (refused with no create or update call; no capability check when--setupis omitted).Review
Full path:
Agent skill upstream boundary
Notes
No setup-ordering, automation service or run-writer files are changed.