Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions hermes_cli/kanban.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,16 @@ def build_parser(parent_subparsers: argparse._SubParsersAction) -> argparse.Argu
help="Permanently delete already-archived task ids from the board",
)

p_delete = sub.add_parser(
"delete",
help="Permanently delete already-archived tasks",
)
p_delete.add_argument(
"task_ids",
nargs="+",
help="Already-archived task ids to permanently delete",
)

# --- tail ---
p_tail = sub.add_parser("tail", help="Follow a task's event stream")
p_tail.add_argument("task_id")
Expand Down Expand Up @@ -1007,6 +1017,7 @@ def kanban_command(args: argparse.Namespace) -> int:
"unblock": _cmd_unblock,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add the new task-level delete action to _DELEGATED_CHILD_DENIED_ACTIONS. archive is already denied there, and the CLI fast-fail at current hermes_cli/kanban.py:981-988 should cover this destructive alias too; the DB guard remains the durable backstop.

"promote": _cmd_promote,
"archive": _cmd_archive,
"delete": _cmd_delete,
"tail": _cmd_tail,
"dispatch": _cmd_dispatch,
"daemon": _cmd_daemon,
Expand Down Expand Up @@ -2267,6 +2278,19 @@ def _cmd_archive(args: argparse.Namespace) -> int:
return 0 if not failed else 1


def _cmd_delete(args: argparse.Namespace) -> int:
"""Permanently delete archived tasks via the explicit CLI verb."""
failed: list[str] = []
with kb.connect_closing() as conn:
for tid in args.task_ids:
if not kb.delete_archived_task(conn, tid):
failed.append(tid)
print(f"cannot delete {tid} (must already be archived)", file=sys.stderr)
else:
print(f"Deleted {tid}")
return 0 if not failed else 1


def _cmd_tail(args: argparse.Namespace) -> int:
last_id = 0
print(f"Tailing events for {args.task_id}. Ctrl-C to stop.")
Expand Down
18 changes: 18 additions & 0 deletions tests/hermes_cli/test_kanban_core_functionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,24 @@ def test_cli_archive_rm_deletes_archived_tasks(kanban_home):
conn.close()


def test_cli_delete_removes_archived_task(kanban_home):
conn = kb.connect()
try:
tid = kb.create_task(conn, title="gone")
assert kb.archive_task(conn, tid)
finally:
conn.close()

out = run_slash(f"delete {tid}")

assert f"Deleted {tid}" in out
conn = kb.connect()
try:
assert kb.get_task(conn, tid) is None
finally:
conn.close()


def test_cli_archive_rm_rejects_live_tasks(kanban_home):
conn = kb.connect()
try:
Expand Down