Chord — The Story Language
Chord is Sharpee's story language. Instead of writing TypeScript against the platform API, you write a .story file — a declarative, block-structured language designed to read like the prose it produces. Chord ships with Sharpee 3.0, and version 1 of the language is locked: what you write today keeps working.
What It Looks Like
Here is a room, an exit that refuses politely, and the prose for it — from the Chord implementation of Cloak of Darkness:
create the Foyer of the Opera House
a room
aka foyer, hall, entrance
west to the Cloakroom
south to the Foyer Bar
north is blocked: cant-leave
You are standing in a spacious hall, splendidly decorated in red and
gold, with glittering chandeliers overhead. The entrance from the
street is to the north, and there are doorways south and west.
Objects declare their traits the same way — the same snap-together pieces you know from the platform, in plain words:
create the brass hook
aka hook, peg
scenery, a supporter with capacity 1
in the Cloakroom
It's just a small brass hook, screwed to the wall.
Behavior attaches directly to the thing that owns it. The message in the sawdust tracks its own state, and reacts when the player reads it:
create the message in the sawdust
aka message, sawdust, floor, writing
scenery
in the Foyer Bar
states: intact, trampled, obliterated
on reading it
select on its state
when intact
phrase message-intact
win
when trampled
phrase message-trampled
when obliterated
phrase message-obliterated
lose
end select
end on
And every piece of text lives in one place, registered by name — the same logic-and-prose separation the platform has always enforced, now built into the language:
define phrases en-US
cant-leave:
You've only just arrived, and besides, the weather outside seems
to be getting worse.
stumble:
Blundering around in the dark isn't a good idea!
The complete Cloak of Darkness is under 100 lines of Chord. The equivalent TypeScript implementation is 785 lines.
And it scales past toy examples: the entire Family Zoo — the book's game, with NPCs, timed events, custom actions, and scoring — is written in Chord as a single zoo.story file.
How It Works
Chord compiles to Story IR — a typed, JSON-serializable representation of your story — which Sharpee's story loader interprets at runtime. Your prose flows through the same phrase algebra as every other Sharpee story, your objects are the same traits and behaviors, and the parser understands the same commands. Chord is a new front door, not a separate engine.
The compiler runs a set of load-time gates over your story before it will produce anything: unknown states, unbound phrase markers, unreachable rules — each reported with the .story line number where you can fix it.
Escape Hatches
When a puzzle needs real code, you don't leave Chord — you declare a hatch: a named TypeScript export with a small, documented interface, bound when the story loads.
define text garbled from "./extras.ts"
Everything else stays declarative. Stories with no hatches are pure data.
Try It
The compiler ships with the CLI you already have:
npm install -g @sharpee/devkit
sharpee compose my-story.story
compose parses and analyzes your story, reports any diagnostics, proves the result actually loads, and emits the Story IR. Use --check to run only the gates (handy in CI), or -o story-ir.json to write the IR to a file.
Reference
- Chord language reference — every construct explained in plain language with a working, compile-checked example
- Chord grammar reference — the full language, production by production
- chord.ebnf — the standalone EBNF grammar
- cloak.story — the complete Cloak of Darkness in Chord
- zoo.story — the complete Family Zoo in Chord, the language's full-scale reference story