refactor: eradicate deprecated tools (sticky_notes, pinned_files, context_workspaces, pr_checklist, preferences) and dead code

This commit is contained in:
Riz Ashraf committed 2026-10-07 11:12:42 +01:00
1 parent d80915635f
commit 79209da711
31 files changed
+1230 -3920

No files matched your search

+1 -156
View File
@@ -7,100 +7,6 @@ use serde_json::Value;
use std::collections::HashSet;
use std::sync::Arc;
pub struct StickyNotesHandler;
#[async_trait]
impl McpTool for StickyNotesHandler {
fn name(&self) -> &'static str {
"sticky_notes"
}
fn schema(&self) -> Value {
crate::mcp::tool_def::<StickyNotesTool>(
"sticky_notes",
"Ephemeral sticky notes with TTL (add, read, delete, clear)",
)
}
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
let req: StickyNotesTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
match req.action {
StickyNoteAction::Add => {
let content = req.content.ok_or_else(|| {
crate::error::AppError::Internal("Missing required parameter 'content' for action 'add'. Next step: Provide non-empty 'content' string in request and retry.".to_string())
})?;
let now = crate::handlers::utils::now_secs();
let expires_at = if let Some(ttl) = req.ttl_seconds {
Some(now + ttl)
} else if req.session_only.unwrap_or(false) {
Some(now + 14400)
} else {
None
};
state.code.sticky.modify(|notes| {
notes.push(StickyNote {
timestamp: now,
content,
expires_at,
..Default::default()
});
});
Ok("Sticky note added.".to_string())
}
StickyNoteAction::Read => {
let now = crate::handlers::utils::now_secs();
let has_expired = state.code.sticky.read_with(|notes| {
notes.iter().any(|n| matches!(n.expires_at, Some(exp) if exp <= now))
});
if has_expired {
state.code.sticky.modify(|notes| {
notes.retain(|n| {
if let Some(exp) = n.expires_at {
exp > now
} else {
true
}
});
});
}
let active_notes = state.code.sticky.read_with(|notes| notes.clone());
Ok(serde_json::to_string(&active_notes)?)
}
StickyNoteAction::Delete => {
let idx = req.index.ok_or_else(|| {
crate::error::AppError::Internal("Missing required parameter 'index' for action 'delete'. Next step: Provide 1-based sticky note 'index' integer in request and retry.".to_string())
})?;
let mut success = false;
state.code.sticky.modify(|notes| {
if idx > 0 && idx <= notes.len() {
notes.remove(idx - 1);
success = true;
} else if idx == 0 && !notes.is_empty() {
notes.remove(0);
success = true;
}
});
if success {
Ok("Sticky note deleted.".to_string())
} else {
Err(crate::error::AppError::Internal(
"Invalid sticky note index. Next step: Call sticky_notes with action='read' to view active notes and valid indices, then retry.".to_string(),
))
}
}
StickyNoteAction::Clear => {
state.code.sticky.modify(|notes| {
notes.clear();
});
Ok("All sticky notes cleared.".to_string())
}
}
}
}
pub struct HandoffMemosHandler;
#[async_trait]
@@ -255,7 +161,7 @@ impl McpTool for PromoteToEntityHandler {
fn schema(&self) -> Value {
crate::mcp::tool_def::<PromoteToEntityTool>(
"promote_to_entity",
"Promote a transient sticky note or active task observation into a permanent Knowledge Graph entity.",
"Promote a task observation or finding into a permanent Knowledge Graph entity.",
)
}
@@ -285,10 +191,6 @@ impl McpTool for PromoteToEntityHandler {
}
});
state.code.sticky.modify(|notes| {
notes.retain(|n| !n.content.contains(&obs));
});
Ok(format!(
"Promoted transient note into permanent entity '{}'.",
req.entity_name
@@ -302,47 +204,6 @@ mod tests {
use serde_json::json;
use tempfile::tempdir;
#[tokio::test]
async fn test_notes_lifecycle() {
let dir = tempdir().unwrap();
let state = Arc::new(MemoryState::new(dir.path().to_str().unwrap()));
let handler = StickyNotesHandler;
let args = json!({
"action": "add",
"content": "Buy milk",
});
let res = handler
.execute(args, state.clone())
.await
.map_err(|e| crate::error::AppError::Internal(e.to_string()))
.unwrap();
assert!(res.contains("Sticky note added"));
let res2 = handler
.execute(json!({"action": "read"}), state.clone())
.await
.map_err(|e| crate::error::AppError::Internal(e.to_string()))
.unwrap();
assert!(res2.contains("Buy milk"));
let args2 = json!({"action": "delete", "index": 1});
let res3 = handler
.execute(args2, state.clone())
.await
.map_err(|e| crate::error::AppError::Internal(e.to_string()))
.unwrap();
assert_eq!(res3, "Sticky note deleted.");
let res4 = handler
.execute(json!({"action": "read"}), state.clone())
.await
.map_err(|e| crate::error::AppError::Internal(e.to_string()))
.unwrap();
assert!(!res4.contains("Buy milk"));
}
#[tokio::test]
async fn test_handoff_and_summaries() {
let dir = tempdir().unwrap();
@@ -392,22 +253,6 @@ mod tests {
.unwrap();
assert!(!res4.is_empty());
}
#[tokio::test]
async fn test_invalid_sticky_note_action() {
let dir = tempfile::tempdir().unwrap();
let state = Arc::new(MemoryState::new(dir.path().to_str().unwrap()));
let handler = StickyNotesHandler;
let invalid_args = serde_json::json!({
"action": "invalid_action"
});
let res = handler
.execute(invalid_args, state.clone())
.await;
assert!(res.is_err());
}
}