Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
917a9058f9 | ||
|
|
efcab4a7b4 | ||
|
|
b8d58b2e64 |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
-- gemini-integration.lua
|
||||
-- Registers the active Neovim instance for the Antigravity MCP Server
|
||||
vim.api.nvim_create_autocmd({"VimEnter", "FocusGained", "BufEnter"}, {
|
||||
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)
|
||||
if #vim.api.nvim_list_uis() > 0 then
|
||||
@@ -38,6 +38,8 @@ vim.api.nvim_create_autocmd({"VimEnter", "FocusGained", "BufEnter"}, {
|
||||
})
|
||||
|
||||
-- Load UI & Keymaps
|
||||
local ui = dofile("C:/Users/reazul.ashraf/workspace/rust/mcp-memory/gemini-ui.lua")
|
||||
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"
|
||||
local ui = dofile(ui_path)
|
||||
ui.setup()
|
||||
_G.gemini = ui -- Expose globally so Agent can call it via execute_lua
|
||||
@@ -17,4 +17,6 @@ fn main() {
|
||||
|
||||
let version = format!("{} ({})", git_date.trim(), git_hash.trim());
|
||||
println!("cargo:rustc-env=APP_VERSION={version}");
|
||||
println!("cargo:rerun-if-changed=../.git/HEAD");
|
||||
println!("cargo:rerun-if-changed=../.git/index");
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
use crate::AppState;
|
||||
use axum::extract::{Query, State};
|
||||
use axum::response::IntoResponse;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use crate::state::GenericEvent;
|
||||
|
||||
pub async fn wait_for_event_handler(
|
||||
State(state): State<Arc<AppState>>,
|
||||
Query(params): Query<HashMap<String, String>>,
|
||||
) -> impl IntoResponse {
|
||||
let topic = params.get("topic").cloned();
|
||||
let session_id = params.get("session_id").cloned();
|
||||
|
||||
let mut rx = state.handler.state.event_bus_tx.subscribe();
|
||||
|
||||
loop {
|
||||
match rx.recv().await {
|
||||
Ok(event) => {
|
||||
let topic_matches = topic.as_ref().map_or(true, |t| t == &event.topic);
|
||||
let session_matches = session_id.as_ref().map_or(true, |s| Some(s) == event.session_id.as_ref());
|
||||
|
||||
if topic_matches && session_matches {
|
||||
return axum::Json(event);
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
return axum::Json(GenericEvent {
|
||||
topic: "error".to_string(),
|
||||
session_id: None,
|
||||
payload: serde_json::json!({"error": "Event bus lagged or closed"}),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn post_event_handler(
|
||||
State(state): State<Arc<AppState>>,
|
||||
axum::Json(event): axum::Json<GenericEvent>,
|
||||
) -> impl IntoResponse {
|
||||
let _ = state.handler.state.event_bus_tx.send(event);
|
||||
axum::Json(serde_json::json!({"status": "ok"}))
|
||||
}
|
||||
@@ -2,3 +2,4 @@ pub mod rest;
|
||||
pub mod setup;
|
||||
pub mod telemetry;
|
||||
pub mod ws;
|
||||
pub mod events;
|
||||
@@ -24,6 +24,8 @@ pub fn create_router(app_state: Arc<AppState>) -> Router {
|
||||
.route("/ws", get(ws_handler))
|
||||
.route("/health", get(health_handler))
|
||||
.route("/nvim/telemetry", post(nvim_telemetry_handler))
|
||||
.route("/events/wait", get(crate::api::events::wait_for_event_handler))
|
||||
.route("/events", post(crate::api::events::post_event_handler))
|
||||
.route("/gate/verify", get(gate_verify_handler))
|
||||
.route("/gate/set", post(gate_set_handler))
|
||||
.route(
|
||||
|
||||
@@ -45,5 +45,18 @@ pub async fn nvim_telemetry_handler(
|
||||
let _ = tx.try_send(msg_str.clone());
|
||||
}
|
||||
|
||||
if payload.event == "BufWritePost" {
|
||||
if let Some(ref file_path) = payload.file {
|
||||
let normalized_file = file_path.replace("\\", "/");
|
||||
let topic = format!("nvim:save:{}", normalized_file);
|
||||
let event = crate::state::GenericEvent {
|
||||
topic,
|
||||
session_id: Some(payload.session_id.clone()),
|
||||
payload: serde_json::json!(&payload),
|
||||
};
|
||||
let _ = state.handler.state.event_bus_tx.send(event);
|
||||
}
|
||||
}
|
||||
|
||||
axum::Json(serde_json::json!({"status": "ok"}))
|
||||
}
|
||||
@@ -5,6 +5,13 @@ use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct GenericEvent {
|
||||
pub topic: String,
|
||||
pub session_id: Option<String>,
|
||||
pub payload: serde_json::Value,
|
||||
}
|
||||
|
||||
pub struct MemoryState {
|
||||
pub base_dir: PathBuf,
|
||||
pub graph: Store<KnowledgeGraph>,
|
||||
@@ -29,6 +36,7 @@ pub struct MemoryState {
|
||||
pub context_workspaces: Store<Vec<ContextWorkspace>>,
|
||||
pub recent_activities: Store<std::collections::VecDeque<serde_json::Value>>,
|
||||
pub activity_tx: tokio::sync::broadcast::Sender<String>,
|
||||
pub event_bus_tx: tokio::sync::broadcast::Sender<GenericEvent>,
|
||||
}
|
||||
|
||||
impl MemoryState {
|
||||
@@ -72,6 +80,7 @@ impl MemoryState {
|
||||
context_workspaces: Store::new("context_workspaces", db.clone()),
|
||||
recent_activities: Store::new("recent_activities", db.clone()),
|
||||
activity_tx: tokio::sync::broadcast::channel(100).0,
|
||||
event_bus_tx: tokio::sync::broadcast::channel(1000).0,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,4 +17,6 @@ fn main() {
|
||||
|
||||
let version = format!("{} ({})", git_date.trim(), git_hash.trim());
|
||||
println!("cargo:rustc-env=APP_VERSION={version}");
|
||||
println!("cargo:rerun-if-changed=../.git/HEAD");
|
||||
println!("cargo:rerun-if-changed=../.git/index");
|
||||
}
|
||||
+2
-2
@@ -106,7 +106,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
tracing::error!("Failed to write to websocket");
|
||||
tracing::warn!("Failed to write to websocket (connection closed)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let _ = stdout.flush().await;
|
||||
}
|
||||
}
|
||||
tracing::error!("Websocket read loop exited");
|
||||
tracing::info!("Websocket read loop exited");
|
||||
});
|
||||
|
||||
tokio::select! {
|
||||
|
||||
@@ -17,4 +17,6 @@ fn main() {
|
||||
|
||||
let version = format!("{} ({})", git_date.trim(), git_hash.trim());
|
||||
println!("cargo:rustc-env=APP_VERSION={version}");
|
||||
println!("cargo:rerun-if-changed=../.git/HEAD");
|
||||
println!("cargo:rerun-if-changed=../.git/index");
|
||||
}
|
||||
Reference in new issue
Block a user