Files
HomerandClaude Opus 5.5 2b1d42b976 Neovim plugin: only project files go along, the shared rules held by shared cases, review fixes
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>
2026-12-03 07:52:14 +00:00

77 lines
3.3 KiB
Lua

-- One start of Neovim with the plugin, for the checks that need a new process: what is remembered
-- from one start to the next, and what is written to the terminal on the way in and out.
-- Run by nvim/tests/layout.lua in the directory under test; $STEP says what to do. The answer is
-- one line on standard output: RESULT {json}. Standard error is left to the plugin alone.
local step = vim.env.STEP or "look"
local repo = assert(vim.env.LLEMBAS_TEST_REPO, "LLEMBAS_TEST_REPO")
local agent = repo .. "/nvim/tests/agent_levels.py"
local function wait(cond, ms) return vim.wait(ms or 8000, cond, 20) end
local function finish(data)
io.stdout:write("RESULT " .. vim.json.encode(data) .. "\n")
pcall(function() require("llembas").restart(true) end)
vim.cmd("qa!")
end
vim.schedule(function()
local ok, err = xpcall(function()
vim.notify = function() end
vim.o.columns, vim.o.lines = 160, 45
vim.g.mapleader = " "
vim.cmd("runtime plugin/llembas.lua")
local L = require("llembas")
if step == "plain" then
L.setup({ cmd = { "python3", agent } })
return finish({ plain = true })
end
L.setup({ cmd = { "python3", agent }, bars = true })
local layout = require("llembas.layout")
local keys = require("llembas.keys")
local chat = require("llembas.chat")
vim.wait(50)
local out = {}
if step == "start" then return finish({ started = true }) end
if step == "chords" then return finish({ chords = keys.chords(), guess = keys._terminal_reports() }) end
if step == "change" then
L.mode("edit")
-- (Until the agent has answered: its event says the new mode before its answer does.)
wait(function() return require("llembas.store").get().mode == "edit" end)
L.effort("high")
wait(function() return L._state.effort == "high" end)
L.autocomplete(false)
layout.toggle("tree", false)
-- The right bar dragged wider: remembered on the way out.
vim.api.nvim_win_set_width(vim.fn.bufwinid(chat.tbuf), 46)
elseif step == "change_b" then
L.mode("plan")
wait(function() return require("llembas.store").get().mode == "plan" end)
elseif step == "session" then
local done = false
L.choices("mode", function() done = true end)
wait(function() return done end)
for _, line in ipairs(vim.fn.readfile(vim.env.FAKE_AGENT_LOG)) do
local m = vim.json.decode(line)
if m.method == "session/new" then out.new_mode, out.new_effort = (m.params._meta or {}).mode, (m.params._meta or {}).effort end
end
elseif step == "default" then
require("llembas.store").make_default()
elseif step == "ai_off" then
L.ai(false)
elseif step == "cd" then
-- Another working directory without a restart: what is remembered there holds.
vim.cmd("cd " .. vim.fn.fnameescape((assert(vim.env.CD_TO, "CD_TO"))))
vim.wait(50)
end
layout.remember_widths()
local s, o = L.settings(), layout.options()
out.mode, out.effort, out.autocomplete, out.ai = s.mode, s.effort, s.autocomplete, s.ai
out.tree, out.chat, out.chat_width, out.tree_width = o.tree, o.chat, o.chat_width, o.tree_width
out.tree_open = require("llembas.tree").is_open()
finish(out)
end, debug.traceback)
if not ok then
io.stdout:write("CHILD FAILED " .. tostring(err) .. "\n")
vim.cmd("cquit!")
end
end)