La referencia de API proviene de los comentarios de documentación de Go en el código fuente y está redactada en inglés.
package editormcp
import "github.com/nsgo-dev/game/pkg/editor/editormcp"Resumen
Package editormcp is the NSGo Game Editor's MCP server: an agent reads and edits the project open in the editor through it, with the same editor commands the inspector, scene tree and viewport use, so every edit is an undo step the person sees and can take back.
A Server serves an editor.Editor. Open serves it on the project's local endpoint (Endpoint), a Unix domain socket private to the user and named after the project's path, never a network port, and follows the editor to another project's endpoint when it opens one. `go tool game mcp` runs a Proxy on standard input and output, which an agent such as Claude Code or Codex starts: it finds the editor that has the project open through that endpoint and forwards to it, and while none has it answers each call with how to open the project.
The server's tools are a registry (Server.AddTool) that the editor's parts join, so that every action with a button or a shortcut has a tool. This package adds the first five, named as the editor's Settings › Tools page lists them:
- scene_read reads a scene, prefab, data or project file with line numbers, the open scene and game.yaml as the editor holds them.
- scene_edit adds, moves, changes and removes objects, components and properties of the open scene through the editor's methods, the edits of one call as one undo step, or none when the editor refuses one; the refusal (EditError) names the file, the edit, the object, the field and the fix.
- selection_get reports what the person has selected.
- viewport_image returns a PNG of the viewport.
- game_check runs the Problems panel's checks (including open unsaved documents) and returns its problems with file, line, column and message.
- problem_propose_fix proposes a validated fix for a live problem with an explanation and diff in the editor's Agent panel without ever applying it.
- game_playtest runs headless bot playtests configured by playtest.yaml with replay recordings and returns the evaluated YAML report.
- playtest_define proposes a new or updated metric in playtest.yaml as a pending review with a diff.
Tool handlers run on the server's goroutines and reach the editor through Call.Editor, which runs a function on the editor's goroutine and waits, so a tool may wait for work the editor does elsewhere, such as a project check, and return an image: the two things an app tool registered with NSGo's automation cannot do (nsgo-dev/nsgo#2342, nsgo-dev/nsgo#2343). RegisterAutomation offers the same tools to nsgo mcp as well, for an editor running under go tool nsgo dev -automation.
Resources editor://scene and editor://selection hold the open scene's YAML and the selection; a client that subscribes to them hears of every change, with _meta saying whether the agent or the person made it (MetaBy) and the editor's revision (MetaRevision).
Índice
- Constantes
- Variables
- func Dial(ctx context.Context, root string) (net.Conn, error)
- func Endpoint(root string) (string, error)
- func InstallCommand() (string, []string)
- func Installed(root string) bool
- func Listen(root string) (net.Listener, error)
- func ProjectRoot(path string) (string, error)
- type Action
- type AgentReportStepResult
- type AgentTurnPayload
- type AutomationResult
- type BriefContext
- type Call
- type Check
- type CheckpointListItem
- type CheckpointListResult
- type CheckpointRestoreResult
- type CodeReviewChecksSummary
- type CodeReviewFileSummary
- type CodeReviewStatusResult
- type CutsceneActorPose
- type CutsceneCameraPose
- type CutsceneChangeSummary
- type CutsceneDialoguePose
- type CutsceneScrubResult
- type CutsceneWriteResult
- type DataTableReviewRecordStatus
- type DataTableReviewStatusResult
- type DocEditResult
- type EditError
- type EditResult
- type FileEditResult
- type FileText
- type GameDeleteFileResult
- type HistoryEntryView
- type HistoryListResult
- type InstallFile
- type InstallResult
- type MergeStatusResult
- type ObjectCopyYAMLResult
- type ObjectDuplicateResult
- type ObjectFieldResult
- type ObjectGroupResult
- type ObjectMoveUnderResult
- type ObjectPasteYAMLResult
- type ObjectSelectSamePrefabResult
- type ObjectVisibilityResult
- type ObjectYAMLLocation
- type Options
- type PermissionDeniedResult
- type PermissionError
- type PermissionPromptAnswer
- type PermissionsDraftResult
- type PlanStepUpdatePayload
- type PlayFrozenContextResult
- type PlayReplayStepResult
- type PlaytestDefineResult
- type PlaytestReportStatusResult
- type PlaytestReview
- type PlaytestRunRequest
- type PlaytestRunResult
- type Problem
- type ProblemProposeFixResult
- type ProjectContext
- type Proxy
- type RefactorRenameResult
- type RefsFindResult
- type Result
- type ReviewChangeSummary
- type ReviewNotesStatusResult
- type ReviewRedoResult
- type RulesContext
- type SaveWarning
- type SelectedObject
- type Selection
- type Server
- func New(ed *editor.Editor, opts Options) *Server
- func (s *Server) AddTool(t Tool) error
- func (s *Server) ApplyPlaytestReview(id string) error
- func (s *Server) BeginStep(ctx context.Context, objectIDs []string, activity string) error
- func (s *Server) BindSessionTask(ss *mcp.ServerSession, taskID string)
- func (s *Server) Clients() []editor.AgentClientInfo
- func (s *Server) Close() error
- func (s *Server) CompleteTaskTurn(ctx context.Context, taskID, summary string) (editor.TaskReview, error)
- func (s *Server) Connect(ctx context.Context, t mcp.Transport) (*mcp.ServerSession, error)
- func (s *Server) ConnectTask(ctx context.Context, t mcp.Transport, taskID string) (*mcp.ServerSession, error)
- func (s *Server) DismissPlaytestReview(id string) error
- func (s *Server) Editor(ctx context.Context, fn func(ed *editor.Editor) error) error
- func (s *Server) EndStep(ctx context.Context) error
- func (s *Server) HeldObjects() map[string]string
- func (s *Server) LastPermissionDecision() (editor.PermissionEvaluation, bool)
- func (s *Server) Open() error
- func (s *Server) PlaytestReviews() []PlaytestReview
- func (s *Server) RegisterAutomation(cx *core.Scope) error
- func (s *Server) ReleaseTaskHolds(taskID string)
- func (s *Server) RemoveTool(name string)
- func (s *Server) SetHoldBlockedHook(fn func(taskID, objectID, holderTaskID string))
- func (s *Server) SetHoldWaitTimeout(d time.Duration)
- func (s *Server) Status() (string, error)
- func (s *Server) Tools() []Tool
- type SketchReadResult
- type SketchReadingResult
- type StatesTestResult
- type StatesWriteResult
- type TasksListResult
- type TileReviewRegionView
- type TileReviewStatusResult
- type TilesetAnimFrameView
- type TilesetEditResult
- type TilesetReadResult
- type TilesetTileView
- type Tool
- type TurnStatus
- type ViewportImage
- type YouOnlyError
Constantes
const (
// ToolAgentReportStep lets a connected agent report a live progress step in its own plain words
// along with the scene object IDs the step touches, and receive queued "Add to this request" follow-ups.
ToolAgentReportStep = "agent_report_step"
// ToolAgentTurnGet returns the latest (or named) agent turn started from the ⌘L in-place composer or Agent panel,
// with the user's prompt, skipPlan flag, selection object IDs, open scene path and YAML, and viewport PNG image.
ToolAgentTurnGet = "agent_turn_get"
// ToolAgentTurnReply records the agent's reply and status ("running", "done", "stopped") on a turn in the Agent panel.
ToolAgentTurnReply = "agent_turn_reply"
)Agent turn tool names exposed by editormcp alongside scene_read, scene_edit, selection_get, and viewport_image.
const (
// ToolCheckpointList lists persistent turn checkpoints and session history entries in the open project.
ToolCheckpointList = "checkpoint_list"
// ToolCheckpointRestore restores a persistent checkpoint back to its pre-turn files as one undoable step.
ToolCheckpointRestore = "checkpoint_restore"
)const (
// ToolCodeReviewPropose stages pending Go files (and optional companion YAML files) in the editor's file-by-file Go review without writing them to disk, and optionally runs nsgo check and nsgo test via a Go build overlay.
ToolCodeReviewPropose = "code_review_propose"
// ToolCodeReviewStatus reports the active Go code review's round, files, confirmation status, check/test outcomes, and any waiting unconfirmed Go files.
ToolCodeReviewStatus = "code_review_status"
// ToolCodeReviewRunChecks reruns nsgo check and nsgo test against the pending Go files via a Go build overlay without touching disk.
ToolCodeReviewRunChecks = "code_review_run_checks"
)const (
// ToolProjectContext returns the project's shared agent context: brief.yaml (with gaps and playtest targets) and AGENTS.md.
ToolProjectContext = "project_context"
// ToolBriefEdit validates and proposes an edit to brief.yaml as a reviewable change without modifying disk until kept.
ToolBriefEdit = "brief_edit"
// ToolRulesEdit proposes an edit or new rule for AGENTS.md as a reviewable change without modifying disk until kept.
ToolRulesEdit = "rules_edit"
)const (
// ToolCutsceneWrite validates a *.cutscene.yaml document and opens it as an interactive agent review on the cutscene timeline (or writes it directly when review is false).
ToolCutsceneWrite = "cutscene_write"
// ToolCutsceneScrub scrubs the cutscene timeline to a chosen timestamp and returns the posed camera, actors, active dialogue and review state.
ToolCutsceneScrub = "cutscene_scrub"
)The names of the cutscene timeline tools added to the editor's MCP server.
const (
// ToolDataTableReviewPropose validates proposed YAML data table changes and opens the row-by-row Data Table review without modifying disk until kept.
ToolDataTableReviewPropose = "datatable_review_propose"
// ToolDataTableReviewChecks attaches or refreshes named agent check figures on the active Data Table review.
ToolDataTableReviewChecks = "datatable_review_checks"
// ToolDataTableReviewStatus reports the active Data Table review state, per-record kept/reverted/user-edited status, and whether agent checks are out of date.
ToolDataTableReviewStatus = "datatable_review_status"
)The names of the Data Table review tools added to the editor's MCP server.
const (
// ToolObjectSetField sets a single inspector field, custom property, or component field on an object through Editor methods.
ToolObjectSetField = "object_set_field"
// ToolObjectLocateYAML locates an object's exact 1-based line in the open scene YAML and optionally opens it via Editor.OnOpenFileAtLine.
ToolObjectLocateYAML = "object_locate_yaml"
)const (
// ClaudeConfigFile is the project-relative MCP configuration file Claude Code reads.
ClaudeConfigFile = ".mcp.json"
// CodexConfigFile is the project-relative MCP configuration file Codex reads.
CodexConfigFile = ".codex/config.toml"
)const (
// ToolMergeStatus inspects the active scene merge conflict session or detects unmerged scene conflicts in Git.
ToolMergeStatus = "merge_status"
// ToolMergeResolve resolves a conflicted scene object (Mine, Theirs, Agent, custom YAML, or all Agent) or updates the agent's suggestion.
ToolMergeResolve = "merge_resolve"
// ToolMergeFinish writes the resolved scene, runs game check and a short playtest, and creates the Git merge commit.
ToolMergeFinish = "merge_finish"
// ToolMergeAbort aborts the active Git merge and restores the branch as it was.
ToolMergeAbort = "merge_abort"
)const (
// ToolObjectCopyYAML serializes an object as canonical sceneformat YAML and copies it to the clipboard.
ToolObjectCopyYAML = "object_copy_yaml"
// ToolObjectPasteYAML pastes canonical sceneformat object YAML into the open scene in one undo step.
ToolObjectPasteYAML = "object_paste_yaml"
// ToolObjectDuplicate clones an object with fresh unique IDs in one undo step.
ToolObjectDuplicate = "object_duplicate"
// ToolObjectGroup wraps one or more objects under a new parent group object in one undo step.
ToolObjectGroup = "object_group"
// ToolObjectMoveUnder reparents an object under another object (or lists valid candidate parents) in one undo step.
ToolObjectMoveUnder = "object_move_under"
// ToolObjectSelectSamePrefab selects every object in the open scene sharing the same prefab or instanced scene.
ToolObjectSelectSamePrefab = "object_select_same_prefab"
// ToolObjectVisibility sets an object's session-only hidden and/or locked state in the viewports.
ToolObjectVisibility = "object_visibility"
// ToolObjectFindUsages finds references or project search matches for an object across the open project.
ToolObjectFindUsages = "object_find_usages"
)Object context-menu tool names exposed alongside scene_edit and selection_get.
const (
// ToolPlanPropose proposes a structured multi-step plan with clarifying questions, editable step parameters,
// planned viewport ghosts, and planned Scene Tree nodes before any file or scene is modified, and waits for
// the person's decision (approved with answers and edited steps, or stopped).
ToolPlanPropose = "plan_propose"
// ToolPlanStepUpdate updates a running plan step's status (running, done, failed, skipped) and optionally
// completes the plan so the turn's review lists each plan step and marks which were done.
ToolPlanStepUpdate = "plan_step_update"
)Plan tool names exposed by editormcp for proposing a plan before edits and tracking step completion.
const (
// ToolPlayFrozenContext returns the frozen Play frame image, prompt, rolling/saved replay YAML, live entities, marks, and panic report.
ToolPlayFrozenContext = "play_frozen_context"
// ToolPlayReplayStep steps the Play mode replay across frames A..B while keeping the game paused and updating the viewport agent pill and step log.
ToolPlayReplayStep = "play_replay_step"
)const (
// ToolGamePlaytest runs headless bot playtests configured by playtest.yaml with replay recordings and returns the evaluated YAML report.
ToolGamePlaytest = "game_playtest"
// ToolPlaytestDefine proposes adding or updating a metric in playtest.yaml, returning a diff that arrives as a review rather than overwriting the file directly.
ToolPlaytestDefine = "playtest_define"
// ToolPlaytestReport opens, inspects or updates the editor's Playtest Report screen (loading a report file, updating the agent's read and suggestions, or watching a run's recording).
ToolPlaytestReport = "playtest_report"
)const (
// ToolRefsFind finds every usage of a prefab, scene, or project file across scenes, prefab variants, data tables, and Go source code.
ToolRefsFind = "refs_find"
// ToolRefactorRename previews a safe YAML-only rename in the editor's References review screen (with exact line diffs and non-rewritten Go warnings), or applies it as one undo step when apply is true.
ToolRefactorRename = "refactor_rename"
)const (
// ToolReleaseNotesDraft drafts player-facing Markdown release notes from commits and kept reviews
// and writes them to the exact file `game release -release-notes` reads.
ToolReleaseNotesDraft = "release_notes_draft"
// ToolReleaseReviewUploads stages the Review uploads confirmation dialog for the person.
// Store uploads ALWAYS ask first in Review uploads, whatever the permission profile.
ToolReleaseReviewUploads = "release_review_uploads"
)const (
// ToolReviewStatus reads the active or most recent agent turn review's seen, reverted, conflict, and hand-edited YAML state.
ToolReviewStatus = "review_status"
// ToolReviewNotesGet reads the active review's round state, changes, and sent notes waiting for the agent.
ToolReviewNotesGet = "review_notes_get"
// ToolReviewRedo redoes only changes that were noted by the author, advancing the review to the next round.
ToolReviewRedo = "review_redo"
)const (
// ToolSketchRead reads the active/sent viewport sketch marks in scene coordinates and optional PNG image.
ToolSketchRead = "sketch_read"
// ToolSketchReading posts the agent's restatement of the user's sketch marks and assumptions before editing.
ToolSketchReading = "sketch_reading"
)The names of the viewport sketch tools added to the editor's MCP server.
const (
// ToolStatesWrite validates and writes a *.states.yaml file in the open project and opens it in the editor.
ToolStatesWrite = "states_write"
// ToolStatesTest plays scripted input against a *.states.yaml file and reports the state trace and any stuck states.
ToolStatesTest = "states_test"
)The names of the sprite state machine tools added to the editor's MCP server.
const (
// SceneURI is the scene open in the editor as YAML, with every edit not yet saved.
SceneURI = "editor://scene"
// SelectionURI is what the person has selected, as selection_get reports it, in JSON.
SelectionURI = "editor://selection"
// AgentTurnURI is the latest agent turn submitted from the ⌘L in-place composer or Agent panel,
// including selection object IDs, open scene YAML, skipPlan flag, and the captured viewport PNG.
AgentTurnURI = "editor://agent/turn"
// BriefURI is the open project's brief.yaml as canonical YAML (empty when absent).
BriefURI = "editor://brief"
// RulesURI is the open project's AGENTS.md as plain Markdown (empty when absent).
RulesURI = "editor://rules"
// ContextURI is the combined JSON context payload (brief.yaml, AGENTS.md, gaps, playtest targets, and pending reviews) the agent reads before every request.
ContextURI = "editor://context"
)The resources of the editor's server, which a client reads and subscribes to for the change stream and shared project context.
const (
// MetaBy says who made the change a notice reports: "agent" when it came from a tool call, "person" when it came from the editor's own controls.
MetaBy = "nsgo.dev/by"
// MetaRevision is the editor's revision (editor.Editor.Revision) after the change.
MetaRevision = "nsgo.dev/revision"
// MetaTurnID names the agent turn carried by an editor://agent/turn notification.
MetaTurnID = "nsgo.dev/turnId"
// MetaSkipPlan reports whether the notified agent turn is a small in-place ⌘L request that skips the plan.
MetaSkipPlan = "nsgo.dev/skipPlan"
)The keys of a resource notice's _meta.
const (
// ToolTasksList lists all background agent tasks, active object holds, and summary badge counts.
ToolTasksList = "tasks_list"
// ToolTasksSubmit queues or runs a background agent request in parallel.
ToolTasksSubmit = "tasks_submit"
// ToolTasksControl controls background tasks (keep, revert, dismiss, stop, retry, open, focus, allow, deny).
ToolTasksControl = "tasks_control"
)const (
// ToolTileQuery queries cells and connected regions/pockets on an inline tilemap layer.
ToolTileQuery = "tile_query"
// ToolTilePaint paints explicit cells, rectangles, or weighted random picks on a tile layer.
ToolTilePaint = "tile_paint"
// ToolTileAutotile re-edges (or places and re-edges) a region using a YAML tileset terrain set.
ToolTileAutotile = "tile_autotile"
// ToolTileErase clears explicit cells or rectangles on a tile layer.
ToolTileErase = "tile_erase"
// ToolTileReviewStatus inspects the active region-based tile edit review (and optionally toggles Before/After or focuses a region).
ToolTileReviewStatus = "tile_review_status"
// ToolTileReviewRevertRegion marks one pending tile review region reverted.
ToolTileReviewRevertRegion = "tile_review_revert_region"
// ToolTileReviewRestoreRegion restores a reverted tile review region.
ToolTileReviewRestoreRegion = "tile_review_restore_region"
// ToolTileReviewKeep commits all kept tile review regions cleanly as one undoable edit.
ToolTileReviewKeep = "tile_review_keep"
// ToolTileReviewRevertAll reverts all pending tile review changes and closes the review.
ToolTileReviewRevertAll = "tile_review_revert_all"
)The names of the tile and tile-review tools added to the editor's MCP server.
const (
// ToolTilesetRead reads a *.tileset.yaml tileset document (or the tileset open in the editor) with its tile collision, animation, terrain, variant weight, and custom data fields.
ToolTilesetRead = "tileset_read"
// ToolTilesetEdit edits a *.tileset.yaml tileset through the editor's undoable tileset commands (flags, collision shapes, animation, custom data, name, weight, and terrain rules).
ToolTilesetEdit = "tileset_edit"
)The names of the tileset tools added to the editor's MCP server.
const (
// ToolSceneRead reads a scene, prefab, data or project file with line numbers.
ToolSceneRead = "scene_read"
// ToolSceneEdit adds, moves, changes and removes objects, components and properties of the open scene.
ToolSceneEdit = "scene_edit"
// ToolSelectionGet reports what the person has selected.
ToolSelectionGet = "selection_get"
// ToolViewportImage returns a PNG of the viewport.
ToolViewportImage = "viewport_image"
// ToolGameCheck runs the Problems panel's checks over the project.
ToolGameCheck = "game_check"
)The names of the tools this package adds, as the editor's Settings › Tools page lists them.
const (
// ToolTurnStart opens a new agent turn that groups subsequent MCP edits across files into one reviewable step.
ToolTurnStart = "turn_start"
// ToolTurnEnd finishes the working agent turn so the person can review, revert individual changes, Keep, or Revert.
ToolTurnEnd = "turn_end"
// ToolTurnStatus reads the current agent turn's derived changes and which changes the person reverted.
ToolTurnStatus = "turn_status"
// ToolFileEdit validates and edits a project YAML file (game.yaml, data table, clip, prefab, or scene) in memory without writing to disk.
ToolFileEdit = "file_edit"
)Tool names for agent turns and multi-file YAML editing. Note: there is intentionally no MCP tool that keeps or reverts a turn; that remains the person's decision.
const (
// ToolPermissionsDraft submits a You-only permissions draft card for the person to review and tick rule by rule.
// It never modifies permissions.yaml or active rules on its own.
ToolPermissionsDraft = "permissions_draft"
// ToolGameDeleteFile proposes deleting a project file in the Review changes panel with its line count and scene usages.
// It never deletes the file directly on disk, refuses You-only files, and Keep all never applies the deletion without per-file confirmation.
ToolGameDeleteFile = "game_delete_file"
)const EndpointDirEnv = "NSGO_GAME_EDITOR_ENDPOINTS"EndpointDirEnv names the environment variable that, when set, holds the directory the editors' endpoints live in instead of the user's cache directory, as a test or a sandboxed agent sets it for both the editor and go tool game mcp.
const ServerName = "nsgo-game-editor"ServerName is the name the editor's server gives clients when they connect.
const ToolHistoryList = "history_list"ToolHistoryList is the MCP tool name exposing recent History timeline entries to connected agents.
const ToolProblemProposeFix = "problem_propose_fix"ToolProblemProposeFix stages an agent-proposed fix for a live problem in the editor's Agent card without ever applying it or mutating any scene or file.
Variables
var (
// ErrNoEditor reports that no editor has the project open: its endpoint does not exist or nothing answers on it.
ErrNoEditor = errors.New("editormcp: no editor has the project open")
// ErrInUse reports that another editor already serves the project's endpoint.
ErrInUse = errors.New("editormcp: another editor already serves the project")
)Funciones
func Dial(ctx context.Context, root string) (net.Conn, error)Dial connects to the editor that has the project at root open. It returns an error wrapping ErrNoEditor, which says how to open the project, when none does.
func Endpoint(root string) (string, error)Endpoint returns the path of the local socket the editor with the project at root open serves on: a file named after a hash of the project's absolute path in the endpoint directory, which is $NSGO_GAME_EDITOR_ENDPOINTS when set (EndpointDirEnv) and otherwise nsgo-game/editor in the user's cache directory. root should come from ProjectRoot, so that every spelling of the project's path names the same endpoint. The endpoint is a Unix domain socket, which macOS, Linux and Windows 10 and later all have; it is never a network port.
func InstallCommand() (string, []string)InstallCommand returns the command and arguments an external MCP client runs in the project root to connect to the open editor.
func Installed(root string) boolInstalled reports whether both Claude Code and Codex project MCP configurations exist in root and reference ServerName.
func Listen(root string) (net.Listener, error)Listen opens the endpoint for the project at root, which only this user can connect to: its directory is created private to the user. When the endpoint is left over from an editor that quit without closing it, Listen replaces it; when another editor answers on it, Listen returns ErrInUse.
func ProjectRoot(path string) (string, error)ProjectRoot returns the absolute, symlink-free directory of the project at path: a game.yaml, the directory holding one, or any directory below that one, as an agent started in a subdirectory of the project names it. It returns an error naming path when no game.yaml is found on the way up.
Tipos
type Action stringAction is what a tool does to the project, which the editor's permission rules decide on: reading changes nothing, editing changes files the person can review and undo, and running starts work such as a check or a playtest.
const (
// ActionRead reads the project or the editor's state and changes nothing.
ActionRead Action = "read"
// ActionEdit changes the open project through editor commands.
ActionEdit Action = "edit"
// ActionCreate creates new files in the open project.
ActionCreate Action = "create"
// ActionDelete deletes files from the open project.
ActionDelete Action = "delete"
// ActionRun runs work over the project, such as game check, playtests, or shell commands.
ActionRun Action = "run"
// ActionCode changes Go source files in the open project.
ActionCode Action = "code"
)The actions a tool takes.
func (a Action) Valid() boolValid reports whether a is one of the recognized tool actions.
type AgentReportStepResult struct {
StepID string `json:"stepId"`
Text string `json:"text"`
Objects []string `json:"objects,omitempty"`
Status string `json:"status"`
FollowUps []string `json:"followUps,omitempty"`
}AgentReportStepResult is the structured payload returned by agent_report_step.
type AgentTurnPayload struct {
ID string `json:"id"`
Prompt string `json:"prompt"`
Source string `json:"source"`
SkipPlan bool `json:"skipPlan"`
Status string `json:"status"`
ScenePath string `json:"scenePath,omitempty"`
SceneName string `json:"sceneName,omitempty"`
SceneYAML string `json:"sceneYaml,omitempty"`
SelectionIDs []string `json:"selectionIds,omitempty"`
SelectionNames []string `json:"selectionNames,omitempty"`
Layer string `json:"layer,omitempty"`
ViewportWidth int `json:"viewportWidth,omitempty"`
ViewportHeight int `json:"viewportHeight,omitempty"`
ViewMode string `json:"viewMode,omitempty"`
HasViewportImage bool `json:"hasViewportImage"`
Reply string `json:"reply,omitempty"`
}AgentTurnPayload is the structured representation of an editor.AgentTurn returned by agent_turn_get and the editor://agent/turn resource.
type AutomationResult struct {
// Text is the tool's text for the agent.
Text string `json:"text,omitempty"`
// Structured is the tool's structured result, or absent.
Structured any `json:"structured,omitempty"`
// PNGBase64 is the tool's PNG in base64, or empty.
PNGBase64 string `json:"pngBase64,omitempty"`
// SaveWarning is set while the editor's automatic saving is failing, so the agent does not build on edits not on disk.
SaveWarning *SaveWarning `json:"saveWarning,omitempty"`
}AutomationResult is what a tool registered by RegisterAutomation returns to nsgo mcp: app tools return JSON, so a PNG comes as base64 text (nsgo-dev/nsgo#2343).
type BriefContext struct {
Exists bool `json:"exists"`
File string `json:"file"`
YAML string `json:"yaml,omitempty"`
Parsed *project.Brief `json:"parsed,omitempty"`
Gaps []project.BriefSection `json:"gaps,omitempty"`
PlaytestTargets []project.BriefPlaytestTarget `json:"playtestTargets,omitempty"`
Error string `json:"error,omitempty"`
}BriefContext is the brief.yaml section of ProjectContext.
type Call struct {
// Args is the call's JSON object of arguments.
Args json.RawMessage
// contains filtered or unexported fields
}Call is one call of a tool: its arguments and the server it runs on.
func (c *Call) Decode(v any) errorDecode decodes the call's arguments into v, refusing a field v does not have, so a misspelled argument is an error the agent reads rather than one silently dropped.
func (c *Call) Editor(ctx context.Context, fn func(ed *editor.Editor) error) errorEditor runs fn on the editor's goroutine and returns its error; see Server.Editor.
type Check struct {
// Problems are the visible problems the Problems panel lists, sorted by file, line, column and message.
Problems []Problem `json:"problems"`
// Unsaved names the open scene when the editor holds edits to it not yet saved on disk (which game_check checked live).
Unsaved string `json:"unsaved,omitempty"`
}Check is what game_check reports.
type CheckpointListItem struct {
ID string `json:"id"`
CheckpointID string `json:"checkpointId,omitempty"`
Time string `json:"time,omitempty"`
Who string `json:"who"`
Kind string `json:"kind,omitempty"`
Title string `json:"title"`
Detail string `json:"detail,omitempty"`
Files []string `json:"files,omitempty"`
Persistent bool `json:"persistent"`
Restorable bool `json:"restorable"`
}CheckpointListItem is one entry returned by checkpoint_list.
type CheckpointListResult struct {
Filter string `json:"filter"`
Total int `json:"total"`
Entries []CheckpointListItem `json:"entries"`
}CheckpointListResult is the structured payload returned by checkpoint_list.
type CheckpointRestoreResult struct {
ID string `json:"id"`
Title string `json:"title"`
Files []string `json:"files,omitempty"`
Revision uint64 `json:"revision"`
}CheckpointRestoreResult is the structured payload returned by checkpoint_restore.
type CodeReviewChecksSummary struct {
Phase string `json:"phase"`
CheckPassed bool `json:"checkPassed"`
CheckError string `json:"checkError,omitempty"`
TestPassed bool `json:"testPassed"`
PassedCount int `json:"passedCount"`
FailedCount int `json:"failedCount"`
TotalCount int `json:"totalCount"`
DurationMs int64 `json:"durationMs,omitempty"`
Packages []string `json:"packages,omitempty"`
Failures []editor.CodeReviewTestFailure `json:"failures,omitempty"`
}CodeReviewChecksSummary is the structured check/test status returned by code_review_* tools.
type CodeReviewFileSummary struct {
Path string `json:"path"`
Kind string `json:"kind"`
AddedLines int `json:"addedLines"`
RemovedLines int `json:"removedLines"`
Confirmed bool `json:"confirmed"`
Applied bool `json:"applied"`
EditedInRound int `json:"editedInRound"`
}CodeReviewFileSummary is one file entry in CodeReviewStatusResult.
type CodeReviewStatusResult struct {
Active bool `json:"active"`
Open bool `json:"open"`
Paused bool `json:"paused"`
KeptYAML bool `json:"keptYaml"`
FixRequested bool `json:"fixRequested"`
TurnID string `json:"turnId,omitempty"`
Prompt string `json:"prompt,omitempty"`
Round int `json:"round,omitempty"`
RoundSummary string `json:"roundSummary,omitempty"`
SelectedPath string `json:"selectedPath,omitempty"`
Layout string `json:"layout,omitempty"`
Files []CodeReviewFileSummary `json:"files,omitempty"`
WaitingGoFiles []string `json:"waitingGoFiles,omitempty"`
Checks CodeReviewChecksSummary `json:"checks"`
}CodeReviewStatusResult is the structured result returned by code_review_propose, code_review_status, and code_review_run_checks.
type CutsceneActorPose struct {
ID string `json:"id"`
X float32 `json:"x"`
Y float32 `json:"y"`
State string `json:"state,omitempty"`
}CutsceneActorPose is one actor's posed coordinates and active state returned by cutscene_scrub.
type CutsceneCameraPose struct {
Label string `json:"label"`
X float32 `json:"x"`
Y float32 `json:"y"`
Zoom float32 `json:"zoom"`
}CutsceneCameraPose is the posed camera state returned by cutscene_scrub.
type CutsceneChangeSummary struct {
ID string `json:"id"`
Sign string `json:"sign"`
Title string `json:"title"`
Detail string `json:"detail"`
Reverted bool `json:"reverted,omitempty"`
}CutsceneChangeSummary summarizes one change inside a pending cutscene review.
type CutsceneDialoguePose struct {
Active bool `json:"active"`
ID string `json:"id,omitempty"`
Speaker string `json:"speaker,omitempty"`
Text string `json:"text,omitempty"`
}CutsceneDialoguePose is the active dialogue subtitle returned by cutscene_scrub.
type CutsceneScrubResult struct {
File string `json:"file,omitempty"`
TimeSeconds float64 `json:"timeSeconds"`
LengthSeconds float64 `json:"lengthSeconds"`
Camera CutsceneCameraPose `json:"camera"`
Actors []CutsceneActorPose `json:"actors,omitempty"`
Dialogue CutsceneDialoguePose `json:"dialogue"`
ReviewOpen bool `json:"reviewOpen,omitempty"`
ShowingBefore bool `json:"showingBefore,omitempty"`
KeptChanges int `json:"keptChanges,omitempty"`
TotalChanges int `json:"totalChanges,omitempty"`
}CutsceneScrubResult is what cutscene_scrub reports.
type CutsceneWriteResult struct {
File string `json:"file"`
Status string `json:"status"` // "pending_review" or "written"
Kind string `json:"kind"`
Length float64 `json:"lengthSeconds,omitempty"`
Tracks int `json:"tracks"`
Opened bool `json:"opened"`
Changes []CutsceneChangeSummary `json:"changes,omitempty"`
}CutsceneWriteResult is what cutscene_write reports.
type DataTableReviewRecordStatus struct {
Key string `json:"key"`
DisplayName string `json:"displayName,omitempty"`
Changed bool `json:"changed,omitempty"`
Reverted bool `json:"reverted,omitempty"`
UserEdited bool `json:"userEdited,omitempty"`
UserReordered bool `json:"userReordered,omitempty"`
}DataTableReviewRecordStatus summarizes one changed, reverted, or user-edited record for MCP callers.
type DataTableReviewStatusResult struct {
editor.DataTableReviewSnapshot
ActiveRecords []DataTableReviewRecordStatus `json:"activeRecords,omitempty"`
}DataTableReviewStatusResult is returned by datatable_review_propose, datatable_review_checks, and datatable_review_status.
type DocEditResult struct {
Status string `json:"status"`
Review editor.DocReview `json:"review"`
}DocEditResult is returned by brief_edit and rules_edit when queuing a reviewable change.
type EditError struct {
// File is the scene the call edits, by its path from the project root.
File string `json:"file"`
// Edit is the 1-based index of the refused edit among the call's edits, or 0 for the call as a whole.
Edit int `json:"edit,omitempty"`
// Op is the refused edit's op.
Op string `json:"op,omitempty"`
// Object is the ID of the object the edit names, or empty.
Object string `json:"object,omitempty"`
// Component is the component the edit names, or empty.
Component string `json:"component,omitempty"`
// Field is the field or property the editor refused, or empty.
Field string `json:"field,omitempty"`
// Problem says what is wrong.
Problem string `json:"problem"`
// Fix says what to change for the edit to apply.
Fix string `json:"fix"`
}EditError is a scene_edit the editor refused. Nothing of the call applied: the open scene, its undo history and its file on disk are as they were.
func (e *EditError) Error() stringError formats e as "scene_edit: file: edit N (op) on object "id" component "c" field "f": problem; fix. Nothing was changed."
type EditResult struct {
// File is the scene edited.
File string `json:"file"`
// Undo is the undo step's label, which one Undo takes back.
Undo string `json:"undo"`
// Objects are the IDs of the objects the edits added, in order.
Objects []string `json:"added,omitempty"`
// Revision is the editor's revision after the edits.
Revision uint64 `json:"revision"`
}EditResult is what scene_edit reports once its edits applied.
type FileEditResult struct {
File string `json:"file"`
InTurn bool `json:"inTurn"`
Revision uint64 `json:"revision"`
}FileEditResult is returned by file_edit after applying a validated in-memory edit.
type FileText struct {
// File is the file's slash-separated path from the project root, or the open scene's name when it has no file.
File string `json:"file"`
// Source is "editor" when the text is what the editor holds, with its unsaved edits, and "disk" when it is the file on disk, as it is whenever the editor holds no unsaved edits to it.
Source string `json:"source"`
// Unsaved reports that the editor holds edits to the file that are not saved.
Unsaved bool `json:"unsaved"`
// Lines is how many lines the file has.
Lines int `json:"lines"`
// From and To are the first and last line returned, 1-based; both are 0 for an empty file.
From int `json:"from"`
To int `json:"to"`
// contains filtered or unexported fields
}FileText is a file scene_read read.
type GameDeleteFileResult struct {
Status string `json:"status"`
File string `json:"file"`
LineCount int `json:"lineCount"`
UsedByAnyScene bool `json:"usedByAnyScene"`
SceneUsages []string `json:"sceneUsages,omitempty"`
UsageSummary string `json:"usageSummary"`
ToolEnabled bool `json:"toolEnabled"`
DeletedOnDisk bool `json:"deletedOnDisk"`
}GameDeleteFileResult is the structured result returned by game_delete_file.
type HistoryEntryView struct {
ID uint64 `json:"id"`
Kind string `json:"kind"`
Author string `json:"author,omitempty"`
AuthorLabel string `json:"authorLabel,omitempty"`
Summary string `json:"summary"`
Detail string `json:"detail,omitempty"`
Files []string `json:"files,omitempty"`
Timestamp string `json:"timestamp"`
RelativeTime string `json:"relativeTime"`
ChangeCount int `json:"changeCount,omitempty"`
KeptCount int `json:"keptCount,omitempty"`
Undone bool `json:"undone,omitempty"`
CheckpointID string `json:"checkpointId,omitempty"`
Persistent bool `json:"persistent,omitempty"`
}HistoryEntryView is one entry returned by history_list.
type HistoryListResult struct {
Scene string `json:"scene"`
Unsaved bool `json:"unsaved"`
PreviewingID uint64 `json:"previewingId,omitempty"`
UndoIndex int `json:"undoIndex"`
Total int `json:"total"`
Entries []HistoryEntryView `json:"entries"`
}HistoryListResult is the structured payload returned by history_list.
type InstallFile struct {
// Client names the external agent that reads this file ("Claude Code" or "Codex").
Client string
// Path is the absolute path on disk.
Path string
// RelPath is the slash-separated path relative to the project root.
RelPath string
// Changed reports whether Install wrote new bytes (false when the file was already identical).
Changed bool
}InstallFile describes one project-level MCP configuration file written or verified by Install.
type InstallResult struct {
Root string
Files []InstallFile
}InstallResult summarizes the files created or updated by Install.
func Install(path string) (*InstallResult, error)Install writes the project-level MCP configuration files that Claude Code (.mcp.json) and Codex (.codex/config.toml) read so they find the editor's MCP server automatically. Existing unrelated MCP servers or settings in either file are preserved, and running Install twice produces byte-for-byte identical files.
func InstallWithServers(path string, extra []editor.AgentMCPServer, removed ...string) (*InstallResult, error)InstallWithServers writes the editor's MCP server plus any enabled external MCP servers from Settings › Tools into Claude Code (.mcp.json) and Codex (.codex/config.toml), removing disabled or removed managed server entries while preserving unrelated servers and comments.
type MergeStatusResult struct {
Open bool `json:"open"`
ScenePath string `json:"scenePath,omitempty"`
Mine editor.MergeSideMeta `json:"mine,omitempty"`
Theirs editor.MergeSideMeta `json:"theirs,omitempty"`
FocusedID string `json:"focusedId,omitempty"`
ResolvedCount int `json:"resolvedCount"`
TotalConflicts int `json:"totalConflicts"`
Finished bool `json:"finished,omitempty"`
CommitSHA string `json:"commitSha,omitempty"`
VerifySummary string `json:"verifySummary,omitempty"`
VerifyErr string `json:"verifyErr,omitempty"`
DetectedScenes []string `json:"detectedScenes,omitempty"`
Conflicts []editor.MergeConflictItem `json:"conflicts,omitempty"`
AutoMerged []editor.MergeAutoItem `json:"autoMerged,omitempty"`
}MergeStatusResult is the structured payload returned by merge_status, merge_resolve, and merge_finish.
type ObjectCopyYAMLResult struct {
ID string `json:"id"`
YAML string `json:"yaml"`
Lines int `json:"lines"`
Toast string `json:"toast"`
}ObjectCopyYAMLResult is returned by object_copy_yaml.
type ObjectDuplicateResult struct {
SourceID string `json:"sourceId"`
ID string `json:"id"`
Revision uint64 `json:"revision"`
}ObjectDuplicateResult is returned by object_duplicate.
type ObjectFieldResult struct {
File string `json:"file"`
Object string `json:"object"`
Component string `json:"component,omitempty"`
Property bool `json:"property,omitempty"`
Field string `json:"field"`
Undo string `json:"undo,omitempty"`
Revision uint64 `json:"revision"`
}ObjectFieldResult is returned by object_set_field.
type ObjectGroupResult struct {
GroupID string `json:"groupId"`
Children []string `json:"children"`
Revision uint64 `json:"revision"`
}ObjectGroupResult is returned by object_group.
type ObjectMoveUnderResult struct {
ID string `json:"id"`
Parent string `json:"parent,omitempty"`
Candidates []editor.MoveUnderCandidate `json:"candidates,omitempty"`
Undo string `json:"undo,omitempty"`
Revision uint64 `json:"revision"`
}ObjectMoveUnderResult is returned by object_move_under.
type ObjectPasteYAMLResult struct {
ID string `json:"id"`
Revision uint64 `json:"revision"`
}ObjectPasteYAMLResult is returned by object_paste_yaml.
type ObjectSelectSamePrefabResult struct {
SelectedIDs []string `json:"selectedIds"`
Count int `json:"count"`
}ObjectSelectSamePrefabResult is returned by object_select_same_prefab.
type ObjectVisibilityResult struct {
ID string `json:"id"`
Hidden bool `json:"hidden"`
Locked bool `json:"locked"`
}ObjectVisibilityResult is returned by object_visibility.
type ObjectYAMLLocation struct {
File string `json:"file"`
Object string `json:"object,omitempty"`
Line int `json:"line"`
Opened bool `json:"opened,omitempty"`
YAML string `json:"yaml,omitempty"`
}ObjectYAMLLocation is returned by object_locate_yaml.
type Options struct {
// Run hands fn to the editor's goroutine and returns at once, as core.Scope.Post does for an editor shown in a window; the server waits for fn to run. When nil, the server runs fn on the calling goroutine, one at a time, for an editor no UI drives, as in a test or a script.
Run func(fn func())
// RunPlaytest optionally overrides how game_playtest executes a playtest request, for tests or in-process runners. When nil, game_playtest runs `go tool nsgo test` in the project root.
RunPlaytest func(ctx context.Context, req PlaytestRunRequest) (*playtest.Report, error)
// OnPermissionAsk is invoked when a tool call matches an Ask rule. When nil (or returning PermissionAnswerPending), the server queues the pending request on the Editor and returns a *PermissionError with Decision == editor.PermissionAsk without invoking the tool handler.
OnPermissionAsk func(ctx context.Context, eval editor.PermissionEvaluation) (PermissionPromptAnswer, error)
// OnPermissionDecision, when non-nil, is called with every permission evaluation produced for a mutating or running tool call (Allow, Ask, or Deny).
OnPermissionDecision func(eval editor.PermissionEvaluation)
}Options configure a Server.
type PermissionDeniedResult struct {
Denied bool `json:"denied"`
AlreadyDenied bool `json:"alreadyDenied,omitempty"`
BlockedByRule bool `json:"blockedByRule,omitempty"`
ContinuedWithoutIt bool `json:"continuedWithoutIt,omitempty"`
Rule string `json:"rule,omitempty"`
Message string `json:"message"`
}PermissionDeniedResult is returned as non-fatal structured content when a tool call is denied by the person on an interactive Agent panel permission card so the agent continues without retrying it.
type PermissionError struct {
// Tool is the MCP tool name that was checked.
Tool string `json:"tool"`
// Action is the evaluated permission action ("edit", "create", "delete", "run", or "code").
Action editor.PermissionAction `json:"action"`
// Target is the evaluated project-relative file path or run target.
Target string `json:"target,omitempty"`
// Decision is editor.PermissionDeny or editor.PermissionAsk.
Decision editor.PermissionDecision `json:"decision"`
// Profile is the active base profile ("cautious", "balanced", or "autonomous").
Profile editor.PermissionProfile `json:"profile"`
// Modified reports whether the active rules differ from the profile preset.
Modified bool `json:"modified,omitempty"`
// RuleIndex is the 0-based index of the first matching rule, or -1 when the profile default decided.
RuleIndex int `json:"ruleIndex"`
// RuleNumber is the 1-based rule number (RuleIndex + 1), or 0 when the profile default decided.
RuleNumber int `json:"ruleNumber,omitempty"`
// RuleTotal is the total number of rules in the active table.
RuleTotal int `json:"ruleTotal,omitempty"`
// Rule is a copy of the matched rule, or nil when the profile default decided.
Rule *editor.PermissionRule `json:"rule,omitempty"`
// Reason is a clear, agent-readable explanation naming the rule and profile.
Reason string `json:"reason"`
// Link is the Settings › Permissions location of the matching rule, such as "Settings › Permissions · rule 7 of 7".
Link string `json:"link"`
// HeldByDisk reports that an external permissions.yaml loosening was held until confirmed in Settings › Permissions.
HeldByDisk bool `json:"heldByDisk,omitempty"`
// RequestID identifies the pending Ask request queued on the editor, when Decision == editor.PermissionAsk.
RequestID string `json:"requestId,omitempty"`
}PermissionError is returned when the editor's MCP permission rules block a tool call (Deny) or pause it awaiting the person's approval (Ask). The underlying tool handler never runs when a PermissionError is returned.
func (e *PermissionError) Error() stringtype PermissionPromptAnswer intPermissionPromptAnswer is the person's response when an MCP tool call matches an Ask permission rule.
const (
// PermissionAnswerPending leaves the request pending without running the tool, returning a *PermissionError with Decision == editor.PermissionAsk.
PermissionAnswerPending PermissionPromptAnswer = iota
// PermissionAnswerAllowOnce allows this single tool call without changing permissions.yaml.
PermissionAnswerAllowOnce
// PermissionAnswerAllowAlways inserts and saves an Allow rule in permissions.yaml, shows the "Always permission rule saved" toast with Show and Undo, and runs the tool.
PermissionAnswerAllowAlways
// PermissionAnswerDeny refuses this tool call without changing permissions.yaml.
PermissionAnswerDeny
)type PermissionsDraftResult struct {
Status string `json:"status"`
DraftID string `json:"draftId"`
Domain editor.YouOnlyDomain `json:"domain"`
RuleCount int `json:"ruleCount"`
TickedCount int `json:"tickedCount"`
Draft *editor.PermissionsDraft `json:"draft"`
}PermissionsDraftResult is the structured result returned by permissions_draft.
type PlanStepUpdatePayload struct {
PlanID string `json:"planId,omitempty"`
Phase editor.PlanPhase `json:"phase"`
Stopped bool `json:"stopped"`
ActiveStep int `json:"activeStep,omitempty"`
DoneSteps int `json:"doneSteps"`
TotalSteps int `json:"totalSteps"`
}PlanStepUpdatePayload is the structured response returned by plan_step_update.
type PlayFrozenContextResult struct {
Playing bool `json:"playing"`
Paused bool `json:"paused"`
Frame int `json:"frame"`
Seconds float64 `json:"seconds"`
Scene string `json:"scene,omitempty"`
Prompt string `json:"prompt,omitempty"`
ReplayPath string `json:"replayPath,omitempty"`
ReplayFrames int `json:"replayFrames"`
WindowStartFrame int `json:"windowStartFrame,omitempty"`
ReplayYAML string `json:"replayYaml,omitempty"`
SelectedID string `json:"selectedId,omitempty"`
LiveEntities []editor.PlayLiveEntityState `json:"liveEntities,omitempty"`
LiveChanges []editor.RemoteLiveChange `json:"liveChanges,omitempty"`
Marks []editor.PlayMark `json:"marks,omitempty"`
LastMarksThread *editor.PlayMarksThread `json:"lastMarksThread,omitempty"`
Panic *editor.PanicReport `json:"panic,omitempty"`
AgentPill string `json:"agentPill,omitempty"`
AgentSteps []editor.PlayAgentStep `json:"agentSteps,omitempty"`
}PlayFrozenContextResult is the structured payload returned by play_frozen_context.
type PlayReplayStepResult struct {
FromFrame int `json:"fromFrame"`
ToFrame int `json:"toFrame"`
CurrentFrame int `json:"currentFrame"`
Paused bool `json:"paused"`
Pill string `json:"pill"`
AgentSteps []editor.PlayAgentStep `json:"agentSteps,omitempty"`
LiveEntities []editor.PlayLiveEntityState `json:"liveEntities,omitempty"`
}PlayReplayStepResult is the structured payload returned by play_replay_step.
type PlaytestDefineResult struct {
// Status is "pending_review", confirming playtest.yaml on disk was not modified yet.
Status string `json:"status"`
// Review holds the proposed playtest.yaml change and its diff.
Review PlaytestReview `json:"review"`
}PlaytestDefineResult is what playtest_define returns beside its text summary.
type PlaytestReportStatusResult struct {
Open bool `json:"open"`
ReportPath string `json:"reportPath,omitempty"`
Scope string `json:"scope,omitempty"`
Project string `json:"project,omitempty"`
ChartKind string `json:"chartKind,omitempty"`
Passed bool `json:"passed"`
MissedCount int `json:"missedCount"`
WatchRunIndex int `json:"watchRunIndex,omitempty"`
PendingProposals int `json:"pendingProposals"`
Read string `json:"read,omitempty"`
Suggestions []string `json:"suggestions,omitempty"`
}PlaytestReportStatusResult is the structured payload returned by playtest_report.
type PlaytestReview struct {
// ID uniquely identifies this pending review on the server (e.g. "playtest-review-1").
ID string `json:"id"`
// File is the slash-separated path to playtest.yaml from the project root.
File string `json:"file"`
// Metric is the proposed playtest metric definition.
Metric playtest.Metric `json:"metric"`
// Rationale explains why the agent proposed this metric (for example, which goal in brief.yaml motivated it).
Rationale string `json:"rationale,omitempty"`
// Replace reports whether the proposal updates an existing metric with the same name instead of appending a new one.
Replace bool `json:"replace,omitempty"`
// Before is the text of playtest.yaml on disk when the proposal was created.
Before string `json:"before"`
// After is the canonical YAML text of playtest.yaml if the proposal is accepted.
After string `json:"after"`
// Diff is a unified line diff between Before and After.
Diff string `json:"diff"`
// Status is "pending", "applied", or "dismissed".
Status string `json:"status"`
}PlaytestReview is a proposed edit to playtest.yaml created by playtest_define awaiting a person's review.
type PlaytestRunRequest struct {
// ProjectRoot is the absolute directory of the open project.
ProjectRoot string
// ConfigFile is the slash-separated path to playtest.yaml relative to ProjectRoot.
ConfigFile string
// ConfigPath is the absolute path to playtest.yaml.
ConfigPath string
// Config is the validated playtest configuration with any count/seeds overrides applied.
Config *playtest.Config
// OutFile is the slash-separated path to the YAML report relative to ProjectRoot.
OutFile string
// OutPath is the absolute path to the YAML report.
OutPath string
// RecordingsDir is the slash-separated directory for per-run .replay.yaml files relative to ProjectRoot, or empty.
RecordingsDir string
// RecordingsPath is the absolute directory for per-run .replay.yaml files, or empty.
RecordingsPath string
// Pattern is the Go test -run regexp (defaults to "Playtest").
Pattern string
}PlaytestRunRequest is the validated request passed to Options.RunPlaytest (or the default `go tool nsgo test` runner).
type PlaytestRunResult struct {
// File is the slash-separated path of the playtest.yaml that ran.
File string `json:"file"`
// ReportFile is the slash-separated path where the YAML report was written.
ReportFile string `json:"reportFile"`
// RecordingsDir is the slash-separated directory where per-seed .replay.yaml recordings were written, if enabled.
RecordingsDir string `json:"recordingsDir,omitempty"`
// Passed reports whether every metric with a goal met its goal.
Passed bool `json:"passed"`
// MissedCount is how many metrics missed their goal.
MissedCount int `json:"missedCount"`
// Report is the evaluated playtest report.
Report *playtest.Report `json:"report"`
}PlaytestRunResult is what game_playtest returns beside its text summary.
type Problem struct {
// File is the slash-separated path of the file at fault from the project root.
File string `json:"file"`
// Line is the 1-based line of the problem, or 0 when it is about the whole file.
Line int `json:"line,omitempty"`
// Column is the 1-based column on Line where the scene format knows it, or 0 when unknown.
Column int `json:"column,omitempty"`
// Object is the ID of the scene object the problem names or belongs to when known.
Object string `json:"object,omitempty"`
// Message says what is wrong.
Message string `json:"message"`
}Problem is one problem game_check reports, as a row of the Problems panel shows it.
type ProblemProposeFixResult struct {
Status string `json:"status"`
Applied bool `json:"applied"`
Fix editor.ProposedProblemFix `json:"fix"`
}ProblemProposeFixResult is what problem_propose_fix returns beside its text summary. Applied is always false because no MCP tool applies a fix.
type ProjectContext struct {
Project string `json:"project,omitempty"`
Language string `json:"language,omitempty"`
Brief BriefContext `json:"brief"`
Rules RulesContext `json:"rules"`
PendingReviews []editor.DocReview `json:"pendingReviews,omitempty"`
}ProjectContext is the combined context payload given to the agent before requests through project_context and the editor://context resource.
type Proxy struct {
// contains filtered or unexported fields
}Proxy is the MCP server go tool game mcp runs on standard input and output: it finds the editor that has the project open, through the project's endpoint, and forwards every tool call, resource read and subscription to it, and the editor's notifications back. It connects when a client first needs the editor and again after the editor closes and opens the project anew, so the agent's session outlives the editor's. While no editor has the project open, it lists the editor's built-in tools and answers each call with an error that says how to open the project.
func NewProxy(root string) *ProxyNewProxy returns the proxy for the project at root, which ProjectRoot finds.
func (p *Proxy) Run(ctx context.Context, t mcp.Transport) errorRun serves one client on t until the client disconnects or ctx ends; then it closes its connection to the editor.
type RefactorRenameResult struct {
From string `json:"from"`
To string `json:"to"`
Valid bool `json:"valid"`
ValidationMsg string `json:"validationMsg,omitempty"`
Applied bool `json:"applied"`
ReviewOpen bool `json:"reviewOpen"`
RewrittenFileCount int `json:"rewrittenFileCount"`
TotalTouchedFiles int `json:"totalTouchedFiles"`
RewrittenRefCount int `json:"rewrittenRefCount"`
PreservedObjects []string `json:"preservedObjects,omitempty"`
Files []editor.SafeRenameFileDiff `json:"files,omitempty"`
Problems []editor.SafeRenameProblem `json:"problems,omitempty"`
CheckProblems []editor.SafeRenameProblem `json:"checkProblems,omitempty"`
}RefactorRenameResult is the structured payload returned by refactor_rename.
type RefsFindResult struct {
Target string `json:"target"`
Open bool `json:"open"`
TotalUsages int `json:"totalUsages"`
TotalFiles int `json:"totalFiles"`
Scenes []editor.UsageFileGroup `json:"scenes,omitempty"`
Variants []editor.UsageFileGroup `json:"variants,omitempty"`
DataTables []editor.UsageFileGroup `json:"dataTables,omitempty"`
GoCode []editor.UsageFileGroup `json:"goCode,omitempty"`
Other []editor.UsageFileGroup `json:"other,omitempty"`
}RefsFindResult is the structured payload returned by refs_find.
type Result struct {
// Text is what the agent reads.
Text string
// Structured is a JSON-encodable value with what Text says, or nil.
Structured any
// PNG is an image the tool returns, such as viewport_image's, or nil.
PNG []byte
// SaveWarning is populated by Server when the editor's automatic saving is currently failing.
SaveWarning *SaveWarning
}Result is what a tool returns: text for the agent, an optional JSON value with the same facts for programs, and an optional PNG.
type ReviewChangeSummary struct {
ID string `json:"id"`
File string `json:"file"`
FileKind editor.ReviewFileKind `json:"file_kind"`
Kind editor.ReviewChangeKind `json:"kind"`
Object string `json:"object,omitempty"`
Field string `json:"field,omitempty"`
Title string `json:"title"`
Detail string `json:"detail"`
Why string `json:"why,omitempty"`
Seen bool `json:"seen"`
Reverted bool `json:"reverted"`
RedoneInRound int `json:"redone_in_round,omitempty"`
}ReviewChangeSummary is one change entry reported by review_notes_get.
type ReviewNotesStatusResult struct {
Active bool `json:"active"`
Open bool `json:"open"`
Paused bool `json:"paused"`
Request string `json:"request,omitempty"`
Round int `json:"round"`
ViewRound int `json:"view_round"`
DraftNoteCount int `json:"draft_note_count"`
PendingNotesRound int `json:"pending_notes_round,omitempty"`
SentNotes []editor.ReviewAgentNote `json:"sent_notes,omitempty"`
Changes []ReviewChangeSummary `json:"changes,omitempty"`
}ReviewNotesStatusResult is the structured result returned by review_notes_get.
type ReviewRedoResult struct {
Round int `json:"round"`
RedoneIDs []string `json:"redone_ids"`
RoundBanner string `json:"round_banner"`
PreservedPrev bool `json:"preserved_previous_round"`
}ReviewRedoResult is the structured result returned by review_redo.
type RulesContext struct {
Exists bool `json:"exists"`
File string `json:"file"`
Markdown string `json:"markdown,omitempty"`
RuleCount int `json:"ruleCount"`
}RulesContext is the AGENTS.md section of ProjectContext.
type SaveWarning struct {
// Message is the human-readable warning appended to tool text output.
Message string `json:"message"`
// Error is the editor's current save error message.
Error string `json:"error"`
// File is the scene or project path that failed to save, when known.
File string `json:"file,omitempty"`
}SaveWarning is attached to tool results while the editor's automatic saving is failing, so the agent does not build on edits that are not on disk.
type SelectedObject struct {
// ID and Name are the object's ID and display name.
ID string `json:"id"`
Name string `json:"name,omitempty"`
// Layer is the layer the object is on.
Layer string `json:"layer"`
// X and Y are where the object sits in its parent's space.
X float32 `json:"x"`
Y float32 `json:"y"`
// Components are the names of its components, sorted.
Components []string `json:"components,omitempty"`
// Line is the line of the open scene's YAML, as scene_read numbers it, that starts the object, or 0 when the scene does not hold it itself.
Line int `json:"line,omitempty"`
// YAML is the object as the open scene's YAML writes it, with line numbers as scene_read shows them.
YAML string `json:"yaml,omitempty"`
}SelectedObject is the selected object of a Selection.
type Selection struct {
// Scene is the open scene's path from the project root, or its file, or "the open scene" when it has none.
Scene string `json:"scene"`
// ActiveLayer is the layer new objects go on.
ActiveLayer string `json:"activeLayer"`
// Object is the selected object, or nil when none is selected.
Object *SelectedObject `json:"object,omitempty"`
// SelectedIDs lists every currently selected object ID when one or more objects are selected.
SelectedIDs []string `json:"selectedIds,omitempty"`
// File is the file selected in the file browser, by its path from the project root, or empty.
File string `json:"file,omitempty"`
// Tool is the viewport's active tool, such as "Select".
Tool string `json:"tool"`
// ViewMode is "2D" or "3D".
ViewMode string `json:"viewMode"`
// Playing reports that the scene plays in the editor, when edits are refused.
Playing bool `json:"playing,omitempty"`
// Language is the editor's active UI language ("en" or "zh"), so connected agents can reply in the same language.
Language string `json:"language,omitempty"`
}Selection is what selection_get reports.
type Server struct {
// contains filtered or unexported fields
}Server is the editor's MCP server. It serves the project open in an Editor on the project's local endpoint (Open), or on any MCP transport (Connect), with a registry of tools that the editor's parts join (AddTool), and a stream of changes to the open scene and the selection as resource notifications.
func New(ed *editor.Editor, opts Options) *ServerNew returns a server for ed with the built-in tools. Call it on the editor's goroutine, which is the one Options.Run hands functions to.
func (s *Server) AddTool(t Tool) errorAddTool adds t to the server, which tells connected clients the tool list changed. It refuses a tool without a name or a handler, with an invalid input schema, or with a name already on the server.
func (s *Server) ApplyPlaytestReview(id string) errorApplyPlaytestReview applies the pending playtest_define review with ID id to disk after verifying the file has not changed since the review was created.
func (s *Server) BeginStep(ctx context.Context, objectIDs []string, activity string) errorBeginStep marks objectIDs as currently touched by the agent's active step with the pill label activity until EndStep is called or the next BeginStep moves the agent onto different objects. While a step is active, manual edits to those objects are refused in the editor while MCP tool edits remain allowed.
func (s *Server) BindSessionTask(ss *mcp.ServerSession, taskID string)BindSessionTask associates an existing MCP ServerSession with background task taskID.
func (s *Server) Clients() []editor.AgentClientInfoClients returns the MCP clients currently attached to the server.
func (s *Server) Close() errorClose stops serving: it closes the endpoint and every session, removes the socket file and stops following the editor. Call it on the editor's goroutine; the editor stays as it is.
func (s *Server) CompleteTaskTurn(ctx context.Context, taskID, summary string) (editor.TaskReview, error)CompleteTaskTurn finishes taskID's active turn, produces its own separate editor.TaskReview from the edits recorded on its session, releases all object holds held by taskID (waking any parallel task waiting on those objects), and transitions the task to TaskReadyToReview. If updating the editor fails, recorded changes and holds are preserved.
func (s *Server) Connect(ctx context.Context, t mcp.Transport) (*mcp.ServerSession, error)Connect serves one MCP session on t until the client disconnects or the server closes, as Open does for each client of the endpoint and as a test or an in-process agent does with mcp.NewInMemoryTransports.
func (s *Server) ConnectTask(ctx context.Context, t mcp.Transport, taskID string) (*mcp.ServerSession, error)ConnectTask serves one dedicated MCP session on t bound to background task taskID. Edits performed on this session automatically hold their target objects for the duration of the task's turn and release those holds when the session closes. Sessions are tracked by Server.wg and Server.Clients() alongside ordinary Connect sessions.
func (s *Server) DismissPlaytestReview(id string) errorDismissPlaytestReview marks the pending playtest_define review with ID id as dismissed without modifying disk.
func (s *Server) Editor(ctx context.Context, fn func(ed *editor.Editor) error) errorEditor runs fn on the editor's goroutine with the editor and returns fn's error, waiting until fn has run. Edits fn makes through the editor's methods count as the agent's in the change stream. When ctx ends before fn starts, fn does not run and Editor returns ctx's error; once fn has started, Editor waits for it. A panic in fn comes back as an error.
func (s *Server) EndStep(ctx context.Context) errorEndStep releases any objects marked by BeginStep so manual edits to them are allowed again.
func (s *Server) HeldObjects() map[string]stringHeldObjects returns a snapshot map of objectID -> holding taskID.
func (s *Server) LastPermissionDecision() (editor.PermissionEvaluation, bool)LastPermissionDecision returns a copy of the most recent permission evaluation recorded by the server for a mutating or running tool call.
func (s *Server) Open() errorOpen starts serving on the endpoint of the project open in the editor (Endpoint) and moves to the new project's endpoint whenever the editor opens another, until Close. Call it on the editor's goroutine. Without a project it serves nothing until one opens. It returns the error opening the endpoint, such as ErrInUse when another editor has the same project open, which Status reports too.
func (s *Server) PlaytestReviews() []PlaytestReviewPlaytestReviews returns all playtest.yaml metric reviews proposed via playtest_define on this server, in creation order.
func (s *Server) RegisterAutomation(cx *core.Scope) errorRegisterAutomation registers the server's tools, as they are now, with github.com/nsgo-dev/nsgo/automation on cx, so that nsgo mcp offers them too while the editor runs under go tool nsgo dev -automation or go tool nsgo test, beside the tools that drive its windows. cx must be a scope on the editor's goroutine, the one Options.Run hands functions to; the tools are unregistered when cx is cleaned up. App tools run synchronously on that goroutine (nsgo-dev/nsgo#2342), so each call runs there from start to end: game_check holds the editor until the check ends. In ordinary and release builds automation registers nothing, and the server's own endpoint (Open) is how agents reach the editor.
func (s *Server) ReleaseTaskHolds(taskID string)ReleaseTaskHolds releases every object hold owned by taskID, clears its buffered turn snapshots/changes, and wakes waiting parallel tasks.
func (s *Server) RemoveTool(name string)RemoveTool removes the tool named name, if the server has it, which tells connected clients the tool list changed.
func (s *Server) SetHoldBlockedHook(fn func(taskID, objectID, holderTaskID string))SetHoldBlockedHook registers an optional deterministic callback fired immediately after a parallel task enters the holding state waiting on an object held by another task.
func (s *Server) SetHoldWaitTimeout(d time.Duration)SetHoldWaitTimeout configures how long acquireObjectHolds waits on a held object before returning an *EditError timeout. Non-positive values reset to defaultHoldWaitTimeout.
func (s *Server) Status() (string, error)Status returns the endpoint the server listens on, empty when it serves none, and why it does not when opening it failed.
func (s *Server) Tools() []ToolTools returns the server's tools sorted by name.
type SketchReadResult struct {
Scene string `json:"scene"`
Active bool `json:"active"`
HoldState string `json:"holdState"`
HoldActive bool `json:"holdActive"`
ChipLabel string `json:"chipLabel,omitempty"`
Prompt string `json:"prompt,omitempty"`
SelectedMark int `json:"selectedMark,omitempty"`
View editor.View2D `json:"view"`
Marks []editor.SketchMark `json:"marks"`
Reading *editor.SketchReading `json:"reading,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
}SketchReadResult is the structured payload returned by sketch_read.
type SketchReadingResult struct {
Scene string `json:"scene"`
HoldState string `json:"holdState"`
HoldActive bool `json:"holdActive"`
Reading *editor.SketchReading `json:"reading"`
}SketchReadingResult is the structured payload returned by sketch_reading.
type StatesTestResult struct {
File string `json:"file,omitempty"`
Summary string `json:"summary"`
DurationSeconds float64 `json:"durationSeconds"`
Steps int `json:"steps"`
Trace []string `json:"trace"`
Transitions []animclip.TransitionEvent `json:"transitions,omitempty"`
VisitedStates []string `json:"visitedStates"`
UnvisitedStates []string `json:"unvisitedStates,omitempty"`
StuckStates []string `json:"stuckStates,omitempty"`
}StatesTestResult is what states_test reports.
type StatesWriteResult struct {
File string `json:"file"`
Entry string `json:"entry"`
States int `json:"states"`
Transitions int `json:"transitions"`
Opened bool `json:"opened"`
}StatesWriteResult is what states_write reports.
type TasksListResult struct {
Summary editor.TaskSummary `json:"summary"`
Tasks []editor.AgentTask `json:"tasks"`
Holds map[string]string `json:"holds,omitempty"`
}TasksListResult is the structured reply returned by tasks_list.
type TileReviewRegionView struct {
Index int `json:"index"`
ID string `json:"id"`
Kind string `json:"kind"`
Sign string `json:"sign"`
Title string `json:"title"`
Detail string `json:"detail"`
Bounds editor.TileRect `json:"bounds"`
CellCount int `json:"cellCount"`
Reverted bool `json:"reverted"`
}TileReviewRegionView summarizes one region returned by tile_review_* MCP tools.
type TileReviewStatusResult struct {
Open bool `json:"open"`
Layer string `json:"layer,omitempty"`
TileLayer string `json:"tileLayer,omitempty"`
ShowingBefore bool `json:"showingBefore"`
PeekingBefore bool `json:"peekingBefore"`
FocusedRegion string `json:"focusedRegion,omitempty"`
KeptRegions int `json:"keptRegions"`
TotalRegions int `json:"totalRegions"`
TotalCells int `json:"totalCells"`
Steps []editor.TileReviewStep `json:"steps,omitempty"`
Regions []TileReviewRegionView `json:"regions,omitempty"`
}TileReviewStatusResult is what tile_review_status, tile_review_revert_region, and tile_review_restore_region return.
type TilesetAnimFrameView struct {
Tile int `json:"tile"`
Duration string `json:"duration"`
}TilesetAnimFrameView is one animation frame in JSON form.
type TilesetEditResult struct {
File string `json:"file"`
Applied int `json:"applied"`
Saved bool `json:"saved"`
Unsaved bool `json:"unsaved"`
Tiles int `json:"tiles"`
}TilesetEditResult is the structured result of tileset_edit.
type TilesetReadResult struct {
File string `json:"file"`
Source string `json:"source"`
Unsaved bool `json:"unsaved"`
Name string `json:"name,omitempty"`
TileWidth int `json:"tileWidth"`
TileHeight int `json:"tileHeight"`
Image string `json:"image,omitempty"`
Atlas string `json:"atlas,omitempty"`
TileCount int `json:"tileCount"`
Terrains []tilemap.TerrainDoc `json:"terrains,omitempty"`
Tiles []TilesetTileView `json:"tiles,omitempty"`
YAML string `json:"yaml"`
}TilesetReadResult is the structured result of tileset_read.
type TilesetTileView struct {
ID int `json:"id"`
Name string `json:"name,omitempty"`
Solid bool `json:"solid,omitempty"`
OneWay bool `json:"oneWay,omitempty"`
Flags tilemap.TileFlags `json:"flags,omitempty"`
Weight *float64 `json:"weight,omitempty"`
Properties map[string]any `json:"properties,omitempty"`
Shapes []tilemap.TileShapeDoc `json:"shapes,omitempty"`
Animation []TilesetAnimFrameView `json:"animation,omitempty"`
Terrain string `json:"terrain,omitempty"`
Neighbors []string `json:"neighbors,omitempty"`
}TilesetTileView is one tile's fields returned by tileset_read.
type Tool struct {
// Name is the tool's MCP name, such as scene_read: letters, digits, '_', '-' and '.', unique on the server.
Name string
// Title is a short human-readable name, such as "Read a file".
Title string
// Description says what the tool does, for the agent.
Description string
// InputSchema is the JSON Schema of the tool's arguments, an object schema; nil takes any object.
InputSchema json.RawMessage
// Action is what the tool does to the project. It must be set to a valid Action; AddTool refuses tools with an empty or unrecognized Action so no tool can silently bypass permission enforcement.
Action Action
// Target optionally derives the permission action and project-relative file path or run target from args and ed before permission rules are evaluated. When nil, the server infers the target from common argument fields (file, path, from, command) or the open scene.
Target func(args json.RawMessage, ed *editor.Editor) (editor.PermissionAction, string)
// DefaultOff marks a tool that starts switched off in Settings › Tools (such as game_delete_file)
// and is not offered to connected agents until the person explicitly turns it on.
DefaultOff bool
// Destructive marks a tool that removes files or data so MCP annotations reflect it accurately.
Destructive bool
// Handler runs the tool on a goroutine of the server, never the editor's: it reaches the editor through Call.Editor, which runs a function on the editor's goroutine, so it may wait for work the editor does elsewhere, such as a project check, without stopping the editor.
Handler func(ctx context.Context, c *Call) (*Result, error)
// contains filtered or unexported fields
}Tool is one tool of the editor's server: the five this package adds (scene_read, scene_edit, selection_get, viewport_image and game_check) and those other parts of the editor add with Server.AddTool, so that every editor action with a button or a shortcut has a tool.
type TurnStatus struct {
HasTurn bool `json:"hasTurn"`
Turn *editor.AgentTurnSnapshot `json:"turn,omitempty"`
}TurnStatus is the read-only structured result returned by turn_start, turn_end, and turn_status.
type ViewportImage struct {
// Width and Height are the PNG's size in pixels.
Width int `json:"width"`
Height int `json:"height"`
// View is the editor's 2D view: the world point at the center, the zoom and the rotation.
View editor.View2D `json:"view"`
// ViewMode is "2D" or "3D".
ViewMode string `json:"viewMode"`
// ViewportOverlays lists the viewport overlay names drawn into this image.
ViewportOverlays []string `json:"viewportOverlays,omitempty"`
// SkippedImages counts the images left out because they are not loaded in memory.
SkippedImages int `json:"skippedImages,omitempty"`
// SkippedOps counts the drawing operations left out by kind.
SkippedOps map[string]int `json:"skippedOps,omitempty"`
}ViewportImage is what viewport_image reports beside its PNG.
type YouOnlyError struct {
Tool string `json:"tool"`
Domain editor.YouOnlyDomain `json:"domain"`
Path string `json:"path"`
Reason string `json:"reason"`
Hint string `json:"hint"`
}YouOnlyError is returned when an agent attempts to write, rename, or delete a You-only settings file (permissions, tools, models, usage, or per-user editor settings) through any MCP tool.
func (e *YouOnlyError) Error() string