feat: add the possibility to also add all files to initial context

This commit is contained in:
2025-02-08 02:21:12 +01:00
parent aa12bca3ab
commit 6723b802bf
3 changed files with 25 additions and 2 deletions

View File

@@ -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