feat(nvim): bake in strict interactive AST blocks for win-nvim to prevent headless deadlock

This commit is contained in:
Riz Ashraf committed 2026-09-21 15:59:49 +01:00
1 parent 1f40e6d32b
commit 891bd481b9
2 files changed
+75

No files matched your search

+13
View File
@@ -990,6 +990,18 @@ pub async fn run_mcp_loop(app_name: &str, app_version: &str) {
"nvim_execute_lua" => {
if let Some(code) = args.get("code").and_then(|v| v.as_str()) {
// BAKE IN: Block interactive prompts that cause server deadlocks
let lower_code = code.to_lowercase();
if lower_code.contains("vim.fn.input") || lower_code.contains("vim.ui.select") || lower_code.contains("vim.fn.confirm") || lower_code.contains("vim.ui.input") {
send_error(id, -32600, "CRITICAL ERROR: Interactive Lua functions (input, select, confirm) are strictly forbidden via MCP as they will hang the headless server.").await;
return;
}
// Block the 'c' confirm flag in vim.cmd substitutions
if (code.contains("vim.cmd") || code.contains("vim.api.nvim_command")) && code.contains("%s") && (code.contains("gc'") || code.contains("gc\"") || code.contains("gc\n") || code.contains("c'") || code.contains("c\"")) {
send_error(id, -32600, "CRITICAL ERROR: The 'c' (confirm) flag in Neovim substitutions is strictly forbidden via MCP as it triggers an interactive prompt that hangs the headless server. Use '/g' or '/ge' instead.").await;
return;
}
match execute_nvim_lua(code).await {
Ok(result) => {
send_text_result!(id.clone(), result);
@@ -1108,3 +1120,4 @@ mod tests {