coding-agent-telegram 2026.3.26__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- coding_agent_telegram-2026.3.26/LICENSE +21 -0
- coding_agent_telegram-2026.3.26/PKG-INFO +475 -0
- coding_agent_telegram-2026.3.26/README.md +461 -0
- coding_agent_telegram-2026.3.26/pyproject.toml +39 -0
- coding_agent_telegram-2026.3.26/setup.cfg +4 -0
- coding_agent_telegram-2026.3.26/setup.py +65 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/__init__.py +4 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/__main__.py +5 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/agent_runner.py +438 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/bot.py +74 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/cli.py +130 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/command_router.py +18 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/config.py +123 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/diff_utils.py +369 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/filters.py +42 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/git_utils.py +250 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/logging_utils.py +17 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/resources/.env.example +83 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/resources/sensitive_path_globs.txt +15 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/resources/snapshot_excluded_dir_globs.txt +30 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/resources/snapshot_excluded_dir_names.txt +16 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/resources/snapshot_excluded_file_globs.txt +4 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/router/__init__.py +2 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/router/base.py +536 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/router/git_commands.py +106 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/router/message_commands.py +45 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/router/project_commands.py +234 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/router/session_commands.py +197 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/session_runtime.py +505 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/session_store.py +309 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram/telegram_sender.py +236 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram.egg-info/PKG-INFO +475 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram.egg-info/SOURCES.txt +46 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram.egg-info/dependency_links.txt +1 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram.egg-info/entry_points.txt +2 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram.egg-info/requires.txt +3 -0
- coding_agent_telegram-2026.3.26/src/coding_agent_telegram.egg-info/top_level.txt +1 -0
- coding_agent_telegram-2026.3.26/tests/test_agent_runner.py +280 -0
- coding_agent_telegram-2026.3.26/tests/test_agent_runner_stall.py +45 -0
- coding_agent_telegram-2026.3.26/tests/test_command_router.py +1665 -0
- coding_agent_telegram-2026.3.26/tests/test_config.py +122 -0
- coding_agent_telegram-2026.3.26/tests/test_diff_chunking.py +231 -0
- coding_agent_telegram-2026.3.26/tests/test_filters.py +9 -0
- coding_agent_telegram-2026.3.26/tests/test_git_utils.py +102 -0
- coding_agent_telegram-2026.3.26/tests/test_project_validation.py +21 -0
- coding_agent_telegram-2026.3.26/tests/test_session_runtime_diff_merge.py +37 -0
- coding_agent_telegram-2026.3.26/tests/test_session_store.py +132 -0
- coding_agent_telegram-2026.3.26/tests/test_telegram_sender.py +43 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dao Cha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: coding-agent-telegram
|
|
3
|
+
Version: 2026.3.26
|
|
4
|
+
Summary: Telegram bot bridge for local coding agents (Codex/Copilot CLI)
|
|
5
|
+
Author: Codex
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: python-telegram-bot<22.0,>=21.0
|
|
11
|
+
Requires-Dist: python-dotenv<2.0.0,>=1.0.0
|
|
12
|
+
Requires-Dist: portalocker<3.0.0,>=2.8.2
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# coding-agent-telegram
|
|
16
|
+
|
|
17
|
+
A Telegram bot bridge for local coding agents such as Codex CLI and Copilot CLI. It lets you manage multiple project sessions from Telegram while keeping execution on your own machine.
|
|
18
|
+
|
|
19
|
+
The bot accepts private chats only.
|
|
20
|
+
|
|
21
|
+
## ✨ What It Does
|
|
22
|
+
|
|
23
|
+
- Connect one Telegram account to multiple Telegram bots.
|
|
24
|
+
- Keep sessions isolated per bot and per chat.
|
|
25
|
+
- Bind each session to one project folder and one provider.
|
|
26
|
+
- Run local coding agents inside your workspace.
|
|
27
|
+
- Show Codex output and file changes back in Telegram.
|
|
28
|
+
- Accept text messages and photos as task input.
|
|
29
|
+
- Auto-create missing project folders with `/project <folder>`.
|
|
30
|
+
|
|
31
|
+
## ✅ Requirements
|
|
32
|
+
|
|
33
|
+
Before starting the server, make sure you have:
|
|
34
|
+
|
|
35
|
+
- Python 3.9 or newer
|
|
36
|
+
- A Telegram bot token from BotFather
|
|
37
|
+
- Your Telegram chat ID
|
|
38
|
+
- Codex CLI and/or Copilot CLI installed locally
|
|
39
|
+
- A workspace directory that contains your projects
|
|
40
|
+
|
|
41
|
+
## 🔑 Telegram Setup
|
|
42
|
+
|
|
43
|
+
### Get a Bot Token
|
|
44
|
+
|
|
45
|
+
1. Open Telegram and start a chat with `@BotFather`.
|
|
46
|
+
2. Send `/newbot`.
|
|
47
|
+
3. Follow the prompts to choose:
|
|
48
|
+
- a display name
|
|
49
|
+
- a bot username ending in `bot`
|
|
50
|
+
4. BotFather will return an HTTP API token.
|
|
51
|
+
5. Put that token into `TELEGRAM_BOT_TOKENS` in your `.env`.
|
|
52
|
+
|
|
53
|
+
### Get Your Chat ID
|
|
54
|
+
|
|
55
|
+
The most reliable way is to use Telegram's `getUpdates` API with your own bot token.
|
|
56
|
+
|
|
57
|
+
1. Start a chat with your bot and send it a message such as `/start`.
|
|
58
|
+
2. Open this URL in your browser, replacing `<BOT_TOKEN>`:
|
|
59
|
+
|
|
60
|
+
```text
|
|
61
|
+
https://api.telegram.org/bot<BOT_TOKEN>/getUpdates
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
3. Find the `chat` object in the JSON response.
|
|
65
|
+
4. Copy the numeric `id` field from that object.
|
|
66
|
+
5. Put that value into `ALLOWED_CHAT_IDS` in your `.env`.
|
|
67
|
+
|
|
68
|
+
Notes:
|
|
69
|
+
|
|
70
|
+
- For private chats, the chat ID is usually a positive integer.
|
|
71
|
+
- If `getUpdates` returns an empty result, send another message to the bot and try again.
|
|
72
|
+
|
|
73
|
+
## 🚀 Quick Start
|
|
74
|
+
|
|
75
|
+
### Option A: Run from a cloned repository
|
|
76
|
+
|
|
77
|
+
#### 1. Clone the repository
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
git clone https://github.com/daocha/coding-agent-telegram
|
|
81
|
+
cd coding-agent-telegram
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### 2. Start with the bootstrap script
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
./startup.sh
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
What `startup.sh` does:
|
|
91
|
+
|
|
92
|
+
- creates `.env` from `src/coding_agent_telegram/resources/.env.example` if missing
|
|
93
|
+
- creates the state files if missing
|
|
94
|
+
- creates `.venv` if missing
|
|
95
|
+
- installs the package into the virtual environment
|
|
96
|
+
- starts the Telegram bot server
|
|
97
|
+
|
|
98
|
+
#### 3. Update `.env`
|
|
99
|
+
|
|
100
|
+
On first run, update the required fields in `.env`:
|
|
101
|
+
|
|
102
|
+
- `WORKSPACE_ROOT`
|
|
103
|
+
- `TELEGRAM_BOT_TOKENS`
|
|
104
|
+
- `ALLOWED_CHAT_IDS`
|
|
105
|
+
|
|
106
|
+
Then run again:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
./startup.sh
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Option B: Install from PyPI with `pip`
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
pip install coding-agent-telegram
|
|
116
|
+
coding-agent-telegram
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
What happens on first run:
|
|
120
|
+
|
|
121
|
+
- the command creates `.env` in your current working directory if missing
|
|
122
|
+
- it tells you which required fields to update
|
|
123
|
+
- after updating `.env`, run `coding-agent-telegram` again
|
|
124
|
+
|
|
125
|
+
Recommended flow:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
mkdir -p ~/my-coding-agent-bot
|
|
129
|
+
cd ~/my-coding-agent-bot
|
|
130
|
+
pip install coding-agent-telegram
|
|
131
|
+
coding-agent-telegram
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Then update `.env` and run:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
coding-agent-telegram
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## 📨 Supported Message Types
|
|
141
|
+
|
|
142
|
+
The bot currently accepts:
|
|
143
|
+
|
|
144
|
+
- plain text messages
|
|
145
|
+
- photos
|
|
146
|
+
|
|
147
|
+
Current media behavior:
|
|
148
|
+
|
|
149
|
+
- photos are supported for Codex sessions
|
|
150
|
+
- videos are not supported
|
|
151
|
+
- video notes are not supported
|
|
152
|
+
- animations are not supported
|
|
153
|
+
- audio and voice messages are not supported
|
|
154
|
+
- documents and stickers are not supported
|
|
155
|
+
|
|
156
|
+
If an unsupported message type is sent, the bot replies with a short error instead of silently ignoring it.
|
|
157
|
+
|
|
158
|
+
## ⚙️ Environment Variables
|
|
159
|
+
|
|
160
|
+
These are the main fields in `.env`.
|
|
161
|
+
|
|
162
|
+
### Required
|
|
163
|
+
|
|
164
|
+
- `WORKSPACE_ROOT`
|
|
165
|
+
Parent folder that contains your project directories.
|
|
166
|
+
Example: `WORKSPACE_ROOT=~/git`
|
|
167
|
+
|
|
168
|
+
- `TELEGRAM_BOT_TOKENS`
|
|
169
|
+
Comma-separated Telegram bot tokens.
|
|
170
|
+
Example: `TELEGRAM_BOT_TOKENS=token_one,token_two`
|
|
171
|
+
|
|
172
|
+
- `ALLOWED_CHAT_IDS`
|
|
173
|
+
Comma-separated Telegram private chat IDs allowed to use the bot.
|
|
174
|
+
Example: `ALLOWED_CHAT_IDS=123456789,987654321`
|
|
175
|
+
|
|
176
|
+
### State and Logging
|
|
177
|
+
|
|
178
|
+
- `STATE_FILE`
|
|
179
|
+
JSON file used to store session state.
|
|
180
|
+
Default: `./state.json`
|
|
181
|
+
|
|
182
|
+
- `STATE_BACKUP_FILE`
|
|
183
|
+
Backup copy of the state file.
|
|
184
|
+
Default: `./state.json.bak`
|
|
185
|
+
|
|
186
|
+
- `LOG_LEVEL`
|
|
187
|
+
Python app log level.
|
|
188
|
+
Default: `INFO`
|
|
189
|
+
|
|
190
|
+
- `LOG_DIR`
|
|
191
|
+
Directory for application logs.
|
|
192
|
+
Default: `./logs`
|
|
193
|
+
|
|
194
|
+
### Agent Configuration
|
|
195
|
+
|
|
196
|
+
- `DEFAULT_AGENT_PROVIDER`
|
|
197
|
+
Default provider for `/new` when none is specified.
|
|
198
|
+
Supported values: `codex`, `copilot`
|
|
199
|
+
|
|
200
|
+
- `CODEX_BIN`
|
|
201
|
+
Command used to launch Codex CLI.
|
|
202
|
+
Default: `codex`
|
|
203
|
+
|
|
204
|
+
- `COPILOT_BIN`
|
|
205
|
+
Command used to launch Copilot CLI.
|
|
206
|
+
Default: `copilot`
|
|
207
|
+
|
|
208
|
+
- `CODEX_MODEL`
|
|
209
|
+
Optional Codex model override.
|
|
210
|
+
Leave empty to use the Codex CLI default model.
|
|
211
|
+
Example: `CODEX_MODEL=gpt-5.4`
|
|
212
|
+
|
|
213
|
+
- `COPILOT_MODEL`
|
|
214
|
+
Optional Copilot model override.
|
|
215
|
+
Leave empty to use the Copilot CLI default model.
|
|
216
|
+
Examples: `COPILOT_MODEL=gpt-5.4`, `COPILOT_MODEL=claude-sonnet-4.6`
|
|
217
|
+
|
|
218
|
+
Use the official model references before setting these values:
|
|
219
|
+
|
|
220
|
+
- OpenAI Codex/OpenAI models: `https://developers.openai.com/codex/models`
|
|
221
|
+
- GitHub Copilot supported models: `https://docs.github.com/en/copilot/reference/ai-models/supported-models`
|
|
222
|
+
|
|
223
|
+
- `COPILOT_AUTOPILOT`
|
|
224
|
+
Default: `true`
|
|
225
|
+
Runs Copilot CLI in autopilot mode by default.
|
|
226
|
+
|
|
227
|
+
- `COPILOT_NO_ASK_USER`
|
|
228
|
+
Default: `true`
|
|
229
|
+
Tells Copilot CLI not to stop and ask the user interactive follow-up questions.
|
|
230
|
+
|
|
231
|
+
- `COPILOT_ALLOW_ALL`
|
|
232
|
+
Default: `true`
|
|
233
|
+
Passes `--allow-all`, which enables tools, paths, and URLs without confirmation.
|
|
234
|
+
This is the default here so Copilot CLI can continue non-interactively inside the Telegram bot flow.
|
|
235
|
+
|
|
236
|
+
- `COPILOT_ALLOW_ALL_TOOLS`
|
|
237
|
+
If `true`, pass `--allow-all-tools` to Copilot CLI.
|
|
238
|
+
Use this only if you are comfortable letting Copilot run tools without approval prompts.
|
|
239
|
+
|
|
240
|
+
- `COPILOT_ALLOW_TOOLS`
|
|
241
|
+
Comma-separated list of tools to allow without prompting.
|
|
242
|
+
Example: `COPILOT_ALLOW_TOOLS=shell(git),shell(npm)`
|
|
243
|
+
|
|
244
|
+
- `COPILOT_DENY_TOOLS`
|
|
245
|
+
Comma-separated list of tools to explicitly deny.
|
|
246
|
+
Example: `COPILOT_DENY_TOOLS=shell(rm),shell(chmod)`
|
|
247
|
+
|
|
248
|
+
- `COPILOT_AVAILABLE_TOOLS`
|
|
249
|
+
Optional comma-separated allowlist of tools Copilot may use at all.
|
|
250
|
+
Example: `COPILOT_AVAILABLE_TOOLS=shell,apply_patch`
|
|
251
|
+
|
|
252
|
+
GitHub documents these Copilot CLI approval controls here:
|
|
253
|
+
|
|
254
|
+
- `https://docs.github.com/en/copilot/concepts/about-github-copilot-cli`
|
|
255
|
+
- `https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference`
|
|
256
|
+
|
|
257
|
+
- `CODEX_APPROVAL_POLICY`
|
|
258
|
+
Approval mode passed to Codex.
|
|
259
|
+
Default: `never`
|
|
260
|
+
|
|
261
|
+
- `CODEX_SANDBOX_MODE`
|
|
262
|
+
Sandbox mode passed to Codex.
|
|
263
|
+
Default: `workspace-write`
|
|
264
|
+
|
|
265
|
+
- `CODEX_SKIP_GIT_REPO_CHECK`
|
|
266
|
+
If `true`, always bypass Codex's trusted-repo check.
|
|
267
|
+
If `false`, existing third-party folders stay protected unless trusted by this app.
|
|
268
|
+
|
|
269
|
+
- `ENABLE_COMMIT_COMMAND`
|
|
270
|
+
If `true`, enable the `/commit` Telegram command.
|
|
271
|
+
Default: `false`
|
|
272
|
+
|
|
273
|
+
### Telegram Behavior
|
|
274
|
+
|
|
275
|
+
- `SNAPSHOT_TEXT_FILE_MAX_BYTES`
|
|
276
|
+
Maximum file size the bot will read as text when building the before/after snapshot for per-run diffs.
|
|
277
|
+
Default: `200000` bytes, about 200 KB
|
|
278
|
+
|
|
279
|
+
- `MAX_TELEGRAM_MESSAGE_LENGTH`
|
|
280
|
+
Max message size used before the app splits responses.
|
|
281
|
+
|
|
282
|
+
- `ENABLE_SENSITIVE_DIFF_FILTER`
|
|
283
|
+
Hide diffs for sensitive paths.
|
|
284
|
+
|
|
285
|
+
### Example `.env` Snippet
|
|
286
|
+
|
|
287
|
+
```env
|
|
288
|
+
WORKSPACE_ROOT=~/git
|
|
289
|
+
TELEGRAM_BOT_TOKENS=bot_token_one,bot_token_two
|
|
290
|
+
ALLOWED_CHAT_IDS=123456789
|
|
291
|
+
|
|
292
|
+
CODEX_BIN=codex
|
|
293
|
+
COPILOT_BIN=copilot
|
|
294
|
+
|
|
295
|
+
CODEX_MODEL=gpt-5.4
|
|
296
|
+
COPILOT_MODEL=claude-sonnet-4.6
|
|
297
|
+
COPILOT_AUTOPILOT=true
|
|
298
|
+
COPILOT_NO_ASK_USER=true
|
|
299
|
+
COPILOT_ALLOW_ALL=true
|
|
300
|
+
COPILOT_ALLOW_ALL_TOOLS=false
|
|
301
|
+
COPILOT_ALLOW_TOOLS=shell(git),shell(npm)
|
|
302
|
+
COPILOT_DENY_TOOLS=shell(rm)
|
|
303
|
+
COPILOT_AVAILABLE_TOOLS=shell,apply_patch
|
|
304
|
+
|
|
305
|
+
CODEX_APPROVAL_POLICY=never
|
|
306
|
+
CODEX_SANDBOX_MODE=workspace-write
|
|
307
|
+
CODEX_SKIP_GIT_REPO_CHECK=false
|
|
308
|
+
|
|
309
|
+
ENABLE_COMMIT_COMMAND=false
|
|
310
|
+
|
|
311
|
+
SNAPSHOT_TEXT_FILE_MAX_BYTES=200000
|
|
312
|
+
LOG_LEVEL=INFO
|
|
313
|
+
LOG_DIR=./logs
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## 🤖 Telegram Commands
|
|
317
|
+
|
|
318
|
+
- `/project <project_folder>`
|
|
319
|
+
Set the current project folder. If the folder does not exist, the app creates it and marks it trusted. If the folder already exists and is still untrusted, the app reminds you to trust it explicitly.
|
|
320
|
+
|
|
321
|
+
- `/new <session_name> [provider]`
|
|
322
|
+
Create a new session for the current project.
|
|
323
|
+
|
|
324
|
+
- `/branch <new_branch>`
|
|
325
|
+
Create a new branch from the repository default branch, after fetching and pulling first.
|
|
326
|
+
|
|
327
|
+
- `/branch <origin_branch> <new_branch>`
|
|
328
|
+
Create a new branch from a specific base branch, after fetching and pulling first.
|
|
329
|
+
|
|
330
|
+
- `/switch`
|
|
331
|
+
Show the latest 10 sessions, newest first.
|
|
332
|
+
|
|
333
|
+
- `/switch page <number>`
|
|
334
|
+
Show another page of stored sessions.
|
|
335
|
+
|
|
336
|
+
- `/switch <session_id>`
|
|
337
|
+
Switch to a specific session by ID.
|
|
338
|
+
|
|
339
|
+
- `/current`
|
|
340
|
+
Show the active session for the current bot and chat.
|
|
341
|
+
|
|
342
|
+
- `/commit <git commands>`
|
|
343
|
+
Run validated git commit-related commands inside the active session project. This command is available only when `ENABLE_COMMIT_COMMAND=true`. The app splits chained input such as `git add ... && git commit ...`, executes only allowed `git` commands, and ignores non-git segments instead of shelling the raw message. Mutating git commands such as `add`, `restore`, and `rm` require the project to be trusted.
|
|
344
|
+
|
|
345
|
+
- `/push`
|
|
346
|
+
Push `origin <branch>` for the current active session. The branch comes from the active session record, or from the current repository branch if the session does not have one stored.
|
|
347
|
+
|
|
348
|
+
## 🧠 Session Model
|
|
349
|
+
|
|
350
|
+
Sessions are scoped by:
|
|
351
|
+
|
|
352
|
+
- Telegram bot
|
|
353
|
+
- Telegram chat
|
|
354
|
+
|
|
355
|
+
That means the same Telegram account can use multiple bots without mixing sessions.
|
|
356
|
+
|
|
357
|
+
Example:
|
|
358
|
+
|
|
359
|
+
- Bot A + your chat -> backend work
|
|
360
|
+
- Bot B + your chat -> frontend work
|
|
361
|
+
- Bot C + your chat -> infra work
|
|
362
|
+
|
|
363
|
+
Each session stores:
|
|
364
|
+
|
|
365
|
+
- session name
|
|
366
|
+
- project folder
|
|
367
|
+
- branch name
|
|
368
|
+
- provider
|
|
369
|
+
- timestamps
|
|
370
|
+
- active session selection for that bot/chat scope
|
|
371
|
+
|
|
372
|
+
## ⚠️ Diff (file changes)
|
|
373
|
+
_During each agent run, the bot also takes a lightweight before/after project snapshot so it can summarize changed files and send diffs back to Telegram. This snapshot is taken by the bot app itself, not by Codex or Copilot._
|
|
374
|
+
|
|
375
|
+
**Snapshot notes:**
|
|
376
|
+
|
|
377
|
+
- the app walks the project directory before and after the run
|
|
378
|
+
- for normal text files, the app prefers the per-run snapshot diff rather than a git-head diff
|
|
379
|
+
- `hidden files` and `hidden directories` are skipped by the snapshot walker by default, git-head diff will be used instead
|
|
380
|
+
- common dependency, cache, and runtime directories are also skipped
|
|
381
|
+
- binary files and files larger than `SNAPSHOT_TEXT_FILE_MAX_BYTES` are not loaded as text
|
|
382
|
+
- for huge projects, this extra scan can add noticeable I/O and memory overhead
|
|
383
|
+
- if the snapshot cannot represent a file as text, the app falls back to git diff when possible
|
|
384
|
+
- for large or non-text files, the diff may still be omitted and replaced with a short unavailable message
|
|
385
|
+
|
|
386
|
+
Snapshot exclusion rules live in package resource files:
|
|
387
|
+
|
|
388
|
+
- `src/coding_agent_telegram/resources/snapshot_excluded_dir_names.txt`
|
|
389
|
+
- `src/coding_agent_telegram/resources/snapshot_excluded_dir_globs.txt`
|
|
390
|
+
- `src/coding_agent_telegram/resources/snapshot_excluded_file_globs.txt`
|
|
391
|
+
|
|
392
|
+
If you want the snapshot diff to include hidden files or hidden directories, remove the `.*` rule from the relevant snapshot exclusion file and restart the bot.
|
|
393
|
+
|
|
394
|
+
## 🌿 Branch Workflow
|
|
395
|
+
|
|
396
|
+
If the selected project is a Git repository, `/project` reports the current branch and reminds you that:
|
|
397
|
+
|
|
398
|
+
- you can keep working on the current branch
|
|
399
|
+
- or create a dedicated work branch with `/branch`
|
|
400
|
+
|
|
401
|
+
When you run `/branch`, the app:
|
|
402
|
+
|
|
403
|
+
- requires `/project` to be set first
|
|
404
|
+
- detects the default branch if you do not specify one
|
|
405
|
+
- runs `git fetch origin`
|
|
406
|
+
- checks out the base branch
|
|
407
|
+
- runs `git pull --ff-only origin <base-branch>`
|
|
408
|
+
- creates and switches to the new branch
|
|
409
|
+
|
|
410
|
+
The chosen branch is stored with the session, so switching sessions restores the expected branch before the agent continues work.
|
|
411
|
+
|
|
412
|
+
## 🔐 Git Trust Behavior
|
|
413
|
+
|
|
414
|
+
- Existing folders follow `CODEX_SKIP_GIT_REPO_CHECK`
|
|
415
|
+
- Folders created through `/project <name>` are marked as trusted by this app
|
|
416
|
+
- Existing folders selected through `/project <name>` remain untrusted until you confirm trust in the Telegram prompt
|
|
417
|
+
- That means newly created project folders can be used immediately
|
|
418
|
+
- `/commit` can be disabled entirely with `ENABLE_COMMIT_COMMAND`
|
|
419
|
+
- Mutating `/commit` operations are allowed only for trusted projects
|
|
420
|
+
|
|
421
|
+
## 🪵 Logs
|
|
422
|
+
|
|
423
|
+
Logs are written under `LOG_DIR`.
|
|
424
|
+
|
|
425
|
+
Main log file:
|
|
426
|
+
|
|
427
|
+
- `coding-agent-telegram.log`
|
|
428
|
+
|
|
429
|
+
Typical logged events:
|
|
430
|
+
|
|
431
|
+
- bot startup and polling start
|
|
432
|
+
- project selection
|
|
433
|
+
- session creation
|
|
434
|
+
- session switching
|
|
435
|
+
- active session reporting
|
|
436
|
+
- normal run execution
|
|
437
|
+
- session replacement after resume failure
|
|
438
|
+
- warnings and runtime errors
|
|
439
|
+
|
|
440
|
+
## 🗂️ Project Structure
|
|
441
|
+
|
|
442
|
+
- `src/coding_agent_telegram/`
|
|
443
|
+
Main application code
|
|
444
|
+
|
|
445
|
+
- `tests/`
|
|
446
|
+
Test suite
|
|
447
|
+
|
|
448
|
+
- `startup.sh`
|
|
449
|
+
Local bootstrap and startup entrypoint
|
|
450
|
+
|
|
451
|
+
- `src/coding_agent_telegram/resources/.env.example`
|
|
452
|
+
Canonical environment template used by both repo startup and packaged installs
|
|
453
|
+
|
|
454
|
+
- `pyproject.toml`
|
|
455
|
+
Packaging and dependency configuration
|
|
456
|
+
|
|
457
|
+
## 🛠️ Typical Local Flow
|
|
458
|
+
|
|
459
|
+
```bash
|
|
460
|
+
./startup.sh
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
Then in Telegram:
|
|
464
|
+
|
|
465
|
+
```text
|
|
466
|
+
/project my-project
|
|
467
|
+
/new my-session
|
|
468
|
+
Fix the failing API test in the current project
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
## 📌 Notes
|
|
472
|
+
|
|
473
|
+
- This project is designed for users running the agents locally on their own machine.
|
|
474
|
+
- The Telegram bot is a control surface, not the execution environment itself.
|
|
475
|
+
- If you run multiple bots, all of them can be managed by one server process.
|