Spire-CTL: A Verifiable Control Plane for *Slay the Spire 2* Agents

Preface

Driving a local game with agents commonly involves screenshots with visual recognition or scripted click simulation. Both methods struggle to provide stable contracts regarding state drift, action legality, and behavior after failures. Within the DeepSeek Harness (DSH) community, workflow-type plugins are treated as reusable “control planes.” If your harness can execute commands and read JSON, yet needs to drive Slay the Spire 2 (STS2), here we introduce the spire-ctl project by maintainer enderzcx: the same package serves as both a CLI and a native tool mountable as a DSH plugin.

What is this?

spire-ctl is an STS2 control plane for agent harnesses: it provides a JSON state contract, a list of legal actions, and a non-replaying execution layer. It does not take screenshots, perform visual recognition, or simulate clicks; instead, it reads structured state via a local Mod and calls the game’s original action queue.

The data flow can be summarized as:

Your agent (any harness)
        ↓  state / act / seq
   spire-ctl: Legal Action Enumeration → Validation/Dispatch → Settlement Check
        ↓  Original Game Action Queue
    STS2 Local Bridge (Mod)

Repository: GitHub — enderzcx/spire-ctl. Community Directory: skillhub.cn/plugins/enderzcx/spire-ctl. Category: Workflow; Current package version 0.3.0, License MIT, Runtime requirement Node.js >= 22. The core implementation has zero npm production dependencies; @deepseek-ai/dsh-tools is an optional peer dependency, allowing standalone CLI use without DSH.

What it Guarantees and Does Not Promise

The value lies in behavior during errors, not in “ability to auto-win”:

Guarantee Meaning
Reject Stale State Once state changes, old identifiers become invalid immediately; card hand indices from the previous turn cannot be reused.
Single-Writer Lock Only one operator is allowed on the same port; two agents will not play cards simultaneously.
No Auto-Retry Dispatch failure or unconfirmed result → persistent stop, awaiting manual verification; absolutely no resending.
Settlement Check Every action is read back for confirmation; unconfirmed means incomplete.
Illegal Actions Dispatched Actions come only from options advertised by the game itself; no self-fabricated IDs.
Stop on Uncertainty Unknown mechanics, empty intents, or fatal attacks that cannot be covered → return to the caller; do not guess.

This is not an auto-win bot. Decision-making belongs to the caller (or an optional quick-decision model); spire-ctl only guarantees that “decided actions are executed legally and verifiably.” There is no default winning strategy or win-rate guarantee.

Division of labor between program and caller: waiting for animation settlement, legality validation, and arithmetic based on game intent are handled by the program; which card to play, route selection, and deck building are handled by the caller; the program stops and returns control when facing unfamiliar intents or unconfirmed results.

Installation and Enablement

1. DSH Plugin (Optional but convenient)

Install the controller with a single command using the same package (it is both a CLI and a DSH plugin):

dsh plugin --profile web add github:enderzcx/spire-ctl

After installation, native tools like spire_state, spire_act, spire_seq, and spire_advance can be called directly without shell assembly. The DSH engine requirement in package.json is >=0.1.0-rc.1 <0.2.0-0.

A health check is recommended after installation: it will explain the reason if the game is not found, the Mod is not installed, or the bridge is not running.

node bin/spire.mjs doctor

The Mod is the only step requiring writing to the game directory; doctor --install-mod will first provide a plan, verify SHA256, and refuse to write while the game is running.

The README also mentions: copy the entire Installation Prompt from the repository to the agent, allowing the agent to install and verify it autonomously.

2. STS2 Bridge Mod (Required)

Download the package corresponding to your platform from sts2-bridge Releases and place it in the Mod directory according to the INSTALL.txt inside. Close the game first and back up your saves.

Verify if the bridge is listening locally:

curl --noproxy '*' http://127.0.0.1:15526/
# {"message":"Hello from STS2 MCP v0.4.0","status":"ok"}

The Mod binds only to the loopback address; do not forward the port to the public network.

3. Permissions and Security

The plugin and CLI run with the permissions of the current DSH / shell process and will read/write local game bridges and runtime files. Read the source code and MIT license before installation; the repository declares it does not contain game assemblies, assets, personal saves, or credentials, and logs do not contain API keys.

Typical Usage

Read-only State

state does not change the game; it returns the current situation, available actions, and state identifiers. See docs/AGENT.md in the repository for operational details.

node bin/spire.mjs state

Single Step and Sequence Execution

node bin/spire.mjs act STATE_ID OPTION_ID
node bin/spire.mjs seq STEPS.json

CLI Command Overview:

Command Purpose
state Read state, legal actions, routing reasons, and current state identifier.
act STATE_ID OPTION_ID Execute a single action.
seq STEPS.json Execute a series of decided actions, re-reading and validating step-by-step.
plan PLAN.json Multi-card prefix with prediction (stops if prediction mismatches).
battle [MAX] [STRATEGY.json] Continuous play with optional quick-decision model.
advance [MAX] Mechanical progression (collect gold, dialog, fixed buttons).
clear-halt STATE_ID Clear stop marker after verifying the situation.
strategy / save-strategy View/Save explicit continuation conditions.

When using act card by card, the hand card_index is a position, and indices will drift after a card is played. seq allows submitting an entire turn at once and specifying by card ID, for example:

{
  "expected_state_id": "…",
  "steps": [
    {"card": "FLAME_BARRIER"},
    {"card": "TOXIC"},
    {"card": "DEFEND_IRONCLAD"},
    {"action": "end_turn"}
  ]
}

Each step re-matches the actions advertised by the game from the newly settled state, with the same transaction semantics as act; if any step is no longer advertised, the sequence stops before playing anything and returns the available actions at that moment. Non-combat interfaces apply similarly (e.g., buying out a shop in one go).

Starting a New Run from Game Over

Do not touch saves, settings, or multiplayer; menu only advertises safe actions, so abandon_run, quit, multiplayer, etc., will not appear.

node bin/spire.mjs state          # game_over → only main_menu available
node bin/spire.mjs act STATE 0    # Return to main menu
# Sequentially: singleplayer → standard → Select Character → embark

Other harnesses not installing DSH should use commands like node bin/spire.mjs state as usual; bin/ and src/ do not import DSH adapters, and this boundary is guarded by test/boundary.test.mjs.

Use Cases and Notes

Suitable for: Users orchestrating agents in DSH or other harnesses who need STS2’s structured state and verifiable execution; want to use seq to reduce index drift; need a single-writer lock and fail-stop behavior rather than silent retries.

Compatibility and Verification: The README records verification on macOS arm64, Game v0.107.1. Changes in the game or upstream Mod API may cause field renames; the controller will report errors explicitly rather than silently continuing. See docs/VALIDATION.md for scope. Offline npm test is not a substitute for verification against a running game.

Concurrency: Concurrent reads are allowed from multiple places, but there can be only one operator; the lock only protects against the project itself and cannot prevent manual play or other tools from directly operating the game.

Uninstallation: Close the game, remove the Mod, and restart via Steam; do not overwrite new progress with old saves.

Conclusion

spire-ctl condenses STS2 into a JSON state contract plus a legal action execution layer, allowing any harness capable of running a Node CLI to drive the same verified workflow; within DSH, it adds a layer of native tool calls. Decision-making remains with you or your model, while the control plane is responsible for legality and predictable stopping upon failure.

  • Directory Page: https://www.skillhub.cn/plugins/enderzcx/spire-ctl
  • Source Code & Docs: https://github.com/enderzcx/spire-ctl
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye