From 20600e05d5280d419edc4436c326387524b9e728 Mon Sep 17 00:00:00 2001 From: zahid0 Date: Sun, 22 Dec 2024 15:22:12 +0530 Subject: [PATCH] list agents command --- README.md | 5 +++++ doc/gp.nvim.txt | 4 ++++ lua/gp/init.lua | 14 ++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 84aa201..17a24da 100644 --- a/README.md +++ b/README.md @@ -369,6 +369,11 @@ Displays currently used agents for chat and command instructions. Choose a new agent based on its name, listing options based on the current buffer (chat agents if current buffer is a chat and command agents otherwise). The agent setting is persisted on disk across Neovim instances. +#### `:GpListAgents` + +Lists all available agents. + + ## Image commands #### `:GpImage` diff --git a/doc/gp.nvim.txt b/doc/gp.nvim.txt index 81d7c6e..4b1fb65 100644 --- a/doc/gp.nvim.txt +++ b/doc/gp.nvim.txt @@ -483,6 +483,10 @@ buffer (chat agents if current buffer is a chat and command agents otherwise). The agent setting is persisted on disk across Neovim instances. +:GpListAgents *:GpListAgents* + +Lists all available agents. + IMAGE COMMANDS *gp.nvim-image-commands* diff --git a/lua/gp/init.lua b/lua/gp/init.lua index 128914c..8eb7182 100644 --- a/lua/gp/init.lua +++ b/lua/gp/init.lua @@ -1513,6 +1513,20 @@ M.cmd.Agent = function(params) end end +M.cmd.ListAgents = function() + local messages = { "List of available agents (* - Chat Agent, # - Command Agent):" } + for name, agent in pairs(M.agents) do + if name == M._state.chat_agent then + table.insert(messages, "* " .. name) + elseif name == M._state.command_agent then + table.insert(messages, "# " .. name) + else + table.insert(messages, "- " .. name) + end + end + M.logger.info(table.concat(messages, "\n")) +end + M.cmd.NextAgent = function() local buf = vim.api.nvim_get_current_buf() local file_name = vim.api.nvim_buf_get_name(buf)