jarvis init — detect hardware, generate config, write to disk.
Functions
init
init(force: bool, config: Optional[Path], full_config: bool = False) -> None
Detect hardware and generate ~/.openjarvis/config.toml.
Source code in src/openjarvis/cli/init_cmd.py
| @click.command()
@click.option(
"--force", is_flag=True, help="Overwrite existing config without prompting."
)
@click.option(
"--config",
type=click.Path(exists=True),
help="Path to config file to use.",
)
@click.option(
"--full",
"full_config",
is_flag=True,
help="Generate full reference config with all sections",
)
def init(force: bool, config: Optional[Path], full_config: bool = False) -> None:
"""Detect hardware and generate ~/.openjarvis/config.toml."""
console = Console()
if DEFAULT_CONFIG_PATH.exists() and not force:
console.print(
f"[yellow]Config already exists at {DEFAULT_CONFIG_PATH}[/yellow]"
)
console.print("Use [bold]--force[/bold] to overwrite.")
raise SystemExit(1)
console.print("[bold]Detecting hardware...[/bold]")
hw = detect_hardware()
console.print(f" Platform : {hw.platform}")
console.print(f" CPU : {hw.cpu_brand} ({hw.cpu_count} cores)")
console.print(f" RAM : {hw.ram_gb} GB")
if hw.gpu:
mem_label = "unified memory" if hw.gpu.vendor == "apple" else "VRAM"
gpu = hw.gpu
console.print(
f" GPU : {gpu.name} ({gpu.vram_gb} GB {mem_label}, x{gpu.count})"
)
else:
console.print(" GPU : none detected")
if config:
toml_content = config.read_text()
else:
if full_config:
toml_content = generate_default_toml(hw)
else:
toml_content = generate_minimal_toml(hw)
DEFAULT_CONFIG_DIR.mkdir(parents=True, exist_ok=True)
if config:
config.write_text(toml_content)
else:
DEFAULT_CONFIG_PATH.write_text(toml_content)
console.print()
console.print(
Panel(toml_content, title=str(DEFAULT_CONFIG_PATH), border_style="green")
)
console.print("[green]Config written successfully.[/green]")
engine = recommend_engine(hw)
model = recommend_model(hw, engine)
if model:
console.print(f"\n [bold]Recommended model:[/bold] {model}")
console.print()
console.print(
Panel(
_next_steps_text(engine, model),
title="Getting Started",
border_style="cyan",
)
)
|