MCPcopy Create free account
hub / github.com/Noumena-Network/code / loadAgentMemoryPrompt

Function loadAgentMemoryPrompt

src/tools/AgentTool/agentMemory.ts:188–227  ·  view source on GitHub ↗
(
  agentType: string,
  scope: AgentMemoryScope,
)

Source from the content-addressed store, hash-verified

186 * @param scope 'user' for ~/.ncode/agent-memory/ (preferred) or 'project' for .ncode/agent-memory/ (preferred)
187 */
188export function loadAgentMemoryPrompt(
189 agentType: string,
190 scope: AgentMemoryScope,
191): string {
192 let scopeNote: string
193 switch (scope) {
194 case 'user':
195 scopeNote =
196 '- Since this memory is user-scope, keep learnings general since they apply across all projects'
197 break
198 case 'project':
199 scopeNote =
200 '- Since this memory is project-scope and shared with your team via version control, tailor your memories to this project'
201 break
202 case 'local':
203 scopeNote =
204 '- Since this memory is local-scope (not checked into version control), tailor your memories to this project and machine'
205 break
206 }
207
208 const memoryDir = getAgentMemoryDir(agentType, scope)
209
210 // Fire-and-forget: this runs at agent-spawn time inside a sync
211 // getSystemPrompt() callback (called from React render in AgentDetail.tsx,
212 // so it cannot be async). The spawned agent won't try to Write until after
213 // a full API round-trip, by which time mkdir will have completed. Even if
214 // it hasn't, FileWriteTool does its own mkdir of the parent directory.
215 void ensureMemoryDirExists(memoryDir)
216
217 const coworkExtraGuidelines =
218 process.env.CLAUDE_COWORK_MEMORY_EXTRA_GUIDELINES
219 return buildMemoryPrompt({
220 displayName: 'Persistent Agent Memory',
221 memoryDir,
222 extraGuidelines:
223 coworkExtraGuidelines && coworkExtraGuidelines.trim().length > 0
224 ? [scopeNote, coworkExtraGuidelines]
225 : [scopeNote],
226 })
227}

Callers 4

parseAgentFromJsonFunction · 0.85
parseAgentFromMarkdownFunction · 0.85
MemoryStepFunction · 0.85
loadAgentFromFileFunction · 0.85

Calls 3

getAgentMemoryDirFunction · 0.85
ensureMemoryDirExistsFunction · 0.85
buildMemoryPromptFunction · 0.85

Tested by

no test coverage detected