@dialecte/cli 0.1.0 → 0.2.1

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
@@ -21,6 +21,32 @@ npm i -D @dialecte/cli # provides the `dialecte` binary
21
21
  dialecte coverage # generate complete, schema-driven type-coverage probes
22
22
  dialecte bench [--check] # measure the type-instantiation cost of your own types (library .d.ts skipped); --check gates CI
23
23
  dialecte audit # render the public type surface and flag readability issues (C1–C6)
24
+ dialecte skills sync # install the agent skills your dependencies ship, for your agents
25
+ dialecte skills generate # refresh the generated blocks of this package's skills
26
+ dialecte skills check # fail on a skill citing what the code no longer has, or an undocumented public function
27
+ dialecte api find "<need>" # find a method by what you need
28
+ dialecte api show <path> # read one method's contract
29
+ dialecte members <expr> # what an expression of the live types holds
30
+ dialecte schema <Tag> # what an element may hold and where
31
+ dialecte models # which model each tier (fast, standard, strong, frontier) means for your vendor
32
+ dialecte doctor # versions, core API generation, skills and station agents in sync, local checkouts
33
+ dialecte rules # code-rules self-check of the changed files
34
+ dialecte gate [--full] # the package's Definition of Done, with the real counts
35
+ dialecte gate --hook # in a commit hook: the suite, unless a green gate --full of the committed tree answers it
36
+ dialecte tdd red|green|status # receipts: each new test failed on an assertion before the code, then passed untouched
37
+ dialecte new verb <namespace> <query|transaction> <name>
38
+ dialecte handover <lots.json> # the guarded commit-by-lots hand-over a human runs (run, list)
39
+ dialecte handover --legend # every term of the hand-over card: what it means, whether to look
40
+ dialecte worktree add|prune # a worktree ready to work in (sibling links, node_modules checked); what a merge left behind
41
+ dialecte record review|decision|snapshot # a lot's findings ledger and round snapshots, in its hand-over folder
42
+ dialecte record choice <folder> --by <who> <decision> # a decision made outside the ledger, in decisions.md
43
+ dialecte recap <folder> # the pull request's expandable part, built from the hand-over's records only
44
+ dialecte mutants run|status|schedule|abandon|migrate|judge|record|drop # mutation testing of the declared scope; survivors tracked until handled
45
+ dialecte text check <file> # the human part of a GitHub text: its fixed headings and its word cap
46
+ dialecte review delta <folder> --round <n> # the fix diff since round n-1; --worktree: the old code to run a test on
47
+ dialecte run <script.ts> # run a script on an in-memory project of the installed dialecte: one structured outcome
48
+ dialecte fixture <Tag> # the smallest valid XML document holding an element, built by the dialecte's engine
49
+ dialecte explain <code> # what an error or diagnostic code means, when it is raised, the usual fix
24
50
  dialecte --help
25
51
  ```
26
52
 
@@ -40,6 +66,1042 @@ Everything is overridable per `package.json` `"dialecte"` field (odd layouts) or
40
66
 
41
67
  Env: `RUNS=5 dialecte bench` (repetitions kept as the min); `COVERAGE_CHILD_CAP=N` (cap child edges).
42
68
 
69
+ ## Agent skills
70
+
71
+ Every Dialecte package ships the agent skills that describe it in `skills/<name>/SKILL.md` (open
72
+ [Agent Skills](https://agentskills.io) format), versioned with its code.
73
+
74
+ - **In an app**: `npx @dialecte/cli skills sync` links the skills of your `@dialecte/*` (and any other)
75
+ dependencies into `.claude/skills` and `.agents/skills` (Codex, Cursor, Gemini CLI, Copilot read the
76
+ latter; add `--agent copilot` for `.github/skills`). Links follow your installed versions; rerun after
77
+ adding a dependency. `--copy` writes copies instead of links.
78
+ - **Station agents (Claude Code)**: when Claude Code is a target (the default) and the project's model vendor
79
+ is anthropic, `skills sync` also writes one agent per station of `dialecte-lot` into
80
+ `.claude/agents/dialecte-<station>.md`: `implementer` and `fixer` (standard tier), `implementer-strong` and
81
+ `reviewer` (strong), `eval-runner` and `standard-reader` (standard), `grader` and `searcher` (fast). Each file
82
+ sets the model (from the `dialecte models` map, as the alias Claude Code accepts: `sonnet`, `opus`,
83
+ `haiku`) and the tools: the reviewer holds the read tools and Bash (it runs the tests) and no Write or Edit,
84
+ the searcher and the grader hold read tools only. The body is a few lines naming the station, the skills to
85
+ load and the never-list; it never copies a skill. The files are owned through the manifest: replaced on
86
+ every sync, removed when no longer produced, and a file of your own with the same name is reported, never
87
+ overwritten. `dialecte doctor` warns about a stale or missing one. Other hosts (Copilot / VS Code, Codex,
88
+ Gemini) get no agent files from this command yet: the tier of each station comes from `dialecte models`
89
+ there, as the `Tier:` line of a brief says.
90
+ - **Session-start check (Claude Code)**: `skills sync` adds a `SessionStart` hook running
91
+ `npx --no-install @dialecte/cli doctor --brief` (the installed cli: no download at a session start) to
92
+ `.claude/settings.json`, inserted by a minimal text edit (the rest of your file stays byte for byte), never
93
+ duplicated, removed when you drop the claude target. If you edited the hook's text since, removal cuts only
94
+ our handler (a comment right next to it may go with it) and writes nothing when anything else would change. Agents and hook are written only when `dialecte-lot`
95
+ is installed for Claude Code. `doctor --brief` prints nothing when the skills, the
96
+ versions and the station agents are in sync, otherwise one line per problem with its fix, and always exits 0.
97
+ `--no-session-check` leaves the hook out (and removes the one a sync added). Elsewhere, the `dialecte` skill
98
+ tells the agent to run `doctor` first.
99
+ - **Working on Dialecte**: `npx @dialecte/cli skills sync --from ../` takes them from your local checkouts.
100
+ - **In a package**: `dialecte skills generate` rewrites the `<!-- dialecte-skills:generated <kind> -->`
101
+ blocks (`extensions`, `core-methods`, `hooks`, `api`, `intents`) from the source; the `api` block lists
102
+ the methods, then one section per package entry (each `exports` subpath shipping a `.d.ts`) with the
103
+ functions it exports.
104
+ `dialecte skills check` verifies every API, path and npm script a page cites, and that every public
105
+ method and every function an entry exports (not `@internal`) has a JSDoc summary and an `@intent` tag; it warns when a summary or an
106
+ intent quotes a sentence, since the generated pages republish the JSDoc. A page about several
107
+ repositories declares `<!-- dialecte-skills workspace -->` and is fully verified with
108
+ `--workspace <folder>`; a deliberate outside mention goes in `<!-- dialecte-skills ignore: token -->`.
109
+
110
+ ## Lookups for agents (and people)
111
+
112
+ Each answers in a few lines, the same with or without the Dialecte repositories, and takes `--json`.
113
+ Exit codes: 0 an answer, 1 nothing found (or a warning for `doctor`), 2 a usage error.
114
+
115
+ - `dialecte api find "<need>" [--package <name>] [--limit 5]` searches the `api.json` every installed
116
+ package ships next to its skill's `api.md` (written by `skills generate`): one line per method - route,
117
+ `q | tx | doc | project | export`, the intent that matched, the package. Ranking, in order: how many words of the
118
+ need the method's `@intent` tags hold, then its summary, then its name - one intent word beats any number
119
+ of summary words; stop words dropped, word forms reduced to a light stem (`copied`, `copies`, `copying`
120
+ → `copy`); ties put a dialecte's verb before core's, then sort by route.
121
+ - `dialecte api show <path>` (`info.of`, `doc.query.info.of`, `tx.reference.applyUuidRemap`): signature as
122
+ declared, summary, intents, other routes, where it is declared in its repository, and one call: the
123
+ method's JSDoc `@example` when it is short and calls the method, else a call from the test next to it
124
+ whose arguments a caller can copy (written-out values first; never a test case field, a fixture constant
125
+ or a cast). No such call, no example.
126
+ - `dialecte members <expression>` (`doc.query`, `doc.query.reference`, `tx.lifecycle.extract`): the
127
+ IntelliSense walk on demand, from the live types of the package where it runs. In an app, point it at
128
+ the namespace holding your project's types: `--namespace <Name> --entry <module>`.
129
+ - `dialecte schema <Tag> [--package <name>]`: parents, children in order with how often each may appear,
130
+ attributes (required, identity, default, fixed, enumeration, pattern), text, xsi:type variants - read
131
+ through the readers of the core each installed dialecte depends on (how often a child may appear is core's
132
+ `childOccurrences`). An unknown tag answers the closest; a dialecte not built is reported as skipped.
133
+ - `dialecte doctor`: installed `@dialecte/*` versions, the core API generation of each dialecte (read from
134
+ the core it resolves; a dialecte on another core than your app's is a warning), whether the synced skills match node_modules (a skill missing; a copied skill of
135
+ another version than the one installed - linked skills follow node_modules), local checkouts (siblings,
136
+ `$DIALECTE_ROOT`); each warning with the one command that fixes it.
137
+
138
+ - `dialecte models [--vendor <id>] [--json]`: the model each tier means for the vendor the project uses
139
+ (`anthropic`, `openai`, `google`), one line per tier, the date the rows were checked and what each tier
140
+ is for. Agents name a tier (`standard`) and ask this command which model that is. The vendor is the one
141
+ `dialecte skills sync` remembered as `vendor` in `.dialecte-skills.json`, in every skill folder of the
142
+ project. Sync detects it from the project (`.claude/`, `AGENTS.md` + `.codex/`, `.gemini/`; a folder holding
143
+ only the skills a sync wrote is no evidence) and asks on a terminal when several agents, a multi-vendor host
144
+ (Copilot, Cursor) or none are found. Without a terminal, a first sync that cannot tell (no manifest, nothing detected) exits 2 naming
145
+ `--vendor <id>`, which also sets it without asking; a project that already has a manifest and an ambiguous
146
+ or empty detection keeps syncing without a vendor and is told how to set it. When manifests disagree, `models` warns on stderr, naming them, and uses the
147
+ most recently written; an unknown vendor id in a manifest is ignored with a warning. Exit 1 for an unknown
148
+ `--vendor`, 2 when no vendor is known.
149
+
150
+ Run outside a package (no `package.json`), each answers a usage error.
151
+
152
+ ## MCP server
153
+
154
+ The MCP server of the read-only lookups is its own package: [`@dialecte/mcp`](https://github.com/dialecte/mcp) (`npx @dialecte/mcp`). It builds on the pure answer functions this package exports at `@dialecte/cli/lookups`.
155
+
156
+ ## Contributing to a Dialecte package
157
+
158
+ Eleven commands for whoever changes a Dialecte package, a person or an agent. Each answers the same way
159
+ every time: exit 0 when green, 1 when a check fails, 2 on a usage error; `--json` where a program reads
160
+ the answer.
161
+
162
+ - `dialecte rules [<files...>] [--json]` checks the code rules on the syntax tree of the changed files
163
+ (or the files given): exported types outside a `*.types.ts` file, module constants outside a
164
+ `*.constants.ts` file, functions declared as `const`, an `await` inside an argument, plan tags and
165
+ standard citations are errors, and so is a test that takes the system's temporary folder itself as
166
+ its root (`tmpdir()` handed to a call that lists or scans a folder, or given as `root` / `cwd` /
167
+ `scratchRoot`...: other tests and processes share it; `mkdtempSync(join(tmpdir(), '<prefix>-'))`
168
+ gives the test a folder of its own); positional parameters (beyond a leading `query` / `tx`, a
169
+ symmetric pair aside) and abbreviated names are warnings. Without file arguments it records its result
170
+ in the worktree's git folder (`dialecte-rules.json`: when, HEAD, the state hash, the files, the errors
171
+ and warnings), which the hand-over card reads; a run on named files records nothing.
172
+ - `dialecte gate [--fast | --full] [--base <ref>] [--no-reuse] [--declare <path>]... [--json]` runs the Definition of Done: `--fast` (default) `check`,
173
+ `skills:check` and the tests of the changed files; `--full` adds `build`, the whole suite (the runner's
174
+ defaults: every file in parallel), `doc:build` and `type-bench:check`. Each step runs unfiltered, with
175
+ `GIT_OPTIONAL_LOCKS=0` (a `git status` inside it never takes the index lock), and is judged on its exit
176
+ code and on the counts it printed: a step exiting non-zero fails whatever it says, a test step that
177
+ counts no test fails - except `--fast` on a change that touches no test (a doc edit): the changed-tests
178
+ step passes with the note "no test file is affected by the change". A step whose npm script the package lacks is skipped. While a hand-over
179
+ holds the repository (`dialecte handover <lots.json>` wrote its lock), the gate runs only under the
180
+ hand-over written for this repository - the script the lock names exists and the `lots.json` beside it
181
+ names this repository, real paths compared - and says so in one line with the command that refreshes
182
+ the hand-over once the gate is green (`dialecte handover <lots.json> --rehash`): an author re-gates
183
+ after a late edit without touching the lock. It refuses under a hand-over of another repository, a
184
+ script that is gone, a folder without a lots file, and while a real `handover run` of that folder is
185
+ in progress (its `running.json` names a live process; that refusal names the marker file, in the
186
+ hand-over folder, so a person can tell a pid reused by another process). A refusal names the script and the lock and
187
+ says what to do: run the hand-over first (its last commit releases the lock), or hand the lock's path
188
+ to the person who runs the repository, who decides. A run that reaches its steps records its result in the
189
+ worktree's git folder, `dialecte-gate-fast.json` or `dialecte-gate-full.json`: when it ran, HEAD, the
190
+ state hash and each step (the tdd step first) with its status, its counts and its note or reason, the
191
+ tdd step with the cases of the change it judged (`cases`: label and status); a run refused at the hygiene records nothing. The state hash is that of the tree the
192
+ worktree would commit (HEAD's tree with the changed and untracked files on top, the deleted ones
193
+ removed, `.dialecte/` left out): committing the lots leaves it the same, any other edit changes it.
194
+ The record also holds its `key`, what the run checked: `tree` (the git tree id the state hash is the
195
+ sha256 of), `lockHash` (sha256 of `node_modules/.package-lock.json`, what npm installed; `none` without
196
+ it), `commandHash` (sha256 of the steps' names and commands in order, and HEAD's commit when a step
197
+ runs only the tests the change affects, which depend on the diff against HEAD; `--base` is no part of
198
+ it: it reads the `tdd` step only) and `linked` (sha256 over the package's `file:` dependencies as node
199
+ loads them - the folder `node_modules/<name>` links to, else the path package.json names - each file
200
+ they publish, their package.json and the paths of its `files`, with its path, size and modification
201
+ time; an exclusion (`!…`) is left out and a glob is walked from the folder before its wildcard, a
202
+ superset of what npm packs; a dependency without package.json or `files` is taken whole;
203
+ `node_modules` and `.git` are always left out). The key is taken before the steps and again after
204
+ them: when they differ (a step edited a file, an install or a rebuilt dependency during the run) the
205
+ record is written without a key, with the state hash of the tree the steps started on, and not stored;
206
+ the gate says so in one line before its verdict (`"stored": false` with `--json`). A run whose steps
207
+ ran is also stored by its tree in the repository's common git folder, `dialecte-checks/<tree>.json`
208
+ (`git rev-parse --git-common-dir`), which every worktree of the repository reads (the newest record
209
+ kept per mode and key). Before its steps, a gate looks there: a green record of the same mode and the
210
+ same key answers instead of running them -
211
+ `reused: gate --<mode> green on this tree at <time> (HEAD <sha>)`, the record's step lines, then
212
+ `gate --<mode>: green (reused)` (`"reused": true` with `--json`) - and the worktree's record is
213
+ written marked `reused` with the time and HEAD of the run it reuses. The hygiene and the `tdd` step
214
+ run every time: they are about the worktree (what is staged, the receipts, `.dialecte/lot.json`, the
215
+ base), not the tree, and a `tdd` step failing now is a failed gate. A record that failed, that ran no
216
+ step, of another mode (`--fast` never answers `--full` nor the reverse) or written by an older cli
217
+ (no key) is never reused; a stored entry of another shape is ignored. A test step that passed only on its
218
+ serial rerun is green: it is reused with its `flaky in parallel` note. `--no-reuse` runs the steps
219
+ whatever the store holds. The key leaves out the Node version and the environment (a path given
220
+ through an environment variable); a `file:` dependency edited and restored to the same size within
221
+ the same modification time is not seen either.
222
+ - `dialecte gate --hook [--no-reuse]` runs in a commit hook: the test steps of `--full` (its steps counting
223
+ tests), unless a green `--full` record of what is committed answers them. Its key is the one a `--full` run of
224
+ that state stores - the tree, what npm installed, the `file:` dependencies, the full gate's command hash - with
225
+ the tree taken from the index git hands the hook (`GIT_INDEX_FILE`, else the worktree's index), never from the
226
+ working files: a merge commit and a partial commit check what they record. A green record of that key prints
227
+ one line, `gate --hook: tests reused from gate --full green on tree <tree> at <time> (HEAD <sha>)`, and runs
228
+ nothing; otherwise `gate --hook: no green gate --full of tree <tree> with this install: running the tests`, the
229
+ test steps (rerun serially on a failure, as the gate does), then one vitest summary line of their summed counts (what the hand-over's hook reader counts),
230
+ and `gate --hook: green` or `gate --hook: failed at <step>` (exit 1). It runs no hygiene and no tdd step,
231
+ reads no hand-over hold (it runs inside `handover run`'s own commit) and records nothing: `handover run`
232
+ records the hook. `--no-reuse` runs the tests whatever the store holds, and so does a hook whose git variables name another
233
+ repository than its folder's (the cli ignores them, so what is committed is unknown); `--hook` with `--fast` or `--full` is
234
+ refused (exit 2). Write it in the hook as an npm script (`"test:hook": "dialecte gate --hook"`), so the
235
+ hand-over reads it as a test step of its own: its card line reads `reused by the hook` when the hook answered
236
+ from a record. The cli's own hook runs `npm run check` (type-check, lint, format; no suite), `npm run
237
+ test:hook`, then `npm run build`.
238
+ - A running step looks running. Each `gate` step and `tdd`'s vitest run is announced before its work:
239
+ off a terminal a start line `▶ <step>` (then a line every 30 s of silence and the result), on a
240
+ terminal one spinner line `⠋ <step> - <what runs> <elapsed>` that the step's result line replaces (the
241
+ gate's summary then leaves out the lines already shown; off a terminal and with `--json` it keeps them).
242
+ A silent hook gets the waiting-for-input / watch-mode hint once, at 90 s of silence, on both. The
243
+ `handover` card is as wide as the terminal's columns, else `$COLUMNS`, else 80: the box is exactly that
244
+ wide and every line wraps inside it with a hanging indent under its text column, never into fewer
245
+ than 20 columns of text: a hang that would leave less is reduced; a commit line whose columns
246
+ (`<sha> <files> <+->`) leave its subject less puts the subject, and a merge lot's merge line, on their
247
+ own rows under it, 2 columns in; a line kept to one row with `…` is wrapped whole when its cut would
248
+ keep less; a word wider than the room after the hang (a long path) takes a row of its own, 2 columns
249
+ in. Colour only on a
250
+ terminal (and never with `NO_COLOR`); the `✓` `!` `✗` marks read the same without it. The command
251
+ follows the box whole on one line, to copy: `cd <folder> && bash commit.sh`, or
252
+ `node <this cli> handover run <folder>` when the repository's own cli does not answer
253
+ `handover run --probe` within 10 s. "This cli" is the script that runs: when it is a temporary one
254
+ (`npx` from the registry, `tsx` on the sources), install `@dialecte/cli` in the repository so the
255
+ card names its own bin.
256
+ - No runner hangs silently. Every child that `dialecte gate` (its steps), `tdd` (its vitest runs) and
257
+ `handover run` (each commit and its hooks, `--rehearse` too) start runs in a process group of its own,
258
+ with its stdin closed (a command that reads it, such as `grep` with no file, gets end-of-file at once),
259
+ and under a stall watchdog. Any output, a part of a line included, counts as activity; so does CPU time
260
+ gained by any process of the child's tree (its descendants and its process group, sampled with `ps`
261
+ every 5 s, macOS and Linux). After 10 minutes with neither, the tree is printed one line per process
262
+ (pid, state, CPU time, command), stopped (SIGTERM to the group and every pid, SIGKILL to what is left
263
+ after 2 s) and the run ends only once its processes are gone, as `stalled`: the gate's step fails with
264
+ `stalled: no output, no CPU for 10 m 0 s` and the tree in its tail, `tdd`'s run fails with the tree, a
265
+ hand-over lot is not committed and its files are unstaged (waiting a few seconds for a stopped git's
266
+ `index.lock`; when the lock stays, the run says the files are still staged, names the lock and says
267
+ to hand its path to the person who runs the repository, who decides once no git runs in it). A
268
+ `ps` that fails or times out gives no verdict on that sample; failing for the whole 10 minutes is a
269
+ stall of its own. Ctrl-C, SIGTERM or SIGHUP received by the cli is passed on to every running child's group.
270
+ A child that asks the terminal (a gpg or ssh passphrase prompt) runs in a background group: it
271
+ stops (state `T`) and is reported as stalled.
272
+ - `dialecte tdd red|green|status [<test file> | <test file>::<case name>]... [--base <ref>] [--json]` makes
273
+ the order of the work visible: tests written from the spec before any code, red for a real reason, then
274
+ made green by an implementation that did not touch them. The ledger lives in the worktree's git folder,
275
+ never in the tree. Runs use the package's own vitest (each project's run of a case is a case of its own),
276
+ with snapshots never written
277
+ (`--update=none`, CI): a snapshot test's snapshot is written by the test station before the red.
278
+ - `red` runs every case of the changed test files (or of the files named). A case that fails on an
279
+ assertion (a snapshot mismatch included), on a stub's error (a message starting with
280
+ `not implemented`) or on an error existing code throws, inside an `expect(...)` a matcher completes,
281
+ gets a red. Refused, each with its reason: a passing case that is new or changed ("it ran green: this
282
+ test proves nothing yet"); a passing case with a receipt whose own test call changed; a passing case
283
+ still waiting for its green whose test file, or test code it imports, changed since its red ("test
284
+ code changed since its red and it passes"); a failure on a missing export, a type or syntax error, a
285
+ timeout, a stub thrown at import or before the assertion; a file holding `.only` or `only: true`. A
286
+ case the same as at the base is marked unchanged; a case the lot accepts is marked accepted; a green
287
+ case whose test code changed around it is kept and flagged `test code changed around it` (the next
288
+ step adding a case to a green file); a case never proven green (only unchanged, accepted or revised)
289
+ is kept without a flag, and no receipt. A file with a refusal still records its other cases'
290
+ receipts, the refusals kept as evidence, but is not frozen: the gate fails on it until no case of
291
+ it is refused.
292
+ - A red records the case (file, full name, project), the hashes of its test file, of its own test call
293
+ and of the production files, the failing message and the time. It is flagged `rollback` at a
294
+ production state the case, or the lot, had already left: a production file moved back from the
295
+ newest content the lot reached to its content at the base or at an earlier receipt (the run prints
296
+ one `rollback:` line naming the files). The ledger keeps, per base and per production state a receipt
297
+ names, the content of each production file changed since that base. The receipts are walked in
298
+ order: a green, or a receipt at a state moving nothing back, makes its state's contents the newest; a
299
+ put back only reds, refusals or unchanged receipts saw stays put back and adds no content, so a
300
+ later red there is flagged again, a restore is not, and a step a green proved (an experiment undone
301
+ and kept) is the new newest. A green run taken at code put back still makes its state the newest;
302
+ its receipts are flagged `rollback`, with the same line, only when a case the run proves had no
303
+ green receipt before (of the same file, name, project and test call; a refused run is no green, an
304
+ earlier green counts whatever its flags): a refactor that keeps proven cases green (drops a file the
305
+ lot added, puts a file back to its content at the base) is not flagged, a green run proving a case
306
+ for the first time there is. Content the refactor
307
+ moved away stays reached: bringing it back later flags the reds and the first greens taken there.
308
+ A state read at another
309
+ base, a lot committed since, is not compared;
310
+ `red after green` when the case's own last receipt is a green at the same production state.
311
+ - The run freezes each test file without a refusal, and a changed helper, fixture or snapshot only when
312
+ a case of a file depending on it went red, or was recorded revised, in that run: what it imports
313
+ (relative, tsconfig `paths` or vite alias, barrels and re-exports followed through test code; a
314
+ package name is a dependency, not test code), a changed file whose name its test code mentions, or
315
+ the text of a production module its test code imports directly (a constant naming a fixture; one hop
316
+ into production, never further, and the module itself is production), its own snapshot. Every
317
+ dependency found by import is followed in turn, and one found by a name written with its folder
318
+ (`fixtures/scan.ts`, a full path): it brings the files it imports (`import type` included). A bare
319
+ file name (`index.ts`) may be another file: the changed file it names is a dependency, not followed. A
320
+ helper no red covers stays unfrozen, and the gate fails on it, unless a `revised` entry names it
321
+ (below). An import that looks local (`@/`, `~/`,
322
+ `#`, a `paths` or alias prefix) and resolves nowhere refuses its file, naming the import.
323
+ - `green` runs the changed test files: each case needs a red receipt, its file, its test call and its
324
+ test code as frozen, production changed since its red ("nothing in production changed since red"),
325
+ and a pass.
326
+ - `status` prints each case (red, green, unchanged, accepted, missing receipt, test edited after red,
327
+ with its flags), the test code changed outside `tdd red`, and the cases the change deletes. A test
328
+ call of the base gone without a title (an `it(name, ...)` whose title is a variable: an edited call
329
+ looks deleted) prints `deleted <file> a test call of the base is gone`; when a `gone` entry of
330
+ `.dialecte/lot.json` names its file (a path or a glob), it prints
331
+ `gone <file> a test call of the base is gone (<reason>)` instead, in the gate's details too. A titled
332
+ test gone and a deleted test file stay `deleted`. A ledger that cannot be read is refused with its
333
+ path.
334
+ - `status --flags` prints only the cases whose receipts carry a flag, with their flags.
335
+ - `status --legend` prints the tdd terms of the hand-over card, each in two lines: what it means, and
336
+ whether to look. It needs no package: it works from any folder.
337
+ - The lot is the uncommitted work: the change is measured from HEAD, so the cases of lots already
338
+ committed on the branch are not asked again. `--base <ref>` (`tdd` and `gate`) gives the
339
+ whole-branch view; `gate --full` measures from where the branch left its base branch.
340
+ - Test code is compared by the leaves of the parser's syntax tree, each file parsed by its extension
341
+ (a `.ts` file is no TSX): whitespace, comments (except the ones a tool reads:
342
+ `@vitest-environment`, `@jest-environment`, `@vite-ignore`), quote style, statement semicolons,
343
+ trailing commas after an element and the order of import statements between side-effect imports
344
+ are formatting (a formatter pass needs no new red); template literals count by their raw text; any
345
+ other edit is a change. The receipts are a version-3 ledger: an older one is refused, to be moved
346
+ aside. A repository without a commit is refused in one line.
347
+ - A package whose test entry is production code declares it:
348
+ `"dialecte": { "tdd": { "production": ["src/test"] } }`; the test files, fixtures, snapshots and
349
+ `*.script.ts` under such a folder stay test code. `testCase.only ? it.only : it` is no focus marker.
350
+ - A case edited at review after it was proven is declared in `.dialecte/lot.json`
351
+ (`"revised": [{ "case": "<file>::<name>", "reason": "<why>" }]`). It needs an earlier receipt of
352
+ the case (a red, an unchanged, an accepted one), not necessarily a red, or to be a case of the base:
353
+ its file exists at the base, every title of its name written as a string now is written there too,
354
+ and, when its own title is the literal title of an `it` / `test` call at the base or now, the base
355
+ holds such a call with its describe path (a computed describe title, a `describe.each` /
356
+ `describe.for` format, matches any; a `describe.skipIf` / `describe.runIf` suite counts by its
357
+ title) and the file now no more of them (a test moved to another describe, or a string of that title
358
+ removed elsewhere, is no proof); otherwise (a table row, a computed title) its own title is written
359
+ as a string there and no more times now. A new case (a new file, a new title, a row added to a table)
360
+ still needs a red; a case whose title the file computes and the base does not write is refused
361
+ ("not provably a case of the base: accept it or prove it red"). The `case` may also be a file path or
362
+ a glob over file paths (`scripts/**/*.test.ts`: `**` any folders, `*` and `?` within one), relative
363
+ to the package root, without `::`: it applies to every case of the matching files, with one reason.
364
+ A file or glob entry never covers a case whose last proof is a red still waiting for its green, and
365
+ keeps the `red after green` flag of a case made red again; an exact entry covers both. An `accept`
366
+ entry stays one exact case. The next `tdd red` records it as revised when it passes (a
367
+ red when it fails) and freezes its file and the changed test code it depends on. A file or glob entry
368
+ may also name a test helper (test code that is not a test file: a helper, a fixture, a constant beside
369
+ the tests) edited at review while its dependent cases stay green: the next `tdd red` freezes it at its
370
+ new hash and prints `revised <helper> <reason>`, when every changed test file depending on it (at
371
+ least one) is in the run and frozen by it with no case red (a refused file, a red still waiting for
372
+ its green, or no dependent file in the run leaves it unfrozen; a changed dependent outside a targeted
373
+ run too, named on an `unfrozen <helper>` line). The new freeze makes the dependent
374
+ cases' earlier green stale: `tdd green` proves them again. Without that red run the gate fails on the
375
+ edit; `status` lists the revised cases, the gate and the hand-over card list the revisions (cases
376
+ and helpers) with their reason, an entry (exact, file or glob) no revised case or helper used as a
377
+ note.
378
+ - What it cannot see: the receipts can be written by an agent with a shell; a deliberate throw in
379
+ production looks like a stub; code written first, hidden, then a red taken at the base state, cannot
380
+ be told from an honest red (at the first step the red's production is the base's). The flags and the
381
+ refusals make the rest visible; the review reads the diff.
382
+ - `dialecte new verb <namespace> <query|transaction> <name> [--version <v>]` writes a verb of a dialecte
383
+ package in the house style: the function (query or transaction first, one params object), its
384
+ `.types.ts`, a table-driven test with one red case (no `only`: `tdd red` refuses a focus marker; while
385
+ iterating, run the case with `npx vitest run <file> -t "<case>"`), its barrel export and, for a new
386
+ namespace, the namespace module and its registration. Its JSDoc summary and `@intent` start with
387
+ `FILL:`, which `skills check` refuses until written; the command prints every placeholder left.
388
+ - `dialecte handover <lots.json> [--out <dir>] [--rehash] [--json]` prepares the commit-by-lots
389
+ hand-over a human runs. The lots file names the repository, the branch and HEAD expected, and the lots
390
+ (paths, message):
391
+
392
+ ```json
393
+ {
394
+ "repository": "/path/to/the/repository",
395
+ "branch": "feat/names",
396
+ "head": "d4b1c04",
397
+ "gates": "the scl cases need DIALECTE_SCL_DIR: skipped here",
398
+ "lots": [
399
+ { "paths": ["src/names/"], "message": "feat(names): names stay unique among siblings" },
400
+ { "paths": ["CHANGELOG.md"], "message": "docs(changelog): unique names" }
401
+ ]
402
+ }
403
+ ```
404
+
405
+ `gates` is optional free text, the caveats for the person about to run the hand-over: the cards printed
406
+ before a run (this one, a rehearsal's) show it as their notes; the card a real run prints after it has
407
+ none. The card reads the gates from their records.
408
+ It refuses (and writes nothing) when the branch or HEAD differ, `core.hooksPath` names a folder that
409
+ does not exist (git would skip every hook; it says how to restore it), something is staged, a changed
410
+ file is in no lot or in two, or a lot file (evals included) or message holds a plan tag or a standard
411
+ citation. Otherwise it writes the hand-over folder - the lots file, the snapshot (`files.txt`,
412
+ `files.sha256`, `files.deleted`, and `lots.sha256`: the lots file as reviewed) and a one-line
413
+ `commit.sh` that runs
414
+ `npx --no-install @dialecte/cli handover run <folder>` (bash, also run with `sh`; when the repository
415
+ installs no cli that can, it says so in one line with the fix) - and prints the hand-over card, the
416
+ command with its absolute `cd` under it. `--json` answers the card as data: the verdict, `failedGates`,
417
+ `otherTreeGates`, `declarations` (the entries to read), `gates` (the gate lines: name, status, detail),
418
+ `tdd` (the tdd lines as the text a person reads, no layout and no padding), `notes`, and each lot with
419
+ `pending` until it is committed. Edited a file after the review? `--rehash` (also after
420
+ editing `lots.json`). The repository stays held until every lot is committed: `dialecte gate` runs
421
+ only under this hand-over (see `gate`), and a hand-over of another folder is refused, naming the script
422
+ that holds the repository and its lock.
423
+
424
+ - The hand-over card is what a person reads before running the hand-over, and again at its end. Its title
425
+ is `hand-over: <repository folder> <branch>`; the repository and worktree paths are not in it. Its
426
+ first line is the verdict: `READY` when no gate line failed and none ran on another tree, `BLOCKED` with
427
+ `<n> gates failed: <names>` and `gates ran on another tree: <names>`, `DONE` once a real run committed
428
+ every lot; then the lots, files and `+<added> −<removed>` (`all gates green` when nothing blocks), and
429
+ `<n> declarations to read (below)` on a second line. Its sections:
430
+ - `commit`: one line per lot - its sha, or `pending`; its files, lines added and removed, and subject. A
431
+ merge lot's line follows (`merge <branch> at <tip> · <n> conflicts · tree <sha>`, or
432
+ `tree not recorded: rehearse first`); a merge lot is sized from the tree it was trial-merged on to
433
+ the tree a rehearsal recorded, else says `size after rehearse`. Then `HEAD <sha>`, after a run
434
+ `HEAD <base> → <tip> · nothing pushed`.
435
+ - `gates`: one line per gate step from the gate records (the latest record of each step over `--fast`,
436
+ `--full` and the commit hook's record, a line of the hook's ending with `commit hook`:
437
+ `✓ test:run 1214/1214 · commit hook`; a gate record newer than the hook's replaces its lines whole,
438
+ since the hook names its own scripts, not the gate's steps), then `rules` from its record, then
439
+ `mutation` when the package declares a mutation scope (below), then
440
+ `review` from the hand-over folder's findings ledger and `round-<n>/` snapshots. `✓` passed; `!` to
441
+ look at (a step not run here, with its reason, or not run after a failure; `rules` never run; no
442
+ findings ledger, or one holding no row yet: `no findings recorded`; only nits open); `✗` failed (a
443
+ failed step,
444
+ a rules error, a blocking or should-fix finding open, `gate never run on this tree` when there is no
445
+ record). The records read are the worktree's last runs and the store's records of the tree the
446
+ hand-over commits - the worktree's tree, or for a hand-over holding a merge lot the tree its last lot
447
+ leaves (the trial merge with its resolutions) - the newest record of each step winning; a tdd step
448
+ another worktree recorded is left out (its verdict is that worktree's), and a stored record counts
449
+ only when it ran against what is installed here now (the same `node_modules` and `file:`
450
+ dependencies) with the command of its mode now. A line from a record made at a commit outside the
451
+ history of HEAD ends `· from <sha>` (the branch commit's hook record read for a merge on main; a
452
+ record of an earlier commit of this line carries none), a rehearsal's record `· rehearsal`. A record
453
+ of another tree than the one checked ends with `(the tree changed since)`: its line turns `!` and
454
+ blocks the hand-over; a failed step stays `✗`.
455
+ The `mutation` line is what the package still owes its mutation runs, read from the mutation store when
456
+ the card is written. `✗` (blocks): `new` survivors or died runs of the package, whatever their lot
457
+ (`2 new survivors · 1 died run: dialecte mutants status`); a run of the branch still running when the
458
+ hand-over merges a branch (`run <id> still running (pid <pid>): the merge waits for it`, a run of a
459
+ merged branch too) or when the lot's mutation switch is `gate` (`...: a gate lot waits for it`); a gate
460
+ lot with no run of its branch (or a merged one) reported on the tree the hand-over commits
461
+ (`gate lot: run dialecte mutants run on this tree first`); an invalid `dialecte.mutation` or lot switch,
462
+ with its reason. `!` (does not block): a run of the branch still running on a plain hand-over
463
+ (`...: its survivors are not in yet`). Otherwise `✓ mutation nothing pending`. To unblock: kill each
464
+ survivor with a test, record its reason
465
+ (`dialecte mutants record --key <key> --family <family> --reason <why>`), or
466
+ `dialecte mutants schedule <follow-up> <key>`; rerun a died run or `dialecte mutants abandon <run id>`;
467
+ wait for a running run; run `dialecte mutants run` on the tree for a gate lot. The switch is the
468
+ hand-over folder's `lot.json` when it holds one, else `.dialecte/lot.json`.
469
+ - `tdd`: the lot's exemption; only the cases of the change count, those the gate's tdd step listed on
470
+ this tree (a retitled or removed case's receipts are not counted under the old title); without a gate
471
+ record of this tree that lists them, one line `counts from the last gate: run the gate on this tree`
472
+ replaces the counts, groups, entries and flags; each case counted once by the status the gate gave
473
+ it (red then green as proven, kept when its last receipt is a kept after a green; accepted and
474
+ revised only in their groups)
475
+ (`<n> proven red → green · <m> unchanged`, and `· <k> kept` when any); the accepted cases: a head
476
+ line `<n> accepted`, then one row per reason of the lot file (`<count> <reason>`, the largest group
477
+ first, a tie in the lot file's order, each reason wrapped under itself); the accepted and revised receipts
478
+ of earlier lots, which the lot file no longer names, on one line
479
+ (`earlier lots: 410 accepted, 12 revised (not in the lot file)`); then
480
+ `<n> revised · <m> gone · <k> unused` with `to read ↓` at its right edge and one entry each: a revised case `<file> › <title>` (named by the lot file exactly, or by a file or glob entry)
481
+ with its reason under it, a helper a red run froze for a `revised` entry as `revised <helper>` with its
482
+ reason under it, a `gone` entry with its reason (whether one covers a finding is the gate's
483
+ to say), an `accept` or `revised` entry no case used. Then one line per kind of flag with its count of
484
+ cases (`dialecte tdd status --flags` lists them); cases whose only flag is `test code changed around it`
485
+ and whose receipts are otherwise only unchanged are counted apart (a case flagged rollback or red after
486
+ green never is), as
487
+ `helper code changed near unchanged cases (noise)`.
488
+ - `notes`: the lots file's `gates` text, as written; only on the cards printed before a run (the
489
+ written card, a rehearsal's), never on the card after a real run.
490
+
491
+ Its closing rule reads `dialecte handover --legend · details: dialecte tdd status` (in a box too narrow
492
+ for it, that text is printed inside, above a plain closing rule). The command stays
493
+ under the box until every lot is committed. `dialecte handover --legend` prints every term the card can
494
+ print, each in two lines: what it means, and whether to look.
495
+
496
+ - `dialecte handover run <folder>` is what `commit.sh` runs. Each guard prints one line with its result
497
+ and its time (`✓ snapshot 110 file(s) 0.4 s`): repository, the lots file as reviewed, hooks
498
+ folder, branch, HEAD, empty index, the files against the snapshot, deleted files, files outside the
499
+ lots, plan tags and citations, and last `mutation`: the card's `mutation` verdict computed again when the
500
+ guard runs (never taken from the card), so a run that reported a survivor, or died, after the card was
501
+ written refuses the run with exit 1 and nothing committed (`✗ mutation <detail>`, each survivor and died
502
+ run indented under it, then what to do with each); a run still running on a plain hand-over passes with
503
+ its warning; `✓ mutation no mutation scope declared` for a package without one. A rehearsal runs the
504
+ same guard. When the staged files are exactly the next lot's (a run stopped after
505
+ staging it), the index guard prints the command that unstages them, with its `cd`.
506
+ Then each lot announced before its work: off a terminal `▶ lot n/N` with its files and subject, and a
507
+ line every 30 s in which nothing of the lot was shown (`… <lot> running 2 m 10 s`: hook lines the view
508
+ leaves out do not count); on a terminal one spinner line naming the lot,
509
+ what runs and the time. The commit's hook output is read as steps, from npm's script headers: a script
510
+ that runs others (`npm run`, `run-p`, `run-s`, `npm-run-all`) is their parent, and the lines of the
511
+ scripts a parent runs in parallel stay the parent's. While the hook runs, only the current step and the
512
+ warning and error lines show (lint, format, type-check and build warnings and errors, failing tests),
513
+ each labelled by the step that printed it (`[lint:check] <line>`): on a terminal the step with its
514
+ elapsed time and those lines live under the spinner, off one `│ ▶ <step>` per step and those lines
515
+ behind `│`. A test step (a `test` segment in its name: `test`, `test:run`, `unit:test`; or a test
516
+ runner on its command line: `vitest`, `jest`, `node --test`) shows its failing tests and failed scripts
517
+ only: the warnings its tests print are theirs, not the repository's. A line its step printed already
518
+ (the same text: Vite's `configLoader` notice, 2-3 times per build) is not a new line: on a terminal
519
+ the first one carries the count, `<line> (×3)`, updated in place; off a terminal (a log) a line is
520
+ written as it is read, its identical repeats right after it are counted, and when that run of repeats
521
+ ends (another warning or error line, the next step, the hook's end) a run of two or more is written
522
+ again as `<line> (×<n>)`. Lines of different steps never merge. Every byte goes to the hook's full
523
+ log as it comes. After a passing hook, one summary line
524
+ (`check ✓ · test:run ✓ 1214 · build ✓ · 1 lint warning in lint:check`: the scripts the hook runs, a
525
+ script they run only when it printed counts or failed; the warnings counted per step and kind, in the
526
+ order first printed, each distinct line once: the same text printed again in its step counts once),
527
+ the labelled warning lines (each once, where it was first printed, with its step's total as
528
+ `(×<n>)` from 2) and `full log: <path>`; after a failing hook, the
529
+ summary with `✗`, the labelled error lines not among the failing step's last 30 lines (each once, with
530
+ its count), those 30 lines
531
+ and the log's path. A hook that ended (passed or failed; not one stopped as stalled) is recorded in
532
+ the git folder of the repository it committed in (`dialecte-gate-hook.json`, mode `hook`): HEAD after
533
+ it (the new commit, or the base when it failed), the state hash of the tree before the commit and the
534
+ steps its summary names with their status and counts; the card reads it with the gate records, so a
535
+ lot committed where no `dialecte gate` ran still shows its gates, until a newer gate record replaces
536
+ it. The record holds its key too (the tree the hook ran on, what npm installed, the `file:` dependencies,
537
+ and for `commandHash` the hook files git runs: husky's `.husky/<hook>` scripts, else the hooks folder's
538
+ executable files) and goes to the repository's store of records by tree. A rehearsal writes it in its
539
+ scratch clone's git folder and in the repository's store, marked `origin: "rehearsal"`, never in the
540
+ repository's own `dialecte-gate-hook.json`. A hook that prints nothing gets `hook ✓` (or
541
+ `hook ✗`) and the log's path; a repository with no commit hook prints none of it (in husky's `.husky/_`,
542
+ which holds a wrapper for every hook name, a hook counts only when its script exists in `.husky/`). Then the commit with
543
+ its stat; the total time and the card at the end. A lot whose `git add` or commit fails is unstaged again: once the cause is fixed, the same command
544
+ finds the lots already committed on top of the recorded HEAD (same message, same paths, same content)
545
+ and resumes at the next one; anything else on top of HEAD is refused with what was found. It never
546
+ pushes. `--rehearse` first decides, per lot and before any clone, whether rehearsing it can find
547
+ something new, and prints one line per lot: `lot <n>/<N> reused <reason>` or
548
+ `lot <n>/<N> rehearse <reason>`. A plain lot is reused when the store holds a green `gate --full` of
549
+ the tree its commit will hold (HEAD with every lot up to it on top) with the key of now - the same
550
+ `node_modules`, `file:` dependencies and `--full` steps - the lot does not change `package-lock.json`,
551
+ and the commit hook stages no files of its own (its text names `git add`, `git stage`, `lint-staged` or
552
+ `git update-index`): `green gate --full on tree <tree>`. A merge lot is reused when the tree it leaves
553
+ (its trial merge with its resolutions) is its tip's tree and a green record of that tree - the branch
554
+ commit's hook record or a `gate --full`, with the key of now - is in the store, under the same
555
+ conditions: `green hook record of the tip's tree <tree>`. Otherwise the line says the first reason that
556
+ holds: `no green gate --full on tree <tree>`, `the lot changes package-lock.json`,
557
+ `the hook stages files (<match>)`, `node_modules changed since the record`,
558
+ `a linked dependency changed since the record`,
559
+ `<branch> moved: the merge leaves tree <tree>, the tip holds <tree>` (`<branch>` the one the hand-over
560
+ commits on: `main moved: ...`), `no green record of the tip's tree <tree>`; `--rehearse --full`
561
+ rehearses every lot (`--full`). The decisions go to `rehearsal.json` in the hand-over folder
562
+ (when, and per lot its tree, `reused` or `rehearsed`, the reason and the record reused: mode, time,
563
+ HEAD). When every lot is reused no clone is made: the guards, a reused merge's `tree <sha>`, then
564
+ `rehearsal skipped: every lot's tree has a green record` and the card. Otherwise the clone is made and
565
+ the reused lots are committed in it with `--no-verify` (their hook skipped, in the clone only), the
566
+ others with their hook. A real run (no `--rehearse`) runs every commit's hook, whatever the store holds.
567
+ The rehearsal clone (`▶ rehearsal clone`) warns naming the untracked files outside
568
+ `.gitignore` and `.git/info/exclude` a hook could read (they are not in the clone), and runs the lots in a scratch clone that looks like your tree - the repository at
569
+ HEAD, your working tree on top, the hooks folder, a copy-on-write copy of `node_modules` - so the hooks
570
+ run as they will for real. The clone sits in a rehearsal folder under a short root, `/tmp` on macOS
571
+ and Linux (the system's temporary folder on Windows):
572
+ `/tmp/dialecte-rehearse-<random>/<repository folder name>`, so a tool's socket under the hook's
573
+ temporary folder stays within the system's path limit; the hook runs with `TMPDIR` set to a folder
574
+ inside the rehearsal folder. Beside the clone, a link per relative `file:` / `link:` dependency of the
575
+ repository's package.json that leaves the repository, to the folder the same path reaches from the
576
+ repository (`file:../core`: `<rehearsal folder>/core` -> the repository's `../core`), so the clone
577
+ resolves it as the checkout does; one line names the links, and a path that leaves the rehearsal
578
+ folder too, or whose target is missing, is not linked (a line says why). The whole rehearsal folder is
579
+ removed at the end - its links unlinked, never what they reach - (`--keep` keeps it and names it:
580
+ `kept the rehearsal folder: <path>`), and on Ctrl-C or SIGTERM, with the hook and every process it
581
+ started stopped. The clone's git folder holds a marker naming the process that made it
582
+ (`dialecte-rehearsal.json`). A real run marks its hand-over folder with `running.json` (its pid and
583
+ start time) while it runs, removed at its end, on a failure, and on Ctrl-C, SIGTERM or SIGHUP received
584
+ while a commit (its hook) or an install runs; a run stopped at another moment leaves it, and a marker whose
585
+ process is gone counts as no run.
586
+ - A lot of `lots.json` can be a merge (git 2.38 or later, for its trial merge):
587
+ `{ "kind": "merge", "branch": "<branch or tag>", "tip": "<sha>", "resolved": { "<path>": "<file>" | null }, "message": "...", "tree": "<sha>" }`
588
+ (`null`: the merge removes the file). Merge lots are trial-merged in sequence: each on the tree the lots
589
+ before it leave - HEAD's, each earlier plain lot's files as they are in the working tree, each earlier
590
+ merge's trial tree with its resolutions - so a conflict that appears only on top of an earlier merge is
591
+ found at the write and needs a resolution, instead of stopping the run. The write refuses a branch that
592
+ is gone or moved since its tip was reviewed, a missing resolution file, a resolution holding conflict
593
+ markers, a conflict of the trial merge without a resolution or on a symlink or a submodule, and a file
594
+ the merge changes that has working-tree changes outside the resolutions (a file an earlier lot commits
595
+ aside). It records the conflicts, each resolution's hash and the tree the merge was trial-merged on
596
+ (`onTree`) in `merges.json`, under the review hash like `lots.json` (`--rehash` after a review). A resolution may
597
+ cover a file that merges cleanly (the lot changes it on top of the merge). Rehearse first:
598
+ `--rehearse` prints the merge's `tree <sha>` (a reused merge too), which goes into the lot as `tree`;
599
+ a real run requires it ("tree not recorded: rehearse first"). Before merging, the run refuses the lot
600
+ when HEAD's tree is not its `onTree` - an earlier lot committed other content (a hook staged files of
601
+ its own) - naming both trees, with nothing merged, and the next step (see what the lots before it
602
+ committed, then write the hand-over again from this HEAD for the lots left). A `merges.json` without
603
+ `onTree` (written by an earlier cli) is refused at the read: write the hand-over again, then
604
+ `--rehash` after a review. The run merges the recorded tip (`git merge --no-ff --no-commit`; a branch
605
+ moved since is a note) and refuses a merge in progress, leaving it - except one of the lot's own tip
606
+ that this cli started (its marker in the git folder) or with `--resume-merge`, aborted and redone. It
607
+ checks the conflicts against the recorded ones, copies the resolutions (hash-checked), refuses
608
+ conflict markers in the result, and checks the staged tree against the recorded one before the commit
609
+ (else the merge is aborted) and the commit's tree after it (a hook may stage files). A merge whose
610
+ hook refuses it is aborted, for a clean rerun. A rerun recognises a done merge by its subject, the
611
+ tip as its second parent and its tree. Before any commit whose staged `package-lock.json` differs
612
+ from HEAD's, `node_modules` are brought to it: the staged lock and `package.json` written over the
613
+ working copies (the working ones saved first in the git folder's `dialecte-install-backup`, put back
614
+ after the install, on an interrupt too; a backup a crash left is restored by the next run when the
615
+ files still hold the staged bytes, else refused naming it),
616
+ `npm ci --ignore-scripts --prefer-offline --no-audit --no-fund` (no install script runs: a `prepare`
617
+ or `postinstall` could change git config, hooks or any file; `npm ci` reinstalls every package, so
618
+ the note after the sync names each installed package of the staged lock that has one,
619
+ `install scripts not run: <names>`: each package once by its name, a nested copy too, five named then
620
+ `and <n> more`), the working copies put back byte for byte;
621
+ refused when the install changed the staged files or the versions still differ (dev, peer and optional
622
+ packages an install leaves out aside). A real run that leaves every lot committed then moves the worktree's `.dialecte/lot.json`
623
+ into the hand-over folder as `lot.json`, after the card is built, and leaves an empty declaration
624
+ (`{}`) in its place, saying so in one line (`lot file archived: <folder>/lot.json`): the next lot on
625
+ the branch does not inherit its entries. No lot file, an empty one, a rehearsal, a stopped run, or a
626
+ folder that holds a `lot.json` already (a second run) leave the lot file as it is.
627
+ - `dialecte handover list [--root <dir>] [--json]` lists every hand-over folder under the workspace's
628
+ `_commit-plan/` (or the folder given, or the current one): repository, worktree, branch, lots, age, and
629
+ its state - pending, partly committed, committed, or stale when something else moved the branch. A
630
+ folder holding a hand-written `commit*.sh` and no lots file shows as "legacy script, state unknown".
631
+ - `dialecte worktree add <repository> <branch> [--from <ref>] [--json]` makes a worktree under the
632
+ workspace's `.worktrees/<repository>-<branch tail>` (the last segment of the branch: `core-depth` for
633
+ `feat/depth`; a new branch starts from `--from`, else the base
634
+ branch): it copies the hooks folder `core.hooksPath` names (husky's `.husky/_` is ignored by git, so a
635
+ plain worktree misses it), copies the main checkout's `node_modules` copy-on-write where the file system
636
+ can (links kept, a relative link to a sibling re-pointed so it still reaches it) - from the worktree that
637
+ has the `--from` branch checked out when it has one, else from the main checkout - lists `.dialecte/`
638
+ once in the exclude file of the repository's common git folder (so for the main checkout and every
639
+ worktree of it), and writes the hygiene baseline `gate --fast` compares with; it prints a card.
640
+ Before the copy it makes the links the worktree's `file:` and `link:` dependencies need (`dependencies`,
641
+ `devDependencies`, `optionalDependencies`, `peerDependencies`): a relative path that leaves the worktree
642
+ into the workspace's `.worktrees/` (`file:../core` from `.worktrees/cli-x` reaches `.worktrees/core`)
643
+ gets a relative link there to the folder the same path reaches from the main checkout
644
+ (`.worktrees/core -> ../core`). Each dependency gets one outcome, in the card's `links` row and the
645
+ JSON's `siblingLinks` (`dependency`, `link`, `target`, `outcome`): `created`; `present` (a link that
646
+ already reaches it: a second worktree changes nothing); `skipped: <target> missing`;
647
+ `skipped: <folder> missing` for a path into a sibling whose own folder is not under `.worktrees/` yet
648
+ (`file:../core/sub/pkg` without `.worktrees/core`); `skipped: outside .worktrees/`;
649
+ `skipped: cannot make the link (<code>)` when the file system refuses it (`EACCES`, ...);
650
+ `kept: points to <its text>, not <target>` or `kept: a real folder` (or file): what is there is never
651
+ replaced. A path inside the repository needs no link and is not listed. After the copy it reads
652
+ `node_modules` against the worktree's `package-lock.json` (its `packages` map, lockfileVersion 2 or 3,
653
+ nested packages included, bundled ones left out): each package installed at its locked version
654
+ (`missing`, `<installed> installed, lock <locked>`, `package.json unreadable`), each link reaching what
655
+ the lockfile resolves it to (`link to <path> missing`, `… points elsewhere`). A package npm may leave
656
+ out of this machine's install is not missing when absent: `optional`, or an `os` / `cpu` list this
657
+ platform does not match (`!x` excluding x); a `devOptional` one is, since a development install puts it
658
+ in. The card's `lockfile` row says
659
+ `✓ node_modules matches package-lock.json (<n> packages)`, or the count of packages that differ with the
660
+ first five, and a `next` row holds the command that puts it right, `cd '<worktree>' && npm ci`. Without
661
+ a lockfile it says `no package-lock.json: not checked`; a lockfile that is not JSON, or has no `packages`
662
+ map (lockfileVersion 1), is not checked either (`package-lock.json unreadable: not checked`,
663
+ `package-lock.json has no packages map: not checked`). The JSON carries it as `nodeModulesCheck`
664
+ (`lockfile`, `notChecked`, `problems`: `package`, `problem`; `command` when there are problems). The
665
+ exit code stays 0 whatever the links and the lockfile say: the worktree exists, and its card says what
666
+ to run.
667
+ - `dialecte lot exempt <reason>`, `lot accept <case> <reason>`, `lot revised <case|file|glob> <reason>`,
668
+ `lot gone <file|glob> <reason>` write the lot declaration `.dialecte/lot.json` at the package root (the
669
+ nearest package.json above the current folder) as tab-indented JSON, keeping what it holds; the same
670
+ case (or file) again replaces its reason. `accept` needs a case `<file>::<name>`; `gone` refuses one
671
+ (it writes `"gone": [{ "file": "<file or glob>", "reason": "..." }]`).
672
+ - `dialecte lot mutation <off|changed|audit|gate>` writes the lot's mutation switch (`"mutation"`, no
673
+ reason). Without it, `dialecte mutants run` mutates the changed lines when the lot's diff touches the
674
+ declared scope and nothing otherwise; `audit` mutates the whole scope; `gate` runs as `changed`.
675
+ - `dialecte mutants run [--mode changed|audit] [--base <ref>]` runs StrykerJS (resolved from the package,
676
+ its devDependency) on the scope `package.json` declares:
677
+ `"dialecte": { "mutation": { "scope": [...], "exclude": [...], "errorFactories": [...], "fast": { "vitestConfig": "..." }, "full": { "command": "..." } } }`.
678
+ `changed` mutates the scope lines changed since the merge base with the base branch (`dialecte.baseBranch`,
679
+ `main` when not said; then the remote's default branch, `refs/remotes/origin/HEAD`; with neither the run
680
+ is refused, exit 2, naming `dialecte.baseBranch` and `--base`) or `--base <ref>`, untracked scope files
681
+ whole; `audit` the whole scope (no base needed). Without `--mode` the lot's switch decides; with no switch,
682
+ `changed` when the change touches the scope, else `mutation off for this lot` and exit 0. A detached HEAD is
683
+ refused: a run is filed under its branch. Before Stryker starts, the run is written `running` with its
684
+ process id and that process's start time to `<git-common-dir>/dialecte-mutation/runs/<run id>.json` (every
685
+ worktree of the repository reads it); a run whose process is gone before it reports, or whose pid now
686
+ belongs to a process that started at another time, reads `died`. Every Stryker call names an empty config
687
+ file (`configFile`), so a `stryker.config.json` of the package is never merged in, and only the fast tier is
688
+ incremental. The fast tier runs first, then the timed-out mutants alone, then the declared full tier on the
689
+ survivors no committed record (`.dialecte/mutation-records.json`) lists; the entry is then replaced
690
+ `reported` with the counts, the survivors and the keys of the mutants it detected (killed or timed out), and
691
+ each survivor no record lists enters the ledger (`<git-common-dir>/dialecte-mutation/ledger.json`) as `new`,
692
+ keyed `<package>::<survivor key>`. A `new` or `scheduled` survivor becomes `killed` only when a later run
693
+ detected that exact mutant, and never by a run that started before the last run reporting it (that run tested
694
+ older code); a record with a reason and a family makes it `recorded` (a scheduled one keeps its follow-up
695
+ name). Any other run leaves it as it is: a survivor whose line changed or went away stays pending until the
696
+ lot tests it, records its reason or schedules it. The ledger's readers and writers hold a lock file beside it
697
+ (one whose owner process is gone, or that names no owner and is a few seconds old, is taken over) and first
698
+ take in every reported run the ledger has not taken in yet, in the order they started, so a run whose ledger
699
+ update was missed still reaches it, once. The last lines name the package, lot (the branch), tree (12
700
+ characters), mode, counts, each new survivor `file:line mutation` and each ledger item the run moved
701
+ (`<key> file:line killed|recorded`). Exit 1 only when Stryker fails (the run stays `running` until the
702
+ process ends); survivors never fail the command. Reports and sandboxes go under `.tmp/mutants/<run id>/`,
703
+ removed once the run reported. Stryker's incremental file lives in the run's work folder, seeded from and
704
+ written back to `<git-common-dir>/dialecte-mutation/incremental/<package hash>-<key>.json` after a reported
705
+ fast tier. The key holds the whole tree (`.dialecte/` left out), the package's path, the installed lock, the
706
+ linked `file:` dependencies, the fast tier's options, the cli version and the ignorer plugin's bytes, so the
707
+ file is reused on an identical tree only (a rerun, other targets, `changed` then `audit`, another worktree at
708
+ the same tree, a rerun after recording reasons) and never across edits. The store keeps the newest 4 files of
709
+ a package. A write-back that fails prints one warning on stderr and the run goes on.
710
+ - `dialecte mutants status [--json]`: the package's running runs with their age, died runs, `new`
711
+ survivors grouped by the lot that first saw them and `scheduled` ones by follow-up.
712
+ `dialecte mutants schedule <follow-up> <key>...` (or `--all-new`) moves `new` survivors to `scheduled`
713
+ under that follow-up (an unknown key refuses the whole call); `dialecte mutants abandon <run id>` marks a
714
+ died run `abandoned` and keeps it (a running or reported run is refused); `dialecte mutants migrate`
715
+ turns `scripts/mutants/equivalent-mutants.json` into `.dialecte/mutation-records.json` (same keys and
716
+ reasons, family `unclassified`, the line's hash), never overwriting an existing file. The store is
717
+ written by the cli only: never edit it by hand.
718
+ - `dialecte mutants judge [--file <file>]` prints, per file (sorted), the package's `new` survivors as a judge
719
+ packet: each survivor's key, line and mutation, a family guess with its reason (the first rule its code
720
+ matches: an `errors/` file or error wording, a `.constants.ts` file or a module-level declaration, an
721
+ exhaustive `default:`; `unclassified` when none does), the covering tests the last run that reported it named
722
+ (five, then `…and <n> more`), the code around it as the file is now (5 lines above and below, 21 at most, each
723
+ line cut at 160 characters, the mutated lines marked `>`, `line changed since the run` when its text differs
724
+ from the reported one) and the `record` and `schedule` commands that close it. A packet holds 10 survivors at
725
+ most and its JSON and its text stay within 12000 bytes each: the rest is counted (`…and <n> more survivors`);
726
+ a lone survivor over the cap loses window lines (context first), then test names, then the end of its mutation
727
+ text, each counted. A run entry stores at most five covering test names per survivor, and how many more.
728
+ `dialecte mutants record (--key <key>... | --file <file>) --family <family> --reason <text> [--removable]`
729
+ writes each survivor's record to `.dialecte/mutation-records.json` (family, trimmed reason of at most 200
730
+ characters, the hashes of its line and tests; `removable` for `invariant-guard` and `fallback-never-taken`
731
+ only; other records kept, files and records sorted), then moves each `new` or `scheduled` one to `recorded`
732
+ (a killed or recorded one stays as it is), both under the ledger lock, the records first: a crash between the
733
+ two leaves the survivor `new` until a later run or `record` takes the record in. `--key` repeats or takes
734
+ several keys; `--file` takes every `new` or `scheduled` survivor of the file. An unknown family, `unclassified`,
735
+ an empty or too long reason, `--removable` with another family, an unknown key, or a `--file` holding no `new`
736
+ or `scheduled` survivor refuses the whole call (exit 1, nothing written); both `--key` and `--file`, neither, no
737
+ `--family` or `--reason`, or an option given another of the verb's options as its value (`--reason --json`) is a
738
+ usage error (exit 2). `dialecte mutants drop <run id>` removes an abandoned run, or a reported run, from the
739
+ store; a running or died run (abandon it first) and the latest reported run of its branch (it is that branch's
740
+ evidence: drop it once a newer run of the branch reported) are refused. Every verb but `run` takes `--json` and
741
+ then prints exactly one JSON object on stdout, a refusal included: `{ "verb", "ok": true, ... }` or
742
+ `{ "verb", "ok": false, "reason" }` with the usual exit code (`status --json` prints the status itself).
743
+ - A `new` survivor or a died run blocks every hand-over of the package (the card's `mutation` line and
744
+ `handover run`'s guard) until it is killed, recorded, scheduled, rerun or abandoned; a running run blocks a
745
+ merge hand-over and a gate lot; `dialecte worktree prune` keeps the worktree of a running or died run.
746
+ - `dialecte worktree prune [--root <workspace>] [--yes] [--json]` lists, per repository of the workspace,
747
+ the worktrees and local branches whose commits are all in the base branch, the hand-over folders whose
748
+ lots are all committed (never `_commit-plan` itself, nor a folder holding other folders) and the
749
+ rehearsals whose process is gone - the rehearsal folders under `/tmp` (each goes whole) and the clones
750
+ earlier cli versions made in the system's temporary folder, each judged by its marker - with the
751
+ command that removes each (its absolute `cd` first).
752
+ `--yes` runs them after a confirmation on a terminal; without a terminal it refuses, so hand the
753
+ commands (or the `--yes` command) to a person. Kept, each with why: an unmerged branch; the branch the
754
+ main checkout is on; a worktree a mutation run was started from while that run still runs
755
+ (`mutation run <id> still running (pid <pid>)`) or after it died before reporting
756
+ (`mutation run <id> died before reporting: rerun or dialecte mutants abandon <id>`; a reported or
757
+ abandoned run keeps nothing); a worktree a hand-over is pending in, or with uncommitted changes; a branch whose
758
+ reflog still reaches commits the base does not hold (reset onto a newer base after commits of its own:
759
+ its reflog is the only way back to them); a worktree or branch with no commit of its own in its reflog
760
+ (just made); a worktree holding ignored files that removing it would delete (anything but
761
+ `node_modules`, `dist`, `.vitepress/cache`, `.vitepress/dist`, `.DS_Store` and the hooks folder; a long
762
+ list is counted, the first three named); a rehearsal clone whose process still runs, or without a
763
+ marker. It never removes, nor offers to remove, a symbolic link or what a link reaches. A worktree
764
+ path, a hand-over folder or a rehearsal clone that is a link, or a hand-over folder reached through a
765
+ linked folder under the workspace at any depth, is kept with
766
+ `a link: prune never removes a link nor what it points to` (a dangling link included). A worktree,
767
+ hand-over folder or rehearsal clone that a link reaches (links looked for one level under the
768
+ workspace, its `.worktrees/`, its `_commit-plan/` and the scratch folder) is kept with
769
+ `the link <link> points to it`. `git worktree prune` unregisters every worktree whose folder holds no
770
+ checkout, a link's too: while a registered worktree of the repository is a link, a worktree deleted
771
+ from disk is kept, naming that link, and no `git worktree prune` is offered. The sibling links
772
+ `worktree add` makes (`.worktrees/core -> ../core`) are in no item. It reads each worktree with
773
+ `git --no-optional-locks`, so it never rewrites an index. `handover list` follows a link to a hand-over
774
+ folder and lists a folder reached by its path and through a link once.
775
+ - `dialecte record review|decision|snapshot` and `dialecte review delta` keep a lot's review rounds in its
776
+ hand-over folder (`_commit-plan/<topic>-<date>/`), which stays outside every repository: each refuses a
777
+ folder inside a git work tree or a git folder (`.git/`, a bare repository). `--` ends the options: the
778
+ words after it are taken as they are, so a finding or a reason may start with `--`.
779
+ - `record review <folder> --round <n> --severity <blocking|should-fix|nit> --at <file:line> <finding>`
780
+ appends the row `| R<n>-<k> | <n> | <severity> | <file:line> | <finding> | open |` to
781
+ `<folder>/findings-ledger.md` (the folder, the file and its table made when absent; k one past the
782
+ highest of the round). A `|` is written `\|`; a line break is refused. A hand-written ledger keeps
783
+ every other byte.
784
+ - `record decision <folder> <id> <state>` rewrites that row's state cell: `open`, `fix-to-verify`,
785
+ `fixed <round> [note]` (a round after the one that raised it), `accepted <reason>`, `logged <where>`.
786
+ An id not in the ledger is refused, naming the ids it holds.
787
+ - `record choice <folder> --by <who> <decision>` appends `| <decision> | <who> | <yyyy-mm-dd> |` to
788
+ `<folder>/decisions.md` (made with its title and table when absent): a decision made outside the
789
+ findings ledger, the user's above all. A `|` is written `\|`; an empty `--by`, a line break, or more
790
+ than one decision word (quote it) is refused.
791
+ - `record snapshot <folder> --round <n>` copies every file `git status --porcelain -z
792
+ --untracked-files=all` lists at the worktree root (the old path of a rename included) to
793
+ `round-<n>/` at its repository-relative path - bytes, mode, a symlink as a symlink; a path gone from
794
+ disk (or now a folder) that HEAD holds goes in `round-<n>.deleted`, NUL-separated, sorted; HEAD in
795
+ `round-<n>.base`. An existing round, an untracked nested repository and a submodule (a gitlink in the
796
+ index or at HEAD) are refused; a run that
797
+ stops part-way leaves only `.partial` names, which the next run removes. `.dialecte/lot.json` is
798
+ never part of it.
799
+ - `review delta <folder> --round <n> [--worktree] [--json]` (n ≥ 2) prints, for each file of
800
+ `round-<n-1>/`, of `round-<n-1>.deleted` or of the worktree's status, what changed since round n-1,
801
+ in the form that fits where the file is: the snapshot copy against the worktree file (or
802
+ `/dev/null` when it is gone), `/dev/null` against a file deleted then and back now or new and absent
803
+ from the base, `git diff HEAD` for a file round n-1 had at the base. Files unchanged since round n-1
804
+ are left out; colour, external diff and textconv settings never apply. It refuses when HEAD moved
805
+ since `round-<n-1>.base`, and refuses a nested repository or a submodule as `record snapshot` does. `--worktree` adds a throwaway worktree on the branch
806
+ `<lot branch>-round-<n-1>` from the lot's branch tip: the deletions applied with `git rm
807
+ --pathspec-from-file`, then `round-<n-1>/` copied over, so a new test can run on the old code; it
808
+ prints its path and the removal command with its absolute `cd`. The lot's worktree is never
809
+ changed.
810
+
811
+ `gate --fast` starts with the hygiene of the worktree: nothing staged; no stash entry pushed on this
812
+ worktree's branch since `worktree add` made it (the baseline keeps every stash entry it saw, so another
813
+ session dropping one changes nothing; one stash is shared by every worktree and session: a new entry of
814
+ another branch is only noted, naming it; without a baseline the stash is not compared); and
815
+ every new file one the change declares (`--declare <path>`, repeatable; an undeclared one is a warning).
816
+ A failure says what changed and how to look at it with read-only commands.
817
+
818
+ Steps run with the runner's defaults - no lock, no `nice`, no worker cap - whoever else shares the machine.
819
+ A step that counts tests and runs vitest (its command, or the npm script it runs, names `vitest`) and fails
820
+ on its exit code or its counts is run once more with `--no-file-parallelism`, on the failing files the first
821
+ run named (through `npm run <script>` after one `--`; the whole step when the output names no file). The
822
+ rerun passes when it exits 0, counts no failed test and at least one passed: the step then passes,
823
+ flagged - `serial rerun of <n> file(s): exit 0, <counts> flaky in parallel` on its line, one
824
+ `flaky <file>` line under it per file, the note kept in the gate record. Otherwise the step fails as a
825
+ `real failure: <why>`, each file listed under it as `failed <file>` when it failed again or `flaky <file>`
826
+ when it passed serially, the rerun's last lines as the tail. While the rerun runs, the step's line still
827
+ shows its own command. A step that stalled, counts no tests, runs no vitest, or already runs one file at a time
828
+ (`--no-file-parallelism` in its command) is never rerun. `--json` carries the rerun of
829
+ each step (`rerun`: files, the files still failing, status, exit code, counts).
830
+
831
+ `gate --fast` and `--full` run a `tdd` step after the hygiene (first in `--full`): every test-code file
832
+ changed since the base (test files, helpers, fixtures, snapshots) must be as the red run that last froze it
833
+ ("test code changed outside tdd red"), and every case of the change red then green, or unchanged; the
834
+ others fail the gate with the list. The flags of the receipts and the deleted cases are printed under the
835
+ step. The lot file may also accept cases without a red - a new test of behaviour that already exists, an honest
836
+ cut of an assertion: `"accept": [{ "case": "<file>::<name> [project]", "reason": "..." }]`. An accepted
837
+ case passes `tdd red` as accepted and does not block its file; the gate lists each acceptance with its
838
+ reason, the hand-over card counts them by reason from the receipts (those of earlier lots, which the file
839
+ no longer names, counted on one line), and both report an acceptance or a `revised` entry no case used. The card
840
+ lists every `gone` entry with its reason; only the gate reports a `gone` entry that covers no finding. The file is strict: an unknown key, at the top or in
841
+ an `accept` entry, and an exemption without a reason are refused, naming what is wrong. A lot the orchestrator declares exempt - a wording, rename or doc-only lot - passes with its reason
842
+ and what the change touches: `{ "tdd": "exempt: <reason>" }` in `.dialecte/lot.json` at the package root
843
+ prints "exempt: <reason> (n production file(s), m test file(s) changed)". The hygiene and the hand-over
844
+ leave the file out (never committed); the hand-over card shows the exemption and the flags. A package that
845
+ does not test with vitest skips the step.
846
+
847
+ A package tunes them in its package.json:
848
+
849
+ ```json
850
+ "dialecte": {
851
+ "gate": {
852
+ "fast": [
853
+ {
854
+ "name": "tests",
855
+ "run": "npx vitest run --project unit --changed",
856
+ "counts": "tests",
857
+ "changedOnly": true
858
+ }
859
+ ]
860
+ },
861
+ "generatedDocs": [".vitepress/data/elements-catalog.json"],
862
+ "referencePatterns": ["SPEC-[0-9]+"],
863
+ "baseBranch": "main"
864
+ }
865
+ ```
866
+
867
+ `gate.fast` / `gate.full` replace the default steps of that mode (`counts: "tests"` makes a step fail
868
+ when it counts no test; `changedOnly: true` marks a step that runs only the tests the change affects,
869
+ so "No test files found" passes with a note instead of failing; `restoresGeneratedDocs: true` restores the `generatedDocs` byte for byte after
870
+ it); `baseBranch` is the branch
871
+ `worktree add` starts from and `worktree prune` compares with (default `main`); `referencePatterns` adds the package's own patterns (extended regular expressions) to the plan
872
+ tags and citations `rules` and `handover` refuse.
873
+
874
+ ### GitHub text: recap and text check
875
+
876
+ Text written with an assistant tends to retell the diff and grow long. The pull request splits in two:
877
+ an expandable part made from records, and a short human part that is checked before it is posted. Both
878
+ commands only print; the user posts.
879
+
880
+ - `dialecte recap <hand-over folder>` prints the expandable part (`<details>`) as GitHub markdown, from the
881
+ records only: the commits of the lots (or `not committed yet`), the test cases the newest gate record of the
882
+ current tree judged red then green, counted per test file, the gate and rules lines (and `mutation`), the
883
+ lot's mutation runs (`Mutation`: each run of the branch and of the branches it merges, oldest first, with
884
+ its mode, id and counts or its state; each survivor those runs killed or recorded; each survivor first seen
885
+ on those branches and scheduled, with its follow-up; `No mutation run.`, or `No mutation scope declared.`
886
+ for a package without one), the review rounds from
887
+ the findings ledger, the decisions (accepted findings, the lot declaration's `accept` and `revised` entries,
888
+ the rows of `decisions.md`), the logged findings as follow-ups, and who reviewed and posted it (`git config
889
+ user.name`; no name set is refused). Every section is always there, saying so in one line when empty; a
890
+ branch that does not hold the lots on top of the recorded base lists none as committed and says so. Each
891
+ finding is printed with its id, its text without one leading reviewer tag `[...]`. The ledger is read whole:
892
+ every row after its header with the header's cell count is a finding, whatever its id (`R<n>-<k>`, `TR3-1`,
893
+ `F-a`, printed as written), notes between rounds included; its round is the round cell's, else the one an
894
+ `R<n>-` id names, else the row is refused. A state is read as a history (`fix wrong 2 (...) - fixed 3
895
+ (reasoned)`): it starts with `fixed`, `accepted`, `logged`, `open`, `fix to verify`, `fix wrong` or
896
+ `reopened`, and a spaced dash starts a new part only before `fixed <n>`, `reopened <n> by <id>`, `fix wrong
897
+ <n>`, `fix to verify`, a closing `open`, or a later `accepted` or `logged` followed by ` (`, `: ` or a
898
+ spaced dash; any other spaced dash belongs to the text before it. The last part decides (`fix wrong`,
899
+ `reopened` and `fix to verify` leave the finding open), an accepted one's reason being the rest (in its
900
+ parentheses, or after `- ` / `: `); a state recap cannot read is refused with the row's id. A `file:line` is
901
+ printed relative to the repository, or to the workspace folder for a sibling repository (the parent of the
902
+ main checkout; of the `.worktrees` folder when the repository is gone), never absolute: an absolute path
903
+ outside both, or one the rewrite does not reach (a `/` starting a path segment after a backtick, a quote,
904
+ `=`, `[`, `-`; `~/`), is refused with the row's id; a `/` starting no segment (`a.ts / b.ts`, `+/- 2`) and
905
+ URLs stay. Where a finding was logged, the hand-over folder and the lots file's notes are left out. It writes
906
+ nothing.
907
+ - `dialecte text check <file> [--kind pr|issue|comment|commit]` checks every line before the first `<details`
908
+ line (the recap is not checked). A pull request or an issue holds the headings `What changes`, `Why`, `How
909
+ to check it` in this order, then `Watch out` only when it has something to say; each with text under it,
910
+ nothing before the first. A comment or a commit holds no heading; a commit's line 1 is its subject, not
911
+ empty and at most 72 characters (longer ones are cut in logs and in GitHub's list), with a blank line before
912
+ the body. The word cap: 150 for a pull request (the diff carries the rest), 200 for an issue (it stands
913
+ alone), 80 for a comment (it answers one point), 100 for a commit body (the why; the subject is not
914
+ counted). Words hold a letter or a digit; headings and fenced code blocks are not counted. Past the cap it
915
+ prints the count, the cap and every line from the one that passed it. Exit 0 when the text holds, 1 with one
916
+ line per problem.
917
+
918
+ ## Run a script
919
+
920
+ `dialecte run <script.ts>` runs a script against an in-memory project of the dialecte your project
921
+ installs (with `@dialecte/core` 0.8.0 or later) and answers one structured outcome. The script is a
922
+ module whose default export receives `{ project, doc, documentId, dialecte, helpers, utils }`; what it
923
+ returns is the outcome's `result`.
924
+
925
+ ```ts
926
+ // add-part.ts
927
+ export default async function addPart({ doc }) {
928
+ const [assembly] = await doc.query.findByAttributes({
929
+ tagName: 'Assembly',
930
+ attributes: { name: 'A1' },
931
+ })
932
+ await doc.transaction(async (tx) =>
933
+ tx.addChild(assembly, { tagName: 'Part', attributes: { name: 'P2' } }),
934
+ )
935
+ }
936
+ ```
937
+
938
+ ```
939
+ dialecte run add-part.ts --in assembly.xml --expect expected.json
940
+ failed: expectations not met
941
+ operations: Assembly +0 ~1 -0, Part +1 ~0 -0
942
+ diagnostics: none
943
+ expectations: 0 passed, 1 failed
944
+ ✗ expected 3 Part under Assembly[name="A1"], found 2
945
+ ```
946
+
947
+ - `--in <file>` imports a file first (an empty document otherwise); its import diagnostics are in the
948
+ outcome. `--out <file>` writes the document once the script ran.
949
+ - `--prepare` stages the script's first transaction instead of committing it and stops the script
950
+ there: the records it would write, and what its callback returned (a lifecycle report), nothing
951
+ committed. Any other write is refused and fails the run, even when the script catches the refusal:
952
+ a second transaction, `commit()` on a prepared transaction, a transaction on a document opened
953
+ through `project.openDocument`, the project's own writes (`importFile`, `removeDocument`,
954
+ `undo`, ...) and its raw database (`getDatabaseInstance`). In every mode the runner alone commits:
955
+ `tx.commit`, `tx.finishStaging` and `tx.clearStagedOperations` are refused inside a callback, and a
956
+ transaction nested in another fails with `CONCURRENT_TRANSACTION`. The guarantee covers the API a
957
+ script is handed; a deliberate call around it (`Object.getPrototypeOf(doc).transaction.call(...)`, a
958
+ store reached by other means) is outside it.
959
+ - `--expect <file>`: a JSON array of expectations `{ "tag", "where"?, "under"?, "count"? }`, checked on
960
+ the result (on the staged transaction under `--prepare`); each one not met is named with the count
961
+ found. `count: 0` means none, no `count` at least one.
962
+ - Deterministic: ids come from a seeded generator (`--seed <n>`, 0 by default), `--now <iso>` freezes
963
+ the clock, both from the moment the script module loads (an id minted at its top level is seeded
964
+ too). The same script, input and seed give the same outcome.
965
+ - Operations are counted per record, as each commit merges them: an element created then updated in
966
+ one transaction is one creation.
967
+ - A thrown structured error is answered as code, key, detail, `meta` and the element's path from the
968
+ root (`/Root/A/AA_2[2]`); `dialecte explain <code>` says what it means.
969
+ - `--json` prints the outcome as data. `--package <name>` names the dialecte when the project depends
970
+ on none or several (`@dialecte/scl/v2019C1`, `@dialecte/core/test`). `--timeout <ms>` (120 s by
971
+ default): the run then answers a timeout and the command exits; called as a library, the script may
972
+ keep running in the caller's process. Exit 0 ok, 1 failed or an expectation not met, 2 usage. The
973
+ script's own console output goes to stderr. A value the script returns that is not JSON (a cycle, a
974
+ BigInt) is given as text with a note.
975
+ - Needs Node 22.18 or later: a `.ts` script runs through Node's built-in type stripping, no build step
976
+ (erasable TypeScript only: types, no enums or namespaces).
977
+
978
+ `dialecte explain <code | key>` reads the error catalogue of the installed core and the error and
979
+ diagnostic catalogues the dialecte exports: the message, when it is raised, the usual fix, the docs
980
+ page. `--json` for the entries as data; exit 1 when no catalogue knows the code.
981
+
982
+ ## A fixture from the engine
983
+
984
+ `dialecte fixture <Tag>` answers the smallest XML document holding `<Tag>` that is valid against the
985
+ dialecte's full schema, built by the engine of the dialecte your project installs - never written by hand.
986
+ It is a `dialecte run` of a script the command writes from the definition, read through core's readers:
987
+
988
+ - the chain of parents from the root down to the element: the shortest one (among chains as short, the
989
+ first in sequence order), or the one `--under A/B` names (the root may be named first or left out);
990
+ - every child an element on the way requires, as many times as it is required, and the first branch of
991
+ each choice it requires (unless a child already takes one), each with what it requires in turn; an
992
+ element declared with an abstract type names its first variant with `xsi:type`;
993
+ - a value for every required attribute, and text for an element whose type an empty text does not
994
+ satisfy: the fixed value, else the default, else the first value the type takes - an enumerated value,
995
+ a string its patterns match, a number counting up from the lowest its range allows, free text from the
996
+ tag name - checked against every facet (enumeration, pattern, length, range). Each sampled value is new
997
+ in the document, so unique and key fields never repeat one;
998
+ - every element a key selects holds its key fields, and every reference a keyref checks points at an
999
+ element of the key: one already planned when the values can meet (the element itself, for a reference to
1000
+ its own key), else one planted along the key's selector, with what it requires in turn (its own
1001
+ references included).
1002
+
1003
+ ```
1004
+ dialecte fixture AAA_1 --package @dialecte/core/test
1005
+ <?xml version="1.0" encoding="UTF-8"?>
1006
+ <Root xmlns="http://dialecte.dev/XML/DEFAULT">
1007
+ <A aA="A">
1008
+ <AA_1 aAA_1="AA_1">
1009
+ <AAA_1 aAAA_1="aaa">
1010
+ <AAAA_1 aAAAA_1="AAAA_1"/>
1011
+ </AAA_1>
1012
+ </AA_1>
1013
+ </A>
1014
+ </Root>
1015
+ ```
1016
+
1017
+ What is guaranteed, and how it is proven: the document is valid against the dialecte's full XSD -
1018
+ structure, values, identity (unique and key) and references (keyref). The tests build the fixture of every
1019
+ element of core's test dialecte and of scl and judge each with `xmllint --schema` on the real XSD.
1020
+
1021
+ What is not:
1022
+
1023
+ - The hooks have the last word on what they fill: an attribute a hook already set when the element was
1024
+ added (an id, a derived name) keeps the hook's value. A dialecte whose hooks fill a key or reference
1025
+ field differently from the plan could break a reference the plan made good; the tests catch it for the
1026
+ dialectes they cover.
1027
+ - Only the first branch of a required choice, and the first variant of an abstract type, are taken; the
1028
+ fixture holds no optional content.
1029
+ - A reference whose key is declared on another element than the keyref, a key reached only through `.//`
1030
+ or through any element, and a field reaching past the selected element are not planted: the command
1031
+ exits 1 naming the constraint, never with a document that breaks it.
1032
+ - The document carries no record-id marks (`dev:db-id`): it is the plain export, as a user would get it.
1033
+
1034
+ - Ids are seeded and the clock is frozen: the same command and the same installed versions give the same
1035
+ bytes.
1036
+ - `--out <file>` writes the document and prints one line (the path of the element, the bytes); `--json`
1037
+ answers `{ ok, packageName, tag, path, bytes, xml }` (`out` in place of `xml` with `--out`).
1038
+ - Exit 1 with the reason when there is no fixture: an unknown tag (the closest tags named), a `--under`
1039
+ step its parent does not hold, an element only an endless chain of required children could hold, a
1040
+ value the fixture cannot make (the attribute named: a pattern construct it does not read, facets no
1041
+ value satisfies), a reference it cannot plant (the constraint named), or a write the engine refuses
1042
+ (its outcome, as `dialecte run` prints it). Exit 2: usage.
1043
+ - The command does not run a schema validator itself: no XSD ships with it.
1044
+
1045
+ ## Developing the cli
1046
+
1047
+ The `schema`, `run`, `fixture` and `explain` tests drive `@dialecte/core`'s own test dialecte: they resolve core from the
1048
+ `@dialecte/core` devDependency, or from the built core checkout `DIALECTE_CORE_DIR` names
1049
+ (`DIALECTE_CORE_DIR=../core npm run test:run`); with neither they fail.
1050
+
1051
+ While the cli follows core's 0.8 train, the devDependency is `"@dialecte/core": "file:../core"`, and the lockfile
1052
+ holds it: the cli's checkout sits next to core's (`Dialecte/cli` and `Dialecte/core`), and a worktree under
1053
+ `Dialecte/.worktrees/` reaches it through the link `Dialecte/.worktrees/core` → `../core`, which
1054
+ `dialecte worktree add` makes (its card says `npm ci` when the copied `node_modules` differs from the
1055
+ lockfile). Build core there (`npm run build`) before running the tests. A release pins a published core again: `prepublishOnly` runs
1056
+ `src/release-check.ts` before the build, which refuses a package.json naming any dependency by a local folder
1057
+ (`file:`, `link:`, `git+file:`, a bare `../x`, `./x`, `/x` or `~/x` path) in `dependencies`, `devDependencies`, `peerDependencies` or `optionalDependencies`, one line
1058
+ per dependency (its field, name and spec), and says how to pin it
1059
+ (`npm install --save-exact <name>@<version>`).
1060
+
1061
+ The cli has a commit hook: `.husky/pre-commit` runs `npm run check` (type-check, lint, format; no suite), then
1062
+ `npm run test:hook` (`dialecte gate --hook` from the sources: the suite, unless a green `gate --full` of the
1063
+ committed tree answers it), then `npm run build`. `npm install` in the
1064
+ cli checkout activates it (`"prepare": "husky"` sets `core.hooksPath` to `.husky/_`), and `dialecte worktree add`
1065
+ copies `.husky/_` into each new worktree, so `handover run` proves a cli lot again at its commit, running the
1066
+ suite only for a tree no green `gate --full` checked. A hook
1067
+ runs with git's `GIT_DIR`, `GIT_INDEX_FILE` and the commit's identity set: the suite's setup file
1068
+ (`test/git-environment.setup.ts`, vitest `setupFiles`) clears them before any test, so a test's git acts on
1069
+ its scratch repository only, and the cli clears git's repository variables at its start.
1070
+
1071
+ The suite leaves no temporary folder behind: every test removes what it makes in its own teardown, also
1072
+ when it fails. A vitest global setup (`test/suite-guard/temp-folder-guard.setup.ts`, `globalSetup`) gives
1073
+ the run one short folder of its own (`dlt-<random>` under the system's temporary folder) and sets it as
1074
+ `TMPDIR` for the workers and the commands they spawn; at the end any entry left in it fails the run,
1075
+ named (ten, then `and <n> more`; Node's compile cache is not one), and the folder is removed whatever
1076
+ the outcome.
1077
+
1078
+ The cli does not re-declare core's types: the definition, record, diagnostic, error, expectation and reader shapes
1079
+ (`ResolvedDefinition`, `DataType`, `AttributeDefinition`, `AnyDialecteConfig`, `ChildOccurrences`, `Diagnostic`,
1080
+ `DialecteError`, `Expectation`, the readers of `@dialecte/core/utils`...) are `import type` from the `@dialecte/core`
1081
+ devDependency, which is erased from the build (the bin loads at run time the core each dialecte resolves, and
1082
+ `isCoreReaders` checks it holds the readers). Types the cli narrows, because a
1083
+ dialecte may run on an older core: the config found by shape (`isDialecteConfig` checks `rootElementName` and
1084
+ `definition` only, typed as `AnyDialecteConfig`), `CoreReaders` (typed from the core the cli is built against;
1085
+ `isCoreReaders` and the `requiredChoices` check report a reader an older core lacks), and `ElementDef` in
1086
+ `coverage` (every member optional). What `run` reads of a project and a document (`RunProject`, `RunDocument`,
1087
+ `RunQuery`) names only the members the runner calls.
1088
+
1089
+ `@dialecte/cli/lookups` (`src/lookups.ts`, built with declaration files) is the library entry of the lookup
1090
+ answers. Its declaration files import types from `@dialecte/core` (a loaded dialecte is typed by them): type-checking
1091
+ a program that uses the entry needs those types (`@dialecte/core` installed) or `skipLibCheck`.
1092
+
1093
+ The `fixture` tests judge every document twice:
1094
+
1095
+ - with core's `assertValidXml` (and scl's validator), which parse with the browser's `DOMParser`: in Node
1096
+ they borrow the cli's `@xmldom/xmldom` development dependency;
1097
+ - with `xmllint --noout --schema` (libxml2; the test fails when it is not installed - CI installs
1098
+ `libxml2-utils`), on the fixture of every element: core's test dialecte against the XSD core ships,
1099
+ `@dialecte/core/test/xsd/test.xsd` of the core the tests run on, always.
1100
+
1101
+ The scl cases run when `DIALECTE_SCL_DIR` names a built scl checkout; the scl validity case also needs
1102
+ `DIALECTE_SCL_XSD`, the path of the scl schema's entry XSD on your machine (the schema does not ship with any
1103
+ package). Both are skipped, by their name, otherwise, and are not run in CI.
1104
+
43
1105
  ## How it fits the ecosystem
44
1106
 
45
1107
  | Package | Bin | Audience | Phase |