Skip to content

fix(ai-tools): honor defaultAI config in termly start - #63

Open
kozliatko wants to merge 1 commit into
termly-dev:mainfrom
kozliatko:fix/use-default-ai-config
Open

fix(ai-tools): honor defaultAI config in termly start#63
kozliatko wants to merge 1 commit into
termly-dev:mainfrom
kozliatko:fix/use-default-ai-config

Conversation

@kozliatko

Copy link
Copy Markdown

Problem

defaultAI is currently a write-only config key.

Three code paths write it, none read it:

Location Role
lib/config/manager.js:7 defines the schema
lib/commands/setup.js:30 termly setup stores the answer
lib/commands/config.js termly config set defaultAI <tool> stores it, termly config prints it
lib/config/manager.js:44 getDefaultAI() — exported, zero call sites

grep -rn "getDefaultAI" lib/ on main returns only the definition and the export.

The user-visible effect: someone runs termly setup, answers "Default AI tool: claude-code", sees Default AI: claude-code in termly config — and still gets the interactive Multiple AI tools detected: Which tool would you like to use? prompt on every single termly start. The setting silently does nothing.

Fix

selectAITool() now consults the config between the --ai flag and auto-detection:

--ai flag  ->  defaultAI config  ->  --no-auto-detect error  ->  auto-detect

--ai still wins, so nothing changes for explicit invocations.

Stale values are non-fatal

Unlike --ai, defaultAI is a stored preference that may have been set months ago. Routing it straight through selectManualTool() would have made termly start exit 1 the day a user uninstalls or renames their configured tool.

So selectConfiguredDefault() warns and returns null, letting the caller fall back to auto-detection:

⚠️  Configured default AI Aider is not installed - falling back to auto-detection
   Change it with: termly config set defaultAI <tool>
✓ Using Claude Code v2.1.263 (auto-detected)

Behavior change

Users who already have defaultAI set — possibly without realizing, since it never did anything — will stop seeing the tool-selection prompt. That is the behavior the setting always advertised, but it is a change worth calling out in release notes.

Verification

All four paths exercised against a stubbed getDefaultAI():

Scenario Result
--ai claude-code + defaultAI=demo claude-code — flag wins
defaultAI=demo (installed) Using Demo Mode (configured default)
defaultAI=nonexistent-xyz warns, falls back to auto-detect
defaultAI=aider (not installed) warns, falls back to auto-detect
defaultAI='' auto-detect, unchanged

Scope: lib/ai-tools/selector.js (+41) and a README note (+4). No dependency, protocol, or config-schema changes.

`defaultAI` was a write-only config key. `termly setup` and
`termly config set defaultAI <tool>` stored it and `termly config`
printed it back, but `getDefaultAI()` had no call sites, so the value
never influenced tool selection. Users who configured a default still
got the interactive "Multiple AI tools detected" prompt on every start.

selectAITool() now consults it between the --ai flag and auto-detection:

  --ai flag  ->  defaultAI config  ->  --no-auto-detect error  ->  auto-detect

Unlike --ai, defaultAI is a stored preference that may be months old, so
a stale value must not break `termly start`. If the configured tool is
unknown or no longer installed, Termly warns and falls back to
auto-detection rather than exiting.
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