Skip to content

An always-on second brain you talk to. Voice notes in Telegram → typed, linked knowledge in your Obsidian vault. Runs 24/7 on the Claude subscription you already have.

feat!: remove weekly digest

smixs1149caedd6ac
diff --git a/deploy/dbrain-weekly.service b/deploy/dbrain-weekly.service
deleted file mode 100644
index 8e05d95..0000000
--- a/deploy/dbrain-weekly.service
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=d-brain weekly digest
-OnFailure=dbrain-notify@%n.service
-
-[Service]
-Type=oneshot
-WorkingDirectory=%h/projects/dbrain
-ExecStart=%h/.local/bin/uv run python scripts/weekly.py
-Environment=PATH=%h/.local/bin:/usr/local/bin:/usr/bin:/bin
-Environment=CLAUDE_CONFIG_DIR=%h/.claude
diff --git a/deploy/dbrain-weekly.timer b/deploy/dbrain-weekly.timer
deleted file mode 100644
index 9ca8f7c..0000000
--- a/deploy/dbrain-weekly.timer
+++ /dev/null
@@ -1,9 +0,0 @@
-[Unit]
-Description=d-brain weekly digest (Friday 06:00 local)
-
-[Timer]
-OnCalendar=Fri *-*-* 06:00:00
-Persistent=true
-
-[Install]
-WantedBy=timers.target
diff --git a/scripts/weekly.py b/scripts/weekly.py
deleted file mode 100644
index a31cfe1..0000000
--- a/scripts/weekly.py
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/usr/bin/env python
-"""Weekly digest script - generates and sends to Telegram."""
-
-import asyncio
-import logging
-import sys
-from pathlib import Path
-
-# Add project root to path
-sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
-
-from aiogram import Bot
-from aiogram.client.default import DefaultBotProperties
-from aiogram.enums import ParseMode
-
-from d_brain.config import get_settings
-from d_brain.services.git import VaultGit
-from d_brain.services.runtime import get_processor
-
-logging.basicConfig(
- level=logging.INFO,
- format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
-)
-logger = logging.getLogger(__name__)
-
-
-async def main() -> None:
- """Generate weekly digest and send to Telegram."""
- settings = get_settings()
- processor = get_processor(settings)
- git = VaultGit(settings.vault_path)
-
- logger.info("Starting weekly digest generation...")
-
- result = processor.generate_weekly()
-
- if "error" in result:
- report = f"Error: {result['error']}"
- logger.error("Weekly digest failed: %s", result["error"])
- else:
- report = result.get("report", "No output")
- logger.info("Weekly digest generated successfully")
- # Commit any changes
- git.commit_and_push("chore: weekly digest")
-
- # Send to Telegram
- bot = Bot(
- token=settings.telegram_bot_token,
- default=DefaultBotProperties(parse_mode=ParseMode.HTML),
- )
- try:
- user_id = settings.allowed_user_ids[0] if settings.allowed_user_ids else None
- if not user_id:
- logger.error("No allowed user IDs configured")
- return
-
- try:
- await bot.send_message(chat_id=user_id, text=report)
- except Exception:
- # Fallback: send without HTML parsing
- await bot.send_message(chat_id=user_id, text=report, parse_mode=None)
-
- logger.info("Weekly digest sent to user %s", user_id)
- finally:
- await bot.session.close()
-
-
-if __name__ == "__main__":
- asyncio.run(main())
diff --git a/src/d_brain/bot/handlers/__init__.py b/src/d_brain/bot/handlers/__init__.py
index 334ef9c..f7c69d9 100644
--- a/src/d_brain/bot/handlers/__init__.py
+++ b/src/d_brain/bot/handlers/__init__.py
@@ -9,7 +9,6 @@ from d_brain.bot.handlers import (
process,
text,
voice,
- weekly,
)
__all__ = [
@@ -21,5 +20,4 @@ __all__ = [
"process",
"text",
"voice",
- "weekly",
]
diff --git a/src/d_brain/bot/handlers/buttons.py b/src/d_brain/bot/handlers/buttons.py
index 7106a45..e137abb 100644
--- a/src/d_brain/bot/handlers/buttons.py
+++ b/src/d_brain/bot/handlers/buttons.py
@@ -25,14 +25,6 @@ async def btn_process(message: Message) -> None:
await cmd_process(message)
[email protected](F.text == "📅 Неделя")
-async def btn_weekly(message: Message) -> None:
- """Handle Weekly button."""
- from d_brain.bot.handlers.weekly import cmd_weekly
-
- await cmd_weekly(message)
-
-
@router.message(F.text == "✨ Запрос")
async def btn_do(message: Message, state: FSMContext) -> None:
"""Handle Do button - set state and wait for input."""
diff --git a/src/d_brain/bot/handlers/commands.py b/src/d_brain/bot/handlers/commands.py
index 44538d1..56ff19c 100644
--- a/src/d_brain/bot/handlers/commands.py
+++ b/src/d_brain/bot/handlers/commands.py
@@ -29,7 +29,6 @@ async def cmd_start(message: Message) -> None:
"/status - статус сегодняшнего дня\n"
"/process - обработать записи\n"
"/do - выполнить произвольный запрос\n"
- "/weekly - недельный дайджест\n"
"/help - справка",
reply_markup=get_main_keyboard(),
)
@@ -49,8 +48,7 @@ async def cmd_help(message: Message) -> None:
"<b>Команды:</b>\n"
"/status - сколько записей сегодня\n"
"/process - обработать записи\n"
- "/do - выполнить произвольный запрос\n"
- "/weekly - недельный дайджест\n\n"
+ "/do - выполнить произвольный запрос\n\n"
"<i>Пример: /do перенеси просроченные задачи на понедельник</i>"
)
diff --git a/src/d_brain/bot/handlers/weekly.py b/src/d_brain/bot/handlers/weekly.py
deleted file mode 100644
index 489c6dc..0000000
--- a/src/d_brain/bot/handlers/weekly.py
+++ /dev/null
@@ -1,61 +0,0 @@
-"""Weekly digest command handler."""
-
-import asyncio
-import logging
-
-from aiogram import Router
-from aiogram.filters import Command
-from aiogram.types import Message
-
-from d_brain.bot.formatters import format_process_report
-from d_brain.config import get_settings
-from d_brain.services.git import VaultGit
-from d_brain.services.runtime import get_ask_lock, get_processor
-
-router = Router(name="weekly")
-logger = logging.getLogger(__name__)
-
-
[email protected](Command("weekly"))
-async def cmd_weekly(message: Message) -> None:
- """Handle /weekly command - generate weekly digest."""
- user_id = message.from_user.id if message.from_user else "unknown"
- logger.info("Weekly digest triggered by user %s", user_id)
-
- status_msg = await message.answer("⏳ Генерирую недельный дайджест...")
-
- settings = get_settings()
- processor = get_processor(settings)
- git = VaultGit(settings.vault_path)
-
- async def run_with_progress() -> dict:
- task = asyncio.create_task(
- asyncio.to_thread(processor.generate_weekly)
- )
-
- elapsed = 0
- while not task.done():
- await asyncio.sleep(30)
- elapsed += 30
- if not task.done():
- try:
- await status_msg.edit_text(
- f"⏳ Генерирую дайджест... ({elapsed // 60}m {elapsed % 60}s)"
- )
- except Exception:
- pass
-
- return await task
-
- async with get_ask_lock():
- report = await run_with_progress()
-
- # Commit any changes (weekly goal updates, etc)
- if "error" not in report:
- await asyncio.to_thread(git.commit_and_push, "chore: weekly digest")
-
- formatted = format_process_report(report)
- try:
- await status_msg.edit_text(formatted)
- except Exception:
- await status_msg.edit_text(formatted, parse_mode=None)
diff --git a/src/d_brain/bot/keyboards.py b/src/d_brain/bot/keyboards.py
index 016e4f5..183ae84 100644
--- a/src/d_brain/bot/keyboards.py
+++ b/src/d_brain/bot/keyboards.py
@@ -10,9 +10,8 @@ def get_main_keyboard() -> ReplyKeyboardMarkup:
# First row: main commands
builder.button(text="📊 Статус")
builder.button(text="⚙️ Обработать")
- builder.button(text="📅 Неделя")
# Second row: additional
builder.button(text="✨ Запрос")
builder.button(text="❓ Помощь")
- builder.adjust(3, 2) # 3 in first row, 2 in second
+ builder.adjust(2, 2) # 2 in first row, 2 in second
return builder.as_markup(resize_keyboard=True, is_persistent=True)
diff --git a/src/d_brain/bot/main.py b/src/d_brain/bot/main.py
index 32fd6a8..791b8c6 100644
--- a/src/d_brain/bot/main.py
+++ b/src/d_brain/bot/main.py
@@ -37,7 +37,6 @@ def create_dispatcher() -> Dispatcher:
process,
text,
voice,
- weekly,
)
# Use memory storage for FSM (required for /do command state)
@@ -46,7 +45,6 @@ def create_dispatcher() -> Dispatcher:
# Register routers - ORDER MATTERS
dp.include_router(commands.router)
dp.include_router(process.router)
- dp.include_router(weekly.router)
dp.include_router(do.router) # Before voice/text to catch FSM state
dp.include_router(buttons.router) # Reply keyboard buttons
dp.include_router(voice.router)
diff --git a/src/d_brain/pipeline.py b/src/d_brain/pipeline.py
index 45caafd..8760236 100644
--- a/src/d_brain/pipeline.py
+++ b/src/d_brain/pipeline.py
@@ -1,12 +1,11 @@
-"""Headless pipeline entrypoint for the daily/weekly cron timers.
+"""Headless pipeline entrypoint for the daily cron timer.
-Replaces the old `claude --print -p` phases in process.sh: each command runs
+Replaces the old `claude --print -p` phases in process.sh: the command runs
through the shared persistent interactive session (subscription billing). The
surrounding shell shim still handles graph rebuild, memory decay, git and
Telegram delivery.
uv run python -m d_brain.pipeline daily # prints the HTML report
- uv run python -m d_brain.pipeline weekly
Exit code 0 on success (report), 1 otherwise.
"""
@@ -22,8 +21,6 @@ def run(cmd: str, proc: Any) -> tuple[str, bool]:
"""Run a pipeline command against a processor. Returns (text, ok)."""
if cmd == "daily":
res = proc.process_daily()
- elif cmd == "weekly":
- res = proc.generate_weekly()
else:
return f"unknown command: {cmd}", False
if res.get("report"):
diff --git a/src/d_brain/services/processor.py b/src/d_brain/services/processor.py
index c619ab4..5d55c8b 100644
--- a/src/d_brain/services/processor.py
+++ b/src/d_brain/services/processor.py
@@ -78,43 +78,6 @@ class ClaudeProcessor:
lines.append("=== END SESSION ===\n")
return "\n".join(lines)
- def _html_to_markdown(self, html: str) -> str:
- import re
-
- text = html
- text = re.sub(r"<b>(.*?)</b>", r"**\1**", text)
- text = re.sub(r"<i>(.*?)</i>", r"*\1*", text)
- text = re.sub(r"<code>(.*?)</code>", r"`\1`", text)
- text = re.sub(r"<s>(.*?)</s>", r"~~\1~~", text)
- text = re.sub(r"</?u>", "", text)
- text = re.sub(r'<a href="([^"]+)">([^<]+)</a>', r"[\2](\1)", text)
- return text
-
- def _save_weekly_summary(self, report_html: str, week_date: date) -> Path:
- year, week, _ = week_date.isocalendar()
- filename = f"{year}-W{week:02d}-summary.md"
- summary_path = self.vault_path / "summaries" / filename
- content = self._html_to_markdown(report_html)
- frontmatter = (
- f"---\ndate: {week_date.isoformat()}\n"
- f"type: weekly-summary\nweek: {year}-W{week:02d}\n---\n\n"
- )
- summary_path.write_text(frontmatter + content)
- logger.info("Weekly summary saved to %s", summary_path)
- return summary_path
-
- def _update_weekly_moc(self, summary_path: Path) -> None:
- moc_path = self.vault_path / "MOC" / "MOC-weekly.md"
- if moc_path.exists():
- content = moc_path.read_text()
- link = f"- [[summaries/{summary_path.name}|{summary_path.stem}]]"
- if summary_path.stem not in content:
- content = content.replace(
- "## Previous Weeks\n", f"## Previous Weeks\n\n{link}\n"
- )
- moc_path.write_text(content)
- logger.info("Updated MOC-weekly.md with %s", summary_path.stem)
-
# ── public operations ────────────────────────────────────────────
def process_daily(self, day: date | None = None) -> dict[str, Any]:
@@ -164,28 +127,3 @@ EXECUTION:
2. Read/write vault files as needed
3. Return HTML status report with results"""
return self._ask(prompt)
-
- def generate_weekly(self) -> dict[str, Any]:
- today = date.today()
- prompt = f"""Сегодня {today}. Сгенерируй недельный дайджест.
-
-WORKFLOW:
-1. Собери данные за неделю (daily файлы в vault/daily/, completed tasks через MCP)
-2. Проанализируй прогресс по целям (goals/3-weekly.md)
-3. Определи победы и вызовы
-4. Сгенерируй HTML отчёт
-
-CRITICAL OUTPUT FORMAT:
-- Return ONLY raw HTML for Telegram (parse_mode=HTML)
-- NO markdown: no **, no ##, no ```, no tables
-- Start with 📅 <b>Недельный дайджест</b>
-- Allowed tags: <b>, <i>, <code>, <s>, <u>
-- Be concise - Telegram has 4096 char limit"""
- result = self._ask(prompt)
- if "report" in result and result["report"]:
- try:
- summary_path = self._save_weekly_summary(result["report"], today)
- self._update_weekly_moc(summary_path)
- except Exception as e: # noqa: BLE001
- logger.warning("Failed to save weekly summary: %s", e)
- return result
diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py
index 47e4bd6..f334557 100644
--- a/tests/test_pipeline.py
+++ b/tests/test_pipeline.py
@@ -1,19 +1,15 @@
-"""Tests for the daily/weekly pipeline entrypoint (no claude -p)."""
+"""Tests for the daily pipeline entrypoint (no claude -p)."""
from d_brain.pipeline import run
class FakeProc:
- def __init__(self, daily=None, weekly=None):
+ def __init__(self, daily=None):
self._daily = daily or {}
- self._weekly = weekly or {}
def process_daily(self):
return self._daily
- def generate_weekly(self):
- return self._weekly
-
def test_run_daily_returns_report_and_ok():
proc = FakeProc(daily={"report": "<b>done</b>", "processed_entries": 1})
@@ -29,10 +25,11 @@ def test_run_daily_error_is_not_ok():
assert "no daily file" in text
-def test_run_weekly():
- proc = FakeProc(weekly={"report": "<b>weekly</b>", "processed_entries": 1})
- text, ok = run("weekly", proc)
- assert ok and text == "<b>weekly</b>"
+def test_run_weekly_is_unknown_command():
+ """v3.0: the weekly digest is removed; 'weekly' is no longer a command."""
+ text, ok = run("weekly", FakeProc())
+ assert not ok
+ assert "unknown" in text.lower()
def test_run_unknown_command():
diff --git a/tests/test_processor.py b/tests/test_processor.py
index 7354d26..425da1b 100644
--- a/tests/test_processor.py
+++ b/tests/test_processor.py
@@ -71,15 +71,6 @@ def test_process_daily_ok(tmp_path):
assert sess.prompts
-def test_generate_weekly_ok(tmp_path):
- (tmp_path / "summaries").mkdir()
- sess = FakeSession(AskResult("ok", reply="<b>weekly</b>"))
- p = ClaudeProcessor(tmp_path, session=sess)
- r = p.generate_weekly()
- assert r["report"] == "<b>weekly</b>"
- assert sess.prompts
-
-
def test_prompts_contain_no_todoist_references(tmp_path):
"""v3.0: Todoist is removed; no prompt may instruct the agent to use it."""
(tmp_path / "daily").mkdir()
diff --git a/upgrade.sh b/upgrade.sh
index 25f22b6..92faec9 100755
--- a/upgrade.sh
+++ b/upgrade.sh
@@ -52,6 +52,9 @@ mkdir -p "$USER_UNITS"
systemctl --user disable --now \
d-brain-bot.service d-brain-process.timer d-brain-weekly.timer 2>/dev/null || true
rm -f "$USER_UNITS"/d-brain-*.service "$USER_UNITS"/d-brain-*.timer
+# v3.0 migration: the weekly digest is removed — retire its units on upgrade.
+systemctl --user disable --now dbrain-weekly.timer dbrain-weekly.service 2>/dev/null || true
+rm -f "$USER_UNITS"/dbrain-weekly.service "$USER_UNITS"/dbrain-weekly.timer
# Install new units, pointing WorkingDirectory/ExecStart at the real path.
for f in "$PROJECT_DIR"/deploy/dbrain-*.service "$PROJECT_DIR"/deploy/dbrain-*.timer; do
sed "s|%h/projects/dbrain|$PROJECT_DIR|g" "$f" > "$USER_UNITS/$(basename "$f")"
@@ -60,12 +63,12 @@ systemctl --user daemon-reload
loginctl enable-linger "$USER" 2>/dev/null || echo " ⚠ could not enable linger (services won't start on boot without it)"
systemctl --user enable \
dbrain-bot.service dbrain-watchdog.service \
- dbrain-process.timer dbrain-doctor.timer dbrain-weekly.timer
+ dbrain-process.timer dbrain-doctor.timer
# restart (not just enable --now): on a re-run the units may have changed, and
# enable --now won't re-apply a new unit to an already-running service.
# KillMode=process means restarting the bot/watchdog does NOT kill the brain.
systemctl --user restart dbrain-bot.service dbrain-watchdog.service
-systemctl --user start dbrain-process.timer dbrain-doctor.timer dbrain-weekly.timer
+systemctl --user start dbrain-process.timer dbrain-doctor.timer
say "7/8 Guard: no claude -p in the hot path"
bash "$PROJECT_DIR/scripts/check-no-claude-p.sh"
diff --git a/vault/.claude/agents/weekly-digest.md b/vault/.claude/agents/weekly-digest.md
deleted file mode 100644
index 702f7e7..0000000
--- a/vault/.claude/agents/weekly-digest.md
+++ /dev/null
@@ -1,138 +0,0 @@
----
-name: weekly-digest
-description: Generate weekly digest with goal progress, wins, challenges, and next week planning. Run on Sundays.
----
-
-# Weekly Digest Agent
-
-Analyzes the past week and generates comprehensive digest report.
-
-## When to Run
-
-- Every Sunday evening
-- On demand via `/weekly` command
-
-## Workflow
-
-### Step 1: Collect Week Data
-
-1. **Read all daily files for the week:**
- ```
- daily/YYYY-MM-DD.md (7 files)
- ```
-
-2. **Get completed tasks from Todoist:**
- ```
- mcp__todoist__find-completed-tasks
- since: {monday}
- until: {sunday}
- ```
-
-3. **Get current goals:**
- ```
- Read goals/1-yearly-2025.md
- Read goals/2-monthly.md
- Read goals/3-weekly.md
- ```
-
-### Step 2: Analyze Progress
-
-Calculate for each yearly goal:
-- Tasks completed related to goal
-- Notes saved related to goal
-- Progress delta (this week vs last week)
-
-### Step 3: Identify Wins & Challenges
-
-**Wins:**
-- Completed tasks marked as important
-- Goals with progress increase
-- Streak maintained (habits)
-
-**Challenges:**
-- Overdue tasks
-- Goals without activity
-- Incomplete ONE Big Thing
-
-### Step 4: Plan Next Week
-
-1. **Update weekly focus:**
- - Suggest new ONE Big Thing
- - Based on goal alignment
-
-2. **Recommend priorities:**
- - Top 3 tasks for next week
- - Based on goals + overdue
-
-### Step 5: Generate Report
-
-Format: Telegram HTML
-
-```html
-📅 <b>Недельный дайджест: {WEEK}</b>
-
-<b>🎯 ONE Big Thing на прошлой неделе:</b>
-{status: ✅ Выполнено | ❌ Не выполнено | 🟡 Частично}
-{description}
-
-<b>🏆 Победы недели:</b>
-• {win 1}
-• {win 2}
-• {win 3}
-
-<b>⚔️ Вызовы:</b>
-• {challenge 1}
-• {challenge 2}
-
-<b>📊 Статистика:</b>
-• Задач выполнено: {N}
-• Заметок сохранено: {M}
-• Голосовых сообщений: {K}
-
-<b>📈 Прогресс по целям:</b>
-• {goal}: {old}% → {new}% {delta_emoji}
-• {goal}: {old}% → {new}% {delta_emoji}
-
-<b>⚠️ Требует внимания:</b>
-• {stale goals or overdue items}
-
-<b>🎯 ONE Big Thing на следующую неделю:</b>
-{suggested ONE thing}
-
-<b>⚡ Топ-3 приоритета:</b>
-1. {task}
-2. {task}
-3. {task}
-
----
-<i>Неделя {week_number} завершена</i>
-```
-
-## Progress Delta Emojis
-
-| Change | Emoji |
-|--------|-------|
-| +10% or more | 🚀 |
-| +1% to +9% | 📈 |
-| No change | ➡️ |
-| -1% to -9% | 📉 |
-| -10% or more | 🔻 |
-
-## Update Files
-
-After generating digest:
-
-1. **Archive current weekly:**
- ```
- Rename goals/3-weekly.md → goals/archive/3-weekly-{WEEK}.md
- ```
-
-2. **Create new weekly:**
- ```
- Create goals/3-weekly.md with new ONE Big Thing
- ```
-
-3. **Update monthly if needed:**
- ```
- Update progress in goals/2-monthly.md
- ```