@milehimikey/em 1.1.0 → 1.1.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/.claude/skills/event-modeling/SKILL.md +23 -70
- package/.claude/skills/event-modeling/reference/em-dsl.md +0 -15
- package/.claude/skills/event-modeling/templates/model-readme.md +4 -4
- package/.claude/skills/event-modeling/templates/slice.md +2 -4
- package/.claude/skills/event-modeling/templates/state.md +3 -9
- package/README.md +4 -31
- package/dist/cli.js +4 -227
- package/dist/cli.js.map +1 -1
- package/dist/model/validate.d.ts +0 -2
- package/dist/model/validate.js +1 -1
- package/dist/model/validate.js.map +1 -1
- package/package.json +2 -3
- package/.claude/skills/event-modeling/reference/frontmatter.md +0 -129
- package/dist/config.d.ts +0 -15
- package/dist/config.js +0 -60
- package/dist/config.js.map +0 -1
- package/dist/migrate/migrate.d.ts +0 -26
- package/dist/migrate/migrate.js +0 -276
- package/dist/migrate/migrate.js.map +0 -1
- package/dist/model/deriveSliceFields.d.ts +0 -21
- package/dist/model/deriveSliceFields.js +0 -60
- package/dist/model/deriveSliceFields.js.map +0 -1
- package/dist/model/frontmatter.d.ts +0 -21
- package/dist/model/frontmatter.js +0 -38
- package/dist/model/frontmatter.js.map +0 -1
- package/dist/model/sliceDoc.d.ts +0 -56
- package/dist/model/sliceDoc.js +0 -28
- package/dist/model/sliceDoc.js.map +0 -1
- package/dist/model/validateSliceDocs.d.ts +0 -7
- package/dist/model/validateSliceDocs.js +0 -195
- package/dist/model/validateSliceDocs.js.map +0 -1
- package/dist/slice/generate.d.ts +0 -17
- package/dist/slice/generate.js +0 -61
- package/dist/slice/generate.js.map +0 -1
- package/dist/slice/query.d.ts +0 -42
- package/dist/slice/query.js +0 -96
- package/dist/slice/query.js.map +0 -1
- package/dist/slice/sync.d.ts +0 -18
- package/dist/slice/sync.js +0 -104
- package/dist/slice/sync.js.map +0 -1
- package/dist/util/findModel.d.ts +0 -1
- package/dist/util/findModel.js +0 -27
- package/dist/util/findModel.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/model/validate.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,+DAA+D;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAA4B,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/model/validate.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,+DAA+D;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAA4B,aAAa,EAAE,MAAM,YAAY,CAAC;AAUrE,MAAM,UAAU,QAAQ,CAAC,KAAsB,EAAE,IAAU;IACzD,MAAM,KAAK,GAAiB,EAAE,CAAC;IAE/B,2EAA2E;IAC3E,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC;YACT,QAAQ,EAAE,OAAO;YACjB,OAAO,EACL,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,oBAAoB,CAAC,CAAC,IAAI,CAAC,IAAI,gBAAgB;gBACjE,eAAe,CAAC,CAAC,MAAM,oCAAoC;YAC7D,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI;SACrB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QACjE,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;QACh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,MAAM,UAAU,SAAS,CAAC,KAAmB;IAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;AACnD,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,gBAAgB,CAAC,CAAa;IAC5C,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACzC,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IACvD,OAAO,KAAK,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milehimikey/em",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "AI-friendly Event Modeling \u2014 a slice-first text DSL rendered to a strict, self-contained Graphviz grid (SVG/PNG)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -51,8 +51,7 @@
|
|
|
51
51
|
"@hpcc-js/wasm-graphviz": "^1.22.0",
|
|
52
52
|
"@resvg/resvg-js": "^2.6.2",
|
|
53
53
|
"chokidar": "^3.6.0",
|
|
54
|
-
"commander": "^12.1.0"
|
|
55
|
-
"yaml": "^2.9.0"
|
|
54
|
+
"commander": "^12.1.0"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
57
|
"@types/node": "^22.0.0",
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
# Slice Frontmatter Reference
|
|
2
|
-
|
|
3
|
-
Every slice doc (`slices/<id>.md`) starts with a required YAML frontmatter block, injected by
|
|
4
|
-
`em slice new` and kept fresh by `em slice sync`. This is what makes slices searchable and
|
|
5
|
-
versionable by AI agents across a model with hundreds of slices, without reading every doc's body.
|
|
6
|
-
Full rationale: `docs/1.0.0-spec.md` in the `em` repo. This file is the quick reference for
|
|
7
|
-
day-to-day use.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Fields
|
|
12
|
-
|
|
13
|
-
**Core identity** (required, `em slice new` sets these):
|
|
14
|
-
|
|
15
|
-
| Field | Meaning |
|
|
16
|
-
|---|---|
|
|
17
|
-
| `schemaVersion` | Frontmatter format version. `1`. |
|
|
18
|
-
| `id` | Stable key, kebab-case, generated once. **Never** re-derived from the title. Reference slices by `id`, never by title or filename. |
|
|
19
|
-
| `title` | Human display name. |
|
|
20
|
-
| `pattern` | `state-change \| state-view \| automation \| translation` — the read/write/automation/translation facet. |
|
|
21
|
-
| `status` | See Lifecycle below. |
|
|
22
|
-
| `version` | Integer, bumped via `em slice update --bump-version` on a meaningful content change. Git log is the real history — this is just a "has it changed" signal. |
|
|
23
|
-
| `model` | Relative path to the `.em` file. |
|
|
24
|
-
| `sliceElement` | The `.em` `Element.id` this doc is linked from (via `note "slices/<id>.md"`). |
|
|
25
|
-
|
|
26
|
-
**Generated** (never hand-edit — run `em slice sync` after any `.em` edit that touches this
|
|
27
|
-
slice's elements):
|
|
28
|
-
|
|
29
|
-
| Field | Meaning |
|
|
30
|
-
|---|---|
|
|
31
|
-
| `commands`, `events`, `readModels` | Names of the command/event/view elements in this slice. |
|
|
32
|
-
| `contexts`, `personas` | Contexts/personas touched by this slice's event/ui elements. |
|
|
33
|
-
| `triggers` | (automation/translation only) The `id` of the slice doc for the command this reaction triggers, in the next slice. |
|
|
34
|
-
| `triggeredBy` | (command slices only) The inverse — set on the doc for the command an automation/translation triggers. |
|
|
35
|
-
|
|
36
|
-
`em validate` warns "frontmatter out of sync with .em; run \`em slice sync\`" if these drift from
|
|
37
|
-
what the `.em` actually says. It never auto-fixes this — you have to run `sync` yourself.
|
|
38
|
-
|
|
39
|
-
**Optional / authored:**
|
|
40
|
-
|
|
41
|
-
| Field | Meaning |
|
|
42
|
-
|---|---|
|
|
43
|
-
| `swimlane` | `{ persona, context }` — structured form of the body's `**Swimlane:**` line. |
|
|
44
|
-
| `upstreamEvents` | Only for dependencies **not** visible in the `.em`'s wiring (an invariant reading state from an event not consumed via `from`). If the `.em` already expresses it, it belongs in the generated fields above, not here. |
|
|
45
|
-
| `relatedSlices` | Freeform cross-references to other slice `id`s. |
|
|
46
|
-
| `tags` | Free text, searchable via `em slice search --tag`. |
|
|
47
|
-
| `owner`, `created`, `updated` | |
|
|
48
|
-
| `supersededBy`, `implementedRef` | Written by external build tools, not by `em` — see Handoff below. |
|
|
49
|
-
|
|
50
|
-
**`compliance` — reserved, unvalidated.** For regulated domains (financial, medical, etc.). `em`
|
|
51
|
-
never writes, reads, or validates this key — it's a documented convention only, so it works the
|
|
52
|
-
same way across industries without `em` having to know any regulation's specifics. Only ask about
|
|
53
|
-
it when the model's Regulatory scope (state file) isn't "none" — see the `slice` phase below.
|
|
54
|
-
|
|
55
|
-
```yaml
|
|
56
|
-
compliance:
|
|
57
|
-
frameworks: [PCI-DSS, SOX, GAAP] # or [HIPAA], [GDPR], etc. — whatever applies
|
|
58
|
-
dataClassification: restricted # public | internal | confidential | restricted
|
|
59
|
-
sensitiveDataCategories: [PCI, financial] # freeform: PCI, PHI, PII, financial, biometric, ...
|
|
60
|
-
controlRefs: [PCI-DSS-3.4, SOX-404] # specific control/citation ids
|
|
61
|
-
retention: 7y
|
|
62
|
-
dataResidency: US-only
|
|
63
|
-
reviewedBy: jane@co.com
|
|
64
|
-
reviewedAt: 2026-06-01
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
`em slice search` includes this block in its free-text match, so it stays findable even though
|
|
68
|
-
it's unvalidated (e.g. `em slice search "PCI-DSS"`).
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
## Lifecycle
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
draft → reviewed → ready-to-implement → in-progress → implemented → (deprecated | superseded)
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
- `draft` / `reviewed` / `ready-to-implement` — the `slice` phase drives these. Move a doc forward
|
|
79
|
-
with `em slice update <id> --status <status>`.
|
|
80
|
-
- `in-progress` / `implemented` / `deprecated` / `superseded` — **post-handoff.** `em` never writes
|
|
81
|
-
these; they exist so validation tolerates a build tool writing them back into the same file.
|
|
82
|
-
Don't set these yourself during a design session.
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
## Handoff to build / SDD tooling
|
|
87
|
-
|
|
88
|
-
A slice is **ready** when `status` is `ready-to-implement` or later, **and** `em validate` is
|
|
89
|
-
clean for both the `.em` and this doc. At that point, here's what's authoritative for whatever
|
|
90
|
-
implements it:
|
|
91
|
-
|
|
92
|
-
- **`id`** — the only stable key. Never key generated code, tests, or tickets on title/filename.
|
|
93
|
-
- **Command/Input field table** — the real parameter contract (richer than the `.em`'s lightweight
|
|
94
|
-
inline `{ field: Type }`, which is a structural preview only — they aren't cross-validated in
|
|
95
|
-
1.0, so the doc wins if they disagree).
|
|
96
|
-
- **Event table's "Immutable Fact?" column** — treat as compile-time-enforced immutability.
|
|
97
|
-
- **`INV-n` invariant ids** — cite them in generated tests (`test("INV-1: ...")`).
|
|
98
|
-
- **Given/When/Then** — acceptance criteria. Happy path is the floor; rule-boundary scenarios
|
|
99
|
-
trace to their `INV-n`.
|
|
100
|
-
- **Alternate & Error Flows** — required test cases, not optional.
|
|
101
|
-
- `triggers`/`triggeredBy` plus upstream/downstream (joining doc + `.em`) — a sequencing hint for
|
|
102
|
-
a build orchestrator (don't build a slice until its upstream slices are `implemented`),
|
|
103
|
-
advisory only.
|
|
104
|
-
|
|
105
|
-
`em` never clobbers fields it doesn't recognize on write (`sync`/`update` shallow-merge) — a build
|
|
106
|
-
tool's own bookkeeping fields survive.
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## CLI
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
em slice new "Place Order" [--pattern state-change] [--id <id>] # scaffold slices/<id>.md
|
|
114
|
-
em slice sync <id> # after wiring `note "slices/<id>.md"` into the .em
|
|
115
|
-
em slice sync --all # re-sync every doc in the directory
|
|
116
|
-
em slice list [--status <s>] [--pattern <p>] [--context <c>] [--tag <t>] [--format json] [--full]
|
|
117
|
-
em slice show <id> [--body] [--format json]
|
|
118
|
-
em slice search "<query>" [--pattern <p>] [--status <s>] [--context <c>] [--tag <t>] [--format json] [--full]
|
|
119
|
-
em slice update <id> [--status <s>] [--bump-version]
|
|
120
|
-
em migrate <model-dir> [--dry-run] [--report <path>] # one-time upgrade from a pre-1.0 model
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
All commands take `--dir <path>` (default `.`) and `--model <path.em>` if a directory has more
|
|
124
|
-
than one `.em` file. `list`/`show`/`search` read **frontmatter only** — never the `.em`, never the
|
|
125
|
-
doc body — so they stay cheap across a large model.
|
|
126
|
-
|
|
127
|
-
`list`/`search` emit a summary row per slice by default. Add **`--full`** (with `--format json`)
|
|
128
|
-
to get every frontmatter field instead — use it when you need the filtered slices' commands,
|
|
129
|
-
events, or contexts, so you don't follow a search with one `slice show` per hit.
|
package/dist/config.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface EmConfig {
|
|
2
|
-
/** Path to a body-only custom slice template, resolved relative to the config file's directory. */
|
|
3
|
-
sliceTemplate?: string;
|
|
4
|
-
}
|
|
5
|
-
export interface ResolvedConfig {
|
|
6
|
-
config: EmConfig;
|
|
7
|
-
/** Absolute path to the em.config.json that was loaded, or null if none was found. */
|
|
8
|
-
configPath: string | null;
|
|
9
|
-
}
|
|
10
|
-
/** Resolve project config starting from `modelDir`, walking up to the filesystem root. */
|
|
11
|
-
export declare function resolveConfig(modelDir: string, explicitPath?: string): ResolvedConfig;
|
|
12
|
-
/** The default slice template shipped with the package (the same one `em skill install` copies). */
|
|
13
|
-
export declare function defaultSliceTemplatePath(): string;
|
|
14
|
-
/** The effective slice template path: the resolved config's custom template, or the shipped default. */
|
|
15
|
-
export declare function resolveSliceTemplatePath(resolved: ResolvedConfig): string;
|
package/dist/config.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
// Project config (em.config.json), per docs/1.0.0-spec.md §4. One field for
|
|
3
|
-
// now: a body-only custom slice template. Resolution: --config flag > model
|
|
4
|
-
// directory > walk up parents > shipped default (no em.config.json needed).
|
|
5
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
-
import { dirname, join, resolve } from "node:path";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
/** Resolve project config starting from `modelDir`, walking up to the filesystem root. */
|
|
9
|
-
export function resolveConfig(modelDir, explicitPath) {
|
|
10
|
-
if (explicitPath) {
|
|
11
|
-
return { config: readConfig(explicitPath), configPath: resolve(explicitPath) };
|
|
12
|
-
}
|
|
13
|
-
let dir = resolve(modelDir);
|
|
14
|
-
for (;;) {
|
|
15
|
-
const candidate = join(dir, "em.config.json");
|
|
16
|
-
if (existsSync(candidate)) {
|
|
17
|
-
return { config: readConfig(candidate), configPath: candidate };
|
|
18
|
-
}
|
|
19
|
-
const parent = dirname(dir);
|
|
20
|
-
if (parent === dir)
|
|
21
|
-
break;
|
|
22
|
-
dir = parent;
|
|
23
|
-
}
|
|
24
|
-
return { config: {}, configPath: null };
|
|
25
|
-
}
|
|
26
|
-
function readConfig(path) {
|
|
27
|
-
const raw = readFileSync(path, "utf8");
|
|
28
|
-
let parsed;
|
|
29
|
-
try {
|
|
30
|
-
parsed = JSON.parse(raw);
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
throw new Error(`invalid JSON in ${path}: ${e instanceof Error ? e.message : String(e)}`);
|
|
34
|
-
}
|
|
35
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
36
|
-
throw new Error(`${path} must contain a JSON object`);
|
|
37
|
-
}
|
|
38
|
-
const { sliceTemplate } = parsed;
|
|
39
|
-
if (sliceTemplate !== undefined && typeof sliceTemplate !== "string") {
|
|
40
|
-
throw new Error(`${path}: \`sliceTemplate\` must be a string path`);
|
|
41
|
-
}
|
|
42
|
-
return parsed;
|
|
43
|
-
}
|
|
44
|
-
/** The default slice template shipped with the package (the same one `em skill install` copies). */
|
|
45
|
-
export function defaultSliceTemplatePath() {
|
|
46
|
-
const pkgDir = dirname(fileURLToPath(import.meta.url));
|
|
47
|
-
return join(pkgDir, "..", ".claude", "skills", "event-modeling", "templates", "slice.md");
|
|
48
|
-
}
|
|
49
|
-
/** The effective slice template path: the resolved config's custom template, or the shipped default. */
|
|
50
|
-
export function resolveSliceTemplatePath(resolved) {
|
|
51
|
-
if (!resolved.config.sliceTemplate)
|
|
52
|
-
return defaultSliceTemplatePath();
|
|
53
|
-
const base = resolved.configPath ? dirname(resolved.configPath) : process.cwd();
|
|
54
|
-
const path = resolve(base, resolved.config.sliceTemplate);
|
|
55
|
-
if (!existsSync(path)) {
|
|
56
|
-
throw new Error(`slice template not found: ${path} (\`sliceTemplate\` in ${resolved.configPath ?? "config"})`);
|
|
57
|
-
}
|
|
58
|
-
return path;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAazC,0FAA0F;AAC1F,MAAM,UAAU,aAAa,CAAC,Q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}
|
|
4
|
-
export interface MigrationNote {
|
|
5
|
-
file: string;
|
|
6
|
-
message: string;
|
|
7
|
-
}
|
|
8
|
-
export interface DocPlan {
|
|
9
|
-
path: string;
|
|
10
|
-
file: string;
|
|
11
|
-
alreadyMigrated: boolean;
|
|
12
|
-
/** New file content to write. Undefined when alreadyMigrated. */
|
|
13
|
-
content?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface MigrationPlan {
|
|
16
|
-
dir: string;
|
|
17
|
-
modelPath: string;
|
|
18
|
-
docs: DocPlan[];
|
|
19
|
-
stateFile?: DocPlan;
|
|
20
|
-
notes: MigrationNote[];
|
|
21
|
-
}
|
|
22
|
-
export declare function planMigration(dir: string, opts?: MigrateOptions): MigrationPlan;
|
|
23
|
-
export declare function applyMigration(plan: MigrationPlan): void;
|
|
24
|
-
export declare function formatMigrationReport(plan: MigrationPlan): string;
|
|
25
|
-
/** Throws unless `dir` is a clean git working tree (or `force` is set). Git is the undo mechanism. */
|
|
26
|
-
export declare function assertCleanWorkingTree(dir: string, force?: boolean): void;
|
package/dist/migrate/migrate.js
DELETED
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
// `em migrate` — one-time upgrade from the pre-1.0 fixed-template format to
|
|
3
|
-
// the frontmatter standard (docs/1.0.0-spec.md §7). planMigration() is pure;
|
|
4
|
-
// applyMigration() is the only thing that writes, so --dry-run is just
|
|
5
|
-
// "compute the plan, don't call apply."
|
|
6
|
-
import { execFileSync } from "node:child_process";
|
|
7
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
8
|
-
import { dirname, join, relative, resolve } from "node:path";
|
|
9
|
-
import { normalize } from "../model/model.js";
|
|
10
|
-
import { parse } from "../parser/parser.js";
|
|
11
|
-
import { buildDocIdByElementId, deriveGeneratedFields } from "../model/deriveSliceFields.js";
|
|
12
|
-
import { frontmatterFromData, parseFrontmatter, stringifyFrontmatter } from "../model/frontmatter.js";
|
|
13
|
-
import { loadSliceDocs } from "../model/sliceDoc.js";
|
|
14
|
-
import { CURRENT_SCHEMA_VERSION } from "../model/validateSliceDocs.js";
|
|
15
|
-
import { findModelFile } from "../util/findModel.js";
|
|
16
|
-
import { dedupe, kebabSlug } from "../util/slug.js";
|
|
17
|
-
const PATTERN_FROM_PROSE = {
|
|
18
|
-
"state change": "state-change",
|
|
19
|
-
"state view": "state-view",
|
|
20
|
-
automation: "automation",
|
|
21
|
-
translation: "translation",
|
|
22
|
-
};
|
|
23
|
-
const STATUS_FROM_PROSE = {
|
|
24
|
-
draft: "draft",
|
|
25
|
-
reviewed: "reviewed",
|
|
26
|
-
"ready-to-implement": "ready-to-implement",
|
|
27
|
-
};
|
|
28
|
-
export function planMigration(dir, opts = {}) {
|
|
29
|
-
const modelPath = findModelFile(dir, opts.modelPath);
|
|
30
|
-
const model = normalize(parse(readFileSync(modelPath, "utf8")));
|
|
31
|
-
const docs = loadSliceDocs(dir);
|
|
32
|
-
const notes = [];
|
|
33
|
-
const usedIds = new Set();
|
|
34
|
-
for (const doc of docs) {
|
|
35
|
-
if (typeof doc.frontmatter?.id === "string")
|
|
36
|
-
usedIds.add(doc.frontmatter.id);
|
|
37
|
-
}
|
|
38
|
-
const drafts = [];
|
|
39
|
-
for (const doc of docs) {
|
|
40
|
-
if (typeof doc.frontmatter?.schemaVersion === "number")
|
|
41
|
-
continue; // already migrated
|
|
42
|
-
const heading = doc.raw.match(/^#\s*Slice:\s*(.+)$/m);
|
|
43
|
-
const title = heading ? heading[1].trim() : doc.file.replace(/\.md$/, "");
|
|
44
|
-
const linkedElement = model.elements.find((el) => el.note && resolve(dirname(modelPath), el.note) === resolve(doc.path));
|
|
45
|
-
let pattern;
|
|
46
|
-
let sliceElementId;
|
|
47
|
-
if (linkedElement) {
|
|
48
|
-
sliceElementId = linkedElement.id;
|
|
49
|
-
pattern = patternFromElementKind(linkedElement.kind);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
const proseMatch = doc.raw.match(/\*\*Pattern:\*\*\s*([A-Za-z ]+)/);
|
|
53
|
-
const key = proseMatch?.[1].trim().toLowerCase();
|
|
54
|
-
const resolved = key ? PATTERN_FROM_PROSE[key] : undefined;
|
|
55
|
-
pattern = resolved ?? "state-change";
|
|
56
|
-
notes.push({
|
|
57
|
-
file: doc.path,
|
|
58
|
-
message: resolved
|
|
59
|
-
? "no .em element links to this doc (orphan); pattern inferred from prose only — please wire a `note` and re-sync"
|
|
60
|
-
: "no .em element links to this doc and its pattern couldn't be inferred from prose; defaulted to state-change — please review",
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
const statusMatch = doc.raw.match(/\*\*Status:\*\*\s*([A-Za-z- ]+)/);
|
|
64
|
-
const statusKey = statusMatch?.[1].trim().toLowerCase();
|
|
65
|
-
const resolvedStatus = statusKey ? STATUS_FROM_PROSE[statusKey] : undefined;
|
|
66
|
-
const status = resolvedStatus ?? "draft";
|
|
67
|
-
if (!resolvedStatus) {
|
|
68
|
-
notes.push({
|
|
69
|
-
file: doc.path,
|
|
70
|
-
message: "status couldn't be confidently inferred from prose; defaulted to draft",
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
const id = dedupe(kebabSlug(title), usedIds, "-");
|
|
74
|
-
const upstreamMatch = doc.raw.match(/\*\*Upstream events this slice relies on:\*\*\s*(.+)/);
|
|
75
|
-
const upstreamEvents = upstreamMatch
|
|
76
|
-
? upstreamMatch[1]
|
|
77
|
-
.split(",")
|
|
78
|
-
.map((s) => s.trim().replace(/^["']|["']$/g, ""))
|
|
79
|
-
.filter((s) => s.length > 0 && !/^\{\{.*\}\}$/.test(s))
|
|
80
|
-
: [];
|
|
81
|
-
if (upstreamMatch && upstreamEvents.length === 0) {
|
|
82
|
-
notes.push({ file: doc.path, message: "upstream events line found but unparseable; left empty" });
|
|
83
|
-
}
|
|
84
|
-
drafts.push({ doc, id, title, pattern, status, sliceElementId, upstreamEvents });
|
|
85
|
-
}
|
|
86
|
-
// Cross-doc id index (already-migrated docs + newly planned drafts) so
|
|
87
|
-
// triggers/triggeredBy resolve even between two docs migrated in the same run.
|
|
88
|
-
const docIdByElementId = buildDocIdByElementId(model, docs);
|
|
89
|
-
for (const d of drafts) {
|
|
90
|
-
if (d.sliceElementId)
|
|
91
|
-
docIdByElementId.set(d.sliceElementId, d.id);
|
|
92
|
-
}
|
|
93
|
-
const docPlans = docs.map((doc) => {
|
|
94
|
-
const draft = drafts.find((d) => d.doc === doc);
|
|
95
|
-
if (!draft)
|
|
96
|
-
return { path: doc.path, file: doc.file, alreadyMigrated: true };
|
|
97
|
-
const today = new Date().toISOString().slice(0, 10);
|
|
98
|
-
const data = {
|
|
99
|
-
schemaVersion: CURRENT_SCHEMA_VERSION,
|
|
100
|
-
id: draft.id,
|
|
101
|
-
title: draft.title,
|
|
102
|
-
pattern: draft.pattern,
|
|
103
|
-
status: draft.status,
|
|
104
|
-
version: 1,
|
|
105
|
-
model: relative(dirname(doc.path), modelPath),
|
|
106
|
-
created: today,
|
|
107
|
-
updated: today,
|
|
108
|
-
};
|
|
109
|
-
if (draft.sliceElementId) {
|
|
110
|
-
data.sliceElement = draft.sliceElementId;
|
|
111
|
-
const derived = deriveGeneratedFields(model, draft.sliceElementId, docIdByElementId);
|
|
112
|
-
if (derived) {
|
|
113
|
-
data.commands = derived.commands;
|
|
114
|
-
data.events = derived.events;
|
|
115
|
-
data.readModels = derived.readModels;
|
|
116
|
-
data.contexts = derived.contexts;
|
|
117
|
-
data.personas = derived.personas;
|
|
118
|
-
if (derived.triggers)
|
|
119
|
-
data.triggers = derived.triggers;
|
|
120
|
-
if (derived.triggeredBy)
|
|
121
|
-
data.triggeredBy = derived.triggeredBy;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (draft.upstreamEvents.length > 0)
|
|
125
|
-
data.upstreamEvents = draft.upstreamEvents;
|
|
126
|
-
const content = stringifyFrontmatter(frontmatterFromData(data), stripLegacyBullets(doc.body));
|
|
127
|
-
return { path: doc.path, file: doc.file, alreadyMigrated: false, content };
|
|
128
|
-
});
|
|
129
|
-
// Every slice's final (id, pattern, status, version) — migrated-this-run or already-migrated —
|
|
130
|
-
// used to regenerate the state file's Slice inventory table below.
|
|
131
|
-
const summaries = docs.map((doc) => {
|
|
132
|
-
const draft = drafts.find((d) => d.doc === doc);
|
|
133
|
-
if (draft)
|
|
134
|
-
return { title: draft.title, id: draft.id, pattern: draft.pattern, status: draft.status, version: 1 };
|
|
135
|
-
// Already-migrated doc: its frontmatter is whatever's on disk, which may be
|
|
136
|
-
// malformed. Fall back rather than rendering `undefined` into the table —
|
|
137
|
-
// `em validate` is what reports the malformed field.
|
|
138
|
-
const fm = doc.frontmatter;
|
|
139
|
-
return {
|
|
140
|
-
title: typeof fm.title === "string" ? fm.title : String(fm.id),
|
|
141
|
-
id: String(fm.id),
|
|
142
|
-
pattern: typeof fm.pattern === "string" ? fm.pattern : "state-change",
|
|
143
|
-
status: typeof fm.status === "string" ? fm.status : "draft",
|
|
144
|
-
version: typeof fm.version === "number" ? fm.version : 1,
|
|
145
|
-
};
|
|
146
|
-
});
|
|
147
|
-
const stateFile = planStateFile(dir, modelPath, summaries, notes);
|
|
148
|
-
return { dir, modelPath, docs: docPlans, stateFile, notes };
|
|
149
|
-
}
|
|
150
|
-
function planStateFile(dir, modelPath, summaries, notes) {
|
|
151
|
-
const stateFilePath = join(dir, ".event-modeling.md");
|
|
152
|
-
if (!existsSync(stateFilePath))
|
|
153
|
-
return undefined;
|
|
154
|
-
const raw = readFileSync(stateFilePath, "utf8");
|
|
155
|
-
const { data, body } = parseFrontmatter(raw);
|
|
156
|
-
if (data && typeof data.schemaVersion === "number") {
|
|
157
|
-
return { path: stateFilePath, file: ".event-modeling.md", alreadyMigrated: true };
|
|
158
|
-
}
|
|
159
|
-
const fmData = { schemaVersion: CURRENT_SCHEMA_VERSION, model: relative(dir, modelPath) };
|
|
160
|
-
const { content: newBody, matchedAny, unmatchedRows } = regenerateSliceInventory(body, summaries);
|
|
161
|
-
if (summaries.length > 0 && !matchedAny) {
|
|
162
|
-
notes.push({
|
|
163
|
-
file: stateFilePath,
|
|
164
|
-
message: "Slice inventory table couldn't be matched to any migrated doc by name; review manually",
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
else if (unmatchedRows > 0) {
|
|
168
|
-
notes.push({
|
|
169
|
-
file: stateFilePath,
|
|
170
|
-
message: `${unmatchedRows} Slice inventory row(s) couldn't be matched to a migrated doc by name; review manually`,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
const content = stringifyFrontmatter(frontmatterFromData(fmData), newBody);
|
|
174
|
-
return { path: stateFilePath, file: ".event-modeling.md", alreadyMigrated: false, content };
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Rewrite the "| Slice | Pattern | Doc status |" table to "| Slice | Id | Pattern | Doc status |",
|
|
178
|
-
* matching each row to a migrated slice by title (or by kebab-slugging the row's slice name) and
|
|
179
|
-
* filling in id/pattern/status/version. Rows that can't be matched (e.g. a still-unfilled
|
|
180
|
-
* `{{Slice Name}}` template row) are left untouched — never guessed.
|
|
181
|
-
*/
|
|
182
|
-
function regenerateSliceInventory(content, summaries) {
|
|
183
|
-
const lines = content.split("\n");
|
|
184
|
-
const headerIdx = lines.findIndex((l) => /^\|\s*Slice\s*\|/i.test(l.trim()));
|
|
185
|
-
const separatorOk = headerIdx !== -1 && /^\|[\s\-:|]+\|$/.test((lines[headerIdx + 1] ?? "").trim());
|
|
186
|
-
if (!separatorOk)
|
|
187
|
-
return { content, matchedAny: false, unmatchedRows: 0 };
|
|
188
|
-
const byTitle = new Map(summaries.map((s) => [s.title.toLowerCase(), s]));
|
|
189
|
-
const bySlug = new Map(summaries.map((s) => [kebabSlug(s.title), s]));
|
|
190
|
-
let rowEnd = headerIdx + 2;
|
|
191
|
-
while (rowEnd < lines.length && lines[rowEnd].trim().startsWith("|"))
|
|
192
|
-
rowEnd++;
|
|
193
|
-
let matchedAny = false;
|
|
194
|
-
let unmatchedRows = 0;
|
|
195
|
-
const newRows = [];
|
|
196
|
-
for (let i = headerIdx + 2; i < rowEnd; i++) {
|
|
197
|
-
const cells = lines[i].split("|").slice(1, -1).map((c) => c.trim());
|
|
198
|
-
const sliceName = cells[0] ?? "";
|
|
199
|
-
const summary = byTitle.get(sliceName.toLowerCase()) ?? bySlug.get(kebabSlug(sliceName));
|
|
200
|
-
if (summary) {
|
|
201
|
-
matchedAny = true;
|
|
202
|
-
newRows.push(`| ${summary.title} | ${summary.id} | ${summary.pattern} | ${summary.status} (v${summary.version}) |`);
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
unmatchedRows++;
|
|
206
|
-
newRows.push(lines[i]);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
if (!matchedAny)
|
|
210
|
-
return { content, matchedAny: false, unmatchedRows };
|
|
211
|
-
const rewritten = [
|
|
212
|
-
...lines.slice(0, headerIdx),
|
|
213
|
-
"| Slice | Id | Pattern | Doc status |",
|
|
214
|
-
"|-------|-----|---------|------------|",
|
|
215
|
-
...newRows,
|
|
216
|
-
...lines.slice(rowEnd),
|
|
217
|
-
];
|
|
218
|
-
return { content: rewritten.join("\n"), matchedAny: true, unmatchedRows };
|
|
219
|
-
}
|
|
220
|
-
function patternFromElementKind(kind) {
|
|
221
|
-
if (kind === "command")
|
|
222
|
-
return "state-change";
|
|
223
|
-
if (kind === "translation")
|
|
224
|
-
return "translation";
|
|
225
|
-
if (kind === "processor" || kind === "automation" || kind === "saga")
|
|
226
|
-
return "automation";
|
|
227
|
-
return "state-view";
|
|
228
|
-
}
|
|
229
|
-
function stripLegacyBullets(body) {
|
|
230
|
-
return body
|
|
231
|
-
.split("\n")
|
|
232
|
-
.filter((line) => !/^-\s*\*\*(Pattern|Status):\*\*/.test(line.trim()))
|
|
233
|
-
.join("\n");
|
|
234
|
-
}
|
|
235
|
-
export function applyMigration(plan) {
|
|
236
|
-
for (const doc of plan.docs) {
|
|
237
|
-
if (!doc.alreadyMigrated && doc.content !== undefined)
|
|
238
|
-
writeFileSync(doc.path, doc.content);
|
|
239
|
-
}
|
|
240
|
-
if (plan.stateFile && !plan.stateFile.alreadyMigrated && plan.stateFile.content !== undefined) {
|
|
241
|
-
writeFileSync(plan.stateFile.path, plan.stateFile.content);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
export function formatMigrationReport(plan) {
|
|
245
|
-
const changed = plan.docs.filter((d) => !d.alreadyMigrated);
|
|
246
|
-
const skipped = plan.docs.filter((d) => d.alreadyMigrated);
|
|
247
|
-
const lines = [`# em migrate report — ${plan.dir}`, "", `Model: ${plan.modelPath}`, ""];
|
|
248
|
-
lines.push(`## Migrated (${changed.length})`);
|
|
249
|
-
lines.push(...(changed.length ? changed.map((d) => `- ${d.file}`) : ["(none)"]));
|
|
250
|
-
lines.push("", `## Already migrated, skipped (${skipped.length})`);
|
|
251
|
-
lines.push(...(skipped.length ? skipped.map((d) => `- ${d.file}`) : ["(none)"]));
|
|
252
|
-
if (plan.stateFile) {
|
|
253
|
-
lines.push("", `## State file: ${plan.stateFile.alreadyMigrated ? "already migrated, skipped" : "migrated"}`);
|
|
254
|
-
}
|
|
255
|
-
lines.push("", `## Flagged for review (${plan.notes.length})`);
|
|
256
|
-
lines.push(...(plan.notes.length ? plan.notes.map((n) => `- ${n.file}: ${n.message}`) : ["(none)"]));
|
|
257
|
-
return lines.join("\n") + "\n";
|
|
258
|
-
}
|
|
259
|
-
/** Throws unless `dir` is a clean git working tree (or `force` is set). Git is the undo mechanism. */
|
|
260
|
-
export function assertCleanWorkingTree(dir, force) {
|
|
261
|
-
if (force)
|
|
262
|
-
return;
|
|
263
|
-
let output;
|
|
264
|
-
try {
|
|
265
|
-
output = execFileSync("git", ["-C", dir, "status", "--porcelain", "."], { encoding: "utf8" });
|
|
266
|
-
}
|
|
267
|
-
catch {
|
|
268
|
-
throw new Error(`${dir} doesn't look like it's inside a git repository — em migrate rewrites files in ` +
|
|
269
|
-
`place and relies on git as the undo mechanism; pass --force to proceed anyway`);
|
|
270
|
-
}
|
|
271
|
-
if (output.trim().length > 0) {
|
|
272
|
-
throw new Error(`${dir} has uncommitted changes — commit or stash them first (git is em migrate's undo ` +
|
|
273
|
-
`mechanism), or pass --force to proceed anyway`);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
//# sourceMappingURL=migrate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/migrate/migrate.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,4EAA4E;AAC5E,6EAA6E;AAC7E,uEAAuE;AACvE,wCAAwC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACtG,OAAO,EAAE,aAAa,EAAuC,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA2BpD,MAAM,kBAAkB,GAAiC;IACvD,cAAc,EAAE,cAAc;IAC9B,YAAY,EAAE,YAAY;IAC1B,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,aAAa;CAC3B,CAAC;AAE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sB,CAAC,GAAW,EAAE,KAAe;IACjE,IAAI,KAAK;QAAE,OAAO;IAElB,IAAI,MAAc,CAAC;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAChG,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,GAAG,GAAG,iFAAiF;YACrF,+EAA+E,CAClF,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CACb,GAAG,GAAG,kFAAkF;YACtF,+CAA+C,CAClD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { NormalizedModel } from "./model.js";
|
|
2
|
-
import { SliceDoc } from "./sliceDoc.js";
|
|
3
|
-
export interface DerivedSliceFields {
|
|
4
|
-
commands: string[];
|
|
5
|
-
events: string[];
|
|
6
|
-
readModels: string[];
|
|
7
|
-
contexts: string[];
|
|
8
|
-
personas: string[];
|
|
9
|
-
triggers?: string;
|
|
10
|
-
triggeredBy?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Derive the generated fields for the slice that `sliceElementId` belongs to.
|
|
14
|
-
* `docIdByElementId` maps every *other* slice doc's linked element id to that
|
|
15
|
-
* doc's frontmatter `id`, so `triggers`/`triggeredBy` (the automation/translation
|
|
16
|
-
* two-slice split) can be resolved without a second .em pass per doc. Returns
|
|
17
|
-
* null if `sliceElementId` doesn't resolve to a real element.
|
|
18
|
-
*/
|
|
19
|
-
export declare function deriveGeneratedFields(model: NormalizedModel, sliceElementId: string, docIdByElementId: ReadonlyMap<string, string>): DerivedSliceFields | null;
|
|
20
|
-
/** Map every doc's linked .em element id -> that doc's frontmatter `id`, skipping unusable docs. */
|
|
21
|
-
export declare function buildDocIdByElementId(model: NormalizedModel, docs: readonly SliceDoc[]): Map<string, string>;
|