@decantr/essence-spec 1.0.8 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,9 +15,9 @@ npm install @decantr/essence-spec
15
15
 
16
16
  - `validateEssence()` for schema validation
17
17
  - `evaluateGuard()` for contract/guard checks
18
- - `normalizeEssence()` for version normalization
19
- - `migrateV2ToV3()` and `migrateV30ToV31()` for structured migrations
20
- - Decantr essence TypeScript types
18
+ - `normalizeEssence()` for active Essence v4 normalization
19
+ - `migrateToV4()` for the explicit legacy migration path
20
+ - Decantr Essence v4 TypeScript types
21
21
 
22
22
  ## Example
23
23
 
@@ -34,12 +34,12 @@ const violations = evaluateGuard(essence, {});
34
34
 
35
35
  ## Schema Exports
36
36
 
37
- - `@decantr/essence-spec/schema/essence.v2.json`
38
- - `@decantr/essence-spec/schema/essence.v3.json`
37
+ - `@decantr/essence-spec/schema/essence.v4.json`
38
+ - `@decantr/essence-spec/schema/essence.v2.json` and `essence.v3.json` remain archived references for migration tooling only
39
39
 
40
40
  ## Compatibility
41
41
 
42
- `@decantr/essence-spec` now defines a stable public contract for Decantr essence validation and migration in the `1.x` line.
42
+ `@decantr/essence-spec` defines the active Essence v4 public contract for Decantr V2. Runtime validation accepts v4 only; older Essence v2/v3 files are supported through `decantr migrate --to v4`.
43
43
 
44
44
  - additive schema fields may be introduced in compatible minor releases
45
45
  - breaking schema or migration behavior changes require a major version
package/dist/index.d.ts CHANGED
@@ -1,11 +1,9 @@
1
1
  /**
2
- * Essence v2 schema types — normalized terminology.
2
+ * Essence v4 active contract types.
3
3
  *
4
- * Terminology mapping (v1 wine terms v2 normalized):
5
- * terroir archetype, vintage theme, tannins features,
6
- * carafe shell, cork → guard, blend → layout, clarity → density,
7
- * vessel → platform, character → personality,
8
- * decantation process → essence pipeline
4
+ * Decantr V2 treats Essence v4 as the only active runtime contract. Older
5
+ * Essence v2/v3 document shapes remain modeled only so `decantr migrate --to v4`
6
+ * can upgrade existing projects.
9
7
  */
10
8
  type ThemeStyle = 'auradecantism' | 'clean' | 'glassmorphism' | 'retro' | 'bioluminescent' | 'launchpad' | 'dopamine' | 'editorial' | 'liquid-glass' | 'prismatic';
11
9
  type ThemeMode = 'light' | 'dark' | 'auto';
@@ -121,7 +119,7 @@ interface Essence {
121
119
  accessibility?: Accessibility;
122
120
  _impression?: Impression;
123
121
  }
124
- interface EssenceSection {
122
+ interface LegacyEssenceSection {
125
123
  id: string;
126
124
  path: string;
127
125
  archetype: string;
@@ -134,7 +132,7 @@ interface SectionedEssence {
134
132
  version: string;
135
133
  platform: Platform;
136
134
  personality: string[];
137
- sections: EssenceSection[];
135
+ sections: LegacyEssenceSection[];
138
136
  shared_features?: string[];
139
137
  density: Density;
140
138
  guard: Guard;
@@ -220,7 +218,7 @@ interface SectionNavigationItem {
220
218
  active_match?: string;
221
219
  badge?: string;
222
220
  }
223
- interface EssenceV31Section {
221
+ interface EssenceSection {
224
222
  id: string;
225
223
  role: ArchetypeRole;
226
224
  shell: ShellType | string;
@@ -243,20 +241,21 @@ interface RouteEntry {
243
241
  }
244
242
  interface EssenceBlueprint {
245
243
  shell?: ShellType | string;
246
- sections?: EssenceV31Section[];
244
+ sections: EssenceSection[];
245
+ /** Migration-only compatibility. Active v4 documents are sectioned-only. */
247
246
  pages?: BlueprintPage[];
248
247
  features: string[];
249
248
  routes?: Record<string, RouteEntry>;
250
249
  icon_style?: string;
251
250
  avatar_style?: string;
252
251
  }
253
- interface EssenceV3Guard {
252
+ interface EssenceV4Guard {
254
253
  mode: GuardMode;
255
254
  dna_enforcement: 'error' | 'warn' | 'off';
256
255
  blueprint_enforcement: 'warn' | 'off';
257
256
  /**
258
- * v2.1 C5. Severity for the experiential interactions guard rule (8th
259
- * rule). When patterns declare `interactions: [...]` but the source
257
+ * Severity for the experiential interactions guard rule. When patterns
258
+ * declare `interactions: [...]` but the source
260
259
  * tree is missing the canonical implementations, this controls whether
261
260
  * the violation is an error, warning, or ignored.
262
261
  *
@@ -269,7 +268,7 @@ interface EssenceMeta {
269
268
  archetype: string;
270
269
  target: GeneratorTarget;
271
270
  platform: Platform;
272
- guard: EssenceV3Guard;
271
+ guard: EssenceV4Guard;
273
272
  seo?: {
274
273
  schema_org?: string[];
275
274
  meta_priorities?: string[];
@@ -315,26 +314,31 @@ interface HotkeySemantics {
315
314
  /** If true: hotkey matching is case-sensitive. Default false — uppercase implies Shift. */
316
315
  match_case?: boolean;
317
316
  /**
318
- * v2.1 C3. If true (default): render the .d-hotkey-indicator corner badge
319
- * when a chord hotkey prefix is armed. If false: silent chord tracking
320
- * (no visual feedback). Recommended true for discoverability.
317
+ * If true (default): render the .d-hotkey-indicator corner badge when a chord
318
+ * hotkey prefix is armed. If false: silent chord tracking (no visual feedback).
319
+ * Recommended true for discoverability.
321
320
  */
322
321
  show_chord_indicator?: boolean;
323
322
  }
324
- interface EssenceV3 {
323
+ interface EssenceV4 {
325
324
  $schema?: string;
326
- version: '3.0.0' | '3.1.0';
325
+ version: '4.0.0';
327
326
  dna: EssenceDNA;
328
327
  blueprint: EssenceBlueprint;
329
328
  meta: EssenceMeta;
330
329
  _impression?: Impression;
331
330
  }
332
- type EssenceFile = Essence | SectionedEssence | EssenceV3;
333
- declare function isV3(essence: EssenceFile): essence is EssenceV3;
331
+ type LegacyEssenceV3 = Omit<EssenceV4, 'version'> & {
332
+ version: '3.0.0' | '3.1.0';
333
+ };
334
+ type EssenceFile = EssenceV4;
335
+ type LegacyEssenceFile = Essence | SectionedEssence | LegacyEssenceV3 | EssenceV4;
336
+ declare function isV4(essence: unknown): essence is EssenceV4;
337
+ declare function isLegacyV3(essence: unknown): essence is LegacyEssenceV3;
334
338
  /** Flatten sections into a flat page list (for guards and backward compat). */
335
339
  declare function flattenPages(blueprint: EssenceBlueprint): BlueprintPage[];
336
- declare function isSectioned(essence: EssenceFile): essence is SectionedEssence;
337
- declare function isSimple(essence: EssenceFile): essence is Essence;
340
+ declare function isSectioned(essence: unknown): essence is SectionedEssence;
341
+ declare function isSimple(essence: unknown): essence is Essence;
338
342
 
339
343
  interface SpatialHints {
340
344
  density_bias?: number;
@@ -350,7 +354,7 @@ interface AutoFix {
350
354
  interface GuardViolation {
351
355
  rule: 'theme' | 'structure' | 'layout' | 'density' | 'theme-mode' | 'pattern-exists' | 'accessibility'
352
356
  /**
353
- * v2.1 C5. Experiential interactions guard rule. Fires when patterns
357
+ * V4 C5. Experiential interactions guard rule. Fires when patterns
354
358
  * declare `interactions: [...]` but the source tree is missing the
355
359
  * canonical implementations. Severity controlled by
356
360
  * `meta.guard.interactions_enforcement` (defaults: creative=off,
@@ -377,7 +381,7 @@ interface GuardContext {
377
381
  patternRegistry?: Map<string, unknown>;
378
382
  a11y_issues?: string[];
379
383
  /**
380
- * v2.1 C5. Pre-computed list of declared interactions whose canonical
384
+ * V4 C5. Pre-computed list of declared interactions whose canonical
381
385
  * implementations are missing from the source tree. Produced by
382
386
  * `verifyInteractionsInSource` from @decantr/verifier; passed in here
383
387
  * so the guard rule can emit violations without owning the source-scan
@@ -391,15 +395,10 @@ interface GuardContext {
391
395
  declare function evaluateGuard(essence: EssenceFile, context?: GuardContext): GuardViolation[];
392
396
 
393
397
  /**
394
- * Migrate a v2 EssenceFile to v3 format (DNA/Blueprint/Meta split).
395
- * If already v3, returns unchanged. SectionedEssence uses first section's theme.
396
- */
397
- declare function migrateV2ToV3(essence: EssenceFile): EssenceV3;
398
- /**
399
- * Migrate a v3.0 flat-page EssenceV3 to v3.1 sectioned format.
400
- * If already v3.1 or has blueprint.sections, returns unchanged.
398
+ * Explicit legacy-to-v4 migration path used by `decantr migrate --to v4`.
399
+ * Active Decantr V2 commands do not call this implicitly.
401
400
  */
402
- declare function migrateV30ToV31(essence: EssenceV3): EssenceV3;
401
+ declare function migrateToV4(input: unknown): EssenceV4;
403
402
 
404
403
  declare function normalizeEssence(input: Record<string, unknown>): EssenceFile;
405
404
 
@@ -408,5 +407,6 @@ interface ValidationResult {
408
407
  errors: string[];
409
408
  }
410
409
  declare function validateEssence(data: unknown): ValidationResult;
410
+ declare function validateLegacyEssenceForMigration(data: unknown): ValidationResult;
411
411
 
412
- export { type Accessibility, type ArchetypeRole, type AutoFix, type BlueprintPage, type ColumnLayout, type CvdPreference, type DNAOverrides, type Density, type DensityLevel, type Essence, type EssenceBlueprint, type EssenceDNA, type EssenceFile, type EssenceMeta, type EssenceSection, type EssenceV3, type EssenceV31Section, type EssenceV3Guard, type GeneratorTarget, type Guard, type GuardContext, type GuardMode, type GuardViolation, type Impression, type LayoutItem, type PatternRef, type Platform, type PlatformType, type RouteEntry, type RoutingStrategy, type SectionedEssence, type ShellGuidance, type ShellType, type SpatialTokenHints, type SpatialTokens, type StructurePage, type Theme, type ThemeMode, type ThemeShape, type ThemeStyle, type ValidationResult, type WcagLevel, computeDensity, computeSpatialTokens, evaluateGuard, flattenPages, getColumnAlias, getColumnId, getColumnPreset, isSectioned, isSimple, isV3, migrateV2ToV3, migrateV30ToV31, normalizeEssence, validateEssence };
412
+ export { type Accessibility, type ArchetypeRole, type AutoFix, type BlueprintPage, type ColumnLayout, type CvdPreference, type DNAOverrides, type Density, type DensityLevel, type Essence, type EssenceBlueprint, type EssenceDNA, type EssenceFile, type EssenceMeta, type EssenceSection, type EssenceV4, type EssenceV4Guard, type GeneratorTarget, type Guard, type GuardContext, type GuardMode, type GuardViolation, type Impression, type LayoutItem, type LegacyEssenceFile, type LegacyEssenceV3, type PatternRef, type Platform, type PlatformType, type RouteEntry, type RoutingStrategy, type SectionedEssence, type ShellGuidance, type ShellType, type SpatialTokenHints, type SpatialTokens, type StructurePage, type Theme, type ThemeMode, type ThemeShape, type ThemeStyle, type ValidationResult, type WcagLevel, computeDensity, computeSpatialTokens, evaluateGuard, flattenPages, getColumnAlias, getColumnId, getColumnPreset, isLegacyV3, isSectioned, isSimple, isV4, migrateToV4, normalizeEssence, validateEssence, validateLegacyEssenceForMigration };