@trainheroic-unofficial/cli 3.1.1 → 3.3.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.
package/dist/cli.mjs CHANGED
@@ -32,7 +32,8 @@ z.looseObject({
32
32
  roles: z.array(z.string()).optional(),
33
33
  org_id: intLikeOrNull$1.optional()
34
34
  });
35
- z.looseObject({
35
+ /** `/v5/athleteProfile/summary` — lifetime training totals. Needs `use_metric` in the query. */
36
+ const athleteProfileSummarySchema = z.looseObject({
36
37
  reps_sum: z.number().optional(),
37
38
  volume_sum: z.number().optional(),
38
39
  sessions_count: z.number().optional(),
@@ -40,7 +41,8 @@ z.looseObject({
40
41
  last_logged_date: z.string().optional(),
41
42
  duration_hours: z.number().optional()
42
43
  });
43
- z.looseObject({
44
+ /** `/v5/users/{id}` — the detailed athlete profile (only the fields we surface). */
45
+ const athleteUserSchema = z.looseObject({
44
46
  id: intLike$1,
45
47
  email: z.string().optional(),
46
48
  name_first: z.string().optional(),
@@ -110,7 +112,8 @@ const liftPRSchema = z.looseObject({
110
112
  isMetric: z.boolean().optional(),
111
113
  description: z.string().optional()
112
114
  });
113
- z.looseObject({
115
+ /** `/v5/exercises/{id}/history` — the per-exercise PRs + session history. */
116
+ const exerciseHistoryDetailSchema = z.looseObject({
114
117
  liftPRs: z.array(liftPRSchema).optional(),
115
118
  singleParamPRs: z.array(z.unknown()).optional(),
116
119
  history: z.array(historyEntrySchema).optional()
@@ -147,7 +150,7 @@ const programWorkoutSchema = z.looseObject({
147
150
  team_title: z.string().optional(),
148
151
  summarizedSavedWorkout: z.unknown().optional()
149
152
  });
150
- z.array(programWorkoutSchema);
153
+ const programWorkoutListSchema = z.array(programWorkoutSchema);
151
154
  /** A `YYYY-MM-DD` date argument. The single definition reused across athlete tool inputs. */
152
155
  const dateString = z.string().regex(/^\d{4}-\d{2}-\d{2}$/u, "expected YYYY-MM-DD");
153
156
  z.object({
@@ -263,8 +266,161 @@ const athleteSessionRemoveArgsSchema = z.object({
263
266
  programWorkoutId: idArgSchema,
264
267
  date: dateString
265
268
  });
269
+ const presentedNullNumber = z.number().nullable();
270
+ const presentedNullString = z.string().nullable();
271
+ /** Flattened exercise within a presented workout: prescriptions, logged results, units. */
272
+ const athleteWorkoutExerciseSchema = z.object({
273
+ exerciseId: presentedNullNumber,
274
+ title: z.string(),
275
+ instruction: presentedNullString,
276
+ units: z.array(presentedNullString),
277
+ prescribed: z.array(z.string()),
278
+ performed: z.array(z.string())
279
+ });
280
+ const athleteWorkoutBlockSchema = z.object({
281
+ order: z.number(),
282
+ title: presentedNullString,
283
+ instruction: presentedNullString,
284
+ isTest: z.boolean(),
285
+ exercises: z.array(athleteWorkoutExerciseSchema)
286
+ });
287
+ const athleteWorkoutViewSchema = z.object({
288
+ id: presentedNullNumber,
289
+ date: z.string(),
290
+ title: z.string(),
291
+ program: presentedNullString,
292
+ team: presentedNullString,
293
+ instruction: presentedNullString,
294
+ logged: z.boolean(),
295
+ personal: z.boolean(),
296
+ blocks: z.array(athleteWorkoutBlockSchema)
297
+ });
298
+ const athleteWorkoutSummarySchema = z.object({
299
+ id: presentedNullNumber,
300
+ date: z.string(),
301
+ title: z.string(),
302
+ program: presentedNullString,
303
+ team: presentedNullString,
304
+ logged: z.boolean(),
305
+ personal: z.boolean(),
306
+ exerciseCount: z.number().int().nonnegative(),
307
+ performedCount: z.number().int().nonnegative()
308
+ });
309
+ z.union([
310
+ z.array(athleteWorkoutSummarySchema),
311
+ z.array(athleteWorkoutViewSchema),
312
+ programWorkoutListSchema
313
+ ]);
314
+ z.looseObject({
315
+ summary: athleteProfileSummarySchema,
316
+ user: athleteUserSchema
317
+ });
318
+ z.array(z.object({
319
+ id: z.union([z.number(), z.string()]),
320
+ title: z.string(),
321
+ isCircuit: z.boolean(),
322
+ units: z.array(presentedNullString)
323
+ }));
324
+ const coachAthleteExerciseSchema = z.object({
325
+ exerciseId: presentedNullNumber,
326
+ title: z.string(),
327
+ summary: presentedNullString,
328
+ completed: z.boolean()
329
+ });
330
+ const coachAthleteSessionSchema = z.object({
331
+ workoutId: presentedNullNumber,
332
+ savedWorkoutId: presentedNullNumber,
333
+ title: z.string(),
334
+ logged: z.boolean(),
335
+ completed: z.boolean(),
336
+ rpe: presentedNullNumber,
337
+ durationMin: presentedNullNumber,
338
+ notes: presentedNullString,
339
+ exercises: z.array(coachAthleteExerciseSchema)
340
+ });
341
+ z.object({
342
+ athleteId: presentedNullNumber,
343
+ athleteName: presentedNullString,
344
+ year: z.number().int(),
345
+ month: z.number().int(),
346
+ sessions: z.array(coachAthleteSessionSchema)
347
+ });
348
+ const rosterActivityRowSchema = z.object({
349
+ athleteId: z.number(),
350
+ sessionsCount: presentedNullNumber,
351
+ firstLoggedDate: presentedNullString,
352
+ lastLoggedDate: presentedNullString,
353
+ totalReps: presentedNullNumber,
354
+ totalVolume: presentedNullNumber
355
+ });
356
+ const teamVolumeAthleteSchema = z.object({
357
+ athleteId: z.number(),
358
+ name: presentedNullString,
359
+ sessions: z.number(),
360
+ reps: z.number(),
361
+ volume: z.number(),
362
+ firstLoggedDate: presentedNullString,
363
+ lastLoggedDate: presentedNullString
364
+ });
365
+ z.object({
366
+ window: z.object({
367
+ start: z.string(),
368
+ end: z.string()
369
+ }),
370
+ athletes: z.array(teamVolumeAthleteSchema),
371
+ totals: z.object({
372
+ athletes: z.number(),
373
+ sessions: z.number(),
374
+ reps: z.number(),
375
+ volume: z.number()
376
+ })
377
+ });
378
+ z.array(rosterActivityRowSchema);
379
+ const presentedExerciseSessionSchema = z.object({
380
+ date: z.string(),
381
+ abr: presentedNullString,
382
+ estimated1RM: presentedNullNumber,
383
+ sets: z.array(z.object({
384
+ setNumber: z.number(),
385
+ value: presentedNullString
386
+ }))
387
+ });
388
+ const presentedExerciseHistorySchema = z.object({
389
+ liftPRs: z.array(z.object({
390
+ description: presentedNullString,
391
+ reps: presentedNullNumber,
392
+ weight: presentedNullNumber,
393
+ units: presentedNullString,
394
+ date: presentedNullString
395
+ })),
396
+ sessions: z.array(presentedExerciseSessionSchema)
397
+ });
398
+ z.union([presentedExerciseHistorySchema, exerciseHistoryDetailSchema]);
266
399
  //#endregion
267
400
  //#region ../dto/src/exercise.ts
401
+ /**
402
+ * A row presented for display. The raw param-type codes are dropped and the fixed
403
+ * measurement units are surfaced positionally in `units`, ordered by entry slot
404
+ * (param 1, then param 2). Positional, not semantic: param 2 is not always the load
405
+ * — some exercises reverse the slots — so the units are not labelled by role.
406
+ */
407
+ const exerciseViewSchema = z.object({
408
+ id: z.number(),
409
+ title: z.string(),
410
+ can_edit: z.number(),
411
+ user_id: z.number().nullable(),
412
+ use_count: z.number(),
413
+ units: z.array(z.string().nullable())
414
+ });
415
+ z.looseObject({
416
+ id: idSchema,
417
+ title: z.string(),
418
+ units: z.array(z.string().nullable())
419
+ });
420
+ z.object({
421
+ match: exerciseViewSchema.nullable(),
422
+ candidates: z.array(exerciseViewSchema)
423
+ });
268
424
  /** Body for creating a custom exercise; extra fields the API accepts are preserved. */
269
425
  const exerciseCreateSchema = z.looseObject({
270
426
  title: z.string().min(1),
@@ -317,6 +473,203 @@ const programCreateResponseSchema = z.looseObject({
317
473
  program_type: intLike
318
474
  }).optional()
319
475
  });
476
+ const teamPublishPatchSchema = z.object({
477
+ pub_enabled: z.union([z.number(), z.boolean()]).optional(),
478
+ pub_days: z.unknown().optional(),
479
+ pub_time: z.unknown().optional(),
480
+ pub_timezone: z.string().optional()
481
+ }).refine((v) => v.pub_enabled !== void 0 || v.pub_days !== void 0 || v.pub_time !== void 0 || v.pub_timezone !== void 0, { message: "Provide at least one pub_* field" });
482
+ //#endregion
483
+ //#region ../dto/src/tool-output.ts
484
+ const nullableNumber = z.number().nullable();
485
+ const nullableString = z.string().nullable();
486
+ const truncationMarkerSchema = z.looseObject({
487
+ field: z.string().optional(),
488
+ returned: z.number().int().nonnegative().optional(),
489
+ total: z.number().int().nonnegative(),
490
+ omitted: z.number().int().nonnegative(),
491
+ hint: z.string()
492
+ });
493
+ /** Dedicated budget-fallback envelope. Never the natural tool shape. */
494
+ const truncatedOutputSchema = z.looseObject({
495
+ preview: z.string().optional(),
496
+ items: z.array(z.json()).optional(),
497
+ __truncated: truncationMarkerSchema
498
+ });
499
+ /**
500
+ * Add the shared size-budget fallback to a tool's natural result shape.
501
+ * Truncation is a dedicated `{ items|preview, __truncated }` envelope, so it cannot
502
+ * validate as the natural object and drop the marker.
503
+ */
504
+ function toolOutputSchema(schema) {
505
+ return z.union([truncatedOutputSchema, schema]);
506
+ }
507
+ toolOutputSchema(z.json());
508
+ const logSetTargetOutputSchema = z.object({
509
+ date: z.string(),
510
+ workoutTitle: z.string(),
511
+ program: nullableString,
512
+ programId: nullableNumber,
513
+ team: nullableString,
514
+ teamId: nullableNumber,
515
+ savedWorkoutSetId: z.number(),
516
+ setTitle: nullableString,
517
+ exercises: z.array(z.object({
518
+ savedWorkoutSetExerciseId: z.number(),
519
+ title: z.string(),
520
+ units: z.array(nullableString),
521
+ prescribed: z.array(z.string()),
522
+ performed: z.array(z.string())
523
+ }))
524
+ });
525
+ z.union([z.array(logSetTargetOutputSchema), programWorkoutListSchema]);
526
+ z.object({
527
+ draft: z.literal(true),
528
+ note: z.string(),
529
+ would_POST: z.string(),
530
+ payload: z.json()
531
+ });
532
+ z.looseObject({
533
+ status: z.enum(["sent", "logged"]),
534
+ reference: z.string().optional(),
535
+ note: z.string()
536
+ });
537
+ z.looseObject({ removed: z.union([z.boolean(), z.number()]) });
538
+ z.object({
539
+ removed: z.literal(true),
540
+ programWorkoutId: z.number(),
541
+ date: z.string()
542
+ });
543
+ z.object({
544
+ invited: z.literal(true),
545
+ teamId: z.number(),
546
+ result: z.json().optional()
547
+ });
548
+ z.object({
549
+ savedWorkoutSetId: z.number(),
550
+ exercisesLogged: z.number().int().nonnegative(),
551
+ setCompleted: z.boolean()
552
+ });
553
+ z.object({
554
+ savedWorkoutSetId: z.number(),
555
+ exercisesPrescribed: z.number().int().nonnegative()
556
+ });
557
+ z.object({
558
+ savedWorkoutSetExerciseId: z.number(),
559
+ athleteId: nullableNumber,
560
+ newExerciseId: z.number(),
561
+ newExerciseTitle: nullableString,
562
+ originalTeamExerciseId: nullableNumber
563
+ });
564
+ const sessionLogSetOutputSchema = z.object({
565
+ savedWorkoutSetId: z.number(),
566
+ exercisesLogged: z.number().int().nonnegative()
567
+ });
568
+ z.object({
569
+ date: z.string(),
570
+ created: z.boolean(),
571
+ sets: z.array(sessionLogSetOutputSchema),
572
+ scheduledAlternatives: z.array(z.object({
573
+ exerciseId: z.number(),
574
+ title: z.string(),
575
+ program: nullableString,
576
+ workoutTitle: z.string(),
577
+ savedWorkoutSetId: z.number(),
578
+ savedWorkoutSetExerciseId: z.number()
579
+ })).optional()
580
+ });
581
+ z.object({
582
+ programWorkoutId: z.number(),
583
+ workoutId: z.number(),
584
+ savedWorkoutId: z.number(),
585
+ groupId: z.number(),
586
+ date: z.string()
587
+ });
588
+ const workoutReadExerciseOutputSchema = z.object({
589
+ order: z.number(),
590
+ title: z.string(),
591
+ reps: z.array(z.string()),
592
+ primaryUnit: nullableString,
593
+ load: z.array(z.string()),
594
+ loadUnit: nullableString,
595
+ instruction: z.string()
596
+ });
597
+ const workoutReadBlockOutputSchema = z.object({
598
+ order: z.number(),
599
+ title: z.string(),
600
+ instruction: z.string(),
601
+ leaderboard: nullableString,
602
+ exercises: z.array(workoutReadExerciseOutputSchema)
603
+ });
604
+ const workoutReadOutputSchema = z.object({
605
+ pwId: z.number(),
606
+ date: z.string(),
607
+ published: z.json().optional(),
608
+ instruction: z.string(),
609
+ blocks: z.array(workoutReadBlockOutputSchema)
610
+ });
611
+ z.object({
612
+ pwId: z.number(),
613
+ workoutId: z.number(),
614
+ programId: z.number(),
615
+ published: z.literal(false),
616
+ advisories: z.object({
617
+ notes: z.array(z.string()),
618
+ warnings: z.array(z.string())
619
+ }),
620
+ readback: workoutReadOutputSchema.nullable(),
621
+ note: z.string()
622
+ });
623
+ z.object({
624
+ published: z.number(),
625
+ readback: workoutReadOutputSchema,
626
+ note: z.string()
627
+ });
628
+ z.object({
629
+ sent: z.literal(true),
630
+ comment: z.json()
631
+ });
632
+ z.object({
633
+ deleted: z.literal(true),
634
+ response: z.json().optional()
635
+ });
636
+ z.object({ deleted: z.number() });
637
+ z.object({ forgotten: z.number() });
638
+ z.looseObject({ id: z.union([z.number(), z.string()]) });
639
+ const mainLiftPrOutputSchema = z.object({
640
+ family: z.enum([
641
+ "cleanjerk",
642
+ "snatch",
643
+ "deadlift",
644
+ "squat",
645
+ "bench",
646
+ "overhead"
647
+ ]),
648
+ label: z.string(),
649
+ exerciseId: nullableNumber,
650
+ title: nullableString,
651
+ weight: nullableNumber,
652
+ reps: nullableNumber,
653
+ units: nullableString,
654
+ date: nullableString
655
+ });
656
+ z.object({
657
+ athleteId: z.number(),
658
+ athleteName: nullableString,
659
+ prs: z.array(mainLiftPrOutputSchema)
660
+ });
661
+ z.object({
662
+ containerId: z.number(),
663
+ programId: z.number(),
664
+ title: z.string(),
665
+ kind: z.enum(["calendar", "fixed"]),
666
+ requestedName: z.string(),
667
+ nameApplied: z.boolean()
668
+ });
669
+ z.object({
670
+ programId: z.number(),
671
+ containerId: nullableNumber
672
+ });
320
673
  //#endregion
321
674
  //#region ../dto/src/workout.ts
322
675
  /** A single exercise prescription inside a block. */
@@ -384,6 +737,11 @@ function parseWorkoutDate(s) {
384
737
  parts[2]
385
738
  ];
386
739
  }
740
+ /** Body for `POST /v5/sessions/template` (library create, not save-from-session). */
741
+ const sessionTemplateCreateSchema = z.object({
742
+ title: z.string().min(1),
743
+ instruction: z.string().optional()
744
+ });
387
745
  //#endregion
388
746
  //#region ../js/src/http-error.ts
389
747
  /**
@@ -851,6 +1209,15 @@ function fetchWorkingMaxes(client) {
851
1209
  function fetchExerciseHistoryList(client) {
852
1210
  return getArray$1(client, "/v5/users/exercises/history", "athlete exercise history list");
853
1211
  }
1212
+ function fetchRecentExercises(client) {
1213
+ return getArray$1(client, "/v5/users/exercises/recent", "athlete recent exercises");
1214
+ }
1215
+ function fetchAthleteCircuits(client, kind = "recent") {
1216
+ return getArray$1(client, `/v5/users/circuits/${kind}`, `athlete ${kind} circuits`);
1217
+ }
1218
+ function fetchAthleteProgrammingPrograms(client) {
1219
+ return getArray$1(client, "/1.0/athlete/programming/programs", "athlete programming programs");
1220
+ }
854
1221
  /** Free-text search over the athlete's logged exercises (FTS replacement via rankSearch). */
855
1222
  async function searchExerciseHistory(client, query, limit = 20) {
856
1223
  return rankSearch(await fetchExerciseHistoryList(client), query, limit);
@@ -2231,6 +2598,22 @@ function serializeWorkoutHistory(workouts, format, opts = {}) {
2231
2598
  };
2232
2599
  }
2233
2600
  //#endregion
2601
+ //#region ../js/src/util.ts
2602
+ /**
2603
+ * Drop the keys whose value is `undefined`, so the result can be passed to a function or
2604
+ * spread into an object under `exactOptionalPropertyTypes` without the per-key
2605
+ * `...(x !== undefined ? { x } : {})` dance. Required keys stay required in the result type;
2606
+ * optional ones lose `undefined` from their value type.
2607
+ *
2608
+ * Example:
2609
+ * definedProps({ metric, teamId: maybeId, date }) // omits teamId/date if they're undefined
2610
+ */
2611
+ function definedProps(obj) {
2612
+ const result = {};
2613
+ for (const [key, value] of Object.entries(obj)) if (value !== void 0) result[key] = value;
2614
+ return result;
2615
+ }
2616
+ //#endregion
2234
2617
  //#region ../js/src/workout-encode.ts
2235
2618
  const LEADERBOARD_TYPE = {
2236
2619
  completion: 0,
@@ -2623,6 +3006,45 @@ async function createProgram(client, args) {
2623
3006
  nameApplied: title === requestedName
2624
3007
  };
2625
3008
  }
3009
+ /**
3010
+ * Delete a standalone program (`DELETE /v5/programs/{programId}`).
3011
+ *
3012
+ * The live API 401s when the path id is a list_programs container id. Pass either id: this
3013
+ * resolves a container to its `group_program` first. Team calendars are not in that list; their
3014
+ * program id is deleted as given. This is not idempotent against an unknown failure.
3015
+ */
3016
+ async function deleteProgram(client, programId) {
3017
+ if (!Number.isInteger(programId) || programId <= 0) throw new Error("Program id must be a positive integer.");
3018
+ const programs = await client.request("GET", "/1.0/coach/programs");
3019
+ if (!programs.ok || !Array.isArray(programs.data)) {
3020
+ const detail = typeof programs.data === "string" ? programs.data : JSON.stringify(programs.data);
3021
+ throw new Error(`GET /1.0/coach/programs failed (HTTP ${programs.status}): ${detail}`);
3022
+ }
3023
+ let targetId = programId;
3024
+ let containerId = null;
3025
+ for (const item of programs.data) {
3026
+ if (!isRecord(item)) continue;
3027
+ const groupProgram = coerceInt(item.group_program);
3028
+ if (coerceInt(item.id) === programId && groupProgram !== null) {
3029
+ containerId = programId;
3030
+ targetId = groupProgram;
3031
+ break;
3032
+ }
3033
+ }
3034
+ const res = await client.request("DELETE", `/v5/programs/${targetId}`, { expectedStatuses: [
3035
+ 401,
3036
+ 403,
3037
+ 404
3038
+ ] });
3039
+ if (!res.ok) {
3040
+ const detail = typeof res.data === "string" ? res.data : JSON.stringify(res.data);
3041
+ throw new Error(`Program delete failed (HTTP ${res.status}): ${detail}`);
3042
+ }
3043
+ return {
3044
+ programId: targetId,
3045
+ containerId
3046
+ };
3047
+ }
2626
3048
  /** Normalize one-or-many emails into a deduped, trimmed list. */
2627
3049
  function emailList(emails) {
2628
3050
  return [...new Set(emails.map((e) => e.trim()).filter((e) => e.length > 0))];
@@ -2720,6 +3142,52 @@ async function updateTeam(client, args) {
2720
3142
  }
2721
3143
  return res.data;
2722
3144
  }
3145
+ /** Collapse the MCP/CLI XOR flags into a single publish target. */
3146
+ function teamPublishTarget(ids) {
3147
+ if (ids.programId !== void 0 && ids.teamId !== void 0) throw new Error("Pass programId or teamId, not both.");
3148
+ if (ids.programId !== void 0) return { programId: ids.programId };
3149
+ if (ids.teamId !== void 0) return { teamId: ids.teamId };
3150
+ throw new Error("Pass programId or teamId.");
3151
+ }
3152
+ async function programIdForTeam(client, teamId) {
3153
+ if (teamId <= 0) throw new Error("teamId must be positive.");
3154
+ const team = await client.request("GET", `/v5/teams/${teamId}`);
3155
+ if (!team.ok || !isRecord(team.data)) {
3156
+ const detail = typeof team.data === "string" ? team.data : JSON.stringify(team.data);
3157
+ throw new Error(`GET /v5/teams/${teamId} failed (HTTP ${team.status}): ${detail}`);
3158
+ }
3159
+ const resolved = coerceInt(team.data.group_program) ?? coerceInt(team.data.programId);
3160
+ if (resolved === null || resolved <= 0) throw new Error(`Team ${teamId} has no group_program.`);
3161
+ return resolved;
3162
+ }
3163
+ async function resolvePublishProgramId(client, target) {
3164
+ if ("programId" in target) return target.programId;
3165
+ return programIdForTeam(client, target.teamId);
3166
+ }
3167
+ /**
3168
+ * Update a team's auto-publish settings (`POST /1.0/coach/team/updatePublishSettings`).
3169
+ * The live API 500s on a partial body; it wants the full program object from
3170
+ * `GET /3.0/coach/program/{programId}` with `pub_*` fields merged on top.
3171
+ */
3172
+ async function updateTeamPublishSettings(client, args) {
3173
+ if (Object.keys(args.patch).length === 0) throw new Error("Provide at least one pub_* field to change.");
3174
+ const programId = await resolvePublishProgramId(client, args);
3175
+ if (programId <= 0) throw new Error("programId must be positive.");
3176
+ const current = await client.request("GET", `/3.0/coach/program/${programId}`);
3177
+ if (!current.ok || !isRecord(current.data)) {
3178
+ const detail = typeof current.data === "string" ? current.data : JSON.stringify(current.data);
3179
+ throw new Error(`GET /3.0/coach/program/${programId} failed (HTTP ${current.status}): ${detail}`);
3180
+ }
3181
+ const res = await client.request("POST", "/1.0/coach/team/updatePublishSettings", { body: {
3182
+ ...current.data,
3183
+ ...args.patch
3184
+ } });
3185
+ if (!res.ok) {
3186
+ const detail = typeof res.data === "string" ? res.data : JSON.stringify(res.data);
3187
+ throw new Error(`updatePublishSettings failed (HTTP ${res.status}): ${detail}`);
3188
+ }
3189
+ return res.data;
3190
+ }
2723
3191
  /**
2724
3192
  * Copy/repeat a session to a target date on a program (`POST /2.0/coach/calendar/copyProgramWorkout`).
2725
3193
  * The API wants the target date as a structured object (with weekday and an isToday flag),
@@ -2971,6 +3439,23 @@ async function teamVolume(client, args) {
2971
3439
  totals
2972
3440
  };
2973
3441
  }
3442
+ /** Create a reusable session template in the coach library (`POST /v5/sessions/template`). */
3443
+ async function createSessionTemplate(client, args) {
3444
+ const title = args.title.trim();
3445
+ if (title === "") throw new Error("Session template title must not be blank.");
3446
+ const res = await client.request("POST", "/v5/sessions/template", { body: definedProps({
3447
+ title,
3448
+ instruction: args.instruction
3449
+ }) });
3450
+ if (!res.ok) {
3451
+ const detail = typeof res.data === "string" ? res.data : JSON.stringify(res.data);
3452
+ throw new Error(`Session template create failed (HTTP ${res.status}): ${detail}`);
3453
+ }
3454
+ if (!isRecord(res.data) || coerceInt(res.data.id) === null) throw new Error("Session template create response is missing an id.");
3455
+ return res.data;
3456
+ }
3457
+ /** First page of the coach session-template library (`GET /1.0/coach/workouts`). */
3458
+ const SESSION_TEMPLATES_LIST_PATH = "/1.0/coach/workouts?page=1&pageSize=50";
2974
3459
  //#endregion
2975
3460
  //#region ../js/src/main-lifts.ts
2976
3461
  /**
@@ -3179,22 +3664,6 @@ async function fetchRosterMainLiftPRs(client, opts = {}) {
3179
3664
  });
3180
3665
  }
3181
3666
  //#endregion
3182
- //#region ../js/src/util.ts
3183
- /**
3184
- * Drop the keys whose value is `undefined`, so the result can be passed to a function or
3185
- * spread into an object under `exactOptionalPropertyTypes` without the per-key
3186
- * `...(x !== undefined ? { x } : {})` dance. Required keys stay required in the result type;
3187
- * optional ones lose `undefined` from their value type.
3188
- *
3189
- * Example:
3190
- * definedProps({ metric, teamId: maybeId, date }) // omits teamId/date if they're undefined
3191
- */
3192
- function definedProps(obj) {
3193
- const result = {};
3194
- for (const [key, value] of Object.entries(obj)) if (value !== void 0) result[key] = value;
3195
- return result;
3196
- }
3197
- //#endregion
3198
3667
  //#region ../js/src/messaging.ts
3199
3668
  const BUCKETS = [
3200
3669
  ["team", "teams"],
@@ -3266,6 +3735,8 @@ var MemoryLibraryCache = class {
3266
3735
  //#region ../js/src/exercise-index.ts
3267
3736
  const LIBRARY_PATH = "/v5/exerciseLibrary/all";
3268
3737
  const CREATE_PATH = "/2.0/coach/exercise/create";
3738
+ const UPDATE_PATH = (id) => `/2.0/coach/exercise/update/${id}`;
3739
+ const DELETE_PATH = (id) => `/v5/exercises/${id}`;
3269
3740
  const TTL_MS$1 = 6048e5;
3270
3741
  function toStored(ex) {
3271
3742
  const id = coerceInt(ex.id);
@@ -3394,12 +3865,18 @@ var ExerciseLibrary = class {
3394
3865
  };
3395
3866
  }
3396
3867
  async create(body) {
3868
+ return this.#writeThrough(CREATE_PATH, body, "create");
3869
+ }
3870
+ async update(id, body) {
3871
+ return this.#writeThrough(UPDATE_PATH(id), body, "update");
3872
+ }
3873
+ async #writeThrough(path, body, label) {
3397
3874
  await this.ensureFresh();
3398
- const res = await this.#client.request("POST", CREATE_PATH, { body });
3399
- if (!res.ok) throw new Error(`Exercise create failed (HTTP ${res.status}).`);
3875
+ const res = await this.#client.request("POST", path, { body });
3876
+ if (!res.ok) throw new Error(`Exercise ${label} failed (HTTP ${res.status}).`);
3400
3877
  const ex = unwrapEnvelope(res.data);
3401
3878
  if (ex && typeof ex === "object") {
3402
- checkResponse(exerciseResponseSchema, ex, "exercise create");
3879
+ checkResponse(exerciseResponseSchema, ex, `exercise ${label}`);
3403
3880
  const s = toStored(ex);
3404
3881
  if (s) {
3405
3882
  this.#byId.set(s.id, s);
@@ -3408,6 +3885,15 @@ var ExerciseLibrary = class {
3408
3885
  }
3409
3886
  return ex;
3410
3887
  }
3888
+ async remove(id) {
3889
+ const res = await this.#client.request("DELETE", DELETE_PATH(id), { expectedStatuses: [
3890
+ 401,
3891
+ 403,
3892
+ 404
3893
+ ] });
3894
+ if (!res.ok) throw new Error(`Exercise delete failed (HTTP ${res.status}).`);
3895
+ await this.recordDelete(id);
3896
+ }
3411
3897
  async recordDelete(id) {
3412
3898
  await this.ensureFresh();
3413
3899
  if (this.#byId.delete(id)) await this.#persist();
@@ -3538,8 +4024,10 @@ Coach — manage a roster (needs a coach account):
3538
4024
 
3539
4025
  teams & join codes:
3540
4026
  coach program-create --kind calendar|fixed --name "..."
4027
+ coach program-delete --program <id> --yes
3541
4028
  coach team-create --title "..."
3542
4029
  coach team-update --team <id> [--title "..."] [--group-program <id>]
4030
+ coach team-publish-settings (--team <id> | --program <id>) [--pub-enabled 0|1] --yes
3543
4031
  coach team-delete --team <id> --yes
3544
4032
  coach team-code-create --team <id> [--type N]
3545
4033
  coach team-code-delete --code <id> --yes (--code is the id from team-code-create, not the join-code number)
@@ -3548,6 +4036,9 @@ Coach — manage a roster (needs a coach account):
3548
4036
  coach session-copy --to-program <id> --pw <id> --to-date Y-M-D
3549
4037
  coach session-unpublish --pw <id> --yes
3550
4038
  coach session-save-template --workout <id>
4039
+ coach session-templates
4040
+ coach session-template-create --title "..." [--instruction "..."]
4041
+ coach session-template-delete --id <id> --yes
3551
4042
 
3552
4043
  analytics (curated metrics; for team training volume/recency use roster-activity --metric instead):
3553
4044
  coach analytics-query [--metric <key>] [--team <id>] [--users id,id] [--exercise <id>] [--date|--start|--end Y-M-D] [--use-metric]
@@ -3560,6 +4051,8 @@ Coach — manage a roster (needs a coach account):
3560
4051
  coach exercise get <id>
3561
4052
  coach exercise sync [--force]
3562
4053
  coach exercise create <json>|--file f
4054
+ coach exercise update <id> <json>|--file f
4055
+ coach exercise delete <id> --yes
3563
4056
  coach exercise forget <id> --yes
3564
4057
  coach exercise stats
3565
4058
 
@@ -3582,6 +4075,9 @@ Athlete — the logged-in user's own training (a coach account works too):
3582
4075
  athlete workouts --start Y-M-D --end Y-M-D [--raw] [--logged-only] [--limit N] [--summary] [--format json|csv|text] (reads what you did; --format exports history with reps/weight broken out; for the log ids use 'athlete log-targets')
3583
4076
  athlete log-targets --start Y-M-D --end Y-M-D [--program <title>|--program-id <id>|--team <id>] [--raw] (the savedWorkoutSetId + savedWorkoutSetExerciseId log-set needs; --program narrows when several workouts share a date)
3584
4077
  athlete exercises [--q <text>] [--limit N]
4078
+ athlete recent-exercises
4079
+ athlete circuits [--kind recent|history]
4080
+ athlete programs
3585
4081
  athlete history <exerciseId> [--raw]
3586
4082
  athlete prs <exerciseId>
3587
4083
  athlete stats <exerciseId> --date Y-M-D
@@ -3702,6 +4198,20 @@ async function cmdExercise(client, rest) {
3702
4198
  const exercise = validate(exerciseCreateSchema, body, "exercise");
3703
4199
  return out(await lib.create(exercise));
3704
4200
  }
4201
+ case "update": {
4202
+ const { values, positionals } = parse(a, { file: { type: "string" } });
4203
+ const id = toInt(need(positionals[0], "coach exercise update <id> <json>|--file f"), "id");
4204
+ const body = await jsonInput(positionals[1], values.file);
4205
+ const exercise = validate(exerciseCreateSchema, body, "exercise");
4206
+ return out(await lib.update(id, exercise));
4207
+ }
4208
+ case "delete": {
4209
+ const { values, positionals } = parse(a, { yes: { type: "boolean" } });
4210
+ const id = toInt(need(positionals[0], "coach exercise delete <id> --yes"), "id");
4211
+ if (values.yes !== true) fail(`add --yes to delete exercise ${id} from TrainHeroic.`);
4212
+ await lib.remove(id);
4213
+ return out({ deleted: id });
4214
+ }
3705
4215
  case "forget": {
3706
4216
  const { values, positionals } = parse(a, { yes: { type: "boolean" } });
3707
4217
  const id = toInt(need(positionals[0], "coach exercise forget <id> --yes"), "id");
@@ -3710,7 +4220,7 @@ async function cmdExercise(client, rest) {
3710
4220
  return out({ forgotten: id });
3711
4221
  }
3712
4222
  case "stats": return out(await lib.stats());
3713
- default: return fail("usage: trainheroic coach exercise <resolve|search|get|sync|create|forget|stats>");
4223
+ default: return fail("usage: trainheroic coach exercise <resolve|search|get|sync|create|update|delete|forget|stats>");
3714
4224
  }
3715
4225
  }
3716
4226
  async function cmdWorkoutBuild(client, a) {
@@ -4114,6 +4624,14 @@ async function cmdAthlete(client, rest) {
4114
4624
  const q = values.q;
4115
4625
  return out(q !== void 0 ? await searchExerciseHistory(client, q, limit) : await fetchExerciseHistoryList(client));
4116
4626
  }
4627
+ case "recent-exercises": return out(await fetchRecentExercises(client));
4628
+ case "circuits": {
4629
+ const { values } = parse(a, { kind: { type: "string" } });
4630
+ const kind = values.kind ?? "recent";
4631
+ if (kind !== "recent" && kind !== "history") fail("athlete circuits --kind recent|history");
4632
+ return out(await fetchAthleteCircuits(client, kind));
4633
+ }
4634
+ case "programs": return out(await fetchAthleteProgrammingPrograms(client));
4117
4635
  case "history": {
4118
4636
  const { values, positionals } = parse(a, { raw: { type: "boolean" } });
4119
4637
  const detail = await fetchExerciseHistoryDetail(client, toInt(need(positionals[0], "athlete history <exerciseId>"), "exerciseId"), await resolveAthleteUserId(client));
@@ -4147,7 +4665,7 @@ async function cmdAthlete(client, rest) {
4147
4665
  case "log-session": return cmdAthleteLogSession(client, a);
4148
4666
  case "session-remove": return cmdAthleteSessionRemove(client, a);
4149
4667
  case "swap-exercise": return cmdAthleteSwapExercise(client, a);
4150
- default: return fail("usage: trainheroic athlete <whoami|profile|prefs|workouts|log-targets|exercises|history|prs|stats|working-maxes|leaderboard|export|log-set|prescribe-set|log-session|session-remove|swap-exercise>");
4668
+ default: return fail("usage: trainheroic athlete <whoami|profile|prefs|workouts|log-targets|exercises|recent-exercises|circuits|programs|history|prs|stats|working-maxes|leaderboard|export|log-set|prescribe-set|log-session|session-remove|swap-exercise>");
4151
4669
  }
4152
4670
  }
4153
4671
  async function cmdSkill(rest) {
@@ -4191,7 +4709,7 @@ async function cmdInstallSkill() {
4191
4709
  }
4192
4710
  out({ installed });
4193
4711
  }
4194
- const COACH_USAGE = "usage: trainheroic coach <head-coach|athletes|programs|teams|notifications|analytics|program <id>|program-create|team <id>|team-codes <id>|roster-activity|team-volume|athlete-training|athlete-lift-history|main-lift-prs|athlete-workouts|log-set|log-session|prescribe-set|swap-exercise|athlete-invite|athlete-archive|athlete-restore|team-create|team-update|team-delete|team-code-create|team-code-delete|session-copy|session-unpublish|session-save-template|analytics-query|exercise|workout|message>";
4712
+ const COACH_USAGE = "usage: trainheroic coach <head-coach|athletes|programs|teams|notifications|notifications-list|subscriptions|prescription-templates|analytics|program <id>|program-create|program-delete|team <id>|team-codes <id>|roster-activity|team-volume|athlete-training|athlete-lift-history|athlete-team-calendar|main-lift-prs|athlete-workouts|log-set|log-session|prescribe-set|swap-exercise|athlete-invite|athlete-archive|athlete-restore|team-create|team-update|team-publish-settings|team-delete|team-code-create|team-code-delete|session-copy|session-unpublish|session-save-template|session-templates|session-template-create|session-template-delete|analytics-query|exercise|workout|message>";
4195
4713
  const COACH_LOG_SET_USAGE = "coach log-set --athlete <id> --date Y-M-D --set <savedWorkoutSetId> <resultsJson> --yes";
4196
4714
  async function cmdCoachLogSet(client, a) {
4197
4715
  const { values, positionals } = parse(a, {
@@ -4393,6 +4911,16 @@ async function cmdCoachProgramCreate(client, a) {
4393
4911
  name
4394
4912
  }));
4395
4913
  }
4914
+ async function cmdCoachProgramDelete(client, a) {
4915
+ const usage = "coach program-delete --program <id> --yes";
4916
+ const { values } = parse(a, {
4917
+ program: { type: "string" },
4918
+ yes: { type: "boolean" }
4919
+ });
4920
+ const programId = toInt(need(values.program, usage), "--program");
4921
+ if (values.yes !== true) fail(`deleting program ${programId} removes the standalone calendar; add --yes.`);
4922
+ return out(await deleteProgram(client, programId));
4923
+ }
4396
4924
  async function cmdCoachTeamUpdate(client, a) {
4397
4925
  const usage = "coach team-update --team <id> [--title \"...\"] [--group-program <id>] (at least one of --title / --group-program)";
4398
4926
  const { values } = parse(a, {
@@ -4467,6 +4995,58 @@ async function cmdCoachSessionSaveTemplate(client, a) {
4467
4995
  const { values } = parse(a, { workout: { type: "string" } });
4468
4996
  return out(await mutate(client, "POST", `/2.0/coach/calendar/programWorkout/saveWorkoutAsTemplate/${toInt(need(values.workout, usage), "--workout")}`));
4469
4997
  }
4998
+ async function cmdCoachSessionTemplateCreate(client, a) {
4999
+ const usage = "coach session-template-create --title \"...\" [--instruction \"...\"]";
5000
+ const { values } = parse(a, {
5001
+ title: { type: "string" },
5002
+ instruction: { type: "string" }
5003
+ });
5004
+ const title = need(values.title, usage);
5005
+ const instruction = values.instruction;
5006
+ return out(await createSessionTemplate(client, validate(sessionTemplateCreateSchema, definedProps({
5007
+ title,
5008
+ instruction
5009
+ }), "session template")));
5010
+ }
5011
+ async function cmdCoachSessionTemplateDelete(client, a) {
5012
+ const usage = "coach session-template-delete --id <id> --yes";
5013
+ const { values } = parse(a, {
5014
+ id: { type: "string" },
5015
+ yes: { type: "boolean" }
5016
+ });
5017
+ const id = toInt(need(values.id, usage), "--id");
5018
+ if (values.yes !== true) fail(`add --yes to delete session template ${id}.`);
5019
+ return out(await mutate(client, "DELETE", `/v5/sessions/template/${id}`));
5020
+ }
5021
+ async function cmdCoachTeamPublishSettings(client, a) {
5022
+ const usage = "coach team-publish-settings (--team <id> | --program <id>) [--pub-enabled 0|1] [--pub-days ...] [--pub-time ...] [--pub-timezone ...] --yes";
5023
+ const { values } = parse(a, {
5024
+ team: { type: "string" },
5025
+ program: { type: "string" },
5026
+ "pub-enabled": { type: "string" },
5027
+ "pub-days": { type: "string" },
5028
+ "pub-time": { type: "string" },
5029
+ "pub-timezone": { type: "string" },
5030
+ yes: { type: "boolean" }
5031
+ });
5032
+ const teamRaw = values.team;
5033
+ const programRaw = values.program;
5034
+ if (teamRaw === void 0 === (programRaw === void 0)) fail(usage);
5035
+ if (values.yes !== true) fail("changing auto-publish is athlete-facing; add --yes.");
5036
+ const patch = validate(teamPublishPatchSchema, definedProps({
5037
+ pub_enabled: values["pub-enabled"] !== void 0 ? toInt(values["pub-enabled"], "--pub-enabled") : void 0,
5038
+ pub_days: values["pub-days"],
5039
+ pub_time: values["pub-time"],
5040
+ pub_timezone: values["pub-timezone"]
5041
+ }), "publish settings");
5042
+ return out(await updateTeamPublishSettings(client, {
5043
+ ...teamPublishTarget(definedProps({
5044
+ teamId: teamRaw !== void 0 ? toInt(teamRaw, "--team") : void 0,
5045
+ programId: programRaw !== void 0 ? toInt(programRaw, "--program") : void 0
5046
+ })),
5047
+ patch
5048
+ }));
5049
+ }
4470
5050
  async function cmdCoachAnalyticsQuery(client, a) {
4471
5051
  const { values } = parse(a, {
4472
5052
  metric: { type: "string" },
@@ -4553,15 +5133,25 @@ async function cmdCoachMainLiftPrs(client, a) {
4553
5133
  ...subset ? { athleteIds: subset } : {}
4554
5134
  }));
4555
5135
  }
5136
+ const COACH_SIMPLE_GETS = {
5137
+ "head-coach": "/v5/headCoach",
5138
+ athletes: "/v5/athletes",
5139
+ programs: "/1.0/coach/programs",
5140
+ teams: "/1.0/coach/teams",
5141
+ notifications: "/v5/notifications/counts",
5142
+ "notifications-list": "/v5/notifications",
5143
+ subscriptions: "/1.0/coach/subscriptions",
5144
+ "prescription-templates": "/2.0/coach/workoutSetExercise/template",
5145
+ analytics: "/v5/analytics",
5146
+ "session-templates": SESSION_TEMPLATES_LIST_PATH
5147
+ };
4556
5148
  async function cmdCoach(client, rest) {
4557
5149
  const [sub, ...a] = rest;
5150
+ if (sub !== void 0) {
5151
+ const path = COACH_SIMPLE_GETS[sub];
5152
+ if (path !== void 0) return out(await get(client, path));
5153
+ }
4558
5154
  switch (sub) {
4559
- case "head-coach": return out(await get(client, "/v5/headCoach"));
4560
- case "athletes": return out(await get(client, "/v5/athletes"));
4561
- case "programs": return out(await get(client, "/1.0/coach/programs"));
4562
- case "teams": return out(await get(client, "/1.0/coach/teams"));
4563
- case "notifications": return out(await get(client, "/v5/notifications/counts"));
4564
- case "analytics": return out(await get(client, "/v5/analytics"));
4565
5155
  case "program": return out(await get(client, `/3.0/coach/program/${encodeURIComponent(need(a[0], "coach program <id>"))}`));
4566
5156
  case "team": return out(await get(client, `/v5/teams/${encodeURIComponent(need(a[0], "coach team <id>"))}`));
4567
5157
  case "team-codes": return out(await get(client, `/v5/teams/${encodeURIComponent(need(a[0], "coach team-codes <id>"))}/teamCodes`));
@@ -4569,6 +5159,10 @@ async function cmdCoach(client, rest) {
4569
5159
  case "team-volume": return cmdCoachTeamVolume(client, a);
4570
5160
  case "athlete-training": return cmdCoachAthleteTraining(client, a);
4571
5161
  case "athlete-lift-history": return cmdCoachAthleteLiftHistory(client, a);
5162
+ case "athlete-team-calendar": {
5163
+ const { values } = parse(a, { athlete: { type: "string" } });
5164
+ return out(await get(client, `/v5/calendars/athletes/${toInt(need(values.athlete, "coach athlete-team-calendar --athlete <id>"), "--athlete")}/coachAthleteTeam`));
5165
+ }
4572
5166
  case "main-lift-prs": return cmdCoachMainLiftPrs(client, a);
4573
5167
  case "athlete-workouts": return cmdCoachAthleteWorkouts(client, a);
4574
5168
  case "log-set": return cmdCoachLogSet(client, a);
@@ -4580,13 +5174,17 @@ async function cmdCoach(client, rest) {
4580
5174
  case "athlete-restore": return cmdCoachAthleteRestore(client, a);
4581
5175
  case "team-create": return cmdCoachTeamCreate(client, a);
4582
5176
  case "program-create": return cmdCoachProgramCreate(client, a);
5177
+ case "program-delete": return cmdCoachProgramDelete(client, a);
4583
5178
  case "team-update": return cmdCoachTeamUpdate(client, a);
5179
+ case "team-publish-settings": return cmdCoachTeamPublishSettings(client, a);
4584
5180
  case "team-delete": return cmdCoachTeamDelete(client, a);
4585
5181
  case "team-code-create": return cmdCoachTeamCodeCreate(client, a);
4586
5182
  case "team-code-delete": return cmdCoachTeamCodeDelete(client, a);
4587
5183
  case "session-copy": return cmdCoachSessionCopy(client, a);
4588
5184
  case "session-unpublish": return cmdCoachSessionUnpublish(client, a);
4589
5185
  case "session-save-template": return cmdCoachSessionSaveTemplate(client, a);
5186
+ case "session-template-create": return cmdCoachSessionTemplateCreate(client, a);
5187
+ case "session-template-delete": return cmdCoachSessionTemplateDelete(client, a);
4590
5188
  case "analytics-query": return cmdCoachAnalyticsQuery(client, a);
4591
5189
  case "exercise": return cmdExercise(client, a);
4592
5190
  case "workout": return cmdWorkout(client, a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/cli",
3
- "version": "3.1.1",
3
+ "version": "3.3.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,13 +21,13 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "zod": "^4.4.3",
24
- "@trainheroic-unofficial/dto": "3.1.1",
25
- "@trainheroic-unofficial/js": "3.1.1"
24
+ "@trainheroic-unofficial/dto": "3.3.0",
25
+ "@trainheroic-unofficial/js": "3.3.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^26.2.0",
29
29
  "tsdown": "^0.22.14",
30
- "tsx": "^4.23.11",
30
+ "tsx": "^4.23.12",
31
31
  "typescript": "^7.0.2",
32
32
  "vitest": "^4.1.10"
33
33
  },
@@ -105,8 +105,8 @@ startDate?/endDate? }`.
105
105
 
106
106
  ## Still unexplored
107
107
 
108
- - `PUT /1.0/athlete/savedworkout/{id}` (whole-workout sync; not needed for per-set logging,
109
- which uses the two-step path above).
110
- - `GET /v5/users/circuits/{recent,history}` (circuit history; shapes mirror the exercise
111
- history list).
112
- - `GET /1.0/athlete/programming/programs` (subscribed programs; empty for the test account).
108
+ Living status table: `.agents/skills/reverse-engineer-api/coverage.md`.
109
+
110
+ In-scope athlete reads are wrapped (`athlete_circuits`, `athlete_programming_programs`,
111
+ `athlete_recent_exercises`). Closed without a wrap: `PUT /1.0/athlete/savedworkout/{id}`
112
+ (per-set logging is enough); working-max write (read exists; set/update never found).
@@ -86,18 +86,18 @@ response shape, or an area not covered here.
86
86
 
87
87
  ## What you can do
88
88
 
89
- | Area | How |
90
- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
91
- | Athletes | `$TH coach athletes`; `coach athlete-invite\|athlete-archive\|athlete-restore` |
92
- | Teams / join codes | `$TH coach teams\|team <id>\|team-codes <id>`; `coach team-create\|team-update\|team-delete\|team-code-create\|team-code-delete` |
93
- | Programs | `$TH coach programs`, `$TH coach program <id>`, `$TH coach program-create --kind calendar\|fixed --name "..."` |
94
- | Exercises | `$TH coach exercise resolve\|search\|get\|sync\|create\|forget\|stats` (below) |
95
- | Sessions / workouts | `$TH coach workout build\|read\|publish\|remove`; `coach session-copy\|session-unpublish\|session-save-template` |
96
- | Roster training | `$TH coach roster-activity\|athlete-training\|athlete-lift-history\|athlete-workouts` (read another athlete's training) |
97
- | Team volume (windowed) | `$TH coach team-volume --team <id>\|--athletes <ids> --start Y-M-D --end Y-M-D` — date-scoped team volume (roster-activity is all-time) |
98
- | Log for an athlete | `$TH coach log-set` (by set id) or `coach log-session` (by exercise) — record a roster athlete's reps/weights (real athletes only; see below) |
99
- | Messaging | `$TH coach message list\|read\|draft\|send\|delete` (below) |
100
- | Analytics | `$TH coach analytics` (category list); `$TH coach analytics-query --metric <key> ...` (the report) |
89
+ | Area | How |
90
+ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
91
+ | Athletes | `$TH coach athletes`; `coach athlete-invite\|athlete-archive\|athlete-restore` |
92
+ | Teams / join codes | `$TH coach teams\|team <id>\|team-codes <id>`; `coach team-create\|team-update\|team-delete\|team-code-create\|team-code-delete` |
93
+ | Programs | `$TH coach programs`, `$TH coach program <id>`, `$TH coach program-create --kind calendar\|fixed --name "..."`, `$TH coach program-delete --program <id> --yes` |
94
+ | Exercises | `$TH coach exercise resolve\|search\|get\|sync\|create\|delete\|forget\|stats` (below) |
95
+ | Sessions / workouts | `$TH coach workout build\|read\|publish\|remove`; `coach session-copy\|session-unpublish\|session-save-template\|session-templates` |
96
+ | Roster training | `$TH coach roster-activity\|athlete-training\|athlete-lift-history\|athlete-workouts` (read another athlete's training) |
97
+ | Team volume (windowed) | `$TH coach team-volume --team <id>\|--athletes <ids> --start Y-M-D --end Y-M-D` — date-scoped team volume (roster-activity is all-time) |
98
+ | Log for an athlete | `$TH coach log-set` (by set id) or `coach log-session` (by exercise) — record a roster athlete's reps/weights (real athletes only; see below) |
99
+ | Messaging | `$TH coach message list\|read\|draft\|send\|delete` (below) |
100
+ | Analytics | `$TH coach analytics` (category list); `$TH coach analytics-query --metric <key> ...` (the report) |
101
101
 
102
102
  ## Resolving exercises
103
103
 
@@ -119,7 +119,8 @@ deleting one via the API, drop it from the mirror:
119
119
 
120
120
  ```bash
121
121
  $TH coach exercise create '{"title":"Sandbag Clean","param_1_type":3,"param_2_type":1}'
122
- $TH coach exercise forget 7721170 --yes # cache-only, run after an API delete
122
+ $TH coach exercise delete 7721170 --yes # live DELETE /v5/exercises/{id} + cache
123
+ $TH coach exercise forget 7721170 --yes # cache-only, if you already deleted via the API
123
124
  ```
124
125
 
125
126
  `$TH coach exercise stats` shows the cached row count.
@@ -294,6 +294,7 @@ Deletes an access code. No request body needed.
294
294
  | GET | `/v5/programs/fixed` | Fixed programs |
295
295
  | GET | `/1.0/coach/programs` | Coach programs list |
296
296
  | POST | `/1.0/coach/programs/create` | Create a standalone program |
297
+ | DELETE | `/v5/programs/{programId}` | Delete a standalone program |
297
298
  | GET | `/1.0/coach/programs/edit/{id}` | Program edit data |
298
299
  | GET | `/3.0/coach/program/{id}` | Program metadata/detail |
299
300
  | GET | `/1.0/coach/subscriptions` | Program subscriptions |
@@ -345,6 +346,14 @@ fixed-length program. The endpoint is not idempotent. Its response contains two
345
346
  `group_program`) is the actual program id used by `/3.0/coach/program/{id}` and workout writes.
346
347
  The live API may ignore `name` and assign a generated title; use the response's `title` as truth.
347
348
 
349
+ #### `DELETE /v5/programs/{programId}`
350
+
351
+ Deletes a standalone calendar or fixed program. The path id must be the underlying
352
+ `programId` (`group_program`), not the `list_programs` container `id` — a container id
353
+ returns 401. The SDK/`program_delete` tool resolves either id. Response body is the string
354
+ `Successfully deleted program`. There is no update/rename endpoint; PUT on this path 405s
355
+ (`Supported methods: DELETE`).
356
+
348
357
  ---
349
358
 
350
359
  ### Exercises
@@ -1369,15 +1378,8 @@ Updates the auto-publish settings for a team's program. Takes the full program o
1369
1378
 
1370
1379
  ## Still Unexplored
1371
1380
 
1372
- - Program update (title, description, settings) — PUT/POST patterns return 405/404
1373
- - Athlete remove from specific team (endpoint pattern not found via probing)
1374
- - Working max set/update from coach side for specific athletes
1375
- - Marketplace endpoints (publishing, pricing, purchases)
1376
- - Notification management (mark read, dismiss — 401/404 on tested patterns)
1377
- - `apis.trainheroic.com/user` endpoint (uses `api-token` header, returns full user profile with teams)
1378
- - Circuit creation (vs superset — circuits may use different block type or field)
1379
- - Prescription template CRUD
1380
- - Coach preferences update (PATCH/PUT on `2.0/coach/prefs` returns 403/405)
1381
- - Library settings
1382
- - Session template update (edit existing template)
1383
- - Workout set reorder / move exercises between blocks
1381
+ Living status table (remaining wrap gaps vs closed-without-a-wrap):
1382
+ `.agents/skills/reverse-engineer-api/coverage.md`.
1383
+
1384
+ Still to wrap: none (in-scope). See coverage.md Closed without a wrap for out-of-scope
1385
+ and unreachable paths.