@milehimikey/em 1.8.1 → 1.9.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.
Files changed (105) hide show
  1. package/.claude/skills/event-modeling/SKILL.md +58 -404
  2. package/.claude/skills/event-modeling-conform/SKILL.md +77 -0
  3. package/.claude/skills/{event-modeling → event-modeling-conform}/reference/conform.md +40 -14
  4. package/.claude/skills/event-modeling-design/SKILL.md +139 -0
  5. package/.claude/skills/event-modeling-discover/SKILL.md +89 -0
  6. package/.claude/skills/{event-modeling → event-modeling-discover}/reference/extract.md +3 -2
  7. package/.claude/skills/event-modeling-implement/SKILL.md +40 -0
  8. package/.claude/skills/{event-modeling → event-modeling-implement}/reference/implement.md +3 -2
  9. package/.claude/skills/event-modeling-review/SKILL.md +58 -0
  10. package/.claude/skills/{event-modeling → event-modeling-shared}/reference/em-dsl.md +115 -83
  11. package/.claude/skills/{event-modeling → event-modeling-shared}/reference/methodology.md +6 -5
  12. package/.claude/skills/event-modeling-shared/reference/operating-principles.md +150 -0
  13. package/.claude/skills/event-modeling-shared/reference/slice-doc-schema.md +381 -0
  14. package/.claude/skills/{event-modeling → event-modeling-shared}/templates/model-readme.md +2 -2
  15. package/.claude/skills/{event-modeling → event-modeling-shared}/templates/slice.md +57 -14
  16. package/README.md +24 -4
  17. package/dist/catalog/build.js +9 -0
  18. package/dist/catalog/build.js.map +1 -1
  19. package/dist/catalog/docJoin.d.ts +15 -0
  20. package/dist/catalog/docJoin.js +8 -0
  21. package/dist/catalog/docJoin.js.map +1 -1
  22. package/dist/catalog/modelCollisionValidate.d.ts +22 -0
  23. package/dist/catalog/modelCollisionValidate.js +67 -0
  24. package/dist/catalog/modelCollisionValidate.js.map +1 -0
  25. package/dist/catalog/orphanedSliceDocValidate.d.ts +11 -0
  26. package/dist/catalog/orphanedSliceDocValidate.js +98 -0
  27. package/dist/catalog/orphanedSliceDocValidate.js.map +1 -0
  28. package/dist/catalog/sliceDoc.d.ts +15 -0
  29. package/dist/catalog/sliceDoc.js +18 -0
  30. package/dist/catalog/sliceDoc.js.map +1 -1
  31. package/dist/cli/changelogBuild.d.ts +12 -0
  32. package/dist/cli/changelogBuild.js +89 -0
  33. package/dist/cli/changelogBuild.js.map +1 -0
  34. package/dist/cli/ciInit.d.ts +42 -0
  35. package/dist/cli/ciInit.js +298 -0
  36. package/dist/cli/ciInit.js.map +1 -0
  37. package/dist/cli/conformSupersede.d.ts +32 -0
  38. package/dist/cli/conformSupersede.js +102 -0
  39. package/dist/cli/conformSupersede.js.map +1 -0
  40. package/dist/cli/coverage.d.ts +6 -1
  41. package/dist/cli/coverage.js +28 -3
  42. package/dist/cli/coverage.js.map +1 -1
  43. package/dist/cli/frontmatterSurgery.d.ts +28 -0
  44. package/dist/cli/frontmatterSurgery.js +66 -0
  45. package/dist/cli/frontmatterSurgery.js.map +1 -0
  46. package/dist/cli/markImplemented.js +6 -45
  47. package/dist/cli/markImplemented.js.map +1 -1
  48. package/dist/cli/ratify.d.ts +41 -0
  49. package/dist/cli/ratify.js +151 -0
  50. package/dist/cli/ratify.js.map +1 -0
  51. package/dist/cli/reratify.d.ts +33 -0
  52. package/dist/cli/reratify.js +137 -0
  53. package/dist/cli/reratify.js.map +1 -0
  54. package/dist/cli/skillCheck.d.ts +6 -0
  55. package/dist/cli/skillCheck.js +46 -0
  56. package/dist/cli/skillCheck.js.map +1 -1
  57. package/dist/cli/skillDirs.d.ts +15 -0
  58. package/dist/cli/skillDirs.js +34 -0
  59. package/dist/cli/skillDirs.js.map +1 -0
  60. package/dist/cli/skillSync.d.ts +10 -0
  61. package/dist/cli/skillSync.js +15 -0
  62. package/dist/cli/skillSync.js.map +1 -1
  63. package/dist/cli/sliceIndex.d.ts +3 -0
  64. package/dist/cli/sliceIndex.js +6 -2
  65. package/dist/cli/sliceIndex.js.map +1 -1
  66. package/dist/cli/sliceLink.d.ts +52 -0
  67. package/dist/cli/sliceLink.js +152 -0
  68. package/dist/cli/sliceLink.js.map +1 -0
  69. package/dist/cli/status.d.ts +261 -0
  70. package/dist/cli/status.js +536 -0
  71. package/dist/cli/status.js.map +1 -0
  72. package/dist/cli/usageLog.d.ts +75 -0
  73. package/dist/cli/usageLog.js +193 -0
  74. package/dist/cli/usageLog.js.map +1 -0
  75. package/dist/cli.js +503 -132
  76. package/dist/cli.js.map +1 -1
  77. package/dist/emit/freshnessJson.d.ts +6 -0
  78. package/dist/emit/freshnessJson.js +24 -0
  79. package/dist/emit/freshnessJson.js.map +1 -0
  80. package/dist/emit/json.d.ts +62 -8
  81. package/dist/emit/json.js +14 -3
  82. package/dist/emit/json.js.map +1 -1
  83. package/dist/emit/statusJson.d.ts +7 -0
  84. package/dist/emit/statusJson.js +39 -0
  85. package/dist/emit/statusJson.js.map +1 -0
  86. package/dist/emit/typespec.d.ts +26 -0
  87. package/dist/emit/typespec.js +356 -0
  88. package/dist/emit/typespec.js.map +1 -0
  89. package/dist/emit/usageReportJson.d.ts +3 -0
  90. package/dist/emit/usageReportJson.js +23 -0
  91. package/dist/emit/usageReportJson.js.map +1 -0
  92. package/dist/mcp/server.d.ts +1 -1
  93. package/dist/mcp/server.js +301 -11
  94. package/dist/mcp/server.js.map +1 -1
  95. package/dist/model/rules.d.ts +13 -0
  96. package/dist/model/rules.js +20 -0
  97. package/dist/model/rules.js.map +1 -1
  98. package/dist/templates.d.ts +1 -1
  99. package/dist/templates.js +2 -2
  100. package/dist/util/markers.d.ts +16 -4
  101. package/dist/util/markers.js +23 -10
  102. package/dist/util/markers.js.map +1 -1
  103. package/package.json +2 -1
  104. /package/.claude/skills/{event-modeling → event-modeling-shared}/templates/conformance-report.md +0 -0
  105. /package/.claude/skills/{event-modeling → event-modeling-shared}/templates/state.md +0 -0
@@ -1,4 +1,4 @@
1
- <!-- DSL behavior change? Update BOTH docs/dsl.md and .claude/skills/event-modeling/reference/em-dsl.md -->
1
+ <!-- DSL behavior change? Update BOTH docs/dsl.md and .claude/skills/event-modeling-shared/reference/em-dsl.md -->
2
2
 
3
3
  # `em` DSL Reference & Cheatsheet
4
4
 
@@ -12,88 +12,118 @@ Keep `.em` files focused on **structure**; put deep design in markdown linked vi
12
12
 
13
13
  <!-- GENERATED:cli:start -- run `npm run docs:generate` to refresh, do not hand-edit -->
14
14
  ```bash
15
- em --version # print the installed em version
16
- em init [file] # scaffold a starter .em model
17
- em init [file] -f, --force # overwrite if the file exists
18
- em scaffold <name> # scaffold a full project: <slug>/<slug>.em, README.md, .event-modeling.md (see docs/cli.md — for just a starter .em, use `em init`)
19
- em scaffold <name> -f, --force # overwrite the directory's contents if it already exists
20
- em render <file> # transpile a model and render it (or emit DOT)
21
- em render <file> -o, --out <path> # output path (extension picks the format)
22
- em render <file> -T, --format <fmt> # output format (svg, png, pdf, ...)
23
- em render <file> --slice <name> # render only this slice, redrawn in its own canonical pattern shape (default out: slices/<kebab-slug>.svg)
24
- em render <file> --emit-dot # print the generated DOT instead of rendering
25
- em render <file> --keep-empty-lanes # keep the API lane even when empty
26
- em export <file> # export a versioned JSON snapshot of the normalized model
27
- em export <file> -o, --out <path> # write to a file instead of stdout
28
- em export <file> --slice <key> # export only this slice's object (pattern/fields/doc) instead of the whole model (export key, MIL-128) — refuses only if THIS slice has an error; an unrelated slice's breakage elsewhere in the model doesn't block it (see docs/cli.md)
29
- em diff <old> [new] # compare two models structurally (two files, or one file across git revisions)
30
- em diff <old> [new] --from <rev> # diff <old> against this git revision instead of a second file
31
- em diff <old> [new] --to <rev> # diff against this git revision instead of the current file (requires --from)
32
- em diff <old> [new] --exit-code # exit 1 if the models differ, 0 if identical (git-diff convention)
33
- em diff <old> [new] --json # print a JSON document instead of the text report (see docs/cli.md)
34
- em glossary <files> # cross-model glossary of terms, with consistency checks across models (see docs/cli.md)
35
- em glossary <files> --json # print the full glossary document instead of the text report
36
- em glossary <files> -o, --out <path> # write the JSON document to a file instead of stdout (requires --json)
37
- em glossary <files> --list-conflicts # print only the conflict lines, no summary
38
- em glossary <files> --fail-on-conflicts # exit non-zero if any cross-model term conflicts were found (opt-in — conflicts are warnings and don't block by default)
39
- em catalog <files> # generate a browsable static HTML catalog site over one or more .em models (see docs/cli.md)
40
- em catalog <files> -o, --out <dir> # output directory
41
- em catalog <files> -T, --format <fmt> # diagram format embedded in the catalog (svg or png)
42
- em catalog <files> --title <text> # catalog site title
43
- em catalog <files> --keep-empty-lanes # keep the API lane even when empty
44
- em slice new <name> # scaffold a fresh slices/<key>.md doc — the 5 frontmatter keys required at `status: draft` plus the `# Slice:` heading and diagram-image stub; judgment sections (Intent, Scenarios, Open Questions, ...) stay hand-authored (see docs/slice-doc-schema.md, templates/slice.md)
45
- em slice new <name> --pattern <pattern> # slice pattern: state-change | state-view | automation | translation
46
- em slice new <name> --swimlane <swimlane> # swimlane, e.g. "Persona → Context"
47
- em slice new <name> -f, --force # overwrite the file if it already exists
48
- em slice index <file> # rewrite the model's sibling README.md's GENERATED Slices table from `em export`'s slice facts (key, pattern, doc status/implementedIn) — the hand-maintained table is deprecated
49
- em slice index <file> --check # verify the table is current; exit non-zero on drift without writing (CI)
50
- em slice mark-implemented <file> <slice-key> <pr-url> # flip a slice doc's frontmatter to `status: implemented` / `implementedIn: <pr-url>` — the one edit an implementing agent makes to a ratified doc at merge (MIL-103, replaces the em-sdd-bridge `em-sdd-mark-implemented` script; see reference/implement.md §6). Idempotent on the same URL; refuses to overwrite a different one; never touches `version:` or the doc body
51
- em changelog <file> # render a model's git history as a business-readable ledger (see docs/cli.md)
52
- em changelog <file> --from <rev> # start the walk at this revision (inclusive)
53
- em changelog <file> --to <rev> # end the walk at this revision (inclusive; default HEAD)
54
- em changelog <file> -o, --out <path> # write to a file instead of stdout
55
- em state read [dir] # print the state file's mechanical fields as JSON
56
- em state set-phase <phase> [dir] # rewrite Current phase: (and Last updated:); --step also rewrites Current step:
57
- em state set-phase <phase> [dir] --step <n> # also set Current step: to this value
58
- em state set-conformance <revision> [dir] # rewrite Last conformance: (and Last updated:) in the exact format reference/conform.md parses
59
- em state set-conformance <revision> [dir] --report <path> # path to the conformance report just written
60
- em state set-review <date> [dir] # rewrite Last stakeholder review: (and Last updated:)
61
- em conform-scope <file> # mechanize conform phase step 1 (reference/conform.md): map the target repo's changed paths since Last conformance: to slices via each slice doc's implementedIn, JSON to stdout — --seed-asis also seeds the <model>-asis.em scratch model (see docs/cli.md)
62
- em conform-scope <file> --repo <path> # path to (or inside) the target codebase's git repository
63
- em conform-scope <file> --full # ignore Last conformance:/changed paths; scope every implemented slice
64
- em conform-scope <file> --seed-asis # write <model>-asis.em as a byte copy of the canonical model and ensure it's gitignored
65
- em watch <file> # re-render on every save
66
- em watch <file> -o, --out <path> # output path (extension picks the format)
67
- em watch <file> -T, --format <fmt> # output format (svg, png, pdf, ...)
68
- em watch <file> --keep-empty-lanes # keep the API lane even when empty
69
- em watch <file> --serve # serve a live viewer with instant push-reload (no polling)
70
- em watch <file> --port <n> # port for --serve (default 5173)
71
- em validate <file> # check a model against event-modeling rules
72
- em validate <file> --list-issues # print only open `issue` diagnostics (slice, element, line, text)
73
- em validate <file> --list-divergences # print only accepted-divergence annotations (slice, element, line, text) — never fails the build
74
- em validate <file> --list-public # print only events and views marked `public` (slice, kind, name, line) — an integration-surface audit, never fails the build
75
- em validate <file> --fail-on-issues # exit non-zero if the model has any open `issue`s (opt-in — issues are warnings and don't block by default)
76
- em validate <file> --slice-ready <key> # readiness gate for one slice (export key): status ready-to-implement, doc resolvable via note binding, zero unchecked Open Questions — exits non-zero if not ready (MIL-87)
77
- em validate <file> --json # print a JSON document instead of text — works on a model WITH errors, unlike `em export` (MIL-128, see docs/cli.md); exit codes are unchanged
78
- em migrate <file> # rewrite the old two-slice Automation/Translation shape into the merged single-slice shape MIL-120 made canonical (see docs/cli.md)
79
- em migrate <file> --write # apply the rewrite to the file (default: dry run — report only, write nothing)
80
- em ledger <file> # check slice docs' version: field agrees with their content across two git revisions (opt-in CI check, MIL-89 — never part of `em validate`, see docs/ci.md)
81
- em ledger <file> --from <rev> # baseline revision
82
- em ledger <file> --to <rev> # compare revision (default: current working tree)
83
- em ledger <file> --json # print a JSON document instead of the text report (see docs/cli.md)
84
- em coverage <file> # check that every INV-* invariant ID cited in a ready-to-implement/implemented slice doc is cited by a test under --tests <dir> (MIL-130) — mechanizes reference/implement.md's definition-of-done citation check; advisory by default, --strict for CI
85
- em coverage <file> --tests <dir> # directory to scan recursively for test files citing invariant IDs
86
- em coverage <file> --strict # exit non-zero if any invariant ID has zero citations (CI)
87
- em coverage <file> --json # print a JSON document instead of the text report (see docs/cli.md)
88
- em contract # print the packaged implementation contract (reference/implement.md) to stdout — the agent-neutral discovery path for any agent that can run a shell, not just Claude Code (MIL-129); see docs/cli.md
89
- em mcp # start an MCP (Model Context Protocol) server over stdio, exposing validate/slice_ready/list_markers/export_model/export_slice/coverage/contract as tools (MIL-21) — a structured, agent-facing alternative to shelling out to `em`; see docs/mcp.md. Equivalent to running the `em-mcp` bin directly
90
- em skill install # copy the event-modeling skill into .claude/skills/event-modeling/
91
- em skill install -f, --force # overwrite an existing installation
92
- em skill install --no-agents-md # skip writing/updating the AGENTS.md agent-contract section (on by default, MIL-129)
93
- em skill sync [path] # update the vendored .claude/skills/event-modeling/ copy in [path] to match the installed em package (overwrites unconditionally; local edits are never merged, MIL-93)
94
- em skill sync [path] --no-agents-md # skip writing/updating the AGENTS.md agent-contract section (on by default, MIL-129)
95
- em skill check [path] # check the vendored .claude/skills/event-modeling/ copy in [path] for drift against the installed em package; exits non-zero on any mismatch (CI-ready, MIL-93)
96
- em skill check [path] --json # print a JSON document instead of the text report (see docs/cli.md)
15
+ em --version # print the installed em version
16
+ em init [file] # scaffold a starter .em model
17
+ em init [file] -f, --force # overwrite if the file exists
18
+ em scaffold <name> # scaffold a full project: <slug>/<slug>.em, README.md, .event-modeling.md (see docs/cli.md — for just a starter .em, use `em init`; for a multi-model project, pass --under to nest it under a shared parent directory)
19
+ em scaffold <name> -f, --force # overwrite the directory's contents if it already exists
20
+ em scaffold <name> --under <dir> # parent directory to scaffold into — writes <dir>/<slug>/ instead of ./<slug>/, the supported multi-model layout (docs/cli.md, "Multi-model projects"): one directory per model, so each model's slices/ never collides with a sibling model's
21
+ em render <file> # transpile a model and render it (or emit DOT)
22
+ em render <file> -o, --out <path> # output path (extension picks the format)
23
+ em render <file> -T, --format <fmt> # output format (svg, png, pdf, ...)
24
+ em render <file> --slice <name> # render only this slice, redrawn in its own canonical pattern shape (default out: slices/<kebab-slug>.svg)
25
+ em render <file> --emit-dot # print the generated DOT instead of rendering
26
+ em render <file> --keep-empty-lanes # keep the API lane even when empty
27
+ em export <file> # export a versioned JSON snapshot of the normalized model
28
+ em export <file> -o, --out <path> # write to a file instead of stdout
29
+ em export <file> --slice <key> # export only this slice's object (pattern/fields/doc) instead of the whole model (export key, MIL-128) — refuses only if THIS slice has an error; an unrelated slice's breakage elsewhere in the model doesn't block it (see docs/cli.md)
30
+ em typespec <file> # EXPERIMENTAL/POC (MIL-159): generate a TypeSpec contract for a model's commands, public events, and public views (see docs/cli.md)
31
+ em typespec <file> -o, --out <path> # write to a file instead of stdout
32
+ em diff <old> [new] # compare two models structurally (two files, or one file across git revisions)
33
+ em diff <old> [new] --from <rev> # diff <old> against this git revision instead of a second file
34
+ em diff <old> [new] --to <rev> # diff against this git revision instead of the current file (requires --from)
35
+ em diff <old> [new] --exit-code # exit 1 if the models differ, 0 if identical (git-diff convention)
36
+ em diff <old> [new] --json # print a JSON document instead of the text report (see docs/cli.md)
37
+ em glossary <files> # cross-model glossary of terms, with consistency checks across models (see docs/cli.md)
38
+ em glossary <files> --json # print the full glossary document instead of the text report
39
+ em glossary <files> -o, --out <path> # write the JSON document to a file instead of stdout (requires --json)
40
+ em glossary <files> --list-conflicts # print only the conflict lines, no summary
41
+ em glossary <files> --fail-on-conflicts # exit non-zero if any cross-model term conflicts were found (opt-in — conflicts are warnings and don't block by default)
42
+ em catalog <files> # generate a browsable static HTML catalog site over one or more .em models (see docs/cli.md)
43
+ em catalog <files> -o, --out <dir> # output directory
44
+ em catalog <files> -T, --format <fmt> # diagram format embedded in the catalog (svg or png)
45
+ em catalog <files> --title <text> # catalog site title
46
+ em catalog <files> --keep-empty-lanes # keep the API lane even when empty
47
+ em slice new <name> # scaffold a fresh slices/<key>.md doc — the 5 frontmatter keys required at `status: draft` plus the `# Slice:` heading and diagram-image stub; judgment sections (Intent, Scenarios, Open Questions, ...) stay hand-authored (see .claude/skills/event-modeling-shared/reference/slice-doc-schema.md, templates/slice.md)
48
+ em slice new <name> --pattern <pattern> # slice pattern: state-change | state-view | automation | translation
49
+ em slice new <name> --swimlane <swimlane> # swimlane, e.g. "Persona → Context"
50
+ em slice new <name> -f, --force # overwrite the file if it already exists
51
+ em slice new <name> --wire <model-file> # also insert the `note "slices/<key>.md"` line onto the slice's primary element in this .em file (matched by export key), instead of just printing it to paste by hand (MIL-161)
52
+ em slice index <file> # rewrite the model's sibling README.md's GENERATED Slices table from `em export`'s slice facts (key, pattern, doc status/implementedIn) — the hand-maintained table is deprecated
53
+ em slice index <file> --check # verify the table is current; exit non-zero on drift without writing (CI)
54
+ em slice mark-implemented <file> <slice-key> <pr-url> # flip a slice doc's frontmatter to `status: implemented` / `implementedIn: <pr-url>` — the one edit an implementing agent makes to a ratified doc at merge (MIL-103, replaces the em-sdd-bridge `em-sdd-mark-implemented` script; see reference/implement.md §6). Idempotent on the same URL; refuses to overwrite a different one; never touches `version:` or the doc body
55
+ em slice ratify <file> <slice-key> # flip a slice doc's frontmatter to `status: ready-to-implement` and record `ratifiedBy:`/`ratifiedOn:` — the handoff sign-off (MIL-165, docs/process.md#what-ratified-means) that makes who ratified, and when, a first-class recorded fact. Idempotent on the same --by/--on pair; refuses to overwrite a different one already recorded; never touches `version:` or the doc body
56
+ em slice ratify <file> <slice-key> --by <name> # the ratifier's name
57
+ em slice ratify <file> <slice-key> --on <date> # ratification date, YYYY-MM-DD (default: today)
58
+ em slice reratify <file> <slice-key> # bump `version:` and flip a shipped slice doc's frontmatter back to `status: ready-to-implement` — the re-ratification mechanical edit (MIL-161, mirrors `em slice mark-implemented`). Only applies to a doc at `status: implemented`; clears any stale `ratifiedBy:`/`ratifiedOn:` (they describe the PRIOR version's sign-off) so a follow-up `em slice ratify --by` applies cleanly; never touches `implementedIn:` or the doc body
59
+ em changelog <file> # render a model's git history as a business-readable ledger (see docs/cli.md)
60
+ em changelog <file> --from <rev> # start the walk at this revision (inclusive)
61
+ em changelog <file> --to <rev> # end the walk at this revision (inclusive; default HEAD)
62
+ em changelog <file> -o, --out <path> # write to a file instead of stdout
63
+ em state read [dir] # print the state file's mechanical fields as JSON
64
+ em state set-phase <phase> [dir] # rewrite Current phase: (and Last updated:); --step also rewrites Current step:
65
+ em state set-phase <phase> [dir] --step <n> # also set Current step: to this value
66
+ em state set-conformance <revision> [dir] # rewrite Last conformance: (and Last updated:) in the exact format reference/conform.md parses
67
+ em state set-conformance <revision> [dir] --report <path> # path to the conformance report just written
68
+ em state set-review <date> [dir] # rewrite Last stakeholder review: (and Last updated:)
69
+ em state log-usage <file> # append one Usage log line — phase(s) touched + em validate's diagnostic categories hit, deduped and canonically formatted (MIL-161, docs/usage-data.md) — the mechanical half of 'save state at the end of every session' that used to be run-validate-then-hand-format; state file resolved next to <file>, same convention as em conform-scope
70
+ em state log-usage <file> --phases <list> # comma-separated phase(s) touched this session: discover, extract, model, slice, implement, conform, review, validate, watch
71
+ em usage-report [root] # aggregate every .event-modeling.md's Usage log under [root] into phase/diagnostic-category tallies (MIL-161) — replaces docs/usage-data.md's hand-rolled grep/awk/sort pipeline; a logged line that doesn't match the canonical em state log-usage format is reported under unparseableLines rather than silently mistallied or dropped
72
+ em usage-report [root] --json # print a JSON document instead of the text report
73
+ em conform-scope <file> # mechanize conform phase step 1 (reference/conform.md): map the target repo's changed paths since Last conformance: to slices via each slice doc's implementedIn, JSON to stdout — --seed-asis also seeds the <model>-asis.em scratch model (see docs/cli.md)
74
+ em conform-scope <file> --repo <path> # path to (or inside) the target codebase's git repository
75
+ em conform-scope <file> --full # ignore Last conformance:/changed paths; scope every implemented slice
76
+ em conform-scope <file> --seed-asis # write <model>-asis.em as a byte copy of the canonical model and ensure it's gitignored
77
+ em conform-supersede <file> <report-path> # stamp a conformance report with a "superseded as of <rev>" banner once its findings have been ruled on (MIL-164, docs/process.md#what-ratified-means) — the companion step to run at ratification time so a reader following the report's file:line citations knows they describe an ancestor of the current model. Additive-only splice, never a rewrite of the report; idempotent on the same --as-of/--findings/--on stamp; refuses if the report doesn't exist
78
+ em conform-supersede <file> <report-path> --as-of <rev> # the revision this ruling was made against — same value passed to `em state set-conformance`
79
+ em conform-supersede <file> <report-path> --findings <spec> # which finding number(s) this stamps as ruled, e.g. "1-3" or "1,2,4"
80
+ em conform-supersede <file> <report-path> --on <date> # ruling date, YYYY-MM-DD (default: today)
81
+ em watch <file> # re-render on every save
82
+ em watch <file> -o, --out <path> # output path (extension picks the format)
83
+ em watch <file> -T, --format <fmt> # output format (svg, png, pdf, ...)
84
+ em watch <file> --keep-empty-lanes # keep the API lane even when empty
85
+ em watch <file> --serve # serve a live viewer with instant push-reload (no polling)
86
+ em watch <file> --port <n> # port for --serve (default 5173)
87
+ em validate <file> # check a model against event-modeling rules
88
+ em validate <file> --list-issues # print only open `issue` diagnostics (slice, element, line, text)
89
+ em validate <file> --list-divergences # print only accepted-divergence annotations (slice, element, line, text) — never fails the build
90
+ em validate <file> --list-public # print only events and views marked `public` (slice, kind, name, line) — an integration-surface audit, never fails the build
91
+ em validate <file> --fail-on-issues # exit non-zero if the model has any open `issue`s (opt-in — issues are warnings and don't block by default)
92
+ em validate <file> --slice-ready <key> # readiness gate for one slice (export key): status ready-to-implement, doc resolvable via note binding, zero unchecked Open Questions — exits non-zero if not ready (MIL-87)
93
+ em validate <file> --json # print a JSON document instead of text — works on a model WITH errors, unlike `em export` (MIL-128, see docs/cli.md); exit codes are unchanged
94
+ em migrate <file> # rewrite the old two-slice Automation/Translation shape into the merged single-slice shape MIL-120 made canonical (see docs/cli.md)
95
+ em migrate <file> --write # apply the rewrite to the file (default: dry run — report only, write nothing)
96
+ em ledger <file> # check slice docs' version: field agrees with their content across two git revisions (opt-in CI check, MIL-89 — never part of `em validate`, see docs/ci.md)
97
+ em ledger <file> --from <rev> # baseline revision
98
+ em ledger <file> --to <rev> # compare revision (default: current working tree)
99
+ em ledger <file> --json # print a JSON document instead of the text report (see docs/cli.md)
100
+ em coverage <file> # check that every INV-* invariant ID cited in a ready-to-implement/implemented slice doc is cited by a test under --tests <dir> (MIL-130) — mechanizes reference/implement.md's definition-of-done citation check; advisory by default, --strict for CI
101
+ em coverage <file> --tests <dir> # directory to scan recursively for test files citing invariant IDs
102
+ em coverage <file> --strict # exit non-zero if any invariant ID has zero citations (CI)
103
+ em coverage <file> --json # print a JSON document instead of the text report (see docs/cli.md)
104
+ em status <files> # deterministic state-of-the-system rollup over one or more .em models: slices by lifecycle status, driftSignal breakdown, invariant coverage totals (with --tests), open issue markers + unchecked Open Questions, and last-conformance commits-behind-HEAD (MIL-163, see docs/cli.md)
105
+ em status <files> --tests <dir> # directory to scan for INV-* test citations — enables invariant coverage totals
106
+ em status <files> --repo <path> # git repo to compute commits-behind-HEAD in (default: each model's own directory)
107
+ em status <files> --json # print a JSON document instead of the text report (see docs/cli.md)
108
+ em status <files> --md # print a markdown block suited for README embedding
109
+ em status <files> --badge # print a generated SVG badge
110
+ em status <files> -o, --out <path> # write output to a file instead of stdout
111
+ em freshness <file> # standalone freshness signal for one model's conformance record (MIL-164): "last conformed <rev> — N commits and M slice-PRs behind HEAD", computed from the same conform-scope machinery `em status`'s conformance clause uses — for when you want just this fact, no full state-of-the-system rollup (see docs/cli.md)
112
+ em freshness <file> --repo <path> # git repo to compute behind-HEAD in (default: the model's own directory)
113
+ em freshness <file> --json # print a JSON document instead of the text line
114
+ em contract # print the packaged implementation contract (reference/implement.md) to stdout — the agent-neutral discovery path for any agent that can run a shell, not just Claude Code (MIL-129); see docs/cli.md
115
+ em mcp # start an MCP (Model Context Protocol) server over stdio, exposing validate/slice_ready/list_markers/export_model/export_slice/coverage/contract as tools (MIL-21) — a structured, agent-facing alternative to shelling out to `em`; see docs/mcp.md. Equivalent to running the `em-mcp` bin directly
116
+ em skill install # copy the event-modeling skill bundle into .claude/skills/ (event-modeling, event-modeling-discover/-design/-implement/-conform/-review, event-modeling-shared)
117
+ em skill install -f, --force # overwrite an existing installation
118
+ em skill install --no-agents-md # skip writing/updating the AGENTS.md agent-contract section (on by default, MIL-129)
119
+ em skill sync [path] # update the vendored .claude/skills/ event-modeling skill bundle in [path] to match the installed em package (overwrites unconditionally; local edits are never merged, MIL-93)
120
+ em skill sync [path] --no-agents-md # skip writing/updating the AGENTS.md agent-contract section (on by default, MIL-129)
121
+ em skill check [path] # check the vendored .claude/skills/ event-modeling skill bundle in [path] for drift against the installed em package; exits non-zero on any mismatch (CI-ready, MIL-93)
122
+ em skill check [path] --json # print a JSON document instead of the text report (see docs/cli.md)
123
+ em ci init <model> # install .github/workflows/em-ci.yml (PR gates: em validate, em slice index --check, em coverage --strict, em ledger, em skill check, em glossary --fail-on-conflicts, plus a push-triggered status-badge rebuild) and em-conform.yml (scheduled, advisory-only conformance cadence) — same install discipline as `em skill install`: marker-delimited, idempotent, --check for CI self-verification (MIL-166, see docs/ci.md)
124
+ em ci init <model> --tests <dir> # test directory the coverage/status steps scan for INV-* citations
125
+ em ci init <model> -f, --force # replace an existing workflow file that has no GENERATED markers
126
+ em ci init <model> --check # verify both files match the current preset; exit non-zero on drift without writing (CI)
97
127
  ```
98
128
  <!-- GENERATED:cli:end -->
99
129
 
@@ -530,6 +560,7 @@ not the prose above has caught up yet. `--slice-ready <key>`-only codes are excl
530
560
  | `both-ends-of-a-flow/ui-unbacked` | warning | `ui` with no read model or command | Add a `view` it displays, or the command it triggers. |
531
561
  | `both-ends-of-a-flow/view-unconsumed` | warning | Read model with no consumer | Add a `ui` or reaction that consumes it, or drop this instance. |
532
562
  | `connection-legality/illegal-pair` | error | Illegal connection | Only ui→command→event→view→ui and view→reaction→command are legal — the message names the missing step. |
563
+ | `cross-model-slice-doc-collision` | warning | Colliding slice doc path across models | Give each model its own directory (see docs/cli.md, "Multi-model projects"). |
533
564
  | `doc-model-element-not-in-doc` | warning | Model element the doc doesn't mention | Add the matching marker to the doc, or remove the element from the model. |
534
565
  | `doc-model-element-not-in-model` | warning | Doc names an element the model doesn't have | Add the element to the model, or fix/remove it in the doc. |
535
566
  | `doc-model-field-mismatch` | warning | Doc/model field mismatch | Reconcile the field table with the model's fields — names and types. |
@@ -553,6 +584,7 @@ not the prose above has caught up yet. `--slice-ready <key>`-only codes are excl
553
584
  | `note-binding-unratified` | warning | Unratified cross-slice note | Add `covers: <this-slice-key>` to that doc's frontmatter, or correct the note's path. |
554
585
  | `note-binding-unusable` | warning | Cross-slice note to a doc with unusable frontmatter | Fix that doc's frontmatter, or fix/remove the note. |
555
586
  | `open-issue` | warning | Open issue | Resolve the question, then remove the `issue` clause. |
587
+ | `orphaned-slice-doc` | warning | Orphaned slice doc | Rename it to a current slice's key, add `covers:` (plus a `note` binding) to attach it to a live slice, or delete it. |
556
588
  | `reaction-from-future-view` | error | Backward timeline (reaction reads a future view) | Declare the view in or before the reaction's slice. |
557
589
  | `reaction-from-unresolved` | error | Unknown read-model source | Project the event into a view first, or fix the `from` reference. |
558
590
  | `tag-composite-unknown-field` | error | Composite tag names an unknown field | Fix the field name, or add it to the event's fields. |
@@ -213,9 +213,10 @@ state change anyone can think of. No commands, no UI yet — just facts.
213
213
  User Clicked Button, User Viewed Page, User Logged In.
214
214
  - Model the process the business **needs**, not how the current system happens to work. Existing
215
215
  system behavior is a common source of fake events — screens and tables leaking in as facts.
216
- (**Extract mode inverts this**: in the skill's `extract` phase the existing system *is* the
217
- subject and this caution is deliberately suspended — see the "Extract" section below and
218
- `reference/extract.md`. The derived-value and telemetry filters still apply there.)
216
+ (**Extract mode inverts this**: in the `event-modeling-discover` skill's `extract` phase the
217
+ existing system *is* the subject and this caution is deliberately suspended — see the
218
+ "Extract" section below and `event-modeling-discover`'s own `reference/extract.md`. The
219
+ derived-value and telemetry filters still apply there.)
219
220
  - Output: a flat list of candidate `event` names.
220
221
 
221
222
  ### Step 2 — The Plot / Storyboard *(discover)*
@@ -251,7 +252,7 @@ or automation never records an event directly; it triggers a command.
251
252
  ### Step 6 — Elaborate Scenarios *(model first pass, slice deep pass)*
252
253
  For each slice, write **Given / When / Then** scenarios and surface **invariants**, **critical
253
254
  fields**, and **alternate / error flows**. In the `model` phase do a light first pass; the
254
- dedicated `slice` phase writes the full rich spec (see `templates/slice.md`).
255
+ dedicated `slice` phase writes the full rich spec (see `../templates/slice.md`).
255
256
  - Prompts: *"Given what starting state, when this command/trigger fires, then what event(s)
256
257
  result? What must always be true? What are the failure paths? Which fields are essential and
257
258
  what are their rules?"*
@@ -311,7 +312,7 @@ Desired-state improvements belong to the `model` and `slice` phases, after the a
311
312
  agreed.
312
313
 
313
314
  Procedure, source modes (event-driven vs. procedural synthesis), and the round-by-round loop:
314
- `reference/extract.md`.
315
+ the `event-modeling-discover` skill's own `reference/extract.md`.
315
316
 
316
317
  ---
317
318
 
@@ -0,0 +1,150 @@
1
+ # Operating principles, preconditions, and project layout (every phase)
2
+
3
+ Shared by every `event-modeling-*` skill. Read this before doing any work in any phase — it's
4
+ the discipline and mechanics that don't change no matter which phase you're facilitating.
5
+ `methodology.md` (the 7 steps + 4 patterns) and `em-dsl.md` (DSL syntax and validation rules) in
6
+ this same directory are the other two shared references; read them too before doing real work —
7
+ they, together with this doc, are the source of truth every phase skill builds on. Templates
8
+ live in `templates/`, a sibling of this `reference/` directory. References to `docs/*.md`
9
+ throughout these skills mean the
10
+ [em repository's docs](https://github.com/milehimikey/em/tree/main/docs) — they are not
11
+ vendored alongside these skills, with one exception: the frontmatter schema doc is vendored
12
+ right here as `reference/slice-doc-schema.md` (kept in sync with the em repo's
13
+ `docs/slice-doc-schema.md` by `em`'s own `docs:generate`/`docs:check`), so every
14
+ `slice-doc-schema.md` reference elsewhere in this bundle points there instead of at `docs/`.
15
+
16
+ ## Operating principles
17
+
18
+ - **Socratic, one question at a time.** Ask focused questions; use `AskUserQuestion` for tight
19
+ multiple-choice decisions. Never assume a domain fact — extract it. Prefer "who/why/what-if/
20
+ what-must-always-be-true/how-do-you-know" over yes-no.
21
+ - **Don't guess — park it.** Unresolved items go into the Open Questions list in
22
+ `.event-modeling.md`, not into invented model content. Note the source, blocker, and revisit
23
+ date when known — cheap now, useful when you come back to it.
24
+ - **Happy path first; branches belong to slicing.** Steps 1-7 build the **happy-path spine**.
25
+ Alternate, unhappy, and exception-path events (rejections, removals, cancellations,
26
+ expirations, declines) are **not** enumerated as a separate discover/model task — they
27
+ surface during the `slice` phase as each slice's alternate/error flows and rule-boundary
28
+ scenarios, and any new branch events get added to the `.em` then. Never list "draft the
29
+ branch events" as a discover/model to-do or ask the user to do it before slicing.
30
+ - **Reflect and re-render.** After each meaningful increment, update the `.em` file, re-render,
31
+ and show the user what changed. Encourage running the live view (`watch`) so a team can follow.
32
+ - **Keep the `.em` structural; put depth in `note` docs.** The diagram holds flow; invariants,
33
+ fields, and scenarios live in `slices/*.md` linked via `note "slices/<name>.md"`.
34
+ - **Headless/API models still use `ui`.** If the system is headless (clients call an API, not
35
+ screens), declare a persona per external caller/role (e.g. `IntegratorAPI`) and treat its `ui`
36
+ boxes as API calls, not screens: writes are `ui → command → event` and reads are
37
+ `read model → ui`, exactly like any other State Change/State View slice — no separate trigger
38
+ slice. `translation` stays reserved for genuine reactions and real external-system boundaries,
39
+ not a synchronous request/response call. Internal-only commands/views with no public route carry
40
+ no `ui` at all — they follow the ordinary Automation pattern instead. **Repeat read models**
41
+ across slices so the timeline flows left-to-right — put each repeat **right after the event that feeds it**, sourcing
42
+ only that one adjacent event, so every arrow is short (a read model far from its source events
43
+ draws a long arrow whose head lands columns away, making the *write* slice read as dangling —
44
+ keep a sub-flow that detours into another context together, not parked at the end of the model).
45
+ Declare every instance after the first with
46
+ **`view X again from "..."`** — `again` instances are exempt from the duplicate-name warning even
47
+ when referenced, and each reference resolves to the right instance. A reaction's command is
48
+ wired by same-slice presence, exactly like `ui → command` — no positional/adjacency rule to get
49
+ right (see `em-dsl.md`).
50
+ See `methodology.md` (State View) and `em-dsl.md`.
51
+ - **Never connect two instances of one read model.** The repeat is a timeline device, not a flow:
52
+ continuity is implied by the shared name, and the events arriving at each instance are what show
53
+ it changing. An arrow between instances says the read model feeds itself, and is an error.
54
+ - **Every slice is a COMPLETE pattern, never a half-slice.** A State Change is
55
+ `ui → command → event`; a State View is `event → read model → ui` (or `→ reaction`). So: a
56
+ command needs something that **triggers** it (the `ui` it's issued from, or the reaction that
57
+ triggers it, also in this slice), its event needs a **reader**, and that read model needs a
58
+ **consumer** of its own. A command nothing points at is a write nobody can start; a reaction
59
+ that triggers no command is a decision the system never acts on; an event nothing projects is
60
+ a write nobody can see; a read model nothing displays is information dropped on the floor.
61
+ Write the whole chain together rather than sweeping up dangling ends later. Reactions don't
62
+ count as readers of *events* — they read views. **Every instance** of a repeated read model
63
+ needs its own consumer: if you repeat a view next to an event just to keep the arrow short,
64
+ bring its screen along, or don't add the instance.
65
+ - **Only six connections are legal:** `ui → command`, `command → event`, `event → read model`,
66
+ `read model → ui`, `read model → reaction`, `reaction → command`. Reaching for anything else —
67
+ above all `command → read model` (the CQRS violation) or `read model → command` — means the model
68
+ is missing an **element**, not an arrow.
69
+ - **Validate continuously.** Run `em validate` and fix errors/warnings as you go (see DSL ref).
70
+ - **Save state at the end of every session** so work resumes cleanly. Also log a Usage log
71
+ line: `em state log-usage <model>.em --phases <phase1,phase2,...>` computes and dedupes the
72
+ diagnostic *categories* that fired for you and appends the canonically-formatted line — never
73
+ hand-run `em validate --json` and format the line yourself. This is the team's only usage
74
+ signal today (`docs/usage-data.md`) — keep it cheap and habitual, not a task to skip.
75
+
76
+ ## Preconditions (run first)
77
+
78
+ 1. Check the tool: `em --version`. If missing, tell the user to run `npm i -g @milehimikey/em`
79
+ and stop until installed.
80
+ 2. Locate the model. Look for an existing `<dir>/.event-modeling.md` and `*.em` in the working
81
+ directory, or — for a multi-model project laid out per the convention below — one level down
82
+ inside a `models/` subfolder (each model gets its own `models/<slug>/` directory; check each
83
+ candidate for its own `.event-modeling.md`/`*.em` pair). If found, run `em state read <dir>`
84
+ to read the state file's mechanical fields (model path, phase, step, last updated, last
85
+ conformance, last review) as JSON — don't parse the bullets by hand. If not, and the phase
86
+ needs one, ask the user for the model name and where to create it (a lone model goes at the
87
+ project root; one of several goes under `models/`, per "Multi-model projects" below).
88
+ 3. If you're not sure which phase applies, or the user gave no phase, use `em state read <dir>`'s
89
+ `phase`/`step` to resume the recorded phase/step — or invoke the `event-modeling` skill, which
90
+ does exactly this and routes to the right skill. If no model exists, propose starting
91
+ `discover` (greenfield, `event-modeling-discover`) or `extract` (modeling an existing system,
92
+ also `event-modeling-discover`).
93
+ 4. Populate the state file's Participants section at session start. For a live workshop, ask for
94
+ a single human proxy to relay questions to the room, and attribute every answer/decision in
95
+ the Decisions log to a named participant.
96
+
97
+ ## Project layout these skills create
98
+
99
+ ```
100
+ <model-name>/
101
+ <model-name>.em # the model (slice docs linked via note "...")
102
+ <model-name>.svg # render target for em watch
103
+ README.md # overview + slice index (from templates/model-readme.md)
104
+ .event-modeling.md # resumable state (from templates/state.md)
105
+ slices/<slice-name>.md # one rich slice doc per slice (from templates/slice.md)
106
+ conformance/<date>-report.md
107
+ # conform-phase reports (from templates/conformance-report.md)
108
+ <model-name>-asis.em # conform-phase scratch model, regenerated per run — git-ignore this
109
+ ```
110
+
111
+ When creating a new model, run `em scaffold <model-name>` — it creates `<model-name>/` and
112
+ writes all three starter files in one step (`<model-name>.em`, `README.md`,
113
+ `.event-modeling.md`), filling the Model Name/model-name placeholders and the state file's
114
+ mechanical fields (model path, `Current phase: discover`, `Current step: 1`, dates) for you, so
115
+ there's nothing left to hand-copy or fill in. Refuses if `<model-name>/` already exists; pass
116
+ `--force` to overwrite. You'll
117
+ usually replace the scaffolded `.em`'s content as the discovery conversation builds up the real
118
+ model — it starts out as the same starter model `em init` writes, titled from `<model-name>`.
119
+ `slices/*.md` and `conformance/` aren't part of `em scaffold`; they come from the `slice` and
120
+ `conform` phases (`event-modeling-design` and `event-modeling-conform`). The `conformance/`
121
+ directory and `<model-name>-asis.em` only appear once the `conform` phase runs; `em conform-scope
122
+ --seed-asis` creates `<model-name>-asis.em` and gitignores `*-asis.em` for you (see
123
+ `event-modeling-conform`'s `reference/conform.md`) — it's scratch, never committed.
124
+
125
+ ### Multi-model projects
126
+
127
+ Slice docs resolve at a fixed path — `slices/<slug>.md`, sibling of the `.em` file that
128
+ declares the slice — with no model namespace anywhere, so **one directory per model** is the
129
+ whole guardrail against two models' slice names colliding. For more than one model, nest each
130
+ one's directory (the exact layout above) under a shared `models/` parent instead of scattering
131
+ them at the project root:
132
+
133
+ ```
134
+ models/
135
+ checkout/
136
+ checkout.em
137
+ slices/...
138
+ fulfillment/
139
+ fulfillment.em
140
+ slices/...
141
+ ```
142
+
143
+ Run `em scaffold <model-name> --under models` for each model — it creates `models/<slug>/`
144
+ directly rather than a two-step `cd models && em scaffold <model-name>`. See
145
+ [docs/cli.md, "Multi-model projects"](https://github.com/milehimikey/em/blob/main/docs/cli.md#multi-model-projects)
146
+ for the full rationale, and why slice keys stay unqualified (no `<model>/<slice>` prefix) —
147
+ directory isolation alone is sufficient. Two `.em` files sharing a directory with colliding
148
+ slice keys don't go undetected: `em status`/`em catalog`, the two commands that ever compile
149
+ more than one model in a run, raise a `cross-model-slice-doc-collision` warning naming both
150
+ files — treat that warning as a sign the models need separating, not a false positive.