feat: implement Trello card management

Add 12 card management tools:
- trello_create_card — create a card on a list
- trello_card_details — view card with members, checklists, comments
- trello_update_card — update title, description, due date
- trello_move_card — move card to a different list
- trello_archive_card — archive a card
- trello_assign_member / trello_remove_member — member management
- trello_add_comment / trello_delete_comment — comments
- trello_add_checklist_item / trello_toggle_checklist_item / trello_delete_checklist_item

Also adds _delete() helper on TrelloClient for DELETE verbs.

73 total tests — all passing.

Issue: #4
This commit is contained in:
Marko (Hermes Implementer)
2026-05-26 22:42:50 +00:00
parent f2d65f8914
commit 034ed2c928
6 changed files with 1161 additions and 1 deletions
+265
View File
@@ -260,6 +260,259 @@ def trello_move_list(list_id: str, pos: str = "bottom") -> str:
return _respond(result)
# ---------------------------------------------------------------------------
# Tools — Card Management
# ---------------------------------------------------------------------------
def trello_create_card(name: str, list_id: str, desc: str = "", due: str | None = None) -> str:
"""Create a new card on a Trello list.
Parameters
----------
name : str
Card title.
list_id : str
List ID.
desc : str, optional
Card description.
due : str, optional
Due date in ISO 8601 format.
Returns
-------
str
JSON with card details.
"""
client = _get_client()
result = client.create_card(name=name, list_id=list_id, desc=desc, due=due)
return _respond(result)
def trello_card_details(card_id: str) -> str:
"""View detailed information about a Trello card.
Parameters
----------
card_id : str
Card ID.
Returns
-------
str
JSON with full card details including members, checklists, and comments.
"""
client = _get_client()
result = client.card_details(card_id=card_id)
return _respond(result)
def trello_update_card(card_id: str, name: str | None = None, desc: str | None = None, due: str | None = None) -> str:
"""Update a card's core attributes (title, description, due date).
Parameters
----------
card_id : str
Card ID.
name : str, optional
New title.
desc : str, optional
New description.
due : str, optional
New due date ISO 8601.
Returns
-------
str
JSON with updated card details.
"""
client = _get_client()
result = client.update_card(card_id=card_id, name=name, desc=desc, due=due)
return _respond(result)
def trello_move_card(card_id: str, list_id: str) -> str:
"""Move a card to a different list.
Parameters
----------
card_id : str
Card ID.
list_id : str
Target list ID.
Returns
-------
str
JSON with success message.
"""
client = _get_client()
result = client.move_card(card_id=card_id, list_id=list_id)
return _respond(result)
def trello_archive_card(card_id: str) -> str:
"""Archive a Trello card.
Parameters
----------
card_id : str
Card ID.
Returns
-------
str
JSON with success message.
"""
client = _get_client()
result = client.archive_card(card_id=card_id)
return _respond(result)
def trello_assign_member(card_id: str, member_id: str) -> str:
"""Add a member to a Trello card.
Parameters
----------
card_id : str
Card ID.
member_id : str
Trello member ID.
Returns
-------
str
JSON with success message.
"""
client = _get_client()
result = client.assign_member(card_id=card_id, member_id=member_id)
return _respond(result)
def trello_remove_member(card_id: str, member_id: str) -> str:
"""Remove a member from a Trello card.
Parameters
----------
card_id : str
Card ID.
member_id : str
Trello member ID.
Returns
-------
str
JSON with success message.
"""
client = _get_client()
result = client.remove_member(card_id=card_id, member_id=member_id)
return _respond(result)
def trello_add_comment(card_id: str, text: str) -> str:
"""Add a comment to a Trello card.
Parameters
----------
card_id : str
Card ID.
text : str
Comment text.
Returns
-------
str
JSON with comment ID.
"""
client = _get_client()
result = client.add_comment(card_id=card_id, text=text)
return _respond(result)
def trello_delete_comment(card_id: str, comment_id: str) -> str:
"""Delete a comment from a Trello card.
Parameters
----------
card_id : str
Card ID.
comment_id : str
Comment/action ID.
Returns
-------
str
JSON with success message.
"""
client = _get_client()
result = client.delete_comment(card_id=card_id, comment_id=comment_id)
return _respond(result)
def trello_add_checklist_item(card_id: str, name: str, checklist_id: str | None = None) -> str:
"""Add a checklist item to a Trello card.
Parameters
----------
card_id : str
Card ID.
name : str
Checklist item text.
checklist_id : str, optional
Specific checklist ID (auto-discovers the first if omitted).
Returns
-------
str
JSON with item details.
"""
client = _get_client()
result = client.add_checklist_item(card_id=card_id, name=name, checklist_id=checklist_id)
return _respond(result)
def trello_toggle_checklist_item(card_id: str, item_id: str, checked: bool) -> str: # noqa: FBT001
"""Mark a checklist item as complete or incomplete.
Parameters
----------
card_id : str
Card ID.
item_id : str
Checklist item ID.
checked : bool
True = complete, False = incomplete.
Returns
-------
str
JSON with updated item state.
"""
client = _get_client()
result = client.toggle_checklist_item(card_id=card_id, item_id=item_id, checked=checked)
return _respond(result)
def trello_delete_checklist_item(card_id: str, item_id: str) -> str:
"""Remove a checklist item from a Trello card.
Parameters
----------
card_id : str
Card ID.
item_id : str
Checklist item ID.
Returns
-------
str
JSON with success message.
"""
client = _get_client()
result = client.delete_checklist_item(card_id=card_id, item_id=item_id)
return _respond(result)
# ---------------------------------------------------------------------------
# Plugin metadata (used by Hermes plugin loader)
# ---------------------------------------------------------------------------
@@ -280,6 +533,18 @@ PLUGIN_TOOLS = [
trello_rename_list,
trello_archive_list,
trello_move_list,
trello_create_card,
trello_card_details,
trello_update_card,
trello_move_card,
trello_archive_card,
trello_assign_member,
trello_remove_member,
trello_add_comment,
trello_delete_comment,
trello_add_checklist_item,
trello_toggle_checklist_item,
trello_delete_checklist_item,
]
PLUGIN_REQUIRES_ENV = ["TRELLO_API_KEY", "TRELLO_TOKEN"]