feat: make initial promt additionally to initial blocks

This commit is contained in:
2024-12-21 11:43:35 +01:00
parent b35860114d
commit f0a5be81bd

View File

@@ -25,11 +25,11 @@ local prompt_blocks = {
Additionally if presented you could also ask for files of a library which is provided in for example composer.json.
2. If file contents is needed provide a yaml which asks for the file contents.
For example:
project_name: example_project
project_name: example_project
files:
- path: "relative/path/to/file"
3. If more information or context is needed, ask the user (outside of the YAML) to provide that. For example:
4. When all necessary information is gathered, provide the final YAML with the
4. When all necessary information is gathered, provide the final YAML with the
project's name and a list of files to be created or modified.
Also explain the changes you made below the yaml.
@@ -119,6 +119,7 @@ function M.load()
config.initial_prompt = "You are a coding assistant who receives a project's context and user instructions. You will guide the user through a workflow:\n1. First, ask the user which files are needed from the project to understand and perform the coding task.\n2. If more information or context is needed, ask for it outside of the YAML.\n3. Once all information is obtained, return the final YAML with the project_name and the files to be created/modified or deleted.\n\nThe final YAML must have:\nproject_name: <project_name>\nfiles:\n - path: \"relative/path/to/file\"\n content: |\n <file content>\n - path: \"relative/path/to/other_file\"\n delete: true\n\nIf more context is needed at any step before providing the final YAML, request it outside of the YAML."
end
-- Merge the default prompt blocks with the config's initial prompt
if type(config.default_prompt_blocks) == "table" and #config.default_prompt_blocks > 0 then
local merged_prompt = {}
for _, block_name in ipairs(config.default_prompt_blocks) do
@@ -127,7 +128,13 @@ function M.load()
end
end
if #merged_prompt > 0 then
config.initial_prompt = table.concat(merged_prompt, "\n\n")
local combined_blocks = table.concat(merged_prompt, "\n\n")
-- We now *append* or combine the existing initial_prompt with the default blocks
if config.initial_prompt ~= "" then
config.initial_prompt = config.initial_prompt .. "\n\n" .. combined_blocks
else
config.initial_prompt = combined_blocks
end
end
end