Skip to main content

cargo_ravenrs/
lib.rs

1//! Offline project generation and version-matched AI tooling for RavenRS.
2mod ai;
3mod mcp;
4mod project;
5
6pub use ai::configure_ai;
7pub use mcp::doctor;
8pub use project::{new_project, project_files};
9
10/// Version of the generator executable.
11pub const CLI_VERSION: &str = env!("CARGO_PKG_VERSION");
12/// Framework version shared by templates, skill and the embedded MCP server.
13/// The CLI package may receive independent fixes without republishing the framework.
14pub const VERSION: &str = ravenrs_project::RAVENRS_VERSION;
15/// Skill embedded from the plugin in this release.
16pub const SKILL: &str = include_str!("../../../plugins/ravenrs/skills/ravenrs/SKILL.md");
17/// Toolchain shared by every template.
18pub const TOOLCHAIN: &str = include_str!("../../../rust-toolchain.toml");
19
20fn read(path: &std::path::Path) -> Result<String, String> {
21    std::fs::read_to_string(path).map_err(|e| format!("{}: {e}", path.display()))
22}
23
24fn write(root: &std::path::Path, path: &str, contents: &str) -> Result<(), String> {
25    let path = root.join(path);
26    if let Some(parent) = path.parent() {
27        std::fs::create_dir_all(parent).map_err(|e| e.to_string())?;
28    }
29    std::fs::write(&path, contents).map_err(|e| format!("{}: {e}", path.display()))
30}
31
32fn run(root: &std::path::Path, command: &str, args: &[&str]) -> Result<(), String> {
33    let status = std::process::Command::new(command)
34        .args(args)
35        .current_dir(root)
36        .status()
37        .map_err(|e| format!("{command}: {e}"))?;
38    if status.success() { Ok(()) } else { Err(format!("{command} {}: {status}", args.join(" "))) }
39}