reading

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 7 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 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

View Source
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).

View Source
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

View Source
var Propose = Options{Clusters: true}

Propose is what init's propose phase reads: change subjects, and clusters.

Functions

func Always

func Always(kind string) bool

Always says whether every capability's session reads a doc of this kind: the agent docs, readme and contributing guide.

func BytesTokens

func BytesTokens(n int) int

BytesTokens estimates the tokens in n bytes, rounding up.

func Figure

func Figure() string

Figure is the bytes per token as people read it: "2.3".

func GatherTokens added in v0.0.6

func GatherTokens(g store.Gather) int

GatherTokens estimates the tokens of everything g holds to read: its docs, its changes' messages and files, and its PRs' titles, bodies, linked issues and comments. It is the gather's estimate, and what recovery's ratio is measured against.

func Linked

func Linked(docs []store.Doc, linked []string) (read []store.Doc)

Linked is the docs a capability's session reads: those Always names, and the others only when linked names them.

func Thousands

func Thousands(n int64) string

Thousands writes n with commas: 14300 is "14,300".

func Tokens

func Tokens(s string) int

Tokens estimates the tokens in s; see BytesTokens.

Types

type Cluster

type Cluster struct {
	Paths   []string
	Changes int
}

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.

func Clusters added in v0.0.3

func Clusters(changes []store.GatheredChange) []Cluster

Clusters finds files that change together, each cluster with all its paths. Changes touching more than ClusterMaxFiles files are skipped; pairs of files sharing at least ClusterMinChanges changes are joined, and joined pairs form clusters. Each cluster counts the changes touching two or more of its files. Clusters are ordered by that count, most first, then by first path.

type Comment

type Comment struct {
	Author          string
	At              time.Time
	RequestsChanges bool
	Body            string
}

Comment is a review comment, whole.

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 Doc

type Doc struct {
	Path string
	Kind string
	Body string
}

Doc is a doc, whole.

type Input

type Input struct {
	Docs     []Doc
	PRs      []PR
	Commits  []Commit
	Clusters []Cluster
	Report   Report
}

Input is what a session reads, in order, and the report of it.

func Of

func Of(g store.Gather, o Options) Input

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

func (in Input) Recounted() Input

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.

func (Report) Lines

func (r Report) Lines() []string

Lines says per source what is read, one plain line each, e.g. "docs: 9, whole, about 52,000 tokens"; a source with nothing gathered says "none".

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.

Jump to

Keyboard shortcuts

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