Documentation
¶
Index ¶
- Constants
- func BuildMemoryPrompt(store *Store) string
- func BuildReinjectMessage(items []CriticalContext) string
- func Register(e *sdk.Extension)
- type CriticalContext
- type Extractor
- type Fact
- type Store
- func (s *Store) Clear() error
- func (s *Store) Delete(key string) error
- func (s *Store) Get(key string) (Fact, bool)
- func (s *Store) List(category string) []Fact
- func (s *Store) Path() string
- func (s *Store) Relate(keyA, keyB string) error
- func (s *Store) Set(key, value, category string) error
- func (s *Store) SetImportance(key string, importance int) error
- func (s *Store) Unrelate(keyA, keyB string) error
- type TurnData
- type WireMsg
- type WireToolResult
Constants ¶
const (
ContextCategory = "_context"
)
Variables ¶
This section is empty.
Functions ¶
func BuildMemoryPrompt ¶
BuildMemoryPrompt generates the prompt section content from memory store.
func BuildReinjectMessage ¶ added in v0.23.0
func BuildReinjectMessage(items []CriticalContext) string
BuildReinjectMessage formats critical context items into a user message to be appended after the compaction summary.
Types ¶
type CriticalContext ¶ added in v0.23.0
type CriticalContext struct {
// contains filtered or unexported fields
}
CriticalContext holds a re-injectable context item after compaction.
func GatherCriticalContext ¶ added in v0.23.0
func GatherCriticalContext(s *Store) []CriticalContext
GatherCriticalContext reads the memory store for context that should survive compaction. It collects plan content, recent edits, and other high-value facts.
type Extractor ¶
type Extractor struct {
// contains filtered or unexported fields
}
Extractor writes structured facts from each turn to the memory store.
func NewExtractor ¶
NewExtractor creates an extractor backed by the given store.
type Fact ¶
type Fact struct {
Key string `json:"key"`
Value string `json:"value"`
Category string `json:"category,omitzero"`
Relations []string `json:"relations,omitzero"`
Importance int `json:"importance,omitzero"` // 0 = default; higher = more important
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Fact is a single key/value memory entry with optional category and relations.
func Related ¶
Related returns all facts reachable from startKey via relation edges, up to maxDepth hops. Returns empty slice if startKey doesn't exist. maxDepth <= 0 means unlimited (capped at maxGraphDepth to prevent runaway). The startKey itself is excluded from results. Results are sorted by key for deterministic output.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds facts in memory backed by a JSONL file.
func NewStore ¶
NewStore creates a Store whose file path is derived from the sha256 of cwd. Existing facts are loaded if the file is present.
func (*Store) Delete ¶
Delete removes a fact by key, cleans up its relations, and rewrites the file.
func (*Store) List ¶
List returns all facts, optionally filtered by category. Results are sorted by key for deterministic output.
func (*Store) Relate ¶
Relate creates a bidirectional link between two facts. Both keys must exist. Idempotent — duplicate relations are ignored.
func (*Store) SetImportance ¶ added in v0.23.0
SetImportance updates the Importance field of an existing fact. No-op if the key does not exist. Use importance values > 0 to signal higher priority; 0 is the default (unset).
type TurnData ¶
type TurnData struct {
Assistant json.RawMessage `json:"Assistant"`
ToolResults []json.RawMessage `json:"ToolResults"`
}
TurnData represents the relevant data from an EventTurnEnd, parsed from JSON.
type WireMsg ¶ added in v0.23.0
WireMsg is an alias for compact.WireMsg — re-exported for backward compatibility with any callers within the memory package that use the name directly.
type WireToolResult ¶ added in v0.23.0
type WireToolResult = compact.WireToolResult
WireToolResult is an alias for compact.WireToolResult — re-exported for backward compatibility with any callers within the memory package.