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.
Python ai-agentsai-automationclaudeclaude-codeebbinghausknowledge-graphllmmemory-systemobsidianpersonal-assistantpkmproductivitypythonsecond-braintelegram-botvoice-assistant
style: zero ruff findings across src and tests
smixs82a7bf3fabe7
diff --git a/src/d_brain/bot/handlers/chat.py b/src/d_brain/bot/handlers/chat.pyindex 46072cf..e53b51b 100644--- a/src/d_brain/bot/handlers/chat.py+++ b/src/d_brain/bot/handlers/chat.py@@ -80,7 +80,9 @@ async def _dispatch_text(bot: Bot, chat_id: int, user_id: int, text: str) -> Nonkind = classify_command(text)if kind == "control":await _get_manager().send_control(text)- await bot.send_message(chat_id, f"⌨️ <code>{html.escape(text)}</code> отправлена в сессию.")+ await bot.send_message(+ chat_id, f"⌨️ <code>{html.escape(text)}</code> отправлена в сессию."+ )returnif kind == "tui":await bot.send_message(@@ -113,7 +115,9 @@ async def _process_and_reply(bot: Bot, chat_id: int, user_id: int, prompt: str)if response:await send_response(bot, chat_id, response)else:- logger.warning("Empty response from Claude for user %d, retrying...", user_id)+ logger.warning(+ "Empty response from Claude for user %d, retrying...", user_id+ )# Retry once before giving up — don't reset session on first emptyresponse = await manager.send_message(user_id, prompt)if response:diff --git a/tests/test_chat_handler.py b/tests/test_chat_handler.pyindex 5e459d3..b9b6803 100644--- a/tests/test_chat_handler.py+++ b/tests/test_chat_handler.py@@ -43,7 +43,9 @@ def test_no_debounce_infrastructure_left():"""The debounce buffer is fully removed."""from d_brain.bot.handlers import chat- for name in ("DEBOUNCE_SECONDS", "DebounceBuffer", "_add_to_buffer", "_debounce_flush", "_buffers"):+ zombies = ("DEBOUNCE_SECONDS", "DebounceBuffer", "_add_to_buffer",+ "_debounce_flush", "_buffers")+ for name in zombies:assert not hasattr(chat, name), f"zombie debounce symbol: {name}"diff --git a/tests/test_claude_session.py b/tests/test_claude_session.pyindex 3a50e40..965c910 100644--- a/tests/test_claude_session.py+++ b/tests/test_claude_session.py@@ -329,7 +329,9 @@ class FakeTmuxText(FakeTmux):def test_ask_wrap_false_does_not_append_marker_instruction(tmp_path, clock):- fake = FakeTmuxText([READY, THINKING, "ответ\n" + READY, "ответ\n" + READY], exists=True)+ fake = FakeTmuxText(+ [READY, THINKING, "ответ\n" + READY, "ответ\n" + READY], exists=True+ )(tmp_path / ".dbrain").mkdir()(tmp_path / ".dbrain" / "ready").touch()s = make_session(tmp_path, fake, clock)diff --git a/tests/test_cron_cli.py b/tests/test_cron_cli.pyindex f479ed6..adcde5d 100644--- a/tests/test_cron_cli.py+++ b/tests/test_cron_cli.py@@ -4,7 +4,7 @@ The CLI is what the brain calls via Bash, so its contract is the UX:human-readable output, exit 0 on success, exit 2 on bad input."""-from datetime import datetime, timedelta, timezone+from datetime import UTC, datetime, timedeltafrom d_brain.cron import mainfrom d_brain.services.cron_store import CronStore@@ -15,7 +15,7 @@ def _dir(tmp_path):def _future_iso():- return (datetime.now(timezone.utc) + timedelta(hours=2)).isoformat()+ return (datetime.now(UTC) + timedelta(hours=2)).isoformat()def test_add_every_writes_job_and_prints_id(tmp_path, capsys):@@ -75,7 +75,7 @@ def test_add_oneshot_at_with_delete_after_run(tmp_path):def test_add_at_in_the_past_exits_2(tmp_path, capsys):- past = (datetime.now(timezone.utc) - timedelta(hours=1)).isoformat()+ past = (datetime.now(UTC) - timedelta(hours=1)).isoformat()rc = main(["add", "--dir", _dir(tmp_path), "--prompt", "x", "--at", past])assert rc == 2assert "past" in capsys.readouterr().errdiff --git a/tests/test_cron_store.py b/tests/test_cron_store.pyindex 1c7abb0..f8af6cc 100644--- a/tests/test_cron_store.py+++ b/tests/test_cron_store.py@@ -1,7 +1,7 @@"""Tests for the cron job store and schedule math (pure, no tmux)."""import json-from datetime import datetime, timedelta, timezone+from datetime import UTC, datetime, timedeltafrom zoneinfo import ZoneInfoimport pytest@@ -14,7 +14,7 @@ from d_brain.services.cron_store import (parse_schedule,)-NOW = datetime(2026, 6, 10, 12, 0, tzinfo=timezone.utc) # 17:00 in Tashkent+NOW = datetime(2026, 6, 10, 12, 0, tzinfo=UTC) # 17:00 in Tashkent# ── parse_schedule ───────────────────────────────────────────────────@@ -81,7 +81,7 @@ def test_next_run_cron_respects_tz():def test_next_run_cron_same_day_when_still_ahead():- early = datetime(2026, 6, 10, 2, 0, tzinfo=timezone.utc) # 07:00 local+ early = datetime(2026, 6, 10, 2, 0, tzinfo=UTC) # 07:00 locals = Schedule(kind="cron", expr="0 9 * * *", tz="Asia/Tashkent")nxt = compute_next_run(s, now=early)assert nxt == datetime(2026, 6, 10, 9, 0, tzinfo=ZoneInfo("Asia/Tashkent"))diff --git a/tests/test_tmux_parse.py b/tests/test_tmux_parse.pyindex 0c922e6..e0485ec 100644--- a/tests/test_tmux_parse.py+++ b/tests/test_tmux_parse.py@@ -332,7 +332,8 @@ def test_is_idle_false_when_footer_present_but_thinking():permissions, so it must never be treated as an idle signal by itself."""from d_brain.services.tmux_parse import is_idle- pane = "long transcript\n" + _WORKING + " ⏵⏵ bypass permissions on (shift+tab to cycle)\n"+ footer = " ⏵⏵ bypass permissions on (shift+tab to cycle)\n"+ pane = "long transcript\n" + _WORKING + footerassert not is_idle(pane)