commit remaining modified project files

This commit is contained in:
windyboy
2026-04-07 08:07:18 +08:00
parent d010cf936c
commit fb128c70d6
28 changed files with 4140 additions and 19643 deletions
+49
View File
@@ -84,6 +84,11 @@ def _command_error(ctx: CLIContext, user_message: str, logger_message: str, *, e
raise SystemExit(1)
def _review_plan_tui_streams_ok() -> bool:
"""Return True if stdin/stdout appear to be an interactive terminal."""
return sys.stdin.isatty() and sys.stdout.isatty()
def _load_or_create_config(config: Path) -> Config:
"""Load configuration from disk or create a default config file."""
if config.exists():
@@ -527,6 +532,12 @@ def plan(ctx: CLIContext, input: Path, output: Path, analysis: Path | None):
default=False,
help='Show all high-risk operations in console preview'
)
@click.option(
'--tui',
is_flag=True,
default=False,
help='Interactive Textual UI (requires: uv pip install -e ".[tui]")'
)
@pass_context
def review_plan_cmd(
ctx: CLIContext,
@@ -536,6 +547,7 @@ def review_plan_cmd(
episode_threshold: int,
preview_limit: int,
show_all: bool,
tui: bool,
):
"""Review a plan and export high-risk operations for manual confirmation."""
from vlm.planner import load_plan
@@ -552,6 +564,19 @@ def review_plan_cmd(
click.echo("Error: --preview-limit must be >= 1", err=True)
sys.exit(1)
if tui:
if not _review_plan_tui_streams_ok():
click.echo("Error: --tui requires an interactive terminal (TTY)", err=True)
sys.exit(1)
try:
from textual.app import App as _TextualApp # noqa: F401
except ImportError:
click.echo(
'Error: Textual is not installed. Install with: uv pip install -e ".[tui]"',
err=True,
)
sys.exit(1)
click.echo(f"Loading plan: {input}")
execution_plan = load_plan(input)
rows, counters = review_plan(
@@ -560,6 +585,30 @@ def review_plan_cmd(
episode_threshold=episode_threshold,
)
if tui:
from vlm.review_tui import ReviewTUIContext, run_plan_review_tui
tui_ctx = ReviewTUIContext(
rows=rows,
counters=counters,
library_root=ctx.config.library_root,
output_csv=output,
plan_input=input,
summary_text=preferred_plan_summary(execution_plan),
)
rc = run_plan_review_tui(tui_ctx)
if rc != 0:
click.echo("Plan review aborted (no CSV written).", err=True)
sys.exit(rc)
click.echo(f"Saved manual review CSV to: {output}")
logger.info(
"Plan review TUI completed: total=%s high_risk=%s output=%s",
counters["total_operations"],
counters["high_risk_operations"],
output,
)
return
save_review_csv(rows, output)
click.echo()