feat: add --sdk flag and interactive SDK prompt to installer (#1415)
Add installSdk() and promptSdk() to the installer so users can optionally install @gsd-build/sdk during GSD setup. The --sdk flag installs without prompting; interactive installs get a Y/N prompt after runtime installation completes. SDK installs use @latest with suppressed npm noise (--force --no-fund --loglevel=error, stdio: pipe). Cherry-picked from fix/sdk-cli-runtime-bugs (de9f18f) which was left out of #1407. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -69,6 +69,7 @@ const hasCursor = args.includes('--cursor');
|
||||
const hasWindsurf = args.includes('--windsurf');
|
||||
const hasBoth = args.includes('--both'); // Legacy flag, keeps working
|
||||
const hasAll = args.includes('--all');
|
||||
const hasSdk = args.includes('--sdk');
|
||||
const hasUninstall = args.includes('--uninstall') || args.includes('-u');
|
||||
|
||||
// Runtime selection - can be set by flags or interactive prompt
|
||||
@@ -327,7 +328,7 @@ if (hasUninstall) {
|
||||
|
||||
// Show help if requested
|
||||
if (hasHelp) {
|
||||
console.log(` ${yellow}Usage:${reset} npx get-shit-done-cc [options]\n\n ${yellow}Options:${reset}\n ${cyan}-g, --global${reset} Install globally (to config directory)\n ${cyan}-l, --local${reset} Install locally (to current directory)\n ${cyan}--claude${reset} Install for Claude Code only\n ${cyan}--opencode${reset} Install for OpenCode only\n ${cyan}--gemini${reset} Install for Gemini only\n ${cyan}--codex${reset} Install for Codex only\n ${cyan}--copilot${reset} Install for Copilot only\n ${cyan}--antigravity${reset} Install for Antigravity only\n ${cyan}--cursor${reset} Install for Cursor only\n ${cyan}--windsurf${reset} Install for Windsurf only\n ${cyan}--all${reset} Install for all runtimes\n ${cyan}-u, --uninstall${reset} Uninstall GSD (remove all GSD files)\n ${cyan}-c, --config-dir <path>${reset} Specify custom config directory\n ${cyan}-h, --help${reset} Show this help message\n ${cyan}--force-statusline${reset} Replace existing statusline config\n\n ${yellow}Examples:${reset}\n ${dim}# Interactive install (prompts for runtime and location)${reset}\n npx get-shit-done-cc\n\n ${dim}# Install for Claude Code globally${reset}\n npx get-shit-done-cc --claude --global\n\n ${dim}# Install for Gemini globally${reset}\n npx get-shit-done-cc --gemini --global\n\n ${dim}# Install for Codex globally${reset}\n npx get-shit-done-cc --codex --global\n\n ${dim}# Install for Copilot globally${reset}\n npx get-shit-done-cc --copilot --global\n\n ${dim}# Install for Copilot locally${reset}\n npx get-shit-done-cc --copilot --local\n\n ${dim}# Install for Antigravity globally${reset}\n npx get-shit-done-cc --antigravity --global\n\n ${dim}# Install for Antigravity locally${reset}\n npx get-shit-done-cc --antigravity --local\n\n ${dim}# Install for Cursor globally${reset}\n npx get-shit-done-cc --cursor --global\n\n ${dim}# Install for Cursor locally${reset}\n npx get-shit-done-cc --cursor --local\n\n ${dim}# Install for Windsurf globally${reset}\n npx get-shit-done-cc --windsurf --global\n\n ${dim}# Install for Windsurf locally${reset}\n npx get-shit-done-cc --windsurf --local\n\n ${dim}# Install for all runtimes globally${reset}\n npx get-shit-done-cc --all --global\n\n ${dim}# Install to custom config directory${reset}\n npx get-shit-done-cc --codex --global --config-dir ~/.codex-work\n\n ${dim}# Install to current project only${reset}\n npx get-shit-done-cc --claude --local\n\n ${dim}# Uninstall GSD from Cursor globally${reset}\n npx get-shit-done-cc --cursor --global --uninstall\n\n ${yellow}Notes:${reset}\n The --config-dir option is useful when you have multiple configurations.\n It takes priority over CLAUDE_CONFIG_DIR / GEMINI_CONFIG_DIR / CODEX_HOME / COPILOT_CONFIG_DIR / ANTIGRAVITY_CONFIG_DIR / CURSOR_CONFIG_DIR / WINDSURF_CONFIG_DIR environment variables.\n`);
|
||||
console.log(` ${yellow}Usage:${reset} npx get-shit-done-cc [options]\n\n ${yellow}Options:${reset}\n ${cyan}-g, --global${reset} Install globally (to config directory)\n ${cyan}-l, --local${reset} Install locally (to current directory)\n ${cyan}--claude${reset} Install for Claude Code only\n ${cyan}--opencode${reset} Install for OpenCode only\n ${cyan}--gemini${reset} Install for Gemini only\n ${cyan}--codex${reset} Install for Codex only\n ${cyan}--copilot${reset} Install for Copilot only\n ${cyan}--antigravity${reset} Install for Antigravity only\n ${cyan}--cursor${reset} Install for Cursor only\n ${cyan}--windsurf${reset} Install for Windsurf only\n ${cyan}--all${reset} Install for all runtimes\n ${cyan}--sdk${reset} Also install GSD SDK CLI (gsd-sdk)\n ${cyan}-u, --uninstall${reset} Uninstall GSD (remove all GSD files)\n ${cyan}-c, --config-dir <path>${reset} Specify custom config directory\n ${cyan}-h, --help${reset} Show this help message\n ${cyan}--force-statusline${reset} Replace existing statusline config\n\n ${yellow}Examples:${reset}\n ${dim}# Interactive install (prompts for runtime and location)${reset}\n npx get-shit-done-cc\n\n ${dim}# Install for Claude Code globally${reset}\n npx get-shit-done-cc --claude --global\n\n ${dim}# Install for Gemini globally${reset}\n npx get-shit-done-cc --gemini --global\n\n ${dim}# Install for Codex globally${reset}\n npx get-shit-done-cc --codex --global\n\n ${dim}# Install for Copilot globally${reset}\n npx get-shit-done-cc --copilot --global\n\n ${dim}# Install for Copilot locally${reset}\n npx get-shit-done-cc --copilot --local\n\n ${dim}# Install for Antigravity globally${reset}\n npx get-shit-done-cc --antigravity --global\n\n ${dim}# Install for Antigravity locally${reset}\n npx get-shit-done-cc --antigravity --local\n\n ${dim}# Install for Cursor globally${reset}\n npx get-shit-done-cc --cursor --global\n\n ${dim}# Install for Cursor locally${reset}\n npx get-shit-done-cc --cursor --local\n\n ${dim}# Install for Windsurf globally${reset}\n npx get-shit-done-cc --windsurf --global\n\n ${dim}# Install for Windsurf locally${reset}\n npx get-shit-done-cc --windsurf --local\n\n ${dim}# Install for all runtimes globally${reset}\n npx get-shit-done-cc --all --global\n\n ${dim}# Install to custom config directory${reset}\n npx get-shit-done-cc --codex --global --config-dir ~/.codex-work\n\n ${dim}# Install to current project only${reset}\n npx get-shit-done-cc --claude --local\n\n ${dim}# Uninstall GSD from Cursor globally${reset}\n npx get-shit-done-cc --cursor --global --uninstall\n\n ${yellow}Notes:${reset}\n The --config-dir option is useful when you have multiple configurations.\n It takes priority over CLAUDE_CONFIG_DIR / GEMINI_CONFIG_DIR / CODEX_HOME / COPILOT_CONFIG_DIR / ANTIGRAVITY_CONFIG_DIR / CURSOR_CONFIG_DIR / WINDSURF_CONFIG_DIR environment variables.\n`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
@@ -4689,6 +4690,70 @@ function handleStatusline(settings, isInteractive, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the GSD SDK globally via npm.
|
||||
* @returns {boolean} true if install succeeded
|
||||
*/
|
||||
function installSdk() {
|
||||
const sdkPkg = '@gsd-build/sdk@latest';
|
||||
console.log(`\n ${cyan}Installing GSD SDK...${reset}`);
|
||||
console.log(` ${dim}npm install -g ${sdkPkg}${reset}\n`);
|
||||
try {
|
||||
require('child_process').execSync(`npm install -g --force --no-fund --loglevel=error ${sdkPkg}`, { stdio: 'pipe' });
|
||||
console.log(`\n ${green}✓${reset} GSD SDK installed (${cyan}gsd-sdk${reset} command available)`);
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.log(`\n ${yellow}⚠${reset} SDK install failed: ${e.message}`);
|
||||
console.log(` ${dim}You can install it manually: npm install -g ${sdkPkg}${reset}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt the user to optionally install the GSD SDK.
|
||||
* Called after runtime installation completes.
|
||||
* @param {Function} callback - called with true/false
|
||||
*/
|
||||
function promptSdk(callback) {
|
||||
if (!process.stdin.isTTY) {
|
||||
callback(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
|
||||
let answered = false;
|
||||
|
||||
rl.on('close', () => {
|
||||
if (!answered) {
|
||||
answered = true;
|
||||
callback(false);
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`
|
||||
${yellow}Also install the GSD SDK?${reset}
|
||||
|
||||
The SDK provides a standalone CLI for autonomous execution:
|
||||
${dim}gsd-sdk init @prd.md${reset} Bootstrap a project from a PRD
|
||||
${dim}gsd-sdk auto${reset} Run full autonomous lifecycle
|
||||
${dim}gsd-sdk run "prompt"${reset} Execute a milestone from text
|
||||
|
||||
${cyan}1${reset}) No
|
||||
${cyan}2${reset}) Yes ${dim}(runs: npm install -g @gsd-build/sdk)${reset}
|
||||
`);
|
||||
|
||||
rl.question(` Choice ${dim}[1]${reset}: `, (answer) => {
|
||||
answered = true;
|
||||
rl.close();
|
||||
const choice = answer.trim() || '1';
|
||||
callback(choice === '2');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt for runtime selection
|
||||
*/
|
||||
@@ -4831,10 +4896,26 @@ function installAllRuntimes(runtimes, isGlobal, isInteractive) {
|
||||
}
|
||||
};
|
||||
|
||||
const afterFinalize = () => {
|
||||
if (hasSdk) {
|
||||
// --sdk flag: install without prompting
|
||||
installSdk();
|
||||
} else if (isInteractive) {
|
||||
promptSdk((wantsSdk) => {
|
||||
if (wantsSdk) installSdk();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const finalizeAndSdk = (shouldInstallStatusline) => {
|
||||
finalize(shouldInstallStatusline);
|
||||
afterFinalize();
|
||||
};
|
||||
|
||||
if (primaryStatuslineResult) {
|
||||
handleStatusline(primaryStatuslineResult.settings, isInteractive, finalize);
|
||||
handleStatusline(primaryStatuslineResult.settings, isInteractive, finalizeAndSdk);
|
||||
} else {
|
||||
finalize(false);
|
||||
finalizeAndSdk(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4882,6 +4963,8 @@ if (process.env.GSD_TEST_MODE) {
|
||||
writeManifest,
|
||||
reportLocalPatches,
|
||||
validateHookFields,
|
||||
installSdk,
|
||||
promptSdk,
|
||||
};
|
||||
} else {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user