termux-ai-agent 3.2.5__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.
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.4
2
+ Name: termux-ai-agent
3
+ Version: 3.2.5
4
+ Summary: Termux AI Agent - 智能终端助手,支持多平台AI(DeepSeek/阿里云百炼/硅基流动),JSON模式工具调用、文件精确编辑、后台任务处理、对话历史
5
+ Author: 我是个人
6
+ Project-URL: Homepage, https://github.com/user/termux-ai-agent
7
+ Project-URL: Repository, https://github.com/user/termux-ai-agent.git
8
+ Project-URL: Issues, https://github.com/user/termux-ai-agent/issues
9
+ Keywords: termux,ai,agent,deepseek,qwen,siliconflow,terminal,assistant,cli
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: Android
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Terminals
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ Requires-Dist: openai==0.28.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7; extra == "dev"
28
+ Requires-Dist: pytest-cov; extra == "dev"
29
+
30
+ # Termux AI Agent v3.2.5
31
+
32
+ 智能终端助手 —— 专为 Termux 环境设计的 AI Agent,支持多平台 AI(DeepSeek / 阿里云百炼 / 硅基流动)。
33
+
34
+ ## 功能特性
35
+
36
+ - 多平台 AI 支持 —— DeepSeek、阿里云百炼(通义千问)、硅基流动,一键切换
37
+ - JSON 模式工具调用 —— 自动执行 shell 命令、读写文件、访问网页
38
+ - 文件精确编辑 —— replace_in_file 只替换需要改的部分
39
+ - 后台任务处理 —— 自动识别服务启动命令并加 `&` 后台运行
40
+ - 对话历史 —— 实时保存,下次启动可继续对话,支持 AI 自动命名
41
+ - 用户自定义规则 —— 嵌入系统提示词,个性化 AI 行为
42
+ - 国内镜像源 —— 支持阿里云/清华源/中科大/自定义四种模式
43
+ - Token 用量统计 —— 输入 token 命令查看当前对话消耗
44
+ - API 错误汉化 —— 常见英文报错自动翻译为中文
45
+ - 终端美化 —— lolcat 彩虹特效、打字机动画、加载动画
46
+ - Termux 环境检测 —— 启动时自动验证运行环境
47
+
48
+ ## 安装
49
+
50
+ ### 准备工作:安装 Termux
51
+
52
+ 本工具基于 Termux 环境运行,如果你还没有安装 Termux,请先下载安装:
53
+
54
+ 👉 [点击下载 Termux](https://m.32r.com/app/136073.html)
55
+
56
+ ### 第一步:换国内镜像源(加速下载)
57
+
58
+ `echo "deb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable main" > $PREFIX/etc/apt/sources.list && apt update`
59
+
60
+ ### 第二步:安装 Python
61
+
62
+ `pkg install python -y`
63
+
64
+ ### 第三步:安装 Termux AI Agent
65
+
66
+ `python -m pip install termux-ai-agent`
67
+
68
+ ### 第四步:启动
69
+
70
+ `termux-ai-agent`
71
+
72
+ ### 从源码安装
73
+
74
+ `git clone https://github.com/user/termux-ai-agent.git`
75
+ `cd termux-ai-agent`
76
+ `pip install -e .`
77
+
78
+ ## 快速开始
79
+
80
+ 安装后直接运行:
81
+
82
+ `termux-ai-agent`
83
+
84
+ 或者作为 Python 模块运行:
85
+
86
+ `python -m deepseek_agent`
87
+
88
+ 首次运行需要:
89
+ 1. 同意用户协议与隐私政策
90
+ 2. 输入 API Key(支持 DeepSeek、阿里云百炼、硅基流动)
91
+
92
+ ## 可用工具
93
+
94
+ | 工具 | 功能 |
95
+ |------|------|
96
+ | run_shell | 执行系统命令 |
97
+ | read_file | 读取文件(带行号) |
98
+ | write_file | 安全写入文件 |
99
+ | replace_in_file | 精确替换文件内容 |
100
+ | mkdir | 创建目录 |
101
+ | fetch_webpage | 访问网页(Lynx) |
102
+ | ask_user | 向用户提问 |
103
+
104
+ ## 特殊命令
105
+
106
+ | 命令 | 功能 |
107
+ |------|------|
108
+ | help / 帮助 | 显示帮助信息 |
109
+ | setting / 设置 | 打开设置菜单(切换平台/模型/镜像源等) |
110
+ | clear | 清屏 |
111
+ | token | 查看当前对话 Token 用量(估算) |
112
+ | history | 浏览和加载历史对话 |
113
+ | reset | 重置对话并删除历史 |
114
+ | exit / 退出 | 保存并退出 |
115
+
116
+ ## 支持的 AI 平台
117
+
118
+ | 平台 | 默认模型 | 获取 Key |
119
+ |------|----------|----------|
120
+ | DeepSeek | deepseek-v4-pro | https://platform.deepseek.com/api_keys |
121
+ | 阿里云百炼 | qwen-max | https://bailian.console.aliyun.com/?apiKey=1 |
122
+ | 硅基流动 | Qwen/Qwen3-235B-A22B | https://cloud.siliconflow.cn/account/ak |
123
+
124
+ ## 系统要求
125
+
126
+ - Android 设备
127
+ - Termux 应用([GitHub](https://github.com/termux/termux-app) 或 [F-Droid](https://f-droid.org/packages/com.termux/))
128
+ - Python 3.8+
129
+ - 至少一个平台的 API Key
130
+
131
+ ## 更新日志
132
+
133
+ ### v3.2.5 (2026-07-03)
134
+ - 新增:多平台 AI 支持 —— DeepSeek / 阿里云百炼(通义千问)/ 硅基流动
135
+ - 新增:分平台独立存储 API Key,互不覆盖
136
+ - 新增:API 错误信息自动汉化
137
+ - 新增:token 命令 —— 查看当前对话 Token 用量(估算)
138
+ - 新增:终端美化 —— lolcat 彩虹特效 + 打字机动画 + 加载动画
139
+ - 新增:用户输入去重 + 工具调用结果缓存
140
+ - 新增:AI 自动为会话生成简短名称
141
+ - 优化:设置菜单增加 AI 平台切换入口
142
+
143
+ ### v3.2.0 (2026-06-28)
144
+ - 修复:pkg 安装阻塞 —— 安装策略优化,优先使用系统默认源,失败后自动切换镜像
145
+ - 修复:工具调用异常 —— 参数解析失败时向 API 返回错误消息,避免对话卡死
146
+ - 优化:Termux 环境自动检测 —— 启动时自动验证运行环境
147
+
148
+ ### v3.1.2 (2026-06-25)
149
+ - 优化:完善 README.md 文档,新增 Termux 下载链接
150
+ - 优化:新增作者主页链接
151
+
152
+ ### v3.1.1 (2026-06-24)
153
+ - 修复:README.md 格式问题,优化 PyPI 页面显示
154
+ - 优化:完善项目文档,新增从零开始安装步骤
155
+
156
+ ### v3.1.0 (2026-06-23)
157
+ - 新增:首次发布到 PyPI,包名 deepseek-agent-2026
158
+ - 新增:支持 pip install 安装
159
+ - 功能:JSON 模式工具调用、用户自定义规则、对话历史、国内镜像源
160
+
161
+ ### v3.0.0 (2026-05-09)
162
+ - 新增:用户自定义规则系统
163
+ - 新增:reset 命令,重置对话并清除历史
164
+ - 新增:关于页面
165
+
166
+ ### v2.9.0 (2026-05)
167
+ - 新增:文件读取带行号
168
+ - 新增:安全文件写入
169
+ - 优化:动态输出规则
170
+
171
+ ### v2.8.0 (2026-04)
172
+ - 新增:对话历史记录
173
+ - 新增:后台任务智能识别
174
+ - 优化:搜索引擎优化
175
+
176
+ ### v2.7.0 及更早
177
+ - 新增:JSON 模式工具调用
178
+ - 新增:自动安装依赖
179
+ - 新增:彩色终端输出
180
+ - 新增:设置中心
181
+
182
+ ## 卸载
183
+
184
+ `python -m pip uninstall termux-ai-agent -y`
185
+
186
+ ## 作者主页
187
+
188
+ 👉 [作者主页:https://www.rtsbox.cn/author/17993?t=0#67m5s](https://www.rtsbox.cn/author/17993?t=0#67m5s)
189
+
190
+ ## 许可证
191
+
192
+ MIT License
@@ -0,0 +1,163 @@
1
+ # Termux AI Agent v3.2.5
2
+
3
+ 智能终端助手 —— 专为 Termux 环境设计的 AI Agent,支持多平台 AI(DeepSeek / 阿里云百炼 / 硅基流动)。
4
+
5
+ ## 功能特性
6
+
7
+ - 多平台 AI 支持 —— DeepSeek、阿里云百炼(通义千问)、硅基流动,一键切换
8
+ - JSON 模式工具调用 —— 自动执行 shell 命令、读写文件、访问网页
9
+ - 文件精确编辑 —— replace_in_file 只替换需要改的部分
10
+ - 后台任务处理 —— 自动识别服务启动命令并加 `&` 后台运行
11
+ - 对话历史 —— 实时保存,下次启动可继续对话,支持 AI 自动命名
12
+ - 用户自定义规则 —— 嵌入系统提示词,个性化 AI 行为
13
+ - 国内镜像源 —— 支持阿里云/清华源/中科大/自定义四种模式
14
+ - Token 用量统计 —— 输入 token 命令查看当前对话消耗
15
+ - API 错误汉化 —— 常见英文报错自动翻译为中文
16
+ - 终端美化 —— lolcat 彩虹特效、打字机动画、加载动画
17
+ - Termux 环境检测 —— 启动时自动验证运行环境
18
+
19
+ ## 安装
20
+
21
+ ### 准备工作:安装 Termux
22
+
23
+ 本工具基于 Termux 环境运行,如果你还没有安装 Termux,请先下载安装:
24
+
25
+ 👉 [点击下载 Termux](https://m.32r.com/app/136073.html)
26
+
27
+ ### 第一步:换国内镜像源(加速下载)
28
+
29
+ `echo "deb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable main" > $PREFIX/etc/apt/sources.list && apt update`
30
+
31
+ ### 第二步:安装 Python
32
+
33
+ `pkg install python -y`
34
+
35
+ ### 第三步:安装 Termux AI Agent
36
+
37
+ `python -m pip install termux-ai-agent`
38
+
39
+ ### 第四步:启动
40
+
41
+ `termux-ai-agent`
42
+
43
+ ### 从源码安装
44
+
45
+ `git clone https://github.com/user/termux-ai-agent.git`
46
+ `cd termux-ai-agent`
47
+ `pip install -e .`
48
+
49
+ ## 快速开始
50
+
51
+ 安装后直接运行:
52
+
53
+ `termux-ai-agent`
54
+
55
+ 或者作为 Python 模块运行:
56
+
57
+ `python -m deepseek_agent`
58
+
59
+ 首次运行需要:
60
+ 1. 同意用户协议与隐私政策
61
+ 2. 输入 API Key(支持 DeepSeek、阿里云百炼、硅基流动)
62
+
63
+ ## 可用工具
64
+
65
+ | 工具 | 功能 |
66
+ |------|------|
67
+ | run_shell | 执行系统命令 |
68
+ | read_file | 读取文件(带行号) |
69
+ | write_file | 安全写入文件 |
70
+ | replace_in_file | 精确替换文件内容 |
71
+ | mkdir | 创建目录 |
72
+ | fetch_webpage | 访问网页(Lynx) |
73
+ | ask_user | 向用户提问 |
74
+
75
+ ## 特殊命令
76
+
77
+ | 命令 | 功能 |
78
+ |------|------|
79
+ | help / 帮助 | 显示帮助信息 |
80
+ | setting / 设置 | 打开设置菜单(切换平台/模型/镜像源等) |
81
+ | clear | 清屏 |
82
+ | token | 查看当前对话 Token 用量(估算) |
83
+ | history | 浏览和加载历史对话 |
84
+ | reset | 重置对话并删除历史 |
85
+ | exit / 退出 | 保存并退出 |
86
+
87
+ ## 支持的 AI 平台
88
+
89
+ | 平台 | 默认模型 | 获取 Key |
90
+ |------|----------|----------|
91
+ | DeepSeek | deepseek-v4-pro | https://platform.deepseek.com/api_keys |
92
+ | 阿里云百炼 | qwen-max | https://bailian.console.aliyun.com/?apiKey=1 |
93
+ | 硅基流动 | Qwen/Qwen3-235B-A22B | https://cloud.siliconflow.cn/account/ak |
94
+
95
+ ## 系统要求
96
+
97
+ - Android 设备
98
+ - Termux 应用([GitHub](https://github.com/termux/termux-app) 或 [F-Droid](https://f-droid.org/packages/com.termux/))
99
+ - Python 3.8+
100
+ - 至少一个平台的 API Key
101
+
102
+ ## 更新日志
103
+
104
+ ### v3.2.5 (2026-07-03)
105
+ - 新增:多平台 AI 支持 —— DeepSeek / 阿里云百炼(通义千问)/ 硅基流动
106
+ - 新增:分平台独立存储 API Key,互不覆盖
107
+ - 新增:API 错误信息自动汉化
108
+ - 新增:token 命令 —— 查看当前对话 Token 用量(估算)
109
+ - 新增:终端美化 —— lolcat 彩虹特效 + 打字机动画 + 加载动画
110
+ - 新增:用户输入去重 + 工具调用结果缓存
111
+ - 新增:AI 自动为会话生成简短名称
112
+ - 优化:设置菜单增加 AI 平台切换入口
113
+
114
+ ### v3.2.0 (2026-06-28)
115
+ - 修复:pkg 安装阻塞 —— 安装策略优化,优先使用系统默认源,失败后自动切换镜像
116
+ - 修复:工具调用异常 —— 参数解析失败时向 API 返回错误消息,避免对话卡死
117
+ - 优化:Termux 环境自动检测 —— 启动时自动验证运行环境
118
+
119
+ ### v3.1.2 (2026-06-25)
120
+ - 优化:完善 README.md 文档,新增 Termux 下载链接
121
+ - 优化:新增作者主页链接
122
+
123
+ ### v3.1.1 (2026-06-24)
124
+ - 修复:README.md 格式问题,优化 PyPI 页面显示
125
+ - 优化:完善项目文档,新增从零开始安装步骤
126
+
127
+ ### v3.1.0 (2026-06-23)
128
+ - 新增:首次发布到 PyPI,包名 deepseek-agent-2026
129
+ - 新增:支持 pip install 安装
130
+ - 功能:JSON 模式工具调用、用户自定义规则、对话历史、国内镜像源
131
+
132
+ ### v3.0.0 (2026-05-09)
133
+ - 新增:用户自定义规则系统
134
+ - 新增:reset 命令,重置对话并清除历史
135
+ - 新增:关于页面
136
+
137
+ ### v2.9.0 (2026-05)
138
+ - 新增:文件读取带行号
139
+ - 新增:安全文件写入
140
+ - 优化:动态输出规则
141
+
142
+ ### v2.8.0 (2026-04)
143
+ - 新增:对话历史记录
144
+ - 新增:后台任务智能识别
145
+ - 优化:搜索引擎优化
146
+
147
+ ### v2.7.0 及更早
148
+ - 新增:JSON 模式工具调用
149
+ - 新增:自动安装依赖
150
+ - 新增:彩色终端输出
151
+ - 新增:设置中心
152
+
153
+ ## 卸载
154
+
155
+ `python -m pip uninstall termux-ai-agent -y`
156
+
157
+ ## 作者主页
158
+
159
+ 👉 [作者主页:https://www.rtsbox.cn/author/17993?t=0#67m5s](https://www.rtsbox.cn/author/17993?t=0#67m5s)
160
+
161
+ ## 许可证
162
+
163
+ MIT License
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "termux-ai-agent"
7
+ version = "3.2.5"
8
+ description = "Termux AI Agent - 智能终端助手,支持多平台AI(DeepSeek/阿里云百炼/硅基流动),JSON模式工具调用、文件精确编辑、后台任务处理、对话历史"
9
+ authors = [
10
+ {name = "我是个人"}
11
+ ]
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Environment :: Console",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: Android",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Topic :: Terminals",
27
+ "Topic :: Software Development :: Libraries :: Python Modules",
28
+ ]
29
+ keywords = ["termux", "ai", "agent", "deepseek", "qwen", "siliconflow", "terminal", "assistant", "cli"]
30
+ dependencies = [
31
+ "openai==0.28.0",
32
+ ]
33
+
34
+ [project.optional-dependencies]
35
+ dev = [
36
+ "pytest>=7",
37
+ "pytest-cov",
38
+ ]
39
+
40
+ [project.urls]
41
+ Homepage = "https://github.com/user/termux-ai-agent"
42
+ Repository = "https://github.com/user/termux-ai-agent.git"
43
+ Issues = "https://github.com/user/termux-ai-agent/issues"
44
+
45
+ [project.scripts]
46
+ termux-ai-agent = "deepseek_agent.__main__:main"
47
+
48
+ [tool.setuptools]
49
+ package-dir = {"" = "src"}
50
+
51
+ [tool.setuptools.packages.find]
52
+ where = ["src"]
53
+
54
+ [tool.pytest.ini_options]
55
+ testpaths = ["tests"]
56
+ python_files = ["test_*.py"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,10 @@
1
+ """
2
+ Termux AI Agent - 智能终端助手 v3.2.5
3
+
4
+ Multi-provider AI Assistant with JSON-mode tool calling, file editing,
5
+ background task handling, conversation history, and user rules.
6
+ Supports DeepSeek, Aliyun Bailian (Qwen), and SiliconFlow.
7
+ """
8
+
9
+ __version__ = "3.2.5"
10
+ __author__ = "我是个人"
@@ -0,0 +1,83 @@
1
+ """入口点 —— termux-ai-agent 启动"""
2
+
3
+ import sys
4
+ import os
5
+
6
+ from .environment import ensure_termux
7
+ from .colors import (print_banner, print_status, Colors, check_beauty_tools,
8
+ install_beauty_tools, loading_animation)
9
+ from .config import load_config, load_api_key, save_api_key, get_current_provider
10
+ from .mirrors import apply_mirror_source, install_pkg_with_retry, install_pip_package, check_command
11
+ from .workspace import create_work_dir
12
+ from .cli import check_agreement, first_run_agreement
13
+
14
+
15
+ def main():
16
+ """主入口函数"""
17
+ # 环境检测
18
+ ensure_termux()
19
+
20
+ # 先加载配置
21
+ load_config()
22
+
23
+ # 首次运行协议
24
+ if not check_agreement():
25
+ if not first_run_agreement():
26
+ sys.exit(0)
27
+
28
+ # 安装美化工具
29
+ check_beauty_tools()
30
+ from .colors import _LOLCAT_AVAILABLE
31
+ if not _LOLCAT_AVAILABLE:
32
+ print_status("检测美化工具...", "info")
33
+ install_beauty_tools()
34
+
35
+ print_banner()
36
+ loading_animation("正在初始化环境...", 0.6)
37
+
38
+ # 应用镜像源
39
+ apply_mirror_source()
40
+
41
+ # 安装 lynx
42
+ if not check_command("lynx"):
43
+ install_pkg_with_retry("lynx")
44
+
45
+ # 检查 openai 库
46
+ try:
47
+ import openai
48
+ except ImportError:
49
+ if not install_pip_package("openai==0.28.0"):
50
+ print_status("openai 安装失败", "error")
51
+ sys.exit(1)
52
+ try:
53
+ import openai
54
+ except ImportError:
55
+ print_status("openai 导入失败", "error")
56
+ sys.exit(1)
57
+
58
+ # 创建工作目录
59
+ from .config import API_PROVIDER
60
+ work_dir = create_work_dir()
61
+ print_status(f"工作目录: {work_dir}", "success")
62
+
63
+ saved_key = load_api_key(API_PROVIDER)
64
+
65
+ if saved_key:
66
+ print(f" {Colors.DIM}🔑 已加载 {get_current_provider()['name']} Key{Colors.RESET}")
67
+ api_key = saved_key
68
+ else:
69
+ p = get_current_provider()
70
+ print(f"\n{Colors.BRIGHT_YELLOW} 🔑 请输入 {p['name']} API Key{Colors.RESET}")
71
+ print(f" {Colors.DIM}(获取: {p['key_url']}){Colors.RESET}")
72
+ api_key = input(f"\n{Colors.BOLD}{Colors.BRIGHT_WHITE} Key{Colors.RESET} {Colors.BRIGHT_BLUE}»{Colors.RESET} ").strip()
73
+ if not api_key:
74
+ sys.exit(1)
75
+ if input(f"\n{Colors.DIM}保存 Key?(Y/n): {Colors.RESET}").strip().lower() in ["", "y", "yes"]:
76
+ save_api_key(api_key, API_PROVIDER)
77
+
78
+ from .agent import start
79
+ start(api_key, work_dir, openai)
80
+
81
+
82
+ if __name__ == "__main__":
83
+ main()