@trainheroic-unofficial/coach-mcp 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/server.mjs +32 -9
  2. package/package.json +3 -3
package/dist/server.mjs CHANGED
@@ -225,6 +225,10 @@ const coachLogSessionArgsSchema = z.object({
225
225
  sets: z.array(loggedSetSchema).min(1)
226
226
  })).min(1)
227
227
  }).extend({ athleteId: idArgSchema });
228
+ z.object({
229
+ programWorkoutId: idArgSchema,
230
+ date: dateString
231
+ });
228
232
  //#endregion
229
233
  //#region ../dto/src/exercise.ts
230
234
  /** Body for creating a custom exercise; extra fields the API accepts are preserved. */
@@ -794,6 +798,22 @@ function str$1(v) {
794
798
  return typeof v === "string" && v !== "" ? v : null;
795
799
  }
796
800
  /**
801
+ * The display title of a saved-copy exercise row, preferring `exercise_title`, then `title`, then
802
+ * the given fallback. The saved-workout shape carries the title under either key depending on the
803
+ * endpoint, so this is the one place that reconciles them.
804
+ */
805
+ function exerciseTitle(ex, fallback = "") {
806
+ return typeof ex.exercise_title === "string" && ex.exercise_title || typeof ex.title === "string" && ex.title || fallback;
807
+ }
808
+ /**
809
+ * True when a program-workout range item is a personal (athlete-created) session rather than a
810
+ * coach-scheduled one. The API marks these with `personal_cal === true`; this is the single
811
+ * definition every consumer (presenter, find-or-create, the remove guard) reads through.
812
+ */
813
+ function isPersonalSession(pw) {
814
+ return isRecord(pw) && pw.personal_cal === true;
815
+ }
816
+ /**
797
817
  * Rank candidate rows for a free-text query (FTS5 replacement). Higher is better:
798
818
  * exact title, then prefix, then count of matched tokens, with shorter titles and
799
819
  * standard (non-custom) exercises preferred on ties.
@@ -1085,6 +1105,7 @@ function presentAthleteWorkout(raw) {
1085
1105
  team: str$1(rec.team_title),
1086
1106
  instruction: str$1(workout.instruction),
1087
1107
  logged: blocks.some((b) => b.exercises.some((e) => e.performed.length > 0)),
1108
+ personal: isPersonalSession(rec),
1088
1109
  blocks
1089
1110
  };
1090
1111
  }
@@ -1145,7 +1166,7 @@ function presentLogTargets(list) {
1145
1166
  if (id === null) return null;
1146
1167
  return {
1147
1168
  savedWorkoutSetExerciseId: id,
1148
- title: typeof ex.exercise_title === "string" && ex.exercise_title || typeof ex.title === "string" && ex.title || "",
1169
+ title: exerciseTitle(ex),
1149
1170
  units: exerciseUnits(ex.param_1_type, ex.param_2_type),
1150
1171
  prescribed: prescribedSets(ex),
1151
1172
  performed: performedSets(ex)
@@ -1387,8 +1408,7 @@ function findSavedWorkoutSet(workouts, savedWorkoutSetId) {
1387
1408
  if (setId !== null) {
1388
1409
  const exLabels = exercises.map((ex) => {
1389
1410
  const exId = coerceInt(ex.id);
1390
- const title = typeof ex.exercise_title === "string" && ex.exercise_title || typeof ex.title === "string" && ex.title || "exercise";
1391
- return exId === null ? null : `${exId} (${title})`;
1411
+ return exId === null ? null : `${exId} (${exerciseTitle(ex, "exercise")})`;
1392
1412
  }).filter((x) => x !== null);
1393
1413
  available.push(`set ${setId} → exercise ids: ${exLabels.join(", ") || "none"}`);
1394
1414
  }
@@ -1565,8 +1585,7 @@ async function writeSetResults(client, target, workouts, savedWorkoutSetId, resu
1565
1585
  if (!ex) {
1566
1586
  const valid = exercises.map((e) => {
1567
1587
  const id = coerceInt(e.id);
1568
- const title = typeof e.exercise_title === "string" && e.exercise_title || typeof e.title === "string" && e.title || "exercise";
1569
- return id === null ? null : `${id} (${title})`;
1588
+ return id === null ? null : `${id} (${exerciseTitle(e, "exercise")})`;
1570
1589
  }).filter((x) => x !== null);
1571
1590
  throw new Error(`savedWorkoutSetExerciseId ${result.savedWorkoutSetExerciseId} not found in saved workout set ${savedWorkoutSetId}. Exercises in this set: ${valid.join(", ") || "none"}.`);
1572
1591
  }
@@ -1601,7 +1620,11 @@ async function writeSetResults(client, target, workouts, savedWorkoutSetId, resu
1601
1620
  setCompleted
1602
1621
  };
1603
1622
  }
1604
- /** Flatten a day's prescribed saved sets into `{ savedWorkoutSetId, ex }` rows (both set keys). */
1623
+ /**
1624
+ * Flatten a day's saved sets into `{ pw, savedWorkoutSetId, ex }` rows (both saved-set keys),
1625
+ * carrying the parent program-workout so a caller can read its identity (`personal_cal`, program
1626
+ * title) without re-walking. The one saved-copy traversal the by-exercise paths share.
1627
+ */
1605
1628
  function eachPrescribedExercise(workouts) {
1606
1629
  const rows = [];
1607
1630
  for (const pw of workouts) {
@@ -1616,6 +1639,7 @@ function eachPrescribedExercise(workouts) {
1616
1639
  if (savedWorkoutSetId === null) continue;
1617
1640
  const exercises = Array.isArray(s.workoutSetExercises) ? s.workoutSetExercises : [];
1618
1641
  for (const ex of exercises) if (isRecord(ex)) rows.push({
1642
+ pw: rec,
1619
1643
  savedWorkoutSetId,
1620
1644
  ex
1621
1645
  });
@@ -1646,8 +1670,7 @@ function prescribedExerciseLabels(workouts) {
1646
1670
  for (const { ex } of eachPrescribedExercise(workouts)) {
1647
1671
  const id = coerceInt(ex.exercise_id);
1648
1672
  if (id === null) continue;
1649
- const title = typeof ex.exercise_title === "string" && ex.exercise_title || typeof ex.title === "string" && ex.title || "exercise";
1650
- labels.push(`${id} (${title})`);
1673
+ labels.push(`${id} (${exerciseTitle(ex, "exercise")})`);
1651
1674
  }
1652
1675
  return labels;
1653
1676
  }
@@ -3657,7 +3680,7 @@ var JsonFileLibraryCache = class {
3657
3680
  };
3658
3681
  //#endregion
3659
3682
  //#region package.json
3660
- var version = "1.5.0";
3683
+ var version = "1.6.0";
3661
3684
  //#endregion
3662
3685
  //#region src/server.ts
3663
3686
  async function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/coach-mcp",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,8 +21,8 @@
21
21
  "dependencies": {
22
22
  "@modelcontextprotocol/sdk": "^1.29.0",
23
23
  "zod": "^4.4.3",
24
- "@trainheroic-unofficial/core": "1.5.0",
25
- "@trainheroic-unofficial/js": "1.5.0"
24
+ "@trainheroic-unofficial/core": "1.6.0",
25
+ "@trainheroic-unofficial/js": "1.6.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^26.0.0",