From fed066bc3908d18ede5490130975203a56c48fc2 Mon Sep 17 00:00:00 2001 From: Igor Soarez Date: Mon, 19 Oct 2026 19:30:03 +0300 Subject: menu bar: herdr-style colored state glyphs; tmux segment before the clock the design panel's monochrome template rendering made every row look alike; restore herdr's agent-panel visual language - green ready, yellow working, red blocked, filled when unseen in the queue. the tmux segment moves left of the clock so it is visible at a glance; the status item logs what it observes for diagnosis. --- crates/dinggerd/src/integrations.rs | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 crates/dinggerd/src/integrations.rs (limited to 'crates/dinggerd/src/integrations.rs') diff --git a/crates/dinggerd/src/integrations.rs b/crates/dinggerd/src/integrations.rs new file mode 100644 index 0000000..a6378d1 --- /dev/null +++ b/crates/dinggerd/src/integrations.rs @@ -0,0 +1,45 @@ +//! Agent integrations: hook extensions that let agents report their own +//! state (herdr's integration model), so detection does not rely on screen +//! scraping for the agents that support it. + +use std::path::PathBuf; + +use detect_core::Agent; + +/// The embedded pi extension, adapted from herdr's `herdr-agent-state.ts` +/// (Apache-2.0, Copyright herdr contributors). +const PI_EXTENSION: &str = include_str!("../assets/pi/pi-agent-state.ts"); + +fn pi_extension_dir() -> Result { + let base = std::env::var_os("PI_CODING_AGENT_DIR") + .map(PathBuf::from) + .or_else(|| std::env::var_os("HOME").map(|home| PathBuf::from(home).join(".pi").join("agent"))) + .ok_or("cannot determine pi agent dir (no HOME)")?; + Ok(base.join("extensions")) +} + +/// Install the integration for one agent. Only pi has an integration today. +pub fn install(agent: &str) -> Result<(), String> { + let parsed = detect_core::parse_agent_label(agent) + .ok_or_else(|| format!("unknown agent: {agent}"))?; + match parsed { + Agent::Pi => install_pi(), + other => Err(format!( + "no hook integration for {} yet — screen detection is used", + detect_core::agent_label(other) + )), + } +} + +fn install_pi() -> Result<(), String> { + let dir = pi_extension_dir()?; + std::fs::create_dir_all(&dir).map_err(|err| format!("mkdir failed: {err}"))?; + let path = dir.join("dingger-agent-state.ts"); + std::fs::write(&path, PI_EXTENSION).map_err(|err| format!("write failed: {err}"))?; + tracing::info!(path = %path.display(), "installed pi extension"); + println!( + "installed {} — new pi sessions report their state directly;\nrestart running pi agents (or reload them) to pick it up", + path.display() + ); + Ok(()) +} -- cgit v1.2.3