/** * IssueProvider — Abstract interface for issue tracker operations. * * Implementations: GitHub (gh CLI), GitLab (glab CLI). * * Note: STATE_LABELS and LABEL_COLORS are kept for backward compatibility * but new code should use the workflow config via lib/workflow.ts. */ import { DEFAULT_WORKFLOW, getStateLabels, getLabelColors } from "../workflow.js"; // --------------------------------------------------------------------------- // State labels — derived from default workflow for backward compatibility // --------------------------------------------------------------------------- /** * @deprecated Use workflow.getStateLabels() instead. * Kept for backward compatibility with existing code. */ export const STATE_LABELS = getStateLabels(DEFAULT_WORKFLOW) as readonly string[]; /** * StateLabel type — union of all valid state labels. * This remains a string type for flexibility with custom workflows. */ export type StateLabel = string; /** * @deprecated Use workflow.getLabelColors() instead. * Kept for backward compatibility with existing code. */ export const LABEL_COLORS: Record = getLabelColors(DEFAULT_WORKFLOW); // --------------------------------------------------------------------------- // Issue types // --------------------------------------------------------------------------- export type Issue = { iid: number; title: string; description: string; labels: string[]; state: string; web_url: string; }; export type IssueComment = { author: string; body: string; created_at: string; }; // --------------------------------------------------------------------------- // Provider interface // --------------------------------------------------------------------------- export interface IssueProvider { ensureLabel(name: string, color: string): Promise; ensureAllStateLabels(): Promise; createIssue(title: string, description: string, label: StateLabel, assignees?: string[]): Promise; listIssuesByLabel(label: StateLabel): Promise; getIssue(issueId: number): Promise; listComments(issueId: number): Promise; transitionLabel(issueId: number, from: StateLabel, to: StateLabel): Promise; closeIssue(issueId: number): Promise; reopenIssue(issueId: number): Promise; hasStateLabel(issue: Issue, expected: StateLabel): boolean; getCurrentStateLabel(issue: Issue): StateLabel | null; hasMergedMR(issueId: number): Promise; getMergedMRUrl(issueId: number): Promise; addComment(issueId: number, body: string): Promise; healthCheck(): Promise; } /** @deprecated Use IssueProvider */ export type TaskManager = IssueProvider;