diff options
| author | Igor Soarez <igor@soarez.org> | 2026-10-19 19:30:03 +0300 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-10-19 19:30:03 +0300 |
| commit | fed066bc3908d18ede5490130975203a56c48fc2 (patch) | |
| tree | 17ecccec1a1b5669e1868a0e169f263bdee53c73 /crates/dinggerd/src/integrations.rs | |
| parent | 7081a103443bafa28d902529d502a89c2dccb79a (diff) | |
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.
Diffstat (limited to 'crates/dinggerd/src/integrations.rs')
| -rw-r--r-- | crates/dinggerd/src/integrations.rs | 45 |
1 files changed, 45 insertions, 0 deletions
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<PathBuf, String> { + 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(()) +} |
