@milehimikey/em 1.12.0 → 1.13.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 (112) hide show
  1. package/.claude/skills/event-modeling/SKILL.md +5 -2
  2. package/.claude/skills/event-modeling-conform/SKILL.md +20 -9
  3. package/.claude/skills/event-modeling-conform/reference/conform.md +107 -10
  4. package/.claude/skills/event-modeling-design/SKILL.md +26 -4
  5. package/.claude/skills/event-modeling-discover/SKILL.md +1 -1
  6. package/.claude/skills/event-modeling-implement/SKILL.md +7 -4
  7. package/.claude/skills/event-modeling-implement/reference/implement.md +26 -8
  8. package/.claude/skills/event-modeling-review/SKILL.md +5 -1
  9. package/.claude/skills/event-modeling-shared/reference/em-dsl.md +45 -6
  10. package/.claude/skills/event-modeling-shared/reference/operating-principles.md +13 -3
  11. package/.claude/skills/event-modeling-shared/reference/slice-doc-schema.md +39 -0
  12. package/.claude/skills/event-modeling-shared/templates/conformance-report.md +8 -1
  13. package/.claude/skills/event-modeling-shared/templates/state.md +3 -0
  14. package/README.md +1 -0
  15. package/dist/catalog/docJoin.d.ts +9 -0
  16. package/dist/catalog/docJoin.js +6 -0
  17. package/dist/catalog/docJoin.js.map +1 -1
  18. package/dist/catalog/driftSignal.d.ts +11 -5
  19. package/dist/catalog/driftSignal.js +18 -4
  20. package/dist/catalog/driftSignal.js.map +1 -1
  21. package/dist/catalog/modelVersionValidate.d.ts +9 -0
  22. package/dist/catalog/modelVersionValidate.js +38 -0
  23. package/dist/catalog/modelVersionValidate.js.map +1 -0
  24. package/dist/catalog/sliceDoc.d.ts +12 -0
  25. package/dist/catalog/sliceDoc.js +15 -0
  26. package/dist/catalog/sliceDoc.js.map +1 -1
  27. package/dist/cli/ciInit.d.ts +24 -0
  28. package/dist/cli/ciInit.js +85 -15
  29. package/dist/cli/ciInit.js.map +1 -1
  30. package/dist/cli/conformScope.d.ts +1 -0
  31. package/dist/cli/conformScope.js +3 -1
  32. package/dist/cli/conformScope.js.map +1 -1
  33. package/dist/cli/conformSupersede.d.ts +24 -2
  34. package/dist/cli/conformSupersede.js +44 -3
  35. package/dist/cli/conformSupersede.js.map +1 -1
  36. package/dist/cli/coverage.d.ts +16 -2
  37. package/dist/cli/coverage.js +26 -4
  38. package/dist/cli/coverage.js.map +1 -1
  39. package/dist/cli/findings.d.ts +134 -0
  40. package/dist/cli/findings.js +355 -0
  41. package/dist/cli/findings.js.map +1 -0
  42. package/dist/cli/metrics.d.ts +93 -0
  43. package/dist/cli/metrics.js +331 -0
  44. package/dist/cli/metrics.js.map +1 -0
  45. package/dist/cli/modelVersion.d.ts +139 -0
  46. package/dist/cli/modelVersion.js +256 -0
  47. package/dist/cli/modelVersion.js.map +1 -0
  48. package/dist/cli/reratify.d.ts +24 -1
  49. package/dist/cli/reratify.js +73 -17
  50. package/dist/cli/reratify.js.map +1 -1
  51. package/dist/cli/skillCheck.js +2 -2
  52. package/dist/cli/skillCheck.js.map +1 -1
  53. package/dist/cli/sliceConform.d.ts +50 -0
  54. package/dist/cli/sliceConform.js +206 -0
  55. package/dist/cli/sliceConform.js.map +1 -0
  56. package/dist/cli/sliceIndex.d.ts +2 -0
  57. package/dist/cli/sliceIndex.js +15 -3
  58. package/dist/cli/sliceIndex.js.map +1 -1
  59. package/dist/cli/sliceNew.d.ts +12 -0
  60. package/dist/cli/sliceNew.js +23 -0
  61. package/dist/cli/sliceNew.js.map +1 -1
  62. package/dist/cli/sliceStubAll.d.ts +76 -0
  63. package/dist/cli/sliceStubAll.js +189 -0
  64. package/dist/cli/sliceStubAll.js.map +1 -0
  65. package/dist/cli/stateFile.d.ts +63 -7
  66. package/dist/cli/stateFile.js +179 -18
  67. package/dist/cli/stateFile.js.map +1 -1
  68. package/dist/cli/status.d.ts +79 -1
  69. package/dist/cli/status.js +134 -15
  70. package/dist/cli/status.js.map +1 -1
  71. package/dist/cli/upgrade.d.ts +132 -0
  72. package/dist/cli/upgrade.js +524 -0
  73. package/dist/cli/upgrade.js.map +1 -0
  74. package/dist/cli.js +609 -50
  75. package/dist/cli.js.map +1 -1
  76. package/dist/emit/coverageJson.d.ts +5 -2
  77. package/dist/emit/coverageJson.js +6 -2
  78. package/dist/emit/coverageJson.js.map +1 -1
  79. package/dist/emit/freshnessJson.d.ts +1 -1
  80. package/dist/emit/freshnessJson.js +3 -1
  81. package/dist/emit/freshnessJson.js.map +1 -1
  82. package/dist/emit/json.d.ts +11 -1
  83. package/dist/emit/json.js +35 -1
  84. package/dist/emit/json.js.map +1 -1
  85. package/dist/emit/metricsJson.d.ts +7 -0
  86. package/dist/emit/metricsJson.js +27 -0
  87. package/dist/emit/metricsJson.js.map +1 -0
  88. package/dist/emit/statusJson.d.ts +1 -1
  89. package/dist/emit/statusJson.js +17 -1
  90. package/dist/emit/statusJson.js.map +1 -1
  91. package/dist/emit/upgradeJson.d.ts +5 -0
  92. package/dist/emit/upgradeJson.js +29 -0
  93. package/dist/emit/upgradeJson.js.map +1 -0
  94. package/dist/emit/validateJson.d.ts +6 -2
  95. package/dist/emit/validateJson.js +12 -5
  96. package/dist/emit/validateJson.js.map +1 -1
  97. package/dist/mcp/server.d.ts +1 -1
  98. package/dist/mcp/server.js +137 -9
  99. package/dist/mcp/server.js.map +1 -1
  100. package/dist/model/rules.d.ts +7 -0
  101. package/dist/model/rules.js +12 -0
  102. package/dist/model/rules.js.map +1 -1
  103. package/dist/model/validate.d.ts +20 -0
  104. package/dist/model/validate.js +94 -45
  105. package/dist/model/validate.js.map +1 -1
  106. package/dist/templates.d.ts +2 -2
  107. package/dist/templates.js +7 -1
  108. package/dist/templates.js.map +1 -1
  109. package/dist/util/semver.d.ts +19 -0
  110. package/dist/util/semver.js +54 -0
  111. package/dist/util/semver.js.map +1 -0
  112. package/package.json +2 -2
@@ -2,7 +2,7 @@ export declare const STARTER_EM = "model \"Order Fulfillment\"\n\npersona Custom
2
2
  /** Raw copy of templates/model-readme.md, \`{{...}}\` placeholders intact — see scaffoldReadme(). */
3
3
  export declare const MODEL_README_TEMPLATE = "# {{Model Name}}\n\n{{One-paragraph description of the business process(es) this event model covers.}}\n\n## Live view\nWhile modeling, run the live view so the team can watch the diagram update:\n\n```bash\nem watch {{model-name}}.em -o {{model-name}}.svg --serve # re-render + instant push-reload\n# then open the URL it prints (http://localhost:5173/?svg={{model-name}}.svg) and share the screen\n```\n\nPan/zoom to navigate the diagram (drag, scroll; **Fit** resets), and click **Review mode** in\nthe header for a slice-by-slice walkthrough. If a save fails to render, the viewer keeps the\nlast good diagram and shows an error banner until the next successful load.\n\nStatic render: `em render {{model-name}}.em -o {{model-name}}.svg`\n\n## Patterns legend\n- **State Change** \u2014 UI \u2192 Command \u2192 Event\n- **State View** \u2014 Event(s) \u2192 Read Model \u2192 UI\n- **Automation** \u2014 Read Model (slice before) \u2192 Processor + Command \u2192 Event, together\n- **Translation** \u2014 External input (or Read Model, slice before) \u2192 Translation + Command \u2192 Event, together\n\nBetween them these are the only legal connections: `ui \u2192 command`, `command \u2192 event`,\n`event \u2192 read model`, `read model \u2192 ui`, `read model \u2192 reaction`, `reaction \u2192 command`. A command\nnever reaches a read model directly \u2014 the event goes between them. Every slice is joined up at\nboth ends: something triggers each command (the screen it's issued from, or the reaction that\ntriggers it, also in this slice), and every event a command records is read by some read model \u2014 so each State\nChange slice is paired with the State View slice that projects its event. A read model repeated\nalong the timeline (`view X again`) shows the same projection at a later point; the instances are\nnever connected to one another.\n\n## Slices\n<!-- The canonical slice index \u2014 the ONE place slices are enumerated (the state file\n points here rather than keeping its own copy). Generated \u2014 run\n `em slice index {{model-name}}.em` to (re)write the table below from the model and its\n slice docs; never hand-edit between the markers. -->\n<!-- GENERATED:slices:start -->\n| # | Slice | Pattern | Status | Reviewed by | Ratified by | Owner | Tracking | Implemented in | Design doc |\n|---|-------|---------|--------|-------------|-------------|-------|----------|----------------|------------|\n<!-- GENERATED:slices:end -->\n\n## Status\nSee [`.event-modeling.md`](.event-modeling.md) for current phase, decisions, and open questions.\n";
4
4
  /** Raw copy of templates/state.md, \`{{...}}\` placeholders intact — see scaffoldStateFile(). */
5
- export declare const STATE_TEMPLATE = "<!--\nResumable progress state for an event model. Stored as <model>/.event-modeling.md\nThe skill reads this on `/event-modeling` (no arg) to resume where you left off.\nKeep it current at the end of every working session.\n-->\n\n# Event Modeling Progress \u2014 {{Model Name}}\n\n- **Model file:** `{{model-name}}.em`\n- **Current phase:** {{discover | extract | model | slice | implement | conform | review | validate}}\n- **Current step:** {{1\u20137, see methodology; or extraction round R1\u2013R7}}\n- **Last updated:** {{YYYY-MM-DD}}\n- **Last conformance:** {{YYYY-MM-DD @ <target-repo revision> \u2014 report: conformance/<date>-report.md | never}}\n- **Last stakeholder review:** {{YYYY-MM-DD \u2014 attendees: see Participants | never}}\n\n## Session inputs\n- **Scope line:** {{one-line description of what's in/out of bounds for this model}}\n- **PRD / spec reference:** {{path, link, or \"none\"}}\n- **Headless/API model:** {{yes | no}}\n- **Source mode:** {{greenfield | extract-event-driven | extract-procedural}}\n- **Existing system refs:** {{repo paths, event-schema/topic locations, docs \u2014 or \"n/a\"}}\n\n## Participants\n<!-- Populate at session start. Live workshop: one human proxy relays questions to the room;\n attribute every answer/decision in the Decisions log to a named participant here. -->\n- {{Name}} \u2014 {{role}} \u2014 {{domain area}}\n\n## Extraction progress (existing-system models only \u2014 delete for greenfield)\n- [ ] R1. Candidate events (extracted/synthesized, filtered, confirmed)\n- [ ] R2. Timeline order (as-is narrative, actors/callers, first render)\n- [ ] R3. Commands / inputs\n- [ ] R4. Read models / outputs (validate from here)\n- [ ] R5. Boundaries & reactions (reaction shares its slice with the command it triggers)\n- [ ] R6. Gap & TBD reconciliation\n- [ ] R7. Convergence (render + validate clean, user confirmed as-is)\n\n## Steps completed\n- [ ] 1. Brainstorm events\n- [ ] 2. Plot / storyboard (personas + UI)\n- [ ] 3. Inputs (commands)\n- [ ] 4. Outputs (read models)\n- [ ] 5. Swimlanes & apply patterns\n- [ ] 6. Elaborate scenarios\n- [ ] 7. Evaluate completeness (`em validate` clean)\n\n## Decisions log\n<!-- Resolved choices, with the reasoning, so they aren't re-litigated. In a live workshop,\n attribute each entry to the participant who made the call (see Participants above). -->\n- {{YYYY-MM-DD}}: {{decision}} \u2014 {{why}} \u2014 by {{participant, if a live workshop}}\n\n## Usage log\n<!-- The team's only usage signal today (see docs/usage-data.md) \u2014 cheap and coarse on purpose.\n One line per session: phase(s) touched, and validate diagnostic *categories* hit (one of\n the exact fixed strings in docs/usage-data.md#categories, e.g. \"read model has no\n consumer\" \u2014 never the full instance message or any domain content). Append, never edit\n past entries. -->\n- {{YYYY-MM-DD}}: phases: {{discover | extract | model | slice | implement | conform | review | validate | watch, ...}} \u2014 validate: {{diagnostic category (docs/usage-data.md#categories), ... | none}}\n\n## Open questions / parking lot\n<!-- Unresolved items to bring back to the user. Never guess these. Metadata is optional and\n flat \u2014 add only what's known: source (ticket/conversation that spawned it), blocked on\n (who/what), revisit (when). -->\n- [ ] {{question}} \u2014 source: {{ticket/conversation link, optional}} \u2014 blocked on: {{who/what, optional}} \u2014 revisit: {{when, optional}}\n\n## Slice inventory\n<!-- Deliberately NOT a table: the canonical slice index (slice, pattern, status, doc link)\n lives in README.md's \"Slices\" section \u2014 one source of truth, updated there. This file\n only tracks resumable session state. -->\nSee `README.md` \u2192 **Slices** for the slice index and per-slice doc status.\n";
5
+ export declare const STATE_TEMPLATE = "<!--\nResumable progress state for an event model. Stored as <model>/.event-modeling.md\nThe skill reads this on `/event-modeling` (no arg) to resume where you left off.\nKeep it current at the end of every working session.\n-->\n\n# Event Modeling Progress \u2014 {{Model Name}}\n\n- **Model file:** `{{model-name}}.em`\n- **Em version:** {{X.Y.Z}}\n- **Current phase:** {{discover | extract | model | slice | implement | conform | review | validate}}\n- **Current step:** {{1\u20137, see methodology; or extraction round R1\u2013R7}}\n- **Last updated:** {{YYYY-MM-DD}}\n- **Last conformance:** {{YYYY-MM-DD @ <target-repo revision> \u2014 report: conformance/<date>-report.md | never}}\n- **Model version:** {{N | none}}\n- **Certified:** {{v<N> @ <target-repo revision> (YYYY-MM-DD) | never}}\n- **Last stakeholder review:** {{YYYY-MM-DD \u2014 attendees: see Participants | never}}\n\n## Session inputs\n- **Scope line:** {{one-line description of what's in/out of bounds for this model}}\n- **PRD / spec reference:** {{path, link, or \"none\"}}\n- **Headless/API model:** {{yes | no}}\n- **Source mode:** {{greenfield | extract-event-driven | extract-procedural}}\n- **Existing system refs:** {{repo paths, event-schema/topic locations, docs \u2014 or \"n/a\"}}\n\n## Participants\n<!-- Populate at session start. Live workshop: one human proxy relays questions to the room;\n attribute every answer/decision in the Decisions log to a named participant here. -->\n- {{Name}} \u2014 {{role}} \u2014 {{domain area}}\n\n## Extraction progress (existing-system models only \u2014 delete for greenfield)\n- [ ] R1. Candidate events (extracted/synthesized, filtered, confirmed)\n- [ ] R2. Timeline order (as-is narrative, actors/callers, first render)\n- [ ] R3. Commands / inputs\n- [ ] R4. Read models / outputs (validate from here)\n- [ ] R5. Boundaries & reactions (reaction shares its slice with the command it triggers)\n- [ ] R6. Gap & TBD reconciliation\n- [ ] R7. Convergence (render + validate clean, user confirmed as-is)\n\n## Steps completed\n- [ ] 1. Brainstorm events\n- [ ] 2. Plot / storyboard (personas + UI)\n- [ ] 3. Inputs (commands)\n- [ ] 4. Outputs (read models)\n- [ ] 5. Swimlanes & apply patterns\n- [ ] 6. Elaborate scenarios\n- [ ] 7. Evaluate completeness (`em validate` clean)\n\n## Decisions log\n<!-- Resolved choices, with the reasoning, so they aren't re-litigated. In a live workshop,\n attribute each entry to the participant who made the call (see Participants above). -->\n- {{YYYY-MM-DD}}: {{decision}} \u2014 {{why}} \u2014 by {{participant, if a live workshop}}\n\n## Usage log\n<!-- The team's only usage signal today (see docs/usage-data.md) \u2014 cheap and coarse on purpose.\n One line per session: phase(s) touched, and validate diagnostic *categories* hit (one of\n the exact fixed strings in docs/usage-data.md#categories, e.g. \"read model has no\n consumer\" \u2014 never the full instance message or any domain content). Append, never edit\n past entries. -->\n- {{YYYY-MM-DD}}: phases: {{discover | extract | model | slice | implement | conform | review | validate | watch, ...}} \u2014 validate: {{diagnostic category (docs/usage-data.md#categories), ... | none}}\n\n## Open questions / parking lot\n<!-- Unresolved items to bring back to the user. Never guess these. Metadata is optional and\n flat \u2014 add only what's known: source (ticket/conversation that spawned it), blocked on\n (who/what), revisit (when). -->\n- [ ] {{question}} \u2014 source: {{ticket/conversation link, optional}} \u2014 blocked on: {{who/what, optional}} \u2014 revisit: {{when, optional}}\n\n## Slice inventory\n<!-- Deliberately NOT a table: the canonical slice index (slice, pattern, status, doc link)\n lives in README.md's \"Slices\" section \u2014 one source of truth, updated there. This file\n only tracks resumable session state. -->\nSee `README.md` \u2192 **Slices** for the slice index and per-slice doc status.\n";
6
6
  /** Raw copy of templates/constitution.md, \`{{...}}\` placeholders intact — see
7
7
  * scaffoldConstitution(). */
8
8
  export declare const CONSTITUTION_TEMPLATE = "<!--\nThe implementation constitution: the house rules an implementing agent follows on EVERY slice \u2014\nstack, code style, testing norms, NFR baselines, review norms. It answers \"how do we build things\nhere\" once, so no slice doc has to repeat it and no agent has to invent it. Slice docs say WHAT to\nbuild; this says HOW it gets built here.\n\nWhere this document lives:\n - No SDD tool: `constitution.md` beside the model \u2014 `em scaffold` writes it there.\n - spec-kit project (a `.specify/` directory exists anywhere above the model): the document IS\n `.specify/memory/constitution.md`. em writes no second copy; the sections below merge into\n that file under these same headings, never overwriting text already there, and ratification is\n recorded in spec-kit's own `**Ratified**:` footer line instead of the frontmatter below.\n\nHow it gets filled: not by an agent guessing. Each section opens with the question a short\nfacilitated conversation asks before the first slice is implemented \u2014 the procedure is \"Before the\nfirst slice: the constitution\" in the `event-modeling-implement` skill's `reference/implement.md`\n(`em contract` prints it). Replace each `{{...}}` block with the real answers; delete the guidance\ncomments and any row that doesn't apply.\n\nRatification: `ratifiedBy:`/`ratifiedOn:` are the same identity discipline slice docs use \u2014 a\nNAMED human and an ISO date, hand-filled at sign-off (no `em` command writes this file).\n**A constitution with an empty `ratifiedBy:` is a draft**: an implementing agent treats it as\nunratified, says so, and does not proceed on unilateral style or stack decisions for a first slice.\n\n`em status` reports this document as present or absent per model \u2014 existence only. em never reads\nor validates its content, and nothing here is machine-parsed.\n-->\n\n---\nschemaVersion: 1\nratifiedBy:\nratifiedOn:\n---\n# {{Project Name}} \u2014 implementation constitution\n\nThe house rules for how implementation happens in this project. They bound every \"purely\ntechnical choice\" an implementing agent would otherwise make alone.\n\n## Stack and architectural shape\n\n> **What do we build on, what shape does the code take, and which implementation skill or\n> approach does each slice pattern route to?**\n\n- **Languages / runtimes:** {{e.g. Kotlin 2.x on JVM 21; TypeScript 5 on Node 24}}\n- **Frameworks / platform:** {{web framework, persistence, messaging, build tool}}\n- **Architectural pattern:** {{e.g. event-sourced CQRS with vertical slices; layered service over\n a relational store; functional core / imperative shell}}\n- **Where a slice's code lives:** {{one package per slice, per context, ...}}\n- **Interface conventions:** {{resource style \u2014 REST/RPC/GraphQL, etc.; error/rejection mapping;\n versioning; auth at the edge \u2014 the shape every `ui`-triggered command or `ui`-consumed view's\n endpoint follows, decided once here rather than invented per slice}}\n\nRouting \u2014 which implementation skill or approach each of the four slice patterns uses:\n\n| Pattern | Skill / approach |\n|---|---|\n| State Change | {{e.g. the `axon-*` skill set \u2014 axon-entity-patterns, then axon-entity-testing}} |\n| State View | {{e.g. the `axon-*` skill set \u2014 axon-projection-patterns, then axon-projection-testing}} |\n| Automation | {{e.g. the `axon-*` skill set \u2014 axon-policy-patterns, then axon-policy-testing}} |\n| Translation | {{e.g. the `axon-*` skill set \u2014 axon-translation-patterns}} |\n\nAn agent implementing a slice reads the doc's `pattern:` frontmatter and follows that row \u2014 this\ntable is the only routing rule.\n\n## Code style\n\n> **What does \"idiomatic\" mean in this codebase \u2014 formatting, naming, module layout?**\n\n- **Formatter / linter:** {{the tool and the command that runs it \u2014 never hand-format against it}}\n- **Naming:** {{commands, events, handlers, files, test names}}\n- **Module layout:** {{what lives in which file/package, and what may not import what}}\n- **Idiomatic here means:** {{the two or three habits a new contributor most often gets wrong}}\n\n## Testing norms\n\n> **What must be tested for each slice pattern, where do those tests live, and how are they named\n> so `em coverage` can trace invariant IDs?**\n\n- **Levels required per pattern:** {{e.g. State Change \u2014 decider unit tests plus a\n given/when/then fixture test; State View \u2014 projection tests; Automation / Translation \u2014\n reaction tests, including a negative case}}\n- **Invariant tests:** {{where they live}} \u2014 every `INV-<MNEMONIC>-n` in a slice doc needs at least\n one test **citing that exact ID** in its name or a comment, so\n `em coverage <model>.em --tests <dir>` can trace it.\n- **Scenario tests:** {{where they live}} \u2014 one per `## Scenarios (Given / When / Then)` entry,\n with rejection scenarios asserting the doc's named rejection reason.\n- **Test naming convention:** {{the exact pattern, e.g. `INV-ORD-3: rejects a second submit`}}\n- **What \"green\" means:** {{the command CI runs}}\n\n## NFR baselines\n\n> **What standing non-functional defaults does every slice inherit \u2014 authz, PII, performance,\n> observability?**\n\n- **Authorization model:** {{who may issue which commands, how it's enforced, and where}}\n- **PII / data handling:** {{what is sensitive, what may be logged, retention}}\n- **Performance defaults:** {{latency / throughput budgets that apply unless a slice says otherwise}}\n- **Observability:** {{logging, metrics, tracing every slice is expected to emit}}\n\nA slice doc's own `## Non-Functional Requirements` section overrides these for that slice; where\nit is silent, these apply.\n\n## Review and merge norms\n\n> **Who reviews an implementation PR, what blocks a merge, and how does the slice doc's status\n> flip fit in?**\n\n- **Reviewers:** {{who \u2014 a team, a CODEOWNERS rule, the slice's ratifier}}\n- **What blocks a merge:** {{e.g. a failing suite, an uncovered invariant, a gap that belongs back\n at the model}}\n- **Branch / commit conventions:** {{...}} \u2014 name only branch naming and commit-message style\n here. **One slice doc = one PR is the implement contract's rule, not this document's to\n amend** \u2014 a `covers:` doc ships as one PR for both keys; a read model is one doc, so a later\n `again` instance is a continuation of the doc that first declared it, not a PR of its own. See\n the agent guide's \u00A75/\u00A710.\n- **At merge:** run `em slice mark-implemented <model>.em <slice-key> <pr-url>` \u2014 the one edit an\n implementing agent makes to a ratified slice doc, run by {{the PR author | CI}}. Never bump\n `version:`; that moves only when a delta is ratified.\n";
@@ -20,7 +20,7 @@ export declare function scaffoldReadme(displayName: string, slugName: string): s
20
20
  * Usage log, Open questions) is dropped rather than filled, leaving a real empty heading with
21
21
  * the template's own guidance comment intact where it has one — per the skill's "don't guess,
22
22
  * park it" principle, never a fabricated example. Never leaves \`{{...}}\` in the result. */
23
- export declare function scaffoldStateFile(displayName: string, slugName: string, today: string): string;
23
+ export declare function scaffoldStateFile(displayName: string, slugName: string, today: string, emVersion: string): string;
24
24
  /** Fill CONSTITUTION_TEMPLATE's project-name placeholder for `em scaffold` (MIL-202).
25
25
  *
26
26
  * Unlike `scaffoldReadme`/`scaffoldStateFile`, this one **deliberately leaves every other
package/dist/templates.js CHANGED
@@ -116,10 +116,13 @@ Keep it current at the end of every working session.
116
116
  # Event Modeling Progress — {{Model Name}}
117
117
 
118
118
  - **Model file:** \`{{model-name}}.em\`
119
+ - **Em version:** {{X.Y.Z}}
119
120
  - **Current phase:** {{discover | extract | model | slice | implement | conform | review | validate}}
120
121
  - **Current step:** {{1–7, see methodology; or extraction round R1–R7}}
121
122
  - **Last updated:** {{YYYY-MM-DD}}
122
123
  - **Last conformance:** {{YYYY-MM-DD @ <target-repo revision> — report: conformance/<date>-report.md | never}}
124
+ - **Model version:** {{N | none}}
125
+ - **Certified:** {{v<N> @ <target-repo revision> (YYYY-MM-DD) | never}}
123
126
  - **Last stakeholder review:** {{YYYY-MM-DD — attendees: see Participants | never}}
124
127
 
125
128
  ## Session inputs
@@ -323,17 +326,20 @@ export function scaffoldReadme(displayName, slugName) {
323
326
  * Usage log, Open questions) is dropped rather than filled, leaving a real empty heading with
324
327
  * the template's own guidance comment intact where it has one — per the skill's "don't guess,
325
328
  * park it" principle, never a fabricated example. Never leaves \`{{...}}\` in the result. */
326
- export function scaffoldStateFile(displayName, slugName, today) {
329
+ export function scaffoldStateFile(displayName, slugName, today, emVersion) {
327
330
  // Replacer functions for the display-name/slug fills, not string patterns — a string
328
331
  // replacement would let `$&`/`$$`/etc. in the value expand against the match instead of
329
332
  // being inserted literally.
330
333
  const filled = STATE_TEMPLATE.replace("{{Model Name}}", () => displayName)
331
334
  .replace("{{model-name}}", () => slugName)
335
+ .replace("{{X.Y.Z}}", () => emVersion) // "Em version:" (MIL-219) — the installed em at scaffold time
332
336
  .replace("{{discover | extract | model | slice | implement | conform | review | validate}}", "discover")
333
337
  .replace("{{1\u20137, see methodology; or extraction round R1\u2013R7}}", "1")
334
338
  .replace("{{YYYY-MM-DD}}", today) // "Last updated" — the first occurrence; later ones belong to
335
339
  // judgment-section placeholder bullets and are dropped whole below.
336
340
  .replace("{{YYYY-MM-DD @ <target-repo revision> \u2014 report: conformance/<date>-report.md | never}}", "never")
341
+ .replace("{{N | none}}", "none") // "Model version:" (MIL-218) \u2014 never bumped yet
342
+ .replace("{{v<N> @ <target-repo revision> (YYYY-MM-DD) | never}}", "never") // "Certified:" (MIL-218)
337
343
  .replace("{{YYYY-MM-DD \u2014 attendees: see Participants | never}}", "never");
338
344
  return filled
339
345
  .split("\n")
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,mCAAmC;AAEnC,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDzB,CAAC;AAEF,wDAAwD;AACxD,EAAE;AACF,2FAA2F;AAC3F,0FAA0F;AAC1F,2FAA2F;AAC3F,2FAA2F;AAC3F,+FAA+F;AAC/F,2FAA2F;AAC3F,2CAA2C;AAE3C,qGAAqG;AACrG,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CpC,CAAC;AAEF,iGAAiG;AACjG,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AqD;SACrF,OAAO,CAAC,wDAAwD,EAAE,OAAO,CAAC,CAAC,yBAAyB;SACpG,OAAO,CAAC,2DAA2D,EAAE,OAAO,CAAC,CAAC;IAEjF,OAAO,MAAM;SACV,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACtC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;;;;;;4CAQ4C;AAC5C,MAAM,UAAU,oBAAoB,CAAC,WAAmB;IACtD,6FAA6F;IAC7F,0FAA0F;IAC1F,wCAAwC;IACxC,OAAO,qBAAqB,CAAC,OAAO,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,19 @@
1
+ export interface Semver {
2
+ major: number;
3
+ minor: number;
4
+ patch: number;
5
+ }
6
+ /** `null` for anything that doesn't start with `<major>.<minor>.<patch>` — including the
7
+ * `"unknown"` sentinel `Em version:` uses for a state file that predates the bullet. */
8
+ export declare function parseSemver(version: string): Semver | null;
9
+ /** -1/0/1, ordinary three-way compare on (major, minor, patch). */
10
+ export declare function compareSemver(a: Semver, b: Semver): number;
11
+ /** `true` when `recorded` parses and is strictly older than `installed` — `false` for an
12
+ * unparseable `recorded` (never a comparison error a caller has to handle; "can't prove it's
13
+ * behind" reads the same as "not behind" for a warn-only advisory). */
14
+ export declare function isOlder(recorded: string | null, installed: string): boolean;
15
+ /** `true` when `installed` is ahead of `recorded` by a minor version or more (a major bump also
16
+ * counts) — the threshold the skill-bundle STOP rule (MIL-219 ruling 3) uses: a patch-only gap
17
+ * is never worth stopping an agent over, a minor or major one is. `false` when either side
18
+ * fails to parse. */
19
+ export declare function isBehindByMinorOrMore(recorded: string | null, installed: string): boolean;
@@ -0,0 +1,54 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Minimal semver parsing/comparison — em has no runtime dependency on the `semver` package, and
3
+ // every comparison it needs (recorded vs. installed `Em version:`, the skill bundle's own
4
+ // `em-version:` stamp) is "is A older than B", never full range matching. Pre-release/build
5
+ // metadata (`-beta.1`, `+build`) is accepted but ignored for ordering — `em` has never shipped
6
+ // one, and treating an unparseable suffix as "equal to the release it's built on" is the safer
7
+ // default over throwing.
8
+ const SEMVER_RE = /^(\d+)\.(\d+)\.(\d+)/;
9
+ /** `null` for anything that doesn't start with `<major>.<minor>.<patch>` — including the
10
+ * `"unknown"` sentinel `Em version:` uses for a state file that predates the bullet. */
11
+ export function parseSemver(version) {
12
+ const m = SEMVER_RE.exec(version.trim());
13
+ if (!m)
14
+ return null;
15
+ return { major: Number(m[1]), minor: Number(m[2]), patch: Number(m[3]) };
16
+ }
17
+ /** -1/0/1, ordinary three-way compare on (major, minor, patch). */
18
+ export function compareSemver(a, b) {
19
+ if (a.major !== b.major)
20
+ return a.major < b.major ? -1 : 1;
21
+ if (a.minor !== b.minor)
22
+ return a.minor < b.minor ? -1 : 1;
23
+ if (a.patch !== b.patch)
24
+ return a.patch < b.patch ? -1 : 1;
25
+ return 0;
26
+ }
27
+ /** `true` when `recorded` parses and is strictly older than `installed` — `false` for an
28
+ * unparseable `recorded` (never a comparison error a caller has to handle; "can't prove it's
29
+ * behind" reads the same as "not behind" for a warn-only advisory). */
30
+ export function isOlder(recorded, installed) {
31
+ if (recorded === null)
32
+ return false;
33
+ const r = parseSemver(recorded);
34
+ const i = parseSemver(installed);
35
+ if (!r || !i)
36
+ return false;
37
+ return compareSemver(r, i) < 0;
38
+ }
39
+ /** `true` when `installed` is ahead of `recorded` by a minor version or more (a major bump also
40
+ * counts) — the threshold the skill-bundle STOP rule (MIL-219 ruling 3) uses: a patch-only gap
41
+ * is never worth stopping an agent over, a minor or major one is. `false` when either side
42
+ * fails to parse. */
43
+ export function isBehindByMinorOrMore(recorded, installed) {
44
+ if (recorded === null)
45
+ return false;
46
+ const r = parseSemver(recorded);
47
+ const i = parseSemver(installed);
48
+ if (!r || !i)
49
+ return false;
50
+ if (i.major !== r.major)
51
+ return i.major > r.major;
52
+ return i.minor > r.minor;
53
+ }
54
+ //# sourceMappingURL=semver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semver.js","sourceRoot":"","sources":["../../src/util/semver.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,gGAAgG;AAChG,0FAA0F;AAC1F,4FAA4F;AAC5F,+FAA+F;AAC/F,+FAA+F;AAC/F,yBAAyB;AAQzB,MAAM,SAAS,GAAG,sBAAsB,CAAC;AAEzC;yFACyF;AACzF,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,MAAM,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACzC,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3E,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,aAAa,CAAC,CAAS,EAAE,CAAS;IAChD,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;wEAEwE;AACxE,MAAM,UAAU,OAAO,CAAC,QAAuB,EAAE,SAAiB;IAChE,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACpC,MAAM,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,CAAC,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACjC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC;AAED;;;sBAGsB;AACtB,MAAM,UAAU,qBAAqB,CAAC,QAAuB,EAAE,SAAiB;IAC9E,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACpC,MAAM,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,CAAC,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACjC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IAClD,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;AAC3B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milehimikey/em",
3
- "version": "1.12.0",
3
+ "version": "1.13.1",
4
4
  "description": "AI-friendly Event Modeling — a slice-first text DSL rendered to a strict, self-contained Graphviz grid (SVG/PNG)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -81,6 +81,6 @@
81
81
  "jsdom": "^26.1.0",
82
82
  "tsx": "^4.19.0",
83
83
  "typescript": "^5.6.0",
84
- "vitest": "^4.1.10"
84
+ "vitest": "^5.0.3"
85
85
  }
86
86
  }