/**
 * Recipe System Types
 *
 * Recipes are reusable workflow templates that automate multi-step tasks.
 * They use markdown with YAML frontmatter (consistent with skills/agents).
 *
 * Recipes live in:
 *   - ~/.sandcode/recipes/     (user-level)
 *   - .sandcode/recipes/       (project-level)
 *   - src/recipes/bundled/     (built-in)
 */

export interface RecipeStep {
  /** The prompt to send to the AI for this step */
  prompt: string
  /** Optional human-readable name for the step */
  name?: string
  /** If true, ask user for confirmation before executing */
  confirm?: boolean
  /** Optional condition — skip this step if condition is falsy */
  when?: string
}

export interface RecipeFrontmatter {
  name: string
  description: string
  tags?: string[]
  /** Ordered steps to execute */
  steps: RecipeStep[]
  /** Optional: require specific tools to be available */
  requires?: string[]
  /** Optional: estimated time to complete */
  estimate?: string
}

export interface Recipe {
  /** Unique identifier derived from filename */
  id: string
  /** Parsed frontmatter metadata */
  metadata: RecipeFrontmatter
  /** Full markdown body (displayed as context before execution) */
  body: string
  /** Source path of the recipe file */
  sourcePath: string
  /** Where the recipe was loaded from */
  source: 'bundled' | 'user' | 'project'
}

export interface RecipeExecutionState {
  recipe: Recipe
  currentStep: number
  totalSteps: number
  completed: boolean
  startedAt: number
  results: StepResult[]
}

export interface StepResult {
  stepIndex: number
  status: 'completed' | 'skipped' | 'failed'
  error?: string
}
