{"modulePath":"github.com/Agent-Field/codeaf","version":"v0.8.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package github\n\nPackage github is a small REST client for the GitHub API used by the PR-AF review pipeline: fetch a PR (metadata + changed files + commits + unified diff), and post a review with inline comments.\n\nIt is a faithful port of src/pr\\_af/github/client.py. Behavioural contract (byte-exact with Python):\n\n  - ParsePRURL: regexp ^https?://github\\\\.com/(\\[^/]+)/(\\[^/]+)/pull/(\\\\d+).\n  - FetchPR: 4 attempts, sleep 2.0\\*(attempt+1)s between them, retry on transport errors + 5xx + 403/429, fail fast on any other 4xx.\n  - Per-request timeouts: 30s (fetch), 60s (post).\n  - Redirects followed (Go's default http.Client) — matches httpx follow\\_redirects=True on the fetch client (see divergence notes below).\n  - Pagination of /files and /commits at per\\_page=100.\n  - Diff via Accept: application/vnd.github.v3.diff.\n  - Auth: the token the constructor is handed, or none. (pr-af's served node also signed in as a GitHub App; codeaf carries no App key.)\n  - PostReview surfaces HTTP failures (incl. 422 \"own pull request\") as a typed \\*APIError carrying StatusCode + Body so the orchestrator can detect the 422 and downgrade the event to COMMENT.\n\nDivergences from Python (intentional, behaviourally inert in production):\n\n  - Go's http.Client follows redirects for every request; Python leaves follow\\_redirects at its default (off) for the post-review call and only enables it for fetch. That endpoint never redirects on api.github.com, so this is inert.\n  - Debug print() lines from the Python client are dropped (they are stdout diagnostics, not behaviour).\n\n## Functions\n\n```go\nfunc NewClient(token string) *client\n```\nNewClient builds a GitHub client on token, which may be empty for a public repository. The caller resolves it (internal/praf's githubToken: GH\\_TOKEN, GITHUB\\_TOKEN, then \\`gh auth token\\`); pr-af's served node also signed in as a GitHub App, which codeaf does not carry.\n\n## Types\n\n```go\ntype APIError struct {\n\tStatusCode int\n\tBody       string\n\tURL        string\n}\n```\nAPIError is returned for any GitHub response with status \u003e= 400. It carries the status code and raw response body so callers can classify failures — in particular the orchestrator inspects StatusCode==422 with Body containing \"own pull request\" to downgrade the review event to COMMENT and retry.\n\n```go\nfunc (e *APIError) Error() string\n```\n\n```go\ntype Client interface {\n\tParsePRURL(url string) (owner, repo string, number int, err error)\n\tFetchPR(ctx context.Context, owner, repo string, number int) (schemas.GitHubPRData, error)\n\tPostReview(ctx context.Context, owner, repo string, number int, review schemas.GitHubReview, commitID string) (map[string]any, error)\n}\n```\nClient is the GitHub surface the review pipeline depends on.\n\n","path":"github.com/Agent-Field/codeaf/internal/praf/github","name":"github","synopsis":"Package github is a small REST client for the GitHub API used by the PR-AF review pipeline: fetch a PR (metadata + changed files + commits + unified diff), and post a review with inline comments.","isRedistributable":true}
