Documentation
¶
Overview ¶
Package memory loads project instruction files (AGENTS.md, CLAUDE.md, GEMINI.md, BLITZ.md), the files they import, and rule files, which are added to the agents' system prompt. Rules scoped to paths are handed out when the agent first touches a matching file (see Rules).
Index ¶
- Constants
- Variables
- func Append(workspace, file, text string) (string, error)
- func DeleteNote(dir, name string) error
- func Imports(content string) []string
- func NotesDir(workspace string) string
- func Render(docs []Doc, scoped ...bool) string
- func RenderNotes(notes []Note) string
- func RenderRules(rules []*Rule) string
- func TrackedByGit(path string) bool
- type Doc
- type Loaded
- type Note
- type Options
- type Rule
Constants ¶
const ( NoteFact = "fact" NotePreference = "preference" NoteCorrection = "correction" )
The kinds of note.
Variables ¶
var ErrNoNote = errors.New("no such note")
ErrNoNote means no note has the name (or several start with it).
var ErrUnknownKind = errors.New("a note is a fact, a preference or a correction")
ErrUnknownKind means a note kind that isn't fact, preference or correction.
Functions ¶
func Imports ¶
Imports returns the @path imports in an instruction file, in order, ignoring fenced code blocks and inline code. A token counts as a path when it has a "/" or a file extension, so "@team" stays text.
func Render ¶
Render formats docs as a system-prompt section. scoped says whether path-scoped rules exist, so the agent knows to expect them.
func RenderNotes ¶
RenderNotes is the notes as the agent's instructions carry them: the newest first, up to maxNotesBytes, framed as what they are.
func RenderRules ¶
RenderRules formats rules handed out with a tool result.
func TrackedByGit ¶
TrackedByGit reports whether git tracks path, for warning about personal files that were committed. Git runs with fsmonitor off: the repository's config may name commands.
Types ¶
type Doc ¶
type Doc struct {
Path string
Content string
Truncated bool
// ImportedFrom is the file whose @path import loaded this one ("" for
// files found by name).
ImportedFrom string
// Local marks a personal file (BLITZ.local.md) that shouldn't be
// committed.
Local bool
}
Doc is one loaded instructions file.
type Loaded ¶
type Loaded struct {
Docs []Doc // always in the prompt (unscoped rules included)
Rules []Rule // scoped rules, handed out by path
}
Loaded is everything Load found.
func LoadAll ¶
func LoadAll(workspace string, cfg config.MemoryConfig, opts ...Options) Loaded
LoadAll returns instruction files and rules: the global file and global rules first, then, for each directory from the repository root (the nearest ancestor containing .git, if any) down to the workspace, the files named in cfg.Files, then cfg.LocalFiles, then the rule files in cfg.RuleDirs, so more specific files come last. Files a loaded file imports (@path) follow it. The same file, or the same content under another name (CLAUDE.md copying AGENTS.md), loads once.
type Note ¶
type Note struct {
Name string // its file's name, without .md
Kind string
Text string
Time time.Time
Path string
}
Note is one saved note.
type Options ¶
type Options struct {
// Blocked reports paths that must never be read (the sandbox's
// blocked_paths): an import of one is skipped.
Blocked func(abs string) bool
}
Options refine loading.