refactor: consolidate nvim crates, extract server library, and update workspace dependencies
This commit is contained in:
1 parent
a083719cf1
commit
533adfd41b
53 files changed
+5967
-1230
No files matched your search
@@ -281,11 +281,12 @@ impl McpTool for ListActiveTasksHandler {
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: ListActiveTasksTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let level = req.summary_level.as_deref().unwrap_or("detailed");
|
||||
let data = state.project.tasks.read_with(|tasks| {
|
||||
let filtered: Vec<_> = tasks
|
||||
.iter()
|
||||
.filter(|t| {
|
||||
let status_match = t.status != "done";
|
||||
let status_match = t.status != "done" && t.status != "completed";
|
||||
let branch_match = match &req.git_branch {
|
||||
Some(branch) => {
|
||||
t.git_branch.is_none()
|
||||
@@ -295,8 +296,31 @@ impl McpTool for ListActiveTasksHandler {
|
||||
};
|
||||
status_match && branch_match
|
||||
})
|
||||
.map(|t| match level {
|
||||
"compact" => serde_json::json!({
|
||||
"id": t.id,
|
||||
"title": t.title,
|
||||
"status": t.status,
|
||||
}),
|
||||
"full" => serde_json::to_value(t).unwrap_or_default(),
|
||||
_ => serde_json::json!({
|
||||
"id": t.id,
|
||||
"title": t.title,
|
||||
"status": t.status,
|
||||
"description": t.description,
|
||||
"git_branch": t.git_branch,
|
||||
}),
|
||||
})
|
||||
.collect();
|
||||
Ok::<String, crate::error::AppError>(serde_json::to_string(&filtered)?)
|
||||
let mut json_str = serde_json::to_string(&filtered)?;
|
||||
if let Some(max_t) = req.max_tokens {
|
||||
let char_limit = max_t * 4;
|
||||
if json_str.len() > char_limit {
|
||||
json_str.truncate(char_limit);
|
||||
json_str.push_str(" ...[truncated due to max_tokens]");
|
||||
}
|
||||
}
|
||||
Ok::<String, crate::error::AppError>(json_str)
|
||||
})?;
|
||||
Ok(data)
|
||||
}
|
||||
@@ -684,4 +708,36 @@ mod tests {
|
||||
.unwrap();
|
||||
assert!(res_del.contains("Deleted task and its children (2 total)."));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
async fn test_list_milestones_with_namespace() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let state = Arc::new(MemoryState::new(dir.path().to_str().unwrap()));
|
||||
|
||||
let add_milestone = AddMilestoneHandler;
|
||||
let args_ms = serde_json::json!({
|
||||
"name": "v1.0",
|
||||
"title": "Release 1.0",
|
||||
"description": "First release",
|
||||
"target_date": 1700000000,
|
||||
"end_date": 1700000000,
|
||||
"namespace": "global"
|
||||
});
|
||||
let res1 = add_milestone
|
||||
.execute(args_ms, state.clone())
|
||||
.await
|
||||
.map_err(|e| crate::error::AppError::Internal(e.to_string()))
|
||||
.unwrap();
|
||||
assert!(res1.contains("Milestone added"));
|
||||
|
||||
let list_ms = ListMilestonesHandler;
|
||||
let res2 = list_ms
|
||||
.execute(serde_json::json!({"namespace": "global"}), state.clone())
|
||||
.await
|
||||
.map_err(|e| crate::error::AppError::Internal(e.to_string()))
|
||||
.unwrap();
|
||||
assert!(res2.contains("Release 1.0"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user