use std::io::{self, Write};
use crate::store::Registry;
pub fn llms_txt(registry: &Registry) -> String {
let mut out = Vec::new();
write_llms_txt(registry, &mut out).expect("writing to string never fails");
String::from_utf8(out).expect("llms.txt is valid UTF-8")
}
pub fn write_llms_txt(registry: &Registry, out: &mut impl Write) -> io::Result<()> {
out.write_all(b"# Offline Protocol\n\n")?;
out.write_all(
b"> Offline-first mesh networking, messaging, and identity SDKs. \
Build apps that work without internet using Bluetooth LE between nearby \
phones with internet relay fallback, MLS end-to-end encryption, and decentralized identity. \
Packages for React Native, React web, Python and Rust, with native Swift and Android \
packages and an embedded leaf crate in early preview.\n\n",
)?;
out.write_all(b"## Packages\n\n")?;
for p in registry.packages() {
writeln!(
out,
"- [{}](offline://packages/{}): v{} — {}",
p.name,
crate::store::man_key(&p.name),
p.version,
p.description
)?;
}
out.write_all(b"\n## Skills\n\n")?;
for s in registry.skills() {
writeln!(
out,
"- [{}](offline://skills/{}): {}",
s.title, s.name, s.description
)?;
}
out.write_all(b"\n## Workflows\n\n")?;
for w in registry.workflows() {
writeln!(
out,
"- [{}](offline://workflows/{}): {}",
w.title, w.name, w.description
)?;
}
out.write_all(b"\n## Templates\n\n")?;
for t in registry.templates() {
writeln!(
out,
"- [{}](offline://templates/{}): {} ({})",
t.title, t.name, t.description, t.platform
)?;
}
out.write_all(b"\n## Tooling\n\n")?;
out.write_all(b"- `offline` CLI: login, create, init, add, doctor, mcp serve\n")?;
out.write_all(
b"- MCP server: `offline mcp serve` (stdio) - tools for search, resolution, planning; all skills exposed as resources\n",
)?;
Ok(())
}
pub fn llms_full_txt(registry: &Registry) -> String {
let mut out = Vec::new();
write_llms_full_txt(registry, &mut out).expect("writing to string never fails");
String::from_utf8(out).expect("llms-full.txt is valid UTF-8")
}
pub fn write_llms_full_txt(registry: &Registry, out: &mut impl Write) -> io::Result<()> {
write_llms_txt(registry, out)?;
out.write_all(b"\n---\n\n# Full skill documents\n\n")?;
for s in registry.skills() {
write!(out, "\n## Skill: {}\n\n{}\n", s.title, s.body)?;
}
out.write_all(b"\n---\n\n# Workflow details\n\n")?;
for w in registry.workflows() {
write!(
out,
"\n## Workflow: {} (`{}`)\n\n{}\n\n",
w.title, w.name, w.description
)?;
write!(out, "Capabilities: {}\n\n", w.capabilities.join(", "))?;
for (platform, pkgs) in &w.packages {
writeln!(out, "Packages ({platform}): {}", pkgs.join(", "))?;
}
}
Ok(())
}