daemon/README.mdGreat Minds Daemon
The daemon is an Agent SDK-based long-running process that replaces the previous cron-based pipeline. It supersedes pipeline-runner.sh, heartbeat.sh, feature-dream.sh, and memory-maintain.sh.
What It Does
The daemon runs a continuous event loop that:
- Watches for new PRDs in
prds/using chokidar file watcher — triggers the full pipeline instantly - Polls GitHub issues every 5 minutes across all monitored repos
- Runs heartbeat health checks every 5 minutes (site status, git status, memory)
- Runs featureDream every 4 hours when idle (board reviews or brainstorms new products)
- Runs memory maintenance every 6 hours (prunes duplicates, consolidates)
Pipeline Phases
When a PRD is detected, the full GSD pipeline runs:
| Phase | Agents | What Happens |
|---|---|---|
| Debate R1 | Steve + Elon (parallel) | Stake positions on design vs. engineering |
| Debate R2 | Steve + Elon (parallel) | Challenge each other, lock decisions |
| Essence | Rick Rubin | Distill the core idea |
| Consolidation | Phil Jackson | Merge decisions into blueprint |
| Plan | Planner + Sara Blakely | Create build plan + gut-check |
| Build | Builder agent | Execute the plan, produce deliverables |
| QA Pass 1 | Margaret Hamilton | Verify requirements, auto-fix if BLOCK |
| QA Pass 2 | Margaret Hamilton | Integration check |
| Creative Review | Jony Ive + Maya Angelou + Aaron Sorkin | Visual, copy, and demo script |
| Board Review | Jensen + Oprah + Buffett + Shonda | Strategic evaluation |
| Ship | Shipper + Marcus Aurelius | Deploy + retrospective |
Architecture
daemon/
bin/greatminds-daemon Shell launcher
src/
daemon.ts Main event loop (watcher + timers + queue)
pipeline.ts GSD pipeline as TypeScript functions
agents.ts Prompt templates for all 14 personas
dream.ts featureDream cycle (IMPROVE / DREAM)
health.ts Heartbeat, git monitor, memory maintenance
config.ts Paths, intervals, repo list
logger.ts Console + file loggingConfiguration
Edit src/config.ts to change:
- Repo paths
- GitHub repos to monitor
- Sites to health-check
- Polling intervals
- Dream/maintenance intervals
Running Locally vs. on Server
Locally:
cd daemon && npm install && ./bin/greatminds-daemonOn server (with tmux for persistence):
tmux new -s daemon
cd ~/projects/great-minds/daemon
npm install && ./bin/greatminds-daemon
# Ctrl+B, D to detachWith Docker:
cd daemon && docker compose up -dfeatureDream Cycle
When the daemon is idle (no active PRDs), it enters the featureDream cycle every 4 hours. This alternates between two modes:
- IMPROVE — the board reviews existing products and files GitHub issues for improvements
- DREAM — agents brainstorm new product ideas, write speculative PRDs, and evaluate them
Memory Maintenance
Every 6 hours, the daemon consolidates memory: pruning duplicate entries, merging related learnings, and verifying that memory index references still resolve to real files. This keeps the agency's persistent memory lean and accurate.
Logs
Logs write to both console (stdout) and /tmp/claude-shared/daemon.log. When running in Docker, use docker compose logs -f to tail output.
Telegram Notifications
The daemon sends real-time notifications to Telegram for pipeline events: starts, completions, failures, and hung agent detection. This lets you monitor the agency from your phone.
Setup
- Message @BotFather on Telegram and create a new bot (
/newbot) - Copy the bot token
- Send a message to your bot, then fetch your chat ID via
https://api.telegram.org/bot<TOKEN>/getUpdates - Set environment variables (see table below)
What Gets Notified
- Pipeline started (PRD name)
- Pipeline completed (duration, phases)
- Pipeline failed (error, phase, retry count)
- Agent hung (agent name, timeout duration)
- PRD archived to failed (after all retries exhausted)
Crash Recovery
When a pipeline phase fails, the daemon retries it up to 2 times with exponential backoff (30s, then 60s). If all retries are exhausted, the PRD is moved to prds/failed/ so it does not block the queue. A Telegram notification is sent on each failure and on final archival.
Hung Agent Detection
Individual agents are killed if they exceed the agent timeout (default: 10 minutes). The entire pipeline is aborted if it exceeds the pipeline timeout (default: 60 minutes). Hung agents trigger a Telegram alert and the phase is retried or skipped depending on remaining retry budget.
Token Ledger
The daemon tracks token usage and estimated cost per agent across every pipeline run. Use /agency-tokens to view the ledger. This helps identify which agents are expensive and where to optimize prompt size or model choice.
Bug Memory
Known bugs are stored in daemon/buglog.json (currently 8 entries). Agents query the buglog before debugging to avoid re-investigating known issues. New bugs can be added manually or by agents during QA passes.
Environment Variables
| Variable | Default | Description |
|---|---|---|
TELEGRAM_BOT_TOKEN | — | Telegram bot token from BotFather |
TELEGRAM_CHAT_ID | — | Telegram chat ID for notifications |
AGENT_TIMEOUT_MS | 600000 (10 min) | Max time for a single agent call |
PIPELINE_TIMEOUT_MS | 3600000 (60 min) | Max time for the entire pipeline |
Stopping
Send SIGINT (Ctrl+C) or SIGTERM. The daemon will finish its current agent call before exiting gracefully.