|
1 | | -"""CLI commands for ralphify — init, run, status, and scaffold new primitives. |
| 1 | +"""CLI commands for ralphify — init, run, and scaffold new primitives. |
2 | 2 |
|
3 | 3 | This is the main module. The ``run`` command delegates to the engine module |
4 | 4 | for the core autonomous loop. Terminal rendering of events is handled by |
|
10 | 10 | import sys |
11 | 11 | import tomllib |
12 | 12 | import uuid |
13 | | -from collections.abc import Callable |
14 | 13 | from pathlib import Path |
15 | | -from typing import TypeVar |
16 | 14 |
|
17 | 15 | import typer |
18 | 16 | from rich.console import Console |
19 | 17 |
|
20 | 18 | from ralphify import __version__ |
21 | 19 | from ralphify._console_emitter import ConsoleEmitter |
22 | | -from ralphify._discovery import Primitive |
23 | 20 | from ralphify._frontmatter import CONFIG_FILENAME |
24 | | -from ralphify.checks import discover_checks |
25 | | -from ralphify.contexts import discover_contexts |
26 | 21 | from ralphify._run_types import RunConfig, RunState |
27 | 22 | from ralphify.engine import run_loop |
28 | | -from ralphify.ralphs import discover_ralphs, resolve_ralph_source |
| 23 | +from ralphify.ralphs import resolve_ralph_source |
29 | 24 | from ralphify.detector import detect_project |
30 | 25 | from ralphify._templates import ( |
31 | 26 | ROOT_RALPH_TEMPLATE, |
|
64 | 59 | ] |
65 | 60 |
|
66 | 61 |
|
67 | | -_P = TypeVar("_P", bound=Primitive) |
68 | | - |
69 | | - |
70 | | -def _print_primitives_section(label: str, items: list[_P], detail_fn: Callable[[_P], str]) -> None: |
71 | | - """Print a status section for discovered primitives.""" |
72 | | - if items: |
73 | | - rprint(f"\n[bold]{label}:[/bold] {len(items)} found") |
74 | | - for item in items: |
75 | | - icon = "[green]✓[/green]" if item.enabled else "[dim]○[/dim]" |
76 | | - rprint(f" {icon} {item.name:<18} {detail_fn(item)}") |
77 | | - else: |
78 | | - rprint(f"\n[bold]{label}:[/bold] [dim]none[/dim]") |
79 | | - |
80 | | - |
81 | 62 | def _print_banner() -> None: |
82 | 63 | width = shutil.get_terminal_size().columns |
83 | 64 | art_width = max(len(line) for line in BANNER_LINES) |
@@ -174,54 +155,6 @@ def new( |
174 | 155 | os.execvp(cmd[0], cmd) |
175 | 156 |
|
176 | 157 |
|
177 | | -@app.command() |
178 | | -def status() -> None: |
179 | | - """Show current configuration and validate setup.""" |
180 | | - config = _load_config() |
181 | | - agent = config["agent"] |
182 | | - command = agent["command"] |
183 | | - args = agent.get("args", []) |
184 | | - ralph_file = agent["ralph"] |
185 | | - ralph_path = Path(ralph_file) |
186 | | - |
187 | | - rprint("[bold]Configuration[/bold]") |
188 | | - rprint(f" Command: [cyan]{command} {' '.join(args)}[/cyan]") |
189 | | - rprint(f" Ralph: [cyan]{ralph_file}[/cyan]") |
190 | | - |
191 | | - issues = [] |
192 | | - |
193 | | - if ralph_path.exists(): |
194 | | - size = len(ralph_path.read_text()) |
195 | | - rprint(f"\n[green]✓[/green] Ralph file exists ({size} chars)") |
196 | | - else: |
197 | | - issues.append("ralph") |
198 | | - rprint(f"\n[red]✗[/red] Ralph file '{ralph_file}' not found") |
199 | | - |
200 | | - if shutil.which(command): |
201 | | - rprint(f"[green]✓[/green] Command '{command}' found on PATH") |
202 | | - else: |
203 | | - issues.append("command") |
204 | | - rprint(f"[red]✗[/red] Command '{command}' not found on PATH") |
205 | | - |
206 | | - checks = discover_checks() |
207 | | - _print_primitives_section("Checks", checks, |
208 | | - lambda c: str(c.script.name) if c.script else c.command or "?") |
209 | | - |
210 | | - contexts = discover_contexts() |
211 | | - _print_primitives_section("Contexts", contexts, |
212 | | - lambda c: str(c.script.name) if c.script else c.command or "(static)") |
213 | | - |
214 | | - ralphs = discover_ralphs() |
215 | | - _print_primitives_section("Ralphs", ralphs, |
216 | | - lambda p: p.description or "(no description)") |
217 | | - |
218 | | - if issues: |
219 | | - rprint("\n[red]Not ready.[/red] Fix the issues above before running.") |
220 | | - raise typer.Exit(1) |
221 | | - else: |
222 | | - rprint("\n[green]Ready to run.[/green]") |
223 | | - |
224 | | - |
225 | 158 | @app.command() |
226 | 159 | def run( |
227 | 160 | prompt: str | None = typer.Argument(None, help="Named ralph from .ralphify/ralphs/."), |
@@ -256,6 +189,10 @@ def run( |
256 | 189 | rprint(f"[red]Prompt file '{ralph_file_path}' not found.[/red]") |
257 | 190 | raise typer.Exit(1) |
258 | 191 |
|
| 192 | + if not shutil.which(command): |
| 193 | + rprint(f"[red]Agent command '{command}' not found on PATH.[/red]") |
| 194 | + raise typer.Exit(1) |
| 195 | + |
259 | 196 | if log_dir: |
260 | 197 | rprint(f"[dim]Logging output to {log_dir}/[/dim]") |
261 | 198 |
|
|
0 commit comments