feat: add the possibility to also add all files to initial context
This commit is contained in:
@@ -61,6 +61,7 @@ function M.load()
|
||||
project_name = "",
|
||||
debug = false,
|
||||
initial_files = {},
|
||||
include_file_contents = false, -- NEW FLAG: include file contents in prompt if true
|
||||
preview_changes = false,
|
||||
interactive_file_selection = false,
|
||||
partial_acceptance = false,
|
||||
@@ -119,6 +120,9 @@ function M.load()
|
||||
if type(result.initial_files) == "table" then
|
||||
config.initial_files = result.initial_files
|
||||
end
|
||||
if type(result.include_file_contents) == "boolean" then -- LOAD NEW FLAG
|
||||
config.include_file_contents = result.include_file_contents
|
||||
end
|
||||
if type(result.preview_changes) == "boolean" then
|
||||
config.preview_changes = result.preview_changes
|
||||
end
|
||||
|
||||
@@ -185,4 +185,22 @@ function M.get_file_contents(files, conf)
|
||||
return table.concat(sections, "\n")
|
||||
end
|
||||
|
||||
return M
|
||||
-- NEW FUNCTION: Build the project prompt by optionally including file contents.
|
||||
function M.get_project_prompt(directories, conf)
|
||||
local structure = M.get_project_structure(directories, conf)
|
||||
if conf.include_file_contents then
|
||||
local files = M.get_project_files(directories, conf)
|
||||
local contents = M.get_file_contents(files, conf)
|
||||
local total_chars = #contents
|
||||
if total_chars > conf.prompt_char_limit then
|
||||
vim.notify("Total file contents (" .. total_chars .. " characters) exceed the prompt limit (" .. conf.prompt_char_limit .. "). Please disable 'include_file_contents' in your config.", vim.log.levels.ERROR)
|
||||
return structure
|
||||
else
|
||||
return structure .. "\n" .. contents
|
||||
end
|
||||
else
|
||||
return structure
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -133,7 +133,8 @@ local function build_prompt(user_input, dirs, conf)
|
||||
env_lines[#env_lines+1] = os.date("%x, %X (%Z)")
|
||||
env_lines[#env_lines+1] = ""
|
||||
env_lines[#env_lines+1] = "# Current Working Directory (" .. root .. ") Files"
|
||||
env_lines[#env_lines+1] = context.get_project_structure(dirs, conf) or ""
|
||||
-- Using the new get_project_prompt function instead of get_project_structure.
|
||||
env_lines[#env_lines+1] = context.get_project_prompt(dirs, conf) or ""
|
||||
env_lines[#env_lines+1] = ""
|
||||
env_lines[#env_lines+1] = "# Current Mode"
|
||||
env_lines[#env_lines+1] = "ACT MODE"
|
||||
|
||||
Reference in New Issue
Block a user