Skip to content

Conversation

brooksmtownsend
Copy link
Member

Summary

This PR implements automatic WIT world detection for TinyGo builds when wit_world is not explicitly configured, addressing the feature request in #58.

Changes

  • Automatic World Detection: When wit_world is not specified in the TinyGo build configuration, the system now automatically scans the WIT directory for available worlds
  • Smart Behavior:
    • If exactly one world is found → automatically uses it and logs the detection
    • If multiple worlds are found → lists all available worlds in the error message for user selection
    • If no worlds are found → maintains the existing placeholder behavior
  • Enhanced Error Messages: Improved error messages that show discovered worlds when multiple exist
  • Comprehensive Tests: Added 5 test cases covering all scenarios (single world, multiple worlds, no worlds, multiple files, missing directory)

Behavior Examples

Before (always required manual configuration):

wash build
# Error: TinyGo builds require wit_world to be specified in the configuration...

After (automatic detection for single-world projects):

wash build  
# ✅ Info: automatically detected WIT world: my-world
# ✅ Success: builds without requiring configuration

Multiple worlds scenario:

wash build
# Error: Multiple worlds found: world-one, world-two. Please update the wit_world field...

Test Plan

  • Added unit tests for detect_wit_worlds function covering all scenarios
  • Tests handle single world, multiple worlds, no worlds, multiple files, and missing directories
  • Manual verification of WIT parsing logic using sample WIT files
  • Verified error messages include helpful world listings

Breaking Changes

None - this is a backward-compatible enhancement that maintains existing behavior when wit_world is explicitly configured.

Fixes #58

🤖 Generated with Claude Code

- Add automatic detection of WIT worlds in project when wit_world is not specified
- If exactly one world is found, use it automatically without requiring configuration
- If multiple worlds exist, list them in the error message for user selection
- If no worlds are found, maintain existing placeholder behavior
- Add comprehensive tests for WIT world detection functionality

Fixes #58

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
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.

[FEATURE] Finding the intended wit world
1 participant