chatmcp-cli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aider/__init__.py +20 -0
- aider/__main__.py +4 -0
- aider/_version.py +21 -0
- aider/analytics.py +250 -0
- aider/args.py +926 -0
- aider/args_formatter.py +228 -0
- aider/coders/__init__.py +34 -0
- aider/coders/architect_coder.py +48 -0
- aider/coders/architect_prompts.py +40 -0
- aider/coders/ask_coder.py +9 -0
- aider/coders/ask_prompts.py +35 -0
- aider/coders/base_coder.py +2483 -0
- aider/coders/base_prompts.py +60 -0
- aider/coders/chat_chunks.py +64 -0
- aider/coders/context_coder.py +53 -0
- aider/coders/context_prompts.py +75 -0
- aider/coders/editblock_coder.py +657 -0
- aider/coders/editblock_fenced_coder.py +10 -0
- aider/coders/editblock_fenced_prompts.py +143 -0
- aider/coders/editblock_func_coder.py +141 -0
- aider/coders/editblock_func_prompts.py +27 -0
- aider/coders/editblock_prompts.py +174 -0
- aider/coders/editor_diff_fenced_coder.py +9 -0
- aider/coders/editor_diff_fenced_prompts.py +11 -0
- aider/coders/editor_editblock_coder.py +8 -0
- aider/coders/editor_editblock_prompts.py +18 -0
- aider/coders/editor_whole_coder.py +8 -0
- aider/coders/editor_whole_prompts.py +10 -0
- aider/coders/help_coder.py +16 -0
- aider/coders/help_prompts.py +46 -0
- aider/coders/patch_coder.py +706 -0
- aider/coders/patch_prompts.py +161 -0
- aider/coders/search_replace.py +757 -0
- aider/coders/shell.py +37 -0
- aider/coders/single_wholefile_func_coder.py +102 -0
- aider/coders/single_wholefile_func_prompts.py +27 -0
- aider/coders/udiff_coder.py +429 -0
- aider/coders/udiff_prompts.py +115 -0
- aider/coders/udiff_simple.py +14 -0
- aider/coders/udiff_simple_prompts.py +25 -0
- aider/coders/wholefile_coder.py +144 -0
- aider/coders/wholefile_func_coder.py +134 -0
- aider/coders/wholefile_func_prompts.py +27 -0
- aider/coders/wholefile_prompts.py +67 -0
- aider/commands.py +1665 -0
- aider/copypaste.py +72 -0
- aider/deprecated.py +126 -0
- aider/diffs.py +128 -0
- aider/dump.py +29 -0
- aider/editor.py +147 -0
- aider/exceptions.py +107 -0
- aider/format_settings.py +26 -0
- aider/gui.py +545 -0
- aider/help.py +163 -0
- aider/help_pats.py +19 -0
- aider/history.py +143 -0
- aider/io.py +1175 -0
- aider/linter.py +304 -0
- aider/llm.py +47 -0
- aider/main.py +1267 -0
- aider/mdstream.py +243 -0
- aider/models.py +1286 -0
- aider/onboarding.py +428 -0
- aider/openrouter.py +128 -0
- aider/prompts.py +64 -0
- aider/queries/tree-sitter-language-pack/README.md +7 -0
- aider/queries/tree-sitter-language-pack/arduino-tags.scm +5 -0
- aider/queries/tree-sitter-language-pack/c-tags.scm +9 -0
- aider/queries/tree-sitter-language-pack/chatito-tags.scm +16 -0
- aider/queries/tree-sitter-language-pack/commonlisp-tags.scm +122 -0
- aider/queries/tree-sitter-language-pack/cpp-tags.scm +15 -0
- aider/queries/tree-sitter-language-pack/csharp-tags.scm +26 -0
- aider/queries/tree-sitter-language-pack/d-tags.scm +26 -0
- aider/queries/tree-sitter-language-pack/dart-tags.scm +92 -0
- aider/queries/tree-sitter-language-pack/elisp-tags.scm +5 -0
- aider/queries/tree-sitter-language-pack/elixir-tags.scm +54 -0
- aider/queries/tree-sitter-language-pack/elm-tags.scm +19 -0
- aider/queries/tree-sitter-language-pack/gleam-tags.scm +41 -0
- aider/queries/tree-sitter-language-pack/go-tags.scm +42 -0
- aider/queries/tree-sitter-language-pack/java-tags.scm +20 -0
- aider/queries/tree-sitter-language-pack/javascript-tags.scm +88 -0
- aider/queries/tree-sitter-language-pack/lua-tags.scm +34 -0
- aider/queries/tree-sitter-language-pack/ocaml-tags.scm +115 -0
- aider/queries/tree-sitter-language-pack/ocaml_interface-tags.scm +98 -0
- aider/queries/tree-sitter-language-pack/pony-tags.scm +39 -0
- aider/queries/tree-sitter-language-pack/properties-tags.scm +5 -0
- aider/queries/tree-sitter-language-pack/python-tags.scm +14 -0
- aider/queries/tree-sitter-language-pack/r-tags.scm +21 -0
- aider/queries/tree-sitter-language-pack/racket-tags.scm +12 -0
- aider/queries/tree-sitter-language-pack/ruby-tags.scm +64 -0
- aider/queries/tree-sitter-language-pack/rust-tags.scm +60 -0
- aider/queries/tree-sitter-language-pack/solidity-tags.scm +43 -0
- aider/queries/tree-sitter-language-pack/swift-tags.scm +51 -0
- aider/queries/tree-sitter-language-pack/udev-tags.scm +20 -0
- aider/queries/tree-sitter-languages/README.md +23 -0
- aider/queries/tree-sitter-languages/c-tags.scm +9 -0
- aider/queries/tree-sitter-languages/c_sharp-tags.scm +46 -0
- aider/queries/tree-sitter-languages/cpp-tags.scm +15 -0
- aider/queries/tree-sitter-languages/dart-tags.scm +91 -0
- aider/queries/tree-sitter-languages/elisp-tags.scm +8 -0
- aider/queries/tree-sitter-languages/elixir-tags.scm +54 -0
- aider/queries/tree-sitter-languages/elm-tags.scm +19 -0
- aider/queries/tree-sitter-languages/go-tags.scm +30 -0
- aider/queries/tree-sitter-languages/hcl-tags.scm +77 -0
- aider/queries/tree-sitter-languages/java-tags.scm +20 -0
- aider/queries/tree-sitter-languages/javascript-tags.scm +88 -0
- aider/queries/tree-sitter-languages/kotlin-tags.scm +27 -0
- aider/queries/tree-sitter-languages/ocaml-tags.scm +115 -0
- aider/queries/tree-sitter-languages/ocaml_interface-tags.scm +98 -0
- aider/queries/tree-sitter-languages/php-tags.scm +26 -0
- aider/queries/tree-sitter-languages/python-tags.scm +12 -0
- aider/queries/tree-sitter-languages/ql-tags.scm +26 -0
- aider/queries/tree-sitter-languages/ruby-tags.scm +64 -0
- aider/queries/tree-sitter-languages/rust-tags.scm +60 -0
- aider/queries/tree-sitter-languages/scala-tags.scm +65 -0
- aider/queries/tree-sitter-languages/typescript-tags.scm +41 -0
- aider/reasoning_tags.py +82 -0
- aider/repo.py +623 -0
- aider/repomap.py +847 -0
- aider/report.py +200 -0
- aider/resources/__init__.py +3 -0
- aider/resources/model-metadata.json +468 -0
- aider/resources/model-settings.yml +1767 -0
- aider/run_cmd.py +132 -0
- aider/scrape.py +284 -0
- aider/sendchat.py +61 -0
- aider/special.py +203 -0
- aider/urls.py +17 -0
- aider/utils.py +338 -0
- aider/versioncheck.py +113 -0
- aider/voice.py +187 -0
- aider/waiting.py +221 -0
- aider/watch.py +318 -0
- aider/watch_prompts.py +12 -0
- aider/website/Gemfile +8 -0
- aider/website/_includes/blame.md +162 -0
- aider/website/_includes/get-started.md +22 -0
- aider/website/_includes/help-tip.md +5 -0
- aider/website/_includes/help.md +24 -0
- aider/website/_includes/install.md +5 -0
- aider/website/_includes/keys.md +4 -0
- aider/website/_includes/model-warnings.md +67 -0
- aider/website/_includes/multi-line.md +22 -0
- aider/website/_includes/python-m-aider.md +5 -0
- aider/website/_includes/recording.css +228 -0
- aider/website/_includes/recording.md +34 -0
- aider/website/_includes/replit-pipx.md +9 -0
- aider/website/_includes/works-best.md +1 -0
- aider/website/_sass/custom/custom.scss +103 -0
- aider/website/docs/config/adv-model-settings.md +1881 -0
- aider/website/docs/config/aider_conf.md +527 -0
- aider/website/docs/config/api-keys.md +90 -0
- aider/website/docs/config/dotenv.md +478 -0
- aider/website/docs/config/editor.md +127 -0
- aider/website/docs/config/model-aliases.md +103 -0
- aider/website/docs/config/options.md +843 -0
- aider/website/docs/config/reasoning.md +209 -0
- aider/website/docs/config.md +44 -0
- aider/website/docs/faq.md +378 -0
- aider/website/docs/git.md +76 -0
- aider/website/docs/index.md +47 -0
- aider/website/docs/install/codespaces.md +39 -0
- aider/website/docs/install/docker.md +57 -0
- aider/website/docs/install/optional.md +100 -0
- aider/website/docs/install/replit.md +8 -0
- aider/website/docs/install.md +115 -0
- aider/website/docs/languages.md +264 -0
- aider/website/docs/legal/contributor-agreement.md +111 -0
- aider/website/docs/legal/privacy.md +104 -0
- aider/website/docs/llms/anthropic.md +77 -0
- aider/website/docs/llms/azure.md +48 -0
- aider/website/docs/llms/bedrock.md +132 -0
- aider/website/docs/llms/cohere.md +34 -0
- aider/website/docs/llms/deepseek.md +32 -0
- aider/website/docs/llms/gemini.md +49 -0
- aider/website/docs/llms/github.md +105 -0
- aider/website/docs/llms/groq.md +36 -0
- aider/website/docs/llms/lm-studio.md +39 -0
- aider/website/docs/llms/ollama.md +75 -0
- aider/website/docs/llms/openai-compat.md +39 -0
- aider/website/docs/llms/openai.md +58 -0
- aider/website/docs/llms/openrouter.md +78 -0
- aider/website/docs/llms/other.md +103 -0
- aider/website/docs/llms/vertex.md +50 -0
- aider/website/docs/llms/warnings.md +10 -0
- aider/website/docs/llms/xai.md +53 -0
- aider/website/docs/llms.md +54 -0
- aider/website/docs/more/analytics.md +122 -0
- aider/website/docs/more/edit-formats.md +116 -0
- aider/website/docs/more/infinite-output.md +137 -0
- aider/website/docs/more-info.md +8 -0
- aider/website/docs/recordings/auto-accept-architect.md +31 -0
- aider/website/docs/recordings/dont-drop-original-read-files.md +35 -0
- aider/website/docs/recordings/index.md +21 -0
- aider/website/docs/recordings/model-accepts-settings.md +69 -0
- aider/website/docs/recordings/tree-sitter-language-pack.md +80 -0
- aider/website/docs/repomap.md +112 -0
- aider/website/docs/scripting.md +100 -0
- aider/website/docs/troubleshooting/aider-not-found.md +24 -0
- aider/website/docs/troubleshooting/edit-errors.md +76 -0
- aider/website/docs/troubleshooting/imports.md +62 -0
- aider/website/docs/troubleshooting/models-and-keys.md +54 -0
- aider/website/docs/troubleshooting/support.md +79 -0
- aider/website/docs/troubleshooting/token-limits.md +96 -0
- aider/website/docs/troubleshooting/warnings.md +12 -0
- aider/website/docs/troubleshooting.md +11 -0
- aider/website/docs/usage/browser.md +57 -0
- aider/website/docs/usage/caching.md +49 -0
- aider/website/docs/usage/commands.md +132 -0
- aider/website/docs/usage/conventions.md +119 -0
- aider/website/docs/usage/copypaste.md +121 -0
- aider/website/docs/usage/images-urls.md +48 -0
- aider/website/docs/usage/lint-test.md +118 -0
- aider/website/docs/usage/modes.md +211 -0
- aider/website/docs/usage/not-code.md +179 -0
- aider/website/docs/usage/notifications.md +87 -0
- aider/website/docs/usage/tips.md +79 -0
- aider/website/docs/usage/tutorials.md +30 -0
- aider/website/docs/usage/voice.md +121 -0
- aider/website/docs/usage/watch.md +294 -0
- aider/website/docs/usage.md +92 -0
- aider/website/share/index.md +101 -0
- chatmcp_cli-0.1.0.dist-info/METADATA +502 -0
- chatmcp_cli-0.1.0.dist-info/RECORD +228 -0
- chatmcp_cli-0.1.0.dist-info/WHEEL +5 -0
- chatmcp_cli-0.1.0.dist-info/entry_points.txt +3 -0
- chatmcp_cli-0.1.0.dist-info/licenses/LICENSE.txt +202 -0
- chatmcp_cli-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
from .udiff_coder import UnifiedDiffCoder
|
2
|
+
from .udiff_simple_prompts import UnifiedDiffSimplePrompts
|
3
|
+
|
4
|
+
|
5
|
+
class UnifiedDiffSimpleCoder(UnifiedDiffCoder):
|
6
|
+
"""
|
7
|
+
A coder that uses unified diff format for code modifications.
|
8
|
+
This variant uses a simpler prompt that doesn't mention specific
|
9
|
+
diff rules like using `@@ ... @@` lines or avoiding line numbers.
|
10
|
+
"""
|
11
|
+
|
12
|
+
edit_format = "udiff-simple"
|
13
|
+
|
14
|
+
gpt_prompts = UnifiedDiffSimplePrompts()
|
@@ -0,0 +1,25 @@
|
|
1
|
+
from .udiff_prompts import UnifiedDiffPrompts
|
2
|
+
|
3
|
+
|
4
|
+
class UnifiedDiffSimplePrompts(UnifiedDiffPrompts):
|
5
|
+
"""
|
6
|
+
Prompts for the UnifiedDiffSimpleCoder.
|
7
|
+
Inherits from UnifiedDiffPrompts and can override specific prompts
|
8
|
+
if a simpler wording is desired for this edit format.
|
9
|
+
"""
|
10
|
+
|
11
|
+
example_messages = []
|
12
|
+
|
13
|
+
system_reminder = """# File editing rules:
|
14
|
+
|
15
|
+
Return edits similar to unified diffs that `diff -U0` would produce.
|
16
|
+
|
17
|
+
The user's patch tool needs CORRECT patches that apply cleanly against the current contents of the file!
|
18
|
+
Think carefully and make sure you include and mark all lines that need to be removed or changed as `-` lines.
|
19
|
+
Make sure you mark all new or modified lines with `+`.
|
20
|
+
Don't leave out any lines or the diff patch won't apply correctly.
|
21
|
+
|
22
|
+
To make a new file, show a diff from `--- /dev/null` to `+++ path/to/new/file.ext`.
|
23
|
+
|
24
|
+
{final_reminders}
|
25
|
+
""" # noqa
|
@@ -0,0 +1,144 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
|
3
|
+
from aider import diffs
|
4
|
+
|
5
|
+
from ..dump import dump # noqa: F401
|
6
|
+
from .base_coder import Coder
|
7
|
+
from .wholefile_prompts import WholeFilePrompts
|
8
|
+
|
9
|
+
|
10
|
+
class WholeFileCoder(Coder):
|
11
|
+
"""A coder that operates on entire files for code modifications."""
|
12
|
+
|
13
|
+
edit_format = "whole"
|
14
|
+
gpt_prompts = WholeFilePrompts()
|
15
|
+
|
16
|
+
def render_incremental_response(self, final):
|
17
|
+
try:
|
18
|
+
return self.get_edits(mode="diff")
|
19
|
+
except ValueError:
|
20
|
+
return self.get_multi_response_content_in_progress()
|
21
|
+
|
22
|
+
def get_edits(self, mode="update"):
|
23
|
+
content = self.get_multi_response_content_in_progress()
|
24
|
+
|
25
|
+
chat_files = self.get_inchat_relative_files()
|
26
|
+
|
27
|
+
output = []
|
28
|
+
lines = content.splitlines(keepends=True)
|
29
|
+
|
30
|
+
edits = []
|
31
|
+
|
32
|
+
saw_fname = None
|
33
|
+
fname = None
|
34
|
+
fname_source = None
|
35
|
+
new_lines = []
|
36
|
+
for i, line in enumerate(lines):
|
37
|
+
if line.startswith(self.fence[0]) or line.startswith(self.fence[1]):
|
38
|
+
if fname is not None:
|
39
|
+
# ending an existing block
|
40
|
+
saw_fname = None
|
41
|
+
|
42
|
+
full_path = self.abs_root_path(fname)
|
43
|
+
|
44
|
+
if mode == "diff":
|
45
|
+
output += self.do_live_diff(full_path, new_lines, True)
|
46
|
+
else:
|
47
|
+
edits.append((fname, fname_source, new_lines))
|
48
|
+
|
49
|
+
fname = None
|
50
|
+
fname_source = None
|
51
|
+
new_lines = []
|
52
|
+
continue
|
53
|
+
|
54
|
+
# fname==None ... starting a new block
|
55
|
+
if i > 0:
|
56
|
+
fname_source = "block"
|
57
|
+
fname = lines[i - 1].strip()
|
58
|
+
fname = fname.strip("*") # handle **filename.py**
|
59
|
+
fname = fname.rstrip(":")
|
60
|
+
fname = fname.strip("`")
|
61
|
+
fname = fname.lstrip("#")
|
62
|
+
fname = fname.strip()
|
63
|
+
|
64
|
+
# Issue #1232
|
65
|
+
if len(fname) > 250:
|
66
|
+
fname = ""
|
67
|
+
|
68
|
+
# Did gpt prepend a bogus dir? It especially likes to
|
69
|
+
# include the path/to prefix from the one-shot example in
|
70
|
+
# the prompt.
|
71
|
+
if fname and fname not in chat_files and Path(fname).name in chat_files:
|
72
|
+
fname = Path(fname).name
|
73
|
+
if not fname: # blank line? or ``` was on first line i==0
|
74
|
+
if saw_fname:
|
75
|
+
fname = saw_fname
|
76
|
+
fname_source = "saw"
|
77
|
+
elif len(chat_files) == 1:
|
78
|
+
fname = chat_files[0]
|
79
|
+
fname_source = "chat"
|
80
|
+
else:
|
81
|
+
# TODO: sense which file it is by diff size
|
82
|
+
raise ValueError(
|
83
|
+
f"No filename provided before {self.fence[0]} in file listing"
|
84
|
+
)
|
85
|
+
|
86
|
+
elif fname is not None:
|
87
|
+
new_lines.append(line)
|
88
|
+
else:
|
89
|
+
for word in line.strip().split():
|
90
|
+
word = word.rstrip(".:,;!")
|
91
|
+
for chat_file in chat_files:
|
92
|
+
quoted_chat_file = f"`{chat_file}`"
|
93
|
+
if word == quoted_chat_file:
|
94
|
+
saw_fname = chat_file
|
95
|
+
|
96
|
+
output.append(line)
|
97
|
+
|
98
|
+
if mode == "diff":
|
99
|
+
if fname is not None:
|
100
|
+
# ending an existing block
|
101
|
+
full_path = (Path(self.root) / fname).absolute()
|
102
|
+
output += self.do_live_diff(full_path, new_lines, False)
|
103
|
+
return "\n".join(output)
|
104
|
+
|
105
|
+
if fname:
|
106
|
+
edits.append((fname, fname_source, new_lines))
|
107
|
+
|
108
|
+
seen = set()
|
109
|
+
refined_edits = []
|
110
|
+
# process from most reliable filename, to least reliable
|
111
|
+
for source in ("block", "saw", "chat"):
|
112
|
+
for fname, fname_source, new_lines in edits:
|
113
|
+
if fname_source != source:
|
114
|
+
continue
|
115
|
+
# if a higher priority source already edited the file, skip
|
116
|
+
if fname in seen:
|
117
|
+
continue
|
118
|
+
|
119
|
+
seen.add(fname)
|
120
|
+
refined_edits.append((fname, fname_source, new_lines))
|
121
|
+
|
122
|
+
return refined_edits
|
123
|
+
|
124
|
+
def apply_edits(self, edits):
|
125
|
+
for path, fname_source, new_lines in edits:
|
126
|
+
full_path = self.abs_root_path(path)
|
127
|
+
new_lines = "".join(new_lines)
|
128
|
+
self.io.write_text(full_path, new_lines)
|
129
|
+
|
130
|
+
def do_live_diff(self, full_path, new_lines, final):
|
131
|
+
if Path(full_path).exists():
|
132
|
+
orig_lines = self.io.read_text(full_path)
|
133
|
+
if orig_lines is not None:
|
134
|
+
orig_lines = orig_lines.splitlines(keepends=True)
|
135
|
+
|
136
|
+
show_diff = diffs.diff_partial_update(
|
137
|
+
orig_lines,
|
138
|
+
new_lines,
|
139
|
+
final=final,
|
140
|
+
).splitlines()
|
141
|
+
return show_diff
|
142
|
+
|
143
|
+
output = ["```"] + new_lines + ["```"]
|
144
|
+
return output
|
@@ -0,0 +1,134 @@
|
|
1
|
+
from aider import diffs
|
2
|
+
|
3
|
+
from ..dump import dump # noqa: F401
|
4
|
+
from .base_coder import Coder
|
5
|
+
from .wholefile_func_prompts import WholeFileFunctionPrompts
|
6
|
+
|
7
|
+
|
8
|
+
class WholeFileFunctionCoder(Coder):
|
9
|
+
functions = [
|
10
|
+
dict(
|
11
|
+
name="write_file",
|
12
|
+
description="create or update one or more files",
|
13
|
+
parameters=dict(
|
14
|
+
type="object",
|
15
|
+
required=["explanation", "files"],
|
16
|
+
properties=dict(
|
17
|
+
explanation=dict(
|
18
|
+
type="string",
|
19
|
+
description=(
|
20
|
+
"Step by step plan for the changes to be made to the code (future"
|
21
|
+
" tense, markdown format)"
|
22
|
+
),
|
23
|
+
),
|
24
|
+
files=dict(
|
25
|
+
type="array",
|
26
|
+
items=dict(
|
27
|
+
type="object",
|
28
|
+
required=["path", "content"],
|
29
|
+
properties=dict(
|
30
|
+
path=dict(
|
31
|
+
type="string",
|
32
|
+
description="Path of file to write",
|
33
|
+
),
|
34
|
+
content=dict(
|
35
|
+
type="string",
|
36
|
+
description="Content to write to the file",
|
37
|
+
),
|
38
|
+
),
|
39
|
+
),
|
40
|
+
),
|
41
|
+
),
|
42
|
+
),
|
43
|
+
),
|
44
|
+
]
|
45
|
+
|
46
|
+
def __init__(self, *args, **kwargs):
|
47
|
+
raise RuntimeError("Deprecated, needs to be refactored to support get_edits/apply_edits")
|
48
|
+
|
49
|
+
self.gpt_prompts = WholeFileFunctionPrompts()
|
50
|
+
super().__init__(*args, **kwargs)
|
51
|
+
|
52
|
+
def add_assistant_reply_to_cur_messages(self, edited):
|
53
|
+
if edited:
|
54
|
+
self.cur_messages += [
|
55
|
+
dict(role="assistant", content=self.gpt_prompts.redacted_edit_message)
|
56
|
+
]
|
57
|
+
else:
|
58
|
+
self.cur_messages += [dict(role="assistant", content=self.partial_response_content)]
|
59
|
+
|
60
|
+
def render_incremental_response(self, final=False):
|
61
|
+
if self.partial_response_content:
|
62
|
+
return self.partial_response_content
|
63
|
+
|
64
|
+
args = self.parse_partial_args()
|
65
|
+
|
66
|
+
if not args:
|
67
|
+
return
|
68
|
+
|
69
|
+
explanation = args.get("explanation")
|
70
|
+
files = args.get("files", [])
|
71
|
+
|
72
|
+
res = ""
|
73
|
+
if explanation:
|
74
|
+
res += f"{explanation}\n\n"
|
75
|
+
|
76
|
+
for i, file_upd in enumerate(files):
|
77
|
+
path = file_upd.get("path")
|
78
|
+
if not path:
|
79
|
+
continue
|
80
|
+
content = file_upd.get("content")
|
81
|
+
if not content:
|
82
|
+
continue
|
83
|
+
|
84
|
+
this_final = (i < len(files) - 1) or final
|
85
|
+
res += self.live_diffs(path, content, this_final)
|
86
|
+
|
87
|
+
return res
|
88
|
+
|
89
|
+
def live_diffs(self, fname, content, final):
|
90
|
+
lines = content.splitlines(keepends=True)
|
91
|
+
|
92
|
+
# ending an existing block
|
93
|
+
full_path = self.abs_root_path(fname)
|
94
|
+
|
95
|
+
content = self.io.read_text(full_path)
|
96
|
+
if content is None:
|
97
|
+
orig_lines = []
|
98
|
+
else:
|
99
|
+
orig_lines = content.splitlines()
|
100
|
+
|
101
|
+
show_diff = diffs.diff_partial_update(
|
102
|
+
orig_lines,
|
103
|
+
lines,
|
104
|
+
final,
|
105
|
+
fname=fname,
|
106
|
+
).splitlines()
|
107
|
+
|
108
|
+
return "\n".join(show_diff)
|
109
|
+
|
110
|
+
def _update_files(self):
|
111
|
+
name = self.partial_response_function_call.get("name")
|
112
|
+
if name and name != "write_file":
|
113
|
+
raise ValueError(f'Unknown function_call name="{name}", use name="write_file"')
|
114
|
+
|
115
|
+
args = self.parse_partial_args()
|
116
|
+
if not args:
|
117
|
+
return
|
118
|
+
|
119
|
+
files = args.get("files", [])
|
120
|
+
|
121
|
+
edited = set()
|
122
|
+
for file_upd in files:
|
123
|
+
path = file_upd.get("path")
|
124
|
+
if not path:
|
125
|
+
raise ValueError(f"Missing path parameter: {file_upd}")
|
126
|
+
|
127
|
+
content = file_upd.get("content")
|
128
|
+
if not content:
|
129
|
+
raise ValueError(f"Missing content parameter: {file_upd}")
|
130
|
+
|
131
|
+
if self.allowed_to_edit(path, content):
|
132
|
+
edited.add(path)
|
133
|
+
|
134
|
+
return edited
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# flake8: noqa: E501
|
2
|
+
|
3
|
+
from .base_prompts import CoderPrompts
|
4
|
+
|
5
|
+
|
6
|
+
class WholeFileFunctionPrompts(CoderPrompts):
|
7
|
+
main_system = """Act as an expert software developer.
|
8
|
+
Take requests for changes to the supplied code.
|
9
|
+
If the request is ambiguous, ask questions.
|
10
|
+
|
11
|
+
Once you understand the request you MUST use the `write_file` function to edit the files to make the needed changes.
|
12
|
+
"""
|
13
|
+
|
14
|
+
system_reminder = """
|
15
|
+
ONLY return code using the `write_file` function.
|
16
|
+
NEVER return code outside the `write_file` function.
|
17
|
+
"""
|
18
|
+
|
19
|
+
files_content_prefix = "Here is the current content of the files:\n"
|
20
|
+
files_no_full_files = "I am not sharing any files yet."
|
21
|
+
|
22
|
+
redacted_edit_message = "No changes are needed."
|
23
|
+
|
24
|
+
# TODO: should this be present for using this with gpt-4?
|
25
|
+
repo_content_prefix = None
|
26
|
+
|
27
|
+
# TODO: fix the chat history, except we can't keep the whole file
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# flake8: noqa: E501
|
2
|
+
|
3
|
+
from .base_prompts import CoderPrompts
|
4
|
+
|
5
|
+
|
6
|
+
class WholeFilePrompts(CoderPrompts):
|
7
|
+
main_system = """Act as an expert software developer.
|
8
|
+
Take requests for changes to the supplied code.
|
9
|
+
If the request is ambiguous, ask questions.
|
10
|
+
|
11
|
+
Always reply to the user in {language}.
|
12
|
+
|
13
|
+
{final_reminders}
|
14
|
+
Once you understand the request you MUST:
|
15
|
+
1. Determine if any code changes are needed.
|
16
|
+
2. Explain any needed changes.
|
17
|
+
3. If changes are needed, output a copy of each file that needs changes.
|
18
|
+
"""
|
19
|
+
|
20
|
+
example_messages = [
|
21
|
+
dict(
|
22
|
+
role="user",
|
23
|
+
content="Change the greeting to be more casual",
|
24
|
+
),
|
25
|
+
dict(
|
26
|
+
role="assistant",
|
27
|
+
content="""Ok, I will:
|
28
|
+
|
29
|
+
1. Switch the greeting text from "Hello" to "Hey".
|
30
|
+
|
31
|
+
show_greeting.py
|
32
|
+
{fence[0]}
|
33
|
+
import sys
|
34
|
+
|
35
|
+
def greeting(name):
|
36
|
+
print(f"Hey {{name}}")
|
37
|
+
|
38
|
+
if __name__ == '__main__':
|
39
|
+
greeting(sys.argv[1])
|
40
|
+
{fence[1]}
|
41
|
+
""",
|
42
|
+
),
|
43
|
+
]
|
44
|
+
|
45
|
+
system_reminder = """To suggest changes to a file you MUST return the entire content of the updated file.
|
46
|
+
You MUST use this *file listing* format:
|
47
|
+
|
48
|
+
path/to/filename.js
|
49
|
+
{fence[0]}
|
50
|
+
// entire file content ...
|
51
|
+
// ... goes in between
|
52
|
+
{fence[1]}
|
53
|
+
|
54
|
+
Every *file listing* MUST use this format:
|
55
|
+
- First line: the filename with any originally provided path; no extra markup, punctuation, comments, etc. **JUST** the filename with path.
|
56
|
+
- Second line: opening {fence[0]}
|
57
|
+
- ... entire content of the file ...
|
58
|
+
- Final line: closing {fence[1]}
|
59
|
+
|
60
|
+
To suggest changes to a file you MUST return a *file listing* that contains the entire content of the file.
|
61
|
+
*NEVER* skip, omit or elide content from a *file listing* using "..." or by adding comments like "... rest of code..."!
|
62
|
+
Create a new file you MUST return a *file listing* which includes an appropriate filename, including any appropriate path.
|
63
|
+
|
64
|
+
{final_reminders}
|
65
|
+
"""
|
66
|
+
|
67
|
+
redacted_edit_message = "No changes are needed."
|