Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .agents/notes/implemented/feature/2026-11-24-mcp-agent-skill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Agent Note: Agent Skill for the NSGo game layer

Status: implemented

## Problem

NSGo ships an installable Agent Skill (`skills/nsgo`) so coding agents can build, test and drive NSGo apps via `go tool nsgo` and `nsgo mcp`, while the game layer (`github.com/nsgo-dev/game/packages/game`) adds 100+ packages, the `go tool game` CLI, strict versioned YAML formats, and the `game/mcp` tool suite. Without a dedicated, installable skill describing those conventions and MCP tools, agents guess package names, bypass `go tool nsgo check`/`test`, write non-canonical YAML, or miss the deterministic `game_loop_*` and inspection workflows.

## Decision

Publish an Agent Skill at `skills/nsgo-game/` (installable via `bunx skills add nsgo-dev/game`) with a concise `SKILL.md` entry point and three on-demand reference files (`references/packages.md`, `references/cli-and-formats.md`, `references/mcp-tools.md`), backed by automated Go tests that keep the skill mechanically aligned with the repository and verify the documented CLI-to-MCP workflow end to end.

## Skill layout and test invariants

- **Standard Agent Skills layout**: `skills/nsgo-game/SKILL.md` carries strict YAML frontmatter (`name: nsgo-game` and `description`) matching the directory name, mirroring NSGo's `skills/nsgo/` layout so `bunx skills add nsgo-dev/game` discovers and installs it cleanly.
- **Progressive disclosure via `references/`**: `SKILL.md` stays short and task-oriented (core rules, `game new`/`generate`/`assets`/`check`/`dev` workflow, minimal `game.Loop` + `mcp.Attach` pattern, and the deterministic MCP verification loop), delegating dense catalogs to `references/packages.md`, `references/cli-and-formats.md`, and `references/mcp-tools.md`.
- **Drift prevention tests (`packages/game/skill_test.go`)**: `TestAgentSkillValid` parses `SKILL.md` frontmatter with `KnownFields(true)`, verifies every relative Markdown link stays inside `skills/nsgo-game/` and resolves on disk, checks `references/packages.md` against `modulePackages(t)` (both directions) and each package's status against `docs/en/stability.md`, and requires the tool tables in `references/mcp-tools.md` to name exactly the tools `mcp.New(mcp.Config{}).Tools()` returns. `TestAgentSkillDocumentsEveryCommand` (`packages/game/cmd/game`) loops over the `commands` slice and requires each subcommand in `references/cli-and-formats.md`.
- **End-to-end CLI and MCP verification**: `TestAgentSkillWorkflowBuildAndVerifyThroughMCP` (`packages/game/skill_test.go`) and `TestAgentSkillCLIScaffoldGenerateCheckAndMCP` (`packages/game/cmd/game/skill_e2e_test.go`) scaffold/validate a project (`game new`, `game generate`, `game index`, `game check`), load the YAML scene into `entities.World`, attach `mcp.Bridge` inside `nsgotest.Start`, and verify deterministic simulation over MCP (`game_scenes_list`, `game_layers_list`, `game_loop_pause`, `game_loop_seed`, `game_loop_step`, `game_entities_list`, `game_entity_inspect`, `game_component_get`).
- **Additive rebase boundary**: Tests live in `packages/game/skill_test.go` and `packages/game/cmd/game/skill_e2e_test.go`, and user docs live in new `docs/{en,zh}/agent-skill.md` pages rather than heavily editing `packages/game/mcp/` or `docs/{en,zh}/mcp.md`, avoiding merge conflicts with sibling MCP tool PRs (#463–#469). `references/mcp-tools.md` documents the complete `#461`–`#469` tool catalog while Go tests compile strictly against the tools landed on `main` (`#461` and `#462`, see [MCP scene, layer, entity and component inspection](2026-11-24-mcp-scene-entity-inspection.md) and [MCP loop control and deterministic seeding](2026-11-24-mcp-loop-control.md)).

## Alternatives considered

### Putting everything into one monolithic `skills/nsgo-game/SKILL.md`

Strongest argument: a single file requires no secondary reads when an agent loads the skill.

Rejected because listing 111 packages, 19 CLI commands, dozens of YAML formats, and 38 MCP tools in one file bloats every agent prompt where the skill triggers. Splitting into a compact `SKILL.md` plus three focused `references/` files matches NSGo's `skills/nsgo/` structure and Agent Skills progressive-disclosure guidelines.

### Placing the skill under `.agents/skills/nsgo-game/` instead of `skills/nsgo-game/`

Strongest argument: `.agents/skills/` is where repository-local contributor skills live (such as `write-notes-like-deepseek`).

Rejected because `.agents/skills/` is for internal repository workflow skills, whereas `skills/nsgo-game/` matches NSGo's published `skills/nsgo/` location for downstream users installing via `bunx skills add nsgo-dev/game`.

### Relying on manual review to keep the skill synchronized with code

Strongest argument: markdown files do not normally require Go tests.

Rejected because new packages, CLI commands, and MCP tools land frequently; without `TestAgentSkillValid`, the skill's package list, relative links, and MCP tool names would silently drift from the codebase.

## Consequences

- **Benefits**: Downstream users can install the game-layer skill with `bunx skills add nsgo-dev/game`; agents have an accurate, concise map of packages, CLI commands, YAML rules, and MCP tools; CI automatically catches missing packages, broken links, or undocumented MCP tools.
- **Costs**: Adding a new package under `packages/game/` now requires updating `skills/nsgo-game/references/packages.md` alongside `docs/{en,zh}/stability.md`, and adding a new tool to `mcp.Bridge.Tools()` requires ensuring its name appears in `skills/nsgo-game/references/mcp-tools.md` (already pre-populated for `#461`–`#469`).

## Verification

Verified with `gofmt`, `go run ./cmd/gameschema -check`, `go tool nsgo check -target macos,windows,linux,android,web`, `go tool nsgo test ./cmd/game`, `go tool nsgo test ./mcp`, `go tool nsgo test . -- -run '^Test(AgentSkill|ASecond|FormatsPage|FormatPackagesRunConformance|StabilityTable)'`, `go run ./tools/changelog check`, and `bun run verify-notes`.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Import the packages from `github.com/nsgo-dev/game/packages/game`:
- [Tutorial: Star Catcher](docs/en/tutorial.md) ([中文](docs/zh/tutorial.md)), nine chapters from an empty project to a shipped game, with each chapter's code in [`examples/tutorial`](examples/tutorial/)
- [Packages](docs/en/packages.md) ([中文](docs/zh/packages.md)): [Loop](docs/en/loop.md), [sprite](docs/en/sprite.md), [sound](docs/en/sound.md)
- [API Stability](docs/en/stability.md) ([中文](docs/zh/stability.md))
- [Agent Skill](docs/en/agent-skill.md) ([中文](docs/zh/agent-skill.md)) — installable via `bunx skills add nsgo-dev/game`
- [3D Models from Blender](docs/en/3d-models-blender.md) ([中文](docs/zh/3d-models-blender.md))
- [Building and Shipping](docs/en/shipping.md) ([中文](docs/zh/shipping.md))

Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/content/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export type GroupKey = 'guides' | 'tutorial' | 'comingFrom' | 'core2d' | 'extended2d' | 'multiplayerModding' | 'threeD' | 'other'

const SIDEBAR_GROUPS: readonly { key: Exclude<GroupKey, 'other'>; slugs: readonly string[] }[] = [
{ key: 'guides', slugs: ['index', 'getting-started', 'project', 'playground', 'packages', 'stability', 'shipping', 'cli', 'cli-reference'] },
{ key: 'guides', slugs: ['index', 'getting-started', 'project', 'playground', 'packages', 'stability', 'shipping', 'cli', 'cli-reference', 'agent-skill'] },
{
key: 'tutorial',
slugs: [
Expand Down
3 changes: 3 additions & 0 deletions changelog.d/mcp-agent-skill-470.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Added

- `skills/nsgo-game`: Agent Skill installable via `bunx skills add nsgo-dev/game` covering the game-layer packages, `go tool game` CLI, plain-text YAML file formats, and `game/mcp` tool suite, along with automated structure and end-to-end MCP workflow tests (#470).
36 changes: 36 additions & 0 deletions docs/en/agent-skill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Agent Skill

The repository publishes an Agent Skill at [`skills/nsgo-game`](../../skills/nsgo-game/SKILL.md) so coding agents know how to scaffold, build, test, inspect and drive NSGo games using the `go tool game` CLI, plain-text YAML formats and the `game/mcp` tool suite.

## Install

Install the skill with `bunx skills add`:

```sh
bunx skills add nsgo-dev/game
```

Pair it with NSGo's own `nsgo` skill for core UI primitives, signals, `nsgotest` and `go tool nsgo`:

```sh
bunx skills add nsgo-dev/nsgo
```

To let an agent inspect and drive a running game live, also register NSGo's MCP server:

```sh
claude mcp add nsgo -- go tool nsgo mcp
```

## What the skill covers

- **[`SKILL.md`](../../skills/nsgo-game/SKILL.md)**: project rules (Go only, plain-text versioned YAML formats, `go tool nsgo check`/`test`, stability tiers), quick-start CLI workflow, minimal `game.Loop` + `mcp.Attach` wiring, and the deterministic MCP verification loop.
- **[`references/packages.md`](../../skills/nsgo-game/references/packages.md)**: complete grouped catalog of every package in `github.com/nsgo-dev/game/packages/game`, with import paths and stability status matching [API Stability](stability.md).
- **[`references/cli-and-formats.md`](../../skills/nsgo-game/references/cli-and-formats.md)**: all `go tool game` subcommands ([Command Reference](cli-reference.md)), companion module tools, the YAML format contract ([File Formats](formats.md)), JSON Schemas ([Schemas](schemas.md)) and native external formats (Tiled, LDtk, Aseprite, TexturePacker, BMFont, glTF, Yarn).
- **[`references/mcp-tools.md`](../../skills/nsgo-game/references/mcp-tools.md)**: `mcp.Bridge` setup ([mcp](mcp.md)) and the full tool catalog covering scene/entity inspection, fixed-step loop control, game-coordinate input, live spawning and component editing, screenshots with diagnostic overlays, debug console tunables, input recording/replay, performance telemetry and live asset hot reload.

## Typical agent workflow

1. Scaffold and add building blocks with `go tool game new`, `go tool game generate`, `go tool game assets` and `go tool game check`.
2. Attach `mcp.Bridge` on the game's `*core.Scope` and run `go tool nsgo dev -automation` (or `nsgotest.Start` in tests).
3. Drive reproducible checks through MCP: pause with `game_loop_pause`, seed with `game_loop_seed`, inject inputs or spawn entities, advance synchronously with `game_loop_step`, inspect entities with `game_entities_list` / `game_entity_inspect` / `game_component_get`, and capture overlays with `game_screenshot`.
2 changes: 2 additions & 0 deletions docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,5 @@ With those, this repository would add an XR camera rig to `scene3d` and XR actio
## For language models

The site publishes the English docs for language models and coding agents, as [nsgo.dev](https://nsgo.dev/llms.txt) does: [llms.txt](https://game.nsgo.dev/llms.txt) lists every page with a line about it, and [llms-full.txt](https://game.nsgo.dev/llms-full.txt) holds every page's Markdown in one file. Both are built from `docs/en` with the site, so they always match these pages. For contributors, the [Agent Evaluation Suite](agent-eval.md) grades fixed game tasks with YAML, build and `game/mcp` checks, and can run a coding agent on them.

For coding agents that support Agent Skills, install the game-layer skill with `bunx skills add nsgo-dev/game`; see [Agent Skill](agent-skill.md).
36 changes: 36 additions & 0 deletions docs/zh/agent-skill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 智能体技能

本仓库在 [`skills/nsgo-game`](../../skills/nsgo-game/SKILL.md) 发布了一个智能体技能(Agent Skill),让编程智能体了解如何通过 `go tool game` 命令行工具、纯文本 YAML 格式和 `game/mcp` 工具集来创建、构建、测试、检查并驱动 NSGo 游戏。

## 安装

使用 `bunx skills add` 安装该技能:

```sh
bunx skills add nsgo-dev/game
```

建议同时安装 NSGo 自身的 `nsgo` 技能,以涵盖核心 UI 组件、signal、`nsgotest` 与 `go tool nsgo`:

```sh
bunx skills add nsgo-dev/nsgo
```

如需让智能体实时检查并驱动运行中的游戏,还需注册 NSGo 的 MCP 服务器:

```sh
claude mcp add nsgo -- go tool nsgo mcp
```

## 技能内容

- **[`SKILL.md`](../../skills/nsgo-game/SKILL.md)**:项目核心规则(纯 Go、带版本号的纯文本 YAML 格式、`go tool nsgo check`/`test`、稳定性分级)、快速上手的 CLI 流程、最小 `game.Loop` + `mcp.Attach` 接入示例,以及确定性 MCP 验证循环。
- **[`references/packages.md`](../../skills/nsgo-game/references/packages.md)**:`github.com/nsgo-dev/game/packages/game` 下所有包的分组目录、导入路径与稳定性状态,与[API 稳定性](stability.md)保持一致。
- **[`references/cli-and-formats.md`](../../skills/nsgo-game/references/cli-and-formats.md)**:全部 `go tool game` 子命令([命令参考](cli-reference.md))、配套模块工具、YAML 格式契约([文件格式](formats.md))、JSON Schema([YAML 文件的 Schema](schemas.md))及直接读取的外部工具格式(Tiled、LDtk、Aseprite、TexturePacker、BMFont、glTF、Yarn)。
- **[`references/mcp-tools.md`](../../skills/nsgo-game/references/mcp-tools.md)**:`mcp.Bridge` 接入方法([mcp](mcp.md))与完整工具目录,覆盖场景/实体检查、固定步长循环控制、游戏坐标输入、实时生成与组件编辑、带诊断叠加层的截图、调试控制台可调参数、输入录制与回放、性能读数以及资源热重载。

## 典型智能体工作流

1. 使用 `go tool game new`、`go tool game generate`、`go tool game assets` 与 `go tool game check` 搭建项目并校验资源和引用。
2. 在游戏的 `*core.Scope` 上挂载 `mcp.Bridge`,并运行 `go tool nsgo dev -automation`(或在测试中使用 `nsgotest.Start`)。
3. 通过 MCP 执行可复现验证:调用 `game_loop_pause` 暂停、`game_loop_seed` 设定随机种子、注入输入或生成实体、调用 `game_loop_step` 同步推进步数、通过 `game_entities_list` / `game_entity_inspect` / `game_component_get` 检查实体状态,并用 `game_screenshot` 截取叠加层画面。
2 changes: 2 additions & 0 deletions docs/zh/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,5 @@ macOS、iOS、Windows、Linux、Android 和 Web。鸿蒙、小程序、watchOS
## 面向语言模型

与 [nsgo.dev](https://nsgo.dev/llms.txt) 一样,本站为语言模型和编程智能体发布英文文档:[llms.txt](https://game.nsgo.dev/llms.txt) 列出每个页面并附一句简介,[llms-full.txt](https://game.nsgo.dev/llms-full.txt) 把每个页面的 Markdown 合在一个文件里。两者都随网站从 `docs/en` 构建,因此始终与这些页面一致。面向贡献者的[智能体评测套件](agent-eval.md)用 YAML、构建与 `game/mcp` 检查为固定的游戏任务评分,也可以让编程智能体来完成这些任务。

对于支持 Agent Skills 的编程智能体,可通过 `bunx skills add nsgo-dev/game` 安装游戏层技能,详见[智能体技能](agent-skill.md)。
Loading
Loading