domaintrail 0.4.0 → 0.5.0

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.
package/README.md CHANGED
@@ -30,19 +30,22 @@ dt -r <root> show <name> # one element resolved: field sets, labels, comm
30
30
  The package installs the same command under two names: `dt` for everyday use and `domaintrail`, its full name, for
31
31
  when `dt` clashes with another command or a script should spell it out (CI, for example).
32
32
 
33
- `<root>` defaults to the current directory; every `*.dt` file below it (except `node_modules`, `.git`, `.domaintrail`)
34
- belongs to the workspace. `dt --help` and `dt <command> --help` show the options with examples.
33
+ `<root>` defaults to the current directory; every `*.dt` file below it (except in `node_modules`, `.git`, `.domaintrail`
34
+ and what `.gitignore` ignores) belongs to the workspace, unless a `domaintrail.jsonc` says otherwise. `dt --help` and `dt <command> --help` show the options with examples.
35
35
 
36
36
  `check` prints diagnostics as `file:line:col - error M00X: message` (with a `hint:` line on what to change, when there is
37
37
  one) and exits non-zero on errors; `check --format json` prints them as one JSON document (`schema/diagnostics.schema.json`).
38
38
  `generate ts` runs `check` first and generates nothing if there are errors.
39
39
 
40
- Try it with the example in this repository (see [Development](#development)):
40
+ Try it with the example in this repository (see [Development](#development)). [examples/shop](examples/shop/README.md)
41
+ is a complete one: the model, the generated code, and the code an AI agent writes against it — the domain
42
+ implementations and a small application layer.
41
43
 
42
44
  ```bash
43
45
  bun run dt -r examples/shop check
44
- bun run dt -r examples/shop generate ts # then examples/shop/src/order-commands.ts type-checks against it
45
- (cd examples/shop && bun test) # and passes the generated contract tests
46
+ bun run dt -r examples/shop generate ts # then examples/shop/src type-checks against it
47
+ (cd examples/shop && bun test) # passes the generated contract tests and the application's tests
48
+ (cd examples/shop && bun src/demo.ts) # a walk through the shop: orders, an invoice, a refund request
46
49
  bun run build && bun run dt -r examples/shop view
47
50
  ```
48
51
 
@@ -72,21 +75,25 @@ The sections, in the guide's order:
72
75
  [domain and technical fields](docs/guide.md#domain-fields-and-technical-fields),
73
76
  [names (表示名)](docs/guide.md#names-labels-and-descriptions),
74
77
  [invariant expressions](docs/guide.md#invariant-expressions), [command requirements](docs/guide.md#command-requirements),
75
- [command changes](docs/guide.md#command-changes), [command events](docs/guide.md#command-events) and
76
- [pure commands](docs/guide.md#pure-commands)
78
+ [command changes](docs/guide.md#command-changes), [command events](docs/guide.md#command-events),
79
+ [pure commands](docs/guide.md#pure-commands), [verified types](docs/guide.md#verified-types) (the evidence of a
80
+ check outside the aggregate, as a command's parameter) and [reactions to events](docs/guide.md#reactions-to-events-policies)
81
+ (policies: when an event happens, a command eventually runs; see [ADR 0022](docs/adr/0022-policy-declarations.md))
77
82
  - [Generated TypeScript](docs/guide.md#generated-typescript): [decisions and `decide`](docs/guide.md#decisions-and-decide),
78
83
  [what is generated and what you write](docs/guide.md#generated-code-and-your-code) (see
79
84
  [ADR 0011](docs/adr/0011-generated-code-boundary.md)), [generated checks](docs/guide.md#generated-checks) and
80
85
  [generated tests](docs/guide.md#generated-tests) (see [ADR 0020](docs/adr/0020-generated-checks-and-contract-tests.md)),
81
86
  [technical metadata](docs/guide.md#technical-metadata) (see [ADR 0013](docs/adr/0013-field-sets-and-technical-metadata.md))
82
87
  and [output directories](docs/guide.md#output-directories)
83
- - [Rules](docs/guide.md#rules): M001–M021, L001–L003
88
+ - [Rules](docs/guide.md#rules): M001–M024, L001–L003
84
89
  - [Looking up one element](docs/guide.md#looking-up-one-element): `dt show`, as text or JSON
85
90
  - [Formatting](docs/guide.md#formatting): `dt fmt`, the one canonical layout of `.dt` files
86
91
  - [Output and exit codes](docs/guide.md#output-and-exit-codes): text, or JSON with `--format json`
87
92
  - [Configuration](docs/guide.md#configuration): `domaintrail.jsonc` (`sources`, `generate.ts.out` /
88
93
  `generate.ts.contexts` / `generate.ts.tests`, `view.port` / `view.host`; JSON Schema in `schema/domaintrail.schema.json`)
89
94
  - [Language server](docs/guide.md#language-server): `dt lsp`, and how to use it from an editor or Claude Code
95
+ - [Editors](docs/guide.md#editors): the Zed extension in `editors/zed` (tree-sitter highlighting, outline, `dt lsp`),
96
+ other editors through `dt lsp` and the tree-sitter grammar in `tree-sitter-domaintrail`
90
97
 
91
98
  A taste of the DSL:
92
99
 
@@ -119,7 +126,9 @@ command transitions ([0014](docs/adr/0014-command-transitions.md)), handlers per
119
126
  ([0017](docs/adr/0017-command-requirements.md)), command events as an exact contract
120
127
  ([0018](docs/adr/0018-command-events-contract.md)), the fields a command changes and decisions
121
128
  ([0019](docs/adr/0019-command-changes-and-decisions.md)), generated checks and contract tests
122
- ([0020](docs/adr/0020-generated-checks-and-contract-tests.md)) and more.
129
+ ([0020](docs/adr/0020-generated-checks-and-contract-tests.md)), event and error fields named after their source
130
+ ([0021](docs/adr/0021-payload-field-names.md)), policy declarations ([0022](docs/adr/0022-policy-declarations.md)),
131
+ verified types ([0023](docs/adr/0023-verified-types.md)) and more.
123
132
 
124
133
  ## Live View
125
134
 
@@ -175,6 +184,8 @@ Requires [Bun](https://bun.sh) (version pinned in `mise.toml`). `bun run dt` run
175
184
  bun install
176
185
  bun run langium:generate # after editing src/language/domain.langium
177
186
  bun run typecheck
187
+ bun run lint # oxlint --type-aware, no narrowing casts without a reason (after `bun run dt -r examples/shop generate ts`)
188
+ bun run fmt # oxfmt (`fmt:check` in CI); the .dt files are formatted by `dt fmt`
178
189
  bun test # the repository's tests (bunfig.toml: test/ only)
179
190
  bun run build # dist/: the CLI bundled for Node and the Live View page (needed by `view` and the tests)
180
191
  ```