Skip to content

Commit

Permalink
Merge branch 'moa' of github.com:gembancud/aider into moa
Browse files Browse the repository at this point in the history
  • Loading branch information
gembancud committed Dec 19, 2024
2 parents 085a6d7 + c08ee12 commit b216a48
Show file tree
Hide file tree
Showing 61 changed files with 3,729 additions and 1,051 deletions.
8 changes: 7 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

### main branch

- Support for running without git installed.
- Improved help messages for AI! and AI? commands.
- Aider wrote 65% of the code in this release.

### Aider v0.69.0

- [Watch files](https://aider.chat/docs/usage/watch.html) improvements:
- Use `# ... AI?` comments to trigger aider and ask questions about your code.
- Now watches *all* files, not just certain source files.
Expand All @@ -14,7 +20,7 @@
- Ask 5% of users if they want to opt-in to analytics.
- `/voice` now lets you edit the transcribed text before sending.
- Disabled auto-complete in Y/N prompts.
- Aider wrote 60% of the code in this release.
- Aider wrote 68% of the code in this release.

### Aider v0.68.0

Expand Down
20 changes: 20 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This needs to sync with aider/help_pats.py

global-exclude .DS_Store

recursive-exclude aider/website/examples *
recursive-exclude aider/website/_posts *

exclude aider/website/HISTORY.md
exclude aider/website/docs/benchmarks*.md
exclude aider/website/docs/ctags.md
exclude aider/website/docs/unified-diffs.md

exclude aider/website/install.ps1
exclude aider/website/install.sh

recursive-exclude aider/website/docs/leaderboards *
recursive-exclude aider/website/assets *
recursive-exclude aider/website *.js
recursive-exclude aider/website *.html
recursive-exclude aider/website *.yml
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,27 @@ VIDEO END -->
cog.out(open("aider/website/_includes/get-started.md").read())
]]]-->

You can get started quickly like this:
If you already have python 3.8-3.13 installed, you can get started quickly like this:

```bash
python -m pip install -U aider-chat
python -m pip install aider-install
aider-install

# Change directory into a git repo
cd /to/your/git/repo
# Change directory into your code base
cd /to/your/project

# Work with Claude 3.5 Sonnet on your repo
export ANTHROPIC_API_KEY=your-key-goes-here
aider
# Work with Claude 3.5 Sonnet on your code
aider --model sonnet --anthropic-api-key your-key-goes-here

# Work with GPT-4o on your repo
export OPENAI_API_KEY=your-key-goes-here
aider
# Work with GPT-4o on your code
aider --model gpt-4o --openai-api-key your-key-goes-here
```
<!--[[[end]]]-->

See the
[installation instructions](https://aider.chat/docs/install.html)
and other
[documentation](https://aider.chat/docs/usage.html)
and
[usage documentation](https://aider.chat/docs/usage.html)
for more details.

## Features
Expand Down
2 changes: 1 addition & 1 deletion aider/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from packaging import version

__version__ = "0.68.1.dev"
__version__ = "0.69.2.dev"
safe_version = __version__

try:
Expand Down
70 changes: 45 additions & 25 deletions aider/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,46 @@
from aider.dump import dump # noqa: F401
from aider.models import model_info_manager

PERCENT = 5


def compute_hex_threshold(percent):
"""Convert percentage to 6-digit hex threshold.
Args:
percent: Percentage threshold (0-100)
Returns:
str: 6-digit hex threshold
"""
return format(int(0xFFFFFF * percent / 100), "06x")


def is_uuid_in_percentage(uuid_str, percent):
"""Check if a UUID string falls within the first X percent of the UUID space.
Args:
uuid_str: UUID string to test
percent: Percentage threshold (0-100)
Returns:
bool: True if UUID falls within the first X percent
"""
if not (0 <= percent <= 100):
raise ValueError("Percentage must be between 0 and 100")

if not uuid_str:
return False

# Convert percentage to hex threshold (1% = "04...", 10% = "1a...", etc)
# Using first 6 hex digits
if percent == 0:
return False

threshold = compute_hex_threshold(percent)
return uuid_str[:6] <= threshold


mixpanel_project_token = "6da9a43058a5d1b9f3353153921fb04d"
posthog_project_api_key = "phc_99T7muzafUMMZX15H8XePbMSreEUzahHbtWjy3l5Qbv"
posthog_host = "https://us.i.posthog.com"
Expand Down Expand Up @@ -84,31 +124,7 @@ def need_to_ask(self, args_analytics):
if not self.user_id:
return False

PERCENT = 5
return self.is_uuid_in_percentage(self.user_id, PERCENT)

def is_uuid_in_percentage(self, uuid_str, percent):
"""Check if a UUID string falls within the first X percent of the UUID space.
Args:
uuid_str: UUID string to test
percent: Percentage threshold (0-100)
Returns:
bool: True if UUID falls within the first X percent
"""
if not (0 <= percent <= 100):
raise ValueError("Percentage must be between 0 and 100")

if not uuid_str:
return False

# Convert percentage to hex threshold (1% = "04...", 10% = "1a...", etc)
# Using first 6 hex digits
if percent == 0:
return False
threshold = format(int(0xFFFFFF * percent / 100), "06x")
return uuid_str[:6] <= threshold
return is_uuid_in_percentage(self.user_id, PERCENT)

def get_data_file_path(self):
try:
Expand Down Expand Up @@ -228,3 +244,7 @@ def event(self, event_name, main_model=None, **kwargs):
f.write("\n")
except OSError:
pass # Ignore OS errors when writing to logfile


if __name__ == "__main__":
dump(compute_hex_threshold(PERCENT))
3 changes: 2 additions & 1 deletion aider/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ def get_parser(default_config_files, git_root):
default="default",
help=(
"Set the markdown code theme (default: default, other options include monokai,"
" solarized-dark, solarized-light)"
" solarized-dark, solarized-light, or a Pygments builtin style,"
" see https://pygments.org/styles for available themes)"
),
)
group.add_argument(
Expand Down
6 changes: 5 additions & 1 deletion aider/coders/search_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import sys
from pathlib import Path

import git
try:
import git
except ImportError:
git = None

from diff_match_patch import diff_match_patch
from tqdm import tqdm

Expand Down
4 changes: 3 additions & 1 deletion aider/help_pats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# This needs to sync with MANIFEST.in

exclude_website_pats = [
"**/.DS_Store",
"examples/**",
"_posts/**",
"HISTORY.md",
Expand All @@ -7,5 +10,4 @@
"docs/unified-diffs.md",
"docs/leaderboards/index.md",
"assets/**",
"**/.DS_Store",
]
8 changes: 7 additions & 1 deletion aider/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ def _(event):
complete_style=CompleteStyle.MULTI_COLUMN,
style=style,
key_bindings=kb,
complete_while_typing=True,
)
else:
line = input(show)
Expand Down Expand Up @@ -773,7 +774,12 @@ def prompt_ask(self, question, default="", subject=None):
res = "no"
else:
if self.prompt_session:
res = self.prompt_session.prompt(question + " ", default=default, style=style)
res = self.prompt_session.prompt(
question + " ",
default=default,
style=style,
complete_while_typing=True,
)
else:
res = input(question + " ")

Expand Down
24 changes: 20 additions & 4 deletions aider/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
from dataclasses import fields
from pathlib import Path

import git
try:
import git
except ImportError:
git = None

import importlib_resources
from dotenv import load_dotenv
from prompt_toolkit.enums import EditingMode
Expand Down Expand Up @@ -93,6 +97,9 @@ def make_new_repo(git_root, io):


def setup_git(git_root, io):
if git is None:
return

try:
cwd = Path.cwd()
except OSError:
Expand Down Expand Up @@ -410,7 +417,9 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
if argv is None:
argv = sys.argv[1:]

if force_git_root:
if git is None:
git_root = None
elif force_git_root:
git_root = force_git_root
else:
git_root = get_git_root()
Expand Down Expand Up @@ -457,6 +466,9 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
# Parse again to include any arguments that might have been defined in .env
args = parser.parse_args(argv)

if git is None:
args.git = False

if args.analytics_disable:
analytics = Analytics(permanently_disable=True)
print("Analytics have been permanently disabled.")
Expand Down Expand Up @@ -646,7 +658,7 @@ def get_io(pretty):
# We can't know the git repo for sure until after parsing the args.
# If we guessed wrong, reparse because that changes things like
# the location of the config.yml and history files.
if args.git and not force_git_root:
if args.git and not force_git_root and git is not None:
right_repo_root = guessed_wrong_repo(io, git_root, fnames, git_dname)
if right_repo_root:
analytics.event("exit", reason="Recursing with correct repo")
Expand Down Expand Up @@ -869,7 +881,11 @@ def get_io(pretty):

if args.watch_files:
file_watcher = FileWatcher(
coder, gitignores=ignores, verbose=args.verbose, analytics=analytics
coder,
gitignores=ignores,
verbose=args.verbose,
analytics=analytics,
root=str(Path.cwd()) if args.subtree_only else None,
)
coder.file_watcher = file_watcher

Expand Down
6 changes: 3 additions & 3 deletions aider/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1246,10 +1246,10 @@ def sanity_check_model(io, model):
status = "Set" if value else "Not set"
io.tool_output(f"- {key}: {status}")

if platform.system() == "Windows" or True:
if platform.system() == "Windows":
io.tool_output(
"If you just set these environment variables using `setx` you may need to restart"
" your terminal or command prompt for the changes to take effect."
"Note: You may need to restart your terminal or command prompt for `setx` to take"
" effect."
)

elif not model.keys_in_environment:
Expand Down
19 changes: 14 additions & 5 deletions aider/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,32 @@
import time
from pathlib import Path, PurePosixPath

import git
try:
import git

ANY_GIT_ERROR = [
git.exc.ODBError,
git.exc.GitError,
]
except ImportError:
git = None
ANY_GIT_ERROR = []

import pathspec

from aider import prompts, utils
from aider.sendchat import simple_send_with_retries

from .dump import dump # noqa: F401

ANY_GIT_ERROR = (
git.exc.ODBError,
git.exc.GitError,
ANY_GIT_ERROR += [
OSError,
IndexError,
BufferError,
TypeError,
ValueError,
)
]
ANY_GIT_ERROR = tuple(ANY_GIT_ERROR)


class GitRepo:
Expand Down
4 changes: 2 additions & 2 deletions aider/resources/model-metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gemini-2.0-flash-exp": {
"vertex_ai-language-models/gemini-2.0-flash-exp": {
"max_tokens": 8192,
"max_input_tokens": 1048576,
"max_output_tokens": 8192,
Expand All @@ -17,7 +17,7 @@
"supports_response_schema": true,
"source": "https://cloud.google.com/vertex-ai/generative-ai/docs/gemini-v2"
},
"gemini-2.0-flash-exp": {
"gemini/gemini-2.0-flash-exp": {
"max_tokens": 8192,
"max_input_tokens": 1048576,
"max_output_tokens": 8192,
Expand Down
4 changes: 2 additions & 2 deletions aider/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import time
from pathlib import Path

import git

from aider.dump import dump # noqa: F401

IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".webp", ".pdf"}
Expand Down Expand Up @@ -73,6 +71,8 @@ def __exit__(self, exc_type, exc_val, exc_tb):


def make_repo(path=None):
import git

if not path:
path = "."
repo = git.Repo.init(path)
Expand Down
Loading

0 comments on commit b216a48

Please sign in to comment.