Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add --map-root argument to configure repository map root directory #2911

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions aider/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ def get_parser(default_config_files, git_root):
default=2,
help="Multiplier for map tokens when no files are specified (default: 2)",
)
group.add_argument(
"--map-root",
metavar="MAP_ROOT",
default=".",
help="Root directory for the repository map (default: current directory)",
)

##########
group = parser.add_argument_group("History Files")
Expand Down
6 changes: 5 additions & 1 deletion aider/coders/base_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,11 @@ def __init__(
ignore_mentions=None,
file_watcher=None,
auto_copy_context=False,
map_root='.',
):
# initialize from args.map_root
self.map_root = map_root

# Fill in a dummy Analytics if needed, but it is never .enable()'d
self.analytics = analytics if analytics is not None else Analytics()

Expand Down Expand Up @@ -442,7 +446,7 @@ def __init__(
if use_repo_map and self.repo and has_map_prompt:
self.repo_map = RepoMap(
map_tokens,
self.root,
self.map_root,
self.main_model,
io,
self.gpt_prompts.repo_content_prefix,
Expand Down
1 change: 1 addition & 0 deletions aider/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ def get_io(pretty):
chat_language=args.chat_language,
detect_urls=args.detect_urls,
auto_copy_context=args.copy_paste,
map_root=args.map_root, # initialize from args.map_root
)
except UnknownEditFormat as err:
io.tool_error(str(err))
Expand Down
3 changes: 3 additions & 0 deletions aider/repomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def __init__(
self.io.tool_output(
f"RepoMap initialized with map_mul_no_files: {self.map_mul_no_files}"
)
self.io.tool_output(
f"RepoMap initialized with map_root: {self.root}"
)

def token_count(self, text):
len_text = len(text)
Expand Down