areas

package
v0.0.33 Latest Latest
Warning

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

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

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

View Source
var Areas string

Areas is the grouping skill: what a session is told before the source files it places in areas.

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

View Source
var Parts string

Parts is appended to Areas when the listing comes in parts.

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

func AreasPrompt(tree string) (system, message string)

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

func FixPrompt(missing []string, twice map[string][]string) string

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

func MergePrompt(briefs string) (system, message string)

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

func ParseSplit(text string) (tests, docs, other []string, err error)

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

func PartPrompt(i, n int, overview, briefs, partTree string) (system, message string)

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

func SplitPrompt(kinds string) (system, message string)

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.

func Text

func Text(w io.Writer, r Result) error

Text writes what the phase did in plain words: the files listed and left out by reason, how many are tests, docs, other and source, the patterns unused or dropped, the parts and merges, each area with its file count and promise, and the sessions' model. It names no session.

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

func ParseAreas(text string) ([]Area, error)

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

type Fix struct {
	Add      map[string][]string
	NewAreas []Area
}

Fix is a session's answer to FixPrompt: exact claims for files that were missing or claimed twice, and any areas it adds.

func ParseFix

func ParseFix(text string) (Fix, error)

ParseFix reads the answer to FixPrompt: "add" and "new_areas" in the last fenced json block. The error follows "the fix answer: ".

type Joint

type Joint struct {
	Into    string
	From    []string
	Promise string
	Why     string
}

Joint is one merge of areas: From joins Into, which takes Promise.

func ParseMerge

func ParseMerge(text string) ([]Joint, error)

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 LeftFiles

type LeftFiles struct {
	Count int      `json:"count"`
	Paths []string `json:"paths"`
}

LeftFiles is the files left out for one reason.

type Loader

type Loader interface {
	Areas(ctx context.Context) (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.

func Load

func Load(st Loader) (Record, bool, error)

Load reads the stored areas and decodes their body, false when none exist.

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

func Run(ctx context.Context, st Store, s Session) (Result, error)

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

type Store

type Store interface {
	Gathered(ctx context.Context) (store.Gather, bool, error)
	PutAreas(context.Context, initrecord.Areas) error
}

Store is init's record as the areas phase uses it.

Jump to

Keyboard shortcuts

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