Documentation
¶
Overview ¶
Package turn renders what an agent reads for one turn of the loop: the context of the turn, its instructions and the prompt that points to them.
Index ¶
- Variables
- func Base() (*template.Template, error)
- func Bundled() (*intentload.Loaded, error)
- func BundledFS() fs.FS
- func CheckTemplate(d dintent.Def, t *template.Template) []intentload.Problem
- func FactText(v any) string
- func NewCache(layers func() []profile.Layer, opts intentload.CacheOptions) (*intentload.Cache, error)
- func NewShared() (*intentload.Shared, error)
- func PayloadFacts(p Payload) expr.Facts
- func Prompt(c Context, id string) string
- func Trimmed(c Context) []string
- func WhySection(text string) string
- type Brief
- type Builder
- type Contents
- type Context
- type DataPayload
- type Dossier
- type DossierReader
- type FactsReader
- type FailingCheck
- type GuideReader
- type Intent
- type ItemsReader
- type PR
- type Payload
- type PayloadCompleter
- type PayloadReader
- type Planned
- type PriorReview
- type RecordedVerdict
- type Rendered
- type Request
- type RoundConflict
- type RoundReason
- type RoundReviewer
- type Scenario
- type Stored
- type Trigger
- type TurnFacts
- type Why
- type WhyFact
- type Wording
Constants ¶
This section is empty.
Variables ¶
var ProbeTitle = brand.Name + " probe"
ProbeTitle is the title of a probe's pull request, which exists nowhere.
Functions ¶
func Base ¶
Base is the set every intent's instructions are parsed on: the bundled partials and the template functions, with missingkey=error. The loader parses a profile's own partials over it.
func Bundled ¶
func Bundled() (*intentload.Loaded, error)
Bundled is the profile the release ships, the bundled layer and the bundled plugins' layers, loaded once; callers never change it.
func CheckTemplate ¶
CheckTemplate renders an intent's instructions and headlines against sample turns: every declared input set and every one zero, each with and without a resume. Each failure is placed at the template's line.
func NewCache ¶
func NewCache(layers func() []profile.Layer, opts intentload.CacheOptions) (*intentload.Cache, error)
NewCache is the registry cache over the bundled intents and those of layers. The caches whose layers are all embedded share one registry.
func NewShared ¶ added in v0.4.0
func NewShared() (*intentload.Shared, error)
NewShared is a registry over the bundled intents for the caches it makes, apart from the one NewCache and Bundled share.
func PayloadFacts ¶
PayloadFacts are p's provider facts as a predicate reads them.
func Prompt ¶
Prompt is the one line typed into the agent's session: the turn in words, and the command that prints its instructions.
func Trimmed ¶
Trimmed are the blocks the turn's guides left out to stay within the judgment limit: the main guide's, then each also_profile guide's under its prefix.
func WhySection ¶
WhySection is the why section of rendered instructions, from its heading to the next one; empty when the instructions carry none.
Types ¶
type Brief ¶
type Brief struct {
Goal, Context, Kind, Size, Risk, RiskWhy string
// Tags are key:value; Files are the changed paths the brief read.
OpenQuestions, Tags, Files []string
// HeadMoved says the pull request got new commits since the brief was
// written; OlderFormat, that the loop's brief format changed since.
HeadMoved, OlderFormat bool
Run int64
// Extra are the brief intent's extra fields, by name.
Extra map[string]any
}
Brief is the stored preview of a pull request a turn reads.
type Builder ¶
type Builder struct {
Guides GuideReader
// Facts reads the stored facts; nil reads nothing.
Facts FactsReader
// Intents is the registry the turn's intent comes from.
Intents func() *intentload.Loaded
// Viewer is the GitHub login of the user; nil leaves pr.mine false.
Viewer func(context.Context) (string, error)
// Config is the configuration for the turn's pull request.
Config config.Config
Command string
// ManagerBinary is the workspace manager's executable, which a probe never runs; "" for none.
ManagerBinary string
// Payloads read each provider's payload.
Payloads map[unit.ProviderID]PayloadReader
// Items nil renders no items.
Items ItemsReader
// Dossiers nil renders no dossier; a dry run reads none.
Dossiers DossierReader
}
type Contents ¶
type Contents interface {
Contents() string
}
Contents is a payload that brings its unit's content as text, such as a Slack thread's messages; the instructions quote it as data.
type Context ¶
type Context struct {
Intent Intent
Trigger Trigger
Planned Planned
Plain bool
Owned bool
// NeedsTakeOver, Round, FollowUpApproval, Headline and Records are
// filled by Complete from the intent's manifest.
NeedsTakeOver bool
Queued bool
Guidance string
Local string
Inputs map[string]any
Facts TurnFacts
Def dintent.Def
Round string
FollowUpApproval bool
Headline string
Records bool
AutomatedReviewers []string
Guide profile.Guide
// Guides are the composed guides by profile: the main one and each also_profile one that applies.
Guides map[string]profile.Guide
Brief *Brief
BriefMissing string
Agent string
Command string
ManagerBinary string
History []instructions.PastTurn
Resume *instructions.Resume
// Why is nil for a turn started by hand.
Why *Why
// Unit, Payload, Wording and Items are the turn's unit as its provider hands it.
Unit unit.Unit
Payload Payload
Wording Wording
Items []instructions.OpenItem // the unit's open items, filled through Builder.Items
// Dossier is the unit's dossier, nil when it has none or the turn names none.
Dossier *Dossier
// WithoutProjectSettings says the session runs without the checkout's
// own agent settings, so its instruction files are not in context.
WithoutProjectSettings bool
}
type DataPayload ¶ added in v0.3.0
type DataPayload interface {
Data() json.RawMessage
}
DataPayload is a payload that carries its plugin's data, which the templates read under the payload root the plugin's manifest names.
type Dossier ¶
type Dossier struct {
Path string
// Granted says the session was launched with the dossier in its policy.
Granted bool
// Merged are the paths of the dossiers of the tasks merged into the unit's task, which the session reads.
Merged []string
}
Dossier is a unit's dossier as a session turn reaches it.
type DossierReader ¶
DossierReader opens a unit's dossier for a session turn.
type FactsReader ¶
FactsReader reads what the loop keeps about a unit; a unit with no brief and no teams reads the zero Stored.
type FailingCheck ¶ added in v0.2.0
FailingCheck is a check that failed on the head; Summary and URL are the CI's own text.
type GuideReader ¶
GuideReader composes the guide a turn of kind reads for a pull request with facts f.
type ItemsReader ¶
type ItemsReader interface {
OpenItems(ctx context.Context, u unit.Unit) ([]instructions.OpenItem, error)
}
ItemsReader lists a unit's open items for its instructions; internal/cli/turnitems.go implements it.
type PR ¶
type PR struct {
URL, Owner, Repo string
Number int
Title, Author string
State string
// Association is GitHub's authorAssociation, such as FIRST_TIME_CONTRIBUTOR.
Association string
Head, Base string
Labels []string
CrossRepository bool
// Visibility is the repository's: public, private or internal; empty
// when not read.
Visibility string
Prior *PriorReview
// ReviewRequested says your review is requested again.
ReviewRequested bool
// LastReviewVerdict is the state of your newest review, comments included.
LastReviewVerdict string
// Address is why an address round runs now; nil on any other turn.
Address *RoundReason
}
func (PR) Anchored ¶ added in v0.3.0
func (p PR) Anchored(v *RecordedVerdict) *PR
Anchored is p with its prior review anchored to the head the loop's record v covered, when the review is no newer than the record.
type Payload ¶
type Payload interface {
Unit() unit.Unit
// Arg is how the instructions command names the unit: a PR URL for github, "<provider>:<key>" otherwise.
Arg() string
Wording() Wording
// Fact resolves a provider-namespaced predicate fact ("pr.author"); ok false for a name it does not own.
Fact(name string) (v any, ok bool)
}
Payload is a unit as its provider hands it to a turn's instructions.
type PayloadCompleter ¶ added in v0.3.0
type PayloadCompleter interface {
CompletePayload(r Request, p Payload) (Payload, error)
SyntheticPayload(u unit.Unit, probe bool) (Payload, error)
}
PayloadCompleter is a PayloadReader that completes a payload the caller handed the turn, and names a unit without reading it for an intent whose context is synthetic, such as a probe.
type PayloadReader ¶
PayloadReader is a provider's turn payload: a source plugin's Planner.Payload as the turn reads it.
type Planned ¶
type Planned int
Planned is the review round the sweep decided to send. A round asked for by hand is Unplanned: your reviews on GitHub make it a follow-up or not.
type PriorReview ¶
PriorReview is your latest review of a pull request: the head it covered, when, and the latest verdict that was not a comment, "" when all were. Endorsed is the endorsement of the turn that published the last verdict, "" when no turn of the loop's did.
type RecordedVerdict ¶
RecordedVerdict is the newest verdict a turn of the loop's published: the head its record covered, its endorsement and when it was recorded.
type Rendered ¶
type Request ¶
type Request struct {
Intent Intent
Trigger Trigger
Planned Planned
Unit unit.Unit
// LastVerdict anchors PR.Prior to the head the loop's record covered, which
// GitHub's review commit drifts from after later pushes.
LastVerdict *RecordedVerdict
Guidance string
Local string // work in the checkout not on the pull request
Queued bool // the prompt waits behind the agent's current turn
Agent string
// Plain is profile try's dry run: the turn publishes and records nothing.
Plain bool
// Owned says the caller checked the pull request is the user's to develop.
Owned bool
// Inputs are the intent's declared inputs the caller set, by name.
Inputs map[string]any
// Payload nil makes Build read it through Builder.Payloads.
Payload Payload
History []instructions.PastTurn
// Resume makes this a resume turn of one whose session is gone.
Resume *instructions.Resume
// BriefMissing says why the turn goes without a brief, when it does.
BriefMissing string
// Why is the workflow that started the turn; nil for a turn started by hand.
Why *workflow.Why
// Items and Task are the unit's item ids and the task the turn was asked about.
Items []string
Task string
}
Request is what a caller knows when it starts a turn; Build completes it into a Context.
type RoundConflict ¶ added in v0.2.0
RoundConflict is the head's conflict with Base, as GitHub reports it.
type RoundReason ¶ added in v0.2.0
type RoundReason struct {
Reviewers []RoundReviewer
Checks []FailingCheck
Conflict *RoundConflict
}
RoundReason is what an address round answers: the reviewers, the failing checks and a conflict with the base. Handled marks what an earlier round already covered.
func (*RoundReason) CheckNames ¶ added in v0.2.0
func (r *RoundReason) CheckNames() []string
func (*RoundReason) ReviewerLogins ¶ added in v0.2.0
func (r *RoundReason) ReviewerLogins() []string
type RoundReviewer ¶ added in v0.2.0
type Scenario ¶
type Scenario struct {
Name string
Context Context
// Expect is the judge's brief: what the agent must know after reading.
Expect string
Must, MustNot []string
// MaxWords bounds the text before "## Brief", or "## Judgment" without one.
MaxWords int
}
Scenario is a turn the eval renders: what its text must and must not carry, and the brief the judge reads.
type Stored ¶
type Stored struct {
// Brief is nil when none is stored.
Brief *Brief
// Teams are the teams a review was requested through, as <org>-<slug>.
Teams []string
}
Stored is what the loop keeps about a unit beyond its provider's read.
type TurnFacts ¶
type TurnFacts struct {
Mine, CrossRepository bool
LastReviewVerdict string
AddressReviews, AddressChecks, FollowupsWithoutWorkspace, AddressWithoutWorkspace bool
// RequestedTeams are the teams a review was requested through, as <org>-<slug>.
RequestedTeams []string
}
TurnFacts are the facts of a turn Build reads besides the request.