import { execFileSync } from "node:child_process"; export function git(cwd: string, args: string[]): string | undefined { try { const out = execFileSync("git", args, { cwd, encoding: "utf8", timeout: 1500, stdio: ["ignore", "pipe", "ignore"], }).trim(); return out.length > 0 ? out : undefined; } catch { return undefined; } } export function shortError(e: unknown): string { return e instanceof Error ? e.message : String(e); } export function truncate(s: string, n: number): string { return s.length <= n ? s : s.slice(0, n) + "…"; }