Documentation
¶
Overview ¶
Package areas divides a repo's source files into areas by promise for init: one session names the repo's test, doc and other files as patterns, then one session (one per part on a large repo) places every source file in exactly one area. Areas are init's own scaffolding, kept in init's record and never in the map.
Index ¶
- Constants
- Variables
- func AreasPrompt(tree string) (system, message string)
- func FixPrompt(missing []string, twice map[string][]string) string
- func MergePrompt(briefs string) (system, message string)
- func ParseSplit(text string) (tests, docs, other []string, err error)
- func PartPrompt(i, n int, overview, briefs, partTree string) (system, message string)
- func SplitPrompt(kinds string) (system, message string)
- func Text(w io.Writer, r Result) error
- type Area
- type AreaCount
- type AreaRecord
- type Fix
- type Joint
- type LeftFiles
- type Loader
- type Record
- type Result
- type Session
- type Store
Constants ¶
const ( // DefaultPartChars is the most listing characters one grouping session // is given when Session.PartChars is 0 and the window allows it. DefaultPartChars = 70_000 // MaxFixRounds is how often one session is sent back the files it left // out or placed twice before the phase fails. MaxFixRounds = 2 )
const AcrossParts = "Group by promise across every part, never by part."
AcrossParts is the first rule of the parts skill: a part is only where the listing was cut, so areas are grouped across every part.
Variables ¶
var Areas string
Areas is the grouping skill: what a session is told before the source files it places in areas.
var Merge string
Merge is the skill for finding areas that keep one family of promises after the parts were placed one at a time.
var Parts string
Parts is appended to Areas when the listing comes in parts.
var Sources string
Sources is the split skill: what a session is told before the repo's folders, so that it names the test, doc and other files as patterns.
Functions ¶
func AreasPrompt ¶
AreasPrompt returns the system prompt (the areas skill) and the message of one session placing every source file: the whole listing, one line per folder with its file names.
func FixPrompt ¶
FixPrompt is the message that sends back the files that fall in no area and the files two areas claim. It asks for an answer holding only those files.
func MergePrompt ¶
MergePrompt returns the system prompt (the merge skill) and the message of the session that finds areas keeping one family of promises: the briefs.
func ParseSplit ¶
ParseSplit reads the split session's answer: the tests, docs and other patterns in the last fenced json block. A list the answer leaves out is empty. The error, worded to follow "the split answer: ", is for a reply with no such block or one that does not decode.
func PartPrompt ¶
PartPrompt returns the system prompt and the message of part i of n. The system is the areas skill followed by the parts skill, so it holds AcrossParts. The message gives every source folder of the repo (overview), the areas so far (briefs) and this part's files (partTree).
func SplitPrompt ¶
SplitPrompt returns the split session's system prompt (the sources skill) and its message: every folder with its file count and extensions. The folders are the repo's, so they sit in a fence; the labels are Physa's.
Types ¶
type Area ¶
type Area struct {
Name string
Promise string
Sources []string
// Files are the slash paths the area holds, sorted. Empty until claimed.
Files []string
}
Area is one family of promises: its name, its one-line promise, the patterns the session gave for it and, once resolved, the files it holds.
func ParseAreas ¶
ParseAreas reads the grouping session's answer: the areas in the last fenced json block. Names are kebab-cased, an empty one becoming "unnamed", and promises are put on one line. The error follows "the areas answer: ".
type AreaCount ¶
type AreaCount struct {
Name string `json:"name"`
Promise string `json:"promise"`
Files int `json:"files"`
}
AreaCount is one area of a Result: its name, promise and file count.
type AreaRecord ¶
type AreaRecord struct {
Name string `json:"name"`
Promise string `json:"promise"`
Files []string `json:"files"`
}
AreaRecord is one stored area: its name, its promise and its files, sorted.
type Fix ¶
Fix is a session's answer to FixPrompt: exact claims for files that were missing or claimed twice, and any areas it adds.
type Joint ¶
Joint is one merge of areas: From joins Into, which takes Promise.
func ParseMerge ¶
ParseMerge reads the merge session's answer: the "merge" list in the last fenced json block, [] for no merge. The error follows "the merge answer: ".
type Loader ¶
type Loader interface {
Areas() (initrecord.Areas, bool, error)
}
Loader is the store as Load reads it.
type Record ¶
type Record struct {
Split sourceset.Division `json:"split"`
Left map[string]LeftFiles `json:"left"`
Areas []AreaRecord `json:"areas"`
Parts int `json:"parts"`
Merges []Joint `json:"merges"`
Sessions []string `json:"sessions"`
}
Record is the body init's record keeps for the areas, which the walk reads with Load: the split as code expanded it, the files left out by reason (sourceset's Left constants), the areas, and how they were made.
type Result ¶
type Result struct {
Listed int `json:"listed"`
Left map[string]int `json:"left"`
Kinds map[sourceset.Kind]int `json:"kinds"`
Source int `json:"source"`
Areas []AreaCount `json:"areas"`
Parts int `json:"parts"`
Merges []Joint `json:"merges"`
MergeKept string `json:"merge_kept"`
FixRounds int `json:"fix_rounds"`
Unused []string `json:"unused"`
Dropped []string `json:"dropped"`
Model string `json:"model"`
Tokens adapter.Tokens `json:"tokens"`
}
Result is what the phase ended with: the tracked files listed, those left out by reason, the files of each kind and the source count, the areas, the parts and merges, the fix rounds run, the unused and dropped patterns, and the model and tokens. MergeKept, when set, says why the merge failed and the areas were kept apart.
func Run ¶
Run is init's areas phase end to end. It lists the repo's tracked files, has one session name the test, doc and other files as patterns, then has one session (one per part when the listing is larger than a part) place every source file in exactly one area; files left out or claimed twice go back to that session, at most MaxFixRounds times. It stores the areas and the split in init's record, and writes nothing to the repo or the map. On any error it stores nothing.
type Session ¶
type Session struct {
Agent func() (adapter.Adapter, error)
Root string
Repo vcs.Repo
Progress io.Writer
Now func() time.Time
PartChars int
}
Session is how the phase's sessions are run: the agent, the repo's root where each runs read-only, the repo (which must be a vcs.Tracker), where progress lines go, the clock (nil is time.Now) and the most listing characters a grouping session is given (0 is DefaultPartChars).