Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command to list available Agents #237

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` <!-- {doc=:GpListAgents} -->

Lists all available agents.


## Image commands

#### `:GpImage` <!-- {doc=:GpImage} -->
Expand Down
4 changes: 4 additions & 0 deletions doc/gp.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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*


Expand Down
14 changes: 14 additions & 0 deletions lua/gp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down