AgentSkillsCN

workout-domain

锻炼区块模型、类型和操作。在构建锻炼、管理区块种类(力量/AMRAP/EMOM/Tabata/ForTime/有氧)、处理组数/次数,或处理锻炼持久性和基准时使用。触发:“锻炼”、“区块”、“力量”、“有氧”、“AMRAP”、“EMOM”、“Tabata”、“ForTime”、“练习”、“组”、“次数”、“重量”、“RIR”、“定时区块”、“创建锻炼”、“构建锻炼”、“区块种类”、“区分联合”、“区块结果”、“轮次”、“间隔”、“基准”、“模板”、“持久锻炼”、“完成锻炼”。

SKILL.md
--- frontmatter
name: workout-domain
description: Workout block model, types, and operations. Use when building workouts, managing block kinds (strength/AMRAP/EMOM/Tabata/ForTime/cardio), handling sets/reps, or working with workout persistence and benchmarks. Triggers: "workout", "block", "strength", "cardio", "AMRAP", "EMOM", "Tabata", "ForTime", "exercise", "set", "reps", "weight", "RIR", "timed block", "create workout", "build workout", "block kind", "discriminated union", "block result", "round", "interval", "benchmark", "template", "persist workout", "complete workout".

Workout Domain

Block-Based Workout Model

Workouts are sequences of blocks using discriminated unions via kind:

ts
type WorkoutBlock = StrengthBlock | TimedBlock | CardioBlock

type TimedBlock = AmrapBlock | EmomBlock | TabataBlock | ForTimeBlock

Strength Block

Traditional sets/reps exercises:

ts
type StrengthBlock = {
  kind: 'strength'
  id: number
  exerciseName: string
  sets: Array<Set>
}

type Set = {
  id: number
  weight?: string    // User input as string
  reps?: string
  rir?: string       // Reps in reserve
  completed: boolean
}

Timed Blocks

AMRAP, EMOM, Tabata, ForTime:

ts
type AmrapBlock = {
  kind: 'amrap'
  id: number
  config: AmrapConfig
  exercises: Array<BlockExercise>
  result?: AmrapResult
}

type EmomBlock = {
  kind: 'emom'
  id: number
  config: EmomConfig
  exercises: Array<BlockExercise>
  result?: EmomResult
}

type TabataBlock = {
  kind: 'tabata'
  id: number
  config: TabataConfig
  exercises: Array<BlockExercise>
  result?: TabataResult
}

type ForTimeBlock = {
  kind: 'fortime'
  id: number
  config: ForTimeConfig
  exercises: Array<BlockExercise>
  result?: ForTimeResult
}

Cardio Block

ts
type CardioBlock = {
  kind: 'cardio'
  id: number
  exerciseName: string
  duration?: number
  distance?: number
  calories?: number
}

Type Files

FilePurpose
src/types/blocks.tsRuntime block types
src/db/schema.tsPersistence types with Db prefix

Convention: Database types use Db prefix (e.g., DbStrengthBlock) and null instead of undefined.

Key Composables

Workout Feature

ComposablePurpose
useWorkout.tsSingleton state, block/set CRUD operations
useWorkoutPersistence.tsAuto-save, complete, discard active workout
useWorkoutExercise.tsExercise selection within workout
useWorkoutBuilder.tsBuild workout from scratch or template

Benchmark Feature

ComposablePurpose
useBenchmark.tsCore benchmark state and operations
useBenchmarkPersistence.tsSave benchmark attempts
useBenchmarkTimer.tsTimer for timed benchmarks

Template Feature

ComposablePurpose
useTemplateForm.tsCreate/edit template form state
useTemplatePicker.tsSelect template to start workout

Working with Blocks

Adding a Block

ts
import { useWorkout } from '@/features/workout/composables/useWorkout'

const { addBlock } = useWorkout()

// Add strength block
addBlock({
  kind: 'strength',
  exerciseName: 'Squat',
  sets: []
})

// Add AMRAP block
addBlock({
  kind: 'amrap',
  config: { duration: 10 },
  exercises: []
})

Type-Safe Block Handling

Use exhaustive switch for block kinds:

ts
function getBlockTitle(block: WorkoutBlock): string {
  switch (block.kind) {
    case 'strength':
      return block.exerciseName
    case 'amrap':
      return `AMRAP ${block.config.duration}min`
    case 'emom':
      return `EMOM ${block.config.rounds}x${block.config.interval}s`
    case 'tabata':
      return 'Tabata'
    case 'fortime':
      return 'For Time'
    case 'cardio':
      return block.exerciseName
    default:
      // TypeScript exhaustiveness check
      const _exhaustive: never = block
      return _exhaustive
  }
}

Quick Find

bash
rg -n "kind: '(strength|amrap|emom|tabata|fortime|cardio)'" src/  # Block usage
rg -n "type.*Block = " src/types/blocks.ts                        # Block type definitions
rg -n "export function use" src/features/workout/composables      # Workout composables