feat: capture normalised bash command heads for the favorite-tools stat

This commit is contained in:
damocles 2026-06-06 00:18:55 +02:00 committed by mara
commit 1569d55f78
7 changed files with 252 additions and 17 deletions

View file

@ -20,12 +20,13 @@ pub fn daemon_socket() -> PathBuf {
.map_or_else(|| PathBuf::from(DEFAULT_DAEMON_SOCKET), PathBuf::from)
}
/// Base directory for task files. Uses `HYPERHIVE_HARNESS_DIR` if set
/// (injected by hive-c0re meta flake after the harness/state split);
/// falls back to a sibling of the state dir for pre-split deployments.
/// Base harness directory. Uses `HYPERHIVE_HARNESS_DIR` if set (injected
/// by the hive-c0re meta flake after the harness/state split); falls
/// back to a `harness/` sibling of the state dir for pre-split
/// deployments. Shared by every per-agent harness artifact path below.
#[must_use]
pub fn tasks_dir() -> PathBuf {
let base = if let Some(p) = std::env::var_os("HYPERHIVE_HARNESS_DIR") {
pub fn harness_dir() -> PathBuf {
if let Some(p) = std::env::var_os("HYPERHIVE_HARNESS_DIR") {
PathBuf::from(p)
} else {
// Pre-split fallback: derive harness/ as a sibling of state/.
@ -34,8 +35,21 @@ pub fn tasks_dir() -> PathBuf {
state_path
.parent()
.map_or_else(|| PathBuf::from(state), |p| p.join("harness"))
};
base.join("bash-tasks")
}
}
/// Base directory for task files.
#[must_use]
pub fn tasks_dir() -> PathBuf {
harness_dir().join("bash-tasks")
}
/// Per-agent turn-stats sqlite — the harness writes one row per claude
/// turn here; the runner appends normalised bash-command heads to its
/// `bash_commands` table for the /stats "favorite tools" view.
#[must_use]
pub fn turn_stats_db() -> PathBuf {
harness_dir().join("hyperhive-turn-stats.sqlite")
}
/// Hyperhive control socket — the daemon writes wake signals here so
@ -56,16 +70,7 @@ pub fn hyperhive_socket() -> PathBuf {
/// code across crates — keep them in sync if the fallback logic changes.
#[must_use]
pub fn mcp_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_or_else(|| PathBuf::from(state), |p| p.join("harness"))
};
base.join("mcp-loose-ends")
harness_dir().join("mcp-loose-ends")
}
/// Full path for a task's JSON metadata file.