aidermacs开源程序使用 Aider 在 Emacs 中进行 AI 配对编程
一、软件介绍
文末提供程序和源码下载
Aidermacs 通过集成 Aider(最强大的开源 AI 配对编程工具之一)为 Emacs 带来了 AI 驱动的开发。如果您缺少 Cursor,但更喜欢生活在 Emacs 中,Aidermacs 提供了类似的 AI 功能,同时保持 Emacs 工作流程。
二、Key Features 主要特点
- 具有多个后端的智能模型选择
- 内置 Ediff 集成,用于 AI 生成的更改
- 来自 Emacs 的增强文件管理
- 出色的可定制性和灵活的内容添加方式
三、Quick Start 快速开始
- Requirements 要求
- Emacs ≥ 26.1 Emacs ≥ 26.1 版
- Aider 帮助
- Transient 短暂的
- Download Aidermacs through Melpa or Non-GNU Elpa, or clone manually
通过 Melpa 或非 GNU Elpa 下载 Aidermacs,或手动克隆 - Modify this sample config and place it in your Emacs
init.el
:
修改此示例配置并将其放在您的 Emacsinit.el
中:
(use-package aidermacs:bind (("C-c a" . aidermacs-transient-menu)):config; Set API_KEY in .bashrc, that will automatically picked up by aider or in elisp(setenv "ANTHROPIC_API_KEY" "sk-..."); defun my-get-openrouter-api-key yourself elsewhere for security reasons(setenv "OPENROUTER_API_KEY" (my-get-openrouter-api-key)):custom; See the Configuration section below(aidermacs-use-architect-mode t)(aidermacs-default-model "sonnet"))
- Open a project and run
M-x aidermacs-transient-menu
orSPC a a
(or your chosen binding).
打开一个项目并运行M-x aidermacs-transient-menu
orSPC a a
(或您选择的绑定)。 - Add files and start coding with AI!
添加文件并开始使用 AI 编码!
Spacemacs 太空马克斯
For Spacemacs users: 对于 Spacemacs 用户:
- Add
aidermacs
to yourdotspacemacs-additional-packages
list in your.spacemacs
file:
将aidermacs
Add to listdotspacemacs-additional-packages
in your.spacemacs
file:
dotspacemacs-additional-packages '((aidermacs :variablesaidermacs-use-architect-mode taidermacs-default-model "sonnet")
)
- Add the keybinding to your
dotspacemacs/user-config
function in.spacemacs
:
在.spacemacs
: 中将键绑定添加到函数dotspacemacs/user-config
中:
(defun dotspacemacs/user-config ();; Set leader key for Aidermacs(spacemacs/set-leader-keys "aa" 'aidermacs-transient-menu) ; Example binding SPC a a
)
- Open a project and run
M-x aidermacs-transient-menu
orSPC a a
(or your chosen binding).
打开一个项目并运行M-x aidermacs-transient-menu
orSPC a a
(或您选择的绑定)。 - Add files and start coding with AI!
添加文件并开始使用 AI 编码!
四、Usage 用法
Getting Started 开始
The main interface to Aidermacs is through its transient menu system (similar to Magit). Access it with:
Aidermacs 的主要界面是通过其瞬态菜单系统(类似于 Magit)。通过以下方式访问它:
<span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><span style="color:#1f2328"><span style="color:var(--fgColor-default, var(--color-fg-default))"><span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><code>M-x aidermacs-transient-menu
</code></span></span></span></span>
Or bind it to a key in your config:
或者将其绑定到配置中的键:
(global-set-key (kbd "C-c a") 'aidermacs-transient-menu)
Once the transient menu is open, you can navigate and execute commands using the displayed keys. Here's a summary of the main menu structure:
打开临时菜单后,您可以使用显示的键导航和执行命令。以下是主菜单结构的摘要:
Core 核心
a
: Start/Open Session (auto-detects project root)
a
:启动/打开会话(自动检测项目根).
: Start in Current Directory (good for monorepos)
.
:从当前目录开始(适用于 monorepos)l
: Clear Chat History
l
:清除聊天记录s
: Reset Session
s
:重置会话x
: Exit Sessionx
:退出会话
Persistent Modes 持久模式
1
: Code Mode1
:代码模式2
: Chat/Ask Mode
2
:聊天/询问模式3
: Architect Mode
3
:建筑师模式4
: Help Mode4
: 帮助模式
Utilities 公用事业
^
: Show Last Commit (if auto-commits enabled)
^
:显示上次提交(如果启用了自动提交)u
: Undo Last Commit (if auto-commits enabled)
u
:撤消上次提交(如果启用了自动提交)R
: Refresh Repo Map
R
:刷新 Repo Maph
: Session History
h
: 会话历史记录o
: Change Main Model
o
:更改主模型?
: Aider Meta-level Help
?
: Aider 元级帮助
File Actions 文件作
f
: Add File (C-u: read-only)
f
:添加文件(C-u:只读)F
: Add Current File
F
:添加当前文件d
: Add From Directory (same type)
d
:从目录添加(相同类型)w
: Add From Window
w
:从窗口添加m
: Add From Dired (marked)
m
: 从 Dired 添加(标记)j
: Drop Filej
: 放置文件J
: Drop Current File
J
:删除当前文件k
: Drop From Dired (marked)
k
: Drop From Dired (标记)K
: Drop All Files
K
:删除所有文件S
: Create Session Scratchpad
S
:创建会话暂存器G
: Add File to Session
G
:将文件添加到会话A
: List Added Files
A
:列出添加的文件
Code Actions 代码作
c
: Code Changec
: 代码更改e
: Question Code
e
: 问题代码r
: Architect Change
r
: 架构师变更q
: General Question
q
: 一般问题p
: Question This Symbol
p
: 质疑此符号g
: Accept Proposed Changes
g
:接受建议的更改i
: Implement TODO
i
:实施 TODOt
: Write Testt
: 编写测试T
: Fix TestT
: 修复测试!
: Debug Exception
!
:调试异常
The All File Actions
and All Code Actions
entries open submenus with more specialized commands. Use the displayed keys to navigate these submenus.
和 All File Actions
All Code Actions
entries 打开包含更专用命令的子菜单。使用显示的键来导航这些子菜单。
五、文件管理和 AI 交互
使用 Aidermacs 时,您可以灵活地决定 AI 应该读取和编辑哪些文件。以下是一些准则:
- Editable Files: Add files you want the AI to potentially edit. This grants the AI permission to both read and modify these files if necessary.
Editable Files(可编辑的文件):添加您希望 AI 可能编辑的文件。这将授予 AI 在必要时读取和修改这些文件的权限。 - Read-Only Files: If you want the AI to read a file without editing it, you can add it as read-only. In Aidermacs, all add file commands can be prefixed with
C-u
to specify read-only access.
只读文件:如果您希望 AI 读取文件而不对其进行编辑,您可以将其添加为只读。在 Aidermacs 中,所有 add file 命令都可以作为前缀C-u
以指定只读访问权限。 - Session Scratchpads: Use the session scratchpads (
S
) to paste notes or documentation that will be fed to the AI as read-only.
会话暂存器:使用会话暂存器 ()S
粘贴注释或文档,这些注释或文档将作为只读馈送到 AI。 - External Files: The "Add file to session" (
G
) command allows you to include files outside the current project (or files in.gitignore
), as Aider doesn't automatically include these files in its context.
外部文件: “Add file to session” (G
) 命令允许您包含当前项目之外的文件(或 中的.gitignore
文件),因为 Aider 不会自动将这些文件包含在其上下文中。
The AI can sometimes determine relevant files on its own, depending on the model and the context of the codebase. However, for precise control, it's often beneficial to manually specify files, especially when dealing with complex projects.
AI 有时可以根据模型和代码库的上下文自行确定相关文件。但是,为了进行精确控制,手动指定文件通常是有益的,尤其是在处理复杂项目时。
Aider encourages a collaborative approach, similar to working with a human co-worker. Sometimes the AI will need explicit guidance, while other times it can infer the necessary context on its own.
Aider 鼓励一种协作方法,类似于与人类同事一起工作。有时 AI 需要明确的指导,而其他时候它可以自行推断必要的上下文。
Prompt Files Minor Mode Prompt Files Minor 模式
Aidermacs provides a minor mode that makes it easy to work with prompt files and other Aider-related files. When enabled, the minor mode provides these convenient keybindings:
Aidermacs 提供了一个次要模式,可以轻松处理提示文件和其他与 Aider 相关的文件。启用后,minor 模式将提供以下方便的键绑定:
C-c C-n
orC-<return>
: Send line/region line-by-line
C-c C-n
或C-<return>
:逐行发送/区域C-c C-c
: Send block/region as whole
C-c C-c
:将块/区域作为整体发送C-c C-z
: Switch to Aidermacs buffer
C-c C-z
:切换到 Aidermacs 缓冲液
The minor mode is automatically enabled for:
次要模式会自动启用:
.aider.prompt.org
files (create withM-x aidermacs-open-prompt-file
)
.aider.prompt.org
文件(使用M-x aidermacs-open-prompt-file
创建 ).aider.chat.md
files.aider.chat.md
文件.aider.chat.history.md
files.aider.chat.history.md
文件.aider.input.history
files.aider.input.history
文件
Configuration 配置
Pre-Run Hook
You can use the aidermacs-before-run-backend-hook
to run custom setup code before starting the Aider backend. This is particularly useful for:
在启动 Aider 后端之前,您可以使用 aidermacs-before-run-backend-hook
to run custom setup code。这特别适用于:
- Setting environment variables
设置环境变量 - Injecting secrets 注入密钥
- Performing any other pre-run configuration
执行任何其他运行前配置
Example usage to securely set an OpenAI API key from password-store:
从 password-store 中安全设置 OpenAI API 密钥的示例用法:
(add-hook 'aidermacs-before-run-backend-hook(lambda ()(setenv "OPENAI_API_KEY" (password-store-get "code/openai_api_key"))))
This approach keeps sensitive information out of your dotfiles while still making it available to Aidermacs.
这种方法将敏感信息排除在点文件之外,同时仍可供 Aidermacs 使用。
Default Model Selection 默认模型选择
You can customize the default AI model used by Aidermacs by setting the aidermacs-default-model
variable:
您可以通过设置 aidermacs-default-model
变量来自定义 Aidermacs 使用的默认 AI 模型:
(setq aidermacs-default-model "sonnet")
This enables easy switching between different AI models without modifying the aidermacs-extra-args
variable.
这样可以在不同的 AI 模型之间轻松切换, aidermacs-extra-args
而无需修改变量。
Note: This configuration will be overwritten by the existence of an .aider.conf.yml
file (see details).
注意:此配置将被 .aider.conf.yml
文件的存在覆盖(请参阅详细信息)。
Dynamic Model Selection 动态模型选择
Aidermacs offers intelligent model selection for solo (non-Architect) mode, automatically detecting and integrating with multiple AI providers:
Aidermacs 为单独(非架构师)模式提供智能模型选择,自动检测并与多个 AI 提供商集成:
- Automatically fetches available models from supported providers (OpenAI, Anthropic, DeepSeek, Google Gemini, OpenRouter)
自动从支持的提供商(OpenAI、Anthropic、DeepSeek、Google Gemini、OpenRouter)获取可用模型 - Caches model lists for quick access
缓存模型列表以便快速访问 - Supports both popular pre-configured models and dynamically discovered ones
支持流行的预配置模型和动态发现的模型 - Handles API keys and authentication automatically from your .bashrc
自动处理来自 .bashrc 的 API 密钥和身份验证 - Provides model compatibility checking
提供模型兼容性检查
The dynamic model selection is only for the solo (non-Architect) mode.
动态模型选择仅适用于 solo (non-Architect) 模式。
To change models in solo mode:
要在 solo 模式下更改模型:
- Use
M-x aidermacs-change-model
or presso
in the transient menu
使用M-x aidermacs-change-model
或按下o
瞬态菜单中的 - Select from either: 从以下任一选项中选择:
- Popular pre-configured models (fast)
流行的预配置模型 (快速) - Dynamically fetched models from all supported providers (comprehensive)
从所有支持的提供商处动态获取模型(全面)
- Popular pre-configured models (fast)
The system will automatically filter models to only show ones that are:
系统将自动筛选模型,仅显示符合以下条件的模型:
- Supported by your current Aider version
受当前 Aider 版本支持 - Available through your configured API keys
通过您配置的 API 密钥提供 - Compatible with your current workflow
与您当前的工作流程兼容
Architect Mode - Separating Code Reasoning and Editing Models
架构师模式 - 分离代码推理和编辑模型
Aidermacs features an experimental mode using two specialized models for each coding task: an Architect model for reasoning and an Editor model for code generation. This approach has achieved state-of-the-art (SOTA) results on aider's code editing benchmark, as detailed in this blog post.
Aidermacs 具有一种实验模式,为每个编码任务使用两个专用模型:用于推理的 Architect 模型和用于代码生成的 Editor 模型。这种方法在 aider 的代码编辑基准测试中取得了最先进的 (SOTA) 结果,如本篇博客文章中所述。
To enable this mode, set aidermacs-use-architect-mode
to t
. You must also configure the aidermacs-architect-model
variable to specify the model to use for the Architect role.
要启用此模式,请设置为 aidermacs-use-architect-mode
t
。您还必须配置 aidermacs-architect-model
变量以指定要用于 Architect 角色的模型。
By default, the aidermacs-editor-model
is the same as aidermacs-default-model
. You only need to set aidermacs-editor-model
if you want to use a different model for the Editor role.
默认情况下,the aidermacs-editor-model
与 aidermacs-default-model
相同。如果您想为 Editor 角色使用其他模型,则只需进行设置 aidermacs-editor-model
。
When Architect mode is enabled, the aidermacs-default-model
setting is ignored, and aidermacs-architect-model
and aidermacs-editor-model
are used instead.
启用 Architect 模式后,将忽略该 aidermacs-default-model
设置,并 aidermacs-architect-model
改用 。 aidermacs-editor-model
(setq aidermacs-use-architect-mode t)
You can switch to it persistently by M-x aidermacs-switch-to-architect-mode
(3
in aidermacs-transient-menu
), or temporarily with M-x aidermacs-architect-this-code
(r
in aidermacs-transient-menu
).
您可以通过 M-x aidermacs-switch-to-architect-mode
( 3
in aidermacs-transient-menu
) 永久切换到它,也可以使用 M-x aidermacs-architect-this-code
() ( r
in aidermacs-transient-menu
)临时切换到它。
You can configure each model independently:
您可以单独配置每个模型:
;; Default model used for all modes unless overridden
(setq aidermacs-default-model "sonnet");; Optional: Set specific model for architect reasoning
(setq aidermacs-architect-model "deepseek/deepseek-reasoner");; Optional: Set specific model for code generation
(setq aidermacs-editor-model "deepseek/deepseek-chat")
The model hierarchy works as follows:
模型层次结构的工作原理如下:
- When Architect mode is enabled:
启用 Architect 模式后:- The Architect model handles high-level reasoning and solution design
Architect 模型处理高级推理和解决方案设计 - The Editor model executes the actual code changes
Editor 模型执行实际的代码更改
- The Architect model handles high-level reasoning and solution design
- When Architect mode is disabled, only
aidermacs-default-model
is used
禁用 Architect 模式时,仅使用aidermacs-default-model
- You can configure specific models or let them automatically use the default model
您可以配置特定模型或让它们自动使用默认模型
Models will reflect changes to aidermacs-default-model
unless they've been explicitly set to a different value.
模型将反映更改, aidermacs-default-model
除非它们已明确设置为不同的值。
Note: These configurations will be overwritten by the existence of an .aider.conf.yml
file (see details).
注意:这些配置将被 .aider.conf.yml
文件的存在覆盖(请参阅详细信息)。
Customize Weak Model 自定义弱模型
The Weak model is used for commit messages (if you have aidermacs-auto-commits
set to t
) and chat history summarization (default depends on –model). You can customize it using
弱模型用于提交消息(如果已 aidermacs-auto-commits
设置为 t
)和聊天历史记录摘要(默认值取决于 –model)。您可以使用
;; default to nil
(setq aidermacs-weak-model "deepseek/deepseek-chat")
You can change the Weak model during a session by using C-u o
(aidermacs-change-model
with a prefix argument). In most cases, you won't need to change this as Aider will automatically select an appropriate Weak model based on your main model.
您可以在会话期间使用 C-u o
aidermacs-change-model
带有 prefix 参数的 () 来更改 Weak 模型。大多数情况下,你不需要更改此设置,因为 Aider 会根据你的主模型自动选择合适的 Weak 模型。
Note: These configurations will be overwritten by the existence of an .aider.conf.yml
file (see details).
注意:这些配置将被 .aider.conf.yml
文件的存在覆盖(请参阅详细信息)。
Architect Mode Confirmation
架构师模式确认
By default, Aidermacs requires explicit confirmation before applying changes proposed in Architect mode. This gives you a chance to review the AI's plan before any code is modified.
默认情况下,Aidermacs 需要明确确认,然后才能应用在 Architect 模式下建议的更改。这使您有机会在修改任何代码之前查看 AI 的计划。
If you prefer to automatically accept all Architect mode changes without confirmation (similar to Aider's default behavior), you can enable this with:
如果您希望在不确认的情况下自动接受所有 Architect 模式更改(类似于 Aider 的默认行为),您可以通过以下方式启用此功能:
(setq aidermacs-auto-accept-architect t)
Note: These configurations will be overwritten by the existence of an .aider.conf.yml
file (see details).
注意:这些配置将被 .aider.conf.yml
文件的存在覆盖(请参阅详细信息)。
Terminal Backend Selection
终端后端选择
Choose your preferred terminal backend by setting aidermacs-backend
:
通过设置 aidermacs-backend
选择您喜欢的终端后端 :
vterm
offers better terminal compatibility, while comint
provides a simple, built-in option that remains fully compatible with Aidermacs.
vterm
提供更好的终端兼容性,同时 comint
提供与 Aidermacs 完全兼容的简单内置选项。
;; Use vterm backend (default is comint)
(setq aidermacs-backend 'vterm)
Available backends: 可用的后端:
comint
(default): Uses Emacs' built-in terminal emulation
comint
(默认):使用 Emacs 的内置终端仿真vterm
: Leverages vterm for better terminal compatibility
vterm
:利用 vterm 实现更好的终端兼容性
Emacs theme support Emacs 主题支持
The vterm backend will use the faces defined by your active Emacs theme to set the colors for aider. It tries to guess some reasonable color values based on your themes. In some cases this will not work perfectly; if text is unreadable for you, you can turn this off as follows:
vterm 后端将使用活动 Emacs 主题定义的人脸来设置 aider 的颜色。它会尝试根据您的主题猜测一些合理的颜色值。在某些情况下,这不会完美工作;如果文本对您来说不可读,您可以按如下方式关闭此功能:
;; don't match emacs theme colors
(setopt aidermacs-vterm-use-theme-colors nil)
Multiline Input Configuration
多线路输入配置
You can customize keybindings for multiline input, this key allows you to enter multiple lines without sending the command to Aider. Press RET
normally to send the command.
您可以自定义多行输入的键绑定,此键允许您输入多行而无需将命令发送给 Aider。按 normally 键 RET
发送命令。
;; Comint backend:
(setq aidermacs-comint-multiline-newline-key "S-<return>")
;; Vterm backend:
(setq aidermacs-vterm-multiline-newline-key "S-<return>")
Remote File Support with Tramp
Tramp 的远程文件支持
Aidermacs fully supports working with remote files through Emacs' Tramp mode. This allows you to use Aidermacs on files hosted on remote servers via SSH, Docker, and other protocols supported by Tramp.
Aidermacs 完全支持通过 Emacs 的 Tramp 模式处理远程文件。这允许通过 SSH、Docker 和 Tramp 支持的其他协议对远程服务器上托管的文件使用 Aidermacs。
When working with remote files:
使用远程文件时:
- File paths are automatically localized for the remote system
文件路径会自动为远程系统本地化 - All Aidermacs features work seamlessly across local and remote files
所有 Aidermacs 功能都可以在本地和远程文件之间无缝工作 - Edits are applied directly to the remote files
编辑将直接应用于远程文件 - Diffs and change reviews work as expected
差异和更改审核按预期工作
Example usage: 用法示例:
;; Open a remote file via SSH
(find-file "/ssh:user@remotehost:/path/to/file.py");; Start Aidermacs session - it will automatically detect the remote context
M-x aidermacs-transient-menu
Prompt Selection and History
提示选择和历史记录
Aidermacs makes it easy to reuse prompts through:
Aidermacs 通过以下方式使重用提示变得容易:
- Prompt History - Your previously used prompts are saved and can be quickly selected
提示历史记录 - 您以前使用的提示将被保存,并且可以快速选择 - Common Prompts - A curated list of frequently used prompts for common tasks defined in
aidermacs-common-prompts
:
常见提示 - 在aidermacs-common-prompts
中定义的常见任务的常用提示的精选列表:
When entering a prompt, you can:
输入提示时,您可以:
- Select from your history or common prompts using completion
使用完成功能从您的历史记录或常见提示中进行选择 - Still type custom prompts when needed
在需要时仍键入自定义提示
The prompt history and common prompts are available across all sessions.
提示历史记录和常见提示在所有会话中都可用。
File Watching 文件监视
Enable watching for AI coding instructions in your repository files with aidermacs-watch-files
:
使用以下命令 aidermacs-watch-files
在存储库文件中启用对 AI 编码指令的监视:
;; Enable file watching
(setq aidermacs-watch-files t)
When enabled, Aidermacs will will watch all files in your repo and look for any AI coding instructions you add using your favorite IDE or text editor.
启用后,Aidermacs 将监视您的存储库中的所有文件,并查找您使用自己喜欢的 IDE 或文本编辑器添加的任何 AI 编码指令。
Specifically, aider looks for one-liner comments (# ...
, // ...
or -- ...
, regardless of the comment style that language supports) that either start or end with AI
, AI!
or AI?
like these:
具体来说,aider 会查找以 、 AI!
开头或结尾的 AI
单行注释( # ...
、 或 // ...
-- ...
,不管该语言支持的注释样式如何),或者 AI?
像这样:
<span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><span style="color:#1f2328"><span style="color:var(--fgColor-default, var(--color-fg-default))"><span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><code># Make a snake game. AI!
# What is the purpose of this method AI?// Write a protein folding prediction engine. AI!
</code></span></span></span></span>
Aidermacs will take note of all the comments that start or end with AI
. Comments that include AI!
with an exclamation point or AI?
with a question mark are special. They trigger aider to take action to collect all the AI comments and use them as your instructions.
Aidermacs 将记录所有以 AI
.包含 AI!
感叹号或 AI?
问号的注释是特殊的。它们触发 aider 采取行动收集所有 AI 评论并将其用作您的指令。
AI!
triggers aider to make changes to your code.
AI!
触发 Aider 以更改您的代码。AI?
triggers aider to answer your question.
AI?
触发 aider 来回答您的问题。
Note: This feature currently only works in the vterm mode.
注意:此功能目前仅在 vterm 模式下有效。
Note: These configurations will be overwritten by the existence of an .aider.conf.yml
file (see details).
注意:这些配置将被 .aider.conf.yml
文件的存在覆盖(请参阅详细信息)。
Diff and Change Review Diff 和 Change Review
Control whether to show diffs for AI-generated changes with aidermacs-show-diff-after-change
:
控制是否显示 AI 生成的更改的 aidermacs-show-diff-after-change
差异 :
;; Enable/disable showing diffs after changes (default: t)
(setq aidermacs-show-diff-after-change t)
When enabled, Aidermacs will:
启用后,Aidermacs 将:
- Capture the state of files before AI edits
在 AI 编辑之前捕获文件状态 - Show diffs using Emacs' built-in ediff interface
使用 Emacs 的内置 ediff 接口显示差异 - Allow you to review and accept/reject changes
允许您查看和接受/拒绝更改
Re-Enable Auto-Commits 重新启用自动提交
Aider automatically commits AI-generated changes by default. We consider this behavior very intrusive, so we've disabled it. You can re-enable auto-commits by setting aidermacs-auto-commits
to t
:
默认情况下,Aider 会自动提交 AI 生成的更改。我们认为此行为非常具有侵入性,因此已禁用它。您可以通过设置为 aidermacs-auto-commits
t
:
;; Enable auto-commits
(setq aidermacs-auto-commits t)
With auto-commits disabled, you must manually commit changes using your preferred Git workflow.
禁用自动提交后,您必须使用首选的 Git 工作流程手动提交更改。
Note: This configuration will be overwritten by the existence of an .aider.conf.yml
file (see details).
注意:此配置将被 .aider.conf.yml
文件的存在覆盖(请参阅详细信息)。
Customize Aider Options with aidermacs-extra-args
自定义 aidermacs-extra-args
Aider 选项
If these configurations aren't sufficient, the aidermacs-extra-args
variable enables passing any Aider-supported command-line options.
如果这些配置还不够,该 aidermacs-extra-args
变量将允许传递任何 Aider 支持的命令行选项。
See the Aider configuration documentation for a full list of available options.
有关可用选项的完整列表,请参阅 Aider 配置文档。
;; Set the verbosity:
(add-to-list 'aidermacs-extra-args "--verbose")
These arguments will be appended to the Aider command when it is run. Note that the --model
argument is automatically handled by aidermacs-default-model
and should not be included in aidermacs-extra-args
.
这些参数将在运行时附加到 Aider 命令中。请注意,该 --model
参数由 aidermacs-default-model
自动处理,不应包含在 aidermacs-extra-args
.
Overwrite Configuration with Configuration File
使用配置文件覆盖配置
Aidermacs supports project-specific configurations via .aider.conf.yml
files. To enable this:
Aidermacs 通过 .aider.conf.yml
文件支持特定于项目的配置。要启用此功能,请执行以下作:
-
Create a
.aider.conf.yml
in your home dir, project's root, or the current directory, defining your desired settings. See the Aider documentation for available options.
.aider.conf.yml
在主目录、项目的根目录或当前目录中创建一个,以定义所需的设置。有关可用选项,请参阅 Aider 文档。 -
Tell Aidermacs to use the config file in one of two ways:
告诉 Aidermacs 以两种方式之一使用配置文件:;; Set the `aidermacs-config-file` variable in your Emacs config: (setq aidermacs-config-file "/path/to/your/project/.aider.conf.yml") ;; *Or*, include the `--config` or `-c` flag in `aidermacs-extra-args`: (setq aidermacs-extra-args '("--config" "/path/to/your/project/.aider.conf.yml"))
Note: You can also rely on Aider's default behavior of automatically searching for .aider.conf.yml
in the home directory, project root, or current directory, in that order. In this case, you do not need to set aidermacs-config-file
or include --config
in aidermacs-extra-args
.
注意:您还可以依赖 Aider 的默认行为,即按顺序在主目录、项目根目录或当前目录中自动搜索 .aider.conf.yml
。在这种情况下,您无需在 中设置 aidermacs-config-file
或包含在 --config
aidermacs-extra-args
中。
- Important: When using a config file, all other Aidermacs configuration variables supplying an argument option (e.g.,
aidermacs-default-model
,aidermacs-architect-model
,aidermacs-use-architect-mode
) are IGNORED. Aider will only use the settings specified in your.aider.conf.yml
file. Do not attempt to combine these Emacs settings with a config file, as the results will be unpredictable.
重要提示:使用配置文件时,所有其他提供参数选项的 Aidermacs 配置变量(例如aidermacs-default-model
, ,aidermacs-architect-model
aidermacs-use-architect-mode
, ) 都将被忽略。Aider 将仅使用您.aider.conf.yml
文件中指定的设置。不要尝试将这些 Emacs 设置与配置文件结合使用,因为结果将是不可预测的。 - Precedence: Settings in
.aider.conf.yml
always take precedence when a config file is explicitly specified.
优先级:当显式指定配置文件时,中的.aider.conf.yml
设置始终优先。 - Avoid Conflicts: When using a config file, do not include model-related arguments (like
--model
,--architect
, etc.) inaidermacs-extra-args
. Configure all settings within your.aider.conf.yml
file.
避免冲突:使用配置文件时,请勿在--model
--architect
aidermacs-extra-args
.配置.aider.conf.yml
文件中的所有设置。
Claude 3.7 Sonnet Thinking Tokens
Claude 3.7 十四行诗思维代币
Aider can work with Sonnet 3.7's new thinking tokens. You can now enable and configure thinking tokens more easily using the following methods:
Aider 可以使用 Sonnet 3.7 的新思维令牌。现在,您可以使用以下方法更轻松地启用和配置 Thinking Tokens:
-
In-Chat Command: Use the
/think-tokens
command followed by the desired token budget. For example:/think-tokens 8k
or/think-tokens 10000
. Supported formats include8096
,8k
,10.5k
, and0.5M
.
聊天内命令:使用/think-tokens
命令后跟所需的令牌预算。例如:/think-tokens 8k
或/think-tokens 10000
.支持的格式包括8096
、 、8k
10.5k
和0.5M
。 -
Command-Line Argument: Set the
--thinking-tokens
argument when starting Aidermacs. For example, you can add this to youraidermacs-extra-args
:
命令行参数:在启动 Aidermacs 时设置--thinking-tokens
参数。例如,您可以将 this 添加到您的aidermacs-extra-args
:(setq aidermacs-extra-args '("--thinking-tokens" "16k"))
These methods provide a more streamlined way to control thinking tokens without requiring manual configuration of .aider.model.settings.yml
files.
这些方法提供了一种更简化的方式来控制思维令牌,而无需手动配置 .aider.model.settings.yml
文件。
Note: If you are using an .aider.conf.yml
file, you can also set the thinking_tokens
option there.
注: 如果您使用的是 .aider.conf.yml
文件,您也可以在此处设置该 thinking_tokens
选项。
Working with Prompt Files
使用提示文件
The .aider.prompt.org
file is particularly useful for:
该文件 .aider.prompt.org
特别适用于:
- Storing frequently used prompts
存储常用提示 - Documenting common workflows
记录常见工作流程 - Quick access to complex instructions
快速访问复杂的说明
You can customize which files automatically enable the minor mode by configuring aidermacs-auto-mode-files
:
您可以通过配置 aidermacs-auto-mode-files
来自定义哪些文件自动启用 minor 模式:
(setq aidermacs-auto-mode-files'(".aider.prompt.org"".aider.chat.md"".aider.chat.history.md"".aider.input.history""my-custom-aider-file.org")) ; Add your own files
六、软件下载
夸克网盘分享
本文信息来源于GitHub作者地址:GitHub - MatthewZMD/aidermacs: AI Pair Programming in Emacs with Aider