gather

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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. A forge that is missing, cannot list merged PRs or cannot answer makes PRs unavailable, which is reported and never a failure. The bound is a date and a most number of PRs: when the PR limit is reached first, history starts where the PRs do. Gather reads the working tree and never writes to it; the caller keeps the result in the store.

Index

Constants

View Source
const (
	KindAgent        = "agent"
	KindContributing = "contributing"
	KindReadme       = "readme"
	KindDecisions    = "decisions"
	KindOverview     = "overview"
)

The kinds of doc.

View Source
const DefaultMaxPRs = 1000

DefaultMaxPRs is the most PRs gathered unless the bound says otherwise.

View Source
const MaxDocBytes = 2 << 20

MaxDocBytes is the largest doc gathered; a larger file is skipped.

View Source
const MaxNamed = 200

MaxNamed is the most named sources read in one gather.

View Source
const Version = 3

Version is the summary's JSON version.

Variables

This section is empty.

Functions

func WriteJSON

func WriteJSON(w io.Writer, s Summary) error

WriteJSON writes the summary as indented JSON.

func WriteText

func WriteText(w io.Writer, s Summary) error

WriteText writes the summary for a person.

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

type Bounds struct {
	Since    time.Time
	SinceSet bool
	MaxPRs   int
}

Bounds is the bound of one gather: Since is its start, SinceSet is true when the caller gave it rather than defaulting it, and MaxPRs is the most merged PRs to list.

type Discover

type Discover struct {
	Session discovery.Session
	Off     string
}

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

type Skip struct {
	Path string `json:"path"`
	Why  string `json:"why"`
}

Skip is a source left out and why. Path is relative to the repo root.

func Docs

func Docs(root string) (docs []store.Doc, skipped []Skip, err error)

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 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"`
	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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL