Skip to content

One query format for the finder, shared by the app and the CLI - #27

Merged
byRandom merged 1 commit into
mainfrom
refactor/query
Nov 15, 2026
Merged

byRandom merged 1 commit into
mainfrom
refactor/query

Conversation

@byRandom

Copy link
Copy Markdown
Owner

Proposal #6 of the architecture review: the finder's query and its results had three hand-written front ends (the find example's argv parsing, the app panel, the tests). They now share one model in mc-core.

What changes

  • Targets in mc-core (structure::target): each searchable group of structures is a structure set in one dimension, optionally narrowed (fortresses and bastions share a set), and has a stable id. The app's layers take their set, dimension and narrowing from it by id, so the app and the core can no longer disagree. StructureFilter is now { target, radius, min_count, ship_only }.
  • A text form for Query (FromStr / Display):
    center=spawn villages:300:2 end_cities+ship:1000 biome=plains,meadow.
    Errors name the problem, for example an unknown structure (listing the valid ids), a bad radius, or +ship on something without ships.
  • Match prints as one line: the CLI output and the app's new "copy all results" button use the same line.
  • find example: it parses the shared form. That means it can now search Nether and End structures and several biomes. --zero and --biome become center=zero and biome=.
  • App finder panel: a query field at the top that you can copy, paste or edit. It stays in sync with the form both ways. Invalid text shows the reason, and goes back to the form's query once the field loses focus. You can still copy it while a search runs.
  • Several biomes at the center in the app: the biome list is now multi-select. Saved settings add biomes and keep writing and reading the old single biome.
  • Docs: README (query syntax), GLOSSARY (Target, Query), ROADMAP (what 0.8 still needs for stable formats).

Verification

  • cargo fmt --all --check && cargo clippy --all-targets -- -D warnings && cargo test pass.
  • The find output matches main (sorted) on three searches: sequential with two filters, center=zero with two biomes, and random seeds.
  • New tests cover:
    • text-form round trips and defaults;
    • 13 bad queries and their messages;
    • consistency of every target (its set exists in its dimension, only matches a structure);
    • the one-line match format;
    • ship_only on a target without ships;
    • every target having an app layer;
    • old settings with a single biome.
  • Mutation testing: 14 mutations of the parser, printer and target code, all caught.
  • Checked in the app under Xvfb: typing a query updates the form, an invalid one shows its error, the biome multi-select updates the text, and a search shows results with the copy-all button.

Generated by Claude Code

Structure targets (a set in one dimension, optionally narrowed, with a
stable id) move from the app's layer list into mc-core, so the finder,
the map and the command line name structures the same way.

The finder's Query gets a text form, `center=spawn villages:300:2
end_cities+ship:1000 biome=plains,meadow`, with FromStr and Display and
errors that say what is wrong. The find example parses it (and so can
now search Nether and End structures), and the app's finder panel shows
it in a field that can be copied, pasted or edited, kept in sync with
the form. A Match prints as one line, used by the CLI and by a new
"copy all results" button. The biome at the center can now be several
biomes in the app too; saved settings keep reading the older single
biome.

The CLI's output is unchanged on three searches compared with main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SenGxDDRwLejx8nir8GXKG
@byRandom
byRandom merged commit 8346aa8 into main Nov 15, 2026
3 checks passed
@byRandom byRandom mentioned this pull request Nov 15, 2026
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.

1 participant