Skip to content

feat: categorize !craftable output by item type#703

Open
atiweb wants to merge 2 commits intomindcraft-bots:developfrom
atiweb:feat/craftable-improvements
Open

feat: categorize !craftable output by item type#703
atiweb wants to merge 2 commits intomindcraft-bots:developfrom
atiweb:feat/craftable-improvements

Conversation

@atiweb
Copy link

@atiweb atiweb commented Feb 6, 2026

Summary

Improves the !craftable command output by organizing items into categories instead of a flat list.

Before

CRAFTABLE_ITEMS
- oak_planks
- stick  
- wooden_pickaxe
- wooden_sword
- crafting_table
- oak_slab
- oak_stairs
- ...

After

CRAFTABLE_ITEMS
Tools: wooden_pickaxe, wooden_axe, wooden_shovel, wooden_hoe
Weapons: wooden_sword
Blocks: oak_planks, oak_slab, oak_stairs, oak_door, oak_fence
Other: stick, crafting_table, chest, torch

How Categorization Works

Uses Minecraft's own naming conventions via regex patterns on item names:

  • Tools: items ending in _pickaxe, _axe, _shovel, _hoe, plus shears, fishing_rod, flint_and_steel
  • Weapons: items ending in _sword, plus bow, crossbow, arrow variants
  • Armor: items ending in _helmet, _chestplate, _leggings, _boots, plus shield
  • Blocks: items ending in _planks, _slab, _stairs, _block, _bricks, _wall, _fence, _pane, _door, _trapdoor, _pressure_plate, _button
  • Other: everything else

These patterns are not hardcoded item lists — they match against the naming conventions that Minecraft itself uses. When new items are added (like mace or spear), they naturally fall into "Other" rather than silently being missing from a hardcoded list.

Design Decisions

  • Single file change — only modifies queries.js
  • No new dependencies — uses standard regex
  • Graceful fallback — uncategorized items go to "Other" so nothing is lost
  • Concise output — comma-separated within categories reduces LLM token consumption vs one-per-line

Relation 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.

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.)
Copilot AI review requested due to automatic review settings February 6, 2026 02:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +167 to +172
for (const [category, items] of Object.entries(categorized)) {
res += `\n${category}: ${items.join(', ')}`;
}
if (other.length > 0) {
res += `\nOther: ${other.join(', ')}`;
}
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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.
Copy link
Contributor

@Sweaterdog Sweaterdog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small, but excellent change

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.

3 participants