新增: Phase 4 注入 — @[项目] 关联任务/灵感 + 三个工具 path 可选
- Augmentation 新增 extra 字段(项目关联信息/任务关联信息/灵感关联信息) - ProjectResolver: @[项目] 时自动查前5条进行中任务+前3条待评估灵感 - TaskResolver/IdeaResolver: extra 预留(后续按需追加) - render_one 渲染 extra 行 - search_files/grep/list_directory path 改为可选,不传时返回引导提示
This commit is contained in:
@@ -66,6 +66,7 @@ fn render_one(aug: &Augmentation, out: &mut String, label: &str) {
|
||||
status,
|
||||
description,
|
||||
path,
|
||||
extra,
|
||||
..
|
||||
} => {
|
||||
out.push_str("【");
|
||||
@@ -85,6 +86,10 @@ fn render_one(aug: &Augmentation, out: &mut String, label: &str) {
|
||||
out.push_str(description);
|
||||
out.push('\n');
|
||||
}
|
||||
for line in extra {
|
||||
out.push_str(line);
|
||||
out.push('\n');
|
||||
}
|
||||
out.push('\n');
|
||||
}
|
||||
Augmentation::Task {
|
||||
@@ -92,6 +97,7 @@ fn render_one(aug: &Augmentation, out: &mut String, label: &str) {
|
||||
status,
|
||||
description,
|
||||
project_name,
|
||||
extra,
|
||||
..
|
||||
} => {
|
||||
out.push_str("【");
|
||||
@@ -111,12 +117,17 @@ fn render_one(aug: &Augmentation, out: &mut String, label: &str) {
|
||||
out.push_str(description);
|
||||
out.push('\n');
|
||||
}
|
||||
for line in extra {
|
||||
out.push_str(line);
|
||||
out.push('\n');
|
||||
}
|
||||
out.push('\n');
|
||||
}
|
||||
Augmentation::Idea {
|
||||
title,
|
||||
status,
|
||||
description,
|
||||
extra,
|
||||
..
|
||||
} => {
|
||||
out.push_str("【");
|
||||
@@ -131,6 +142,10 @@ fn render_one(aug: &Augmentation, out: &mut String, label: &str) {
|
||||
out.push_str(description);
|
||||
out.push('\n');
|
||||
}
|
||||
for line in extra {
|
||||
out.push_str(line);
|
||||
out.push('\n');
|
||||
}
|
||||
out.push('\n');
|
||||
}
|
||||
Augmentation::Skill {
|
||||
|
||||
@@ -17,6 +17,7 @@ use df_storage::crud::{IdeaRepo, ProjectRepo, TaskRepo};
|
||||
use df_storage::db::Database;
|
||||
use df_types::augmentation::{Augmentation, MentionRef, ResolveError, SanitizedPath};
|
||||
use df_types::types::{IdeaStatus, ProjectStatus, TaskStatus};
|
||||
use df_storage::crud::{IdeaQuery, TaskQuery};
|
||||
|
||||
use crate::commands::ai::augmentation::registry::ResolverRegistry;
|
||||
use crate::commands::ai::augmentation::sanitize::{sanitize_for, ProviderLocality};
|
||||
@@ -100,6 +101,43 @@ impl MentionResolver for ProjectResolver {
|
||||
status,
|
||||
description: record.description,
|
||||
path,
|
||||
extra: {
|
||||
let mut lines: Vec<String> = Vec::new();
|
||||
// Phase 4:查询该项目的前 5 条未完成任务
|
||||
let task_repo = TaskRepo::new(&self.db);
|
||||
if let Ok(tasks) = task_repo.list_by_query(&TaskQuery {
|
||||
project_id: Some(id.clone()),
|
||||
status: Some("in_progress".into()),
|
||||
limit: Some(5),
|
||||
..Default::default()
|
||||
}).await {
|
||||
if !tasks.is_empty() {
|
||||
let mut task_lines: Vec<String> = tasks.iter().map(|t| {
|
||||
format!(" - {} ({})", t.title, t.status)
|
||||
}).collect();
|
||||
task_lines.insert(0, format!("进行中任务({}):", tasks.len()));
|
||||
lines.push(task_lines.join("\n"));
|
||||
}
|
||||
}
|
||||
// 待评估灵感
|
||||
let idea_repo = IdeaRepo::new(&self.db);
|
||||
if let Ok(ideas) = idea_repo.list_by_query(&IdeaQuery {
|
||||
limit: Some(3),
|
||||
..Default::default()
|
||||
}).await {
|
||||
let related: Vec<_> = ideas.iter()
|
||||
.filter(|i| i.status == "pending_review")
|
||||
.take(3)
|
||||
.map(|i| format!(" - {} ({})", i.title, i.status))
|
||||
.collect();
|
||||
if !related.is_empty() {
|
||||
let mut idea_lines = vec![format!("待评估灵感({}):", related.len())];
|
||||
idea_lines.extend(related);
|
||||
lines.push(idea_lines.join("\n"));
|
||||
}
|
||||
}
|
||||
lines
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -166,6 +204,7 @@ impl MentionResolver for TaskResolver {
|
||||
status,
|
||||
description: task.description,
|
||||
project_name,
|
||||
extra: vec![],
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -220,6 +259,7 @@ impl MentionResolver for IdeaResolver {
|
||||
title: record.title,
|
||||
status,
|
||||
description: record.description,
|
||||
extra: vec![],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user