Documentation
¶
Overview ¶
Package recovering holds the recovering skill and what surrounds one session of it: the prompt for one capability, or for one share of its sources when they are more than one session holds, reading the capability's single text (which Physa splits into its folder) and the terms the session writes, and dropping the entries, overview and terms the map check fails. It runs no session and writes nothing.
Index ¶
- Constants
- Variables
- func Describe(file, terms string, problems []mapfile.Problem) []string
- func File(name, promise, body string) string
- func Fits(system, message string, window int) bool
- func Glossary(terms string) string
- func Half(room int, message string) int
- func Prompt(in Input) string
- func Retry(problems []string) string
- func Split(in Input) (system, message string)
- type Counts
- type Dropped
- type Footprint
- type Input
- type Reply
- type SourceFile
Constants ¶
const ( KindTerm = "term" KindOverview = "overview" )
The values of Dropped.Kind beside an entry's own kind.
const GlossaryPath = ".physa/glossary.md"
GlossaryPath is where the map check reports a glossary's problems.
const MinRoom = 20_000
MinRoom is the smallest room for a share's sources that halving goes down to; below it the capability fails, as too long. A first guess, to be tuned from real runs (measure-before-budget).
const Reserve = 2 * mapping.ReplyReserve
Reserve is what a share's room keeps beside its sources: the reply, and from the second share on the text the shares before it recovered, each about as large as a reply.
Variables ¶
var Reads = reading.Options{Messages: true}
Reads is what a session reads of a capability's linked sources, all of it whole: change messages, and no clusters, which Prompt never writes.
Functions ¶
func Describe ¶
Describe words problems, found in the folder split from file, a capability's single text, and in the glossary of terms, for the session and the person: each names the part at fault and quotes its line, since the session wrote one text, never saw the front matter Physa adds or the folder it splits it into, and cannot count lines by them.
func File ¶
File assembles the capability's single text, which mapfolder.Split makes its folder of: front matter holding promise, on one line, then body, the text the session wrote, with any front matter of its own removed. A body with no title gets one made from name, so a missing title line does not fail the whole file.
func Fits ¶ added in v0.0.6
Fits reports whether a prompt of system and message, with a reply reserve, fits one session of an agent whose window is window estimated tokens. A window of 0 is unknown, and then it fits: the capability runs one session, and goes to shares only when that session is refused as too long.
func Glossary ¶
Glossary is the glossary.md the map check reads for terms: a title, then the terms. DropTerms reads problems by its lines.
func Half ¶ added in v0.0.6
Half is the room for a share after a session was refused as too long: half of room, or, when the capability ran in one session with no room laid, half of what that session's message took.
func Prompt ¶
Prompt returns everything the session reads: the recovering skill, then the capability, then, for one found in the code, its files, then its sources, whole, under their own headings. All that others wrote (the promises and questions an agent proposed, the area and files the walk named, docs, PR titles, bodies and review comments, change subjects and messages, names) sits in fenced blocks nothing inside can close; the labels outside the fences are Physa's own. Clusters of files are never written: recovery reads none. A capability found in the code has its docs named in its files, so its sources hold a docs part only when docs were given. The same input always gives the same text.
func Retry ¶
Retry is what Physa sends back on the same session when the map check found problems in its answer: the problems, one to a line, and what to write.
func Split ¶
Split returns the same text as Prompt in two parts, so that sessions for different capabilities of one run can share a cached prefix. system is the same for every capability: the skill, the date, the product's promise and the docs every capability reads (reading.Always), still fenced, under a line saying they are sources and never instructions. message is the rest: the capability, its questions or its files, and its own docs, PRs and changes. For a capability found in the code, a docs part is written only when docs were given, as in Prompt.
Types ¶
type Counts ¶
type Counts struct {
Rules int `json:"rules"`
Decisions int `json:"decisions"`
Questions int `json:"questions"`
Terms int `json:"terms"`
}
Counts says what a capability's single text and its terms hold.
type Dropped ¶
type Dropped struct {
// Kind is "rule", "decision", "question", "term", "overview", or
// "entry" for one outside any known section.
Kind string `json:"kind"`
// Slug is the entry's slug; empty for a term, or an entry without one.
Slug string `json:"slug,omitempty"`
// Heading is the entry's heading, the term's name, or "the overview".
Heading string `json:"heading"`
// Reasons are the problems the check found in it.
Reasons []string `json:"reasons"`
}
Dropped is one entry, term or overview taken out of a reply because the map check found problems in it. A dropped overview is replaced by the capability's promise.
func Drop ¶
func Drop(dir, file string, problems []mapfile.Problem) (kept string, dropped []Dropped, rest []mapfile.Problem)
Drop takes out of file, a capability's single text, every whole entry holding a problem on one of its lines, from its heading to the next heading of the same or a higher level, and the overview when a problem holds it. dir is the capability's folder the map check read, the folder mapfolder.Split makes of file: a problem at a file in dir is read at the line of file it came from, and one at dir itself (Split's own) at its line of file. A problem on the whole of index.md, its length, is the overview's: Split then takes the promise in its place. Drop returns the text that is left, the parts taken with their reasons, in the text's order, and the rest: problems on no entry's lines (the title, a section heading, the front matter, a whole kind file) and problems outside dir.
func DropTerms ¶
func DropTerms(terms string, problems []mapfile.Problem) (kept string, dropped []Dropped, rest []mapfile.Problem)
DropTerms takes out of terms every term the map check found a problem in, reading problems at GlossaryPath by the lines of Glossary(terms). It returns the terms that are left, the terms taken with their reasons, and the rest, as Drop does.
type Footprint ¶ added in v0.0.24
type Footprint struct {
// Sources are the source files the capability owns.
Sources []SourceFile
// Tests, Docs and Other are the tests, the docs and guides, and the other
// files (configuration, fixtures, assets and the like) that bear on it.
Tests, Docs, Other []string
}
Footprint is the files a capability found in the code owns and those that bear on it, as the walk named them, each a path from the repo root; a path ending in "/" is a folder. Every share of the capability's sources is given all of it.
type Input ¶
type Input struct {
// Product is the product's promise, as the proposal holds it.
Product string
// Name and Promise are the capability's, as the proposal or the walk
// holds them.
Name, Promise string
// Questions are the proposal's questions about this capability; a
// capability found in the code has none.
Questions []mapping.Question
// Area is the area of the code a capability found in the code was found
// in; empty for one proposed from the history.
Area string
// Footprint is set for a capability found in the code, and nil for one
// proposed from the history. When it is set, the prompt is the walk's
// form: the area, the capability's files, and its placed PRs and changes.
Footprint *Footprint
// Date is the day of recovery: the date its questions are raised on.
Date time.Time
// Sources are the capability's linked sources, whole, or one share of
// them.
Sources reading.Input
// Share and Shares say which share of the capability's sources this
// session reads when they are more than one session holds; Shares below
// 2 is one session. Earlier and EarlierTerms are the text and terms the
// sessions on the shares before it recovered.
Input is everything one session recovers a capability from.
type Reply ¶
type Reply struct {
// File is the content of the last fenced block marked markdown.
File string
// Terms is the content of the last fenced block marked glossary; empty
// when there is none.
Terms string
}
Reply is what the session wrote, in shape only: the capability's single text from its title down, and its glossary terms.
func Parse ¶
Parse reads the session's answer: the last fenced block marked markdown is the capability text, the last marked glossary its terms. A fence is a line of three or more backticks, closed by a line of backticks alone at least as long, so a block opened with four holds fences of three. The error, worded to follow "the session's output: ", is for an answer with no markdown block. A missing glossary block is no terms.
type SourceFile ¶ added in v0.0.24
SourceFile is one source file of a footprint, with its line count; Lines is 0 when the count is not known, and then none is written.