* 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)
| 325 | * as the distilled index — this prompt only changes where NEW memories go. |
| 326 | */ |
| 327 | function buildAssistantDailyLogPrompt(skipIndex = false): string { |
| 328 | const memoryDir = getAutoMemPath() |
| 329 | // Describe the path as a pattern rather than inlining today's literal path: |
| 330 | // this prompt is cached by systemPromptSection('memory', ...) and NOT |
| 331 | // invalidated on date change. The model derives the current date from the |
| 332 | // date_change attachment (appended at the tail on midnight rollover) rather |
| 333 | // than the user-context message — the latter is intentionally left stale to |
| 334 | // preserve the prompt cache prefix across midnight. |
| 335 | const logPathPattern = join(memoryDir, 'logs', 'YYYY', 'MM', 'YYYY-MM-DD.md') |
| 336 | |
| 337 | const lines: string[] = [ |
| 338 | '# auto memory', |
| 339 | '', |
| 340 | `You have a persistent, file-based memory system found at: \`${memoryDir}\``, |
| 341 | '', |
| 342 | "This session is long-lived. As you work, record anything worth remembering by **appending** to today's daily log file:", |
| 343 | '', |
| 344 | `\`${logPathPattern}\``, |
| 345 | '', |
| 346 | "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.", |
| 347 | '', |
| 348 | '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.', |
| 349 | '', |
| 350 | '## What to log', |
| 351 | '- User corrections and preferences ("use bun, not npm"; "stop summarizing diffs")', |
| 352 | '- Facts about the user, their role, or their goals', |
| 353 | '- Project context that is not derivable from the code (deadlines, incidents, decisions and their rationale)', |
| 354 | '- Pointers to external systems (dashboards, Linear projects, Slack channels)', |
| 355 | '- Anything the user explicitly asks you to remember', |
| 356 | '', |
| 357 | ...WHAT_NOT_TO_SAVE_SECTION, |
| 358 | '', |
| 359 | ...(skipIndex |
| 360 | ? [] |
| 361 | : [ |
| 362 | `## ${ENTRYPOINT_NAME}`, |
| 363 | `\`${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.`, |
| 364 | '', |
| 365 | ]), |
| 366 | ...buildSearchingPastContextSection(memoryDir), |
| 367 | ] |
| 368 | |
| 369 | return lines.join('\n') |
| 370 | } |
| 371 | |
| 372 | /** |
| 373 | * Build the "Searching past context" section if the feature gate is enabled. |
no test coverage detected