Documentation
¶
Overview ¶
Package msgprefix is the ONE table of the prefixes gofer puts in front of the text it delivers into an agent session (design 2026-10-22-message-prefixes, D1):
[来自 web,<user>] … a person's new message from the web [来自 web 回复,<user>] … a person answering a session's question [gofer · job 完成] … gofer system messages, one prefix per type
The split is the point: anything opening with "[来自 web" was written by a person, anything opening with "[gofer · " is machine text gofer generated (a job end notice, a wakeup, a work-item request, a memory injection, a hint). Every generator and every recogniser uses this package, so the two halves cannot drift apart — they did once (a job-end notice wore the web's reply prefix and the agent read it as the person talking).
The package depends on nothing else in internal/ (G022): it is the bottom of the delivery stack.
Index ¶
Constants ¶
const ( // WebMessage is a person's new message from the web. WebMessage = "web-message" // WebReply is a person answering a question a session asked (a relay turn). WebReply = "web-reply" // JobDone is a "your job has finished" notice. JobDone = "job-done" // Wakeup is a wakeup instruction (a continuation that a timer / event started). Wakeup = "wakeup" // WorkHandoff is a work item's hand-over request. WorkHandoff = "work-handoff" // WorkReport is a work item's progress-report request. WorkReport = "work-report" // Steward is the steward relaying a person's words. Steward = "steward" // Memory is an injected memory (workspace / repository). Memory = "memory" // Hint is any other gofer hint for the agent (a topic reminder, a generic // system notice that names no type of its own). Hint = "hint" )
Message kinds. One per row of the prefix table.
const ( // WebMessageOpen is the head of a person's web message prefix. WebMessageOpen = "[来自 web" // WebReplyOpen is the head of a person's session-question reply prefix. It is // checked before WebMessageOpen, which it shares its first characters with. WebReplyOpen = "[来自 web 回复" )
A person's prefix opens with these words; the person's name and a closing bracket follow ("[来自 web,alice] ").
const ( // JobDoneOpen opens a job-end notice. JobDoneOpen = "[gofer · job 完成]" // WakeupOpen opens a wakeup instruction. WakeupOpen = "[gofer · 唤醒]" // WorkHandoffOpen opens a work item's hand-over request. WorkHandoffOpen = "[gofer · 工作项交接]" // WorkReportOpen opens a work item's report request. WorkReportOpen = "[gofer · 工作项汇报]" // StewardOpen opens a message the steward relays for a person. StewardOpen = "[gofer · 管家带话]" // MemoryOpen opens an injected memory block line. MemoryOpen = "[gofer · 记忆]" // HintOpen opens a gofer hint (topic reminder, generic notice). HintOpen = "[gofer · 提示]" )
A gofer system prefix is "[gofer · <type>]" with one space after the bracket. These are whole prefixes (no part of them varies), so a generator can use them as constants and a recogniser can compare what it reads.
const DefaultUser = "web"
DefaultUser is the name used for a person whose name is not known (an anonymous web caller, a reply recorded before the speaker was kept).
Variables ¶
This section is empty.
Functions ¶
func Classify ¶
Classify reads the prefix of a delivered text. kind is the message kind ("" when the text carries no prefix this package knows), fromPerson tells the two halves apart: true = a person wrote it, false = gofer generated it. Unknown text answers ("", false), so a plain human prompt is never mistaken for a notice.
func IsPerson ¶
IsPerson reports whether text was written by a person (the current web prefixes and, until v0.188, the old "[gofer web 回复]").
func IsSystem ¶
IsSystem reports whether text is a gofer system message (the current prefixes and, until v0.188, the old ones).
func Person ¶
Person reports whether kind is a person's message kind (the other kinds are gofer's own).
func Prefix ¶
Prefix returns the prefix of kind, with the one space that separates it from the body, or "" for an unknown kind. user is the person's name for a person's kind and ignored otherwise; an empty name falls back to DefaultUser (a person's message always carries a name, so the two halves stay distinguishable).
func SystemPrefixes ¶
func SystemPrefixes() []string
SystemPrefixes returns the whole prefix of every system kind (documentation, tests and the outward-facing说明 of the table).
Types ¶
This section is empty.