Auto-Coder
是一个基于终端(terminal)的、利用大语言模型(LLM,比如 GPT 或类似模型)为开发者进行代码补全、解释和重构的 AI 辅助编程工具。它的理念很像“ChatGPT for terminal”,但专为程序员场景优化,可以无缝和本地代码、终端流程结合。
源码:allwefantasy/auto-coder GitCode - 全球开发者的开源社区,开源代码托管平台
介绍视频:GitCode九分钟带你认识Auto-Coder_哔哩哔哩_bilibili
手册:Docs
因为依赖库ray安装问题,导致auto-coder无法安装在FreeBSD系统。在Ubuntu22.04和FreeBSD兼容模式下的Ubuntu22.04环境下安装成功。
conda create --name autocoder python=3.10.11
conda activate autocoder
pip install -U auto-coder
auto-coder.chat
当然也可以使用pip安装
pip install auto-coder -U
# 或者
uv pip install auto-coder -U
有可能还需要手工安装pypdf或者byzerllm等库
pip install byzerllm pypdf
# 或者
uv pip install byzerllm pypdf
pip show auto-coder
pip show auto-coder
Name: auto-coder
Version: 0.1.377
Summary: AutoCoder: AutoCoder
Home-page:
Author: allwefantasy
Author-email:
License:
Location: /home/skywalk/py312/lib/python3.12/site-packages
Requires: aiofiles, anthropic, azure-cognitiveservices-speech, byzerllm, cairosvg, colorama, contextlib2, dashscope, diff-match-patch, docx2pdf, docx2txt, duckdb, fastapi, filelock, GitPython, google-generativeai, jinja2, jupyter-client, loguru, mammoth, markdownify, matplotlib, mcp, ninja, openai, openpyxl, paramiko, patch, pathspec, pathvalidate, pdf2image, pdfminer.six, pexpect, prompt-toolkit, protobuf, puremagic, pydub, pyjava, pylint, pyperclip, python-docx, python-pptx, readerwriterlock, real-agent, reportlab, retrying, rich, setuptools, SpeechRecognition, tabulate, tiktoken, tokenizers, tqdm, uvicorn, watchfiles, youtube-transcript-api, zhipuai
Required-by:
下载链接:3.Auto-Coder安装和配置 - 飞书云文档 找到autocodertest.zip文件,下载,解压
~/work/autocoder$ unzip /mnt/e/360Downloads/autocodertest.zip
auto-coder.chat --lite --debug
输入项目类型:java
如果留空,默认是python:Default is 'py' if left empty.
只支持四个模型供应商,有点少啊!后来发现,可以加自定义模型。
初始化后,进入控制台,加入自定义模型
/models /add_model name=newgp4-4o model_name=gp4-4o base_url=http://192.168.1.5:1337/v1
可以看到加入成功
All Models (内置 + models.json)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━┓
┃ ┃ ┃ ┃ Input ┃ Output ┃ ┃
┃ ┃ ┃ ┃ Price ┃ Price ┃ Speed ┃
┃ Name ┃ Model Name ┃ Base URL ┃ (M) ┃ (M) ┃ (s/req) ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━┩
│ newgp4-4o │ gpt-4o │ http://192.168.1.5:133 │ 0.00 │ 0.00 │ 0.000 │
│ │ │ 7/v1 │ │ │
拼写错误了,后面改掉
激活模型的意思就是给这个模型加上key。也就是这个模型有key了,能被调用了。
/models /add openrouter-sonnet-3.5
/models /add newgp4-4o
看,我们加进去的newgpt-4o模型被加入,并被激活:
[email protected]:~$ /models /list
All Models (内置 + models.json)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━┓
┃ ┃ ┃ ┃ Input ┃ Output ┃ ┃
┃ ┃ ┃ ┃ Price ┃ Price ┃ Speed ┃
┃ Name ┃ Model Name ┃ Base URL ┃ (M) ┃ (M) ┃ (s/req) ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━┩
│ newgpt-4o * │ gpt-4o │ http://192.168.1.5:133 │ 0.00 │ 0.00 │ 0.000 │
│ │ │ 7/v1 │ │ │ │
├───────────────────────────────────┼─────────────────────────┼────────────────────────┼──────────┼─────────┼──────────┤
│ gp4-4o │ gp4-4o │ https://api.openai.com │ 0.00 │ 0.00 │ 0.000 │
│ │ │ /v1 │ │ │ │
/conf chat_model:newgpt-4o
就是说要用这个模型就行chat了
/conf model:ark_v3_0324_chat
/models /activate sili_deepseek_r1_chat
这部分是不是看得迷迷糊糊? 我也是!
说实话,每家AI助手的模型设定部分都不太一样,但是aotu-coder的实在有点麻烦。
怎么这个也是激活模型呢?
/models /add newgp4-4o
直接输入指令即可:
───────────────────────────────────────── Starting Agentic Edit: autocodertest ─────────────────────────────────────────
╭───────────────────────────────────────────────────── Objective ──────────────────────────────────────────────────────╮
│ User Query: │
│ hello │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
当前会话总 tokens: 8882
Hello! How can I assist you today?当前会话总 tokens: 8902
当前会话总 tokens: 8971
当前会话总 tokens: 9021
╭─ ️ Action: AskFollowupQuestionTool ──────────────────────────────────────────────────────────────────────────────────╮
│ AutoCoder is asking a question: │
│ How can I assist you? Please let me know your specific task or request. │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭────────────────────── auto-coder.chat's Question ───────────────────────╮
│ How can I assist you? Please let me know your specific task or request. │
╰─────────────────────────────────────────────────────────────────────────╯
Your Reply: 帮我分析当前项目的流程图
可以看到,上来会话tokens就是8882个起...果然是token的大杀器,不过我喜欢!
最终输出
File: project_flowchart.md
╭──────────────────────────────────────── File Diff ─────────────────────────────────────────╮
│ 1 diff --git a/project_flowchart.md b/project_flowchart.md │
│ 2 new file mode 100644 │
│ 3 index 0000000..7e28921 │
│ 4 --- /dev/null │
│ 5 +++ b/project_flowchart.md │
│ 6 @@ -0,0 +1,12 @@ │
│ 7 + │
│ 8 +# 项目流程图 │
│ 9 + │
│ 10 +```mermaid │
│ 11 +flowchart TD │
│ 12 + A[启动程序: AutocodertestApplication.main] --> B{Spring Boot自动配置} │
│ 13 + B --> C[扫描并加载配置] │
│ 14 + B --> D[启动Web服务器] │
│ 15 + D --> E[等待请求] │
│ 16 +``` │
│ 17 + │
│ 18 +当前项目仅包含 Spring Boot 启动入口,无具体 Controller 或 Service 实现,主流程如上。 │
╰────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Task Completion ─────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 已根据项目源代码结构分析并生成项目流程图,内容已保存至 project_flowchart.md。流程图采用 Mermaid 语法,展示了 Spring │
│ Boot 项目的启动主流程。由于项目当前仅包含启动入口,未实现具体业务逻辑,流程图反映了启动与自动配置的基本流程。 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
──────────────────────────────────────────────── Agentic Edit Finished ─────────────────────────────────────────────────
感觉,还是不错的!
然后一会儿就完成了:已创建 hello.py 文件,内容为经典的 Hello World 演示。你可以运行该脚本,输出 "Hello, World!",这是最基础的跨平台 │
│ Hello World 示例。
这时候直接输入:[email protected]:~$ /shell python hello.py
看到了期待的输出:Hello, World!
证明整个项目运行ok
如下是整个任务的信息:
───────────────────────────────────────── Starting Agentic Edit: autocodertest ─────────────────────────────────────────
╭───────────────────────────────────────────────────── Objective ──────────────────────────────────────────────────────╮
│ User Query: │
│ 帮我写个helloworld demo │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
当前会话总 tokens: 8888
用户请求一个“helloworld demo”。根据常见惯例,最简单且通用的 Hello World 演示可以用多种语言实现(如 Python、JavaScript 、C、Java 等)。但用户未指定语言或平台。根据当前工作目录结构和操作系统(Ubuntu 22.04),一种最简单的方式是用 Python 或 Bash 脚本,或者生成一个 HTML 文件(可在浏览器直接打开)。
分析 environment_details,当前目录为空,没有其他项目依赖,那么直接创建一个 hello.py(Python 脚本)或 hello.html(HTML 文件)都合适。Python 在 Ubuntu 上默认可用,HTML 不依赖任何环境。
选择 Python 作为最直接、简单、跨平台的示例,文件名为 hello.py,内容为经典的 print("Hello, World!")。
使用 write_to_file 工具创建 hello.py 文件,并写入内容。
当前会话总 tokens: 9135
╭─ ️ Action: WriteToFileTool ──────────────────────────────────────────────────────────────────────────────────────────╮
│ AutoCoder wants to write to this file: │
│ hello.py │
│ │
│ Content Snippet: │
│ │
│ print("Hello, World!") │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ ✅ Tool Result: WriteToFileTool ────────────────────────────────────────────────────────────────────────────────────╮
│ Status: Success │
│ Message: hello.py │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
{
"content": "\nprint(\"Hello, World!\")\n"
}
当前会话总 tokens: 9193
已经确认 hello.py 文件成功创建,内容为经典的 Hello World 输出。现在可以通过命令行运行 python hello.py 来展示结果。用户系统为 Ubuntu,Python 应为默认可用。
当前会话总 tokens: 9327
✅ Successfully updated YAML file: /home/skywalk/work/autocoder/autocodertest/actions/000000000013_chat_action.yml
╭───────────────────── Git Commit Summary ──────────────────────╮
│ Commit Information (Use /revert to revert this commit) │
│ ┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ │
│ ┃ Attribute ┃ Value ┃ │
│ ┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │
│ │ Commit Hash │ 1a815180346c2e7ff673594065cfd79be1209485 │ │
│ │ Commit Message │ 帮我写个helloworld demo │ │
│ │ │ auto_coder_000000000013_chat_action.yml │ │
│ │ Changed Files │ hello.py │ │
│ └────────────────┴──────────────────────────────────────────┘ │
╰───────────────────────────────────────────────────────────────╯
File: hello.py
╭───────────── File Diff ──────────────╮
│ 1 diff --git a/hello.py b/hello.py │
│ 2 new file mode 100644 │
│ 3 index 0000000..d2c66e8 │
│ 4 --- /dev/null │
│ 5 +++ b/hello.py │
│ 6 @@ -0,0 +1,2 @@ │
│ 7 + │
│ 8 +print("Hello, World!") │
╰──────────────────────────────────────╯
╭─ Task Completion ─────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 已创建 hello.py 文件,内容为经典的 Hello World 演示。你可以运行该脚本,输出 "Hello, World!",这是最基础的跨平台 │
│ Hello World 示例。 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Suggested command: python3 hello.py
──────────────────────────────────────────────── Agentic Edit Finished ─────────────────────────────────────────────────
[email protected]:~$ /shell python hello.py
Running command: /tmp/tmpmjuo396e.sh
Output streaming:
Hello, World!
Command completed with return code: 0
后来还让它写了个雷电打飞机的小游戏,是我用很多AI助手,写出来最丝滑手感的两个AI助手之一!
使用/shell 开头,可以运行常规命令,如:
[email protected]:~$ /shell pip install -U curl_cffi
后来发现它很聪明,如果不用/shell,它有时候也能识别出来意图,比如有一次直接写了“df”,结果它思考半天,执行了“df -h”指令,并开始分析硬盘空间大小等问题,相当智能!
这是我近期试用的命令行下的AI工具里,几乎是效果最好的,bug最少得一个。
不过它的模型配置那块略有些繁琐,跟其它几种工具的配置方法不一样,有点不习惯。
安装byzerllm
pip install byzerllm
# 或者
uv pip install byzerllm
安装pypdf
pip install pypdf
也可以开始安装auto-coder的时候,选择
uv pip install auto-coder[all] -U
Traceback (most recent call last):
File "/home/skywalk/py312/bin/auto-coder", line 10, in
sys.exit(main())
^^^^^^
File "/home/skywalk/py312/lib/python3.12/site-packages/autocoder/auto_coder.py", line 133, in main
if not os.path.isabs(args.source_dir):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "
TypeError: expected str, bytes or os.PathLike object, not NoneType