2026-05-06 18:28:04 +08:00
|
|
|
|
# GSP
|
|
|
|
|
|
|
|
|
|
|
|
GSP = Game Specification Protocol。
|
|
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
GSP 是一个通用游戏规格协议与配套工具链,用于在人类、AI、工具、运行时、实现模块、测试与验收之间传递游戏设计信息。
|
2026-05-06 18:28:04 +08:00
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
## 目录结构
|
2026-05-06 18:28:04 +08:00
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
```text
|
|
|
|
|
|
GSP/
|
2026-05-06 19:40:55 +08:00
|
|
|
|
specs/ GSP 版本化协议规范与 schema
|
2026-05-06 18:54:21 +08:00
|
|
|
|
toolkit/ GSP Toolkit Go CLI 源码
|
2026-05-06 19:06:32 +08:00
|
|
|
|
examples/ 示例 GSP 工程
|
2026-05-06 18:28:04 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
生成产物默认放在:
|
2026-05-06 18:28:04 +08:00
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
```text
|
|
|
|
|
|
bin/ 本地构建出的 CLI,可删除
|
|
|
|
|
|
.gsp/ Toolkit 输出结果,可删除
|
2026-05-06 18:28:04 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
这两个目录默认不进入 Git。
|
2026-05-06 18:28:04 +08:00
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
## 如何生成 Toolkit
|
2026-05-06 18:28:04 +08:00
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
需要本机安装 Go。
|
2026-05-06 18:28:04 +08:00
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
从仓库根目录执行:
|
2026-05-06 18:28:04 +08:00
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
```powershell
|
|
|
|
|
|
cd toolkit
|
|
|
|
|
|
go build -o ..\bin\gsp.exe .\cmd\gsp
|
|
|
|
|
|
cd ..
|
2026-05-06 18:28:04 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
生成后得到:
|
2026-05-06 18:28:04 +08:00
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
```text
|
|
|
|
|
|
bin/gsp.exe
|
2026-05-06 18:28:04 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
## 如何生成 GSP 输出
|
2026-05-06 18:28:04 +08:00
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
使用示例目录生成检查报告、索引、扁平上下文、上下文包和关系图:
|
2026-05-06 18:28:04 +08:00
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
```powershell
|
|
|
|
|
|
.\bin\gsp.exe validate --root examples\lottery --out .gsp\report.json
|
|
|
|
|
|
.\bin\gsp.exe index --root examples\lottery --out .gsp\index.json
|
|
|
|
|
|
.\bin\gsp.exe flatten page.lottery.main --root examples\lottery --depth -1 --out .gsp\flattened.json
|
|
|
|
|
|
.\bin\gsp.exe pack page.lottery.main --root examples\lottery --depth -1 --budget 12000 --out .gsp\context-pack.json
|
2026-05-07 10:17:24 +08:00
|
|
|
|
.\bin\gsp.exe pack page.lottery.main --root examples\lottery --for implement --stage implement --format md --out .gsp\context-pack.md
|
2026-05-07 10:41:38 +08:00
|
|
|
|
.\bin\gsp.exe links page.lottery.main --root examples\lottery --format md --out .gsp\links.md
|
2026-05-07 10:17:24 +08:00
|
|
|
|
.\bin\gsp.exe impact feedback.positive --root examples\lottery --format md --out .gsp\impact.md
|
|
|
|
|
|
.\bin\gsp.exe impact feedback.positive --root examples\lottery --format canvas --out .gsp\impact.canvas
|
|
|
|
|
|
.\bin\gsp.exe message validate messages\implement-page.gspmsg --root examples\lottery --out .gsp\message-report.json
|
2026-05-06 18:54:21 +08:00
|
|
|
|
.\bin\gsp.exe graph page.lottery.main --root examples\lottery --format mermaid --out .gsp\graph.mmd
|
2026-05-06 20:00:50 +08:00
|
|
|
|
.\bin\gsp.exe graph page.lottery.main --root examples\lottery --format md --out .gsp\graph.md
|
|
|
|
|
|
.\bin\gsp.exe graph page.lottery.main --root examples\lottery --format canvas --out .gsp\graph.canvas
|
2026-05-06 18:54:21 +08:00
|
|
|
|
.\bin\gsp.exe stage-check --root examples\lottery --stage implement --out .gsp\stage-report.json
|
2026-05-06 20:34:43 +08:00
|
|
|
|
.\bin\gsp.exe completion powershell
|
2026-05-06 18:28:04 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
输出文件:
|
2026-05-06 18:28:04 +08:00
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
```text
|
|
|
|
|
|
.gsp/report.json
|
|
|
|
|
|
.gsp/index.json
|
|
|
|
|
|
.gsp/flattened.json
|
|
|
|
|
|
.gsp/context-pack.json
|
2026-05-07 10:17:24 +08:00
|
|
|
|
.gsp/context-pack.md
|
2026-05-07 10:41:38 +08:00
|
|
|
|
.gsp/links.md
|
2026-05-07 10:17:24 +08:00
|
|
|
|
.gsp/impact.md
|
|
|
|
|
|
.gsp/impact.canvas
|
|
|
|
|
|
.gsp/message-report.json
|
2026-05-06 18:54:21 +08:00
|
|
|
|
.gsp/graph.mmd
|
2026-05-06 20:00:50 +08:00
|
|
|
|
.gsp/graph.md
|
|
|
|
|
|
.gsp/graph.canvas
|
2026-05-06 18:54:21 +08:00
|
|
|
|
.gsp/stage-report.json
|
2026-05-06 18:28:04 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
## 文档入口
|
2026-05-06 18:28:04 +08:00
|
|
|
|
|
2026-05-06 18:54:21 +08:00
|
|
|
|
| 文档 | 作用 |
|
|
|
|
|
|
|---|---|
|
2026-05-06 19:40:55 +08:00
|
|
|
|
| `specs/README.md` | GSP 规范版本入口。 |
|
|
|
|
|
|
| `specs/versions/0.1/README.md` | GSP 0.1 语言说明。 |
|
|
|
|
|
|
| `specs/versions/0.1/gsp.schema.json` | GSP 0.1 核心字段 schema。 |
|
|
|
|
|
|
| `specs/versions/0.1/gsp.manifest.schema.json` | GSP 0.1 工程 manifest schema。 |
|
2026-05-07 11:04:11 +08:00
|
|
|
|
| `specs/versions/0.1/gsp.fields.schema.json` | GSP 0.1 自定义字段注册 schema。 |
|
2026-05-07 10:17:24 +08:00
|
|
|
|
| `specs/versions/0.1/gsp.message.schema.json` | GSP 0.1 agent 通信消息 schema。 |
|
2026-05-06 19:40:55 +08:00
|
|
|
|
| `specs/versions/0.1/commands.md` | GSP 0.1 命令规范。 |
|
|
|
|
|
|
| `specs/versions/0.1/ai-usage.md` | GSP 0.1 AI 使用规则。 |
|
2026-05-07 10:17:24 +08:00
|
|
|
|
| `specs/versions/0.1/message.md` | GSP Message 说明。 |
|
2026-05-06 18:54:21 +08:00
|
|
|
|
| `toolkit/README.md` | GSP Toolkit 命令与实现说明。 |
|
2026-05-06 19:06:32 +08:00
|
|
|
|
|
|
|
|
|
|
## GSP 工程结构
|
|
|
|
|
|
|
|
|
|
|
|
GSP 工程默认使用以下结构:
|
|
|
|
|
|
|
|
|
|
|
|
```text
|
|
|
|
|
|
project/
|
|
|
|
|
|
gsp.manifest
|
2026-05-07 11:04:11 +08:00
|
|
|
|
gsp.fields
|
2026-05-06 19:06:32 +08:00
|
|
|
|
design/
|
|
|
|
|
|
*.gsp
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Toolkit 默认从工程根目录的 `design/` 目录扫描 `.gsp` 文件。`gsp.manifest` 可声明语言版本、Toolkit 版本、入口 GSP、扫描范围、阶段规则和 type 列表。
|
2026-05-06 19:40:55 +08:00
|
|
|
|
|
|
|
|
|
|
## AI 使用入口
|
|
|
|
|
|
|
|
|
|
|
|
给当前 GSP 工程生成 AI 友好入口:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
gsp ai-init
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
默认生成:
|
|
|
|
|
|
|
|
|
|
|
|
```text
|
|
|
|
|
|
README.md
|
|
|
|
|
|
AI_USAGE.md
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
可选生成代理说明或 skill 入口:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
gsp ai-init --agents
|
|
|
|
|
|
gsp ai-init --skill generic
|
|
|
|
|
|
gsp ai-init --skill codex
|
|
|
|
|
|
gsp ai-init --all
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 安装为命令
|
|
|
|
|
|
|
|
|
|
|
|
Windows:
|
|
|
|
|
|
|
|
|
|
|
|
```powershell
|
|
|
|
|
|
powershell -ExecutionPolicy Bypass -File .\toolkit\scripts\install.ps1
|
|
|
|
|
|
gsp version
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
macOS:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
sh ./toolkit/scripts/install.sh
|
|
|
|
|
|
gsp version
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
安装后可以在任意目录使用:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
gsp init
|
|
|
|
|
|
gsp ai-init
|
|
|
|
|
|
gsp version
|
2026-05-06 20:34:43 +08:00
|
|
|
|
gsp completion install powershell
|
2026-05-06 19:40:55 +08:00
|
|
|
|
gsp validate
|
|
|
|
|
|
gsp index
|
2026-05-07 11:04:11 +08:00
|
|
|
|
gsp fields list
|
|
|
|
|
|
gsp fields validate
|
2026-05-06 19:40:55 +08:00
|
|
|
|
gsp flatten <id>
|
2026-05-07 10:17:24 +08:00
|
|
|
|
gsp pack <id> --for implement --format md
|
2026-05-07 10:41:38 +08:00
|
|
|
|
gsp links <id> --format md
|
2026-05-07 10:17:24 +08:00
|
|
|
|
gsp impact <id> --format md
|
|
|
|
|
|
gsp message validate message.gspmsg
|
2026-05-06 19:40:55 +08:00
|
|
|
|
gsp graph <id>
|
|
|
|
|
|
gsp stage-check --stage implement
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 初始化 GSP 工程
|
|
|
|
|
|
|
|
|
|
|
|
在当前目录初始化:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
gsp init
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
在指定目录初始化:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
gsp init path/to/project --name project-name --entry project.entry
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
初始化结果:
|
|
|
|
|
|
|
|
|
|
|
|
```text
|
|
|
|
|
|
project/
|
|
|
|
|
|
gsp.manifest
|
2026-05-07 11:04:11 +08:00
|
|
|
|
gsp.fields
|
2026-05-06 19:40:55 +08:00
|
|
|
|
design/
|
|
|
|
|
|
project.entry.gsp
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
已有 `gsp.manifest` 或入口 `.gsp` 时,`gsp init` 默认不会覆盖。需要重建初始化文件时使用:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
gsp init path/to/project --force
|
|
|
|
|
|
```
|
2026-05-06 20:34:43 +08:00
|
|
|
|
|
|
|
|
|
|
## 命令补全
|
|
|
|
|
|
|
|
|
|
|
|
输出补全脚本:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
gsp completion powershell
|
|
|
|
|
|
gsp completion bash
|
|
|
|
|
|
gsp completion zsh
|
|
|
|
|
|
gsp completion fish
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
安装 PowerShell 补全:
|
|
|
|
|
|
|
|
|
|
|
|
```powershell
|
|
|
|
|
|
gsp completion install powershell
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
安装后重新打开 PowerShell,`gsp <Tab>` 会补全子命令,`gsp graph --format <Tab>` 会补全格式,`gsp graph <Tab>` 会读取当前工程的 GSP id。
|