The agent that turns websites into APIs!
feat(cli): add `list` subcommand for script/run discovery
kalil03213a26e3e61cba
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5b622ef..9759330 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).+## [0.4.0] - 2026-03-10++### Added+- **`list` CLI subcommand**: Non-interactive command to list generated scripts and runs+ - Rich table output (compact and full modes) and JSON output (`--json`)+ - Filter by mode (`--mode`), model (`--model`), prompt search (`--search`), and limit (`--limit`)+ - Shows script directory paths, file counts, and local path detection+## [0.3.3] - 2026-03-10### Addeddiff --git a/pyproject.toml b/pyproject.tomlindex fb20567..c82894a 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[project]name = "reverse-api-engineer"-version = "0.3.3"+version = "0.4.0"description = "A tool to capture browser traffic for API reverse engineering"readme = "README.md"requires-python = ">=3.11"diff --git a/src/reverse_api/cli.py b/src/reverse_api/cli.pyindex 67be552..0bf0e0a 100644--- a/src/reverse_api/cli.py+++ b/src/reverse_api/cli.py@@ -1,4 +1,5 @@import asyncio+import jsonimport refrom pathlib import Path@@ -36,6 +37,7 @@ from .utils import (generate_folder_name,generate_run_id,get_actions_path,+ get_base_output_dir,get_config_path,get_har_dir,get_history_path,@@ -1730,6 +1732,126 @@ def run_engineer(return result+def _get_run_details(run: dict) -> dict:+ """Enrich a history entry with filesystem info."""+ run_id = run.get("run_id", "")+ output_dir = config_manager.get("output_dir")+ base_dir = get_base_output_dir(output_dir)+ script_dir = base_dir / "scripts" / run_id++ files = []+ if script_dir.exists():+ files = sorted(f.name for f in script_dir.iterdir() if f.is_file())++ # Scan ./scripts/ subdirectories to find local copy+ local_path = None+ local_scripts = Path.cwd() / "scripts"+ if local_scripts.exists() and files:+ files_set = set(files)+ for subdir in local_scripts.iterdir():+ if subdir.is_dir():+ local_files = {f.name for f in subdir.iterdir() if f.is_file()}+ if local_files and local_files == files_set:+ local_path = f"./scripts/{subdir.name}/"+ break++ usage = run.get("usage", {})+ cost = usage.get("total_cost", usage.get("cost"))++ return {+ "run_id": run_id,+ "prompt": run.get("prompt", ""),+ "timestamp": run.get("timestamp", ""),+ "model": run.get("model", ""),+ "mode": run.get("mode", ""),+ "sdk": run.get("sdk", ""),+ "cost": cost,+ "script_dir": str(script_dir),+ "files": files,+ "file_count": len(files),+ "local_path": local_path,+ }++[email protected]("list")[email protected]("--json", "as_json", is_flag=True, help="Output as flat JSON array.")[email protected]("--full", is_flag=True, help="Show all columns (default: compact view).")[email protected]("--limit", "-n", type=int, default=None, help="Limit number of results.")[email protected]("--mode", "-m", type=str, default=None, help="Filter by mode (auto/manual/agent/engineer/collector).")[email protected]("--model", type=str, default=None, help="Filter by model name.")[email protected]("--search", "-s", type=str, default=None, help="Case-insensitive substring match on prompt.")+def list_runs(as_json, full, limit, mode, model, search):+ """List generated scripts and runs with optional filters."""+ from rich.table import Table++ runs = list(session_manager.history)++ if mode:+ runs = [r for r in runs if r.get("mode", "") == mode]+ if model:+ runs = [r for r in runs if model.lower() in (r.get("model") or "").lower()]+ if search:+ runs = [r for r in runs if search.lower() in (r.get("prompt") or "").lower()]++ if not runs:+ if not session_manager.history:+ console.print("No runs found.", style="dim")+ else:+ console.print("No matching runs found.")+ return++ if limit is not None:+ runs = runs[:limit]++ results = [_get_run_details(r) for r in runs]++ if as_json:+ click.echo(json.dumps(results, indent=2))+ return++ if full:+ table = Table(show_lines=False)+ table.add_column("run_id", style="cyan")+ table.add_column("prompt", max_width=40)+ table.add_column("timestamp")+ table.add_column("model")+ table.add_column("mode")+ table.add_column("sdk")+ table.add_column("cost", justify="right")+ table.add_column("script_dir")+ table.add_column("files", justify="right")+ for r in results:+ prompt = r["prompt"][:40] + ("..." if len(r["prompt"]) > 40 else "")+ cost_str = f"${r['cost']:.2f}" if r["cost"] is not None else ""+ table.add_row(+ r["run_id"],+ prompt,+ r["timestamp"],+ r["model"] or "",+ r["mode"] or "",+ r["sdk"] or "",+ cost_str,+ r["script_dir"],+ str(r["file_count"]),+ )+ else:+ table = Table(show_lines=False)+ table.add_column("run_id", style="cyan")+ table.add_column("prompt", max_width=40)+ table.add_column("timestamp")+ table.add_column("script_dir")+ for r in results:+ prompt = r["prompt"][:40] + ("..." if len(r["prompt"]) > 40 else "")+ table.add_row(+ r["run_id"],+ prompt,+ r["timestamp"],+ r["script_dir"],+ )++ console.print(table)++@main.command("install-host")@click.option("--extension-id",diff --git a/uv.lock b/uv.lockindex 94d7a12..31a2384 100644--- a/uv.lock+++ b/uv.lock@@ -2189,7 +2189,7 @@ wheels = [[[package]]name = "reverse-api-engineer"-version = "0.3.2"+version = "0.4.0"source = { editable = "." }dependencies = [{ name = "aiohttp" },