This commit is contained in:
Paul Gauthier 2024-05-08 13:35:34 -07:00
parent fb8ed21b13
commit f256b43043
8 changed files with 34 additions and 33 deletions

View file

@ -338,6 +338,12 @@ def get_parser(default_config_files, git_root):
help="Print the repo map and exit (debug)", help="Print the repo map and exit (debug)",
default=False, default=False,
) )
group.add_argument(
"--show-prompts",
action="store_true",
help="Print the system prompts and exit (debug)",
default=False,
)
group.add_argument( group.add_argument(
"--message", "--message",
"--msg", "--msg",

View file

@ -415,6 +415,7 @@ class Coder:
all_content = "" all_content = ""
repo_content = self.get_repo_map() repo_content = self.get_repo_map()
if repo_content: if repo_content:
if all_content: if all_content:
all_content += "\n" all_content += "\n"

View file

@ -13,3 +13,13 @@ You always COMPLETELY IMPLEMENT the needed code!
""" """
example_messages = [] example_messages = []
files_content_prefix = "These are files that you can edit:\n"
files_no_full_files = "I am not sharing any files that you can edit yet."
repo_content_prefix = """I'm discussing files that are part of a git repository.
Here are summaries of some files present in my git repo.
Do not propose changes to these files, treat them as *read-only*.
If you need to edit one of them, ask me to *add it to the chat* first.
"""

View file

@ -12,7 +12,7 @@ Take requests for changes to the supplied code.
If the request is ambiguous, ask questions. If the request is ambiguous, ask questions.
Once you understand the request you MUST: Once you understand the request you MUST:
1. List the files you need to modify. Only suggest changes to a *read-write* files. Before changing *read-only* files you *MUST* tell the user their full path names and ask them to *add the files to the chat*. End your reply and wait for their approval. 1. List the files you need to modify. Only suggest changes to files that the user has given you permission to edit.
2. Think step-by-step and explain the needed changes with a numbered list of short sentences. 2. Think step-by-step and explain the needed changes with a numbered list of short sentences.
3. Describe each change with a *SEARCH/REPLACE block* per the examples below. All changes to files must use this *SEARCH/REPLACE block* format. ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*! 3. Describe each change with a *SEARCH/REPLACE block* per the examples below. All changes to files must use this *SEARCH/REPLACE block* format. ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
@ -125,7 +125,7 @@ Every *SEARCH* section must *EXACTLY MATCH* the existing source code, character
Include *ALL* the code being searched and replaced! Include *ALL* the code being searched and replaced!
Only *SEARCH/REPLACE* files that are *read-write*. Only *SEARCH/REPLACE* files that the user has given you permission to edit.
To move code within a file, use 2 *SEARCH/REPLACE* blocks: 1 to delete it from its current location, 1 to insert it in the new location. To move code within a file, use 2 *SEARCH/REPLACE* blocks: 1 to delete it from its current location, 1 to insert it in the new location.
@ -136,13 +136,4 @@ If you want to put code in a new file, use a *SEARCH/REPLACE block* with:
{lazy_prompt} {lazy_prompt}
ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*! ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
"""
files_content_prefix = "These are the *read-write* files:\n"
files_no_full_files = "I am not sharing any *read-write* files yet."
repo_content_prefix = """Below here are summaries of files present in the user's git repository.
Do not propose changes to these files, they are *read-only*.
To make a file *read-write*, ask the user to *add it to the chat*.
""" """

View file

@ -105,13 +105,4 @@ To move code within a file, use 2 hunks: 1 to delete it from its current locatio
To make a new file, show a diff from `--- /dev/null` to `+++ path/to/new/file.ext`. To make a new file, show a diff from `--- /dev/null` to `+++ path/to/new/file.ext`.
{lazy_prompt} {lazy_prompt}
"""
files_content_prefix = "These are the *read-write* files:\n"
files_no_full_files = "I am not sharing any *read-write* files yet."
repo_content_prefix = """Below here are summaries of some files present in this git repository.
Do not propose changes to these files, they are *read-only*.
To make a file *read-write*, ask the user to *add it to the chat*.
""" """

View file

@ -61,14 +61,4 @@ Create a new file you MUST return a *file listing* which includes an appropriate
{lazy_prompt} {lazy_prompt}
""" """
files_content_prefix = "Here is the current content of the files:\n"
files_no_full_files = "I am not sharing any files yet."
redacted_edit_message = "No changes are needed." redacted_edit_message = "No changes are needed."
# this coder is not able to handle repo content
repo_content_prefix = None
repo_content_prefix = """Below here are summaries of files present in the user's git repository.
Do not propose changes to these files, they are *read-only*.
"""

View file

@ -7,7 +7,7 @@ import git
from dotenv import load_dotenv from dotenv import load_dotenv
from streamlit.web import cli from streamlit.web import cli
from aider import __version__, models from aider import __version__, models, utils
from aider.args import get_parser from aider.args import get_parser
from aider.coders import Coder from aider.coders import Coder
from aider.commands import SwitchModel from aider.commands import SwitchModel
@ -341,6 +341,11 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
coder.show_announcements() coder.show_announcements()
if args.show_prompts:
messages = coder.format_messages()
utils.show_messages(messages)
return
if args.commit: if args.commit:
coder.commands.cmd_commit("") coder.commands.cmd_commit("")
return return

View file

@ -68,6 +68,9 @@ class RepoMap:
self.io.tool_error("Disabling repo map, git repo too large?") self.io.tool_error("Disabling repo map, git repo too large?")
self.max_map_tokens = 0 self.max_map_tokens = 0
return return
dump(chat_files, other_files)
dump(files_listing)
if not files_listing: if not files_listing:
return return
@ -87,6 +90,7 @@ class RepoMap:
repo_content += files_listing repo_content += files_listing
dump(repo_content)
return repo_content return repo_content
def get_rel_fname(self, fname): def get_rel_fname(self, fname):
@ -258,8 +262,8 @@ class RepoMap:
references[tag.name].append(rel_fname) references[tag.name].append(rel_fname)
## ##
# dump(defines) dump(defines)
# dump(references) dump(references)
if not references: if not references:
references = dict((k, list(v)) for k, v in defines.items()) references = dict((k, list(v)) for k, v in defines.items())
@ -287,6 +291,7 @@ class RepoMap:
try: try:
ranked = nx.pagerank(G, weight="weight", **pers_args) ranked = nx.pagerank(G, weight="weight", **pers_args)
except ZeroDivisionError: except ZeroDivisionError:
dump(ZeroDivisionError)
return [] return []
# distribute the rank from each source node, across all of its out edges # distribute the rank from each source node, across all of its out edges
@ -334,6 +339,8 @@ class RepoMap:
ranked_tags = self.get_ranked_tags(chat_fnames, other_fnames) ranked_tags = self.get_ranked_tags(chat_fnames, other_fnames)
num_tags = len(ranked_tags) num_tags = len(ranked_tags)
dump(num_tags)
lower_bound = 0 lower_bound = 0
upper_bound = num_tags upper_bound = num_tags
best_tree = None best_tree = None