feat: add beat init interactive setup command#75
Merged
Conversation
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([beat init args]) --> B[parseInitArgs]
B --> C{--agent flag?}
C -- yes --> D[isAgentProvider?]
D -- no --> E[return code:1\nUnknown agent]
D -- yes --> F[saveConfig defaultAgent]
F -- fail --> G[return code:1\nsave error]
F -- ok --> H[checkAuth agent]
H --> I[return code:0\nagent + status]
C -- no --> J{deps.isTTY?}
J -- no --> K[return code:1\nNo TTY detected]
J -- yes --> L{existingAgent\n&& !--yes?}
L -- yes --> M[confirmReconfigure]
M -- cancelled --> N[return code:0\nSetup cancelled.]
M -- false --> O[return code:0\nConfiguration unchanged.]
M -- true --> P
L -- no --> P[checkAuth all providers]
P --> Q[selectAgent prompt]
Q -- cancelled --> N
Q -- provider --> R[saveConfig defaultAgent]
R -- fail --> G
R -- ok --> S[find status in statuses]
S --> T[return code:0\nagent + status]
I --> U{initCommand\ndisplay}
T --> U
N --> V[ui.cancel]
O --> W[ui.outro\nConfiguration unchanged.]
U --> X{isInteractive?}
X -- yes --> Y[ui.info hint\nui.outro success]
X -- no --> Z[ui.info hint\nui.success]
E --> AA[ui.error + exit 1]
G --> AA
K --> AA
Last reviewed commit: 0d68d96 |
added 2 commits
March 8, 2026 02:04
Replace direct p.intro()/p.outro() calls in init.ts with TTY-aware ui.intro()/ui.outro()/ui.cancel() wrappers for consistency with the rest of the CLI. Update agents list hint to recommend `beat init`.
Move deps.checkAuth() inside the isInteractive branch so non-interactive `beat init --agent <agent>` skips the spawnSync 'which' call. Addresses PR review feedback.
Show auth hint unconditionally (not gated on !status.ready) so cli-installed agents display their verification instructions. Fix import sort order in cli-init.test.ts for Biome CI check.
- Support `--agent=value` syntax in parseInitArgs - Thread AgentAuthStatus via InitResult to eliminate redundant checkAuth - Non-interactive path now also shows auth hint - Change cli-installed authHint label from 'CLI found' to 'may need login'
Address Greptile review: statuses.find() fallback prevents silent undefined if selectAgent ever returns an unexpected provider.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
beat initcommand for first-time agent setup — detects installed agents, prompts for default, writes config--agentflag) for CI/scripting,--yesto skip reconfigure promptresolveDefaultAgenterror message to recommendbeat initfirstDetails
New files:
src/cli/commands/init.ts—runInit()core logic with DI,parseInitArgs(),initCommand()CLI entrytests/unit/cli-init.test.ts— 22 tests (arg parsing, non-interactive, non-TTY, interactive flows)Modified files:
src/cli.ts— init command dispatchsrc/cli/commands/help.ts— Setup section + examplessrc/core/agents.ts— error message mentionsbeat initpackage.json—test:cliincludes init testsDesign:
InitDepsinterface —selectAgent/confirmReconfigureinjected as async callbacks, zerovi.mock()in testsInitResultreturn type (notprocess.exit()) for testability@clack/promptsoutput to stderr (MCP-clean stdout)Closes #74
Test plan
npm run build— clean compilenpm run test:cli— 146 tests pass (22 new init tests)npm run test:core— 367 tests pass (updated resolveDefaultAgent assertion)npx biome check— no lint/format issuesbeat init --agent claude(non-interactive)beat initin terminal (interactive flow)