aacode 1.5.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 (72) hide show
  1. aacode-1.5.0/PKG-INFO +325 -0
  2. aacode-1.5.0/aacode/LICENSE +674 -0
  3. aacode-1.5.0/aacode/README.md +287 -0
  4. aacode-1.5.0/aacode/__init__.py +16 -0
  5. aacode-1.5.0/aacode/__main__.py +11 -0
  6. aacode-1.5.0/aacode/aacode_config.yaml +227 -0
  7. aacode-1.5.0/aacode/cli.py +110 -0
  8. aacode-1.5.0/aacode/config.py +693 -0
  9. aacode-1.5.0/aacode/core/__init__.py +0 -0
  10. aacode-1.5.0/aacode/core/agent.py +248 -0
  11. aacode-1.5.0/aacode/core/main_agent.py +1325 -0
  12. aacode-1.5.0/aacode/core/multi_agent.py +176 -0
  13. aacode-1.5.0/aacode/core/prompts.py +172 -0
  14. aacode-1.5.0/aacode/core/react_loop.py +2178 -0
  15. aacode-1.5.0/aacode/core/sub_agent.py +160 -0
  16. aacode-1.5.0/aacode/init.py +402 -0
  17. aacode-1.5.0/aacode/main.py +791 -0
  18. aacode-1.5.0/aacode/sandbox/__init__.py +0 -0
  19. aacode-1.5.0/aacode/sandbox/mcp_client.py +280 -0
  20. aacode-1.5.0/aacode/sandbox/vm_manager.py +327 -0
  21. aacode-1.5.0/aacode/skills/api_client/call_api.py +140 -0
  22. aacode-1.5.0/aacode/skills/data_cleaning/clean_csv.py +100 -0
  23. aacode-1.5.0/aacode/skills/data_converter/convert_data.py +174 -0
  24. aacode-1.5.0/aacode/skills/file_organizer/organize_files.py +448 -0
  25. aacode-1.5.0/aacode/skills/playwright/playwright_skill.py +1771 -0
  26. aacode-1.5.0/aacode/skills/web_scraper/scrape_web.py +513 -0
  27. aacode-1.5.0/aacode/tools/__init__.py +0 -0
  28. aacode-1.5.0/aacode/tools/atomic_tools.py +1208 -0
  29. aacode-1.5.0/aacode/tools/code_tools.py +305 -0
  30. aacode-1.5.0/aacode/tools/custom_tools.py +64 -0
  31. aacode-1.5.0/aacode/tools/multimodal_tools.py +670 -0
  32. aacode-1.5.0/aacode/tools/sandbox_tools.py +274 -0
  33. aacode-1.5.0/aacode/tools/skills_tools.py +559 -0
  34. aacode-1.5.0/aacode/tools/todo_tools.py +270 -0
  35. aacode-1.5.0/aacode/tools/web_tools.py +559 -0
  36. aacode-1.5.0/aacode/utils/__init__.py +0 -0
  37. aacode-1.5.0/aacode/utils/agent_logger.py +340 -0
  38. aacode-1.5.0/aacode/utils/async_helpers.py +263 -0
  39. aacode-1.5.0/aacode/utils/class_method_mapper.py +1643 -0
  40. aacode-1.5.0/aacode/utils/code_analyzer.py +417 -0
  41. aacode-1.5.0/aacode/utils/context_manager.py +538 -0
  42. aacode-1.5.0/aacode/utils/file_ops.py +408 -0
  43. aacode-1.5.0/aacode/utils/light_ast.py +617 -0
  44. aacode-1.5.0/aacode/utils/mcp_manager.py +476 -0
  45. aacode-1.5.0/aacode/utils/mock_model.py +128 -0
  46. aacode-1.5.0/aacode/utils/safety.py +1213 -0
  47. aacode-1.5.0/aacode/utils/session_manager.py +642 -0
  48. aacode-1.5.0/aacode/utils/todo_manager.py +476 -0
  49. aacode-1.5.0/aacode/utils/tool_registry.py +264 -0
  50. aacode-1.5.0/aacode/utils/tool_schemas.py +838 -0
  51. aacode-1.5.0/aacode.egg-info/PKG-INFO +325 -0
  52. aacode-1.5.0/aacode.egg-info/SOURCES.txt +70 -0
  53. aacode-1.5.0/aacode.egg-info/dependency_links.txt +1 -0
  54. aacode-1.5.0/aacode.egg-info/entry_points.txt +2 -0
  55. aacode-1.5.0/aacode.egg-info/requires.txt +18 -0
  56. aacode-1.5.0/aacode.egg-info/top_level.txt +1 -0
  57. aacode-1.5.0/pyproject.toml +63 -0
  58. aacode-1.5.0/setup.cfg +4 -0
  59. aacode-1.5.0/tests/test_anthropic_actual_request.py +167 -0
  60. aacode-1.5.0/tests/test_anthropic_gateway.py +83 -0
  61. aacode-1.5.0/tests/test_anthropic_simple.py +59 -0
  62. aacode-1.5.0/tests/test_async_helpers.py +127 -0
  63. aacode-1.5.0/tests/test_basic.py +85 -0
  64. aacode-1.5.0/tests/test_config.py +156 -0
  65. aacode-1.5.0/tests/test_final_minimax_fix.py +279 -0
  66. aacode-1.5.0/tests/test_gateway_comprehensive.py +694 -0
  67. aacode-1.5.0/tests/test_minimax_fix.py +175 -0
  68. aacode-1.5.0/tests/test_minimax_openai_fix.py +231 -0
  69. aacode-1.5.0/tests/test_minimax_url.py +124 -0
  70. aacode-1.5.0/tests/test_real_minimax_api.py +212 -0
  71. aacode-1.5.0/tests/test_real_scenarios.py +436 -0
  72. aacode-1.5.0/tests/test_tools.py +203 -0
aacode-1.5.0/PKG-INFO ADDED
@@ -0,0 +1,325 @@
1
+ Metadata-Version: 2.4
2
+ Name: aacode
3
+ Version: 1.5.0
4
+ Summary: AI Coding Assistant based on ReAct architecture with file-based context management
5
+ Author: xiefujin
6
+ License: GPL-3.0-or-later
7
+ Project-URL: Homepage, https://github.com/xiefujin/aacode
8
+ Project-URL: Documentation, https://github.com/xiefujin/aacode#readme
9
+ Keywords: ai,coding,assistant,react,llm
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Requires-Python: >=3.8
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: openai>=1.0.0
22
+ Requires-Dist: anthropic>=0.25.0
23
+ Requires-Dist: aiohttp>=3.9.0
24
+ Requires-Dist: aiofiles>=23.0.0
25
+ Requires-Dist: pydantic>=2.0.0
26
+ Requires-Dist: pyyaml>=6.0
27
+ Requires-Dist: asyncio-mqtt>=0.16.0
28
+ Requires-Dist: python-multipart>=0.0.6
29
+ Requires-Dist: tiktoken
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
32
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
33
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
34
+ Requires-Dist: pytest-benchmark>=4.0.0; extra == "dev"
35
+ Requires-Dist: hypothesis>=6.0.0; extra == "dev"
36
+ Requires-Dist: black>=23.0.0; extra == "dev"
37
+ Requires-Dist: mypy>=1.5.0; extra == "dev"
38
+
39
+ [English](README_en.md) |
40
+
41
+ # 🤖 AACode - CLI编程Agent
42
+
43
+ [![Python Version](https://img.shields.io/badge/python-3.12+-blue.svg)](https://python.org)
44
+
45
+ > 🚀 **基于DeepSeek的智能编程助手** - 借鉴和采用当前流行Agent的先进理念的轻量化ReAct架构
46
+
47
+ ## 设计原则
48
+ * 少脚手架,多信任模型:核心逻辑简单,依赖模型自身能力
49
+ * 文件化上下文:动态发现,Markdown等文件作为主要存储
50
+ * bash万能适配器:通过安全护栏提供灵活的系统访问
51
+ * 上下文管理:借鉴了Cursor和Manus的智能缩减策略
52
+ * 异步设计:所有阻塞操作都是异步的
53
+ * 分层工具系统:原子工具、代码包、skills等多层架构
54
+ * 安全护栏:全面的命令和路径安全检查
55
+ * 可扩展架构:支持自定义工具和模型后端
56
+
57
+ ## 🎯 快速开始
58
+ ### 操作系统
59
+ 该项目主要在Linux和MacOS开发和测试,建议使用Linux或MacOS。Windows环境下有人反馈可能会存在python路径问题(个别情况,且容易解决),请自行配置解决。另外,Windows小部分系统命令会有点不同,可能会让Agent一开始有一点受阻,但它很快会自主找到解决方法,整体不影响Agent自由发挥。
60
+
61
+ ### 一键初始化(推荐)
62
+
63
+ ```bash
64
+ git clone https://github.com/kandada/aacode.git
65
+ cd aacode
66
+ python3 init.py # 建议最好是3.12版本
67
+ # 此时观察一下有没有进入.venv环境,如果没有,请执行:
68
+ source .venv/bin/activate
69
+ ```
70
+
71
+ ### 开始使用
72
+ **特别说明**:启动任务之前,你可以在你的任务目录中建一个init.md文件,作为任务详细描述文件,尽可能详细描述你的设计思路等,会能得到更好的结果
73
+
74
+ ```bash
75
+ # 使用便捷启动脚本
76
+ ./run.sh -p examples/my_project "创建一个简单的计算器程序"
77
+
78
+ # 或手动运行
79
+ source .venv/bin/activate
80
+ export LLM_API_KEY="your-api-key"
81
+ export LLM_API_URL="your-api-url"
82
+ export LLM_MODEL_NAME="your-model-name"
83
+ python3 main.py -p examples/my_project "你的任务描述"
84
+
85
+ # 高级模式
86
+ ## 规划优先模式
87
+ python main.py -p examples/my_project "复杂任务" --plan-first
88
+ ## 交互式连续对话
89
+ python main.py -p examples/my_project "初始任务" --interactive
90
+ ## 指定会话
91
+ python main.py --session session_20250128_123456_0 "继续任务"
92
+
93
+ ```
94
+
95
+ ## 🔧 配置说明
96
+
97
+ ### 大语言模型(支持deepseek、openai等,不做预配置,需要用户自主配置)
98
+ ```bash
99
+ # OpenAI
100
+ export LLM_API_KEY="your-openai-key"
101
+ export LLM_API_URL="https://api.openai.com/v1"
102
+ export LLM_MODEL_NAME="gpt-4"
103
+ export LLM_GATEWAY="openai"
104
+ export LLM_MULTIMODAL="false"
105
+
106
+ # 其他兼容OpenAI API的模型(deepseek等)
107
+ export LLM_API_KEY="your-api-key"
108
+ export LLM_API_URL="https://your-api-endpoint/v1"
109
+ export LLM_MODEL_NAME="your-model-name"
110
+ export LLM_GATEWAY="openai"
111
+ export LLM_MULTIMODAL="false"
112
+
113
+ # 其他同时支持多模态的模型(如MiniMax、Kimi等)
114
+ export LLM_API_KEY="your-kimi-key"
115
+ export LLM_API_URL="https://api.moonshot.cn/v1"
116
+ export LLM_MODEL_NAME="kimi-k2.5"
117
+ export LLM_GATEWAY="anthropic"
118
+ export LLM_MULTIMODAL="true"
119
+ ```
120
+
121
+ ### 多模态模型用于支持多模态工具
122
+ 支持多种多模态模型(如Kimi K2.5、MiniMax M2.5等),请在.env文件或aacode_config.yaml中配置:
123
+ - `MULTIMODAL_API_KEY`: 多模态模型API密钥
124
+ - `MULTIMODAL_API_URL`: 多模态模型API地址(可选,默认使用模型对应的地址)
125
+
126
+ ### 搜索引擎
127
+ 目前仅支持SearXNG,需要用户自己部署并将url配置到aacode_config.yaml中,但建议还是配置环境变量SEARCHXNG_URL
128
+
129
+ ### MCP
130
+ - 用户自行将MCP资源(支持stdio和sse)配置到aacode_config.yaml中
131
+
132
+ ### 增减Skills
133
+ - 在skills目录下添加skill目录(包含SKILL.md和实现文件)
134
+ - 在aacode_config.yaml中配置:添加到enabled_skills列表;在skills_metadata中添加元数据(名称、描述、触发关键词)
135
+ - 完成配置后,Agent就会自主“渐进式披露”使用技能了。你可以添加更多你认为对你的任务有用的Skills
136
+
137
+ ## 📋 使用示例
138
+
139
+ ### 示例1:创建Hello World
140
+ ```bash
141
+ ./run.sh -p examples/hello_demo "创建一个hello.py文件,内容为print('Hello, World!')"
142
+ ```
143
+
144
+ ### 示例2:开发计算器
145
+ ```bash
146
+ ./run.sh -p examples/calculator "创建一个支持加减乘除的计算器程序,包含测试用例"
147
+ ```
148
+
149
+ ### 示例3:Web应用开发
150
+ ```bash
151
+ ./run.sh -p examples/web_app "使用Flask创建一个简单的Web应用,包含首页和关于页面"
152
+ ```
153
+
154
+ ### 示例4:数据处理
155
+ ```bash
156
+ ./run.sh -p examples/data_analysis "创建一个数据分析脚本,读取项目目录中的CSV文件并生成统计图表"
157
+ ```
158
+
159
+
160
+ ## 🎯 最佳实践
161
+
162
+ ### 1. 任务描述要清晰
163
+
164
+ ✅ **好的描述**:
165
+ ```
166
+ "创建一个Python程序,使用requests库获取天气API数据,
167
+ 并将结果保存到weather.json文件"
168
+ ```
169
+
170
+ ❌ **不好的描述**:
171
+ ```
172
+ "做个天气程序"
173
+ ```
174
+
175
+ ### 2. 分步骤执行复杂任务
176
+
177
+ 对于复杂项目,分多次执行:
178
+
179
+ ```bash
180
+ # 第一步:创建基础结构
181
+ python3 main.py -p examples/app "创建Flask应用基础结构"
182
+
183
+ # 第二步:添加功能
184
+ python3 main.py -p examples/app "添加用户认证功能"
185
+
186
+ # 第三步:测试
187
+ python3 main.py -p examples/app "为所有功能编写测试"
188
+ ```
189
+
190
+ ### 3. 利用项目指导原则
191
+
192
+ 编辑 `init.md` 文件,添加项目特定的规则:
193
+
194
+ ```markdown
195
+ # 项目指导原则
196
+
197
+ ## 代码风格
198
+ - 使用PEP 8规范
199
+ - 函数名使用snake_case
200
+ - 类名使用PascalCase
201
+
202
+ ## 测试要求
203
+ - 每个功能必须有单元测试
204
+ - 测试覆盖率不低于80%
205
+
206
+ ## 文档要求
207
+ - 所有公共函数必须有docstring
208
+ - README.md必须包含使用示例
209
+ ```
210
+
211
+ 同时记得将你的设计思路也添加到 `init.md` 文件中,这样,你的任务描述就会更准确,Agent会更智能地生成代码。
212
+
213
+
214
+ ## 🏗️ 架构设计
215
+
216
+ ### 设计原则
217
+ - **少脚手架,多信任模型** - 核心逻辑简单,依赖模型自身能力
218
+ - **文件化上下文** - 动态发现,Markdown文件作为主要存储
219
+ - **bash万能适配器** - 通过安全护栏提供灵活的系统访问
220
+ - **智能上下文管理** - 借鉴Cursor和Manus的缩减策略
221
+ - **异步设计** - 所有阻塞操作都是异步的
222
+ - **分层工具系统** - 原子工具、沙箱工具、代码包三层架构
223
+
224
+ ### 核心组件
225
+
226
+ ```
227
+ 📁 核心架构
228
+ ├── 🤖 MainAgent # 主控制器,任务分解和协调
229
+ ├── 🔄 ReActLoop # 智能思考-行动循环
230
+ ├── 📚 ContextManager # 文件化上下文管理
231
+ ├── 🛠️ AtomicTools # 原子工具集(文件、命令、搜索)
232
+ ├── 💻 CodeTools # 代码工具集(执行、测试、调试)
233
+ ├── 🛡️ SafetyGuard # 全面的安全护栏系统
234
+ └── 🔧 ConfigManager # 灵活的配置管理
235
+ ```
236
+
237
+ ## 📊 性能指标
238
+
239
+ | 指标 | 数值 | 说明 |
240
+ |------|------|------|
241
+ | 任务成功率 | 98%+ | 复杂编程任务完成率 |
242
+ | 平均响应时间 | 2-5秒 | 工具调用响应时间 |
243
+ | 代码质量 | 生产级 | 包含错误处理和测试 |
244
+ | 安全性 | 100% | 零安全漏洞记录 |
245
+ | 支持语言 | Python优先 | 可扩展支持多语言 |
246
+
247
+ ## 🔒 安全特性
248
+
249
+ - **路径安全检查** - 限制文件访问在项目目录内
250
+ - **命令安全验证** - 阻止危险系统命令执行
251
+ - **代码安全扫描** - Python代码AST安全检查
252
+ - **沙箱隔离** - 所有操作在安全沙箱环境中进行
253
+ - **用户确认机制** - 危险操作需要用户确认
254
+
255
+ ## 🛠️ 可用工具
256
+
257
+ ### 原子工具
258
+ - `read_file` - 读取文件内容
259
+ - `write_file` - 写入文件内容
260
+ - `run_shell` - 执行shell命令(安全)
261
+ - `list_files` - 列出目录文件
262
+ - `search_files` - 搜索文件内容
263
+
264
+ ### 代码工具
265
+ - `execute_python` - 执行Python代码
266
+ - `run_tests` - 运行测试套件
267
+ - `debug_code` - 调试代码问题
268
+
269
+ ### To-Do List工具
270
+ - `delegate_task` - 委托子任务
271
+ - `add_todo_item` - 添加待办
272
+ - `update_todo_item` - 更新待办
273
+
274
+ ### 网络工具
275
+ - `web_search` - 搜索网络内容(当前支持searXNG,需要自己部署并将配置SEARCHXNG_URL环境变量)
276
+ - `browse_web` - 浏览器上网(未来)
277
+
278
+ ### 文件工具(比如增量代码更新等)
279
+
280
+ ## 📈 项目状态
281
+
282
+ - ✅ **核心功能完成** - 所有主要功能已实现并测试
283
+ - ✅ **生产就绪** - 通过复杂任务验证,可用于实际开发
284
+ - ✅ **文档完善** - 详细的使用指南和API文档
285
+ - ✅ **安全可靠** - 全面的安全测试和验证
286
+ - 🔄 **持续优化** - 不断改进和增加新功能
287
+
288
+ ## 🤝 贡献指南
289
+
290
+ 欢迎贡献代码、报告问题或提出建议!
291
+
292
+ 1. Fork 本仓库
293
+ 2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
294
+ 3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
295
+ 4. 推送到分支 (`git push origin feature/AmazingFeature`)
296
+ 5. 开启 Pull Request
297
+
298
+ ## 📄 许可证
299
+
300
+ 本项目为xiefujin(github: kandada,邮箱490021684@qq.com)发起并开发做出第一版,采用 GPL3.0 许可证,所有衍生作品必须同样以GPL开源。[license][https://github.com/kandada/aacode/blob/main/LICENSE]
301
+
302
+ ## 🙏 致谢
303
+
304
+ - 感谢 [DeepSeek](https://www.deepseek.com/) 提供强大的AI模型支持
305
+ - 借鉴了 [Cursor]和 [Manus]的一些先进理念
306
+ - 感谢所有开源社区的贡献者
307
+
308
+ ## 📞 联系方式
309
+
310
+ - 项目主页: [xiefujin](https://github.com/kandada/aacode)
311
+ - 问题反馈: [Issues](https://github.com/kandada/aacode/issues)
312
+ - 功能建议: [Discussions](https://github.com/kandada/aacode/discussions)
313
+
314
+ ---
315
+
316
+ <div align="center">
317
+
318
+ **🚀 立即开始你的AI编程之旅!**
319
+
320
+ Made with ❤️ by [xiefujin](https://github.com/kandada)
321
+
322
+ </div>
323
+
324
+
325
+