diff --git a/features/project_cli_commands.feature b/features/project_cli_commands.feature index b6b48be2f..14f12022b 100644 --- a/features/project_cli_commands.feature +++ b/features/project_cli_commands.feature @@ -196,6 +196,11 @@ Feature: Project CLI command functions coverage When I invoke project-delete for "local/del-json" with yes format "json" Then the project cmd output should contain "deleted" + Scenario: delete command JSON includes deletion timestamp + Given a project "local/del-json-ts" is created in the commands DB + When I invoke project-delete for "local/del-json-ts" with yes format "json" + Then the project cmd JSON data should include deleted_at + Scenario: delete nonexistent project fails When I invoke project-delete for "local/nope" with yes Then the project cmd should fail diff --git a/features/steps/project_cli_commands_steps.py b/features/steps/project_cli_commands_steps.py index 2a4e4e44e..180f23ee2 100644 --- a/features/steps/project_cli_commands_steps.py +++ b/features/steps/project_cli_commands_steps.py @@ -12,6 +12,7 @@ database, then restored after every step that needs them. from __future__ import annotations +import json from io import StringIO from typing import Any @@ -675,3 +676,22 @@ def step_cmd_fail(context: Any) -> None: assert context._cmd_failed, ( f"Expected command to fail but it succeeded. Output:\n{context._cmd_output}" ) + + +@then("the project cmd JSON data should include deleted_at") +def step_cmd_json_has_deleted_at(context: Any) -> None: + output = context._cmd_output.strip() + try: + envelope = json.loads(output) + except json.JSONDecodeError as exc: + raise AssertionError( + f"Command output is not valid JSON:\n{context._cmd_output}" + ) from exc + + data = envelope.get("data") + assert isinstance(data, dict), ( + f"Expected envelope data to be a dict, got {type(data).__name__}: {data}" + ) + assert "deleted_at" in data, ( + f"Expected 'deleted_at' in command JSON data, got keys {list(data.keys())}" + ) diff --git a/src/cleveragents/cli/commands/project.py b/src/cleveragents/cli/commands/project.py index fd06e4924..d03ac5ef6 100644 --- a/src/cleveragents/cli/commands/project.py +++ b/src/cleveragents/cli/commands/project.py @@ -19,6 +19,7 @@ Based on ADR-009 (CLI Framework) and implementation_plan.md task B0.cli.projects from __future__ import annotations import re +from datetime import UTC, datetime from pathlib import Path from typing import Annotated, Any @@ -977,4 +978,13 @@ def delete( if output_format.lower() == OutputFormat.RICH: console.print(f"[green]✓[/green] Project '{name}' deleted.") else: - console.print(format_output({"deleted": name, "success": True}, output_format)) + console.print( + format_output( + { + "deleted": name, + "success": True, + "deleted_at": datetime.now(tz=UTC), + }, + output_format, + ) + )