@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
@@ -0,0 +1,524 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // `em upgrade` (MIL-219): bring a model repo authored under an older em (1.6 forward) up to the
3
+ // installed version. Nothing here is new machinery — every mechanical step DELEGATES to an
4
+ // existing command's own plan/apply (`em skill sync`, `em migrate`, `em ci init`) or an existing
5
+ // stateFile.ts primitive; this module is the orchestration: fixed step order, detect-then-apply,
6
+ // one git commit per applied step, and the human list of things no command can safely decide by
7
+ // itself.
8
+ //
9
+ // Two disjoint lists, always both computed together (dry-run, `--apply`, and `--check` alike):
10
+ // - **steps** — mechanical, idempotent, each `{ id, sinceVersion, detect, apply }`. `detect`
11
+ // is pure-ish (reads fs, never writes); `apply` performs the actual write and is only ever
12
+ // called when `detect` said `applicable`. A step never partially writes on failure — the
13
+ // same "verify before write" discipline `em migrate` itself holds (migrateReactionShape.ts).
14
+ // - **human** — detect-only, by construction never applied by this command. One of these
15
+ // (`predates-1.6`) is also the one thing that makes `--check` exit 1 — see `checkUpgrade`.
16
+ //
17
+ // `UpgradeContext` batches everything a step/human-detector needs: the already-compiled model
18
+ // (steps never re-compile — the ONE exception, `reaction-shape`, re-reads `modelFile`'s raw text
19
+ // itself before applying, precisely because a prior step in the same run could have touched it,
20
+ // though in practice no other step ever does) plus the resolved repo root every skill-bundle/
21
+ // ci-block/constitution check needs. Requires the model directory to be inside a git
22
+ // repository — same requirement `em conform-scope` holds, for the same reason (there is no
23
+ // "changed since when" or "commit per step" without one).
24
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
25
+ import { basename, extname, join } from "node:path";
26
+ import { realGit } from "./diff-inputs.js";
27
+ import { resolveSliceDocJoin } from "../catalog/docJoin.js";
28
+ import { validateOrphanedSliceDocs } from "../catalog/orphanedSliceDocValidate.js";
29
+ import { planMigration, verifyMigration } from "./migrateReactionShape.js";
30
+ import { planSkillSyncBundle, applySkillSyncBundle } from "./skillSync.js";
31
+ import { EM_ALL_SKILL_BUNDLE_DIRS, EM_SKILL_ANCHOR_DIR } from "./skillDirs.js";
32
+ import { ciWorkflowPath, conformWorkflowPath, buildCiWorkflowFile, buildConformWorkflowFile, ciManagedBody, conformManagedBody, planCiFile, applyCiFile, CI_WORKFLOW_MARKER, CONFORM_WORKFLOW_MARKER, } from "./ciInit.js";
33
+ import { findSpecifyRoot } from "./status.js";
34
+ import { scaffoldConstitution, scaffoldStateFile } from "../templates.js";
35
+ import { loadStateFile, parseState, setEmVersion, ensureOptionalBullets, resolveStateFilePath } from "./stateFile.js";
36
+ import { fieldLineRegex, normalizeFieldValue, locateFrontmatterInner } from "./frontmatterSurgery.js";
37
+ import { localIsoDate } from "../util/localDate.js";
38
+ export const UPGRADE_MIN_SUPPORTED_VERSION = "1.6.0";
39
+ // ---- Step 1: skill-bundle — delegates to `em skill sync`'s own plan/apply. ----
40
+ function vendoredSkillsRootOf(repoRoot) {
41
+ return join(repoRoot, ".claude", "skills");
42
+ }
43
+ function detectSkillBundle(ctx) {
44
+ const vendoredRoot = vendoredSkillsRootOf(ctx.repoRoot);
45
+ if (!existsSync(join(vendoredRoot, EM_SKILL_ANCHOR_DIR))) {
46
+ return { applicable: false, reason: "no vendored skill bundle installed at .claude/skills/ — run `em skill install` first if you want one" };
47
+ }
48
+ const bundlePlan = planSkillSyncBundle(ctx.packagedSkillsRoot, vendoredRoot, EM_ALL_SKILL_BUNDLE_DIRS);
49
+ const totalChanges = bundlePlan.reduce((n, { plan }) => n + plan.changes.length, 0);
50
+ if (totalChanges === 0)
51
+ return { applicable: false, reason: "vendored skill bundle already matches the installed em" };
52
+ return { applicable: true, reason: `vendored skill bundle differs from the installed em in ${totalChanges} file(s)` };
53
+ }
54
+ function applySkillBundle(ctx) {
55
+ const vendoredRoot = vendoredSkillsRootOf(ctx.repoRoot);
56
+ const bundlePlan = planSkillSyncBundle(ctx.packagedSkillsRoot, vendoredRoot, EM_ALL_SKILL_BUNDLE_DIRS);
57
+ const totalChanges = bundlePlan.reduce((n, { plan }) => n + plan.changes.length, 0);
58
+ if (totalChanges === 0)
59
+ return { ok: false, message: "nothing to sync" };
60
+ applySkillSyncBundle(bundlePlan, ctx.packagedSkillsRoot, vendoredRoot);
61
+ const changedFiles = bundlePlan.flatMap(({ dirName, plan }) => plan.changes.map((c) => join(".claude", "skills", dirName, c.relPath)));
62
+ return { ok: true, changedFiles };
63
+ }
64
+ // ---- Step 2: reaction-shape — delegates to `em migrate`'s own plan/verify/apply. ----
65
+ function readMigrationPlan(ctx) {
66
+ const source = readFileSync(ctx.modelFile, "utf8");
67
+ try {
68
+ return planMigration(source);
69
+ }
70
+ catch {
71
+ return null; // parse error — surfaced by the normal compile path before upgrade ever runs
72
+ }
73
+ }
74
+ function detectReactionShape(ctx) {
75
+ const plan = readMigrationPlan(ctx);
76
+ if (!plan)
77
+ return { applicable: false, reason: "model file has a parse error — fix it before running em upgrade" };
78
+ if (plan.changes.length === 0)
79
+ return { applicable: false, reason: "no old two-slice Automation/Translation shape found" };
80
+ return { applicable: true, reason: `${plan.changes.length} old two-slice reaction site(s) found` };
81
+ }
82
+ function applyReactionShape(ctx) {
83
+ const source = readFileSync(ctx.modelFile, "utf8");
84
+ const plan = readMigrationPlan(ctx);
85
+ if (!plan || plan.changes.length === 0)
86
+ return { ok: false, message: "nothing to migrate" };
87
+ const verify = verifyMigration(source, plan.rewritten);
88
+ if (!verify.ok) {
89
+ return { ok: false, message: `the rewrite would introduce ${verify.newErrors.length} new error(s) — aborting, ${ctx.modelFile} left untouched` };
90
+ }
91
+ writeFileSync(ctx.modelFile, plan.rewritten);
92
+ return { ok: true, changedFiles: [ctx.modelFile] };
93
+ }
94
+ // ---- Step 3: state-file — scaffold when absent (MIL-257); else ensure Model version:/Certified:
95
+ // are present (MIL-218 defaults). ----
96
+ // `Em version:` itself is deliberately NOT this step's job when the file already exists —
97
+ // `runUpgradeApply` always writes it as its own dedicated final commit, whether or not this step
98
+ // ran (module header). A freshly scaffolded file is written already carrying the installed
99
+ // version (scaffoldStateFile's own `Em version:` fill), so that final commit is then a no-op.
100
+ /** MIL-257: the one human-readable sentence for "the state file exists but `parseState` rejected
101
+ * it", naming the file so the `--check` final line / `--apply` refusal is self-explanatory.
102
+ * `parseState`'s "missing bullet line(s): ..." reads as `is missing ...`; its format-mismatch
103
+ * messages (`"- **X:**" doesn't match ...`) follow a colon instead. */
104
+ export function describeStateFileFailure(path, parseMessage) {
105
+ return parseMessage.startsWith("missing ") ? `state file ${path} is ${parseMessage}` : `state file ${path}: ${parseMessage}`;
106
+ }
107
+ /** MIL-257: non-null when the state file exists but isn't parseable — shared by `detectStateFile`
108
+ * (so the checklist line shows the real cause rather than the migration-tolerant
109
+ * `Model version:`/`Certified:` item) and `applyStateFile`. */
110
+ function stateFileParseFailure(ctx) {
111
+ const loaded = loadStateFile(ctx.baseDir);
112
+ if (!loaded.ok)
113
+ return null; // absent — scaffolded, not an error (MIL-257)
114
+ const parsed = parseState(loaded.text);
115
+ return parsed.ok ? null : describeStateFileFailure(loaded.path, parsed.message);
116
+ }
117
+ function detectStateFile(ctx) {
118
+ const loaded = loadStateFile(ctx.baseDir);
119
+ if (!loaded.ok) {
120
+ return {
121
+ applicable: true,
122
+ reason: `no state file at ${resolveStateFilePath(ctx.baseDir)} — em upgrade will scaffold one (Current phase: discover, Current step: 1, Last conformance/Last stakeholder review: never)`,
123
+ };
124
+ }
125
+ const failure = stateFileParseFailure(ctx);
126
+ if (failure !== null)
127
+ return { applicable: false, reason: failure };
128
+ const patched = ensureOptionalBullets(loaded.text, "1970-01-01");
129
+ if (!patched.ok)
130
+ return { applicable: false, reason: patched.message };
131
+ if (patched.text === loaded.text)
132
+ return { applicable: false, reason: "Model version:/Certified: bullets already present" };
133
+ return { applicable: true, reason: "state file is missing Model version:/Certified: bullet(s)" };
134
+ }
135
+ function applyStateFile(ctx) {
136
+ const loaded = loadStateFile(ctx.baseDir);
137
+ const today = localIsoDate();
138
+ if (!loaded.ok) {
139
+ // MIL-257: reuse `em scaffold`'s own generator (templates.ts scaffoldStateFile) rather than a
140
+ // second one. `Model file:` names the model actually being upgraded (its own basename).
141
+ const path = resolveStateFilePath(ctx.baseDir);
142
+ const slug = basename(ctx.modelFile, extname(ctx.modelFile));
143
+ writeFileSync(path, scaffoldStateFile(ctx.model.name, slug, today, ctx.installedVersion));
144
+ return { ok: true, changedFiles: [path] };
145
+ }
146
+ const failure = stateFileParseFailure(ctx);
147
+ if (failure !== null)
148
+ return { ok: false, message: failure };
149
+ const patched = ensureOptionalBullets(loaded.text, today);
150
+ if (!patched.ok)
151
+ return { ok: false, message: patched.message };
152
+ if (patched.text === loaded.text)
153
+ return { ok: false, message: "nothing to change" };
154
+ writeFileSync(loaded.path, patched.text);
155
+ return { ok: true, changedFiles: [loaded.path] };
156
+ }
157
+ // ---- Step 4: ci-block — refreshes both generated workflow files via `em ci init`'s own
158
+ // plan/apply, reusing whatever <model>/--tests arguments the existing em-ci.yml was already
159
+ // generated with (extracted from its own coverage step — never guessed, never re-prompted).
160
+ // Only touches a file that already carries the GENERATED markers; never creates one from
161
+ // scratch (module header / ticket: "never creates a workflow the repo didn't ask for"). ----
162
+ // Not anchored on a literal "em coverage" — the generated line pins an exact version
163
+ // (`npx @milehimikey/em@1.9.0 coverage "..."`, ciInit.ts's own `em` template variable), so
164
+ // "em" and "coverage" are never adjacent in the real file.
165
+ const CI_INIT_ARGS_RE = /\bcoverage "([^"]*)" --tests "([^"]*)" --strict\b/;
166
+ function extractCiInitArgs(emCiContent) {
167
+ const m = CI_INIT_ARGS_RE.exec(emCiContent);
168
+ return m ? { model: m[1], testsDir: m[2] } : null;
169
+ }
170
+ function ciBlockPlans(ctx) {
171
+ const ciPath = ciWorkflowPath(ctx.repoRoot);
172
+ const conformPath = conformWorkflowPath(ctx.repoRoot);
173
+ if (!existsSync(ciPath))
174
+ return { ciPath, ciStale: false, conformPath, conformStale: false, args: null };
175
+ const args = extractCiInitArgs(readFileSync(ciPath, "utf8"));
176
+ if (!args)
177
+ return { ciPath, ciStale: false, conformPath, conformStale: false, args: null };
178
+ const ciStatus = planCiFile(ciPath, buildCiWorkflowFile(args.model, args.testsDir, ctx.installedVersion), ciManagedBody(args.model, args.testsDir, ctx.installedVersion), CI_WORKFLOW_MARKER, false);
179
+ const ciStale = ciStatus.kind === "stale";
180
+ let conformStale = false;
181
+ if (existsSync(conformPath)) {
182
+ const conformStatus = planCiFile(conformPath, buildConformWorkflowFile(args.model, ctx.installedVersion), conformManagedBody(args.model, ctx.installedVersion), CONFORM_WORKFLOW_MARKER, false);
183
+ conformStale = conformStatus.kind === "stale";
184
+ }
185
+ return { ciPath, ciStale, conformPath, conformStale, args };
186
+ }
187
+ function detectCiBlock(ctx) {
188
+ const { ciPath, ciStale, conformStale, args } = ciBlockPlans(ctx);
189
+ if (!existsSync(ciPath))
190
+ return { applicable: false, reason: "no .github/workflows/em-ci.yml — em upgrade never creates one" };
191
+ if (!args)
192
+ return { applicable: false, reason: "can't determine the <model>/--tests arguments em-ci.yml was generated with — run `em ci init <model>` by hand if it needs refreshing" };
193
+ if (!ciStale && !conformStale)
194
+ return { applicable: false, reason: "generated CI block(s) already match the installed em" };
195
+ return { applicable: true, reason: "generated CI block(s) are stale" };
196
+ }
197
+ function applyCiBlock(ctx) {
198
+ const { ciPath, ciStale, conformPath, conformStale, args } = ciBlockPlans(ctx);
199
+ if (!args || (!ciStale && !conformStale))
200
+ return { ok: false, message: "nothing to refresh" };
201
+ const changedFiles = [];
202
+ if (ciStale) {
203
+ const status = planCiFile(ciPath, buildCiWorkflowFile(args.model, args.testsDir, ctx.installedVersion), ciManagedBody(args.model, args.testsDir, ctx.installedVersion), CI_WORKFLOW_MARKER, false);
204
+ applyCiFile(ciPath, status);
205
+ changedFiles.push(ciPath);
206
+ }
207
+ if (conformStale) {
208
+ const status = planCiFile(conformPath, buildConformWorkflowFile(args.model, ctx.installedVersion), conformManagedBody(args.model, ctx.installedVersion), CONFORM_WORKFLOW_MARKER, false);
209
+ applyCiFile(conformPath, status);
210
+ changedFiles.push(conformPath);
211
+ }
212
+ return { ok: true, changedFiles };
213
+ }
214
+ // ---- Step 5: constitution — scaffold a draft when absent and no .specify/ owns the slot. ----
215
+ function detectConstitution(ctx) {
216
+ const path = join(ctx.baseDir, "constitution.md");
217
+ if (existsSync(path))
218
+ return { applicable: false, reason: "constitution.md already exists" };
219
+ const specifyRoot = findSpecifyRoot(ctx.baseDir);
220
+ if (specifyRoot) {
221
+ return {
222
+ applicable: false,
223
+ human: true,
224
+ reason: `no constitution.md, but ${join(specifyRoot, ".specify")} exists — spec-kit owns the constitution slot (.specify/memory/constitution.md); decide by hand whether it needs writing`,
225
+ };
226
+ }
227
+ return { applicable: true, reason: "no constitution.md and no .specify/ — em upgrade will scaffold a draft" };
228
+ }
229
+ function applyConstitution(ctx) {
230
+ const path = join(ctx.baseDir, "constitution.md");
231
+ if (existsSync(path))
232
+ return { ok: false, message: "constitution.md already exists" };
233
+ if (findSpecifyRoot(ctx.baseDir))
234
+ return { ok: false, message: ".specify/ exists — not scaffolding a second constitution" };
235
+ writeFileSync(path, scaffoldConstitution(ctx.model.name));
236
+ return { ok: true, changedFiles: [path] };
237
+ }
238
+ export const UPGRADE_STEPS = [
239
+ { id: "skill-bundle", sinceVersion: "1.7.0", detect: detectSkillBundle, apply: applySkillBundle },
240
+ { id: "reaction-shape", sinceVersion: "1.8.0", detect: detectReactionShape, apply: applyReactionShape },
241
+ { id: "state-file", sinceVersion: "1.13.0", detect: detectStateFile, apply: applyStateFile },
242
+ { id: "ci-block", sinceVersion: "1.9.0", detect: detectCiBlock, apply: applyCiBlock },
243
+ { id: "constitution", sinceVersion: "1.11.0", detect: detectConstitution, apply: applyConstitution },
244
+ ];
245
+ function elementRefOf(ctx) {
246
+ return (id) => ctx.refs.refById.get(id);
247
+ }
248
+ /** Every non-continuation slice's doc join — computed once, shared by every human detector below
249
+ * that needs a doc's `status`/`ratifiedBy` (mirrors `modelVersion.ts`'s `computeSlicesVector`
250
+ * exclusion of continuation slices, MIL-208: a continuation's own join already resolves to its
251
+ * originating slice's doc, so counting it again here would double-count). */
252
+ function nonContinuationDocs(ctx) {
253
+ const results = [];
254
+ ctx.model.slices.forEach((slice, i) => {
255
+ const key = ctx.refs.sliceKeys[i];
256
+ const { doc, continuationOf } = resolveSliceDocJoin(ctx.model, ctx.refs, slice, key, ctx.baseDir, elementRefOf(ctx));
257
+ if (continuationOf !== null)
258
+ return;
259
+ results.push({ key, status: doc.status, ratifiedBy: doc.ratifiedBy });
260
+ });
261
+ return results;
262
+ }
263
+ function detectNoModelVersion(ctx) {
264
+ const loaded = loadStateFile(ctx.baseDir);
265
+ if (!loaded.ok)
266
+ return null;
267
+ const parsed = parseState(loaded.text);
268
+ if (!parsed.ok || parsed.state.modelVersion !== null)
269
+ return null;
270
+ const hasImplemented = nonContinuationDocs(ctx).some((d) => d.status === "implemented");
271
+ if (!hasImplemented)
272
+ return null;
273
+ return {
274
+ id: "no-model-version",
275
+ reason: "Model version: none, but at least one slice is implemented — run `em model version bump --by <name>` to start tracking design versions",
276
+ };
277
+ }
278
+ function detectContinuationHasOwnDoc(ctx) {
279
+ const diags = validateOrphanedSliceDocs(ctx.model, ctx.refs, ctx.baseDir);
280
+ const count = diags.filter((d) => d.code === "continuation-has-own-doc").length;
281
+ if (count === 0)
282
+ return null;
283
+ return {
284
+ id: "continuation-has-own-doc",
285
+ reason: `${count} continuation slice(s) still carry their own doc file instead of sharing their originating slice's — see \`em validate\`'s continuation-has-own-doc warning(s)`,
286
+ };
287
+ }
288
+ function detectReadyNoRatifiedBy(ctx) {
289
+ const keys = nonContinuationDocs(ctx)
290
+ .filter((d) => d.status === "ready-to-implement" && !d.ratifiedBy)
291
+ .map((d) => d.key)
292
+ .sort();
293
+ if (keys.length === 0)
294
+ return null;
295
+ return {
296
+ id: "ready-to-implement-no-ratifiedby",
297
+ reason: `${keys.length} ready-to-implement doc(s) with no ratifiedBy: ${keys.join(", ")} — run \`em slice ratify --by <name>\` on each`,
298
+ };
299
+ }
300
+ function detectCoverageScopeDefault(ctx) {
301
+ const ciPath = ciWorkflowPath(ctx.repoRoot);
302
+ if (!existsSync(ciPath))
303
+ return null;
304
+ const content = readFileSync(ciPath, "utf8");
305
+ if (!/\bcoverage\b[^\n]*--strict\b/.test(content))
306
+ return null;
307
+ const anyImplemented = nonContinuationDocs(ctx).some((d) => d.status === "implemented");
308
+ if (anyImplemented)
309
+ return null;
310
+ return {
311
+ id: "coverage-scope-default",
312
+ reason: "em-ci.yml runs `em coverage --strict`, but no slice doc is status: implemented yet (MIL-207 scopes --strict to implemented docs only) — the gate is trivially green until the first slice is marked implemented",
313
+ };
314
+ }
315
+ function detectUnratifiedConstitution(ctx) {
316
+ const specifyRoot = findSpecifyRoot(ctx.baseDir);
317
+ const path = specifyRoot ? join(specifyRoot, ".specify", "memory", "constitution.md") : join(ctx.baseDir, "constitution.md");
318
+ if (!existsSync(path))
319
+ return null;
320
+ const content = readFileSync(path, "utf8");
321
+ const inner = locateFrontmatterInner(content);
322
+ if (!inner)
323
+ return null;
324
+ const innerText = content.slice(inner.innerStart, inner.innerEnd);
325
+ const m = fieldLineRegex("ratifiedBy").exec(innerText);
326
+ const value = m ? normalizeFieldValue(m[2]) : null;
327
+ if (value !== null)
328
+ return null;
329
+ return { id: "unratified-constitution", reason: `${path} has no ratifiedBy: — it's still a draft` };
330
+ }
331
+ function detectPredates16(ctx) {
332
+ const plan = readMigrationPlan(ctx);
333
+ if (!plan || plan.refusals.length === 0)
334
+ return null;
335
+ return {
336
+ id: "predates-1.6",
337
+ reason: `${plan.refusals.length} old-shape reaction site(s) can't be auto-migrated — run \`em migrate\` by hand, resolve the refusal(s), then re-run \`em upgrade\``,
338
+ };
339
+ }
340
+ const HUMAN_DETECTORS = [
341
+ detectNoModelVersion,
342
+ detectContinuationHasOwnDoc,
343
+ detectReadyNoRatifiedBy,
344
+ detectCoverageScopeDefault,
345
+ detectUnratifiedConstitution,
346
+ detectPredates16,
347
+ ];
348
+ export function detectHumanItems(ctx) {
349
+ return HUMAN_DETECTORS.map((d) => d(ctx)).filter((x) => x !== null);
350
+ }
351
+ const EM_VERSION_STAMP_RE = /^em-version:\s*(.+)$/m;
352
+ /** `Em version:` if recorded; else a best-effort inference from artifacts already on disk, with
353
+ * the basis always stated so the output never claims false precision. Never throws — a repo
354
+ * with no evidence at all reads as "unknown", same sentinel the bullet itself uses. */
355
+ export function resolveFromVersion(ctx, recorded) {
356
+ if (recorded !== null)
357
+ return { version: recorded, inferred: false, basis: "recorded `Em version:` bullet" };
358
+ const reactionPlan = readMigrationPlan(ctx);
359
+ if (reactionPlan && (reactionPlan.changes.length > 0 || reactionPlan.refusals.length > 0)) {
360
+ return { version: UPGRADE_MIN_SUPPORTED_VERSION, inferred: true, basis: "old two-slice Automation/Translation reaction shape (pre-1.7.1) found in the model" };
361
+ }
362
+ const skillMdPath = join(vendoredSkillsRootOf(ctx.repoRoot), EM_SKILL_ANCHOR_DIR, "SKILL.md");
363
+ if (existsSync(skillMdPath)) {
364
+ const m = EM_VERSION_STAMP_RE.exec(readFileSync(skillMdPath, "utf8"));
365
+ if (m)
366
+ return { version: m[1].trim(), inferred: true, basis: "vendored skill bundle's em-version: stamp" };
367
+ }
368
+ const loaded = loadStateFile(ctx.baseDir);
369
+ if (loaded.ok) {
370
+ const hasMil218Bullets = /^-\s+\*\*Model version:\*\*/m.test(loaded.text) || /^-\s+\*\*Certified:\*\*/m.test(loaded.text);
371
+ if (hasMil218Bullets)
372
+ return { version: "1.13.0", inferred: true, basis: "state file already carries Model version:/Certified: bullets (MIL-218)" };
373
+ }
374
+ return { version: "unknown", inferred: true, basis: "no version evidence found (no Em version: bullet, no skill stamp, no MIL-218 bullets, no old reaction shape)" };
375
+ }
376
+ // ---- git plumbing for `--apply` ----
377
+ export function resolveRepoRoot(anchorDir, runGit = realGit) {
378
+ const r = runGit(["-C", anchorDir, "rev-parse", "--show-toplevel"]);
379
+ if (r.status !== 0)
380
+ return { ok: false, message: `em upgrade: ${anchorDir} is not inside a git repository — em upgrade --apply needs one commit per step` };
381
+ return { ok: true, repoRoot: r.stdout.trim() };
382
+ }
383
+ export function isWorkingTreeClean(repoRoot, runGit = realGit) {
384
+ const r = runGit(["-C", repoRoot, "status", "--porcelain"]);
385
+ return r.status === 0 && r.stdout.trim().length === 0;
386
+ }
387
+ /** `true` when `git commit` in `repoRoot` would actually succeed identity-wise — `git config
388
+ * user.name`/`user.email` (the merged local+global+system view, same one `git commit` itself
389
+ * consults) both resolve to something non-empty. Checked once, up front, alongside the
390
+ * dirty-tree refusal: failing here with a clear, single message beats discovering it deep into
391
+ * step 1's own `git commit` with a confusing passthrough error, and it's a real gap to check —
392
+ * a CI runner (unlike a developer's own machine) routinely has no git identity configured at
393
+ * all. */
394
+ export function hasGitIdentity(repoRoot, runGit = realGit) {
395
+ const name = runGit(["-C", repoRoot, "config", "user.name"]);
396
+ const email = runGit(["-C", repoRoot, "config", "user.email"]);
397
+ return name.status === 0 && name.stdout.trim().length > 0 && email.status === 0 && email.stdout.trim().length > 0;
398
+ }
399
+ function gitCommitAll(repoRoot, message, runGit) {
400
+ const add = runGit(["-C", repoRoot, "add", "-A"]);
401
+ if (add.status !== 0)
402
+ return { ok: false, message: `git add failed: ${(add.stderr || "").trim() || "unknown error"}` };
403
+ const commit = runGit(["-C", repoRoot, "commit", "-m", message]);
404
+ if (commit.status !== 0)
405
+ return { ok: false, message: `git commit failed: ${(commit.stderr || "").trim() || "unknown error"}` };
406
+ return { ok: true };
407
+ }
408
+ /** Discards every uncommitted change in `repoRoot` — tracked and untracked alike. Only ever
409
+ * called right after a step's `apply` reports failure, to restore the "clean before the next
410
+ * step" invariant `isWorkingTreeClean`'s pre-flight check depends on; safe precisely because
411
+ * that pre-flight check already proved the tree was clean before this run started, so anything
412
+ * dirty now was written by the step that just failed. */
413
+ function gitDiscardAll(repoRoot, runGit) {
414
+ runGit(["-C", repoRoot, "checkout", "--", "."]);
415
+ runGit(["-C", repoRoot, "clean", "-fd", "."]);
416
+ }
417
+ /** Dry-run: detect every step and every human item, apply nothing. Shared by `--json`, plain
418
+ * text output, `--check`, and the first phase of `--apply`. */
419
+ export function detectUpgrade(ctx) {
420
+ const loaded = loadStateFile(ctx.baseDir);
421
+ let recorded = null;
422
+ // MIL-257: an ABSENT state file is no longer an error — the `state-file` step scaffolds it — so
423
+ // `stateFileError` is `null` for it (the pending step's own reason carries the detail). It is
424
+ // set only for a file that exists but doesn't parse, and now names the file.
425
+ let stateFileError = null;
426
+ if (loaded.ok) {
427
+ const parsed = parseState(loaded.text);
428
+ if (!parsed.ok)
429
+ stateFileError = describeStateFileFailure(loaded.path, parsed.message);
430
+ else
431
+ recorded = parsed.state.emVersion;
432
+ }
433
+ const from = resolveFromVersion(ctx, recorded);
434
+ const steps = UPGRADE_STEPS.map((s) => {
435
+ const d = s.detect(ctx);
436
+ return { id: s.id, sinceVersion: s.sinceVersion, applicable: d.applicable, human: d.human === true, reason: d.reason };
437
+ });
438
+ const human = detectHumanItems(ctx);
439
+ return { from, to: ctx.installedVersion, steps, human, stateFileError };
440
+ }
441
+ /**
442
+ * `--apply`: detect, then apply every applicable mechanical step in fixed order, one commit
443
+ * each (`em upgrade: <step-id> (<from> → <to>)`), stopping at the first failure with every
444
+ * prior commit intact and the failed step's own partial writes discarded. On full success,
445
+ * writes `Em version: <to>` as one final commit — always, even when every step above was a
446
+ * no-op, UNLESS the bullet already reads `<to>` (idempotent second run makes zero commits).
447
+ * Refuses outright on a dirty starting working tree.
448
+ */
449
+ export function applyUpgrade(ctx, runGit = realGit) {
450
+ const report = detectUpgrade(ctx);
451
+ if (report.stateFileError) {
452
+ return { ok: false, message: `em upgrade: unparseable state file — ${report.stateFileError}`, report, applied: [] };
453
+ }
454
+ if (!isWorkingTreeClean(ctx.repoRoot, runGit)) {
455
+ return { ok: false, message: "em upgrade --apply: working tree is not clean — commit or stash first", report, applied: [] };
456
+ }
457
+ if (!hasGitIdentity(ctx.repoRoot, runGit)) {
458
+ return {
459
+ ok: false,
460
+ message: "em upgrade --apply: no git identity configured — run `git config user.name <name>` and " +
461
+ "`git config user.email <email>` first (add --global to set it once for every repo)",
462
+ report,
463
+ applied: [],
464
+ };
465
+ }
466
+ const applied = [];
467
+ for (const step of UPGRADE_STEPS) {
468
+ const detection = step.detect(ctx);
469
+ if (!detection.applicable) {
470
+ applied.push({ id: step.id, applied: false, changedFiles: [], commit: null });
471
+ continue;
472
+ }
473
+ const result = step.apply(ctx);
474
+ if (!result.ok) {
475
+ gitDiscardAll(ctx.repoRoot, runGit);
476
+ return { ok: false, message: `em upgrade: step "${step.id}" failed — ${result.message}`, report, applied };
477
+ }
478
+ const message = `em upgrade: ${step.id} (${report.from.version} → ${report.to})`;
479
+ const commitResult = gitCommitAll(ctx.repoRoot, message, runGit);
480
+ if (!commitResult.ok) {
481
+ return { ok: false, message: `em upgrade: step "${step.id}" applied but failed to commit — ${commitResult.message}`, report, applied };
482
+ }
483
+ applied.push({ id: step.id, applied: true, changedFiles: result.changedFiles, commit: message });
484
+ }
485
+ const loaded = loadStateFile(ctx.baseDir);
486
+ let emVersionCommit = null;
487
+ if (loaded.ok) {
488
+ const today = localIsoDate();
489
+ const stamped = setEmVersion(loaded.text, ctx.installedVersion, today);
490
+ if (stamped.ok && stamped.text !== loaded.text) {
491
+ writeFileSync(loaded.path, stamped.text);
492
+ const message = `em upgrade: em-version (${report.from.version} → ${report.to})`;
493
+ const commitResult = gitCommitAll(ctx.repoRoot, message, runGit);
494
+ if (!commitResult.ok) {
495
+ return { ok: false, message: `em upgrade: writing Em version: failed to commit — ${commitResult.message}`, report, applied };
496
+ }
497
+ emVersionCommit = message;
498
+ }
499
+ }
500
+ return { ok: true, report, applied, emVersionCommit };
501
+ }
502
+ /** MIL-257: every cause that makes `--check` exit 1, each as one sentence, so the final line
503
+ * always says why. Empty when there is no hard incompatibility. */
504
+ export function hardIncompatibilityReasons(report) {
505
+ const reasons = [];
506
+ if (report.stateFileError !== null)
507
+ reasons.push(report.stateFileError);
508
+ for (const h of report.human)
509
+ if (h.id === "predates-1.6")
510
+ reasons.push(`predates-1.6: ${h.reason}`);
511
+ return reasons;
512
+ }
513
+ /** `--check` (what CI runs): exit-worthiness only — no writes. Hard incompatibilities are the
514
+ * ONLY thing that makes this fail: a state file that exists but is unparseable (a MISSING one is
515
+ * scaffolded by the `state-file` step, MIL-257, so it is a pending step, not a failure), or a
516
+ * `predates-1.6` human item (an old reaction shape `em migrate` itself refuses to touch). Every
517
+ * other human item — including the ordinary "some steps are applicable" case — is advisory, same
518
+ * as running `em upgrade` without `--apply` at all. `reasons` (MIL-257) is why `ok` is false. */
519
+ export function checkUpgrade(ctx) {
520
+ const report = detectUpgrade(ctx);
521
+ const reasons = hardIncompatibilityReasons(report);
522
+ return { ok: reasons.length === 0, report, reasons };
523
+ }
524
+ //# sourceMappingURL=upgrade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../src/cli/upgrade.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,gGAAgG;AAChG,2FAA2F;AAC3F,iGAAiG;AACjG,iGAAiG;AACjG,gGAAgG;AAChG,UAAU;AACV,EAAE;AACF,+FAA+F;AAC/F,8FAA8F;AAC9F,8FAA8F;AAC9F,4FAA4F;AAC5F,gGAAgG;AAChG,0FAA0F;AAC1F,8FAA8F;AAC9F,EAAE;AACF,8FAA8F;AAC9F,iGAAiG;AACjG,gGAAgG;AAChG,8FAA8F;AAC9F,qFAAqF;AACrF,2FAA2F;AAC3F,0DAA0D;AAE1D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGpD,OAAO,EAAa,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAiB,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,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