feat: categorize !craftable output by item type#703
feat: categorize !craftable output by item type#703atiweb wants to merge 2 commits intomindcraft-bots:developfrom
Conversation
Improve the !craftable command to group items into categories (Tools, Weapons, Armor, Blocks, Other) for better readability. Categories use Minecraft's naming conventions (e.g. items ending in _pickaxe, _sword, _helmet) which are stable across versions since they come from the game data itself, not hardcoded lists. Before: flat list of all craftable items After: organized by category (Tools: ..., Weapons: ..., etc.)
There was a problem hiding this comment.
Pull request overview
This PR improves the !craftable command output by categorizing craftable items using Minecraft's naming conventions. This is a focused improvement extracted from the larger PR #693, specifically addressing the categorization of items to reduce token consumption and improve readability for the LLM.
Changes:
- Adds dynamic item categorization using regex patterns based on Minecraft naming conventions (Tools, Weapons, Armor, Blocks, Other)
- Changes output format from vertical list to comma-separated items within categories
- Adds early return when no craftable items exist
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/agent/commands/queries.js
Outdated
| for (const [category, items] of Object.entries(categorized)) { | ||
| res += `\n${category}: ${items.join(', ')}`; | ||
| } | ||
| if (other.length > 0) { | ||
| res += `\nOther: ${other.join(', ')}`; | ||
| } |
There was a problem hiding this comment.
The category order in the output is non-deterministic because it depends on which categories have matching items. This means "Weapons" might appear before "Tools" in one response and after in another, which could be confusing for the LLM parsing this output.
Consider iterating over the categories in a fixed order (e.g., Tools, Weapons, Armor, Blocks, Other) by iterating through the keys of the 'categories' object instead of the dynamically populated 'categorized' object. This ensures consistent output format regardless of which items are craftable.
Use an array of [label, testFn] tuples instead of an object to guarantee categories always appear in the same order: Tools -> Weapons -> Armor -> Blocks -> Other This ensures consistent output for the LLM regardless of which items happen to be craftable. Also simplified the implementation by removing the intermediate categorized object.
Sweaterdog
left a comment
There was a problem hiding this comment.
Small, but excellent change
Summary
Improves the
!craftablecommand output by organizing items into categories instead of a flat list.Before
After
How Categorization Works
Uses Minecraft's own naming conventions via regex patterns on item names:
_pickaxe,_axe,_shovel,_hoe, plusshears,fishing_rod,flint_and_steel_sword, plusbow,crossbow,arrowvariants_helmet,_chestplate,_leggings,_boots, plusshield_planks,_slab,_stairs,_block,_bricks,_wall,_fence,_pane,_door,_trapdoor,_pressure_plate,_buttonThese patterns are not hardcoded item lists — they match against the naming conventions that Minecraft itself uses. When new items are added (like
maceorspear), they naturally fall into "Other" rather than silently being missing from a hardcoded list.Design Decisions
queries.jsRelation to Previous PR
This is a focused subset of changes from #693, addressing review feedback about hardcoded regex patterns. The categorization now uses Minecraft naming conventions that are stable across versions.