msgprefix

package
v0.202.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 2 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 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; localized forms: design 2026-10-27-i18n-design.md §5 / §9.3):

[来自 web,<user>] …         a person's new message from the web
[from web, <user>] …
[来自 web 回复,<user>] …    a person answering a session's question
[web reply, <user>] …
[gofer · job 完成] …         gofer system messages, one prefix per type
[gofer · job done] …
[gofer · 退信] …             a letter gofer could not deliver, returned to its sender
[gofer · bounce] …

The split is the point: anything opening with a person's prefix 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).

Two languages: gofer GENERATES the prefix in the language of the session it is speaking to (its project's language, design §3), and the recognisers accept every known spelling, because a session holds messages written under the language it had when they were sent (a project's language can change, a worker's copy of a message can be older than the server's settings). "[gofer · " is therefore language-independent, and only the type inside the bracket differs.

The package depends on internal/i18n only (G022): it is the bottom of the delivery stack.

Index

Constants

View Source
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"
	// Bounce is a letter gofer could not deliver, returned to its sender (内部/mail
	// 退信): the body of that letter is a gofer notice, so the recipient reads it as
	// machine text and not as the addressee writing back.
	Bounce = "bounce"
)

Message kinds. One per row of the prefix table.

View Source
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 回复"

	// 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 · 提示]"
	// BounceOpen opens a returned letter (退信).
	BounceOpen = "[gofer · 退信]"
)

The default-language spelling of each person prefix and system kind. They are CONSTANTS because call sites declare their own constants from them (a package's "already carries it" marker); TestDefaultSpellingsMatchTheTable keeps them equal to the table's default-language entry, so the table stays the one source.

A generator that knows its recipient's language uses Open / PrefixIn / FormatIn instead; these are for recognisers and for a generator whose recipient is unknown (the default language is still written).

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

func Classify(text string) (kind string, fromPerson bool)

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.

Both languages are recognised: this is a read path, and the text may have been written under any language the deployment ever had.

func Format

func Format(kind, user, body string) string

Format is FormatIn in the DEFAULT language. See Prefix.

DEPRECATED(v0.198): see Prefix.

func FormatIn added in v0.198.0

func FormatIn(lang i18n.Lang, kind, user, body string) string

FormatIn renders one delivered message in lang: the prefix of kind, then body.

func IsPerson

func IsPerson(text string) bool

IsPerson reports whether text was written by a person (both languages' web prefixes and — until v0.188 — the old "[gofer web 回复]").

func IsSystem

func IsSystem(text string) bool

IsSystem reports whether text is a gofer system message (both languages, and — until v0.188 — the old prefixes).

func Open added in v0.198.0

func Open(lang i18n.Lang, kind string) string

Open returns the whole prefix of a SYSTEM kind in lang — the text gofer writes ("[gofer · job done]"), without the separating space. "" for an unknown kind or for a person's kind (a person's prefix carries a name: use PrefixIn).

func Opens added in v0.198.0

func Opens(kind string) []string

Opens returns every known spelling of a system kind, all languages. A recogniser (a "does this prompt already carry it" check, a prefix comparison) must accept all of them: the session may hold the text of the language it had when written.

func Person

func Person(kind string) bool

Person reports whether kind is a person's message kind (the other kinds are gofer's own).

func PersonOpens added in v0.198.0

func PersonOpens(kind string) []string

PersonOpens returns every known spelling of a person kind's opening words, all languages ("[来自 web", "[from web"): a recogniser must accept both, since the session may hold a message written under another language.

func Prefix

func Prefix(kind, user string) string

Prefix is PrefixIn in the DEFAULT language — the form for a generator that does not know its recipient's language (a hook process, a caller whose text travels to a session it never read). A caller that knows the recipient's project uses PrefixIn; the two render the same table, so they cannot drift apart.

DEPRECATED(v0.198): a generator that learns its recipient's language switches to PrefixIn; remove this form once every generator does (design 2026-10-27-i18n §6).

func PrefixIn added in v0.198.0

func PrefixIn(lang i18n.Lang, kind, user string) string

PrefixIn returns the prefix of kind in lang, 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 in every language (documentation, tests and the outward-facing 说明 of the table).

Types

This section is empty.

Jump to

Keyboard shortcuts

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