@decantr/core 1.0.0-beta.8 → 1.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 ADDED
@@ -0,0 +1,55 @@
1
+ # @decantr/core
2
+
3
+ Support status: `core-supported`
4
+ Release channel: `stable`
5
+
6
+ Low-level Decantr compiler and execution-pack foundation.
7
+
8
+ Most teams should use `@decantr/cli`, `@decantr/registry`, or `@decantr/mcp-server` directly. This package remains inside the Decantr implementation boundary and is not part of the supported public package contract.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @decantr/core
14
+ ```
15
+
16
+ ## Stability
17
+
18
+ `@decantr/core` is published for advanced package consumers that need low-level execution-pack primitives. It is stable in the `1.x` line for the documented exports in this package, but it is still not the recommended first integration surface for most Decantr adopters.
19
+
20
+ ## What It Exports
21
+
22
+ - execution-pack builders for scaffold, section, page, mutation, and review scopes
23
+ - execution-pack schema URLs
24
+ - markdown rendering for compiled packs
25
+ - IR and pipeline helpers used by higher-level Decantr surfaces
26
+
27
+ ## Example
28
+
29
+ ```ts
30
+ import { buildReviewPack, renderExecutionPackMarkdown } from '@decantr/core';
31
+
32
+ const pack = buildReviewPack({
33
+ projectName: 'Acme Console',
34
+ target: 'react',
35
+ routeCount: 4,
36
+ sections: ['overview', 'settings'],
37
+ });
38
+
39
+ const markdown = renderExecutionPackMarkdown(pack);
40
+ ```
41
+
42
+ ## Schema Exports
43
+
44
+ This package publishes execution-pack schemas under:
45
+
46
+ - `@decantr/core/schema/scaffold-pack.v1.json`
47
+ - `@decantr/core/schema/section-pack.v1.json`
48
+ - `@decantr/core/schema/page-pack.v1.json`
49
+ - `@decantr/core/schema/mutation-pack.v1.json`
50
+ - `@decantr/core/schema/review-pack.v1.json`
51
+ - `@decantr/core/schema/pack-manifest.v1.json`
52
+
53
+ ## License
54
+
55
+ MIT
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { EssenceFile, StructurePage } from '@decantr/essence-spec';
2
- import { Pattern, ResolvedPreset, Recipe, ContentResolver } from '@decantr/registry';
1
+ import { EssenceFile, EssenceV3, StructurePage } from '@decantr/essence-spec';
2
+ import { ContentResolver, Pattern, ResolvedPreset, Theme } from '@decantr/registry';
3
3
 
4
4
  type IRNodeType = 'app' | 'shell' | 'page' | 'pattern' | 'grid' | 'nav' | 'store';
5
5
  interface IRSpatial {
@@ -31,8 +31,8 @@ interface IRPatternMeta {
31
31
  contained: boolean;
32
32
  standalone: boolean;
33
33
  code: {
34
- imports: string;
35
- example: string;
34
+ imports?: string;
35
+ example?: string;
36
36
  } | null;
37
37
  components: string[];
38
38
  }
@@ -43,7 +43,6 @@ interface IRVisualEffect {
43
43
  interface IRCardWrapping {
44
44
  mode: 'always' | 'minimal' | 'none';
45
45
  headerLabel: string;
46
- background?: string;
47
46
  }
48
47
  interface IRNavItem {
49
48
  href: string;
@@ -55,9 +54,9 @@ interface IRShellConfig {
55
54
  brand: string;
56
55
  nav: IRNavItem[];
57
56
  inset: boolean;
58
- recipe: IRRecipeDecoration | null;
57
+ decoration: IRThemeDecoration | null;
59
58
  }
60
- interface IRRecipeDecoration {
59
+ interface IRThemeDecoration {
61
60
  root: string;
62
61
  nav: string;
63
62
  header: string;
@@ -71,10 +70,9 @@ interface IRRecipeDecoration {
71
70
  } | null;
72
71
  }
73
72
  interface IRTheme {
74
- style: string;
73
+ id: string;
75
74
  mode: string;
76
75
  shape: string | null;
77
- recipe: string;
78
76
  isAddon: boolean;
79
77
  }
80
78
  interface IRRoute {
@@ -96,7 +94,7 @@ interface IRAppNode extends IRNode {
96
94
  type: 'app';
97
95
  theme: IRTheme;
98
96
  routes: IRRoute[];
99
- routing: 'hash' | 'history';
97
+ routing: 'hash' | 'history' | 'pathname';
100
98
  shell: IRShellNode;
101
99
  store: IRStoreNode;
102
100
  features: string[];
@@ -138,13 +136,283 @@ interface IRStoreNode extends IRNode {
138
136
  }[];
139
137
  }
140
138
 
139
+ type ExecutionPackType = 'scaffold' | 'section' | 'page' | 'mutation' | 'review';
140
+ declare const EXECUTION_PACK_SCHEMA_URLS: {
141
+ readonly scaffold: "https://decantr.ai/schemas/scaffold-pack.v1.json";
142
+ readonly section: "https://decantr.ai/schemas/section-pack.v1.json";
143
+ readonly page: "https://decantr.ai/schemas/page-pack.v1.json";
144
+ readonly mutation: "https://decantr.ai/schemas/mutation-pack.v1.json";
145
+ readonly review: "https://decantr.ai/schemas/review-pack.v1.json";
146
+ };
147
+ declare const PACK_MANIFEST_SCHEMA_URL = "https://decantr.ai/schemas/pack-manifest.v1.json";
148
+ declare const EXECUTION_PACK_BUNDLE_SCHEMA_URL = "https://decantr.ai/schemas/execution-pack-bundle.v1.json";
149
+ declare const SELECTED_EXECUTION_PACK_SCHEMA_URL = "https://decantr.ai/schemas/selected-execution-pack.v1.json";
150
+ interface ExecutionPackTarget {
151
+ platform: 'web';
152
+ framework: string | null;
153
+ runtime: string | null;
154
+ adapter: string;
155
+ }
156
+ interface ExecutionPackScope {
157
+ appId: string;
158
+ pageIds: string[];
159
+ patternIds: string[];
160
+ }
161
+ interface ExecutionPackExample {
162
+ id: string;
163
+ label: string;
164
+ language: string;
165
+ snippet: string;
166
+ }
167
+ interface ExecutionPackAntiPattern {
168
+ id: string;
169
+ summary: string;
170
+ guidance: string;
171
+ }
172
+ interface ExecutionPackSuccessCheck {
173
+ id: string;
174
+ label: string;
175
+ severity: 'error' | 'warn' | 'info';
176
+ }
177
+ interface ExecutionPackTokenBudget {
178
+ target: number;
179
+ max: number;
180
+ strategy: string[];
181
+ }
182
+ interface ExecutionPackBase<TData> {
183
+ $schema: string;
184
+ packVersion: '1.0.0';
185
+ packType: ExecutionPackType;
186
+ objective: string;
187
+ target: ExecutionPackTarget;
188
+ preset: string | null;
189
+ scope: ExecutionPackScope;
190
+ requiredSetup: string[];
191
+ allowedVocabulary: string[];
192
+ examples: ExecutionPackExample[];
193
+ antiPatterns: ExecutionPackAntiPattern[];
194
+ successChecks: ExecutionPackSuccessCheck[];
195
+ tokenBudget: ExecutionPackTokenBudget;
196
+ data: TData;
197
+ renderedMarkdown: string;
198
+ }
199
+ interface PackManifestEntry {
200
+ id: string;
201
+ markdown: string;
202
+ json: string;
203
+ }
204
+ interface PackManifestSectionEntry extends PackManifestEntry {
205
+ pageIds: string[];
206
+ }
207
+ interface PackManifestPageEntry extends PackManifestEntry {
208
+ sectionId: string | null;
209
+ sectionRole: string | null;
210
+ }
211
+ interface PackManifestMutationEntry extends PackManifestEntry {
212
+ mutationType: MutationPackKind;
213
+ }
214
+ interface ExecutionPackManifest {
215
+ $schema: string;
216
+ version: '1.0.0';
217
+ generatedAt: string;
218
+ scaffold: PackManifestEntry | null;
219
+ review: PackManifestEntry | null;
220
+ sections: PackManifestSectionEntry[];
221
+ pages: PackManifestPageEntry[];
222
+ mutations: PackManifestMutationEntry[];
223
+ }
224
+ interface ScaffoldPackRoute {
225
+ pageId: string;
226
+ path: string;
227
+ patternIds: string[];
228
+ }
229
+ interface ScaffoldPackData {
230
+ shell: string;
231
+ theme: {
232
+ id: string;
233
+ mode: string;
234
+ shape: string | null;
235
+ };
236
+ routing: 'hash' | 'history' | 'pathname';
237
+ features: string[];
238
+ routes: ScaffoldPackRoute[];
239
+ }
240
+ interface ScaffoldExecutionPack extends ExecutionPackBase<ScaffoldPackData> {
241
+ packType: 'scaffold';
242
+ }
243
+ interface SectionPackInput {
244
+ id: string;
245
+ role: string;
246
+ shell: string;
247
+ description: string;
248
+ features: string[];
249
+ pageIds: string[];
250
+ }
251
+ interface SectionPackRoute {
252
+ pageId: string;
253
+ path: string;
254
+ patternIds: string[];
255
+ }
256
+ interface SectionPackData {
257
+ sectionId: string;
258
+ role: string;
259
+ shell: string;
260
+ description: string;
261
+ features: string[];
262
+ theme: {
263
+ id: string;
264
+ mode: string;
265
+ shape: string | null;
266
+ };
267
+ routes: SectionPackRoute[];
268
+ }
269
+ interface SectionExecutionPack extends ExecutionPackBase<SectionPackData> {
270
+ packType: 'section';
271
+ }
272
+ interface PagePackInput {
273
+ pageId: string;
274
+ shell: string;
275
+ sectionId: string | null;
276
+ sectionRole: string | null;
277
+ features: string[];
278
+ }
279
+ interface PagePackPattern {
280
+ id: string;
281
+ alias: string;
282
+ preset: string;
283
+ layout: string;
284
+ }
285
+ interface PagePackData {
286
+ pageId: string;
287
+ path: string;
288
+ shell: string;
289
+ sectionId: string | null;
290
+ sectionRole: string | null;
291
+ features: string[];
292
+ surface: string;
293
+ theme: {
294
+ id: string;
295
+ mode: string;
296
+ shape: string | null;
297
+ };
298
+ wiringSignals: string[];
299
+ patterns: PagePackPattern[];
300
+ }
301
+ interface PageExecutionPack extends ExecutionPackBase<PagePackData> {
302
+ packType: 'page';
303
+ }
304
+ type MutationPackKind = 'add-page' | 'modify';
305
+ interface MutationPackData {
306
+ mutationType: MutationPackKind;
307
+ shell: string;
308
+ theme: {
309
+ id: string;
310
+ mode: string;
311
+ shape: string | null;
312
+ };
313
+ routing: 'hash' | 'history' | 'pathname';
314
+ features: string[];
315
+ routes: ScaffoldPackRoute[];
316
+ workflow: string[];
317
+ }
318
+ interface MutationExecutionPack extends ExecutionPackBase<MutationPackData> {
319
+ packType: 'mutation';
320
+ }
321
+ type ReviewPackKind = 'app';
322
+ interface ReviewPackData {
323
+ reviewType: ReviewPackKind;
324
+ shell: string;
325
+ theme: {
326
+ id: string;
327
+ mode: string;
328
+ shape: string | null;
329
+ };
330
+ routing: 'hash' | 'history' | 'pathname';
331
+ features: string[];
332
+ routes: ScaffoldPackRoute[];
333
+ focusAreas: string[];
334
+ workflow: string[];
335
+ }
336
+ interface ReviewExecutionPack extends ExecutionPackBase<ReviewPackData> {
337
+ packType: 'review';
338
+ }
339
+ interface ExecutionPackBundle {
340
+ $schema: string;
341
+ generatedAt: string;
342
+ sourceEssenceVersion: string;
343
+ manifest: ExecutionPackManifest;
344
+ scaffold: ScaffoldExecutionPack;
345
+ review: ReviewExecutionPack;
346
+ sections: SectionExecutionPack[];
347
+ pages: PageExecutionPack[];
348
+ mutations: MutationExecutionPack[];
349
+ }
350
+ type SelectedExecutionPack = ScaffoldExecutionPack | ReviewExecutionPack | SectionExecutionPack | PageExecutionPack | MutationExecutionPack;
351
+ interface ExecutionPackSelector {
352
+ packType: ExecutionPackType;
353
+ id?: string | null;
354
+ }
355
+ interface SelectedExecutionPackResponse {
356
+ $schema: string;
357
+ generatedAt: string;
358
+ sourceEssenceVersion: string;
359
+ manifest: ExecutionPackManifest;
360
+ selector: {
361
+ packType: ExecutionPackType;
362
+ id: string | null;
363
+ };
364
+ pack: SelectedExecutionPack;
365
+ }
366
+ interface ScaffoldPackBuilderOptions {
367
+ objective?: string;
368
+ target?: Partial<ExecutionPackTarget>;
369
+ preset?: string | null;
370
+ requiredSetup?: string[];
371
+ examples?: ExecutionPackExample[];
372
+ antiPatterns?: ExecutionPackAntiPattern[];
373
+ successChecks?: ExecutionPackSuccessCheck[];
374
+ tokenBudget?: Partial<ExecutionPackTokenBudget>;
375
+ }
376
+ interface SectionPackBuilderOptions extends ScaffoldPackBuilderOptions {
377
+ }
378
+ interface PagePackBuilderOptions extends ScaffoldPackBuilderOptions {
379
+ }
380
+ interface MutationPackBuilderOptions extends ScaffoldPackBuilderOptions {
381
+ mutationType: MutationPackKind;
382
+ workflow?: string[];
383
+ }
384
+ interface ReviewPackBuilderOptions extends ScaffoldPackBuilderOptions {
385
+ reviewType?: ReviewPackKind;
386
+ focusAreas?: string[];
387
+ workflow?: string[];
388
+ }
389
+ interface CompileExecutionPackBundleOptions {
390
+ contentRoot?: string;
391
+ overridePaths?: string[];
392
+ resolver?: ContentResolver;
393
+ }
394
+ declare function renderExecutionPackMarkdown(pack: ExecutionPackBase<unknown>): string;
395
+ declare function resolvePackAdapter(target: string | undefined, platformType: string | undefined): string;
396
+ declare function listPackSections(essence: EssenceV3): SectionPackInput[];
397
+ declare function listPackPages(essence: EssenceV3): PagePackInput[];
398
+ declare function buildScaffoldPack(appNode: IRAppNode, options?: ScaffoldPackBuilderOptions): ScaffoldExecutionPack;
399
+ declare function buildSectionPack(appNode: IRAppNode, input: SectionPackInput, options?: SectionPackBuilderOptions): SectionExecutionPack;
400
+ declare function buildPagePack(appNode: IRAppNode, input: PagePackInput, options?: PagePackBuilderOptions): PageExecutionPack;
401
+ declare function buildMutationPack(appNode: IRAppNode, options: MutationPackBuilderOptions): MutationExecutionPack;
402
+ declare function buildReviewPack(appNode: IRAppNode, options?: ReviewPackBuilderOptions): ReviewExecutionPack;
403
+ declare function compileExecutionPackBundle(essence: EssenceFile, options?: CompileExecutionPackBundleOptions): Promise<ExecutionPackBundle>;
404
+ declare function selectExecutionPackFromBundle(bundle: ExecutionPackBundle, selector: ExecutionPackSelector): SelectedExecutionPackResponse | null;
405
+ declare function compileSelectedExecutionPack(essence: EssenceFile, selector: ExecutionPackSelector, options?: CompileExecutionPackBundleOptions): Promise<SelectedExecutionPackResponse | null>;
406
+
141
407
  interface PipelineOptions {
142
- /** Path to content directory (patterns, archetypes, recipes) */
143
- contentRoot: string;
408
+ /** Path to content directory (patterns, archetypes, themes) */
409
+ contentRoot?: string;
144
410
  /** Override paths for local content resolution */
145
411
  overridePaths?: string[];
146
412
  /** Only resolve specific page(s) */
147
413
  pageFilter?: string;
414
+ /** Optional custom resolver for hosted or in-memory execution */
415
+ resolver?: ContentResolver;
148
416
  }
149
417
  interface PipelineResult {
150
418
  /** The framework-agnostic intermediate representation */
@@ -153,7 +421,7 @@ interface PipelineResult {
153
421
  /**
154
422
  * Run the Design Pipeline:
155
423
  * 1. Validate Essence against schema + guard rules
156
- * 2. Resolve all references (patterns, recipe, wiring) from registry
424
+ * 2. Resolve all references (patterns, theme, wiring) from registry
157
425
  * 3. Build framework-agnostic IR tree
158
426
  * 4. Return IR (no code generation — that's the consumer's job)
159
427
  */
@@ -164,7 +432,7 @@ interface ResolvedPatternEntry {
164
432
  preset: ResolvedPreset;
165
433
  }
166
434
  /** Build IR tree for a single page from its resolved structure + patterns */
167
- declare function buildPageIR(page: StructurePage, resolvedPatterns: Map<string, ResolvedPatternEntry>, wiring: IRWiring | null, recipe: Recipe | null, density: {
435
+ declare function buildPageIR(page: StructurePage, resolvedPatterns: Map<string, ResolvedPatternEntry>, wiring: IRWiring | null, theme: Theme | null, density: {
168
436
  gap: string;
169
437
  }, layer?: IRLayer): IRPageNode;
170
438
 
@@ -179,7 +447,7 @@ interface ResolvedPage {
179
447
  interface ResolvedEssence {
180
448
  essence: EssenceFile;
181
449
  pages: ResolvedPage[];
182
- recipe: Recipe | null;
450
+ registryTheme: Theme | null;
183
451
  density: {
184
452
  gap: string;
185
453
  level: string;
@@ -191,7 +459,7 @@ interface ResolvedEssence {
191
459
  /** True when the source essence was v3 (DNA/Blueprint/Meta) */
192
460
  isV3Source: boolean;
193
461
  }
194
- declare function resolveVisualEffects(recipe: Recipe, pattern: Pattern, _slot?: string): IRVisualEffect | null;
462
+ declare function resolveVisualEffects(theme: Theme, pattern: Pattern, _slot?: string): IRVisualEffect | null;
195
463
  /** Resolve all external references in an Essence file */
196
464
  declare function resolveEssence(essence: EssenceFile, resolver: ContentResolver): Promise<ResolvedEssence>;
197
465
 
@@ -207,4 +475,4 @@ declare function validateIR(root: IRNode): string[];
207
475
  /** Convert a kebab-case or snake_case string to PascalCase */
208
476
  declare function pascalCase(str: string): string;
209
477
 
210
- export { type IRAppNode, type IRBreakpointEntry, type IRCardWrapping, type IRGridNode, type IRHookType, type IRLayer, type IRNavItem, type IRNode, type IRNodeType, type IRPageNode, type IRPatternMeta, type IRPatternNode, type IRRecipeDecoration, type IRRoute, type IRShellConfig, type IRShellNode, type IRSpatial, type IRStoreNode, type IRTheme, type IRVisualEffect, type IRWiring, type IRWiringSignal, type PipelineOptions, type PipelineResult, type ResolvedEssence, type ResolvedPage, buildPageIR, countPatterns, findNodes, pascalCase, resolveEssence, resolveVisualEffects, runPipeline, validateIR, walkIR };
478
+ export { type CompileExecutionPackBundleOptions, EXECUTION_PACK_BUNDLE_SCHEMA_URL, EXECUTION_PACK_SCHEMA_URLS, type ExecutionPackAntiPattern, type ExecutionPackBase, type ExecutionPackBundle, type ExecutionPackExample, type ExecutionPackManifest, type ExecutionPackScope, type ExecutionPackSelector, type ExecutionPackSuccessCheck, type ExecutionPackTarget, type ExecutionPackTokenBudget, type ExecutionPackType, type IRAppNode, type IRBreakpointEntry, type IRCardWrapping, type IRGridNode, type IRHookType, type IRLayer, type IRNavItem, type IRNode, type IRNodeType, type IRPageNode, type IRPatternMeta, type IRPatternNode, type IRRoute, type IRShellConfig, type IRShellNode, type IRSpatial, type IRStoreNode, type IRTheme, type IRThemeDecoration, type IRVisualEffect, type IRWiring, type IRWiringSignal, type MutationExecutionPack, type MutationPackBuilderOptions, type MutationPackData, type MutationPackKind, PACK_MANIFEST_SCHEMA_URL, type PackManifestEntry, type PackManifestMutationEntry, type PackManifestPageEntry, type PackManifestSectionEntry, type PageExecutionPack, type PagePackBuilderOptions, type PagePackData, type PagePackInput, type PagePackPattern, type PipelineOptions, type PipelineResult, type ResolvedEssence, type ResolvedPage, type ReviewExecutionPack, type ReviewPackBuilderOptions, type ReviewPackData, type ReviewPackKind, SELECTED_EXECUTION_PACK_SCHEMA_URL, type ScaffoldExecutionPack, type ScaffoldPackBuilderOptions, type ScaffoldPackData, type ScaffoldPackRoute, type SectionExecutionPack, type SectionPackBuilderOptions, type SectionPackData, type SectionPackInput, type SectionPackRoute, type SelectedExecutionPack, type SelectedExecutionPackResponse, buildMutationPack, buildPageIR, buildPagePack, buildReviewPack, buildScaffoldPack, buildSectionPack, compileExecutionPackBundle, compileSelectedExecutionPack, countPatterns, findNodes, listPackPages, listPackSections, pascalCase, renderExecutionPackMarkdown, resolveEssence, resolvePackAdapter, resolveVisualEffects, runPipeline, selectExecutionPackFromBundle, validateIR, walkIR };