Expand description
Structured, cached issue:// and pr:// read engine.
The read-command integration owns transport routing and protocol response
adaptation. This module owns everything specific to GitHub resources: strict
URL parsing, structured gh fetches, normalization, canonical rendering,
durable-cache coordination, deferred network work, and vision-gated images.
Structs§
- Downloaded
Github Image - A downloader result whose final URL is retained for redirect validation.
- GhCli
Fetcher - Structured
gh issue view/gh pr viewfetcher. - GhCommand
Output - A subprocess result for the
ghcommand seam. - Github
Comment - Github
Comment Selector - Ordinals selected by a
/comments/<sel>discussion drill-down. - Github
Document - Structured GitHub data consumed by the canonical Rust renderer.
- Github
Fetch Request - Request context passed to a structured GitHub fetcher.
- Github
Image Attachment - One complete, validated image attachment. Text rendering retains the source URL; this is out-of-band data for a caller that explicitly supports vision.
- Github
Pull Request File - Github
Reaction - Github
Read Completion - A completed GitHub read ready for the transport-specific response adapter.
- Github
Read Deferred - Handle for a fetch or attachment task that is running away from the request
loop. Poll it from
PendingResponse; never wait on it in standalone input handling. - Github
Read Engine - Coordinates live GitHub fetches, durable fallback copies, single-flight work, rendering, and deferred attachments for both issue and PR reads.
- Github
Read Request - Request context that the read integration supplies before entering a
deferred fetch. An absent capability is intentionally different from an
inferred one: only
Some(true)permits image downloads. - Github
Resource - A validated
issue://orpr://resource. - Github
Review - Github
Review Comment Section - One review’s inline-comment section. Each section is capped independently, so an active review cannot crowd comments out of a different review.
- Invalid
Github Resource - A typed error produced before a GitHub resource can enter the fetch path.
- Normalize
Error - A structured-response error. The fetch layer maps this into a typed, redacted user-facing fetch failure.
- Reqwest
Github Image Downloader - Production GitHub-image downloader. Redirect following is manual so every target receives the same allowlist check as the original URL.
- Sqlite
Github Read Cache Store aft.dbimplementation of the GitHub read cache seam.- System
GhCommand Runner - Production runner that executes the bare
ghcommand in the caller’s working directory so the CLI owns short-form repository resolution. - System
Github Read Clock - Production wall clock for cache timestamps.
Enums§
- GhCommand
Error - Error running
ghbefore it produced a process result. - Github
Document Kind - Resource-kind mirror included in structured fixtures and normalized data.
- Github
Read Error - The typed failures returned by the GitHub read engine.
- Github
Read Freshness - Origin of the text that satisfied a request.
- Github
Read Selector - Selector applied only after the complete canonical document is rendered.
- Github
Read Start - The initial outcome for a GitHub read. Every read is deferred because it performs a live GitHub fetch before considering any cached fallback.
- Github
Resource Kind - One of the two GitHub resource kinds supported by the read scheme.
Constants§
- MAX_
GITHUB_ IMAGE_ ATTACHMENTS - At most this many GitHub-hosted images become attachments for one read. Keeping the count fixed prevents a long issue thread from creating an unbounded transport payload.
- MAX_
GITHUB_ IMAGE_ ATTACHMENT_ BYTES - Attachments for one read may contain at most this many downloaded bytes in total. A candidate that exceeds the remaining budget is dropped whole, so callers never receive a partial image.
- MAX_
RENDERED_ COMMENTS_ PER_ SECTION - The maximum number of newest comments rendered for an issue or one pull request review-comment section. Older comments remain available on GitHub and are disclosed in the canonical document instead of silently dropped.
Traits§
- GhCommand
Runner - Injectable
ghrunner. Fixture runners can assert the exact command and request working directory without requiring a real GitHub installation. - Github
Fetcher - Fetches structured GitHub data. Implementations never return CLI display text; the engine only accepts a normalized document from this interface.
- Github
Image Downloader - Synchronous downloader used inside a deferred worker. Tests can replace it with a deterministic fixture downloader that records URLs and byte budgets.
- Github
Read Cache Store - A cache persistence seam. The production implementation stores canonical
text in AFT’s existing
aft.db; tests can use an in-memory fixture store. - Github
Read Clock - Clock seam used to make freshness boundaries deterministic in tests.
Functions§
- apply_
selector - Apply selection to the completed canonical render, never to raw GitHub data.
- discover_
github_ image_ urls - Discover eligible HTTPS GitHub image candidates in textual document order. Repeated URLs remain repeated candidates: their positions in the canonical document determine which attachment claims a count slot first.
- download_
github_ image_ attachments - Download complete attachment candidates without changing canonical text. This function is capability-agnostic so tests can call it directly; callers with a missing or false vision capability must not invoke it.
- gh_
pr_ review_ comments_ args - Build the structured GraphQL fetch for inline PR review comments. The first
pr view --jsoncall resolves the repository; this second JSON call fills comment sections thatgh pr viewdoes not expose as a display field. - gh_
view_ args - Build the exact structured-view invocation. Short forms intentionally omit
-R; explicit forms include it and are otherwise identical. - is_
allowed_ github_ image_ url - The only hosts allowed to become vision attachments.
github.comis limited to/user-attachments/; an arbitrary GitHub page is not an image source and must not turn this feature into a generic web fetcher. - normalize_
structured_ document - Normalize
gh --jsonor GraphQL JSON into the renderer’s stable model. - parse_
resource - Parse only the GitHub resource forms that the read command exposes.
- redact_
gh_ error - Redact ambient credentials while keeping GitHub’s actionable authorization, private-resource, and not-found diagnostics visible to the caller.
- render_
document - Render the complete, transport-independent GitHub document once in Rust.
- sqlite_
cache_ store - Convenience constructor for the real cache location. The read integration
supplies its existing
aft.dbpath; this module never creates a second DB.