msgprefix

package
v0.191.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 1 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):

[来自 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

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"
)

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 回复"
)

A person's prefix opens with these words; the person's name and a closing bracket follow ("[来自 web,alice] ").

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

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.

func Format

func Format(kind, user, body string) string

Format renders one delivered message: the prefix of kind, then body.

func IsPerson

func IsPerson(text string) bool

IsPerson reports whether text was written by a person (the current 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 (the current prefixes and, until v0.188, the old ones).

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 Prefix

func Prefix(kind, user string) string

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.

Jump to

Keyboard shortcuts

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