Repository navigation
[1599 by Claude Opus 4.8] Add setup wizard domain model and idempotent stack state helpers - #1610
Conversation
…1599. Summary I created a setup-specific domain layer for the upcoming `propr setup` command, so the flow is fully testable without Ink or readline. `scaffoldStack` was already exported from `initStack.ts`, so no separate prerequisite change was needed. New files `packages/cli/src/commands/setup/types.ts` — the shared domain model: - `SetupStepStatus` (`pending` / `active` / `done` / `skipped` / `error`) and `SetupStepId` for the nine ordered steps (checks, init-stack, pull-images, agents, github-auth, start-stack, whitelist, repo, ui). - `SETUP_STEPS` definitions (title, description, `optional` flag) with each step documented against the existing API it reuses (`runChecks`, `scaffoldStack`, `pullImages`, `startStack`, the env helpers, etc.). - `SetupStepState` / `SetupState` (progress + `detail`/`error`/`action` for "next action"), `StackState` (fs-only scaffolding snapshot), and `SETUP_STATUS_GLYPH` / `SETUP_STATUS_LABEL` constants shared by both the TUI and a fallback renderer (mirroring `checkCommands.ts` conventions). `packages/cli/src/commands/setup/state.ts` — pure helpers: - `resolveSetupRoot` (wraps the shared `resolveStackRoot`), `getStackState` / `isStackInitialized` (fs-only idempotency), `initializeStack` (idempotent `scaffoldStack` wrapper), and `isStackRunning` (lazily imports the orchestrator so the module never touches Docker on import). - Safe `.env` editing: `readEnvValues` / `getEnvValue`, `isPlaceholderEnvValue` (kept in sync with `checkCommands.ts`), `writeEnvSelection` (explicit choices, skips empties), and `seedEnvDefaults` (non-destructive — only fills missing/placeholder values, preserving real ones). Both writers reuse `upsertEnvVars`. - Step-model helpers: `createSetupState`, `updateStep` (immutable), `nextActionableStep`, `summarizeSetup`, `isSetupComplete`. `test/cliSetupState.test.ts` — 8 `node:test` cases (matching the existing `cliEnvFile.test.ts` style) covering stack-state detection, env parsing, placeholder detection, both write helpers' preserve/overwrite semantics, and step-model advancement. Verification - `tsc --noEmit` passes for the CLI package. - All 8 new tests pass; the existing `cliEnvFile` test still passes. Acceptance criteria - ✅ Helpers import without starting Docker or rendering UI (orchestrator is loaded lazily only inside `isStackRunning`). - ✅ Existing `.env` values preserved unless a step explicitly writes a selected value (`seedEnvDefaults` vs `writeEnvSelection`). - ✅ The model carries enough (status, detail, action, summary, next-step) for both a TUI and a sequential renderer.
|
/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 setup wizard domain model plus stack/env state helpers and focused tests. The structure is generally sound and aligns with the issue’s goal of keeping setup logic renderer-independent. I would mark this as needing minor changes before merge. The main concerns are around edge-case correctness in step progression and stack initialization detection. Findings🟡 Errored steps are skipped by nextActionableStep — In 🟡 Stack initialization treats files as directories — In 🟡 Whitespace-only env selections are written — In 🟡 Top-level orchestrator import contradicts lazy-import intent — 🟢 Consider clearing stale fields when status changes — In 🟢 Consider validating skipped required steps — ✅ Good separation of domain model from UI — ✅ Env writes are mostly non-destructive — ✅ Focused tests cover the core helpers — ScoreSolid foundation with good test coverage, but a few edge cases could cause incorrect setup flow decisions or invalid stack state detection. Score: 7/10 🤖 Review Details
|
|
✅ Applied the requested follow-up changes in commit a6e1dee
Summary of ChangesAll changes are complete and verified (12/12 tests pass, no type errors). Here's a summary of what I addressed from the review: Changes to
|
| Command | Description | Example |
|---|---|---|
/merge |
Merge target branch into this PR and resolve conflicts | /merge |
/review |
Request an AI code review | /review or /review claude-sonnet |
/fix |
Implement fixes for issues found by /review |
/fix or /fix address the null check issue |
/switch |
Change the AI model for this PR | /switch claude-opus |
/use |
Override the model for a single follow-up run | /use claude-sonnet |
/ultrafix |
Loop review→fix cycles until score goal is met | /ultrafix or /ultrafix goal=8 max=10 |
… type errors). Here's a summary of what I addressed from the review: All changes are complete and verified (12/12 tests pass, no type errors). Here's a summary of what I addressed from the review: ## Changes to `packages/cli/src/commands/setup/state.ts` **🟡 Errored steps skipped by `nextActionableStep`** — Now returns `pending`, `active`, **or `error`** steps, so a failed step is surfaced ahead of later pending steps and the flow waits for the user to act. **🟡 Stack initialization treats files as directories** — Added type-aware `isFile`/`isDirectory` helpers (wrapping `statSync`, catching errors). `getStackState` now requires `data`/`logs`/`repos` to be real directories and `.env` to be a real file, so a regular file named `data` no longer makes a root look initialized. **🟡 Whitespace-only env selections written** — Replaced `isEmpty` with a `hasValue` type guard that rejects `undefined`, `""`, **and whitespace-only** values. Used in both `writeEnvSelection` and `seedEnvDefaults`, so blank prompt input is skipped rather than written. **🟡 Top-level orchestrator import vs. lazy intent** — Updated the module doc comment to accurately describe the boundary: `resolveStackRoot` is a pure path helper (node builtins only — importing it does not load the Docker-backed core), and the heavy `orchestrator.mjs` core is still loaded lazily only by `isStackRunning`. **🟢 Stale fields on status change** — `updateStep` now clears a stale `error` when a step leaves the `error` state (e.g. `error → done` after a retry), unless the caller explicitly sets a new error in the patch. **🟢 Skipped required steps** — `isSetupComplete` now treats a `skipped` step as complete **only if the step is optional** (using the `optional` flag from `SETUP_STEPS`); a skipped required step keeps setup incomplete. ## Tests added to `test/cliSetupState.test.ts` Coverage for files-masquerading-as-dirs, whitespace env values, errored-step surfacing, stale-error clearing, and skipped-required-step rejection. I have not committed — the system will handle that. PR: #1610 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 clean setup wizard domain layer with step/status types, stack initialization state helpers, non-destructive Findings🟡 Warning — 🟡 Warning — 🟢 Suggestion — Placeholder detection should probably normalize quotes (packages/cli/src/commands/setup/state.ts): 🟢 Suggestion — Test ✅ Positive — Good separation between domain state and rendering (packages/cli/src/commands/setup/types.ts, packages/cli/src/commands/setup/state.ts): The step model is UI-agnostic and should work for both Ink and fallback renderers without pulling in readline or terminal concerns. ✅ Positive — Non-destructive env writing is well designed (packages/cli/src/commands/setup/state.ts): Splitting explicit selections from default seeding is a good distinction, and the tests cover preservation, overwrite, and blank-value skipping. ✅ Positive — Stack initialization checks are type-aware (packages/cli/src/commands/setup/state.ts): Treating files named ScoreScore: 8/10 🤖 Review Details
|
AI Implementation Summary
Closes #1599
Branch:
1599/claude-opus-4-8-add-setup-wizard-domain-m-20260622-0930-ge5Commits: ✅ Changes committed (7b5bdc1)
AI Processing Completed
Execution Details:
Summary:
Everything passes. Here's a summary of what I implemented for issue #1599.
Summary
I created a setup-specific domain layer for the upcoming
propr setupcommand, so the flow is fully testable without Ink or readline.scaffoldStackwas already exported frominitStack.ts, so no separate prerequisite change was needed.New files
packages/cli/src/commands/setup/types.ts— the shared domain model:SetupStepStatus(pending/active/done/skipped/error) andSetupStepIdfor the nine ordered steps (checks, init-stack, pull-images, agents, github-auth, start-stack, whitelist, repo, ui).SETUP_STEPSdefinitions (title, description,optionalflag) with each step documented against the existing API it reuses (runChecks,scaffoldStack,pullImages,startStack, the env helpers, etc.).SetupStepState/SetupState(progress +detail/error/actionfor "next action"),StackState(fs-only scaffolding snapshot), andSETUP_STATUS_GLYPH/SETUP_STATUS_LABELconstants shared by both the TUI and a fallback renderer (mirroringcheckCommands.tsconventions).packages/cli/src/commands/setup/state.ts— pure helpers:resolveSetupRoot(wraps the sharedresolveStackRoot),getStackState/isStackInitialized(fs-only idempotency),initializeStack(idempotentscaffoldStackwrapper), andisStackRunning(lazily imports the orchestrator so the module never touches Docker on import)..envediting:readEnvValues/getEnvValue,isPlaceholderEnvValue(kept in sync withcheckCommands.ts),writeEnvSelection(explicit choices, skips empties), andseedEnvDefaults(non-destructive — only fills missing/placeholder values, preserving real ones). Both writers reuseupsertEnvVars.createSetupState,updateStep(immutable),nextActionableStep,summarizeSetup,isSetupComplete.test/cliSetupState.test.ts— 8node:testcases (matching the existingcliEnvFile.test.tsstyle) covering stack-state detection, env parsing, placeholder detection, both write helpers' preserve/overwrite semantics, and step-model advancement.Verification
tsc --noEmitpasses for the CLI package.cliEnvFiletest still passes.Acceptance criteria
isStackRunning)..envvalues preserved unless a step explicitly writes a selected value (seedEnvDefaultsvswriteEnvSelection).Detailed Logs:
1ab8e64c-9164-41f1-bacd-5f22fc6a3739Log files stored at:
/tmp/claude-logs/issue-1599-2026-06-22T09-37-37-091Z-conversation.json/tmp/claude-logs/issue-1599-2026-06-22T09-37-37-091Z-output.txtLatest Conversation Messages
This PR was created automatically by ProPR after processing issue #1599.
💡 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!