Skip to content

feat(build): automatically detect WIT world for TinyGo builds #58#59

Open
brooksmtownsend wants to merge 1 commit intomainfrom
fix/issue-58}
Open

feat(build): automatically detect WIT world for TinyGo builds #58#59
brooksmtownsend wants to merge 1 commit intomainfrom
fix/issue-58}

Conversation

@brooksmtownsend
Copy link
Copy Markdown
Member

Summary

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

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 wasmCloud/wasmCloud#4959

🤖 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 <noreply@anthropic.com>
@automation-wasmcloud
Copy link
Copy Markdown

This repository has been merged into wasmCloud/wasmCloud. Please re-open this PR against wasmCloud/wasmCloud:main.

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

2 participants