Skip to content

feat(setup): add the setup agent step to the wizard (2/7) - #895

Draft
atornsii wants to merge 6 commits into
atorns/agent-1-opencode-adapterfrom
atorns/agent-2-wizard-step
Draft

atornsii wants to merge 6 commits into
atorns/agent-1-opencode-adapterfrom
atorns/agent-2-wizard-step

Conversation

@atornsii

@atornsii atornsii commented Oct 20, 2026 •

Copy link
Copy Markdown

This adds the setup agent step to the ldcli setup wizard, on top of the adapter from PR 1.

What changed

  • The agent step replaces the init step. Setup always uses the agent. If OpenCode is missing or the agent fails, setup stops with the error. It does not use the init templates.
  • ldcli setup --project <key> --environment <key> selects the project and environment and skips their screens, so one command can start setup.
  • ldcli setup agentcontrol --path . --sdk-id node-server --flag-key my-new-flag runs only the agent step, without the wizard.
  • The step shows finished tool calls, and it shows the agent's questions with numbered options (s skips). Permission requests are queued, if a version asks for them.
  • After the run, the wizard lists the changed files and shows the export command for the SDK's own credential only. It then goes to the existing verify step.
  • Setup stops OpenCode when the user quits, when a run finishes starting after the user quit, and when the terminal closes (SIGHUP).

Testing

Wizard tests with a fake runner cover the agent step, the queue of permission requests, questions with one or several items, the error when the agent cannot run or fails, the --project and --environment presets and an unknown key, the close on quit, and the credential line. ldcli setup agentcontrol tests cover permission and question input on the terminal.

Diagram

flowchart TD
  setup["setup.go<br/>NewSetupCmd: --project, --environment<br/>AddCommand newAgentCmd"]:::chg
  cmdag["agent.go<br/>agentTask<br/>credentialExport, describeTool<br/>newAgentCmd, runAgent<br/>streamAgent, askQuestions"]:::new
  model["model.go<br/>stepAgent, agentRunner, agentRun<br/>permission and question queues<br/>runTracker"]:::chg
  view["view.go<br/>agentView, agentWaitView"]:::chg
  upd["update.go<br/>handleAgentEvent<br/>agentFailed, closeAgent<br/>answerAgentQuestion"]:::chg
  cmds["commands.go<br/>startAgent, waitForAgentEvent<br/>replyAgent, answerAgent"]:::chg
  pkg["internal/setup/agent from #894<br/>Runner.Start, Run.Events"]:::earlier
  verify["verify step<br/>existing wizard step"]:::earlier
  setup -->|newAgentCmd| cmdag
  setup -->|runner, mode| model
  view -->|reads state| model
  upd -->|updates state| model
  upd -->|returns tea.Cmd| cmds
  upd -->|describeTool, credentialExport| cmdag
  cmds -->|agentTask| cmdag
  cmds -->|Start, Events, Reply, Answer| pkg
  cmdag -->|runAgent| pkg
  upd -->|agent done| verify
  classDef new fill:#e6f0fa,stroke:#1d6fb8,stroke-width:2px,color:#19202b
  classDef chg fill:#fbf1e1,stroke:#a86a12,stroke-width:2px,color:#19202b
  classDef earlier fill:#ffffff,stroke:#7a8494,stroke-dasharray:5 4,color:#19202b
  classDef ext fill:#eceefa,stroke:#4e5a9c,stroke-width:2px,color:#19202b
Loading

Blue boxes are new files, orange boxes are changed files, dashed boxes are files from an earlier PR, and purple boxes are outside ldcli. A solid arrow goes from the caller to the code that it calls. A dashed arrow shows data that moves without a direct call.

setup.go adds the --project and --environment flags, gives the runner to the wizard model, and registers ldcli setup agentcontrol. When the project or environment list loads, update.go selects a preset key and skips that screen. In the wizard, commands.go starts the run and waits for each event as a Bubble Tea command (a function that returns a message to the wizard). update.go handles each event, changes the state in model.go, and returns the next command. view.go draws that state. If the agent cannot run or fails, update.go stops setup with the error. When the agent finishes, the wizard goes to the existing verify step. The ldcli setup agentcontrol subcommand in agent.go uses the same runner without the wizard.

This PR uses only the Runner and Run interfaces and the Event types from #894. It does not change the agent package.

Stack

This is one of seven PRs for the ldcli setup agent. Review and merge them in order, after #877 (Go 1.26):

  1. feat(setup): add an OpenCode adapter for the setup agent (1/7) #894 OpenCode adapter
  2. feat(setup): add the setup agent step to the wizard (2/7) #895 Wizard agent step
  3. feat(setup): run the setup agent in a macOS sandbox (3/7) #896 macOS sandbox
  4. feat(setup): read the setup agent config through the gonfalon relay (4/7) #897 AI SDK and relay
  5. feat(setup): run the setup agent through the Go AI SDK with an OpenCode handler (5/7) #898 OpenCode handler
  6. fix(setup): fix the agent sandbox and give the agent more facts (6/7) #899 Run fixes
  7. feat(setup): send the agent's model calls to a LaunchDarkly Bedrock relay (7/7) #930 Bedrock model routing

The gonfalon side is launchdarkly/gonfalon#75196 to #75199 (the SDK relay) and launchdarkly/gonfalon#75426 (the model relay). This stack replaces #876 and #878, which are closed.

🤖 Generated with Claude Code

The wizard now uses the setup agent to add the SDK initialization code.
The agent step replaces the init step, and `ldcli setup agent` runs
only that step.

The --agent flag controls the step. With auto, the default, setup uses
the agent if OpenCode 1.19.0 or later is installed, and the templates
if not. With on, setup stops if the agent cannot run. With off, setup
always uses the templates.

The step shows the agent's finished tool calls and its questions, with
numbered options. After the run, it lists the changed files and the
export command for the SDK's own credential. If the agent fails after
it changed a file, setup stops and does not apply a template on top.
Setup stops OpenCode when the user quits, when the run starts late, and
when the terminal closes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
atornsii and others added 5 commits October 20, 2026 11:22
…ronment

Setup now always uses the setup agent. The --agent flag and its auto, on, and off modes are gone, and so is the fallback to the init templates. If the agent cannot run or fails, setup stops with the error.

ldcli setup now takes --project and --environment. The wizard selects them and skips their screens, so one command can start setup.

The subcommand that runs only the agent step is now ldcli setup agentcontrol.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@atornsii atornsii changed the title feat(setup): add the setup agent step to the wizard (2/6) feat(setup): add the setup agent step to the wizard (2/7) Oct 21, 2026
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