memory

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	ID        string    `json:"entry_id"`
	CreatedAt time.Time `json:"created_at"`
	Kind      string    `json:"kind"`
	Title     string    `json:"title"`
	Category  string    `json:"category,omitempty"`
	Fields    []Field   `json:"fields"`
	Path      string    `json:"path,omitempty"`
}

Entry 表示单条日记条目。

func (*Entry) Count

func (e *Entry) Count() int

Count 返回累计次数。

func (*Entry) FieldValue

func (e *Entry) FieldValue(key string) string

FieldValue 读取指定字段值。

func (*Entry) Headline

func (e *Entry) Headline() string

Headline 返回条目标题行。

func (*Entry) Markdown

func (e *Entry) Markdown() string

Markdown 渲染为标准 markdown。

func (*Entry) RelatedIDs

func (e *Entry) RelatedIDs() []string

RelatedIDs 返回关联条目列表。

func (*Entry) ReviewItem

func (e *Entry) ReviewItem() ReviewItem

ReviewItem 返回回顾摘要。

func (*Entry) SetCount

func (e *Entry) SetCount(count int)

SetCount 更新次数。

func (*Entry) SetField

func (e *Entry) SetField(key string, value string)

SetField 写入字段值。

func (*Entry) SetRelatedIDs

func (e *Entry) SetRelatedIDs(ids []string)

SetRelatedIDs 更新关联条目。

func (*Entry) SetStatus

func (e *Entry) SetStatus(status string)

SetStatus 更新状态。

func (*Entry) Status

func (e *Entry) Status() string

Status 返回条目状态。

type Factory

type Factory struct{}

Factory 负责生成标准化记忆条目。

func (Factory) Create

func (f Factory) Create(kind string, title string, category string, fields []Field, relatedEntries []*Entry, now time.Time) (*Entry, error)

Create 构建新条目。

func (Factory) InferAutoPromotionTarget

func (Factory) InferAutoPromotionTarget(entry *Entry) string

InferAutoPromotionTarget 推断自动提升目标。

type Field

type Field struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Field 表示记忆条目的有序字段。

type LogResult

type LogResult struct {
	Path           string         `json:"path"`
	EntryID        string         `json:"entry_id"`
	Entry          string         `json:"entry"`
	Status         string         `json:"status"`
	Count          int            `json:"count"`
	RelatedEntries []ReviewItem   `json:"related_entries"`
	Promoted       *PromoteResult `json:"promoted,omitempty"`
}

LogResult 表示记录日记后的结果。

type Parser

type Parser struct{}

Parser 负责把 markdown 日记解析为结构化条目。

func (Parser) Parse

func (Parser) Parse(content string, path string) ([]*Entry, error)

Parse 解析单个 markdown 文件。

type PromoteResult

type PromoteResult struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

PromoteResult 表示长期提升结果。

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository 负责管理 workspace 记忆文件。

func NewRepository

func NewRepository(workspacePath string) *Repository

NewRepository 创建记忆仓储。

func (*Repository) AppendEntry

func (r *Repository) AppendEntry(entry *Entry) (string, error)

AppendEntry 把条目追加到今日日志。

func (*Repository) AppendToMemorySection

func (r *Repository) AppendToMemorySection(filename string, sectionTitle string, bullet string) (string, error)

AppendToMemorySection 向长期文件追加规则。

func (*Repository) ListRecentEntries

func (r *Repository) ListRecentEntries(days int, limit int) ([]*Entry, error)

ListRecentEntries 返回近期条目。

func (*Repository) ReadSlice

func (r *Repository) ReadSlice(relativePath string, fromLine int, lines int) (*Slice, error)

ReadSlice 读取文件片段。

func (*Repository) Search

func (r *Repository) Search(query string, limit int) ([]SearchMatch, error)

Search 在记忆文件中做关键词检索。

func (*Repository) UpdateEntry

func (r *Repository) UpdateEntry(entryID string, updater func(*Entry)) (*Entry, error)

UpdateEntry 更新指定条目。

type ReviewItem

type ReviewItem struct {
	EntryID  string `json:"entry_id"`
	Path     string `json:"path"`
	Headline string `json:"headline"`
	Kind     string `json:"kind"`
	Status   string `json:"status"`
	Count    int    `json:"count"`
}

ReviewItem 表示近期回顾条目的摘要。

type SearchMatch

type SearchMatch struct {
	Path    string `json:"path"`
	Line    int    `json:"line"`
	Content string `json:"content"`
}

SearchMatch 表示检索结果。

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service 负责检索、记录、提升和流转工作区记忆。

func NewService

func NewService(workspacePath string) *Service

NewService 创建记忆服务。

func (*Service) BuildReviewMarkdown

func (s *Service) BuildReviewMarkdown(days int, limit int, maxChars int) (string, error)

BuildReviewMarkdown 构造注入 prompt 的近期摘要。

func (*Service) Get

func (s *Service) Get(relativePath string, fromLine int, lines int) (*Slice, error)

Get 读取文件片段。

func (*Service) Log

func (s *Service) Log(kind string, title string, category string, fields []Field, promoteTarget string) (*LogResult, error)

Log 记录今日日记。

func (*Service) Promote

func (s *Service) Promote(target string, content string, title string, entryID string) (*PromoteResult, error)

Promote 把经验提升到长期文件。

func (*Service) ResolveEntry

func (s *Service) ResolveEntry(entryID string, note string) (*ReviewItem, error)

ResolveEntry 把条目标记为已解决。

func (*Service) ReviewRecentEntries

func (s *Service) ReviewRecentEntries(days int, limit int) ([]ReviewItem, error)

ReviewRecentEntries 返回近期日记摘要。

func (*Service) Search

func (s *Service) Search(query string, limit int) ([]SearchMatch, error)

Search 执行关键词检索。

func (*Service) SetEntryStatus

func (s *Service) SetEntryStatus(entryID string, status string, note string) (*ReviewItem, error)

SetEntryStatus 更新条目状态。

type SimilarityMatcher

type SimilarityMatcher struct{}

SimilarityMatcher 负责发现相似条目。

func (SimilarityMatcher) FindRelated

func (SimilarityMatcher) FindRelated(target *Entry, candidates []*Entry, limit int) []*Entry

FindRelated 返回相似条目。

type Slice

type Slice struct {
	Path     string `json:"path"`
	FromLine int    `json:"from_line"`
	ToLine   int    `json:"to_line"`
	Content  string `json:"content"`
}

Slice 表示文件片段。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL