Skip to content

About

Prompt coding agents (Capy, Hoplite, Claude Code) from inside Minecraft. Paper plugin.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

AgentCraft

A Paper plugin that lets you prompt cloud coding agents from inside Minecraft. It works with Capy and Hoplite, and each agent can run on either one.

  • Summon an agent: run /agent spawn Claude Opus 5.5, or rename any mob with a name tag to a model name (Claude Opus 5.5, GPT-6.1 Sol, or an alias like claude or chatgpt). It turns into a player-shaped mannequin wearing that model's skin.
  • Every agent has a handle, shown under its name: @claude, @claude2, @gpt, and so on. Rename one with /agent handle <name> while looking at it.
  • Prompt it:
    • Right-click it holding a Book & Quill.
    • Type @claude2 fix the tests in chat.
    • Use /agent ask <prompt> for the agent you're looking at.
  • Vague mentions: @opus or @claude with no exact handle match goes to the only matching agent nearby, or the one you're looking at. Otherwise you get a clickable "Which one?" list.
  • Live replies: the plugin streams each thread from its backend. The speech bubble shows thinking... with the tool being run, types the reply out as it's written, and shows each message of a multi-message run.
  • Full reply book: when the run ends, every message lands in your inventory as a signed book. If you're offline, it's waiting for you when you join.
  • New chat: right-click with a plain Book, or use /agent new. Renaming an agent to another model keeps the chat and switches the model.
  • Status: right-click with an empty hand, or use /agent status. It shows the backend, the exact model ID sent, and whether it bills your Claude plan.
  • Switch backends: /agent backend lists Capy and Hoplite for the agent you're looking at, and /agent backend hoplite moves it. The next prompt starts a new chat there.

Backends

Capy Hoplite
Key CAPY_API_KEY (capy.ai → Settings → API) HOPLITE_API_KEY (hop_…, Settings → Workspace → API keys)
Project CAPY_PROJECT_ID, or the first project HOPLITE_PROJECT_ID, or the first project
Live stream Thread SSE with transcript cursor Event feed SSE with drafts, plus event replay
Models provider/model IDs as-is Mapped to Hoplite's IDs from /api/model-providers. If Hoplite doesn't offer the model, the project default is used

Configure one or both. New agents use backend: in config.yml (or AGENTCRAFT_BACKEND). auto picks Capy if it has a key, then Hoplite. Each agent remembers the backend its chat lives on, so a mixed server works. Agents created before backends existed stay on Capy.

Claude Code subscriptions

Capy can run Claude models on your own Claude Pro or Max plan in Claude Code mode, using claude-code/… models. AgentCraft prefers that: a Claude agent asks for claude-code/claude-opus-5-5 first.

If Capy answers that Claude Code isn't connected, the plugin falls back to anthropic/claude-opus-5-5 on Capy credits, logs it once, and stops trying until /agent reload. Set capy.claude-code (or CAPY_CLAUDE_CODE) to:

  • auto: prefer Claude Code, fall back if needed (the default)
  • always: require Claude Code
  • never: always use Capy credits

To connect your plan, open the Claude Code tab in Capy's model picker (or Settings → Models). Run claude setup-token and paste the token.

Persistence

Each agent stores its model, thread ID, transcript cursor, handle and last requester on the entity itself, and agents are saved with the world.

After a restart or chunk reload, an agent whose thread kept running picks the stream back up from its cursor. A reply that finished while the server was down is still delivered.

The model is only sent to the backend when a thread is created or after you switch models in-game. Otherwise the model selected in the Capy or Hoplite app wins, and the agent updates its name and skin to match.

Run it locally

Requirements: Docker. The build runs in a container, so you don't need a local JDK.

cp .env.example .env      # CAPY_API_KEY and/or HOPLITE_API_KEY, optional project IDs, OPS=<your MC name>
./dev.sh                  # builds the jar and (re)starts Paper 26.3 on localhost:25565
docker compose logs -f paper

Connect to localhost with any recent client (ViaVersion is installed) and accept the resource pack, which holds the skins.

dev.sh stops the server gracefully before recreating it. Recreating a running container kills the server mid-save and loses entities.

Tests

docker run --rm -v "$PWD":/project -w /project gradle:9-jdk25 ./gradlew test

Unit tests cover the SSE parser, statuses, text formatting and model matching.

Unit tests also cover Claude Code routing and Hoplite model mapping.

End-to-end tests run against mock Capy and Hoplite APIs that stream a scripted multi-message run:

./test/run-e2e.sh

It runs the suite three times on a fresh world each time:

  • Capy with Claude Code connected
  • Capy without a Claude subscription (checks the fallback)
  • Hoplite

A headless player (Mineflayer) joins the offline-mode test server on port 25566. The test drives agents with /execute as, then checks:

  • handles, ambiguity prompts and skins
  • the thinking, tool and typing bubbles
  • multi-message reply books and follow-ups
  • delivery of a reply that finishes while the server is restarting

Config (server/plugins/AgentCraft/config.yml)

Key What it does
backend / AGENTCRAFT_BACKEND Backend for new agents: auto, capy, or hoplite
capy.api-key / CAPY_API_KEY Capy API key
capy.project-id / CAPY_PROJECT_ID Project for new threads (default: the first project the key can see)
capy.base-url / CAPY_BASE_URL API base URL (default https://api.capy.ai/api/v1)
capy.claude-code / CAPY_CLAUDE_CODE auto, always, or never use your Claude plan for Claude models
capy.reasoning Optional reasoning mode (low … max)
capy.delivery How a follow-up reaches a busy agent: queue, steer, or interrupt
hoplite.api-key / HOPLITE_API_KEY Hoplite API key (hop_…)
hoplite.project-id / HOPLITE_PROJECT_ID Hoplite project (default: the first project)
hoplite.base-url / HOPLITE_BASE_URL API base URL (default https://api.hoplite.sh)
hoplite.reasoning / hoplite.speed Optional reasoning mode and standard or fast
agent.intro / agent.follow-up-prefix Context added to messages. %player%, %agent%, %handle% are filled in
agent.turn-timeout-minutes How long to follow one turn live
chat.mention-radius How far @model mentions look for agents
resource-pack.public-url Where clients download the skin pack. Change it from localhost when hosting for friends
models name, provider id (anthropic/…, openai/…), skin, base handle, color, aliases. The id is translated for each backend

Run /agent reload after editing.

Skins

Mannequins take a skin texture from a resource pack. The plugin zips every PNG in plugins/AgentCraft/skins/ into a pack, serves it on port 8765, and sends it to players on join. To change a skin, drop a 64×64 PNG in that folder and run /agent reload.

The Claude and ChatGPT skins are hand-picked. tools/gen_skins.py generates the others.

Layout

src/main/java/dev/agentcraft/
  backend/    AgentBackend interface, SSE subscription with resume, statuses (no Bukkit dependencies)
    capy/     Capy adapter, with Claude Code routing
    hoplite/  Hoplite adapter: event replay, live drafts, model mapping
  config/     Settings (loaded and validated once), model catalog
  agent/      Agent (typed entity data), registry and handles, factory, mentions, conversations
  ui/         Speech bubbles, reply books, offline mailbox, text formatting
  pack/       Skin resource pack builder and HTTP server
  listener/   Interactions, chat mentions, entity lifecycle
  command/    /agent (Paper Brigadier)
  util/       Main-thread executor
  AgentCraftPlugin.java   wiring and lifecycle only

Paper pitfalls this avoids

  • Network calls stay off the main thread. Every result returns through a main-thread executor that drops work once the plugin is disabled, so there are no IllegalPluginAccessExceptions.
  • No long-lived Entity or Player references. Only UUIDs are kept and resolved again when needed, which avoids leaks and invalid entities after an unload.
  • No scanning every entity. Loaded agents are tracked through entity load and unload events instead of scanning worlds each second.
  • Text displays aren't saved with the world. Bubbles are non-persistent passengers and can't be orphaned.
  • Everything is cleaned up on disable. Tasks are cancelled and streams, the HTTP client and the pack server are closed. /agent reload reloads config without the Bukkit /reload.
  • Interactions fire once. Right-click handling ignores the off-hand. Command senders are checked before any cast to Player.
  • Commands use Paper's Brigadier API, with greedy arguments and suggestions for multi-word model names.
  • Settings are read once. Config is read and validated once into typed records, not on every event.
  • The skin pack is sent with its SHA-1 hash and a stable UUID.
  • Shutdown saves finish. The server gets a long stop grace period, so world saves complete.

License

MIT. See LICENSE.

About

Prompt coding agents (Capy, Hoplite, Claude Code) from inside Minecraft. Paper plugin.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages