-- 1) Determine the Git root based on the currently opened file.
-- 1) Determine the Git root based on the currently opened file.
-- 2) If no file is open or not in Git repo, fallback to current working directory.
-- 2) If no file is open or not in Git repo, fallback to current working directory.
-- 3) Add support for configuring a list of default prompt blocks ("go-development", "typo3-development", "basic-prompt") that can override the initial prompt if provided.
localM={}
localM={}
localuv=vim.loop
localuv=vim.loop
@@ -25,7 +26,6 @@ local function get_project_root()
root_dir=vim.fn.getcwd()
root_dir=vim.fn.getcwd()
else
else
-- Attempt to find git root from the file's directory
-- Attempt to find git root from the file's directory
-- We run git rev-parse with `cd` to the file's directory.
@@ -45,34 +45,58 @@ local function get_config_path()
returnroot.."/.chatgpt_config.yaml"
returnroot.."/.chatgpt_config.yaml"
end
end
localprompt_blocks={
["go-development"]="You are a coding assistant specialized in Go development. You will receive a project’s context and user instructions related to Go code, and you must return the requested modifications or guidance. When returning modifications, follow the specified YAML structure. Keep your suggestions aligned with Go best practices and idiomatic Go.",
["typo3-development"]="You are a coding assistant specialized in TYPO3 development. You have access to the project’s context and the user’s instructions. Your answers should focus on TYPO3 coding guidelines, extension development best practices, and TSconfig or TypoScript recommendations. When returning modifications, follow the YAML structure given.",
["basic-prompt"]="You are a coding assistant who receives a project’s context and user instructions. The user will provide a prompt, and you will return modifications to the project in a YAML structure. The YAML must have a top-level key named files, which should be a list of file changes. Each element in files must be a mapping with the keys path and content. The path should be the file path relative to the project’s root directory, and content should contain the new file content as a multiline string. Do not include additional commentary outside of the YAML."
initial_prompt="You are a coding assistant who receives a project’s context and user instructions. The user will provide a prompt, and you will return modifications to the project in a YAML structure. This YAML must have a top-level key named files, which should be a list of file changes. Each element in files must be a mapping with the keys path and content. The path should be the file path relative to the project’s root directory, and content should contain the new file content as a multiline string (using the YAML | literal style). Do not include additional commentary outside of the YAML.\n Here is the structure expected in your final answer:\n files:\n - path: \"relative/path/to/file1.ext\"\n content: |\n <full file content here>\n - path: \"relative/path/to/file2.ext\"\n content: |\n <full file content here>\n Based on the prompt and project context provided, you must only return the YAML structure shown above (with actual file paths and contents substituted in). Any file that should be created or modified must appear as one of the files entries. The content should contain the complete and final code for that file, reflecting all changes requested by the user.",
-- Default fallback configuration
directories={"."},
config.initial_prompt="You are a coding assistant who receives a project’s context and user instructions. The user will provide a prompt, and you will return modifications to the project in a YAML structure. This YAML must have a top-level key named files, which should be a list of file changes. Each element in files must be a mapping with the keys path and content. The path should be the file path relative to the project’s root directory, and content should contain the new file content as a multiline string (using the YAML | literal style). Do not include additional commentary outside of the YAML.\n Here is the structure expected in your final answer:\n files:\n - path: \"relative/path/to/file1.ext\"\n content: |\n <full file content here>\n - path: \"relative/path/to/file2.ext\"\n content: |\n <full file content here>\n Based on the prompt and project context provided, you must only return the YAML structure shown above (with actual file paths and contents substituted in). Any file that should be created or modified must appear as one of the files entries. The content should contain the complete and final code for that file, reflecting all changes requested by the user."
}
end
-- If default_prompt_blocks are specified, concatenate all matching prompts
-- Make the prompt more readable for the O1 model:
-- 1. Include initial prompt and user input at the start.
-- 2. Provide a clear project structure section.
-- 3. Clearly label the files section.
-- 4. The file_sections already include <<<CGPT Current File blocks for each file,
-- we just need to ensure there's a clear intro.
localsections={
localsections={
conf.initial_prompt.."\n"..user_input,
conf.initial_prompt.."\n"..user_input,
"\n\nProject Structure:\n",
"\n\nProject Structure:\n",
project_structure,
project_structure,
"\n\nBelow are the files from the project, each enclosed in <<<CGPT Current File ... >>> blocks for clarity.\n"
"\n\nBelow are the files from the project, each preceded by its filename in backticks and enclosed in triple backticks.\n"
}
}
table.insert(sections,file_sections)
table.insert(sections,file_sections)
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.