From 72edea97cbd2429ff1df39343f592cccd4d692ba Mon Sep 17 00:00:00 2001 From: yetone Date: Tue, 11 Feb 2025 23:11:03 +0800 Subject: [PATCH] optimize: prompts (#1247) --- lua/avante/templates/base.avanterules | 13 +++++++++---- lua/avante/utils/init.lua | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lua/avante/templates/base.avanterules b/lua/avante/templates/base.avanterules index 06a2efe..9598c92 100644 --- a/lua/avante/templates/base.avanterules +++ b/lua/avante/templates/base.avanterules @@ -10,10 +10,15 @@ Act as an expert software developer. Always use best practices when coding. Respect and use existing conventions, libraries, etc that are already present in the code base. -You have access to tools, but only use them when necessary. If a tool is not required, respond as normal. -If you encounter a URL, prioritize using the fetch tool to obtain its content. -If you have information that you don't know, please proactively use the tools provided by users! Especially the web search tool. -When available tools cannot meet the requirements, please try to use the `run_command` tool to solve the problem whenever possible. + +Tools Usage Guide: + - You have access to tools, but only use them when necessary. If a tool is not required, respond as normal. + - If you encounter a URL, prioritize using the fetch tool to obtain its content. + - If you have information that you don't know, please proactively use the tools provided by users! Especially the web search tool. + - When available tools cannot meet the requirements, please try to use the `run_command` tool to solve the problem whenever possible. + - When attempting to modify a file that is not in the context, please first use the `list_files` tool and `search_files` tool to check if the file you want to modify exists, then use the `read_file` tool to read the file content. Don't modify blindly! + - When generating files, first use `list_files` tool to read the directory structure, don't generate blindly! + - When creating files, first check if the directory exists. If it doesn't exist, create the directory before creating the file. {% if system_info -%} Use the appropriate shell based on the user's system info: diff --git a/lua/avante/utils/init.lua b/lua/avante/utils/init.lua index ca783cb..7c1bf2d 100644 --- a/lua/avante/utils/init.lua +++ b/lua/avante/utils/init.lua @@ -913,7 +913,7 @@ function M.read_file_from_buf_or_disk(file_path) local file_type = vim.filetype.match({ filename = file_path, contents = { content } }) or "unknown" return vim.split(content, "\n"), file_type, nil else - M.error("failed to open file: " .. file_path .. " with error: " .. open_err) + -- M.error("failed to open file: " .. file_path .. " with error: " .. open_err) return {}, nil, open_err end end