Skip to content

feat: source file tracking and invocation logging#1

Merged
rolandmarg merged 2 commits intomainfrom
feat/source-tracking-and-logging
Apr 1, 2026
Merged

feat: source file tracking and invocation logging#1
rolandmarg merged 2 commits intomainfrom
feat/source-tracking-and-logging

Conversation

@rolandmarg
Copy link
Copy Markdown
Owner

Summary

  • Source tracking: Each <entry> in the injected XML now includes a source attribute with the relative file path (.claude/lorebook/foo.md or ~/.claude/lorebook/foo.md). Matched entries are also printed to stderr so the user sees what loaded in their terminal.
  • Invocation logging: New JSONL log at ~/.claude/lorebook/lorebook.log. Each line records timestamp, full prompt, and matched entry headers (name, source, keywords). Only logs when at least one entry matched. Fire-and-forget — never breaks the hook.

Test plan

  • All 43 existing + new tests pass (bun test)
  • Typecheck passes (bun run typecheck)
  • Manual: run lorebook test "some prompt" and verify source attribute appears in XML
  • Manual: run via Claude Code hook and verify stderr shows [lorebook] lines
  • Manual: check ~/.claude/lorebook/lorebook.log after a matched invocation

🤖 Generated with Claude Code

rolandmarg and others added 2 commits March 31, 2026 23:44
Two features: (1) add file path to entry XML and stderr output,
(2) JSONL log file for auditing matched invocations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add filePath to LorebookEntry, display relative paths in XML source attribute
- Print matched entries to stderr so user sees what loaded
- New src/log.ts: JSONL log at ~/.claude/lorebook/lorebook.log (matches-only)
- Log records prompt, matched entry headers (name, source, keywords)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rolandmarg rolandmarg merged commit 31ef7fd into main Apr 1, 2026
1 check passed
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.

1 participant