@trainheroic-unofficial/coach-mcp 3.3.3 → 3.4.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 +33 -8
  2. package/package.json +5 -5
package/dist/server.mjs CHANGED
@@ -238,6 +238,12 @@ 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" });
241
247
  const presentedNullNumber = z.number().nullable();
242
248
  const presentedNullString = z.string().nullable();
243
249
  /** Flattened exercise within a presented workout: prescriptions, logged results, units. */
@@ -263,6 +269,8 @@ const athleteWorkoutViewSchema = z.object({
263
269
  program: presentedNullString,
264
270
  team: presentedNullString,
265
271
  instruction: presentedNullString,
272
+ notes: presentedNullString,
273
+ rpe: presentedNullNumber,
266
274
  logged: z.boolean(),
267
275
  personal: z.boolean(),
268
276
  blocks: z.array(athleteWorkoutBlockSchema)
@@ -572,6 +580,13 @@ z.object({
572
580
  groupId: z.number(),
573
581
  date: z.string()
574
582
  });
583
+ z.object({
584
+ programWorkoutId: z.number(),
585
+ savedWorkoutId: z.number(),
586
+ date: z.string(),
587
+ notes: z.string(),
588
+ rpe: nullableNumber
589
+ });
575
590
  const workoutReadExerciseOutputSchema = z.object({
576
591
  order: z.number(),
577
592
  title: z.string(),
@@ -1325,6 +1340,15 @@ function isPersonalSession(pw) {
1325
1340
  return isRecord(pw) && pw.personal_cal === true;
1326
1341
  }
1327
1342
  /**
1343
+ * The `saved_workout` blob on a program-workout range item, or null if the athlete has no saved
1344
+ * copy yet. Session notes, RPE, and set writes all resolve through this.
1345
+ */
1346
+ function savedWorkoutOf(pw) {
1347
+ if (!isRecord(pw)) return null;
1348
+ const ssw = isRecord(pw.summarizedSavedWorkout) ? pw.summarizedSavedWorkout : {};
1349
+ return isRecord(ssw.saved_workout) ? ssw.saved_workout : null;
1350
+ }
1351
+ /**
1328
1352
  * Rank candidate rows for a free-text query (FTS5 replacement). Higher is better:
1329
1353
  * exact title, then prefix, then count of matched tokens, with shorter titles and
1330
1354
  * standard (non-custom) exercises preferred on ties.
@@ -1562,7 +1586,7 @@ function mergeAthleteWorkout(raw) {
1562
1586
  const rec = raw;
1563
1587
  const ssw = isRecord(rec.summarizedSavedWorkout) ? rec.summarizedSavedWorkout : {};
1564
1588
  const workout = isRecord(ssw.workout) ? ssw.workout : {};
1565
- const saved = isRecord(ssw.saved_workout) ? ssw.saved_workout : {};
1589
+ const saved = savedWorkoutOf(rec) ?? {};
1566
1590
  const prescriptionSets = (Array.isArray(workout.workoutSets) ? workout.workoutSets : []).filter(isRecord);
1567
1591
  const logged = savedSets(saved);
1568
1592
  const performedById = performedSlotsByExerciseId(logged);
@@ -1591,6 +1615,8 @@ function mergeAthleteWorkout(raw) {
1591
1615
  program: str$1(rec.program_title),
1592
1616
  team: str$1(rec.team_title),
1593
1617
  instruction: str$1(workout.instruction),
1618
+ notes: str$1(saved.notes),
1619
+ rpe: coerceInt(saved.rpe),
1594
1620
  logged: blocks.some((b) => b.exercises.some((e) => e.sets.some((s) => s.performed !== null))),
1595
1621
  personal: isPersonalSession(rec),
1596
1622
  blocks
@@ -1638,6 +1664,8 @@ function presentAthleteWorkout(raw) {
1638
1664
  program: w.program,
1639
1665
  team: w.team,
1640
1666
  instruction: w.instruction,
1667
+ notes: w.notes,
1668
+ rpe: w.rpe,
1641
1669
  logged: w.logged,
1642
1670
  personal: w.personal,
1643
1671
  blocks: w.blocks.map(toStringBlock)
@@ -1757,7 +1785,7 @@ function presentCoachAthleteTraining(raw, athleteId, year, month) {
1757
1785
  completed: coerceInt(item.completed) === 1,
1758
1786
  rpe: coerceInt(item.rpe),
1759
1787
  durationMin: coerceInt(item.session_duration),
1760
- notes: typeof item.notes === "string" && item.notes !== "" ? item.notes : null,
1788
+ notes: str$1(item.notes),
1761
1789
  exercises
1762
1790
  });
1763
1791
  }
@@ -1977,9 +2005,7 @@ function assertUniqueExerciseResults(results) {
1977
2005
  function findSavedWorkoutSet(workouts, savedWorkoutSetId) {
1978
2006
  const available = [];
1979
2007
  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;
2008
+ const sw = savedWorkoutOf(pw);
1983
2009
  if (!sw) continue;
1984
2010
  const sets = Array.isArray(sw.workoutSets) ? sw.workoutSets : [];
1985
2011
  for (const s of sets) {
@@ -2199,8 +2225,7 @@ function eachPrescribedExercise(workouts) {
2199
2225
  const rows = [];
2200
2226
  for (const pw of workouts) {
2201
2227
  const rec = pw;
2202
- const ssw = isRecord(rec.summarizedSavedWorkout) ? rec.summarizedSavedWorkout : {};
2203
- const sw = isRecord(ssw.saved_workout) ? ssw.saved_workout : null;
2228
+ const sw = savedWorkoutOf(rec);
2204
2229
  if (!sw) continue;
2205
2230
  const sets = [...Array.isArray(sw.workoutSets) ? sw.workoutSets : [], ...Array.isArray(sw.addedWorkoutSets) ? sw.addedWorkoutSets : []];
2206
2231
  for (const s of sets) {
@@ -4699,7 +4724,7 @@ var JsonFileLibraryCache = class {
4699
4724
  };
4700
4725
  //#endregion
4701
4726
  //#region package.json
4702
- var version = "3.3.3";
4727
+ var version = "3.4.0";
4703
4728
  //#endregion
4704
4729
  //#region src/server.ts
4705
4730
  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.4.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.4.0",
25
+ "@trainheroic-unofficial/js": "3.4.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",