增强: 任务查询支持按状态过滤(list_tasks status)

- AI 工具 list_tasks: schema 加 status 参数 + handler 内存过滤
  (todo/in_progress/in_review/testing/blocked/done/cancelled)
- df-mcp list_tasks: handler 加 status 过滤(MCP 对外一致)
  (spec 声明待补:中文 Edit 编码匹配限制,后续补)

自验: workspace EXIT 0 + df-mcp cargo check EXIT 0
This commit is contained in:
2026-06-19 19:54:16 +08:00
parent d3e7640b8d
commit 2f8b13ff7c
2 changed files with 13 additions and 5 deletions

View File

@@ -346,12 +346,16 @@ fn bind_directory(ctx: &Ctx, args: Value) -> BoxFuture<'static, CallToolResult>
fn list_tasks(ctx: &Ctx, args: Value) -> BoxFuture<'static, CallToolResult> {
let db = ctx.db.clone();
let project_id_filter = args.get("project_id").and_then(|v| v.as_str()).map(|s| s.to_owned());
let status_filter = args.get("status").and_then(|v| v.as_str()).map(|s| s.to_owned());
Box::pin(async move {
let repo = TaskRepo::new(&db);
match repo.list_active().await {
Ok(mut list) => {
if let Some(pid) = project_id_filter {
list.retain(|t| t.project_id == pid);
if let Some(pid) = &project_id_filter {
list.retain(|t| t.project_id == *pid);
}
if let Some(st) = &status_filter {
list.retain(|t| t.status == *st);
}
json_ok(json!({ "tasks": list, "count": list.len() }))
}