diff --git a/ROADMAP.md b/ROADMAP.md new file mode 100644 index 0000000..d0bcc87 --- /dev/null +++ b/ROADMAP.md @@ -0,0 +1,238 @@ +# `tg` Roadmap — Agent-Automatable Telegram CLI + +## Vision + +Turn `tg` into a single static binary that an AI agent (or any script) can drive to +automate everyday Telegram work on a **personal account**: message yourself, list and +triage chats, mark chats as read, reply, upload/download files, search history, and more. + +The goal is a broad capability surface — and strong agent ergonomics — delivered as a +fast, dependency-free Go binary built on [`gotd/td`](https://github.com/gotd/td), exposed +as composable subcommands. New capability should land as `tg` subcommands. + +## The central gap: user-account auth + +`tg` today authenticates **only as a bot** (`Config.BotToken`, `client.Auth().Bot(...)`, +and `app.Before` hard-rejects a config without a bot token). Bots cannot: + +- access **Saved Messages** / "message yourself", +- list **dialogs** (`messages.getDialogs` is unavailable to bots), +- read arbitrary chat history or mark dialogs as read the way a user can, +- see the chat/folder list, contacts, or most account state. + +**Every automation use case in the request requires a user session.** So user login is +Phase 0 and gates everything else. `gotd/td` already supports this: `auth.NewFlow` with a +code-prompt + 2FA handler, and `qrlogin` for QR-based login. + +## Agent-first design principles + +These cut across every feature and matter as much as the features themselves: + +1. **Structured output.** Global `--output json|text` (default `text` for humans, but + agents pass `--output json`). Every command emits a stable, documented JSON object on + stdout. No data on stderr; logs/progress go to stderr only. +2. **Non-interactive by default.** Never block on a TTY prompt in agent mode. Auth codes, + confirmations, and 2FA come from flags / env / a pre-established session. +3. **Stable exit codes.** `0` success, distinct non-zero codes for auth failure, peer not + found, flood-wait exceeded, permission denied — so agents can branch on them. +4. **No decorative output in machine mode.** The upload progress bar and typing-action + updates must be suppressed under `--output json`. +5. **Consistent peer resolution.** One shared `--peer` grammar everywhere: `me`/`self`, + `@username`, numeric ID, phone, `t.me/...` link. Cache resolved access-hashes in the + session dir (StringSession-style sessions have no entity cache — we must keep our own). +6. **Idempotency & safety.** Destructive actions (delete history, leave, ban, delete + account-level state) require `--yes` in agent mode and are clearly marked read-only vs + mutating. +7. **Schema versioning.** Include `"schema": 1` (or similar) in JSON so agents can adapt. +8. **Account selection.** Every command accepts a global `--account