feat: replace_matching_properties — bulk property edit (closes #127)#128
Merged
Conversation
…g nodes (#127) One call applies a property change to every node matching a value predicate (AND across keys; token refs match literally; structured values by shape), with scope-subtree and node-type filters and a dryRun preview — instead of one batch_design U() op per node. - src/scene-graph.ts: collectMatchingNodes + replaceMatchingProperties (pure, id/type stripped from set like updateNode) - src/index.ts: tool registration, INSTRUCTIONS paragraph, GOTCHAS entry - README, GUIDELINES (Sharp edges), VISION (issue-driven improvements) - test-replace-matching.ts: 14 checks (matching, scoping, replacing, id/type safety); test-discoverability stays green
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #127.
What
New MCP tool
replace_matching_properties: find every node whose properties equal all thematchentries and apply thesetproperties to each in one call — the "set width: "100%" on all nodes currently width: 110" case from the issue becomes one line instead of 68 hand-authoredU()ops.Returns
{ ok, count, matches: [{ id, type, name? }] }(+dryRun: trueon previews). Refuses an emptymatch(would match every node) and an emptyset(unless dryRun).ensureFreshruns before the mutation like every other mutating tool.Implementation
collectMatchingNodes(document-order walk, scope-inclusive) +replaceMatchingProperties;propEqualsis strict for primitives, JSON-shape for structured values.batch_design; viewer URL on real writes only.INSTRUCTIONSparagraph,GOTCHASentry, README section, GUIDELINES "Sharp edges" bullet, VISION checklist entry.Testing
test-replace-matching.ts— 14/14: AND matching, token-ref + structured-value matching, scope/type filters + decoys, scope-inclusivity, missing-scope throw, replace mutation, id/type stripping.test-discoverability.ts— 14/14 (48 tools).tscclean.dryRunmarker).Not included
The
search_all_unique_properties-style companion (enumerate distinct values in use) noted in the issue as prior art —dryRuncovers the preview need; the enumerator can be a follow-up if wanted.