Format reference
Project and Versions
Resource
A project is a folder. Every resource file in it has the same three fields:
apiVersion: dialogue/v1 # <plugin>/<version>
kind: Dialogue # what this resource is
data: # the resource itself
id: 01_intro_sceneEvery *.yaml and *.json file in the folder is loaded, in subfolders too (folders whose name starts with . are skipped), and which file a resource lives in does not matter. Each file holds exactly one resource. JSON files have the same content as YAML ones.
data.id is unique per kind: a Character and a Document may share an id, two Characters may not. Ids use ASCII letters, digits, _ and - (not as the first character), never dots, because dots separate the parts of references and translation keys. Other resources are referenced as Kind.id, for example Dialogue.02_shadows_speak or Character.stranger; variables are referenced by their bare id in set and requires.
Versions
Every .osf project has exactly one Versions block, normally in versions.osf. It pins the language version and every plugin the project uses, the way Terraform’s versions.tf pins providers. language, story and dialogue are required.
Every resource compiles with its apiVersion taken from this block, so upgrading a plugin is a one-line change in one file. The YAML side shows two of the resources it applies to:
Versions {
language = "1"
story = "v1"
dialogue = "v1"
}osf convertapiVersion: story/v1
kind: Story
data:
id: demo
name: DemoapiVersion: story/v1
kind: Character
data:
id: kael
name: KaelWith plugins
Plugins that are not built in, such as i18n, are listed in Versions and compile to a plugins/v1 Configuration. Using a block whose plugin is not listed (an I18n block without i18n, for example) is an error.
Versions {
language = "1"
story = "v1"
dialogue = "v1"
i18n = "v1"
}osf convertapiVersion: plugins/v1
kind: Configuration
data:
plugins:
- i18n/v1Resources
A project contains resources of these types:
| Type | apiVersion | kind | Built in |
|---|---|---|---|
| Story | story/v1 | Story | yes |
| Character | story/v1 | Character | yes |
| Document | story/v1 | Document | yes |
| Variable | story/v1 | Variable | yes |
| Dialogue, with its nodes and options | dialogue/v1 | Dialogue | yes |
| I18n | i18n/v1 | Configuration | no |
| Locale | i18n/v1 | Locale | no |
| Plugin list | plugins/v1 | Configuration | yes |
Editor support
The JSON Schema gives completion and validation for YAML resources in VS Code, JetBrains and Neovim. Add this first line to a file:
# yaml-language-server: $schema=<relative path>/schema/osf-v1.schema.jsonError codes
osf validate checks the schema and everything a schema cannot express. Every rule has a stable code: OSF001–OSF099 for lexing and parsing .osf, OSF100–OSF199 for structure and references, OSF200–OSF299 for variables, OSF300–OSF399 for translations, and OSF900–OSF999 for warnings. The full list is docs/diagnostics.md.