feat(recovery): death handler + auto-defend + bulk-collect rework + mc_stay shim #3

Merged
halofourteen merged 1 commits from feat/recovery-improvements into main 2026-05-25 15:07:08 +03:00
halofourteen commented 2026-05-25 15:06:59 +03:00 (Migrated from github.com)

Four targeted fixes for issues observed during the first live autonomous test.

What was broken

  1. mc_stay crashed with pause undefined — Mindcraft skills assume a bot.modes API from a plugin that doesn't exist on npm.
  2. Bot died twice to zombies at night; after respawn Pi was stuck on a stale current-task.json referencing inventory it no longer had.
  3. No combat reflex — hostile mobs within 6 blocks did not trigger any defense; Pi only reacts after its slow reasoning loop.
  4. mc_collect_block with count > 1 reliably timed out (270s+) even though count=1 worked in 25s. Upstream collectBlock plugin appears to drift in dense terrain after the first dig.

What this PR changes

File Fix
extensions/lib/mcdata.js Install no-op bot.modes shim in attachPluginsAndInitpause/unpause/isOn/getMiningCooldown all become harmless
extensions/mineflayer-bridge.ts New death event handler → diary line + clear current-task. spawn within 5s of death → log respawn position
extensions/mineflayer-bridge.ts New setInterval(2s) auto-defend tick: if health <18 AND hostile within 6 blocks AND no active world task → fire bot.pvp.attack(nearest). No LLM call, sub-second reaction
extensions/mindcraft-skills.ts mc_collect_block rewritten to loop count=1 internally, 75s per iter, abort after 3 consecutive failures, returns aggregate

Smoke test

Both extensions load. Bot connects, perception report includes hostiles nearby. No errors at startup.

What to expect after merge

  • Bot can be left online overnight without getting permanently stuck after a death.
  • Hostile mob within 6 blocks at low HP → automatic attack (no waiting for Pi to think).
  • mc_collect_block({blockType: "dark_oak_log", count: 8}) will now actually collect up to 8 logs (or abort cleanly with a count of how many it managed before giving up).
  • mc_stay, mc_consume, mc_defend_self, mc_avoid_enemies all stop crashing on bot.modes.

🤖 Generated with Claude Code

Four targeted fixes for issues observed during the first live autonomous test. ## What was broken 1. `mc_stay` crashed with `pause undefined` — Mindcraft skills assume a `bot.modes` API from a plugin that doesn't exist on npm. 2. Bot died twice to zombies at night; after respawn Pi was stuck on a stale `current-task.json` referencing inventory it no longer had. 3. No combat reflex — hostile mobs within 6 blocks did not trigger any defense; Pi only reacts after its slow reasoning loop. 4. `mc_collect_block` with `count > 1` reliably timed out (270s+) even though `count=1` worked in 25s. Upstream collectBlock plugin appears to drift in dense terrain after the first dig. ## What this PR changes | File | Fix | |---|---| | `extensions/lib/mcdata.js` | Install no-op `bot.modes` shim in `attachPluginsAndInit` — `pause/unpause/isOn/getMiningCooldown` all become harmless | | `extensions/mineflayer-bridge.ts` | New `death` event handler → diary line + clear current-task. `spawn` within 5s of death → log respawn position | | `extensions/mineflayer-bridge.ts` | New `setInterval(2s)` auto-defend tick: if health <18 AND hostile within 6 blocks AND no active world task → fire `bot.pvp.attack(nearest)`. No LLM call, sub-second reaction | | `extensions/mindcraft-skills.ts` | `mc_collect_block` rewritten to loop `count=1` internally, 75s per iter, abort after 3 consecutive failures, returns aggregate | ## Smoke test Both extensions load. Bot connects, perception report includes hostiles nearby. No errors at startup. ## What to expect after merge - Bot can be left online overnight without getting permanently stuck after a death. - Hostile mob within 6 blocks at low HP → automatic attack (no waiting for Pi to think). - `mc_collect_block({blockType: "dark_oak_log", count: 8})` will now actually collect up to 8 logs (or abort cleanly with a count of how many it managed before giving up). - `mc_stay`, `mc_consume`, `mc_defend_self`, `mc_avoid_enemies` all stop crashing on `bot.modes`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.