feat: include active bash tasks in get_loose_ends output
This commit is contained in:
parent
044ff5523c
commit
3c853c2b58
2 changed files with 46 additions and 7 deletions
|
|
@ -157,6 +157,32 @@ pub fn read_task(id: &str) -> Option<TaskFile> {
|
|||
// Public API used by MCP tools
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Return all tasks in `Pending` or `Running` state. Used by the
|
||||
/// `get_loose_ends` tool to surface active background work alongside
|
||||
/// broker-side items (questions, reminders). Silently skips unreadable
|
||||
/// or unparseable files.
|
||||
#[must_use]
|
||||
pub fn active_tasks() -> Vec<TaskFile> {
|
||||
let Ok(rd) = std::fs::read_dir(tasks_dir()) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let mut out = Vec::new();
|
||||
for entry in rd.flatten() {
|
||||
let path = entry.path();
|
||||
if path.extension().and_then(|e| e.to_str()) != Some("json") {
|
||||
continue;
|
||||
}
|
||||
let Some(id) = path.file_stem().and_then(|s| s.to_str()).map(str::to_owned) else {
|
||||
continue;
|
||||
};
|
||||
let Some(task) = read_task(&id) else { continue };
|
||||
if matches!(task.status, TaskStatus::Pending | TaskStatus::Running) {
|
||||
out.push(task);
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Create a new pending task and write it to disk. Returns the task ID
|
||||
/// the MCP tool should return to claude. The runner will pick it up
|
||||
/// within the next poll interval (~200ms).
|
||||
|
|
|
|||
Loading…
Reference in a new issue