Skip to content

Add search_activities and add_exercise tools - #79

Open
paultristanwagner wants to merge 2 commits into
rwestergren:mainfrom
paultristanwagner:log-exercise
Open

paultristanwagner wants to merge 2 commits into
rwestergren:mainfrom
paultristanwagner:log-exercise

Conversation

@paultristanwagner

Copy link
Copy Markdown

All code in this PR was written by an AI agent (Claude Opus 5.5) working with me; I directed it and tested the results on my own account. Feel free to take, change or drop any part of it.

Part of #73.

Adds search_activities and add_exercise tools to log exercise.

The app logs exercise with POST /api/v2/add_exercise:

{"exercise": {"exerciseId": null, "type": "Exercise", "activityId": 1342,
              "activitySpecId": 370, "minutes": 15.0, "weight": 176.4,
              "calories": -42.0, "calorieOverride": false, "day": …,
              "order": …, …},
 "auth": {…}, "config": {"call_version": 1}}

The app works out calories itself, from activity intensity data that
isn't in the activity lists. This change has the caller pass the calorie
burn and sets calorieOverride, like entering calories by hand in the app.
Verified against the live API on 1900-01-02:

  • activitySpecId can be left out (it's stored as 0)
  • weight (body weight in lb) is required: without it the server
    answers 500. It's taken from the profile's weightInKG pref.
  • activity ids from both catalogs the app's picker merges work:
    get_activity_forest (about 200 activities, ids 1135 and up) and
    all_legacy_activities (about 1100 more specific ones, ids 1-1134,
    e.g. "Walking 3.0 mph, moderate"). The id ranges don't overlap.

Exercises appear in get_diary as "type": "Exercise" entries. Deleting
them needs delete_entries to match exerciseId (#74).

Changes:

  • client: get_activities() merges both catalogs.
    add_exercise(activity_id, minutes, calories, day, diary_group) sends
    the burn as a negative number with calorieOverride: true, plus the
    profile weight.
  • server: search_activities (every query word must appear in the
    name) and add_exercise. Its description asks the model to estimate the
    burn from the MET value when the user doesn't know it.
  • README: tool table rows.

https://claude.ai/code/session_01MCJFDo71qoSqTRtcGfkpXJ

The app logs exercise with /api/v2/add_exercise. It computes the calorie
burn itself; here the caller passes it and calorieOverride is set, so no
activity intensity data is needed. The server requires the body weight
(lb), which comes from the profile. Activities come from the two catalogs
the app's picker merges (get_activity_forest and all_legacy_activities).
Verified against the live API with ids from both catalogs.

Claude-Session: https://claude.ai/code/session_01MCJFDo71qoSqTRtcGfkpXJ

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant