feat: add agent mode and CoderType command for mode switching

- Add agent module with tool execution support (read_file, edit_file, bash)
- Add agent/ui.lua with chat sidebar, input area, and real-time logs panel
- Add agent/logs.lua for token counting and request/response logging
- Add generate_with_tools to claude.lua and ollama.lua for tool use
- Add chat_switcher.lua modal picker for Ask/Agent mode selection
- Add CoderType command to show mode switcher (replaces C-Tab keymaps)
- Update ask.lua and agent/ui.lua headers to reference :CoderType

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-13 20:45:55 -05:00
parent 9c99944f26
commit 2989fb5f14
13 changed files with 2658 additions and 129 deletions

View File

@@ -50,19 +50,18 @@ local function create_output_buffer()
-- Set initial content
local header = {
"╔═════════════════════════════╗",
"🤖 CODETYPER ASK",
"╠═════════════════════════════╣",
"║ Ask about code or concepts ║",
"║ ║",
"💡 Keymaps:",
"@ → attach file",
"║ C-Enter → send",
"║ C-nnew chat ",
"C-f → add current file",
"C-h/j/k/l → navigate",
"║ q → close │ K/J → jump ║",
"╚═════════════════════════════╝",
"╔═════════════════════════════════",
" [ASK MODE] Q&A Chat",
"╠═════════════════════════════════",
"║ Ask about code or concepts ",
" ",
"@ → attach file",
"C-Enter → send ",
"║ C-n → new chat ",
"║ C-fadd current file",
":CoderType → switch mode ",
"q → close │ K/J → jump ",
"╚═════════════════════════════════╝",
"",
}
vim.api.nvim_buf_set_lines(buf, 0, -1, false, header)
@@ -788,19 +787,18 @@ function M.clear_history()
if state.output_buf and vim.api.nvim_buf_is_valid(state.output_buf) then
local header = {
"╔═══════════════════════════════════",
"🤖 CODETYPER ASK ",
"╠═══════════════════════════════════",
"║ Ask about code or concepts ",
" ",
"💡 Keymaps: ",
"@ → attach file ",
"║ C-Enter → send ",
"║ C-nnew chat ",
"C-f → add current file ",
"C-h/j/k/l → navigate ",
"║ q → close │ K/J → jump ║",
"╚═══════════════════════════════════╝",
"╔═════════════════════════════════╗",
" [ASK MODE] Q&A Chat",
"╠═════════════════════════════════╣",
"║ Ask about code or concepts ║",
"║ ║",
"@ → attach file",
"C-Enter → send",
"║ C-n → new chat",
"║ C-fadd current file",
":CoderType → switch mode",
"q → close │ K/J → jump",
"╚═════════════════════════════════╝",
"",
}
vim.bo[state.output_buf].modifiable = true
@@ -846,6 +844,12 @@ function M.copy_last_response()
end
utils.notify("No response to copy", vim.log.levels.WARN)
end
--- Show chat mode switcher modal
function M.show_chat_switcher()
local switcher = require("codetyper.chat_switcher")
switcher.show()
end
--- Check if ask panel is open (validates window state)
---@return boolean
function M.is_open()