diff --git a/features/steps/actor_run_signature_resolve_steps.py b/features/steps/actor_run_signature_resolve_steps.py index 19b07f741..4e0cbbb58 100644 --- a/features/steps/actor_run_signature_resolve_steps.py +++ b/features/steps/actor_run_signature_resolve_steps.py @@ -28,6 +28,7 @@ with contextlib.suppress(ImportError, ModuleNotFoundError): resolve_config_files, ) + # --------------------------------------------------------------------------- @when("I call resolve_config_files with a config list") def step_resolve_with_config_list(context: Any) -> None: @@ -140,7 +141,9 @@ def step_resolve_with_no_config_data(context: Any) -> None: context.resolve_exit_code = 0 except (SystemExit, click.exceptions.Exit) as exc: context.resolve_exit_code = getattr( - exc, "exit_code", getattr(exc, "code", 1) + exc, + "exit_code", + getattr(exc, "code", 1), ) context.resolve_stderr = " ".join(captured_stderr) @@ -184,7 +187,9 @@ def step_resolve_unknown_actor_directly(context: Any) -> None: context.resolve_exit_code = 0 except (SystemExit, click.exceptions.Exit) as exc: context.resolve_exit_code = getattr( - exc, "exit_code", getattr(exc, "code", 1) + exc, + "exit_code", + getattr(exc, "code", 1), ) context.resolve_stderr = " ".join(captured_stderr) @@ -235,7 +240,9 @@ def step_resolve_with_empty_config_blob(context: Any) -> None: context.resolve_exit_code = 0 except (SystemExit, click.exceptions.Exit) as exc: context.resolve_exit_code = getattr( - exc, "exit_code", getattr(exc, "code", 1) + exc, + "exit_code", + getattr(exc, "code", 1), ) context.resolve_stderr = " ".join(captured_stderr) @@ -277,7 +284,9 @@ def step_resolve_with_empty_name(context: Any) -> None: context.empty_name_exit_code = 0 except (SystemExit, typer.Exit) as exc: context.empty_name_exit_code = getattr( - exc, "exit_code", getattr(exc, "code", 1) + exc, + "exit_code", + getattr(exc, "code", 1), ) context.resolve_stderr = " ".join(captured_stderr) @@ -331,7 +340,9 @@ def step_resolve_with_unserializable_config_blob(context: Any) -> None: context.resolve_exit_code = 0 except (SystemExit, click.exceptions.Exit) as exc: context.resolve_exit_code = getattr( - exc, "exit_code", getattr(exc, "code", 1) + exc, + "exit_code", + getattr(exc, "code", 1), ) context.resolve_stderr = " ".join(captured_stderr) diff --git a/features/steps/tui_persona_cycle_steps.py b/features/steps/tui_persona_cycle_steps.py index c29dc8dc5..e1465ad4c 100644 --- a/features/steps/tui_persona_cycle_steps.py +++ b/features/steps/tui_persona_cycle_steps.py @@ -21,9 +21,7 @@ def _registry_for_temp_dir(path: Path) -> PersonaRegistry: return PersonaRegistry(config_dir=path) -@given( - 'I save TUI persona "{name}" with actor "{actor}" and cycle order {cycle:d}' -) +@given('I save TUI persona "{name}" with actor "{actor}" and cycle order {cycle:d}') def step_save_persona_cycle( context: Context, name: str, actor: str, cycle: int ) -> None: diff --git a/src/cleveragents/cli/commands/actor.py b/src/cleveragents/cli/commands/actor.py index 8cbc2ab5b..dde96e901 100644 --- a/src/cleveragents/cli/commands/actor.py +++ b/src/cleveragents/cli/commands/actor.py @@ -185,7 +185,7 @@ def run( except UnsafeConfigurationError as exc: typer.echo(f"Error: {exc}", err=True) raise typer.Exit(code=1) from exc - except click.exceptions.Exit: + except (click.exceptions.Exit, typer.Exit): raise except CleverAgentsError as exc: typer.echo(f"Error: {exc}", err=True) diff --git a/src/cleveragents/cli/commands/actor_run.py b/src/cleveragents/cli/commands/actor_run.py index 14b2d2cf2..0131bd692 100644 --- a/src/cleveragents/cli/commands/actor_run.py +++ b/src/cleveragents/cli/commands/actor_run.py @@ -159,7 +159,7 @@ def run( except UnsafeConfigurationError as exc: typer.echo(f"Error: {exc}", err=True) raise typer.Exit(code=1) from exc - except click.exceptions.Exit: + except (click.exceptions.Exit, typer.Exit): raise except CleverAgentsError as exc: typer.echo(f"Error: {exc}", err=True) diff --git a/src/cleveragents/tui/persona/registry.py b/src/cleveragents/tui/persona/registry.py index 288cd61a5..a5172dd15 100644 --- a/src/cleveragents/tui/persona/registry.py +++ b/src/cleveragents/tui/persona/registry.py @@ -79,24 +79,24 @@ class PersonaRegistry: return result def resolve_export_path(self, output_path: Path) -> Path: - """Resolve export path, accepting both absolute and relative paths.""" - resolved = output_path.resolve() - # Allow absolute paths directly + """Resolve export path; only relative paths within cwd are accepted.""" if output_path.is_absolute(): - return resolved - # For relative paths, ensure they stay within working directory + raise ValueError( + "Export path must be relative to current working directory" + ) + resolved = output_path.resolve() base = Path.cwd().resolve() if not resolved.is_relative_to(base): raise ValueError("Export path must stay within working directory") return resolved def resolve_import_path(self, input_path: Path) -> Path: - """Resolve import path, accepting both absolute and relative paths.""" - resolved = input_path.resolve() - # Allow absolute paths directly + """Resolve import path; only relative paths within cwd are accepted.""" if input_path.is_absolute(): - return resolved - # For relative paths, ensure they stay within working directory + raise ValueError( + "Import path must be relative to current working directory" + ) + resolved = input_path.resolve() base = Path.cwd().resolve() if not resolved.is_relative_to(base): raise ValueError("Import path must stay within working directory") diff --git a/src/cleveragents/tui/persona/state.py b/src/cleveragents/tui/persona/state.py index a7e8b9bc9..a600e2180 100644 --- a/src/cleveragents/tui/persona/state.py +++ b/src/cleveragents/tui/persona/state.py @@ -72,7 +72,7 @@ class PersonaState: personas = self.registry.list_personas() cyclic = sorted( [p for p in personas if p.cycle_order > 0], - key=lambda p: p.cycle_order + key=lambda p: p.cycle_order, ) if not cyclic: