2026-03-10 22:28:37 -06:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
import { execSync } from 'child_process'
|
2026-03-11 01:10:13 -06:00
|
|
|
import { createRequire } from 'module'
|
2026-03-10 22:28:37 -06:00
|
|
|
import os from 'os'
|
2026-03-11 01:10:13 -06:00
|
|
|
import { fileURLToPath } from 'url'
|
|
|
|
|
import { dirname, resolve } from 'path'
|
2026-03-10 22:28:37 -06:00
|
|
|
|
2026-03-11 01:10:13 -06:00
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
|
|
|
const require = createRequire(import.meta.url)
|
|
|
|
|
const pkg = require(resolve(__dirname, '..', 'package.json'))
|
|
|
|
|
|
|
|
|
|
// Colors
|
|
|
|
|
const cyan = '\x1b[36m'
|
|
|
|
|
const green = '\x1b[32m'
|
|
|
|
|
const yellow = '\x1b[33m'
|
|
|
|
|
const dim = '\x1b[2m'
|
|
|
|
|
const reset = '\x1b[0m'
|
|
|
|
|
|
|
|
|
|
const banner =
|
|
|
|
|
'\n' +
|
|
|
|
|
cyan +
|
|
|
|
|
' ██████╗ ███████╗██████╗ \n' +
|
|
|
|
|
' ██╔════╝ ██╔════╝██╔══██╗\n' +
|
|
|
|
|
' ██║ ███╗███████╗██║ ██║\n' +
|
|
|
|
|
' ██║ ██║╚════██║██║ ██║\n' +
|
|
|
|
|
' ╚██████╔╝███████║██████╔╝\n' +
|
|
|
|
|
' ╚═════╝ ╚══════╝╚═════╝ ' +
|
|
|
|
|
reset + '\n' +
|
|
|
|
|
'\n' +
|
|
|
|
|
` Get Shit Done ${dim}v${pkg.version}${reset}\n` +
|
|
|
|
|
` A standalone coding agent that plans, executes, and ships.\n` +
|
|
|
|
|
'\n' +
|
|
|
|
|
` ${green}✓${reset} Installed successfully\n` +
|
|
|
|
|
` ${dim}Run ${reset}${cyan}gsd${reset}${dim} to get started.${reset}\n`
|
|
|
|
|
|
2026-03-11 17:19:33 -07:00
|
|
|
function run(command, options = {}) {
|
|
|
|
|
return execSync(command, {
|
|
|
|
|
cwd: resolve(__dirname, '..'),
|
|
|
|
|
encoding: 'utf8',
|
|
|
|
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
|
|
|
...options,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function printCaptured(output) {
|
|
|
|
|
if (output) process.stderr.write(output)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-11 01:13:19 -06:00
|
|
|
process.stderr.write(banner)
|
2026-03-11 01:10:13 -06:00
|
|
|
|
2026-03-11 11:24:44 -06:00
|
|
|
// Apply patches to upstream dependencies (non-fatal)
|
|
|
|
|
try {
|
2026-03-11 17:19:33 -07:00
|
|
|
const output = run('npx patch-package')
|
|
|
|
|
printCaptured(output)
|
2026-03-11 11:24:44 -06:00
|
|
|
process.stderr.write(`\n ${green}✓${reset} Patches applied\n`)
|
2026-03-11 17:19:33 -07:00
|
|
|
} catch (error) {
|
|
|
|
|
printCaptured(error.stdout)
|
|
|
|
|
printCaptured(error.stderr)
|
2026-03-11 11:24:44 -06:00
|
|
|
process.stderr.write(`\n ${yellow}⚠${reset} Failed to apply patches — run ${cyan}npx patch-package${reset} manually\n`)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-11 17:19:33 -07:00
|
|
|
// Install Playwright chromium for browser tools (non-fatal).
|
|
|
|
|
// We intentionally avoid --with-deps here because install scripts should not
|
|
|
|
|
// block on interactive sudo prompts. Playwright validates host requirements
|
|
|
|
|
// after download; if Linux libs are missing, suggest the explicit follow-up.
|
2026-03-10 22:28:37 -06:00
|
|
|
try {
|
2026-03-11 17:19:33 -07:00
|
|
|
const output = run('npx playwright install chromium')
|
|
|
|
|
printCaptured(output)
|
2026-03-11 01:13:19 -06:00
|
|
|
process.stderr.write(`\n ${green}✓${reset} Browser tools ready\n\n`)
|
2026-03-11 17:19:33 -07:00
|
|
|
} catch (error) {
|
|
|
|
|
const output = `${error.stdout ?? ''}${error.stderr ?? ''}`
|
|
|
|
|
printCaptured(output)
|
|
|
|
|
|
|
|
|
|
if (os.platform() === 'linux' && output.includes('Host system is missing dependencies to run browsers.')) {
|
|
|
|
|
process.stderr.write(
|
|
|
|
|
`\n ${yellow}⚠${reset} Browser downloaded, but Linux system dependencies are missing.\n` +
|
|
|
|
|
` ${dim}Run ${reset}${cyan}sudo npx playwright install-deps chromium${reset}${dim} to finish setup.${reset}\n\n`
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
process.stderr.write(
|
|
|
|
|
`\n ${yellow}⚠${reset} Browser tools unavailable — run ${cyan}npx playwright install chromium${reset} to enable\n\n`
|
|
|
|
|
)
|
|
|
|
|
}
|
2026-03-10 22:28:37 -06:00
|
|
|
}
|