Documentation
¶
Index ¶
- Constants
- func EntryContents(entries []MemoryEntry) []string
- func FormatMemoryPolicyStatus(memoryWrite string, fromFile bool) string
- func FormatMemoryPromptBody(entries []MemoryEntry) string
- func FormatMemoryUsage(used, limit int) string
- func JoinUnderRoot(root string, parts ...string) string
- func LedgerRel(root string) string
- func LegacyStagedContentSummary(content string) string
- func LegacyStagedKind(content string) (action, oldText, newContent string)
- func LooksLikeSecret(s string) bool
- func MemoryFileRel(root, file string) string
- func MemoryPolicyRel(root string) string
- func NormalizeMemoryToolAction(action string) string
- func RenderMemory(entries []MemoryEntry) string
- func RenderMemoryDocument(entries []MemoryEntry, docName string) string
- func SkillsPolicyRel(root string) string
- func StagedDirRel(root string) string
- func StagedPendingSummary(e StagedMemory) string
- type MemoryAddResult
- type MemoryAtCapacityError
- type MemoryEntry
- type MemoryLedger
- type MemoryLedgerEvent
- type MemoryPolicyStore
- type MemoryStore
- func (s *MemoryStore) Add(content string) (MemoryAddResult, error)
- func (s *MemoryStore) Load() ([]MemoryEntry, error)
- func (s *MemoryStore) Remove(oldText string) (string, error)
- func (s *MemoryStore) Replace(oldText, content string) (MemoryAddResult, error)
- func (s *MemoryStore) Save(entries []MemoryEntry) error
- func (s *MemoryStore) TotalChars(entries []MemoryEntry) int
- type MemoryToolInput
- type MemoryToolOutput
- type MemoryWritePolicy
- type StagedMemory
- type StagedStore
Constants ¶
const ( DefaultRoot = "." DefaultFile = "memory.md" )
const ( StagedActionAdd = "add" StagedActionReplace = "replace" StagedActionRemove = "remove" )
Staged action kinds for pending.json (empty Action = legacy encoded Content).
const DefaultMemoryCharLimit = 2200
DefaultMemoryCharLimit is the default memory.md body size budget (runes).
const MemoryToolDescription = `` /* 1171-byte string literal not displayed */
MemoryToolDescription is the main-agent memory tool prompt (aligned with Hermes WHEN/HOW/SKIP, adapted for memory.md + per-turn prompt freeze).
Variables ¶
This section is empty.
Functions ¶
func EntryContents ¶
func EntryContents(entries []MemoryEntry) []string
EntryContents returns trimmed entry bodies for tool errors.
func FormatMemoryPolicyStatus ¶
FormatMemoryPolicyStatus renders /memory policy output.
func FormatMemoryPromptBody ¶
func FormatMemoryPromptBody(entries []MemoryEntry) string
FormatMemoryPromptBody renders deduped entries for prompt injection (blank lines between facts).
func FormatMemoryUsage ¶
FormatMemoryUsage returns a compact usage string such as "1474/2200".
func JoinUnderRoot ¶
JoinUnderRoot joins segments under memoryRoot (".", "global:.", "local:memory", …).
func LegacyStagedContentSummary ¶
LegacyStagedContentSummary decodes pre-structured pending payloads.
func LegacyStagedKind ¶
LegacyStagedKind classifies a legacy Content-only staged row.
func LooksLikeSecret ¶
LooksLikeSecret rejects content that may contain credentials.
func MemoryFileRel ¶
func MemoryPolicyRel ¶
func RenderMemory ¶
func RenderMemory(entries []MemoryEntry) string
RenderMemory serializes entries into a memory.md file body.
func RenderMemoryDocument ¶
func RenderMemoryDocument(entries []MemoryEntry, docName string) string
RenderMemoryDocument serializes §-delimited entries with a file title header.
func SkillsPolicyRel ¶
func StagedDirRel ¶
func StagedPendingSummary ¶
func StagedPendingSummary(e StagedMemory) string
StagedPendingSummary is a human-readable line for /memory pending.
Types ¶
type MemoryAddResult ¶
type MemoryAddResult struct {
Outcome capmemory.AddOutcome
}
MemoryAddResult is the outcome of MemoryStore.Add.
type MemoryAtCapacityError ¶
type MemoryAtCapacityError struct {
Used int
Limit int
Adding int
Entries []MemoryEntry
}
MemoryAtCapacityError is returned when a write would exceed the char limit.
func (*MemoryAtCapacityError) Error ¶
func (e *MemoryAtCapacityError) Error() string
type MemoryEntry ¶
type MemoryEntry = capmemory.MemoryEntry
MemoryEntry is one §-delimited block in memory.md (same shape as cap/memory).
func DedupeMemoryEntries ¶
func DedupeMemoryEntries(entries []MemoryEntry) []MemoryEntry
DedupeMemoryEntries merges a list in order (later entries can replace earlier subsets).
func MergeMemoryAdd ¶
func MergeMemoryAdd(entries []MemoryEntry, content string) ([]MemoryEntry, capmemory.AddOutcome)
MergeMemoryAdd integrates one fact into existing entries (exact + substring rules).
func ParseMemory ¶
func ParseMemory(raw string) []MemoryEntry
ParseMemory splits a memory.md body into entries.
type MemoryLedger ¶
type MemoryLedger struct {
Path string
}
MemoryLedger appends JSON lines under memory/ledger.jsonl (not injected into prompts).
func (*MemoryLedger) Append ¶
func (l *MemoryLedger) Append(ev MemoryLedgerEvent) error
func (*MemoryLedger) Rewrite ¶
func (l *MemoryLedger) Rewrite(events []MemoryLedgerEvent) error
Rewrite truncates and rewrites the ledger (tests).
type MemoryLedgerEvent ¶
type MemoryLedgerEvent struct {
Action string `json:"action"`
Content string `json:"content,omitempty"`
Match string `json:"match,omitempty"`
Source string `json:"source,omitempty"`
At time.Time `json:"at"`
}
MemoryLedgerEvent is one append-only audit row for memory.md changes.
type MemoryPolicyStore ¶
type MemoryPolicyStore struct {
Path string
}
MemoryPolicyStore persists memory/policy.json under memoryRoot.
func (*MemoryPolicyStore) Load ¶
func (s *MemoryPolicyStore) Load() (MemoryWritePolicy, error)
func (*MemoryPolicyStore) Save ¶
func (s *MemoryPolicyStore) Save(p MemoryWritePolicy) error
type MemoryStore ¶
type MemoryStore struct {
Path string
CharLimit int
// DocName is the file title in the on-disk header (default memory.md).
DocName string
}
MemoryStore reads and writes a §-delimited memory.md file with capacity limits.
func NewMemoryStore ¶
func NewMemoryStore(path string, charLimit int) *MemoryStore
NewMemoryStore opens a store at path with the given char limit.
func (*MemoryStore) Add ¶
func (s *MemoryStore) Add(content string) (MemoryAddResult, error)
Add merges one fact into memory.md on disk.
func (*MemoryStore) Load ¶
func (s *MemoryStore) Load() ([]MemoryEntry, error)
Load reads all entries from disk.
func (*MemoryStore) Remove ¶
func (s *MemoryStore) Remove(oldText string) (string, error)
Remove deletes the entry whose body contains oldText.
func (*MemoryStore) Replace ¶
func (s *MemoryStore) Replace(oldText, content string) (MemoryAddResult, error)
Replace updates the entry whose body contains oldText.
func (*MemoryStore) Save ¶
func (s *MemoryStore) Save(entries []MemoryEntry) error
Save writes entries atomically.
func (*MemoryStore) TotalChars ¶
func (s *MemoryStore) TotalChars(entries []MemoryEntry) int
TotalChars counts runes across entry bodies.
type MemoryToolInput ¶
type MemoryToolInput = capmemory.MemoryToolInput
type MemoryToolOutput ¶
type MemoryToolOutput = capmemory.MemoryToolOutput
type MemoryWritePolicy ¶
type MemoryWritePolicy struct {
MemoryWrite string `json:"memoryWrite,omitempty"` // approve | auto
}
MemoryWritePolicy is tenant-local background-review memory write mode.
func (MemoryWritePolicy) Normalized ¶
func (p MemoryWritePolicy) Normalized() MemoryWritePolicy
type StagedMemory ¶
type StagedMemory struct {
ID string `json:"id"`
Action string `json:"action,omitempty"` // add | replace | remove; empty = legacy Content encoding
OldText string `json:"oldText,omitempty"` // replace/remove match substring
Content string `json:"content"` // add body or replace new text
Source string `json:"source"`
CreatedAt time.Time `json:"createdAt"`
}
StagedMemory is a pending memory write awaiting approval.
func NormalizeStagedEntry ¶
func NormalizeStagedEntry(e StagedMemory) StagedMemory
NormalizeStagedEntry fills Action/OldText/Content from legacy Content encoding when needed.
type StagedStore ¶
type StagedStore struct {
Dir string
}
StagedStore persists pending memory entries under workspace local root.
func (*StagedStore) Add ¶
func (s *StagedStore) Add(entry StagedMemory) error
func (*StagedStore) List ¶
func (s *StagedStore) List() ([]StagedMemory, error)
func (*StagedStore) Remove ¶
func (s *StagedStore) Remove(id string) (StagedMemory, error)