earslang.com

module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2026 License: Apache-2.0

README

earslang

The name stands for EARS Amplified by RFC for Spec-Driven Development.

A markdown format for writing requirements: the sentence patterns of EARS with the keywords of BCP 14 (RFC 2119 and RFC 8174), with capitals marking the structure of every sentence. It is written in .ears files or ```ears blocks inside markdown, and read and edited by any markdown tool. This repository holds the compiler, ears, which checks the format and writes the rules out as JSON, and the specification.

The website, with a playground that runs this compiler in the browser, is https://earslang.com/. Its source is https://gitlab.com/earslang/site.

Status: earslang 0.1. Every command of 0.1 is built (the spec says which). Every part may still change.

---
source: Support requests about lost changes
---

- R1: The app MUST work with no account and no sign-in.
- R2: WHEN the user closes a file, THEN the app MUST ask before discarding changes.
- R3: The app SHOULD sync in the background. [proposed]

Classic EARS and earslang

EARS (Easy Approach to Requirements Syntax, Mavin et al., 2009) is the base. earslang keeps its sentence patterns, adds strength levels, and makes capitals the signal for structure. It is not endorsed by the authors of EARS or of BCP 14.

Classic EARS earslang
Sentence patterns Ubiquitous, State, Event, Optional feature, Unwanted, and combinations the same
Condition words sentence case: When, While, Where, If, then capitals: WHEN, WHILE, WHERE, IF, THEN; in lowercase they are ordinary text, except in a classic EARS sentence
THEN only after "If" once, after the conditions; may be left out before a system declared in ears.mod
Commas between conditions and before the subject optional; the standard form keeps them
Obligation shall MUST, SHALL, or "X is REQUIRED"
Prohibition shall not MUST NOT, SHALL NOT
Recommendation none SHOULD, SHOULD NOT, "X is RECOMMENDED", "X is NOT RECOMMENDED"
Permission none ("Where" is for optional features, not permission) MAY, "X is OPTIONAL"
Capital letters not part of the method required for keywords (RFC 8174) and for structure words
Classic text — accepted in a rule with no structure word, when a comma or "then" follows its conditions or its subject is a declared system; ears fix rewrites it in the standard form
Where it is written prose documents markdown: .ears files or ```ears blocks; a plain list of classic EARS sentences is already valid when each has one "shall" and a comma or "then" after its conditions, or a declared system as its subject
Checked by review by a compiler: keywords, sentence structure, IDs, the tags that cite other rules, and rules that contradict each other

A classic EARS sentence with one "shall" is valid earslang when a comma or "then" follows its conditions, or its subject is a system declared in ears.mod (S7.4). All eleven keywords of BCP 14 are accepted. A project bound to "shall" sets spelling shall in ears.mod, and the standard form then writes SHALL.

If you already know EARS, RFC 2119 or Gherkin

- L1: The app MUST save every change.
- L2: WHEN the user closes a file, THEN the app MUST ask before discarding changes.
- L3: WHILE offline, THEN the app SHOULD queue every change.
- L4: IF the disk is full, THEN the app MUST warn the user.

One rule per list item. A list item or a paragraph line with a keyword is a rule, and so is one with a lowercase "shall" and no structure word. The lines of a paragraph join, as a list item's continuation lines do, so a paragraph line with neither, before or after a rule's line, is part of that rule; other text is prose. A rule is in force unless tagged ([proposed], [dropped]). An ID such as L4: lets other rules cite this one ([from L4]). IDs are optional, but once one rule in a file has one, the compiler warns about each rule that does not.

You know What is different
EARS WHEN, WHILE, WHERE, IF and THEN are in capitals. THEN comes once, after all the conditions, not only after IF. Besides shall (still accepted), you have MUST, SHOULD and MAY. A valid classic EARS sentence is still read, and ears fix rewrites it in the standard form.
RFC 2119 The keywords mean what you know; MAY NOT is refused (use MUST NOT, or MAY with a positive response). One keyword per rule. Conditions come first, in capitals, then THEN.
Gherkin Given becomes WHILE for a state or WHEN for an event; GIVEN is refused. When is WHEN. Then is THEN followed by the system and a strength: "THEN the app MUST …". For And or But between conditions, repeat the condition word: "WHEN a, WHEN b". Scenarios stay in Gherkin; ears export --out gherkin writes their skeletons.

A common first mistake is a condition with no THEN:

error[E0015]: THEN is required after a condition
 --> rules.ears:1:32
  |
1 | - WHEN the user saves, the app MUST write the file.
  |                                ^^^^
  = help: write THEN after the comma: "WHEN the user saves, THEN the app MUST write the file."

ears explain <code> prints a code's explanation, for example ears explain E0015.

Installing

Download a binary for macOS, Linux or Windows from the releases page or https://earslang.com/download/, and check it against SHA256SUMS. Or, with Go:

go install earslang.com/cmd/ears@latest

From a checkout, go build ./cmd/ears. go.mod names the Go toolchain (1.27.3), which an older Go fetches by itself. The outside dependencies are the goldmark markdown parser and Cucumber's Gherkin parser, with its messages module and Google's uuid. The commands are listed in the spec, §11.

For a web page, GOOS=js GOARCH=wasm go build ./cmd/ears-wasm builds the same compiler for the browser: the page hands it the files and nothing is sent anywhere. Its package comment gives the request and reply. The page loads it with cmd/ears-wasm/wasm_exec.js, Go's loader, kept in the repository and held to its hash by a test.

Development

go test ./...

GitLab CI runs gofmt, go vet and the tests on every push, and builds the programs for macOS, Linux and Windows. A tag such as v0.1.1 also publishes those binaries, with a SHA256SUMS file, as a GitLab release. The macOS binaries are not signed with an Apple Developer ID; the download page says how to run one.

Plan

Version Adds
0.1 (this release) the language, check, test, fmt, fix, diff, explain, init, mcp; export to JSON, HTML, markdown and Gherkin; import from Gherkin; plugins (ears-<name>)
0.2 declared states and events, truth tables and the gap report (possibly as an ears-states plugin); traceability: code and tests cite rules in a comment (ears: R1.2), and ears check reports rules in force that nothing cites
0.3 ReqIF export and import
1.0 the conditions for 1.0, still to be written; from 1.0, the compiler accepts every project that was valid under any version from 1.0 up to its own
later a language server (ears lsp) and editor extensions; mermaid and dot exports; a command that suggests the next free ID; markdown files read as earslang without an ears block or the .ears name; keywords in languages other than English; Gherkin import of feature files in a language other than en, English dialects such as en-au among them

Not planned: blocking in ears diff. If it is ever wanted, the acknowledgement goes in the commit message, never in a CI argument.

Open questions

  • Q2. Declared states. Planned for 0.2. In the core, or as an ears-states plugin: to be decided. (Q1, the name, is settled: earslang.)

Licence

Copyright 2026 Richard Pringle II.

The specification and documentation in docs/ are under CC BY 4.0 (docs/LICENSE.md). The compiler and everything else are under the Apache License 2.0 (LICENSE), except cmd/ears-wasm/wasm_exec.js, which is Go's, under the licence in cmd/ears-wasm/wasm_exec.LICENSE.

Directories

Path Synopsis
Package assets holds the files the compiler builds in.
Package assets holds the files the compiler builds in.
cmd
ears command
Command ears is the earslang compiler (spec §11).
Command ears is the earslang compiler (spec §11).
ears-import-kiro command
Command ears-import-kiro is the ears import extension for Kiro (spec §11.4): ears import --from kiro .kiro/specs/<feature>/requirements.md.
Command ears-import-kiro is the ears import extension for Kiro (spec §11.4): ears import --from kiro .kiro/specs/<feature>/requirements.md.
ears-import-openspec command
Command ears-import-openspec is the ears import extension for OpenSpec (spec §11.4): ears import --from openspec openspec/specs/<capability>/spec.md.
Command ears-import-openspec is the ears import extension for OpenSpec (spec §11.4): ears import --from openspec openspec/specs/<capability>/spec.md.
ears-import-speckit command
Command ears-import-speckit is the ears import extension for Spec Kit (spec §11.4): ears import --from speckit specs/<feature>/spec.md.
Command ears-import-speckit is the ears import extension for Spec Kit (spec §11.4): ears import --from speckit specs/<feature>/spec.md.
ears-wasm command
Command ears-wasm is the compiler for a web page, like the TypeScript playground: built for WebAssembly, it runs in the browser and reads the files the page gives it, so nothing is sent anywhere.
Command ears-wasm is the compiler for a web page, like the TypeScript playground: built for WebAssembly, it runs in the browser and reads the files the page gives it, so nothing is sent anywhere.
Package explanations reads the long explanations of diagnostics from assets/diagnostics.md, the one copy.
Package explanations reads the long explanations of diagnostics from assets/diagnostics.md, the one copy.
Package highlight renders earslang text as HTML, coloured by the compiler's tokens and marked by its diagnostics.
Package highlight renders earslang text as HTML, coloured by the compiler's tokens and marked by its diagnostics.
internal
count
Package count writes a count with its noun, so that every message counts alike: "1 file", "2 files".
Package count writes a count with its noun, so that every message counts alike: "1 file", "2 files".
diff
Package diff compares two compiled specs and lists what changed in meaning (§11.5).
Package diff compares two compiled specs and lists what changed in meaning (§11.5).
export
Package export writes the compiled spec in the built-in formats of ears export: json, html, md and gherkin (spec §11.3).
Package export writes the compiled spec in the built-in formats of ears export: json, html, md and gherkin (spec §11.3).
format
Package format is ears fmt and ears fix (spec §11.1, §11.2): the new text of each file they change, worked out in memory.
Package format is ears fmt and ears fix (spec §11.1, §11.2): the new text of each file they change, worked out in memory.
gittest
Package gittest makes git repositories for tests.
Package gittest makes git repositories for tests.
importer
Package importer holds what every importer of ears import shares (spec §11.4): the rules it builds, the markdown it writes, and the list of what it could not map.
Package importer holds what every importer of ears import shares (spec §11.4): the rules it builds, the markdown it writes, and the list of what it could not map.
importer/importertest
Package importertest holds the check every importer's tests share: that an import's output passes ears check.
Package importertest holds the check every importer's tests share: that an import's output passes ears check.
markdown
Package markdown finds the block structure of a markdown file: front matter, headings, and the block-level parts under each heading, with their lines (spec §12).
Package markdown finds the block structure of a markdown file: front matter, headings, and the block-level parts under each heading, with their lines (spec §12).
mcp
Package mcp is ears mcp: a Model Context Protocol server on standard input and output, for AI tools (spec §11).
Package mcp is ears mcp: a Model Context Protocol server on standard input and output, for AI tools (spec §11).
project
Package project reads a project from the disk for the compiler: it finds ears.mod, lists the files (S1.6 to S1.8), skips what git ignores, and reads them.
Package project reads a project from the disk for the compiler: it finds ears.mod, lists the files (S1.6 to S1.8), skips what git ignores, and reads them.
Package spec compiles earslang files into the compiled spec (JSON Schema 0.1, docs/reference/json-schema/0.1/spec.schema.json) and reports diagnostics.
Package spec compiles earslang files into the compiled spec (JSON Schema 0.1, docs/reference/json-schema/0.1/spec.schema.json) and reports diagnostics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL