refactor: implement discriminated unions for GitHub contexts

Split ParsedGitHubContext into entity-specific and automation contexts:
- ParsedGitHubContext: For entity events (issues/PRs) with required entityNumber and isPR
- AutomationContext: For workflow_dispatch/schedule events without entity fields
- GitHubContext: Union type for all contexts

This eliminates ~20 null checks throughout the codebase and provides better type safety.
Entity-specific code paths are now guaranteed to have the required fields.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
km-anthropic
2025-07-29 13:09:01 -07:00
parent f1ce8b3d62
commit b1033b2ba1
14 changed files with 171 additions and 132 deletions

View File

@@ -1,4 +1,4 @@
import type { ParsedGitHubContext } from "../github/context";
import type { GitHubContext } from "../github/context";
import type { Octokits } from "../github/api/client";
import type { Mode } from "../modes/types";
@@ -13,7 +13,7 @@ export type PrepareResult = {
};
export type PrepareOptions = {
context: ParsedGitHubContext;
context: GitHubContext;
octokit: Octokits;
mode: Mode;
githubToken: string;