workout generator audit: rules engine, structure rules, split patterns, injury UX, metadata cleanup

- Add rules_engine.py with quantitative rules for all 8 workout types
- Add quality gate retry loop in generate_single_workout()
- Expand calibrate_structure_rules to all 120 combinations (8 types × 5 goals × 3 sections)
- Wire WeeklySplitPattern DB records into _pick_weekly_split()
- Enforce movement patterns from WorkoutStructureRule in exercise selection
- Add straight-set strength support (single main lift, 4-6 rounds)
- Add modality consistency check for duration-dominant workout types
- Add InjuryStep component to onboarding and preferences
- Add sibling exercise exclusion in regenerate and preview_day endpoints
- Display generator warnings on dashboard
- Expand fix_rep_durations, fix_exercise_flags, fix_movement_pattern_typo
- Add audit_exercise_data and check_rules_drift management commands
- Add Next.js frontend with dashboard, onboarding, preferences, history pages
- Add generator app with ML-powered workout generation pipeline
- 96 new tests across 7 test modules

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-02-22 20:07:40 -06:00
parent 2a16b75c4b
commit 1c61b80731
111 changed files with 28108 additions and 30 deletions

View File

@@ -0,0 +1,35 @@
import type { ReactNode } from "react";
type BadgeVariant = "default" | "success" | "warning" | "error" | "accent";
interface BadgeProps {
variant?: BadgeVariant;
children: ReactNode;
className?: string;
}
const variantClasses: Record<BadgeVariant, string> = {
default: "bg-zinc-700 text-zinc-300",
success: "bg-green-500/20 text-green-400",
warning: "bg-amber-500/20 text-amber-400",
error: "bg-red-500/20 text-red-400",
accent: "bg-[rgba(57,255,20,0.1)] text-[#39FF14]",
};
export function Badge({
variant = "default",
children,
className = "",
}: BadgeProps) {
return (
<span
className={`
inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
${variantClasses[variant]}
${className}
`}
>
{children}
</span>
);
}

View File

@@ -0,0 +1,69 @@
"use client";
import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from "react";
import { Spinner } from "@/components/ui/Spinner";
type Variant = "primary" | "secondary" | "danger" | "ghost";
type Size = "sm" | "md" | "lg";
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: Variant;
size?: Size;
loading?: boolean;
children: ReactNode;
}
const variantClasses: Record<Variant, string> = {
primary:
"bg-accent text-black font-bold hover:bg-accent-hover active:bg-accent-hover",
secondary: "bg-zinc-700 text-zinc-100 hover:bg-zinc-600 active:bg-zinc-500",
danger: "bg-red-500 text-white hover:bg-red-600 active:bg-red-700",
ghost: "bg-transparent text-zinc-100 hover:bg-zinc-800 active:bg-zinc-700",
};
const sizeClasses: Record<Size, string> = {
sm: "px-3 py-1.5 text-sm rounded-lg",
md: "px-5 py-2.5 text-base rounded-lg",
lg: "px-7 py-3.5 text-lg rounded-xl",
};
const Button = forwardRef<HTMLButtonElement, ButtonProps>(
(
{
variant = "primary",
size = "md",
loading = false,
disabled,
className = "",
children,
...rest
},
ref
) => {
const isDisabled = disabled || loading;
return (
<button
ref={ref}
disabled={isDisabled}
className={`
inline-flex items-center justify-center gap-2 font-medium
transition-colors duration-150 ease-in-out
${variantClasses[variant]}
${sizeClasses[size]}
${isDisabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
${className}
`}
{...rest}
>
{loading && <Spinner size="sm" />}
{children}
</button>
);
}
);
Button.displayName = "Button";
export { Button };
export type { ButtonProps };

View File

@@ -0,0 +1,23 @@
import type { ReactNode, HTMLAttributes } from "react";
interface CardProps extends HTMLAttributes<HTMLDivElement> {
className?: string;
children: ReactNode;
onClick?: () => void;
}
export function Card({ className = "", children, onClick, ...rest }: CardProps) {
return (
<div
onClick={onClick}
className={`
bg-zinc-900 border border-zinc-700/50 rounded-xl
${onClick ? "hover:bg-zinc-800/50 cursor-pointer transition-colors duration-150" : ""}
${className}
`}
{...rest}
>
{children}
</div>
);
}

View File

@@ -0,0 +1,50 @@
"use client";
interface SliderProps {
min: number;
max: number;
value: number;
onChange: (value: number) => void;
step?: number;
label?: string;
unit?: string;
className?: string;
}
export function Slider({
min,
max,
value,
onChange,
step = 1,
label,
unit,
className = "",
}: SliderProps) {
return (
<div className={`flex flex-col gap-2 ${className}`}>
{(label || unit) && (
<div className="flex items-center justify-between">
{label && (
<label className="text-sm font-medium text-zinc-300">
{label}
</label>
)}
<span className="text-sm font-semibold text-accent tabular-nums">
{value}
{unit && <span className="ml-0.5 text-zinc-400">{unit}</span>}
</span>
</div>
)}
<input
type="range"
min={min}
max={max}
step={step}
value={value}
onChange={(e) => onChange(Number(e.target.value))}
className="range-slider w-full h-2 rounded-full appearance-none cursor-pointer bg-zinc-700"
/>
</div>
);
}

View File

@@ -0,0 +1,37 @@
type SpinnerSize = "sm" | "md" | "lg";
interface SpinnerProps {
size?: SpinnerSize;
className?: string;
}
const sizePx: Record<SpinnerSize, number> = {
sm: 16,
md: 24,
lg: 40,
};
const borderWidth: Record<SpinnerSize, number> = {
sm: 2,
md: 3,
lg: 4,
};
export function Spinner({ size = "md", className = "" }: SpinnerProps) {
const px = sizePx[size];
const bw = borderWidth[size];
return (
<span
role="status"
aria-label="Loading"
className={`inline-block animate-spin rounded-full ${className}`}
style={{
width: px,
height: px,
border: `${bw}px solid rgba(63,63,70,0.6)`,
borderTopColor: "#39FF14",
}}
/>
);
}