这篇文章是使用 aider 进行命令行文章编辑。
aider 是 openhands 某种程度上的替代品,成熟度比 openhands 要高很多(开源版本的 openhands 经常不可用)。
安装 aider 非常简单,就像是官方文档描述的一样:
1
2
| python -m pip install aider-install
aider-install
|
然后最好在自己的终端里面配置好 api key。如果使用硅基流动的 deepseek,你可以这样配置:
1
2
3
| # using siliconflow
export OPENAI_API_KEY=<your key>
export OPENAI_BASE_URL=https://api.siliconflow.cn/v1
|
这样一来,就可以直接使用 aider 了。
让我们试试采用deepseek-ai/DeepSeek-R1-0528-Qwen3-8B
模型。
aider --model openai/deepseek-ai/DeepSeek-R1-0528-Qwen3-8B README.md
得到输出:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| ~/work/blog/hugo-blog master ⇡3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── svtter@debian-vm 09:28:01 PM
❯ aider --model fast README.md
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Warning for openai/deepseek-ai/DeepSeek-R1-0528-Qwen3-8B: Unknown context window size and costs, using sane defaults.
You can skip this check with --no-show-model-warnings
https://aider.chat/docs/llms/warnings.html
Open documentation url for more info? (Y)es/(N)o/(D)on't ask again [Yes]: n
Aider v0.84.0
Model: openai/deepseek-ai/DeepSeek-R1-0528-Qwen3-8B with diff edit format
Git repo: .git with 5,038 files
Warning: For large repos, consider using --subtree-only and .aiderignore
See: https://aider.chat/docs/faq.html#can-i-use-aider-in-a-large-mono-repo
Repo-map: using 1024 tokens, auto refresh
Added README.md to the chat.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
README.md
>
|
这说明成功了;如果失败了,会提示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| ~/work/blog/hugo-blog master !1 ?1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── svtter@debian-vm 09:23:49 PM
❯ aider --model fast /home/svtter/work/blog/hugo-blog/content/post/2025-06-03-using-aider-for-cli-code-edit/index.md
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Warning for fast: Unknown context window size and costs, using sane defaults.
Did you mean one of these?
- openrouter/x-ai/grok-3-fast-beta
- openrouter/x-ai/grok-3-mini-fast-beta
- xai/grok-3-fast-beta
- xai/grok-3-fast-latest
- xai/grok-3-mini-fast-beta
- xai/grok-3-mini-fast-latest
You can skip this check with --no-show-model-warnings
https://aider.chat/docs/llms/warnings.html
Open documentation url for more info? (Y)es/(N)o/(D)on't ask again [Yes]:
|
简单的编辑,可以直接用小模型来处理。
至于怎么算简单…
本文的 tag 就是通过 aider 生成的。Have fun。