feat(wellness): add update_wellness write tool, computed Form (TSB), date-label fix
Add an update_wellness MCP tool that writes nutrition macros, hydration, vitals,
sleep, and subjective ratings to Intervals.icu via PUT /athlete/{id}/wellness/{date}.
Only provided fields are sent; pass -1 to clear a numeric field and locked=True to
stop device/app syncs from overwriting the values. Sleep is taken in hours and
stored as seconds (with -1 passing through as the clear sentinel).
Also surface computed Form (TSB = CTL - ATL) in wellness output, and prefer an
explicit `date` field over the record `id` for the Date label.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NGzHtDvJur9U7ysgRKRUTN
This commit is contained in:
@@ -64,6 +64,24 @@ def test_format_wellness_entry():
|
||||
assert result == expected_result
|
||||
|
||||
|
||||
def test_format_wellness_entry_computes_form_tsb():
|
||||
"""Form (TSB) is computed as CTL - ATL when both are present."""
|
||||
result = format_wellness_entry({"id": "2024-06-01", "ctl": 50, "atl": 65})
|
||||
assert "Form (TSB): -15.0" in result
|
||||
|
||||
|
||||
def test_format_wellness_entry_no_form_without_both_components():
|
||||
"""Form is omitted if either CTL or ATL is missing."""
|
||||
result = format_wellness_entry({"id": "2024-06-01", "ctl": 50})
|
||||
assert "Form (TSB)" not in result
|
||||
|
||||
|
||||
def test_format_wellness_entry_prefers_explicit_date_over_id():
|
||||
"""An explicit `date` field wins over `id` for the Date line."""
|
||||
result = format_wellness_entry({"id": "2024-06-01", "date": "2024-06-02", "ctl": 50})
|
||||
assert "Date: 2024-06-02" in result
|
||||
|
||||
|
||||
def test_format_wellness_entry_include_all_fields():
|
||||
"""
|
||||
Test that format_wellness_entry with include_all_fields=True includes additional unknown fields.
|
||||
|
||||
Reference in New Issue
Block a user