updated readme

This commit is contained in:
Paul Gauthier 2023-05-10 22:48:26 -07:00
parent 13760f3071
commit d9789f3fd7
2 changed files with 25 additions and 26 deletions

View file

@ -1,8 +1,8 @@
# Aider # Aider
Aider is a command-line tool that allows you to chat with GPT-4 about your code. Aider is a command-line tool that allows you to chat with GPT-4 about your code.
It can make changes, improvements, and bug fixes to the code in your local git repo. Aider will directly edit your source files as directed by the GPT-4 chat, and commit those changes to your local git repo.
Each change is automatically committed to git with a sensible commit message. Each change is automatically committed to git with a sensible commit message, making it easy and safe for aider to help you code.
[![asciicast](https://asciinema.org/a/eDDqO3PlqH4lUBBXnLlMG7l2x.svg)](https://asciinema.org/a/eDDqO3PlqH4lUBBXnLlMG7l2x) [![asciicast](https://asciinema.org/a/eDDqO3PlqH4lUBBXnLlMG7l2x.svg)](https://asciinema.org/a/eDDqO3PlqH4lUBBXnLlMG7l2x)
@ -10,16 +10,17 @@ Each change is automatically committed to git with a sensible commit message.
* Chat with GPT-4 about your code by launching aider with set of source files to discuss and edit together. * Chat with GPT-4 about your code by launching aider with set of source files to discuss and edit together.
* Request changes, improvements, and bug fixes to your code. * Request changes, improvements, and bug fixes to your code.
* Aider will apply the edits suggested by GPT-4. * Aider will apply the edits suggested by GPT-4 directly to your source files.
* Aider will automatically commit each changeset to git with a sensible commit message. These frequent, automatic commits provide a safety net. It's easy to use standard git workflows to either adopt or undo/abandon a series of changes. * Aider will automatically commit each changeset to your local git repo with a sensible commit message. These frequent, automatic commits provide a safety net. It's easy to undo aider's changes or use standard git workflows to manage longer sequences of changes.
* Aider can review multiple source files at once and make coordinated code changes across all of them in a single changeset/commit. * Aider can review multiple source files at once and make coordinated code changes across all of them in a single changeset/commit.
* Aider knows about all the files in your repo, so it can ask for permission to review whichever files seem relevant to your requests.
* You can also edit the files in your editor while chatting with aider. * You can also edit the files in your editor while chatting with aider.
* Aider will notice if you edit the files outside the chat. * Aider will notice if you edit the files outside the chat.
* It will help you commit these out-of-band changes, if you'd like. * It will help you commit these out-of-band changes, if you'd like.
* It will import the new file contents into the chat. * It will bring the updated file contents into the chat.
* You can bounce back and forth between the aider chat and your editor, to fluidly collaborate. * You can bounce back and forth between the aider chat and your editor, to fluidly collaborate.
* Live, colorized, human friendly output. * Live, colorized, human friendly output.
* Readline style chat input history, with autocompletion of tokens found in the source files being discussed (via `prompt_toolkit`) * Readline style chat input history, with autocompletion of code tokens found in the source files being discussed (via `prompt_toolkit` and `pygments` lexers)
## Installation ## Installation
@ -28,13 +29,17 @@ Each change is automatically committed to git with a sensible commit message.
## Usage ## Usage
Run the Aider tool by executing the following command: Run the aider tool by executing the following command:
``` ```
aider <file1> <file2> ... aider <file1> <file2> ...
``` ```
Replace `<file1>`, `<file2>`, etc., with the paths to the source code files you want to work on. Replace `<file1>`, `<file2>`, etc., with the paths to the source code files you want to work on. These files will be added to the chat session.
You can also just launch `aider` anywhere in a git repo without naming files on the command line.
It will discover all the files in the repo.
You can then add and remove individual files in the chat session with the `/add` and `/drop` chat commands described below.
You can also use additional command-line options to customize the behavior of the tool. The following options are available, along with their corresponding environment variable overrides: You can also use additional command-line options to customize the behavior of the tool. The following options are available, along with their corresponding environment variable overrides:
@ -46,14 +51,14 @@ You can also use additional command-line options to customize the behavior of th
For more information, run `aider --help`. For more information, run `aider --help`.
## Commands ## Chat commands
Aider supports the following commands from within the chat: Aider supports the following commands from within the chat:
* `/add <file>`: Add matching files to the chat. * `/add <file>`: Add matching files to the chat session.
* `/drop <file>`: Remove matching files from the chat. * `/drop <file>`: Remove matching files from the chat session.
* `/ls`: List files and show their chat status. * `/ls`: List all known files and those included in the chat session.
* `/commit [message]`: Commit outstanding changes to the chat files. Aider will provide a commit message if you don't. * `/commit [message]`: Commit outstanding changes to the chat session files. Aider will provide a commit message if you don't.
* `/undo`: Undo the last git commit if it was done by aider. * `/undo`: Undo the last git commit if it was done by aider.
* `/diff`: Display the diff of the last aider commit. * `/diff`: Display the diff of the last aider commit.

View file

@ -66,7 +66,7 @@ class Commands:
self.console.print(f"[red]Error: {first_word} is not a valid command.") self.console.print(f"[red]Error: {first_word} is not a valid command.")
def cmd_commit(self, args): def cmd_commit(self, args):
"Commit edits to chat files made outside the chat (commit message optional)" "Commit edits to chat session files made outside the chat (commit message optional)"
if not self.coder.repo: if not self.coder.repo:
self.console.print("[red]No git repository found.") self.console.print("[red]No git repository found.")
@ -102,9 +102,7 @@ class Commands:
not last_commit.message.startswith("aider:") not last_commit.message.startswith("aider:")
or last_commit.hexsha[:7] != self.coder.last_aider_commit_hash or last_commit.hexsha[:7] != self.coder.last_aider_commit_hash
): ):
self.console.print( self.console.print("[red]The last commit was not made by aider in this chat session.")
"[red]The last commit was not made by aider in this chat session."
)
return return
self.coder.repo.git.reset("--hard", "HEAD~1") self.coder.repo.git.reset("--hard", "HEAD~1")
self.console.print( self.console.print(
@ -127,9 +125,7 @@ class Commands:
commits = f"{self.coder.last_aider_commit_hash}~1" commits = f"{self.coder.last_aider_commit_hash}~1"
if self.coder.pretty: if self.coder.pretty:
diff = self.coder.repo.git.diff( diff = self.coder.repo.git.diff(commits, "--color", self.coder.last_aider_commit_hash)
commits, "--color", self.coder.last_aider_commit_hash
)
else: else:
diff = self.coder.repo.git.diff(commits, self.coder.last_aider_commit_hash) diff = self.coder.repo.git.diff(commits, self.coder.last_aider_commit_hash)
@ -143,7 +139,7 @@ class Commands:
yield Completion(fname, start_position=-len(partial)) yield Completion(fname, start_position=-len(partial))
def cmd_add(self, args): def cmd_add(self, args):
"Add matching files to the chat" "Add matching files to the chat session"
added_fnames = [] added_fnames = []
files = self.coder.get_all_relative_files() files = self.coder.get_all_relative_files()
@ -199,7 +195,7 @@ class Commands:
yield Completion(fname, start_position=-len(partial)) yield Completion(fname, start_position=-len(partial))
def cmd_drop(self, args): def cmd_drop(self, args):
"Remove matching files from the chat" "Remove matching files from the chat session"
for word in args.split(): for word in args.split():
matched_files = [ matched_files = [
@ -213,12 +209,10 @@ class Commands:
for matched_file in matched_files: for matched_file in matched_files:
relative_fname = os.path.relpath(matched_file, self.coder.root) relative_fname = os.path.relpath(matched_file, self.coder.root)
self.coder.abs_fnames.remove(matched_file) self.coder.abs_fnames.remove(matched_file)
self.console.print( self.console.print(f"[bright_black]Removed {relative_fname} from the chat")
f"[bright_black]Removed {relative_fname} from the chat"
)
def cmd_ls(self, args): def cmd_ls(self, args):
"List files and show their chat status" "List all known files and those included in the chat session"
files = self.coder.get_all_relative_files() files = self.coder.get_all_relative_files()