fix: replace bash_tasks.rs with generic mcp_loose_ends scanner
- hive-ag3nt: remove bash_tasks.rs entirely; add mcp_loose_ends.rs that scans harness/mcp-loose-ends/*.json generically (no bash knowledge) - hive-bash-mcp: daemon writes mcp-loose-ends/bash.json on every task state transition (pending/running/done/interrupted/timed_out) - get_loose_ends: reads mcp_loose_ends::collect() instead of bash-specific code - implements the generic mechanism from #1162
This commit is contained in:
parent
8b559eceec
commit
8731474104
6 changed files with 119 additions and 93 deletions
50
hive-ag3nt/src/mcp_loose_ends.rs
Normal file
50
hive-ag3nt/src/mcp_loose_ends.rs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
//! Generic scanner for MCP loose-end summary files.
|
||||
//!
|
||||
//! External MCP daemons (hive-bash-mcp, hive-matrix-mcp, etc.) write
|
||||
//! JSON files to `$HYPERHIVE_HARNESS_DIR/mcp-loose-ends/<name>.json`.
|
||||
//! Each file contains a JSON array of plain-text summary strings.
|
||||
//!
|
||||
//! The harness reads all files in this directory in `get_loose_ends` to
|
||||
//! surface active background work from any MCP without hardcoding
|
||||
//! per-MCP knowledge here.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn loose_ends_dir() -> PathBuf {
|
||||
let base = if let Some(p) = std::env::var_os("HYPERHIVE_HARNESS_DIR") {
|
||||
PathBuf::from(p)
|
||||
} else {
|
||||
let state = std::env::var("HYPERHIVE_STATE_DIR").unwrap_or_default();
|
||||
let state_path = PathBuf::from(&state);
|
||||
state_path
|
||||
.parent()
|
||||
.map(|p| p.join("harness"))
|
||||
.unwrap_or_else(|| PathBuf::from(state))
|
||||
};
|
||||
base.join("mcp-loose-ends")
|
||||
}
|
||||
|
||||
/// Collect all loose-end summary strings published by external MCP daemons.
|
||||
/// Each string is a single line suitable for inclusion in `get_loose_ends`
|
||||
/// output. Returns an empty vec if the directory doesn't exist or is empty.
|
||||
#[must_use]
|
||||
pub fn collect() -> Vec<String> {
|
||||
let Ok(rd) = std::fs::read_dir(loose_ends_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 Ok(content) = std::fs::read_to_string(&path) else {
|
||||
continue;
|
||||
};
|
||||
let Ok(items) = serde_json::from_str::<Vec<String>>(&content) else {
|
||||
continue;
|
||||
};
|
||||
out.extend(items);
|
||||
}
|
||||
out
|
||||
}
|
||||
Loading…
Reference in a new issue