feat: multi-runtime selection in interactive installer (#1281)

The interactive prompt now accepts comma-separated or space-separated
choices (e.g., "1,4,6" or "1 4 6") to install multiple runtimes in
one go, without needing --all or running the installer multiple times.

- Replaced if/else-if chain with runtimeMap lookup + split parser
- Added hint text: "Select multiple: 1,4,6 or 1 4 6"
- Invalid choices silently filtered, duplicates deduplicated
- Empty input still defaults to Claude Code
- Choice "8" still selects all runtimes

Tests: 10 new tests covering comma/space/mixed separators,
deduplication, invalid input filtering, order preservation,
and source-level assertions.

Closes #1281

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-03-21 09:52:52 -04:00
parent 33db504934
commit f3ce0957cd
3 changed files with 181 additions and 27 deletions

View File

@@ -4283,6 +4283,17 @@ function promptRuntime(callback) {
}
});
const runtimeMap = {
'1': 'claude',
'2': 'opencode',
'3': 'gemini',
'4': 'codex',
'5': 'copilot',
'6': 'antigravity',
'7': 'cursor'
};
const allRuntimes = ['claude', 'opencode', 'gemini', 'codex', 'copilot', 'antigravity', 'cursor'];
console.log(` ${yellow}Which runtime(s) would you like to install for?${reset}\n\n ${cyan}1${reset}) Claude Code ${dim}(~/.claude)${reset}
${cyan}2${reset}) OpenCode ${dim}(~/.config/opencode)${reset} - open source, free models
${cyan}3${reset}) Gemini ${dim}(~/.gemini)${reset}
@@ -4291,29 +4302,32 @@ function promptRuntime(callback) {
${cyan}6${reset}) Antigravity ${dim}(~/.gemini/antigravity)${reset}
${cyan}7${reset}) Cursor ${dim}(~/.cursor)${reset}
${cyan}8${reset}) All
${dim}Select multiple: 1,4,6 or 1 4 6${reset}
`);
rl.question(` Choice ${dim}[1]${reset}: `, (answer) => {
answered = true;
rl.close();
const choice = answer.trim() || '1';
if (choice === '8') {
callback(['claude', 'opencode', 'gemini', 'codex', 'copilot', 'antigravity', 'cursor']);
} else if (choice === '7') {
callback(['cursor']);
} else if (choice === '6') {
callback(['antigravity']);
} else if (choice === '5') {
callback(['copilot']);
} else if (choice === '4') {
callback(['codex']);
} else if (choice === '3') {
callback(['gemini']);
} else if (choice === '2') {
callback(['opencode']);
} else {
callback(['claude']);
const input = answer.trim() || '1';
// "All" shortcut
if (input === '8') {
callback(allRuntimes);
return;
}
// Parse comma-separated, space-separated, or single choice
const choices = input.split(/[\s,]+/).filter(Boolean);
const selected = [];
for (const c of choices) {
const runtime = runtimeMap[c];
if (runtime && !selected.includes(runtime)) {
selected.push(runtime);
}
}
callback(selected.length > 0 ? selected : ['claude']);
});
}