Documentation
¶
Overview ¶
Package gather collects the sources init reads, within a bound, and summarises what it found: a repo's docs (agent docs, contributing guides, readmes, decision records), its history through version control, and its merged PRs through the forge when there is one, page by page, waiting out the forge's rate limits (internal/gather/merged). A forge that is missing, cannot list merged PRs, or is unavailable or unauthenticated before it lists any PR makes PRs unavailable, which is reported and never a failure. Any other forge error, or one after PRs were listed, fails the gather with a Stopped error that still returns the gather with every PR listed. The bound is a date and, when given, a most number of PRs: when the PR limit is reached first, history starts where the PRs do, and each area the PRs miss gets a few PRs of its own (quiet). Gather reads the working tree and never writes to it; the caller keeps the result in the store.
Index ¶
Constants ¶
const ( KindAgent = "agent" KindContributing = "contributing" KindReadme = "readme" KindDecisions = "decisions" KindOverview = "overview" )
The kinds of doc.
const MaxDocBytes = 2 << 20
MaxDocBytes is the largest doc gathered; a larger file is skipped.
const MaxNamed = 200
MaxNamed is the most named sources read in one gather.
const Version = 3
Version is the summary's JSON version.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BoundSummary ¶
type BoundSummary struct {
Since string `json:"since"`
FromFlag bool `json:"from_flag"`
MaxPRs int `json:"max_prs"`
PRLimitReached bool `json:"pr_limit_reached"`
HistorySince string `json:"history_since,omitempty"`
}
BoundSummary is the bound used. Since is a date; FromFlag is false when it is the 12-month default. PRLimitReached is true when the PR limit stopped the PRs before the date did, and HistorySince is then the date history starts at.
type Bounds ¶
Bounds is the bound of one gather: Since is its start, SinceSet is true when the caller gave it rather than defaulting it, MaxPRs is the most merged PRs to list (0 means no limit), and Wait is how the forge's rate limits are waited out (zero means its defaults).
type Discover ¶
Discover asks for the agent's search for more sources. Its zero value asks for none. Off, when set, is the reason not to start one and is reported as the why.
type Discovery ¶
type Discovery struct {
Started bool `json:"started"`
Why string `json:"why,omitempty"`
Named int `json:"named"`
Added int `json:"added"`
Model string `json:"model,omitempty"`
Tokens adapter.Tokens `json:"tokens"`
}
Discovery says what the agent's search for more sources did. Why says why it was not started or added nothing, and is empty when it added sources.
type DocFile ¶
type DocFile struct {
Path string `json:"path"`
Kind string `json:"kind"`
Reason string `json:"reason"`
}
DocFile is one doc found.
type DocsSummary ¶
type DocsSummary struct {
Count int `json:"count"`
Bytes int `json:"bytes"`
Files []DocFile `json:"files"`
Skipped []Skip `json:"skipped"`
}
DocsSummary counts the docs.
type HistorySummary ¶
type HistorySummary struct {
Changes int `json:"changes"`
WithTrailers int `json:"with_trailers"`
Reverts int `json:"reverts"`
WithAltered int `json:"with_altered_files"`
DistinctFiles int `json:"distinct_files"`
Bytes int `json:"bytes"`
// Shallow is true when the clone is shallow: history is only what was fetched.
Shallow bool `json:"shallow"`
}
HistorySummary counts the changes.
type PRsSummary ¶
type PRsSummary struct {
Available bool `json:"available"`
Reason string `json:"reason,omitempty"`
Count int `json:"count"`
ReviewComments int `json:"review_comments"`
RequestingChanges int `json:"requesting_changes"`
LinkedIssues int `json:"linked_issues"`
Bytes int `json:"bytes"`
}
PRsSummary counts the PRs, or says why there are none to count.
type Skip ¶
Skip is a source left out and why. Path is relative to the repo root.
func Docs ¶
Docs reads the repo's docs from the working tree under root: agent docs (including CONTEXT.md), contributing guides, readmes, decisions with decision-record folders, and the plan and overview files (PLAN, ROADMAP, OVERVIEW, ARCHITECTURE, CONTEXT, any case) directly under docs/. Each doc's path is relative to root with forward slashes, sorted, and its Reason says by which rule it was found. A file over MaxDocBytes is left out and returned in skipped with its size; a candidate that is missing or not a regular file is a guess and is left out silently.
func Named ¶
func Named(root string, listed map[string]bool, named []Source, have []store.Doc) (docs []store.Doc, skipped []Skip)
Named reads the named sources under root. A source is refused, and never read past the checks that need its bytes, when its path is outside the repo, under .git, under an ignored folder (or, when listed is not nil, not among the repo's listed files), missing, not a regular file (a symlink is not), over MaxDocBytes, of an unknown kind, a duplicate of a doc in have or of an earlier source, over MaxNamed accepted, or not text (a NUL byte or invalid UTF-8 in its first 8 KB). Each refusal is a Skip with its why.
type Source ¶
type Source struct{ Path, Kind, Reason string }
Source is a file someone named as worth reading: a path relative to the repo root, one of the five kinds, and the reason it was named.
type Stopped ¶ added in v0.0.22
Stopped is the error of a gather the forge stopped, returned with the gather holding every PR listed; see merged.Stopped.
type Summary ¶
type Summary struct {
Version int `json:"version"`
Store string `json:"store"`
Bound BoundSummary `json:"bound"`
Docs DocsSummary `json:"docs"`
History HistorySummary `json:"history"`
PRs PRsSummary `json:"prs"`
Discovery Discovery `json:"discovery"`
Quiet *quiet.Summary `json:"quiet,omitempty"`
EstimatedTokens int `json:"estimated_tokens"`
}
Summary says what a gather found.
func Run ¶
func Run(root string, repo vcs.Repo, f forge.Forge, o Bounds, d Discover, now time.Time) (store.Gather, Summary, error)
Run gathers the docs under root, the history of repo and, through f, the merged PRs, within the bound o sets, as of now. It returns the gather for the caller to store and its summary, whose Store is left for the caller to set. f may be nil. d asks for the agent's search for more sources, whose finds join the docs; it never makes Run fail. When the forge stops the list, Run still returns the gather and its summary, with every PR listed and the history of the whole bound, and a *Stopped error.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package merged lists a forge's merged PRs page by page within gather's bound, and waits out the forge's rate limits as GitHub says: its retry-after, else until its primary limit resets, else a minute doubling on each repeat, up to a total wait limit.
|
Package merged lists a forge's merged PRs page by page within gather's bound, and waits out the forge's rate limits as GitHub says: its retry-after, else until its primary limit resets, else a minute doubling on each repeat, up to a total wait limit. |