Skip to content

pyros-projects/wishful

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

125 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Wishful Banner

PyPI version Python 3.12+ License: MIT Tests Coverage Code style: ruff

"Import your wildest dreams"

Stop writing boilerplate. Start wishing for it instead.

wishful turns your wildest import dreams into reality. Just write the import you wish existed, and an LLM conjures up the code on the spot. The first run? Pure magic. Every run after? Blazing fast, because it's cached like real Python.

Think of it as wishful thinking, but for imports. The kind that actually works.

โœจ Quick Wish

1. Install the dream

pip install wishful

2. Set your API key (any provider supported by litellm)

export OPENAI_API_KEY=your_key_here
# or AZURE_API_KEY, ANTHROPIC_API_KEY, etc.

3. Import your wildest fantasies

from wishful.static.text import extract_emails
from wishful.static.dates import to_yyyy_mm_dd

raw = "Contact us at team@example.com or sales@demo.dev"
print(extract_emails(raw))  # ['team@example.com', 'sales@demo.dev']
print(to_yyyy_mm_dd("31.12.2025"))  # '2025-12-31'

What just happened?

  • First import: wishful waves its wand ๐Ÿช„, asks the LLM to write extract_emails and to_yyyy_mm_dd, validates the code for safety, and caches it to .wishful/text.py and .wishful/dates.py.
  • Every subsequent run: instant. Just regular Python imports. No latency, no drama, no API calls.

It's like having a junior dev who never sleeps and always delivers exactly what you asked for (well, almost always).

๐Ÿ’ก Pro tip: Use wishful.static.* for cached imports (recommended) or wishful.dynamic.* for runtime-aware regeneration. See Static vs Dynamic below.


๐ŸŽฏ Wishful Guidance: Help the AI Read Your Mind

Want better results? Drop hints. Literal comments. wishful reads the code around your import and forwards that context to the LLM. It's like pair programming, but your partner is a disembodied intelligence with questionable opinions about semicolons.

# desired: parse standard nginx combined logs into list of dicts
from wishful.static.logs import parse_nginx_logs

records = parse_nginx_logs(Path("/var/log/nginx/access.log").read_text())

๐ŸŽจ Type Registry: Teach the AI Your Data Structures

Want the LLM to generate functions that return properly structured data? Register your types with @wishful.type:

Pydantic Models with Constraints

from pydantic import BaseModel, Field
import wishful

@wishful.type
class ProjectPlan(BaseModel):
    """Project plan written by master yoda from star wars."""
    project_brief: str
    milestones: list[str] = Field(description="list of milestones", min_length=10)
    budget: float = Field(gt=0, description="project budget in USD")

# Now the LLM knows about ProjectPlan and will respect Field constraints!
from wishful.static.pm import project_plan_generator

plan = project_plan_generator(idea="sudoku web app")
print(plan.milestones)  
# ['Decide, you must, key features.', 'Wireframe, you will, the interface.', ...]
# ^ 10+ milestones in Yoda-speak because of the docstring! ๐ŸŽญ

What's happening here?

  • The @wishful.type decorator registers your Pydantic model
  • The docstring influences the LLM's tone/style (Yoda-speak!)
  • Field constraints (min_length=10, gt=0) are actually enforced
  • Generated code uses your exact type definition

Dataclasses and TypedDict Too

from dataclasses import dataclass
from typing import TypedDict

@wishful.type(output_for="parse_user_data")
@dataclass
class UserProfile:
    """User profile with name, email, and age."""
    name: str
    email: str
    age: int

class ProductInfo(TypedDict):
    """Product information."""
    name: str
    price: float
    in_stock: bool

# Tell the LLM multiple functions use this type
wishful.type(ProductInfo, output_for=["parse_product", "create_product"])

The LLM will generate functions that return instances of your registered types. It's like having an API contract, but the implementation writes itself. โœจ


๐Ÿ”„ Static vs Dynamic: When to Use Which

wishful supports two import modes:

wishful.static.* โ€” Cached & Consistent (Default)

from wishful.static.text import extract_emails
  • โœ… Cached: Generated once, reused forever
  • โœ… Fast: No LLM calls after first import
  • โœ… Editable: Tweak .wishful/text.py directly
  • ๐Ÿ‘‰ Use for: utilities, parsers, validators, anything stable

wishful.dynamic.* โ€” Runtime-Aware & Fresh

# when importing as dynamic module all bets are off
import wishful.dynamic.content as magical_content

my_intro = magical_content.create_a_cosmic_horrorstory_intro()
  • ๐Ÿ”„ Regenerates: Fresh LLM call on every import
  • ๐ŸŽฏ Context-aware: Captures runtime context each time
  • ๐ŸŽจ Creative: Different results on each run
  • ๐Ÿ‘‰ Use for: creative content, experiments, testing variations

Note: Dynamic imports always regenerate and never use the cache, even if a cached version exists. This ensures fresh, context-aware results every time.


๐Ÿ” Explore: When One Wish Isn't Enough

Sometimes the genie needs a few tries to get it right.

What if instead of trusting the first implementation, you could generate multiple variants, test them all, and keep only the winner? Enter wishful.explore():

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

The magic: explore() generates multiple candidates, tests each one, and caches the winner to .wishful/. Subsequent imports skip the exploration entirelyโ€”you get the proven implementation instantly.

Find the Fastest Implementation

def benchmark_sort(fn):
    import time
    start = time.perf_counter()
    for _ in range(100):
        fn(list(range(1000, 0, -1)))
    return 100 / (time.perf_counter() - start)  # ops/sec

# Generate 10 variants, benchmark each, return the fastest
fastest = wishful.explore(
    "wishful.static.algorithms.sort_list",
    variants=10,
    benchmark=benchmark_sort,
    optimize="fastest"
)

print(fastest.__wishful_metadata__)
# {'variant_index': 7, 'benchmark_score': 814106.86, ...}

Beautiful Progress Display

explore() shows a real-time Rich display while it works:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ ๐Ÿ” wishful.explore โ†’ wishful.static.text.extract_emails โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚    Exploring extract_emails โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 3/3 โ€ข 0:00:03     โ”‚
โ”‚  Strategy:  first_passing                                                    โ”‚
โ”‚  Passed:    2                                                                โ”‚
โ”‚  Failed:    1                                                                โ”‚
โ”‚                                   Variants                                   โ”‚
โ”‚  โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“  โ”‚
โ”‚  โ”ƒ    # โ”ƒ Status     โ”ƒ    Time โ”ƒ Info                                     โ”ƒ  โ”‚
โ”‚  โ”กโ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ  โ”‚
โ”‚  โ”‚    0 โ”‚ passed     โ”‚    1.4s โ”‚ def extract_emails(text: str) -> list[st โ”‚  โ”‚
โ”‚  โ”‚    1 โ”‚ failed     โ”‚    0.8s โ”‚ def extract_emails(s): return re.findall โ”‚  โ”‚
โ”‚  โ”‚    2 โ”‚ passed     โ”‚    1.2s โ”‚ import re  def extract_emails(text): ... โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Results are also saved to CSV in .wishful/_explore/ for downstream analysis. Because data-driven wishful thinking is still wishful thinking. ๐Ÿ“Š

Going Deeper: LLMs Judging LLMs

Want to get really wild? Check out examples/13_explore_advanced.py for:

  • LLM-as-Judge: Use wishful.dynamic to score code quality
  • Code Golf: Find the shortest working implementation
  • Self-Improving Loops: The winner helps evaluate the next round
  • Multi-Objective Optimization: Speed ร— brevity ร— quality

It's turtles all the way down. ๐Ÿข


๐Ÿงฌ Evolve: Improve a Function Over Generations

explore() tries several fresh variants. evolve() goes one step further: it keeps a history of prior attempts, scores, and failures, then passes that history back into the next mutation prompt.

import wishful


def normalize_scores(values):
    values = [float(value) for value in values]
    if not values:
        return []
    minimum = min(values)
    maximum = max(values)
    if maximum == minimum:
        return [0.0 for _ in values]
    return [(value - minimum) / (maximum - minimum) for value in values]


normalize_scores.__wishful_source__ = """
def normalize_scores(values):
    values = [float(value) for value in values]
    if not values:
        return []
    minimum = min(values)
    maximum = max(values)
    if maximum == minimum:
        return [0.0 for _ in values]
    return [(value - minimum) / (maximum - minimum) for value in values]
""".strip()


def is_correct(fn):
    return (
        fn([10, 20, 30]) == [0.0, 0.5, 1.0]
        and fn([2, 2, 2]) == [0.0, 0.0, 0.0]
    )


def score(fn):
    return 1_000.0 - len(fn.__wishful_source__) if is_correct(fn) else 0.0


evolved = wishful.evolve(
    normalize_scores,
    fitness=score,
    test=is_correct,
    generations=3,
    variants=4,
    mutation_prompt="Keep behavior identical but make the code concise.",
)

print(evolved.__wishful_evolution__)

The returned function carries:

  • __wishful_source__: the winning source code
  • __wishful_evolution__: original score, final score, improvement, generation summaries, and every attempted variant

Try the deterministic offline demo:

WISHFUL_FAKE_LLM=1 uv run python examples/14_evolve.py

๐Ÿ—„๏ธ Cache Ops: Because Sometimes Wishes Need Revising

import wishful

# See what you've wished for
wishful.inspect_cache()   # ['.wishful/text.py', '.wishful/dates.py']

# Regenerate a module
wishful.regenerate("wishful.static.text")

# Force fresh import (useful for dynamic imports in loops)
story = wishful.reimport('wishful.dynamic.story')

# Nuclear option: forget everything
wishful.clear_cache()

CLI: wishful inspect, wishful clear, wishful regen <module>

wishful is a real console script (installed via pip install wishful), but python -m wishful inspect|clear|regen <module> works identically. Every command accepts --json for machine-readable output, and exits 0 on success, 1 on error, 2 on a usage mistake.

The cache is just regular Python files in .wishful/. Want to tweak the generated code? Edit it directly. It's your wish, after all.


โš™๏ธ Configuration: Fine-Tune Your Wishes

Because even genies need settings.

import wishful

wishful.configure(
    model="openai/gpt-5",          # Switch models - use litellm model IDs (default: "azure/gpt-4.1")
    cache_dir="/tmp/.wishful",     # Cache directory for generated modules (default: ".wishful")
    spinner=False,                 # Show/hide the "generating..." spinner (default: True)
    review=True,                   # Review code before execution (default: False)
    allow_unsafe=False,            # Disable safety checks - dangerous! (default: False)
    temperature=0.7,               # LLM sampling temperature (default: 1.0)
    max_tokens=16384,              # Maximum LLM response tokens (default: 16384)
    debug=True,                    # Enable debug logging (default: False)
    log_level="INFO",              # Logging level: DEBUG, INFO, WARNING, ERROR (default: WARNING)
    log_to_file=True,              # Write logs to cache_dir/_logs/ (default: False, opt-in)
    request_timeout=120,           # Per-request LLM timeout in seconds (default: 300)
    system_prompt="Custom prompt", # Override the system prompt for LLM (advanced)
)

# Context radius is configured separately (it likes to be special)
wishful.set_context_radius(6)  # Lines of context around imports AND call sites (default: 3)

All Configuration Options:

Your wish, your rules.

Parameter Type Default Description
model str "azure/gpt-4.1" LLM model identifier (litellm format)
cache_dir str | Path ".wishful" Directory for cached generated modules
review bool False Prompt for approval before executing generated code
spinner bool True Show spinner during LLM generation
allow_unsafe bool False Disable safety validation (use with caution!)
temperature float 1.0 LLM sampling temperature (0.0-2.0)
max_tokens int 16384 Maximum tokens for LLM response (sized for reasoning models)
debug bool False Enable debug mode (sets log_level to DEBUG)
log_level str "WARNING" Logging level (DEBUG, INFO, WARNING, ERROR)
log_to_file bool False Write logs to {cache_dir}/_logs/ (opt-in)
request_timeout float 300 Per-request LLM timeout in seconds
system_prompt str (see source) Custom system prompt for LLM (advanced)

Environment Variables:

All settings can also be configured via environment variables:

  • WISHFUL_MODEL - LLM model identifier; takes precedence over DEFAULT_MODEL
  • DEFAULT_MODEL - fallback LLM model identifier when WISHFUL_MODEL is unset
  • WISHFUL_CACHE_DIR - Cache directory path
  • WISHFUL_REVIEW - Set to "1" to enable review mode
  • WISHFUL_DEBUG - Set to "1" to enable debug mode
  • WISHFUL_UNSAFE - Set to "1" to disable safety checks
  • WISHFUL_SPINNER - Set to "0" to disable spinner
  • WISHFUL_MAX_TOKENS - Maximum tokens (integer)
  • WISHFUL_TEMPERATURE - Sampling temperature (float)
  • WISHFUL_REQUEST_TIMEOUT - Per-request LLM timeout in seconds (float, default 300)
  • WISHFUL_CONTEXT_RADIUS - Context lines around imports and call sites (integer)
  • WISHFUL_LOG_LEVEL - Logging level (DEBUG, INFO, WARNING, ERROR)
  • WISHFUL_LOG_TO_FILE - File logging is off by default; set to "1" to enable
  • WISHFUL_LOG_PROMPTS - Off by default; set to "1" to log prompt/context bodies (which may contain your source or secrets) at DEBUG
  • WISHFUL_SYSTEM_PROMPT - Custom system prompt
  • WISHFUL_FAKE_LLM - Set to "1" for deterministic stub generation (testing)

๐Ÿ›ก๏ธ Safety Rails: Defense in Depth, Not a Sandbox

Before generated code runs, it's AST-scanned and the obvious dangerous patterns are blocked: forbidden imports (os, subprocess, sys, importlib, builtins, ctypes, runpy, pickle, marshal, shutil, โ€ฆ), eval/exec/compile/__import__, __builtins__/globals()/vars()/locals() gadget access, introspection escape chains (__subclasses__, __globals__, __code__, __bases__, โ€ฆ) in both attribute and subscript form, aliased dangerous builtins (f = open), getattr/setattr with computed names, write-mode (or non-literal-mode) open(), and file-write/exec methods (Path.write_text, runpy.run_path). The same scan runs again when a cached file is loaded, so a tampered .wishful/ file is re-checked, not trusted.

Be honest about what this is. Generated code executes in your process, and the validator is a blocklist โ€” fundamentally incomplete over a language as large as Python. There are always more stdlib file-write/exec paths and runtime-reflection tricks than any static scan can enumerate. The scan catches careless generations, not a determined attacker. The real security boundary is the review gate (review=True) plus running wishful where arbitrary code execution is acceptable โ€” or an out-of-process sandbox. Treat the validator as a seatbelt, not a vault. For untrusted inputs, review the cached code (it's plain Python) before trusting it.

Override at your own peril: WISHFUL_UNSAFE=1 or allow_unsafe=True turns the scan off entirely.


๐Ÿงช Testing: Wishes Without Consequences

Need deterministic, offline behavior? Set WISHFUL_FAKE_LLM=1 and wishful generates placeholder stubs instead of hitting the network. Perfect for CI, unit tests, or when your Wi-Fi is acting up.

export WISHFUL_FAKE_LLM=1
uv run python my_tests.py  # No API calls, just predictable stubs

๐Ÿ”ฎ How the Magic Actually Works

Spoiler: it's not actual magic. Or is it?

  1. Import hook intercepts wishful.static.* and wishful.dynamic.* imports
  2. Cache check: static imports load instantly if cached; dynamic always regenerates
  3. Context discovery: Captures nearby comments, code, and registered type schemas
  4. LLM generation: Generates code via litellm based on your import + context
  5. Safety validation: AST-parsed and checked for dangerous patterns
  6. Execution: Code is cached to .wishful/, compiled, and executed
  7. Transparency: Just plain Python files. Edit them. Commit them. They're yours.

It's import hooks meets LLMs meets type-aware code generation meets "why didn't this exist already?"


๐ŸŽญ Fun with Wishful Thinking

# Cosmic horror stories? Just import it.
from wishful.static.story import cosmic_horror_intro

intro = cosmic_horror_intro(
    setting="a deserted amusement park",
    word_count_at_least=100
)
print(intro)  # ๐ŸŽข๐Ÿ‘ป

# Math that writes itself
from wishful.static.numbers import primes_from_to, sum_list

total = sum_list(list=primes_from_to(1, 100))
print(total)  # 1060

# Because who has time to write date parsers?
from wishful.static.dates import parse_fuzzy_date

print(parse_fuzzy_date("next Tuesday"))  # Your guess is as good as mine

# Want different results each time? Use dynamic imports!
# The key: import the MODULE, not individual functions!
import wishful
import wishful.dynamic.jokes

# Each function CALL triggers fresh regeneration with runtime context
print(wishful.dynamic.jokes.programming_joke())  # Fresh joke!
print(wishful.dynamic.jokes.programming_joke())  # Different joke! ๐ŸŽฒ
print(wishful.dynamic.jokes.programming_joke())  # Another new joke!

# Alternative: use wishful.reimport() to force a fresh module load
jokes = wishful.reimport('wishful.dynamic.jokes')
print(jokes.programming_joke())  # Also regenerates!

# Why does this matter?
# โœ“ DO:   import wishful.dynamic.jokes
#         wishful.dynamic.jokes.my_func()  # Regenerates on each call
# โœ“ DO:   wishful.reimport('wishful.dynamic.jokes')  # Forces fresh import
# โœ— DON'T: from wishful.dynamic.jokes import my_func
#          my_func()  # This binds once and won't regenerate!

๐Ÿ’ป Development: Working with This Repo

This project uses uv for blazing-fast Python package management.

Setup

# Install uv if needed
curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone the repo
git clone https://github.com/pyros-projects/wishful.git
cd wishful

# Install dependencies (uv handles everything)
uv sync

Running Tests

# Run the full test suite
uv run pytest tests/ -v

# Run a specific test file
uv run pytest tests/test_import_hook.py -v

# Run with coverage
uv run pytest --cov=wishful tests/

Running Examples

All examples support WISHFUL_FAKE_LLM=1 for deterministic testing:

# Run with fake LLM (no API calls)
WISHFUL_FAKE_LLM=1 uv run python examples/00_quick_start.py

# Run with real LLM (requires API keys)
uv run python examples/00_quick_start.py

# 17 examples ship in examples/ (00_quick_start.py โ€ฆ 16_safety_and_review.py)

Adding Dependencies

# Add a runtime dependency
uv add package-name

# Add a dev dependency
uv add --dev package-name

# Update all dependencies
uv lock --upgrade

Project Structure

wishful/
โ”œโ”€โ”€ src/wishful/          # Main package
โ”‚   โ”œโ”€โ”€ __init__.py       # Public API
โ”‚   โ”œโ”€โ”€ __main__.py       # CLI interface
โ”‚   โ”œโ”€โ”€ config.py         # Configuration
โ”‚   โ”œโ”€โ”€ exceptions.py     # WishfulError base + exception hierarchy
โ”‚   โ”œโ”€โ”€ logging.py        # Logging citizenship (loguru)
โ”‚   โ”œโ”€โ”€ ui.py             # Rich spinner / progress UI
โ”‚   โ”œโ”€โ”€ cache/            # Cache management
โ”‚   โ”œโ”€โ”€ core/             # Import hooks & discovery
โ”‚   โ”œโ”€โ”€ llm/              # LLM integration (sync + async)
โ”‚   โ”œโ”€โ”€ types/            # Type registry system
โ”‚   โ”œโ”€โ”€ explore/          # Multi-variant generation & selection
โ”‚   โ”œโ”€โ”€ evolve/           # Generational evolution of functions
โ”‚   โ””โ”€โ”€ safety/           # Safety validation
โ”œโ”€โ”€ tests/                # Test suite (380+ tests)
โ”œโ”€โ”€ examples/             # 17 usage examples
โ”‚   โ”œโ”€โ”€ 00_quick_start.py
โ”‚   โ”œโ”€โ”€ 01_json_yaml.py
โ”‚   โ”œโ”€โ”€ 02_web_scraping.py
โ”‚   โ”œโ”€โ”€ 03_data_validation.py
โ”‚   โ”œโ”€โ”€ 04_format_conversion.py
โ”‚   โ”œโ”€โ”€ 05_api_client.py
โ”‚   โ”œโ”€โ”€ 06_omg_why.py
โ”‚   โ”œโ”€โ”€ 07_typed_outputs.py         # Type registry showcase
โ”‚   โ”œโ”€โ”€ 08_dynamic_vs_static.py     # Static vs dynamic modes
โ”‚   โ”œโ”€โ”€ 09_context_shenanigans.py   # Context discovery
โ”‚   โ”œโ”€โ”€ 10_cosmic_horror_line_by_line.py
โ”‚   โ”œโ”€โ”€ 11_logging.py               # Logging knobs: debug, levels, files, prompts
โ”‚   โ”œโ”€โ”€ 12_explore.py               # Multi-variant exploration
โ”‚   โ”œโ”€โ”€ 13_explore_advanced.py      # LLM-as-judge, self-improving loops
โ”‚   โ”œโ”€โ”€ 14_evolve.py                # Generational evolution
โ”‚   โ”œโ”€โ”€ 15_cli_and_config.py        # CLI (--json) + configure/reset_defaults
โ”‚   โ””โ”€โ”€ 16_safety_and_review.py     # SecurityError, allow_unsafe, review=True
โ””โ”€โ”€ pyproject.toml        # Project config

๐Ÿค” FAQ (Frequently Asked Wishes)

Q: Is this production-ready?
A: Define "production." ๐Ÿ™ƒ (But seriously: the cache gives you plain Python files you can review, edit, and commit. So... maybe?)

Q: Can I make the LLM follow a specific style?
A: Yes! Use docstrings in @wishful.type decorated classes. Want Yoda-speak? Add """Written by master yoda from star wars.""" โ€” the LLM will actually do it.

Q: Do type hints and Pydantic constraints actually work?
A: Surprisingly, yes! Field constraints like min_length=10 or gt=0 are serialized and sent to the LLM, which respects them.

Q: What if the LLM generates bad code?
A: That's what the cache is for. Check .wishful/, tweak it, commit it, and it's locked in.

Q: Can I use this with OpenAI/Claude/local models?
A: Yes! Built on litellm, so anything it supports works here.

Q: What if I import something that doesn't make sense?
A: The LLM will do its best. Results may vary. Hilarity may ensue.

Q: Is this just lazy programming?
A: It's not lazy. It's efficient wishful thinking. ๐Ÿ˜Ž

Q: What if the LLM generates multiple bad implementations?
A: That's what wishful.explore() is for! Generate 5-10 variants, test each one, keep the winner. It's like having a code review, but automated and with more variants than your team has patience for.

Q: Does explore() cache the winning implementation?
A: Yes! The winning variant gets cached to .wishful/ just like a regular import. Future imports use the proven winnerโ€”no re-exploration needed.


๐Ÿ“œ License

MIT.

Go forth and wish responsibly. โœจ

Your imports will never be the same.