fix: removing dependency on copilot too expensive

This commit is contained in:
2026-06-06 17:09:17 -04:00
parent 6914bfed15
commit 70d2eb2e65
6 changed files with 206 additions and 179 deletions
+123 -121
View File
@@ -1,5 +1,4 @@
vim.keymap.set({'n', 'v'}, '<leader>mct', '<cmd>CodeCompanionChat Toggle<cr>', { noremap = true, silent = true, desc = "CC Toggle" })
vim.keymap.set({'n', 'v'}, '<leader>mca', '<cmd>CodeCompanionActions<cr>', { noremap = true, silent = true, desc = "CC Action" })
vim.keymap.set({'n', 'v'}, '<leader>mce', '<cmd>CodeCompanion Explain<cr>', { desc = "CC Explain" })
@@ -37,6 +36,17 @@ local function get_abacus_key()
return key
end
local function get_opencode_key()
local ok, res = pcall(vim.fn.systemlist, "pass show opencode-api")
if not ok or not res or vim.tbl_isempty(res) then
return ""
end
-- systemlist returns lines; join and trim whitespace
local key = table.concat(res, "\n")
key = key:gsub("^%s+", ""):gsub("%s+$", "")
return key
end
local function copilot_supports_sampling(self)
local model = self.schema.model.default
if type(model) == "function" then
@@ -79,15 +89,14 @@ codecompanion.setup({
},
})
end,
abacus = function()
opencode_zen = function()
return require("codecompanion.adapters").extend("openai_compatible", {
name = "abacus",
formatted_name = "Abacus.AI",
name = "opencode-zen",
formatted_name = "OpenCode Zen",
env = {
url = "https://routellm.abacus.ai/v1",
-- IMPORTANT: include /v1 in the base url
api_key = get_abacus_key(),
chat_url = "/chat/completions"
url = "https://opencode.ai/zen",
api_key = get_opencode_key(),
chat_url = "/v1/chat/completions",
},
headers = {
["Content-Type"] = "application/json",
@@ -95,107 +104,98 @@ codecompanion.setup({
},
schema = {
model = {
order = 1,
mapping = "parameters",
type = "enum",
desc = "The model to use for chat completions.",
default = "route-llm",
choices = {
-- Routing Model
["route-llm"] = { opts = { desc = "Intelligent routing to best model" } },
-- OpenAI Models
["gpt-5.2"] = { opts = { has_vision = true } },
["gpt-5.1"] = { opts = { has_vision = true } },
["gpt-5.1-chat-latest"] = { opts = { has_vision = true } },
["gpt-5"] = { opts = { has_vision = true } },
["gpt-5-mini"] = { opts = { has_vision = true } },
["gpt-5-nano"] = { opts = { has_vision = true } },
["gpt-4o"] = { opts = { has_vision = true } },
["gpt-4o-mini"] = { opts = { has_vision = true } },
["o4-mini"] = { opts = { can_reason = true } },
["o3"] = { opts = { can_reason = true } },
["o3-pro"] = { opts = { can_reason = true } },
-- Anthropic Models
["claude-4-5-sonnet"] = { opts = { has_vision = true } },
["claude-4-5-haiku"] = { opts = { has_vision = true } },
["claude-4-5-opus"] = { opts = { has_vision = true } },
["claude-3-opus"] = { opts = { has_vision = true } },
-- Google Models
["gemini-3-pro"] = { opts = { has_vision = true } },
["gemini-3-flash"] = { opts = { has_vision = true } },
["gemini-2.5-pro"] = { opts = { has_vision = true } },
["gemini-2.5-flash"] = { opts = { has_vision = true } },
-- xAI Models
["grok-4-1-fast"] = {},
["grok-4"] = {},
["grok-code-fast-1"] = {},
-- Meta Models
["llama-4-Maverick-17B"] = {},
["llama-3.1-405B"] = {},
["llama-3.1-70B"] = {},
-- DeepSeek Models
["deepseek-v3.2"] = {},
["deepseek-v3.1-Terminus"] = {},
["deepseek-R1"] = { opts = { can_reason = true } },
-- Qwen Models
["qwen-3-Max"] = {},
["qwen3-coder-480b-a35b-instruct"] = {},
["qwen-3-32B"] = {},
["qwq-32B"] = { opts = { can_reason = true } },
},
},
temperature = {
order = 2,
mapping = "parameters",
type = "number",
optional = true,
default = 1.0,
desc = "Controls randomness of output (0-2).",
validate = function(n)
return n >= 0 and n <= 2, "Must be between 0 and 2"
end,
},
max_tokens = {
order = 3,
mapping = "parameters",
type = "integer",
optional = true,
default = nil,
desc = "Maximum tokens to generate.",
validate = function(n)
return n > 0, "Must be greater than 0"
end,
},
top_p = {
order = 4,
mapping = "parameters",
type = "number",
optional = true,
default = 1.0,
desc = "Nucleus sampling parameter (0-1).",
validate = function(n)
return n >= 0 and n <= 1, "Must be between 0 and 1"
end,
default = "deepseek-v4-flash-free",
-- choices = {
-- ["minimax-m3-free"] = { opts = { has_vision = true, can_reason = true } },
-- ["big-pickle"] = { opts = { has_vision = true, can_reason = true } },
-- ["mini-v2.5-free"] = { opts = { has_vision = true, can_reason = true } },
-- ["nemotron-3-super-free"] = { opts = { has_vision = true, can_reason = true } },
-- ["nemotron-3-ultra-free"] = { opts = { has_vision = true, can_reason = true } },
-- ["deepseek-v4-flash-free"] = { opts = { has_vision = true, can_reason = true } },
-- ["qwen-3.6-plus-free"] = { opts = { has_vision = true, can_reason = true } },
-- },
},
},
})
end,
ollama = function()
local ollama_url = os.getenv("OLLAMA_URL") or "http://192.168.33.74:11434"
opencode_go_anthropic = function()
return require("codecompanion.adapters").extend("anthropic", {
name = "opencode-go-anthropic",
formatted_name = "OpenCode Go Anthropic",
env = {
url = "https://opencode.ai/zen/go",
api_key = get_opencode_key(),
},
headers = {
["x-api-key"] = "${api_key}",
["anthropic-version"] = "2023-06-01",
["content-type"] = "application/json",
},
schema = {
model = {
default = "minimax-m3",
},
},
})
end,
opencode_go = function()
return require("codecompanion.adapters").extend("openai_compatible", {
name = "opencode-go",
formatted_name = "OpenCode Go",
env = {
url = "https://opencode.ai/zen/go",
api_key = get_opencode_key(),
chat_url = "/v1/chat/completions",
},
headers = {
["Content-Type"] = "application/json",
["Authorization"] = "Bearer ${api_key}",
},
schema = {
model = {
default = "mimo-v2.5-pro",
-- choices = {
-- ["minimax-m3"] = { opts = { has_vision = true, can_reason = true } },
-- ["minimax-m2.7"] = { opts = { has_vision = true, can_reason = true } },
-- ["mini-v2.5-pro"] = { opts = { has_vision = true, can_reason = true } },
-- ["mini-v2.5"] = { opts = { has_vision = true, can_reason = true } },
-- ["mimo-v2.5-pro"] = { opts = { has_vision = true, can_reason = true } },
-- ["mimo-v2.5"] = { opts = { has_vision = true, can_reason = true } },
-- ["kimi-k2.6"] = { opts = { has_vision = true, can_reason = true } },
-- ["kimi-k2.5"] = { opts = { has_vision = true, can_reason = true } },
-- ["glm-5.1"] = { opts = { has_vision = true, can_reason = true } },
-- ["deepseek-v4-flash"] = { opts = { has_vision = true, can_reason = true } },
-- ["deepseek-v4-pro"] = { opts = { has_vision = true, can_reason = true } },
-- ["qwen-3.7-plus"] = { opts = { has_vision = true, can_reason = true } },
-- ["qwen-3.7-max"] = { opts = { has_vision = true, can_reason = true } },
-- ["hy3-preview"] = { opts = { has_vision = true, can_reason = true } },
-- },
},
},
})
end,
allears = function()
local ollama_url = os.getenv("ALLEARS_OLLAMA_URL") or "http://192.168.33.74:11434"
return require("codecompanion.adapters").extend("ollama", {
env = {
url = ollama_url,
},
schema = {
model = {
default = "qwen3.5",
default = "qwen3.6",
},
},
})
end,
sagacity = function()
local ollama_url = os.getenv("SAGACITY_OLLAMA_URL") or "http://172.25.11.30"
return require("codecompanion.adapters").extend("ollama", {
env = {
url = ollama_url,
},
schema = {
model = {
default = "qwen3.6",
},
},
})
@@ -265,6 +265,7 @@ codecompanion.setup({
-- end,
},
},
ghost_text = { enabled = false },
rules = {
opts = {
chat = {
@@ -305,8 +306,8 @@ codecompanion.setup({
picker = "snacks",
dir_to_save = vim.env.HOME .. "/Documents/ai-history",
title_generation_opts = {
adapter = "copilot",
model = "gpt-5-mini",
adapter = "opencode_zen",
model = "big-pickle",
},
summary = {
create_summary_keymap = "ghc",
@@ -556,18 +557,19 @@ codecompanion.setup({
},
-- adapter = { name = "abacus", model = "route-llm" },
-- adapter = { name = "opencode", model = "github-copilot/gpt-5.2-codex" },
adapter = { name = "copilot", model = "gpt-5-mini" },
-- adapter = { name = "copilot", model = "gpt-5-mini" },
-- adapter = { name = "goose" },
adapter = { name = "opencode_go", model = "mimo-v2.5-pro" },
},
inline = {
-- adapter = { name = "abacus", model = "route-llm" },
adapter = { name = "copilot", model = "gpt-5.1-codex-mini" },
adapter = { name = "opencode_zen", model = "deepseek-v4-flash-free" },
},
cmd = {
adapter = { name = "copilot", model = "gpt-5-mini" },
adapter = { name = "opencode_zen", model = "mimo-v2.5-free" },
},
background = {
adapter = { name = "copilot", model = "gpt-5-mini" },
adapter = { name = "opencode_zen", model = "mimo-v2.5-free" },
},
},
prompt_library = {
@@ -583,10 +585,10 @@ codecompanion.setup({
opts = {
mapping = "<LocalLeader>rpc",
modes = { "v" },
adapter = {
name = "copilot",
model = "chatgpt-5.3-codex",
},
-- adapter = {
-- name = "copilot",
-- model = "chatgpt-5.3-codex",
-- },
},
prompts = {
{
@@ -610,10 +612,10 @@ codecompanion.setup({
opts = {
mapping = "<LocalLeader>rpo",
modes = { "v" },
adapter = {
name = "copilot",
model = "chatgpt-5.3-codex",
},
-- adapter = {
-- name = "copilot",
-- model = "chatgpt-5.3-codex",
-- },
},
prompts = {
{
@@ -637,10 +639,10 @@ codecompanion.setup({
mapping = "<LocalLeader>rpd",
modes = { "v" },
adapter = {
name = "copilot",
model = "chatgpt-5.3-codex",
},
-- adapter = {
-- name = "copilot",
-- model = "chatgpt-5.3-codex",
-- },
},
prompts = {
{
@@ -682,10 +684,10 @@ codecompanion.setup({
mapping = "<LocalLeader>rpa",
modes = { "v" },
adapter = {
name = "copilot",
model = "chatgpt-5.4",
},
-- adapter = {
-- name = "copilot",
-- model = "chatgpt-5.4",
-- },
},
prompts = {
{