使用说明
自主人工智能编码助手
一个实用的智能AI编程助手 就像克劳德·科德一样 - 使用纯人工智能,不包含任何硬编码模式。
哲学
“相信大脑,而非模式。”
这个代理使用 纯粹的人工智能 理解自然语言请求并自主执行编码任务。无需正则表达式模式,无需硬编码规则,无需预定义响应——全靠模型的智能。
特点/特性
🧠 纯粹的人工智能
- 无硬编码模式 - 所有理解都来源于人工智能模型
- 自然语言处理 - 天然地问任何问题,人工智能都能理解
- 情境感知规划 - 利用会话内存进行智能决策
- 自适应执行 - 与任何Ollama模型兼容,自动检测功能
🚀 自主执行
- 只读操作自动执行 - 列出文件、阅读代码、搜索、分析时无需确认
- 安全写入操作 - 请求批准文件创建、编辑、命令执行
- 智能后处理 - 分析结果并提供自然语言解释
💾 会话内存
- 文件追踪 - 记住会话期间读取的文件
- 项目背景 - 了解项目类型和结构
- 对话历史 - 在多个请求之间保持上下文
- 智能优化 - 避免重复读取文件
建筑学
User Request
↓
🧠 AI Planning (Pure Intelligence)
├─ Understands intent naturally
├─ Checks session memory
├─ Chooses appropriate tools
└─ Creates execution plan
↓
Execute Plan
├─ Read-only: Auto-execute
└─ Write ops: Ask approval
↓
📊 Post-Processing
└─ AI explains results naturally
快速入门
先决条件
- Ollama(注:这是一个专有名词或特定项目名,直接翻译可能无具体含义,故保留原样) 已安装至少一个型号:
# Recommended models
ollama pull qwen2.5-coder:32b-instruct-q4_K_M # Best for coding (32B)
ollama pull qwen2.5:14b-instruct-q4_K_M # Good balance (14B)
ollama pull llama3.2:7b-instruct-q4_K_M # Smaller option (7B)
- Python 3.8及以上版本 带有依赖项:
pip install -r requirements.txt
运行代理程序
标准I/O模式(默认) - 客户端自动启动服务器:
./start_client.sh
HTTP 模式 - 服务器独立运行:
# Terminal 1: Start server
./start_server.sh
# Terminal 2: Connect client
./start_client_http.sh
使用示例
该代理能够完全理解自然语言。以下是一些示例:
只读操作(自动执行)
You: what directory am i in
🧠 Thinking...
📋 Plan: List files in current directory
🔓 All operations are read-only - executing automatically
⚙️ Step 1/1: List files in current directory
✅ Done
📁 Found 11 items...
💡 You're in the Autonomous-AI-Coding-Assistant project directory.
You: read client.py and explain what it does
🧠 Thinking...
📋 Plan: Read client.py and provide analysis
🔓 All operations are read-only - executing automatically
⚙️ Step 1/1: Read file client.py
✅ Done
📄 client.py content: [syntax highlighted preview]
📝 Added to session memory (35,234 chars)
💡 client.py implements the AutonomousCodingAgent class with pure AI
intelligence. It uses Ollama models to understand requests naturally,
plan tasks, and execute them autonomously...
You: search for the MCPClient class
🧠 Thinking...
📋 Plan: Search codebase for MCPClient
🔓 All operations are read-only - executing automatically
⚙️ Step 1/1: Search for 'MCPClient' in .
✅ Done
🔍 Found in mcp-client/client.py:61
写操作(请求审批)
You: generate a django project on movie recommendations
🧠 Thinking...
📋 Plan:
1. Create project directory structure 🔒
2. Write manage.py and settings.py 🔒
3. Create movies app with models 🔒
4. Write views and templates 🔒
🚀 Execute plan? [y/n]
它是如何工作的
1. 纯粹的人工智能规划
人工智能模型接收的不是硬编码的模式,而是:
- 用户请求
- 会话内存(读取的文件、项目上下文、对话历史)
- 可用工具
- 最简指令
人工智能大脑自然地理解了该做什么,并制定了一个计划。
2. 自主执行
只读操作 (安全):
list_files- 列出目录内容read_file- 读取文件内容search_code- 搜索模式analyze_project- 分析项目结构get_file_info- 获取文件信息
→ 无需询问,自动执行
写入操作 (待批准):
write_file- 创建/编写文件edit_file- 编辑现有文件execute_command- 运行Shell命令create_directory- 创建目录
→ 请求用户批准
3. 智能后处理
执行后,AI进行分析:
- 用户的问题
- 被执行的是什么
- 会话内存中的文件
- 项目背景
然后对结果进行自然语言解释。
模型要求
该代理与……合作 任何Ollama模型但智力各不相同:
| 模型大小 | 性能 | 推荐 |
|---|---|---|
| 32B+ | 卓越 - 轻松应对复杂任务 | ✅ 推荐 |
| 14-20B | 良好 - 对于大多数任务来说可靠 | ✅ 好选择 |
| 7-14B | Decent(尚可)- 适用于简单任务 | ⚠️ 基本使用 |
| <7B | 有限制 - 可能在规划方面遇到困难 | ❌ 不建议 |
测试的最佳模型:
qwen2.5-coder:32b-instruct-q4_K_M- 最适合编程(16GB 显存)qwen2.5:14b-instruct-q4_K_M- 良好的平衡性(8GB 显存)llama3.2:7b-instruct-q4_K_M- 最低配置选项(4GB 显存)
命令
一旦运行起来,您可以使用这些斜杠命令:
/model- 切换AI模型/clear- 清屏/session- 显示会话内存(读取的文件、上下文)/history- 显示命令历史/context- 管理上下文长度/help- 显示帮助/quit- 退出助手
会话内存
代理保持智能会话记忆:
You: /session
📋 Session Memory
📄 Files Read
┌────────────┬──────────┬────────┬──────────────────────────┐
│ File │ Size │ Lines │ Summary │
├────────────┼──────────┼────────┼──────────────────────────┤
│ client.py │ 35,234 │ 992 │ Autonomous AI agent with │
│ │ │ │ Ollama integration │
└────────────┴──────────┴────────┴──────────────────────────┘
💬 Recent Context:
1. User asked about project structure
2. Read client.py and explained architecture
3. Analyzed MCP server tools
人工智能利用这种记忆来:
- 避免重复读取文件
- 了解项目背景
- 回答关于已查看文件的问题
- 根据情境做出决策
项目结构
Autonomous-AI-Coding-Assistant/
├── mcp-client/ # AI agent client
│ ├── client.py # Main agent implementation
│ └── README.md # Client documentation
├── mcp-server/ # MCP tool server
│ ├── server.py # FastMCP server with 9 tools
│ └── README.md # Server documentation
├── start_client.sh # Start client (stdio mode)
├── start_server.sh # Start server (HTTP mode)
├── start_client_http.sh # Start client (HTTP mode)
├── requirements.txt # Python dependencies
└── README.md # This file
连接模式
标准I/O模式(默认)
- 客户端自动启动服务器作为子进程
- 简单的单命令启动
- 通过标准输入/输出进行通信
./start_client.sh
HTTP/SSE 模式
- 服务器独立运行
- 多个客户端可以连接
- 通过HTTP + 服务器发送事件进行通信
# Terminal 1
./start_server.sh
# Terminal 2
./start_client_http.sh
文档
- PURE_AI_ARCHITECTURE.md 翻译为中文是:“纯人工智能架构.md” - 纯人工智能系统的工作原理
- 自主执行说明文件(或:自主执行指南).md - 解释自主执行
- CONNECTION_MODES.md 翻译为中文是:“连接模式.md”(注:这里的“.md”通常表示Markdown文件格式,但在中文语境下,我们通常直接保留“.md”以指明文件类型,不进行翻译)。所以,完整的翻译可以是“连接模式(Markdown文件)” - 标准I/O(Stdio)与HTTP模式对比
- mcp-client/README.md(文件名保持不变,翻译说明部分)翻译为:“mcp客户端/README.md”(注:在实际文件系统中,文件名通常不需要翻译,保持原样即可,这里是为了说明文件名的含义而给出的翻译。) - 客户端架构
- mcp-server/README.md(文件名,可翻译为“MCP服务器/README.md”或保持原样,因为文件名在技术语境下通常不翻译) - 服务器工具
与基于模式的助手的关键区别
| 传统助手 | 本代理(纯AI) |
|---|---|
| 250+ 行正则表达式模式 | 零硬编码模式 |
| 固定意图检测 | AI自然理解 |
| 固定回复模板 | AI生成回复 |
| 仅限预定义命令 | 可处理任何自然语言 |
| 需要持续维护 | 无需维护 |
| 仅支持特定短语 | 支持任何短语表述 |
自然语言理解的示例
人工智能能自然地理解这些(以及无限多的变化形式):
✅ "what directory am i in"
✅ "list files"
✅ "read client.py"
✅ "search for the MCPClient class"
✅ "analyze this project"
✅ "what's the purpose of server.py"
✅ "generate a django project on X"
✅ "create a REST API for Y"
✅ "fix the bug in Z"
✅ "add error handling"
✅ "refactor the database models"
无需图案! 人工智能大脑理解一切。
与Claude代码的比较
这个代理使用 与克劳德·科德(Claude Code)相同的哲学:
| 特性 | 本代理 | Claude 代码 |
|---|---|---|
| 模式匹配 | ❌ 无 | ❌ 无 |
| 固定编码规则 | ❌ 无 | ❌ 无 |
| 自然语言 | ✅ 完整 | ✅ 完整 |
| 上下文感知 | ✅ 是 | ✅ 是 |
| 内存 | ✅ 会话 | ✅ 对话 |
| 方法 | 🧠 纯AI | 🧠 纯AI |
要求
- Python 3.8或更高版本
- 安装了至少一个模型的Ollama
- 4GB+ 显存(越多越好)
- Linux/macOS/带有WSL的Windows
故障排除
模型未能生成有效计划
- 使用一个更大的模型(建议使用140亿参数及以上)
- 尝试使用qwen2.5-coder模型(专为编码设计)
- 检查模型是否正常工作:
ollama run <model> "test"
“工具‘X’不可用”错误
- 检查MCP服务器是否正在运行
- 验证已加载的工具:
/session命令显示工具 - 重启客户端:
./start_client.sh
反应迟钝
- 使用较小的模型(7-140亿参数范围)
- 使用量化模型(q4_K_M 或 q5_K_M)
- 确保有足够的显存可用
贡献
这是一个纯AI代理——其改进来源于:
- 使用更好/更大的模型
- 增强会话记忆系统
- 增加更多MCP工具
- 优化最小AI提示(或:改进最基本的AI提示)
无需维护模式匹配!
许可证
MIT 许可证 - 请参阅 LICENSE 文件
功劳;学分;资历
构建于:
- Ollama(注:这是一个专有名词或特定项目/公司的名称,直接翻译可能无法准确传达其含义,因此在这里保留原样) - 本地大型语言模型(LLM)托管
- FastMCP - MCP服务器框架
- Rich(人名,可译为“里奇”) - 终端用户界面
- Prompt 工具包 - 交互式命令行界面(CLI)
受……的启发 克劳德·科德 - 最棒的AI编程助手。
