From b89e6d84a0d286a79a0519f92f56ad587c490c7a Mon Sep 17 00:00:00 2001 From: yetone Date: Mon, 2 Jun 2025 23:17:31 +0800 Subject: [PATCH] fix: update view tool prompts (#2116) --- lua/avante/llm_tools/view.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/avante/llm_tools/view.lua b/lua/avante/llm_tools/view.lua index 4d134d5..f14689d 100644 --- a/lua/avante/llm_tools/view.lua +++ b/lua/avante/llm_tools/view.lua @@ -10,7 +10,7 @@ M.name = "view" M.description = [[The view tool allows you to examine the contents of a file or list the contents of a directory. It can read the entire file or a specific range of lines. If the file content is already in the context, do not use this tool. -IMPORTANT NOTE: If the file content exceeds a certain size, the returned content will be truncated, and `is_truncated` will be set to true. If `is_truncated` is true, use the `view_range` parameter to specify the range to view. +IMPORTANT NOTE: If the file content exceeds a certain size, the returned content will be truncated, and `is_truncated` will be set to true. If `is_truncated` is true, use the `start_line` parameter and `end_line` parameter to specify the range to view. ]] M.enabled = function(opts) @@ -97,9 +97,11 @@ function M.func(opts, on_log, on_complete, session_ctx) end table.insert(truncated_lines, line) end + local total_line_count = lines and #lines or 0 local content = truncated_lines and table.concat(truncated_lines, "\n") or "" local result = vim.json.encode({ content = content, + total_line_count = total_line_count, is_truncated = is_truncated, }) if not on_complete then return result, nil end