/** * GitHubCli - Effect service contract for `gh` process interactions. * * Provides thin command execution helpers used by Git workflow orchestration. * * @module GitHubCli */ import { ServiceMap } from "effect"; import type { Effect } from "effect"; import type { ProcessRunResult } from "../../processRunner"; import type { GitHubCliError } from "../Errors.ts"; export interface GitHubPullRequestSummary { readonly number: number; readonly title: string; readonly url: string; readonly baseRefName: string; readonly headRefName: string; readonly state?: "open" | "closed" | "merged"; readonly isCrossRepository?: boolean; readonly headRepositoryNameWithOwner?: string | null; readonly headRepositoryOwnerLogin?: string | null; } export interface GitHubRepositoryCloneUrls { readonly nameWithOwner: string; readonly url: string; readonly sshUrl: string; } /** * GitHubCliShape - Service API for executing GitHub CLI commands. */ export interface GitHubCliShape { /** * Execute a GitHub CLI command and return full process output. */ readonly execute: (input: { readonly cwd: string; readonly args: ReadonlyArray; readonly timeoutMs?: number; }) => Effect.Effect; /** * List open pull requests for a head branch. */ readonly listOpenPullRequests: (input: { readonly cwd: string; readonly headSelector: string; readonly limit?: number; }) => Effect.Effect, GitHubCliError>; /** * Resolve a pull request by URL, number, or branch-ish identifier. */ readonly getPullRequest: (input: { readonly cwd: string; readonly reference: string; }) => Effect.Effect; /** * Resolve clone URLs for a GitHub repository. */ readonly getRepositoryCloneUrls: (input: { readonly cwd: string; readonly repository: string; }) => Effect.Effect; /** * Create a pull request from branch context and body file. */ readonly createPullRequest: (input: { readonly cwd: string; readonly baseBranch: string; readonly headSelector: string; readonly title: string; readonly bodyFile: string; }) => Effect.Effect; /** * Resolve repository default branch through GitHub metadata. */ readonly getDefaultBranch: (input: { readonly cwd: string; }) => Effect.Effect; /** * Checkout a pull request into the current repository worktree. */ readonly checkoutPullRequest: (input: { readonly cwd: string; readonly reference: string; readonly force?: boolean; }) => Effect.Effect; } /** * GitHubCli - Service tag for GitHub CLI process execution. */ export class GitHubCli extends ServiceMap.Service()( "t3/git/Services/GitHubCli", ) {}