fr-cli 2.1.0__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 (83) hide show
  1. fr_cli-2.1.0/LICENSE +21 -0
  2. fr_cli-2.1.0/MANIFEST.in +2 -0
  3. fr_cli-2.1.0/PKG-INFO +227 -0
  4. fr_cli-2.1.0/README.md +157 -0
  5. fr_cli-2.1.0/fr_cli/README.md +148 -0
  6. fr_cli-2.1.0/fr_cli/WEAPON.MD +186 -0
  7. fr_cli-2.1.0/fr_cli/__init__.py +4 -0
  8. fr_cli-2.1.0/fr_cli/addon/plugin.py +69 -0
  9. fr_cli-2.1.0/fr_cli/agent/__init__.py +9 -0
  10. fr_cli-2.1.0/fr_cli/agent/builtins/__init__.py +4 -0
  11. fr_cli-2.1.0/fr_cli/agent/builtins/_utils.py +48 -0
  12. fr_cli-2.1.0/fr_cli/agent/builtins/db.py +269 -0
  13. fr_cli-2.1.0/fr_cli/agent/builtins/local.py +105 -0
  14. fr_cli-2.1.0/fr_cli/agent/builtins/rag.py +652 -0
  15. fr_cli-2.1.0/fr_cli/agent/builtins/rag_watcher_daemon.py +156 -0
  16. fr_cli-2.1.0/fr_cli/agent/builtins/remote.py +214 -0
  17. fr_cli-2.1.0/fr_cli/agent/builtins/spider.py +247 -0
  18. fr_cli-2.1.0/fr_cli/agent/client.py +164 -0
  19. fr_cli-2.1.0/fr_cli/agent/executor.py +86 -0
  20. fr_cli-2.1.0/fr_cli/agent/generator.py +104 -0
  21. fr_cli-2.1.0/fr_cli/agent/manager.py +193 -0
  22. fr_cli-2.1.0/fr_cli/agent/master.py +604 -0
  23. fr_cli-2.1.0/fr_cli/agent/master_prompt.py +118 -0
  24. fr_cli-2.1.0/fr_cli/agent/remote.py +70 -0
  25. fr_cli-2.1.0/fr_cli/agent/server.py +279 -0
  26. fr_cli-2.1.0/fr_cli/agent/workflow.py +164 -0
  27. fr_cli-2.1.0/fr_cli/breakthrough/update.py +154 -0
  28. fr_cli-2.1.0/fr_cli/command/__init__.py +4 -0
  29. fr_cli-2.1.0/fr_cli/command/executor.py +276 -0
  30. fr_cli-2.1.0/fr_cli/command/registry.py +1034 -0
  31. fr_cli-2.1.0/fr_cli/command/security.py +30 -0
  32. fr_cli-2.1.0/fr_cli/conf/config.py +126 -0
  33. fr_cli-2.1.0/fr_cli/conf/wizard.py +172 -0
  34. fr_cli-2.1.0/fr_cli/core/chat.py +280 -0
  35. fr_cli-2.1.0/fr_cli/core/core.py +111 -0
  36. fr_cli-2.1.0/fr_cli/core/intent.py +129 -0
  37. fr_cli-2.1.0/fr_cli/core/recommender.py +71 -0
  38. fr_cli-2.1.0/fr_cli/core/stream.py +83 -0
  39. fr_cli-2.1.0/fr_cli/core/sysmon.py +117 -0
  40. fr_cli-2.1.0/fr_cli/core/thinking.py +215 -0
  41. fr_cli-2.1.0/fr_cli/gatekeeper/__init__.py +7 -0
  42. fr_cli-2.1.0/fr_cli/gatekeeper/daemon.py +216 -0
  43. fr_cli-2.1.0/fr_cli/gatekeeper/manager.py +218 -0
  44. fr_cli-2.1.0/fr_cli/lang/i18n.py +827 -0
  45. fr_cli-2.1.0/fr_cli/main.py +329 -0
  46. fr_cli-2.1.0/fr_cli/memory/context.py +119 -0
  47. fr_cli-2.1.0/fr_cli/memory/history.py +96 -0
  48. fr_cli-2.1.0/fr_cli/memory/session.py +134 -0
  49. fr_cli-2.1.0/fr_cli/repl/__init__.py +0 -0
  50. fr_cli-2.1.0/fr_cli/repl/commands.py +1098 -0
  51. fr_cli-2.1.0/fr_cli/security/security.py +46 -0
  52. fr_cli-2.1.0/fr_cli/ui/ui.py +116 -0
  53. fr_cli-2.1.0/fr_cli/weapon/cron.py +217 -0
  54. fr_cli-2.1.0/fr_cli/weapon/dataframe.py +97 -0
  55. fr_cli-2.1.0/fr_cli/weapon/disk.py +141 -0
  56. fr_cli-2.1.0/fr_cli/weapon/fs.py +206 -0
  57. fr_cli-2.1.0/fr_cli/weapon/launcher.py +249 -0
  58. fr_cli-2.1.0/fr_cli/weapon/loader.py +98 -0
  59. fr_cli-2.1.0/fr_cli/weapon/mail.py +227 -0
  60. fr_cli-2.1.0/fr_cli/weapon/mcp.py +204 -0
  61. fr_cli-2.1.0/fr_cli/weapon/vision.py +74 -0
  62. fr_cli-2.1.0/fr_cli/weapon/web.py +88 -0
  63. fr_cli-2.1.0/fr_cli.egg-info/PKG-INFO +227 -0
  64. fr_cli-2.1.0/fr_cli.egg-info/SOURCES.txt +81 -0
  65. fr_cli-2.1.0/fr_cli.egg-info/dependency_links.txt +1 -0
  66. fr_cli-2.1.0/fr_cli.egg-info/entry_points.txt +2 -0
  67. fr_cli-2.1.0/fr_cli.egg-info/requires.txt +52 -0
  68. fr_cli-2.1.0/fr_cli.egg-info/top_level.txt +1 -0
  69. fr_cli-2.1.0/pyproject.toml +70 -0
  70. fr_cli-2.1.0/setup.cfg +4 -0
  71. fr_cli-2.1.0/tests/test_agent_client.py +199 -0
  72. fr_cli-2.1.0/tests/test_agent_server.py +199 -0
  73. fr_cli-2.1.0/tests/test_ai_save_file_with_verify.py +228 -0
  74. fr_cli-2.1.0/tests/test_all.py +917 -0
  75. fr_cli-2.1.0/tests/test_auto_session.py +116 -0
  76. fr_cli-2.1.0/tests/test_builtins.py +67 -0
  77. fr_cli-2.1.0/tests/test_dataframe.py +42 -0
  78. fr_cli-2.1.0/tests/test_gatekeeper.py +118 -0
  79. fr_cli-2.1.0/tests/test_integration.py +224 -0
  80. fr_cli-2.1.0/tests/test_intent_classification.py +268 -0
  81. fr_cli-2.1.0/tests/test_launcher.py +98 -0
  82. fr_cli-2.1.0/tests/test_master_agent.py +162 -0
  83. fr_cli-2.1.0/tests/test_structured_tools.py +245 -0
fr_cli-2.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 leungyukit
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,2 @@
1
+ include fr_cli/WEAPON.MD
2
+ include fr_cli/README.md
fr_cli-2.1.0/PKG-INFO ADDED
@@ -0,0 +1,227 @@
1
+ Metadata-Version: 2.4
2
+ Name: fr-cli
3
+ Version: 2.1.0
4
+ Summary: 凡人打字机 - 基于智谱AI的终极全能终端工具
5
+ Author: FANREN CLI Author
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/yourname/fr-cli
8
+ Project-URL: Issues, https://github.com/yourname/fr-cli/issues
9
+ Keywords: zhipuai,glm,cli,ai,terminal,chatbot
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Topic :: Utilities
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: zhipuai>=2.0.0
27
+ Requires-Dist: requests>=2.28.0
28
+ Requires-Dist: mcp>=1.6.0
29
+ Provides-Extra: data
30
+ Requires-Dist: pandas>=1.5.0; extra == "data"
31
+ Requires-Dist: openpyxl>=3.0.0; extra == "data"
32
+ Provides-Extra: db
33
+ Requires-Dist: pymysql>=1.0.0; extra == "db"
34
+ Requires-Dist: psycopg2-binary>=2.9.0; extra == "db"
35
+ Requires-Dist: pyodbc>=4.0.0; extra == "db"
36
+ Requires-Dist: oracledb>=1.3.0; extra == "db"
37
+ Provides-Extra: rag
38
+ Requires-Dist: chromadb>=0.4.0; extra == "rag"
39
+ Requires-Dist: sentence-transformers>=2.2.0; extra == "rag"
40
+ Provides-Extra: remote
41
+ Requires-Dist: paramiko>=3.0.0; extra == "remote"
42
+ Provides-Extra: spider
43
+ Requires-Dist: selenium>=4.10.0; extra == "spider"
44
+ Provides-Extra: cloud
45
+ Requires-Dist: bypy; extra == "cloud"
46
+ Requires-Dist: aligo; extra == "cloud"
47
+ Requires-Dist: msal; extra == "cloud"
48
+ Provides-Extra: monitor
49
+ Requires-Dist: watchdog>=3.0.0; extra == "monitor"
50
+ Provides-Extra: all
51
+ Requires-Dist: pandas>=1.5.0; extra == "all"
52
+ Requires-Dist: openpyxl>=3.0.0; extra == "all"
53
+ Requires-Dist: pymysql>=1.0.0; extra == "all"
54
+ Requires-Dist: psycopg2-binary>=2.9.0; extra == "all"
55
+ Requires-Dist: pyodbc>=4.0.0; extra == "all"
56
+ Requires-Dist: oracledb>=1.3.0; extra == "all"
57
+ Requires-Dist: chromadb>=0.4.0; extra == "all"
58
+ Requires-Dist: sentence-transformers>=2.2.0; extra == "all"
59
+ Requires-Dist: paramiko>=3.0.0; extra == "all"
60
+ Requires-Dist: selenium>=4.10.0; extra == "all"
61
+ Requires-Dist: bypy; extra == "all"
62
+ Requires-Dist: aligo; extra == "all"
63
+ Requires-Dist: msal; extra == "all"
64
+ Requires-Dist: watchdog>=3.0.0; extra == "all"
65
+ Provides-Extra: dev
66
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
67
+ Requires-Dist: build; extra == "dev"
68
+ Requires-Dist: twine; extra == "dev"
69
+ Dynamic: license-file
70
+
71
+ # 凡人打字机 (fr-cli)
72
+
73
+ 基于智谱 AI (ZhipuAI/GLM) 的终极全能终端工具。
74
+
75
+ ## ✨ 功能特性
76
+
77
+ - 🤖 **AI 对话**:基于 GLM-4 系列模型的智能对话
78
+ - 🧠 **MasterAgent 主控**:自我进化的 ReAct 主控 Agent,自动规划、调用工具、反思进化
79
+ - 🧩 **思维模式**:direct / CoT / ToT / ReAct 四种推理模式切换
80
+ - 📁 **文件沙盒**:安全的虚拟文件系统,支持读写/目录操作
81
+ - 🔍 **联网搜索**:内置 Web 搜索与网页内容提取(SSRF 防护)
82
+ - 🖼️ **视觉能力**:图片生成 (CogView) 与多模态识别 (GLM-4V)
83
+ - 📧 **邮件收发**:支持 IMAP/SMTP(防头注入)
84
+ - ⏰ **定时任务**:后台定时执行命令(shlex 安全解析)
85
+ - ☁️ **云盘集成**:百度/阿里/OneDrive 网盘
86
+ - 🔌 **插件系统**:AI 生成代码自动保存为插件(子进程隔离,无代码注入)
87
+ - 🧠 **会话记忆**:自动保留最近 5 轮对话摘要 + 按日期自动存档
88
+ - 🛡️ **安全确认**:四阶危险操作拦截 + 虚拟文件系统沙盒
89
+ - 👤 **Agent 分身系统**:AI 自动生成 Agent(人设/记忆/技能/代码),支持工作流编排
90
+ - 🌐 **Agent HTTP API**:将 Agent 发布为 REST API 供外部调用(默认 127.0.0.1 + Bearer Token)
91
+ - 🖥️ **本机应用启动**:一键调用浏览器、微信、Word、WPS 等本地程序
92
+ - 🧑‍💻 **内置 Agent**:`@local` `@remote` `@spider` `@db` `@RAG`
93
+ - 📊 **数据卷轴**:Excel / CSV 读取与智能分析
94
+ - 🗄️ **数据库助手**:MySQL / PostgreSQL / SQL Server / Oracle 智能 SQL 生成
95
+ - 📚 **本地 RAG**:ChromaDB 向量库 + 自动文件监控与向量化
96
+ - 🔗 **MCP 外部神通**:支持 Model Context Protocol,连接外部工具服务器(stdio/SSE)
97
+ - 🧠 **多源信息融合**:大模型初步回答 + 工具结果(搜索/RAG/MCP/Agent)统一汇总整理
98
+ - 🌍 **中英文切换**:完整国际化支持
99
+
100
+ ## 🚀 快速安装
101
+
102
+ ```bash
103
+ pip install fr-cli
104
+ fr-cli
105
+ ```
106
+
107
+ 首次运行会引导输入智谱 API Key。
108
+
109
+ ## 📝 使用示例
110
+
111
+ ### 终端命令
112
+
113
+ ```bash
114
+ fr-cli
115
+
116
+ # 用户直接输入的命令
117
+ /ls # 列出文件
118
+ /cat hello.md # 查看文件
119
+ /cd /tmp # 切换目录
120
+ /save mysession # 保存会话
121
+ /export # 导出为 Markdown
122
+ /agent_server start 8080 # 启动 Agent HTTP API
123
+ /agent_create coder "编写Python代码的助手" # 自动生成Agent
124
+ /open /Users/me/doc.pdf # 用默认应用打开文件
125
+ /launch chrome github.com # 用 Chrome 打开网址
126
+ /launch 微信 # 启动微信
127
+ /apps # 列出可用应用
128
+ @local 查看当前目录最大的5个文件 # 本地系统操作Agent
129
+ @spider https://example.com 2 # 智能爬虫(深度2)
130
+ @db mydb 查询最近7天注册用户 # 数据库智能助手
131
+ @RAG 什么是向量数据库 # 本地知识库问答
132
+ /read_excel report.xlsx # 读取 Excel
133
+ /read_csv data.csv # 读取 CSV
134
+
135
+ # MasterAgent 自我进化主控
136
+ /master on # 启用主控Agent
137
+ /master off # 关闭主控Agent
138
+ /master status # 查看主控状态
139
+
140
+ # MCP 外部神通
141
+ /mcp_list # 列出已配置的 MCP 服务器及工具
142
+ /mcp_add fs npx -y @modelcontextprotocol/server-filesystem /tmp
143
+ /mcp_del fs # 删除 MCP 服务器
144
+ /mcp_enable fs # 启用服务器
145
+ /mcp_disable fs # 禁用服务器
146
+ /mcp_refresh # 刷新工具列表
147
+
148
+ # 思维模式切换
149
+ /mode direct # 直接回答(默认)
150
+ /mode cot # CoT 链式思考
151
+ /mode tot # ToT 树状搜索
152
+ /mode react # ReAct 深度推理
153
+
154
+ # 自动会话存档
155
+ /session_list # 列出按日期存档的会话
156
+ /session_load 0 # 加载第0个存档
157
+ /session_del 1 # 删除第1个存档
158
+
159
+ /help # 查看帮助
160
+ /exit # 退出
161
+ ```
162
+
163
+ ### AI 自动工具调用
164
+
165
+ 向 AI 描述需求,它会自动调用内置工具:
166
+
167
+ ```
168
+ >>> 搜索一下 Python 最新版本
169
+ 🧙 仙人 [基于知识初步回答 + 调用 search_web 获取最新信息]
170
+ ...
171
+ 🤖 自动执行命令:
172
+ ✅ 工具调用成功: search_web
173
+ ...
174
+ 🧙 仙人 [整理后的最终答案,融合自身知识与搜索结果]
175
+
176
+ >>> 把刚才的内容保存到文件
177
+ 🧙 仙人 【调用:write_file({"path": "python_news.md", "content": "..."})】
178
+ ✅ 卷轴已刻录
179
+ ```
180
+
181
+ ### Agent HTTP API 调用
182
+
183
+ 启动服务后,外部系统可直接调用 Agent:
184
+
185
+ ```bash
186
+ # 在 fr-cli 中启动服务
187
+ >>> /agent_server start 8080
188
+
189
+ # 外部系统调用(需携带 Bearer Token)
190
+ curl http://localhost:8080/agents \
191
+ -H "Authorization: Bearer <token>"
192
+ curl -X POST http://localhost:8080/agents/my_agent/run \
193
+ -H "Content-Type: application/json" \
194
+ -H "Authorization: Bearer <token>" \
195
+ -d '{"input": "请分析这个需求"}'
196
+ ```
197
+
198
+ ### 插件调用
199
+
200
+ 自定义插件保持命令方式:
201
+
202
+ ```
203
+ >>> 运行我的天气插件
204
+ 🧙 仙人 【命令:/weather 北京】
205
+ ```
206
+
207
+ ## 📦 安装
208
+
209
+ ```bash
210
+ # 一键安装(v2.1.0 起所有功能依赖默认包含)
211
+ pip install fr-cli
212
+ ```
213
+
214
+ 默认包含:智谱 AI SDK、HTTP 请求、Excel/CSV 处理、MySQL/PostgreSQL/SQL Server/Oracle 驱动、ChromaDB 向量库、sentence-transformers、SSH、Selenium、文件监控、云盘支持。
215
+
216
+ ## 🔧 开发
217
+
218
+ ```bash
219
+ git clone https://github.com/yourname/fr-cli.git
220
+ cd fr-cli
221
+ pip install -e .
222
+ python -m pytest tests/ -v
223
+ ```
224
+
225
+ ## 📄 License
226
+
227
+ MIT
fr_cli-2.1.0/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # 凡人打字机 (fr-cli)
2
+
3
+ 基于智谱 AI (ZhipuAI/GLM) 的终极全能终端工具。
4
+
5
+ ## ✨ 功能特性
6
+
7
+ - 🤖 **AI 对话**:基于 GLM-4 系列模型的智能对话
8
+ - 🧠 **MasterAgent 主控**:自我进化的 ReAct 主控 Agent,自动规划、调用工具、反思进化
9
+ - 🧩 **思维模式**:direct / CoT / ToT / ReAct 四种推理模式切换
10
+ - 📁 **文件沙盒**:安全的虚拟文件系统,支持读写/目录操作
11
+ - 🔍 **联网搜索**:内置 Web 搜索与网页内容提取(SSRF 防护)
12
+ - 🖼️ **视觉能力**:图片生成 (CogView) 与多模态识别 (GLM-4V)
13
+ - 📧 **邮件收发**:支持 IMAP/SMTP(防头注入)
14
+ - ⏰ **定时任务**:后台定时执行命令(shlex 安全解析)
15
+ - ☁️ **云盘集成**:百度/阿里/OneDrive 网盘
16
+ - 🔌 **插件系统**:AI 生成代码自动保存为插件(子进程隔离,无代码注入)
17
+ - 🧠 **会话记忆**:自动保留最近 5 轮对话摘要 + 按日期自动存档
18
+ - 🛡️ **安全确认**:四阶危险操作拦截 + 虚拟文件系统沙盒
19
+ - 👤 **Agent 分身系统**:AI 自动生成 Agent(人设/记忆/技能/代码),支持工作流编排
20
+ - 🌐 **Agent HTTP API**:将 Agent 发布为 REST API 供外部调用(默认 127.0.0.1 + Bearer Token)
21
+ - 🖥️ **本机应用启动**:一键调用浏览器、微信、Word、WPS 等本地程序
22
+ - 🧑‍💻 **内置 Agent**:`@local` `@remote` `@spider` `@db` `@RAG`
23
+ - 📊 **数据卷轴**:Excel / CSV 读取与智能分析
24
+ - 🗄️ **数据库助手**:MySQL / PostgreSQL / SQL Server / Oracle 智能 SQL 生成
25
+ - 📚 **本地 RAG**:ChromaDB 向量库 + 自动文件监控与向量化
26
+ - 🔗 **MCP 外部神通**:支持 Model Context Protocol,连接外部工具服务器(stdio/SSE)
27
+ - 🧠 **多源信息融合**:大模型初步回答 + 工具结果(搜索/RAG/MCP/Agent)统一汇总整理
28
+ - 🌍 **中英文切换**:完整国际化支持
29
+
30
+ ## 🚀 快速安装
31
+
32
+ ```bash
33
+ pip install fr-cli
34
+ fr-cli
35
+ ```
36
+
37
+ 首次运行会引导输入智谱 API Key。
38
+
39
+ ## 📝 使用示例
40
+
41
+ ### 终端命令
42
+
43
+ ```bash
44
+ fr-cli
45
+
46
+ # 用户直接输入的命令
47
+ /ls # 列出文件
48
+ /cat hello.md # 查看文件
49
+ /cd /tmp # 切换目录
50
+ /save mysession # 保存会话
51
+ /export # 导出为 Markdown
52
+ /agent_server start 8080 # 启动 Agent HTTP API
53
+ /agent_create coder "编写Python代码的助手" # 自动生成Agent
54
+ /open /Users/me/doc.pdf # 用默认应用打开文件
55
+ /launch chrome github.com # 用 Chrome 打开网址
56
+ /launch 微信 # 启动微信
57
+ /apps # 列出可用应用
58
+ @local 查看当前目录最大的5个文件 # 本地系统操作Agent
59
+ @spider https://example.com 2 # 智能爬虫(深度2)
60
+ @db mydb 查询最近7天注册用户 # 数据库智能助手
61
+ @RAG 什么是向量数据库 # 本地知识库问答
62
+ /read_excel report.xlsx # 读取 Excel
63
+ /read_csv data.csv # 读取 CSV
64
+
65
+ # MasterAgent 自我进化主控
66
+ /master on # 启用主控Agent
67
+ /master off # 关闭主控Agent
68
+ /master status # 查看主控状态
69
+
70
+ # MCP 外部神通
71
+ /mcp_list # 列出已配置的 MCP 服务器及工具
72
+ /mcp_add fs npx -y @modelcontextprotocol/server-filesystem /tmp
73
+ /mcp_del fs # 删除 MCP 服务器
74
+ /mcp_enable fs # 启用服务器
75
+ /mcp_disable fs # 禁用服务器
76
+ /mcp_refresh # 刷新工具列表
77
+
78
+ # 思维模式切换
79
+ /mode direct # 直接回答(默认)
80
+ /mode cot # CoT 链式思考
81
+ /mode tot # ToT 树状搜索
82
+ /mode react # ReAct 深度推理
83
+
84
+ # 自动会话存档
85
+ /session_list # 列出按日期存档的会话
86
+ /session_load 0 # 加载第0个存档
87
+ /session_del 1 # 删除第1个存档
88
+
89
+ /help # 查看帮助
90
+ /exit # 退出
91
+ ```
92
+
93
+ ### AI 自动工具调用
94
+
95
+ 向 AI 描述需求,它会自动调用内置工具:
96
+
97
+ ```
98
+ >>> 搜索一下 Python 最新版本
99
+ 🧙 仙人 [基于知识初步回答 + 调用 search_web 获取最新信息]
100
+ ...
101
+ 🤖 自动执行命令:
102
+ ✅ 工具调用成功: search_web
103
+ ...
104
+ 🧙 仙人 [整理后的最终答案,融合自身知识与搜索结果]
105
+
106
+ >>> 把刚才的内容保存到文件
107
+ 🧙 仙人 【调用:write_file({"path": "python_news.md", "content": "..."})】
108
+ ✅ 卷轴已刻录
109
+ ```
110
+
111
+ ### Agent HTTP API 调用
112
+
113
+ 启动服务后,外部系统可直接调用 Agent:
114
+
115
+ ```bash
116
+ # 在 fr-cli 中启动服务
117
+ >>> /agent_server start 8080
118
+
119
+ # 外部系统调用(需携带 Bearer Token)
120
+ curl http://localhost:8080/agents \
121
+ -H "Authorization: Bearer <token>"
122
+ curl -X POST http://localhost:8080/agents/my_agent/run \
123
+ -H "Content-Type: application/json" \
124
+ -H "Authorization: Bearer <token>" \
125
+ -d '{"input": "请分析这个需求"}'
126
+ ```
127
+
128
+ ### 插件调用
129
+
130
+ 自定义插件保持命令方式:
131
+
132
+ ```
133
+ >>> 运行我的天气插件
134
+ 🧙 仙人 【命令:/weather 北京】
135
+ ```
136
+
137
+ ## 📦 安装
138
+
139
+ ```bash
140
+ # 一键安装(v2.1.0 起所有功能依赖默认包含)
141
+ pip install fr-cli
142
+ ```
143
+
144
+ 默认包含:智谱 AI SDK、HTTP 请求、Excel/CSV 处理、MySQL/PostgreSQL/SQL Server/Oracle 驱动、ChromaDB 向量库、sentence-transformers、SSH、Selenium、文件监控、云盘支持。
145
+
146
+ ## 🔧 开发
147
+
148
+ ```bash
149
+ git clone https://github.com/yourname/fr-cli.git
150
+ cd fr-cli
151
+ pip install -e .
152
+ python -m pytest tests/ -v
153
+ ```
154
+
155
+ ## 📄 License
156
+
157
+ MIT
@@ -0,0 +1,148 @@
1
+ # 凡人打字机 (fr-cli)
2
+
3
+ 基于智谱 AI (ZhipuAI / GLM) 的终极全能终端工具。
4
+
5
+ **🇨🇳 中文简介**
6
+
7
+ 支持:AI 智能对话、MasterAgent 自我进化主控、思维模式切换(direct/CoT/ToT/ReAct)、文件沙盒操作、联网搜索(SSRF 防护)、图片生成与识别、邮件收发、定时任务(shlex 安全解析)、云盘集成、会话记忆、按日期自动存档、插件进化(子进程隔离)、四阶安全拦截、Shell 管道直通 AI。
8
+
9
+ **🇺🇸 English Intro**
10
+
11
+ The ultimate all-knowing terminal tool based on Zhipu AI. Supports AI chat, MasterAgent self-evolving controller, thinking modes (direct/CoT/ToT/ReAct), virtual filesystem, web search (SSRF-protected), image generation & vision, email, cron jobs (shlex-safe), cloud drive, session memory, auto date-based archiving, self-evolving plugins (subprocess-isolated), and powerful Shell piping.
12
+
13
+ ---
14
+
15
+ ## 🚀 快速开始
16
+
17
+ ```bash
18
+ pip install fr-cli
19
+ fr-cli
20
+ ```
21
+
22
+ 首次运行会引导输入智谱 API Key。
23
+
24
+ ## 🎮 使用方式
25
+
26
+ ### 用户直接命令
27
+
28
+ 在 `>>>` 提示符下输入 `/` 命令:
29
+
30
+ ```
31
+ /ls 列出当前目录文件
32
+ /cat <file> 查看文件内容
33
+ /write <file> 写入文件(多行输入,Ctrl+D 结束)
34
+ /cd <dir> 切换工作目录
35
+ /delete <file> 删除文件
36
+ /search <query> 联网搜索
37
+ /save <name> 保存会话
38
+ /load 加载历史会话
39
+ /export 导出会话为 Markdown
40
+ /session_list 列出按日期存档的会话
41
+ /session_load <idx> 加载存档会话
42
+ /mode direct|cot|tot|react 切换思维模式
43
+ /master on|off|status MasterAgent 主控
44
+ /mcp_list 列出 MCP 服务器及工具
45
+ /mcp_add <名> <命令> [参数] 添加 MCP 服务器
46
+ /mcp_del <名> 删除 MCP 服务器
47
+ /help 查看全部命令
48
+ /exit 退出
49
+ ```
50
+
51
+ ### AI 自动工具调用
52
+
53
+ 当请求涉及文件、搜索、画图等操作时,AI 会自动调用内置工具:
54
+
55
+ ```
56
+ 【调用:write_file({"path": "hello.md", "content": "# Hello\n\nWorld"})】
57
+ 【调用:search_web({"query": "Python 教程"})】
58
+ 【调用:generate_image({"prompt": "一只猫在月球上"})】
59
+ ```
60
+
61
+ ### 插件(Skills)
62
+
63
+ 自定义插件通过命令方式调用:
64
+
65
+ ```
66
+ 【命令:/my_plugin 参数】
67
+ ```
68
+
69
+ ---
70
+
71
+ ## 📂 项目结构
72
+
73
+ ```
74
+ fr_cli/
75
+ ├── main.py # 核心入口:REPL 循环、AI 交互编排(~600行)
76
+ ├── repl/
77
+ │ └── commands.py # 40个命令处理器(从 main.py 提取)
78
+ ├── WEAPON.MD # 法宝图谱(工具清单,人类可读,不再参与程序逻辑)
79
+ ├── agent/ # Agent 分身系统 + MasterAgent 主控
80
+ │ ├── master.py # 自我进化主控 Agent(ReAct 循环)
81
+ │ ├── master_prompt.py # MasterAgent 系统提示词模板
82
+ │ ├── manager.py # Agent 生命周期管理
83
+ │ ├── executor.py # Agent 执行器(run/delegate/multi-agent)
84
+ │ ├── workflow.py # 工作流引擎(workflow.md 解析与执行)
85
+ │ └── server.py # HTTP 服务(默认 127.0.0.1 + Bearer Token)
86
+ ├── command/
87
+ │ ├── executor.py # 命令执行引擎(动态构建依赖,消除 _deps 快照)
88
+ │ ├── registry.py # 统一工具注册表
89
+ │ └── security.py # 四阶安全确认管理器
90
+ ├── weapon/ # 武器库/扩展子系统
91
+ │ ├── fs.py # 虚拟文件系统 VFS
92
+ │ ├── web.py # 网络搜索与网页抓取(SSRF 防护)
93
+ │ ├── vision.py # 图片生成 (CogView) / 多模态 (GLM-4V)
94
+ │ ├── mail.py # 邮件客户端(防头注入)
95
+ │ ├── disk.py # 云盘适配器
96
+ │ ├── cron.py # 定时任务(shlex + shell=False)
97
+ │ ├── launcher.py # 本地应用启动器(跨平台)
98
+ │ ├── dataframe.py # Excel / CSV 读取与分析
99
+ │ └── loader.py # 从注册表动态生成工具描述
100
+ ├── memory/
101
+ │ ├── history.py # 会话历史保存/加载/导出
102
+ │ ├── context.py # 上下文记忆(最近 5 轮摘要)
103
+ │ └── session.py # 按日期自动存档会话引擎
104
+ ├── core/
105
+ │ ├── core.py # AppState 全局状态容器(DI 容器)
106
+ │ ├── stream.py # 流式输出与代码块高亮
107
+ │ ├── recommender.py # 功能推荐引擎
108
+ │ ├── sysmon.py # 系统状态监控
109
+ │ └── thinking.py # 思维模式引擎(CoT/ToT/ReAct)
110
+ ├── addon/
111
+ │ └── plugin.py # 插件加载与执行(runpy + json.dumps)
112
+ ├── conf/
113
+ │ └── config.py # 配置读写(mkstemp + 0o600 原子写入)
114
+ ├── lang/
115
+ │ └── i18n.py # 国际化 (zh/en)
116
+ ├── security/
117
+ │ └── security.py # 安全确认引擎
118
+ └── ui/
119
+ └── ui.py # 终端 UI、颜色、动画
120
+ ```
121
+
122
+ ---
123
+
124
+ ## 📦 可选依赖
125
+
126
+ ```bash
127
+ pip install fr-cli[all] # 全功能(含网盘)
128
+ pip install fr-cli[baidu] # 百度网盘
129
+ pip install fr-cli[aliyun] # 阿里云盘
130
+ pip install fr-cli[onedrive] # OneDrive
131
+ ```
132
+
133
+ ---
134
+
135
+ ## 🔧 开发
136
+
137
+ ```bash
138
+ git clone https://github.com/yourname/fr-cli.git
139
+ cd fr-cli
140
+ pip install -e ".[all]"
141
+ python -m pytest tests/ -v
142
+ ```
143
+
144
+ ---
145
+
146
+ ## 📄 License
147
+
148
+ MIT