diff --git a/scripts/dev.ts b/scripts/dev.ts index a17ce4a11..5366534f9 100644 --- a/scripts/dev.ts +++ b/scripts/dev.ts @@ -54,7 +54,7 @@ const bunCmd = process.execPath; // Generate review builtin files before dev launch console.log('[dev] Generating review builtin files...'); const genResult = Bun.spawnSync(['bun', 'run', 'scripts/generate-review-builtin.ts'], { - stdio: 'inherit', + stdio: ["inherit", "inherit", "inherit"], cwd: projectRoot, }); if (!genResult.success) { diff --git a/scripts/generate-review-builtin.ts b/scripts/generate-review-builtin.ts index 071554091..0af742575 100644 --- a/scripts/generate-review-builtin.ts +++ b/scripts/generate-review-builtin.ts @@ -36,7 +36,21 @@ type IndexJson = { const REPO = 'zgsm-ai/costrict-review' const BRANCH = 'main' -const CLONE_URL = `git@github.com:${REPO}.git` +const CLONE_URL = getCloneUrl() + +function getCloneUrl(): string { + // Try gh CLI token first, then env vars, fall back to public HTTPS + const ghToken = (() => { + try { + return spawnSync('gh', ['auth', 'token'], { encoding: 'utf-8' }).stdout?.trim() || '' + } catch { return '' } + })() + const token = ghToken || process.env.GH_TOKEN || process.env.GITHUB_TOKEN || '' + if (token) { + return `https://x-access-token:${token}@github.com/${REPO}.git` + } + return `https://github.com/${REPO}.git` +} function git(...args: string[]): { ok: boolean; stdout: string; stderr: string } { const result = spawnSync('git', args, { encoding: 'utf-8' })