[tools] Add compare_styles_tool for style comparison #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements a comprehensive style comparison tool that performs deep structural comparison of two Mapbox styles, identifying additions, removals, and modifications.
Key Features
ignoreMetadataflag to ignore metadata fields (id, owner, created, modified, draft, visibility)Implementation Details
BaseToolfor offline operation (no API calls required)Testing
All tests passing ✅
Documentation
Added comprehensive README documentation for all three validation tools:
validate_geojson_tool(PR Add validate_geojson_tool for offline GeoJSON validation #50)validate_expression_tool(PR Add validate_expression_tool for Mapbox expression validation #51)compare_styles_tool(this PR)Each tool is documented with parameters, features, return values, and example prompts.
Testing
Test 1: Identical Styles
Purpose: Verify that two identical styles are detected as identical
Prompt to Claude:
Compare these two Mapbox styles using compare_styles_tool:
Style A:
Style B: (same as Style A)
Expected Result:
Test 2: Color Change in Layer
Purpose: Detect a modified paint property
Prompt to Claude:
Compare these two styles where the background color changed:
Style A:
Style B:
Expected Result:
Test 3: Layer Added
Purpose: Detect when a new layer is added
Prompt to Claude:
Compare these styles where Style B has an additional water layer:
Style A:
Style B:
Expected Result:
Test 4: Layer Removed
Purpose: Detect when a layer is removed
Prompt to Claude:
Compare these styles where the water layer was removed in Style B:
Style A:
Style B:
Expected Result:
Test #5: Metadata Changes with ignoreMetadata=true
Purpose: Verify that metadata fields can be ignored
Prompt to Claude:
Compare these styles with ignoreMetadata=true. They differ only in metadata:
Style A:
Style B:
Use ignoreMetadata: true
Expected Result:
Test #6: Metadata Changes with ignoreMetadata=false
Purpose: Verify that metadata differences are detected when not ignored
Prompt to Claude:
Compare the same styles from Test #5, but with ignoreMetadata=false or omitted.
Expected Result:
Test #7: Layer Reordering (ID-based comparison)
Purpose: Verify that layers are compared by ID, not array position
Prompt to Claude:
Compare these styles where layers are in different order:
Style A:
Style B:
Expected Result:
Related PRs
Part of the offline validation tools initiative: