refactor(#2455): split hive-agent-mcp into its own bin crate
This commit is contained in:
parent
59dd3a0aa7
commit
e7f8254788
15 changed files with 334 additions and 100 deletions
42
hive-agent-mcp/src/loose_ends.rs
Normal file
42
hive-agent-mcp/src/loose_ends.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
//! 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;
|
||||
|
||||
/// Resolution lives in `hive_sh4re::paths` so the harness + every MCP
|
||||
/// daemon agree on where loose-end summary files are written.
|
||||
fn loose_ends_dir() -> PathBuf {
|
||||
hive_sh4re::paths::mcp_loose_ends_dir()
|
||||
}
|
||||
|
||||
/// 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