chore: fix formatting and clippy lints

This commit is contained in:
Riz Ashraf committed 2026-10-08 23:01:38 +01:00
1 parent 8952bd5399
commit 9d9e959744
35 files changed
+1091 -582

No files matched your search

+46 -23
View File
@@ -79,7 +79,11 @@ pub fn spawn_watcher(state: Arc<MemoryState>) {
fn should_review(path: &Path) -> bool {
let path_str = path.to_string_lossy();
if path_str.contains(".git") || path_str.contains("target") || path_str.contains(".gemini") || path_str.contains("node_modules") {
if path_str.contains(".git")
|| path_str.contains("target")
|| path_str.contains(".gemini")
|| path_str.contains("node_modules")
{
return false;
}
@@ -89,13 +93,19 @@ fn should_review(path: &Path) -> bool {
}
async fn trigger_autonomous_review(path: &Path, state: Arc<MemoryState>) {
info!("Triggering autonomous review & incremental AST index for {:?}", path);
state.broadcast_activity("AUTONOMOUS", &format!("Modified: {:?}", path.file_name().unwrap_or_default()));
info!(
"Triggering autonomous review & incremental AST index for {:?}",
path
);
state.broadcast_activity(
"AUTONOMOUS",
&format!("Modified: {:?}", path.file_name().unwrap_or_default()),
);
// ADR-0109: Incremental Background AST Indexing & Differential Graph Updates
let ext = path.extension().and_then(|e| e.to_str()).unwrap_or("");
if matches!(ext, "rs" | "ts" | "js" | "py" | "go" | "java" | "c" | "cpp") {
if let Ok(content) = std::fs::read_to_string(path) {
if matches!(ext, "rs" | "ts" | "js" | "py" | "go" | "java" | "c" | "cpp")
&& let Ok(content) = std::fs::read_to_string(path) {
let language = match ext {
"rs" => Some(tree_sitter_rust::LANGUAGE),
"ts" | "js" => Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT),
@@ -109,12 +119,20 @@ async fn trigger_autonomous_review(path: &Path, state: Arc<MemoryState>) {
if let Some(lang) = language {
let mut parser = tree_sitter::Parser::new();
if parser.set_language(&lang.into()).is_ok() {
if let Some(tree) = parser.parse(&content, None) {
if parser.set_language(&lang.into()).is_ok()
&& let Some(tree) = parser.parse(&content, None) {
let mut chunks = Vec::new();
crate::indexer::extract_chunks(tree.root_node(), &content, &mut chunks, ext);
crate::indexer::extract_chunks(
tree.root_node(),
&content,
&mut chunks,
ext,
);
let file_str = path.to_string_lossy().to_string();
let now = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap_or_default().as_secs();
let now = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap_or_default()
.as_secs();
let chunks_count = chunks.len();
let file_str_clone = file_str.clone();
@@ -140,16 +158,21 @@ async fn trigger_autonomous_review(path: &Path, state: Arc<MemoryState>) {
"McpTool".to_string()
};
g.entities.insert(symbol_name.clone(), crate::models::Entity {
name: symbol_name.clone(),
entity_type: symbol_type,
observations: vec![format!("AST definition: {} chars", chunk_code.len())],
namespace: "global".to_string(),
file_path: Some(file_str.clone()),
created_at: Some(now),
updated_at: Some(now),
..Default::default()
}
g.entities.insert(
symbol_name.clone(),
crate::models::Entity {
name: symbol_name.clone(),
entity_type: symbol_type,
observations: vec![format!(
"AST definition: {} chars",
chunk_code.len()
)],
namespace: "global".to_string(),
file_path: Some(file_str.clone()),
created_at: Some(now),
updated_at: Some(now),
..Default::default()
},
);
let rel = crate::models::Relation {
@@ -183,12 +206,13 @@ async fn trigger_autonomous_review(path: &Path, state: Arc<MemoryState>) {
}),
});
}
}
}
}
}
info!("Autonomous review & incremental AST index complete for {:?}", path);
info!(
"Autonomous review & incremental AST index complete for {:?}",
path
);
}
#[cfg(test)]
mod tests {
@@ -220,4 +244,3 @@ mod tests {
spawn_watcher(state);
}
}