diff --git a/lua/ai.lua b/lua/ai.lua index 12c3845..e059ac8 100644 --- a/lua/ai.lua +++ b/lua/ai.lua @@ -97,16 +97,25 @@ require("codecompanion").setup({ -- List only the two agents below in the adapter picker. opts = { show_presets = false }, + -- Chat agents start in their own auto mode: the agent approves + -- routine actions itself and only asks about risky ones. + -- (Claude falls back to its default if a model lacks auto.) claude_code = function() - return acp.extend("claude_code", {}) + return acp.extend("claude_code", { + defaults = { session_config_options = { mode = "auto" } }, + }) end, - antigravity = function() return antigravity("antigravity") end, + antigravity = function() return antigravity("antigravity", { mode = "auto" }) end, -- Inline edits: Gemini 4 Hydrogen at high effort. A separate -- adapter because inline can only pin a model, not effort, and -- setting effort on `antigravity` would change chats too. Hidden - -- from the `ga` picker below. + -- from the `ga` picker below. No auto mode here on purpose: + -- inline never prompts you anyway (CodeCompanion answers the + -- agent's permission requests itself), and those requests are + -- how it keeps the agent to editing only the buffer copy. An + -- agent in auto mode would skip them. antigravity_inline = function() return antigravity("antigravity_inline", { model = "gemini-4-hydrogen", @@ -122,6 +131,11 @@ require("codecompanion").setup({ interactions = { chat = { adapter = "claude_code", + -- CodeCompanion's own approval layer (`gty` to change per chat). + -- Auto: the agent's reads, searches, edits and fetches go through; + -- shell commands outside tools.run_command.opts.safe_commands + -- (git status, ls, pwd) and anything else (e.g. deletes) still ask. + tools = { opts = { approval_mode = "auto" } }, keymaps = { -- `ga` already switches agent + model; `ge` (normally "end of -- previous word", only overridden in the chat buffer) switches @@ -149,8 +163,12 @@ require("codecompanion").setup({ cli = { agent = "claude_code", agents = { - claude_code = { cmd = "claude", args = {}, description = "Claude Code CLI" }, - antigravity = { cmd = "agy", args = {}, description = "Antigravity CLI" }, + claude_code = { + cmd = "claude", -- must stay "claude" for :CodeCompanionCLI Install hooks + args = { "--permission-mode", "auto" }, + description = "Claude Code CLI", + }, + antigravity = { cmd = "agy", args = { "--mode", "auto" }, description = "Antigravity CLI" }, }, }, },