- Add message.groups to required bot events in README
- Add groups:history and groups:read to required scopes in README
- app_mention handler now logs messages directly instead of relying on message event
- Add deduplication in ChannelStore.logMessage() to prevent double-logging
- Remove redundant current message append in agent.ts (already in log)
- Add getLastTimestamp() to ChannelStore to read last ts from log.jsonl
- Add backfillChannel() to fetch up to 3 pages (3000 messages) per channel
- Add backfillAllChannels() called in start() before socket connection
- Include mom's own messages (as bot) and user messages, exclude other bots
- Process attachments from backfilled messages
- Add logging: logBackfillStart, logBackfillChannel, logBackfillComplete
- Warn if attachment missing name instead of failing
fixes#103
Major improvements to mom's logging and cost reporting:
Centralized Logging System:
- Add src/log.ts with type-safe logging functions
- Colored console output (green=user, yellow=mom, dim=details)
- Consistent format: [HH:MM:SS] [context] message
- Replace scattered console.log/error calls throughout codebase
Usage Tracking & Cost Reporting:
- Track tokens (input, output, cache read/write) and costs per run
- Display summary at end of each run in console and Slack thread
- Example: 💰 Usage: 12,543 in + 847 out (5,234 cache read) = $0.0234
Prompt Caching Optimization:
- Move recent messages from system prompt to user message
- System prompt now mostly static (only changes with memory files)
- Enables effective use of Anthropic's prompt caching
- Significantly reduces costs on subsequent requests
Model & Cost Improvements:
- Switch from Claude Opus 4.5 to Sonnet 4.5 (~40% cost reduction)
- Fix Claude Opus 4.5 cache pricing in ai package (was 3x too expensive)
- Add manual override in generate-models.ts until upstream fix merges
- Submitted PR to models.dev: https://github.com/sst/models.dev/pull/439
UI/UX Improvements:
- Extract actual text from tool results instead of JSON wrapper
- Cleaner Slack thread formatting with duration and labels
- Tool args formatting shows paths with offset:limit notation
- Add chalk for colored terminal output
Dependencies:
- Add chalk package for terminal colors
- Add MEMORY.md files for persistent working memory
- Global memory: workspace/MEMORY.md (shared across channels)
- Channel memory: workspace/<channel>/MEMORY.md (channel-specific)
- Automatically loaded into system prompt on each request
- Enhance JSONL log format with ISO 8601 dates
- Add 'date' field for easy grepping (e.g., grep '"date":"2025-11-26"')
- Migrated existing logs to include date field
- Improve log query efficiency
- Add jq query patterns to prevent context overflow
- Emphasize limiting NUMBER of messages (10-50), not truncating text
- Show full message text and attachments in queries
- Handle null/empty attachments with (.attachments // [])
- Optimize system prompt
- Add current date/time for date-aware operations
- Format recent messages as TSV (43% token savings vs raw JSONL)
- Add efficient query examples with both JSON and TSV output
- Enhanced security documentation
- Add prompt injection risk warnings
- Document credential exfiltration scenarios
- Provide mitigation strategies