feat(server): refactor handlers, router, state management, and memory tools
This commit is contained in:
1 parent
87ddb01063
commit
a083719cf1
36 files changed
+1899
-597
No files matched your search
+28
-3
@@ -1,8 +1,8 @@
|
||||
use crate::state::MemoryState;
|
||||
use notify::{Config, Event, RecommendedWatcher, RecursiveMode, Watcher};
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use crate::state::MemoryState;
|
||||
use tracing::{info, error};
|
||||
use tracing::{error, info};
|
||||
|
||||
pub fn spawn_watcher(_state: Arc<MemoryState>) {
|
||||
let watch_path = std::env::current_dir().unwrap_or_else(|_| std::path::PathBuf::from("."));
|
||||
@@ -52,7 +52,7 @@ fn should_review(path: &Path) -> bool {
|
||||
if path_str.contains(".git") || path_str.contains("target") {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if let Some(ext) = path.extension() {
|
||||
let ext_str = ext.to_string_lossy();
|
||||
if ext_str == "rs" || ext_str == "md" || ext_str == "toml" || ext_str == "lua" {
|
||||
@@ -68,3 +68,28 @@ async fn trigger_autonomous_review(path: &Path) {
|
||||
// MVP: Just write an info log if Neovim isn't reachable.
|
||||
info!("Autonomous review complete for {:?}", path);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_should_review() {
|
||||
assert!(should_review(Path::new("src/lib.rs")));
|
||||
assert!(should_review(Path::new("README.md")));
|
||||
assert!(should_review(Path::new("Cargo.toml")));
|
||||
assert!(should_review(Path::new("init.lua")));
|
||||
|
||||
assert!(!should_review(Path::new("target/debug/app.exe")));
|
||||
assert!(!should_review(Path::new(".git/HEAD")));
|
||||
assert!(!should_review(Path::new("data.json")));
|
||||
assert!(!should_review(Path::new("image.png")));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_spawn_watcher_lifecycle() {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
let state = Arc::new(MemoryState::new(temp_dir.path().to_str().unwrap()));
|
||||
spawn_watcher(state);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user