One table of keys binds every action in two forms (the terminal's chords, and keys that always arrive), and the bottom bar shows the form that works for the bar that has the focus. The prompt says what Enter will do (ask, rewrite, add; Tab switches in an empty prompt) and carries the selection or the cursor's line as its attachment. Mode, effort, suggestions, AI on or off and the bars are remembered per directory with a machine-wide default. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
73 lines
3.1 KiB
Lua
73 lines
3.1 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)
|
|
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)
|