HERAKLES: Hierarchical Skill Compilation for Open-ended LLM Agents