feat: load templates from cache and project directories (#2126)

This commit is contained in:
kyrisu
2025-06-03 20:24:53 +01:00
committed by GitHub
parent 1eaf2d50de
commit 4495ee6bcf
3 changed files with 44 additions and 11 deletions

View File

@@ -145,7 +145,7 @@ function M.generate_prompts(opts)
end
local project_root = Utils.root.get()
Path.prompts.initialize(Path.prompts.get_templates_dir(project_root))
Path.prompts.initialize(Path.prompts.get_templates_dir(project_root), project_root)
local tool_id_to_tool_name = {}
local tool_id_to_path = {}

View File

@@ -167,7 +167,7 @@ function Prompt.get_custom_prompts_filepath(mode) return string.format("custom.%
function Prompt.get_builtin_prompts_filepath(mode) return string.format("%s.avanterules", mode) end
---@class AvanteTemplates
---@field initialize fun(directory: string): nil
---@field initialize fun(cache_directory: string, project_directory: string): nil
---@field render fun(template: string, context: AvanteTemplateOptions): string
local _templates_lib = nil
@@ -244,7 +244,9 @@ function Prompt.render_mode(mode, opts)
return _templates_lib.render(filepath, opts)
end
function Prompt.initialize(directory) _templates_lib.initialize(directory) end
function Prompt.initialize(cache_directory, project_directory)
_templates_lib.initialize(cache_directory, project_directory)
end
P.prompts = Prompt