shire Docs

C++ SDK

Files:

  • sdk/cpp/shire_sdk.hpp — client, named-pipe transport, UI helpers.
  • sdk/cpp/shire_json.hpp — small JSON parser/writer (no external dependency).

The SDK uses two connections: one for sequential request/response and one read by an event thread. This avoids a blocking read on a synchronous handle serializing a write from another thread.

Connect

#include "shire_sdk.hpp"

shire::sdk::Client client;
std::string error;
if (!client.connectFromEnvironment(error)) {
    std::fprintf(stderr, "%s\n", error.c_str());
    return 1;
}

It reads SHIRE_PLUGIN_PIPE, SHIRE_PLUGIN_TOKEN, SHIRE_PLUGIN_ID, opens both connections and performs plugin.hello on each.

Calls

std::string error;
client.log("hello", error);
client.notify("Title", "Body");
client.notify("Title", "Body", 0, error);

shire::json::Value position;
client.player_position(position, error);
int scene = 0;
client.scene(scene, error);

shire::json::Value entities;
client.entities(64, entities, error);
shire::json::Value markers;
client.markers(128, markers, error);

client.teleport(1.0, 2.0, 3.0, 0, error);

UI

shire::json::Value layout = shire::json::Value::Array();
layout.array.push_back(shire::sdk::Client::text("Player", "title"));
layout.array.push_back(shire::sdk::Client::toggle("enabled", "Enabled", true));
layout.array.push_back(shire::sdk::Client::button("refresh", "Refresh"));
client.set_ui(layout, error);

// Or from JSON:
client.set_ui_json("[{\"type\":\"text\",\"id\":\"title\",\"text\":\"Hello\"}]", error);

Events

The event thread fills poll_event; run() loops and prints each event. A real plugin can call poll_event in its own loop:

std::vector<std::string> events = {"player.position", "scene.changed"};
client.subscribe(events, error);
client.run(); // or poll_event(event, data) in a timer loop

Build

examples/plugins/hello-cpp is a complete CMake project:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

The CMake template writes out/plugin.exe; the manifest uses:

{
  "language": "executable",
  "entrypoint": "out/plugin.exe",
  "permissions": ["notifications.show", "ui.create"]
}

shire-plugin build detects CMake and runs both commands. The SDK is Windows only because the Shire transport is a Windows named pipe.

Shire Plugin API 1.0 · Written in English. Documentation home · API status · Changelog

Independent project. Not affiliated with HoYoverse. Never put secrets in a plugin, manifest or package.