fix: remove redundant GitHub CLI prompt during provisioning (#2318)

Auto-detect GitHub credentials (GITHUB_TOKEN env var or `gh auth token`)
instead of interactively asking users. Rename promptGithubAuth → detectGithubAuth.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ahmed Abushagur 2026-03-08 00:01:09 -08:00 committed by GitHub
parent 459e25a844
commit 0ff1da1093
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,7 +8,7 @@ import { unlinkSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { hasMessage } from "./type-guards";
import { Err, jsonEscape, logError, logInfo, logStep, logWarn, Ok, prompt, withRetry } from "./ui";
import { Err, jsonEscape, logError, logInfo, logStep, logWarn, Ok, withRetry } from "./ui";
/**
* Wrap an SSH-based async operation into a Result for use with withRetry.
@ -195,44 +195,40 @@ function readHostGitConfig(key: string): string {
return "";
}
async function promptGithubAuth(): Promise<void> {
if (process.env.SPAWN_SKIP_GITHUB_AUTH) {
return;
}
process.stderr.write("\n");
const choice = await prompt("Set up GitHub CLI (gh) on this machine? (y/N): ");
if (/^[Yy]$/.test(choice)) {
githubAuthRequested = true;
if (process.env.GITHUB_TOKEN) {
githubToken = process.env.GITHUB_TOKEN;
} else {
try {
const result = Bun.spawnSync(
[
"gh",
"auth",
"token",
async function detectGithubAuth(): Promise<void> {
if (process.env.GITHUB_TOKEN) {
githubToken = process.env.GITHUB_TOKEN;
} else {
try {
const result = Bun.spawnSync(
[
"gh",
"auth",
"token",
],
{
stdio: [
"ignore",
"pipe",
"ignore",
],
{
stdio: [
"ignore",
"pipe",
"ignore",
],
},
);
if (result.exitCode === 0) {
githubToken = new TextDecoder().decode(result.stdout).trim();
}
} catch {
/* ignore */
},
);
if (result.exitCode === 0) {
githubToken = new TextDecoder().decode(result.stdout).trim();
}
} catch {
/* ignore */
}
// Capture host git identity to propagate to the remote VM
hostGitName = readHostGitConfig("user.name");
hostGitEmail = readHostGitConfig("user.email");
}
if (githubToken) {
githubAuthRequested = true;
}
// Capture host git identity to propagate to the remote VM
hostGitName = readHostGitConfig("user.name");
hostGitEmail = readHostGitConfig("user.email");
}
export async function offerGithubAuth(runner: CloudRunner): Promise<void> {
@ -534,7 +530,7 @@ function createAgents(runner: CloudRunner): Record<string, AgentConfig> {
claude: {
name: "Claude Code",
cloudInitTier: "minimal",
preProvision: promptGithubAuth,
preProvision: detectGithubAuth,
install: () => installClaudeCode(runner),
envVars: (apiKey) => [
`OPENROUTER_API_KEY=${apiKey}`,
@ -552,7 +548,7 @@ function createAgents(runner: CloudRunner): Record<string, AgentConfig> {
codex: {
name: "Codex CLI",
cloudInitTier: "node",
preProvision: promptGithubAuth,
preProvision: detectGithubAuth,
install: () =>
installAgent(
runner,
@ -571,7 +567,7 @@ function createAgents(runner: CloudRunner): Record<string, AgentConfig> {
openclaw: {
name: "OpenClaw",
cloudInitTier: "full",
preProvision: promptGithubAuth,
preProvision: detectGithubAuth,
modelPrompt: true,
modelDefault: "openrouter/auto",
install: () =>
@ -598,7 +594,7 @@ function createAgents(runner: CloudRunner): Record<string, AgentConfig> {
opencode: {
name: "OpenCode",
cloudInitTier: "minimal",
preProvision: promptGithubAuth,
preProvision: detectGithubAuth,
install: () => installAgent(runner, "OpenCode", openCodeInstallCmd()),
envVars: (apiKey) => [
`OPENROUTER_API_KEY=${apiKey}`,
@ -609,7 +605,7 @@ function createAgents(runner: CloudRunner): Record<string, AgentConfig> {
kilocode: {
name: "Kilo Code",
cloudInitTier: "node",
preProvision: promptGithubAuth,
preProvision: detectGithubAuth,
install: () =>
installAgent(
runner,
@ -629,7 +625,7 @@ function createAgents(runner: CloudRunner): Record<string, AgentConfig> {
zeroclaw: {
name: "ZeroClaw",
cloudInitTier: "minimal",
preProvision: promptGithubAuth,
preProvision: detectGithubAuth,
install: async () => {
// Add swap before building — low-memory instances (e.g., AWS nano 512 MB)
// OOM during Rust compilation if --prefer-prebuilt falls back to source.
@ -653,7 +649,7 @@ function createAgents(runner: CloudRunner): Record<string, AgentConfig> {
hermes: {
name: "Hermes Agent",
cloudInitTier: "minimal",
preProvision: promptGithubAuth,
preProvision: detectGithubAuth,
install: () =>
installAgent(
runner,
@ -673,7 +669,7 @@ function createAgents(runner: CloudRunner): Record<string, AgentConfig> {
junie: {
name: "Junie",
cloudInitTier: "node",
preProvision: promptGithubAuth,
preProvision: detectGithubAuth,
install: () =>
installAgent(
runner,