@auto-engineer/narrative 1.139.0 → 1.140.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.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +5 -5
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +32 -0
- package/README.md +8 -8
- package/dist/scripts/convert-flow-exec.js +2 -2
- package/dist/scripts/convert-flow-exec.js.map +1 -1
- package/dist/scripts/print-schema.js +5 -5
- package/dist/scripts/print-schema.js.map +1 -1
- package/dist/src/fluent-builder.d.ts +29 -29
- package/dist/src/fluent-builder.d.ts.map +1 -1
- package/dist/src/fluent-builder.js +81 -81
- package/dist/src/fluent-builder.js.map +1 -1
- package/dist/src/{getNarratives.d.ts → getScenes.d.ts} +6 -6
- package/dist/src/getScenes.d.ts.map +1 -0
- package/dist/src/{getNarratives.js → getScenes.js} +16 -16
- package/dist/src/getScenes.js.map +1 -0
- package/dist/src/id/addAutoIds.d.ts.map +1 -1
- package/dist/src/id/addAutoIds.js +22 -22
- package/dist/src/id/addAutoIds.js.map +1 -1
- package/dist/src/id/hasAllIds.d.ts.map +1 -1
- package/dist/src/id/hasAllIds.js +2 -2
- package/dist/src/id/hasAllIds.js.map +1 -1
- package/dist/src/index.d.ts +8 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/loader/index.js +1 -1
- package/dist/src/loader/index.js.map +1 -1
- package/dist/src/loader/runtime-cjs.js +1 -1
- package/dist/src/loader/runtime-cjs.js.map +1 -1
- package/dist/src/narrative-context.d.ts +9 -9
- package/dist/src/narrative-context.d.ts.map +1 -1
- package/dist/src/narrative-context.js +47 -47
- package/dist/src/narrative-context.js.map +1 -1
- package/dist/src/narrative-registry.d.ts +6 -6
- package/dist/src/narrative-registry.d.ts.map +1 -1
- package/dist/src/narrative-registry.js +26 -26
- package/dist/src/narrative-registry.js.map +1 -1
- package/dist/src/narrative.d.ts +5 -5
- package/dist/src/narrative.d.ts.map +1 -1
- package/dist/src/narrative.js +26 -27
- package/dist/src/narrative.js.map +1 -1
- package/dist/src/parse-graphql-request.d.ts +1 -1
- package/dist/src/parse-graphql-request.d.ts.map +1 -1
- package/dist/src/parse-graphql-request.js +3 -3
- package/dist/src/parse-graphql-request.js.map +1 -1
- package/dist/src/samples/items.narrative.js +2 -2
- package/dist/src/samples/items.narrative.js.map +1 -1
- package/dist/src/samples/mixed-given-types.narrative.js +2 -2
- package/dist/src/samples/mixed-given-types.narrative.js.map +1 -1
- package/dist/src/samples/place-order.narrative.js +2 -2
- package/dist/src/samples/place-order.narrative.js.map +1 -1
- package/dist/src/samples/questionnaires.narrative.js +2 -2
- package/dist/src/samples/questionnaires.narrative.js.map +1 -1
- package/dist/src/samples/seasonal-assistant.schema.json +2 -2
- package/dist/src/samples/test-with-ids.narrative.js +2 -2
- package/dist/src/samples/test-with-ids.narrative.js.map +1 -1
- package/dist/src/schema.d.ts +136 -136
- package/dist/src/schema.d.ts.map +1 -1
- package/dist/src/schema.js +76 -76
- package/dist/src/schema.js.map +1 -1
- package/dist/src/slice-builder.d.ts +6 -6
- package/dist/src/slice-builder.d.ts.map +1 -1
- package/dist/src/slice-builder.js +21 -21
- package/dist/src/slice-builder.js.map +1 -1
- package/dist/src/transformers/model-to-narrative/analysis/lint-helpers.js +1 -1
- package/dist/src/transformers/model-to-narrative/analysis/lint-helpers.js.map +1 -1
- package/dist/src/transformers/model-to-narrative/cross-module-imports.js +4 -4
- package/dist/src/transformers/model-to-narrative/cross-module-imports.js.map +1 -1
- package/dist/src/transformers/model-to-narrative/generators/compose.js +3 -3
- package/dist/src/transformers/model-to-narrative/generators/compose.js.map +1 -1
- package/dist/src/transformers/model-to-narrative/generators/flow.d.ts +2 -2
- package/dist/src/transformers/model-to-narrative/generators/flow.d.ts.map +1 -1
- package/dist/src/transformers/model-to-narrative/generators/flow.js +20 -20
- package/dist/src/transformers/model-to-narrative/generators/flow.js.map +1 -1
- package/dist/src/transformers/model-to-narrative/generators/imports.d.ts +1 -1
- package/dist/src/transformers/model-to-narrative/generators/imports.d.ts.map +1 -1
- package/dist/src/transformers/model-to-narrative/generators/imports.js +1 -1
- package/dist/src/transformers/model-to-narrative/generators/imports.js.map +1 -1
- package/dist/src/transformers/model-to-narrative/generators/module-code.js +14 -14
- package/dist/src/transformers/model-to-narrative/generators/module-code.js.map +1 -1
- package/dist/src/transformers/model-to-narrative/index.d.ts +4 -4
- package/dist/src/transformers/model-to-narrative/index.d.ts.map +1 -1
- package/dist/src/transformers/model-to-narrative/index.js +1 -1
- package/dist/src/transformers/model-to-narrative/spec-traversal.d.ts +2 -2
- package/dist/src/transformers/model-to-narrative/spec-traversal.d.ts.map +1 -1
- package/dist/src/transformers/model-to-narrative/spec-traversal.js +5 -5
- package/dist/src/transformers/model-to-narrative/spec-traversal.js.map +1 -1
- package/dist/src/transformers/model-to-narrative/types.d.ts +1 -1
- package/dist/src/transformers/model-to-narrative/types.d.ts.map +1 -1
- package/dist/src/transformers/model-to-narrative/utils/integration-extractor.d.ts +1 -1
- package/dist/src/transformers/model-to-narrative/utils/integration-extractor.d.ts.map +1 -1
- package/dist/src/transformers/model-to-narrative/utils/integration-extractor.js +4 -4
- package/dist/src/transformers/model-to-narrative/utils/integration-extractor.js.map +1 -1
- package/dist/src/transformers/model-to-narrative/validate-modules.d.ts +1 -1
- package/dist/src/transformers/model-to-narrative/validate-modules.d.ts.map +1 -1
- package/dist/src/transformers/model-to-narrative/validate-modules.js +19 -19
- package/dist/src/transformers/model-to-narrative/validate-modules.js.map +1 -1
- package/dist/src/transformers/narrative-to-model/assemble.d.ts +2 -2
- package/dist/src/transformers/narrative-to-model/assemble.d.ts.map +1 -1
- package/dist/src/transformers/narrative-to-model/assemble.js +10 -3
- package/dist/src/transformers/narrative-to-model/assemble.js.map +1 -1
- package/dist/src/transformers/narrative-to-model/debug.d.ts.map +1 -1
- package/dist/src/transformers/narrative-to-model/debug.js +1 -1
- package/dist/src/transformers/narrative-to-model/debug.js.map +1 -1
- package/dist/src/transformers/narrative-to-model/derive-modules.d.ts +2 -2
- package/dist/src/transformers/narrative-to-model/derive-modules.d.ts.map +1 -1
- package/dist/src/transformers/narrative-to-model/derive-modules.js +9 -9
- package/dist/src/transformers/narrative-to-model/derive-modules.js.map +1 -1
- package/dist/src/transformers/narrative-to-model/index.d.ts +2 -2
- package/dist/src/transformers/narrative-to-model/index.d.ts.map +1 -1
- package/dist/src/transformers/narrative-to-model/index.js +39 -39
- package/dist/src/transformers/narrative-to-model/index.js.map +1 -1
- package/dist/src/transformers/narrative-to-model/spec-processors.js +1 -1
- package/dist/src/transformers/narrative-to-model/spec-processors.js.map +1 -1
- package/dist/src/transformers/narrative-to-model/strings.d.ts +1 -1
- package/dist/src/transformers/narrative-to-model/strings.d.ts.map +1 -1
- package/dist/src/transformers/narrative-to-model/strings.js +6 -6
- package/dist/src/transformers/narrative-to-model/strings.js.map +1 -1
- package/dist/src/validate-slice-requests.d.ts +4 -4
- package/dist/src/validate-slice-requests.d.ts.map +1 -1
- package/dist/src/validate-slice-requests.js +34 -34
- package/dist/src/validate-slice-requests.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/scripts/convert-flow-exec.ts +2 -2
- package/scripts/print-schema.ts +8 -8
- package/src/fluent-builder.specs.ts +3 -3
- package/src/fluent-builder.ts +141 -141
- package/src/{getNarratives.cache.specs.ts → getScenes.cache.specs.ts} +45 -45
- package/src/{getNarratives.specs.ts → getScenes.specs.ts} +302 -300
- package/src/{getNarratives.ts → getScenes.ts} +20 -20
- package/src/id/addAutoIds.specs.ts +105 -105
- package/src/id/addAutoIds.ts +26 -26
- package/src/id/hasAllIds.specs.ts +59 -59
- package/src/id/hasAllIds.ts +6 -6
- package/src/index.ts +12 -13
- package/src/loader/index.ts +1 -1
- package/src/loader/runtime-cjs.ts +1 -1
- package/src/model-to-narrative.specs.ts +133 -135
- package/src/narrative-context.specs.ts +24 -24
- package/src/narrative-context.ts +61 -61
- package/src/narrative-registry.ts +31 -31
- package/src/narrative.ts +31 -33
- package/src/parse-graphql-request.specs.ts +5 -5
- package/src/parse-graphql-request.ts +3 -3
- package/src/samples/items.narrative.ts +2 -2
- package/src/samples/mixed-given-types.narrative.ts +2 -2
- package/src/samples/place-order.narrative.ts +2 -2
- package/src/samples/questionnaires.narrative.ts +2 -2
- package/src/samples/seasonal-assistant.schema.json +2 -2
- package/src/samples/test-with-ids.narrative.ts +2 -2
- package/src/schema.specs.ts +99 -91
- package/src/schema.ts +89 -89
- package/src/slice-builder.ts +30 -30
- package/src/transformers/model-to-narrative/analysis/lint-helpers.ts +1 -1
- package/src/transformers/model-to-narrative/cross-module-imports.specs.ts +43 -43
- package/src/transformers/model-to-narrative/cross-module-imports.ts +4 -4
- package/src/transformers/model-to-narrative/generators/compose.ts +4 -4
- package/src/transformers/model-to-narrative/generators/flow.ts +36 -36
- package/src/transformers/model-to-narrative/generators/imports.ts +1 -1
- package/src/transformers/model-to-narrative/generators/module-code.ts +15 -15
- package/src/transformers/model-to-narrative/index.ts +4 -4
- package/src/transformers/model-to-narrative/modules.specs.ts +58 -58
- package/src/transformers/model-to-narrative/spec-traversal.specs.ts +43 -43
- package/src/transformers/model-to-narrative/spec-traversal.ts +6 -6
- package/src/transformers/model-to-narrative/types.ts +1 -1
- package/src/transformers/model-to-narrative/utils/integration-extractor.ts +5 -5
- package/src/transformers/model-to-narrative/validate-modules.ts +22 -22
- package/src/transformers/narrative-to-model/assemble.ts +12 -4
- package/src/transformers/narrative-to-model/debug.ts +1 -1
- package/src/transformers/narrative-to-model/derive-modules.specs.ts +35 -35
- package/src/transformers/narrative-to-model/derive-modules.ts +11 -11
- package/src/transformers/narrative-to-model/index.ts +47 -47
- package/src/transformers/narrative-to-model/spec-processors.ts +1 -1
- package/src/transformers/narrative-to-model/strings.ts +6 -6
- package/src/transformers/narrative-to-model/type-inference.specs.ts +11 -11
- package/src/validate-slice-requests.specs.ts +113 -113
- package/src/validate-slice-requests.ts +49 -49
- package/dist/src/getNarratives.d.ts.map +0 -1
- package/dist/src/getNarratives.js.map +0 -1
package/src/schema.ts
CHANGED
|
@@ -15,16 +15,16 @@ export const ModuleSchema = z
|
|
|
15
15
|
isDerived: z.boolean().describe('True if auto-derived from sourceFile grouping, false if user-authored'),
|
|
16
16
|
contains: z
|
|
17
17
|
.object({
|
|
18
|
-
|
|
18
|
+
sceneIds: z.array(z.string()).describe('IDs of scenes in this module'),
|
|
19
19
|
})
|
|
20
|
-
.describe('
|
|
20
|
+
.describe('Scenes contained in this module'),
|
|
21
21
|
declares: z
|
|
22
22
|
.object({
|
|
23
23
|
messages: z.array(MessageRefSchema).describe('Message types owned by this module'),
|
|
24
24
|
})
|
|
25
25
|
.describe('Types declared/owned by this module'),
|
|
26
26
|
})
|
|
27
|
-
.describe('Module for grouping
|
|
27
|
+
.describe('Module for grouping scenes and owning types');
|
|
28
28
|
|
|
29
29
|
const IntegrationSchema = z
|
|
30
30
|
.object({
|
|
@@ -233,7 +233,7 @@ const UISchema = z
|
|
|
233
233
|
regions: z.record(z.array(RegionEntrySchema)),
|
|
234
234
|
customizationNotes: z.string().optional(),
|
|
235
235
|
})
|
|
236
|
-
.describe('UI composition for a
|
|
236
|
+
.describe('UI composition for a moment');
|
|
237
237
|
|
|
238
238
|
const ComponentDefinitionSchema = z
|
|
239
239
|
.object({
|
|
@@ -254,17 +254,17 @@ export const DesignSchema = z
|
|
|
254
254
|
})
|
|
255
255
|
.describe('Design fields for visual representation');
|
|
256
256
|
|
|
257
|
-
const
|
|
257
|
+
const BaseMomentSchema = z
|
|
258
258
|
.object({
|
|
259
259
|
name: z.string(),
|
|
260
|
-
id: z.string().optional().describe('Optional unique identifier for the
|
|
260
|
+
id: z.string().optional().describe('Optional unique identifier for the moment'),
|
|
261
261
|
description: z.string().optional(),
|
|
262
|
-
stream: z.string().optional().describe('Event stream pattern for this
|
|
263
|
-
via: z.array(z.string()).optional().describe('Integration names used by this
|
|
262
|
+
stream: z.string().optional().describe('Event stream pattern for this moment'),
|
|
263
|
+
via: z.array(z.string()).optional().describe('Integration names used by this moment'),
|
|
264
264
|
additionalInstructions: z.string().optional().describe('Additional instructions'),
|
|
265
265
|
design: DesignSchema.optional().describe('Design fields for visual representation'),
|
|
266
266
|
})
|
|
267
|
-
.describe('Base properties shared by all
|
|
267
|
+
.describe('Base properties shared by all moment types');
|
|
268
268
|
|
|
269
269
|
const StepErrorSchema = z.object({
|
|
270
270
|
type: z.enum(['IllegalStateError', 'ValidationError', 'NotFoundError']).describe('Error type'),
|
|
@@ -339,7 +339,7 @@ export const ClientSpecNodeSchema: z.ZodType<ClientSpecNode> = z.lazy(() =>
|
|
|
339
339
|
|
|
340
340
|
export const ClientSpecSchema = z.array(ClientSpecNodeSchema).default([]);
|
|
341
341
|
|
|
342
|
-
const
|
|
342
|
+
const CommandMomentSchema = BaseMomentSchema.extend({
|
|
343
343
|
type: z.literal('command'),
|
|
344
344
|
client: z.object({
|
|
345
345
|
specs: ClientSpecSchema,
|
|
@@ -348,12 +348,12 @@ const CommandSliceSchema = BaseSliceSchema.extend({
|
|
|
348
348
|
mappings: z.array(MappingEntrySchema).optional().describe('Field mappings between Command/Event/State messages'),
|
|
349
349
|
server: z.object({
|
|
350
350
|
description: z.string(),
|
|
351
|
-
data: DataSchema.optional().describe('Data configuration for command
|
|
351
|
+
data: DataSchema.optional().describe('Data configuration for command moments'),
|
|
352
352
|
specs: z.array(SpecSchema).describe('Server-side specifications with rules and examples'),
|
|
353
353
|
}),
|
|
354
|
-
}).describe('Command
|
|
354
|
+
}).describe('Command moment handling user actions and business logic');
|
|
355
355
|
|
|
356
|
-
const
|
|
356
|
+
const QueryMomentSchema = BaseMomentSchema.extend({
|
|
357
357
|
type: z.literal('query'),
|
|
358
358
|
client: z.object({
|
|
359
359
|
specs: ClientSpecSchema,
|
|
@@ -362,32 +362,32 @@ const QuerySliceSchema = BaseSliceSchema.extend({
|
|
|
362
362
|
mappings: z.array(MappingEntrySchema).optional().describe('Field mappings between Command/Event/State messages'),
|
|
363
363
|
server: z.object({
|
|
364
364
|
description: z.string(),
|
|
365
|
-
data: DataSchema.optional().describe('Data configuration for query
|
|
365
|
+
data: DataSchema.optional().describe('Data configuration for query moments'),
|
|
366
366
|
specs: z.array(SpecSchema).describe('Server-side specifications with rules and examples'),
|
|
367
367
|
}),
|
|
368
|
-
}).describe('Query
|
|
368
|
+
}).describe('Query moment for reading data and maintaining projections');
|
|
369
369
|
|
|
370
|
-
const
|
|
370
|
+
const ReactMomentSchema = BaseMomentSchema.extend({
|
|
371
371
|
type: z.literal('react'),
|
|
372
372
|
server: z.object({
|
|
373
373
|
description: z.string().optional(),
|
|
374
|
-
data: DataSchema.optional().describe('Data configuration for react
|
|
374
|
+
data: DataSchema.optional().describe('Data configuration for react moments'),
|
|
375
375
|
specs: z.array(SpecSchema).describe('Server-side specifications with rules and examples'),
|
|
376
376
|
}),
|
|
377
|
-
}).describe('React
|
|
377
|
+
}).describe('React moment for automated responses to events');
|
|
378
378
|
|
|
379
|
-
const
|
|
379
|
+
const ExperienceMomentSchema = BaseMomentSchema.extend({
|
|
380
380
|
type: z.literal('experience'),
|
|
381
381
|
client: z.object({
|
|
382
382
|
specs: ClientSpecSchema,
|
|
383
383
|
}),
|
|
384
|
-
}).describe('Experience
|
|
384
|
+
}).describe('Experience moment for user interactions and UI behavior');
|
|
385
385
|
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
386
|
+
const MomentSchema = z.discriminatedUnion('type', [
|
|
387
|
+
CommandMomentSchema,
|
|
388
|
+
QueryMomentSchema,
|
|
389
|
+
ReactMomentSchema,
|
|
390
|
+
ExperienceMomentSchema,
|
|
391
391
|
]);
|
|
392
392
|
|
|
393
393
|
export const SceneRouteSchema = z
|
|
@@ -420,64 +420,64 @@ export const SceneClassificationSchema = z
|
|
|
420
420
|
.optional(),
|
|
421
421
|
route: SceneRouteSchema.optional(),
|
|
422
422
|
})
|
|
423
|
-
.describe('Scene classification metadata for a
|
|
423
|
+
.describe('Scene classification metadata for a scene');
|
|
424
424
|
|
|
425
|
-
export const
|
|
425
|
+
export const NarrativeSchema = z
|
|
426
426
|
.object({
|
|
427
|
-
id: z.string().optional().describe('Unique identifier for the
|
|
428
|
-
name: z.string().describe('
|
|
427
|
+
id: z.string().optional().describe('Unique identifier for the narrative'),
|
|
428
|
+
name: z.string().describe('Narrative name'),
|
|
429
429
|
description: z.string().optional(),
|
|
430
430
|
actors: z.array(z.string()).optional(),
|
|
431
|
-
|
|
431
|
+
sceneIds: z.array(z.string()).describe('Ordered scene IDs composing this narrative'),
|
|
432
432
|
design: DesignSchema.optional().describe('Design fields for visual representation'),
|
|
433
433
|
})
|
|
434
|
-
.describe('
|
|
434
|
+
.describe('Narrative grouping scenes into an ordered flow');
|
|
435
435
|
|
|
436
|
-
const
|
|
436
|
+
const SceneSchema = z
|
|
437
437
|
.object({
|
|
438
438
|
name: z.string(),
|
|
439
|
-
id: z.string().optional().describe('Optional unique identifier for the
|
|
439
|
+
id: z.string().optional().describe('Optional unique identifier for the scene'),
|
|
440
440
|
description: z.string().optional(),
|
|
441
|
-
|
|
441
|
+
moments: z.array(MomentSchema),
|
|
442
442
|
sourceFile: z.string().optional(),
|
|
443
443
|
scene: SceneClassificationSchema.optional(),
|
|
444
444
|
design: DesignSchema.optional().describe('Design fields for visual representation'),
|
|
445
445
|
})
|
|
446
|
-
.describe('Business
|
|
446
|
+
.describe('Business scene containing related moments');
|
|
447
447
|
|
|
448
|
-
// Variant 1: Just
|
|
449
|
-
export const
|
|
448
|
+
// Variant 1: Just scene names
|
|
449
|
+
export const SceneNamesOnlySchema = z
|
|
450
450
|
.object({
|
|
451
451
|
name: z.string(),
|
|
452
|
-
id: z.string().optional().describe('Optional unique identifier for the
|
|
452
|
+
id: z.string().optional().describe('Optional unique identifier for the scene'),
|
|
453
453
|
description: z.string().optional(),
|
|
454
454
|
})
|
|
455
|
-
.describe('
|
|
455
|
+
.describe('Scene with just name for initial planning');
|
|
456
456
|
|
|
457
|
-
// Variant 2:
|
|
458
|
-
const
|
|
457
|
+
// Variant 2: Scene with moment names
|
|
458
|
+
const MomentNamesOnlySchema = z
|
|
459
459
|
.object({
|
|
460
460
|
name: z.string(),
|
|
461
|
-
id: z.string().optional().describe('Optional unique identifier for the
|
|
461
|
+
id: z.string().optional().describe('Optional unique identifier for the moment'),
|
|
462
462
|
description: z.string().optional(),
|
|
463
463
|
type: z.enum(['command', 'query', 'react']),
|
|
464
464
|
})
|
|
465
|
-
.describe('
|
|
465
|
+
.describe('Moment with just name and type for structure planning');
|
|
466
466
|
|
|
467
|
-
const
|
|
467
|
+
const SceneWithMomentNamesSchema = z
|
|
468
468
|
.object({
|
|
469
469
|
name: z.string(),
|
|
470
|
-
id: z.string().optional().describe('Optional unique identifier for the
|
|
470
|
+
id: z.string().optional().describe('Optional unique identifier for the scene'),
|
|
471
471
|
description: z.string().optional(),
|
|
472
|
-
|
|
472
|
+
moments: z.array(MomentNamesOnlySchema),
|
|
473
473
|
})
|
|
474
|
-
.describe('
|
|
474
|
+
.describe('Scene with moment names for structure planning');
|
|
475
475
|
|
|
476
|
-
// Variant 3:
|
|
477
|
-
const
|
|
476
|
+
// Variant 3: Scene with client & server names
|
|
477
|
+
const ClientServerNamesMomentSchema = z
|
|
478
478
|
.object({
|
|
479
479
|
name: z.string(),
|
|
480
|
-
id: z.string().optional().describe('Optional unique identifier for the
|
|
480
|
+
id: z.string().optional().describe('Optional unique identifier for the moment'),
|
|
481
481
|
type: z.enum(['command', 'query', 'react']),
|
|
482
482
|
description: z.string().optional(),
|
|
483
483
|
client: z
|
|
@@ -491,54 +491,54 @@ const ClientServerNamesSliceSchema = z
|
|
|
491
491
|
})
|
|
492
492
|
.optional(),
|
|
493
493
|
})
|
|
494
|
-
.describe('
|
|
494
|
+
.describe('Moment with client/server descriptions for behavior planning');
|
|
495
495
|
|
|
496
|
-
const
|
|
496
|
+
const SceneWithClientServerNamesSchema = z
|
|
497
497
|
.object({
|
|
498
498
|
name: z.string(),
|
|
499
|
-
id: z.string().optional().describe('Optional unique identifier for the
|
|
499
|
+
id: z.string().optional().describe('Optional unique identifier for the scene'),
|
|
500
500
|
description: z.string().optional(),
|
|
501
|
-
|
|
501
|
+
moments: z.array(ClientServerNamesMomentSchema),
|
|
502
502
|
})
|
|
503
|
-
.describe('
|
|
503
|
+
.describe('Scene with client/server descriptions for behavior planning');
|
|
504
504
|
|
|
505
505
|
// Variant 4: Full specs (uses existing schemas)
|
|
506
506
|
|
|
507
|
-
const
|
|
507
|
+
const NarrativePlanningNarrativeSchema = z
|
|
508
508
|
.object({
|
|
509
509
|
name: z.string(),
|
|
510
510
|
description: z.string().optional(),
|
|
511
511
|
actors: z.array(z.string()).optional(),
|
|
512
|
-
|
|
512
|
+
sceneNames: z.array(z.string()).describe('Ordered scene names'),
|
|
513
513
|
})
|
|
514
|
-
.describe('
|
|
514
|
+
.describe('Narrative with scene names for planning');
|
|
515
515
|
|
|
516
|
-
export const
|
|
516
|
+
export const NarrativePlanningSchema = z
|
|
517
517
|
.object({
|
|
518
|
-
variant: z.literal('
|
|
519
|
-
|
|
520
|
-
|
|
518
|
+
variant: z.literal('narrative-planning').describe('Narrative-based planning with scene names'),
|
|
519
|
+
narratives: z.array(NarrativePlanningNarrativeSchema),
|
|
520
|
+
scenes: z.array(SceneNamesOnlySchema),
|
|
521
521
|
})
|
|
522
|
-
.describe('Progressive disclosure variant for
|
|
522
|
+
.describe('Progressive disclosure variant for narrative-based planning');
|
|
523
523
|
|
|
524
|
-
export const
|
|
524
|
+
export const SceneNamesSchema = z
|
|
525
525
|
.object({
|
|
526
|
-
variant: z.literal('
|
|
527
|
-
|
|
526
|
+
variant: z.literal('scene-names').describe('Just scene names for initial ideation'),
|
|
527
|
+
scenes: z.array(SceneNamesOnlySchema),
|
|
528
528
|
})
|
|
529
|
-
.describe('System with just
|
|
529
|
+
.describe('System with just scene names for initial planning');
|
|
530
530
|
|
|
531
|
-
export const
|
|
531
|
+
export const MomentNamesSchema = z
|
|
532
532
|
.object({
|
|
533
|
-
variant: z.literal('
|
|
534
|
-
|
|
533
|
+
variant: z.literal('moment-names').describe('Scenes with moment names for structure planning'),
|
|
534
|
+
scenes: z.array(SceneWithMomentNamesSchema),
|
|
535
535
|
})
|
|
536
|
-
.describe('System with
|
|
536
|
+
.describe('System with scene and moment names for structure planning');
|
|
537
537
|
|
|
538
538
|
export const ClientServerNamesSchema = z
|
|
539
539
|
.object({
|
|
540
|
-
variant: z.literal('client-server-names').describe('
|
|
541
|
-
|
|
540
|
+
variant: z.literal('client-server-names').describe('Scenes with client/server descriptions'),
|
|
541
|
+
scenes: z.array(SceneWithClientServerNamesSchema),
|
|
542
542
|
})
|
|
543
543
|
.describe('System with client/server descriptions for behavior planning');
|
|
544
544
|
|
|
@@ -549,11 +549,11 @@ const ModelDesignSchema = DesignSchema.extend({
|
|
|
549
549
|
export const modelSchema = z
|
|
550
550
|
.object({
|
|
551
551
|
variant: z.literal('specs').describe('Full specification with all details'),
|
|
552
|
-
|
|
552
|
+
scenes: z.array(SceneSchema),
|
|
553
553
|
messages: z.array(MessageSchema),
|
|
554
554
|
integrations: z.array(IntegrationSchema).optional(),
|
|
555
555
|
modules: z.array(ModuleSchema).describe('Modules for type ownership and file grouping'),
|
|
556
|
-
|
|
556
|
+
narratives: z.array(NarrativeSchema),
|
|
557
557
|
design: ModelDesignSchema.optional().describe('Design fields for visual representation'),
|
|
558
558
|
})
|
|
559
559
|
.describe('Complete system specification with all implementation details');
|
|
@@ -568,12 +568,12 @@ export {
|
|
|
568
568
|
StateSchema,
|
|
569
569
|
QuerySchema,
|
|
570
570
|
IntegrationSchema,
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
571
|
+
CommandMomentSchema,
|
|
572
|
+
QueryMomentSchema,
|
|
573
|
+
ReactMomentSchema,
|
|
574
|
+
ExperienceMomentSchema,
|
|
575
|
+
MomentSchema,
|
|
576
|
+
SceneSchema,
|
|
577
577
|
ExampleSchema,
|
|
578
578
|
RuleSchema,
|
|
579
579
|
SpecSchema,
|
|
@@ -590,12 +590,12 @@ export {
|
|
|
590
590
|
};
|
|
591
591
|
|
|
592
592
|
export type Model = z.infer<typeof modelSchema>;
|
|
593
|
-
export type
|
|
594
|
-
export type
|
|
595
|
-
export type
|
|
596
|
-
export type
|
|
597
|
-
export type
|
|
598
|
-
export type
|
|
593
|
+
export type Scene = z.infer<typeof SceneSchema>;
|
|
594
|
+
export type Moment = z.infer<typeof MomentSchema>;
|
|
595
|
+
export type QueryMoment = z.infer<typeof QueryMomentSchema>;
|
|
596
|
+
export type ReactMoment = z.infer<typeof ReactMomentSchema>;
|
|
597
|
+
export type CommandMoment = z.infer<typeof CommandMomentSchema>;
|
|
598
|
+
export type ExperienceMoment = z.infer<typeof ExperienceMomentSchema>;
|
|
599
599
|
export type Message = z.infer<typeof MessageSchema>;
|
|
600
600
|
export type Example = z.infer<typeof ExampleSchema>;
|
|
601
601
|
export type MessageField = z.infer<typeof MessageFieldSchema>;
|
|
@@ -606,11 +606,11 @@ export type Module = z.infer<typeof ModuleSchema>;
|
|
|
606
606
|
export type MessageRef = z.infer<typeof MessageRefSchema>;
|
|
607
607
|
export type MappingFieldRef = z.infer<typeof MappingFieldRefSchema>;
|
|
608
608
|
export type MappingEntry = z.infer<typeof MappingEntrySchema>;
|
|
609
|
-
export type
|
|
609
|
+
export type Narrative = z.infer<typeof NarrativeSchema>;
|
|
610
610
|
export type DataTarget = z.infer<typeof DataTargetSchema>;
|
|
611
611
|
export type SceneClassification = z.infer<typeof SceneClassificationSchema>;
|
|
612
612
|
export type SceneRoute = z.infer<typeof SceneRouteSchema>;
|
|
613
|
-
export type
|
|
613
|
+
export type NarrativePlanning = z.infer<typeof NarrativePlanningSchema>;
|
|
614
614
|
export type ImageAsset = z.infer<typeof ImageAssetSchema>;
|
|
615
615
|
export type Design = z.infer<typeof DesignSchema>;
|
|
616
616
|
export type RegionEntry = z.infer<typeof RegionEntrySchema>;
|
package/src/slice-builder.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { CommandMoment, QueryMoment, ReactMoment } from './index';
|
|
2
|
+
import { addMoment, getCurrentScene } from './narrative-context';
|
|
3
3
|
import type { Integration } from './types';
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface MomentConfig {
|
|
6
6
|
integration?: Integration;
|
|
7
7
|
eventStream?: string;
|
|
8
8
|
retries?: number;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export interface
|
|
12
|
-
via(integrationOrStream: Integration | string):
|
|
11
|
+
export interface MomentBuilder {
|
|
12
|
+
via(integrationOrStream: Integration | string): MomentBuilder;
|
|
13
13
|
|
|
14
|
-
retries(count: number):
|
|
14
|
+
retries(count: number): MomentBuilder;
|
|
15
15
|
|
|
16
|
-
stream(eventStream: string):
|
|
16
|
+
stream(eventStream: string): MomentBuilder;
|
|
17
17
|
|
|
18
18
|
command(name: string, fn: () => void): void;
|
|
19
19
|
|
|
@@ -22,29 +22,29 @@ export interface SliceBuilder {
|
|
|
22
22
|
reaction(name: string, fn: () => void): void;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export const
|
|
26
|
-
via(integrationOrStream: Integration | string):
|
|
25
|
+
export const createMomentBuilder = (config: MomentConfig = {}): MomentBuilder => ({
|
|
26
|
+
via(integrationOrStream: Integration | string): MomentBuilder {
|
|
27
27
|
if (typeof integrationOrStream === 'string') {
|
|
28
|
-
return
|
|
28
|
+
return createMomentBuilder({ ...config, eventStream: integrationOrStream });
|
|
29
29
|
} else {
|
|
30
|
-
return
|
|
30
|
+
return createMomentBuilder({ ...config, integration: integrationOrStream });
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
|
|
34
|
-
retries(count: number):
|
|
35
|
-
return
|
|
34
|
+
retries(count: number): MomentBuilder {
|
|
35
|
+
return createMomentBuilder({ ...config, retries: count });
|
|
36
36
|
},
|
|
37
37
|
|
|
38
|
-
stream(eventStream: string):
|
|
39
|
-
return
|
|
38
|
+
stream(eventStream: string): MomentBuilder {
|
|
39
|
+
return createMomentBuilder({ ...config, eventStream });
|
|
40
40
|
},
|
|
41
41
|
|
|
42
42
|
command(name: string, fn: () => void) {
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
43
|
+
const currentScene = getCurrentScene();
|
|
44
|
+
if (!currentScene) throw new Error('No active scene');
|
|
45
45
|
|
|
46
|
-
// Create a properly typed command
|
|
47
|
-
const slice:
|
|
46
|
+
// Create a properly typed command moment
|
|
47
|
+
const slice: CommandMoment = {
|
|
48
48
|
type: 'command',
|
|
49
49
|
name,
|
|
50
50
|
client: { specs: [] },
|
|
@@ -54,16 +54,16 @@ export const createSliceBuilder = (config: SliceConfig = {}): SliceBuilder => ({
|
|
|
54
54
|
...(config.integration && { via: [config.integration.name] }),
|
|
55
55
|
...(config.retries != null && { additionalInstructions: `retries: ${config.retries}` }),
|
|
56
56
|
};
|
|
57
|
-
|
|
57
|
+
addMoment(slice);
|
|
58
58
|
fn();
|
|
59
59
|
},
|
|
60
60
|
|
|
61
61
|
query(name: string, fn: () => void) {
|
|
62
|
-
const
|
|
63
|
-
if (!
|
|
62
|
+
const currentScene = getCurrentScene();
|
|
63
|
+
if (!currentScene) throw new Error('No active scene');
|
|
64
64
|
|
|
65
|
-
// Create a properly typed query
|
|
66
|
-
const slice:
|
|
65
|
+
// Create a properly typed query moment
|
|
66
|
+
const slice: QueryMoment = {
|
|
67
67
|
type: 'query',
|
|
68
68
|
name,
|
|
69
69
|
client: { specs: [] },
|
|
@@ -74,18 +74,18 @@ export const createSliceBuilder = (config: SliceConfig = {}): SliceBuilder => ({
|
|
|
74
74
|
...(config.retries != null && { additionalInstructions: `retries: ${config.retries}` }),
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
addMoment(slice);
|
|
78
78
|
|
|
79
79
|
// Execute the function which will populate client/server blocks
|
|
80
80
|
fn();
|
|
81
81
|
},
|
|
82
82
|
|
|
83
83
|
reaction(name: string, fn: () => void) {
|
|
84
|
-
const
|
|
85
|
-
if (!
|
|
84
|
+
const currentScene = getCurrentScene();
|
|
85
|
+
if (!currentScene) throw new Error('No active scene');
|
|
86
86
|
|
|
87
|
-
// Create a properly typed react
|
|
88
|
-
const slice:
|
|
87
|
+
// Create a properly typed react moment (note: 'reaction' -> 'react' for schema compliance)
|
|
88
|
+
const slice: ReactMoment = {
|
|
89
89
|
type: 'react',
|
|
90
90
|
name,
|
|
91
91
|
server: { specs: [], data: undefined },
|
|
@@ -94,7 +94,7 @@ export const createSliceBuilder = (config: SliceConfig = {}): SliceBuilder => ({
|
|
|
94
94
|
...(config.integration && { via: [config.integration.name] }),
|
|
95
95
|
...(config.retries != null && { additionalInstructions: `retries: ${config.retries}` }),
|
|
96
96
|
};
|
|
97
|
-
|
|
97
|
+
addMoment(slice);
|
|
98
98
|
fn();
|
|
99
99
|
},
|
|
100
100
|
});
|
|
@@ -43,7 +43,7 @@ export function findCodeBoundaries(lines: string[]): { lastImportIdx: number } {
|
|
|
43
43
|
for (let i = 0; i < lines.length; i++) {
|
|
44
44
|
if (lines[i].match(/^\s*import\s/)) {
|
|
45
45
|
lastImportIdx = i;
|
|
46
|
-
} else if (lines[i].includes('
|
|
46
|
+
} else if (lines[i].includes('scene(')) {
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
49
|
}
|