Skip to content

Add run and skip setup choices to the automation CLI - #36543

Merged
brennanb2025 merged 6 commits into
mainfrom
brennanb2025/lu-setup-cli
Nov 1, 2026
Merged

brennanb2025 merged 6 commits into
mainfrom
brennanb2025/lu-setup-cli

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​542 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​539
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​156 $\color{#cf222e}{\Huge{\mathbf{−}}}$​55 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​101

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 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.

Linked Issue

Tracked in STA-10576.

Visual Proof

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.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 31, 2026 10:33
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent 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: 341854bf-83a0-42ef-94c3-df44956946ce
Commits

Reviewing files that changed from the base of the PR and between 3986202 and 8c9915c.

Files selected for processing: 1
  • src/main/runtime/rpc/methods/automation-update-precondition-rpc.test.ts

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: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning 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 Passed checks: 4 passed
Check name Status Explanation
Title check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

Share

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Nitpick comments: 1
src/cli/index-automation-setup.test.ts: 1

128-167: Trivial · Maintainability & Code Quality · Quick win

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.

Files selected for processing: 13
  • skill-guides/orca-cli/references/automations.md
  • src/cli/automation-format.test.ts
  • src/cli/automation-format.ts
  • src/cli/bundled-skill-guides.ts
  • src/cli/handlers/automation-extra-agent-args-flag.ts
  • src/cli/handlers/automation-setup-flag.ts
  • src/cli/handlers/automations.ts
  • src/cli/index-automation-setup.test.ts
  • src/cli/specs/automations.ts
  • src/main/automations/automation-chat-setup-choice.test.ts
  • src/main/automations/headless-workspace-create.test.ts
  • src/main/persistence/applying-settings/persistence-automations.test.ts
  • src/renderer/src/hooks/useAutomationDispatchEvents.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Comment thread src/cli/handlers/automations.ts Resolved
…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.
@brennanb2025

brennanb2025 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Review loop status: done on 3986202

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.

For Brennan's review:

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.

Main removed automations.test.ts; keep its workspace-mode precondition RPC test in a focused file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant