MCPcopy Create free account
hub / github.com/MatterAIOrg/OrbCode / renderMemorySection

Function renderMemorySection

src/memory/loader.ts:150–173  ·  view source on GitHub ↗
(files: MemoryFile[])

Source from the content-addressed store, hash-verified

148
149/** Render the memory files into a single system-prompt section. */
150export function renderMemorySection(files: MemoryFile[]): string {
151 const valid = files.filter((f) => f.content.trim())
152 if (valid.length === 0) return ""
153 const parts: string[] = [
154 "# Project & User Instructions (AGENTS.md)",
155 "",
156 "Instructions from AGENTS.md files are shown below. Adhere to these instructions; they override default behavior. Treat them as authoritative guidance from the user about this codebase.",
157 "",
158 ]
159 let total = 0
160 for (const file of valid) {
161 if (total >= MAX_TOTAL_CHARS) {
162 parts.push("… (remaining memory files truncated to stay within context budget)")
163 break
164 }
165 const label = labelFor(file)
166 parts.push(`## ${label}: \`${file.path}\``)
167 parts.push("")
168 parts.push(file.content.trim())
169 parts.push("")
170 total += file.content.length
171 }
172 return parts.join("\n")
173}
174
175function labelFor(file: MemoryFile): string {
176 switch (file.type) {

Callers 1

buildSystemPromptFunction · 0.85

Calls 1

labelForFunction · 0.85

Tested by

no test coverage detected