Skip to main content

semora_cli/commands/
skill.rs

1//! `semora skill`: the agent guide (same text as the server's `/docs.md`).
2
3use crate::config::origin;
4use crate::{Ctx, exit};
5
6pub const TEXT: &str = semora_proto::GUIDE;
7
8/// The guide with the configured server in place of the example host.
9pub fn text(ctx: &Ctx) -> String {
10    match &ctx.settings.server {
11        Some(server) => {
12            let base = origin(server);
13            let ws = match base.strip_prefix("https://") {
14                Some(rest) => format!("wss://{rest}"),
15                None => base.replacen("http://", "ws://", 1),
16            };
17            TEXT.replace("wss://semora.example.com", &ws)
18                .replace("https://semora.example.com", &base)
19        }
20        None => TEXT.to_string(),
21    }
22}
23
24pub fn run(ctx: &Ctx) -> anyhow::Result<i32> {
25    print!("{}", text(ctx));
26    Ok(exit::OK)
27}