Skip to content

The preflight offers to install what is missing, starts the login, and --doctor runs just that (#59) - #62

Merged
brettheap merged 2 commits into
mainfrom
feat/guided-preflight
Sep 6, 2026
Merged

brettheap merged 2 commits into
mainfrom
feat/guided-preflight

Conversation

@brettheap

@brettheap brettheap commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Lane: xfactory-2 (xFactory-2)
Claim: #59 (claim in the issue body)

Closes #59.

What this changes

The preflight offers to install what is missing, starts the login, and --doctor runs just that. Brett Heap, 2026-09-05, in session, after walking through the eight steps a new Mac user takes: "why not have an install program that will do all this? so the user gets our program and then runs that and we do all this?" → "yes" to this design. Steps 5 and 7 of that walk were already the program; steps 1–4 were commands the preflight NAMED and then left the user to type. Now it asks.

  • Offers, in setup-project.py only. When a check fails and a terminal is attached, the preflight prints the platform's install command and asks once — Run \brew install gh` now? Type yes to continue:— runs it onyes, re-checks once, and continues. Anything else leaves today's text and today's exit code. The table (INSTALL_OFFERS, keyed by tool and sys.platform, first row whose package manager is on PATH wins): git → xcode-select --installon macOS (Apple's dialog; the tool says "run this again when it has finished" and stops, no re-check),sudo apt-get install -y git/sudo dnf install -y git, winget install --id Git.Git -e; gh → brew install ghwhen brew is present (no brew: the brew.sh link and stop — **Homebrew's installer is never run by us**), the README's own apt and dnf blocks byte for byte,winget install --id GitHub.cli -e; then gh auth login; then gh auth setup-git. A too-old Python gets text only (an install cannot change the interpreter already running); make` stays optional and unoffered; an unrecognised platform gets today's text.
  • Consent is per action and is NOT --yes. --yes skips the one scaffold question and cannot answer an offer. No terminal → no prompt, today's refusal. EOF on the prompt is "no". Nothing in the test suite has a terminal, and every offer in the tests runs against a fake runner and a fake which, so CI cannot execute an installer on any platform.
  • The login is started, not completed. gh installed but not authenticated → offer gh auth login, attached to the user's terminal; the browser half is theirs. gh authenticated but git has no credential helper at all (neither credential.https://github.com.helper nor credential.helper) → a [??] warning and an offer of gh auth setup-git, never a refusal: keychain, Windows credential manager and SSH remotes all work without gh's helper.
  • --doctor. Preflight with its offers, then stop: exit 0 when everything is present and gh is authenticated (or --local-remote-dir is given), 1 otherwise. It returns before the git probe and the checkout probe, so it needs no --org and never clones the standard. openRepoShape --doctor forwards it without asking for an organisation or a project; py setup-project.py --doctor on Windows. setup.sh needed no change for the flag.
  • The bare Mac. On a Mac without the Command Line Tools the shim fails on Python before it ever reaches its git probe, so both of the shim's refusals gain a Darwin-only sentence pointing at xcode-select --install, which supplies git, make and a python3. Text only, no prompt, bash 3.2 clean; the shim is otherwise byte-identical to setup.sh is a shim over setup-project.py: the flow exists once (#50) #60.
  • README § Quick start leads with "run it; it offers the rest, or --doctor first" and keeps the per-platform paragraphs as the reference for what the offers run; winget … -e now matches the table. AGENTS.md gains the rule that an assistant never answers an install prompt — the human types it, exactly as for the repository-creation prompt.
  • Tests (+20): the offer table per platform (Darwin with and without brew, linux with apt-get, with dnf, with neither, win32), a refused offer keeps today's text and code, no TTY → no prompt, --yes does not install, --doctor exit codes with and without --local-remote-dir, README ↔ table parity (the fenced apt/dnf blocks and the one-line commands are the same bytes), the command forwards --doctor without an org, the shim's Darwin sentence, pure-ASCII still holds. One hygiene regex relaxed from single-match to all-match because the README now carries py setup-project.py twice.

Adversarial Opus review before opening: proved the CI-safety claim live over a real pseudo-terminal (EOF at the prompt is "no"; --yes with gh missing still asks; every offer in the tests runs against a fake runner and a fake which; the four new subprocess tests all go through the stdin-closing harnesses), AST-walked the offer table (every command is a string literal; nothing user-controlled can reach bash -c), and confirmed --doctor returns before the git probe, the checkout probe and the org handshake by position. Four fixes folded in: the AGENTS.md rule now names all three prompts (install, gh auth login, gh auth setup-git), not installs alone; the shim-flag test's allowance is tied to xcode-select --install so a re-grown --install) case would still fail it; a README-rationale count corrected; the command's new usage line is asserted. Residual, stated: openRepoShape --doctor on a real machine still self-bootstraps a temp checkout of the standard first (git and network), as the design accepted; py setup-project.py --doctor clones nothing.

Known and deliberately left. gh's own "is this our helper" rule is not transcribed: under the rule above any helper at all is silence, so identifying gh's would change no outcome. Pre-existing, not touched here: tests/test_adopt_plan.py:27 carries a host-absolute scratchpad path to an optional MedxEHR clone (skip-guarded; there since the first commits, 6013a5b, 2026-09-02). An environment variable is the fix: #61, filed unclaimed.

Evidence

Linux: python3 -m pytest tests -q — 611 passed (591 on main at a0962e8). macOS and Windows: the tests-macos and tests-windows jobs on this PR; every offer row is platform-pure (the platform is an argument), so the same tests run on all three. Live, nothing installed: --doctor --local-remote-dir exits 0 and creates nothing; with an emptied PATH it lists both faults and exits 1 with no prompt; with git's config emptied it warns about the helper and still exits 0; openRepoShape --doctor prompts for nothing.

Merge word: Brett Heap, 2026-09-05, "merge #59 on green too".

🤖 Generated with Claude Code

Summary by Sourcery

Guide users through missing prerequisite installation and authentication during preflight, and provide a preflight-only doctor mode.

New Features:

  • Add guided preflight offers that can install missing Git and GitHub CLI prerequisites on supported platforms after explicit per-action consent.
  • Add optional guided offers to start GitHub CLI authentication and configure Git credential integration.
  • Add a --doctor mode that runs preflight checks and exits without requiring project or organisation details or creating repositories.

Bug Fixes:

  • Improve macOS bootstrap guidance by pointing users without Command Line Tools to xcode-select --install.

Enhancements:

  • Treat missing Git credential helpers as non-blocking warnings while offering gh auth setup-git when appropriate.
  • Preserve non-interactive behavior and ensure --yes cannot approve installation or authentication actions.

Documentation:

  • Update the quick-start and platform guidance to document guided offers, --doctor, and revised Windows commands.
  • Document that assistants must not answer installation, login, or credential setup prompts.

Tests:

  • Add coverage for platform-specific install offers, consent and terminal behavior, authentication and credential setup, doctor exit behavior, command forwarding, documentation parity, and macOS shim guidance.

…d --doctor runs just that (#59)

Brett Heap, 2026-09-05, after walking through the eight steps a new Mac user
takes: "why not have an install program that will do all this? so the user
gets our program and then runs that and we do all this?" then "yes" to this
design. Two of those steps were already the program; the other four were
commands the preflight NAMED and then left the user to type. Now it asks.

setup-project.py: an offer table keyed by tool and platform, first row whose
package manager is on PATH wins — xcode-select --install (Apple's dialog; the
tool says run again when it finishes and stops), apt-get/dnf for git, brew
install gh or the brew.sh link (Homebrew's installer is never run by us), the
README's own apt and dnf blocks byte for byte, winget for git and gh, then
gh auth login, then gh auth setup-git. Each is one typed yes, mirroring the
scaffold's own prompt; --yes never answers an offer; no terminal means no
prompt and today's refusal; EOF is no; re-check once. A too-old Python gets
text only, because an install cannot change the interpreter already running.
A missing credential helper is a warning plus an offer, never a refusal.

--doctor runs the preflight with its offers and stops: exit 0 when everything
is present and gh is authenticated (or --local-remote-dir is given), else 1.
It returns before the git probe, the checkout probe and the org handshake, so
it needs no --org and never clones the standard. The openRepoShape command
forwards it without asking for an organisation or a project.

setup.sh: a bare Mac fails in find_python before the shim's git probe, so both
refusals gain a Darwin-only sentence pointing at xcode-select --install. Text
only, bash 3.2 clean, otherwise byte-identical to #60.

README § Quick start leads with "run it; it offers the rest, or --doctor
first" and keeps the per-platform paragraphs as the reference for what the
offers run. AGENTS.md: an assistant never answers the install, login or
credential-helper prompt; the human types it. Caps 948 -> 967 and 273 -> 277.

Tests (+20), all with a fake runner and a fake which so nothing is ever
executed: the table per platform, a refused offer, no TTY, --yes does not
install, --doctor exit codes, README <-> table parity, the command forwards
--doctor, the shim's Darwin sentence. 611 pass on Linux.

Adversarial Opus review before opening proved the CI-safety claim over a real
pty and folded in four fixes (the AGENTS.md rule names all three prompts; the
shim-flag allowance is tied to its one string; a rationale count; a usage-line
assertion).

Lane: xfactory-2 (xFactory-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 6, 2026 01:34
@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 13 hours and 30 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@sourcery-ai

sourcery-ai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR turns preflight into a consent-driven, platform-aware setup assistant for missing Git, gh, login, and credential configuration, adds a non-scaffolding --doctor diagnostic path, updates the shell entry-point guidance and documentation, and adds extensive tests to enforce CI safety and README/command parity.

Sequence diagram for preflight installation offers

sequenceDiagram
    participant User
    participant Preflight
    participant PackageManager
    participant Tool

    Preflight->>Preflight: _check_git()
    alt Git is missing and terminal is attached
        Preflight->>User: offer(command)
        User-->>Preflight: Type yes
        Preflight->>PackageManager: run_command_text(install command)
        PackageManager-->>Preflight: return code
        Preflight->>Preflight: re-check Git once
    else Offer declined or no terminal
        Preflight-->>User: Keep existing failure and exit behavior
    end

    Preflight->>Preflight: _check_gh()
    alt gh is missing
        Preflight->>User: offer(command)
        User-->>Preflight: Type yes
        Preflight->>PackageManager: run_command_text(install command)
        PackageManager-->>Preflight: return code
        Preflight->>Preflight: Re-check gh once
    else gh is unauthenticated
        Preflight->>User: offer(gh auth login)
        User-->>Preflight: Type yes
        Preflight->>Tool: gh auth login
        Tool-->>User: Interactive login and browser flow
        Preflight->>Tool: gh auth status
    end
Loading

Flow diagram for the --doctor diagnostic path

flowchart TD
    A["--doctor"] --> B["preflight_checks(opts)"]
    B --> C["Check Git, Python, bootstrap, and gh"]
    C --> D{"Missing item has an install offer?"}
    D -- Yes --> E["Ask for typed yes and run offer"]
    D -- No --> F["Keep diagnostic failure"]
    E --> G["Re-check once"]
    F --> H["Compute readiness"]
    G --> H
    H --> I{"All required checks pass?"}
    I -- Yes --> J["Exit 0; nothing was created"]
    I -- No --> K["Exit 1; nothing was created"]
Loading

File-Level Changes

Change Details Files
Add interactive, platform-aware prerequisite installation offers to the Python preflight while preserving non-interactive behavior and existing refusal semantics.
  • Define an INSTALL_OFFERS table for Git and GitHub CLI across macOS, Linux, and Windows, selecting the first available package manager.
  • Prompt only on an attached terminal and require an exact per-action yes; keep --yes scoped to repository creation and never run Homebrew’s installer.
  • Run package-manager commands from reviewed string literals, re-check successful installs once, and handle macOS Command Line Tools, Windows PATH refreshes, and failures explicitly.
  • Offer gh auth login through inherited terminal I/O and warn/optionally offer gh auth setup-git when no GitHub credential helper is configured.
  • Keep Python, make, unsupported platforms, and Homebrew installation as text-only/manual paths.
setup-project.py
Introduce a doctor mode that performs only preflight checks and reports machine readiness without scaffolding or requiring project/organisation inputs.
  • Add and parse --doctor, return before checkout, self-bootstrap, organisation, and project handling.
  • Use exit code 0 for readiness and 1 for missing prerequisites while preserving normal scaffold refusal behavior.
  • Support --local-remote-dir and ensure doctor mode creates no repositories or temporary checkout.
setup-project.py
openRepoShape
tests/test_openreposhape_command.py
tests/test_setup_project_py.py
Document the guided preflight workflow and prevent automated assistants from accepting installation or authentication prompts.
  • Explain offers, consent rules, doctor usage, and platform command references in the quick-start and requirements documentation.
  • Align Windows commands and README install snippets with the executable offer table.
  • Explicitly require humans to answer install, login, and credential-helper prompts.
README.md
AGENTS.md
Improve the macOS bootstrap shim and preserve its role as a text-only prerequisite gate.
  • Add a Darwin-only Command Line Tools hint to both Python and Git refusal messages.
  • Do not add install prompting or duplicate the offer table to the shell shim.
  • Extend shim tests to constrain the exception for xcode-select --install.
setup.sh
tests/test_setup_project_py.py
Expand safety, parity, and behavior coverage for offers, doctor mode, documentation, and command forwarding.
  • Test platform table selection, package-manager precedence, consent, TTY gating, EOF/refusal, --yes isolation, re-check behavior, and shell versus argv execution.
  • Test login and credential-helper handling, doctor exit codes, no-org forwarding, no-clone behavior, and Darwin shim messaging.
  • Verify offer commands are ASCII and documented in README, and update hygiene assertions for new documentation occurrences.
tests/test_setup_project_py.py
tests/test_openreposhape_command.py
tests/test_repo_hygiene.py

Assessment against linked issues

Issue Objective Addressed Explanation
#59 Have preflight offer and run the documented platform-specific commands for every missing prerequisite, including Git, Python, GitHub CLI, login, and Git credential setup, with per-action human consent, no silent installation, and no offers without a terminal. ❌ The PR implements offers for Git and GitHub CLI and starts the login, but it deliberately does not offer a Python installation when the Python check fails; it only prints guidance. It also stops after launching macOS's xcode-select dialog instead of re-checking and continuing as specified. Additionally, credential-helper detection treats any configured helper as sufficient rather than verifying that the helper reaches GitHub/gh as required.
#59 Add --doctor to run the preflight and its offers only, require no project or organisation, create nothing, and return 0 when ready or 1 when prerequisites remain missing. ✅
#59 Update the documented entry points, README, AGENTS.md, and tests while keeping setup.sh as an unchanged shim and preserving command parity between the README and the offer table. ❌ The README, AGENTS.md, and tests are updated and the offer-table parity is covered, but the PR modifies setup.sh despite the issue explicitly stating that anything in setup.sh is out of scope and that it must remain a shim.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It adds new interactive “run install/login commands” execution paths that can directly affect user machines, so it warrants final human review despite strong test coverage.

Pull request overview

This PR implements the “guided preflight” experience: when prerequisites are missing and an interactive terminal is attached, setup-project.py offers to run the documented platform install/login commands (with explicit per-action consent), and introduces a --doctor mode that runs preflight+offers and then stops without scaffolding.

Changes:

  • Add an install/offer table plus prompting + execution helpers in setup-project.py, including gh auth login / gh auth setup-git offers and a new --doctor early-exit path.
  • Update the openRepoShape wrapper and setup.sh shim to support --doctor and improve bare-macOS guidance (Command Line Tools hint).
  • Expand tests and docs to lock README↔offer parity, consent/TTY behavior, and --doctor exit semantics; update AGENTS.md with the “never answer install/login prompts” rule.
File summaries
File Description
tests/test_setup_project_py.py Adds extensive unit coverage for offer behavior, credential-helper warnings, and --doctor.
tests/test_repo_hygiene.py Updates doc-length caps and enforces README↔offer-command parity; improves Windows py … checks.
tests/test_openreposhape_command.py Adds --doctor usage assertions and passthrough behavior tests.
setup.sh Adds macOS Command Line Tools hinting in refusals (text-only) for bare machines.
setup-project.py Implements offer table, prompting/execution, credential-helper warning+offer, and --doctor.
README.md Documents the new guided preflight behavior and --doctor, and aligns commands (incl. winget -e).
openRepoShape Adds --doctor flag handling to avoid org/project prompting while still forwarding args.
AGENTS.md Adds rule forbidding assistants from answering install/login/setup-git prompts.
Review details

Suppressed comments (1)

setup.sh:79

  • This refusal message concatenates the documentation URL and $MAC_TOOLS with no separator, producing output like https://git-scm.com/downloads On a Mac, ... that reads like a malformed URL. Add a sentence separator and strip the leading space from $MAC_TOOLS at the use site.
command -v git >/dev/null 2>&1 || die "git is not installed. Install it: https://git-scm.com/downloads$MAC_TOOLS"
  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread setup.sh
return 1
}
PY="$(find_python)" || die "no Python 3.9 or newer on this machine (tried python3, python). Install Python 3.9 or newer and re-run: https://www.python.org/downloads/"
PY="$(find_python)" || die "no Python 3.9 or newer on this machine (tried python3, python). Install Python 3.9 or newer and re-run: https://www.python.org/downloads/$MAC_TOOLS"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Taken, in 610363c. The Mac sentence now starts on its own line, indented two spaces under the refusal, so the URL stands alone: bash 3.2-safe $'...' quoting, words unchanged, and die prints with printf '%s' so the newline is real. Both call sites render the same way.

Lane: xfactory-2 (xFactory-2)

…ot on #62)

Copilot's one finding on PR #62: the Darwin-only Command Line Tools sentence
ran straight on from the python.org or git-scm URL on the same line. It now
begins with a newline and a two-space indent, so the URL stands alone and the
sentence reads underneath it. Bash 3.2-safe $'...' quoting; the words are
unchanged; `die` prints with printf '%s' so the newline is real. No test
asserted the old separator.

Lane: xfactory-2 (xFactory-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 6, 2026 01:50
@sonarqubecloud

sonarqubecloud Bot commented Sep 6, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Several user-facing messages/docs claim --doctor “creates nothing” even though --doctor can run installers (and the wrapper path creates a temporary checkout), so wording should be corrected for accuracy.

Review details

Suppressed comments (5)

Previously missed (3) — in code that hasn't changed since the last review.

README.md:116

  • This paragraph says --doctor runs "creating nothing", but --doctor can run install commands (and the openRepoShape entry point self-bootstraps a temporary checkout). Consider rephrasing to "creating no repositories" to match actual behavior.

This issue also appears on line 269 of the same file.
openRepoShape:41

  • The usage line says --doctor "creates nothing", but --doctor can offer to run installers; clarify that it creates no repositories (i.e., does not scaffold) rather than implying it makes no system changes.
    setup-project.py:154
  • --doctor can run install/login/setup commands (after a typed yes), so describing it as "Creates nothing" is misleading; it should be phrased as "creates no repositories" (or similar) to avoid implying it makes no system changes.

This issue also appears on line 1138 of the same file.

setup-project.py:1138

  • The --doctor output says "nothing was created", but a doctor run may execute installers (and when invoked via setup.sh/openRepoShape it also creates a temporary checkout). Wording like "no repositories were created" is accurate in all cases.
    say("  nothing was created; this checked the machine only.")

README.md:270

  • This sentence says --doctor "creates nothing", but --doctor can run installer commands after consent; consider clarifying to "creates no repositories" (i.e., it does not scaffold) to avoid implying no system changes.
Or run `openRepoShape --doctor`, which checks this machine, offers what is
missing and creates nothing.
  • Files reviewed: 8/8 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap
brettheap merged commit 6942d83 into main Sep 6, 2026
6 checks passed
@brettheap
brettheap deleted the feat/guided-preflight branch September 6, 2026 01:57
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.

The preflight offers to install what is missing and starts the login: a guided first run, --doctor (after #50)

2 participants