Public Access
polish the codecompanion look, review inline diffs, inline effort medium
Chat: markdown rendered by render-markdown.nvim (chat buffer only, not markdown files), `## You` / `## Claude Code` headers as tinted bars, upright code, no line numbers. Winbar shows icon, title and agent · model · effort, with a spinner and timer while the agent works; a lualine extension shows context items and tokens. Highlights live in lua/ai_ui.lua and follow gruvbox's light/dark switch. Inline: the progress float is now a pill with per-part colours that shows done/failed/cancelled for a moment; the diff banner is a label. Inline edits always open the diff for review again (approval_mode auto was applying them straight away), and run at medium effort with every agent and model unless an adapter sets its own thought_level. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
056c309bd6
commit
6fcc20b6ff
4 files changed
+470
-69
No files matched your search
+54
-50
@@ -4,12 +4,13 @@
|
||||
-- which reuses the `claude` CLI login.
|
||||
-- antigravity -> `agy acp` (Antigravity CLI: Gemini, plus Claude/GPT-OSS via
|
||||
-- Google). Uses the `agy` Google login.
|
||||
-- Chat uses Claude Code, inline uses Antigravity (Gemini 4 Hydrogen, high).
|
||||
-- Chat uses Claude Code, inline uses Antigravity (Gemini 4 Hydrogen).
|
||||
-- Inline always runs at medium effort, whichever agent/model (see below).
|
||||
-- Agents read their own CLAUDE.md / GEMINI.md / AGENTS.md and settings, so
|
||||
-- model, permissions and MCP servers come from the CLI configs unless pinned
|
||||
-- here (only inline is).
|
||||
-- In a chat: `ga` switches agent/model, `ge` effort, `?` lists all keymaps.
|
||||
-- The winbar shows the current agent · model · effort.
|
||||
-- The winbar shows the current agent · model · effort (see lua/ai_ui.lua).
|
||||
|
||||
-- The ACP module directly: the generic adapters.extend() decides http vs acp
|
||||
-- by looking the name up in the config, and gemini_cli is hidden from it.
|
||||
@@ -55,41 +56,7 @@ local function pick_effort(chat)
|
||||
vim.log.levels.WARN)
|
||||
end
|
||||
|
||||
-- Display name of an ACP chat's current value for an option category, read
|
||||
-- live from the agent connection. (The metadata CodeCompanion hands the
|
||||
-- winbar caches its value->name map before the agent has sent its options,
|
||||
-- so it only has raw ids there, e.g. Claude's model is just "default".)
|
||||
local function acp_option_name(md, category)
|
||||
local bufnr
|
||||
for b, m in pairs(_G.codecompanion_chat_metadata or {}) do
|
||||
if m == md then bufnr = b end
|
||||
end
|
||||
local chat = bufnr and require("codecompanion").buf_get_chat(bufnr)
|
||||
local conn = chat and chat.acp_connection
|
||||
if not conn then return nil end
|
||||
for _, opt in ipairs(conn:get_config_options()) do
|
||||
if opt.category == category and opt.currentValue then
|
||||
for _, item in ipairs(opt.options or {}) do
|
||||
for _, v in ipairs(item.options or { item }) do -- items may be grouped
|
||||
if v.value == opt.currentValue then return v.name end
|
||||
end
|
||||
end
|
||||
return opt.currentValue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Chat winbar: title on the left, `agent · model · effort` on the right.
|
||||
local function chat_winbar(md)
|
||||
local title = (md.title or "CodeCompanion"):gsub("%%", "%%%%")
|
||||
local parts = { md.adapter.name }
|
||||
local model = acp_option_name(md, "model") or md.adapter.model -- HTTP: model id
|
||||
if model then table.insert(parts, model) end
|
||||
local effort = acp_option_name(md, "thought_level")
|
||||
if effort then table.insert(parts, "effort " .. effort:lower()) end
|
||||
local right = table.concat(parts, " · "):gsub("%%", "%%%%")
|
||||
return string.format("%%#CodeCompanionChatHeader# %s%%*%%=%%#Comment#%s ", title, right)
|
||||
end
|
||||
local ui = require("ai_ui") -- look of the chat (lua/ai_ui.lua)
|
||||
|
||||
require("codecompanion").setup({
|
||||
adapters = {
|
||||
@@ -108,19 +75,16 @@ require("codecompanion").setup({
|
||||
|
||||
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. No auto mode here on purpose:
|
||||
-- Inline edits: Gemini 4 Hydrogen. A separate adapter so the
|
||||
-- model pin doesn't change chats. Effort comes from the inline
|
||||
-- default further down (set `thought_level` here to override it).
|
||||
-- Hidden 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",
|
||||
thought_level = "high",
|
||||
})
|
||||
return antigravity("antigravity_inline", { model = "gemini-4-hydrogen" })
|
||||
end,
|
||||
},
|
||||
-- Merged into the default hidden list. All HTTP adapters get hidden
|
||||
@@ -131,6 +95,7 @@ require("codecompanion").setup({
|
||||
interactions = {
|
||||
chat = {
|
||||
adapter = "claude_code",
|
||||
roles = ui.roles, -- `## You` / `## Claude Code` headers
|
||||
-- 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
|
||||
@@ -174,11 +139,11 @@ require("codecompanion").setup({
|
||||
},
|
||||
|
||||
display = {
|
||||
chat = {
|
||||
-- Winbar title, padding instead of line numbers, etc.
|
||||
chat = vim.tbl_deep_extend("force", ui.chat_display, {
|
||||
window = { position = "right", width = 0.4 },
|
||||
-- Winbar instead of a heading in the buffer, so it stays visible.
|
||||
title = { position = "winbar", text = { winbar = chat_winbar } },
|
||||
},
|
||||
}),
|
||||
input = { title = " Inline edit" }, -- `:CodeCompanion` with no prompt
|
||||
},
|
||||
})
|
||||
|
||||
@@ -191,7 +156,46 @@ for name in pairs(http_adapters) do
|
||||
if name ~= "opts" and name ~= "extend" then http_adapters.opts.hidden[name] = true end
|
||||
end
|
||||
|
||||
-- Progress float while an inline edit runs (see lua/ai_status.lua).
|
||||
-- Inline edits always open the diff for review. CodeCompanion decides that
|
||||
-- with the same approval check as chat tools, keyed by the edited buffer, and
|
||||
-- buffers without a mode of their own fall back to approval_mode ("auto"
|
||||
-- above), which would apply the edit straight away. So give each buffer that
|
||||
-- gets an inline edit "ask". Only that check looks at a file buffer's mode
|
||||
-- (chat tools look up the chat's); `g1` (always accept for this buffer) in
|
||||
-- the diff still works. Internal API, fine while pinned to ^20.
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "CodeCompanionInlineStarted",
|
||||
callback = function(ev)
|
||||
require("codecompanion.interactions.chat.tools.approvals"):set_mode(ev.data.bufnr, { mode = "ask" })
|
||||
end,
|
||||
})
|
||||
|
||||
-- Inline edits run at medium effort with every agent and model, including
|
||||
-- ones picked with `ga` in the inline prompt: those come with the chat
|
||||
-- adapter's settings, which leave effort to the agent (and so to whatever the
|
||||
-- CLI was last set to). When CodeCompanion opens an inline session it applies
|
||||
-- the adapter's session_config_options; this adds `thought_level` to them
|
||||
-- unless the adapter sets its own. Chats are untouched (the caller check),
|
||||
-- and a model without a "medium" level keeps its default (logged, no popup).
|
||||
-- Internal API, fine while pinned to ^20.
|
||||
local INLINE_EFFORT = "medium"
|
||||
local acp_defaults = require("codecompanion.interactions.chat.acp.defaults")
|
||||
local apply_defaults = acp_defaults.apply
|
||||
acp_defaults.apply = function(adapter, connection)
|
||||
local caller = debug.getinfo(2, "S").source -- the module opening the session
|
||||
local opts = vim.tbl_get(adapter or {}, "defaults", "session_config_options") or {}
|
||||
if caller:find("/interactions/inline/", 1, true) and opts.thought_level == nil then
|
||||
local defaults = vim.tbl_extend("force", adapter.defaults or {}, {
|
||||
session_config_options = vim.tbl_extend("force", opts, { thought_level = INLINE_EFFORT }),
|
||||
})
|
||||
adapter = setmetatable({ defaults = defaults }, { __index = adapter })
|
||||
end
|
||||
return apply_defaults(adapter, connection)
|
||||
end
|
||||
|
||||
-- Highlights, markdown rendering in the chat, busy spinner in its winbar.
|
||||
ui.setup()
|
||||
-- Progress pill while an inline edit runs (see lua/ai_status.lua).
|
||||
require("ai_status").setup()
|
||||
|
||||
-- Keymaps: everything under <leader>a. Visual-mode maps use `:` rather than
|
||||
|
||||
Reference in new issue
Block a user