Skip to content

Independent Auditing of AI Agents. Run by human or the agent itself, to answer the most crucial question in the AI Agent Economy. Is the agent doing what is supposed to do? With iFixAi you can have this answer in less than 120 seconds.

fix(cli): create missing parent directories for --artifact-out (#333)

Rudy Mizrahi Celekli8d87b2495833
diff --git a/ifixai/cli/run.py b/ifixai/cli/run.py
index 93568bf..c7d1449 100644
--- a/ifixai/cli/run.py
+++ b/ifixai/cli/run.py
@@ -2116,6 +2116,8 @@ def run(
if result.self_judged
else ""
)
+ # Match save_reports, which creates the -o directory on demand.
+ Path(artifact_out).parent.mkdir(parents=True, exist_ok=True)
Path(artifact_out).write_text(
render_artifact(
result,
diff --git a/ifixai/tests/test_cli_report_destinations.py b/ifixai/tests/test_cli_report_destinations.py
index f1d2e6e..627dcfe 100644
--- a/ifixai/tests/test_cli_report_destinations.py
+++ b/ifixai/tests/test_cli_report_destinations.py
@@ -118,3 +118,15 @@ def test_write_only_destinations_keep_existing_permission_policy(tmp_path, monke
assert "Interactive artifact ->" in result.output
assert len(list(output.glob("*.json"))) == 1
assert "<html" in artifact.read_text(encoding="utf-8").lower()
+
+
+def test_artifact_parent_directory_is_created_like_report_output(tmp_path, monkeypatch, owned_endpoint):
+ endpoint, calls = owned_endpoint
+ output = tmp_path / "new" / "reports"
+ artifact = tmp_path / "new" / "artifacts" / "scorecard.html"
+ result = invoke(tmp_path, monkeypatch, endpoint, ["--output", str(output), "--artifact-out", str(artifact)])
+ assert calls, result.output
+ assert result.exception is None or isinstance(result.exception, SystemExit), result.exception
+ assert "Interactive artifact ->" in result.output
+ assert "Run manifest" in result.output
+ assert "<html" in artifact.read_text(encoding="utf-8").lower()