Technical Briefing – takopi Concise, consultant‑grade; all file paths and counts come from the repository’s static analysis.
The Problem
Engineers who use LLMs (Codex, Claude, OpenAI, Pi) need a single entry point that can run agents across many git worktrees, stream progress back to a Telegram chat, and resume sessions later without losing state. takopi fills that gap, but its internal structure and CI hygiene need scrutiny before production adoption.
What This Does
takopi is a Telegram‑bridged runner that lets you start, monitor, and resume agent sessions from chat. Key components live under src/takopi/:
src/takopi/telegram/loop.py– 50 functions/10 classes; the main message‑poller and dispatch loop.src/takopi/config.py– 9 functions/3 classes; reads/writes the persistent config (viaread_config,load_or_init_config).src/takopi/runner.py– 39 functions/7 classes; orchestratesrun_with_resume_lockand worktree management.src/takopi/telegram/bridge.py– 17 importers, 15 exports; bridges Telegram updates to the internal command pipeline.
The repo also ships scripts/ (5 files) for release/onboarding helpers and a pyproject.toml that pins the tool as a uv‑installed package.
How It Is Wired
Entry points (from the internal call graph):
| Entry | File | Reaches |
|---|---|---|
execute | src/takopi/telegram/client.py:146 | 46 functions |
handle | src/takopi/commands.py:81 | 166 functions |
run | src/takopi/runner.py:95 | 171 functions |
init | src/takopi/cli/__init__.py:105 | 25 functions |
Control flow typically starts at handle → run_one → _run_engine → resolve_run_cwd → ensure_worktree (filesystem). The longest shortest path to an out‑of‑process effect is handle → run_one → _run_engine → resolve_run_cwd → ensure_worktree (worktree creation).
Hub & cycle costs – src/takopi/logging.py is imported by 33 modules (instability 0), making changes ripple widely. A 19‑module import cycle involves src/takopi/telegram/bridge.py, topics.py, and commands/reply.py; any modification risks breaking the circular dependency unless shared types are extracted.
What the code touches outside itself – 90 functions read/write files; 2 make outbound network calls (Telegram API); 1 performs crypto/secret generation; 1 runs external commands. The shortest path from handle to a filesystem write goes through ensure_worktree (worktree directory creation).
How To Use It
- Setup – Install with the documented command: ``
sh uv tool install -U takopi`Then run the setup wizard (takopi`) to create a BotFather token, pick a workflow (assistant/workspace/handoff), and connect your chat.
- Configuration – The wizard writes a config file (see
src/takopi/config.py). Environment variables for engine binaries (codex,claude,opencode,pi) must be onPATH.
- Running it – After setup, invoke: ``
sh takopi`Send messages to your bot; prefix with/codex,/claude,/opencode, or/pito select an engine. Use/<project> <command>to target a registered project (e.g.,/happy-gadgets hard reset the timeline`).
- Development – See
docs/developing.mdanddocs/reference/specification.mdfor contributor onboarding; the repo uses GitHub Actions CI (.github/workflows/ci.yml).
Real‑World Use
A team maintaining several feature branches can takopi init my‑project to register the repo, then from any chat send /my‑project @feat/new‑ui implement the new dashboard. The agent runs in a dedicated worktree, streams progress (logs, file changes, elapsed time) back to the Telegram topic, and a resume line can be copied to continue the same session from a terminal later.
Code Health & Issues
Measured analysis (59 findings, 27 high, 32 medium, 0 low)
| Severity | Issue | Files (example) |
|---|---|---|
| HIGH | Import‑cycle member (19 modules) | src/takopi/telegram/bridge.py, topics.py, commands/reply.py |
| HIGH | Broad exception handling (x2) | src/takopi/logging.py, src/takopi/telegram/client_api.py |
| HIGH | Deep nesting (x15) | src/takopi/telegram/bridge.py, src/takopi/settings.py, src/takopi/runner_bridge.py |
| HIGH | Hub module (33 dependents) | src/takopi/logging.py, src/takopi/config.py, src/takopi/model.py |
| HIGH | Oversized files (x6) | src/takopi/runner.py, src/takopi/telegram/loop.py, tests/test_telegram_bridge.py |
| HIGH | Duplicated code blocks (346 × 6‑line blocks) | scripts/commit_notify.py, scripts/release_notify.py, scripts/onboarding_preview.py, src/takopi/telegram/onboarding.py … |
| MEDIUM | File opened without context manager | src/takopi/logging.py |
| MEDIUM | High branching density (21 branches /69 lines) | src/takopi/runners/tool_actions.py, src/takopi/telegram/render.py |
SDLC observations (from structure):
- No lockfile → non‑reproducible builds (
pyproject.tomldeclares deps without arequirements.txt/.txtlock). - CI declares no dependency‑vulnerability scan; no
dependabot.ymlconfigured. - Secrets not found in the repo, but GitHub Actions pins are not locked to commit SHAs (see health audit below).
Code Health Audit (6 findings)
| Severity | Issue | Evidence | Fix |
|---|---|---|---|
| HIGH | Pin third‑party GitHub Actions to commit SHAs | astral-sh/setup-uv@v7, pypa/gh-action-pypi-publish@release/v1, softprops/action-gh-release@v2 | Replace @vN with 40‑char SHA; let Dependabot bump SHAs. |
| HIGH | Discarding exit code of critical steps | ci.yml line 69 discards failure | Let the step fail or test the expected condition. |
| MEDIUM | Declare least‑privilege GITHUB_TOKEN permissions | 1 workflow declares no permissions | Add permissions: contents: read at top, widen per‑job as needed. |
| MEDIUM | Enable Dependabot or Renovate | Only 1 manifest, no update bot | Commit .github/dependabot.yml covering python and github-actions. |
| MEDIUM | Gate PRs on dependency vulnerability scan | No scan in CI | Add dependency-review-action on pull_request or osv-scanner on push. |
| LOW | Set timeout-minutes on workflow jobs | 2 jobs have no timeout | Add realistic timeout-minutes per job. |
The Bottom Line
takopi delivers a practical Telegram‑bridged runner for LLM‑driven agents, handling worktrees, progress streaming, and resume lines with a clear feature set. The codebase is functional but carries several high‑severity maintainability risks—import cycles, oversized files, duplicated logic, and unpinned GitHub Actions—that should be addressed before relying on it in a mission‑critical pipeline. Teams that need rapid, chat‑driven agent orchestration across multiple repos will find immediate value, provided the listed hygiene items are resolved.
Word count ≈ 480.