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

Function buildAssistantDailyLogPrompt

src/memdir/memdir.ts:326–369  ·  view source on GitHub ↗

* Assistant-mode daily-log prompt. Gated behind feature('KAIROS'). * * Assistant sessions are effectively perpetual, so the agent writes memories * append-only to a date-named log file rather than maintaining MEMORY.md as * a live index. A separate nightly /dream skill distills logs into topic

(skipIndex = false)

Source from the content-addressed store, hash-verified

324 * as the distilled index — this prompt only changes where NEW memories go.
325 */
326function buildAssistantDailyLogPrompt(skipIndex = false): string {
327 const memoryDir = getAutoMemPath()
328 // Describe the path as a pattern rather than inlining today's literal path:
329 // this prompt is cached by systemPromptSection('memory', ...) and NOT
330 // invalidated on date change. The model derives the current date from the
331 // date_change attachment (appended at the tail on midnight rollover) rather
332 // than the user-context message — the latter is intentionally left stale to
333 // preserve the prompt cache prefix across midnight.
334 const logPathPattern = join(memoryDir, 'logs', 'YYYY', 'MM', 'YYYY-MM-DD.md')
335
336 const lines: string[] = [
337 '# auto memory',
338 '',
339 `You have a persistent, file-based memory system found at: \`${memoryDir}\``,
340 '',
341 "This session is long-lived. As you work, record anything worth remembering by **appending** to today's daily log file:",
342 '',
343 `\`${logPathPattern}\``,
344 '',
345 "Substitute today's date (from `currentDate` in your context) for `YYYY-MM-DD`. When the date rolls over mid-session, start appending to the new day's file.",
346 '',
347 'Write each entry as a short timestamped bullet. Create the file (and parent directories) on first write if it does not exist. Do not rewrite or reorganize the log — it is append-only. A separate nightly process distills these logs into `MEMORY.md` and topic files.',
348 '',
349 '## What to log',
350 '- User corrections and preferences ("use bun, not npm"; "stop summarizing diffs")',
351 '- Facts about the user, their role, or their goals',
352 '- Project context that is not derivable from the code (deadlines, incidents, decisions and their rationale)',
353 '- Pointers to external systems (dashboards, Linear projects, Slack channels)',
354 '- Anything the user explicitly asks you to remember',
355 '',
356 ...WHAT_NOT_TO_SAVE_SECTION,
357 '',
358 ...(skipIndex
359 ? []
360 : [
361 `## ${ENTRYPOINT_NAME}`,
362 `\`${ENTRYPOINT_NAME}\` is the distilled index (maintained nightly from your logs) and is loaded into your context automatically. Read it for orientation, but do not edit it directly — record new information in today's log instead.`,
363 '',
364 ]),
365 ...buildSearchingPastContextSection(memoryDir),
366 ]
367
368 return lines.join('\n')
369}
370
371/**
372 * Build the "Searching past context" section if the feature gate is enabled.

Callers 1

loadMemoryPromptFunction · 0.85

Calls 1

Tested by

no test coverage detected