[1601 by Claude Opus 4.8] Implement the setup wizard engine that sequences checks and safe actions - #1613
Conversation
… I implemented for issue #1601. Summary I created the UI-agnostic setup wizard engine that sequences `check` + `init stack` behavior and the remaining one-time setup tasks in a safe order. Files 1. `packages/cli/src/commands/setup/engine.ts` (new) — the engine. It builds on the existing `setup/types.ts` and `setup/state.ts` (step model + non-destructive `.env` helpers) already present in the base branch. 2. `packages/cli/src/commands/setup/engine.test.ts` (new) — 9 tests, all passing, run via `npx tsx --test`. 3. `packages/cli/tsconfig.json` (modified) — excludes `*.test.ts` from the build so the test lives next to its source without leaking into `dist/`. Design The engine separates *sequencing/decision logic* from *I/O* via two injectable seams, so it runs fully mocked in tests (no Docker/network/TTY): - `SetupPrompts` — optional callback hooks a renderer (Ink or readline, in later issues) supplies for user decisions (root, agents, GitHub auth, start, whitelist, repo, UI). Every hook is optional with a safe non-interactive default. - `SetupActions` — the side-effecting operations, with `createDefaultActions()` binding to the real `runChecks`, `scaffoldStack`, orchestrator (pull/start/health), and repo API. Heavy modules are lazy-imported so importing the engine stays cheap and Docker-free. - `SetupReporter` — optional progress hooks (`onState`/`onStepStart`/`onStepSettled`/`onLog`). Order & safety contract (matches all requirements) `check → init-stack → pull-images → configure-agents → github-auth → start-stack → whitelist → repo → launch-ui` - Checks run first and steer the rest; a missing/unreachable Docker daemon blocks the flow with a clear next action, while addressable failures (e.g. GitHub auth) continue. - Init only when `.env` is missing or the user picks a new root; `scaffoldStack` is always called without `force`, so an existing `.env` is never overwritten wholesale. - Core images pull by default; agent images only for selected agents (default = agents detected on the host). - Stack start validates backend health afterward; a running stack is reused, not restarted (user data untouched). - All `.env` edits go through the non-destructive per-key `applyEnvSelection`. - Optional repo addition can be skipped or fail without aborting the run (becomes a warning). Verification - `npm run typecheck` ✅ - `npm run build` ✅ (declarations emit cleanly; test excluded from `dist/`) - `npm run lint` ✅ (only a pre-existing warning in a generated file) - 9/9 engine tests pass, covering: re-run leaves install intact, selective image pulls, optional-repo skip/failure tolerance, Docker-blocked check, unresolved auth warning, unhealthy-backend warning, running-stack reuse, and a full unattended run hitting every step in order.
|
/ultrafix |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 10) First action:
|
|
✅ AI Code Review Complete requested by @propr-dev[bot] Posted 1 review: |
🔍 AI Code Review — codex:gpt-5.5Overall EvaluationThis PR adds a clean, UI-agnostic setup wizard engine with injectable actions/prompts and focused tests around the main happy paths and several failure modes. The structure is generally solid, but I would not merge it as-is because a few required setup scenarios can still fail silently or escape the engine’s state model. Overall: needs minor-to-moderate changes before merge. Findings🔴 Incomplete stack roots are treated as initialized — 🔴 Several setup action failures can throw out of 🟡 Prompt-selected agent types are not validated — 🟡 🟡 🟡 Hard-coded Docker check names are brittle — 🟡 Tests are excluded from 🟢 Consider sharing the agent catalog instead of duplicating it — 🟢 Consider reporting GitHub auth warnings from ✅ Good separation of orchestration from UI — ✅ Non-destructive setup behavior is a strong default — ✅ Tests cover important behavior without Docker/network dependencies — ScoreThe implementation is well-structured and close, but the incomplete-stack handling and uncaught action failures are important correctness gaps for a setup wizard. 🤖 Review Details
|
|
✅ Applied the requested follow-up changes in commit d5ef628
Summary of ChangesAll findings are addressed. Here's a summary of the changes I made to address the AI review findings on PR #1613: 🔴 Critical fixes
🟡 Moderate fixes
🟢 Minor
I left the 🟢 "share the agent catalog" suggestion as-is — deduplicating it would require restructuring exports across the check/init modules, which is broader than this focused fix. Verification
🤖 Implementation Details
💡 ProPR Slash Commands
|
…ars only in the check-step path (its legitimate use), confirming it was cleanly removed from the image-pull boundary. All findings are addressed. `skipRemoteImageCheck` now appears only in the check-step path (its legitimate use), confirming it was cleanly removed from the image-pull boundary. Here's a summary of the changes I made to address the AI review findings on PR #1613: ## 🔴 Critical fixes 1. **Incomplete stack roots no longer treated as initialized** (`engine.ts`) — the scaffold decision now keys off `!init.initialized` instead of `!init.envExists`. A root with a stray `.env` but missing `data/`/`logs/`/`repos/` now gets re-scaffolded (non-destructively, `.env` preserved) instead of being skipped and failing later at startup. 2. **Setup action failures become step failures, never escaped exceptions** — wrapped the previously-unguarded bodies of `pull-images` (incl. `selectAgents`), `configure-agents`, `github-auth`, `start-stack` (incl. `isStackRunning`/`checkBackendHealth`), `whitelist` (incl. `readEnvVars`), `repo`, and `launch-ui` prompts in try/catch. Required steps settle as `failed` and stop the flow; optional steps degrade to `warning`. Honors the documented "expected failures are reported in state" contract. ## 🟡 Moderate fixes 3. **Agent selections validated** — renderer-returned agent names are now de-duped (first wins) and filtered against the catalog, so unknown names never reach `pullImages()` and duplicates can't double-apply credentials. 4. **`RootDecision.reinitialize` comment clarified** to reflect the actual non-destructive behavior. 5. **`skipRemoteImageCheck` removed from `PullImagesParams`** since the default action ignored it; it remains only on the check step where it's used. 6. **`blockingDockerFailure` made structural** — keys off `group === "Docker" && status === "fail"` instead of exact check-name strings (the socket check tops out at `warn`, so this is precise). 7. **Tests are now type-checked** — added `tsconfig.test.json` (includes `*.test.ts`) and wired it into `npm run typecheck`. ## 🟢 Minor 8. **GitHub auth warnings surfaced** — when the shared detector resolves a mode but flags a partial config, the step now reports a `warning` with those warnings instead of silently showing `done`. I left the 🟢 "share the agent catalog" suggestion as-is — deduplicating it would require restructuring exports across the check/init modules, which is broader than this focused fix. ## Verification - `npm run typecheck` (now incl. tests) — clean - `npm run build` — clean - Engine tests — **12 passing** (added 3 new: incomplete-stack scaffolding, agent de-dup/filtering, action-throw-becomes-step-failure) - `npm run lint` — only a pre-existing warning in a generated `dist/` file I didn't touch PR: #1613 Comment by: @propr-ultrafix (ID: 0) Model: claude-opus-4-8
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-5.5Overall EvaluationThis PR adds a UI-agnostic setup wizard engine with good separation between prompts, reporting, and side effects. The flow is mostly well-structured, heavily mockable, and covered by focused node:test tests for re-runs, partial stack scaffolding, optional steps, and failure handling. I would rate this as close to mergeable, but it needs minor changes before merging due to a couple of behavior and maintainability concerns in the engine defaults. Findings🟡 Warning — Start skip still allows later backend-dependent steps: In 🟡 Warning — Duplicated agent catalog can drift from command behavior: 🟡 Warning — 🟢 Suggestion — Sanitize empty whitelist prompt results before deciding status: In 🟢 Suggestion — ✅ Positive — Good side-effect isolation: ✅ Positive — Re-run safety is explicitly handled: The initialization logic preserves existing ✅ Positive — Tests cover the important flow boundaries: ✅ Positive — Build/test TypeScript separation is sensible: Excluding tests from ScoreScore: 8/10 Strong implementation with clear architecture and useful tests. I would address the skipped-start follow-on behavior and agent catalog drift before merging. 🤖 Review Details
|
348560e
into
1599-epic-build-comprehensive-b5c
AI Implementation Summary
Closes #1601
Branch:
1601/claude-opus-4-8-implement-the-setup-wizar-20260622-0950-0emCommits: ✅ Changes committed (0c98d83)
AI Processing Completed
Execution Details:
Summary:
The implementation is complete and verified. Here's a summary of what I implemented for issue #1601.
Summary
I created the UI-agnostic setup wizard engine that sequences
check+init stackbehavior and the remaining one-time setup tasks in a safe order.Files
packages/cli/src/commands/setup/engine.ts(new) — the engine. It builds on the existingsetup/types.tsandsetup/state.ts(step model + non-destructive.envhelpers) already present in the base branch.packages/cli/src/commands/setup/engine.test.ts(new) — 9 tests, all passing, run vianpx tsx --test.packages/cli/tsconfig.json(modified) — excludes*.test.tsfrom the build so the test lives next to its source without leaking intodist/.Design
The engine separates sequencing/decision logic from I/O via two injectable seams, so it runs fully mocked in tests (no Docker/network/TTY):
SetupPrompts— optional callback hooks a renderer (Ink or readline, in later issues) supplies for user decisions (root, agents, GitHub auth, start, whitelist, repo, UI). Every hook is optional with a safe non-interactive default.SetupActions— the side-effecting operations, withcreateDefaultActions()binding to the realrunChecks,scaffoldStack, orchestrator (pull/start/health), and repo API. Heavy modules are lazy-imported so importing the engine stays cheap and Docker-free.SetupReporter— optional progress hooks (onState/onStepStart/onStepSettled/onLog).Order & safety contract (matches all requirements)
check → init-stack → pull-images → configure-agents → github-auth → start-stack → whitelist → repo → launch-ui.envis missing or the user picks a new root;scaffoldStackis always called withoutforce, so an existing.envis never overwritten wholesale..envedits go through the non-destructive per-keyapplyEnvSelection.Verification
npm run typecheck✅npm run build✅ (declarations emit cleanly; test excluded fromdist/)npm run lint✅ (only a pre-existing warning in a generated file)Detailed Logs:
22028230-932c-4e73-8fb8-36d4feaa9a9dLog files stored at:
/tmp/claude-logs/issue-1601-2026-06-22T10-02-25-217Z-conversation.json/tmp/claude-logs/issue-1601-2026-06-22T10-02-25-217Z-output.txtLatest Conversation Messages
This PR was created automatically by ProPR after processing issue #1601.
💡 Need changes?
Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!