Open History to see the last commit
1/**
2 * GitHubCli - Effect service contract for `gh` process interactions.
3 *
4 * Provides thin command execution helpers used by Git workflow orchestration.
5 *
6 * @module GitHubCli
7 */
8import { ServiceMap } from "effect";
9import type { Effect } from "effect";
10
11import type { ProcessRunResult } from "../../processRunner";
12import type { GitHubCliError } from "../Errors.ts";
13
14export interface GitHubPullRequestSummary {
15 readonly number: number;
16 readonly title: string;
17 readonly url: string;
18 readonly baseRefName: string;
19 readonly headRefName: string;
20}
21
22/**
23 * GitHubCliShape - Service API for executing GitHub CLI commands.
24 */
25export interface GitHubCliShape {
26 /**
27 * Execute a GitHub CLI command and return full process output.
28 */
29 readonly execute: (input: {
30 readonly cwd: string;
31 readonly args: ReadonlyArray<string>;
32 readonly timeoutMs?: number;
33 }) => Effect.Effect<ProcessRunResult, GitHubCliError>;
34
35 /**
36 * List open pull requests for a head branch.
37 */
38 readonly listOpenPullRequests: (input: {
39 readonly cwd: string;
40 readonly headBranch: string;
41 readonly limit?: number;
42 }) => Effect.Effect<ReadonlyArray<GitHubPullRequestSummary>, GitHubCliError>;
43
44 /**
45 * Create a pull request from branch context and body file.
46 */
47 readonly createPullRequest: (input: {
48 readonly cwd: string;
49 readonly baseBranch: string;
50 readonly headBranch: string;
51 readonly title: string;
52 readonly bodyFile: string;
53 }) => Effect.Effect<void, GitHubCliError>;
54
55 /**
56 * Resolve repository default branch through GitHub metadata.
57 */
58 readonly getDefaultBranch: (input: {
59 readonly cwd: string;
60 }) => Effect.Effect<string | null, GitHubCliError>;
61}
62
63/**
64 * GitHubCli - Service tag for GitHub CLI process execution.
65 */
66export class GitHubCli extends ServiceMap.Service<GitHubCli, GitHubCliShape>()(
67 "t3/git/Services/GitHubCli",
68) {}