Skip to content

feat: Add wishful.explore() for multi-variant generation + documentation overhaul#6

Merged
pyros-projects merged 8 commits intomainfrom
feat/documentation
Nov 25, 2025
Merged

feat: Add wishful.explore() for multi-variant generation + documentation overhaul#6
pyros-projects merged 8 commits intomainfrom
feat/documentation

Conversation

@pyros-projects
Copy link
Copy Markdown
Owner

✨ Overview

This PR introduces wishful.explore() - a powerful new feature that generates multiple implementation variants, tests them, and caches the winner. Plus a comprehensive documentation overhaul.

🔍 New Feature: wishful.explore()

Generate multiple variants of a function and automatically select the best one:

import wishful

# Generate 5 implementations, keep the first one that passes
parser = wishful.explore(
    "wishful.static.text.extract_emails",
    variants=5,
    test=lambda fn: fn("test@example.com") == ["test@example.com"]
)

# The winner is cached! Future imports use the proven implementation.
from wishful.static.text import extract_emails  # ← Uses the battle-tested winner

Key Features

  • Test-based selection: Filter variants with pass/fail tests (test=)
  • Benchmark scoring: Score variants and pick the best (benchmark=, optimize="fastest")
  • Winner caching: The selected variant is automatically cached to .wishful/
  • Beautiful Rich progress display: Real-time progress with variant status table
  • CSV logging: Results saved to {cache_dir}/_explore/ for analysis
  • Metadata on functions: Access __wishful_metadata__ and __wishful_source__

Selection Strategies

  • first_passing (default): Return first variant that passes the test
  • fastest / best_score: Benchmark all variants, return highest scorer

📚 Documentation Overhaul

  • AGENTS.md: Comprehensive guide for AI agents working on the codebase
  • README.md: Major updates including explore docs, better configuration table
  • docs-site/explore.mdx: Full documentation for the explore feature
  • New examples:
    • examples/12_explore.py: Basic explore usage
    • examples/13_explore_advanced.py: Advanced patterns (LLM-as-judge, code golf, self-improving loops)
  • Updated examples: 00_quick_start, 05_api_client, 07_typed_outputs, 08_dynamic_vs_static

🔧 Technical Changes

New Module: src/wishful/explore/

src/wishful/explore/
├── __init__.py      # Public API: explore, ExplorationError
├── explorer.py      # Core explore() - async internally, sync API
├── strategies.py    # Selection strategies (first_passing, best_score)
├── variant.py       # VariantMetadata and wrapper
├── progress.py      # Rich Live progress display and CSV logging
└── exceptions.py    # ExplorationError

Other Changes

  • LLM client: Added async generation support (agenerate_module_code)
  • Tests: 22+ new tests in test_explore.py
  • Version: Bumped to 0.2.4
  • Test badge: Updated from 83 → 112 passing tests

🗑️ Removed

  • docs/CHANGELOG.md (outdated)
  • docs/ideas/advanced_context_discovery.md (moved to internal docs)

📊 Stats

28 files changed, 2875 insertions(+), 642 deletions(-)

Previously, __wishful_source__ was only attached to functions after
selection via wrap_with_metadata(). This meant benchmark functions
couldn't access the source code during evaluation.

The fix attaches __wishful_source__ immediately after compilation,
enabling LLM-as-Judge patterns where the benchmark inspects generated
code quality.

Also adds examples/13_explore_advanced.py demonstrating:
- LLM-as-Judge scoring
- Code golf (shortest implementation)
- Self-improving loops
- Multi-objective optimization
- Real-world regex challenges
- Add 'Going Deeper: LLMs Judging LLMs' section to README
- Add 'Advanced: LLMs Judging LLMs' section to explore.mdx
- Update project structure to include 13_explore_advanced.py
@pyros-projects pyros-projects merged commit 78c081c into main Nov 25, 2025
1 check passed
@pyros-projects pyros-projects deleted the feat/documentation branch November 25, 2025 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant