feat: add Neovim agent review workflow

This commit is contained in:
kiri committed 2026-09-10 10:38:36 +02:00
1 parent 3bfb233614
commit 81dc673ac2
4 files changed
+81

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
-- Run with the configured Neovim, using the same headless invocation as neovim-ergonomics.lua.
assert(package.loaded["diffview"] == nil, "Diffview should load on demand")
vim.cmd("doautocmd VimEnter")
local root = vim.fn.tempname() .. " review"
vim.fn.mkdir(root, "p")
local function git(...)
local result = vim.system({ "git", "-C", root, ... }, { text = true }):wait()
assert(result.code == 0, result.stderr)
end
local file = root .. "/tracked.txt"
git("init", "--quiet")
vim.fn.writefile({ "original" }, file)
git("add", ".")
git("-c", "user.name=Review Test", "-c", "[email protected]", "commit", "--quiet", "-m", "Baseline")
vim.cmd.edit(vim.fn.fnameescape(file))
assert(
vim.wait(5000, function()
return vim.fn.maparg(" gs", "n") ~= ""
end),
"Gitsigns should attach to the tracked file"
)
vim.fn.writefile({ "staged change" }, file)
git("add", "tracked.txt")
vim.fn.writefile({ "unstaged change after staging" }, file)
vim.fn.writefile({ "new file" }, root .. "/untracked.txt")
vim.api.nvim_exec_autocmds("FocusGained", { modeline = false })
vim.api.nvim_feedkeys(" gd", "xt", false)
assert(package.loaded["diffview"] ~= nil, "Review shortcut should load Diffview")
local view = require("diffview.lib").get_current_view()
assert(view, "Review shortcut should open a view even when cwd is outside the repository")
assert(
vim.wait(5000, function()
return #view.files.working == 2 and #view.files.staged == 1 and view.cur_entry and view.cur_entry.opened
end),
"Review should include the tracked and untracked files"
)
local refreshed = false
view.emitter:on("file_open_post", function()
refreshed = true
end)
vim.cmd("DiffviewRefresh")
assert(
vim.wait(5000, function()
return refreshed
end),
"Refresh should finish before closing the view"
)
vim.cmd("DiffviewClose")
assert(require("diffview.lib").get_current_view() == nil)
vim.cmd("%bwipeout!")
vim.fn.delete(root, "rf")
print("Neovim agent review smoke check passed")