# 082: AI Code Generation
# Let AI write implementations

# Explicit AI call
result = ai.generate:
  input: sales_data
  output: "summary report with charts"
  constraints: [
    "Group by region",
    "Show top 5 products",
    "Calculate growth percentage"
  ]

show result

# AI with type hints
generate_user_report(user_id):
  # AI infers: fetch data, format nicely, return string
  ai.generate:
    task: "Create user activity report"
    input: user_id
    output: "markdown formatted report"

# Complex data transformation
messy_data = [
  { "firstName": "Alex", "last_name": "Chen", "AGE": "28" },
  { "firstName": "Jordan", "LastName": "Lee", "age": 25 }
]

### Intent: Normalize this data to consistent format
### Expected output: [{ first_name, last_name, age }]

normalized = ai.normalize(messy_data, {
  format: "snake_case",
  required_fields: ["first_name", "last_name", "age"]
})

show normalized

# AI shows proposed code, you approve
# Once approved, it runs
# Future runs use the cached implementation
