Skip to content

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

TypeScript
747 B
Raw Blame
import type Backend from '../../../hooks/backend'
import type { RecordingProbe } from './recording-probe.js'
import { stubBackendOf } from './stub-backend-of.js'

/**
 * A backend probe that notes each host it is asked about and answers a stub
 * backend at the toplevel, or declines (null) when given none.
 *
 * @param toplevel the working copy's root, or null to decline
 * @returns the probe and the hosts it was asked about, in order
 */
export function recordingProbeOf(toplevel: string | null): RecordingProbe {
  const asked: Backend.BackendHost[] = []
  const answer = toplevel === null ? null : stubBackendOf(toplevel)

  return {
    asked,
    probe: host => {
      asked.push(host)

      return Promise.resolve(answer)
    },
  }
}