# Haunted Crew > Haunted Crew turns Kiro coding agents into ghosts in a Minecraft (Fabric, 26.3) mod. A Node bridge talks to Kiro (hooks and the Agent Client Protocol), runs multi-agent workflows in git worktrees with in-game reviewed merges, and streams a headless browser onto in-game screens. - Source: https://github.com/YUST777/haunted-crew - Site: https://haunted-crew.pages.dev - Everything below is plain markdown generated from the repository's /docs folder. --- # Haunted Crew documentation Haunted Crew turns Kiro agents into ghosts in Minecraft. A small Node **bridge** talks to Kiro, a Fabric **mod** draws the ghosts and the console, and everything the agents do shows up in the world. ## Built with Kiro (Kiroween 2026, Frankenstein) The product runs on Kiro: every ghost is a real `kiro-cli` agent, tested end to end with real Kiro. The Kiro setup for this repo is in the [`.kiro/` folder](https://github.com/YUST777/haunted-crew/tree/main/.kiro): | Kiro feature | How it is used here | |---|---| | Specs (6) | Requirements, design and task lists for the hook event bridge, reviewed merges and the demo video (trailer, explainer clips, edit). | | Hooks (18) | Ten forward every Kiro event to the ghosts in Minecraft. The others run the bridge tests on save, typecheck the site, keep the docs true to the code and block risky shell commands. | | Steering (11) | Product, tech, structure, mod, bridge, site, Blender assets, privacy, writing style and video rules, loaded into every Kiro session. | | Agents (ACP) | Every ghost is a real `kiro-cli` agent over the Agent Client Protocol, with its own generated agent profile. | | MCP | A crew MCP server gives ghosts messages, memory, a shared database and history; Blender was driven through MCP for the models. | | Powers | `plugin.json` and the `haunted-crew-setup` skill let Kiro install the whole project from one prompt. | The full write-up is [Kiro integration](kiro-integration.md). ## Pages | Page | What it covers | |---|---| | [Kiro integration](kiro-integration.md) | Exactly how and where Kiro is used: ACP, hooks, agent profile, MCP, skills, credits, plugin. | | [Mod reference](mod-reference.md) | Every item, block, entity, command, key, screen, payload and config key in the Minecraft mod. | | [Bridge reference](bridge-reference.md) | Every flag, env var, HTTP route, event kind, crew tool and module in the bridge. | | [Architecture](architecture.md) | The three parts, the data flow, and why it is built this way. | | [Bridge](bridge.md) | Every bridge module: ACP, agents, workflows, memory, database, routines, browser, backup. | | [Workflows](workflows.md) | Lead delegation, templates, custom agents, the crew tools, mid-turn steering. | | [Reviewed merges](merges.md) | Git worktrees per run, off-tree merge, the in-game diff review, conflict and rework ghosts. | | [Screens and browser](screens.md) | The wall dashboard, live code, and the headless-Chrome browser pipeline. | | [Minecraft mod](mod.md) | Ghost entities, the office, console, workflow editor, merge screen, rendering. | | [Security](security.md) | Tokens, pairing, the git sandbox, approvals, privacy. | | [Testing](testing.md) | The test suite and how to check the whole system. | Quick start lives in the [main README](../README.md). The HTTP API table is in [bridge/README.md](../bridge/README.md). *Screenshot: The Haunted Office* --- # Architecture ``` Kiro IDE / CLI ──hooks──┐ ├─► bridge (Node 22) ──WebSocket──► Fabric mod (server) ──► ghosts, office, console console agents ◄──ACP───┘ │ ▲ │ (kiro-cli acp, git │ └──── HTTP (command token) ◄───┘ prompts, approvals, merges, sign-in worktree per run) └──► headless Chrome ──JPEG frames──► big screens ``` ## The three parts **Bridge (`bridge/`)** is a dependency-light Node 22 ESM service. It has two jobs: 1. *Observe.* Kiro hook events (from the IDE or CLI) are posted to `/event`, stripped of prompts and file contents, normalised to one event shape and broadcast on `WS /stream`. 2. *Act.* It starts agents of its own through the Agent Client Protocol (`kiro-cli acp`), runs workflows over them, keeps their memory, shared database, routines and history, and gates their work behind approvals and merges. **Mod (`mod/`)** is a Fabric mod for Minecraft 26.3 (Java 25, split client/main source sets). The server side holds the crew state, the Haunted Office, the screen wall and the HTTP/WebSocket client to the bridge. The client side renders ghosts and implements the console, workflow editor, merge review and browser screens. **Tools (`tools/`)** is the Blender pipeline that produced the ghost and monitor models and the office. ## Event flow 1. A Kiro agent calls a tool. Its hook runs `send-event.mjs`, which always exits 0 and prints nothing. 2. The bridge drops sensitive fields, assigns a ghost identity per session, and emits `tool_start` / `tool_end`. 3. The mod's `BridgeClient` receives the event and updates the ghost: glow colour for status, an item in hand for the tool category, a walk to the matching desk. 4. Commands go the other way over HTTP with the command token: summon, prompt, answer approval, merge. ## Console agents Console agents are started by the bridge itself. `src/acp.mjs` speaks ACP over stdio, `src/agents.mjs` pools processes and keeps a spare session ready so a summon is near instant, and `src/normalize.mjs` turns ACP updates into the same event shape hooks produce. That is why hook agents and console agents look identical in the world. ## Design choices - **One event shape** for everything, so the mod and the dashboard never care where an agent came from. - **No secrets in the stream.** Prompts, file contents and tool output from hooks never leave the bridge. - **The checkout is sacred.** Agents work in worktrees and land code only after an in-game approval. - **Everything optional.** No Chrome means no browser screen; no git repo means no worktrees; the rest keeps working. --- # Haunted Crew Fabric mod: exhaustive reference Scope: every Java file under `mod/src/main/java/dev/hauntedcrew`, `mod/src/client/java/dev/hauntedcrew/client`, and `mod/src/test/java/dev/hauntedcrew`, plus `mod/src/main/resources` (fabric.mod.json, lang, item/block/model JSON, ghost model, world preset, tag, office template) and `mod/README.md`. Target: Minecraft 26.3, Java 25, Fabric Loader 0.20.1, Fabric API 0.165.0+26.3, mod version 0.1.0. Every value below was read from the code or resource files. Items marked **Not verified** at the end of the document were not checked. ## Table of contents 1. [Mod metadata and dependencies](#1-mod-metadata-and-dependencies) 2. [Registered content](#2-registered-content) 3. [Server entry point and lifecycle (HauntedCrew)](#3-server-entry-point-and-lifecycle-hauntedcrew) 4. [Commands (/crew)](#4-commands-crew) 5. [Keybinding, items and in-world controls](#5-keybinding-items-and-in-world-controls) 6. [Config file config/hauntedcrew.json](#6-config-file-confighauntedcrewjson) 7. [CrewProtocol: bridge messages, Job, Status, Session](#7-crewprotocol-bridge-messages-job-status-session) 8. [CrewManager and GhostEntity: ghosts, desks, slots, reconcile](#8-crewmanager-and-ghostentity-ghosts-desks-slots-reconcile) 9. [Office builder](#9-office-builder) 10. [Big screen: ScreenWall, ScreenEntity, frame pipeline](#10-big-screen-screenwall-screenentity-frame-pipeline) 11. [Client: ghost rendering and client state](#11-client-ghost-rendering-and-client-state) 12. [Client screens](#12-client-screens) 13. [Guide NPC (Boo)](#13-guide-npc-boo) 14. [Payloads and ConsoleService: every action and what the server does](#14-payloads-and-consoleservice-every-action-and-what-the-server-does) 15. [BridgeClient and bridge HTTP calls](#15-bridgeclient-and-bridge-http-calls) 16. [Build and test](#16-build-and-test) 17. [Source map](#17-source-map) 18. [Not verified](#18-not-verified) --- ## 1. Mod metadata and dependencies Source: `mod/src/main/resources/fabric.mod.json`, `mod/build.gradle`, `mod/gradle.properties`. | Field | Value | |---|---| | `schemaVersion` | 1 | | `id` | `hauntedcrew` | | `version` | `${version}` (expanded from `gradle.properties` `version=0.1.0` by `processResources`) | | `name` | Haunted Crew | | `description` | Watch your Kiro agents work as ghosts in a haunted office. | | `authors` | `["Haunted Crew team"]` | | `license` | MIT | | `icon` | `assets/hauntedcrew/icon.png` | | `environment` | `*` (both sides) | | `entrypoints.main` | `dev.hauntedcrew.HauntedCrew` | | `entrypoints.client` | `dev.hauntedcrew.client.HauntedCrewClient` | | `depends.fabricloader` | `>=0.20.1` | | `depends.minecraft` | `~26.3` | | `depends.java` | `>=25` | | `depends.fabric-api` | `*` | There is no `mixins` JSON, no access widener, and no `src/client/resources` directory. The mod does not use mixins. Build inputs (`gradle.properties`): `minecraft_version=26.3`, `loader_version=0.20.1`, `loom_version=1.19-SNAPSHOT`, `fabric_api_version=0.165.0+26.3`, `junit_version=5.11.4`, `group=dev.hauntedcrew`, `version=0.1.0`. Gradle JVM args `-Xmx2G`, parallel and configuration cache enabled. Build script (`build.gradle`): Fabric Loom plugin; `loom.splitEnvironmentSourceSets()`; one Loom mod `hauntedcrew` built from the `main` and `client` source sets; dependencies `minecraft`, `fabric-loader`, `fabric-api`, and JUnit 5 for tests; Java toolchain 25 and `options.release = 25`; `withSourcesJar()`; the jar includes `LICENSE` renamed to `LICENSE_hauntedcrew`. ## 2. Registered content ### 2.1 Registry summary | Kind | Registry id | Java field | Class | Registered in | |---|---|---|---|---| | Entity type | `hauntedcrew:ghost` | `HauntedCrew.GHOST` | `GhostEntity` (extends `PathfinderMob`) | `HauntedCrew` static init | | Entity type | `hauntedcrew:screen` | `HauntedCrew.SCREEN` | `ScreenEntity` (extends `Entity`) | `HauntedCrew` static init | | Block | `hauntedcrew:monitor` | `HauntedCrew.MONITOR` | `MonitorBlock` (extends `HorizontalDirectionalBlock`) | `HauntedCrew` static init | | Item (block item) | `hauntedcrew:monitor` | `HauntedCrew.MONITOR_ITEM` | `BlockItem` wrapping `MONITOR` | `HauntedCrew` static init | | Item | `hauntedcrew:screen_remote` | `HauntedCrew.SCREEN_REMOTE` | `CrewItem`, kind `REMOTE` | `HauntedCrew.item(...)` | | Item | `hauntedcrew:agent_console` | `HauntedCrew.AGENT_CONSOLE` | `CrewItem`, kind `CONSOLE` | `HauntedCrew.item(...)` | | Keybinding | `key.hauntedcrew.console` | `HauntedCrewClient.OPEN_CONSOLE` | `KeyMapping` | `HauntedCrewClient` | | Key category | `hauntedcrew:main` | `HauntedCrewClient.CATEGORY` | `KeyMapping.Category` | `HauntedCrewClient` | | Payload type | `hauntedcrew:console` | `ConsolePayloads.ToClient.TYPE` | clientbound play | `HauntedCrew.onInitialize` | | Payload type | `hauntedcrew:screen_frame` | `ConsolePayloads.ScreenFrame.TYPE` | clientbound play | `HauntedCrew.onInitialize` | | Payload type | `hauntedcrew:console_action` | `ConsolePayloads.ToServer.TYPE` | serverbound play | `HauntedCrew.onInitialize` | | Model layer | `hauntedcrew:ghost` (layer `main`) | `GhostModel.LAYER` | `GhostModel` | `HauntedCrewClient` | | Structure template | `hauntedcrew:office` | `Office.TEMPLATE` | `StructureTemplate` file `data/hauntedcrew/structure/office.nbt` | `Office` | | World preset | `hauntedcrew:haunted_office` | (datapack JSON) | `data/hauntedcrew/worldgen/world_preset/haunted_office.json` | datapack | Nothing else is registered: no custom sounds, no creative tab (`CreativeModeTab` is not referenced anywhere in the mod), no spawn eggs, no custom attributes beyond the ghost's default attributes, no block entities, no menus or recipes. Entity details: - `hauntedcrew:ghost`: `MobCategory.MISC`, size 0.7 x 0.9, `noSave()`, `fireImmune()`, `clientTrackingRange(10)`. Default attributes from `GhostEntity.createAttributes()`: `MAX_HEALTH` 20.0, `MOVEMENT_SPEED` 0.3, registered with `FabricDefaultAttributeRegistry`. - `hauntedcrew:screen`: `MobCategory.MISC`, size 0.5 x 0.5, `noSave()`, `clientTrackingRange(10)`. Block details (`MonitorBlock`): `Block.box(1, 0, 1, 15, 14, 15)` collision and outline shape; properties `strength(1.0f)`, `noOcclusion()`, `lightLevel(state -> 7)`, `sound(SoundType.METAL)`; `FACING` property (horizontal); on placement the block faces the placing player (`getHorizontalDirection().getOpposite()`); default state FACING north. Item properties: `stacksTo` not set (default), `useBlockDescriptionPrefix()`. Item details (`CrewItem`): `stacksTo(1)`. Both items are one stack per slot. Textures and models: `models/block/monitor.json` (parent `minecraft:block/block`, 8 box elements, one of which has `light_emission` 15 and `shade` false for the glowing screen face); `blockstates/monitor.json` (`facing=north` 0 degrees, east 90, south 180, west 270); `items/monitor.json`, `items/agent_console.json`, `items/screen_remote.json` (item models); `models/item/agent_console.json` and `models/item/screen_remote.json` (parent `minecraft:item/generated`); textures `textures/block/monitor.png`, `textures/item/agent_console.png`, `textures/item/screen_remote.png`, `textures/entity/ghost.png`, `icon.png`. Ghost model file `models/entity/ghost.json`: texture size 256 x 128, scale 0.5, 67 parts (body plus cap, side, hem, tail, arm, and accessory parts). Accessory parts named `acc__*`; their parent part (`body`, `left_arm`, or `right_arm`) is listed in section 11. Sounds: no sound events are registered. The mod plays vanilla `SoundEvents.AMETHYST_BLOCK_CHIME` (Guide tips) and `SoundEvents.NOTE_BLOCK_BELL` (approval prompt). ### 2.2 Lang keys (`assets/hauntedcrew/lang/en_us.json`) | Key | Text | |---|---| | `generator.hauntedcrew.haunted_office` | Haunted Office | | `entity.hauntedcrew.ghost` | Kiro Ghost | | `entity.hauntedcrew.screen` | Big Screen | | `block.hauntedcrew.monitor` | Agent Monitor (also used for the monitor block item) | | `item.hauntedcrew.agent_console` | Agent Console | | `item.hauntedcrew.screen_remote` | Screen Remote | | `key.category.hauntedcrew.main` | Haunted Crew | | `key.hauntedcrew.console` | Open agent console | | `screen.hauntedcrew.console` | Haunted Crew Console | | `screen.hauntedcrew.console.input` | Message | No lang keys exist for the workflow, merge, browser or Ghost Rush screens. Those screens use literal English strings. ### 2.3 World type and worldgen - `data/hauntedcrew/worldgen/world_preset/haunted_office.json`: preset with four dimensions. `minecraft:overworld` is a `minecraft:flat` generator with biome `minecraft:the_void`, `features` false, `lakes` false, `layers` empty, `structure_overrides` empty. `minecraft:the_end` and `minecraft:the_nether` use the vanilla noise generators (`minecraft:end` and `minecraft:nether` settings). - `data/minecraft/tags/worldgen/world_preset/normal.json`: `replace: false`, `values: ["hauntedcrew:haunted_office"]`. This adds the preset to the Create New World World Type list. - `data/hauntedcrew/structure/office.nbt`: the shipped office template (section 9). ## 3. Server entry point and lifecycle (HauntedCrew) Class `dev.hauntedcrew.HauntedCrew` (`ModInitializer`). Purpose: registers content, owns the server-side singletons (`CrewConfig`, `CrewManager`, `ConsoleService`, `ScreenWall`, `BridgeClient`), and wires events. Static constants: `MOD_ID = "hauntedcrew"`, `LOG` (slf4j), `KIT_TAG = "hauntedcrew_kit2"`. Helper `id(path)` returns `Identifier` in namespace `hauntedcrew`. `onInitialize()` in order: 1. `FabricDefaultAttributeRegistry.register(GHOST, GhostEntity.createAttributes())`. 2. Registers payload types: clientbound play `ToClient` (`console`), clientbound play `ScreenFrame` (`screen_frame`), serverbound play `ToServer` (`console_action`). 3. Registers the server receiver for `ToServer`: calls `console.handle(player, json)` when a console exists. 4. `configFile = FabricLoader.getConfigDir().resolve("hauntedcrew.json")`. 5. `SERVER_STARTED` runs `start(server)`. `SERVER_STOPPING` runs `stop()`. 6. `END_SERVER_TICK`: `manager.tick()`, `Guide.tick(server)`, `screen.tick(console.sessions(), console.lines(), bridgeState())` when both exist, and every 200 ticks (about 10 s) `rediscover(server)` when config is loaded. 7. `CommandRegistrationCallback` registers the `/crew` tree (section 4). 8. `ServerPlayConnectionEvents.JOIN`: on the next server tick, if the big screen exists and the player does not have tag `hauntedcrew_kit2`, the tag is added and the player gets the kit (`giveKit`). If the office has a spawn marker, that same first-join player is teleported to it with `tp 180 0` (x and z are the marker centre, y is the marker's block y). `start(server)`: 1. `CrewConfig.load(configFile)`. On `IOException`, logs an error and returns. Then no manager, console or screen exist and `/crew status` reports not paired or not connected. 2. `Office.load(server)`. If no layout file exists and `Office.isOfficeWorld(server)` is true, `Office.setUpNewWorld(server)` builds the office. 3. `manager = new CrewManager(server, anchorOf(...))`, `console = new ConsoleService(server, config, HauntedCrew::bridgeState)`. 4. If the office exists: `manager.setDesks(deskSeats)`, `officeSpawn = spawn`, `Guide.setHome(guide marker)`, and if a `screen` marker exists `screen = new ScreenWall(server, screenMarker)`. 5. `connect(server)`. `stop()`: stops the bridge, clears the manager (removes all sessions and ghosts), nulls manager, console, and screen (screen clear discards its display entities). `connect(server)`: if the source is not `paired`, calls `config.discoverLocal()`. If `config.validate()` returns a problem, logs `waiting for a bridge: ` and returns. Logs a warning if `insecureRemote()`. Starts `BridgeClient` on `config.url() + "?frames=1"` (or `&frames=1` if the URL already has a query), with token `config.token()`. Each text message: if it starts with `{"type":"frame"`, goes to `forwardFrame`; otherwise `CrewProtocol.parse` and on the server thread `manager.apply(msg)` and `console.apply(msg)`. `rediscover(server)`: only when the source is not `paired`. Re-runs `discoverLocal()`. If a launcher is found and (no bridge exists or the URL/token changed and the bridge state is not CONNECTED), calls `reconnect`. `reconnect(server)`: stops the bridge, sets it null, calls `Guide.setHome(null)`, then `connect`. Note: `Guide.setHome(null)` clears the guide's home until `start` runs again (`/crew reload` or a server restart); `reconnect` is called by pairing and by rediscovery. `bridgeState()`: if no bridge: `"not paired"` when config source is `none` (or config is null), else `"not connected"`. Otherwise the `BridgeClient.State` name in lowercase: `stopped`, `connecting`, `connected`, `retrying`, `unauthorized`. `pair(server, code, url, reply)`: section 6.3. `forwardFrame(server, json)`: section 10.4. `giveKit(player)`: for slot index 0 `AGENT_CONSOLE` and slot index 1 `SCREEN_REMOTE`: skips an item the player already has; puts the stack in that inventory slot if empty, otherwise adds it. `cycleScreen(player)`: section 5.3. `anchorOf(server, cfg, office)`: returns the config anchor if set; else the office layout centre; else the bottom centre of the server's respawn position. ## 4. Commands (/crew) Registered in `HauntedCrew.registerCommands`. Root literal `crew`, `.requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS))` applies to every subcommand. `LEVEL_GAMEMASTERS` is the vanilla permission level 2 (README: "op level 2"); this is the only permission check for `/crew`. | Syntax | Effect | Output | |---|---|---| | `/crew status` | Reports bridge state, URL and source, session count and loaded ghost count. | `Haunted Crew: bridge at (), session(s), ghost(s) loaded` | | `/crew reload` | `stop()` then `start(server)`: re-reads config, rebuilds the office layout and manager, reconnects. | `Haunted Crew: config reloaded` (broadcast to ops) | | `/bigscreen ` | Sets the big screen to `dashboard`, `code`, `website`, `search` or `activity` (same as the Screen Remote) and starts the page it needs. For the world owner or an operator, no cheats needed. Needs an office world; fails with the mode list otherwise. | | `/crew anchor` | Sets the config anchor to the command source's position, saves the config, and moves non-desk ghosts there. Fails if the mod is not running. | `Haunted Crew: ghosts now gather here` | | `/crew kit` | Gives the calling player the Agent Console and Screen Remote (same slots as the join kit). Requires a player. Works without an office. | `Haunted Crew: here are your tools (console, dashboard, activity log)` | | `/crew pair ` | Pairs with the bridge using a launcher code, default URL is the current config URL. | `Haunted Crew: ` | | `/crew pair ` | Same, with `` (greedy string). | same | | `/crew office place` | Pastes the office template with its floor centre at the command source's block position, saves `office.json`, and sets the desks. Does not rebuild the screen wall or guide. | `Haunted Crew: office placed with desk(s)`, or `Office template not found` | | `/crew office save ` | Saves the region between two block positions as this world's office template (`BlockPosArgument`, loaded blocks). Max 96 blocks per side. Does not update `office.json`. | `Haunted Crew: office saved under ` | Pair messages from `/crew pair` are prefixed `Haunted Crew: `. If the mod has no config (not running): `Haunted Crew is not running.` The `pair` result messages are in section 6.3. ## 5. Keybinding, items and in-world controls ### 5.1 Keybinding - Name `key.hauntedcrew.console` ("Open agent console"), default `InputConstants.KEY_K` (keyboard), category `KeyMapping.Category.register(HauntedCrew.id("main"))` shown as "Haunted Crew" under Options > Controls > Key Binds. Registered with `KeyMappingHelper.registerKeyMapping`. - Each client tick, while the key is clicked and no other screen is open and the player exists, `openConsole()` runs. - `openConsole()`: if `ClientConsole.available()` is false (the server did not accept the `console_action` payload), prints `Haunted Crew isn't installed on this server.` Otherwise sends action `open` and opens `ConsoleScreen`. ### 5.2 Items | Item | Right-click (use) | Left-click on the big screen | Sneak + right-click | Sneak + left-click on the big screen | |---|---|---|---|---| | Agent Console (`agent_console`) | Opens `ConsoleScreen` (client `UseItemCallback`). Sends `open`. | No effect (client returns PASS for non-remote; AttackBlock handler only for the remote). | Same as right-click. | Same. | | Screen Remote (`screen_remote`) | Server: cycles the big screen mode (section 5.3). Client: nothing (PASS). | Client: sends `screen_click` with the hit point (u, v) on the screen quad, then opens `BrowserScreen`. Returns FAIL, so no block is broken. | Client: opens `BrowserScreen` directly (no server action; the server's `use` does nothing when sneaking). | Client: sends `screen_scroll` with text `500` (scroll down) and returns FAIL. | Left-click with the remote, when the ray misses every `ScreenEntity` within 40 blocks, returns FAIL and does nothing else. Only the client does the hit test (`clickScreen`); the server then checks trust for `screen_` actions (section 14). ### 5.3 Screen Remote cycle (server, `HauntedCrew.cycleScreen`) - No big screen in this world: overlay `No big screen here. Use a Haunted Office world.` - Caller not trusted (`ConsoleService.isTrusted`: operator level 2 or singleplayer owner): overlay `Only the world owner or an operator can switch the screen.` - Otherwise mode advances `ordinal + 1` modulo 5 over `DASHBOARD, CODE, WEBSITE, SEARCH, ACTIVITY`. Overlay `Big screen: