Skip to content

Commit e2aeebf

Browse files
author
Your Name
committed
- Update when linting and edit restrictions occur to interrupt the LLM less while fixing mistakes
- Remove indent_text tool since it almost never gets used
1 parent 9b45684 commit e2aeebf

8 files changed

Lines changed: 22 additions & 253 deletions

File tree

cecli/coders/agent_coder.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def __init__(self, *args, **kwargs):
6666
}
6767
self.write_tools = {
6868
"deletetext",
69-
"indenttext",
7069
"inserttext",
7170
"replacetext",
7271
"undochange",
@@ -244,14 +243,14 @@ async def initialize_mcp_tools(self):
244243

245244
async def _execute_local_tool_calls(self, tool_calls_list):
246245
tool_responses = []
247-
has_write_tool = False
246+
used_write_tool = False
248247

249248
for tool_call in tool_calls_list:
250249
tool_name = tool_call.function.name
251250
result_message = ""
252251
try:
253252
if tool_name.lower() in self.write_tools:
254-
has_write_tool = True
253+
used_write_tool = True
255254

256255
args_string = tool_call.function.arguments.strip()
257256
parsed_args_list = []
@@ -342,7 +341,7 @@ async def _execute_local_tool_calls(self, tool_calls_list):
342341
{"role": "tool", "tool_call_id": tool_call.id, "content": result_message}
343342
)
344343

345-
if self.auto_lint and has_write_tool:
344+
if self.auto_lint and used_write_tool and not self.edit_allowed:
346345
edited = list(self.files_edited_by_tools)
347346
lint_errors = self.lint_edited(edited)
348347
self.lint_outcome = not lint_errors

cecli/prompts/agent.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ main_system: |
5151
Do not attempt to write these content ids. They are automatically generated.
5252
5353
**MANDATORY Three-Phase Safety Protocol**:
54-
1. **Phase 1**: Use `ShowContext` to get the hashline-prefixed content around the pattern to modify.
55-
2. **Phase 2**: Execute the edit (`ReplaceText`, `InsertText`, `DeleteText`, `IndentText`) using the verified hashlines prefixes from the `ShowContext` tool.
54+
1. **Phase 1**: Use `ShowContext` to get the hashline-prefixed content around the pattern to modify. Capture entire functions, logical blocks and closures
55+
2. **Phase 2**: Execute the edit (`ReplaceText`, `InsertText`, `DeleteText`) using the verified hashlines prefixes from the `ShowContext` tool.
5656
3. **Phase 3**: Use the diff messages provided after changes are made to ensure the appropriate content was modified. For errant modifications, use `UndoChange` immediately, else proceed with the task.
57+
58+
**Atomic Scope:** Include the **entire function or logical block**. Never return partial syntax or broken closures. Do not attempt to replace just the beginning or end of a closure.
59+
**Indentation**: Preserve all whitespace (spaces, tabs, and newlines).
5760
</context>
5861
5962
Use the `.cecli/workspace` directory for all temporary, test, or scratch files.

cecli/tools/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
git_show,
1616
git_status,
1717
grep,
18-
indent_text,
1918
insert_text,
2019
list_changes,
2120
load_skill,
@@ -44,7 +43,6 @@
4443
git_show,
4544
git_status,
4645
grep,
47-
indent_text,
4846
insert_text,
4947
list_changes,
5048
load_skill,

cecli/tools/delete_text.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from cecli.helpers.hashline import HashlineError, apply_hashline_operation
1+
from cecli.helpers.hashline import apply_hashline_operation
22
from cecli.tools.utils.base_tool import BaseTool
33
from cecli.tools.utils.helpers import (
44
ToolError,
@@ -63,8 +63,6 @@ def execute(
6363
raise ToolError(
6464
"Please call `ShowContext` first to make sure edits are appropriately scoped"
6565
)
66-
else:
67-
coder.edit_allowed = False
6866

6967
tool_name = "DeleteText"
7068
try:
@@ -80,7 +78,7 @@ def execute(
8078
operation="delete",
8179
text=None,
8280
)
83-
except (ToolError, HashlineError, ToolError) as e:
81+
except Exception as e:
8482
raise ToolError(f"Hashline deletion failed: {str(e)}")
8583

8684
# Check if any changes were made
@@ -118,6 +116,8 @@ def execute(
118116
)
119117

120118
coder.files_edited_by_tools.add(rel_path)
119+
coder.edit_allowed = False
120+
121121
# 5. Format and return result
122122
success_message = f"Deleted lines {start_line} to {end_line} in {file_path}"
123123
return format_tool_result(

cecli/tools/indent_text.py

Lines changed: 0 additions & 232 deletions
This file was deleted.

cecli/tools/insert_text.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import traceback
22

3-
from cecli.helpers.hashline import HashlineError, apply_hashline_operation
3+
from cecli.helpers.hashline import apply_hashline_operation
44
from cecli.tools.utils.base_tool import BaseTool
55
from cecli.tools.utils.helpers import (
66
ToolError,
@@ -72,8 +72,6 @@ def execute(
7272
raise ToolError(
7373
"Please call `ShowContext` first to make sure edits are appropriately scoped"
7474
)
75-
else:
76-
coder.edit_allowed = False
7775

7876
tool_name = "InsertText"
7977
try:
@@ -89,7 +87,7 @@ def execute(
8987
operation="insert",
9088
text=content,
9189
)
92-
except (ToolError, HashlineError, ValueError) as e:
90+
except Exception as e:
9391
raise ToolError(f"Hashline insertion failed: {str(e)}")
9492

9593
# Check if any changes were made
@@ -125,6 +123,7 @@ def execute(
125123
)
126124

127125
coder.files_edited_by_tools.add(rel_path)
126+
coder.edit_allowed = False
128127

129128
# 5. Format and return result
130129
success_message = f"Inserted content at {start_line} in {file_path}"

0 commit comments

Comments
 (0)