feat(mcp): Add 5 developer enhancements (git, logs, clipboard watcher, ast skeleton, nvim ghost text)
This commit is contained in:
1 parent
ccc268d807
commit
0e9748f797
27 files changed
+1401
-174
No files matched your search
@@ -0,0 +1,47 @@
|
||||
use crate::state::MemoryState;
|
||||
use crate::models::StickyNote;
|
||||
use std::sync::Arc;
|
||||
use tokio::time::{sleep, Duration};
|
||||
use clipboard_win::{formats, get_clipboard, Clipboard};
|
||||
|
||||
pub fn spawn_watcher(state: Arc<MemoryState>) {
|
||||
tokio::spawn(async move {
|
||||
let mut last_text = String::new();
|
||||
loop {
|
||||
sleep(Duration::from_millis(1000)).await;
|
||||
|
||||
let is_enabled = {
|
||||
let watch = state.clipboard_watch_mode.read().await;
|
||||
*watch
|
||||
};
|
||||
|
||||
if !is_enabled {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Ok(_clip) = tokio::task::spawn_blocking(|| Clipboard::new_attempts(3)).await.unwrap() {
|
||||
if let Ok(text) = get_clipboard::<String, _>(formats::Unicode) {
|
||||
if text != last_text && !text.trim().is_empty() {
|
||||
last_text = text.clone();
|
||||
|
||||
let note = StickyNote {
|
||||
timestamp: std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs(),
|
||||
content: text,
|
||||
expires_at: None,
|
||||
};
|
||||
|
||||
state.sticky.modify(|notes| {
|
||||
notes.push(note.clone());
|
||||
});
|
||||
|
||||
// We use rebuild_index to index the new sticky note
|
||||
state.rebuild_index().await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user