brief

package
v0.209.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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.

View Source
const DefaultMaxLines = 400

DefaultMaxLines caps the rendered brief (`--max-lines`).

Variables

This section is empty.

Functions

func PrimePlanLinesIn added in v0.198.0

func PrimePlanLinesIn(lang i18n.Lang, p client.Plan, issues []tracker.Issue) []string

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

func RefocusHeadIn(lang i18n.Lang, resumed bool) string

RefocusHeadIn is the sentence after the prefix in lang: why the section appeared.

func RenderRefocusIn added in v0.198.0

func RenderRefocusIn(lang i18n.Lang, r Refocus, resumed bool, budget int) string

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.

func SynthesisFresh added in v0.208.0

func SynthesisFresh(day string, now time.Time) bool

SynthesisFresh reports whether a synthesis of `day` (YYYY-MM-DD, local zone) is recent enough to reference at now. A malformed day is never fresh.

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

func IssueBrief(id string, opts Options) (Brief, error)

IssueBrief assembles the brief of one repository issue (design §一, sections in order: issue → 上下文树 → 设计稿 → 相关提交 → 相关 job / plan → 适用记忆 → 接手提示).

func PlanBrief

func PlanBrief(id string, opts Options) (Brief, error)

PlanBrief assembles the brief of a server plan: its fields, the todo list (status, dependencies, acceptance, the latest job and its outcome), the handoff note, and a short brief of every repository issue the plan or its todos name.

func (Brief) Text

func (b Brief) Text() string

Text renders the brief as markdown-ish text.

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.

func Connect

func Connect(cli *client.Client) (Client, string)

Connect re-binds cli with ClientTimeout and probes the server once. It returns (nil, reason) when the server does not answer, so the server sections are skipped with that reason instead of each one waiting on its own timeout.

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.

func (Refocus) Empty added in v0.186.0

func (r Refocus) Empty() bool

Empty reports whether there is nothing to remind the session of (no section then: a compact must not add an empty header to the prime).

type RefocusClaim added in v0.186.0

type RefocusClaim struct {
	ID       string
	Title    string
	Status   string
	Inferred bool
}

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

type RefocusJob struct {
	JobID  string
	Title  string
	Status string
}

RefocusJob is a job the session was waiting on.

type RefocusMail added in v0.186.0

type RefocusMail struct {
	ID      int64
	From    string
	Subject string
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL