@structured-vibe-coding/core 0.17.2 → 0.19.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 (50) hide show
  1. package/defaults/prices.yaml +9 -0
  2. package/defaults/search.yaml +18 -0
  3. package/defaults/teams/research/roles/researcher.md +29 -0
  4. package/defaults/teams/research/team.yaml +7 -0
  5. package/defaults/teams/software/roles/architect.md +31 -0
  6. package/defaults/teams/software/roles/dev-lead.md +32 -0
  7. package/defaults/teams/software/roles/developer.md +30 -0
  8. package/defaults/teams/software/roles/product-manager.md +32 -0
  9. package/defaults/teams/software/roles/product-owner.md +30 -0
  10. package/defaults/teams/software/roles/qa.md +35 -0
  11. package/defaults/teams/software/routing.yaml +28 -0
  12. package/defaults/teams/software/team.yaml +24 -0
  13. package/defaults/teams/solo/roles/developer.md +28 -0
  14. package/defaults/teams/solo/team.yaml +7 -0
  15. package/defaults/templates/plan.md +17 -0
  16. package/defaults/templates/review.md +11 -0
  17. package/defaults/templates/story.md +13 -0
  18. package/defaults/templates/task.md +11 -0
  19. package/defaults/workflows/team-software.yaml +153 -0
  20. package/dist/{agents-RWYBLZQE.js → agents-PSIOQEYH.js} +18 -7
  21. package/dist/{change-context-W4HDO2IK.js → change-context-EZJMSGSP.js} +2 -4
  22. package/dist/chunk-26YG6A4M.js +1210 -0
  23. package/dist/chunk-2FJBFYVJ.js +1576 -0
  24. package/dist/{chunk-KYWETNFU.js → chunk-4BRO7BOJ.js} +2 -4
  25. package/dist/{chunk-74OGSVJZ.js → chunk-H55RFAEI.js} +2 -2
  26. package/dist/chunk-HG7TPW5V.js +567 -0
  27. package/dist/{chunk-EPFURATC.js → chunk-O5SP6X5R.js} +89 -0
  28. package/dist/chunk-TGRV6WGS.js +3436 -0
  29. package/dist/{gather-BZDW4EN4.js → gather-7TSVKQO2.js} +3 -4
  30. package/dist/{greenfield-Z425JOMP.js → greenfield-QFA5WVHE.js} +5 -6
  31. package/dist/index.d.ts +1832 -44
  32. package/dist/index.js +5172 -992
  33. package/dist/{sources-PF45EUH2.js → sources-3TXUPU6V.js} +2 -3
  34. package/package.json +11 -3
  35. package/vendor/tree-sitter/NOTICE +29 -0
  36. package/vendor/tree-sitter/tree-sitter-javascript.wasm +0 -0
  37. package/vendor/tree-sitter/tree-sitter-python.wasm +0 -0
  38. package/vendor/tree-sitter/tree-sitter-rust.wasm +0 -0
  39. package/vendor/tree-sitter/tree-sitter-tsx.wasm +0 -0
  40. package/vendor/tree-sitter/tree-sitter-typescript.wasm +0 -0
  41. package/dist/chunk-67AUAGNV.js +0 -150
  42. package/dist/chunk-7JLDL2OK.js +0 -771
  43. package/dist/chunk-7MJYPJMR.js +0 -51
  44. package/dist/chunk-A752UVPF.js +0 -317
  45. package/dist/chunk-P3N67UEZ.js +0 -538
  46. package/dist/chunk-R5WQN4HA.js +0 -139
  47. package/dist/chunk-WHDG6OTG.js +0 -46
  48. package/dist/config-X5VDBVR4.js +0 -16
  49. package/dist/fs-J6DIV6CX.js +0 -28
  50. package/dist/paths-64GA32IZ.js +0 -28
package/dist/index.d.ts CHANGED
@@ -5,16 +5,20 @@ declare const GateSchema: z.ZodObject<{
5
5
  type: z.ZodDefault<z.ZodEnum<["none", "soft", "hard"]>>;
6
6
  mode: z.ZodDefault<z.ZodEnum<["none", "human_approval", "checklist"]>>;
7
7
  checklist: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
8
+ /** Role names, or human for a person listed on the team. */
9
+ approvers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
8
10
  overridable: z.ZodDefault<z.ZodBoolean>;
9
11
  }, "strip", z.ZodTypeAny, {
10
12
  type: "none" | "soft" | "hard";
11
13
  checklist: string[];
12
14
  mode: "none" | "human_approval" | "checklist";
13
15
  overridable: boolean;
16
+ approvers?: string[] | undefined;
14
17
  }, {
15
18
  type?: "none" | "soft" | "hard" | undefined;
16
19
  checklist?: string[] | undefined;
17
20
  mode?: "none" | "human_approval" | "checklist" | undefined;
21
+ approvers?: string[] | undefined;
18
22
  overridable?: boolean | undefined;
19
23
  }>;
20
24
  declare const ArtifactDefSchema: z.ZodObject<{
@@ -58,6 +62,15 @@ declare const StageSchema: z.ZodObject<{
58
62
  kind: z.ZodDefault<z.ZodEnum<["standard", "brainstorm", "clarify"]>>;
59
63
  /** When true, stage is optional (skippable); agents may skip if not needed */
60
64
  optional: z.ZodDefault<z.ZodBoolean>;
65
+ /** Role that produces this stage. */
66
+ owner: z.ZodOptional<z.ZodString>;
67
+ /** Roles who work with the owner on this stage. */
68
+ collaborates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
69
+ /**
70
+ * One item per matching file when the stage starts.
71
+ * A directory, a slash, and one star in the file name: tasks/T-*.md
72
+ */
73
+ items_from: z.ZodOptional<z.ZodString>;
61
74
  artifacts: z.ZodDefault<z.ZodArray<z.ZodObject<{
62
75
  id: z.ZodString;
63
76
  path: z.ZodString;
@@ -78,16 +91,20 @@ declare const StageSchema: z.ZodObject<{
78
91
  type: z.ZodDefault<z.ZodEnum<["none", "soft", "hard"]>>;
79
92
  mode: z.ZodDefault<z.ZodEnum<["none", "human_approval", "checklist"]>>;
80
93
  checklist: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
94
+ /** Role names, or human for a person listed on the team. */
95
+ approvers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
81
96
  overridable: z.ZodDefault<z.ZodBoolean>;
82
97
  }, "strip", z.ZodTypeAny, {
83
98
  type: "none" | "soft" | "hard";
84
99
  checklist: string[];
85
100
  mode: "none" | "human_approval" | "checklist";
86
101
  overridable: boolean;
102
+ approvers?: string[] | undefined;
87
103
  }, {
88
104
  type?: "none" | "soft" | "hard" | undefined;
89
105
  checklist?: string[] | undefined;
90
106
  mode?: "none" | "human_approval" | "checklist" | undefined;
107
+ approvers?: string[] | undefined;
91
108
  overridable?: boolean | undefined;
92
109
  }>>;
93
110
  skippable: z.ZodDefault<z.ZodBoolean>;
@@ -153,10 +170,14 @@ declare const StageSchema: z.ZodObject<{
153
170
  checklist: string[];
154
171
  mode: "none" | "human_approval" | "checklist";
155
172
  overridable: boolean;
173
+ approvers?: string[] | undefined;
156
174
  };
157
175
  skippable: boolean;
158
176
  title?: string | undefined;
159
177
  summary?: string | undefined;
178
+ owner?: string | undefined;
179
+ collaborates?: string[] | undefined;
180
+ items_from?: string | undefined;
160
181
  skip_when?: {
161
182
  flags?: string[] | undefined;
162
183
  } | undefined;
@@ -178,6 +199,9 @@ declare const StageSchema: z.ZodObject<{
178
199
  summary?: string | undefined;
179
200
  kind?: "standard" | "brainstorm" | "clarify" | undefined;
180
201
  optional?: boolean | undefined;
202
+ owner?: string | undefined;
203
+ collaborates?: string[] | undefined;
204
+ items_from?: string | undefined;
181
205
  artifacts?: {
182
206
  path: string;
183
207
  id: string;
@@ -188,6 +212,7 @@ declare const StageSchema: z.ZodObject<{
188
212
  type?: "none" | "soft" | "hard" | undefined;
189
213
  checklist?: string[] | undefined;
190
214
  mode?: "none" | "human_approval" | "checklist" | undefined;
215
+ approvers?: string[] | undefined;
191
216
  overridable?: boolean | undefined;
192
217
  } | undefined;
193
218
  skippable?: boolean | undefined;
@@ -223,6 +248,15 @@ declare const WorkflowSchema: z.ZodObject<{
223
248
  kind: z.ZodDefault<z.ZodEnum<["standard", "brainstorm", "clarify"]>>;
224
249
  /** When true, stage is optional (skippable); agents may skip if not needed */
225
250
  optional: z.ZodDefault<z.ZodBoolean>;
251
+ /** Role that produces this stage. */
252
+ owner: z.ZodOptional<z.ZodString>;
253
+ /** Roles who work with the owner on this stage. */
254
+ collaborates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
255
+ /**
256
+ * One item per matching file when the stage starts.
257
+ * A directory, a slash, and one star in the file name: tasks/T-*.md
258
+ */
259
+ items_from: z.ZodOptional<z.ZodString>;
226
260
  artifacts: z.ZodDefault<z.ZodArray<z.ZodObject<{
227
261
  id: z.ZodString;
228
262
  path: z.ZodString;
@@ -243,16 +277,20 @@ declare const WorkflowSchema: z.ZodObject<{
243
277
  type: z.ZodDefault<z.ZodEnum<["none", "soft", "hard"]>>;
244
278
  mode: z.ZodDefault<z.ZodEnum<["none", "human_approval", "checklist"]>>;
245
279
  checklist: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
280
+ /** Role names, or human for a person listed on the team. */
281
+ approvers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
246
282
  overridable: z.ZodDefault<z.ZodBoolean>;
247
283
  }, "strip", z.ZodTypeAny, {
248
284
  type: "none" | "soft" | "hard";
249
285
  checklist: string[];
250
286
  mode: "none" | "human_approval" | "checklist";
251
287
  overridable: boolean;
288
+ approvers?: string[] | undefined;
252
289
  }, {
253
290
  type?: "none" | "soft" | "hard" | undefined;
254
291
  checklist?: string[] | undefined;
255
292
  mode?: "none" | "human_approval" | "checklist" | undefined;
293
+ approvers?: string[] | undefined;
256
294
  overridable?: boolean | undefined;
257
295
  }>>;
258
296
  skippable: z.ZodDefault<z.ZodBoolean>;
@@ -318,10 +356,14 @@ declare const WorkflowSchema: z.ZodObject<{
318
356
  checklist: string[];
319
357
  mode: "none" | "human_approval" | "checklist";
320
358
  overridable: boolean;
359
+ approvers?: string[] | undefined;
321
360
  };
322
361
  skippable: boolean;
323
362
  title?: string | undefined;
324
363
  summary?: string | undefined;
364
+ owner?: string | undefined;
365
+ collaborates?: string[] | undefined;
366
+ items_from?: string | undefined;
325
367
  skip_when?: {
326
368
  flags?: string[] | undefined;
327
369
  } | undefined;
@@ -343,6 +385,9 @@ declare const WorkflowSchema: z.ZodObject<{
343
385
  summary?: string | undefined;
344
386
  kind?: "standard" | "brainstorm" | "clarify" | undefined;
345
387
  optional?: boolean | undefined;
388
+ owner?: string | undefined;
389
+ collaborates?: string[] | undefined;
390
+ items_from?: string | undefined;
346
391
  artifacts?: {
347
392
  path: string;
348
393
  id: string;
@@ -353,6 +398,7 @@ declare const WorkflowSchema: z.ZodObject<{
353
398
  type?: "none" | "soft" | "hard" | undefined;
354
399
  checklist?: string[] | undefined;
355
400
  mode?: "none" | "human_approval" | "checklist" | undefined;
401
+ approvers?: string[] | undefined;
356
402
  overridable?: boolean | undefined;
357
403
  } | undefined;
358
404
  skippable?: boolean | undefined;
@@ -435,10 +481,14 @@ declare const WorkflowSchema: z.ZodObject<{
435
481
  checklist: string[];
436
482
  mode: "none" | "human_approval" | "checklist";
437
483
  overridable: boolean;
484
+ approvers?: string[] | undefined;
438
485
  };
439
486
  skippable: boolean;
440
487
  title?: string | undefined;
441
488
  summary?: string | undefined;
489
+ owner?: string | undefined;
490
+ collaborates?: string[] | undefined;
491
+ items_from?: string | undefined;
442
492
  skip_when?: {
443
493
  flags?: string[] | undefined;
444
494
  } | undefined;
@@ -477,6 +527,9 @@ declare const WorkflowSchema: z.ZodObject<{
477
527
  summary?: string | undefined;
478
528
  kind?: "standard" | "brainstorm" | "clarify" | undefined;
479
529
  optional?: boolean | undefined;
530
+ owner?: string | undefined;
531
+ collaborates?: string[] | undefined;
532
+ items_from?: string | undefined;
480
533
  artifacts?: {
481
534
  path: string;
482
535
  id: string;
@@ -487,6 +540,7 @@ declare const WorkflowSchema: z.ZodObject<{
487
540
  type?: "none" | "soft" | "hard" | undefined;
488
541
  checklist?: string[] | undefined;
489
542
  mode?: "none" | "human_approval" | "checklist" | undefined;
543
+ approvers?: string[] | undefined;
490
544
  overridable?: boolean | undefined;
491
545
  } | undefined;
492
546
  skippable?: boolean | undefined;
@@ -524,6 +578,16 @@ declare const WorkflowSchema: z.ZodObject<{
524
578
  }>;
525
579
  declare const ConfigSchema: z.ZodObject<{
526
580
  version: z.ZodDefault<z.ZodNumber>;
581
+ metrics: z.ZodDefault<z.ZodObject<{
582
+ enabled: z.ZodDefault<z.ZodBoolean>;
583
+ exclude: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
584
+ }, "strip", z.ZodTypeAny, {
585
+ enabled: boolean;
586
+ exclude: string[];
587
+ }, {
588
+ enabled?: boolean | undefined;
589
+ exclude?: string[] | undefined;
590
+ }>>;
527
591
  memory_path: z.ZodDefault<z.ZodString>;
528
592
  changes_path: z.ZodDefault<z.ZodString>;
529
593
  archive_path: z.ZodDefault<z.ZodString>;
@@ -583,6 +647,10 @@ declare const ConfigSchema: z.ZodObject<{
583
647
  }>>;
584
648
  }, "strip", z.ZodTypeAny, {
585
649
  version: number;
650
+ metrics: {
651
+ enabled: boolean;
652
+ exclude: string[];
653
+ };
586
654
  memory_path: string;
587
655
  changes_path: string;
588
656
  archive_path: string;
@@ -608,6 +676,10 @@ declare const ConfigSchema: z.ZodObject<{
608
676
  allowed_workflows?: string[] | undefined;
609
677
  }, {
610
678
  version?: number | undefined;
679
+ metrics?: {
680
+ enabled?: boolean | undefined;
681
+ exclude?: string[] | undefined;
682
+ } | undefined;
611
683
  memory_path?: string | undefined;
612
684
  changes_path?: string | undefined;
613
685
  archive_path?: string | undefined;
@@ -641,6 +713,11 @@ declare const ChangeMetaSchema: z.ZodObject<{
641
713
  status: z.ZodDefault<z.ZodEnum<["in_progress", "blocked", "completed", "abandoned"]>>;
642
714
  stage: z.ZodString;
643
715
  branch: z.ZodOptional<z.ZodString>;
716
+ /** Epic key such as issue-37. Stories in one epic share a dependency graph. */
717
+ epic: z.ZodOptional<z.ZodString>;
718
+ /** Story id such as S-001. */
719
+ story: z.ZodOptional<z.ZodString>;
720
+ depends: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
644
721
  domain: z.ZodOptional<z.ZodString>;
645
722
  flags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodNumber]>>>;
646
723
  overrides: z.ZodDefault<z.ZodObject<{
@@ -658,6 +735,15 @@ declare const ChangeMetaSchema: z.ZodObject<{
658
735
  kind: z.ZodDefault<z.ZodEnum<["standard", "brainstorm", "clarify"]>>;
659
736
  /** When true, stage is optional (skippable); agents may skip if not needed */
660
737
  optional: z.ZodDefault<z.ZodBoolean>;
738
+ /** Role that produces this stage. */
739
+ owner: z.ZodOptional<z.ZodString>;
740
+ /** Roles who work with the owner on this stage. */
741
+ collaborates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
742
+ /**
743
+ * One item per matching file when the stage starts.
744
+ * A directory, a slash, and one star in the file name: tasks/T-*.md
745
+ */
746
+ items_from: z.ZodOptional<z.ZodString>;
661
747
  artifacts: z.ZodDefault<z.ZodArray<z.ZodObject<{
662
748
  id: z.ZodString;
663
749
  path: z.ZodString;
@@ -678,16 +764,20 @@ declare const ChangeMetaSchema: z.ZodObject<{
678
764
  type: z.ZodDefault<z.ZodEnum<["none", "soft", "hard"]>>;
679
765
  mode: z.ZodDefault<z.ZodEnum<["none", "human_approval", "checklist"]>>;
680
766
  checklist: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
767
+ /** Role names, or human for a person listed on the team. */
768
+ approvers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
681
769
  overridable: z.ZodDefault<z.ZodBoolean>;
682
770
  }, "strip", z.ZodTypeAny, {
683
771
  type: "none" | "soft" | "hard";
684
772
  checklist: string[];
685
773
  mode: "none" | "human_approval" | "checklist";
686
774
  overridable: boolean;
775
+ approvers?: string[] | undefined;
687
776
  }, {
688
777
  type?: "none" | "soft" | "hard" | undefined;
689
778
  checklist?: string[] | undefined;
690
779
  mode?: "none" | "human_approval" | "checklist" | undefined;
780
+ approvers?: string[] | undefined;
691
781
  overridable?: boolean | undefined;
692
782
  }>>;
693
783
  skippable: z.ZodDefault<z.ZodBoolean>;
@@ -753,10 +843,14 @@ declare const ChangeMetaSchema: z.ZodObject<{
753
843
  checklist: string[];
754
844
  mode: "none" | "human_approval" | "checklist";
755
845
  overridable: boolean;
846
+ approvers?: string[] | undefined;
756
847
  };
757
848
  skippable: boolean;
758
849
  title?: string | undefined;
759
850
  summary?: string | undefined;
851
+ owner?: string | undefined;
852
+ collaborates?: string[] | undefined;
853
+ items_from?: string | undefined;
760
854
  skip_when?: {
761
855
  flags?: string[] | undefined;
762
856
  } | undefined;
@@ -778,6 +872,9 @@ declare const ChangeMetaSchema: z.ZodObject<{
778
872
  summary?: string | undefined;
779
873
  kind?: "standard" | "brainstorm" | "clarify" | undefined;
780
874
  optional?: boolean | undefined;
875
+ owner?: string | undefined;
876
+ collaborates?: string[] | undefined;
877
+ items_from?: string | undefined;
781
878
  artifacts?: {
782
879
  path: string;
783
880
  id: string;
@@ -788,6 +885,7 @@ declare const ChangeMetaSchema: z.ZodObject<{
788
885
  type?: "none" | "soft" | "hard" | undefined;
789
886
  checklist?: string[] | undefined;
790
887
  mode?: "none" | "human_approval" | "checklist" | undefined;
888
+ approvers?: string[] | undefined;
791
889
  overridable?: boolean | undefined;
792
890
  } | undefined;
793
891
  skippable?: boolean | undefined;
@@ -825,10 +923,14 @@ declare const ChangeMetaSchema: z.ZodObject<{
825
923
  checklist: string[];
826
924
  mode: "none" | "human_approval" | "checklist";
827
925
  overridable: boolean;
926
+ approvers?: string[] | undefined;
828
927
  };
829
928
  skippable: boolean;
830
929
  title?: string | undefined;
831
930
  summary?: string | undefined;
931
+ owner?: string | undefined;
932
+ collaborates?: string[] | undefined;
933
+ items_from?: string | undefined;
832
934
  skip_when?: {
833
935
  flags?: string[] | undefined;
834
936
  } | undefined;
@@ -854,6 +956,9 @@ declare const ChangeMetaSchema: z.ZodObject<{
854
956
  summary?: string | undefined;
855
957
  kind?: "standard" | "brainstorm" | "clarify" | undefined;
856
958
  optional?: boolean | undefined;
959
+ owner?: string | undefined;
960
+ collaborates?: string[] | undefined;
961
+ items_from?: string | undefined;
857
962
  artifacts?: {
858
963
  path: string;
859
964
  id: string;
@@ -864,6 +969,7 @@ declare const ChangeMetaSchema: z.ZodObject<{
864
969
  type?: "none" | "soft" | "hard" | undefined;
865
970
  checklist?: string[] | undefined;
866
971
  mode?: "none" | "human_approval" | "checklist" | undefined;
972
+ approvers?: string[] | undefined;
867
973
  overridable?: boolean | undefined;
868
974
  } | undefined;
869
975
  skippable?: boolean | undefined;
@@ -913,6 +1019,9 @@ declare const ChangeMetaSchema: z.ZodObject<{
913
1019
  /** Results from `sdd verify` keyed by stage id */
914
1020
  verify_results: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
915
1021
  ok: z.ZodBoolean;
1022
+ /** pass | fail | not_run (absent in metas written before 0.17.3) */
1023
+ status: z.ZodOptional<z.ZodEnum<["pass", "fail", "not_run"]>>;
1024
+ head_sha: z.ZodOptional<z.ZodString>;
916
1025
  at: z.ZodString;
917
1026
  results: z.ZodDefault<z.ZodArray<z.ZodObject<{
918
1027
  name: z.ZodString;
@@ -931,9 +1040,13 @@ declare const ChangeMetaSchema: z.ZodObject<{
931
1040
  name: string;
932
1041
  exitCode: number | null;
933
1042
  }[];
1043
+ status?: "pass" | "fail" | "not_run" | undefined;
1044
+ head_sha?: string | undefined;
934
1045
  }, {
935
1046
  at: string;
936
1047
  ok: boolean;
1048
+ status?: "pass" | "fail" | "not_run" | undefined;
1049
+ head_sha?: string | undefined;
937
1050
  results?: {
938
1051
  name: string;
939
1052
  exitCode: number | null;
@@ -981,10 +1094,14 @@ declare const ChangeMetaSchema: z.ZodObject<{
981
1094
  checklist: string[];
982
1095
  mode: "none" | "human_approval" | "checklist";
983
1096
  overridable: boolean;
1097
+ approvers?: string[] | undefined;
984
1098
  };
985
1099
  skippable: boolean;
986
1100
  title?: string | undefined;
987
1101
  summary?: string | undefined;
1102
+ owner?: string | undefined;
1103
+ collaborates?: string[] | undefined;
1104
+ items_from?: string | undefined;
988
1105
  skip_when?: {
989
1106
  flags?: string[] | undefined;
990
1107
  } | undefined;
@@ -1014,9 +1131,14 @@ declare const ChangeMetaSchema: z.ZodObject<{
1014
1131
  name: string;
1015
1132
  exitCode: number | null;
1016
1133
  }[];
1134
+ status?: "pass" | "fail" | "not_run" | undefined;
1135
+ head_sha?: string | undefined;
1017
1136
  }>;
1018
1137
  updated?: string | undefined;
1019
1138
  branch?: string | undefined;
1139
+ epic?: string | undefined;
1140
+ story?: string | undefined;
1141
+ depends?: string[] | undefined;
1020
1142
  domain?: string | undefined;
1021
1143
  pr?: {
1022
1144
  number?: number | undefined;
@@ -1038,6 +1160,9 @@ declare const ChangeMetaSchema: z.ZodObject<{
1038
1160
  }> | undefined;
1039
1161
  updated?: string | undefined;
1040
1162
  branch?: string | undefined;
1163
+ epic?: string | undefined;
1164
+ story?: string | undefined;
1165
+ depends?: string[] | undefined;
1041
1166
  domain?: string | undefined;
1042
1167
  overrides?: {
1043
1168
  gates?: Record<string, "none" | "soft" | "hard"> | undefined;
@@ -1048,6 +1173,9 @@ declare const ChangeMetaSchema: z.ZodObject<{
1048
1173
  summary?: string | undefined;
1049
1174
  kind?: "standard" | "brainstorm" | "clarify" | undefined;
1050
1175
  optional?: boolean | undefined;
1176
+ owner?: string | undefined;
1177
+ collaborates?: string[] | undefined;
1178
+ items_from?: string | undefined;
1051
1179
  artifacts?: {
1052
1180
  path: string;
1053
1181
  id: string;
@@ -1058,6 +1186,7 @@ declare const ChangeMetaSchema: z.ZodObject<{
1058
1186
  type?: "none" | "soft" | "hard" | undefined;
1059
1187
  checklist?: string[] | undefined;
1060
1188
  mode?: "none" | "human_approval" | "checklist" | undefined;
1189
+ approvers?: string[] | undefined;
1061
1190
  overridable?: boolean | undefined;
1062
1191
  } | undefined;
1063
1192
  skippable?: boolean | undefined;
@@ -1086,6 +1215,8 @@ declare const ChangeMetaSchema: z.ZodObject<{
1086
1215
  verify_results?: Record<string, {
1087
1216
  at: string;
1088
1217
  ok: boolean;
1218
+ status?: "pass" | "fail" | "not_run" | undefined;
1219
+ head_sha?: string | undefined;
1089
1220
  results?: {
1090
1221
  name: string;
1091
1222
  exitCode: number | null;
@@ -1111,19 +1242,773 @@ declare function configPath(projectRoot: string): string;
1111
1242
  declare function workflowsDir(projectRoot: string): string;
1112
1243
  declare function templatesDir(projectRoot: string): string;
1113
1244
  declare function memoryDir(projectRoot: string, config: Config): string;
1245
+ /** Project-relative memory folder, always with a trailing slash stripped. */
1246
+ declare function memoryPathRel(config: Pick<Config, "memory_path">): string;
1247
+ /** Project-relative changes folder, always with a trailing slash stripped. */
1248
+ declare function changesPathRel(config: Pick<Config, "changes_path">): string;
1249
+ /** Repo-relative archive directory for a completed change. */
1250
+ declare function displayArchivePath(config: Pick<Config, "archive_path">, changeId: string): string;
1251
+ /** Repo-relative change directory shown to humans. Never an absolute machine path. */
1252
+ declare function displayChangePath(config: Pick<Config, "changes_path">, changeId: string): string;
1253
+ /** Paths agents should be told to read, taken from config rather than defaults. */
1254
+ declare function guidancePaths(config: Pick<Config, "memory_path" | "changes_path">): {
1255
+ memory: string;
1256
+ changes: string;
1257
+ constitution: string;
1258
+ memoryIndex: string;
1259
+ };
1114
1260
  declare function changesDir(projectRoot: string, config: Config): string;
1115
1261
  declare function archiveDir(projectRoot: string, config: Config): string;
1116
1262
  declare function domainsDir(projectRoot: string, config: Config): string;
1117
1263
  declare function changePath(projectRoot: string, config: Config, changeId: string): string;
1118
1264
  declare function changeMetaPath(projectRoot: string, config: Config, changeId: string): string;
1119
1265
  declare function activePointerPath(projectRoot: string, config: Config): string;
1266
+ declare function searchConfigPath(projectRoot: string): string;
1267
+ declare function indexDbPath(projectRoot: string): string;
1120
1268
 
1121
1269
  declare function isInitialized(projectRoot: string): Promise<boolean>;
1122
1270
  declare function loadConfig(projectRoot: string): Promise<Config>;
1123
1271
  declare function saveConfig(projectRoot: string, config: Config): Promise<void>;
1124
1272
  declare function defaultConfig(): Config;
1273
+ /** Merge a user's config over current defaults, then validate and strip unsupported keys. */
1274
+ declare function mergeConfigDefaults(existing: unknown): Config;
1275
+
1276
+ type GitHeadRunner = (projectRoot: string) => Promise<string>;
1277
+ declare function getHeadSha(projectRoot: string, runGit?: GitHeadRunner): Promise<string | null>;
1278
+
1279
+ declare const PhaseMetricSchema: z.ZodEffects<z.ZodObject<{
1280
+ phase: z.ZodString;
1281
+ startedAt: z.ZodString;
1282
+ endedAt: z.ZodOptional<z.ZodString>;
1283
+ }, "strip", z.ZodTypeAny, {
1284
+ phase: string;
1285
+ startedAt: string;
1286
+ endedAt?: string | undefined;
1287
+ }, {
1288
+ phase: string;
1289
+ startedAt: string;
1290
+ endedAt?: string | undefined;
1291
+ }>, {
1292
+ phase: string;
1293
+ startedAt: string;
1294
+ endedAt?: string | undefined;
1295
+ }, {
1296
+ phase: string;
1297
+ startedAt: string;
1298
+ endedAt?: string | undefined;
1299
+ }>;
1300
+ declare const TokenUsageMetricSchema: z.ZodObject<{
1301
+ provider: z.ZodEnum<["claude-code", "codex", "grok"]>;
1302
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1303
+ requestId: z.ZodString;
1304
+ phase: z.ZodString;
1305
+ startedAt: z.ZodString;
1306
+ inputTokens: z.ZodNullable<z.ZodNumber>;
1307
+ cacheReadTokens: z.ZodNullable<z.ZodNumber>;
1308
+ cacheWriteTokens: z.ZodNullable<z.ZodNumber>;
1309
+ outputTokens: z.ZodNullable<z.ZodNumber>;
1310
+ measured: z.ZodLiteral<true>;
1311
+ }, "strip", z.ZodTypeAny, {
1312
+ phase: string;
1313
+ startedAt: string;
1314
+ provider: "claude-code" | "codex" | "grok";
1315
+ requestId: string;
1316
+ inputTokens: number | null;
1317
+ cacheReadTokens: number | null;
1318
+ cacheWriteTokens: number | null;
1319
+ outputTokens: number | null;
1320
+ measured: true;
1321
+ model?: string | null | undefined;
1322
+ }, {
1323
+ phase: string;
1324
+ startedAt: string;
1325
+ provider: "claude-code" | "codex" | "grok";
1326
+ requestId: string;
1327
+ inputTokens: number | null;
1328
+ cacheReadTokens: number | null;
1329
+ cacheWriteTokens: number | null;
1330
+ outputTokens: number | null;
1331
+ measured: true;
1332
+ model?: string | null | undefined;
1333
+ }>;
1334
+ declare const DecisionMetricSchema: z.ZodObject<{
1335
+ workType: z.ZodEnum<["route", "classify", "check", "draft", "design", "code", "review"]>;
1336
+ kind: z.ZodEnum<["reason", "decide"]>;
1337
+ provider: z.ZodEnum<["command", "ollama"]>;
1338
+ model: z.ZodNullable<z.ZodString>;
1339
+ startedAt: z.ZodString;
1340
+ inputTokens: z.ZodNullable<z.ZodNumber>;
1341
+ cacheReadTokens: z.ZodNullable<z.ZodNumber>;
1342
+ cacheWriteTokens: z.ZodNullable<z.ZodNumber>;
1343
+ outputTokens: z.ZodNullable<z.ZodNumber>;
1344
+ }, "strip", z.ZodTypeAny, {
1345
+ kind: "reason" | "decide";
1346
+ startedAt: string;
1347
+ provider: "command" | "ollama";
1348
+ model: string | null;
1349
+ inputTokens: number | null;
1350
+ cacheReadTokens: number | null;
1351
+ cacheWriteTokens: number | null;
1352
+ outputTokens: number | null;
1353
+ workType: "code" | "route" | "classify" | "check" | "draft" | "design" | "review";
1354
+ }, {
1355
+ kind: "reason" | "decide";
1356
+ startedAt: string;
1357
+ provider: "command" | "ollama";
1358
+ model: string | null;
1359
+ inputTokens: number | null;
1360
+ cacheReadTokens: number | null;
1361
+ cacheWriteTokens: number | null;
1362
+ outputTokens: number | null;
1363
+ workType: "code" | "route" | "classify" | "check" | "draft" | "design" | "review";
1364
+ }>;
1365
+ declare const ChangeMetricsSchema: z.ZodObject<{
1366
+ version: z.ZodLiteral<1>;
1367
+ phases: z.ZodArray<z.ZodEffects<z.ZodObject<{
1368
+ phase: z.ZodString;
1369
+ startedAt: z.ZodString;
1370
+ endedAt: z.ZodOptional<z.ZodString>;
1371
+ }, "strip", z.ZodTypeAny, {
1372
+ phase: string;
1373
+ startedAt: string;
1374
+ endedAt?: string | undefined;
1375
+ }, {
1376
+ phase: string;
1377
+ startedAt: string;
1378
+ endedAt?: string | undefined;
1379
+ }>, {
1380
+ phase: string;
1381
+ startedAt: string;
1382
+ endedAt?: string | undefined;
1383
+ }, {
1384
+ phase: string;
1385
+ startedAt: string;
1386
+ endedAt?: string | undefined;
1387
+ }>, "many">;
1388
+ requests: z.ZodArray<z.ZodObject<{
1389
+ provider: z.ZodEnum<["claude-code", "codex", "grok"]>;
1390
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1391
+ requestId: z.ZodString;
1392
+ phase: z.ZodString;
1393
+ startedAt: z.ZodString;
1394
+ inputTokens: z.ZodNullable<z.ZodNumber>;
1395
+ cacheReadTokens: z.ZodNullable<z.ZodNumber>;
1396
+ cacheWriteTokens: z.ZodNullable<z.ZodNumber>;
1397
+ outputTokens: z.ZodNullable<z.ZodNumber>;
1398
+ measured: z.ZodLiteral<true>;
1399
+ }, "strip", z.ZodTypeAny, {
1400
+ phase: string;
1401
+ startedAt: string;
1402
+ provider: "claude-code" | "codex" | "grok";
1403
+ requestId: string;
1404
+ inputTokens: number | null;
1405
+ cacheReadTokens: number | null;
1406
+ cacheWriteTokens: number | null;
1407
+ outputTokens: number | null;
1408
+ measured: true;
1409
+ model?: string | null | undefined;
1410
+ }, {
1411
+ phase: string;
1412
+ startedAt: string;
1413
+ provider: "claude-code" | "codex" | "grok";
1414
+ requestId: string;
1415
+ inputTokens: number | null;
1416
+ cacheReadTokens: number | null;
1417
+ cacheWriteTokens: number | null;
1418
+ outputTokens: number | null;
1419
+ measured: true;
1420
+ model?: string | null | undefined;
1421
+ }>, "many">;
1422
+ decisions: z.ZodOptional<z.ZodArray<z.ZodObject<{
1423
+ workType: z.ZodEnum<["route", "classify", "check", "draft", "design", "code", "review"]>;
1424
+ kind: z.ZodEnum<["reason", "decide"]>;
1425
+ provider: z.ZodEnum<["command", "ollama"]>;
1426
+ model: z.ZodNullable<z.ZodString>;
1427
+ startedAt: z.ZodString;
1428
+ inputTokens: z.ZodNullable<z.ZodNumber>;
1429
+ cacheReadTokens: z.ZodNullable<z.ZodNumber>;
1430
+ cacheWriteTokens: z.ZodNullable<z.ZodNumber>;
1431
+ outputTokens: z.ZodNullable<z.ZodNumber>;
1432
+ }, "strip", z.ZodTypeAny, {
1433
+ kind: "reason" | "decide";
1434
+ startedAt: string;
1435
+ provider: "command" | "ollama";
1436
+ model: string | null;
1437
+ inputTokens: number | null;
1438
+ cacheReadTokens: number | null;
1439
+ cacheWriteTokens: number | null;
1440
+ outputTokens: number | null;
1441
+ workType: "code" | "route" | "classify" | "check" | "draft" | "design" | "review";
1442
+ }, {
1443
+ kind: "reason" | "decide";
1444
+ startedAt: string;
1445
+ provider: "command" | "ollama";
1446
+ model: string | null;
1447
+ inputTokens: number | null;
1448
+ cacheReadTokens: number | null;
1449
+ cacheWriteTokens: number | null;
1450
+ outputTokens: number | null;
1451
+ workType: "code" | "route" | "classify" | "check" | "draft" | "design" | "review";
1452
+ }>, "many">>;
1453
+ }, "strip", z.ZodTypeAny, {
1454
+ version: 1;
1455
+ phases: {
1456
+ phase: string;
1457
+ startedAt: string;
1458
+ endedAt?: string | undefined;
1459
+ }[];
1460
+ requests: {
1461
+ phase: string;
1462
+ startedAt: string;
1463
+ provider: "claude-code" | "codex" | "grok";
1464
+ requestId: string;
1465
+ inputTokens: number | null;
1466
+ cacheReadTokens: number | null;
1467
+ cacheWriteTokens: number | null;
1468
+ outputTokens: number | null;
1469
+ measured: true;
1470
+ model?: string | null | undefined;
1471
+ }[];
1472
+ decisions?: {
1473
+ kind: "reason" | "decide";
1474
+ startedAt: string;
1475
+ provider: "command" | "ollama";
1476
+ model: string | null;
1477
+ inputTokens: number | null;
1478
+ cacheReadTokens: number | null;
1479
+ cacheWriteTokens: number | null;
1480
+ outputTokens: number | null;
1481
+ workType: "code" | "route" | "classify" | "check" | "draft" | "design" | "review";
1482
+ }[] | undefined;
1483
+ }, {
1484
+ version: 1;
1485
+ phases: {
1486
+ phase: string;
1487
+ startedAt: string;
1488
+ endedAt?: string | undefined;
1489
+ }[];
1490
+ requests: {
1491
+ phase: string;
1492
+ startedAt: string;
1493
+ provider: "claude-code" | "codex" | "grok";
1494
+ requestId: string;
1495
+ inputTokens: number | null;
1496
+ cacheReadTokens: number | null;
1497
+ cacheWriteTokens: number | null;
1498
+ outputTokens: number | null;
1499
+ measured: true;
1500
+ model?: string | null | undefined;
1501
+ }[];
1502
+ decisions?: {
1503
+ kind: "reason" | "decide";
1504
+ startedAt: string;
1505
+ provider: "command" | "ollama";
1506
+ model: string | null;
1507
+ inputTokens: number | null;
1508
+ cacheReadTokens: number | null;
1509
+ cacheWriteTokens: number | null;
1510
+ outputTokens: number | null;
1511
+ workType: "code" | "route" | "classify" | "check" | "draft" | "design" | "review";
1512
+ }[] | undefined;
1513
+ }>;
1514
+ type PhaseMetric = z.infer<typeof PhaseMetricSchema>;
1515
+ type TokenUsageMetric = z.infer<typeof TokenUsageMetricSchema>;
1516
+ type DecisionMetric = z.infer<typeof DecisionMetricSchema>;
1517
+ type ChangeMetrics = z.infer<typeof ChangeMetricsSchema>;
1518
+ interface MetricsImportResult {
1519
+ imported: number;
1520
+ duplicates: number;
1521
+ ignored: number;
1522
+ unmatched: number;
1523
+ providers: string[];
1524
+ incomplete: boolean;
1525
+ }
1526
+ declare function emptyChangeMetrics(): ChangeMetrics;
1527
+ declare function readChangeMetrics(projectRoot: string, config: Config, changeId: string): Promise<ChangeMetrics>;
1528
+ declare function recordDecisionMetric(projectRoot: string, config: Config, changeId: string, draft: DecisionMetric): Promise<void>;
1529
+ declare function startPhase(projectRoot: string, config: Config, changeId: string, phase: string, startedAt?: string): Promise<void>;
1530
+ declare function transitionPhase(projectRoot: string, config: Config, changeId: string, fromPhase: string, toPhase: string | null, at?: string, fromStartedAt?: string): Promise<void>;
1531
+ /**
1532
+ * Refuse an in-repo session log under metrics.exclude before the file is opened.
1533
+ * Logs outside the project root are not excluded. Invalid prefixes throw first.
1534
+ */
1535
+ declare function assertSessionLogAllowed(projectRoot: string, prefixes: readonly string[], sessionLogPath: string): void;
1536
+ declare function importSessionMetrics(projectRoot: string, config: Config, changeId: string, sessionLogPath: string): Promise<MetricsImportResult>;
1537
+
1538
+ declare const PriceCardSchema: z.ZodObject<{
1539
+ input_per_million_usd: z.ZodNumber;
1540
+ cache_read_per_million_usd: z.ZodNumber;
1541
+ cache_write_per_million_usd: z.ZodNumber;
1542
+ output_per_million_usd: z.ZodNumber;
1543
+ }, "strip", z.ZodTypeAny, {
1544
+ input_per_million_usd: number;
1545
+ cache_read_per_million_usd: number;
1546
+ cache_write_per_million_usd: number;
1547
+ output_per_million_usd: number;
1548
+ }, {
1549
+ input_per_million_usd: number;
1550
+ cache_read_per_million_usd: number;
1551
+ cache_write_per_million_usd: number;
1552
+ output_per_million_usd: number;
1553
+ }>;
1554
+ declare const PricesSchema: z.ZodObject<{
1555
+ usd_to_inr: z.ZodDefault<z.ZodNumber>;
1556
+ models: z.ZodObject<{
1557
+ default: z.ZodObject<{
1558
+ input_per_million_usd: z.ZodNumber;
1559
+ cache_read_per_million_usd: z.ZodNumber;
1560
+ cache_write_per_million_usd: z.ZodNumber;
1561
+ output_per_million_usd: z.ZodNumber;
1562
+ }, "strip", z.ZodTypeAny, {
1563
+ input_per_million_usd: number;
1564
+ cache_read_per_million_usd: number;
1565
+ cache_write_per_million_usd: number;
1566
+ output_per_million_usd: number;
1567
+ }, {
1568
+ input_per_million_usd: number;
1569
+ cache_read_per_million_usd: number;
1570
+ cache_write_per_million_usd: number;
1571
+ output_per_million_usd: number;
1572
+ }>;
1573
+ }, "strip", z.ZodObject<{
1574
+ input_per_million_usd: z.ZodNumber;
1575
+ cache_read_per_million_usd: z.ZodNumber;
1576
+ cache_write_per_million_usd: z.ZodNumber;
1577
+ output_per_million_usd: z.ZodNumber;
1578
+ }, "strip", z.ZodTypeAny, {
1579
+ input_per_million_usd: number;
1580
+ cache_read_per_million_usd: number;
1581
+ cache_write_per_million_usd: number;
1582
+ output_per_million_usd: number;
1583
+ }, {
1584
+ input_per_million_usd: number;
1585
+ cache_read_per_million_usd: number;
1586
+ cache_write_per_million_usd: number;
1587
+ output_per_million_usd: number;
1588
+ }>, z.objectOutputType<{
1589
+ default: z.ZodObject<{
1590
+ input_per_million_usd: z.ZodNumber;
1591
+ cache_read_per_million_usd: z.ZodNumber;
1592
+ cache_write_per_million_usd: z.ZodNumber;
1593
+ output_per_million_usd: z.ZodNumber;
1594
+ }, "strip", z.ZodTypeAny, {
1595
+ input_per_million_usd: number;
1596
+ cache_read_per_million_usd: number;
1597
+ cache_write_per_million_usd: number;
1598
+ output_per_million_usd: number;
1599
+ }, {
1600
+ input_per_million_usd: number;
1601
+ cache_read_per_million_usd: number;
1602
+ cache_write_per_million_usd: number;
1603
+ output_per_million_usd: number;
1604
+ }>;
1605
+ }, z.ZodObject<{
1606
+ input_per_million_usd: z.ZodNumber;
1607
+ cache_read_per_million_usd: z.ZodNumber;
1608
+ cache_write_per_million_usd: z.ZodNumber;
1609
+ output_per_million_usd: z.ZodNumber;
1610
+ }, "strip", z.ZodTypeAny, {
1611
+ input_per_million_usd: number;
1612
+ cache_read_per_million_usd: number;
1613
+ cache_write_per_million_usd: number;
1614
+ output_per_million_usd: number;
1615
+ }, {
1616
+ input_per_million_usd: number;
1617
+ cache_read_per_million_usd: number;
1618
+ cache_write_per_million_usd: number;
1619
+ output_per_million_usd: number;
1620
+ }>, "strip">, z.objectInputType<{
1621
+ default: z.ZodObject<{
1622
+ input_per_million_usd: z.ZodNumber;
1623
+ cache_read_per_million_usd: z.ZodNumber;
1624
+ cache_write_per_million_usd: z.ZodNumber;
1625
+ output_per_million_usd: z.ZodNumber;
1626
+ }, "strip", z.ZodTypeAny, {
1627
+ input_per_million_usd: number;
1628
+ cache_read_per_million_usd: number;
1629
+ cache_write_per_million_usd: number;
1630
+ output_per_million_usd: number;
1631
+ }, {
1632
+ input_per_million_usd: number;
1633
+ cache_read_per_million_usd: number;
1634
+ cache_write_per_million_usd: number;
1635
+ output_per_million_usd: number;
1636
+ }>;
1637
+ }, z.ZodObject<{
1638
+ input_per_million_usd: z.ZodNumber;
1639
+ cache_read_per_million_usd: z.ZodNumber;
1640
+ cache_write_per_million_usd: z.ZodNumber;
1641
+ output_per_million_usd: z.ZodNumber;
1642
+ }, "strip", z.ZodTypeAny, {
1643
+ input_per_million_usd: number;
1644
+ cache_read_per_million_usd: number;
1645
+ cache_write_per_million_usd: number;
1646
+ output_per_million_usd: number;
1647
+ }, {
1648
+ input_per_million_usd: number;
1649
+ cache_read_per_million_usd: number;
1650
+ cache_write_per_million_usd: number;
1651
+ output_per_million_usd: number;
1652
+ }>, "strip">>;
1653
+ }, "strip", z.ZodTypeAny, {
1654
+ usd_to_inr: number;
1655
+ models: {
1656
+ default: {
1657
+ input_per_million_usd: number;
1658
+ cache_read_per_million_usd: number;
1659
+ cache_write_per_million_usd: number;
1660
+ output_per_million_usd: number;
1661
+ };
1662
+ } & {
1663
+ [k: string]: {
1664
+ input_per_million_usd: number;
1665
+ cache_read_per_million_usd: number;
1666
+ cache_write_per_million_usd: number;
1667
+ output_per_million_usd: number;
1668
+ };
1669
+ };
1670
+ }, {
1671
+ models: {
1672
+ default: {
1673
+ input_per_million_usd: number;
1674
+ cache_read_per_million_usd: number;
1675
+ cache_write_per_million_usd: number;
1676
+ output_per_million_usd: number;
1677
+ };
1678
+ } & {
1679
+ [k: string]: {
1680
+ input_per_million_usd: number;
1681
+ cache_read_per_million_usd: number;
1682
+ cache_write_per_million_usd: number;
1683
+ output_per_million_usd: number;
1684
+ };
1685
+ };
1686
+ usd_to_inr?: number | undefined;
1687
+ }>;
1688
+ type PriceCard = z.infer<typeof PriceCardSchema>;
1689
+ type Prices = z.infer<typeof PricesSchema>;
1690
+ interface TokenCounts {
1691
+ input: number | null;
1692
+ cacheRead: number | null;
1693
+ cacheWrite: number | null;
1694
+ output: number | null;
1695
+ }
1696
+ interface PhaseTimingRow {
1697
+ phase: string;
1698
+ startedAt: string;
1699
+ endedAt?: string;
1700
+ activeMs: number;
1701
+ open: boolean;
1702
+ }
1703
+ interface PhaseTiming {
1704
+ activeMs: number;
1705
+ waitMs: number;
1706
+ totalMs: number;
1707
+ phases: PhaseTimingRow[];
1708
+ }
1709
+ interface ChangePhaseOrder {
1710
+ id: string;
1711
+ /** First phase start. Null when a valid file has no phases. Ignored when invalid. */
1712
+ firstStartedAt: string | null;
1713
+ invalid: boolean;
1714
+ }
1715
+ interface RenderChangeReportInput {
1716
+ changeId: string;
1717
+ metrics: ChangeMetrics;
1718
+ prices: Prices | null;
1719
+ /** Unicode code points in `.sdd/handoff.md`. Null means that file is missing. */
1720
+ handoffCodePoints: number | null;
1721
+ now: Date;
1722
+ }
1723
+ /** `Hh Mm Ss` from whole seconds. Negative and non-finite inputs are `0h 0m 0s`. */
1724
+ declare function formatDuration(ms: number): string;
1725
+ /** Active time per stored visit, plus human wait as the gaps between visits. */
1726
+ declare function phaseTiming(phases: readonly PhaseMetric[], now: Date): PhaseTiming;
1727
+ /**
1728
+ * Sum category USD from numeric token counts only, then round once.
1729
+ * INR multiplies the unrounded USD sum by `usdToInr`, then rounds once.
1730
+ */
1731
+ declare function costFor(counts: TokenCounts, card: PriceCard, usdToInr: number): {
1732
+ usd: string;
1733
+ inr: string;
1734
+ };
1735
+ /** Parsed prices, null when `.sdd/prices.yaml` is missing, or a throw when it is invalid. */
1736
+ declare function loadPrices(projectRoot: string): Promise<Prices | null>;
1737
+ /** Plain-text one-change report. Does not read or write the filesystem. */
1738
+ declare function renderChangeReport(input: RenderChangeReportInput): string;
1739
+ /** Valid files with a first start, then empty phases, then invalid files. Tie-break by id. */
1740
+ declare function compareChangesByFirstPhase(left: ChangePhaseOrder, right: ChangePhaseOrder): number;
1741
+ declare function readHandoffCodePoints(projectRoot: string): Promise<number | null>;
1742
+ /** One-change report. Reads metrics and, when unmeasured, the handoff. Writes nothing. */
1743
+ declare function reportChange(input: {
1744
+ projectRoot: string;
1745
+ config: Config;
1746
+ changeId: string;
1747
+ prices: Prices | null;
1748
+ now: Date;
1749
+ }): Promise<string>;
1750
+ /** Every direct child that has metrics.json, or the empty-result sentence. Writes nothing. */
1751
+ declare function reportAllChanges(projectRoot: string, config: Config, prices: Prices | null, now: Date): Promise<string>;
1752
+
1753
+ declare function countTokens(text: string): number;
1754
+ /** FTS5 tokens. A token character is 0-9, A-Z, a-z, `_`, or a code point above 127. */
1755
+ declare function ftsTokens(query: string): string[];
1756
+
1757
+ declare class SearchConfigError extends Error {
1758
+ constructor();
1759
+ }
1760
+ declare const SearchConfigSchema: z.ZodObject<{
1761
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1762
+ provider: z.ZodDefault<z.ZodString>;
1763
+ k: z.ZodDefault<z.ZodNumber>;
1764
+ embeddings: z.ZodDefault<z.ZodBoolean>;
1765
+ budgets: z.ZodDefault<z.ZodObject<{
1766
+ default: z.ZodDefault<z.ZodNumber>;
1767
+ }, "strip", z.ZodNumber, z.objectOutputType<{
1768
+ default: z.ZodDefault<z.ZodNumber>;
1769
+ }, z.ZodNumber, "strip">, z.objectInputType<{
1770
+ default: z.ZodDefault<z.ZodNumber>;
1771
+ }, z.ZodNumber, "strip">>>;
1772
+ exclude: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1773
+ }, "strip", z.ZodTypeAny, {
1774
+ version: 1;
1775
+ exclude: string[];
1776
+ provider: string;
1777
+ k: number;
1778
+ embeddings: boolean;
1779
+ budgets: {
1780
+ default: number;
1781
+ } & {
1782
+ [k: string]: number;
1783
+ };
1784
+ }, {
1785
+ version?: 1 | undefined;
1786
+ exclude?: string[] | undefined;
1787
+ provider?: string | undefined;
1788
+ k?: number | undefined;
1789
+ embeddings?: boolean | undefined;
1790
+ budgets?: z.objectInputType<{
1791
+ default: z.ZodDefault<z.ZodNumber>;
1792
+ }, z.ZodNumber, "strip"> | undefined;
1793
+ }>;
1794
+ type SearchConfig = z.infer<typeof SearchConfigSchema>;
1795
+ declare function budgetForStage(config: SearchConfig, stage: string | undefined): number;
1796
+ declare function loadSearchConfig(projectRoot: string): Promise<SearchConfig>;
1797
+
1798
+ type SearchScope = "code" | "specs" | "memory";
1799
+ interface SearchQuery {
1800
+ scope: SearchScope;
1801
+ k: number;
1802
+ budget: number;
1803
+ /** Header text counted against the budget. Empty for context and handoff. */
1804
+ preamble?: string;
1805
+ }
1806
+ interface SearchHit {
1807
+ scope: SearchScope;
1808
+ path: string;
1809
+ startLine: number;
1810
+ endLine: number;
1811
+ symbol: string;
1812
+ /**
1813
+ * Keyword hits store raw SQLite bm25() (more negative is better).
1814
+ * Hybrid hits store the RRF score (higher is better).
1815
+ */
1816
+ score: number;
1817
+ form: "full" | "signature" | "summary";
1818
+ text: string;
1819
+ signature: string;
1820
+ body: string;
1821
+ language: string;
1822
+ }
1823
+ interface SearchResult {
1824
+ provider: "builtin";
1825
+ warning?: string;
1826
+ query: string;
1827
+ scope: SearchScope;
1828
+ budget: number;
1829
+ usedTokens: number;
1830
+ hits: SearchHit[];
1831
+ text: string;
1832
+ }
1833
+ interface IndexStats {
1834
+ provider: "builtin";
1835
+ files: number;
1836
+ chunks: number;
1837
+ lastIndexFilesConsidered: number;
1838
+ lastIndexFilesReindexed: number;
1839
+ lastIndexChunksReindexed: number;
1840
+ lastIndexChunksEmbedded: number;
1841
+ indexedCommit: string | null;
1842
+ }
1843
+ interface SearchProvider {
1844
+ readonly id: string;
1845
+ index(changed?: readonly string[]): Promise<IndexStats>;
1846
+ search(query: string, options: SearchQuery): Promise<SearchResult>;
1847
+ stats(): Promise<IndexStats>;
1848
+ }
1849
+ interface RawHit {
1850
+ scope: SearchScope;
1851
+ path: string;
1852
+ startLine: number;
1853
+ endLine: number;
1854
+ symbol: string;
1855
+ score: number;
1856
+ signature: string;
1857
+ body: string;
1858
+ language: string;
1859
+ /** Not printed. Keyword rows are bm25. Fused rows are rrf. */
1860
+ rankedBy?: "bm25" | "rrf";
1861
+ /** Pack-time extract. Absent for code and for the active change. */
1862
+ summary?: string;
1863
+ }
1864
+
1865
+ declare function searchPreamble(query: string, scope: string, budget: number, hybrid?: boolean): string;
1866
+ declare function renderBlock(hit: RawHit, form: "full" | "signature" | "summary"): string;
1867
+ declare function packHits(input: {
1868
+ preamble: string;
1869
+ hits: readonly RawHit[];
1870
+ budget: number;
1871
+ }): {
1872
+ text: string;
1873
+ usedTokens: number;
1874
+ hits: SearchHit[];
1875
+ };
1876
+
1877
+ declare function isHardDenied(rel: string): boolean;
1878
+ /**
1879
+ * Directories the walker does not open. A directory whose basename merely
1880
+ * contains "secret" (the fixture `secret-nest`) is not pruned: `isSecretPath`
1881
+ * applies to the file itself, and `packages/secret-nest/shown.ts` is allowed.
1882
+ */
1883
+ declare function isPrunedDir(rel: string): boolean;
1884
+ declare function loadExcluder(projectRoot: string, exclude: readonly string[]): Promise<(rel: string) => boolean>;
1885
+
1886
+ interface MarkdownChunk {
1887
+ symbol: string;
1888
+ startLine: number;
1889
+ endLine: number;
1890
+ signature: string;
1891
+ body: string;
1892
+ }
1893
+ declare function chunkMarkdown(text: string): MarkdownChunk[];
1894
+
1895
+ declare const SUMMARY_TOKEN_CAP = 80;
1896
+ /** Deterministic extract. Same signature and body always return the same string. */
1897
+ declare function extractiveSummary(signature: string, body: string): string;
1898
+
1899
+ declare function resolveActiveDirectory(projectRoot: string, config: Config): Promise<string>;
1900
+
1901
+ interface CodeChunk {
1902
+ symbol: string;
1903
+ startLine: number;
1904
+ endLine: number;
1905
+ signature: string;
1906
+ body: string;
1907
+ language: string;
1908
+ }
1909
+ declare function chunkCode(text: string, ext: string): Promise<CodeChunk[] | null>;
1910
+
1911
+ declare const EMBEDDING_MODEL = "BAAI/bge-small-en-v1.5";
1912
+ declare const EMBEDDINGS_UNAVAILABLE = "Embeddings are unavailable. Using keyword search.";
1913
+ interface Embedder {
1914
+ /** One L2-normalized vector per text, same order. Text is the raw chunk body. */
1915
+ embedPassages(texts: readonly string[]): Promise<Float32Array[]>;
1916
+ /** One L2-normalized vector for the raw user query. */
1917
+ embedQuery(text: string): Promise<Float32Array>;
1918
+ }
1919
+ interface SearchRuntime {
1920
+ embedder?: Embedder;
1921
+ /** Called instead of fastembed. A throw is an embedder failure. */
1922
+ embedderFactory?: () => Promise<Embedder>;
1923
+ }
1924
+ type EmbedFailure = "none" | "load" | "query";
1925
+ interface FastembedModel {
1926
+ passageEmbed(texts: readonly string[], batchSize: number): AsyncIterable<ArrayLike<number>[]>;
1927
+ queryEmbed(text: string): Promise<ArrayLike<number>>;
1928
+ }
1929
+ type FastembedInit = (options: {
1930
+ model: unknown;
1931
+ executionProviders: unknown[];
1932
+ maxLength: number;
1933
+ showDownloadProgress: boolean;
1934
+ cacheDir: string;
1935
+ }) => Promise<FastembedModel>;
1936
+ interface FastembedHooks {
1937
+ init?: FastembedInit;
1938
+ }
1939
+ /** Incremented only when the embeddings-on path evaluates `import("fastembed")`. */
1940
+ declare let fastembedImportCount: number;
1941
+ /** Fastembed adapter. One successful session per cache directory per process. */
1942
+ declare function createFastembedEmbedder(projectRoot: string, hooks?: FastembedHooks): Promise<Embedder>;
1943
+ /** Embeddings off returns null and does not import fastembed. */
1944
+ declare function resolveEmbedder(projectRoot: string, embeddings: boolean, runtime?: SearchRuntime): Promise<Embedder | null>;
1945
+ declare function embedSearchQuery(embedder: Embedder | null, embeddings: boolean, query: string): Promise<{
1946
+ queryVec: Float32Array | null;
1947
+ failure: EmbedFailure;
1948
+ }>;
1949
+
1950
+ interface RankSession {
1951
+ embeddings: boolean;
1952
+ queryVec: Float32Array | null;
1953
+ failure: EmbedFailure;
1954
+ }
1955
+ declare function scopeForPath(rel: string, config: Config): SearchScope | null;
1956
+ declare function createBuiltinProvider(projectRoot: string, config: Config, runtime?: SearchRuntime): SearchProvider;
1957
+ declare function keywordHits(projectRoot: string, query: string, scope: SearchScope, k: number): Promise<RawHit[]>;
1958
+ declare function listScopeHits(projectRoot: string, scope: SearchScope): Promise<RawHit[]>;
1959
+ declare function rankScope(projectRoot: string, query: string, scope: SearchScope, k: number, session: RankSession): Promise<{
1960
+ hits: RawHit[];
1961
+ warning: boolean;
1962
+ hybrid: boolean;
1963
+ }>;
1964
+
1965
+ declare const RRF_K = 60;
1966
+ declare function rrf(rank: number | undefined): number;
1967
+ interface RankInput {
1968
+ id: string;
1969
+ path: string;
1970
+ startLine: number;
1971
+ symbol: string;
1972
+ keywordRank?: number;
1973
+ vectorRank?: number;
1974
+ }
1975
+ /** Pure fusion. Higher score first, then path, start line, and symbol. */
1976
+ declare function fuseByRank(entries: readonly RankInput[]): {
1977
+ id: string;
1978
+ score: number;
1979
+ }[];
1980
+ /** Union of the two source lists. Does not cut the result to k. */
1981
+ declare function fuseHits(keyword: readonly RawHit[], vector: readonly RawHit[]): RawHit[];
1982
+ /**
1983
+ * All-bm25 keeps the S1 sort. Any rrf hit is emitted first by RRF descending,
1984
+ * then bm25 hits by BM25 ascending. The two scores are never compared.
1985
+ */
1986
+ declare function mergeRankedHits(hits: readonly RawHit[]): RawHit[];
1987
+
1988
+ declare function registerSearchProvider(provider: SearchProvider): void;
1989
+ declare function clearRegisteredSearchProviders(): void;
1990
+ declare function fallbackWarning(name: string): string;
1991
+ declare function resolveSearchProvider(projectRoot: string, config: Config, search: SearchConfig, runtime?: SearchRuntime): SearchProvider;
1992
+ declare function buildRetrievedInner(projectRoot: string, config: Config, title: string, stage: string | undefined, budget: number | undefined, runtime?: SearchRuntime, activeChange?: string): Promise<string>;
1993
+ declare function executeSearch(projectRoot: string, config: Config, query: string, scope: SearchScope, budget: number | undefined): Promise<SearchResult>;
1994
+
1995
+ interface SyncChangeResult {
1996
+ changeId: string;
1997
+ headSha: string;
1998
+ updatedResults: number;
1999
+ reportUpdated: boolean;
2000
+ reportPreserved: boolean;
2001
+ }
2002
+ declare function syncChangeHead(projectRoot: string, config: Config, changeId: string, opts?: {
2003
+ headSha?: string | null;
2004
+ }): Promise<SyncChangeResult>;
1125
2005
 
1126
2006
  declare function listWorkflowNames(projectRoot: string): Promise<string[]>;
2007
+ /** Workflow packs shipped inside this CLI build. */
2008
+ declare function listBundledWorkflowNames(): Promise<string[]>;
2009
+ /** Bundled workflow names that this project has not copied into `.sdd/workflows/`. */
2010
+ declare function missingBundledWorkflows(projectRoot: string): Promise<string[]>;
2011
+ declare function workflowUnavailableMessage(name: string, available: string[], bundled: string[]): string;
1127
2012
  declare function loadWorkflow(projectRoot: string, name: string): Promise<Workflow>;
1128
2013
  /** Resolve effective stages for a change (workflow + per-change overrides). */
1129
2014
  declare function resolveStages(workflow: Workflow, meta: ChangeMeta): Stage[];
@@ -1152,9 +2037,15 @@ declare function recommendWorkflow(projectRoot: string, title: string, config: C
1152
2037
  alternatives: string[];
1153
2038
  }>;
1154
2039
 
2040
+ /** cl100k counts for each workflow file, its artifact templates, and the active change. */
2041
+ declare function formatTokenInventory(projectRoot: string, config: Config): Promise<string>;
2042
+
1155
2043
  interface ChangeContext {
1156
2044
  id: string;
2045
+ /** Absolute directory used for file reads and writes. */
1157
2046
  path: string;
2047
+ /** Repo-relative directory for status, handoff, and active-context text. */
2048
+ displayPath: string;
1158
2049
  meta: ChangeMeta;
1159
2050
  workflow: Workflow;
1160
2051
  stages: Stage[];
@@ -1175,7 +2066,7 @@ declare function resolveChangeId(projectRoot: string, config: Config, changeId?:
1175
2066
  */
1176
2067
  declare function incompletePriorStageErrors(ctx: ChangeContext): Promise<string[]>;
1177
2068
  /** Artifact + gate + verify checks before leaving the current stage. */
1178
- declare function canLeaveStage(ctx: ChangeContext, config: Config): Promise<{
2069
+ declare function canLeaveStage(ctx: ChangeContext, config: Config, projectRoot?: string): Promise<{
1179
2070
  ok: boolean;
1180
2071
  errors: string[];
1181
2072
  warnings: string[];
@@ -1188,13 +2079,13 @@ declare function fallbackIncompleteStageId(ctx: ChangeContext): Promise<string |
1188
2079
  declare function approveGate(projectRoot: string, config: Config, changeId: string, stageId: string | undefined, note?: string, status?: "approved" | "waived" | "failed"): Promise<ChangeContext>;
1189
2080
 
1190
2081
  declare function formatStatus(ctx: ChangeContext): string;
1191
- declare function buildAgentPrompt(ctx: ChangeContext, config: Config, projectRoot: string): Promise<string>;
2082
+ declare function buildAgentPrompt(ctx: ChangeContext, config: Config, projectRoot: string, budget?: number, runtime?: SearchRuntime): Promise<string>;
1192
2083
 
1193
2084
  /**
1194
2085
  * Artifact content quality — existence alone is not "stage complete"
1195
2086
  * (templates are materialized on stage entry and would otherwise auto-pass).
1196
2087
  */
1197
- /** Strip comments/headings/empty bullets; require real prose. */
2088
+ /** Strip comments/headings/empty bullets/instructional template prose; require real prose. */
1198
2089
  declare function isSubstantiveArtifactContent(content: string): boolean;
1199
2090
 
1200
2091
  interface CreateChangeInput {
@@ -1205,6 +2096,9 @@ interface CreateChangeInput {
1205
2096
  domain?: string;
1206
2097
  flags?: Record<string, boolean | string | number>;
1207
2098
  branch?: string;
2099
+ epic?: string;
2100
+ story?: string;
2101
+ depends?: string[];
1208
2102
  }
1209
2103
  interface AdvanceResult {
1210
2104
  ctx: ChangeContext;
@@ -1226,6 +2120,99 @@ declare function completeChange(projectRoot: string, config: Config, changeId: s
1226
2120
  promoted?: string[];
1227
2121
  }>;
1228
2122
 
2123
+ /**
2124
+ * Typed, user-facing errors for sdd core.
2125
+ * CLI maps these to exit codes and optional hints.
2126
+ */
2127
+ declare class SddError extends Error {
2128
+ readonly code: string;
2129
+ readonly hint?: string;
2130
+ readonly exitCode: number;
2131
+ constructor(message: string, options?: {
2132
+ code?: string;
2133
+ hint?: string;
2134
+ exitCode?: number;
2135
+ cause?: unknown;
2136
+ });
2137
+ }
2138
+ declare function isSddError(err: unknown): err is SddError;
2139
+ /** Normalize unknown throws into Error for logging. */
2140
+ declare function errorMessage(err: unknown): string;
2141
+
2142
+ /**
2143
+ * Markers for files sdd generates outside its own state (AGENTS.md, host agent
2144
+ * stubs, protocol). The marker carries a sha256 of the generated body, so sdd
2145
+ * can tell three cases apart:
2146
+ *
2147
+ * - `unmodified`: sdd wrote it and nobody changed it. Safe to regenerate or remove.
2148
+ * - `edited`: sdd wrote it, then someone edited it. Never overwrite or delete.
2149
+ * - `not-generated`: no marker (a user's own file, another tool's, or an old sdd
2150
+ * version's). Never overwrite or delete.
2151
+ */
2152
+ type GeneratedState = "unmodified" | "edited" | "not-generated";
2153
+ /** Line endings are normalized (CRLF → LF) so a Windows/autocrlf checkout is not "edited". */
2154
+ declare function contentHash(body: string): string;
2155
+ /** Insert the marker after YAML front matter (agent hosts parse it) or at the top. */
2156
+ declare function markGenerated(body: string): string;
2157
+ declare function generatedState(content: string): GeneratedState;
2158
+ /**
2159
+ * Why a file was left alone:
2160
+ * - `not-generated` / `edited`: see {@link GeneratedState}
2161
+ * - `symlink`: a symbolic link (or a path through one); sdd never follows, writes
2162
+ * through, or deletes through links
2163
+ * - `unreadable`: could not be read, so sdd cannot prove it generated it
2164
+ */
2165
+ type KeptReason = "not-generated" | "edited" | "symlink" | "unreadable";
2166
+ interface KeptFile {
2167
+ /** Project-relative path */
2168
+ path: string;
2169
+ reason: KeptReason;
2170
+ }
2171
+ declare const GeneratedManifestSchema: z.ZodObject<{
2172
+ version: z.ZodLiteral<1>;
2173
+ files: z.ZodRecord<z.ZodString, z.ZodString>;
2174
+ }, "strict", z.ZodTypeAny, {
2175
+ version: 1;
2176
+ files: Record<string, string>;
2177
+ }, {
2178
+ version: 1;
2179
+ files: Record<string, string>;
2180
+ }>;
2181
+ type GeneratedManifest = z.infer<typeof GeneratedManifestSchema>;
2182
+ interface ReconcileGeneratedResult {
2183
+ created: string[];
2184
+ refreshed: string[];
2185
+ kept: KeptFile[];
2186
+ changed: boolean;
2187
+ }
2188
+ declare function loadGeneratedManifest(path: string): Promise<GeneratedManifest>;
2189
+ declare function saveGeneratedManifest(path: string, manifest: GeneratedManifest): Promise<void>;
2190
+ declare function reconcileGeneratedTree(projectRoot: string, sourceDir: string, destinationDir: string, destinationRelative: string, manifest: GeneratedManifest, force: boolean): Promise<ReconcileGeneratedResult>;
2191
+ declare function describeKept(k: KeptFile): string;
2192
+
2193
+ /** One product role, in the order the host agent must run. */
2194
+ interface ProductTeamMember {
2195
+ order: number;
2196
+ name: string;
2197
+ job: string;
2198
+ accepts: string;
2199
+ file: string;
2200
+ source: "repo" | "user";
2201
+ }
2202
+ /**
2203
+ * Directory whose `.sdd/` holds a user-default team.
2204
+ * `SDD_HOME` overrides the home directory so a test does not read a real `~/.sdd`.
2205
+ */
2206
+ declare function productTeamHome(): string;
2207
+ /**
2208
+ * Product team for the host entrypoint.
2209
+ * A repo `team.yaml` sets the order. Role files in name order are the fallback.
2210
+ * A user-global team is used only when the repo has neither.
2211
+ */
2212
+ declare function loadProductTeam(projectRoot: string): Promise<ProductTeamMember[]>;
2213
+ /** Markdown block for protocol, AGENTS.md, the host rule, and the handoff. */
2214
+ declare function renderProductTeamSection(members: ProductTeamMember[]): string;
2215
+
1229
2216
  /**
1230
2217
  * AI coding agents (not IDEs).
1231
2218
  * Speckit-style: one integration at a time; public keys: `copilot` | `claude` | `grok` | `ollama` | `kilo`.
@@ -1269,10 +2256,36 @@ declare function optionForTarget(target: AgentTarget): AgentTargetOption;
1269
2256
  * Never includes shared SDD dirs (memory, changes, .sdd) or whole .github (workflows stay).
1270
2257
  */
1271
2258
  declare function agentHostPaths(target: AgentTarget): string[];
2259
+ interface RemoveAgentHostsResult {
2260
+ /** Project-relative files and directories sdd removed */
2261
+ removed: string[];
2262
+ /** Files left in place because sdd did not generate them, they were edited, or are links */
2263
+ kept: KeptFile[];
2264
+ }
2265
+ /** Turn a raw fs error (EACCES, EISDIR, …) into a sentence naming the path. */
2266
+ declare function describeFsError(err: unknown, action: string, rel: string): string;
2267
+ /** Thrown before anything is written when sdd cannot safely install agent files. */
2268
+ declare class AgentInstallPreflightError extends SddError {
2269
+ readonly problems: string[];
2270
+ constructor(problems: string[]);
2271
+ }
2272
+ /** Files sdd would remove from other hosts' folders, and what it leaves alone. */
2273
+ interface RemovalPlan {
2274
+ remove: string[];
2275
+ kept: KeptFile[];
2276
+ }
1272
2277
  /**
1273
- * Remove agent files for hosts other than `keep` (and legacy IntelliJ notes).
2278
+ * Remove agent files for hosts other than `keep`, but only files sdd generated
2279
+ * and nobody edited since (marker + content hash). User files, edited files,
2280
+ * symlinks and other tools' files in those folders are kept and reported.
2281
+ * Never follows symlinks. Only folders emptied by this removal are pruned.
1274
2282
  * Does not touch .sdd/, memory/, changes/, or non-agent .github content.
1275
2283
  */
2284
+ declare function removeOtherAgentHostsDetailed(projectRoot: string, keep: AgentTarget): Promise<RemoveAgentHostsResult>;
2285
+ /**
2286
+ * Remove sdd-generated, unedited agent files for hosts other than `keep`.
2287
+ * Returns the removed paths. See {@link removeOtherAgentHostsDetailed} for kept files.
2288
+ */
1276
2289
  declare function removeOtherAgentHosts(projectRoot: string, keep: AgentTarget): Promise<string[]>;
1277
2290
  /** Parse one Speckit-style integration key. */
1278
2291
  declare function parseIntegration(raw: string): AgentTarget;
@@ -1298,7 +2311,12 @@ interface InstallAgentOptions {
1298
2311
  }
1299
2312
  interface InstallAgentResult {
1300
2313
  created: string[];
2314
+ /** sdd-generated, unedited files that already existed (re-run with force to regenerate) */
1301
2315
  skipped: string[];
2316
+ /** Files never overwritten or deleted: not generated by sdd, or edited since */
2317
+ kept: KeptFile[];
2318
+ /** Other hosts' sdd-generated files that were removed */
2319
+ removed: string[];
1302
2320
  target: AgentTarget;
1303
2321
  }
1304
2322
  /** @deprecated Use InstallAgentOptions / installAgentIntegration. */
@@ -1313,6 +2331,30 @@ type InstallAgentsResult = {
1313
2331
  skipped: string[];
1314
2332
  targets: AgentTarget[];
1315
2333
  };
2334
+ /** What installAgentIntegration would do with one generated file. */
2335
+ interface PlannedWrite {
2336
+ rel: string;
2337
+ content: string;
2338
+ /** create: new file · overwrite: unmodified sdd file + force · skip: unmodified, no force · keep: never touched */
2339
+ action: "create" | "overwrite" | "skip" | "keep";
2340
+ keptReason?: KeptFile["reason"];
2341
+ /** For symlinks on the path: the link itself */
2342
+ keptPath?: string;
2343
+ }
2344
+ interface AgentInstallPlan {
2345
+ writes: PlannedWrite[];
2346
+ removal: RemovalPlan;
2347
+ /** Reasons the install cannot proceed safely; empty when it can */
2348
+ problems: string[];
2349
+ }
2350
+ /**
2351
+ * Work out every write and removal for an agent install without touching the disk,
2352
+ * and collect anything that would make it fail half-way (a directory where a file
2353
+ * goes, unreadable or read-only files, non-writable folders).
2354
+ */
2355
+ declare function planAgentIntegration(opts: InstallAgentOptions): Promise<AgentInstallPlan>;
2356
+ /** Throw {@link AgentInstallPreflightError} (before any write) if the install cannot finish. */
2357
+ declare function assertAgentInstallable(opts: InstallAgentOptions): Promise<void>;
1316
2358
  /**
1317
2359
  * Install thin agents for **one** AI integration (registry-driven).
1318
2360
  * Writes protocol + active-context + role stubs + single `.sdd/agents.json` snapshot.
@@ -1323,8 +2365,8 @@ declare function installAgentIntegration(opts: InstallAgentOptions): Promise<Ins
1323
2365
  * Prefer installAgentIntegration for product flows.
1324
2366
  */
1325
2367
  declare function installAgentIntegrations(opts: InstallAgentsOptions): Promise<InstallAgentsResult>;
1326
- /** Thin agent body shared across hosts (same text). */
1327
- declare function renderThinAgent(role: SddAgentRole): string;
2368
+ /** Thin agent body shared across hosts (same text). Paths come from config. */
2369
+ declare function renderThinAgent(role: SddAgentRole, config?: Config, team?: ProductTeamMember[]): string;
1328
2370
  interface InstalledAgentSnapshot {
1329
2371
  /** Public key: copilot | claude | grok | ollama | kilo */
1330
2372
  ai: string;
@@ -1337,7 +2379,7 @@ declare function loadInstalledAgent(projectRoot: string): Promise<InstalledAgent
1337
2379
  * Write `.sdd/handoff.md` for the active (or given) change — full agent brief.
1338
2380
  * Used by `sdd agent` and auto-launch after `sdd new`.
1339
2381
  */
1340
- declare function writeAgentHandoff(projectRoot: string, config: Config, changeId: string): Promise<string>;
2382
+ declare function writeAgentHandoff(projectRoot: string, config: Config, changeId: string, budget?: number, runtime?: SearchRuntime): Promise<string>;
1341
2383
  /** Short kickoff line to pass into agent CLIs (full brief is in handoff.md). */
1342
2384
  declare function agentKickoffMessage(opts: {
1343
2385
  title: string;
@@ -1350,34 +2392,60 @@ declare function agentKickoffMessage(opts: {
1350
2392
  * (used by sdd refine and other specialized modes).
1351
2393
  */
1352
2394
  instructions?: string;
2395
+ /** Configured folders; defaults keep existing `memory/` and `changes/` wording. */
2396
+ memoryPath?: string;
2397
+ changesPath?: string;
1353
2398
  }): string;
1354
2399
  /** Write .sdd/active-context.md for the current change. */
1355
2400
  declare function refreshActiveAgentContext(projectRoot: string): Promise<string | null>;
1356
- /** Single playbook — only long agent-facing content we author once. */
1357
- declare const PROTOCOL_MD = "# SDD protocol\n\nThis repo uses **Structured Vibe Coding** (`sdd`). Agents must follow this file plus `.sdd/active-context.md`. Do not invent a parallel process.\n\n## Source of truth\n\n| What | Where |\n|------|--------|\n| Process state | `changes/<id>/meta.yaml` (workflow, stage, gates) |\n| Current task snapshot | `.sdd/active-context.md` |\n| Non-negotiables | `memory/constitution.md` if present |\n| Stable product/tech rules | `memory/*.md` (start at `memory/index.md` if present) |\n| Stage artifacts | files in `changes/<id>/` for the active change |\n\n## Required read order\n\n1. `.sdd/active-context.md`\n2. This file (`.sdd/protocol.md`)\n3. `memory/constitution.md` if present (non-negotiables agents must not violate)\n4. `meta.yaml` + artifacts for the **current stage** (and prior stages if needed)\n5. `memory/index.md` (documentation map) if present, then linked memory pages when architecture or conventions matter\n\n## Stage behavior\n\n| Stage kind | Agent focus |\n|------------|-------------|\n| intent / feature / stories | Clarify scope; write short artifacts |\n| design / lld / db / research / hl_arb | Specs and decisions; minimal product code |\n| tasks | Break work into implementable checklist |\n| implement | Code only for this change; follow tasks/acceptance |\n| local_verify | Check acceptance; fix only; prepare for complete |\n| brainstorm (optional) | Multiple approaches; parallel exploration; no final design yet |\n| clarify_* (optional) | Ask clarifying questions; write Q&A; or tell human to skip |\n\n## Optional stages\n\n- Stages marked **optional** / kind `brainstorm` or `clarify` may be skipped: \n `sdd skip <stage_id> -r \"not needed\"`\n- Do **not** invent a skip by jumping stages. `sdd next` blocks on empty required stubs (e.g. design.md).\n- If the tool falls back to an earlier stage, **complete that stage** before advancing again.\n\n## Hard rules\n\n1. **Do not skip hard gates.** If blocked, tell the human to run `sdd gate approve` (or fix the gate).\n2. **Stay in scope** of the active change title/intent. No drive-by refactors or new features.\n3. **Honor constraints** in `arb-decision.md`, design, and memory non-negotiables.\n4. **Local verify** is part of done when the workflow has a verify stage: `sdd verify`.\n5. Prefer small, reviewable diffs.\n6. **Required stage artifacts must be substantive** \u2014 not empty templates. Design cannot be skipped via empty design.md.\n\n## Commands (human / shell)\n\n```bash\nsdd status\nsdd next\nsdd agent # print handoff\nsdd agents refresh # refresh active-context.md\nsdd verify\nsdd complete\n```\n\n## Out of scope for agents\n\n- Replacing CI/CD or team process tools\n- Deleting `.sdd` / completed change history\n- Claiming complete without verify when required\n";
2401
+ /** Default-path protocol text. Generated files use {@link renderProtocolMd}. */
2402
+ declare const PROTOCOL_MD: string;
2403
+ /** Single playbook — paths come from project config, not hard-coded defaults. */
2404
+ declare function renderProtocolMd(config: Pick<Config, "memory_path" | "changes_path">, team?: ProductTeamMember[]): string;
2405
+ declare function renderAgentsMd(integ: AgentIntegration, config?: Config, team?: ProductTeamMember[]): string;
1358
2406
 
1359
2407
  interface InitOptions {
1360
2408
  projectRoot: string;
1361
2409
  force?: boolean;
2410
+ /** Place memory, changes, domains, and archive beneath this project-relative root. */
2411
+ layoutRoot?: string;
1362
2412
  /**
1363
2413
  * AI coding agent to install (single, Speckit-style). Not an IDE.
1364
2414
  * - omit / `false` — no agent files
1365
2415
  * - `AgentTarget` — install that integration only
1366
2416
  */
1367
2417
  agents?: false | AgentTarget;
2418
+ /**
2419
+ * Test seam for "is this path tracked?". Return null when git cannot answer.
2420
+ * Production uses `git ls-files`.
2421
+ */
2422
+ indexLookup?: (projectRoot: string, relativePaths: string[]) => Promise<string[] | null>;
1368
2423
  }
1369
2424
  interface InitResult {
1370
2425
  created: string[];
1371
2426
  config: Config;
2427
+ warnings: string[];
2428
+ /** Existing files init left alone: not generated by sdd, or edited since */
2429
+ kept: KeptFile[];
1372
2430
  agents?: {
1373
2431
  created: string[];
1374
2432
  skipped: string[];
2433
+ kept: KeptFile[];
2434
+ removed: string[];
1375
2435
  };
1376
2436
  }
1377
2437
  declare function initProject(opts: InitOptions): Promise<InitResult>;
2438
+ /** Append missing required ignore lines. Does not rewrite config, memory, or workflows. */
2439
+ declare function repairRequiredIgnores(projectRoot: string): Promise<boolean>;
1378
2440
 
2441
+ /** pass: every command ran and exited 0 · fail: a command failed · not_run: nothing was executed */
2442
+ type VerifyStatus = "pass" | "fail" | "not_run";
1379
2443
  interface VerifyResult {
1380
2444
  stageId: string;
2445
+ /** Overall outcome; never "pass" unless at least one command ran and all exited 0 */
2446
+ status: VerifyStatus;
2447
+ /** Why the status is not "pass" (human readable) */
2448
+ reason?: string;
1381
2449
  results: {
1382
2450
  name: string;
1383
2451
  command: string;
@@ -1387,13 +2455,21 @@ interface VerifyResult {
1387
2455
  checklist: string[];
1388
2456
  /** Path to evidence dir when configured; null when no evidence_dir is set */
1389
2457
  evidencePath: string | null;
1390
- /** False if any required command failed or was not run when required */
2458
+ /** local-test-results.md that was written; null when nothing was recorded (wrong stage) */
2459
+ resultsPath: string | null;
2460
+ /** True only when status is "pass" */
1391
2461
  ok: boolean;
1392
2462
  }
1393
2463
  declare function runLocalVerify(projectRoot: string, config: Config, changeId: string, opts?: {
1394
2464
  runCommands?: boolean;
2465
+ headSha?: string | null;
1395
2466
  }): Promise<VerifyResult>;
1396
2467
 
2468
+ /**
2469
+ * Lowercase, strip quotes, collapse non-alphanumerics to `-`.
2470
+ * At most 60 characters, cut only on token boundaries.
2471
+ * A trailing `#NNN` is kept whole when it fits, never sliced into a shorter number.
2472
+ */
1397
2473
  declare function slugify(input: string): string;
1398
2474
  declare function todayIsoDate(d?: Date): string;
1399
2475
  declare function nowIso(d?: Date): string;
@@ -1409,9 +2485,12 @@ declare function uniqueChangeDirName(base: string, taken: Set<string>): string;
1409
2485
  */
1410
2486
  declare function defaultsRoot(): string;
1411
2487
  declare function defaultWorkflowsDir(): string;
2488
+ declare function defaultTeamsDir(): string;
1412
2489
  declare function defaultTemplatesDir(): string;
1413
2490
  declare function defaultMemoryDir(): string;
1414
2491
  declare function defaultMcpYamlPath(): string;
2492
+ declare function defaultPricesYamlPath(): string;
2493
+ declare function defaultSearchYamlPath(): string;
1415
2494
 
1416
2495
  declare function pathExists(path: string): Promise<boolean>;
1417
2496
  declare function ensureDir(path: string): Promise<void>;
@@ -1431,25 +2510,6 @@ declare function copyDirSkipExisting(src: string, dest: string): Promise<void>;
1431
2510
  declare function writeTextIfMissing(path: string, content: string): Promise<boolean>;
1432
2511
  declare function removePath(path: string): Promise<void>;
1433
2512
 
1434
- /**
1435
- * Typed, user-facing errors for sdd core.
1436
- * CLI maps these to exit codes and optional hints.
1437
- */
1438
- declare class SddError extends Error {
1439
- readonly code: string;
1440
- readonly hint?: string;
1441
- readonly exitCode: number;
1442
- constructor(message: string, options?: {
1443
- code?: string;
1444
- hint?: string;
1445
- exitCode?: number;
1446
- cause?: unknown;
1447
- });
1448
- }
1449
- declare function isSddError(err: unknown): err is SddError;
1450
- /** Normalize unknown throws into Error for logging. */
1451
- declare function errorMessage(err: unknown): string;
1452
-
1453
2513
  /**
1454
2514
  * Sanitize env maps for child processes (MCP stdio, verify commands).
1455
2515
  */
@@ -1458,6 +2518,16 @@ declare function toProcessEnv(base: NodeJS.ProcessEnv | Record<string, string |
1458
2518
 
1459
2519
  declare const SDD_CORE_VERSION: string;
1460
2520
 
2521
+ /** `.sdd/README.md` body. Paths come from config. */
2522
+ declare function renderSddReadme(config: Pick<Config, "memory_path" | "changes_path">): string;
2523
+ /** Documentation map. Paths come from config. */
2524
+ declare function renderMemoryIndex(config: Pick<Config, "memory_path" | "changes_path">): string;
2525
+ /**
2526
+ * Rewrite generated guidance that still names the default folders when config
2527
+ * uses other paths. Edited files are left alone.
2528
+ */
2529
+ declare function refreshConfiguredGuidance(projectRoot: string, config: Config): Promise<void>;
2530
+
1461
2531
  /**
1462
2532
  * Public + internal types for the on-demand structure-aware code context pipeline.
1463
2533
  * Contracts: LLD §2.1 / research §6.5.
@@ -1498,7 +2568,7 @@ interface CodeContextRequest {
1498
2568
  */
1499
2569
  writeArtifactTo?: string | null;
1500
2570
  }
1501
- type CodeContextGapCode = "no_focus" | "path_missing" | "path_denied_secret" | "path_ignored" | "unsupported_language" | "parse_error" | "empty_extract" | "cap_truncated" | "no_active_change" | "change_not_found" | "adapter_unavailable";
2571
+ type CodeContextGapCode = "no_focus" | "path_missing" | "path_denied_secret" | "path_ignored" | "unsupported_language" | "parse_error" | "empty_extract" | "cap_truncated" | "no_active_change" | "change_not_found" | "adapter_unavailable" | "embeddings_unavailable";
1502
2572
  interface CodeContextGap {
1503
2573
  code: CodeContextGapCode;
1504
2574
  message: string;
@@ -1664,10 +2734,12 @@ declare const fallbackAdapter: LanguageAdapter;
1664
2734
  * Public entry: generateCodeContext
1665
2735
  */
1666
2736
 
1667
- /** Optional deps for tests (inject adapters). */
2737
+ /** Optional deps for tests (inject adapters or an embedder). */
1668
2738
  type GenerateCodeContextDeps = {
1669
2739
  adapters?: LanguageAdapter[];
1670
2740
  now?: () => Date;
2741
+ embedder?: SearchRuntime["embedder"];
2742
+ embedderFactory?: SearchRuntime["embedderFactory"];
1671
2743
  };
1672
2744
  /**
1673
2745
  * Main entry: on-demand pipeline. Partial success returns ok:true with gaps.
@@ -1900,11 +2972,11 @@ declare const McpSourceSchema: z.ZodObject<{
1900
2972
  intents: string[];
1901
2973
  };
1902
2974
  priority: number;
2975
+ enabled: boolean;
2976
+ command: string;
1903
2977
  args: string[];
1904
2978
  transport: "stdio";
1905
- command: string;
1906
2979
  env: Record<string, string>;
1907
- enabled: boolean;
1908
2980
  cwd?: string | undefined;
1909
2981
  invoke?: {
1910
2982
  tool: string;
@@ -1922,11 +2994,11 @@ declare const McpSourceSchema: z.ZodObject<{
1922
2994
  intents?: string[] | undefined;
1923
2995
  } | undefined;
1924
2996
  priority?: number | undefined;
2997
+ enabled?: boolean | undefined;
2998
+ cwd?: string | undefined;
1925
2999
  args?: string[] | undefined;
1926
3000
  transport?: "stdio" | undefined;
1927
3001
  env?: Record<string, string> | undefined;
1928
- cwd?: string | undefined;
1929
- enabled?: boolean | undefined;
1930
3002
  invoke?: {
1931
3003
  tool: string;
1932
3004
  args?: Record<string, unknown> | undefined;
@@ -2009,11 +3081,11 @@ declare const McpConfigSchema: z.ZodObject<{
2009
3081
  intents: string[];
2010
3082
  };
2011
3083
  priority: number;
3084
+ enabled: boolean;
3085
+ command: string;
2012
3086
  args: string[];
2013
3087
  transport: "stdio";
2014
- command: string;
2015
3088
  env: Record<string, string>;
2016
- enabled: boolean;
2017
3089
  cwd?: string | undefined;
2018
3090
  invoke?: {
2019
3091
  tool: string;
@@ -2031,11 +3103,11 @@ declare const McpConfigSchema: z.ZodObject<{
2031
3103
  intents?: string[] | undefined;
2032
3104
  } | undefined;
2033
3105
  priority?: number | undefined;
3106
+ enabled?: boolean | undefined;
3107
+ cwd?: string | undefined;
2034
3108
  args?: string[] | undefined;
2035
3109
  transport?: "stdio" | undefined;
2036
3110
  env?: Record<string, string> | undefined;
2037
- cwd?: string | undefined;
2038
- enabled?: boolean | undefined;
2039
3111
  invoke?: {
2040
3112
  tool: string;
2041
3113
  args?: Record<string, unknown> | undefined;
@@ -2056,11 +3128,11 @@ declare const McpConfigSchema: z.ZodObject<{
2056
3128
  intents: string[];
2057
3129
  };
2058
3130
  priority: number;
3131
+ enabled: boolean;
3132
+ command: string;
2059
3133
  args: string[];
2060
3134
  transport: "stdio";
2061
- command: string;
2062
3135
  env: Record<string, string>;
2063
- enabled: boolean;
2064
3136
  cwd?: string | undefined;
2065
3137
  invoke?: {
2066
3138
  tool: string;
@@ -2083,11 +3155,11 @@ declare const McpConfigSchema: z.ZodObject<{
2083
3155
  intents?: string[] | undefined;
2084
3156
  } | undefined;
2085
3157
  priority?: number | undefined;
3158
+ enabled?: boolean | undefined;
3159
+ cwd?: string | undefined;
2086
3160
  args?: string[] | undefined;
2087
3161
  transport?: "stdio" | undefined;
2088
3162
  env?: Record<string, string> | undefined;
2089
- cwd?: string | undefined;
2090
- enabled?: boolean | undefined;
2091
3163
  invoke?: {
2092
3164
  tool: string;
2093
3165
  args?: Record<string, unknown> | undefined;
@@ -2188,4 +3260,720 @@ declare function gatherMcpContextForChange(projectRoot: string, ctx: ChangeConte
2188
3260
  declare function formatMcpContextForHandoff(results: McpFetchResult[]): string;
2189
3261
  declare function listMatchingSourceIds(sources: McpSource[], match: McpMatchContext): string[];
2190
3262
 
2191
- export { AGENT_INTEGRATIONS, AGENT_TARGET_OPTIONS, ALL_AGENT_TARGETS, type AdapterExtractResult, AdapterRegistry, type AdvanceResult, type AgentIntegration, type AgentTarget, type AgentTargetOption, type ArtifactDef, ArtifactDefSchema, type BuildRefinePlanOptions, type CallMcpToolResult, type ChangeContext, type ChangeMeta, ChangeMetaSchema, type CodeContextCaps, type CodeContextGap, type CodeContextGapCode, type CodeContextRequest, type CodeContextResult, type CodeContextSummary, type CodeSlice, type Complexity, type Config, ConfigSchema, type CreateChangeInput, DEFAULT_CODE_CONTEXT_CAPS, DEFAULT_INIT_INTEGRATION, type FocusPlan, type Gate, GateSchema, type GatherMcpOptions, type GenerateCodeContextDeps, type GreenfieldFeature, type InitOptions, type InitResult, type InstallAgentOptions, type InstallAgentResult, type InstallAgentsOptions, type InstallAgentsResult, type InstalledAgentSnapshot, type LanguageAdapter, type McpConfig, McpConfigSchema, type McpFetchResult, type McpInvoke, McpInvokeSchema, type McpMatchContext, type McpSource, McpSourceSchema, type McpWhen, McpWhenSchema, PROTOCOL_MD, type RefineArtifactRef, type RefineMode, type RefinePlan, SDD_AGENT_ROLES, SDD_CORE_VERSION, SDD_DIR, type SddAgentRole, type SddAgentRoleId, SddError, type Stage, StageSchema, type StartFeatureInput, type StartGreenfieldInput, type StartGreenfieldResult, type SymbolInfo, type SymbolKind, VerifyCommandSchema, type VerifyResult, type Workflow, WorkflowSchema, activePointerPath, activeStages, addMcpSource, advanceStage, agentHostPaths, agentKickoffMessage, approveGate, archiveDir, buildAgentPrompt, buildContext, buildRefinePlan, callMcpSourceTool, canLeaveStage, changeDirName, changeMetaPath, changePath, changesDir, classifyPath, clearActiveIf, completeChange, configPath, copyDir, copyDirSkipExisting, createChange, defaultConfig, defaultMcpConfig, defaultMcpYamlPath, defaultMemoryDir, defaultTemplatesDir, defaultWorkflowsDir, defaultsRoot, domainsDir, ensureDir, ensureMcpConfig, errorMessage, explainMatch, fallbackAdapter, fallbackIncompleteStageId, findFeaturesBacklogPath, firstActiveStageId, formatJsonSummary, formatMcpContextForHandoff, formatStatus, gatherMcpContext, gatherMcpContextForChange, generateCodeContext, getActiveChangeId, getIntegration, getStage, incompletePriorStageErrors, inferComplexity, initProject, installAgentIntegration, installAgentIntegrations, integrationKeyFor, interpolate, interpolateArgs, isIgnoredPath, isInitialized, isSddError, isSecretPath, isStageSkipped, isSubstantiveArtifactContent, listBacklogFeatures, listChanges, listDirs, listFiles, listMatchingSourceIds, listMcpSourceTools, listWorkflowNames, loadChangeMeta, loadConfig, loadInstalledAgent, loadMcpConfig, loadWorkflow, matchMcpSources, mcpConfigPath, mcpTimeoutMs, memoryDir, mergeCaps, nextStageId, nowIso, optionForTarget, parseAgentTargets, parseFeaturesBacklog, parseIntegration, pathExists, promoteGreenfieldToMemory, readText, readYaml, recommendWorkflow, refreshActiveAgentContext, removeMcpSource, removeOtherAgentHosts, removePath, renderThinAgent, resolveChangeId, resolveFocus, resolveStages, runLocalVerify, saveChangeMeta, saveConfig, saveMcpConfig, sddRoot, setActiveChange, shouldAutoSkip, skipStage, slugify, startFeatureFromBacklog, startGreenfield, switchWorkflow, templatesDir, toProcessEnv, todayIsoDate, tokenizeKeywords, typescriptAdapter, uniqueChangeDirName, updateFeatureStatus, withMcpSource, workflowsDir, writeAgentHandoff, writeRefineBrief, writeText, writeTextIfMissing, writeYaml };
3263
+ interface RoleLists {
3264
+ owns: string[];
3265
+ inputs: string[];
3266
+ outputs: string[];
3267
+ collaborates: string[];
3268
+ reviews: string[];
3269
+ approvers: string[];
3270
+ never: string[];
3271
+ askHumanWhen: string[];
3272
+ skills: string[];
3273
+ rules: string[];
3274
+ goals: string[];
3275
+ }
3276
+ interface RoleProfile extends RoleLists {
3277
+ name: string;
3278
+ label: string;
3279
+ job: string;
3280
+ description: string;
3281
+ askFirst: boolean;
3282
+ pinned: boolean;
3283
+ hidden: boolean;
3284
+ }
3285
+ interface RoleModel {
3286
+ complete(input: {
3287
+ roleId: string;
3288
+ prompt: string;
3289
+ }): Promise<string>;
3290
+ }
3291
+ declare const WORK_TYPES: readonly ["route", "classify", "check", "draft", "design", "code", "review"];
3292
+ type WorkType = (typeof WORK_TYPES)[number];
3293
+ declare function isWorkType(value: string): value is WorkType;
3294
+ /** Route, classify, and check are cheap decisions. The other work types reason. */
3295
+ declare function workKind(workType: WorkType): "reason" | "decide";
3296
+ interface DecisionModel {
3297
+ decide<T extends string>(input: {
3298
+ state: string;
3299
+ question: string;
3300
+ options: readonly T[];
3301
+ }): Promise<{
3302
+ pick: T;
3303
+ probs: Record<T, number>;
3304
+ }>;
3305
+ }
3306
+ interface ModelChoice {
3307
+ id: string;
3308
+ kind: "reason" | "decide";
3309
+ provider: "rules" | "command" | "ollama";
3310
+ why: string;
3311
+ }
3312
+ interface RoleCommandResult {
3313
+ exitCode: number;
3314
+ stdout: string;
3315
+ runId?: string;
3316
+ }
3317
+
3318
+ declare function setRoleMessaging(root: string, enabled: boolean): Promise<RoleCommandResult>;
3319
+ declare function handoffRole(root: string, input: {
3320
+ from: string;
3321
+ to: string;
3322
+ task?: string;
3323
+ change?: string;
3324
+ section?: string;
3325
+ model?: RoleModel;
3326
+ now?: () => Date;
3327
+ }): Promise<RoleCommandResult>;
3328
+ declare function showRoleGroup(root: string, changeId: string): Promise<RoleCommandResult>;
3329
+ declare function planNetwork(root: string, input: {
3330
+ change?: string;
3331
+ section?: string;
3332
+ task?: string;
3333
+ model?: RoleModel;
3334
+ now?: () => Date;
3335
+ }): Promise<RoleCommandResult>;
3336
+ declare function acceptNetwork(root: string, input: {
3337
+ change?: string;
3338
+ section?: string;
3339
+ }): Promise<RoleCommandResult>;
3340
+ declare function runNetwork(root: string, input: {
3341
+ change?: string;
3342
+ section?: string;
3343
+ model?: RoleModel;
3344
+ now?: () => Date;
3345
+ }): Promise<RoleCommandResult>;
3346
+ declare function rebuildNetwork(root: string, input: {
3347
+ change?: string;
3348
+ section?: string;
3349
+ model?: RoleModel;
3350
+ now?: () => Date;
3351
+ }): Promise<RoleCommandResult>;
3352
+
3353
+ interface RunRoleInput {
3354
+ name: string;
3355
+ task?: string;
3356
+ withRole?: string;
3357
+ kind?: string;
3358
+ section?: string;
3359
+ change?: string;
3360
+ stop?: boolean;
3361
+ model?: RoleModel;
3362
+ now?: () => Date;
3363
+ }
3364
+ interface AllowRoleInput {
3365
+ runId: string;
3366
+ mode: "once" | "always" | "deny";
3367
+ now?: () => Date;
3368
+ }
3369
+ declare function runRole(root: string, input: RunRoleInput): Promise<RoleCommandResult>;
3370
+ declare function allowRole(root: string, input: AllowRoleInput): Promise<RoleCommandResult>;
3371
+
3372
+ declare function recordSignoff(root: string, input: {
3373
+ note?: string;
3374
+ stage?: string;
3375
+ change?: string;
3376
+ }): Promise<RoleCommandResult>;
3377
+ declare function recordDecisionRequest(root: string, input: {
3378
+ note?: string;
3379
+ change?: string;
3380
+ }): Promise<RoleCommandResult>;
3381
+
3382
+ declare function createRole(root: string, input: {
3383
+ name: string;
3384
+ label: string;
3385
+ job: string;
3386
+ description?: string;
3387
+ askFirst?: boolean;
3388
+ } & Partial<RoleLists>): Promise<RoleCommandResult>;
3389
+ declare function editRole(root: string, nameInput: string, patch: {
3390
+ label?: string;
3391
+ job?: string;
3392
+ description?: string;
3393
+ askFirst?: boolean;
3394
+ }): Promise<RoleCommandResult>;
3395
+ declare function pinRole(root: string, name: string): Promise<RoleCommandResult>;
3396
+ declare function hideRole(root: string, name: string): Promise<RoleCommandResult>;
3397
+ declare function showRoles(root: string, opts?: {
3398
+ name?: string;
3399
+ all?: boolean;
3400
+ }): Promise<RoleCommandResult>;
3401
+ declare function duplicateRole(root: string, nameInput: string): Promise<RoleCommandResult>;
3402
+ declare function deleteRole(root: string, nameInput: string): Promise<RoleCommandResult>;
3403
+
3404
+ /** Project team file written to `.sdd/team.yaml`. */
3405
+ declare const TeamSchema: z.ZodEffects<z.ZodObject<{
3406
+ template: z.ZodOptional<z.ZodString>;
3407
+ branch: z.ZodString;
3408
+ rooms: z.ZodObject<{
3409
+ commit: z.ZodBoolean;
3410
+ }, "strict", z.ZodTypeAny, {
3411
+ commit: boolean;
3412
+ }, {
3413
+ commit: boolean;
3414
+ }>;
3415
+ bots: z.ZodArray<z.ZodObject<{
3416
+ name: z.ZodString;
3417
+ role: z.ZodString;
3418
+ wip: z.ZodNumber;
3419
+ }, "strict", z.ZodTypeAny, {
3420
+ name: string;
3421
+ role: string;
3422
+ wip: number;
3423
+ }, {
3424
+ name: string;
3425
+ role: string;
3426
+ wip: number;
3427
+ }>, "many">;
3428
+ humans: z.ZodDefault<z.ZodArray<z.ZodObject<{
3429
+ name: z.ZodString;
3430
+ }, "strict", z.ZodTypeAny, {
3431
+ name: string;
3432
+ }, {
3433
+ name: string;
3434
+ }>, "many">>;
3435
+ role_wip: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
3436
+ limits: z.ZodOptional<z.ZodEffects<z.ZodObject<{
3437
+ loop_max_steps: z.ZodOptional<z.ZodNumber>;
3438
+ room_rounds: z.ZodOptional<z.ZodNumber>;
3439
+ }, "strict", z.ZodTypeAny, {
3440
+ loop_max_steps?: number | undefined;
3441
+ room_rounds?: number | undefined;
3442
+ }, {
3443
+ loop_max_steps?: number | undefined;
3444
+ room_rounds?: number | undefined;
3445
+ }>, {
3446
+ loop_max_steps?: number | undefined;
3447
+ room_rounds?: number | undefined;
3448
+ }, {
3449
+ loop_max_steps?: number | undefined;
3450
+ room_rounds?: number | undefined;
3451
+ }>>;
3452
+ }, "strict", z.ZodTypeAny, {
3453
+ branch: string;
3454
+ bots: {
3455
+ name: string;
3456
+ role: string;
3457
+ wip: number;
3458
+ }[];
3459
+ rooms: {
3460
+ commit: boolean;
3461
+ };
3462
+ humans: {
3463
+ name: string;
3464
+ }[];
3465
+ template?: string | undefined;
3466
+ role_wip?: Record<string, number> | undefined;
3467
+ limits?: {
3468
+ loop_max_steps?: number | undefined;
3469
+ room_rounds?: number | undefined;
3470
+ } | undefined;
3471
+ }, {
3472
+ branch: string;
3473
+ bots: {
3474
+ name: string;
3475
+ role: string;
3476
+ wip: number;
3477
+ }[];
3478
+ rooms: {
3479
+ commit: boolean;
3480
+ };
3481
+ template?: string | undefined;
3482
+ humans?: {
3483
+ name: string;
3484
+ }[] | undefined;
3485
+ role_wip?: Record<string, number> | undefined;
3486
+ limits?: {
3487
+ loop_max_steps?: number | undefined;
3488
+ room_rounds?: number | undefined;
3489
+ } | undefined;
3490
+ }>, {
3491
+ branch: string;
3492
+ bots: {
3493
+ name: string;
3494
+ role: string;
3495
+ wip: number;
3496
+ }[];
3497
+ rooms: {
3498
+ commit: boolean;
3499
+ };
3500
+ humans: {
3501
+ name: string;
3502
+ }[];
3503
+ template?: string | undefined;
3504
+ role_wip?: Record<string, number> | undefined;
3505
+ limits?: {
3506
+ loop_max_steps?: number | undefined;
3507
+ room_rounds?: number | undefined;
3508
+ } | undefined;
3509
+ }, {
3510
+ branch: string;
3511
+ bots: {
3512
+ name: string;
3513
+ role: string;
3514
+ wip: number;
3515
+ }[];
3516
+ rooms: {
3517
+ commit: boolean;
3518
+ };
3519
+ template?: string | undefined;
3520
+ humans?: {
3521
+ name: string;
3522
+ }[] | undefined;
3523
+ role_wip?: Record<string, number> | undefined;
3524
+ limits?: {
3525
+ loop_max_steps?: number | undefined;
3526
+ room_rounds?: number | undefined;
3527
+ } | undefined;
3528
+ }>;
3529
+ type TeamConfig = z.infer<typeof TeamSchema>;
3530
+
3531
+ declare const ModelEntrySchema: z.ZodDiscriminatedUnion<"provider", [z.ZodObject<{
3532
+ kind: z.ZodLiteral<"decide">;
3533
+ provider: z.ZodLiteral<"rules">;
3534
+ }, "strict", z.ZodTypeAny, {
3535
+ kind: "decide";
3536
+ provider: "rules";
3537
+ }, {
3538
+ kind: "decide";
3539
+ provider: "rules";
3540
+ }>, z.ZodObject<{
3541
+ kind: z.ZodEnum<["decide", "reason"]>;
3542
+ provider: z.ZodLiteral<"command">;
3543
+ command_env: z.ZodString;
3544
+ min_confidence: z.ZodOptional<z.ZodNumber>;
3545
+ }, "strict", z.ZodTypeAny, {
3546
+ kind: "reason" | "decide";
3547
+ provider: "command";
3548
+ command_env: string;
3549
+ min_confidence?: number | undefined;
3550
+ }, {
3551
+ kind: "reason" | "decide";
3552
+ provider: "command";
3553
+ command_env: string;
3554
+ min_confidence?: number | undefined;
3555
+ }>, z.ZodObject<{
3556
+ kind: z.ZodLiteral<"decide">;
3557
+ provider: z.ZodLiteral<"ollama">;
3558
+ model: z.ZodString;
3559
+ base_url_env: z.ZodString;
3560
+ min_confidence: z.ZodOptional<z.ZodNumber>;
3561
+ }, "strict", z.ZodTypeAny, {
3562
+ kind: "decide";
3563
+ provider: "ollama";
3564
+ model: string;
3565
+ base_url_env: string;
3566
+ min_confidence?: number | undefined;
3567
+ }, {
3568
+ kind: "decide";
3569
+ provider: "ollama";
3570
+ model: string;
3571
+ base_url_env: string;
3572
+ min_confidence?: number | undefined;
3573
+ }>]>;
3574
+ type ModelEntry = z.infer<typeof ModelEntrySchema>;
3575
+ declare const ModelsConfigSchema: z.ZodEffects<z.ZodObject<{
3576
+ version: z.ZodLiteral<1>;
3577
+ models: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<"provider", [z.ZodObject<{
3578
+ kind: z.ZodLiteral<"decide">;
3579
+ provider: z.ZodLiteral<"rules">;
3580
+ }, "strict", z.ZodTypeAny, {
3581
+ kind: "decide";
3582
+ provider: "rules";
3583
+ }, {
3584
+ kind: "decide";
3585
+ provider: "rules";
3586
+ }>, z.ZodObject<{
3587
+ kind: z.ZodEnum<["decide", "reason"]>;
3588
+ provider: z.ZodLiteral<"command">;
3589
+ command_env: z.ZodString;
3590
+ min_confidence: z.ZodOptional<z.ZodNumber>;
3591
+ }, "strict", z.ZodTypeAny, {
3592
+ kind: "reason" | "decide";
3593
+ provider: "command";
3594
+ command_env: string;
3595
+ min_confidence?: number | undefined;
3596
+ }, {
3597
+ kind: "reason" | "decide";
3598
+ provider: "command";
3599
+ command_env: string;
3600
+ min_confidence?: number | undefined;
3601
+ }>, z.ZodObject<{
3602
+ kind: z.ZodLiteral<"decide">;
3603
+ provider: z.ZodLiteral<"ollama">;
3604
+ model: z.ZodString;
3605
+ base_url_env: z.ZodString;
3606
+ min_confidence: z.ZodOptional<z.ZodNumber>;
3607
+ }, "strict", z.ZodTypeAny, {
3608
+ kind: "decide";
3609
+ provider: "ollama";
3610
+ model: string;
3611
+ base_url_env: string;
3612
+ min_confidence?: number | undefined;
3613
+ }, {
3614
+ kind: "decide";
3615
+ provider: "ollama";
3616
+ model: string;
3617
+ base_url_env: string;
3618
+ min_confidence?: number | undefined;
3619
+ }>]>>;
3620
+ defaults: z.ZodObject<{
3621
+ by_work_type: z.ZodRecord<z.ZodEnum<["route", "classify", "check", "draft", "design", "code", "review"]>, z.ZodString>;
3622
+ fallback_reason: z.ZodString;
3623
+ fallback_decide: z.ZodString;
3624
+ }, "strict", z.ZodTypeAny, {
3625
+ by_work_type: Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>;
3626
+ fallback_reason: string;
3627
+ fallback_decide: string;
3628
+ }, {
3629
+ by_work_type: Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>;
3630
+ fallback_reason: string;
3631
+ fallback_decide: string;
3632
+ }>;
3633
+ overrides: z.ZodOptional<z.ZodObject<{
3634
+ bots: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEnum<["route", "classify", "check", "draft", "design", "code", "review"]>, z.ZodString>>>;
3635
+ stages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEnum<["route", "classify", "check", "draft", "design", "code", "review"]>, z.ZodString>>>;
3636
+ roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEnum<["route", "classify", "check", "draft", "design", "code", "review"]>, z.ZodString>>>;
3637
+ }, "strict", z.ZodTypeAny, {
3638
+ stages?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3639
+ bots?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3640
+ roles?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3641
+ }, {
3642
+ stages?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3643
+ bots?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3644
+ roles?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3645
+ }>>;
3646
+ }, "strict", z.ZodTypeAny, {
3647
+ version: 1;
3648
+ models: Record<string, {
3649
+ kind: "decide";
3650
+ provider: "rules";
3651
+ } | {
3652
+ kind: "reason" | "decide";
3653
+ provider: "command";
3654
+ command_env: string;
3655
+ min_confidence?: number | undefined;
3656
+ } | {
3657
+ kind: "decide";
3658
+ provider: "ollama";
3659
+ model: string;
3660
+ base_url_env: string;
3661
+ min_confidence?: number | undefined;
3662
+ }>;
3663
+ defaults: {
3664
+ by_work_type: Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>;
3665
+ fallback_reason: string;
3666
+ fallback_decide: string;
3667
+ };
3668
+ overrides?: {
3669
+ stages?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3670
+ bots?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3671
+ roles?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3672
+ } | undefined;
3673
+ }, {
3674
+ version: 1;
3675
+ models: Record<string, {
3676
+ kind: "decide";
3677
+ provider: "rules";
3678
+ } | {
3679
+ kind: "reason" | "decide";
3680
+ provider: "command";
3681
+ command_env: string;
3682
+ min_confidence?: number | undefined;
3683
+ } | {
3684
+ kind: "decide";
3685
+ provider: "ollama";
3686
+ model: string;
3687
+ base_url_env: string;
3688
+ min_confidence?: number | undefined;
3689
+ }>;
3690
+ defaults: {
3691
+ by_work_type: Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>;
3692
+ fallback_reason: string;
3693
+ fallback_decide: string;
3694
+ };
3695
+ overrides?: {
3696
+ stages?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3697
+ bots?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3698
+ roles?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3699
+ } | undefined;
3700
+ }>, {
3701
+ version: 1;
3702
+ models: Record<string, {
3703
+ kind: "decide";
3704
+ provider: "rules";
3705
+ } | {
3706
+ kind: "reason" | "decide";
3707
+ provider: "command";
3708
+ command_env: string;
3709
+ min_confidence?: number | undefined;
3710
+ } | {
3711
+ kind: "decide";
3712
+ provider: "ollama";
3713
+ model: string;
3714
+ base_url_env: string;
3715
+ min_confidence?: number | undefined;
3716
+ }>;
3717
+ defaults: {
3718
+ by_work_type: Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>;
3719
+ fallback_reason: string;
3720
+ fallback_decide: string;
3721
+ };
3722
+ overrides?: {
3723
+ stages?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3724
+ bots?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3725
+ roles?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3726
+ } | undefined;
3727
+ }, {
3728
+ version: 1;
3729
+ models: Record<string, {
3730
+ kind: "decide";
3731
+ provider: "rules";
3732
+ } | {
3733
+ kind: "reason" | "decide";
3734
+ provider: "command";
3735
+ command_env: string;
3736
+ min_confidence?: number | undefined;
3737
+ } | {
3738
+ kind: "decide";
3739
+ provider: "ollama";
3740
+ model: string;
3741
+ base_url_env: string;
3742
+ min_confidence?: number | undefined;
3743
+ }>;
3744
+ defaults: {
3745
+ by_work_type: Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>;
3746
+ fallback_reason: string;
3747
+ fallback_decide: string;
3748
+ };
3749
+ overrides?: {
3750
+ stages?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3751
+ bots?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3752
+ roles?: Record<string, Partial<Record<"code" | "route" | "classify" | "check" | "draft" | "design" | "review", string>>> | undefined;
3753
+ } | undefined;
3754
+ }>;
3755
+ type ModelsConfig = z.infer<typeof ModelsConfigSchema>;
3756
+ declare function loadModels(root: string): Promise<{
3757
+ config: ModelsConfig;
3758
+ } | {
3759
+ error: string;
3760
+ } | null>;
3761
+ declare function checkModels(root: string): Promise<{
3762
+ ok: true;
3763
+ } | {
3764
+ ok: false;
3765
+ message: string;
3766
+ }>;
3767
+
3768
+ interface ModelContext {
3769
+ workType: WorkType;
3770
+ role?: string;
3771
+ bot?: string;
3772
+ stage?: string;
3773
+ }
3774
+ /** Pure precedence: bot, stage, role, work-type default, then the fallback for that kind. */
3775
+ declare function selectModel(config: ModelsConfig, ctx: ModelContext): ModelChoice;
3776
+
3777
+ interface DecideInput<T extends string> {
3778
+ models: ModelsConfig | null;
3779
+ ctx: ModelContext & {
3780
+ workType: WorkType;
3781
+ };
3782
+ state: string;
3783
+ question: string;
3784
+ options: readonly T[];
3785
+ env: Readonly<Record<string, string | undefined>>;
3786
+ fetch?: typeof fetch;
3787
+ runCommand?: (command: string, stdin: string) => Promise<string>;
3788
+ now?: () => Date;
3789
+ metrics?: {
3790
+ projectRoot: string;
3791
+ config: Config;
3792
+ changeId: string;
3793
+ };
3794
+ }
3795
+ interface DecisionOutcome<T extends string> {
3796
+ pick: T | "human";
3797
+ source: "rules" | "decide" | "reason" | "human";
3798
+ choice: ModelChoice | null;
3799
+ confidence: number | null;
3800
+ }
3801
+ declare function decide<T extends string>(input: DecideInput<T>): Promise<DecisionOutcome<T>>;
3802
+
3803
+ declare function spawnModelCommand(command: string, stdin: string): Promise<string>;
3804
+ declare function modelFromEnv(env: Readonly<Record<string, string | undefined>>): RoleModel | undefined;
3805
+
3806
+ declare function formatModels(config: ModelsConfig): string;
3807
+ declare function explainModel(config: ModelsConfig, workType: WorkType, ctx: {
3808
+ role?: string;
3809
+ bot?: string;
3810
+ stage?: string;
3811
+ }): string;
3812
+
3813
+ interface RouteItem {
3814
+ id?: string;
3815
+ stage?: string;
3816
+ artifact?: string;
3817
+ skill?: string;
3818
+ bot?: string;
3819
+ }
3820
+ interface RouteDeps {
3821
+ env?: Readonly<Record<string, string | undefined>>;
3822
+ fetch?: typeof fetch;
3823
+ runCommand?: (command: string, stdin: string) => Promise<string>;
3824
+ now?: () => Date;
3825
+ }
3826
+ type RouteHit = {
3827
+ kind: "role";
3828
+ role: string;
3829
+ reason: string;
3830
+ rule: string;
3831
+ } | {
3832
+ kind: "ask";
3833
+ reason: string;
3834
+ };
3835
+ declare function routeRole(root: string, input: RouteItem, deps?: RouteDeps): Promise<RoleCommandResult>;
3836
+ declare function queueRole(root: string, bot?: string): Promise<RoleCommandResult>;
3837
+ declare function takeRole(root: string, input: RouteItem): Promise<RoleCommandResult>;
3838
+
3839
+ declare function gitUserName(root: string): string | null;
3840
+ declare function listTeamTemplates(): Promise<string[]>;
3841
+ declare function listRoleTemplates(): Promise<string[]>;
3842
+ declare function initTeam(root: string, template: string, gitUser: string | null): Promise<RoleCommandResult>;
3843
+ declare function readTeamConfig(root: string): Promise<{
3844
+ team: TeamConfig;
3845
+ } | {
3846
+ error: string;
3847
+ }>;
3848
+ declare function formatTeam(team: TeamConfig, gitUser: string | null): string;
3849
+ declare function resolveBot(team: TeamConfig, name: string): TeamConfig["bots"][number] | {
3850
+ error: string;
3851
+ };
3852
+ declare function showTeam(root: string, gitUser: string | null): Promise<RoleCommandResult>;
3853
+ declare function checkTeam(root: string): Promise<RoleCommandResult>;
3854
+ declare function createRoleFromTemplate(root: string, input: {
3855
+ name: string;
3856
+ template: string;
3857
+ label?: string;
3858
+ job?: string;
3859
+ description?: string;
3860
+ }): Promise<RoleCommandResult>;
3861
+
3862
+ interface Fact {
3863
+ key: string;
3864
+ value: string;
3865
+ ts: string;
3866
+ by: string;
3867
+ source: string;
3868
+ }
3869
+ declare function getFacts(root: string, query?: {
3870
+ keys?: string[];
3871
+ query?: string;
3872
+ }): Promise<Fact[]>;
3873
+ declare function setFact(root: string, input: {
3874
+ key?: string;
3875
+ value?: string;
3876
+ source?: string;
3877
+ }): Promise<RoleCommandResult>;
3878
+ declare function showFact(root: string, key?: string): Promise<RoleCommandResult>;
3879
+ declare function listFacts(root: string, query?: string): Promise<RoleCommandResult>;
3880
+
3881
+ interface Lesson {
3882
+ ts: string;
3883
+ by: string;
3884
+ text: string;
3885
+ source?: string;
3886
+ tags?: string[];
3887
+ }
3888
+ declare function showMemory(root: string, bot: string): Promise<RoleCommandResult>;
3889
+ declare function addLesson(root: string, bot: string, text: string): Promise<RoleCommandResult>;
3890
+ declare function migrateTeamMemory(root: string): Promise<RoleCommandResult>;
3891
+
3892
+ interface PackedFile {
3893
+ path: string;
3894
+ text: string;
3895
+ }
3896
+ interface WorkItem {
3897
+ text: string;
3898
+ }
3899
+ interface Brain {
3900
+ role: RoleProfile;
3901
+ bot: TeamConfig["bots"][number];
3902
+ memory: string;
3903
+ lessons: Lesson[];
3904
+ facts: Fact[];
3905
+ inputs: PackedFile[];
3906
+ prompt: string;
3907
+ warning: string;
3908
+ }
3909
+ declare function loadBrain(root: string, cfg: TeamConfig, bot: string, item: WorkItem, budgetTokens: number): Promise<Brain | {
3910
+ error: string;
3911
+ }>;
3912
+
3913
+ declare function runLoop(input: {
3914
+ root: string;
3915
+ cfg: TeamConfig;
3916
+ brain: Brain;
3917
+ model: RoleModel;
3918
+ file: string;
3919
+ roleName: string;
3920
+ logName: string;
3921
+ }): Promise<RoleCommandResult>;
3922
+
3923
+ declare function showRoom(root: string, input: {
3924
+ change?: string;
3925
+ stage?: string;
3926
+ }): Promise<RoleCommandResult>;
3927
+ declare function postRoom(root: string, input: {
3928
+ change?: string;
3929
+ stage?: string;
3930
+ from?: string;
3931
+ type?: string;
3932
+ text?: string;
3933
+ cite?: string;
3934
+ evidence?: string[];
3935
+ }): Promise<RoleCommandResult>;
3936
+ declare function reviewRoom(root: string, input: {
3937
+ change?: string;
3938
+ stage?: string;
3939
+ roles?: string[];
3940
+ model?: RoleModel;
3941
+ env?: Readonly<Record<string, string | undefined>>;
3942
+ runCommand?: (command: string, stdin: string) => Promise<string>;
3943
+ }): Promise<RoleCommandResult>;
3944
+
3945
+ interface StoryNode {
3946
+ changeId: string;
3947
+ title: string;
3948
+ story: string;
3949
+ epic: string;
3950
+ depends: string[];
3951
+ status: string;
3952
+ }
3953
+ interface StoryDraft {
3954
+ epic?: string;
3955
+ story?: string;
3956
+ depends: string[];
3957
+ }
3958
+ declare function validBranchName(name: string): boolean;
3959
+ declare function parseStoryDraft(input: {
3960
+ epic?: string;
3961
+ story?: string;
3962
+ depends?: string[];
3963
+ }): {
3964
+ ok: true;
3965
+ draft: StoryDraft;
3966
+ } | {
3967
+ ok: false;
3968
+ stdout: string;
3969
+ };
3970
+ declare function loadEpicStories(projectRoot: string, config: Config, epic: string): Promise<StoryNode[]>;
3971
+ declare function storyIdTaken(projectRoot: string, config: Config, epic: string, story: string): Promise<boolean>;
3972
+ declare function formatEpicGraph(nodes: StoryNode[]): {
3973
+ exitCode: number;
3974
+ stdout: string;
3975
+ };
3976
+ /** Graph errors, then open dependencies. Null means the branch may be created. */
3977
+ declare function branchBlock(nodes: StoryNode[], story: string): string | null;
3978
+
3979
+ export { AGENT_INTEGRATIONS, AGENT_TARGET_OPTIONS, ALL_AGENT_TARGETS, type AdapterExtractResult, AdapterRegistry, type AdvanceResult, type AgentInstallPlan, AgentInstallPreflightError, type AgentIntegration, type AgentTarget, type AgentTargetOption, type AllowRoleInput, type ArtifactDef, ArtifactDefSchema, type BuildRefinePlanOptions, type CallMcpToolResult, type ChangeContext, type ChangeMeta, ChangeMetaSchema, type ChangeMetrics, ChangeMetricsSchema, type ChangePhaseOrder, type CodeContextCaps, type CodeContextGap, type CodeContextGapCode, type CodeContextRequest, type CodeContextResult, type CodeContextSummary, type CodeSlice, type Complexity, type Config, ConfigSchema, type CreateChangeInput, DEFAULT_CODE_CONTEXT_CAPS, DEFAULT_INIT_INTEGRATION, type DecideInput, type DecisionMetric, DecisionMetricSchema, type DecisionModel, type DecisionOutcome, EMBEDDINGS_UNAVAILABLE, EMBEDDING_MODEL, type Embedder, type FastembedHooks, type FocusPlan, type Gate, GateSchema, type GatherMcpOptions, type GenerateCodeContextDeps, type GeneratedManifest, type GeneratedState, type GitHeadRunner, type GreenfieldFeature, type IndexStats, type InitOptions, type InitResult, type InstallAgentOptions, type InstallAgentResult, type InstallAgentsOptions, type InstallAgentsResult, type InstalledAgentSnapshot, type KeptFile, type KeptReason, type LanguageAdapter, type McpConfig, McpConfigSchema, type McpFetchResult, type McpInvoke, McpInvokeSchema, type McpMatchContext, type McpSource, McpSourceSchema, type McpWhen, McpWhenSchema, type MetricsImportResult, type ModelChoice, type ModelContext, type ModelEntry, type ModelsConfig, ModelsConfigSchema, PROTOCOL_MD, type PhaseMetric, PhaseMetricSchema, type PhaseTiming, type PhaseTimingRow, type PlannedWrite, type PriceCard, type Prices, type ProductTeamMember, RRF_K, type RawHit, type ReconcileGeneratedResult, type RefineArtifactRef, type RefineMode, type RefinePlan, type RemoveAgentHostsResult, type RenderChangeReportInput, type RoleCommandResult, type RoleLists, type RoleModel, type RoleProfile, type RouteDeps, type RouteHit, type RouteItem, type RunRoleInput, SDD_AGENT_ROLES, SDD_CORE_VERSION, SDD_DIR, SUMMARY_TOKEN_CAP, type SddAgentRole, type SddAgentRoleId, SddError, type SearchConfig, SearchConfigError, type SearchHit, type SearchProvider, type SearchQuery, type SearchResult, type SearchRuntime, type SearchScope, type Stage, StageSchema, type StartFeatureInput, type StartGreenfieldInput, type StartGreenfieldResult, type StoryDraft, type StoryNode, type SymbolInfo, type SymbolKind, type SyncChangeResult, type TeamConfig, TeamSchema, type TokenCounts, type TokenUsageMetric, TokenUsageMetricSchema, VerifyCommandSchema, type VerifyResult, type VerifyStatus, WORK_TYPES, type WorkType, type Workflow, WorkflowSchema, acceptNetwork, activePointerPath, activeStages, addLesson, addMcpSource, advanceStage, agentHostPaths, agentKickoffMessage, allowRole, approveGate, archiveDir, assertAgentInstallable, assertSessionLogAllowed, branchBlock, budgetForStage, buildAgentPrompt, buildContext, buildRefinePlan, buildRetrievedInner, callMcpSourceTool, canLeaveStage, changeDirName, changeMetaPath, changePath, changesDir, changesPathRel, checkModels, checkTeam, chunkCode, chunkMarkdown, classifyPath, clearActiveIf, clearRegisteredSearchProviders, compareChangesByFirstPhase, completeChange, configPath, contentHash, copyDir, copyDirSkipExisting, costFor, countTokens, createBuiltinProvider, createChange, createFastembedEmbedder, createRole, createRoleFromTemplate, decide, defaultConfig, defaultMcpConfig, defaultMcpYamlPath, defaultMemoryDir, defaultPricesYamlPath, defaultSearchYamlPath, defaultTeamsDir, defaultTemplatesDir, defaultWorkflowsDir, defaultsRoot, deleteRole, describeFsError, describeKept, displayArchivePath, displayChangePath, domainsDir, duplicateRole, editRole, embedSearchQuery, emptyChangeMetrics, ensureDir, ensureMcpConfig, errorMessage, executeSearch, explainMatch, explainModel, extractiveSummary, fallbackAdapter, fallbackIncompleteStageId, fallbackWarning, fastembedImportCount, findFeaturesBacklogPath, firstActiveStageId, formatDuration, formatEpicGraph, formatJsonSummary, formatMcpContextForHandoff, formatModels, formatStatus, formatTeam, formatTokenInventory, ftsTokens, fuseByRank, fuseHits, gatherMcpContext, gatherMcpContextForChange, generateCodeContext, generatedState, getActiveChangeId, getFacts, getHeadSha, getIntegration, getStage, gitUserName, guidancePaths, handoffRole, hideRole, importSessionMetrics, incompletePriorStageErrors, indexDbPath, inferComplexity, initProject, initTeam, installAgentIntegration, installAgentIntegrations, integrationKeyFor, interpolate, interpolateArgs, isHardDenied, isIgnoredPath, isInitialized, isPrunedDir, isSddError, isSecretPath, isStageSkipped, isSubstantiveArtifactContent, isWorkType, keywordHits, listBacklogFeatures, listBundledWorkflowNames, listChanges, listDirs, listFacts, listFiles, listMatchingSourceIds, listMcpSourceTools, listRoleTemplates, listScopeHits, listTeamTemplates, listWorkflowNames, loadBrain, loadChangeMeta, loadConfig, loadEpicStories, loadExcluder, loadGeneratedManifest, loadInstalledAgent, loadMcpConfig, loadModels, loadPrices, loadProductTeam, loadSearchConfig, loadWorkflow, markGenerated, matchMcpSources, mcpConfigPath, mcpTimeoutMs, memoryDir, memoryPathRel, mergeCaps, mergeConfigDefaults, mergeRankedHits, migrateTeamMemory, missingBundledWorkflows, modelFromEnv, nextStageId, nowIso, optionForTarget, packHits, parseAgentTargets, parseFeaturesBacklog, parseIntegration, parseStoryDraft, pathExists, phaseTiming, pinRole, planAgentIntegration, planNetwork, postRoom, productTeamHome, promoteGreenfieldToMemory, queueRole, rankScope, readChangeMetrics, readHandoffCodePoints, readTeamConfig, readText, readYaml, rebuildNetwork, recommendWorkflow, reconcileGeneratedTree, recordDecisionMetric, recordDecisionRequest, recordSignoff, refreshActiveAgentContext, refreshConfiguredGuidance, registerSearchProvider, removeMcpSource, removeOtherAgentHosts, removeOtherAgentHostsDetailed, removePath, renderAgentsMd, renderBlock, renderChangeReport, renderMemoryIndex, renderProductTeamSection, renderProtocolMd, renderSddReadme, renderThinAgent, repairRequiredIgnores, reportAllChanges, reportChange, resolveActiveDirectory, resolveBot, resolveChangeId, resolveEmbedder, resolveFocus, resolveSearchProvider, resolveStages, reviewRoom, routeRole, rrf, runLocalVerify, runLoop, runNetwork, runRole, saveChangeMeta, saveConfig, saveGeneratedManifest, saveMcpConfig, scopeForPath, sddRoot, searchConfigPath, searchPreamble, selectModel, setActiveChange, setFact, setRoleMessaging, shouldAutoSkip, showFact, showMemory, showRoleGroup, showRoles, showRoom, showTeam, skipStage, slugify, spawnModelCommand, startFeatureFromBacklog, startGreenfield, startPhase, storyIdTaken, switchWorkflow, syncChangeHead, takeRole, templatesDir, toProcessEnv, todayIsoDate, tokenizeKeywords, transitionPhase, typescriptAdapter, uniqueChangeDirName, updateFeatureStatus, validBranchName, withMcpSource, workKind, workflowUnavailableMessage, workflowsDir, writeAgentHandoff, writeRefineBrief, writeText, writeTextIfMissing, writeYaml };