MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / add

Method add

core/memory_v2.py:88–107  ·  view source on GitHub ↗

Add or refresh a file in working memory.

(self, file_path: str, content: str, tokens: int)

Source from the content-addressed store, hash-verified

86 self._turn: int = 0
87
88 def add(self, file_path: str, content: str, tokens: int):
89 """Add or refresh a file in working memory."""
90 now = int(time.time())
91 if file_path in self._files:
92 item = self._files[file_path]
93 item.content = content
94 item.tokens = tokens
95 item.last_used_at = now
96 item.last_used_turn = self._turn
97 item.access_count += 1
98 else:
99 self._files[file_path] = WorkingMemoryItem(
100 file_path=file_path,
101 content=content,
102 tokens=tokens,
103 loaded_at=now,
104 last_used_at=now,
105 last_used_turn=self._turn,
106 )
107 self._evict_by_tokens()
108
109 def get(self, file_path: str) -> Optional[str]:
110 """Get file content and mark as recently used."""

Callers 3

load_fileMethod · 0.45
add_to_workingMethod · 0.45
add_to_projectMethod · 0.45

Calls 2

_evict_by_tokensMethod · 0.95
WorkingMemoryItemClass · 0.85

Tested by

no test coverage detected