zig-core 0.11.0

Core library for zig — workflow orchestration engine for AI coding agents
Documentation
/// Embedded manpage content, compiled from `manpages/` markdown files.
mod pages {
    pub const ZIG: &str = include_str!("../manpages/zig.md");
    pub const RUN: &str = include_str!("../manpages/run.md");
    pub const CONTINUE: &str = include_str!("../manpages/continue.md");
    pub const LISTEN: &str = include_str!("../manpages/listen.md");
    pub const SERVE: &str = include_str!("../manpages/serve.md");
    pub const WORKFLOW: &str = include_str!("../manpages/workflow.md");
    pub const VALIDATE: &str = include_str!("../manpages/validate.md");
    pub const RESOURCES: &str = include_str!("../manpages/resources.md");
    pub const MEMORY: &str = include_str!("../manpages/memory.md");
    pub const SELF: &str = include_str!("../manpages/self.md");
}

/// All available manpage topics in display order.
pub const TOPICS: &[(&str, &str)] = &[
    ("zig", "Overview of the zig CLI"),
    ("run", "Execute a .zwf/.zwfz workflow file"),
    (
        "continue",
        "Resume the most recent step's agent conversation from the last run",
    ),
    ("listen", "Tail a running or completed zig session"),
    ("serve", "Start an HTTP API server"),
    (
        "workflow",
        "Manage workflows (list, show, create, update, delete, pack)",
    ),
    ("validate", "Validate a .zwf or .zwfz workflow file"),
    (
        "resources",
        "Manage reference files advertised to step agents",
    ),
    (
        "memory",
        "Manage the memory scratch pad for workflows and steps",
    ),
    (
        "self",
        "Commands that act on the currently running zig/zag session",
    ),
];

/// Look up a manpage by topic name.
///
/// Returns the markdown content if the topic exists, or `None`.
pub fn get(topic: &str) -> Option<&'static str> {
    match topic {
        "zig" => Some(pages::ZIG),
        "run" => Some(pages::RUN),
        "continue" => Some(pages::CONTINUE),
        "listen" => Some(pages::LISTEN),
        "serve" => Some(pages::SERVE),
        "workflow" => Some(pages::WORKFLOW),
        "validate" => Some(pages::VALIDATE),
        "resources" => Some(pages::RESOURCES),
        "memory" => Some(pages::MEMORY),
        "self" => Some(pages::SELF),
        _ => None,
    }
}

/// List all available manpage topics with their descriptions.
pub fn list_topics() -> String {
    let mut out = String::from("Available manpages:\n\n");
    let max_name_len = TOPICS.iter().map(|(name, _)| name.len()).max().unwrap_or(0);
    for (name, description) in TOPICS {
        out.push_str(&format!(
            "  {name:<width$}  {description}\n",
            width = max_name_len
        ));
    }
    out.push_str("\nUsage: zig man <topic>");
    out
}

#[cfg(test)]
#[path = "man_tests.rs"]
mod tests;