@decantr/core 1.0.2 → 1.0.4

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,14 +267,52 @@ 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[];
286
+ /**
287
+ * Required theme decorator contract — surfaced ONCE at the project level
288
+ * here, then referenced (not duplicated) in each section pack. Cold-LLM
289
+ * runs reported the table was duplicated 7-10× across context files
290
+ * (~270-540 redundant lines per scaffold) when each section pack carried
291
+ * its own copy. Centralizing in scaffold-pack — which the cold prompt
292
+ * tells AI to read first — keeps the contract authoritative without the
293
+ * per-section repetition.
294
+ */
295
+ themeDecorators?: ThemeDecoratorEntry[];
296
+ }
297
+ interface CommandPaletteContract {
298
+ trigger?: string;
299
+ placeholder?: string;
300
+ width?: string;
301
+ styling?: 'modal' | 'sheet' | 'inline' | 'fullscreen';
302
+ commands?: Array<{
303
+ id: string;
304
+ label: string;
305
+ section?: string;
306
+ hotkey?: string;
307
+ action?: string;
308
+ route?: string;
309
+ }>;
310
+ }
311
+ interface HotkeySemantics {
312
+ chord_window_ms?: number;
313
+ input_guard?: boolean;
314
+ modifier_suppression?: boolean;
315
+ match_case?: boolean;
249
316
  }
250
317
  interface ScaffoldExecutionPack extends ExecutionPackBase<ScaffoldPackData> {
251
318
  packType: 'scaffold';
@@ -257,6 +324,18 @@ interface SectionPackInput {
257
324
  description: string;
258
325
  features: string[];
259
326
  pageIds: string[];
327
+ navigationItems?: SectionNavigationItemPack[];
328
+ /** Execution-level directives — short imperative rules for this section. */
329
+ directives?: string[];
330
+ }
331
+ /** Navigation item contract for a section's primary navigation. */
332
+ interface SectionNavigationItemPack {
333
+ label: string;
334
+ route: string;
335
+ icon?: string;
336
+ hotkey?: string;
337
+ active_match?: string;
338
+ badge?: string;
260
339
  }
261
340
  interface SectionPackRoute {
262
341
  pageId: string;
@@ -276,6 +355,26 @@ interface SectionPackData {
276
355
  shape: string | null;
277
356
  };
278
357
  routes: SectionPackRoute[];
358
+ /** Contract for items rendered in this section's primary navigation. */
359
+ navigationItems?: SectionNavigationItemPack[];
360
+ /** Execution-level directives emitted into the section-pack rendering. */
361
+ directives?: string[];
362
+ /**
363
+ * Required theme decorator contract surfaced into the compact pack.
364
+ * Mirrors the long-form section-context "Required Theme Decorators" table.
365
+ * Cold prompts instruct AI assistants to read packs first, so the strong
366
+ * decorator contract has to live HERE, not just in the long-form file.
367
+ */
368
+ themeDecorators?: ThemeDecoratorEntry[];
369
+ }
370
+ /** Compact, render-ready decorator entry for pack contracts. */
371
+ interface ThemeDecoratorEntry {
372
+ /** Decorator class name without leading dot, e.g. "lum-glass". */
373
+ class: string;
374
+ /** Authored intent describing what the decorator does. */
375
+ intent: string;
376
+ /** Authored slot hints listing where to apply it (joined from usage[]). */
377
+ applyTo: string;
279
378
  }
280
379
  interface SectionExecutionPack extends ExecutionPackBase<SectionPackData> {
281
380
  packType: 'section';
@@ -286,12 +385,28 @@ interface PagePackInput {
286
385
  sectionId: string | null;
287
386
  sectionRole: string | null;
288
387
  features: string[];
388
+ /** Execution-level directives — short imperative rules for this page. */
389
+ directives?: string[];
289
390
  }
290
391
  interface PagePackPattern {
291
392
  id: string;
292
393
  alias: string;
293
394
  preset: string;
294
395
  layout: string;
396
+ /**
397
+ * Per-preset prose from the pattern's preset.description. When present,
398
+ * the page-pack renderer emits it as a short description line so cold
399
+ * LLMs read preset-specific guidance instead of having to look up the
400
+ * pattern's root description.
401
+ */
402
+ presetDescription?: string;
403
+ /**
404
+ * v2.1 Tier C1. Declared interactions from the pattern JSON. Rendered
405
+ * as a checkbox checklist so cold LLMs in generation mode see a
406
+ * hard-edged list they can't categorize as "philosophy". Enforced by
407
+ * decantr check --strict (C5 guard rule).
408
+ */
409
+ interactions?: string[];
295
410
  }
296
411
  interface PagePackData {
297
412
  pageId: string;
@@ -308,6 +423,8 @@ interface PagePackData {
308
423
  };
309
424
  wiringSignals: string[];
310
425
  patterns: PagePackPattern[];
426
+ /** Execution-level directives emitted into the page-pack rendering. */
427
+ directives?: string[];
311
428
  }
312
429
  interface PageExecutionPack extends ExecutionPackBase<PagePackData> {
313
430
  packType: 'page';
@@ -384,13 +501,22 @@ interface ScaffoldPackBuilderOptions {
384
501
  successChecks?: ExecutionPackSuccessCheck[];
385
502
  tokenBudget?: Partial<ExecutionPackTokenBudget>;
386
503
  navigation?: {
387
- commandPalette: boolean;
504
+ commandPalette: boolean | CommandPaletteContract;
388
505
  hotkeys: Array<{
389
506
  key: string;
390
507
  route?: string;
391
508
  label?: string;
509
+ semantics?: HotkeySemantics;
392
510
  }>;
511
+ hotkeySemantics?: HotkeySemantics;
393
512
  };
513
+ /**
514
+ * Required theme decorator contract surfaced into the scaffold pack.
515
+ * The scaffold pack is read first per cold-prompt rules, so the canonical
516
+ * decorator contract belongs here. Section packs reference this without
517
+ * duplicating to avoid the 7-10× repetition cold-LLM runs reported.
518
+ */
519
+ themeDecorators?: ThemeDecoratorEntry[];
394
520
  }
395
521
  interface SectionPackBuilderOptions extends ScaffoldPackBuilderOptions {
396
522
  }
@@ -436,6 +562,13 @@ interface PipelineOptions {
436
562
  interface PipelineResult {
437
563
  /** The framework-agnostic intermediate representation */
438
564
  ir: IRAppNode;
565
+ /**
566
+ * The fully-resolved registry theme record, including `decorator_definitions`
567
+ * and other rich theme data not carried in the lite IR `theme` node.
568
+ * Consumers (e.g. pack builders) need this to render decorator contracts
569
+ * into compiled artifacts.
570
+ */
571
+ registryTheme: Theme | null;
439
572
  }
440
573
  /**
441
574
  * Run the Design Pipeline:
@@ -446,15 +579,6 @@ interface PipelineResult {
446
579
  */
447
580
  declare function runPipeline(essence: EssenceFile, options: PipelineOptions): Promise<PipelineResult>;
448
581
 
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
582
  interface ResolvedPage {
459
583
  page: StructurePage;
460
584
  patterns: Map<string, {
@@ -482,15 +606,6 @@ declare function resolveVisualEffects(theme: Theme, pattern: Pattern, _slot?: st
482
606
  /** Resolve all external references in an Essence file */
483
607
  declare function resolveEssence(essence: EssenceFile, resolver: ContentResolver): Promise<ResolvedEssence>;
484
608
 
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
609
  /** Convert a kebab-case or snake_case string to PascalCase */
495
610
  declare function pascalCase(str: string): string;
496
611