Merge branch 'feature-editor-reporter' into 'add_swe_agent_ablilities_to_engineer2'

Feature editor reporter

See merge request pub/MetaGPT!365
This commit is contained in:
林义章 2024-09-05 08:12:24 +00:00
commit 2157feafa0

View file

@ -321,6 +321,7 @@ class Editor(BaseModel):
output = self._cur_file_header(path, total_lines)
output += self._print_window(path, self.current_line, self._clamp(context_lines, 1, 2000))
self.resource.report(path, "path")
return output
def goto_line(self, line_number: int) -> str:
@ -823,6 +824,7 @@ class Editor(BaseModel):
)
# lint_error = bool(LINTER_ERROR_MSG in ret_str)
# TODO: automatically tries to fix linter error (maybe involve some static analysis tools on the location near the edit to figure out indentation)
self.resource.report(file_name, "path")
return ret_str
def insert_content_at_line(self, file_name: str, line_number: int, content: str) -> str:
@ -951,6 +953,9 @@ class Editor(BaseModel):
res_list.append(f'[End of matches for "{search_term}" in {file_path}]')
else:
res_list.append(f'[No matches found for "{search_term}" in {file_path}]')
extra = {"type": "search", "symbol": search_term, "lines": [i[0] - 1 for i in matches]} if matches else None
self.resource.report(file_path, "path", extra=extra)
return "\n".join(res_list)
def find_file(self, file_name: str, dir_path: str = "./") -> str: