Documentation
¶
Overview ¶
Package transcript turns an agent CLI's own session file into a short list of conversation turns for the work-item summarizer (W2a, design §14.2). It reads only the tail of a file the session registered, parses the three jsonl dialects gofer knows (claude, codex rollout, omp), and never touches the network or any tool.
Parsing is deliberately forgiving: an unknown line, a missing field or a truncated first line is skipped, because a transcript is a moving target written by someone else's program.
Index ¶
- Constants
- func CheckPath(path string) (string, error)
- func DialectFor(agent string) string
- func Format(turns []Turn, o FormatOpts) string
- func ReadTail(path string, maxBytes int64) ([]byte, error)
- func ReadTailSafe(path string, maxBytes int64) (data []byte, size int64, truncated bool, err error)
- func Resolve(configured, agent string) string
- func Roots() []string
- type FormatOpts
- type Turn
Constants ¶
const ( RoleUser = "user" RoleAssistant = "assistant" RoleTool = "tool" // a one-line note that the agent ran a tool )
Turn roles.
const ( DialectClaude = "claude" DialectCodex = "codex" DialectOmp = "omp" // DialectGeneric is the agent-neutral format a self-built agent can write: one JSON // object per line, {"v":1,"type":"user|assistant|tool","ts":RFC3339,"text":…, // "injected":bool,"name":…,"summary":…}. DialectGeneric = "generic" )
Dialects.
const DefaultTailBytes = 256 * 1024
DefaultTailBytes is how much of a transcript's end is read by default.
const EnvRoots = "GOFER_TRANSCRIPT_ROOTS"
EnvRoots adds directories (an OS path list) a transcript may live under, besides the user's home directory. Operators who keep agent session stores elsewhere (a relocated CLAUDE_CONFIG_DIR / CODEX_HOME is picked up automatically) set it.
const MaxTailBytes = 512 * 1024
MaxTailBytes is the hard cap of one safe tail read (the wire cap of a worker answer).
Variables ¶
This section is empty.
Functions ¶
func CheckPath ¶
CheckPath is the boundary for reading a session-registered transcript: an absolute .jsonl path that, with symlinks resolved, is a regular file under an allowed root. The server only ever passes the path a session registered, but the reader must not trust that — it would otherwise be a remote file reader. It returns the resolved path.
func DialectFor ¶
DialectFor maps a gofer agent name (or an acp variant of it) to the transcript dialect, "" when unknown (Parse then sniffs the content).
func Format ¶
func Format(turns []Turn, o FormatOpts) string
Format renders the newest turns as plain text, oldest first, within the bounds.
func ReadTail ¶
ReadTail reads at most maxBytes from the end of the file. When it had to cut, the first (partial) line is dropped so the result starts on a line boundary.
func ReadTailSafe ¶
ReadTailSafe vets the path (CheckPath) and reads at most maxBytes from its end (capped at MaxTailBytes; <=0 = DefaultTailBytes). size is the file's full size and truncated says the file was longer than what came back.
Types ¶
type FormatOpts ¶
type FormatOpts struct {
// MaxTurns keeps at most this many of the newest turns (default 40).
MaxTurns int
// MaxBytes bounds the whole rendering (default 32KB); older turns are dropped first.
MaxBytes int
// MaxTurnRunes caps one turn's text (default 2000); an over-long turn keeps its head
// and its tail (the conclusion is usually at the end).
MaxTurnRunes int
// Lang is the language of the role labels and the elision marker (the text is read
// by an agent). The zero value is i18n.Default.
Lang i18n.Lang
}
FormatOpts bounds the rendered tail.