Support item-dependent refill behaviour

The refill slot was only putting as many items as possible in a
stack, which does nothing for tools.  Tools could benefit from repair,
recharging, or other behaviour depending on the type of tool.  Change the
default refill behaviour to repair mechanical wear as well as fully
stacking.  Because other kinds of refill will require knowledge of the
metadata format, they can't be directly handled here.  So add an on_refill
hook, that tool definitions can supply to plug in appropriate behaviour.