Documentation
¶
Overview ¶
Package brief assembles the handoff brief (接手包, design 2026-10-10-handoff-brief-and-knowledge-loop §一): everything a fresh agent session needs to take over an issue or a plan, in one bounded text.
It reads the repository tracker, git and docs/ directly, and the server through the narrow Client interface; a section that needs the server is skipped with a note when there is none. Like internal/focusremote it sits between the command layer and tracker (tracker must not import client), so `gofer issue|plan brief` and the MCP gofer_issue_brief / gofer_plan_brief tools only bind inputs and print.
Index ¶
- Constants
- func PrimePlanLines(p client.Plan, issues []tracker.Issue) []string
- func RefocusHead(resumed bool) string
- func RenderRefocus(r Refocus, resumed bool, budget int) string
- type Brief
- type Client
- type Options
- type Refocus
- type RefocusClaim
- type RefocusJob
- type RefocusMail
- type RefocusPlan
- type Section
Constants ¶
const ClientTimeout = 8 * time.Second
ClientTimeout bounds every server request a brief makes, so an unreachable server costs seconds, not the client's default 30s per call. 3s proved too tight while the host was busy (a 200-job list timed out under a full test run); a refused connection still fails at once, so only a hung server pays the full bound.
const DefaultMaxLines = 400
DefaultMaxLines caps the rendered brief (`--max-lines`).
Variables ¶
This section is empty.
Functions ¶
func PrimePlanLines ¶
PrimePlanLines renders one open plan for the prime 「进行中 plan」 section: the plan line with the brief hint, then its doing / ready todos with the issues they name.
func RefocusHead ¶ added in v0.186.0
RefocusHead is the sentence after the prefix: why the section appeared.
func RenderRefocus ¶ added in v0.186.0
RenderRefocus renders the section, or "" when there is nothing to say, it does not fit the budget, or the caller asked for no section at all.
budget is the number of BYTES the whole prime has left (the same budget tracker.PrimeMaxBytes gives the other sections): items are appended while they fit, so a long topic still leaves room for the first claim instead of dropping the whole section.
Types ¶
type Brief ¶
type Brief struct {
Kind string `json:"kind"` // issue | plan
ID string `json:"id"`
Sections []Section `json:"sections"`
}
Brief is a rendered handoff brief.
func IssueBrief ¶
IssueBrief assembles the brief of one repository issue (design §一, sections in order: issue → 上下文树 → 设计稿 → 相关提交 → 相关 job / plan → 适用记忆 → 接手提示).
type Client ¶
type Client interface {
ListJobs(opts job.ListOpts) ([]job.JobResult, error)
ListPlans(opts client.PlanListOpts) (client.PlanList, error)
GetPlan(id string) (client.Plan, error)
GetPlanHandoff(id string, version int) (client.PlanHandoff, error)
ListScopedMemories(opts client.ScopedMemoryListOpts) ([]client.ScopedMemory, error)
}
Client is the slice of the server API a brief reads.
type Options ¶
type Options struct {
// Store is the repository tracker (required for an issue brief; optional for a
// plan brief, where it resolves the issues the todos mention).
Store *tracker.Store
// Root is the repository root for git and docs/ (default Store.RepoRoot()).
Root string
// Client is the server; nil skips the server sections with ClientNote.
Client Client
ClientNote string
// ProjectKey scopes job / plan / project-memory lookups ("" = all projects for
// jobs and plans, no project memories).
ProjectKey string
// GlobalMemories reads the global memories from this machine's copy (no
// network). nil, or tracker.ErrGlobalNotSynced from it, reads them from Client.
GlobalMemories func() ([]tracker.Memory, error)
// AgentName filters `agent:<name>` tagged memories (tracker.MemoryForAgent).
AgentName string
MaxLines int
Now time.Time
}
Options are the inputs of a brief.
type Refocus ¶ added in v0.186.0
type Refocus struct {
Topic string
Claims []RefocusClaim
Plans []RefocusPlan
Jobs []RefocusJob
Mail []RefocusMail
}
Refocus is everything the re-injection section may hold.
type RefocusClaim ¶ added in v0.186.0
RefocusClaim is an issue the session has claimed. Inferred marks a claim that the tracker does not record against this session: it looks like the session's work (in_progress, touched while the session was running) but prime can only say 「可能」.
type RefocusJob ¶ added in v0.186.0
RefocusJob is a job the session was waiting on.
type RefocusMail ¶ added in v0.186.0
RefocusMail is a letter the session has not answered yet.
type RefocusPlan ¶ added in v0.186.0
type RefocusPlan struct {
PlanID string
Title string
Status string
Progress int
Total int
Next string
Blocked string
}
RefocusPlan is an open / blocked plan the session supervises.
type Section ¶
type Section struct {
Title string `json:"title"`
Lines []string `json:"lines,omitempty"`
// Note says why the section is empty or partial (e.g. no server).
Note string `json:"note,omitempty"`
// More is the command that shows what the brief left out.
More string `json:"more,omitempty"`
// Truncated counts the lines cut to fit max-lines.
Truncated int `json:"truncated,omitempty"`
}
Section is one titled part of a brief.