Matériel coché dans le profil, bibliothèque « ce que mon matériel permet » (5a)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pierre MARTIN
2026-11-23 02:12:25 +01:00
co-authored by Claude Opus 5.5
parent 938d6cf198
commit 72adffb613
15 changed files with 281 additions and 20 deletions
+5 -2
View File
@@ -6,6 +6,7 @@
// - buildEvolutionBrief : faire évoluer le programme existant, à partir de l'état.
// Les clés des formats sont en anglais (ce sont celles du code), le texte en français.
import { KIT, kitLabels } from "./kit.js";
import { WOD_TYPES, scoreLabel } from "./wod.js";
import { BENCHMARKS } from "./benchmarks.js";
import { EXERCISES, FAMILIES, MUSCLES } from "./exercises.js";
@@ -143,7 +144,8 @@ Une séance WOD porte un \`format\`. L'app affiche alors un chrono adapté (comp
Profile {
goal: l'objectif, en une phrase
context: pratique passée, niveau, lieu d'entraînement
equipment: [matériel disponible]
equipment: [matériel disponible, en texte libre : ce que kit ne dit pas]
kit?: [matériel coché, parmi ${Object.keys(KIT).map((k) => `"${k}"`).join(", ")}] ; omis : pas renseigné
constraints: [contraintes de sécurité et d'organisation]
heightCm: taille en centimètres, ou null
sessionMinutes: durée visée d'une séance, de 10 à 240
@@ -275,7 +277,8 @@ Tu es le coach qui fait évoluer mon programme de musculation. IA-Fit (${appUrl(
- Contexte : ${text(p.context)}
- Taille : ${p.heightCm ? p.heightCm + " cm" : "non renseignée"} ; poids : ${weightLine(state.weights)}
- Durée visée d'une séance : ${p.sessionMinutes} minutes
- Matériel :
- Matériel coché : ${p.kit ? (p.kit.length ? kitLabels(p.kit).join(", ") : "aucun (poids du corps seulement)") : "non renseigné"}
- Autre matériel :
${list(p.equipment)}
- Contraintes (à respecter absolument) :
${list(p.constraints)}
+92
View File
@@ -0,0 +1,92 @@
// Le matériel, en cases à cocher (lot 5a) : ce que le profil possède (Profile.kit) et
// ce que demande chaque exercice de la bibliothèque. Sert au filtre « Ce que je peux
// faire » de la bibliothèque, à la vérification des propositions (5b) et au
// générateur de WOD (5c). Glossaire : docs/glossaire/materiel.md
// Ces clés font partie du format des événements (ProfileUpdated) : en ajouter est
// possible, en renommer demande une migration.
import { EXERCISES } from "./exercises.js";
/** Le matériel qu'on peut cocher, dans l'ordre d'affichage. */
export const KIT = Object.freeze({
barbell: "Barre et disques",
rack: "Rack ou supports de squat",
bench: "Banc",
dumbbells: "Haltères",
kettlebell: "Kettlebell",
"pullup-bar": "Barre de traction",
"dip-bars": "Barres parallèles",
rings: "Anneaux",
bands: "Élastiques",
machines: "Machines guidées",
cable: "Poulie",
rower: "Rameur",
bike: "Vélo ou air bike",
"ski-erg": "SkiErg",
"jump-rope": "Corde à sauter",
box: "Box ou plateforme",
"medicine-ball": "Médecine-ball, wall ball",
"ab-wheel": "Roue abdominale",
"battle-rope": "Corde ondulatoire",
sled: "Traîneau",
ghd: "Banc GHD",
"climbing-rope": "Corde à grimper",
});
/** @typedef {keyof typeof KIT} Kit */
/** Ce que demande chaque catégorie de matériel de la bibliothèque. */
const BY_EQUIPMENT = /** @type {Record<string, Kit[]>} */ ({
barbell: ["barbell"], dumbbell: ["dumbbells"], dumbbells: ["dumbbells"], kettlebell: ["kettlebell"],
machine: ["machines"], cable: ["cable"], band: ["bands"],
});
/** Ce que la catégorie ne dit pas : un support, un banc, un petit matériel. */
const EXTRA = /** @type {Record<string, Kit[]>} */ ({
squat: ["rack"], "front-squat": ["rack"], "bench-press": ["rack", "bench"], "incline-bench-press": ["rack", "bench"],
"dumbbell-bench-press": ["bench"], "incline-dumbbell-press": ["bench"], "dumbbell-fly": ["bench"],
"seated-dumbbell-press": ["bench"], "one-arm-dumbbell-row": ["bench"], "dumbbell-pullover": ["bench"],
"skull-crusher": ["bench"], "hip-thrust": ["bench"], "bulgarian-split-squat": ["bench"], "step-up": ["bench"],
"bench-dips": ["bench"],
"pull-up": ["pullup-bar"], "chin-up": ["pullup-bar"], "kipping-pull-up": ["pullup-bar"], "hanging-leg-raise": ["pullup-bar"],
"toes-to-bar": ["pullup-bar"], "knees-to-elbow": ["pullup-bar"], "muscle-up": ["pullup-bar"],
"band-assisted-pull-up": ["pullup-bar"],
"parallel-bar-dips": ["dip-bars"], "ring-dip": ["rings"], "ring-row": ["rings"],
"ab-wheel-rollout": ["ab-wheel"], "jump-rope": ["jump-rope"], "double-under": ["jump-rope"], "box-jump": ["box"],
"wall-ball": ["medicine-ball"], "ball-slam": ["medicine-ball"], "battle-rope": ["battle-rope"], "sled-push": ["sled"],
"ghd-sit-up": ["ghd"], "rope-climb": ["climbing-rope"],
"rowing-machine": ["rower"], "assault-bike": ["bike"], "ski-erg": ["ski-erg"],
});
/**
* Le matériel que demande un exercice de la bibliothèque. Vide : rien (poids du
* corps, ou exercice hors bibliothèque, dont on ne sait rien).
* @param {string} ref
* @returns {Kit[]}
*/
export function requiredKit(ref) {
const x = EXERCISES[ref];
if (!x) return [];
return [...new Set([...(BY_EQUIPMENT[x.equipment] ?? []), ...(EXTRA[ref] ?? [])])];
}
/**
* Le matériel qui manque pour un exercice. Rien ne manque tant que le profil n'a
* pas coché son matériel (`kit` absent).
* @param {string} ref
* @param {readonly string[]|undefined} kit
* @returns {Kit[]}
*/
export function missingKit(ref, kit) {
if (!kit) return [];
const have = new Set(kit);
return requiredKit(ref).filter((k) => !have.has(k));
}
/** @param {string} ref @param {readonly string[]|undefined} kit */
export const canDo = (ref, kit) => missingKit(ref, kit).length === 0;
/** @param {unknown} x */
export const isKit = (x) => typeof x === "string" && Object.hasOwn(KIT, x);
/** Libellés lisibles, dans l'ordre de KIT. @param {readonly string[]} kit */
export const kitLabels = (kit) => Object.keys(KIT).filter((k) => kit.includes(k)).map((k) => KIT[/** @type {Kit} */ (k)]);
+10 -3
View File
@@ -3,6 +3,7 @@
// Les critères vivent dans l'adresse (ADR 0009) : `#/bibliotheque?zone=lower&muscle=glutes`.
// Glossaire : docs/glossaire/bibliotheque.md
import { canDo } from "./kit.js";
import { EXERCISES, FAMILIES, MUSCLES } from "./exercises.js";
import { exerciseKey, resolveExercise } from "./program.js";
import { exerciseHistory } from "./analysis.js";
@@ -36,10 +37,11 @@ export const ZONE_LABELS = { upper: "Haut du corps", lower: "Bas du corps", core
* @property {Zone} [zone]
* @property {string} [muscle] clé de MUSCLES, dans la zone choisie
* @property {EquipmentGroup} [equipment]
* @property {boolean} [possible] seulement ce que le matériel du profil permet (lot 5a)
*/
/** Noms des paramètres dans l'adresse. */
const PARAMS = /** @type {const} */ ({ q: "q", family: "famille", zone: "zone", muscle: "muscle", equipment: "materiel" });
const PARAMS = /** @type {const} */ ({ q: "q", family: "famille", zone: "zone", muscle: "muscle", equipment: "materiel", possible: "possible" });
/**
* Lit les critères dans la requête de l'adresse. Une valeur inconnue est ignorée ;
@@ -64,6 +66,7 @@ export function parseCriteria(query) {
}
const equipment = p.get(PARAMS.equipment);
if (equipment && equipment in EQUIPMENT_GROUPS) c.equipment = /** @type {EquipmentGroup} */ (equipment);
if (p.get(PARAMS.possible) === "1") c.possible = true;
return c;
}
@@ -75,6 +78,7 @@ export function formatCriteria(c) {
const p = new URLSearchParams();
for (const key of /** @type {(keyof LibraryCriteria)[]} */ (["q", "family", "zone", "muscle", "equipment"]))
if (c[key]) p.set(PARAMS[key], /** @type {string} */ (c[key]));
if (c.possible) p.set(PARAMS.possible, "1");
return p.toString();
}
@@ -84,15 +88,18 @@ export const fold = (s) => s.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCas
/**
* Les exercices de la bibliothèque qui répondent aux critères, groupés par
* famille dans l'ordre de FAMILIES, triés par nom. Le filtre de zone et de
* muscle porte sur les muscles principaux.
* muscle porte sur les muscles principaux. `possible` ne garde que ce que permet
* `kit`, le matériel coché du profil (sans effet tant qu'il n'est pas renseigné).
* @param {LibraryCriteria} c
* @param {readonly string[]} [kit]
* @returns {{family: Family, label: string, items: {ref: string, exercise: LibraryExercise}[]}[]}
*/
export function filterLibrary(c) {
export function filterLibrary(c, kit) {
const words = c.q ? fold(c.q).split(/\s+/).filter(Boolean) : [];
const equipment = c.equipment ? /** @type {readonly string[]} */ (EQUIPMENT_GROUPS[c.equipment].equipment) : null;
const match = (/** @type {string} */ ref, /** @type {LibraryExercise} */ x) =>
(!c.family || x.family === c.family) &&
(!c.possible || canDo(ref, kit)) &&
(!equipment || equipment.includes(x.equipment)) &&
(!c.muscle || x.primary.includes(c.muscle)) &&
(!c.zone || x.primary.some((m) => MUSCLES[m].zone === c.zone)) &&
+6 -1
View File
@@ -1,11 +1,14 @@
// Le profil : ce que l'IA doit savoir pour construire le programme.
// Glossaire : docs/glossaire/profil.md
import { isKit } from "./kit.js";
/**
* @typedef {object} Profile
* @property {string} goal objectif, en une phrase
* @property {string} context pratique passée, lieu d'entraînement
* @property {string[]} equipment matériel disponible
* @property {string[]} equipment matériel disponible, en texte libre (ce que les cases ne disent pas)
* @property {import("./kit.js").Kit[]} [kit] matériel coché (lot 5a) ; absent : pas encore renseigné
* @property {string[]} constraints contraintes de sécurité et d'organisation
* @property {number|null} heightCm
* @property {number} sessionMinutes durée visée d'une séance
@@ -33,6 +36,8 @@ export function validateProfile(profile) {
for (const k of ["goal", "context"]) if (typeof p[k] !== "string") errors.push(`'${k}' doit être un texte.`);
for (const k of ["equipment", "constraints"])
if (!Array.isArray(p[k]) || !p[k].every((/** @type {unknown} */ s) => typeof s === "string")) errors.push(`'${k}' doit être une liste de textes.`);
if (p.kit !== undefined && !(Array.isArray(p.kit) && p.kit.every(isKit) && new Set(p.kit).size === p.kit.length))
errors.push("'kit' doit être une liste de clés de matériel connues, sans doublon (voir le format du profil).");
if (p.heightCm !== null && !(typeof p.heightCm === "number" && p.heightCm > 50 && p.heightCm < 260))
errors.push("'heightCm' doit être une taille en centimètres, ou null.");
if (!(typeof p.sessionMinutes === "number" && p.sessionMinutes >= 10 && p.sessionMinutes <= 240))
+2 -1
View File
@@ -97,7 +97,8 @@ WodFormat {
<pre><code>Profile {
goal: l'objectif, en une phrase
context: pratique passée, niveau, lieu d'entraînement
equipment: [matériel disponible]
equipment: [matériel disponible, en texte libre : ce que kit ne dit pas]
kit?: [matériel coché, parmi &quot;barbell&quot;, &quot;rack&quot;, &quot;bench&quot;, &quot;dumbbells&quot;, &quot;kettlebell&quot;, &quot;pullup-bar&quot;, &quot;dip-bars&quot;, &quot;rings&quot;, &quot;bands&quot;, &quot;machines&quot;, &quot;cable&quot;, &quot;rower&quot;, &quot;bike&quot;, &quot;ski-erg&quot;, &quot;jump-rope&quot;, &quot;box&quot;, &quot;medicine-ball&quot;, &quot;ab-wheel&quot;, &quot;battle-rope&quot;, &quot;sled&quot;, &quot;ghd&quot;, &quot;climbing-rope&quot;] ; omis : pas renseigné
constraints: [contraintes de sécurité et d'organisation]
heightCm: taille en centimètres, ou null
sessionMinutes: durée visée d'une séance, de 10 à 240
+2 -1
View File
@@ -99,7 +99,8 @@ Une séance WOD porte un `format`. L'app affiche alors un chrono adapté (compte
Profile {
goal: l'objectif, en une phrase
context: pratique passée, niveau, lieu d'entraînement
equipment: [matériel disponible]
equipment: [matériel disponible, en texte libre : ce que kit ne dit pas]
kit?: [matériel coché, parmi "barbell", "rack", "bench", "dumbbells", "kettlebell", "pullup-bar", "dip-bars", "rings", "bands", "machines", "cable", "rower", "bike", "ski-erg", "jump-rope", "box", "medicine-ball", "ab-wheel", "battle-rope", "sled", "ghd", "climbing-rope"] ; omis : pas renseigné
constraints: [contraintes de sécurité et d'organisation]
heightCm: taille en centimètres, ou null
sessionMinutes: durée visée d'une séance, de 10 à 240
+2
View File
@@ -117,6 +117,8 @@
.lib-more { margin-top: var(--space-3); }
.lib-more > summary { list-style: none; gap: var(--space-2); cursor: pointer; font-family: var(--font-mark); font-size: var(--fs-mark); font-weight: 700; text-transform: uppercase; min-height: var(--tap); display: flex; align-items: center; }
.lib-count { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font-family: var(--font-mark); font-size: var(--fs-mark); font-weight: 700; text-transform: uppercase; }
.lib-possible { width: 100%; border: var(--b) solid var(--ink); }
.lib-kit strong { display: block; margin-top: var(--space-1); }
.lib-usage { font-size: var(--fs-sm); margin: var(--space-3) 0; }
.lib-more > summary::-webkit-details-marker { display: none; }
.lib-more > summary::before { content: "+"; font-family: var(--font-mark); }
+26 -5
View File
@@ -2,6 +2,7 @@
// filtres dans l'adresse (ADR 0009), et la fiche d'un exercice. Calculs du
// domaine : domain/library.js.
import { KIT, canDo, missingKit, requiredKit } from "../../domain/kit.js";
import { h, replace } from "../dom.js";
import { EXERCISES, FAMILIES, MUSCLES } from "../../domain/exercises.js";
import { resolveExercise } from "../../domain/program.js";
@@ -84,7 +85,13 @@ export function libraryScreen({ store, nav, query }) {
const c = criteria;
const muscles = c.zone ? Object.entries(MUSCLES).filter(([, m]) => m.zone === c.zone) : [];
const more = !!(c.family || c.equipment);
const kit = store.getState().profile.kit;
replace(filters,
// Le matériel coché du profil (lot 5a) : un seul geste pour ne voir que le faisable.
kit && h("button", {
type: "button", class: "choice lib-possible", "aria-pressed": String(!!c.possible),
on: { click: () => update({ ...c, possible: !c.possible || undefined }) },
}, "Seulement ce que mon matériel permet"),
h("p", { class: "mini-label" }, "Zone"),
segmented("Zone", ZONES.map((z) => [z, ZONE_LABELS[z]]), c.zone, (zone) => update({ ...c, zone: /** @type {any} */ (zone), muscle: undefined })),
muscles.length > 1 && [
@@ -97,13 +104,13 @@ export function libraryScreen({ store, nav, query }) {
h("p", { class: "mini-label" }, "Matériel"),
segmented("Matériel", Object.entries(EQUIPMENT_GROUPS).map(([k, v]) => [k, v.label]), c.equipment, (equipment) => update({ ...c, equipment: /** @type {any} */ (equipment) }))));
const groups = filterLibrary(c);
const groups = filterLibrary(c, kit);
const count = groups.reduce((n, g) => n + g.items.length, 0);
// Les exercices génériques n'ont pas de muscles : ils ne suivent que la recherche.
const words = c.q ? fold(c.q).split(/\s+/).filter(Boolean) : [];
const generic = c.zone || c.muscle || c.family || c.equipment ? []
const generic = c.zone || c.muscle || c.family || c.equipment || c.possible ? []
: genericExercises(store.getState()).filter((x) => words.every((w) => fold(x.name).includes(w)));
const filtered = !!(c.q || c.zone || c.muscle || c.family || c.equipment);
const filtered = !!(c.q || c.zone || c.muscle || c.family || c.equipment || c.possible);
replace(results,
h("p", { class: "lib-count" }, filtered ? `${plural(count, "exercice")} sur ${total}` : `${total} exercices`,
filtered && h("button", { type: "button", class: "btn btn--ghost btn--sm", on: { click: () => { search.value = ""; update({}); } } }, "Tout effacer")),
@@ -125,8 +132,9 @@ export function libraryScreen({ store, nav, query }) {
paint();
const near = pick ? [
...(pick.planned.id !== pick.currentId && EXERCISES[pick.planned.id] ? [pick.planned.id] : []),
// Pas un exercice déjà dans la séance : on ne remplace pas par un doublon.
...similarExercises(pick.planned.id, 12).filter((r) => !pick.draft.exercises.some((x) => x.id === r)).slice(0, 8),
// Ni un exercice déjà dans la séance (un doublon), ni un que le matériel coché ne permet pas.
...similarExercises(pick.planned.id, 16)
.filter((r) => !pick.draft.exercises.some((x) => x.id === r) && canDo(r, store.getState().profile.kit)).slice(0, 8),
] : [];
const node = h("div", { class: "screen" },
pick
@@ -181,6 +189,7 @@ export function libraryItemScreen({ store, nav, today, id }) {
library && h("ul", { class: "chips", "aria-label": "Muscles" },
library.primary.map((m) => h("li", { class: "chip" }, MUSCLES[m].name)),
library.secondary.map((m) => h("li", { class: "chip chip--secondary" }, MUSCLES[m].name))),
library && kitLine(id, state.profile.kit),
h("h2", { class: "tape" }, "Dans ton programme"),
use.sessions.length
@@ -229,6 +238,18 @@ function pickContext(state, query) {
}
/** Ligne d'une liste : matériel et muscles principaux. @param {import("../../domain/exercises.js").LibraryExercise} x */
/**
* Le matériel que demande l'exercice, et ce qui manque au profil (lot 5a).
* @param {string} ref @param {readonly string[]|undefined} kit
*/
function kitLine(ref, kit) {
const needs = requiredKit(ref);
if (!needs.length) return null;
const missing = missingKit(ref, kit);
return h("p", { class: "lib-kit" }, `Matériel : ${needs.map((k) => KIT[k]).join(", ")}.`,
missing.length > 0 && h("strong", null, ` Il te manque : ${missing.map((k) => KIT[k].toLowerCase()).join(", ")}.`));
}
const metaOf = (x) => `${EQUIPMENT_LABELS[x.equipment]} · ${x.primary.map((m) => MUSCLES[m].name).join(", ")}`;
/** @param {string} link @param {string} title @param {string} meta */
+29 -3
View File
@@ -6,6 +6,7 @@
import { h } from "../dom.js";
import { MODES } from "../../domain/vocabulary.js";
import { validateProfile } from "../../domain/profile.js";
import { KIT } from "../../domain/kit.js";
import { screenHeader } from "../layout.js";
import { href } from "../router.js";
import { toast } from "../feedback.js";
@@ -21,7 +22,8 @@ export const MODE_LABELS = {
/**
* Lit le formulaire. Les listes s'écrivent une ligne par élément.
* @param {{goal: string, context: string, equipment: string, constraints: string, heightCm: string, sessionMinutes: string}} form
* @param {{goal: string, context: string, equipment: string, constraints: string, heightCm: string, sessionMinutes: string, kit?: string[]}} form
* kit : le matériel coché, omis s'il n'a jamais été renseigné
* @returns {{profile: import("../../domain/profile.js").Profile, errors: string[]}}
*/
export function profileFromForm(form) {
@@ -33,6 +35,7 @@ export function profileFromForm(form) {
context: form.context.trim(),
equipment: lines(form.equipment),
constraints: lines(form.constraints),
...(form.kit ? { kit: /** @type {import("../../domain/kit.js").Kit[]} */ (Object.keys(KIT).filter((k) => form.kit?.includes(k))) } : {}),
heightCm: height,
sessionMinutes: Math.round(Number(form.sessionMinutes.replace(",", "."))),
};
@@ -63,10 +66,26 @@ export function profileScreen({ store, nav }) {
const minutes = h("input", { id: "p-minutes", class: "field__input", type: "text", inputmode: "numeric", value: String(p.sessionMinutes) });
const status = h("p", { class: "status", role: "status", "aria-live": "polite" });
// Matériel coché (lot 5a) : absent tant qu'on n'a rien touché, pour ne rien filtrer à tort.
/** @type {Set<string>|null} */
let kit = p.kit ? new Set(p.kit) : null;
const kitBtns = Object.entries(KIT).map(([k, label]) => h("button", {
type: "button", class: "segmented__opt", data: { kit: k },
on: { click: () => { kit ??= new Set(); if (kit.has(k)) kit.delete(k); else kit.add(k); paintKit(); } },
}, label));
const kitNote = h("p", { class: "field__hint" });
const paintKit = () => {
kitBtns.forEach((b) => b.setAttribute("aria-pressed", String(!!kit?.has(/** @type {string} */ (b.dataset.kit)))));
kitNote.textContent = kit === null ? "Pas encore renseigné : la bibliothèque montre tout."
: kit.size === 0 ? "Rien de coché : poids du corps seulement." : `${kit.size} coché${kit.size > 1 ? "s" : ""}.`;
};
const setKit = (/** @type {string[]} */ keys) => { kit = new Set(keys); paintKit(); };
paintKit();
const save = () => {
const { profile, errors } = profileFromForm({
goal: goal.value, context: context.value, equipment: equipment.value, constraints: constraints.value,
heightCm: height.value, sessionMinutes: minutes.value,
heightCm: height.value, sessionMinutes: minutes.value, kit: kit ? [...kit] : undefined,
});
if (errors.length) {
status.className = "status status--err";
@@ -109,7 +128,14 @@ export function profileScreen({ store, nav }) {
h("h2", { class: "tape" }, "Toi"),
field("p-goal", "Objectif", goal, "En une phrase."),
field("p-context", "Contexte", context, "Pratique passée, lieu d'entraînement."),
field("p-equipment", "Matériel", equipment, "Un élément par ligne."),
h("div", { class: "field" },
h("p", { class: "field__label", id: "p-kit" }, "Matériel"),
h("div", { class: "segmented segmented--wrap", role: "group", "aria-labelledby": "p-kit" }, kitBtns),
kitNote,
h("div", { class: "btn-row" },
h("button", { type: "button", class: "btn btn--ghost btn--sm", on: { click: () => setKit(Object.keys(KIT)) } }, "Salle complète"),
h("button", { type: "button", class: "btn btn--ghost btn--sm", on: { click: () => setKit([]) } }, "Poids du corps seulement"))),
field("p-equipment", "Autre matériel", equipment, "Ce que les cases ne disent pas (charges des haltères, hauteur du plafond…). Un élément par ligne."),
field("p-constraints", "Contraintes", constraints, "Sécurité, blessures, organisation. Une par ligne."),
h("div", { class: "field-pair" },
field("p-height", "Taille (cm)", height),
+1 -1
View File
@@ -64,7 +64,7 @@ briques, dans cet ordre, après R2, 1i et l'extension du format WOD (Chelsea, Ba
| Sous-lot | Contenu | État |
| --- | --- | --- |
| 5a | Matériel structuré dans le profil (cases à cocher), filtre « ce que je peux faire » dans la bibliothèque | ⏳ |
| 5a | Matériel structuré dans le profil (cases à cocher), filtre « ce que je peux faire » dans la bibliothèque | 🔄 |
| 5b | Vérification des propositions : équilibre, volume par muscle, récupération, matériel, variété d'un WOD ; alertes dans l'aperçu et dans la réponse MCP, adoption libre | ⏳ |
| 5c | Générateur de « WOD du jour » hors ligne : format, durée, modalités variées, matériel, historique | ⏳ |
| 5d | Progression et décharge : semaine de décharge proposée, règle pour la charge par série | ⏳ |
+1
View File
@@ -42,6 +42,7 @@ existe.
| [Créneau](creneau.md) | Slot |
| [De chaque côté](chaque-cote.md) | Sides (`sidesOf`) |
| [Double progression](double-progression.md) | Double progression |
| [Matériel](materiel.md) | Kit (`KIT`) |
| [Remplacement](remplacement.md) | Replacement (`replaceExercise`) |
| [Score](score.md) | Score (`WodResult`) |
| [WOD](wod.md) | WOD (`WodFormat`) |
+22
View File
@@ -0,0 +1,22 @@
---
term: Matériel
english: Kit
code: KIT
---
# Matériel
**En bref** : ce que l'utilisateur a pour s'entraîner, coché dans son profil (barre et disques, banc, barre de traction, rameur…), et ce que demande chaque exercice de la bibliothèque.
Le profil garde le matériel coché (`kit`), et à côté un texte libre pour ce que les cases ne
disent pas (« haltères jusqu'à 30 kg »). Tant que rien n'est coché, le matériel n'est pas
renseigné et l'app ne filtre rien. « Poids du corps seulement » est un choix explicite :
une liste vide.
Ce que demande un exercice se déduit de sa catégorie (barre, haltères, machine…), plus les
supports et le petit matériel qu'elle ne dit pas : un banc pour le développé couché, une
barre de traction pour les tractions, une box pour les box jumps. Un exercice hors
bibliothèque ne demande rien, faute de savoir. La bibliothèque peut ne montrer que ce que
le matériel permet ; la fiche d'un exercice dit ce qui manque, et le remplacement en séance
ne propose que des exercices faisables.
Voir aussi : [Profil](profil.md), [Bibliothèque](bibliotheque.md), [Exercice](exercice.md)
+2 -2
View File
@@ -68,7 +68,7 @@ const TOOLS = [
type: "object",
properties: {
program: { type: "object", description: "Programme complet au format IA-Fit : {name, sessions: [{key, name, exercises: [{ref|name, sets, reps, rest, …}]}], activities?, cardio?, rules?}." },
profile: { type: "object", description: "Profil complet, facultatif : {goal, context, equipment[], constraints[], heightCm, sessionMinutes}." },
profile: { type: "object", description: "Profil complet, facultatif : {goal, context, equipment[], kit?[], constraints[], heightCm, sessionMinutes} (kit : matériel coché, clés listées dans ia.md)." },
reason: { type: "string", description: "Pourquoi ce changement, en une ou deux phrases adressées à l'utilisateur." },
},
required: ["program", "reason"],
@@ -108,7 +108,7 @@ const TOOLS = [
inputSchema: {
type: "object",
properties: {
profile: { type: "object", description: "Profil complet : {goal, context, equipment[], constraints[], heightCm, sessionMinutes}." },
profile: { type: "object", description: "Profil complet : {goal, context, equipment[], kit?[], constraints[], heightCm, sessionMinutes} (kit : matériel coché, clés listées dans ia.md)." },
reason: { type: "string", description: "Pourquoi ce changement." },
},
required: ["profile", "reason"],
+15 -1
View File
@@ -292,9 +292,14 @@ function check(scheme, cond, msg) {
// ---- profil et mode ----------------------------------------------------------------
await go("#/profil");
await page.getByLabel("Objectif").fill("Prendre de la force sans me blesser");
await page.getByLabel("Matériel").fill("Barre\nBanc\nHaltères");
ok(await page.getByText("Pas encore renseigné").isVisible(), "matériel : pas encore renseigné");
await button("Salle complète").click();
await button("Barre de traction").click();
ok(await button("Barre de traction").getAttribute("aria-pressed") === "false" && await button("Banc", { exact: true }).getAttribute("aria-pressed") === "true", "matériel coché : salle complète sans barre de traction");
await page.getByLabel("Autre matériel").fill("Haltères jusqu'à 30 kg");
await button("Enregistrer le profil").click();
ok(await page.getByText("Profil enregistré.").isVisible(), "profil enregistré");
ok(await page.evaluate(async () => (await import("./main.js")).store.getState().profile.kit?.includes("pullup-bar")) === false, "matériel gardé dans le profil");
await button("Maintien").click();
ok(await button("Maintien").getAttribute("aria-pressed") === "true", "mode maintien");
await shot("11-profil", true);
@@ -349,6 +354,15 @@ function check(scheme, cond, msg) {
await page.goBack();
await settle();
ok(page.url().endsWith("?q=pont&zone=lower&muscle=glutes"), "retour : la liste filtrée");
// Matériel coché (lot 5a) : sans barre de traction, plus de tractions.
await go("#/bibliotheque?q=traction");
const before = await page.locator(".lib-results .row").count();
await button("Seulement ce que mon matériel permet").click();
await page.waitForTimeout(200);
ok(page.url().endsWith("#/bibliotheque?q=traction&possible=1"), "« ce que mon matériel permet » dans l'adresse : " + page.url().split("#")[1]);
ok(await page.locator(".lib-results .row").count() < before && await page.getByRole("link", { name: /^Traction/ }).count() === 0, "sans barre de traction : plus de tractions");
await go("#/bibliotheque/pull-up");
ok(await page.getByText("Il te manque : barre de traction.").isVisible(), "fiche : le matériel qui manque");
await go("#/bibliotheque/squat");
ok(await page.getByText(/Fait \d+ fois/).isVisible(), "fiche du squat : historique et lien vers les analyses");
await button(/Demander à mon IA/).click();
+66
View File
@@ -0,0 +1,66 @@
// Le matériel coché (lot 5a) : ce que demande chaque exercice, ce qui manque,
// le profil, la bibliothèque et le texte pour l'IA. Glossaire : docs/glossaire/materiel.md
import { test } from "node:test";
import assert from "node:assert/strict";
import { EXERCISES } from "../../app/domain/exercises.js";
import { KIT, canDo, isKit, kitLabels, missingKit, requiredKit } from "../../app/domain/kit.js";
import { DEFAULT_PROFILE, validateProfile } from "../../app/domain/profile.js";
import { filterLibrary, formatCriteria, parseCriteria } from "../../app/domain/library.js";
import { buildEvolutionBrief, buildOnboardingBrief } from "../../app/domain/ai-brief.js";
import { createEvent } from "../../app/domain/events.js";
import { foldEvents } from "../../app/domain/state.js";
import { profileFromForm } from "../../app/ui/screens/profile.js";
test("chaque exercice demande du matériel connu ; la catégorie et les exceptions s'additionnent", () => {
for (const ref of Object.keys(EXERCISES)) for (const k of requiredKit(ref)) assert.ok(isKit(k), `${ref} : ${k}`);
assert.deepEqual(requiredKit("bench-press").sort(), ["barbell", "bench", "rack"]);
assert.deepEqual(requiredKit("pull-up"), ["pullup-bar"]);
assert.deepEqual(requiredKit("push-up"), []);
assert.deepEqual(requiredKit("rowing-machine"), ["rower"]);
assert.deepEqual(requiredKit("inconnu"), [], "hors bibliothèque : on ne sait pas, rien n'est exigé");
// Tout ce qui n'est pas au poids du corps demande quelque chose.
for (const [ref, x] of Object.entries(EXERCISES))
if (x.equipment !== "bodyweight") assert.ok(requiredKit(ref).length > 0, `${ref} (${x.equipment}) ne demande rien`);
});
test("ce qui manque : rien tant que le matériel n'est pas renseigné", () => {
assert.deepEqual(missingKit("bench-press", undefined), []);
assert.deepEqual(missingKit("bench-press", ["barbell", "bench"]), ["rack"]);
assert.equal(canDo("bench-press", ["barbell", "bench", "rack"]), true);
assert.equal(canDo("push-up", []), true);
assert.deepEqual(kitLabels(["bench", "barbell"]), ["Barre et disques", "Banc"], "dans l'ordre de KIT");
});
test("profil : kit facultatif, clés connues, sans doublon", () => {
assert.deepEqual(validateProfile(DEFAULT_PROFILE), []);
assert.deepEqual(validateProfile({ ...DEFAULT_PROFILE, kit: ["barbell", "rack"] }), []);
assert.deepEqual(validateProfile({ ...DEFAULT_PROFILE, kit: [] }), []);
assert.match(validateProfile({ ...DEFAULT_PROFILE, kit: ["trampoline"] })[0], /'kit'/);
assert.match(validateProfile({ ...DEFAULT_PROFILE, kit: ["bench", "bench"] })[0], /'kit'/);
});
test("formulaire du profil : kit omis s'il n'a jamais été renseigné, dans l'ordre de KIT sinon", () => {
const form = { goal: "", context: "", equipment: "", constraints: "", heightCm: "", sessionMinutes: "50" };
assert.equal("kit" in profileFromForm(form).profile, false);
assert.deepEqual(profileFromForm({ ...form, kit: ["bench", "barbell"] }).profile.kit, ["barbell", "bench"]);
assert.deepEqual(profileFromForm({ ...form, kit: [] }).profile.kit, []);
});
test("bibliothèque : « ce que mon matériel permet », gardé dans l'adresse", () => {
assert.deepEqual(parseCriteria("possible=1"), { possible: true });
assert.equal(formatCriteria({ possible: true, zone: "upper" }), "zone=upper&possible=1");
const refs = (/** @type {any} */ c, /** @type {string[]|undefined} */ kit) => filterLibrary(c, kit).flatMap((g) => g.items.map((i) => i.ref));
const bodyweight = refs({ possible: true }, []);
assert.ok(bodyweight.includes("push-up") && !bodyweight.includes("pull-up") && !bodyweight.includes("squat"));
assert.ok(refs({ possible: true }, ["pullup-bar"]).includes("pull-up"));
assert.equal(refs({ possible: true }, undefined).length, Object.keys(EXERCISES).length, "matériel non renseigné : tout");
});
test("texte pour l'IA : le format du profil liste les clés, le profil montre le matériel coché", () => {
assert.match(buildOnboardingBrief({ baseUrl: "https://ia-fit.example" }), /kit\?: \[matériel coché, parmi "barbell", "rack"/);
const profile = { ...DEFAULT_PROFILE, kit: /** @type {any} */ (["barbell", "bench"]) };
const s = foldEvents([createEvent("ProfileUpdated", { profile }, { device: "d", at: "2026-11-01T10:00:00.000Z" })]);
assert.match(buildEvolutionBrief(s, { today: "2026-11-02", baseUrl: "https://ia-fit.example" }), /Matériel coché : Barre et disques, Banc/);
assert.match(buildEvolutionBrief(foldEvents([]), { today: "2026-11-02", baseUrl: "https://ia-fit.example" }), /Matériel coché : non renseigné/);
assert.equal(Object.keys(KIT).length >= 20, true);
});