feat(nvim,telemetry): implement ADR-0102 circuit breaker and ADR-0103 knowledge graph projection
This commit is contained in:
1 parent
3d77e60a02
commit
ec977c24dd
7 files changed
+692
-11
No files matched your search
+28
-1
@@ -26,11 +26,38 @@ 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",
|
||||
"-H", "Content-Type: application/json",
|
||||
"-d", payload
|
||||
}, { detach = true })
|
||||
}, {
|
||||
stdout_buffered = true,
|
||||
on_stdout = function(_, data)
|
||||
if data and #data > 0 then
|
||||
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
|
||||
vim.schedule(function()
|
||||
if _G.gemini and _G.gemini.project_knowledge then
|
||||
_G.gemini.project_knowledge(resp.tech_debts, resp.adrs, current_buf)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- 3. UDP Mirroring (Native fast sync)
|
||||
local uv = vim.uv or vim.loop
|
||||
local client = uv.new_udp()
|
||||
if client then
|
||||
client:send(payload, "127.0.0.1", 3002, function(err)
|
||||
client:close()
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
Reference in new issue
Block a user