Skip to content

Commit

Permalink
feat: Add --map-root argument to configure repository map root directory
Browse files Browse the repository at this point in the history
  • Loading branch information
coredevorg committed Jan 19, 2025
1 parent 6451d59 commit 11b682e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
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

0 comments on commit 11b682e

Please sign in to comment.