mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-18 04:41:56 +00:00
fix(kanban): parse include_archived explicitly
This commit is contained in:
parent
236cbe16b6
commit
26bf45f8c5
2 changed files with 63 additions and 1 deletions
|
|
@ -180,6 +180,52 @@ def test_list_rejects_bad_limit(worker_env):
|
|||
assert json.loads(kt._handle_list({"limit": 0})).get("error")
|
||||
|
||||
|
||||
def test_list_parses_include_archived_string_false(worker_env):
|
||||
from hermes_cli import kanban_db as kb
|
||||
conn = kb.connect()
|
||||
try:
|
||||
live = kb.create_task(conn, title="live task", assignee="factory")
|
||||
archived = kb.create_task(conn, title="archived task", assignee="factory")
|
||||
assert kb.archive_task(conn, archived)
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
from tools import kanban_tools as kt
|
||||
out = kt._handle_list({
|
||||
"assignee": "factory",
|
||||
"include_archived": "false",
|
||||
})
|
||||
ids = [t["id"] for t in json.loads(out)["tasks"]]
|
||||
assert live in ids
|
||||
assert archived not in ids
|
||||
|
||||
|
||||
def test_list_parses_include_archived_string_true(worker_env):
|
||||
from hermes_cli import kanban_db as kb
|
||||
conn = kb.connect()
|
||||
try:
|
||||
live = kb.create_task(conn, title="live task", assignee="factory")
|
||||
archived = kb.create_task(conn, title="archived task", assignee="factory")
|
||||
assert kb.archive_task(conn, archived)
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
from tools import kanban_tools as kt
|
||||
out = kt._handle_list({
|
||||
"assignee": "factory",
|
||||
"include_archived": "true",
|
||||
})
|
||||
ids = [t["id"] for t in json.loads(out)["tasks"]]
|
||||
assert live in ids
|
||||
assert archived in ids
|
||||
|
||||
|
||||
def test_list_rejects_bad_include_archived(worker_env):
|
||||
from tools import kanban_tools as kt
|
||||
out = kt._handle_list({"include_archived": "sometimes"})
|
||||
assert "include_archived must be" in json.loads(out).get("error", "")
|
||||
|
||||
|
||||
def test_complete_happy_path(worker_env):
|
||||
from tools import kanban_tools as kt
|
||||
out = kt._handle_complete({
|
||||
|
|
|
|||
|
|
@ -145,6 +145,20 @@ def _normalize_profile(value: Any) -> Optional[str]:
|
|||
return text
|
||||
|
||||
|
||||
def _parse_bool_arg(args: dict, name: str, *, default: bool = False):
|
||||
value = args.get(name)
|
||||
if value is None:
|
||||
return default, None
|
||||
if isinstance(value, bool):
|
||||
return value, None
|
||||
text = str(value).strip().lower()
|
||||
if text in ("true", "1", "yes"):
|
||||
return True, None
|
||||
if text in ("false", "0", "no"):
|
||||
return False, None
|
||||
return default, f"{name} must be a boolean or 'true'/'false'"
|
||||
|
||||
|
||||
def _task_summary_dict(kb, conn, task) -> dict[str, Any]:
|
||||
"""Compact task shape for board-listing tools."""
|
||||
parents = kb.parent_ids(conn, task.id)
|
||||
|
|
@ -250,7 +264,9 @@ def _handle_list(args: dict, **kw) -> str:
|
|||
assignee = args.get("assignee")
|
||||
status = args.get("status")
|
||||
tenant = args.get("tenant")
|
||||
include_archived = bool(args.get("include_archived"))
|
||||
include_archived, bool_error = _parse_bool_arg(args, "include_archived")
|
||||
if bool_error:
|
||||
return tool_error(bool_error)
|
||||
limit = args.get("limit")
|
||||
if limit is not None:
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue