speckeeper 0.1.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.
@@ -0,0 +1,1377 @@
1
+ import { z, ZodType } from 'zod';
2
+
3
+ declare const PhaseSchema: z.ZodEnum<["REQ", "HLD", "LLD", "IMPL", "OPS", "CI"]>;
4
+ type Phase = z.infer<typeof PhaseSchema>;
5
+ declare const PrioritySchema: z.ZodEnum<["must", "should", "could", "wont"]>;
6
+ type Priority = z.infer<typeof PrioritySchema>;
7
+ type RequirementId = string;
8
+ type ComponentId = string;
9
+ type BoundaryId = string;
10
+ type LayerId = string;
11
+ type EntityId = string;
12
+ type RelationId = string;
13
+ type RuleId = string;
14
+ type ScreenId = string;
15
+ type TransitionId = string;
16
+ type FormId = string;
17
+ type UIComponentId = string;
18
+ type ProcessFlowId = string;
19
+ type UseCaseId = string;
20
+ type ActorId = string;
21
+ type DTORequirementId = string;
22
+ type EventRequirementId = string;
23
+ type APIRefId = string;
24
+ type TableRefId = string;
25
+ type IaCRefId = string;
26
+ type BatchRefId = string;
27
+ type ErrorCaseId = string;
28
+ type TermId = string;
29
+ type StateId = string;
30
+ declare const createRequirementId: (id: string) => RequirementId;
31
+ declare const createComponentId: (id: string) => ComponentId;
32
+ declare const createBoundaryId: (id: string) => BoundaryId;
33
+ declare const createLayerId: (id: string) => LayerId;
34
+ declare const createEntityId: (id: string) => EntityId;
35
+ declare const createRelationId: (id: string) => RelationId;
36
+ declare const createRuleId: (id: string) => RuleId;
37
+ declare const createScreenId: (id: string) => ScreenId;
38
+ declare const createTransitionId: (id: string) => TransitionId;
39
+ declare const createFormId: (id: string) => FormId;
40
+ declare const createUIComponentId: (id: string) => UIComponentId;
41
+ declare const createProcessFlowId: (id: string) => ProcessFlowId;
42
+ declare const createUseCaseId: (id: string) => UseCaseId;
43
+ declare const createActorId: (id: string) => ActorId;
44
+ declare const createDTORequirementId: (id: string) => DTORequirementId;
45
+ declare const createEventRequirementId: (id: string) => EventRequirementId;
46
+ declare const createAPIRefId: (id: string) => APIRefId;
47
+ declare const createTableRefId: (id: string) => TableRefId;
48
+ declare const createIaCRefId: (id: string) => IaCRefId;
49
+ declare const createBatchRefId: (id: string) => BatchRefId;
50
+ declare const createErrorCaseId: (id: string) => ErrorCaseId;
51
+ declare const createTermId: (id: string) => TermId;
52
+ declare const createStateId: (id: string) => StateId;
53
+ declare const ID_PATTERNS: {
54
+ readonly requirement: RegExp;
55
+ readonly component: RegExp;
56
+ readonly boundary: RegExp;
57
+ readonly layer: RegExp;
58
+ readonly entity: RegExp;
59
+ readonly relation: RegExp;
60
+ readonly rule: RegExp;
61
+ readonly screen: RegExp;
62
+ readonly transition: RegExp;
63
+ readonly form: RegExp;
64
+ readonly uiComponent: RegExp;
65
+ readonly processFlow: RegExp;
66
+ readonly useCase: RegExp;
67
+ readonly actor: RegExp;
68
+ readonly dtoRequirement: RegExp;
69
+ readonly eventRequirement: RegExp;
70
+ readonly apiRef: RegExp;
71
+ readonly tableRef: RegExp;
72
+ readonly iacRef: RegExp;
73
+ readonly batchRef: RegExp;
74
+ readonly errorCase: RegExp;
75
+ readonly term: RegExp;
76
+ };
77
+ declare const ConcretizationSlotSchema: z.ZodObject<{
78
+ field: z.ZodString;
79
+ mustDecideBy: z.ZodEnum<["REQ", "HLD", "LLD", "IMPL", "OPS", "CI"]>;
80
+ value: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
81
+ description: z.ZodOptional<z.ZodString>;
82
+ }, "strip", z.ZodTypeAny, {
83
+ field: string;
84
+ mustDecideBy: "REQ" | "HLD" | "LLD" | "IMPL" | "OPS" | "CI";
85
+ value?: string | null | undefined;
86
+ description?: string | undefined;
87
+ }, {
88
+ field: string;
89
+ mustDecideBy: "REQ" | "HLD" | "LLD" | "IMPL" | "OPS" | "CI";
90
+ value?: string | null | undefined;
91
+ description?: string | undefined;
92
+ }>;
93
+ type ConcretizationSlot = z.infer<typeof ConcretizationSlotSchema>;
94
+ interface Link {
95
+ type: 'requirement' | 'component' | 'entity' | 'screen' | 'usecase' | 'external';
96
+ id: string;
97
+ label?: string;
98
+ }
99
+ declare const LinkSchema: z.ZodObject<{
100
+ type: z.ZodEnum<["requirement", "component", "entity", "screen", "usecase", "external"]>;
101
+ id: z.ZodString;
102
+ label: z.ZodOptional<z.ZodString>;
103
+ }, "strip", z.ZodTypeAny, {
104
+ type: "requirement" | "component" | "entity" | "screen" | "usecase" | "external";
105
+ id: string;
106
+ label?: string | undefined;
107
+ }, {
108
+ type: "requirement" | "component" | "entity" | "screen" | "usecase" | "external";
109
+ id: string;
110
+ label?: string | undefined;
111
+ }>;
112
+ type Severity = 'error' | 'warning' | 'info';
113
+ interface ValidationError {
114
+ severity: Severity;
115
+ code: string;
116
+ message: string;
117
+ path?: string;
118
+ id?: string;
119
+ suggestions?: string[];
120
+ }
121
+ interface ValidationResult {
122
+ valid: boolean;
123
+ errors: ValidationError[];
124
+ warnings: ValidationError[];
125
+ }
126
+ interface ModelRegistrySchema {
127
+ requirements: Map<RequirementId, unknown>;
128
+ components: Map<ComponentId, unknown>;
129
+ boundaries: Map<BoundaryId, unknown>;
130
+ layers: Map<LayerId, unknown>;
131
+ entities: Map<EntityId, unknown>;
132
+ relations: Map<RelationId, unknown>;
133
+ rules: Map<RuleId, unknown>;
134
+ screens: Map<ScreenId, unknown>;
135
+ transitions: Map<TransitionId, unknown>;
136
+ forms: Map<FormId, unknown>;
137
+ uiComponents: Map<UIComponentId, unknown>;
138
+ processFlows: Map<ProcessFlowId, unknown>;
139
+ useCases: Map<UseCaseId, unknown>;
140
+ actors: Map<ActorId, unknown>;
141
+ dtoRequirements: Map<DTORequirementId, unknown>;
142
+ eventRequirements: Map<EventRequirementId, unknown>;
143
+ apiRefs: Map<APIRefId, unknown>;
144
+ tableRefs: Map<TableRefId, unknown>;
145
+ iacRefs: Map<IaCRefId, unknown>;
146
+ batchRefs: Map<BatchRefId, unknown>;
147
+ errorCases: Map<ErrorCaseId, unknown>;
148
+ terms: Map<TermId, unknown>;
149
+ }
150
+
151
+ /**
152
+ * Export Context
153
+ * Context information passed to exporter functions
154
+ */
155
+ interface ExportContext {
156
+ /** Access to all models (MetaModelRegistry type, using unknown to avoid circular references) */
157
+ registry: unknown;
158
+ /** Configuration (SpeckeeperConfig type, using unknown to avoid circular references) */
159
+ config: unknown;
160
+ /** Output base directory */
161
+ outputDir: string;
162
+ /** Current date/time */
163
+ generatedAt: Date;
164
+ }
165
+ /**
166
+ * Lint Context
167
+ * Context information passed to lint functions
168
+ */
169
+ interface LintContext {
170
+ /** Access to all models (MetaModelRegistry type) */
171
+ registry: unknown;
172
+ /** Current phase */
173
+ phase?: 'REQ' | 'HLD' | 'LLD' | 'OPS';
174
+ /** Strict mode */
175
+ strict?: boolean;
176
+ }
177
+ /**
178
+ * Check Context
179
+ * Context information passed to external SSOT check functions
180
+ */
181
+ interface CheckContext {
182
+ /** Access to all models (MetaModelRegistry type) */
183
+ registry: unknown;
184
+ /** External SSOT file path */
185
+ sourcePath: string;
186
+ /** Configuration (SpeckeeperConfig type) */
187
+ config: unknown;
188
+ }
189
+ /**
190
+ * Lint Issue
191
+ */
192
+ interface LintIssue {
193
+ /** Issue message */
194
+ message: string;
195
+ /** Problematic field (optional) */
196
+ field?: string;
197
+ /** Fix suggestion (optional) */
198
+ suggestion?: string;
199
+ }
200
+ /**
201
+ * Check Result
202
+ */
203
+ interface CheckResult$1 {
204
+ /** Whether successful */
205
+ success: boolean;
206
+ /** List of error messages */
207
+ errors: CheckError[];
208
+ /** List of warning messages */
209
+ warnings: CheckWarning[];
210
+ }
211
+ interface CheckError {
212
+ /** Error message */
213
+ message: string;
214
+ /** Target model ID */
215
+ modelId: string;
216
+ /** External SSOT reference */
217
+ externalRef?: string;
218
+ }
219
+ interface CheckWarning {
220
+ /** Warning message */
221
+ message: string;
222
+ /** Target model ID */
223
+ modelId: string;
224
+ }
225
+ /**
226
+ * Markdown Exporter
227
+ */
228
+ interface MarkdownExporter<T> {
229
+ /** Single document generation */
230
+ single: (model: T, context: ExportContext) => string;
231
+ /** Index page generation (optional) */
232
+ index?: (models: T[], context: ExportContext) => string;
233
+ /** Output directory (relative path from docs/) */
234
+ outputDir: string;
235
+ /** Filename generation (default is model.id) */
236
+ filename?: (model: T) => string;
237
+ }
238
+ /**
239
+ * Mermaid Diagram Exporter
240
+ */
241
+ interface MermaidExporter<T> {
242
+ /** Diagram type */
243
+ diagramType: 'flowchart' | 'sequenceDiagram' | 'erDiagram' | 'stateDiagram' | 'C4Context' | 'C4Container' | 'C4Component' | 'custom';
244
+ /** Diagram generation function */
245
+ generate: (models: T[], context: ExportContext) => string;
246
+ /** Output file path (relative path from docs/) */
247
+ outputPath: string;
248
+ /** Diagram title */
249
+ title?: string;
250
+ }
251
+ /**
252
+ * JSON Schema Exporter Settings
253
+ */
254
+ interface JsonSchemaExporter {
255
+ /** Enabled */
256
+ enabled: boolean;
257
+ /** Output directory (relative path from specs/) */
258
+ outputDir: string;
259
+ }
260
+ /**
261
+ * Lint Rule
262
+ */
263
+ interface LintRule$1<T> {
264
+ /** Rule ID */
265
+ id: string;
266
+ /** Rule description */
267
+ description: string;
268
+ /** Severity */
269
+ severity: 'error' | 'warning' | 'info';
270
+ /** Check function */
271
+ check: (model: T, context: LintContext) => LintIssue | null;
272
+ }
273
+ /**
274
+ * External SSOT Checker
275
+ */
276
+ interface ExternalChecker$1<T> {
277
+ /** External SSOT type to check */
278
+ targetType: 'openapi' | 'ddl' | 'iac' | 'custom';
279
+ /** Execute check */
280
+ check: (model: T, externalSource: unknown, context: CheckContext) => CheckResult$1;
281
+ /** Get external SSOT file path (from model) */
282
+ getSourcePath?: (model: T) => string | undefined;
283
+ }
284
+ /**
285
+ * Inter-model Reference Definition (for traceability)
286
+ */
287
+ interface ReferenceDefinition {
288
+ /** Field name with reference */
289
+ field: string;
290
+ /** Referenced model ID */
291
+ targetModel: string;
292
+ /** Whether reference is required */
293
+ required?: boolean;
294
+ /** Whether reference is array */
295
+ isArray?: boolean;
296
+ }
297
+ /**
298
+ * Model Definition
299
+ * Interface for users to define new entities
300
+ */
301
+ interface ModelDefinition<T extends z.ZodTypeAny = z.ZodTypeAny> {
302
+ /** Model unique identifier (kebab-case recommended) */
303
+ id: string;
304
+ /** Model name (PascalCase recommended) */
305
+ name: string;
306
+ /** Model description */
307
+ description: string;
308
+ /** Zod Schema */
309
+ schema: T;
310
+ /** ID prefix for generation */
311
+ idPrefix: string;
312
+ /** Exporter settings */
313
+ exporters?: {
314
+ /** Markdown exporter */
315
+ markdown?: MarkdownExporter<z.infer<T>>;
316
+ /** Mermaid diagram exporter (multiple allowed) */
317
+ mermaid?: MermaidExporter<z.infer<T>> | MermaidExporter<z.infer<T>>[];
318
+ /** JSON Schema exporter */
319
+ jsonSchema?: JsonSchemaExporter;
320
+ };
321
+ /** Lint rules */
322
+ lintRules?: LintRule$1<z.infer<T>>[];
323
+ /** External SSOT checker */
324
+ externalChecker?: ExternalChecker$1<z.infer<T>>;
325
+ /** Reference definitions (for traceability) */
326
+ references?: ReferenceDefinition[];
327
+ /** DSL function name (the Xxx part of defineXxx) */
328
+ dslName?: string;
329
+ /** Phase (the phase where this model is primarily used) */
330
+ phase?: 'REQ' | 'HLD' | 'LLD' | 'OPS';
331
+ }
332
+ /**
333
+ * Meta Model Registry
334
+ * Manages registered model definitions and model instances
335
+ */
336
+ interface MetaModelRegistry {
337
+ /** Registered model definitions */
338
+ definitions: Map<string, ModelDefinition>;
339
+ /** Model instances (Map<instanceId, instance> for each model ID) */
340
+ instances: Map<string, Map<string, unknown>>;
341
+ }
342
+ /**
343
+ * Additional settings for meta model
344
+ */
345
+ interface MetaModelConfig {
346
+ /** Custom model definitions */
347
+ models?: ModelDefinition[];
348
+ /** External SSOT settings */
349
+ externalSsot?: {
350
+ openapi?: {
351
+ enabled: boolean;
352
+ paths: string[];
353
+ };
354
+ ddl?: {
355
+ enabled: boolean;
356
+ type: 'ddl' | 'prisma' | 'typeorm' | 'drizzle';
357
+ path: string;
358
+ };
359
+ iac?: {
360
+ enabled: boolean;
361
+ type: 'cloudformation' | 'cdk' | 'terraform';
362
+ path: string;
363
+ };
364
+ };
365
+ }
366
+ /**
367
+ * Base type for model instances
368
+ * All model instances have an id
369
+ */
370
+ interface BaseModelInstance {
371
+ id: string;
372
+ }
373
+ /**
374
+ * Helper type for creating type-safe model definitions
375
+ */
376
+ type InferModelType<T extends ModelDefinition> = z.infer<T['schema']>;
377
+ declare const ReferenceDefinitionSchema: z.ZodObject<{
378
+ field: z.ZodString;
379
+ targetModel: z.ZodString;
380
+ required: z.ZodOptional<z.ZodBoolean>;
381
+ isArray: z.ZodOptional<z.ZodBoolean>;
382
+ }, "strip", z.ZodTypeAny, {
383
+ field: string;
384
+ targetModel: string;
385
+ required?: boolean | undefined;
386
+ isArray?: boolean | undefined;
387
+ }, {
388
+ field: string;
389
+ targetModel: string;
390
+ required?: boolean | undefined;
391
+ isArray?: boolean | undefined;
392
+ }>;
393
+ declare const LintIssueSchema: z.ZodObject<{
394
+ message: z.ZodString;
395
+ field: z.ZodOptional<z.ZodString>;
396
+ suggestion: z.ZodOptional<z.ZodString>;
397
+ }, "strip", z.ZodTypeAny, {
398
+ message: string;
399
+ field?: string | undefined;
400
+ suggestion?: string | undefined;
401
+ }, {
402
+ message: string;
403
+ field?: string | undefined;
404
+ suggestion?: string | undefined;
405
+ }>;
406
+ declare const CheckErrorSchema: z.ZodObject<{
407
+ message: z.ZodString;
408
+ modelId: z.ZodString;
409
+ externalRef: z.ZodOptional<z.ZodString>;
410
+ }, "strip", z.ZodTypeAny, {
411
+ message: string;
412
+ modelId: string;
413
+ externalRef?: string | undefined;
414
+ }, {
415
+ message: string;
416
+ modelId: string;
417
+ externalRef?: string | undefined;
418
+ }>;
419
+ declare const CheckWarningSchema: z.ZodObject<{
420
+ message: z.ZodString;
421
+ modelId: z.ZodString;
422
+ }, "strip", z.ZodTypeAny, {
423
+ message: string;
424
+ modelId: string;
425
+ }, {
426
+ message: string;
427
+ modelId: string;
428
+ }>;
429
+ declare const CheckResultSchema: z.ZodObject<{
430
+ success: z.ZodBoolean;
431
+ errors: z.ZodArray<z.ZodObject<{
432
+ message: z.ZodString;
433
+ modelId: z.ZodString;
434
+ externalRef: z.ZodOptional<z.ZodString>;
435
+ }, "strip", z.ZodTypeAny, {
436
+ message: string;
437
+ modelId: string;
438
+ externalRef?: string | undefined;
439
+ }, {
440
+ message: string;
441
+ modelId: string;
442
+ externalRef?: string | undefined;
443
+ }>, "many">;
444
+ warnings: z.ZodArray<z.ZodObject<{
445
+ message: z.ZodString;
446
+ modelId: z.ZodString;
447
+ }, "strip", z.ZodTypeAny, {
448
+ message: string;
449
+ modelId: string;
450
+ }, {
451
+ message: string;
452
+ modelId: string;
453
+ }>, "many">;
454
+ }, "strip", z.ZodTypeAny, {
455
+ success: boolean;
456
+ errors: {
457
+ message: string;
458
+ modelId: string;
459
+ externalRef?: string | undefined;
460
+ }[];
461
+ warnings: {
462
+ message: string;
463
+ modelId: string;
464
+ }[];
465
+ }, {
466
+ success: boolean;
467
+ errors: {
468
+ message: string;
469
+ modelId: string;
470
+ externalRef?: string | undefined;
471
+ }[];
472
+ warnings: {
473
+ message: string;
474
+ modelId: string;
475
+ }[];
476
+ }>;
477
+
478
+ /**
479
+ * Definition and validation of model relations
480
+ */
481
+
482
+ /**
483
+ * Model abstraction level
484
+ *
485
+ * - L0: Business + Domain Analysis (Why / Problem space)
486
+ * Desired outcomes/value, business flows, actors, terminology, business rules
487
+ * - L1: Requirements (What)
488
+ * Functional/non-functional requirements, constraints, acceptance criteria
489
+ * - L2: Design (How / Direction)
490
+ * Architecture, component breakdown, domain model, key sequences
491
+ * - L3: Detailed Design/Implementation (How to build / Concrete artifacts)
492
+ * Screen/API/DB definitions, external SSOT references
493
+ */
494
+ type ModelLevel = 'L0' | 'L1' | 'L2' | 'L3';
495
+ /**
496
+ * Get numeric index of level
497
+ */
498
+ declare function getLevelIndex(level: ModelLevel): number;
499
+ /**
500
+ * Relation types
501
+ */
502
+ declare const RELATION_TYPES: readonly ["dependsOn", "uses", "includes", "implements", "refines", "verifies", "satisfies", "traces", "relatedTo"];
503
+ type RelationType = typeof RELATION_TYPES[number];
504
+ /**
505
+ * Relation schema
506
+ */
507
+ declare const RelationSchema: z.ZodObject<{
508
+ /** Relation type */
509
+ type: z.ZodEnum<["dependsOn", "uses", "includes", "implements", "refines", "verifies", "satisfies", "traces", "relatedTo"]>;
510
+ /** Target ID */
511
+ target: z.ZodString;
512
+ /** Description (optional) */
513
+ description: z.ZodOptional<z.ZodString>;
514
+ }, "strip", z.ZodTypeAny, {
515
+ type: "includes" | "dependsOn" | "uses" | "implements" | "refines" | "verifies" | "satisfies" | "traces" | "relatedTo";
516
+ target: string;
517
+ description?: string | undefined;
518
+ }, {
519
+ type: "includes" | "dependsOn" | "uses" | "implements" | "refines" | "verifies" | "satisfies" | "traces" | "relatedTo";
520
+ target: string;
521
+ description?: string | undefined;
522
+ }>;
523
+ /**
524
+ * Relation field to add to model schemas
525
+ * Usage: schema.extend({ relations: RelationsFieldSchema })
526
+ */
527
+ declare const RelationsFieldSchema: z.ZodOptional<z.ZodArray<z.ZodObject<{
528
+ /** Relation type */
529
+ type: z.ZodEnum<["dependsOn", "uses", "includes", "implements", "refines", "verifies", "satisfies", "traces", "relatedTo"]>;
530
+ /** Target ID */
531
+ target: z.ZodString;
532
+ /** Description (optional) */
533
+ description: z.ZodOptional<z.ZodString>;
534
+ }, "strip", z.ZodTypeAny, {
535
+ type: "includes" | "dependsOn" | "uses" | "implements" | "refines" | "verifies" | "satisfies" | "traces" | "relatedTo";
536
+ target: string;
537
+ description?: string | undefined;
538
+ }, {
539
+ type: "includes" | "dependsOn" | "uses" | "implements" | "refines" | "verifies" | "satisfies" | "traces" | "relatedTo";
540
+ target: string;
541
+ description?: string | undefined;
542
+ }>, "many">>;
543
+ type Relation = z.infer<typeof RelationSchema>;
544
+ /**
545
+ * Definition of relation constraints
546
+ */
547
+ interface RelationConstraint {
548
+ /** Allowed target levels (all levels allowed if not specified) */
549
+ allowedTargetLevels?: ModelLevel[];
550
+ /** Level constraint rule */
551
+ levelRule: 'source>target' | 'source>=target' | 'same' | 'any';
552
+ /** Direction of impact propagation */
553
+ propagation: 'forward' | 'backward' | 'both';
554
+ }
555
+ /**
556
+ * Constraint definitions per relation type
557
+ *
558
+ * Level hierarchy:
559
+ * L0 (Business) → L1 (Requirements) → L2 (Design) → L3 (Implementation)
560
+ * Abstract ───────────────────────────→ Concrete
561
+ */
562
+ declare const RELATION_CONSTRAINTS: Record<RelationType, RelationConstraint>;
563
+ /**
564
+ * Relation validation error
565
+ */
566
+ interface RelationValidationError {
567
+ type: 'level_violation' | 'target_level_violation' | 'self_reference' | 'cycle_detected';
568
+ message: string;
569
+ relation: Relation;
570
+ sourceId: string;
571
+ }
572
+ /**
573
+ * Validate level constraint for single relation
574
+ *
575
+ * @param sourceLevel - Source model level (set in _models/)
576
+ * @param sourceSpecId - Source spec ID
577
+ * @param relation - Relation
578
+ * @param targetLevel - Target model level
579
+ */
580
+ declare function validateRelationLevel(sourceLevel: ModelLevel | undefined, sourceSpecId: string, relation: Relation, targetLevel: ModelLevel | undefined): RelationValidationError | null;
581
+ /**
582
+ * Detect circular references
583
+ */
584
+ declare function detectCycles(relations: Array<{
585
+ sourceId: string;
586
+ targetId: string;
587
+ type: RelationType;
588
+ }>): RelationValidationError[];
589
+ /**
590
+ * Infer model ID from spec ID (prefix-based)
591
+ */
592
+ declare function inferModelIdFromSpecId(specId: string): string | undefined;
593
+
594
+ /**
595
+ * Model base class
596
+ *
597
+ * All model definitions inherit from this class
598
+ */
599
+
600
+ /**
601
+ * Lint rule definition
602
+ */
603
+ interface LintRule<T> {
604
+ id: string;
605
+ severity: 'error' | 'warning' | 'info';
606
+ message: string;
607
+ check: (spec: T) => boolean;
608
+ }
609
+ /**
610
+ * Lint result
611
+ */
612
+ interface LintResult {
613
+ ruleId: string;
614
+ severity: 'error' | 'warning' | 'info';
615
+ message: string;
616
+ specId?: string;
617
+ }
618
+ /**
619
+ * Exporter definition
620
+ */
621
+ interface Exporter<T> {
622
+ format: 'markdown' | 'json' | 'mermaid';
623
+ single?: (spec: T) => string;
624
+ index?: (specs: T[]) => string;
625
+ outputDir?: string;
626
+ filename?: (spec: T) => string;
627
+ }
628
+ /**
629
+ * External checker definition
630
+ */
631
+ interface ExternalChecker<T> {
632
+ targetType: string;
633
+ sourcePath: (spec: T) => string;
634
+ check: (spec: T, externalData: unknown) => CheckResult;
635
+ }
636
+ /**
637
+ * Check result
638
+ */
639
+ interface CheckResult {
640
+ success: boolean;
641
+ errors: {
642
+ message: string;
643
+ field?: string;
644
+ specId?: string;
645
+ }[];
646
+ warnings: {
647
+ message: string;
648
+ field?: string;
649
+ specId?: string;
650
+ }[];
651
+ }
652
+ /**
653
+ * Coverage result
654
+ */
655
+ interface CoverageResult {
656
+ /** Total target count */
657
+ total: number;
658
+ /** Covered count */
659
+ covered: number;
660
+ /** Uncovered count */
661
+ uncovered: number;
662
+ /** Coverage rate (%) */
663
+ coveragePercent: number;
664
+ /** Details of covered items */
665
+ coveredItems: {
666
+ id: string;
667
+ description?: string;
668
+ }[];
669
+ /** Details of uncovered items */
670
+ uncoveredItems: {
671
+ id: string;
672
+ description?: string;
673
+ sourceId?: string;
674
+ }[];
675
+ }
676
+ /**
677
+ * Coverage checker definition
678
+ *
679
+ * Verify cross-model consistency (coverage).
680
+ * Example: Whether TestRef covers acceptanceCriteria of Requirement
681
+ */
682
+ interface CoverageChecker<T> {
683
+ /** Target model ID for coverage (e.g. 'requirement') */
684
+ targetModel: string;
685
+ /** Description of coverage check */
686
+ description: string;
687
+ /** Execute coverage check */
688
+ check: (specs: T[], registry: Record<string, Map<string, unknown>>) => CoverageResult;
689
+ }
690
+ /**
691
+ * Render context
692
+ * Simplified version compatible with embedoc's EmbedContext
693
+ */
694
+ interface RenderContext {
695
+ /** Parameters (filter conditions other than format, etc.) */
696
+ params: Record<string, string | undefined>;
697
+ /** Markdown helpers */
698
+ markdown: {
699
+ /** Generate table */
700
+ table: (headers: string[], rows: (string | unknown)[][]) => string;
701
+ };
702
+ }
703
+ /**
704
+ * Renderer definition
705
+ *
706
+ * Model-specific rendering called from embeds
707
+ */
708
+ interface Renderer<T> {
709
+ /** Format ID ('table', 'list', 'detail', 'spec-chapter', etc.) */
710
+ format: string;
711
+ /** Rendering process */
712
+ render: (specs: T[], ctx: RenderContext) => string;
713
+ }
714
+ /**
715
+ * Model base class
716
+ *
717
+ * @template TSchema - Zod schema type
718
+ */
719
+ declare abstract class Model<TSchema extends ZodType> {
720
+ /** Singleton instance storage (per subclass) */
721
+ private static _instances;
722
+ /**
723
+ * Get singleton instance of the model
724
+ * Usage: RequirementModel.instance
725
+ */
726
+ static get instance(): Model<ZodType>;
727
+ /** Model ID ('requirement', 'usecase', etc.) */
728
+ abstract readonly id: string;
729
+ /** Model name ('Requirement', 'UseCase', etc.) */
730
+ abstract readonly name: string;
731
+ /** ID prefix ('REQ', 'UC', etc.) */
732
+ abstract readonly idPrefix: string;
733
+ /** Zod schema */
734
+ abstract readonly schema: TSchema;
735
+ /** Model description (optional) */
736
+ readonly description?: string;
737
+ /** External SSOT type (optional, e.g. 'OpenAPI', 'DDL/Prisma') */
738
+ readonly externalSsotType?: string;
739
+ /** Spec instance type */
740
+ protected get specType(): z.infer<TSchema>;
741
+ /** Lint rules (override in subclass) */
742
+ protected lintRules: LintRule<z.infer<TSchema>>[];
743
+ /** Exporters (override in subclass) */
744
+ protected exporters: Exporter<z.infer<TSchema>>[];
745
+ /** External checker (optional) */
746
+ protected externalChecker?: ExternalChecker<z.infer<TSchema>>;
747
+ /** Coverage checker (optional) */
748
+ protected coverageChecker?: CoverageChecker<z.infer<TSchema>>;
749
+ /** Model level (set in _models/) */
750
+ protected modelLevel?: ModelLevel;
751
+ /** Renderers (for embeds, override in subclass) */
752
+ protected renderers: Renderer<z.infer<TSchema>>[];
753
+ /**
754
+ * Get model level
755
+ * Returns modelLevel set in _models/
756
+ */
757
+ get level(): ModelLevel | undefined;
758
+ /**
759
+ * Execute schema validation
760
+ */
761
+ validate(spec: unknown): z.infer<TSchema>;
762
+ /**
763
+ * Schema validation (safe version, returns error object on failure)
764
+ */
765
+ safeParse(spec: unknown): {
766
+ success: true;
767
+ data: z.infer<TSchema>;
768
+ } | {
769
+ success: false;
770
+ error: z.ZodError;
771
+ };
772
+ /**
773
+ * Execute lint
774
+ */
775
+ lint(spec: z.infer<TSchema>): LintResult[];
776
+ /**
777
+ * Execute lint for multiple specs
778
+ */
779
+ lintAll(specs: z.infer<TSchema>[]): LintResult[];
780
+ /**
781
+ * Validate level constraints of relations
782
+ * @param spec - Spec instance (if it has relations property)
783
+ * @returns Array of validation errors
784
+ */
785
+ validateRelations(spec: z.infer<TSchema>): RelationValidationError[];
786
+ /**
787
+ * Validate relations of multiple specs (including circular reference check)
788
+ */
789
+ validateAllRelations(specs: z.infer<TSchema>[]): RelationValidationError[];
790
+ /**
791
+ * Export in specified format (single spec)
792
+ */
793
+ exportSingle(spec: z.infer<TSchema>, format: string): string | null;
794
+ /**
795
+ * Export in specified format (index)
796
+ */
797
+ exportIndex(specs: z.infer<TSchema>[], format: string): string | null;
798
+ /**
799
+ * Get exporter output directory
800
+ */
801
+ getOutputDir(format: string): string | null;
802
+ /**
803
+ * Get filename
804
+ */
805
+ getFilename(spec: z.infer<TSchema>, format: string): string | null;
806
+ /**
807
+ * Check consistency with external SSOT
808
+ */
809
+ check(spec: z.infer<TSchema>, externalData: unknown): CheckResult;
810
+ /**
811
+ * Get external SSOT path
812
+ */
813
+ getExternalSourcePath(spec: z.infer<TSchema>): string | null;
814
+ /**
815
+ * Execute coverage check
816
+ * @param specs - Array of spec instances for this model
817
+ * @param registry - Registry of all models
818
+ */
819
+ checkCoverage(specs: z.infer<TSchema>[], registry: Record<string, Map<string, unknown>>): CoverageResult | null;
820
+ /**
821
+ * Get coverage checker
822
+ */
823
+ getCoverageChecker(): CoverageChecker<z.infer<TSchema>> | undefined;
824
+ /**
825
+ * Get lint rules
826
+ */
827
+ getLintRules(): LintRule<z.infer<TSchema>>[];
828
+ /**
829
+ * Get exporters
830
+ */
831
+ getExporters(): Exporter<z.infer<TSchema>>[];
832
+ /**
833
+ * Render in specified format
834
+ * @param format - Format ID ('table', 'list', 'detail', etc.)
835
+ * @param specs - Array of specs to render
836
+ * @param ctx - Render context
837
+ * @returns Rendered result (Markdown string), null if no matching renderer
838
+ */
839
+ render(format: string, specs: z.infer<TSchema>[], ctx: RenderContext): string | null;
840
+ /**
841
+ * Get list of available formats
842
+ */
843
+ getAvailableFormats(): string[];
844
+ /**
845
+ * Get renderers
846
+ */
847
+ getRenderers(): Renderer<z.infer<TSchema>>[];
848
+ /**
849
+ * Check if renderer exists for specific format
850
+ */
851
+ hasRenderer(format: string): boolean;
852
+ }
853
+ /**
854
+ * Register model
855
+ */
856
+ declare function registerModel(model: Model<any>): void;
857
+ /**
858
+ * Get model
859
+ */
860
+ declare function getModel(id: string): Model<any> | undefined;
861
+ /**
862
+ * Get all registered models
863
+ */
864
+ declare function getAllModels(): Model<any>[];
865
+ /**
866
+ * Clear registry
867
+ */
868
+ declare function clearModelRegistry(): void;
869
+
870
+ /**
871
+ * Register model definition
872
+ */
873
+ declare function registerModelDefinition<T extends z.ZodTypeAny>(definition: ModelDefinition<T>): void;
874
+ /**
875
+ * Register multiple model definitions at once
876
+ */
877
+ declare function registerModelDefinitions(definitions: ModelDefinition[]): void;
878
+ /**
879
+ * Get model definition
880
+ */
881
+ declare function getModelDefinition(modelId: string): ModelDefinition | undefined;
882
+ /**
883
+ * Get all model definitions
884
+ */
885
+ declare function getAllModelDefinitions(): ModelDefinition[];
886
+ /**
887
+ * Register model instance
888
+ */
889
+ declare function registerModelInstance<T extends {
890
+ id: string;
891
+ }>(modelId: string, instance: T): void;
892
+ /**
893
+ * Get model instance
894
+ */
895
+ declare function getModelInstance<T = unknown>(modelId: string, instanceId: string): T | undefined;
896
+ /**
897
+ * Get all instances of a model
898
+ */
899
+ declare function getAllModelInstances<T = unknown>(modelId: string): T[];
900
+ /**
901
+ * Get all instances of all models (flattened)
902
+ */
903
+ declare function getAllInstances(): Array<{
904
+ modelId: string;
905
+ instance: unknown;
906
+ }>;
907
+ /**
908
+ * Get global registry
909
+ */
910
+ declare function getGlobalModelRegistry(): MetaModelRegistry;
911
+ /**
912
+ * Reset registry (for testing)
913
+ */
914
+ declare function resetModelRegistry(): void;
915
+ /**
916
+ * Reset instances only (keep definitions)
917
+ */
918
+ declare function resetModelInstances(): void;
919
+ /**
920
+ * Execute lint for specific model
921
+ */
922
+ declare function lintModel<T extends {
923
+ id: string;
924
+ }>(modelId: string, instance: T, context: LintContext): Array<{
925
+ rule: LintRule$1<T>;
926
+ issue: LintIssue;
927
+ }>;
928
+ /**
929
+ * Execute lint for all models
930
+ */
931
+ declare function lintAllModels(context: LintContext): Array<{
932
+ modelId: string;
933
+ instanceId: string;
934
+ rule: LintRule$1<unknown>;
935
+ issue: LintIssue;
936
+ }>;
937
+ /**
938
+ * Execute Markdown export
939
+ */
940
+ declare function exportMarkdown(modelId: string, context: ExportContext): Array<{
941
+ path: string;
942
+ content: string;
943
+ }>;
944
+ /**
945
+ * Execute Mermaid diagram export
946
+ */
947
+ declare function exportMermaid(modelId: string, context: ExportContext): Array<{
948
+ path: string;
949
+ content: string;
950
+ }>;
951
+ /**
952
+ * Execute export for all models
953
+ */
954
+ declare function exportAllModels(context: ExportContext): Array<{
955
+ path: string;
956
+ content: string;
957
+ }>;
958
+ /**
959
+ * Execute external SSOT check
960
+ */
961
+ declare function checkExternalSsot<T extends {
962
+ id: string;
963
+ }>(modelId: string, externalSource: unknown, context: CheckContext): CheckResult$1;
964
+ /**
965
+ * Resolve reference
966
+ */
967
+ declare function resolveReference(modelId: string, instanceId: string, field: string): unknown | undefined;
968
+ /**
969
+ * Check reference integrity
970
+ */
971
+ declare function checkReferenceIntegrity(): Array<{
972
+ modelId: string;
973
+ instanceId: string;
974
+ field: string;
975
+ targetModel: string;
976
+ missingIds: string[];
977
+ }>;
978
+ /**
979
+ * Get registry statistics
980
+ */
981
+ declare function getModelRegistryStats(): {
982
+ definitionCount: number;
983
+ instanceCounts: Record<string, number>;
984
+ totalInstances: number;
985
+ };
986
+
987
+ /**
988
+ * Configuration API for speckeeper
989
+ *
990
+ * Provides `defineConfig` and `defineModel` functions for users to
991
+ * create speckeeper.config.ts files with custom model definitions.
992
+ */
993
+
994
+ /**
995
+ * speckeeper configuration type
996
+ */
997
+ interface SpeckeeperConfigInput {
998
+ /** Project name */
999
+ projectName?: string;
1000
+ /** Project version */
1001
+ version?: string;
1002
+ /** Design files directory */
1003
+ designDir?: string;
1004
+ /** Docs output directory */
1005
+ docsDir?: string;
1006
+ /** Specs output directory */
1007
+ specsDir?: string;
1008
+ /** Custom model definitions (Model instances or ModelDefinition objects) */
1009
+ models?: any[];
1010
+ /** External SSOT configuration */
1011
+ externalSsot?: {
1012
+ openapi?: {
1013
+ enabled: boolean;
1014
+ paths: string[];
1015
+ };
1016
+ ddl?: {
1017
+ enabled: boolean;
1018
+ type: 'ddl' | 'prisma' | 'typeorm' | 'drizzle';
1019
+ path: string;
1020
+ };
1021
+ iac?: {
1022
+ enabled: boolean;
1023
+ type: 'cloudformation' | 'cdk' | 'terraform';
1024
+ path: string;
1025
+ };
1026
+ };
1027
+ /** Lint configuration */
1028
+ lint?: {
1029
+ /** Strict mode */
1030
+ strict?: boolean;
1031
+ /** Disable specific rules */
1032
+ disabledRules?: string[];
1033
+ };
1034
+ }
1035
+ /**
1036
+ * Resolved speckeeper configuration
1037
+ */
1038
+ interface ResolvedSpeckeeperConfig extends SpeckeeperConfigInput {
1039
+ designDir: string;
1040
+ docsDir: string;
1041
+ specsDir: string;
1042
+ }
1043
+ /**
1044
+ * Define speckeeper configuration
1045
+ *
1046
+ * @example
1047
+ * ```typescript
1048
+ * // speckeeper.config.ts
1049
+ * import { defineConfig, defineModel } from 'speckeeper';
1050
+ *
1051
+ * export default defineConfig({
1052
+ * projectName: 'My Project',
1053
+ * models: [
1054
+ * // Custom model definitions
1055
+ * ],
1056
+ * });
1057
+ * ```
1058
+ */
1059
+ declare function defineConfig(input: SpeckeeperConfigInput): ResolvedSpeckeeperConfig;
1060
+ /**
1061
+ * Model definition input type
1062
+ */
1063
+ interface ModelDefinitionInput<T extends z.ZodTypeAny> {
1064
+ /** Unique identifier for the model (kebab-case recommended) */
1065
+ id: string;
1066
+ /** Model name (PascalCase recommended) */
1067
+ name: string;
1068
+ /** Model description */
1069
+ description: string;
1070
+ /** Zod schema */
1071
+ schema: T;
1072
+ /** Prefix for ID generation */
1073
+ idPrefix: string;
1074
+ /** Exporter configuration */
1075
+ exporters?: {
1076
+ markdown?: MarkdownExporter<z.infer<T>>;
1077
+ mermaid?: MermaidExporter<z.infer<T>> | MermaidExporter<z.infer<T>>[];
1078
+ jsonSchema?: JsonSchemaExporter;
1079
+ };
1080
+ /** Lint rules */
1081
+ lintRules?: LintRule$1<z.infer<T>>[];
1082
+ /** External SSOT checker */
1083
+ externalChecker?: ExternalChecker$1<z.infer<T>>;
1084
+ /** Reference definitions */
1085
+ references?: ReferenceDefinition[];
1086
+ /** DSL function name */
1087
+ dslName?: string;
1088
+ /** Phase */
1089
+ phase?: 'REQ' | 'HLD' | 'LLD' | 'OPS';
1090
+ }
1091
+ /**
1092
+ * Create a custom model definition
1093
+ *
1094
+ * @example
1095
+ * ```typescript
1096
+ * const RetryPolicyModel = defineModel({
1097
+ * id: 'retry-policy',
1098
+ * name: 'RetryPolicy',
1099
+ * description: 'Retry policy definition',
1100
+ * schema: z.object({
1101
+ * id: z.string(),
1102
+ * name: z.string(),
1103
+ * maxAttempts: z.number().min(1),
1104
+ * initialDelay: z.number().min(0),
1105
+ * backoffMultiplier: z.number().min(1),
1106
+ * }),
1107
+ * idPrefix: 'RETRY',
1108
+ * exporters: {
1109
+ * markdown: {
1110
+ * single: (m) => `# ${m.name}\n\n- Max Attempts: ${m.maxAttempts}`,
1111
+ * outputDir: 'docs/retry-policies',
1112
+ * },
1113
+ * },
1114
+ * lintRules: [
1115
+ * {
1116
+ * id: 'retry-max-limit',
1117
+ * description: 'maxAttempts should not exceed 10',
1118
+ * severity: 'warning',
1119
+ * check: (m) => m.maxAttempts > 10
1120
+ * ? { message: `maxAttempts ${m.maxAttempts} exceeds recommended limit` }
1121
+ * : null,
1122
+ * },
1123
+ * ],
1124
+ * });
1125
+ * ```
1126
+ */
1127
+ declare function defineModel<T extends z.ZodTypeAny>(input: ModelDefinitionInput<T>): ModelDefinition<T>;
1128
+ /**
1129
+ * Helper to create Markdown exporter
1130
+ */
1131
+ declare function createMarkdownExporter<T>(config: {
1132
+ outputDir: string;
1133
+ single: (model: T, context: unknown) => string;
1134
+ index?: (models: T[], context: unknown) => string;
1135
+ filename?: (model: T) => string;
1136
+ }): MarkdownExporter<T>;
1137
+ /**
1138
+ * Helper to create Mermaid diagram exporter
1139
+ */
1140
+ declare function createMermaidExporter<T>(config: {
1141
+ diagramType: MermaidExporter<T>['diagramType'];
1142
+ outputPath: string;
1143
+ generate: (models: T[], context: unknown) => string;
1144
+ title?: string;
1145
+ }): MermaidExporter<T>;
1146
+ /**
1147
+ * Helper to create lint rule
1148
+ */
1149
+ declare function createLintRule<T>(config: {
1150
+ id: string;
1151
+ description: string;
1152
+ severity: 'error' | 'warning' | 'info';
1153
+ check: (model: T, context: unknown) => {
1154
+ message: string;
1155
+ field?: string;
1156
+ suggestion?: string;
1157
+ } | null;
1158
+ }): LintRule$1<T>;
1159
+ /**
1160
+ * Load speckeeper.config.ts file and register custom models
1161
+ */
1162
+ declare function loadSpeckeeperConfig(configPath?: string): Promise<ResolvedSpeckeeperConfig | null>;
1163
+
1164
+ /**
1165
+ * Specification-compliant output path definitions
1166
+ *
1167
+ * Human-readable artifacts (docs/):
1168
+ * requirements/ - Requirements Markdown
1169
+ * usecases/ - Use cases
1170
+ * architecture/ - Architecture (C4 diagrams)
1171
+ * data-model/ - Conceptual model (ER diagrams)
1172
+ * screens/ - Screen specifications
1173
+ * flows/ - Process flows
1174
+ * glossary/ - Glossary
1175
+ *
1176
+ * Machine-readable artifacts (specs/):
1177
+ * schemas/entities/ - Entity JSON Schema
1178
+ * index.json - Aggregated data
1179
+ */
1180
+ interface OutputPaths {
1181
+ requirements: string;
1182
+ usecases: string;
1183
+ architecture: string;
1184
+ dataModel: string;
1185
+ screens: string;
1186
+ flows: string;
1187
+ glossary: string;
1188
+ component: string;
1189
+ schemasEntities: string;
1190
+ }
1191
+ interface SpeckeeperConfig {
1192
+ projectName?: string;
1193
+ version?: string;
1194
+ srcDir: string;
1195
+ requirementsDir?: string;
1196
+ designDir?: string;
1197
+ usecasesDir?: string;
1198
+ docsDir: string;
1199
+ specsDir: string;
1200
+ externalSsot?: {
1201
+ openapi?: {
1202
+ enabled: boolean;
1203
+ paths: string[];
1204
+ microContracts?: {
1205
+ enabled: boolean;
1206
+ requiredExtensions?: string[];
1207
+ strictMode?: boolean;
1208
+ };
1209
+ };
1210
+ ddl?: {
1211
+ enabled: boolean;
1212
+ paths: string[];
1213
+ type: 'ddl' | 'prisma' | 'typeorm' | 'drizzle';
1214
+ };
1215
+ iac?: {
1216
+ enabled: boolean;
1217
+ paths: string[];
1218
+ type: 'cloudformation' | 'terraform' | 'cdk';
1219
+ };
1220
+ };
1221
+ lint?: {
1222
+ architecture?: {
1223
+ allowCrossBoundaryDependencies?: boolean;
1224
+ allowCrossLayerViolations?: boolean;
1225
+ maxComponentsPerDiagram?: number;
1226
+ };
1227
+ conceptModel?: {
1228
+ requireEntityDescription?: boolean;
1229
+ requireAggregateRoot?: boolean;
1230
+ warnOnOrphanEntities?: boolean;
1231
+ namingConvention?: 'PascalCase' | 'camelCase' | 'snake_case' | 'none';
1232
+ };
1233
+ screen?: {
1234
+ warnOnOrphanScreens?: boolean;
1235
+ warnOnDeadEnds?: boolean;
1236
+ checkAuthPaths?: boolean;
1237
+ };
1238
+ phaseGate?: {
1239
+ currentPhase?: 'REQ' | 'HLD' | 'LLD' | 'OPS';
1240
+ strictMode?: boolean;
1241
+ };
1242
+ };
1243
+ build?: {
1244
+ generateMermaidImages?: boolean;
1245
+ mermaidCliPath?: string;
1246
+ };
1247
+ models?: unknown[];
1248
+ }
1249
+ /**
1250
+ * Get output paths compliant with specification
1251
+ */
1252
+ declare function getOutputPaths(config: SpeckeeperConfig, cwd?: string): OutputPaths;
1253
+ /**
1254
+ * List of expected output paths (for drift check)
1255
+ */
1256
+ declare function getExpectedOutputDirs(config: SpeckeeperConfig, cwd?: string): string[];
1257
+ /**
1258
+ * Validate if output path complies with specification
1259
+ */
1260
+ declare function validateOutputPaths(actualPath: string, config: SpeckeeperConfig, cwd?: string): {
1261
+ valid: boolean;
1262
+ expectedPaths: string[];
1263
+ message?: string;
1264
+ };
1265
+ declare function findConfigFile(startDir?: string): string | null;
1266
+ declare function loadConfig(configPath?: string, cwd?: string): Promise<SpeckeeperConfig>;
1267
+ declare function validateConfig(config: SpeckeeperConfig): string[];
1268
+
1269
+ interface WriteResult {
1270
+ path: string;
1271
+ created: boolean;
1272
+ updated: boolean;
1273
+ unchanged: boolean;
1274
+ }
1275
+ declare function ensureDir(dirPath: string): void;
1276
+ declare function writeFile(filePath: string, content: string): WriteResult;
1277
+ declare function writeJsonFile(filePath: string, data: unknown, indent?: number): WriteResult;
1278
+ interface BatchWriteResult {
1279
+ results: WriteResult[];
1280
+ created: number;
1281
+ updated: number;
1282
+ unchanged: number;
1283
+ total: number;
1284
+ }
1285
+ declare function batchWriteFiles(files: Array<{
1286
+ path: string;
1287
+ content: string;
1288
+ }>): BatchWriteResult;
1289
+ interface DriftResult {
1290
+ file: string;
1291
+ hasDrift: boolean;
1292
+ expectedHash?: string;
1293
+ actualHash?: string;
1294
+ missing?: boolean;
1295
+ }
1296
+ declare function computeHash(content: string): string;
1297
+ declare function checkFileDrift(filePath: string, expectedContent: string): DriftResult;
1298
+ declare function checkBatchDrift(files: Array<{
1299
+ path: string;
1300
+ content: string;
1301
+ }>): DriftResult[];
1302
+ declare function findFiles(pattern: string, cwd?: string): Promise<string[]>;
1303
+ declare function findTypeScriptFiles(srcDir: string): Promise<string[]>;
1304
+ declare function findDefinitionFiles(srcDir: string, subDir: string): Promise<string[]>;
1305
+ declare function generateDocsPath(baseDir: string, category: string, filename: string): string;
1306
+ declare function generateSpecsPath(baseDir: string, category: string, filename: string): string;
1307
+
1308
+ /**
1309
+ * Model Loader
1310
+ *
1311
+ * Load models defined in TypeScript and convert to usable format for build command
1312
+ */
1313
+
1314
+ /**
1315
+ * Model registry - stores all loaded models
1316
+ */
1317
+ interface ModelRegistry {
1318
+ requirements: Map<string, unknown>;
1319
+ useCases: Map<string, unknown>;
1320
+ actors: Map<string, unknown>;
1321
+ components: Map<string, unknown>;
1322
+ entities: Map<string, unknown>;
1323
+ relations: Map<string, unknown>;
1324
+ rules: Map<string, unknown>;
1325
+ screens: Map<string, unknown>;
1326
+ transitions: Map<string, unknown>;
1327
+ forms: Map<string, unknown>;
1328
+ processFlows: Map<string, unknown>;
1329
+ glossaryTerms: Map<string, unknown>;
1330
+ apiRefs: Map<string, unknown>;
1331
+ tableRefs: Map<string, unknown>;
1332
+ testRefs: Map<string, unknown>;
1333
+ layers: Map<string, unknown>;
1334
+ boundaries: Map<string, unknown>;
1335
+ artifacts: Map<string, unknown>;
1336
+ }
1337
+ declare function createEmptyRegistry(): ModelRegistry;
1338
+ declare function getGlobalRegistry(): ModelRegistry;
1339
+ declare function resetGlobalRegistry(): void;
1340
+ /**
1341
+ * Dynamically import TS files from specified directory and collect models
1342
+ */
1343
+ declare function loadModelsFromDirectory(dirPath: string, options?: {
1344
+ recursive?: boolean;
1345
+ }): Promise<string[]>;
1346
+ /**
1347
+ * Load all models based on configuration
1348
+ */
1349
+ declare function loadAllModels(config: SpeckeeperConfig, cwd?: string): Promise<{
1350
+ registry: ModelRegistry;
1351
+ loadedFiles: string[];
1352
+ errors: Array<{
1353
+ file: string;
1354
+ error: unknown;
1355
+ }>;
1356
+ }>;
1357
+ /**
1358
+ * Get registry statistics
1359
+ */
1360
+ declare function getRegistryStats(registry: ModelRegistry): Record<string, number>;
1361
+ /**
1362
+ * Get all IDs in registry
1363
+ */
1364
+ declare function getAllIds(registry: ModelRegistry): Set<string>;
1365
+ /**
1366
+ * Identify model type from ID
1367
+ */
1368
+ declare function findModelType(registry: ModelRegistry, id: string): keyof ModelRegistry | null;
1369
+ /**
1370
+ * Get model by ID
1371
+ */
1372
+ declare function getModelById(registry: ModelRegistry, id: string): {
1373
+ type: keyof ModelRegistry;
1374
+ model: unknown;
1375
+ } | null;
1376
+
1377
+ export { type APIRefId, type ActorId, type BaseModelInstance, type BatchRefId, type BatchWriteResult, type BoundaryId, type CheckContext, type CheckError, CheckErrorSchema, type CheckResult, CheckResultSchema, type CheckWarning, CheckWarningSchema, type ComponentId, type ConcretizationSlot, ConcretizationSlotSchema, type CoverageChecker, type CoverageResult, type DTORequirementId, type DriftResult, type EntityId, type ErrorCaseId, type EventRequirementId, type ExportContext, type Exporter, type ExternalChecker, type FormId, ID_PATTERNS, type IaCRefId, type InferModelType, type JsonSchemaExporter, type LayerId, type Link, LinkSchema, type LintContext, type LintIssue, LintIssueSchema, type LintResult, type LintRule, type MarkdownExporter, type MermaidExporter, type MetaModelConfig, type MetaModelRegistry, Model, type ModelDefinition, type ModelDefinitionInput, type ModelLevel, type ModelRegistry, type ModelRegistrySchema, type OutputPaths, type Phase, PhaseSchema, type Priority, PrioritySchema, type ProcessFlowId, RELATION_CONSTRAINTS, RELATION_TYPES, type ReferenceDefinition, ReferenceDefinitionSchema, type Relation, type RelationId, RelationSchema, type RelationValidationError, RelationsFieldSchema, type RenderContext, type Renderer, type RequirementId, type ResolvedSpeckeeperConfig, type RuleId, type ScreenId, type Severity, type SpeckeeperConfig, type SpeckeeperConfigInput, type StateId, type TableRefId, type TermId, type TransitionId, type UIComponentId, type UseCaseId, type ValidationError, type ValidationResult, type WriteResult, batchWriteFiles, checkBatchDrift, checkExternalSsot, checkFileDrift, checkReferenceIntegrity, clearModelRegistry, computeHash, createAPIRefId, createActorId, createBatchRefId, createBoundaryId, createComponentId, createDTORequirementId, createEmptyRegistry, createEntityId, createErrorCaseId, createEventRequirementId, createFormId, createIaCRefId, createLayerId, createLintRule, createMarkdownExporter, createMermaidExporter, createProcessFlowId, createRelationId, createRequirementId, createRuleId, createScreenId, createStateId, createTableRefId, createTermId, createTransitionId, createUIComponentId, createUseCaseId, defineConfig, defineModel, detectCycles, ensureDir, exportAllModels, exportMarkdown, exportMermaid, findConfigFile, findDefinitionFiles, findFiles, findModelType, findTypeScriptFiles, generateDocsPath, generateSpecsPath, getAllIds, getAllInstances, getAllModelDefinitions, getAllModelInstances, getAllModels, getExpectedOutputDirs, getGlobalModelRegistry, getGlobalRegistry, getLevelIndex, getModel, getModelById, getModelDefinition, getModelInstance, getModelRegistryStats, getOutputPaths, getRegistryStats, inferModelIdFromSpecId, lintAllModels, lintModel, loadAllModels, loadConfig, loadModelsFromDirectory, loadSpeckeeperConfig, registerModel, registerModelDefinition, registerModelDefinitions, registerModelInstance, resetGlobalRegistry, resetModelInstances, resetModelRegistry, resolveReference, validateConfig, validateOutputPaths, validateRelationLevel, writeFile, writeJsonFile };