MCPcopy Create free account
hub / github.com/betta-tech/byo-coding-agent / NewSessionFiles

Function NewSessionFiles

internal/memory/sessionfiles.go:45–55  ·  view source on GitHub ↗

NewSessionFiles opens (or creates) the memory directory at root and loads the index. Missing sessions referenced in the index get pruned silently — drift between disk and index is fixed in place instead of surfacing as errors at recall time.

(root string)

Source from the content-addressed store, hash-verified

43// silently — drift between disk and index is fixed in place instead of
44// surfacing as errors at recall time.
45func NewSessionFiles(root string) (*SessionFiles, error) {
46 if err := os.MkdirAll(filepath.Join(root, "sessions"), 0o755); err != nil {
47 return nil, fmt.Errorf("memory: create %s: %w", root, err)
48 }
49 s := &SessionFiles{root: root, sessionStart: time.Now()}
50 if err := s.loadIndex(); err != nil {
51 return nil, err
52 }
53 s.pruneMissing()
54 return s, nil
55}
56
57func (s *SessionFiles) loadIndex() error {
58 data, err := os.ReadFile(filepath.Join(s.root, "index.json"))

Calls 2

loadIndexMethod · 0.95
pruneMissingMethod · 0.95