diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-08-14 04:22:48 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-08-14 04:22:48 +0300 |
| commit | 1af1a5b86f642ae7b053037bc472913cfbc1e206 (patch) | |
| tree | 9b2826f592bcaa5420149d9e9752a79ec9ed9d30 /src | |
| parent | 1ac5e9805784e14a5322a0e60e435348149721ee (diff) | |
feat(cli): guide agents to Herdr resources
Diffstat (limited to 'src')
| -rw-r--r-- | src/cli.rs | 9 | ||||
| -rw-r--r-- | src/cli/spec.rs | 30 | ||||
| -rw-r--r-- | src/main.rs | 3 |
3 files changed, 37 insertions, 5 deletions
@@ -29,6 +29,15 @@ const TERMINAL_SESSION_OBSERVE_USAGE: &str = "usage: herdr terminal session observe <target> [--cols N] [--rows N]"; const TERMINAL_SESSION_CONTROL_USAGE: &str = "usage: herdr terminal session control <target> [--takeover] [--cols N] [--rows N]"; +pub(crate) const AGENT_HELP_FOOTER: &str = concat!( + "Are you an AI? Use these resources ONLY IF your task specifically asks you to:\n", + " Help a human understand or set up Herdr for the first time:\n", + " https://herdr.dev/agent-guide.md\n", + " Debug or investigate a problem with Herdr:\n", + " https://herdr.dev/llms.txt\n", + " Control Herdr panes, agents, or workspaces:\n", + " SKIP if a Herdr skill is already in your context. Otherwise run: herdr --skill", +); pub(crate) fn parse_token_assignment(raw: &str) -> Result<(String, Option<String>), String> { let Some((key, value)) = raw.split_once('=') else { diff --git a/src/cli/spec.rs b/src/cli/spec.rs index ba454bfc..b2b6cb03 100644 --- a/src/cli/spec.rs +++ b/src/cli/spec.rs @@ -43,18 +43,23 @@ pub(super) fn command() -> Command { .subcommand(session_command()) .subcommand(integration_command()) .subcommand(plugin_command()); - configure_help(command, true) + configure_help(command, 0) } -fn configure_help(command: Command, root: bool) -> Command { - let command = if root { +fn configure_help(command: Command, depth: usize) -> Command { + let command = if depth == 0 { command } else { command.disable_help_flag(false) }; + let command = if depth == 1 && command.has_subcommands() { + command.after_help(super::AGENT_HELP_FOOTER) + } else { + command + }; command .disable_help_subcommand(true) - .mut_subcommands(|subcommand| configure_help(subcommand, false)) + .mut_subcommands(|subcommand| configure_help(subcommand, depth + 1)) } pub(super) fn print_requested_help(args: &[String]) -> std::io::Result<bool> { @@ -1307,6 +1312,23 @@ mod tests { } #[test] + fn agent_resources_appear_on_command_groups_but_not_leaf_commands() { + for group in ["agent", "pane", "workspace", "terminal"] { + let help = long_help(&[group]); + assert!( + help.contains(super::super::AGENT_HELP_FOOTER), + "herdr {group} is missing agent resources: {help}" + ); + } + + let leaf = long_help(&["agent", "wait"]); + assert!( + !leaf.contains(super::super::AGENT_HELP_FOOTER), + "leaf help should stay focused: {leaf}" + ); + } + + #[test] fn next_step_hints_render_without_replacing_existing_after_help() { let agent_start = long_help(&["agent", "start"]); assert!( diff --git a/src/main.rs b/src/main.rs index d3b72192..868c0b5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -715,7 +715,8 @@ fn main() -> io::Result<()> { println!("Logs: {}", logging::help_log_paths_summary()); println!("Env: HERDR_CONFIG_PATH overrides config file path"); println!("Home: https://herdr.dev"); - println!("Skill: herdr --skill prints agent instructions for driving herdr from a pane"); + println!(); + println!("{}", cli::AGENT_HELP_FOOTER); return Ok(()); } |
