Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.0 KB
Raw Blame
/** Read message/stderr/stdout: execFile duplicates stderr in message, while Orca’s dirty-removal errors attach status output to stdout.
 * Classifiers must agree across both shapes. Real Git refusals use error()/die() on stderr (2.25–2.55). */
export function readGitCommandFailureText(error: unknown): string {
  if (typeof error !== 'object' || error === null) {
    return String(error)
  }
  const parts: string[] = []
  for (const field of ['message', 'stderr', 'stdout'] as const) {
    const value = (error as Record<string, unknown>)[field]
    if (typeof value === 'string' && value) {
      parts.push(value)
    }
  }
  return parts.join('\n')
}

export function readGitCommandFailureStderr(error: unknown): string | null {
  if (typeof error !== 'object' || error === null || !('stderr' in error)) {
    return null
  }
  if (typeof error.stderr === 'string') {
    return error.stderr
  }
  if (typeof Buffer !== 'undefined' && Buffer.isBuffer(error.stderr)) {
    return error.stderr.toString('utf8')
  }
  return null
}