MCPcopy Create free account
hub / github.com/astercloud/aster / GetSummary

Method GetSummary

pkg/memory/project/file_store.go:142–172  ·  view source on GitHub ↗

GetSummary 获取摘要(用于 AI 上下文注入)

(ctx context.Context, projectID string)

Source from the content-addressed store, hash-verified

140
141// GetSummary 获取摘要(用于 AI 上下文注入)
142func (s *FileStore) GetSummary(ctx context.Context, projectID string) (string, error) {
143 memory, err := s.Load(ctx, projectID)
144 if err != nil {
145 return "", err
146 }
147
148 var sb strings.Builder
149 sb.WriteString("## 项目记忆摘要\n\n")
150
151 // 用户偏好
152 prefs := memory.GetEntries(SectionPreferences)
153 if len(prefs) > 0 {
154 sb.WriteString("### 用户偏好\n")
155 for _, e := range prefs {
156 sb.WriteString(fmt.Sprintf("- [%s] %s\n", e.Category, e.Content))
157 }
158 sb.WriteString("\n")
159 }
160
161 // 关键选择
162 choices := memory.GetEntries(SectionChoices)
163 if len(choices) > 0 {
164 sb.WriteString("### 关键选择\n")
165 for _, e := range choices {
166 sb.WriteString(fmt.Sprintf("- %s\n", e.Content))
167 }
168 sb.WriteString("\n")
169 }
170
171 return sb.String(), nil
172}
173
174// GetVersionHistory 获取版本历史(文件存储不支持,返回空)
175func (s *FileStore) GetVersionHistory(ctx context.Context, projectID string, limit int) ([]*ProjectMemory, error) {

Callers

nothing calls this directly

Calls 3

LoadMethod · 0.95
GetEntriesMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected