Skip to content

fix(bootstrap): detect installed AI assistant before non-interactive skip check - #342

Open
evansenter wants to merge 1 commit into
mainfrom
fix/prompt-ai-install-ordering
Open

fix(bootstrap): detect installed AI assistant before non-interactive skip check#342
evansenter wants to merge 1 commit into
mainfrom
fix/prompt-ai-install-ordering

Conversation

@evansenter

Copy link
Copy Markdown
Owner

Summary

Fixes ordering in prompt_ai_install in bootstrap.sh. Previously, the non-interactive check ([[ ! -t 0 ]]) was evaluated before checking whether claude or agy was already installed (command -v). As a result, running ./bootstrap.sh -f in non-interactive environments (such as agent runners, CI, or subshells) defaulted INSTALL_AI to false and skipped AI directory and MCP server configuration even on machines where Claude or Antigravity was installed.

Changes

  • In prompt_ai_install, check command -v claude || command -v agy before checking [[ ! -t 0 ]].
  • Added unit test test_prompt_ai_install_detects_installed_assistant in tests/test-bootstrap.sh verifying that an installed assistant is detected even when stdin is not a tty.

Verification

  • make check passes (129/129 hook tests, 54/54 bootstrap tests, shellcheck, syntax checks).
  • Verified running ./bootstrap.sh -f in non-interactive subshell now configures AI setup.

Comment thread bootstrap.sh
return 0
fi

# Non-interactive: default to skip

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Suggestion] Worth noting the blast radius this reorder opens up on the --pull/-p path, since it goes beyond the symlink/MCP configuration the PR description motivates.

With the installed-assistant check now ahead of the tty check, a non-interactive ./bootstrap.sh -f -p on a machine that has claude or agy also takes the INSTALL_AI == true branches at bootstrap.sh:573 (SteamOS Tailscale binary download), bootstrap.sh:658 (curl -fsSL https://tailscale.com/install.sh | sh on Debian/Ubuntu), bootstrap.sh:888 (pip3 install --upgrade piper-tts), and the Brewfile.ai bundle at bootstrap.sh:1026. Those are network-and-sudo side effects that previously could not happen without a human at the terminal.

This is not a defect — the Debian branch already runs sudo apt-get unconditionally a few lines earlier, so sudo-in-non-interactive is a pre-existing property of -p, and sudo without a tty errors rather than hanging. But if the intent was narrower ("configure AI dirs and MCP servers non-interactively") and not "install AI packages non-interactively", a tighter shape would be to keep INSTALL_AI=false for the package phase and gate only sync_dotfiles on assistant presence. Purely your call on which semantics you want.

Comment thread tests/test-bootstrap.sh
local ok=0
local result
result=$(
PATH="$stub:$PATH"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Suggestion] Two small robustness gaps in the new test:

  1. PATH="$stub:$PATH" prepends the stub rather than replacing PATH. On any machine where a real claude or agy is already on PATH — i.e. the maintainer machine, which is where make check usually runs — the command -v inside prompt_ai_install succeeds regardless of the stub, so the test would pass even if stub creation silently broke. Using PATH="$stub:/usr/bin:/bin" (or asserting the stub is what gets resolved) makes the test prove what it claims.

  2. Only the positive branch is covered. The reorder must also preserve "nothing installed + non-interactive → INSTALL_AI=false", which is the behavior the original ordering existed to provide. A sibling case with an empty stub dir and a scrubbed PATH asserting false would pin both halves, and would catch a future change that drops the tty check entirely.

Minor style note: the neighboring tests extract functions through _load_<fn> helpers (e.g. _load_symlink_agy_configs immediately below). Inlining the sed/eval here works fine, but a helper would match the local idiom.

@claude claude 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.

Prompt: evansenter/dotfiles/.../claude-review.md

Code Review — Round 1

Summary

The reorder in prompt_ai_install is correct and minimal: the "already an AI machine" fast path now runs before the non-interactive skip, so ./bootstrap.sh -f under an agent runner or subshell no longer drops Claude/agy directory symlinking and MCP registration on machines that clearly want it. The caching guard stays first, so repeat calls across the ~6 call sites still short-circuit, and the interactive prompt path is untouched. The new test is a genuine regression test — under the old ordering with stdin redirected from /dev/null it would observe false and fail.

Previously Addressed (Filtered)

None — no prior automated review rounds on this PR.

Verdict

APPROVE - No blocking findings. Two non-blocking suggestions posted inline: the widened scope of the non-interactive -p package path, and test isolation plus negative-branch coverage.


Automated review by Claude Code

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