chore: fix clippy warnings and run rustfmt
This commit is contained in:
1 parent
fecd8bf33f
commit
3765e6b05d
21 files changed
+420
-369
No files matched your search
@@ -120,9 +120,10 @@ impl McpTool for ReadFileSkeletonHandler {
|
||||
}
|
||||
}
|
||||
if header.is_empty()
|
||||
&& let Some(first_line) = node_text.lines().next() {
|
||||
header = first_line.to_string();
|
||||
}
|
||||
&& let Some(first_line) = node_text.lines().next()
|
||||
{
|
||||
header = first_line.to_string();
|
||||
}
|
||||
|
||||
out.push_str(&indent);
|
||||
out.push_str(header.trim());
|
||||
@@ -425,9 +426,10 @@ fn scan_workspace_for_symbol(
|
||||
break;
|
||||
}
|
||||
if let Ok(meta) = std::fs::metadata(path)
|
||||
&& meta.len() > 1024 * 1024 {
|
||||
continue;
|
||||
}
|
||||
&& meta.len() > 1024 * 1024
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if let Ok(content) = std::fs::read_to_string(path) {
|
||||
for (line_num, line) in content.lines().enumerate() {
|
||||
let is_match = if filter_fn_call {
|
||||
|
||||
+19
-18
@@ -140,27 +140,28 @@ impl McpTool for QueryGitDiffsHandler {
|
||||
let mut results = Vec::new();
|
||||
let cwd = env::current_dir().unwrap_or_default();
|
||||
if let Ok(repo) = git2::Repository::discover(&cwd)
|
||||
&& let Ok(mut revwalk) = repo.revwalk() {
|
||||
let _ = revwalk.push_head();
|
||||
let mut count = 0;
|
||||
for oid in revwalk.flatten() {
|
||||
if count >= remaining {
|
||||
break;
|
||||
}
|
||||
if let Ok(commit) = repo.find_commit(oid) {
|
||||
let summary = commit.summary().unwrap_or("");
|
||||
if summary.to_lowercase().contains(&q) {
|
||||
count += 1;
|
||||
results.push(json!({
|
||||
"commit_id": oid.to_string(),
|
||||
"author": commit.author().name().unwrap_or("unknown"),
|
||||
"message": summary,
|
||||
"timestamp": commit.time().seconds(),
|
||||
}));
|
||||
}
|
||||
&& let Ok(mut revwalk) = repo.revwalk()
|
||||
{
|
||||
let _ = revwalk.push_head();
|
||||
let mut count = 0;
|
||||
for oid in revwalk.flatten() {
|
||||
if count >= remaining {
|
||||
break;
|
||||
}
|
||||
if let Ok(commit) = repo.find_commit(oid) {
|
||||
let summary = commit.summary().unwrap_or("");
|
||||
if summary.to_lowercase().contains(&q) {
|
||||
count += 1;
|
||||
results.push(json!({
|
||||
"commit_id": oid.to_string(),
|
||||
"author": commit.author().name().unwrap_or("unknown"),
|
||||
"message": summary,
|
||||
"timestamp": commit.time().seconds(),
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
results
|
||||
})
|
||||
.await
|
||||
|
||||
@@ -63,16 +63,17 @@ impl<'a> GraphQueryBuilder<'a> {
|
||||
}
|
||||
nodes_at_current_depth -= 1;
|
||||
if current_depth < self.max_depth
|
||||
&& let Some(neighbors) = adj.get(current) {
|
||||
for &(neighbor, rel_type, is_inverse) in neighbors {
|
||||
if !visited.contains(neighbor) {
|
||||
visited.insert(neighbor);
|
||||
parents.insert(neighbor, (current, rel_type, is_inverse));
|
||||
queue.push_back(neighbor);
|
||||
nodes_at_next_depth += 1;
|
||||
}
|
||||
&& let Some(neighbors) = adj.get(current)
|
||||
{
|
||||
for &(neighbor, rel_type, is_inverse) in neighbors {
|
||||
if !visited.contains(neighbor) {
|
||||
visited.insert(neighbor);
|
||||
parents.insert(neighbor, (current, rel_type, is_inverse));
|
||||
queue.push_back(neighbor);
|
||||
nodes_at_next_depth += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if nodes_at_current_depth == 0 {
|
||||
current_depth += 1;
|
||||
nodes_at_current_depth = nodes_at_next_depth;
|
||||
@@ -997,13 +998,14 @@ impl McpTool for GetSubgraphHandler {
|
||||
|
||||
while let Some((curr, d)) = queue.pop_front() {
|
||||
if d < depth
|
||||
&& let Some(neighbors) = adj.get(curr) {
|
||||
for &next in neighbors {
|
||||
if visited.insert(next.to_string()) {
|
||||
queue.push_back((next, d + 1));
|
||||
}
|
||||
&& let Some(neighbors) = adj.get(curr)
|
||||
{
|
||||
for &next in neighbors {
|
||||
if visited.insert(next.to_string()) {
|
||||
queue.push_back((next, d + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let ent: std::collections::HashMap<String, crate::models::Entity> = visited
|
||||
@@ -1176,9 +1178,11 @@ impl McpTool for ResolveStaleSymbolsHandler {
|
||||
state.modify_graph(|g| {
|
||||
for name in g.entities.keys() {
|
||||
if let Some(target) = &req.target
|
||||
&& name != target && !name.contains(target) {
|
||||
continue;
|
||||
}
|
||||
&& name != target
|
||||
&& !name.contains(target)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
checked += 1;
|
||||
let path = std::path::Path::new(name);
|
||||
if (name.contains('/') || name.contains('\\') || name.contains('.'))
|
||||
|
||||
+68
-54
@@ -111,9 +111,10 @@ impl McpTool for SearchErrorFixesHandler {
|
||||
score += 0.5;
|
||||
}
|
||||
if let Some(emb) = &f.embedding
|
||||
&& !query_emb.is_empty() {
|
||||
score += crate::embedding::cosine_similarity(&query_emb, emb);
|
||||
}
|
||||
&& !query_emb.is_empty()
|
||||
{
|
||||
score += crate::embedding::cosine_similarity(&query_emb, emb);
|
||||
}
|
||||
(f, score)
|
||||
})
|
||||
.filter(|(_, score)| *score > 0.1)
|
||||
@@ -198,9 +199,10 @@ impl McpTool for LogCodeChangeHandler {
|
||||
description = format!("{} [Line Range: {}]", description, range);
|
||||
}
|
||||
if let Some(symbols) = &req.symbol_references
|
||||
&& !symbols.is_empty() {
|
||||
description = format!("{} [Symbols: {}]", description, symbols.join(", "));
|
||||
}
|
||||
&& !symbols.is_empty()
|
||||
{
|
||||
description = format!("{} [Symbols: {}]", description, symbols.join(", "));
|
||||
}
|
||||
|
||||
if state.ollama.is_available().await {
|
||||
let prompt = format!(
|
||||
@@ -244,13 +246,12 @@ impl McpTool for LogCodeChangeHandler {
|
||||
let detected_vcs = if let Some(vcs) = req.vcs_type.clone() {
|
||||
Some(vcs)
|
||||
} else if let Some(ref rev) = effective_rev {
|
||||
if rev.starts_with('r') && rev[1..].chars().all(|c| c.is_ascii_digit()) {
|
||||
Some("svn".to_string())
|
||||
} else if req
|
||||
.repo_url
|
||||
.as_deref()
|
||||
.map(|u| u.contains("/svn/"))
|
||||
.unwrap_or(false)
|
||||
if (rev.starts_with('r') && rev[1..].chars().all(|c| c.is_ascii_digit()))
|
||||
|| req
|
||||
.repo_url
|
||||
.as_deref()
|
||||
.map(|u| u.contains("/svn/"))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
Some("svn".to_string())
|
||||
} else {
|
||||
@@ -337,21 +338,23 @@ impl McpTool for QueryRecentChangesHandler {
|
||||
.rev()
|
||||
.filter(|c| {
|
||||
if let Some(ns) = &req.namespace
|
||||
&& !c.namespace.eq_ignore_ascii_case(ns) {
|
||||
return false;
|
||||
}
|
||||
&& !c.namespace.eq_ignore_ascii_case(ns)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(repo) = &req.repo_name
|
||||
&& c.repo_name
|
||||
.as_ref()
|
||||
.map(|rn| !rn.eq_ignore_ascii_case(repo))
|
||||
.unwrap_or(true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(vcs) = &req.vcs_type
|
||||
&& !c.effective_vcs().eq_ignore_ascii_case(vcs) {
|
||||
return false;
|
||||
}
|
||||
&& !c.effective_vcs().eq_ignore_ascii_case(vcs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
true
|
||||
})
|
||||
.skip(offset)
|
||||
@@ -464,10 +467,11 @@ impl McpTool for DecisionsHandler {
|
||||
&& let Some(s_pos) = adrs
|
||||
.iter()
|
||||
.position(|a| a.id.eq_ignore_ascii_case(superseded_id))
|
||||
&& s_pos != pos {
|
||||
adrs[s_pos].status = "superseded".to_string();
|
||||
adrs_to_index.push(adrs[s_pos].clone());
|
||||
}
|
||||
&& s_pos != pos
|
||||
{
|
||||
adrs[s_pos].status = "superseded".to_string();
|
||||
adrs_to_index.push(adrs[s_pos].clone());
|
||||
}
|
||||
|
||||
let a = &mut adrs[pos];
|
||||
if let Some(t) = req.title {
|
||||
@@ -1273,20 +1277,23 @@ impl McpTool for ManageCheckpointHandler {
|
||||
}
|
||||
|
||||
if let Ok(graph_content) = std::fs::read_to_string(target_dir.join("graph.json"))
|
||||
&& let Ok(graph) = serde_json::from_str(&graph_content) {
|
||||
state.graph.modify(|g| *g = graph);
|
||||
}
|
||||
&& let Ok(graph) = serde_json::from_str(&graph_content)
|
||||
{
|
||||
state.graph.modify(|g| *g = graph);
|
||||
}
|
||||
|
||||
if let Ok(tasks_content) = std::fs::read_to_string(target_dir.join("tasks.json"))
|
||||
&& let Ok(tasks) = serde_json::from_str(&tasks_content) {
|
||||
state.project.tasks.modify(|t| *t = tasks);
|
||||
}
|
||||
&& let Ok(tasks) = serde_json::from_str(&tasks_content)
|
||||
{
|
||||
state.project.tasks.modify(|t| *t = tasks);
|
||||
}
|
||||
|
||||
if let Ok(debts_content) =
|
||||
std::fs::read_to_string(target_dir.join("tech_debts.json"))
|
||||
&& let Ok(debts) = serde_json::from_str(&debts_content) {
|
||||
state.code.tech_debts.modify(|d| *d = debts);
|
||||
}
|
||||
&& let Ok(debts) = serde_json::from_str(&debts_content)
|
||||
{
|
||||
state.code.tech_debts.modify(|d| *d = debts);
|
||||
}
|
||||
|
||||
Ok(format!("Checkpoint '{}' restored successfully.", name))
|
||||
}
|
||||
@@ -1296,9 +1303,10 @@ impl McpTool for ManageCheckpointHandler {
|
||||
if let Ok(entries) = std::fs::read_dir(&checkpoints_dir) {
|
||||
for entry in entries.flatten() {
|
||||
if entry.path().is_dir()
|
||||
&& let Some(n) = entry.file_name().to_str() {
|
||||
list.push(serde_json::json!({"type": "checkpoint", "name": n}));
|
||||
}
|
||||
&& let Some(n) = entry.file_name().to_str()
|
||||
{
|
||||
list.push(serde_json::json!({"type": "checkpoint", "name": n}));
|
||||
}
|
||||
}
|
||||
}
|
||||
let snaps = state.project.snapshots.read_with(|snaps| snaps.clone());
|
||||
@@ -1467,9 +1475,10 @@ impl McpTool for GetNextActionableTasksHandler {
|
||||
|
||||
if let Some(branch) = &req.git_branch
|
||||
&& let Some(tb) = &task.git_branch
|
||||
&& tb != branch {
|
||||
continue;
|
||||
}
|
||||
&& tb != branch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
let unblocked = task.dependencies.is_empty()
|
||||
|| task.dependencies.iter().all(|d| completed_ids.contains(d));
|
||||
@@ -1541,9 +1550,10 @@ impl McpTool for HypothesesHandler {
|
||||
.into_iter()
|
||||
.filter(|h| {
|
||||
if let Some(tid) = &req.task_id
|
||||
&& h.task_id.as_ref() != Some(tid) {
|
||||
return false;
|
||||
}
|
||||
&& h.task_id.as_ref() != Some(tid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(q) = &req.query {
|
||||
let lq = q.to_lowercase();
|
||||
return h.hypothesis.to_lowercase().contains(&lq)
|
||||
@@ -1725,20 +1735,24 @@ impl McpTool for AgentSignalsHandler {
|
||||
.iter()
|
||||
.filter(|s| {
|
||||
if let Some(ttl) = s.ttl_seconds
|
||||
&& now > s.timestamp + ttl {
|
||||
return false;
|
||||
}
|
||||
&& now > s.timestamp + ttl
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(sender) = &req.sender
|
||||
&& s.sender.to_lowercase() != sender.to_lowercase() {
|
||||
return false;
|
||||
}
|
||||
&& s.sender.to_lowercase() != sender.to_lowercase()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(st) = &req.signal_type
|
||||
&& s.signal_type.to_lowercase() != st.to_lowercase() {
|
||||
return false;
|
||||
}
|
||||
&& s.signal_type.to_lowercase() != st.to_lowercase()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
true
|
||||
})
|
||||
.take(req.limit.unwrap_or(20)).cloned()
|
||||
.take(req.limit.unwrap_or(20))
|
||||
.cloned()
|
||||
.collect::<Vec<_>>()
|
||||
});
|
||||
|
||||
|
||||
@@ -245,11 +245,11 @@ pub fn recalculate_milestones(state: &MemoryState) -> Vec<String> {
|
||||
&& (t.status == "in_progress" || t.status == "active")
|
||||
}))
|
||||
&& !m.status.eq_ignore_ascii_case("in_progress")
|
||||
&& !m.status.eq_ignore_ascii_case("completed")
|
||||
{
|
||||
m.status = "in_progress".to_string();
|
||||
updated.push(m.id.clone());
|
||||
}
|
||||
&& !m.status.eq_ignore_ascii_case("completed")
|
||||
{
|
||||
m.status = "in_progress".to_string();
|
||||
updated.push(m.id.clone());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -287,9 +287,10 @@ pub async fn reconcile_commit_or_code_change(
|
||||
return true;
|
||||
}
|
||||
if let (Some(n1), Some(n2)) = (adr_numeric_id(&adr.id), adr_numeric_id(cand))
|
||||
&& n1 == n2 {
|
||||
return true;
|
||||
}
|
||||
&& n1 == n2
|
||||
{
|
||||
return true;
|
||||
}
|
||||
false
|
||||
});
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ impl McpTool for TasksHandler {
|
||||
priority: req.priority,
|
||||
assigned_agent: req.assigned_agent,
|
||||
verification_command: req.verification_command,
|
||||
..Default::default()
|
||||
};
|
||||
let idx = state.get_search_index().await;
|
||||
drop(idx.index_task(&task));
|
||||
@@ -479,9 +478,10 @@ impl McpTool for MilestonesHandler {
|
||||
m.status = status.clone();
|
||||
if (status.eq_ignore_ascii_case("completed")
|
||||
|| status.eq_ignore_ascii_case("done"))
|
||||
&& m.completed_at.is_none() {
|
||||
m.completed_at = Some(crate::handlers::utils::now_secs());
|
||||
}
|
||||
&& m.completed_at.is_none()
|
||||
{
|
||||
m.completed_at = Some(crate::handlers::utils::now_secs());
|
||||
}
|
||||
if let Some(task_ids) = &req.task_ids {
|
||||
m.task_ids = task_ids.clone();
|
||||
if let Some(deliverables) = &req.deliverables {
|
||||
|
||||
@@ -191,10 +191,9 @@ pub fn html_to_markdown(html: &str) -> String {
|
||||
out.push_str("* ");
|
||||
}
|
||||
}
|
||||
"/li"
|
||||
if !in_cell => {
|
||||
out.push('\n');
|
||||
}
|
||||
"/li" if !in_cell => {
|
||||
out.push('\n');
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else if c == '&' {
|
||||
@@ -510,7 +509,8 @@ pub async fn process_clipboard_snapshot(state: Arc<MemoryState>) {
|
||||
.search_index
|
||||
.read()
|
||||
.await
|
||||
.index_clipboard_image(&doc_id, &path_str, text);
|
||||
.index_clipboard_image(&doc_id, &path_str, text)
|
||||
.await;
|
||||
}
|
||||
|
||||
let cached = crate::state::CachedClipboardImage {
|
||||
@@ -567,9 +567,10 @@ pub async fn process_clipboard_snapshot(state: Arc<MemoryState>) {
|
||||
|
||||
let mut cache = state.clipboard_cache.write().await;
|
||||
if let Some(ref prev) = cache.last_text
|
||||
&& prev.text == cached.text {
|
||||
return;
|
||||
}
|
||||
&& prev.text == cached.text
|
||||
{
|
||||
return;
|
||||
}
|
||||
cache.last_text = Some(cached.clone());
|
||||
cache
|
||||
.history
|
||||
@@ -891,12 +892,10 @@ impl McpTool for ClipboardHandler {
|
||||
}
|
||||
|
||||
if let Some(eng) = engine
|
||||
&& let Some(ocr_text) = perform_ocrs_ocr(eng, &dynamic_img) {
|
||||
out.insert(
|
||||
"image_analysis".to_string(),
|
||||
json!(ocr_text.trim()),
|
||||
);
|
||||
}
|
||||
&& let Some(ocr_text) = perform_ocrs_ocr(eng, &dynamic_img)
|
||||
{
|
||||
out.insert("image_analysis".to_string(), json!(ocr_text.trim()));
|
||||
}
|
||||
}
|
||||
Ok(out)
|
||||
},
|
||||
@@ -905,9 +904,7 @@ impl McpTool for ClipboardHandler {
|
||||
.map_err(|e| crate::error::AppError::Internal(format!("Task panic: {}", e)))??;
|
||||
|
||||
state.record_activity("clipboard", "Read contents from OS clipboard", None);
|
||||
Ok::<String, crate::error::AppError>(serde_yaml::to_string(&Value::Object(
|
||||
out,
|
||||
))?)
|
||||
Ok::<String, crate::error::AppError>(serde_yaml::to_string(&Value::Object(out))?)
|
||||
}
|
||||
ClipboardAction::Write => {
|
||||
let text_opt = req.text;
|
||||
|
||||
Reference in new issue
Block a user