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 PrimePlanLinesIn(lang i18n.Lang, p client.Plan, issues []tracker.Issue) []string
- func RefocusHeadIn(lang i18n.Lang, resumed bool) string
- func RenderRefocusIn(lang i18n.Lang, r Refocus, resumed bool, budget int) string
- func RenderSynthesisIn(lang i18n.Lang, r SynthesisRef, budget int) string
- func SynthesisFresh(day string, now time.Time) bool
- type Brief
- type Client
- type Options
- type Refocus
- type RefocusClaim
- type RefocusJob
- type RefocusMail
- type RefocusPlan
- type Section
- type SynthesisRef
Constants ¶
const ( // SynthesisPrimeMaxBytes bounds the whole block, heading and hint included. SynthesisPrimeMaxBytes = 600 // SynthesisPrimeMaxAgeDays: a synthesis whose day is older than this is not referenced // (an old summary must not pass for today's state). SynthesisPrimeMaxAgeDays = 3 )
The session-opening reference to the latest daily memory synthesis (design 2026-10-28-daily-memory-synthesis §6): one short block with the day, the run id, a bounded summary and the command to read more. It never carries highlights, source material or anything but the run's own (already scrubbed) summary sentence; with no recent successful synthesis there is no block at all.
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 PrimePlanLinesIn ¶ added in v0.198.0
PrimePlanLinesIn renders one open plan for the prime 「进行中 plan」 section in lang: the plan line with the brief hint, then its doing / ready todos with the issues they name.
func RefocusHeadIn ¶ added in v0.198.0
RefocusHeadIn is the sentence after the prefix in lang: why the section appeared.
func RenderRefocusIn ¶ added in v0.198.0
RenderRefocusIn renders the section in lang, 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.
func RenderSynthesisIn ¶ added in v0.208.0
func RenderSynthesisIn(lang i18n.Lang, r SynthesisRef, budget int) string
RenderSynthesisIn renders the block in lang ("\n" first, "\n" last, like the other prime sections) or "" when there is nothing to say or it does not fit: budget is the bytes the whole prime has left. An over-long summary is cut at a rune boundary with an ellipsis; when even the shortest useful summary does not fit, the whole block is omitted rather than squeezing out the prime's core rules.
Types ¶
type Brief ¶
type Brief struct {
Kind string `json:"kind"` // issue | plan
ID string `json:"id"`
Sections []Section `json:"sections"`
// Lang is the language the sections were written in (not part of the JSON shape).
Lang i18n.Lang `json:"-"`
}
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
// Language is the language of the brief's own text (design
// 2026-10-27-i18n-design.md §3): the job project's language for a brief an MCP tool
// hands to an agent, the client config's for `gofer issue|plan brief`. "" keeps the
// deployment default, so an existing deployment reads the text it always read.
Language i18n.Lang
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.
type SynthesisRef ¶ added in v0.208.0
type SynthesisRef struct {
Day string // YYYY-MM-DD of the synthesized business day
ID string // run id
Summary string
}
SynthesisRef is the input of RenderSynthesisIn.