feature: save prompt history to $HOME/.cache
Feature request
I'd like to request the integration of a logging system for Avante inputs directly into the avante.nvim plugin. This would save user inputs to timestamped log files and provide convenient Telescope integration for browsing and searching through past prompts.
Motivation
I'm currently using a custom solution to log my Avante prompts because I often want to reference or reuse previous prompts I've written. Without logging, these valuable prompts are lost after each session.
Other
If this is something that will benefit many users, i'd be glad to create a PR, since i already created a module that achieves this and would love to see it get into main. Of course, it will be an opt-in feature disabled by default.
Here is an example of my saved prompts:
Can the Avante History Manager(
Hi @yetone, i am not sure what that is supposed to do. Hitting :AvanteHistory pops up this window with a single entry
I understand your needs. Do you want to automatically record your input into the prompts store or selectively record it?
For my use case, automatic is the way to go. I have implemented a POC: https://github.com/hamidi-dev/avante.nvim/commit/d582c544365fcad0bf24e20f418bfd7687cb0d3d
I'd be happy to open a PR for it :)
not sure what to do about the telescope part yet. Whether it should be part of avante.nvim or a separate telescope extension:
-- Telescope utilities
local Path = require("plenary.path")
local scan = require("plenary.scandir")
-- Find Avante log files
vim.keymap.set("n", "<leader>fa", function()
local log_dir = vim.fn.expand("~/.cache/nvim/avante_logs")
local files = scan.scan_dir(log_dir, { hidden = true, depth = 1 })
table.sort(files, function(a, b)
return a > b
end)
require("telescope.pickers").new({}, {
prompt_title = "Avante Logs",
finder = require("telescope.finders").new_table {
results = files,
entry_maker = function(entry)
return {
value = entry,
display = Path:new(entry):make_relative(log_dir),
ordinal = entry,
path = entry,
}
end,
},
previewer = require("telescope.previewers").vim_buffer_cat.new({}),
sorter = require("telescope.config").values.generic_sorter({}),
}):find()
end, { desc = "Find Avante Logs" })
-- Live grep in Avante logs
vim.keymap.set("n", "<leader>fl", function()
require("telescope.builtin").live_grep({
prompt_title = "Grep Avante Logs",
cwd = vim.fn.expand("~/.cache/nvim/avante_logs"),
})
end, { desc = "Grep Avante Logs" })
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.