Documentation
¶
Overview ¶
Package reading shapes a gather into what one session reads, whole and deterministically, and estimates its tokens. Nothing a session is given is ever cut: every doc, PR title, PR body, review comment and change it reads reaches it whole (the owner, 2026-11-23: "This process is important, nothing should get cut."). Options choose what a session reads, never how much of it: propose reads change subjects and clusters of files that change together, as hints; recovery reads change messages and no clusters. Its estimates inform, never stop, a session: init is never bounded, and its estimate is shown before it asks to go on. Tokens are estimated at one measured figure, BytesPerTokenTenths. Reading does no I/O and calls no agent.
Index ¶
- Constants
- Variables
- func Always(kind string) bool
- func BytesTokens(n int) int
- func Figure() string
- func Linked(docs []store.Doc, linked []string) (read []store.Doc)
- func Thousands(n int64) string
- func Tokens(s string) int
- type Cluster
- type Comment
- type Commit
- type Doc
- type Input
- type Options
- type PR
- type Report
- type SourceReport
Constants ¶
const ( // ClusterMaxFiles is the most files a change may touch and still count // for clusters; a larger change says little about what belongs together. ClusterMaxFiles = 20 // ClusterMinChanges is the fewest changes a pair of files must share to // be clustered. ClusterMinChanges = 3 // ClusterPaths is the most paths listed for one cluster. ClusterPaths = 8 )
Each cluster number below is a first guess, to be tuned from real runs (measure-before-budget).
const BytesPerTokenTenths = 23
BytesPerTokenTenths is the bytes per token every estimate uses, in tenths: 2.3. It was measured on #25's real propose prompts: 178,659 bytes read as 66,069 input tokens on Physa (2.70 a token) and 321,819 as 135,135 on nebari (2.38); the lower, rounded down, so estimates err high.
Variables ¶
var Propose = Options{Clusters: true}
Propose is what init's propose phase reads: change subjects, and clusters.
Functions ¶
func Always ¶
Always says whether every capability's session reads a doc of this kind: the agent docs, readme and contributing guide.
func BytesTokens ¶
BytesTokens estimates the tokens in n bytes, rounding up.
Types ¶
type Cluster ¶
Cluster is a set of files that change together: its first ClusterPaths paths, sorted, and how many changes touch two or more of its files.
type Commit ¶
type Commit struct {
Short string
Subject string
Message string
Author string
At time.Time
Reverts string
}
Commit is a change: its short id and subject and, when Options.Messages, its whole message without the subject line, author, time and the change it reverts.
type Input ¶
Input is what a session reads, in order, and the report of it.
func Of ¶
Of is all of g as o reads it: docs by kind, then path; PRs newest merge first; changes newest first; then, with o.Clusters, the clusters. The same gather and options always give the same Input.
func (Input) Recounted ¶
Recounted is in with its Report counted again from what in holds, under the sources in's Report names (all of sourceNames but clusters when it names none, and clusters too when in holds any). A part of an Input, such as one share of propose, so reports exactly what it reads, counted as Of counts it.
type Options ¶
type Options struct {
// Messages keeps each change's message (without its subject line),
// author, time and the change it reverts; without it a change is its
// short id and subject.
Messages bool
// Clusters adds clusters of files that change together, as hints.
Clusters bool
}
Options say what a session reads of a gather.
type PR ¶
type PR struct {
Number int
Title string
Author string
MergedBy string
MergedAt time.Time
Issues []string
Body string
Comments []Comment
}
PR is a PR, whole: its number, title, author, merge date, linked issue titles, body and review comments.
type Report ¶
type Report struct {
Tokens int
Sources []SourceReport
}
Report says what a session reads: one SourceReport per source, in order (docs, pull requests, review comments, changes, then clusters when read), and their estimated tokens together.
type SourceReport ¶
type SourceReport struct {
Name string
Items int
Tokens int
// contains filtered or unexported fields
}
SourceReport counts one source: the items read, all of them whole, and their estimated tokens, without what the prompt writes around them.