|
1 | | -import json |
2 | | - |
3 | 1 | from cecli.helpers.hashline import ( |
4 | 2 | ContentHashError, |
5 | 3 | apply_hashline_operations, |
|
15 | 13 | validate_file_for_edit, |
16 | 14 | ) |
17 | 15 | from cecli.tools.utils.output import color_markers, tool_footer, tool_header |
| 16 | +from cecli.tools.validations import ToolValidations |
18 | 17 |
|
19 | 18 | VALID_OPERATIONS = {"replace", "delete", "insert"} |
20 | 19 | OPERATION_NOUNS = { |
@@ -235,7 +234,7 @@ def execute( |
235 | 234 | if new_content != original_content: |
236 | 235 | file_successful_edits += len(successful_ops) |
237 | 236 | else: |
238 | | - raise ToolError("Invalid Edit - Edit Results In Same Content") |
| 237 | + raise ToolError("Invalid Edit - Update content hash bounds") |
239 | 238 |
|
240 | 239 | if len(failed_ops): |
241 | 240 | for failed_op in failed_ops: |
@@ -373,12 +372,16 @@ def execute( |
373 | 372 | def format_output(cls, coder, mcp_server, tool_response): |
374 | 373 | color_start, color_end = color_markers(coder) |
375 | 374 |
|
| 375 | + # Output header |
| 376 | + tool_header(coder=coder, mcp_server=mcp_server, tool_response=tool_response) |
| 377 | + |
376 | 378 | try: |
377 | | - params = json.loads(tool_response.function.arguments) |
378 | | - except json.JSONDecodeError: |
| 379 | + params = ToolValidations.validate_params( |
| 380 | + tool_response.function.arguments, cls.VALIDATIONS, cls.SCHEMA |
| 381 | + ) |
| 382 | + except ToolError: |
379 | 383 | coder.io.tool_error("Invalid Tool JSON") |
380 | | - |
381 | | - tool_header(coder=coder, mcp_server=mcp_server, tool_response=tool_response) |
| 384 | + return |
382 | 385 |
|
383 | 386 | # Group edits by file_path for display |
384 | 387 | edits_by_file = {} |
@@ -453,4 +456,4 @@ def format_output(cls, coder, mcp_server, tool_response): |
453 | 456 | coder.io.tool_output(range_info) |
454 | 457 | coder.io.tool_output("") |
455 | 458 |
|
456 | | - tool_footer(coder=coder, tool_response=tool_response) |
| 459 | + tool_footer(coder=coder, tool_response=tool_response, params=params) |
0 commit comments