avante.nvim icon indicating copy to clipboard operation
avante.nvim copied to clipboard

feature: save prompt history to $HOME/.cache

Open hamidi-dev opened this issue 7 months ago • 5 comments

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:

Image

hamidi-dev avatar May 16 '25 15:05 hamidi-dev

Can the Avante History Manager(ah) meet your needs?

yetone avatar May 17 '25 15:05 yetone

Hi @yetone, i am not sure what that is supposed to do. Hitting :AvanteHistory pops up this window with a single entry

Image when i choose it, it just opens the sidebar. What i am after is some way to save my prompts to disk and have a convenient way to telescope.find_file and telescope.live_grep through them. Sometimes for whatever reason when i send a prompt through avante, something goes wrong. On reopening avante, i dont find my last prompt. Then i have to retype the prompt.

hamidi-dev avatar May 17 '25 15:05 hamidi-dev

‌‌‌‌I understand your needs. Do you want to automatically record your input into the prompts store or selectively record it?

yetone avatar May 18 '25 05:05 yetone

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 :)

hamidi-dev avatar May 18 '25 09:05 hamidi-dev

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" })

hamidi-dev avatar May 18 '25 09:05 hamidi-dev

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.

github-actions[bot] avatar Jun 18 '25 02:06 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Jun 23 '25 02:06 github-actions[bot]