This commit is contained in:
coredevorg 2025-05-14 06:14:48 +02:00 committed by GitHub
commit 19002a4f5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 8 deletions

View file

@ -262,6 +262,16 @@ 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-cache-dir",
metavar="MAP_CACHE_DIR",
dest="map_cache_dir",
default=".",
help=(
"Directory for the repository map cache .aider.tags.cache.v3"
" (default: current directory)"
),
)
##########
group = parser.add_argument_group("History Files")
@ -553,7 +563,7 @@ def get_parser(default_config_files, git_root):
help="Run tests, fix problems found and then exit",
default=False,
)
##########
group = parser.add_argument_group("Analytics")
group.add_argument(

View file

@ -335,7 +335,11 @@ class Coder:
file_watcher=None,
auto_copy_context=False,
auto_accept_architect=True,
map_cache_dir='.',
):
# initialize from args.map_cache_dir
self.map_cache_dir = map_cache_dir
# Fill in a dummy Analytics if needed, but it is never .enable()'d
self.analytics = analytics if analytics is not None else Analytics()
@ -492,7 +496,7 @@ class Coder:
if use_repo_map and self.repo and has_map_prompt:
self.repo_map = RepoMap(
map_tokens,
self.root,
self.map_cache_dir,
self.main_model,
io,
self.gpt_prompts.repo_content_prefix,

View file

@ -996,6 +996,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
detect_urls=args.detect_urls,
auto_copy_context=args.copy_paste,
auto_accept_architect=args.auto_accept_architect,
map_cache_dir=args.map_cache_dir,
)
except UnknownEditFormat as err:
io.tool_error(str(err))

View file

@ -46,7 +46,7 @@ class RepoMap:
def __init__(
self,
map_tokens=1024,
root=None,
map_cache_dir='.',
main_model=None,
io=None,
repo_content_prefix=None,
@ -59,9 +59,8 @@ class RepoMap:
self.verbose = verbose
self.refresh = refresh
if not root:
root = os.getcwd()
self.root = root
self.map_cache_dir = map_cache_dir
self.root = os.getcwd()
self.load_tags_cache()
self.cache_threshold = 0.95
@ -84,6 +83,12 @@ class RepoMap:
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_cache_dir: {self.map_cache_dir}"
)
self.io.tool_output(
f"RepoMap assumes repo root is: {self.root}"
)
def token_count(self, text):
len_text = len(text)
@ -182,7 +187,7 @@ class RepoMap:
if isinstance(getattr(self, "TAGS_CACHE", None), dict):
return
path = Path(self.root) / self.TAGS_CACHE_DIR
path = Path(self.map_cache_dir) / self.TAGS_CACHE_DIR
# Try to recreate the cache
try:
@ -214,7 +219,7 @@ class RepoMap:
self.TAGS_CACHE = dict()
def load_tags_cache(self):
path = Path(self.root) / self.TAGS_CACHE_DIR
path = Path(self.map_cache_dir) / self.TAGS_CACHE_DIR
try:
self.TAGS_CACHE = Cache(path)
except SQLITE_ERRORS as e: