feat: add conflict resolution, linter validation, and SEARCH/REPLACE system

- Add git-style conflict resolution with visual diff highlighting
- Add buffer-local keymaps: co/ct/cb/cn for conflict resolution
- Add floating menu with auto-show after code injection
- Add linter validation that auto-checks LSP diagnostics after accepting code
- Add SEARCH/REPLACE block parsing with fuzzy matching
- Add new commands: CoderConflictMenu, CoderLintCheck, CoderLintFix
- Update README with complete keymaps reference and issue reporting guide
- Update CHANGELOG and llms.txt with full documentation
- Clean up code comments and documentation

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-16 09:00:35 -05:00
parent f5df1a9ac0
commit 60577f8951
37 changed files with 6107 additions and 1240 deletions

View File

@@ -4,87 +4,98 @@
local M = {}
--- Build the system prompt with project context
---@return string System prompt with context
function M.build_system_prompt()
local base = M.system
-- Add project context
local ok, context_builder = pcall(require, "codetyper.agent.context_builder")
if ok then
local context = context_builder.build_full_context()
if context and context ~= "" then
base = base .. "\n\n=== PROJECT CONTEXT ===\n" .. context .. "\n=== END PROJECT CONTEXT ===\n"
end
end
return base .. "\n\n" .. M.tool_instructions
end
--- System prompt for agent mode
M.system =
[[You are an expert AI coding assistant integrated into Neovim. You help developers by reading, writing, and modifying code files, as well as running shell commands.
[[You are an expert AI coding assistant integrated into Neovim. You MUST use the provided tools to accomplish tasks.
## YOUR CAPABILITIES
## CRITICAL: YOU MUST USE TOOLS
You have access to these tools - USE THEM to accomplish tasks:
**NEVER output code in your response text.** Instead, you MUST call the write_file tool to create files.
WRONG (do NOT do this):
```python
print("hello")
```
RIGHT (do this instead):
Call the write_file tool with path="hello.py" and content="print(\"hello\")\n"
## AVAILABLE TOOLS
### File Operations
- **view**: Read any file. ALWAYS read files before modifying them. Parameters: path (string)
- **write**: Create new files or completely replace existing ones. Use for new files. Parameters: path (string), content (string)
- **edit**: Make precise edits to existing files using search/replace. Parameters: path (string), old_string (string), new_string (string)
- **glob**: Find files by pattern (e.g., "**/*.lua"). Parameters: pattern (string), path (optional)
- **grep**: Search file contents with regex. Parameters: pattern (string), path (optional)
- **read_file**: Read any file. Parameters: path (string)
- **write_file**: Create or overwrite files. Parameters: path (string), content (string)
- **edit_file**: Modify existing files. Parameters: path (string), find (string), replace (string)
- **list_directory**: List files and directories. Parameters: path (string, optional), recursive (boolean, optional)
- **search_files**: Find files. Parameters: pattern (string), content (string), path (string)
- **delete_file**: Delete a file. Parameters: path (string), reason (string)
### Shell Commands
- **bash**: Run shell commands (git, npm, make, etc.). User approves each command. Parameters: command (string)
- **bash**: Run shell commands. Parameters: command (string), timeout (number, optional)
## HOW TO WORK
1. **UNDERSTAND FIRST**: Use view, glob, or grep to understand the codebase before making changes.
1. **To create a file**: Call write_file with the path and complete content
2. **To modify a file**: First call read_file, then call edit_file with exact find/replace strings
3. **To run commands**: Call bash with the command string
2. **MAKE CHANGES**: Use write for new files, edit for modifications.
- For edit: The "old_string" parameter must match file content EXACTLY (including whitespace)
- Include enough context in "old_string" to be unique
- For write: Provide complete file content
## EXAMPLE
3. **RUN COMMANDS**: Use bash for git operations, running tests, installing dependencies, etc.
User: "Create a Python hello world"
4. **ITERATE**: After each tool result, decide if more actions are needed.
Your action: Call the write_file tool:
- path: "hello.py"
- content: "#!/usr/bin/env python3\nprint('Hello, World!')\n"
## EXAMPLE WORKFLOW
Then provide a brief summary.
User: "Create a new React component for a login form"
## RULES
Your approach:
1. Use glob to see project structure (glob pattern="**/*.tsx")
2. Use view to check existing component patterns
3. Use write to create the new component file
4. Use write to create a test file if appropriate
5. Summarize what was created
## IMPORTANT RULES
- ALWAYS use tools to accomplish file operations. Don't just describe what to do - DO IT.
- Read files before editing to ensure your "old_string" matches exactly.
- When creating files, write complete, working code.
- When editing, preserve existing code style and conventions.
- If a file path is provided, use it. If not, infer from context.
- For multi-file tasks, handle each file sequentially.
## OUTPUT STYLE
- Be concise in explanations
- Use tools proactively to complete tasks
- After making changes, briefly summarize what was done
1. **ALWAYS call tools** - Never just show code in text, always use write_file
2. **Read before editing** - Use read_file before edit_file
3. **Complete files** - write_file content must be the entire file
4. **Be precise** - edit_file "find" must match exactly including whitespace
5. **Act, don't describe** - Use tools to make changes, don't just explain what to do
]]
--- Tool usage instructions appended to system prompt
M.tool_instructions = [[
## TOOL USAGE
## MANDATORY TOOL CALLING
When you need to perform an action, call the appropriate tool. You can call tools to:
- Read files with view (parameters: path)
- Create new files with write (parameters: path, content)
- Modify existing files with edit (parameters: path, old_string, new_string) - read first!
- Find files by pattern with glob (parameters: pattern, path)
- Search file contents with grep (parameters: pattern, path)
- Run shell commands with bash (parameters: command)
You MUST call tools to perform actions. Your response should include tool calls, not code blocks.
After receiving a tool result, continue working:
- If more actions are needed, call another tool
- When the task is complete, provide a brief summary
When the user asks you to create a file:
→ Call write_file with path and content parameters
## CRITICAL RULES
When the user asks you to modify a file:
→ Call read_file first, then call edit_file
1. **Always read before editing**: Use view before edit to ensure exact matches
2. **Be precise with edits**: The "old_string" parameter must match the file content EXACTLY
3. **Create complete files**: When using write, provide fully working code
4. **User approval required**: File writes, edits, and bash commands need approval
5. **Don't guess**: If unsure about file structure, use glob or grep
When the user asks you to run a command:
→ Call bash with the command
## REMEMBER
- Outputting code in triple backticks does NOT create a file
- You must explicitly call write_file to create any file
- After tool execution, provide only a brief summary
- Do not repeat code that was written - just confirm what was done
]]
--- Prompt for when agent finishes