@decantr/core 1.0.1 → 1.0.3

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { EssenceFile, EssenceV3, StructurePage } from '@decantr/essence-spec';
2
- import { ContentResolver, Pattern, ResolvedPreset, Theme } from '@decantr/registry';
1
+ import { StructurePage, EssenceFile, EssenceV3 } from '@decantr/essence-spec';
2
+ import { Pattern, ResolvedPreset, Theme, ContentResolver } from '@decantr/registry';
3
3
 
4
4
  type IRNodeType = 'app' | 'shell' | 'page' | 'pattern' | 'grid' | 'nav' | 'store';
5
5
  interface IRSpatial {
@@ -35,6 +35,17 @@ interface IRPatternMeta {
35
35
  example?: string;
36
36
  } | null;
37
37
  components: string[];
38
+ /**
39
+ * Per-preset prose from pattern.presets[preset].description. Threaded
40
+ * into PagePackPattern so the page-pack renderer can emit preset-specific
41
+ * guidance instead of the blueprint-generic pattern root description.
42
+ */
43
+ presetDescription?: string;
44
+ /**
45
+ * v2.1 Tier C1. Declared runtime interactions from the pattern JSON.
46
+ * Page-pack renderer surfaces these as a checkbox checklist.
47
+ */
48
+ interactions?: string[];
38
49
  }
39
50
  interface IRVisualEffect {
40
51
  decorators: string[];
@@ -137,6 +148,24 @@ interface IRStoreNode extends IRNode {
137
148
  }[];
138
149
  }
139
150
 
151
+ interface ResolvedPatternEntry {
152
+ pattern: Pattern;
153
+ preset: ResolvedPreset;
154
+ }
155
+ /** Build IR tree for a single page from its resolved structure + patterns */
156
+ declare function buildPageIR(page: StructurePage, resolvedPatterns: Map<string, ResolvedPatternEntry>, wiring: IRWiring | null, theme: Theme | null, density: {
157
+ gap: string;
158
+ }, layer?: IRLayer): IRPageNode;
159
+
160
+ /** Depth-first walk of IR tree, calling visitor on each node */
161
+ declare function walkIR(node: IRNode, visitor: (node: IRNode, parent: IRNode | null) => void, parent?: IRNode | null): void;
162
+ /** Find all nodes of a specific type */
163
+ declare function findNodes<T extends IRNode>(root: IRNode, type: string): T[];
164
+ /** Count total patterns in an IR tree */
165
+ declare function countPatterns(root: IRNode): number;
166
+ /** Validate IR tree structure (no orphaned grids, patterns have meta, etc.) */
167
+ declare function validateIR(root: IRNode): string[];
168
+
140
169
  type ExecutionPackType = 'scaffold' | 'section' | 'page' | 'mutation' | 'review';
141
170
  declare const EXECUTION_PACK_SCHEMA_URLS: {
142
171
  readonly scaffold: "https://decantr.ai/schemas/scaffold-pack.v1.json";
@@ -238,15 +267,43 @@ interface ScaffoldPackData {
238
267
  routing: 'hash' | 'history' | 'pathname';
239
268
  features: string[];
240
269
  navigation?: {
241
- commandPalette: boolean;
270
+ /**
271
+ * true = palette enabled with implicit defaults.
272
+ * false = not enabled.
273
+ * object = explicit structured contract (see CommandPaletteContract).
274
+ */
275
+ commandPalette: boolean | CommandPaletteContract;
242
276
  hotkeys: Array<{
243
277
  key: string;
244
278
  route?: string;
245
279
  label?: string;
280
+ semantics?: HotkeySemantics;
246
281
  }>;
282
+ /** Default hotkey semantics applied unless per-hotkey semantics override. */
283
+ hotkeySemantics?: HotkeySemantics;
247
284
  };
248
285
  routes: ScaffoldPackRoute[];
249
286
  }
287
+ interface CommandPaletteContract {
288
+ trigger?: string;
289
+ placeholder?: string;
290
+ width?: string;
291
+ styling?: 'modal' | 'sheet' | 'inline' | 'fullscreen';
292
+ commands?: Array<{
293
+ id: string;
294
+ label: string;
295
+ section?: string;
296
+ hotkey?: string;
297
+ action?: string;
298
+ route?: string;
299
+ }>;
300
+ }
301
+ interface HotkeySemantics {
302
+ chord_window_ms?: number;
303
+ input_guard?: boolean;
304
+ modifier_suppression?: boolean;
305
+ match_case?: boolean;
306
+ }
250
307
  interface ScaffoldExecutionPack extends ExecutionPackBase<ScaffoldPackData> {
251
308
  packType: 'scaffold';
252
309
  }
@@ -257,6 +314,18 @@ interface SectionPackInput {
257
314
  description: string;
258
315
  features: string[];
259
316
  pageIds: string[];
317
+ navigationItems?: SectionNavigationItemPack[];
318
+ /** Execution-level directives — short imperative rules for this section. */
319
+ directives?: string[];
320
+ }
321
+ /** Navigation item contract for a section's primary navigation. */
322
+ interface SectionNavigationItemPack {
323
+ label: string;
324
+ route: string;
325
+ icon?: string;
326
+ hotkey?: string;
327
+ active_match?: string;
328
+ badge?: string;
260
329
  }
261
330
  interface SectionPackRoute {
262
331
  pageId: string;
@@ -276,6 +345,26 @@ interface SectionPackData {
276
345
  shape: string | null;
277
346
  };
278
347
  routes: SectionPackRoute[];
348
+ /** Contract for items rendered in this section's primary navigation. */
349
+ navigationItems?: SectionNavigationItemPack[];
350
+ /** Execution-level directives emitted into the section-pack rendering. */
351
+ directives?: string[];
352
+ /**
353
+ * Required theme decorator contract surfaced into the compact pack.
354
+ * Mirrors the long-form section-context "Required Theme Decorators" table.
355
+ * Cold prompts instruct AI assistants to read packs first, so the strong
356
+ * decorator contract has to live HERE, not just in the long-form file.
357
+ */
358
+ themeDecorators?: ThemeDecoratorEntry[];
359
+ }
360
+ /** Compact, render-ready decorator entry for pack contracts. */
361
+ interface ThemeDecoratorEntry {
362
+ /** Decorator class name without leading dot, e.g. "lum-glass". */
363
+ class: string;
364
+ /** Authored intent describing what the decorator does. */
365
+ intent: string;
366
+ /** Authored slot hints listing where to apply it (joined from usage[]). */
367
+ applyTo: string;
279
368
  }
280
369
  interface SectionExecutionPack extends ExecutionPackBase<SectionPackData> {
281
370
  packType: 'section';
@@ -286,12 +375,28 @@ interface PagePackInput {
286
375
  sectionId: string | null;
287
376
  sectionRole: string | null;
288
377
  features: string[];
378
+ /** Execution-level directives — short imperative rules for this page. */
379
+ directives?: string[];
289
380
  }
290
381
  interface PagePackPattern {
291
382
  id: string;
292
383
  alias: string;
293
384
  preset: string;
294
385
  layout: string;
386
+ /**
387
+ * Per-preset prose from the pattern's preset.description. When present,
388
+ * the page-pack renderer emits it as a short description line so cold
389
+ * LLMs read preset-specific guidance instead of having to look up the
390
+ * pattern's root description.
391
+ */
392
+ presetDescription?: string;
393
+ /**
394
+ * v2.1 Tier C1. Declared interactions from the pattern JSON. Rendered
395
+ * as a checkbox checklist so cold LLMs in generation mode see a
396
+ * hard-edged list they can't categorize as "philosophy". Enforced by
397
+ * decantr check --strict (C5 guard rule).
398
+ */
399
+ interactions?: string[];
295
400
  }
296
401
  interface PagePackData {
297
402
  pageId: string;
@@ -308,6 +413,8 @@ interface PagePackData {
308
413
  };
309
414
  wiringSignals: string[];
310
415
  patterns: PagePackPattern[];
416
+ /** Execution-level directives emitted into the page-pack rendering. */
417
+ directives?: string[];
311
418
  }
312
419
  interface PageExecutionPack extends ExecutionPackBase<PagePackData> {
313
420
  packType: 'page';
@@ -384,15 +491,24 @@ interface ScaffoldPackBuilderOptions {
384
491
  successChecks?: ExecutionPackSuccessCheck[];
385
492
  tokenBudget?: Partial<ExecutionPackTokenBudget>;
386
493
  navigation?: {
387
- commandPalette: boolean;
494
+ commandPalette: boolean | CommandPaletteContract;
388
495
  hotkeys: Array<{
389
496
  key: string;
390
497
  route?: string;
391
498
  label?: string;
499
+ semantics?: HotkeySemantics;
392
500
  }>;
501
+ hotkeySemantics?: HotkeySemantics;
393
502
  };
394
503
  }
395
504
  interface SectionPackBuilderOptions extends ScaffoldPackBuilderOptions {
505
+ /**
506
+ * Required theme decorator contract for the section pack contract.
507
+ * When present, the renderer emits a "Required Theme Decorators" table
508
+ * with class + intent + apply-to slots — same shape as the long-form
509
+ * section-context renderer in CLI scaffold.ts.
510
+ */
511
+ themeDecorators?: ThemeDecoratorEntry[];
396
512
  }
397
513
  interface PagePackBuilderOptions extends ScaffoldPackBuilderOptions {
398
514
  }
@@ -436,6 +552,13 @@ interface PipelineOptions {
436
552
  interface PipelineResult {
437
553
  /** The framework-agnostic intermediate representation */
438
554
  ir: IRAppNode;
555
+ /**
556
+ * The fully-resolved registry theme record, including `decorator_definitions`
557
+ * and other rich theme data not carried in the lite IR `theme` node.
558
+ * Consumers (e.g. pack builders) need this to render decorator contracts
559
+ * into compiled artifacts.
560
+ */
561
+ registryTheme: Theme | null;
439
562
  }
440
563
  /**
441
564
  * Run the Design Pipeline:
@@ -446,15 +569,6 @@ interface PipelineResult {
446
569
  */
447
570
  declare function runPipeline(essence: EssenceFile, options: PipelineOptions): Promise<PipelineResult>;
448
571
 
449
- interface ResolvedPatternEntry {
450
- pattern: Pattern;
451
- preset: ResolvedPreset;
452
- }
453
- /** Build IR tree for a single page from its resolved structure + patterns */
454
- declare function buildPageIR(page: StructurePage, resolvedPatterns: Map<string, ResolvedPatternEntry>, wiring: IRWiring | null, theme: Theme | null, density: {
455
- gap: string;
456
- }, layer?: IRLayer): IRPageNode;
457
-
458
572
  interface ResolvedPage {
459
573
  page: StructurePage;
460
574
  patterns: Map<string, {
@@ -482,15 +596,6 @@ declare function resolveVisualEffects(theme: Theme, pattern: Pattern, _slot?: st
482
596
  /** Resolve all external references in an Essence file */
483
597
  declare function resolveEssence(essence: EssenceFile, resolver: ContentResolver): Promise<ResolvedEssence>;
484
598
 
485
- /** Depth-first walk of IR tree, calling visitor on each node */
486
- declare function walkIR(node: IRNode, visitor: (node: IRNode, parent: IRNode | null) => void, parent?: IRNode | null): void;
487
- /** Find all nodes of a specific type */
488
- declare function findNodes<T extends IRNode>(root: IRNode, type: string): T[];
489
- /** Count total patterns in an IR tree */
490
- declare function countPatterns(root: IRNode): number;
491
- /** Validate IR tree structure (no orphaned grids, patterns have meta, etc.) */
492
- declare function validateIR(root: IRNode): string[];
493
-
494
599
  /** Convert a kebab-case or snake_case string to PascalCase */
495
600
  declare function pascalCase(str: string): string;
496
601