Watch
0
0
Fork
You've already forked hyperhive
0

move the send and turn row markers into hive-types

This commit is contained in:
atlas 2026-10-18 19:06:36 +02:00
commit 6084fb6329
9 changed files with 119 additions and 43 deletions

View file

@ -15,7 +15,8 @@
//! `mcp__hyperhive__send`'s row say, which tools get an expandable body)
//! didn't change; only the shape it gets packed into did.
use crate::term_msg::{BodyFormat, ClassifyCtx, Level, SEND_ICON, SEND_SUMMARY_PREFIX, TermMsg};
use crate::term_msg::{BodyFormat, ClassifyCtx, Level, TermMsg};
use hive_types::term_msg::{SEND_ICON, SEND_SUMMARY_PREFIX};
use serde_json::{Value, json};
/// Classify one raw claude stream-json line into zero or more terminal rows.
@ -1346,13 +1347,16 @@ mod tests {
}));
assert_eq!(row.icon.as_deref(), Some(SEND_ICON));
assert_eq!(row.summary.contains(" · 3L"), lines, "{}", row.summary);
assert_eq!(crate::term_msg::send_recipient(&row.summary), Some("iris"));
assert_eq!(
hive_types::term_msg::send_recipient(&row.summary),
Some("iris")
);
}
assert_eq!(crate::term_msg::send_recipient("send* →"), None);
assert_eq!(crate::term_msg::send_recipient("Read(x)"), None);
assert_eq!(hive_types::term_msg::send_recipient("send* →"), None);
assert_eq!(hive_types::term_msg::send_recipient("Read(x)"), None);
// A suffix lookalike in the name is not stripped.
assert_eq!(
crate::term_msg::send_recipient("send* → a · xL"),
hive_types::term_msg::send_recipient("send* → a · xL"),
Some("a · xL")
);
}

View file

@ -128,41 +128,6 @@ pub fn iso8601_utc(unix_seconds: i64) -> String {
.to_rfc3339_opts(SecondsFormat::Secs, true)
}
/// Icon of the row an agent's `send` tool call makes.
pub const SEND_ICON: &str = "📤";
/// What a `send` row's summary starts with; the recipient follows. A
/// multi-line body appends ` · <N>L`, which [`send_recipient`] drops.
pub const SEND_SUMMARY_PREFIX: &str = "send* → ";
/// Icon of the row a turn started by a message makes.
pub const TURN_ICON: &str = "◆";
/// What a turn-start row's summary starts with; the sender follows.
pub const TURN_SUMMARY_PREFIX: &str = "TURN ← ";
/// The recipient a `send` row's summary names, without the line-count suffix.
#[must_use]
pub fn send_recipient(summary: &str) -> Option<&str> {
let rest = summary.strip_prefix(SEND_SUMMARY_PREFIX)?;
Some(match rest.rsplit_once(" · ") {
Some((to, lines))
if lines
.strip_suffix('L')
.is_some_and(|n| !n.is_empty() && n.bytes().all(|b| b.is_ascii_digit())) =>
{
to
}
_ => rest,
})
}
/// The sender a turn-start row's summary names.
#[must_use]
pub fn turn_sender(summary: &str) -> Option<&str> {
summary.strip_prefix(TURN_SUMMARY_PREFIX)
}
/// Per-connection/per-request classification state. A live SSE stream keeps
/// one of these alive for the connection's lifetime — `tool_use` id → name
/// correlation, so a `tool_result` can tell it's answering a `recv` call and