gs2-studio-dsl 2026.11.10 → 2026.11.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/LLM.md +413 -0
  2. package/README.md +15 -5
  3. package/REFERENCE.md +1650 -0
  4. package/index.d.ts +994 -1105
  5. package/package.json +3 -1
package/LLM.md ADDED
@@ -0,0 +1,413 @@
1
+ # gs2-studio-dsl for LLM coding agents
2
+
3
+ Instructions for an agent that writes or edits a GS2 Studio package DSL. Follow them literally. Section names in
4
+ [REFERENCE.md](REFERENCE.md) are linked where an API is involved.
5
+
6
+ ## 1. What the DSL is
7
+
8
+ - A package DSL is a TypeScript module that calls `definePackage({ ... })` and exports the package definition (or the
9
+ result of `.build()`). GS2 Studio's `dsl build` command evaluates it, validates the package, and saves it into a GS2
10
+ Studio project.
11
+ - This npm package (`gs2-studio-dsl`) contains type declarations only. It has no runtime; never try to run a DSL with
12
+ Node, `ts-node`, a bundler or a test runner. Only `dsl build` evaluates it.
13
+ - `dsl build` does not type-check. It removes types with Node's type stripping and runs the result. Type errors you do
14
+ not catch with `tsc --noEmit` become run-time failures or wrong packages.
15
+ - The generated package files in the project (`packages/<id>/**`, `project.json`) are output. Never edit them; change
16
+ the DSL and rebuild.
17
+
18
+ ## 2. Project layout
19
+
20
+ ```text
21
+ <project>/ GS2 Studio project (project.json, packages/)
22
+ <dsl>/
23
+ index.ts the entry: exports exactly one definePackage({...}) or .build() result
24
+ id-ledger.json ids of the package; created by dsl build --write-ledger; commit it
25
+ dependency-surface.json written by dsl build: what this package publishes to packages that depend on it
26
+ surfaces/<packageId>.json written by dsl surfaces: what each package of the project publishes
27
+ tsconfig.json the tsconfig from the README
28
+ package.json devDependencies: gs2-studio-dsl, typescript
29
+ ```
30
+
31
+ Besides `gs2-studio-dsl` and `gs2-studio-dsl/gs2`, a module may import only by relative path (`./...` or `../...`,
32
+ anywhere on disk): `.ts` files (the extension may be left out), `.json` files, and any file as text with `?raw`. Nothing
33
+ else (see [Modules and imports](REFERENCE.md#modules-and-imports)).
34
+
35
+ ## 3. Workflow
36
+
37
+ `<GS2 Studio>` is the GS2 Studio executable (the README gives its path per platform).
38
+
39
+ To start a new `<dsl>`, run `"<GS2 Studio>" dsl init --dir <project> --out <dsl> --package-id <id>`, then
40
+ `npm install` in `<dsl>` (without `--package-id`, the package id is the name of `<dsl>`). It writes `package.json`,
41
+ `tsconfig.json`, a starter `index.ts`, `surfaces/`, these documents under `docs/`, and an `AGENTS.md` that lists the
42
+ commands below with the executable's path; the first build writes the ledger. It refuses when one of its files exists.
43
+
44
+ 1. Put every dependency in the project first: install it in GS2 Studio ("Add dependency", under any package of the
45
+ project), or, for a package you author too, build it into the project with `dsl build`. The DSL cannot install
46
+ packages.
47
+ 2. If the package depends on other packages, write their surfaces (one file per package of the project):
48
+ `"<GS2 Studio>" dsl surfaces --dir <project> --out <dsl>/surfaces`
49
+ 3. Write or edit `<dsl>/index.ts`. When the package depends on other packages, declare the dependencies first and build
50
+ (steps 4 to 7): the build then names the types of the dependencies that need rows from this package.
51
+ 4. Type-check: `npx tsc --noEmit -p <dsl>`. Fix every error before building.
52
+ 5. First build of a new package:
53
+ `"<GS2 Studio>" dsl build --dir <project> --entry <dsl>/index.ts --write-ledger`
54
+ It adds the package with the id `definePackage({ id })` declares beside the project's other packages, which stay as
55
+ they are; later builds replace that package. Only a DSL that declares the id `local-project` replaces `local-project`.
56
+ 6. Later builds: the same command without `--write-ledger`. Add `--write-ledger` only when the build reports missing
57
+ ledger tokens for things you added (a type, property, row or transform) and reports no token as "not current".
58
+ A "not current" token means a rename or removal: handle it as in section 4 first.
59
+ 7. Read what a build that saved the package prints on stderr: the `[error]` and `[warning]` lines `project check`
60
+ reports for the project. The build exits with 0 because it saved the package, but each line says what deploy or code
61
+ generation will do wrong or leave out. Fix each one the DSL can fix (section 6) and build again; tell the user about a
62
+ line on another package that the DSL does not change. Then open the project in GS2 Studio and fix what it reports:
63
+ what Unity code generation alone refuses is not printed (see
64
+ [Building with dsl build](REFERENCE.md#building-with-dsl-build)). A build with no such line prints
65
+ `project check (without Unity code generation): no errors or warnings` last.
66
+ 8. Keep `id-ledger.json` and `dependency-surface.json` with `index.ts`; commit them together.
67
+
68
+ A build that fails a check writes nothing. On failure, read every listed problem, fix the DSL, and rerun.
69
+
70
+ ## 4. Hard rules
71
+
72
+ MUST:
73
+
74
+ - Export exactly one `definePackage({ ... })` (or `.build()`) result from the entry.
75
+ - Register every domain type definition you reference in `definePackage({ domainTypes: [...] })`. Refer to types,
76
+ resources and action transforms by their definition handles (never by raw type name strings).
77
+ - Use thunks (`() => Type` or `() => resource`) when two definitions refer to each other or when a definition refers to
78
+ one declared later in the file.
79
+ - Import types with `import type` or `type` specifiers (`import { type LocalizedDisplay, PT } from "gs2-studio-dsl"`).
80
+ - Name domain types in PascalCase and properties in camelCase. Never declare a property named `id`.
81
+ - Bind every `.masterData()` property in some master data resource and every `.userData()` property in some user data
82
+ resource, or remove the hint.
83
+ - Put a `defineUiComponent`, and the type of a `UiSource.rowProp`, only on a type that gets a Handler; `dsl build`
84
+ refuses either on a type without one and says why. A dependency's type gets one when `types.<Type>.generatedHandlers`
85
+ of its surface is not `[]` (`mountedBy` names the dependency's resources that mount it), or when your package mounts
86
+ its overlay of the type itself. A type gets one only when a user data resource, or a master data resource of a model
87
+ other than a namespace, mounts it.
88
+ - To use what a dependency does as it is (for example "make the wallet usable" with `foundation-economy-currency`),
89
+ declare the dependency and call its transforms; add rows, resources or UI only for what the surface or a build asks
90
+ for. The dependency's own UI components (`types.<Type>.uiComponents`) are generated with it, and the game places
91
+ the Handler that holds the row they show, such as a `WalletHandler` set to the slot (`"0"`). See
92
+ [Rows in the game](REFERENCE.md#rows-in-the-game).
93
+ - Before adding UI to a dependency's type, read `types.<Type>.uiComponents` of its surface. Reuse a listed item instead
94
+ of adding one that shows the same, and give new items unlisted class names: a listed one replaces that item.
95
+ - Give a single-entry type's row the type name in lower case as its id (`GameSettings` → `gamesettings`).
96
+ - Refer to anything of another package only through `dependencyPackage(surface)` built from a surface file that
97
+ `dsl surfaces` wrote (or, for a package you build yourself, the `dependency-surface.json` beside its ledger, which
98
+ has the same content): `dep.type(...)`, `dep.overlay(...)`, `dep.typeId(...)`, `dep.propertyId(...)`,
99
+ `dep.transformId(...)`, `dep.transformCall(...)`, `dep.transformProgram(...)`, `dep.resourceId(...)`. Declare the
100
+ dependency in `definePackage({ dependencies: { [dep.packageId]: spec } })`. The spec of a package authored in the same
101
+ project is `"*"`. An installed package has the spec of its source, as the `dependencies` of
102
+ `<project>/packages/<packageId>/package.json` of the package that installed it declare it: a package installed from
103
+ GitHub is `github:<owner>/<repo>[@<range>]` without its subdirectory, and every package of the GS2 Studio package
104
+ repository is `github:gs2io/gs2-studio-package`. A package that came in as a dependency of another one appears in no
105
+ `package.json` there: take the spec from its entry in `<project>/project-lock.json` (`github:<owner>/<repo>` for
106
+ `"sourceKind": "github"`). Never give an installed package `"*"`; `dsl build` refuses it and prints the spec to
107
+ declare (see [Dependencies](REFERENCE.md#dependencies)).
108
+ - Learn what a dependency needs from its surface file, not from its package files: `types.<Type>.propertyDetails`
109
+ gives each property's `type`, `requirement`, `bindingHint` and, when it has one, its `display` (label and description
110
+ per locale); `actionTransformSignatures.<Name>` gives each transform's category and parameters (name, type,
111
+ required and, when it has one, description); `types.<Type>.delegatedActions.<Method>.parameters` gives what a
112
+ `UiItem.buttonAction` on that method takes as `args`; `types.<Type>.sort` gives the order of its rows, which an overlay of
113
+ the type keeps unless it sets a `sort` other than id ascending. A `ref<T>` parameter or property takes a row id of `T`.
114
+ - Call a dependency's transform with `dep.transformCall(name, { <parameter>: source })` (spread into an
115
+ `actionPropertyTransforms` entry) or `dep.transformProgram(name, { <parameter>: source })` (in `actionProgram`),
116
+ not with `dep.transformId(...)` and hand-written arguments, so `tsc` and `dsl build` check the parameter names. The
117
+ two name a property differently: `transformCall` takes `{ kind: "domainProperty", propertyName: "<property of the
118
+ row>" }`, `transformProgram` takes `{ kind: "domainProperty", source: Source.direct(...) }`. See the examples in
119
+ [Overlay types](REFERENCE.md#overlay-types) and [Action programs](REFERENCE.md#action-programs-and-arguments).
120
+ - Add the rows a dependency's type needs from the project with `instance(dep.type("<Type>"), id, values)` in
121
+ `definePackage({ instances: [...] })`: every type a build names in `No master data is registered for domain model
122
+ "<Type>"`. Never author a row whose id a surface lists for the same type (`shippedRowIds`,
123
+ `shippedRowsOfDependencyTypes`): a package ships it, and a row with its id replaces it (use `overlayInstance`). Take
124
+ the values from `types.<Type>.propertyDetails` of the surface. Give a value to every `requirement: "always"` property
125
+ except `id` (the row id), `userData` properties and action lists
126
+ (`list<consumeAction>` and the other action kinds): a missing one fails the build. An action list you leave out
127
+ deploys as what `actionPropertyTransforms` add to it, or empty.
128
+ - Choose each property's binding hint by what reads its value, also for a property an overlay adds: the client, from
129
+ the rows you author (a UI component shows it) → `.assetDelivery()`; only an `actionPropertyTransforms` argument → no
130
+ hint; a field a master data resource of this package binds → `.masterData()`. See the table in
131
+ [Property modifiers](REFERENCE.md#property-modifiers).
132
+ - Check the value keys of rows written with a dependency type (`instance(dep.type("Energy"), ...)`) against the
133
+ published property names yourself: `tsc` does not check them, and `dsl build` refuses an unknown one
134
+ (`unresolvedPropertySlot`).
135
+ - Regenerate surface files after a dependency changes. Never edit them by hand.
136
+ - In master data, use `Bind.domainProperty` only in a resource mounted on a domain type, and never use
137
+ `Bind.domainProperties` (user data only). `dsl build` accepts both mistakes; the editor and code generation refuse
138
+ them.
139
+ - When you edit `id-ledger.json`, keep the key order `schemaVersion`, `retired`, `random`, `deterministicOverrides` and
140
+ keep the entries of each section sorted by token.
141
+
142
+ MUST NOT:
143
+
144
+ - Edit generated package JSON in the project.
145
+ - Change, swap or reuse an existing id in `id-ledger.json`. Other packages and projects refer to these ids.
146
+ - Delete ledger entries. Move the entry of a removed thing from `random` to `retired`; move the id of a renamed thing to
147
+ its new token.
148
+ - Hand-write ids (`dt_...`, `prop_...`, `at_...`, `mdr_...`) in the DSL. Take them from a surface or let the build
149
+ generate them.
150
+ - Use `enum`, `namespace` with values, parameter properties, top-level `await`, dynamic `import()` of the DSL modules,
151
+ `node:*` modules or npm packages other than `gs2-studio-dsl`.
152
+ - Attach one `defineMasterDataResource` / `defineUserDataResource` definition in two places.
153
+ - Use one `defineInlineElement` schema for two list properties.
154
+
155
+ Names and ids:
156
+
157
+ - You write names; GS2 Studio stores ids. The ledger maps names (tokens such as `property:Item.count`) to ids.
158
+ - Renaming a type, property, row or transform: the build reports the old token as "not current" and the new one as
159
+ missing, in one line that says it looks like a rename and names the id to move when it can pair them. In
160
+ `id-ledger.json`, move the old token's id to the new token in `random`, then build without `--write-ledger`. Never let
161
+ `--write-ledger` record a new id for a renamed thing. Renaming a type also renames its `property:<Type>.<name>` and
162
+ row tokens; move each of them, all before the next build. It also changes, without a message, the ids of the
163
+ type's UI component and its items and of user data resources mounted on the type; keep them with
164
+ `deterministicOverrides`. See [The id ledger](REFERENCE.md#the-id-ledger).
165
+ - A row id is letters, digits, `_`, `.` and `-`, at most 128 characters; a resource that binds `id` to a GS2 name sends
166
+ it as that name (a `micro-economy-quest` `Quest` row id is the quest model name), and some GS2 fields take fewer.
167
+ - A row token contains the row id. Before you treat a "not current" + "missing" row token pair as a rename of a
168
+ composite-key row, check the new row id against the composite key rule below; a wrong id must be fixed in the DSL,
169
+ not moved in the ledger.
170
+ - A composite-key row id is its key values joined with `.` in ascending order of the key members' property ids in the
171
+ ledger, not in the order passed to `compositeKey`. Build the type with `--write-ledger` before adding its rows,
172
+ read the ids, then add the rows. See [Keys and identity](REFERENCE.md#keys-and-identity).
173
+
174
+ ## 5. API cheat sheet
175
+
176
+ | Task | API | Reference |
177
+ | --- | --- | --- |
178
+ | Declare a package | `definePackage({ id, version, display?, dependencies?, domainTypes?, instances?, ... }).build()` | [Packages](REFERENCE.md#packages) |
179
+ | Label a package or type | `display` on `definePackage`; `localizedDisplay` on `defineDomainType` / `defineOverlayDomainType` / `defineInlineElement` | [Packages](REFERENCE.md#packages), [Domain types](REFERENCE.md#domain-types) |
180
+ | Declare a type | `defineDomainType(name, { properties, localizedDisplay?, localizedProperties?, singleEntry?, compositeKey?, sort?, delegatedActions? })` | [Domain types](REFERENCE.md#domain-types) |
181
+ | Declare a property | `PT.int32().masterData().required()`, `PT.ref(Item)`, `PT.enum("a", "b")` in `properties: { name: ... }` | [Properties](REFERENCE.md#properties) |
182
+ | Choose a binding hint | `.assetDelivery()` (the client shows it), none (only a transform argument), `.masterData()` (a resource binds it) | [Property modifiers](REFERENCE.md#property-modifiers) |
183
+ | Text shown in the player's language (a display name) | One `displayName: PT.localizedString().assetDelivery()`, rows `{ ja: "...", en: "..." }`, a `UiItem.label` on it; not one property per language | [Localized text](REFERENCE.md#localized-text) |
184
+ | Localized text in a template or a condition | `templateLabel` placeholder and `UiCond.truthy` / `eq` / `neq` read the player's locale's translation; never `gt`/`lt`, never against a number | [Localized text](REFERENCE.md#localized-text) |
185
+ | Conditional requirement | `.requiredWhen(Cond.eq("limited", true))` | [Conditions](REFERENCE.md#conditions) |
186
+ | Identity and order | `singleEntry: true`, `compositeKey: [...]`, `sort: { key, direction? }` | [Keys and identity](REFERENCE.md#keys-and-identity) |
187
+ | Author rows | `instance(definition, id, values)` in `instances: [...]` | [Instances](REFERENCE.md#instances) |
188
+ | Rows a dependency's type needs from the project | `instance(dep.type("Energy"), id, values)` in `instances: [...]` | [Instances](REFERENCE.md#instances) |
189
+ | Change a row a dependency ships | `overlayInstance(type, sourceInstanceId, { overrides?, suppressed? })` in `overlayInstances: [...]` | [Instances](REFERENCE.md#instances) |
190
+ | Extend a dependency's type | `defineOverlayDomainType(name, dep.overlay(name), { properties?, actionPropertyTransforms?, ... })` | [Overlay types](REFERENCE.md#overlay-types) |
191
+ | List of structured elements | `defineInlineElement(name, { properties, elementKey?, ... })`, `PT.listOf(PT.inlineElement(schema))`, `inlineElementOf(Host, "listProp")` | [Inline elements](REFERENCE.md#inline-elements) |
192
+ | Configure a GS2 master data model | `defineMasterDataResource({ model: GS2.svc.Model, mount: T, bindings: {...}, children?, arrayChildren? })` | [Master data resources](REFERENCE.md#master-data-resources) |
193
+ | Map GS2 user data to properties | `defineUserDataResource({ model: GS2.svc.Model, linkedMaster?, mount?, bindings: {...}, children? })` | [User data resources](REFERENCE.md#user-data-resources) |
194
+ | Field values | `Bind.*`, `Source.direct(T, "prop")`, `Source.parent(...)`, `transactionSettingV2()` | [Bindings](REFERENCE.md#bindings) |
195
+ | Actions of an action entry | `ActionProgram.transform(transform, [Arg...])`; a dependency's: `dep.transformProgram(name, { count: { kind: "domainProperty", source: Source.parent(Source.direct(T, "count")) } })` | [Action programs and arguments](REFERENCE.md#action-programs-and-arguments) |
196
+ | Add a dependency's transform to an inherited action property | `actionPropertyTransforms: [{ targetProperty, mode: "append", ...dep.transformCall(name, { count: { kind: "domainProperty", propertyName: "price" } }) }]` | [Overlay types](REFERENCE.md#overlay-types) |
197
+ | Produce GS2 actions from parameters | `defineActionTransform(name, { category, parameters, outputs })` + `OutputMap.*` | [Action transforms](REFERENCE.md#action-transforms) |
198
+ | A method that runs a GS2 action | `delegatedActions: { Method: { targetActionKey, targetResource } }` on the type, or `definePackage({ delegatedActions: [{ target, methodName, action: { targetActionKey, targetResource } }] })` | [Delegated actions](REFERENCE.md#delegated-actions) |
199
+ | Generated UI | `defineUiComponent(T, { items: [UiItem.label(...), UiItem.buttonAction(...)] })`, `UiSource.*`, `UiCond.*` | [UI components](REFERENCE.md#ui-components) |
200
+ | Enable a button by another type's row (stamina, coins) | `UiItem.interactable("StartInteractable", UiCond.gte(UiSource.rowProp(energy.type("Energy"), "stamina", "currentValue"), UiSource.prop("staminaCost")))` | [Another type's row](REFERENCE.md#another-types-row) |
201
+ | Choose a UI item and its options | `label` shows text, `templateLabel` text around values, `value` sends a typed value the game formats; a button never disables itself (add `interactable`). `{ name, description }` only label the item in GS2 Studio's editor; leave them out | [UI components](REFERENCE.md#ui-components), [Item options](REFERENCE.md#item-options) |
202
+ | Show every row in the game, in order | A UI component describes one row; the generated `<T>ListHandler` makes one instance of a prefab per row, in the order of `sort` (an overlay: the dependency's order unless it sets a `sort` other than id ascending) | [Rows in the game](REFERENCE.md#rows-in-the-game) |
203
+ | A button on a dependency's delegated action | `UiItem.buttonAction("StartButton", "Start", args, options)`; `args` takes only the names under `types.<T>.delegatedActions.Start.parameters` of the surface and needs each `required: true` one; with none required it may be `undefined` | [Dependencies](REFERENCE.md#dependencies) |
204
+ | Code template | `codeTemplates: [{ outputFileName: "File.cs", templateSource: text }]` with a `?raw` import | [Code templates](REFERENCE.md#code-templates) |
205
+ | Use another package of the project | `dependencyPackage(surface)`, `dependencies: { [dep.packageId]: spec }`; spec `"*"` (authored in the project), or for an installed package the spec the package that installed it declares (`"github:gs2io/gs2-studio-package"` for an official package) | [Dependencies](REFERENCE.md#dependencies) |
206
+
207
+ ## 6. Common mistakes
208
+
209
+ | Symptom | Cause | Fix |
210
+ | --- | --- | --- |
211
+ | `CLI_DSL_LOAD_FAILED` ... `imports X from "gs2-studio-dsl", which exports no value with that name` | A type imported as a value. | Use `import type` / `type X`. |
212
+ | `CLI_DSL_LOAD_FAILED` ... `which a DSL cannot import` | An import other than the published modules, relative `.ts`, `.json` or `?raw` files. | Remove it; inline the code or copy the file into the DSL directory. |
213
+ | `CLI_DSL_LOAD_FAILED` ... `dependency surface: no type named "X"` (or `no property`, `no ActionTransform`) | The name is not in the surface file, or the surface is stale. | Rerun `dsl surfaces`; use a published name. |
214
+ | `tsc`: `... is not assignable to parameter of type 'never'` on `dep.transformCall` / `dep.transformProgram`, or `CLI_DSL_LOAD_FAILED` ... `publishes no parameters of ActionTransform` | The surface file was written by a GS2 Studio that did not publish transform signatures. | Rerun `dsl surfaces` (and `dsl build` of a dependency you author). |
215
+ | `tsc`: `Object literal may only specify known properties` in a `transformCall` argument, or `ActionTransform "X" has no parameter "y"` / `needs the required parameter "z"` | A wrong or missing parameter name. The message lists the parameters. | Use the names under `actionTransformSignatures.X.parameters` of the surface. |
216
+ | `CLI_DSL_EXPORT_INVALID` | Zero or several built packages exported. | Export exactly one `definePackage({...})` or `.build()` result. |
217
+ | `{"kind":"domainTypeDefinitionNotRegistered",...}`, `{"kind":"invalidInstanceType",...}`, `{"kind":"uiComponentTargetTypeUnknown",...}` | A definition used (in a mount or binding, a row, a UI component) without being listed in `domainTypes: [...]`. | Include it in `definePackage({ domainTypes: [...] })`. |
218
+ | `{"kind":"reservedPropertyName",...}` | A property named `id`. | Rename it; `id` exists already. |
219
+ | `{"kind":"unresolvedPropertySlot",...}` | A misspelled or undeclared property name in values, overlay options or UI. | Use a declared or published name; the error lists both. |
220
+ | `{"kind":"uiComponentUnknownProperty",...}` / `{"kind":"uiComponentUnknownDelegatedAction",...}` | `UiSource.prop` or `UiItem.buttonAction` names something the target lacks. | Declare the property or register the delegated action on that type. |
221
+ | `{"kind":"duplicateUiComponentClassName",...}` | Two items of the same type share a class name. | Make class names unique per type. |
222
+ | `{"kind":"uiComponentTemplateLabelKeyMismatch",...}` | `{key}` placeholders and `sources` keys differ. | Make them match one to one. |
223
+ | `{"kind":"singleEntryInstanceIdMismatch",...,"expectedId":"..."}` | Wrong row id on a single-entry type. | Use `expectedId`. |
224
+ | `{"kind":"invalidCompositeKey","reason":"unsupportedMemberBindingHint",...}` | A key member without `masterData` / `assetDelivery`. | Add the hint. |
225
+ | `{"kind":"invalidSortKey","reason":"notRequired",...}` | Sorting by an optional property. | Make it `.required()` or sort by `"id"`. |
226
+ | `{"kind":"invalidBindingValue",...}` | A binding kind the resource does not accept (for example `Bind.resourceKey()` on user data), a malformed directive, or an inline schema used twice. | Read `context`; use an accepted kind. |
227
+ | `{"kind":"unresolvedResourceRef",...}` | A `resource`, `linkedMaster`, `resourceLink` or `mountedResource` handle names a resource never included in the package's `masterDataResources` / `userDataResources` trees. | Include the resource in `masterDataResources`, `userDataResources`, `children`, or `arrayChildren`. |
228
+ | `{"kind":"resourceDefinitionAttachedTwice",...}` | One resource definition included in two places (two `children` lists, or a root and a child). | Make a second definition with its own `defineMasterDataResource` / `defineUserDataResource`. |
229
+ | `{"kind":"unresolvedParentBinding",...}` | `Source.parent(...)` on a root resource. | Use `Source.direct(...)`, or move the resource under a parent. |
230
+ | `CLI_DSL_LEDGER_MISSING` | First build without `--write-ledger`. | Add `--write-ledger`. |
231
+ | `CLI_DSL_LEDGER_MISMATCH` ... `random token ... is missing from the ledger`, and no token is "not current" | You added something. | Check the tokens, then rebuild with `--write-ledger`. |
232
+ | `CLI_DSL_LEDGER_MISMATCH` ... `looks like a rename: ... move its id "<id>" from "<old>" to "<new>"` | You renamed something, or changed a row id. | If you renamed it, move the id as the line says (a changed composite-key row id: first check it against the composite key rule). If you removed it and added another, do what the line's last sentence says. Then rebuild without `--write-ledger`. |
233
+ | `CLI_DSL_LEDGER_MISMATCH` ... `is not current; move it to retired` | You renamed or removed something, or changed a row id. | A changed composite-key row id: first check it against the composite key rule. Renamed: move the old token's id to the new token. Removed: move token and id to `retired`. Then rebuild without `--write-ledger`. |
234
+ | `CLI_DSL_LEDGER_INVALID` ... `not canonical` | The ledger's key order, entry order, indentation or final newline differs from what GS2 Studio writes. | Restore that form (section 4). |
235
+ | `CLI_DSL_VALIDATION_FAILED` ... `No master data resource binds this property.` | A `.masterData()` property no resource binds. | Bind it with `Bind.domainProperty(Source.direct(T, "prop"))` in a resource mounted on `T`, or remove the hint. |
236
+ | `CLI_DSL_VALIDATION_FAILED` ... `No user data resource binds this property.` | A `.userData()` property no resource binds. | Bind it in a user data resource (`Bind.domainProperty` / `Bind.domainProperties` with `Source.direct(T, "prop")`), or remove the hint. |
237
+ | `CLI_DSL_VALIDATION_FAILED` ... `No Handler is generated for the target domain model` | A UI component on a type that gets no Handler (`generatedHandlers: []` in its surface). | Mount the type with a user data resource or a master data resource of a model other than a namespace, or remove the component. |
238
+ | `CLI_DSL_VALIDATION_FAILED` ... `the condition cannot read a value of another domain model's row` | A `UiSource.rowProp` of a type that gets no Handler. | Read a type whose `generatedHandlers` is not `[]`, or remove the item. |
239
+ | `CLI_DSL_VALIDATION_FAILED` ... `instance ids that no longer match their composite-key values` | Row ids not composed from key values in property-id order. | Recompose ids per [Keys and identity](REFERENCE.md#keys-and-identity). |
240
+ | `CLI_DSL_DEPENDENCY_NOT_INSTALLED` | `dependencies` names a package the project lacks. | A package authored in the project: build it with `dsl build` first. Another package: add it in GS2 Studio. |
241
+ | `CLI_DSL_PACKAGE_INVALID` ... `Invalid GitHub dependency spec: github:<owner>/<repo>/<dir>` | A subdirectory in a GitHub spec. | Use `github:<owner>/<repo>`; the project's lock records the directory. |
242
+ | `CLI_DSL_DEPENDENCY_SPEC_MISMATCH` | `dependencies` gives an installed package a spec that names another source than the one the project installed it from, such as `"*"`. | Declare it with the spec the message prints, then build again. |
243
+ | `CLI_DSL_VALIDATION_FAILED` ... `the parent <resource> resource has no row` ... `Add a row of "T"` | Rows of a dependency's type sit under a GS2 resource made from rows of `T`, which nobody authored. | Add a row of `T` with `instance(dep.type("T"), id, values)` and point your rows at it (for example the `collection` of a quest row). |
244
+ | `... is a dependency the DSL cannot change, so these are fixed through the dependency that brings it in: ...` | A defect of the dependency itself, not of this DSL. | If the message says to remove the dependency `"X"` from the DSL and the package does not need X, remove it and what refers to it. Otherwise tell the user: the project's owner updates or removes the dependency in GS2 Studio, as the message says. |
245
+ | A successful build prints `[warning] ... No master data is registered for domain model "T"` | A dependency's GS2 resource needs rows of `T` from the project; it is not deployed without them. | Add the row the message names, `instance(dep.type("T"), id, values)`, with the values it names, and build again. `dep.type("<Type>")` means the message names no type `dep.type()` takes: for an inline schema, add elements to the host type's list property with `dep.inlineElements(...)`; for an unresolved type, find it in the surfaces. |
246
+ | A successful build prints `[error] ... the required arguments (...) of action transform ... have no value for row "r"` | An `actionPropertyTransforms` argument reads a property row `r` has no value for. | Give the row the value; for a row a dependency ships, use `overlayInstance(type, "r", { overrides })`. |
247
+ | `CLI_DSL_VALIDATION_FAILED` ... `is not a UTC ISO 8601 timestamp` | A `PT.timestamp()` value in another form, such as with an offset (`+09:00`). The message says `In package "<your package>"` when the row is yours, even of a dependency's type. | Write it in UTC with `Z`, such as `"2026-11-30T15:00:00Z"`, in that `instance(...)` (see [Property types](REFERENCE.md#property-types)). |
248
+ | A UI item of a property you added shows nothing (or `0`) in the game | The property has no binding hint, so the client never gets its value. | Give it `.assetDelivery()`. |
249
+
250
+ ## 7. Minimal complete example
251
+
252
+ A package with one type, a master data resource tree, a user data resource, a UI component and two action transforms.
253
+ It builds with `dsl build` as shown in the workflow.
254
+
255
+ ```ts
256
+ import {
257
+ Bind,
258
+ defineActionTransform,
259
+ defineDomainType,
260
+ defineMasterDataResource,
261
+ definePackage,
262
+ defineUiComponent,
263
+ defineUserDataResource,
264
+ type LocalizedDisplay,
265
+ OutputMap,
266
+ PT,
267
+ Source,
268
+ UiCond,
269
+ UiItem,
270
+ UiSource,
271
+ } from "gs2-studio-dsl";
272
+ import { GS2 } from "gs2-studio-dsl/gs2";
273
+
274
+ function text(label: string, description: string): LocalizedDisplay {
275
+ return { en: { label, description } };
276
+ }
277
+
278
+ const Item = defineDomainType("Item", {
279
+ properties: {
280
+ count: PT.int64().userData().required(),
281
+ },
282
+ localizedDisplay: text("Item", "An item a player can own."),
283
+ localizedProperties: {
284
+ id: text("ID", "Identifies the item."),
285
+ count: text("Owned quantity", "How many of the item the player owns."),
286
+ },
287
+ });
288
+
289
+ const SimpleItemModel = defineMasterDataResource({
290
+ model: GS2.inventory.SimpleItemModel,
291
+ mount: Item,
292
+ bindings: {
293
+ name: Bind.domainProperty(Source.direct(Item, "id")),
294
+ },
295
+ });
296
+
297
+ const AcquireItem = defineActionTransform("AcquireItem", {
298
+ category: "acquire",
299
+ parameters: {
300
+ itemName: { type: PT.ref(Item) },
301
+ count: { type: PT.int32() },
302
+ },
303
+ outputs: [
304
+ {
305
+ kind: "direct",
306
+ actionName: "Gs2Inventory:AcquireSimpleItemsByUserId",
307
+ resource: SimpleItemModel,
308
+ parameterMappings: {
309
+ namespaceName: OutputMap.resourceKey(),
310
+ inventoryName: OutputMap.resourceKey(),
311
+ userId: OutputMap.placeholder("#{userId}"),
312
+ "acquireCounts[0].itemName": OutputMap.parameter("itemName"),
313
+ "acquireCounts[0].count": OutputMap.parameter("count"),
314
+ },
315
+ },
316
+ ],
317
+ });
318
+
319
+ const ConsumeItem = defineActionTransform("ConsumeItem", {
320
+ category: "consume",
321
+ parameters: {
322
+ itemName: { type: PT.ref(Item) },
323
+ count: { type: PT.int32() },
324
+ },
325
+ outputs: [
326
+ {
327
+ kind: "direct",
328
+ actionName: "Gs2Inventory:ConsumeSimpleItemsByUserId",
329
+ resource: SimpleItemModel,
330
+ parameterMappings: {
331
+ namespaceName: OutputMap.resourceKey(),
332
+ inventoryName: OutputMap.resourceKey(),
333
+ userId: OutputMap.placeholder("#{userId}"),
334
+ "consumeCounts[0].itemName": OutputMap.parameter("itemName"),
335
+ "consumeCounts[0].count": OutputMap.parameter("count"),
336
+ },
337
+ },
338
+ ],
339
+ });
340
+
341
+ export const exampleInventory = definePackage({
342
+ id: "example-inventory",
343
+ version: "0.0.1",
344
+ display: text("Items", "Tracks the items a player owns."),
345
+ domainTypes: [Item],
346
+ masterDataResources: [
347
+ defineMasterDataResource({
348
+ model: GS2.inventory.Namespace,
349
+ bindings: {
350
+ name: Bind.static("Inventory"),
351
+ },
352
+ children: [
353
+ defineMasterDataResource({
354
+ model: GS2.inventory.SimpleInventoryModel,
355
+ bindings: {
356
+ name: Bind.static("Inventory"),
357
+ },
358
+ arrayChildren: {
359
+ simpleItemModels: [SimpleItemModel],
360
+ },
361
+ }),
362
+ ],
363
+ }),
364
+ ],
365
+ userDataResources: [
366
+ defineUserDataResource({
367
+ model: GS2.inventory.SimpleItem,
368
+ linkedMaster: SimpleItemModel,
369
+ bindings: {
370
+ count: Bind.domainProperties([Source.direct(Item, "count")]),
371
+ itemName: Bind.skip(),
372
+ userId: Bind.skip(),
373
+ },
374
+ }),
375
+ ],
376
+ uiComponents: [
377
+ defineUiComponent(Item, {
378
+ items: [
379
+ UiItem.templateLabel("StockLabel", "{id} x{count}", {
380
+ id: UiSource.prop("id"),
381
+ count: UiSource.prop("count"),
382
+ }),
383
+ UiItem.value("CountValue", UiSource.prop("count")),
384
+ UiItem.interactable(
385
+ "OwnedInteractable",
386
+ UiCond.gt(UiSource.prop("count"), UiSource.lit(0))
387
+ ),
388
+ ],
389
+ }),
390
+ ],
391
+ actionTransforms: [AcquireItem, ConsumeItem],
392
+ });
393
+ ```
394
+
395
+ Its `id-ledger.json` after the first `dsl build --write-ledger`:
396
+
397
+ ```json
398
+ {
399
+ "schemaVersion": 1,
400
+ "retired": {},
401
+ "random": {
402
+ "property:Item.count": "prop_1DQWSQS8AC837BT0EWF1439PFW",
403
+ "transform:AcquireItem": "at_0XAMJJD9WX8S0TR71Z8KMQ8V80",
404
+ "transform:ConsumeItem": "at_1YA7MG1XJH88XT3P4Z6JF09ZVW",
405
+ "type:Item": "dt_20QRK0BTMW89TAWPHGNYFXNYJ5"
406
+ },
407
+ "deterministicOverrides": {}
408
+ }
409
+ ```
410
+
411
+ For dependencies, overlays, delegated actions and code templates, read the `example-gift-shop` sections of
412
+ [REFERENCE.md](REFERENCE.md#dependencies). For an overlay that appends a dependency's transform to an inherited action
413
+ property with `dep.transformCall`, read `example-gift-sale` in [Overlay types](REFERENCE.md#overlay-types).
package/README.md CHANGED
@@ -5,12 +5,15 @@ GS2 Studio evaluates the DSL itself: it strips the TypeScript types with Node's
5
5
  stripping and runs the result against the DSL runtime bundled in the app. The app does not
6
6
  type-check; use these declarations in your editor and with `tsc --noEmit`.
7
7
 
8
+ - Syntax reference: [REFERENCE.md](REFERENCE.md)
9
+ - For LLM coding agents: [LLM.md](LLM.md)
10
+
8
11
  ```sh
9
- npm install --save-dev gs2-studio-dsl@2026.11.10
12
+ npm install --save-dev gs2-studio-dsl@2026.11.14
10
13
  ```
11
14
 
12
15
  The version is the GS2 Studio version whose DSL these declarations describe: a DSL written
13
- against gs2-studio-dsl 2026.11.10 builds with GS2 Studio 2026.11.10 and later. Install the version that
16
+ against gs2-studio-dsl 2026.11.14 builds with GS2 Studio 2026.11.14 and later. Install the version that
14
17
  matches the oldest GS2 Studio you build with.
15
18
 
16
19
  ```ts
@@ -44,7 +47,9 @@ parameter properties), and type-only imports must be marked with `import type`:
44
47
  "erasableSyntaxOnly": true,
45
48
  "resolveJsonModule": true,
46
49
  "allowImportingTsExtensions": true,
47
- "types": ["gs2-studio-dsl/raw"]
50
+ "types": [
51
+ "gs2-studio-dsl/raw"
52
+ ]
48
53
  }
49
54
  }
50
55
  ```
@@ -57,9 +62,14 @@ parameter properties), and type-only imports must be marked with `import type`:
57
62
  The GS2 Studio executable runs the `dsl` commands headless and exits with their exit code:
58
63
 
59
64
  ```sh
60
- # write <out>/<packageId>.json for each dependency the project installs
65
+ # start a DSL directory for the project: package.json, this tsconfig, a starter index.ts, docs/LLM.md,
66
+ # docs/REFERENCE.md, AGENTS.md (CLAUDE.md) with these commands, and surfaces/; then run npm install in it
67
+ "<GS2 Studio>" dsl init --dir <project> --out <dsl> --package-id <id>
68
+ # write <out>/<packageId>.json for each package of the project (installed or authored in it)
61
69
  "<GS2 Studio>" dsl surfaces --dir <project> --out <out>
62
- # evaluate the DSL, check it, and save the package into the project (--write-ledger the first time)
70
+ # evaluate the DSL, check it, and save the package it declares into the project beside the project's other packages
71
+ # (--write-ledger the first time); after saving it prints the [error] and [warning] lines project check reports, or a
72
+ # line saying there are none, and exits with 0
63
73
  "<GS2 Studio>" dsl build --dir <project> --entry <dsl/index.ts> --write-ledger
64
74
  ```
65
75