Documentation
¶
Overview ¶
Package initbranch writes init's map to the branch physa/init (design 02 section 2.6) in an isolated working copy: the map's files and the AGENTS.md pointer, and nothing else. It commits only after the map passes the map check, pushes the branch with a lease and opens or refreshes its one PR, whose body summarises what init proposed, recovered, raised, dropped and spent. It never touches the person's own working copy, index or checked-out branch, and never merges: the person edits, deletes or merges the PR like any other.
Index ¶
Constants ¶
const ( HookNotAsked = "" // the run did not ask for the hook HookInstalled = "installed" // the hook was installed HookAlready = "already" // the hook was already there HookRefused = "refused" // the hook was refused; Detail says why )
The values of Hook.State.
const ( PRNotAsked = "" // the run did not ask for a PR PROpened = "opened" // a PR was opened PRRefreshed = "refreshed" // the open PR's body was rebuilt PRReady = "ready" // no forge to open one; the branch is ready )
The states of PR.
const Branch = "physa/init"
Branch is the branch init writes its map to.
Variables ¶
This section is empty.
Functions ¶
func Body ¶
Body is the PR body for m (design 02 section 2.6): the capabilities proposed, the entries recovered for each with their anchors or why it has none, the questions raised, the entries dropped and the tokens spent, then what happened to the Session: hook. Entries are read back from m's files as the map reader reads them; Run's Outcome.Body is the same text, read from the branch's working copy. Last, when Summary.Skill is set, comes the agent's Physa skill line.
Types ¶
type Capability ¶
type Capability struct {
// Name is the capability's name, a slug, and its folder's name.
Name string
// Promise is what the product promises its users, on one line.
Promise string
// File is the recovered capability as one text, split into its folder;
// empty when not recovered, and the folder then holds the promise only.
File string
// Status is the recovery's status, such as "not yet recovered" or
// "failed"; Reason says why, when there is no File.
Status, Reason string
// Dropped are the entries and terms recovery took out of the text.
Dropped []Drop
}
Capability is one capability of the map.
type Drop ¶
type Drop struct {
// What names its kind: "rule", "term", "capability", "malformed item".
What string
// Value is the thing itself: a heading, a name, what the session wrote.
Value string
// Reason says why it was taken out.
Reason string
}
Drop is one thing taken out before the map was written, with its reason.
type Hook ¶
type Hook struct {
State string
// Detail is where the hook was installed, or why it was refused.
Detail string
}
Hook is what happened to the Session: hook.
type Map ¶
type Map struct {
// ProductName is the title of the product's index.md.
ProductName string
// ProductPromise is the product's promise, on one line.
ProductPromise string
// ProductRules are the product's rules, each the full text of one rule
// entry (heading, meta line, body, Because:), written as given.
ProductRules []string
// ProductQuestions are the product-wide questions, raised by physa.
ProductQuestions []Question
// Capabilities are written in this order, one folder each.
Capabilities []Capability
// Terms are the glossary's terms, as glossary.md writes them.
Terms string
// Sessions are the ids of the sessions Physa started; each is written
// once as a Session: trailer.
Sessions []string
// Date is the day the product's questions are raised on; zero means
// today.
Date time.Time
// Summary is what the PR body says beside the files.
Summary Summary
}
Map is everything init writes: the product, its capabilities and terms, the sessions Physa started for them, and what the PR body summarises.
type Options ¶
type Options struct {
// Push pushes the branch to the default branch's remote, with a lease.
Push bool
// PR opens or refreshes the branch's PR; it needs Push.
PR bool
// PRs opens and refreshes the PR; nil means no forge to do it, and
// ForgeReason says why.
PRs forge.PRs
ForgeReason string
// PRExists resolves #N anchors for the map check; nil checks their
// form only.
PRExists func(int) (bool, error)
}
Options say how far a run goes.
type Outcome ¶
type Outcome struct {
// Commit is the change written to the branch; nil when nothing was.
Commit *Commit
// Files are the files written, relative to the repo root, sorted.
Files []string
// Body is the PR body for what was written.
Body string
// Pushed reports whether the branch was pushed.
Pushed bool
// PR is what happened to the branch's PR.
PR PR
}
Outcome is what one run did.
func Run ¶
Run writes m to the branch with w: it refuses a branch checked out in any working copy and a default branch that already holds a map, writes the map's files and the AGENTS.md pointer in a working copy at the default branch, checks the map there and commits only when it passes, then points the branch at that one change, replacing what it held. With o.Push it pushes first, with the remote's branch as the lease, and moves the local branch only after the remote took the change. With o.PR it opens the PR, or refreshes the open one. A lost lease is an error, never retried. The Outcome holds what was done even when it returns an error.
type PR ¶
type PR struct {
State string
Number int
URL string
// Reason says why there is no forge, for PRReady.
Reason string
}
PR is what a run did with the branch's PR.
type Question ¶
type Question struct {
// Question is the matter, one line ending with a question mark.
Question string
// SuggestedBy names the PRs ("#12") and changes (short ids) that
// suggested it.
SuggestedBy []string
}
Question is an undecided matter the sources suggest but do not settle.
type Summary ¶
type Summary struct {
// Dropped are what proposing took out, with the malformed items of its
// reply.
Dropped []Drop
// Tokens are the tokens spent, one row per phase.
Tokens []Tokens
// Hook is what happened to the Session: hook.
Hook Hook
// Skill is the line saying the agent init ran with has no current Physa
// skill; empty when it has one or its state could not be read.
Skill string
}
Summary is what the PR body reports beside the files.