/** * GitHub CLI utilities for issue creation and management. * * Provides functions to interact with GitHub via the `gh` CLI tool, * with retry logic for transient errors. * * @example * ```typescript * import { * checkGhCli, * createIssue, * searchIssues, * getIssueLabels, * } from './github-cli.js'; * * // Check if gh is available and authenticated * const status = await checkGhCli(); * if (!status.ok) { * throw new Error(status.message); * } * * // Create an issue * const issue = await createIssue({ * title: 'New feature', * body: 'Description...', * labels: ['feature'], * }); * ``` */ /** * Result of checking gh CLI availability and authentication. */ export interface GhCliCheckResult { /** Whether gh is available and authenticated */ ok: boolean; /** Error message if not ok */ message?: string; /** gh version if available */ version?: string; /** Authenticated user if available */ user?: string; } /** * Options for creating a GitHub issue. */ export interface CreateIssueOptions { /** Issue title */ title: string; /** Issue body (markdown) */ body?: string; /** Labels to apply */ labels?: string[]; /** Assignees */ assignees?: string[]; /** Milestone number */ milestone?: number; /** Project number */ project?: number; /** Working directory */ cwd?: string; } /** * Created issue result. */ export interface CreatedIssueResult { /** Issue number */ number: number; /** Issue URL */ url: string; /** Issue title */ title: string; } /** * Options for searching issues. */ export interface SearchIssuesOptions { /** Search query (GitHub search syntax) */ query: string; /** Maximum results to return */ maxResults?: number; /** Specific repository (owner/repo) */ repo?: string; /** Working directory */ cwd?: string; } /** * Search result item. */ export interface SearchResultItem { /** Issue number */ number: number; /** Issue title */ title: string; /** Issue URL */ url: string; /** Issue state */ state: 'open' | 'closed'; } /** * Error codes for GitHub CLI operations. */ export type GhCliErrorCode = 'GH_CLI_NOT_FOUND' | 'GH_NOT_AUTHENTICATED' | 'ISSUE_CREATE_FAILED' | 'SEARCH_FAILED' | 'LABEL_FETCH_FAILED' | 'RATE_LIMITED' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR'; /** * GitHub CLI error. */ export declare class GhCliError extends Error { readonly code: GhCliErrorCode; readonly command?: string; readonly retryable: boolean; constructor(message: string, code: GhCliErrorCode, options?: { command?: string; retryable?: boolean; }); } /** * Check if gh CLI is installed and authenticated. * * @param cwd - Working directory * @returns Check result * * @example * ```typescript * const result = await checkGhCli(); * if (!result.ok) { * console.error(result.message); * } * ``` */ export declare function checkGhCli(cwd?: string): Promise; /** * Create a GitHub issue. * * @param options - Issue creation options * @returns Created issue info * @throws GhCliError on failure * * @example * ```typescript * const issue = await createIssue({ * title: 'Implement feature X', * body: '## Description\n...', * labels: ['feature', 'enhancement'], * }); * console.log(`Created issue #${issue.number}`); * ``` */ export declare function createIssue(options: CreateIssueOptions): Promise; /** * Search for GitHub issues. * * @param options - Search options * @returns Array of matching issues * * @example * ```typescript * const issues = await searchIssues({ * query: 'is:open label:bug', * maxResults: 10, * }); * ``` */ export declare function searchIssues(options: SearchIssuesOptions): Promise; /** * Get labels from a GitHub issue. * * @param issueNumber - Issue number * @param cwd - Working directory * @returns Array of label names * * @example * ```typescript * const labels = await getIssueLabels(42); * if (labels.includes('type:epic')) { * // Handle epic * } * ``` */ export declare function getIssueLabels(issueNumber: number, cwd?: string): Promise; /** * Get repository info from current directory. * * @param cwd - Working directory * @returns Repository info (owner/repo) */ export declare function getRepoInfo(cwd?: string): Promise<{ owner: string; repo: string; }>; /** * Check if an issue already exists with similar title. * * Useful for duplicate detection. * * @param title - Title to search for * @param cwd - Working directory * @returns Existing issue number if found, null otherwise */ export declare function findExistingIssue(title: string, cwd?: string): Promise; //# sourceMappingURL=github-cli.d.ts.map