@trainheroic-unofficial/coach-mcp 3.3.3 → 3.5.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 +62 -10
  2. package/package.json +5 -5
package/dist/server.mjs CHANGED
@@ -238,6 +238,16 @@ z.object({
238
238
  programWorkoutId: idArgSchema,
239
239
  date: dateString
240
240
  });
241
+ z.object({
242
+ date: dateString,
243
+ programWorkoutId: idArgSchema,
244
+ notes: z.string().optional(),
245
+ rpe: z.number().int().min(1).max(10).optional()
246
+ }).refine((v) => v.notes !== void 0 || v.rpe !== void 0, { message: "Provide notes and/or rpe" });
247
+ z.object({
248
+ savedWorkoutSetExerciseId: idArgSchema,
249
+ notes: z.string()
250
+ });
241
251
  const presentedNullNumber = z.number().nullable();
242
252
  const presentedNullString = z.string().nullable();
243
253
  /** Flattened exercise within a presented workout: prescriptions, logged results, units. */
@@ -245,6 +255,7 @@ const athleteWorkoutExerciseSchema = z.object({
245
255
  exerciseId: presentedNullNumber,
246
256
  title: z.string(),
247
257
  instruction: presentedNullString,
258
+ notes: presentedNullString,
248
259
  units: z.array(presentedNullString),
249
260
  prescribed: z.array(z.string()),
250
261
  performed: z.array(z.string())
@@ -263,6 +274,8 @@ const athleteWorkoutViewSchema = z.object({
263
274
  program: presentedNullString,
264
275
  team: presentedNullString,
265
276
  instruction: presentedNullString,
277
+ notes: presentedNullString,
278
+ rpe: presentedNullNumber,
266
279
  logged: z.boolean(),
267
280
  personal: z.boolean(),
268
281
  blocks: z.array(athleteWorkoutBlockSchema)
@@ -351,6 +364,7 @@ const rosterActivityOutputSchema = z.array(rosterActivityRowSchema);
351
364
  const presentedExerciseSessionSchema = z.object({
352
365
  date: z.string(),
353
366
  abr: presentedNullString,
367
+ notes: presentedNullString,
354
368
  estimated1RM: presentedNullNumber,
355
369
  sets: z.array(z.object({
356
370
  setNumber: z.number(),
@@ -505,6 +519,7 @@ const logSetTargetOutputSchema = z.object({
505
519
  savedWorkoutSetExerciseId: z.number(),
506
520
  title: z.string(),
507
521
  units: z.array(nullableString),
522
+ notes: nullableString,
508
523
  prescribed: z.array(z.string()),
509
524
  performed: z.array(z.string())
510
525
  }))
@@ -572,6 +587,17 @@ z.object({
572
587
  groupId: z.number(),
573
588
  date: z.string()
574
589
  });
590
+ z.object({
591
+ programWorkoutId: z.number(),
592
+ savedWorkoutId: z.number(),
593
+ date: z.string(),
594
+ notes: z.string(),
595
+ rpe: nullableNumber
596
+ });
597
+ z.object({
598
+ savedWorkoutSetExerciseId: z.number(),
599
+ notes: z.string()
600
+ });
575
601
  const workoutReadExerciseOutputSchema = z.object({
576
602
  order: z.number(),
577
603
  title: z.string(),
@@ -1325,6 +1351,15 @@ function isPersonalSession(pw) {
1325
1351
  return isRecord(pw) && pw.personal_cal === true;
1326
1352
  }
1327
1353
  /**
1354
+ * The `saved_workout` blob on a program-workout range item, or null if the athlete has no saved
1355
+ * copy yet. Session notes, RPE, and set writes all resolve through this.
1356
+ */
1357
+ function savedWorkoutOf(pw) {
1358
+ if (!isRecord(pw)) return null;
1359
+ const ssw = isRecord(pw.summarizedSavedWorkout) ? pw.summarizedSavedWorkout : {};
1360
+ return isRecord(ssw.saved_workout) ? ssw.saved_workout : null;
1361
+ }
1362
+ /**
1328
1363
  * Rank candidate rows for a free-text query (FTS5 replacement). Higher is better:
1329
1364
  * exact title, then prefix, then count of matched tokens, with shorter titles and
1330
1365
  * standard (non-custom) exercises preferred on ties.
@@ -1505,6 +1540,16 @@ function performedSlotsByExerciseId(sets) {
1505
1540
  }
1506
1541
  return map;
1507
1542
  }
1543
+ /** Per-exercise athlete notes keyed by the prescription template id (`workout_set_exercise_id`). */
1544
+ function notesByTemplateId(sets) {
1545
+ const map = /* @__PURE__ */ new Map();
1546
+ for (const { exercises } of sets) for (const ex of exercises) {
1547
+ const id = coerceInt(ex.workout_set_exercise_id);
1548
+ const notes = str$1(ex.notes);
1549
+ if (id !== null && notes !== null) map.set(id, notes);
1550
+ }
1551
+ return map;
1552
+ }
1508
1553
  /** Align an exercise's prescribed slots with the slots the athlete logged, per set index. */
1509
1554
  function mergeExercise(prescribed, performed, meta) {
1510
1555
  const indices = [.../* @__PURE__ */ new Set([...prescribed.keys(), ...performed.keys()])].sort((a, b) => a - b);
@@ -1518,7 +1563,7 @@ function mergeExercise(prescribed, performed, meta) {
1518
1563
  };
1519
1564
  }
1520
1565
  /** A prescription block, each exercise aligned with the slots the athlete logged against it. */
1521
- function mergePrescriptionBlock(set, performedById) {
1566
+ function mergePrescriptionBlock(set, performedById, notesById) {
1522
1567
  const exercises = Array.isArray(set.workoutSetExercises) ? set.workoutSetExercises : [];
1523
1568
  return {
1524
1569
  order: coerceInt(set.order) ?? 0,
@@ -1532,6 +1577,7 @@ function mergePrescriptionBlock(set, performedById) {
1532
1577
  exerciseId: coerceInt(ex.exercise_id),
1533
1578
  title: typeof ex.title === "string" ? ex.title : "",
1534
1579
  instruction: str$1(ex.instruction),
1580
+ notes: id !== null ? notesById.get(id) ?? null : null,
1535
1581
  units: exerciseUnits(ex.param_1_type, ex.param_2_type)
1536
1582
  });
1537
1583
  })
@@ -1548,6 +1594,7 @@ function mergeSavedBlock(set, exercises) {
1548
1594
  exerciseId: coerceInt(ex.exercise_id),
1549
1595
  title: typeof ex.exercise_title === "string" ? ex.exercise_title : "",
1550
1596
  instruction: str$1(ex.instruction),
1597
+ notes: str$1(ex.notes),
1551
1598
  units: exerciseUnits(ex.param_1_type, ex.param_2_type)
1552
1599
  }))
1553
1600
  };
@@ -1562,11 +1609,12 @@ function mergeAthleteWorkout(raw) {
1562
1609
  const rec = raw;
1563
1610
  const ssw = isRecord(rec.summarizedSavedWorkout) ? rec.summarizedSavedWorkout : {};
1564
1611
  const workout = isRecord(ssw.workout) ? ssw.workout : {};
1565
- const saved = isRecord(ssw.saved_workout) ? ssw.saved_workout : {};
1612
+ const saved = savedWorkoutOf(rec) ?? {};
1566
1613
  const prescriptionSets = (Array.isArray(workout.workoutSets) ? workout.workoutSets : []).filter(isRecord);
1567
1614
  const logged = savedSets(saved);
1568
1615
  const performedById = performedSlotsByExerciseId(logged);
1569
- const blocks = prescriptionSets.map((s) => mergePrescriptionBlock(s, performedById)).sort((a, b) => a.order - b.order);
1616
+ const notesById = notesByTemplateId(logged);
1617
+ const blocks = prescriptionSets.map((s) => mergePrescriptionBlock(s, performedById, notesById)).sort((a, b) => a.order - b.order);
1570
1618
  const prescribedIds = /* @__PURE__ */ new Set();
1571
1619
  for (const s of prescriptionSets) {
1572
1620
  const exs = Array.isArray(s.workoutSetExercises) ? s.workoutSetExercises : [];
@@ -1591,6 +1639,8 @@ function mergeAthleteWorkout(raw) {
1591
1639
  program: str$1(rec.program_title),
1592
1640
  team: str$1(rec.team_title),
1593
1641
  instruction: str$1(workout.instruction),
1642
+ notes: str$1(saved.notes),
1643
+ rpe: coerceInt(saved.rpe),
1594
1644
  logged: blocks.some((b) => b.exercises.some((e) => e.sets.some((s) => s.performed !== null))),
1595
1645
  personal: isPersonalSession(rec),
1596
1646
  blocks
@@ -1610,6 +1660,7 @@ function toStringExercise(ex) {
1610
1660
  exerciseId: ex.exerciseId,
1611
1661
  title: ex.title,
1612
1662
  instruction: ex.instruction,
1663
+ notes: ex.notes,
1613
1664
  units: ex.units,
1614
1665
  prescribed: sideStrings(ex.sets, (s) => s.prescribed),
1615
1666
  performed: sideStrings(ex.sets, (s) => s.performed)
@@ -1638,6 +1689,8 @@ function presentAthleteWorkout(raw) {
1638
1689
  program: w.program,
1639
1690
  team: w.team,
1640
1691
  instruction: w.instruction,
1692
+ notes: w.notes,
1693
+ rpe: w.rpe,
1641
1694
  logged: w.logged,
1642
1695
  personal: w.personal,
1643
1696
  blocks: w.blocks.map(toStringBlock)
@@ -1702,6 +1755,7 @@ function presentLogTargets(list) {
1702
1755
  savedWorkoutSetExerciseId: id,
1703
1756
  title: exerciseTitle(ex),
1704
1757
  units: exerciseUnits(ex.param_1_type, ex.param_2_type),
1758
+ notes: str$1(ex.notes),
1705
1759
  prescribed: prescribedStrings(ex),
1706
1760
  performed: performedStrings(ex)
1707
1761
  };
@@ -1757,7 +1811,7 @@ function presentCoachAthleteTraining(raw, athleteId, year, month) {
1757
1811
  completed: coerceInt(item.completed) === 1,
1758
1812
  rpe: coerceInt(item.rpe),
1759
1813
  durationMin: coerceInt(item.session_duration),
1760
- notes: typeof item.notes === "string" && item.notes !== "" ? item.notes : null,
1814
+ notes: str$1(item.notes),
1761
1815
  exercises
1762
1816
  });
1763
1817
  }
@@ -1782,6 +1836,7 @@ function presentExerciseHistory(detail) {
1782
1836
  sessions: (detail.history ?? []).map((h) => ({
1783
1837
  date: h.dateCompleted,
1784
1838
  abr: h.abr ?? null,
1839
+ notes: str$1(h.notes),
1785
1840
  estimated1RM: h.bestEstimated1RM ?? null,
1786
1841
  sets: (h.sets ?? []).map((s) => ({
1787
1842
  setNumber: s.setNumber,
@@ -1977,9 +2032,7 @@ function assertUniqueExerciseResults(results) {
1977
2032
  function findSavedWorkoutSet(workouts, savedWorkoutSetId) {
1978
2033
  const available = [];
1979
2034
  for (const pw of workouts) {
1980
- const rec = pw;
1981
- const ssw = isRecord(rec.summarizedSavedWorkout) ? rec.summarizedSavedWorkout : {};
1982
- const sw = isRecord(ssw.saved_workout) ? ssw.saved_workout : null;
2035
+ const sw = savedWorkoutOf(pw);
1983
2036
  if (!sw) continue;
1984
2037
  const sets = Array.isArray(sw.workoutSets) ? sw.workoutSets : [];
1985
2038
  for (const s of sets) {
@@ -2199,8 +2252,7 @@ function eachPrescribedExercise(workouts) {
2199
2252
  const rows = [];
2200
2253
  for (const pw of workouts) {
2201
2254
  const rec = pw;
2202
- const ssw = isRecord(rec.summarizedSavedWorkout) ? rec.summarizedSavedWorkout : {};
2203
- const sw = isRecord(ssw.saved_workout) ? ssw.saved_workout : null;
2255
+ const sw = savedWorkoutOf(rec);
2204
2256
  if (!sw) continue;
2205
2257
  const sets = [...Array.isArray(sw.workoutSets) ? sw.workoutSets : [], ...Array.isArray(sw.addedWorkoutSets) ? sw.addedWorkoutSets : []];
2206
2258
  for (const s of sets) {
@@ -4699,7 +4751,7 @@ var JsonFileLibraryCache = class {
4699
4751
  };
4700
4752
  //#endregion
4701
4753
  //#region package.json
4702
- var version = "3.3.3";
4754
+ var version = "3.5.0";
4703
4755
  //#endregion
4704
4756
  //#region src/server.ts
4705
4757
  function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/coach-mcp",
3
- "version": "3.3.3",
3
+ "version": "3.5.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,15 +21,15 @@
21
21
  "dependencies": {
22
22
  "@modelcontextprotocol/server": "2.0.0",
23
23
  "zod": "^4.4.3",
24
- "@trainheroic-unofficial/core": "3.3.3",
25
- "@trainheroic-unofficial/js": "3.3.3"
24
+ "@trainheroic-unofficial/core": "3.5.0",
25
+ "@trainheroic-unofficial/js": "3.5.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@types/node": "^26.2.0",
28
+ "@types/node": "^26.3.0",
29
29
  "tsdown": "^0.22.14",
30
30
  "tsx": "^4.23.12",
31
31
  "typescript": "^7.0.2",
32
- "vitest": "^4.1.10"
32
+ "vitest": "^4.1.11"
33
33
  },
34
34
  "scripts": {
35
35
  "start": "tsx src/server.ts",