Skip to content

imitry/second-brain-gemini

Repository files navigation

Agent Second Brain

License: MIT Stars Forks

Agent Second Brain

A voice-first AI assistant that turns your Telegram messages into an organized knowledge base. Send voice notes, text, photos, or forwarded messages β€” the agent classifies everything, creates tasks in Todoist, saves thoughts to an Obsidian vault, tracks your goals, and sends you a daily report. Your personal second brain that runs 24/7 on a $5 VPS.

πŸ‡·πŸ‡Ί Π§ΠΈΡ‚Π°Ρ‚ΡŒ Π½Π° русском


What's New in v2

  • Conversational Agent β€” Talk to the bot like a real assistant. No need to press buttons β€” just send a voice note or text message and have a natural dialogue. Ask follow-up questions, clarify, change your mind. The agent remembers context within the session and has full access to your vault, goals, and Todoist.
  • Agent Memory β€” Ebbinghaus forgetting curve with tiered decay. Memory cards move through tiers (core / active / warm / cold / archive) based on access patterns and time.
  • Vault Health β€” Automated health scoring, Map of Content (MOC) generation, broken link repair, and orphan detection across your entire vault.
  • 3-Phase Pipeline β€” Processing is now split into CAPTURE, EXECUTE, and REFLECT phases with structured JSON handoff between each stage.
  • Processing Rules β€” Configurable formatting rules for Obsidian markdown and weekly reflections.
  • Memory Config β€” .memory-config.json file for fine-tuning decay rates, tier thresholds, and type inference rules.

Architecture

Telegram (voice / text / photo / forwarded messages)
    |
    v
Telegram Bot (Node.js) --> Deepgram (voice-to-text)
    |
    v
Gemini CLI (--approval-mode yolo --sandbox false)
    |
    v
+-- CAPTURE: classify entries --> JSON
+-- EXECUTE: Todoist tasks + vault writes --> JSON
+-- REFLECT: HTML report + MEMORY update
    |
    v
+-- Todoist (tasks)
+-- Obsidian vault (thoughts, CRM, goals)
+-- Telegram (HTML report)
+-- GitHub (git push)

The bot runs as a systemd service on a VPS. A daily timer (21:00 UTC) triggers the 3-phase processing pipeline via scripts/process.sh. Each phase receives the previous phase's output as structured JSON, ensuring reliable handoff and auditability.


Skills Catalog

Skill Purpose
dbrain-processor Core pipeline: classify voice/text entries, create tasks, save thoughts
agent-memory Ebbinghaus decay engine: tiered search, creative recall, memory stats
vault-health Health scoring, MOC generation, link repair, orphan detection
graph-builder Knowledge graph analysis, entity relationships, domain mapping
todoist-ai Task management via mcp-cli (Todoist MCP integration)

Skills live in vault/.gemini/skills/ and are invoked automatically by Gemini CLI during processing.

Want just the memory engine? See agent-memory-skill β€” standalone, zero dependencies.


Quick Start

1. Fork this repo

Go to github.com/imitry/second-brain-gemini and click Fork. Make the fork private β€” it will contain your personal data.

2. Clone to your machine

git clone https://github.com/YOUR_USERNAME/second-brain-gemini.git
cd second-brain-gemini

3. Fill in templates

Open the following files and replace the placeholders with your information:

  • vault/goals/0-vision-3y.md β€” 3-year vision
  • vault/goals/1-yearly.md β€” yearly goals
  • vault/goals/2-monthly.md β€” monthly priorities
  • vault/goals/3-weekly.md β€” weekly focus (ONE Big Thing)
  • vault/.gemini/skills/dbrain-processor/references/about.md β€” your profile
  • vault/.gemini/skills/dbrain-processor/references/classification.md β€” entry categories

4. Get API keys

Token Where to get it
Telegram Bot Token @BotFather in Telegram
Your Telegram ID @userinfobot in Telegram
Deepgram API Key console.deepgram.com
Todoist API Token todoist.com β†’ Settings β†’ Integrations β†’ Developer

5. Deploy with Docker

We recommend deploying using Docker or Coolify for a fast and reproducible setup.

All detailed options, including manual VPS setup and Coolify deployment, can be found in the docs:

Short version (Docker):

  1. Create a docker-compose.yml based on the repository structure.
  2. Provide your .env file credentials.
  3. Run docker-compose up -d.

Configuration

File Purpose
.env API tokens for Telegram, Deepgram, Todoist (copy from .env.example)
.memory-config.json Decay rates, tier thresholds, type inference rules for agent memory
mcp-config.json MCP server configuration (Todoist and other integrations)
vault/.gemini/GEMINI.md Agent instructions, session bootstrap sequence, navigation rules
vault/.gemini/skills/dbrain-processor/references/about.md Your personal profile β€” helps the agent understand context

All secrets go into .env which is gitignored. Never commit API tokens to the repository.


Vault Structure

vault/
β”œβ”€β”€ daily/              # Daily entries (voice transcripts, notes)
β”œβ”€β”€ goals/              # Vision, yearly, monthly, weekly goals
β”œβ”€β”€ business/
β”‚   β”œβ”€β”€ crm/            # Client cards
β”‚   └── network/        # Professional contacts
β”œβ”€β”€ projects/
β”‚   β”œβ”€β”€ clients/        # Client project notes
β”‚   └── leads/          # Sales pipeline
β”œβ”€β”€ thoughts/
β”‚   β”œβ”€β”€ ideas/          # Ideas and brainstorms
β”‚   β”œβ”€β”€ learnings/      # Lessons learned
β”‚   └── reflections/    # Personal reflections
β”œβ”€β”€ templates/          # Card templates (CRM, daily)
β”œβ”€β”€ MOC/                # Maps of Content (auto-generated)
β”œβ”€β”€ MEMORY.md           # Long-term memory (hot context)
└── .gemini/            # Agent configuration
    β”œβ”€β”€ skills/         # 5 skills (processor, memory, health, graph, todoist)
    β”œβ”€β”€ rules/          # Formatting rules (obsidian-markdown, weekly-reflection)
    └── docs/           # Reference documentation

The vault follows a Zettelkasten-inspired structure. Each domain has an _index.md hub file. Navigation starts from hubs and follows wiki-links.


How It Works

3-Phase Pipeline

The daily processing pipeline runs in three isolated phases:

  1. CAPTURE β€” Reads daily/YYYY-MM-DD.md, classifies each entry (task, thought, idea, CRM update, goal progress), and outputs structured JSON.
  2. EXECUTE β€” Takes the classification JSON, creates Todoist tasks, writes vault files, updates CRM cards, and outputs an execution report as JSON.
  3. REFLECT β€” Generates an HTML summary report, updates MEMORY.md with key decisions, and sends the report to Telegram.

Each phase runs as a separate Gemini CLI invocation. JSON is passed between phases via files, ensuring clean boundaries and debuggability.

Memory Decay

Agent memory follows the Ebbinghaus forgetting curve with linear decay:

  • Decay rate: 0.015 per day
  • Floor: 0.1 (memories never fully disappear)
  • Formula: strength = max(floor, initial - rate * days_since_access)

Memory cards move through five tiers based on their current strength:

Tier Strength Range Behavior
core 0.9 - 1.0 Always loaded into context
active 0.7 - 0.9 Included in heartbeat searches
warm 0.4 - 0.7 Included in normal searches
cold 0.1 - 0.4 Only in deep searches
archive 0.0 - 0.1 Candidates for creative recall

Tiered Search

Different search depths retrieve different tiers:

  • heartbeat β€” core + active (fast, low-cost)
  • normal β€” core + active + warm (default)
  • deep β€” all tiers (thorough)
  • creative β€” random sampling from cold/archive (serendipity)

Health Scoring

Vault health is scored on a 100-point scale:

health = 100 - orphan_penalty - broken_penalty - density_penalty - desc_penalty
  • orphan_penalty β€” files with no incoming or outgoing links
  • broken_penalty β€” wiki-links pointing to non-existent files
  • density_penalty β€” low average link count per file
  • desc_penalty β€” files missing retrieval filter descriptions in frontmatter

The vault-health skill auto-generates MOCs, repairs broken links, and suggests connections for orphans.


Cost Breakdown

Service Cost Purpose
Gemini API ~$1-5/mo AI processing (Gemini 2.5 Pro/Flash)
VPS ~$5/mo 24/7 bot hosting
Deepgram Free ($200 credit) Voice transcription
Todoist Free / $4/mo Pro Task management
Total ~$25/mo

Bot Commands

The Telegram bot presents an inline keyboard with the following buttons:

Button Action
πŸ“Š Status Show today's entry count and processing status
βš™οΈ Process Run the 3-phase processing pipeline on demand
πŸ“… Week Generate and send a weekly digest
✨ Query Ask the agent anything β€” it reads your vault and Todoist
❓ Help Show available commands and usage tips

Talk to it like a real assistant

Buttons are just shortcuts. You can message the bot directly β€” voice or text β€” and have a full conversation. Ask follow-up questions, clarify, argue, brainstorm. It remembers context within the session and has access to your entire vault, goals, and Todoist.

What you can send:

  • Voice notes β€” transcribed via Deepgram, saved to daily file
  • Text β€” links, quotes, quick thoughts
  • Photos β€” saved with AI-generated descriptions
  • Forwarded messages β€” saved with source attribution

Example conversation:

You: "What did I write about the marketing project last week?" Bot: finds and shows relevant entries You: "Turn the second idea into a Todoist task for Monday" Bot: creates the task You: "Actually make it high priority and add a subtask for the presentation" Bot: updates the task


License

MIT

About

Second brain v2 gemini version

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors