Documentation
¶
Overview ¶
Package history persists the global, append-only prompt history shared by golder's interactive front-ends (the TUI for now). It mirrors Codex's message-history store: one JSON object per line in $GOLDER_HOME/history.jsonl, appended with a single write so concurrent processes never interleave partial lines, capped by size so the file cannot grow without bound. The front-end reads the newest entries once (lazily, on first use) and keeps them in memory for ↑/↓ browsing and Ctrl+R search across sessions.
Index ¶
Constants ¶
const FileName = "history.jsonl"
FileName is the history file inside the golder home directory.
const MaxEntries = 500
MaxEntries bounds what Load returns: the newest N entries. The on-disk file can hold more (up to maxBytes); the reader only ever holds this window.
Variables ¶
This section is empty.
Functions ¶
func Append ¶
Append adds one entry to the history file at path, creating it (and its parent directory) when needed. The record is marshaled first and written to an O_APPEND descriptor in one Write, so concurrent appenders do not interleave partial lines; the file is mode 0600. When the file exceeds maxBytes it is rewritten to keep the newest lines (trimRatio of the cap). Appending to a path whose directory cannot be resolved fails.
func WriteAll ¶
WriteAll replaces the history file with entries (oldest first), creating the parent directory as needed. It writes through a temp file and an atomic rename at mode 0600, so a concurrent reader never sees a half-written file. It is the bulk-write counterpart to Append, used by the one-time backfill that seeds the file from existing sessions.
Types ¶
type Entry ¶
type Entry struct {
TS int64 `json:"ts"`
SessionID string `json:"session_id,omitempty"`
Cwd string `json:"cwd,omitempty"`
Text string `json:"text"`
}
Entry is one persisted prompt-history record. Text is the fully expanded prompt as submitted (paste placeholders resolved), so recalling and resubmitting it is faithful.