claude-code-tg 0.8.3__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.
Files changed (127) hide show
  1. claude_code_tg-0.8.3/.editorconfig +18 -0
  2. claude_code_tg-0.8.3/.env.example +62 -0
  3. claude_code_tg-0.8.3/.gitattributes +22 -0
  4. claude_code_tg-0.8.3/.github/CODEOWNERS +24 -0
  5. claude_code_tg-0.8.3/.github/ISSUE_TEMPLATE/bug_report.md +62 -0
  6. claude_code_tg-0.8.3/.github/ISSUE_TEMPLATE/config.yml +8 -0
  7. claude_code_tg-0.8.3/.github/ISSUE_TEMPLATE/feature_request.md +39 -0
  8. claude_code_tg-0.8.3/.github/ISSUE_TEMPLATE/question.md +56 -0
  9. claude_code_tg-0.8.3/.github/pull_request_template.md +21 -0
  10. claude_code_tg-0.8.3/.github/workflows/ci.yml +64 -0
  11. claude_code_tg-0.8.3/.github/workflows/release.yml +52 -0
  12. claude_code_tg-0.8.3/.gitignore +30 -0
  13. claude_code_tg-0.8.3/AGENTS.md +117 -0
  14. claude_code_tg-0.8.3/CHANGELOG.md +106 -0
  15. claude_code_tg-0.8.3/CODE_OF_CONDUCT.md +60 -0
  16. claude_code_tg-0.8.3/CONTRIBUTING.md +93 -0
  17. claude_code_tg-0.8.3/LICENSE +21 -0
  18. claude_code_tg-0.8.3/MAINTAINERS.md +53 -0
  19. claude_code_tg-0.8.3/PKG-INFO +245 -0
  20. claude_code_tg-0.8.3/README.en.md +203 -0
  21. claude_code_tg-0.8.3/README.md +203 -0
  22. claude_code_tg-0.8.3/SECURITY.md +69 -0
  23. claude_code_tg-0.8.3/SUPPORT.md +57 -0
  24. claude_code_tg-0.8.3/docs/architecture.md +223 -0
  25. claude_code_tg-0.8.3/docs/assets/tgcc-demo.svg +38 -0
  26. claude_code_tg-0.8.3/docs/compatibility.md +76 -0
  27. claude_code_tg-0.8.3/docs/dev/e2e/telegram-e2e-findings.md +42 -0
  28. claude_code_tg-0.8.3/docs/dev/e2e/telegram-e2e.md +276 -0
  29. claude_code_tg-0.8.3/docs/dev/project-memory.md +174 -0
  30. claude_code_tg-0.8.3/docs/index.md +48 -0
  31. claude_code_tg-0.8.3/docs/operator-guide.md +113 -0
  32. claude_code_tg-0.8.3/docs/quickstart.md +172 -0
  33. claude_code_tg-0.8.3/docs/roadmap.md +51 -0
  34. claude_code_tg-0.8.3/docs/security-model.md +86 -0
  35. claude_code_tg-0.8.3/docs/troubleshooting.md +152 -0
  36. claude_code_tg-0.8.3/docs/user-guide.md +302 -0
  37. claude_code_tg-0.8.3/pyproject.toml +95 -0
  38. claude_code_tg-0.8.3/scripts/e2e_log_scan.py +113 -0
  39. claude_code_tg-0.8.3/scripts/e2e_macos_click.py +142 -0
  40. claude_code_tg-0.8.3/scripts/e2e_mini_app_api.py +498 -0
  41. claude_code_tg-0.8.3/scripts/e2e_preflight.py +231 -0
  42. claude_code_tg-0.8.3/scripts/e2e_prepare_assets.py +205 -0
  43. claude_code_tg-0.8.3/scripts/e2e_reset_telegram_menu.py +174 -0
  44. claude_code_tg-0.8.3/scripts/validate_local.py +69 -0
  45. claude_code_tg-0.8.3/src/claude_code_tg/__init__.py +0 -0
  46. claude_code_tg-0.8.3/src/claude_code_tg/attachment_cleanup.py +132 -0
  47. claude_code_tg-0.8.3/src/claude_code_tg/attachments.py +244 -0
  48. claude_code_tg-0.8.3/src/claude_code_tg/bot.py +509 -0
  49. claude_code_tg-0.8.3/src/claude_code_tg/bot_app.py +326 -0
  50. claude_code_tg-0.8.3/src/claude_code_tg/bot_commands.py +1281 -0
  51. claude_code_tg-0.8.3/src/claude_code_tg/bot_processing.py +398 -0
  52. claude_code_tg-0.8.3/src/claude_code_tg/claude_sessions.py +375 -0
  53. claude_code_tg-0.8.3/src/claude_code_tg/cli.py +456 -0
  54. claude_code_tg-0.8.3/src/claude_code_tg/cli_init.py +391 -0
  55. claude_code_tg-0.8.3/src/claude_code_tg/cli_instances.py +169 -0
  56. claude_code_tg-0.8.3/src/claude_code_tg/cli_parser.py +182 -0
  57. claude_code_tg-0.8.3/src/claude_code_tg/command_menu.py +330 -0
  58. claude_code_tg-0.8.3/src/claude_code_tg/command_view.py +107 -0
  59. claude_code_tg-0.8.3/src/claude_code_tg/config.py +235 -0
  60. claude_code_tg-0.8.3/src/claude_code_tg/diagnostics.py +517 -0
  61. claude_code_tg-0.8.3/src/claude_code_tg/executor.py +841 -0
  62. claude_code_tg-0.8.3/src/claude_code_tg/file_security.py +351 -0
  63. claude_code_tg-0.8.3/src/claude_code_tg/instance_store.py +208 -0
  64. claude_code_tg-0.8.3/src/claude_code_tg/interaction_log.py +64 -0
  65. claude_code_tg-0.8.3/src/claude_code_tg/message_input.py +142 -0
  66. claude_code_tg-0.8.3/src/claude_code_tg/message_output.py +57 -0
  67. claude_code_tg-0.8.3/src/claude_code_tg/pending_reply.py +64 -0
  68. claude_code_tg-0.8.3/src/claude_code_tg/process_control.py +58 -0
  69. claude_code_tg-0.8.3/src/claude_code_tg/py.typed +1 -0
  70. claude_code_tg-0.8.3/src/claude_code_tg/result_view.py +99 -0
  71. claude_code_tg-0.8.3/src/claude_code_tg/resume_view.py +113 -0
  72. claude_code_tg-0.8.3/src/claude_code_tg/run_view.py +618 -0
  73. claude_code_tg-0.8.3/src/claude_code_tg/sanitizer.py +45 -0
  74. claude_code_tg-0.8.3/src/claude_code_tg/server.py +142 -0
  75. claude_code_tg-0.8.3/src/claude_code_tg/sessions.py +402 -0
  76. claude_code_tg-0.8.3/src/claude_code_tg/telegram_ui.py +123 -0
  77. claude_code_tg-0.8.3/src/claude_code_tg/utils.py +133 -0
  78. claude_code_tg-0.8.3/src/claude_code_tg/web_console.py +260 -0
  79. claude_code_tg-0.8.3/tests/__init__.py +0 -0
  80. claude_code_tg-0.8.3/tests/bot_helpers.py +74 -0
  81. claude_code_tg-0.8.3/tests/test_attachment_cleanup.py +278 -0
  82. claude_code_tg-0.8.3/tests/test_attachments.py +422 -0
  83. claude_code_tg-0.8.3/tests/test_bot.py +2774 -0
  84. claude_code_tg-0.8.3/tests/test_bot_app.py +371 -0
  85. claude_code_tg-0.8.3/tests/test_bot_attachments.py +294 -0
  86. claude_code_tg-0.8.3/tests/test_bot_processing.py +361 -0
  87. claude_code_tg-0.8.3/tests/test_claude_sessions.py +319 -0
  88. claude_code_tg-0.8.3/tests/test_cli.py +98 -0
  89. claude_code_tg-0.8.3/tests/test_cli_attachments.py +171 -0
  90. claude_code_tg-0.8.3/tests/test_cli_bulk.py +180 -0
  91. claude_code_tg-0.8.3/tests/test_cli_doctor.py +531 -0
  92. claude_code_tg-0.8.3/tests/test_cli_init.py +441 -0
  93. claude_code_tg-0.8.3/tests/test_cli_instances.py +225 -0
  94. claude_code_tg-0.8.3/tests/test_cli_logs.py +183 -0
  95. claude_code_tg-0.8.3/tests/test_cli_parser.py +99 -0
  96. claude_code_tg-0.8.3/tests/test_cli_start.py +431 -0
  97. claude_code_tg-0.8.3/tests/test_cli_status.py +95 -0
  98. claude_code_tg-0.8.3/tests/test_cli_stop.py +210 -0
  99. claude_code_tg-0.8.3/tests/test_command_menu.py +254 -0
  100. claude_code_tg-0.8.3/tests/test_command_view.py +49 -0
  101. claude_code_tg-0.8.3/tests/test_config.py +186 -0
  102. claude_code_tg-0.8.3/tests/test_diagnostics.py +354 -0
  103. claude_code_tg-0.8.3/tests/test_e2e_log_scan.py +86 -0
  104. claude_code_tg-0.8.3/tests/test_e2e_macos_click.py +86 -0
  105. claude_code_tg-0.8.3/tests/test_e2e_mini_app_api.py +134 -0
  106. claude_code_tg-0.8.3/tests/test_e2e_preflight.py +151 -0
  107. claude_code_tg-0.8.3/tests/test_e2e_prepare_assets.py +95 -0
  108. claude_code_tg-0.8.3/tests/test_e2e_reset_telegram_menu.py +101 -0
  109. claude_code_tg-0.8.3/tests/test_executor.py +1458 -0
  110. claude_code_tg-0.8.3/tests/test_file_security.py +1008 -0
  111. claude_code_tg-0.8.3/tests/test_instance_store.py +312 -0
  112. claude_code_tg-0.8.3/tests/test_main.py +405 -0
  113. claude_code_tg-0.8.3/tests/test_message_input.py +41 -0
  114. claude_code_tg-0.8.3/tests/test_message_output.py +57 -0
  115. claude_code_tg-0.8.3/tests/test_process_control.py +219 -0
  116. claude_code_tg-0.8.3/tests/test_repository_secrets.py +29 -0
  117. claude_code_tg-0.8.3/tests/test_result_view.py +55 -0
  118. claude_code_tg-0.8.3/tests/test_resume_view.py +64 -0
  119. claude_code_tg-0.8.3/tests/test_run_view.py +331 -0
  120. claude_code_tg-0.8.3/tests/test_sanitizer.py +125 -0
  121. claude_code_tg-0.8.3/tests/test_sessions.py +308 -0
  122. claude_code_tg-0.8.3/tests/test_telegram_ui.py +30 -0
  123. claude_code_tg-0.8.3/tests/test_utils.py +215 -0
  124. claude_code_tg-0.8.3/tests/test_validate_local.py +89 -0
  125. claude_code_tg-0.8.3/tests/test_web_console.py +328 -0
  126. claude_code_tg-0.8.3/tests/token_fixtures.py +14 -0
  127. claude_code_tg-0.8.3/uv.lock +676 -0
@@ -0,0 +1,18 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ insert_final_newline = true
7
+ indent_style = space
8
+ indent_size = 4
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.{yml,yaml}]
12
+ indent_size = 2
13
+
14
+ [*.toml]
15
+ indent_size = 2
16
+
17
+ [*.md]
18
+ trim_trailing_whitespace = false
@@ -0,0 +1,62 @@
1
+ # tgcc 配置模板
2
+ # 复制为 .env 后填写,并执行 chmod 600 .env(tgcc init 会自动设好权限)。
3
+ # 不要把真实 token 提交到 git。每个实例用一个独立的 BotFather token。
4
+ # 也可以直接运行 `tgcc init` 交互式生成本文件。
5
+
6
+ # ── 必填 ──────────────────────────────────────────────
7
+ # Bot Token:在 Telegram 找 @BotFather 创建 bot 获取
8
+ TELEGRAM_BOT_TOKEN=
9
+ # 你的 Telegram 数字 User ID(不是 @用户名):找 @userinfobot 获取
10
+ # 多个用逗号分隔;admin 拥有最高权限,请保持范围最小
11
+ ADMIN_USER_IDS=
12
+
13
+ # ── 常用(已有默认值,可不改)─────────────────────────
14
+ # 其他允许使用本 bot 的用户 ID,逗号分隔;留空则仅 admin 可用
15
+ ALLOWED_USER_IDS=
16
+ # Claude 可读写的项目目录(默认当前目录);改动后建议跑 tgcc doctor
17
+ CLAUDE_PROJECT_DIR=.
18
+ # 权限模式:bypassPermissions(信任本地项目)| default | plan(更严格)
19
+ # 项目目录不完全可信时,改成 default 或 plan
20
+ CLAUDE_PERMISSION_MODE=bypassPermissions
21
+ # 模型别名或完整名(如 opus / sonnet / haiku);留空用 Claude Code 默认
22
+ CLAUDE_MODEL=
23
+ # 思考强度:low / medium / high / xhigh / max / ultracode;留空用 Claude Code 默认
24
+ CLAUDE_EFFORT=
25
+ # 单次执行超时(秒)
26
+ CLAUDE_TIMEOUT=300
27
+ # 排队等待的最大消息数
28
+ QUEUE_MAX_SIZE=3
29
+
30
+ # ── 附件 ──────────────────────────────────────────────
31
+ # 附件处理方式:path(传本地路径给 Claude,推荐)
32
+ # | copy-to-project(复制进项目目录)| reject(禁用文件上传)
33
+ ATTACHMENT_MODE=path
34
+ # 单个附件大小上限(MB)
35
+ ATTACHMENT_MAX_MB=20
36
+ # 附件缓存保留天数;留空或 0 表示不自动清理
37
+ ATTACHMENT_RETENTION_DAYS=
38
+
39
+ # ── 高级 ──────────────────────────────────────────────
40
+ # 危险:旧式的全量权限绕过;true 仅用于完全可信的项目目录
41
+ CLAUDE_SKIP_PERMISSIONS=false
42
+ # 改写 tgcc 的 transcript 入口,使本地 Claude Code /resume 能看到
43
+ # 由 Telegram 发起的会话;默认关闭
44
+ CLAUDE_CLI_RESUME_COMPAT=false
45
+ # 记录交互日志(已脱敏)
46
+ LOG_INTERACTIONS=false
47
+ # 在 Telegram 命令菜单中透传 Claude 的 slash 命令
48
+ CLAUDE_COMMAND_MENU=false
49
+ # 在私聊中流式显示临时草稿预览;默认关闭
50
+ TELEGRAM_DRAFT_PREVIEW=false
51
+
52
+ # ── Mini App(可选的 HTTPS 控制台)────────────────────
53
+ # 启用 Telegram Mini App 控制台
54
+ TELEGRAM_MINI_APP_ENABLED=false
55
+ # Mini App 对外可访问的 HTTPS 地址(启用时必填)
56
+ TELEGRAM_MINI_APP_PUBLIC_URL=
57
+ # 本地监听地址
58
+ TELEGRAM_MINI_APP_HOST=127.0.0.1
59
+ # 本地监听端口
60
+ TELEGRAM_MINI_APP_PORT=8787
61
+ # Mini App 在 Telegram 菜单中显示的文字
62
+ TELEGRAM_MINI_APP_MENU_TEXT=tgcc
@@ -0,0 +1,22 @@
1
+ # Normalize text files across platforms.
2
+ * text=auto eol=lf
3
+
4
+ # Source, docs, and config files are reviewed as text.
5
+ *.py text eol=lf
6
+ *.md text eol=lf
7
+ *.toml text eol=lf
8
+ *.yml text eol=lf
9
+ *.yaml text eol=lf
10
+ *.json text eol=lf
11
+ *.txt text eol=lf
12
+ *.svg text eol=lf
13
+
14
+ # Binary assets should not be line-ending normalized.
15
+ *.png binary
16
+ *.jpg binary
17
+ *.jpeg binary
18
+ *.gif binary
19
+ *.ico binary
20
+ *.pdf binary
21
+ *.zip binary
22
+ *.tar.gz binary
@@ -0,0 +1,24 @@
1
+ # Maintainer ownership for security and runtime boundaries.
2
+ * @Ike-li
3
+
4
+ /.github/ @Ike-li
5
+ /SECURITY.md @Ike-li
6
+ /SUPPORT.md @Ike-li
7
+ /CONTRIBUTING.md @Ike-li
8
+ /CODE_OF_CONDUCT.md @Ike-li
9
+ /MAINTAINERS.md @Ike-li
10
+ /README.en.md @Ike-li
11
+ /pyproject.toml @Ike-li
12
+ /CHANGELOG.md @Ike-li
13
+ /scripts/validate_local.py @Ike-li
14
+ /src/claude_code_tg/ @Ike-li
15
+ /tests/ @Ike-li
16
+ /docs/index.md @Ike-li
17
+ /docs/quickstart.md @Ike-li
18
+ /docs/troubleshooting.md @Ike-li
19
+ /docs/architecture.md @Ike-li
20
+ /docs/user-guide.md @Ike-li
21
+ /docs/operator-guide.md @Ike-li
22
+ /docs/compatibility.md @Ike-li
23
+ /docs/roadmap.md @Ike-li
24
+ /docs/security-model.md @Ike-li
@@ -0,0 +1,62 @@
1
+ ---
2
+ name: Bug report
3
+ about: Report a reproducible tgcc problem
4
+ title: "[Bug]: "
5
+ labels: bug, needs triage
6
+ assignees: ""
7
+ ---
8
+
9
+ ## What happened?
10
+
11
+ Describe the problem and the expected behavior.
12
+
13
+ ## Steps to reproduce
14
+
15
+ 1.
16
+ 2.
17
+ 3.
18
+
19
+ ## Environment
20
+
21
+ - tgcc version or commit: run `tgcc --version`, or include the exact commit
22
+ - Python version:
23
+ - OS:
24
+ - Claude Code CLI version:
25
+ - Install method: `uv tool install "git+https://github.com/Ike-li/claude-code-tg.git"` / `uv tool install -e .` / `uv sync` / other
26
+
27
+ ## Configuration shape
28
+
29
+ Do not paste secrets, tokens, chat transcripts, unsanitized logs, or local
30
+ filesystem paths. Include only safe values such as:
31
+
32
+ ```env
33
+ CLAUDE_PROJECT_DIR=
34
+ CLAUDE_TIMEOUT=
35
+ QUEUE_MAX_SIZE=
36
+ CLAUDE_PERMISSION_MODE=
37
+ CLAUDE_MODEL=
38
+ ATTACHMENT_MAX_MB=
39
+ ATTACHMENT_MODE=
40
+ ATTACHMENT_RETENTION_DAYS=
41
+ CLAUDE_SKIP_PERMISSIONS=
42
+ ```
43
+
44
+ ## Logs
45
+
46
+ Paste relevant sanitized output from:
47
+
48
+ ```bash
49
+ tgcc doctor --env <file>
50
+ tgcc status --env <file>
51
+ tgcc logs --env <file> -n 100
52
+ ```
53
+
54
+ ## Additional context
55
+
56
+ Screenshots, Telegram message examples, or suspected related changes. Redact
57
+ personal data before sharing anything publicly.
58
+
59
+ ## Privacy checklist
60
+
61
+ - [ ] I did not include Telegram bot tokens, `.env` files, Claude credentials, API keys, private chat transcripts, unsanitized logs, local filesystem paths, screenshots with personal data, or exploit details.
62
+ - [ ] This is not a security vulnerability report. Security-sensitive reports should follow SECURITY.md instead of public issues.
@@ -0,0 +1,8 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: Security vulnerability report
4
+ url: https://github.com/Ike-li/claude-code-tg/security/advisories/new
5
+ about: Report vulnerabilities privately instead of posting tokens, logs, chat transcripts, or exploit details in public issues.
6
+ - name: Support policy
7
+ url: https://github.com/Ike-li/claude-code-tg/blob/main/SUPPORT.md
8
+ about: Check support scope, reporting paths, and what not to share publicly.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest a focused improvement for tgcc
4
+ title: "[Feature]: "
5
+ labels: enhancement, needs triage
6
+ assignees: ""
7
+ ---
8
+
9
+ ## Problem
10
+
11
+ What user problem should this solve?
12
+
13
+ ## Proposed behavior
14
+
15
+ Describe the smallest useful behavior that would solve it.
16
+
17
+ ## Why this fits tgcc
18
+
19
+ tgcc is intentionally a lightweight, self-hosted Claude Code Telegram manager.
20
+ Explain how the feature supports that positioning.
21
+
22
+ ## Environment / scope
23
+
24
+ If this depends on setup, include safe non-secret context.
25
+
26
+ - tgcc version or commit (if known): run `tgcc --version`, or include the exact commit
27
+ - Install method: `uv tool install "git+https://github.com/Ike-li/claude-code-tg.git"` / `uv tool install -e .` / `uv sync` / not applicable
28
+ - Runtime area: Telegram bot / CLI / docs / release process / other
29
+
30
+ ## Alternatives considered
31
+
32
+ What workaround or different approach did you consider?
33
+
34
+ ## Acceptance checks
35
+
36
+ - [ ] Documentation updated
37
+ - [ ] Tests or smoke steps included
38
+ - [ ] Security/privacy impact considered
39
+ - [ ] No tokens, chat transcripts, unsanitized logs, local filesystem paths, or private chat content included
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: Question / help
3
+ about: Ask for setup or usage help within tgcc support scope
4
+ title: "[Question]: "
5
+ labels: question, needs triage
6
+ assignees: ""
7
+ ---
8
+
9
+ ## What are you trying to do?
10
+
11
+ Describe the setup, command, or Telegram workflow you are trying to complete.
12
+
13
+ ## Where are you stuck?
14
+
15
+ Describe what happened, what you expected, and which README or troubleshooting
16
+ step you already tried.
17
+
18
+ ## Environment
19
+
20
+ - tgcc version or commit: run `tgcc --version`, or include the exact commit
21
+ - Python version:
22
+ - OS:
23
+ - Claude Code CLI version:
24
+ - Install method: `uv tool install "git+https://github.com/Ike-li/claude-code-tg.git"` / `uv tool install -e .` / `uv sync` / other
25
+
26
+ ## Configuration shape
27
+
28
+ Do not paste secrets, tokens, chat transcripts, unsanitized logs, or local
29
+ filesystem paths. Include only safe values such as:
30
+
31
+ ```env
32
+ CLAUDE_PROJECT_DIR=
33
+ CLAUDE_TIMEOUT=
34
+ QUEUE_MAX_SIZE=
35
+ CLAUDE_PERMISSION_MODE=
36
+ CLAUDE_MODEL=
37
+ ATTACHMENT_MAX_MB=
38
+ ATTACHMENT_MODE=
39
+ ATTACHMENT_RETENTION_DAYS=
40
+ CLAUDE_SKIP_PERMISSIONS=
41
+ ```
42
+
43
+ ## Diagnostics
44
+
45
+ Paste relevant sanitized output from:
46
+
47
+ ```bash
48
+ tgcc doctor --env <file>
49
+ tgcc status --env <file>
50
+ tgcc logs --env <file> -n 100
51
+ ```
52
+
53
+ ## Privacy checklist
54
+
55
+ - [ ] I did not include Telegram bot tokens, `.env` files, Claude credentials, API keys, private chat transcripts, unsanitized logs, local filesystem paths, screenshots with personal data, or exploit details.
56
+ - [ ] This is not a security vulnerability report. Security-sensitive reports should follow SECURITY.md instead of public issues.
@@ -0,0 +1,21 @@
1
+ ## Summary
2
+
3
+ Describe the user-facing change and why it belongs in tgcc.
4
+
5
+ ## Checks
6
+
7
+ - [ ] I kept the change focused and consistent with the lightweight self-hosted scope.
8
+ - [ ] I updated README/docs when behavior, setup, or security expectations changed.
9
+ - [ ] I added or updated tests for user-visible behavior.
10
+ - [ ] I ran `uv run python scripts/validate_local.py` or documented the skipped check below.
11
+ - [ ] I ran tests, `uv run ruff check .`, `uv run --extra dev mypy`, `uv run ruff format --check .`, and `uv build`.
12
+ - [ ] I did not include `.env` files, tokens, unsanitized logs, local filesystem paths, chat transcripts, or private chat content.
13
+
14
+ ## Security And Privacy Impact
15
+
16
+ - [ ] I considered whether this changes token handling, `.env` files, logs, local paths, chat transcripts, attachments, Claude permission modes, GitHub Actions, or release artifacts.
17
+ - [ ] Security-sensitive changes update `SECURITY.md` or `docs/security-model.md` as needed.
18
+
19
+ ## Notes
20
+
21
+ Mention any known gaps, skipped checks, or follow-up work.
@@ -0,0 +1,64 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.ref }}
12
+ cancel-in-progress: true
13
+
14
+ env:
15
+ UV_VERSION: "0.11.17"
16
+
17
+ jobs:
18
+ test:
19
+ runs-on: ubuntu-latest
20
+ timeout-minutes: 20
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ python-version: ["3.11", "3.12", "3.13"]
25
+
26
+ steps:
27
+ - name: Check out repository
28
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # actions/checkout@v6.0.2
29
+ with:
30
+ persist-credentials: false
31
+
32
+ - name: Set up Python
33
+ uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # actions/setup-python@v6.2.0
34
+ with:
35
+ python-version: ${{ matrix.python-version }}
36
+
37
+ - name: Install uv
38
+ run: python -m pip install --upgrade pip "uv==${UV_VERSION}"
39
+
40
+ - name: Install dependencies
41
+ run: uv sync --extra dev --frozen
42
+
43
+ - name: Run tests
44
+ run: uv run pytest --cov=claude_code_tg --cov-report=term-missing --cov-report=xml
45
+
46
+ - name: Upload coverage XML
47
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # actions/upload-artifact@v7.0.1
48
+ with:
49
+ name: coverage-${{ matrix.python-version }}
50
+ path: coverage.xml
51
+ if-no-files-found: error
52
+ retention-days: 14
53
+
54
+ - name: Run ruff
55
+ run: uv run ruff check .
56
+
57
+ - name: Run mypy
58
+ run: uv run --extra dev mypy
59
+
60
+ - name: Check formatting
61
+ run: uv run ruff format --check .
62
+
63
+ - name: Build distributions
64
+ run: uv build
@@ -0,0 +1,52 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ env:
12
+ UV_VERSION: "0.11.17"
13
+
14
+ jobs:
15
+ publish:
16
+ name: Build and publish to PyPI
17
+ runs-on: ubuntu-latest
18
+ timeout-minutes: 15
19
+ environment:
20
+ name: pypi
21
+ url: https://pypi.org/p/claude-code-tg
22
+ permissions:
23
+ id-token: write # required for PyPI Trusted Publishing (OIDC)
24
+ steps:
25
+ - name: Check out repository
26
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # actions/checkout@v6.0.2
27
+ with:
28
+ persist-credentials: false
29
+
30
+ - name: Set up Python
31
+ uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # actions/setup-python@v6.2.0
32
+ with:
33
+ python-version: "3.12"
34
+
35
+ - name: Install uv
36
+ run: python -m pip install --upgrade pip "uv==${UV_VERSION}"
37
+
38
+ - name: Verify tag matches package version
39
+ run: |
40
+ pkg_version="$(grep -m1 '^version = ' pyproject.toml | sed -E 's/version = "(.*)"/\1/')"
41
+ tag_version="${GITHUB_REF_NAME#v}"
42
+ echo "pyproject version: ${pkg_version}; tag: ${tag_version}"
43
+ if [ "${pkg_version}" != "${tag_version}" ]; then
44
+ echo "::error::Tag ${tag_version} does not match pyproject version ${pkg_version}"
45
+ exit 1
46
+ fi
47
+
48
+ - name: Build distributions
49
+ run: uv build
50
+
51
+ - name: Publish to PyPI
52
+ uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # pypa/gh-action-pypi-publish@v1.14.0
@@ -0,0 +1,30 @@
1
+ # Environment and secrets
2
+ .env
3
+ *.env
4
+
5
+ # Python
6
+ __pycache__/
7
+ *.py[cod]
8
+ .pytest_cache/
9
+ .ruff_cache/
10
+ .mypy_cache/
11
+ .coverage
12
+ .coverage.*
13
+ coverage.xml
14
+ htmlcov/
15
+ dist/
16
+ build/
17
+ *.egg-info/
18
+ .venv/
19
+ .hypothesis/
20
+
21
+ # IDE and local orchestration
22
+ .idea/
23
+ .vscode/
24
+ .omc/
25
+ .omx/
26
+ .antigravitycli
27
+ .tgcc-attachments/
28
+
29
+ # OS noise
30
+ .DS_Store
@@ -0,0 +1,117 @@
1
+ # Repository Guidelines
2
+
3
+ ## Project Structure & Module Organization
4
+
5
+ This is a Python 3.11+ package for bridging Telegram chats to the Claude Code CLI.
6
+ Source lives in `src/claude_code_tg/`; the main areas are bot wiring
7
+ (`bot.py`, `bot_app.py`, `bot_commands.py`), the CLI (`cli.py`, `cli_parser.py`,
8
+ `cli_init.py`, `cli_instances.py`) and config (`config.py`), Claude execution
9
+ (`executor.py`), sessions (`sessions.py`, `claude_sessions.py`), command menu
10
+ (`command_menu.py`), attachments, diagnostics, interaction logging, and
11
+ file-security helpers. See `docs/architecture.md` for the full module map. Tests
12
+ live in `tests/` and mirror source modules with `test_*.py` files. User docs
13
+ live in `docs/`; contributor/maintainer notes live in `docs/dev/`; assets are
14
+ under `docs/assets/`. Local helper scripts live in `scripts/`.
15
+
16
+ ## Build, Test, and Development Commands
17
+
18
+ - `uv run python scripts/validate_local.py` runs the full local gate: pytest with
19
+ coverage, Ruff lint, mypy, Ruff format check, and package build.
20
+ - `uv run pytest` runs the test suite. Use paths for focused runs, for example
21
+ `uv run pytest tests/test_bot.py`.
22
+ - `uv run ruff check .` checks linting and import ordering.
23
+ - `uv run --extra dev mypy` type-checks `src/claude_code_tg`.
24
+ - `uv build` builds the sdist and wheel.
25
+ - `uv run tgcc --help` inspects the installed CLI entry point locally.
26
+
27
+ ## Session Handoff
28
+
29
+ When opening a fresh maintainer or agent session, read
30
+ `docs/dev/project-memory.md` first, then run `git log -2 --oneline` before
31
+ making assumptions about current state. For Telegram E2E work, also read
32
+ `docs/dev/e2e/telegram-e2e.md` and `docs/dev/e2e/telegram-e2e-findings.md`
33
+ before starting a real-client run.
34
+
35
+ ## Documentation Maintenance
36
+
37
+ Use `docs/index.md` as the document map before adding or moving docs. Keep
38
+ `README.md` as the Chinese landing page, `README.en.md` as the English landing
39
+ page (kept in parity with the Chinese one), `docs/quickstart.md` as the shortest
40
+ first-run path, and `docs/user-guide.md` as the source of truth for day-to-day
41
+ Telegram behavior. Prefer linking to the specific owner document over repeating
42
+ setup, security, or E2E details in multiple files.
43
+
44
+ Do not add new run-specific Telegram E2E docs for ordinary test passes; update
45
+ `docs/dev/e2e/telegram-e2e.md` for procedure changes and
46
+ `docs/dev/e2e/telegram-e2e-findings.md` for compact closure notes. Use
47
+ `docs/dev/project-memory.md` only for current handoff state, not long-lived user
48
+ documentation.
49
+
50
+ ## Coding Style & Naming Conventions
51
+
52
+ Use 4-space indentation, type annotations for public/internal boundaries, and
53
+ clear `snake_case` names for modules, functions, variables, and tests. Keep code
54
+ small and explicit; prefer existing helpers for sessions, file safety, output
55
+ pagination, and command parsing. Ruff controls formatting-adjacent lint rules
56
+ and import ordering; do not hand-format around it.
57
+
58
+ ## Testing Guidelines
59
+
60
+ Tests use `pytest`, `pytest-asyncio`, and `pytest-cov`; coverage must stay at or
61
+ above 85%. Name tests `test_<behavior>` and group related cases in `Test...`
62
+ classes. Use `AsyncMock`/fixtures instead of real Telegram network calls. Mark
63
+ real subprocess integration tests with `@pytest.mark.slow` when needed.
64
+
65
+ ## Telegram E2E Notes
66
+
67
+ Use a dedicated test bot, ignored env file, throwaway project directory, and
68
+ real Telegram client for end-to-end Telegram validation. Do not write tokens,
69
+ numeric Telegram IDs, full session IDs, tunnel URLs, private logs, or attachment
70
+ caches into docs or commits. Avoid direct `getUpdates` while polling is active;
71
+ it conflicts with the running bot and pollutes logs.
72
+
73
+ E2E local artifacts have fixed homes: keep test env files such as
74
+ `cctg_test.env` at the repository root where `*.env` ignores them, keep
75
+ temporary Mini App HTTPS tunnel URLs only in that ignored env file while active,
76
+ keep the throwaway Claude project outside this repository via
77
+ `CLAUDE_PROJECT_DIR`, and rely on `$HOME/.tgcc/` for runtime state/logs. Telegram
78
+ test groups and BotFather settings live in Telegram itself, not in git.
79
+
80
+ Telegram E2E procedure and historical closure status are captured under
81
+ `docs/dev/e2e/`. Notable lessons:
82
+ Computer Use is useful for Telegram buttons, ForceReply, and Mini App menu
83
+ checks, but it uses the user's active Mac pointer, keyboard, and focused
84
+ window; it is not an isolated second keyboard/mouse. Telegram Desktop attachment
85
+ preview and replying to an older bot message are fragile to automate. Natural
86
+ non-command group `@bot` mentions require BotFather privacy to be disabled;
87
+ slash commands addressed to the bot work with privacy enabled. Real Mini App
88
+ menu testing needs a temporary HTTPS tunnel and cleanup of both default and
89
+ chat-specific menu buttons; use
90
+ `uv run python scripts/e2e_reset_telegram_menu.py --env cctg_test.env` for the
91
+ cleanup step. Use `uv run python scripts/e2e_log_scan.py --env cctg_test.env`
92
+ for sanitized final log scans instead of pasting raw logs.
93
+ Start E2E runs with `uv run python scripts/e2e_preflight.py --env cctg_test.env`
94
+ to verify the ignored env file, owner-only permissions, outside-repo project,
95
+ and cleanup defaults without printing secrets. Then run
96
+ `uv run python scripts/e2e_prepare_assets.py --env cctg_test.env` to create
97
+ synthetic upload files and copyable prompts under the throwaway project instead
98
+ of using private local files. For macOS Telegram Desktop button-heavy batches,
99
+ run `uv run python scripts/e2e_macos_click.py --preflight`; if it passes, use
100
+ that helper with `--dry-run` first to click Telegram window-relative coordinates
101
+ when Computer Use coordinate clicks are unreliable.
102
+
103
+ ## Commit & Pull Request Guidelines
104
+
105
+ Recent history uses short imperative subjects, sometimes with conventional
106
+ prefixes such as `feat:`. Keep commits focused, for example `feat: add command
107
+ cache` or `Fix session restore edge case`. PRs should include a concise summary,
108
+ validation commands run, linked issues when relevant, and any security/config
109
+ impact. Include screenshots only for Telegram UX changes where visual behavior
110
+ matters.
111
+
112
+ ## Security & Configuration Tips
113
+
114
+ Never commit real bot tokens, chat IDs, `.env` files, runtime logs, or attachment
115
+ caches. Prefer `.env.example` for defaults and `tgcc doctor --env <file>` for
116
+ operator checks. Be conservative with `CLAUDE_PERMISSION_MODE`,
117
+ `CLAUDE_SKIP_PERMISSIONS`, and attachment modes; document risk changes clearly.