Add optional digest companion app (recent-memory summaries to Slack/Discord)#59
Merged
Conversation
…iscord) A separate, port-less CapRover app (mirrors backup/) that periodically pulls recent memories from the REST API, optionally summarizes them with Claude, and posts the result to a Slack or Discord incoming webhook. Adapts the OB1 project's daily/weekly digest recipe to this server. - digest/digest.py: pure, unit-testable helpers (parse_timestamp, filter_recent, build_digest with Claude-or-plain-list fallback, webhook formatting) + a main() that wires fetch -> filter -> summarize -> deliver. Self-contained (httpx only). - digest/entrypoint.sh: snapshots env for cron, builds the crontab from $DIGEST_CRON (default daily 08:00 UTC), optional run-on-start, streams the log. - digest/Dockerfile (python:3.12-alpine + dcron), requirements.txt, captain-definition. - tests/test_digest.py: 17 cases (pure helpers + respx-mocked fetch/summarize/ deliver + main wiring for deliver and empty-skip paths). - docs: USER_GUIDE deploy section (env table, cost note, docker run) + troubleshooting row; DEVELOPER_GUIDE layout; CLAUDE.md companion-app note. Closes #50. https://claude.ai/code/session_017835DVrvURaYnbQiPQwzue
There was a problem hiding this comment.
Pull request overview
Adds a new optional digest/ companion cron container that periodically fetches recent memories via the existing REST API, optionally summarizes them with Anthropic Claude, and posts the result to a Slack/Discord webhook (plus docs + tests to support deployment and behavior).
Changes:
- Introduces the standalone
digest/CapRover app (Dockerfile, entrypoint cron wiring, anddigest.pyhelpers +main()). - Adds a dedicated pytest suite for the digest behavior (pure helpers + respx-mocked network behavior).
- Updates user/developer documentation to describe deploying and operating the new digest companion app.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
digest/digest.py |
Implements digest fetching/filtering/summarization/delivery logic and env-driven main(). |
digest/entrypoint.sh |
Cron container entrypoint: snapshots env, writes crontab, optional run-on-start, tails log. |
digest/Dockerfile |
Builds minimal Python + dcron Alpine image for the digest companion app. |
digest/requirements.txt |
Pins digest app runtime dependency (httpx). |
digest/captain-definition |
CapRover build descriptor for the digest app. |
digest/__init__.py |
Marks digest/ as a package for test imports. |
tests/test_digest.py |
Adds unit/integration-style tests (helpers + HTTP interactions via respx). |
docs/USER_GUIDE.md |
Documents optional digest deployment/configuration and troubleshooting. |
docs/DEVELOPER_GUIDE.md |
Updates project layout documentation to include digest/. |
CLAUDE.md |
Notes the new digest companion app in the repo overview. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- digest.py: the REST list endpoint caps limit at 100, but DIGEST_MAX_MEMORIES defaulted to 200 — every run with defaults would 422. Default to 100 and clamp via a new _int_env() helper that also handles unparseable values gracefully. Update the module docstring accordingly. - entrypoint.sh: env vars can contain spaces (DIGEST_CRON, DIGEST_TITLE) and quotes, which broke the raw `printenv` env file when sourced by the cron job. Emit single-quote-escaped `export` lines instead, and chmod 600 the file since it holds MEM0_API_KEY. - tests: _int_env clamp/default/bad-value cases + main() requests limit<=100. - docs: USER_GUIDE DIGEST_MAX_MEMORIES row (default 100, server cap noted); DEVELOPER_GUIDE digest layout bullets de-swapped and clarified. https://claude.ai/code/session_017835DVrvURaYnbQiPQwzue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional digest companion app that periodically posts a summary of recently added memories to a Slack or Discord channel — a lightweight way to resurface what you've been capturing. Adapts the OB1 / Open Brain daily/weekly digest recipe (backlog issue #50) to this server.
It's a separate, port-less CapRover app built from
digest/, mirroring the existingbackup/app's cron-container pattern (so it can't destabilize the stateless main API).How it works
Each scheduled run:
fetch recent memories (REST) → filter to the look-back window → summarize (Claude, optional) → post to webhook.ANTHROPIC_API_KEYis unset, the digest is a plain bulleted list (zero added cost). If set, it's one Claude call per run.textvscontent), overridable.httpx(already pinned); nothing fromapp/or the main image.DIGEST_CRON, default daily 08:00 UTC);DIGEST_RUN_ON_START=truetriggers an immediate run to verify config.Files
digest/digest.py— pure, unit-testable helpers (parse_timestamp,memory_text,filter_recent,summarize_with_claude,build_digestwith graceful fallback,format_payload/detect_format,fetch_memories,deliver) plusmain().digest/entrypoint.sh— snapshots env for cron (crond jobs don't inherit it), builds/etc/crontabs/rootfrom$DIGEST_CRON, optional run-on-start, streams the log to stdout.digest/Dockerfile(python:3.12-alpine+dcron),requirements.txt,captain-definition.Tests
tests/test_digest.py— 17 cases: timestamp parsing (Z/naive/bad),filter_recent(recent vs old vs missing-timestamp,updated_atpreference), text extraction, prompt/format/detect helpers, and respx-mockedfetch_memories(bearer + limit),deliver,summarize_with_claude(headers + parsing),build_digest(Claude path, no-key fallback, error fallback), andmain()wiring (delivers when recent; skips when nothing new).ruffclean.entrypoint.shpassessh -n, crontab line generates correctly, and print-mode (no webhook) renders the fallback digest.Docs
docker runexample for non-CapRover hosts; plus a troubleshooting row.Architecture notes
No changes to the main app, its invariants, or runtime deps. The digest is a read-only REST consumer in its own container.
Closes #50.
https://claude.ai/code/session_017835DVrvURaYnbQiPQwzue
Generated by Claude Code