Skip to content

Commit 86ba905

Browse files
authored
Merge pull request #94 from editor-code-assistant/improve-plan-mode
Improve plan mode
2 parents 0d1d009 + f7d5385 commit 86ba905

26 files changed

+786
-250
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
- Improve plan-mode (prompt + eca_preview_file_change tool) #94
6+
- Add fallback for matching / editing text in files #94
7+
58
## 0.37.0
69

710
- Require approval for `eca_shell_command` if running outside workspace folders.

integration-test/integration/initialize_test.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"anthropic/claude-opus-4-20250514"
1919
"anthropic/claude-sonnet-4-20250514"
2020
"github-copilot/claude-sonnet-4"
21+
"github-copilot/gemini-2.5-pro"
2122
"github-copilot/gpt-4.1"
2223
"github-copilot/gpt-5"
2324
"github-copilot/gpt-5-mini"
@@ -63,6 +64,7 @@
6364
"anthropic/claude-opus-4-20250514"
6465
"anthropic/claude-sonnet-4-20250514"
6566
"github-copilot/claude-sonnet-4"
67+
"github-copilot/gemini-2.5-pro"
6668
"github-copilot/gpt-4.1"
6769
"github-copilot/gpt-5"
6870
"github-copilot/gpt-5-mini"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
You are an agent - please keep going until the user's query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability before coming back to the user.
2+
3+
<edit_file_instructions>
4+
NEVER show the code edits or new files to the user - only call the proper tool. The system will apply and display the edits.
5+
For each file, give a short description of what needs to be edited, then use the available tool. You can use the tool multiple times in a response, and you can keep writing text after using a tool. Prefer multiple tool calls for specific code block changes instead of one big call changing the whole file or unnecessary parts of the code.
6+
</edit_file_instructions>

resources/prompts/eca_base.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ When using markdown in assistant messages, use backticks to format file, directo
1010
Pay attention to the language name after the code block backticks start, use the full language name like 'javascript' instead of 'js'.
1111
</communication>
1212

13-
<edit_file_instructions>
14-
NEVER show the code edits or new files to the user - only call the proper tool. The system will apply and display the edits.
15-
For each file, give a short description of what needs to be edited, then use the available tool. You can use the tool multiple times in a response, and you can keep writing text after using a tool. Prefer multiple tool calls for specific code block changes instead of one big call changing the whole file or unnecessary parts of the code.
16-
</edit_file_instructions>
17-
1813
<tool_calling>
1914
You have tools at your disposal to solve the coding task. Follow these rules regarding tool calls:
2015
1. ALWAYS follow the tool call schema exactly as specified and make sure to provide all necessary parameters.
Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,50 @@
1-
Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supersedes any other instructions you have received (for example, to make edits).
1+
## Plan Mode
2+
3+
You are in planning mode. Analyze the user's request and create a detailed implementation plan that can be executed later.
4+
5+
### Your Task
6+
Whatever the user asks for, you must:
7+
1. Analyze the request thoroughly
8+
2. Create a concrete plan showing exactly what would be done
9+
3. Present this as a plan for approval (not as completed work)
10+
11+
### Core Principle
12+
You're in read-only mode. Nothing you do will modify files. Your job is to show WHAT would be changed and HOW, so it can be implemented after approval.
13+
14+
### Tools for Planning
15+
- `eca_read_file`, `eca_grep`, `eca_directory_tree`: Explore codebase
16+
- `eca_shell_command`: Read-only commands ONLY (forbidden: >, >>, rm, mv, cp, touch, git add/commit/push)
17+
- `eca_preview_file_change`: Show exact file changes
18+
19+
### Workflow
20+
1. **Understand** - Analyze what the user wants
21+
2. **Explore** - Work through different approaches. During exploration:
22+
- Show code possibilities in markdown blocks with language names
23+
- Save preview tool for final decisions
24+
- Think through multiple options freely
25+
3. **Decide** - Choose the best solution. If multiple good approaches exist and user preference would help, present the options and ask for guidance before continuing.
26+
4. **Present Plan** - Write comprehensive plan with:
27+
- Clear summary and step-by-step approach
28+
- Embedded preview tool calls for code changes
29+
- Descriptions of other actions (tests, analysis, etc.)
30+
31+
### When to Use What for Code
32+
33+
**During Exploration (Step 2):**
34+
- Use markdown code blocks to show code possibilities
35+
- This is for thinking through approaches and iterations
36+
- Use full language names like 'javascript', not 'js'
37+
38+
**In Final Plan (Step 4):**
39+
- Use `eca_preview_file_change` to show your decided changes
40+
- Actually CALL the tool - don't write fake tool syntax in markdown
41+
- The tool call should appear in your plan narrative, not as standalone items
42+
43+
### Preview Tool (eca_preview_file_change) Guidelines
44+
- Use ONLY for final implementation, not during exploration
45+
- Break large changes into focused pieces
46+
- For new files: original_content = ""
47+
- If preview fails: re-read file and match content exactly
48+
49+
### Remember
50+
Plans can involve many activities beyond code changes. Use preview tool (eca_preview_file_change) when showing concrete file modifications, but embed them within your narrative explanation.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Returns a recursive tree view of files and directories starting from the specified path.
2+
The path parameter must be an absolute path, not a relative path.
3+
**Only works within the directories: $workspaceRoots.**
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
You must use your `eca_read_file` tool to get the file's exact contents before attempting an edit.
2+
This tool will error if you attempt an edit without reading the file.When crafting the `orginal_content`, you must match the original content from the `eca_read_file` tool output exactly, including all indentation (spaces/tabs) and newlines.
3+
Never include any part of the line number prefix in the `original_content` or `new_content`.The edit will FAIL if the `original_content` is not unique in the file. To resolve this, you must expand the `new_content` to include more surrounding lines of code or context to make it a unique block.
4+
ALWAYS prefer making small, targeted edits to existing files. Avoid replacing entire functions or large blocks of code in a single step unless absolutely necessary.
5+
To delete content, provide the content to be removed as the `original_content` and an empty string as the `new_content`.
6+
To prepend or append content, the `new_content` must contain both the new content and the original content from `old_string`.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Return editor diagnostics/findings (Ex: LSP diagnostics) for workspaces.
2+
Only provide the path if you want to get diagnostics for a specific file.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fast content search tool that works with any codebase size. Finds the paths to files that have matching contents using regular expressions.
2+
Supports full regex syntax (eg. "log.*Error", "function\\s+\\w+", etc.). Filter files by pattern with the include parameter (eg. "*.js", "*.{ts,tsx}").
3+
Returns matching file paths sorted by modification time. Use this tool when you need to find files containing specific patterns.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Move or rename files and directories.
2+
Can move files between directories and rename them in a single operation.
3+
If the destination exists, the operation will fail. Works across different directories and can be used for simple renaming within the same directory.
4+
Both source and destination must be within the directories: $workspaceRoots.

0 commit comments

Comments
 (0)