Skip to content

feat: inject the most recent daily logs instead of today and yesterday - #67

Open
pstanton237 wants to merge 1 commit into
jayzeng:mainfrom
pstanton237:feat/recent-daily-logs
Open

pstanton237 wants to merge 1 commit into
jayzeng:mainfrom
pstanton237:feat/recent-daily-logs

Conversation

@pstanton237

Copy link
Copy Markdown

Summary

Context injection picked daily logs by calendar date (today and yesterday). After a weekend or time off, both slots were empty, so the first session back had no daily log in context. This PR injects the N most recent non-empty daily logs up to today instead, skipping days without a log.

Fixes #66.

Approach

  • The newest log takes the slot that today's log had (before search results and MEMORY.md). The remaining logs go after MEMORY.md, newest first, so the 16K total cap trims the oldest ones first. Priority order is otherwise unchanged.
  • Headings keep the real date. (today) and (yesterday) are added only when they are true, so a Friday log seen on Monday is not labeled "yesterday".
  • PI_MEMORY_DAILY_LOGS sets N (default 2, 0 disables daily-log injection). Empty or invalid values fall back to the default. The value is shown in memory_status.
  • Future-dated files (e.g. after a timezone change), whitespace-only files, and non-date filenames in daily/ are ignored.

Compatibility: with the default, a user who has logs for both today and yesterday gets the same context as before. No change to the on-disk format or qmd behavior. Each context build now lists daily/, which is one readdir.

Verification

  • New unit tests (weekend gap, today plus the last earlier log, ordering with N=3, 0 disables, ignored files, env parsing) failed before the change and pass after.
  • bun test test/unit.test.ts (203 passed)
  • npm run build
  • npm run lint
  • Ran the patched extension in a real session where the previous calendar day had no log. Injected headings were 2026-11-17 (today) and 2026-11-15.

README (context injection list and env table) and CHANGELOG [Unreleased] are updated.

Context injection read daily/<today>.md and daily/<yesterday>.md by
calendar date. A day without a log (weekend, time off) left the slot
empty, so the first session on a Monday got no daily log at all and the
Friday context was gone.

Pick the N most recent non-empty logs up to today instead. The newest
keeps today's priority slot; the rest go after MEMORY.md, newest first.
PI_MEMORY_DAILY_LOGS sets N (default 2, 0 disables daily injection).

Signed-off-by: pstanton237 <4250687+pstanton237@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Daily-log injection is empty after a weekend or time off

1 participant