feat: add memory bank prompt, rename read_file and edit_file, improve basic prompt

This commit is contained in:
2025-02-13 01:14:58 +01:00
parent 01932be82a
commit 5b972c5c9f
5 changed files with 100 additions and 28 deletions

View File

@@ -173,8 +173,8 @@ local function build_prompt(user_input, dirs, conf)
table.insert(final_sections, table.concat(env_lines, "\n"))
local final_prompt = table.concat(final_sections, "\n\n")
-- Replace placeholder "%PROJECT_NAME%" with the actual project name from configuration
final_prompt = final_prompt:gsub("%%PROJECT_NAME%%", conf.project_name)
-- Replace placeholder "chatgpt.vim" with the actual project name from configuration
final_prompt = final_prompt:gsub("%chatgpt.vim%", conf.project_name)
return final_prompt
end
@@ -453,13 +453,8 @@ local function run_chatgpt_current_buffer_command()
end
------------------------------------------------------------------------------
-- PUBLIC API
-- GLOBAL FILE COMPLETION FUNCTION
------------------------------------------------------------------------------
M.run_chatgpt_command = run_chatgpt_command
M.run_chatgpt_paste_command = run_chatgpt_paste_command
M.run_chatgpt_current_buffer_command = run_chatgpt_current_buffer_command
-- New: Global function for file name auto-completion in ChatGPT prompt
function _G.chatgpt_file_complete(findstart, base)
if findstart == 1 then
local line = vim.fn.getline('.')
@@ -474,9 +469,8 @@ function _G.chatgpt_file_complete(findstart, base)
local conf = config.load()
local files = context.get_project_files({'.'}, conf)
local completions = {}
local esc_base = base:gsub("([^%w])", "%%%1")
for _, f in ipairs(files) do
if f:match("^" .. esc_base) then
if f:find(base, 1, true) then
table.insert(completions, f)
end
end