Skip to content

Commit 5e439c3

Browse files
committed
refactor: Line up argument names and function names
Signed-off-by: Edward Z. Yang <[email protected]> ghstack-source-id: c641c40 Pull-Request-resolved: #294
1 parent 262b79c commit 5e439c3

File tree

10 files changed

+175
-238
lines changed

10 files changed

+175
-238
lines changed

codemcp/main.py

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
from .common import normalize_file_path
1818
from .git_query import get_current_commit_hash
1919
from .tools.chmod import chmod
20-
from .tools.edit_file import edit_file_content
21-
from .tools.glob import glob_files
22-
from .tools.grep import grep_files
20+
from .tools.edit_file import edit_file
21+
from .tools.glob import glob
22+
from .tools.grep import grep
2323
from .tools.init_project import init_project
24-
from .tools.ls import ls_directory
25-
from .tools.mv import mv_file
26-
from .tools.read_file import read_file_content
27-
from .tools.rm import rm_file
24+
from .tools.ls import ls
25+
from .tools.mv import mv
26+
from .tools.read_file import read_file
27+
from .tools.rm import rm
2828
from .tools.run_command import run_command
2929
from .tools.think import think
30-
from .tools.write_file import write_file_content
30+
from .tools.write_file import write_file
3131

3232
# Initialize FastMCP server
3333
mcp = FastMCP("codemcp")
@@ -182,7 +182,7 @@ async def codemcp(
182182
if path is None:
183183
raise ValueError("path is required for ReadFile subtool")
184184

185-
result = await read_file_content(path, offset, limit, chat_id, commit_hash)
185+
result = await read_file(path, offset, limit, chat_id, commit_hash)
186186
return result
187187

188188
if subtool == "WriteFile":
@@ -193,9 +193,7 @@ async def codemcp(
193193
if chat_id is None:
194194
raise ValueError("chat_id is required for WriteFile subtool")
195195

196-
result = await write_file_content(
197-
path, content, description, chat_id, commit_hash
198-
)
196+
result = await write_file(path, content, description, chat_id, commit_hash)
199197
return result
200198

201199
if subtool == "EditFile":
@@ -216,16 +214,14 @@ async def codemcp(
216214
# Accept either new_string or new_str (prefer new_string if both are provided)
217215
new_content = new_string or new_str
218216

219-
result = await edit_file_content(
220-
path, old_content, new_content, None, description, chat_id, commit_hash
221-
)
217+
result = await edit_file(path, old_content, new_content, None, description, chat_id, commit_hash)
222218
return result
223219

224220
if subtool == "LS":
225221
if path is None:
226222
raise ValueError("path is required for LS subtool")
227223

228-
result = await ls_directory(path, chat_id, commit_hash)
224+
result = await ls(path, chat_id, commit_hash)
229225
return result
230226

231227
if subtool == "InitProject":
@@ -267,9 +263,7 @@ async def codemcp(
267263
raise ValueError("path is required for Grep subtool")
268264

269265
try:
270-
result_string = await grep_files(
271-
pattern, path, include, chat_id, commit_hash
272-
)
266+
result_string = await grep(pattern, path, include, chat_id, commit_hash)
273267
return result_string
274268
except Exception as e:
275269
logging.error(f"Error in Grep subtool: {e}", exc_info=True)
@@ -282,9 +276,7 @@ async def codemcp(
282276
raise ValueError("path is required for Glob subtool")
283277

284278
try:
285-
result_string = await glob_files(
286-
pattern, path, limit, offset, chat_id, commit_hash
287-
)
279+
result_string = await glob(pattern, path, limit, offset, chat_id, commit_hash)
288280
return result_string
289281
except Exception as e:
290282
logging.error(f"Error in Glob subtool: {e}", exc_info=True)
@@ -298,7 +290,7 @@ async def codemcp(
298290
if chat_id is None:
299291
raise ValueError("chat_id is required for RM subtool")
300292

301-
result = await rm_file(path, description, chat_id, commit_hash)
293+
result = await rm(path, description, chat_id, commit_hash)
302294
return result
303295

304296
if subtool == "MV":
@@ -315,9 +307,7 @@ async def codemcp(
315307
if chat_id is None:
316308
raise ValueError("chat_id is required for MV subtool")
317309

318-
result = await mv_file(
319-
source_path, target_path, description, chat_id, commit_hash
320-
)
310+
result = await mv(source_path, target_path, description, chat_id, commit_hash)
321311
return result
322312

323313
if subtool == "Think":

codemcp/tools/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
from .git_diff import git_diff
77
from .git_log import git_log
88
from .git_show import git_show
9-
from .mv import mv_file
10-
from .rm import rm_file
9+
from .mv import mv
10+
from .rm import rm
1111

1212
__all__ = [
1313
"chmod",
1414
"git_blame",
1515
"git_diff",
1616
"git_log",
1717
"git_show",
18-
"mv_file",
19-
"rm_file",
18+
"mv",
19+
"rm",
2020
]

codemcp/tools/edit_file.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
logger = logging.getLogger(__name__)
2626

2727
__all__ = [
28-
"edit_file_content",
28+
"edit_file",
2929
"find_similar_file",
3030
"apply_edit_pure",
3131
]
@@ -744,8 +744,8 @@ def debug_string_comparison(
744744
return not content_same
745745

746746

747-
async def edit_file_content(
748-
file_path: str,
747+
async def edit_file(
748+
path: str,
749749
old_string: str | None = None,
750750
new_string: str | None = None,
751751
read_file_timestamps: dict[str, float] | None = None,
@@ -761,7 +761,7 @@ async def edit_file_content(
761761
whitespace on otherwise empty lines.
762762
763763
Args:
764-
file_path: The absolute path to the file to edit
764+
path: The absolute path to the file to edit
765765
old_string: The text to replace (use empty string for new file creation)
766766
new_string: The new text to replace old_string with
767767
read_file_timestamps: Dictionary mapping file paths to timestamps when they were last read
@@ -785,7 +785,7 @@ async def edit_file_content(
785785
chat_id = "" if chat_id is None else chat_id
786786

787787
# Normalize the file path
788-
full_file_path = normalize_file_path(file_path)
788+
full_file_path = normalize_file_path(path)
789789

790790
# Normalize string inputs to ensure consistent newlines
791791
old_string = old_string.replace("\r\n", "\n")

0 commit comments

Comments
 (0)