mirror of
https://github.com/katanemo/plano.git
synced 2026-05-18 13:45:15 +02:00
rewrite planoai CLI in Rust
Add crates/plano-cli/ as a full Rust rewrite of the Python CLI. Binary name: planoai. All subcommands ported: up, down, build, logs, cli-agent, trace, init. Config validation and Tera template rendering replace the Python config_generator. CI updated to use cargo test/build instead of Python test jobs.
This commit is contained in:
parent
406fa92802
commit
15b9e8b95c
37 changed files with 4658 additions and 91 deletions
105
crates/plano-cli/src/commands/build.rs
Normal file
105
crates/plano-cli/src/commands/build.rs
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
use std::process::Command;
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
|
||||
use crate::consts::plano_docker_image;
|
||||
use crate::utils::{find_repo_root, print_cli_header};
|
||||
|
||||
pub async fn run(docker: bool) -> Result<()> {
|
||||
let dim = console::Style::new().dim();
|
||||
let red = console::Style::new().red();
|
||||
let bold = console::Style::new().bold();
|
||||
|
||||
if !docker {
|
||||
print_cli_header();
|
||||
|
||||
let repo_root = find_repo_root().ok_or_else(|| {
|
||||
anyhow::anyhow!(
|
||||
"Could not find repository root. Make sure you're inside the plano repository."
|
||||
)
|
||||
})?;
|
||||
|
||||
let crates_dir = repo_root.join("crates");
|
||||
|
||||
// Check cargo is available
|
||||
if which::which("cargo").is_err() {
|
||||
eprintln!(
|
||||
"{} {} not found. Install Rust: https://rustup.rs",
|
||||
red.apply_to("✗"),
|
||||
bold.apply_to("cargo")
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
// Build WASM plugins
|
||||
eprintln!(
|
||||
"{}",
|
||||
dim.apply_to("Building WASM plugins (wasm32-wasip1)...")
|
||||
);
|
||||
let status = Command::new("cargo")
|
||||
.args([
|
||||
"build",
|
||||
"--release",
|
||||
"--target",
|
||||
"wasm32-wasip1",
|
||||
"-p",
|
||||
"llm_gateway",
|
||||
"-p",
|
||||
"prompt_gateway",
|
||||
])
|
||||
.current_dir(&crates_dir)
|
||||
.status()?;
|
||||
|
||||
if !status.success() {
|
||||
bail!("WASM build failed");
|
||||
}
|
||||
|
||||
// Build brightstaff
|
||||
eprintln!("{}", dim.apply_to("Building brightstaff (native)..."));
|
||||
let status = Command::new("cargo")
|
||||
.args(["build", "--release", "-p", "brightstaff"])
|
||||
.current_dir(&crates_dir)
|
||||
.status()?;
|
||||
|
||||
if !status.success() {
|
||||
bail!("brightstaff build failed");
|
||||
}
|
||||
|
||||
let wasm_dir = crates_dir.join("target/wasm32-wasip1/release");
|
||||
let native_dir = crates_dir.join("target/release");
|
||||
|
||||
println!("\n{}:", bold.apply_to("Build artifacts"));
|
||||
println!(" {}", wasm_dir.join("prompt_gateway.wasm").display());
|
||||
println!(" {}", wasm_dir.join("llm_gateway.wasm").display());
|
||||
println!(" {}", native_dir.join("brightstaff").display());
|
||||
} else {
|
||||
let repo_root =
|
||||
find_repo_root().ok_or_else(|| anyhow::anyhow!("Could not find repository root."))?;
|
||||
|
||||
let dockerfile = repo_root.join("Dockerfile");
|
||||
if !dockerfile.exists() {
|
||||
bail!("Dockerfile not found at {}", dockerfile.display());
|
||||
}
|
||||
|
||||
println!("Building plano image from {}...", repo_root.display());
|
||||
let status = Command::new("docker")
|
||||
.args([
|
||||
"build",
|
||||
"-f",
|
||||
&dockerfile.to_string_lossy(),
|
||||
"-t",
|
||||
&plano_docker_image(),
|
||||
&repo_root.to_string_lossy(),
|
||||
"--add-host=host.docker.internal:host-gateway",
|
||||
])
|
||||
.status()?;
|
||||
|
||||
if !status.success() {
|
||||
bail!("Docker build failed");
|
||||
}
|
||||
|
||||
println!("plano image built successfully.");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue