@fractary/faber 1.0.2 → 1.2.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.
Files changed (52) hide show
  1. package/README.md +12 -0
  2. package/dist/__tests__/config.test.d.ts +7 -0
  3. package/dist/__tests__/config.test.d.ts.map +1 -0
  4. package/dist/__tests__/config.test.js +297 -0
  5. package/dist/__tests__/config.test.js.map +1 -0
  6. package/dist/__tests__/integration/forge-integration.test.d.ts +7 -0
  7. package/dist/__tests__/integration/forge-integration.test.d.ts.map +1 -0
  8. package/dist/__tests__/integration/forge-integration.test.js +370 -0
  9. package/dist/__tests__/integration/forge-integration.test.js.map +1 -0
  10. package/dist/__tests__/integration/init-workflow.test.d.ts +7 -0
  11. package/dist/__tests__/integration/init-workflow.test.d.ts.map +1 -0
  12. package/dist/__tests__/integration/init-workflow.test.js +309 -0
  13. package/dist/__tests__/integration/init-workflow.test.js.map +1 -0
  14. package/dist/config/__tests__/initializer.test.d.ts +7 -0
  15. package/dist/config/__tests__/initializer.test.d.ts.map +1 -0
  16. package/dist/config/__tests__/initializer.test.js +317 -0
  17. package/dist/config/__tests__/initializer.test.js.map +1 -0
  18. package/dist/config/initializer.d.ts +68 -0
  19. package/dist/config/initializer.d.ts.map +1 -0
  20. package/dist/config/initializer.js +230 -0
  21. package/dist/config/initializer.js.map +1 -0
  22. package/dist/config.d.ts +94 -46
  23. package/dist/config.d.ts.map +1 -1
  24. package/dist/config.js +100 -18
  25. package/dist/config.js.map +1 -1
  26. package/dist/spec/__tests__/manager.test.d.ts +7 -0
  27. package/dist/spec/__tests__/manager.test.d.ts.map +1 -0
  28. package/dist/spec/__tests__/manager.test.js +206 -0
  29. package/dist/spec/__tests__/manager.test.js.map +1 -0
  30. package/dist/spec/manager.d.ts +9 -1
  31. package/dist/spec/manager.d.ts.map +1 -1
  32. package/dist/spec/manager.js +23 -1
  33. package/dist/spec/manager.js.map +1 -1
  34. package/dist/types.d.ts +24 -5
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/workflow/__tests__/agent-executor.test.d.ts +5 -0
  37. package/dist/workflow/__tests__/agent-executor.test.d.ts.map +1 -0
  38. package/dist/workflow/__tests__/agent-executor.test.js +282 -0
  39. package/dist/workflow/__tests__/agent-executor.test.js.map +1 -0
  40. package/dist/workflow/agent-executor.d.ts +59 -0
  41. package/dist/workflow/agent-executor.d.ts.map +1 -0
  42. package/dist/workflow/agent-executor.js +150 -0
  43. package/dist/workflow/agent-executor.js.map +1 -0
  44. package/dist/workflow/faber.d.ts +13 -0
  45. package/dist/workflow/faber.d.ts.map +1 -1
  46. package/dist/workflow/faber.js +85 -0
  47. package/dist/workflow/faber.js.map +1 -1
  48. package/dist/workflow/index.d.ts +2 -0
  49. package/dist/workflow/index.d.ts.map +1 -1
  50. package/dist/workflow/index.js +3 -1
  51. package/dist/workflow/index.js.map +1 -1
  52. package/package.json +5 -1
package/dist/config.d.ts CHANGED
@@ -5,6 +5,16 @@
5
5
  */
6
6
  import { z } from 'zod';
7
7
  import { FaberConfig, WorkConfig, RepoConfig, WorkflowConfig, SpecConfig, LogConfig, StateConfig } from './types';
8
+ /**
9
+ * Options for configuration loading functions
10
+ */
11
+ export interface LoadConfigOptions {
12
+ /**
13
+ * If true, return null instead of throwing when config is missing
14
+ * @default false
15
+ */
16
+ allowMissing?: boolean;
17
+ }
8
18
  declare const WorkConfigSchema: z.ZodObject<{
9
19
  platform: z.ZodEnum<["github", "jira", "linear"]>;
10
20
  owner: z.ZodOptional<z.ZodString>;
@@ -86,11 +96,11 @@ declare const WorkflowConfigSchema: z.ZodObject<{
86
96
  } & {
87
97
  refineSpec: z.ZodDefault<z.ZodBoolean>;
88
98
  }, "strip", z.ZodTypeAny, {
89
- enabled: boolean;
90
99
  refineSpec: boolean;
100
+ enabled: boolean;
91
101
  }, {
92
- enabled?: boolean | undefined;
93
102
  refineSpec?: boolean | undefined;
103
+ enabled?: boolean | undefined;
94
104
  }>>;
95
105
  build: z.ZodDefault<z.ZodObject<{
96
106
  enabled: z.ZodDefault<z.ZodBoolean>;
@@ -104,11 +114,11 @@ declare const WorkflowConfigSchema: z.ZodObject<{
104
114
  } & {
105
115
  maxRetries: z.ZodDefault<z.ZodNumber>;
106
116
  }, "strip", z.ZodTypeAny, {
107
- enabled: boolean;
108
117
  maxRetries: number;
118
+ enabled: boolean;
109
119
  }, {
110
- enabled?: boolean | undefined;
111
120
  maxRetries?: number | undefined;
121
+ enabled?: boolean | undefined;
112
122
  }>>;
113
123
  release: z.ZodDefault<z.ZodObject<{
114
124
  enabled: z.ZodDefault<z.ZodBoolean>;
@@ -116,53 +126,53 @@ declare const WorkflowConfigSchema: z.ZodObject<{
116
126
  requestReviews: z.ZodDefault<z.ZodBoolean>;
117
127
  reviewers: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
118
128
  }, "strip", z.ZodTypeAny, {
119
- enabled: boolean;
120
129
  requestReviews: boolean;
121
130
  reviewers: string[];
131
+ enabled: boolean;
122
132
  }, {
123
- enabled?: boolean | undefined;
124
133
  requestReviews?: boolean | undefined;
125
134
  reviewers?: string[] | undefined;
135
+ enabled?: boolean | undefined;
126
136
  }>>;
127
137
  }, "strip", z.ZodTypeAny, {
128
138
  frame: {
129
139
  enabled: boolean;
130
140
  };
131
141
  architect: {
132
- enabled: boolean;
133
142
  refineSpec: boolean;
143
+ enabled: boolean;
134
144
  };
135
145
  build: {
136
146
  enabled: boolean;
137
147
  };
138
148
  evaluate: {
139
- enabled: boolean;
140
149
  maxRetries: number;
150
+ enabled: boolean;
141
151
  };
142
152
  release: {
143
- enabled: boolean;
144
153
  requestReviews: boolean;
145
154
  reviewers: string[];
155
+ enabled: boolean;
146
156
  };
147
157
  }, {
148
158
  frame?: {
149
159
  enabled?: boolean | undefined;
150
160
  } | undefined;
151
161
  architect?: {
152
- enabled?: boolean | undefined;
153
162
  refineSpec?: boolean | undefined;
163
+ enabled?: boolean | undefined;
154
164
  } | undefined;
155
165
  build?: {
156
166
  enabled?: boolean | undefined;
157
167
  } | undefined;
158
168
  evaluate?: {
159
- enabled?: boolean | undefined;
160
169
  maxRetries?: number | undefined;
170
+ enabled?: boolean | undefined;
161
171
  } | undefined;
162
172
  release?: {
163
- enabled?: boolean | undefined;
164
173
  requestReviews?: boolean | undefined;
165
174
  reviewers?: string[] | undefined;
175
+ enabled?: boolean | undefined;
166
176
  } | undefined;
167
177
  }>;
168
178
  hooks: z.ZodOptional<z.ZodObject<{
@@ -206,20 +216,20 @@ declare const WorkflowConfigSchema: z.ZodObject<{
206
216
  enabled: boolean;
207
217
  };
208
218
  architect: {
209
- enabled: boolean;
210
219
  refineSpec: boolean;
220
+ enabled: boolean;
211
221
  };
212
222
  build: {
213
223
  enabled: boolean;
214
224
  };
215
225
  evaluate: {
216
- enabled: boolean;
217
226
  maxRetries: number;
227
+ enabled: boolean;
218
228
  };
219
229
  release: {
220
- enabled: boolean;
221
230
  requestReviews: boolean;
222
231
  reviewers: string[];
232
+ enabled: boolean;
223
233
  };
224
234
  };
225
235
  hooks?: {
@@ -240,20 +250,20 @@ declare const WorkflowConfigSchema: z.ZodObject<{
240
250
  enabled?: boolean | undefined;
241
251
  } | undefined;
242
252
  architect?: {
243
- enabled?: boolean | undefined;
244
253
  refineSpec?: boolean | undefined;
254
+ enabled?: boolean | undefined;
245
255
  } | undefined;
246
256
  build?: {
247
257
  enabled?: boolean | undefined;
248
258
  } | undefined;
249
259
  evaluate?: {
250
- enabled?: boolean | undefined;
251
260
  maxRetries?: number | undefined;
261
+ enabled?: boolean | undefined;
252
262
  } | undefined;
253
263
  release?: {
254
- enabled?: boolean | undefined;
255
264
  requestReviews?: boolean | undefined;
256
265
  reviewers?: string[] | undefined;
266
+ enabled?: boolean | undefined;
257
267
  } | undefined;
258
268
  };
259
269
  autonomy?: "dry-run" | "assisted" | "guarded" | "autonomous" | undefined;
@@ -411,11 +421,11 @@ declare const FaberConfigSchema: z.ZodObject<{
411
421
  } & {
412
422
  refineSpec: z.ZodDefault<z.ZodBoolean>;
413
423
  }, "strip", z.ZodTypeAny, {
414
- enabled: boolean;
415
424
  refineSpec: boolean;
425
+ enabled: boolean;
416
426
  }, {
417
- enabled?: boolean | undefined;
418
427
  refineSpec?: boolean | undefined;
428
+ enabled?: boolean | undefined;
419
429
  }>>;
420
430
  build: z.ZodDefault<z.ZodObject<{
421
431
  enabled: z.ZodDefault<z.ZodBoolean>;
@@ -429,11 +439,11 @@ declare const FaberConfigSchema: z.ZodObject<{
429
439
  } & {
430
440
  maxRetries: z.ZodDefault<z.ZodNumber>;
431
441
  }, "strip", z.ZodTypeAny, {
432
- enabled: boolean;
433
442
  maxRetries: number;
443
+ enabled: boolean;
434
444
  }, {
435
- enabled?: boolean | undefined;
436
445
  maxRetries?: number | undefined;
446
+ enabled?: boolean | undefined;
437
447
  }>>;
438
448
  release: z.ZodDefault<z.ZodObject<{
439
449
  enabled: z.ZodDefault<z.ZodBoolean>;
@@ -441,53 +451,53 @@ declare const FaberConfigSchema: z.ZodObject<{
441
451
  requestReviews: z.ZodDefault<z.ZodBoolean>;
442
452
  reviewers: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
443
453
  }, "strip", z.ZodTypeAny, {
444
- enabled: boolean;
445
454
  requestReviews: boolean;
446
455
  reviewers: string[];
456
+ enabled: boolean;
447
457
  }, {
448
- enabled?: boolean | undefined;
449
458
  requestReviews?: boolean | undefined;
450
459
  reviewers?: string[] | undefined;
460
+ enabled?: boolean | undefined;
451
461
  }>>;
452
462
  }, "strip", z.ZodTypeAny, {
453
463
  frame: {
454
464
  enabled: boolean;
455
465
  };
456
466
  architect: {
457
- enabled: boolean;
458
467
  refineSpec: boolean;
468
+ enabled: boolean;
459
469
  };
460
470
  build: {
461
471
  enabled: boolean;
462
472
  };
463
473
  evaluate: {
464
- enabled: boolean;
465
474
  maxRetries: number;
475
+ enabled: boolean;
466
476
  };
467
477
  release: {
468
- enabled: boolean;
469
478
  requestReviews: boolean;
470
479
  reviewers: string[];
480
+ enabled: boolean;
471
481
  };
472
482
  }, {
473
483
  frame?: {
474
484
  enabled?: boolean | undefined;
475
485
  } | undefined;
476
486
  architect?: {
477
- enabled?: boolean | undefined;
478
487
  refineSpec?: boolean | undefined;
488
+ enabled?: boolean | undefined;
479
489
  } | undefined;
480
490
  build?: {
481
491
  enabled?: boolean | undefined;
482
492
  } | undefined;
483
493
  evaluate?: {
484
- enabled?: boolean | undefined;
485
494
  maxRetries?: number | undefined;
495
+ enabled?: boolean | undefined;
486
496
  } | undefined;
487
497
  release?: {
488
- enabled?: boolean | undefined;
489
498
  requestReviews?: boolean | undefined;
490
499
  reviewers?: string[] | undefined;
500
+ enabled?: boolean | undefined;
491
501
  } | undefined;
492
502
  }>;
493
503
  hooks: z.ZodOptional<z.ZodObject<{
@@ -531,20 +541,20 @@ declare const FaberConfigSchema: z.ZodObject<{
531
541
  enabled: boolean;
532
542
  };
533
543
  architect: {
534
- enabled: boolean;
535
544
  refineSpec: boolean;
545
+ enabled: boolean;
536
546
  };
537
547
  build: {
538
548
  enabled: boolean;
539
549
  };
540
550
  evaluate: {
541
- enabled: boolean;
542
551
  maxRetries: number;
552
+ enabled: boolean;
543
553
  };
544
554
  release: {
545
- enabled: boolean;
546
555
  requestReviews: boolean;
547
556
  reviewers: string[];
557
+ enabled: boolean;
548
558
  };
549
559
  };
550
560
  hooks?: {
@@ -565,20 +575,20 @@ declare const FaberConfigSchema: z.ZodObject<{
565
575
  enabled?: boolean | undefined;
566
576
  } | undefined;
567
577
  architect?: {
568
- enabled?: boolean | undefined;
569
578
  refineSpec?: boolean | undefined;
579
+ enabled?: boolean | undefined;
570
580
  } | undefined;
571
581
  build?: {
572
582
  enabled?: boolean | undefined;
573
583
  } | undefined;
574
584
  evaluate?: {
575
- enabled?: boolean | undefined;
576
585
  maxRetries?: number | undefined;
586
+ enabled?: boolean | undefined;
577
587
  } | undefined;
578
588
  release?: {
579
- enabled?: boolean | undefined;
580
589
  requestReviews?: boolean | undefined;
581
590
  reviewers?: string[] | undefined;
591
+ enabled?: boolean | undefined;
582
592
  } | undefined;
583
593
  };
584
594
  autonomy?: "dry-run" | "assisted" | "guarded" | "autonomous" | undefined;
@@ -613,20 +623,20 @@ declare const FaberConfigSchema: z.ZodObject<{
613
623
  enabled: boolean;
614
624
  };
615
625
  architect: {
616
- enabled: boolean;
617
626
  refineSpec: boolean;
627
+ enabled: boolean;
618
628
  };
619
629
  build: {
620
630
  enabled: boolean;
621
631
  };
622
632
  evaluate: {
623
- enabled: boolean;
624
633
  maxRetries: number;
634
+ enabled: boolean;
625
635
  };
626
636
  release: {
627
- enabled: boolean;
628
637
  requestReviews: boolean;
629
638
  reviewers: string[];
639
+ enabled: boolean;
630
640
  };
631
641
  };
632
642
  hooks?: {
@@ -722,20 +732,20 @@ declare const FaberConfigSchema: z.ZodObject<{
722
732
  enabled?: boolean | undefined;
723
733
  } | undefined;
724
734
  architect?: {
725
- enabled?: boolean | undefined;
726
735
  refineSpec?: boolean | undefined;
736
+ enabled?: boolean | undefined;
727
737
  } | undefined;
728
738
  build?: {
729
739
  enabled?: boolean | undefined;
730
740
  } | undefined;
731
741
  evaluate?: {
732
- enabled?: boolean | undefined;
733
742
  maxRetries?: number | undefined;
743
+ enabled?: boolean | undefined;
734
744
  } | undefined;
735
745
  release?: {
736
- enabled?: boolean | undefined;
737
746
  requestReviews?: boolean | undefined;
738
747
  reviewers?: string[] | undefined;
748
+ enabled?: boolean | undefined;
739
749
  } | undefined;
740
750
  };
741
751
  autonomy?: "dry-run" | "assisted" | "guarded" | "autonomous" | undefined;
@@ -768,16 +778,31 @@ export declare function findProjectRoot(startDir?: string): string;
768
778
  export declare function loadJsonConfig<T>(filePath: string): T | null;
769
779
  /**
770
780
  * Load work plugin configuration
781
+ *
782
+ * @param projectRoot - Optional project root directory
783
+ * @param options - Loading options (allowMissing to return null instead of throwing)
784
+ * @returns WorkConfig or null
785
+ * @throws ConfigValidationError if missing and allowMissing is false
771
786
  */
772
- export declare function loadWorkConfig(projectRoot?: string): WorkConfig | null;
787
+ export declare function loadWorkConfig(projectRoot?: string, options?: LoadConfigOptions): WorkConfig | null;
773
788
  /**
774
789
  * Load repo plugin configuration
790
+ *
791
+ * @param projectRoot - Optional project root directory
792
+ * @param options - Loading options (allowMissing to return null instead of throwing)
793
+ * @returns RepoConfig or null
794
+ * @throws ConfigValidationError if missing and allowMissing is false
775
795
  */
776
- export declare function loadRepoConfig(projectRoot?: string): RepoConfig | null;
796
+ export declare function loadRepoConfig(projectRoot?: string, options?: LoadConfigOptions): RepoConfig | null;
777
797
  /**
778
798
  * Load the full FABER configuration
799
+ *
800
+ * @param projectRoot - Optional project root directory
801
+ * @param options - Loading options (allowMissing to return null instead of throwing)
802
+ * @returns FaberConfig or null (if allowMissing is true and config doesn't exist)
803
+ * @throws ConfigValidationError if config exists but is invalid, or if missing and allowMissing is false
779
804
  */
780
- export declare function loadFaberConfig(projectRoot?: string): FaberConfig | null;
805
+ export declare function loadFaberConfig(projectRoot?: string, options?: LoadConfigOptions): FaberConfig | null;
781
806
  /**
782
807
  * Validate a configuration object
783
808
  */
@@ -792,23 +817,46 @@ export declare function getDefaultWorkflowConfig(): WorkflowConfig;
792
817
  export declare function mergeWithDefaults(partial: Partial<WorkflowConfig>): WorkflowConfig;
793
818
  /**
794
819
  * Write configuration to file
820
+ *
821
+ * @deprecated Use ConfigInitializer.writeConfig() instead
795
822
  */
796
823
  export declare function writeConfig(configPath: string, config: Record<string, unknown>): void;
797
824
  /**
798
825
  * Initialize FABER configuration in a project
826
+ *
827
+ * @deprecated Use ConfigInitializer.generateDefaultConfig() and ConfigInitializer.writeConfig() instead
828
+ * @example
829
+ * // Old way (deprecated):
830
+ * // initFaberConfig(projectRoot, partialConfig);
831
+ *
832
+ * // New way:
833
+ * // const config = ConfigInitializer.generateDefaultConfig();
834
+ * // ConfigInitializer.writeConfig(config);
799
835
  */
800
836
  export declare function initFaberConfig(projectRoot: string, config: Partial<FaberConfig>): string;
801
837
  /**
802
838
  * Load spec configuration
839
+ *
840
+ * @param projectRoot - Optional project root directory
841
+ * @param options - Loading options (allowMissing to return default config instead of throwing)
842
+ * @returns SpecConfig (with defaults if allowMissing is true and config missing)
843
+ * @throws ConfigValidationError if missing and allowMissing is false
803
844
  */
804
- export declare function loadSpecConfig(projectRoot?: string): SpecConfig;
845
+ export declare function loadSpecConfig(projectRoot?: string, options?: LoadConfigOptions): SpecConfig;
805
846
  /**
806
847
  * Load log configuration
848
+ *
849
+ * @param projectRoot - Optional project root directory
850
+ * @returns LogConfig (always returns defaults if config missing - logs are optional)
807
851
  */
808
852
  export declare function loadLogConfig(projectRoot?: string): LogConfig;
809
853
  /**
810
854
  * Load state configuration
855
+ *
856
+ * @param projectRoot - Optional project root directory
857
+ * @returns StateConfig (always returns defaults if config missing - state is optional)
811
858
  */
812
859
  export declare function loadStateConfig(projectRoot?: string): StateConfig;
860
+ export { ConfigInitializer } from './config/initializer';
813
861
  export { FaberConfigSchema, WorkConfigSchema, RepoConfigSchema, WorkflowConfigSchema, };
814
862
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,WAAW,EACX,UAAU,EACV,UAAU,EACV,cAAc,EACd,UAAU,EACV,SAAS,EACT,WAAW,EACZ,MAAM,SAAS,CAAC;AAOjB,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;EAMpB,CAAC;AASH,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOpB,CAAC;AAgCH,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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(this && this.__importStar) || (function () {
38
38
  };
39
39
  })();
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.WorkflowConfigSchema = exports.RepoConfigSchema = exports.WorkConfigSchema = exports.FaberConfigSchema = void 0;
41
+ exports.WorkflowConfigSchema = exports.RepoConfigSchema = exports.WorkConfigSchema = exports.FaberConfigSchema = exports.ConfigInitializer = void 0;
42
42
  exports.findProjectRoot = findProjectRoot;
43
43
  exports.loadJsonConfig = loadJsonConfig;
44
44
  exports.loadWorkConfig = loadWorkConfig;
@@ -197,13 +197,28 @@ function loadJsonConfig(filePath) {
197
197
  }
198
198
  /**
199
199
  * Load work plugin configuration
200
+ *
201
+ * @param projectRoot - Optional project root directory
202
+ * @param options - Loading options (allowMissing to return null instead of throwing)
203
+ * @returns WorkConfig or null
204
+ * @throws ConfigValidationError if missing and allowMissing is false
200
205
  */
201
- function loadWorkConfig(projectRoot) {
206
+ function loadWorkConfig(projectRoot, options) {
202
207
  const root = projectRoot || findProjectRoot();
203
208
  const configPath = path.join(root, WORK_CONFIG_PATH);
204
209
  const config = loadJsonConfig(configPath);
205
210
  if (!config) {
206
- return null;
211
+ if (options?.allowMissing) {
212
+ return null;
213
+ }
214
+ throw new errors_1.ConfigValidationError([
215
+ 'Work plugin configuration not found.',
216
+ '',
217
+ 'Run the following command to create a default configuration:',
218
+ ' fractary init',
219
+ '',
220
+ `Expected config at: ${configPath}`,
221
+ ]);
207
222
  }
208
223
  // Handle handlers structure from plugins
209
224
  const handlers = config['handlers'];
@@ -227,17 +242,32 @@ function loadWorkConfig(projectRoot) {
227
242
  if (result.success) {
228
243
  return result.data;
229
244
  }
230
- return null;
245
+ throw new errors_1.ConfigValidationError(['Invalid work configuration']);
231
246
  }
232
247
  /**
233
248
  * Load repo plugin configuration
249
+ *
250
+ * @param projectRoot - Optional project root directory
251
+ * @param options - Loading options (allowMissing to return null instead of throwing)
252
+ * @returns RepoConfig or null
253
+ * @throws ConfigValidationError if missing and allowMissing is false
234
254
  */
235
- function loadRepoConfig(projectRoot) {
255
+ function loadRepoConfig(projectRoot, options) {
236
256
  const root = projectRoot || findProjectRoot();
237
257
  const configPath = path.join(root, REPO_CONFIG_PATH);
238
258
  const config = loadJsonConfig(configPath);
239
259
  if (!config) {
240
- return null;
260
+ if (options?.allowMissing) {
261
+ return null;
262
+ }
263
+ throw new errors_1.ConfigValidationError([
264
+ 'Repo plugin configuration not found.',
265
+ '',
266
+ 'Run the following command to create a default configuration:',
267
+ ' fractary init',
268
+ '',
269
+ `Expected config at: ${configPath}`,
270
+ ]);
241
271
  }
242
272
  // Handle handlers structure from plugins
243
273
  const handlers = config['handlers'];
@@ -261,19 +291,24 @@ function loadRepoConfig(projectRoot) {
261
291
  if (result.success) {
262
292
  return result.data;
263
293
  }
264
- return null;
294
+ throw new errors_1.ConfigValidationError(['Invalid repo configuration']);
265
295
  }
266
296
  /**
267
297
  * Load the full FABER configuration
298
+ *
299
+ * @param projectRoot - Optional project root directory
300
+ * @param options - Loading options (allowMissing to return null instead of throwing)
301
+ * @returns FaberConfig or null (if allowMissing is true and config doesn't exist)
302
+ * @throws ConfigValidationError if config exists but is invalid, or if missing and allowMissing is false
268
303
  */
269
- function loadFaberConfig(projectRoot) {
304
+ function loadFaberConfig(projectRoot, options) {
270
305
  const root = projectRoot || findProjectRoot();
271
306
  const configPath = path.join(root, FABER_CONFIG_PATH);
272
307
  const config = loadJsonConfig(configPath);
273
308
  if (!config) {
274
309
  // Try to construct from individual plugin configs
275
- const workConfig = loadWorkConfig(root);
276
- const repoConfig = loadRepoConfig(root);
310
+ const workConfig = loadWorkConfig(root, { allowMissing: true });
311
+ const repoConfig = loadRepoConfig(root, { allowMissing: true });
277
312
  if (workConfig && repoConfig) {
278
313
  return {
279
314
  schema_version: '1.0',
@@ -296,7 +331,18 @@ function loadFaberConfig(projectRoot) {
296
331
  },
297
332
  };
298
333
  }
299
- return null;
334
+ // Config not found - throw or return null based on options
335
+ if (options?.allowMissing) {
336
+ return null;
337
+ }
338
+ throw new errors_1.ConfigValidationError([
339
+ 'FABER configuration not found.',
340
+ '',
341
+ 'Run the following command to create a default configuration:',
342
+ ' fractary init',
343
+ '',
344
+ `Expected config at: ${configPath}`,
345
+ ]);
300
346
  }
301
347
  const result = FaberConfigSchema.safeParse(config);
302
348
  if (!result.success) {
@@ -361,6 +407,8 @@ function ensureDir(dirPath) {
361
407
  }
362
408
  /**
363
409
  * Write configuration to file
410
+ *
411
+ * @deprecated Use ConfigInitializer.writeConfig() instead
364
412
  */
365
413
  function writeConfig(configPath, config) {
366
414
  ensureDir(path.dirname(configPath));
@@ -368,6 +416,15 @@ function writeConfig(configPath, config) {
368
416
  }
369
417
  /**
370
418
  * Initialize FABER configuration in a project
419
+ *
420
+ * @deprecated Use ConfigInitializer.generateDefaultConfig() and ConfigInitializer.writeConfig() instead
421
+ * @example
422
+ * // Old way (deprecated):
423
+ * // initFaberConfig(projectRoot, partialConfig);
424
+ *
425
+ * // New way:
426
+ * // const config = ConfigInitializer.generateDefaultConfig();
427
+ * // ConfigInitializer.writeConfig(config);
371
428
  */
372
429
  function initFaberConfig(projectRoot, config) {
373
430
  const configPath = path.join(projectRoot, FABER_CONFIG_PATH);
@@ -389,50 +446,75 @@ function initFaberConfig(projectRoot, config) {
389
446
  // ============================================================================
390
447
  /**
391
448
  * Load spec configuration
449
+ *
450
+ * @param projectRoot - Optional project root directory
451
+ * @param options - Loading options (allowMissing to return default config instead of throwing)
452
+ * @returns SpecConfig (with defaults if allowMissing is true and config missing)
453
+ * @throws ConfigValidationError if missing and allowMissing is false
392
454
  */
393
- function loadSpecConfig(projectRoot) {
455
+ function loadSpecConfig(projectRoot, options) {
394
456
  const root = projectRoot || findProjectRoot();
395
- const faberConfig = loadFaberConfig(root);
457
+ const faberConfig = loadFaberConfig(root, { allowMissing: true });
396
458
  if (faberConfig?.artifacts?.specs) {
397
459
  return {
398
460
  localPath: path.join(root, faberConfig.artifacts.specs.local_path),
399
461
  };
400
462
  }
401
- // Default spec config
463
+ // No FABER config found - throw or return defaults based on options
464
+ if (!options?.allowMissing) {
465
+ throw new errors_1.ConfigValidationError([
466
+ 'Spec configuration not found.',
467
+ '',
468
+ 'Run the following command to create a default configuration:',
469
+ ' fractary init',
470
+ ]);
471
+ }
472
+ // Return default spec config
402
473
  return {
403
474
  localPath: path.join(root, 'specs'),
404
475
  };
405
476
  }
406
477
  /**
407
478
  * Load log configuration
479
+ *
480
+ * @param projectRoot - Optional project root directory
481
+ * @returns LogConfig (always returns defaults if config missing - logs are optional)
408
482
  */
409
483
  function loadLogConfig(projectRoot) {
410
484
  const root = projectRoot || findProjectRoot();
411
- const faberConfig = loadFaberConfig(root);
485
+ const faberConfig = loadFaberConfig(root, { allowMissing: true });
412
486
  if (faberConfig?.artifacts?.logs) {
413
487
  return {
414
488
  localPath: path.join(root, faberConfig.artifacts.logs.local_path),
415
489
  };
416
490
  }
417
- // Default log config
491
+ // No FABER config found - return defaults (logs are optional)
418
492
  return {
419
493
  localPath: path.join(root, '.fractary', 'logs'),
420
494
  };
421
495
  }
422
496
  /**
423
497
  * Load state configuration
498
+ *
499
+ * @param projectRoot - Optional project root directory
500
+ * @returns StateConfig (always returns defaults if config missing - state is optional)
424
501
  */
425
502
  function loadStateConfig(projectRoot) {
426
503
  const root = projectRoot || findProjectRoot();
427
- const faberConfig = loadFaberConfig(root);
504
+ const faberConfig = loadFaberConfig(root, { allowMissing: true });
428
505
  if (faberConfig?.artifacts?.state) {
429
506
  return {
430
507
  localPath: path.join(root, faberConfig.artifacts.state.local_path),
431
508
  };
432
509
  }
433
- // Default state config
510
+ // No FABER config found - return defaults (state is optional)
434
511
  return {
435
512
  localPath: path.join(root, '.faber', 'state'),
436
513
  };
437
514
  }
515
+ // ============================================================================
516
+ // Exports
517
+ // ============================================================================
518
+ var initializer_1 = require("./config/initializer");
519
+ Object.defineProperty(exports, "ConfigInitializer", { enumerable: true, get: function () { return initializer_1.ConfigInitializer; } });
438
520
  //# sourceMappingURL=config.js.map