fix: first-time setup skips API key prompts + install.sh sudo on WSL

Two issues fixed:

1. (Critical) hermes setup tools / hermes tools: On first-time setup,
   the tool checklist showed all tools as pre-selected (from the default
   hermes-cli toolset), but after confirming the selection, NO API key
   prompts appeared. This is because the code only prompted for 'newly
   added' tools (added = new_enabled - current_enabled), but since all
   tools were already in the default set, 'added' was always empty.

   Fix: Detect first-time configuration (no platform_toolsets entry in
   config) and check ALL enabled tools for missing API keys, not just
   newly added ones. Returning users still only get prompted for newly
   added tools (preserving skip behavior).

2. install.sh: When run via curl|bash on WSL2/Ubuntu, ripgrep and ffmpeg
   install was silently skipped with a confusing 'Non-interactive mode'
   message. The script already uses /dev/tty for the setup wizard, but
   the system package section didn't.

   Fix: Try reading from /dev/tty when available (same pattern as the
   build-tools section and setup wizard). Only truly skip when no
   terminal is available at all (Docker build, CI).
This commit is contained in:
teknium1 2026-03-08 21:59:39 -07:00
parent 35d57ed752
commit a130aa8165
2 changed files with 42 additions and 9 deletions

View file

@ -882,7 +882,10 @@ def tools_command(args=None):
# Show checklist
new_enabled = _prompt_toolset_checklist(pinfo["label"], current_enabled)
if new_enabled != current_enabled:
# Detect first-time configuration (no saved toolsets for this platform yet)
is_first_config = pkey not in config.get("platform_toolsets", {})
if new_enabled != current_enabled or is_first_config:
added = new_enabled - current_enabled
removed = current_enabled - new_enabled
@ -895,12 +898,28 @@ def tools_command(args=None):
label = next((l for k, l, _ in CONFIGURABLE_TOOLSETS if k == ts), ts)
print(color(f" - {label}", Colors.RED))
# Configure newly enabled toolsets that need API keys
if added:
for ts_key in sorted(added):
if TOOL_CATEGORIES.get(ts_key) or TOOLSET_ENV_REQUIREMENTS.get(ts_key):
if not _toolset_has_keys(ts_key):
_configure_toolset(ts_key, config)
# Determine which tools need API key configuration.
# On first-time setup, check ALL enabled tools (the defaults
# include everything, so "added" would be empty and no API key
# prompts would ever appear). For returning users, only
# prompt for newly added tools.
tools_to_configure = new_enabled if is_first_config else added
unconfigured = [
ts_key for ts_key in sorted(tools_to_configure)
if (TOOL_CATEGORIES.get(ts_key) or TOOLSET_ENV_REQUIREMENTS.get(ts_key))
and not _toolset_has_keys(ts_key)
]
if unconfigured:
print()
print(color(f" {len(unconfigured)} tool(s) need API keys to be configured:", Colors.YELLOW))
for ts_key in unconfigured:
label = next((l for k, l, _ in CONFIGURABLE_TOOLSETS if k == ts_key), ts_key)
print(color(f"{label}", Colors.DIM))
print()
for ts_key in unconfigured:
_configure_toolset(ts_key, config)
_save_platform_tools(config, pkey, new_enabled)
save_config(config)