use super::agent::Agent;
use super::assets::{skill_description, skill_md_body};
const RULE_NOTE: &str = "> **Single-file install.** The `references/` packs, `templates/`, and \
`themes/` ship with the full folder skill (Claude Code, Codex, OpenCode) and live in the \
[repo](https://github.com/zenitheditor/zenith). In this agent, drive the self-documenting \
`zenith` CLI directly — run `zenith --help` and `zenith <command> --help` for exact flags, \
and read the repo's `examples/*.zen` for syntax.";
pub fn render_rule(agent: Agent) -> String {
let body = skill_md_body();
let desc = skill_description().unwrap_or_default();
match agent {
Agent::Cursor => format!(
"---\nalwaysApply: false\ndescription: {desc}\n---\n\n{RULE_NOTE}\n\n{body}",
desc = yaml_scalar(&desc),
),
Agent::Windsurf => format!("{RULE_NOTE}\n\n{body}"),
Agent::Aider
| Agent::Zed
| Agent::Gemini
| Agent::Copilot
| Agent::Continue
| Agent::Kiro
| Agent::Antigravity => format!("# Zenith\n\n{RULE_NOTE}\n\n{body}"),
Agent::ClaudeCode | Agent::Codex | Agent::OpenCode => body.to_owned(),
}
}
fn yaml_scalar(s: &str) -> String {
let needs = s.contains(':')
|| s.contains('#')
|| s.contains('"')
|| s.contains('\'')
|| s.starts_with(char::is_whitespace)
|| s.ends_with(char::is_whitespace);
if needs {
format!("\"{}\"", s.replace('\\', "\\\\").replace('"', "\\\""))
} else {
s.to_owned()
}
}