Privacy: pieces of other open files with a suggestion, and the names of other open files with a
message, now come only from files inside the working directory, never from a file that looks
like it holds secrets (one table, tests/rules/private_files.json, which the VS Code extension
reads too), and never from one the project's .gitignore leaves out. In a file that looks secret
no suggestion is asked for; said once. :help llembas-privacy says what is and is not sent.
- require("llembas").cli(): the one function that decides where the LLeMbas CLI is (PATH, then
~/.local/bin); LLeMbas IDE and its launcher follow it.
- A late answer from an agent that was replaced (:LLeMbasNew!, :LLeMbasRestart) no longer ends
the new turn.
- :LLeMbasOpen judges a file by its first bytes and its name (llembas.shown), as VS Code does.
- The existing sign-in is read by whole lines; an address that reads as an option is refused.
- A protocol line over the limit is dropped whole, not the message after it; a notification
that fails is noted in :LLeMbasLog.
- After :cd the remembered settings of the new directory hold.
- Versions: "1.2.3junk" is no version, as in VS Code.
- tests/rules/: versions, private files, server addresses, sign-in lines, protocol lines and
openable files, as data both editors' suites read (scripts/test-nvim.sh rules).
- The stand-in agent answers _lembas/session/delete as the CLI does ({deleted}, no notification
on serve --stdio).
- Texts: one sentence for "still working" and one for "this CLI is too old"; plain words in
:LLeMbasStatus and the length presets; the help card is "LLeMbas — commands and keys".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
90 lines
6.8 KiB
Lua
90 lines
6.8 KiB
Lua
if vim.g.loaded_llembas then return end
|
|
vim.g.loaded_llembas = true
|
|
if vim.fn.has("nvim-0.10") == 0 then
|
|
vim.notify("LLeMbas needs Neovim 0.10 or newer", vim.log.levels.WARN)
|
|
return
|
|
end
|
|
|
|
local function L() return require("llembas") end
|
|
local cmd = vim.api.nvim_create_user_command
|
|
|
|
cmd("LLeMbas", function() L().toggle() end, { desc = "LLeMbas: open or close the chat panel" })
|
|
cmd("LLeMbasAsk", function(o) L().ask(o.line1, o.line2, o.args) end,
|
|
{ range = true, nargs = "*", desc = "LLeMbas: ask about the selected lines" })
|
|
cmd("LLeMbasEdit", function(o) L().edit(o.line1, o.line2, o.args) end,
|
|
{ range = true, nargs = "*", desc = "LLeMbas: have the selected lines rewritten" })
|
|
cmd("LLeMbasGenerate", function(o) L().generate(o.args) end,
|
|
{ nargs = "*", desc = "LLeMbas: generate code at the cursor" })
|
|
cmd("LLeMbasCancelEdit", function() require("llembas.diff").cancel() end,
|
|
{ desc = "LLeMbas: cancel an in-flight rewrite or generation" })
|
|
cmd("LLeMbasStop", function() L().stop() end, { desc = "LLeMbas: stop the running turn" })
|
|
cmd("LLeMbasNew", function(o) L().new(o.bang) end, { bang = true, desc = "LLeMbas: start a new session (! also while a turn hangs)" })
|
|
cmd("LLeMbasCompact", function() L().compact() end, { desc = "LLeMbas: compact session context" })
|
|
cmd("LLeMbasMode", function(o) L().mode(o.args) end,
|
|
{ nargs = "?", complete = function() return L().mode_ids() end, desc = "LLeMbas: change the mode" })
|
|
cmd("LLeMbasModel", function(o) L().model(o.args) end, { nargs = "?", desc = "LLeMbas: show or change the model" })
|
|
cmd("LLeMbasAccept", function(o) require("llembas.diff").accept(o.bang) end, { bang = true, desc = "LLeMbas: accept the change under the cursor (! all)" })
|
|
cmd("LLeMbasReject", function(o) require("llembas.diff").reject(o.bang) end, { bang = true, desc = "LLeMbas: reject the change under the cursor (! all)" })
|
|
cmd("LLeMbasNextHunk", function() require("llembas.diff").next_hunk() end, { desc = "LLeMbas: jump to next proposed change" })
|
|
cmd("LLeMbasPrevHunk", function() require("llembas.diff").prev_hunk() end, { desc = "LLeMbas: jump to previous proposed change" })
|
|
local function on_off(arg) if arg == "on" then return true elseif arg == "off" then return false end end
|
|
local function on_off_words() return { "on", "off" } end
|
|
cmd("LLeMbasAutocomplete", function(o) L().autocomplete(on_off(o.args)) end,
|
|
{ nargs = "?", complete = on_off_words, desc = "LLeMbas: suggestions as you type on or off" })
|
|
cmd("LLeMbasAI", function(o) L().ai(on_off(o.args)) end,
|
|
{ nargs = "?", complete = on_off_words, desc = "LLeMbas: everything of LLeMbas on or off (off: a plain editor)" })
|
|
cmd("LLeMbasEffort", function(o) L().effort(o.args) end,
|
|
{ nargs = "?", complete = function() return L().EFFORTS end, desc = "LLeMbas: the effort of the conversation" })
|
|
cmd("LLeMbasPrompt", function(o)
|
|
local intent = o.args ~= "" and o.args or nil
|
|
if o.range > 0 then L().prompt({ intent = intent, first = o.line1, last = o.line2 }) else L().prompt({ intent = intent }) end
|
|
end, { range = true, nargs = "?", complete = function() return { "ask", "rewrite", "add" } end,
|
|
desc = "LLeMbas: to the prompt with the lines or the cursor's line (ask, rewrite or add)" })
|
|
cmd("LLeMbasMenu", function() L().menu() end, { desc = "LLeMbas: every command and every setting" })
|
|
cmd("LLeMbasTree", function() require("llembas.layout").toggle("tree") end, { desc = "LLeMbas: the file tree, show and hide" })
|
|
cmd("LLeMbasBars", function(o)
|
|
local layout = require("llembas.layout")
|
|
local a = o.fargs
|
|
if #a == 0 then return L().setup({ bars = not layout.options().on and true or false }) end
|
|
if a[1] == "on" or a[1] == "off" then return L().setup({ bars = a[1] == "on" }) end
|
|
layout.toggle(a[1], on_off(a[2]))
|
|
end, { nargs = "*", complete = function() return { "on", "off", "top", "bottom", "tree", "chat" } end,
|
|
desc = "LLeMbas: the four bars on or off, or one of them (top, bottom, tree, chat) [on|off]" })
|
|
cmd("LLeMbasAutocompleteTokens", function(o) L().autocomplete_tokens(o.args) end,
|
|
{ nargs = "?", complete = function() return { "auto", "words", "line", "block", "file", "24", "64", "256", "1024", "2048" } end,
|
|
desc = "LLeMbas: set autocomplete max tokens or prediction length preset" })
|
|
cmd("LLeMbasAutocompleteInstructions", function(o) L().autocomplete_instructions(o.args) end,
|
|
{ nargs = "*", desc = "LLeMbas: set custom instructions for autocomplete (- clears)" })
|
|
cmd("LLeMbasAutocompleteModel", function(o) L().autocomplete_model(o.args, o.bang) end,
|
|
{ nargs = "?", bang = true, desc = "LLeMbas: the autocomplete model (! for this editor only, - for the default)" })
|
|
cmd("LLeMbasMainModel", function(o) L().main_model(o.args) end,
|
|
{ nargs = "?", desc = "LLeMbas: the model for chat and rewriting, saved in your account (? shows both)" })
|
|
cmd("LLeMbasOpen", function() L().open_shown() end, { desc = "LLeMbas: open the file the agent showed last" })
|
|
cmd("LLeMbasFiles", function(o) L().files(o.args, o.bang) end,
|
|
{ nargs = "?", bang = true, desc = "LLeMbas: search project files and attach @path (! opens file in editor)" })
|
|
cmd("LLeMbasOpenFile", function(o) L().files(o.args, true) end,
|
|
{ nargs = "?", desc = "LLeMbas: open a file of this project" })
|
|
cmd("LLeMbasCommands", function() L().commands() end, { desc = "LLeMbas: pick a /command or skill" })
|
|
cmd("LLeMbasSessions", function() L().sessions() end, { desc = "LLeMbas: list and resume a previous session" })
|
|
cmd("LLeMbasExplain", function(o) L().explain(o.line1, o.line2) end,
|
|
{ range = true, desc = "LLeMbas: explain the selected lines" })
|
|
cmd("LLeMbasFix", function() L().fix() end, { desc = "LLeMbas: fix diagnostics in the current buffer" })
|
|
cmd("LLeMbasToggleThoughts", function() L().toggle_thoughts() end, { desc = "LLeMbas: toggle showing model thinking" })
|
|
cmd("LLeMbasStatus", function() L().status_popup() end, { desc = "LLeMbas: show agent, session and autocomplete status" })
|
|
cmd("LLeMbasLogin", function(o)
|
|
local address, ca = nil, nil
|
|
local args = o.fargs
|
|
local i = 1
|
|
while i <= #args do
|
|
if args[i] == "--ca" then ca = args[i + 1]; i = i + 2 else address = address or args[i]; i = i + 1 end
|
|
end
|
|
require("llembas.login").login(address, ca)
|
|
end, { nargs = "*", desc = "LLeMbas: sign this computer in to a LLeMbas server ([address] [--ca file])" })
|
|
cmd("LLeMbasLoginCancel", function()
|
|
if not require("llembas.login").cancel() then vim.notify("LLeMbas: no sign-in is under way", vim.log.levels.INFO) end
|
|
end, { desc = "LLeMbas: stop a sign-in that is waiting to be approved" })
|
|
cmd("LLeMbasLogout", function() require("llembas.login").logout() end, { desc = "LLeMbas: sign this computer out of its LLeMbas server" })
|
|
cmd("LLeMbasRestart", function() L().restart() end, { desc = "LLeMbas: stop the agent (it starts again when needed)" })
|
|
cmd("LLeMbasLog", function() L().log() end, { desc = "LLeMbas: show what the agent wrote on stderr" })
|
|
cmd("LLeMbasHelp", function() L().help() end, { desc = "LLeMbas: show commands and keymaps" })
|