GitHunt

Sleep Digest Bot ๐ŸŒ™

Standalone Telegram bot that collects OpenClaw conversation transcripts nightly,
generates intelligent summaries via Doudou (OpenClaw AI agent), and writes
them to an Obsidian vault for archival.

AI agents: read AGENTS.md first.


Commands

Command Description
/digest Start or update nightly digest
/sleep Run reflection, finalize, goodnight
/status Check current state
/reflect Re-run reflection on latest digest

Architecture

โ†’ Full details: docs/architecture/overview.md

Telegram โ†’ main.py โ†’ collector.py โ†’ collection_engine.py (parallel)
                                         โ†“
                                    llm.py โ†’ openclaw agent (per session)
                                         โ†“
                                    recorder.py โ†’ Obsidian vault
                                         โ†“ (/sleep)
                                    reflection.py โ†’ workspace memory files

Development

5-Step Lifecycle (Mandatory)

  1. Intake โ€” PRD in specs/, assign DIGEST-XXX ID
  2. TDD โ€” Write failing tests first
  3. Implement โ€” Make tests green
  4. E2E โ€” python3 tests/run_e2e.py --verbose
  5. Deploy โ€” launchctl kickstart -k gui/$(id -u)/com.digest-bot

Quick Commands

# Unit tests (run files individually โ€” bulk hangs on async)
python3 -m pytest tests/test_recorder.py -v
python3 -m pytest tests/test_reflection.py -v
python3 -m pytest tests/test_collection_engine.py -v
python3 -m pytest tests/test_derived_sessions.py -v

# E2E (bot must be running, Telegram Desktop open)
python3 tests/run_e2e.py --verbose
python3 tests/run_e2e.py --test collection

# Restart
launchctl kickstart -k gui/$(id -u)/com.digest-bot

# Logs
tail -f /tmp/digest-bot.log

Project Structure

digest-bot/
โ”œโ”€โ”€ AGENTS.md            # AI agent onboarding (read first)
โ”œโ”€โ”€ README.md            # This file
โ”œโ”€โ”€ TODO.md              # Work tracking (active + completed)
โ”œโ”€โ”€ main.py              # Bot entry, commands, state machine
โ”œโ”€โ”€ collector.py         # Transcript reader + message extractor
โ”œโ”€โ”€ collection_engine.py # Parallel, retriable collection
โ”œโ”€โ”€ llm.py               # LLM interface (sync + async)
โ”œโ”€โ”€ recorder.py          # Digest file writer (YAML + markdown)
โ”œโ”€โ”€ reflection.py        # Nightly reflection orchestration
โ”œโ”€โ”€ config.py            # Constants, paths, SGT timezone
โ”œโ”€โ”€ scheduler.py         # APScheduler: timed collections
โ”œโ”€โ”€ stt.py               # Voice transcription (Whisper)
โ”‚
โ”œโ”€โ”€ specs/               # Active PRDs only
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ architecture/    # System design, format spec, testing strategy
โ”‚   โ””โ”€โ”€ completed/       # Archived PRDs and historical specs
โ”œโ”€โ”€ tests/               # Unit (test_*.py) + E2E (run_e2e.py)
โ””โ”€โ”€ scripts/             # Utilities

Service

Item Value
LaunchAgent ~/Library/LaunchAgents/com.digest-bot.plist
Log /tmp/digest-bot.log
Git remote github-digest:boyangwang/digest.git
Output NotesVault/Artificial-Colloquia/Doudou-Digest/

PRD Template

# DIGEST-XXX: <Title>

> **Status:** ๐Ÿ”ด Draft
> **Priority:** P1
> **Tasks:** 0/N complete
> **Created:** YYYY-MM-DD

## Problem Statement
## Tasks
- [ ] **T1** โ€” description
## Acceptance Criteria
## Files to Modify

Test counts: 159 (134 unit/integration + 25 E2E) โ€” 2026-03-03

boyangwang/digest | GitHunt