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

Function buildSearchingPastContextSection

src/memdir/memdir.ts:374–403  ·  view source on GitHub ↗
(autoMemDir: string)

Source from the content-addressed store, hash-verified

372 * Build the "Searching past context" section if the feature gate is enabled.
373 */
374export function buildSearchingPastContextSection(autoMemDir: string): string[] {
375 if (!getFeatureValue_CACHED_MAY_BE_STALE('ncode_coral_fern', false)) {
376 return []
377 }
378 const projectDir = getProjectDir(getOriginalCwd())
379 // Ant-native builds alias grep to embedded ugrep and remove the dedicated
380 // Grep tool, so give the model a real shell invocation there.
381 const embedded = hasEmbeddedSearchTools()
382 const memSearch = embedded
383 ? `grep -rn "<search term>" ${autoMemDir} --include="*.md"`
384 : `${GREP_TOOL_NAME} with pattern="<search term>" path="${autoMemDir}" glob="*.md"`
385 const transcriptSearch = embedded
386 ? `grep -rn "<search term>" ${projectDir}/ --include="*.jsonl"`
387 : `${GREP_TOOL_NAME} with pattern="<search term>" path="${projectDir}/" glob="*.jsonl"`
388 return [
389 '## Searching past context',
390 '',
391 'When looking for past context:',
392 '1. Search topic files in your memory directory:',
393 '```',
394 memSearch,
395 '```',
396 '2. Session transcript logs (last resort — large files, slow):',
397 '```',
398 transcriptSearch,
399 '```',
400 'Use narrow search terms (error messages, file paths, function names) rather than broad keywords.',
401 '',
402 ]
403}
404
405/**
406 * Load the unified memory prompt for inclusion in the system prompt.

Callers 3

buildMemoryLinesFunction · 0.85

Calls 4

getOriginalCwdFunction · 0.85
hasEmbeddedSearchToolsFunction · 0.85
getProjectDirFunction · 0.50

Tested by

no test coverage detected