Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/hive-sh4re/src/assets.rs
damocles c0eb6780ec templates: the agent system prompt is a Jinja template, rendered through hive-template
system.md carries {{ label }}-style variables and an {% if not archetype %} block in place of the config:repo / config:archetype marker pairs, so prompt.rs drops its line filter, marker parsers and string replaces. The rendered prompt is byte for byte the old one for a custom agent, an archetype agent and an empty archetype name, with and without hive, swarm, docs and operators. hive-template now drops a block tag's own line.
2026-11-11 09:04:42 +01:00

51 lines
2.1 KiB
Rust

//! Resolve the on-disk path to hyperhive's static assets (branding +
//! claude prompts). Single source of truth for both the host daemon
//! (`hive-c0re`) and the in-container harness binaries so they agree
//! on the lookup contract.
//!
//! At runtime, the path is read from `$HIVE_ASSETS_DIR`. Setting it is
//! the deployment's job; this crate's contract is only that it names a
//! directory laid out like the packaged assets.
//! For `cargo run` outside nix, set it yourself:
//!
//! ```sh
//! HIVE_ASSETS_DIR=$(pwd)/dev-assets cargo run ...
//! ```
//!
//! where `dev-assets/` mirrors the nix output's `branding/` + `prompts/`
//! layout.
//!
//! Each crate that wants a specific asset goes through one of the
//! typed helpers (currently just `prompt_template()` — the branding
//! SVG used to live here too; the per-agent icon now 404s server-side
//! when unconfigured and falls back to a frontend-bundled default
//! client-side instead of a server-resolved runtime path, see
//! `hive-agent::web_ui::screen::serve_icon`) so the lookup contract is
//! centralised. Missing files panic at first call with a clear "set
//! `HIVE_ASSETS_DIR` + put the file at …" message.
use std::path::PathBuf;
/// Read `$HIVE_ASSETS_DIR`. Panics with a clear remediation message
/// when unset — every code path that calls into this module is one
/// the binary cannot run without, so a hard early failure is the
/// right shape.
fn dir() -> PathBuf {
match std::env::var("HIVE_ASSETS_DIR") {
Ok(v) if !v.is_empty() => PathBuf::from(v),
_ => panic!(
"HIVE_ASSETS_DIR is not set. A deployment sets it; when \
running a binary outside one, point it at a directory \
with `branding/` and `prompts/` subdirs. See \
hive-sh4re/src/assets.rs for the contract.",
),
}
}
/// `$HIVE_ASSETS_DIR/prompts/system.md` — the claude system prompt
/// template. `hive-agent::prompt::render` renders it as a Jinja template per
/// agent, with a block for a custom or an archetype agent.
#[must_use]
pub fn prompt_template() -> PathBuf {
dir().join("prompts/system.md")
}