feat: event-driven parity, Windows shell detection, dirty build timestamps, and gatekeeper integration
This commit is contained in:
1 parent
64857f9d5e
commit
f4dcf3acbf
33 files changed
+3501
-143
No files matched your search
+85
-4
@@ -1,5 +1,9 @@
|
||||
-- gemini-integration.lua
|
||||
-- Registers the active Neovim instance for the Antigravity MCP Server
|
||||
|
||||
local last_active_task = nil
|
||||
local last_active_gate = nil
|
||||
|
||||
vim.api.nvim_create_autocmd({"VimEnter", "FocusGained", "BufEnter", "BufWritePost"}, {
|
||||
callback = function(ev)
|
||||
-- Only register if Neovim has an active UI attached (ignore headless/embedded instances)
|
||||
@@ -18,7 +22,7 @@ vim.api.nvim_create_autocmd({"VimEnter", "FocusGained", "BufEnter", "BufWritePos
|
||||
end
|
||||
end
|
||||
|
||||
-- 2. V2 Telemetry Push (WebSockets & Cross-OS Sync via Rust Server)
|
||||
-- 2. V2 Telemetry Push (HTTP with Knowledge Projection + UDP Fast Mirror)
|
||||
local file = vim.api.nvim_buf_get_name(0)
|
||||
local cursor = vim.api.nvim_win_get_cursor(0)
|
||||
local row, col = cursor[1], cursor[2]
|
||||
@@ -26,6 +30,7 @@ vim.api.nvim_create_autocmd({"VimEnter", "FocusGained", "BufEnter", "BufWritePos
|
||||
'{"session_id": "%s", "event": "%s", "file": "%s", "line": %d, "col": %d}',
|
||||
server_name:gsub("\\", "\\\\"), ev.event, file:gsub("\\", "\\\\"), row, col
|
||||
)
|
||||
|
||||
local current_buf = ev.buf
|
||||
vim.fn.jobstart({
|
||||
"curl", "-s", "-X", "POST", "http://127.0.0.1:3000/nvim/telemetry",
|
||||
@@ -38,11 +43,16 @@ vim.api.nvim_create_autocmd({"VimEnter", "FocusGained", "BufEnter", "BufWritePos
|
||||
local raw = table.concat(data, "")
|
||||
if raw ~= "" then
|
||||
local ok, resp = pcall(vim.fn.json_decode, raw)
|
||||
if ok and resp and (resp.tech_debts or resp.adrs) then
|
||||
if ok and resp then
|
||||
vim.schedule(function()
|
||||
if _G.gemini and _G.gemini.project_knowledge then
|
||||
if (resp.tech_debts or resp.adrs) and _G.gemini and _G.gemini.project_knowledge then
|
||||
_G.gemini.project_knowledge(resp.tech_debts, resp.adrs, current_buf)
|
||||
end
|
||||
if _G.gemini and _G.gemini.update_statusline then
|
||||
last_active_task = resp.active_task
|
||||
last_active_gate = resp.active_gate
|
||||
_G.gemini.update_statusline(resp.active_task, resp.active_gate)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
@@ -50,7 +60,6 @@ vim.api.nvim_create_autocmd({"VimEnter", "FocusGained", "BufEnter", "BufWritePos
|
||||
end,
|
||||
})
|
||||
|
||||
-- 3. UDP Mirroring (Native fast sync)
|
||||
local uv = vim.uv or vim.loop
|
||||
local client = uv.new_udp()
|
||||
if client then
|
||||
@@ -64,6 +73,78 @@ vim.api.nvim_create_autocmd({"VimEnter", "FocusGained", "BufEnter", "BufWritePos
|
||||
desc = "Register active Neovim instance for Gemini CLI",
|
||||
})
|
||||
|
||||
-- 3. Push-driven Server-Sent Events (SSE) subscriber (Zero Polling)
|
||||
local sse_job_id = nil
|
||||
|
||||
local function start_sse_subscriber()
|
||||
if sse_job_id then
|
||||
pcall(vim.fn.jobstop, sse_job_id)
|
||||
sse_job_id = nil
|
||||
end
|
||||
|
||||
sse_job_id = vim.fn.jobstart({
|
||||
"curl", "-s", "-N", "http://127.0.0.1:3000/api/events/stream"
|
||||
}, {
|
||||
on_stdout = function(_, data)
|
||||
if not data then return end
|
||||
for _, line in ipairs(data) do
|
||||
if line:match("^data:%s*") then
|
||||
local raw_json = line:gsub("^data:%s*", "")
|
||||
local ok, ev = pcall(vim.fn.json_decode, raw_json)
|
||||
if ok and ev and ev.payload then
|
||||
local topic = ev.topic
|
||||
local payload = ev.payload
|
||||
local changed = false
|
||||
|
||||
if topic == "task:event" then
|
||||
if payload.active_task ~= nil then
|
||||
last_active_task = payload.active_task
|
||||
changed = true
|
||||
elseif payload.status == "in_progress" or payload.status == "active" then
|
||||
last_active_task = payload.title or payload.task_id
|
||||
changed = true
|
||||
elseif payload.status == "completed" or payload.status == "expired" or payload.status == "failed" then
|
||||
if last_active_task == (payload.title or payload.task_id) then
|
||||
last_active_task = nil
|
||||
changed = true
|
||||
end
|
||||
end
|
||||
elseif topic == "gate:event" then
|
||||
if payload.active_gate ~= nil then
|
||||
last_active_gate = payload.active_gate
|
||||
changed = true
|
||||
elseif payload.status then
|
||||
last_active_gate = payload.status
|
||||
changed = true
|
||||
end
|
||||
end
|
||||
|
||||
if changed and _G.gemini and _G.gemini.update_statusline then
|
||||
vim.schedule(function()
|
||||
_G.gemini.update_statusline(last_active_task, last_active_gate)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_exit = function()
|
||||
sse_job_id = nil
|
||||
-- Reconnect after server restart without busy looping
|
||||
vim.defer_fn(function()
|
||||
if #vim.api.nvim_list_uis() > 0 then
|
||||
start_sse_subscriber()
|
||||
end
|
||||
end, 5000)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- Initialize SSE push listener when UI is active
|
||||
if #vim.api.nvim_list_uis() > 0 then
|
||||
start_sse_subscriber()
|
||||
end
|
||||
|
||||
-- Load UI & Keymaps
|
||||
local is_win = vim.fn.has("win32") == 1
|
||||
local ui_path = is_win and "C:/Users/reazul.ashraf/workspace/rust/mcp-memory/gemini-ui.lua" or "/mnt/c/Users/reazul.ashraf/workspace/rust/mcp-memory/gemini-ui.lua"
|
||||
|
||||
Reference in new issue
Block a user