//! `/help` (hub spec ยง6.3): getting started with this hub's own address, //! remote name and certificate filled in, the keyboard, and a glossary //! for people coming from GitHub. use super::repo::Quickstart; use super::{Page, Shell}; use crate::auth::Viewer; use crate::Shared; use askama::Template; use axum::extract::State; #[derive(Template)] #[template(path = "help.html")] pub struct HelpPage { shell: Shell, q: Quickstart, base: String, /// The signed-in user, or a placeholder, for example URLs. who: String, } pub async fn help(State(app): State, viewer: Viewer) -> Page { let shell = Shell::new(&app, "/help", &viewer); let who = shell.user.clone().unwrap_or_else(|| "OWNER".into()); let base = app.config.base_url().trim_end_matches('/').to_string(); Page(HelpPage { shell, q: Quickstart::new(&app, true), base, who }) } impl HelpPage { /// An example repository address on this hub. pub fn repo_url(&self) -> String { format!("{}/{}/REPOSITORY", self.base, self.who) } /// An agent's own home, keyless, with its grant kept (#287). pub fn agent_home_cmd(&self) -> String { format!( "export OXY_HOME=~/.oxy-agents/claude\noxy config --user author.signer keyless\noxy config --user keyless.hub {base}\noxy config --user core.sign seal\noxy auth grant {base} # paste the token, then Ctrl-D", base = self.base ) } /// A repository's trust policy admitting an agent's certified keys (#287). pub fn subject_grant_cmd(&self) -> String { format!( "curl -fsSL {}/.well-known/oxyhub-key -o hub.identity\noxy policy grant-subject agent:claude@{} --issuer hub.identity --scope changes,refs", self.base, self.who ) } pub fn delegate_cmd(&self) -> String { format!( "curl -fsSL {}/.well-known/oxyhub-key -o hub.identity\noxy identity delegate add hub.identity --scope changes,refs", self.base ) } pub fn clone_cmd(&self) -> String { let url = self.repo_url(); match &self.q.ca_url { Some(_) => format!("OXY_CA={} oxy clone {url}", self.q.ca_file), None => format!("oxy clone {url}"), } } }