68 lines · 1.9 KB · TypeScript
RawDownload
/** * 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;} /** * 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<string>;    readonly timeoutMs?: number;  }) => Effect.Effect<ProcessRunResult, GitHubCliError>;   /**   * List open pull requests for a head branch.   */  readonly listOpenPullRequests: (input: {    readonly cwd: string;    readonly headBranch: string;    readonly limit?: number;  }) => Effect.Effect<ReadonlyArray<GitHubPullRequestSummary>, GitHubCliError>;   /**   * Create a pull request from branch context and body file.   */  readonly createPullRequest: (input: {    readonly cwd: string;    readonly baseBranch: string;    readonly headBranch: string;    readonly title: string;    readonly bodyFile: string;  }) => Effect.Effect<void, GitHubCliError>;   /**   * Resolve repository default branch through GitHub metadata.   */  readonly getDefaultBranch: (input: {    readonly cwd: string;  }) => Effect.Effect<string | null, GitHubCliError>;} /** * GitHubCli - Service tag for GitHub CLI process execution. */export class GitHubCli extends ServiceMap.Service<GitHubCli, GitHubCliShape>()(  "t3/git/Services/GitHubCli",) {}