scmJS docs

AI

scm-js/plugin-ai, not a default, is the worked example for calling another plugin's commands, api.document.create and a plugin's own submenu, and the first plugin that needs a server: scm-js/ai-server holds the Anthropic key, the prompt recipes, the access rules and the budgets, and never any game data. The split is deliberate — the editor already has everything that makes a map a map, so the model never emits tiles. Each recipe takes the facts the plugin gathered (the tileset's terrain vocabulary, statistics, a rendered picture, the script's declarations) and answers with a plan or text the plugin applies through the ordinary API: a map plan is a coarse grid of legend characters the plugin turns into isometric brush strokes (so cliffs and shores draw themselves), bases laid with the Melee Wizard's geometry, doodads scattered by category; a trigger request answers in the Trigger Script plugin's language, is compiled through that plugin's trigger-script.compile command, repaired against the diagnostics, and built with trigger-script.build (so it needs that plugin on, and says so when it is not); a review sends document.renderImage; the assistant panel is a tool-use loop whose tools — reads, screenshots, and one undoable write (or one settings transaction) each — are defined and run in the plugin, with the server adding the system prompt and the caching. The assistant is the reason document.update grew the settings family, api.settings and document.resize: its sixty-odd tools reach everything the editor's dialogs write. With every message it sends the map's facts (players, counts, what is selected, where the view is, the top of the undo stack) and, once per map, a reference block built from api.terrain.types(), api.palette.doodadCategories(), api.settings.unitTypes(), api.triggers.defs and the text format — the server keeps it as a cached system block, and puts a cache breakpoint on the conversation, so a long session with screenshots is read from the cache rather than re-billed each round. protocol.ts, kept identical in both repositories, is the contract. Tools ▸ AI holds the whole of it; Settings there takes the server's address, an access token the operator issued, or your own Anthropic key, which is forwarded and never stored on the server.