qfai 0.4.0 → 0.4.2

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 (161) hide show
  1. package/README.md +6 -1
  2. package/assets/init/.qfai/README.md +2 -1
  3. package/assets/init/.qfai/prompts/README.md +1 -0
  4. package/assets/init/.qfai/prompts/qfai-generate-test-globs.md +29 -0
  5. package/assets/init/root/qfai.config.yaml +6 -0
  6. package/assets/init/root/tests/qfai-traceability.sample.test.ts +2 -2
  7. package/dist/cli/index.cjs +337 -117
  8. package/dist/cli/index.cjs.map +1 -1
  9. package/dist/cli/index.d.ts +0 -2
  10. package/dist/cli/index.mjs +337 -117
  11. package/dist/cli/index.mjs.map +1 -1
  12. package/dist/index.cjs +327 -107
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +23 -9
  15. package/dist/index.d.ts +156 -2
  16. package/dist/index.mjs +327 -107
  17. package/dist/index.mjs.map +1 -1
  18. package/package.json +2 -1
  19. package/dist/cli/commands/init.d.ts +0 -8
  20. package/dist/cli/commands/init.d.ts.map +0 -1
  21. package/dist/cli/commands/init.js +0 -30
  22. package/dist/cli/commands/init.js.map +0 -1
  23. package/dist/cli/commands/report.d.ts +0 -7
  24. package/dist/cli/commands/report.d.ts.map +0 -1
  25. package/dist/cli/commands/report.js +0 -80
  26. package/dist/cli/commands/report.js.map +0 -1
  27. package/dist/cli/commands/validate.d.ts +0 -9
  28. package/dist/cli/commands/validate.d.ts.map +0 -1
  29. package/dist/cli/commands/validate.js +0 -57
  30. package/dist/cli/commands/validate.js.map +0 -1
  31. package/dist/cli/index.d.ts.map +0 -1
  32. package/dist/cli/index.js +0 -7
  33. package/dist/cli/index.js.map +0 -1
  34. package/dist/cli/lib/args.d.ts +0 -18
  35. package/dist/cli/lib/args.d.ts.map +0 -1
  36. package/dist/cli/lib/args.js +0 -98
  37. package/dist/cli/lib/args.js.map +0 -1
  38. package/dist/cli/lib/assets.d.ts +0 -2
  39. package/dist/cli/lib/assets.d.ts.map +0 -1
  40. package/dist/cli/lib/assets.js +0 -24
  41. package/dist/cli/lib/assets.js.map +0 -1
  42. package/dist/cli/lib/failOn.d.ts +0 -5
  43. package/dist/cli/lib/failOn.d.ts.map +0 -1
  44. package/dist/cli/lib/failOn.js +0 -10
  45. package/dist/cli/lib/failOn.js.map +0 -1
  46. package/dist/cli/lib/fs.d.ts +0 -11
  47. package/dist/cli/lib/fs.d.ts.map +0 -1
  48. package/dist/cli/lib/fs.js +0 -91
  49. package/dist/cli/lib/fs.js.map +0 -1
  50. package/dist/cli/lib/logger.d.ts +0 -4
  51. package/dist/cli/lib/logger.d.ts.map +0 -1
  52. package/dist/cli/lib/logger.js +0 -10
  53. package/dist/cli/lib/logger.js.map +0 -1
  54. package/dist/cli/main.d.ts +0 -2
  55. package/dist/cli/main.d.ts.map +0 -1
  56. package/dist/cli/main.js +0 -66
  57. package/dist/cli/main.js.map +0 -1
  58. package/dist/core/config.d.ts +0 -46
  59. package/dist/core/config.d.ts.map +0 -1
  60. package/dist/core/config.js +0 -222
  61. package/dist/core/config.js.map +0 -1
  62. package/dist/core/contractIndex.d.ts +0 -13
  63. package/dist/core/contractIndex.d.ts.map +0 -1
  64. package/dist/core/contractIndex.js +0 -66
  65. package/dist/core/contractIndex.js.map +0 -1
  66. package/dist/core/contracts.d.ts +0 -5
  67. package/dist/core/contracts.d.ts.map +0 -1
  68. package/dist/core/contracts.js +0 -42
  69. package/dist/core/contracts.js.map +0 -1
  70. package/dist/core/discovery.d.ts +0 -14
  71. package/dist/core/discovery.d.ts.map +0 -1
  72. package/dist/core/discovery.js +0 -55
  73. package/dist/core/discovery.js.map +0 -1
  74. package/dist/core/fs.d.ts +0 -6
  75. package/dist/core/fs.d.ts.map +0 -1
  76. package/dist/core/fs.js +0 -55
  77. package/dist/core/fs.js.map +0 -1
  78. package/dist/core/gherkin/parse.d.ts +0 -7
  79. package/dist/core/gherkin/parse.d.ts.map +0 -1
  80. package/dist/core/gherkin/parse.js +0 -25
  81. package/dist/core/gherkin/parse.js.map +0 -1
  82. package/dist/core/ids.d.ts +0 -6
  83. package/dist/core/ids.d.ts.map +0 -1
  84. package/dist/core/ids.js +0 -52
  85. package/dist/core/ids.js.map +0 -1
  86. package/dist/core/index.d.ts +0 -13
  87. package/dist/core/index.d.ts.map +0 -1
  88. package/dist/core/index.js +0 -13
  89. package/dist/core/index.js.map +0 -1
  90. package/dist/core/parse/adr.d.ts +0 -13
  91. package/dist/core/parse/adr.d.ts.map +0 -1
  92. package/dist/core/parse/adr.js +0 -33
  93. package/dist/core/parse/adr.js.map +0 -1
  94. package/dist/core/parse/gherkin.d.ts +0 -12
  95. package/dist/core/parse/gherkin.d.ts.map +0 -1
  96. package/dist/core/parse/gherkin.js +0 -22
  97. package/dist/core/parse/gherkin.js.map +0 -1
  98. package/dist/core/parse/markdown.d.ts +0 -14
  99. package/dist/core/parse/markdown.d.ts.map +0 -1
  100. package/dist/core/parse/markdown.js +0 -45
  101. package/dist/core/parse/markdown.js.map +0 -1
  102. package/dist/core/parse/spec.d.ts +0 -28
  103. package/dist/core/parse/spec.d.ts.map +0 -1
  104. package/dist/core/parse/spec.js +0 -80
  105. package/dist/core/parse/spec.js.map +0 -1
  106. package/dist/core/report.d.ts +0 -41
  107. package/dist/core/report.d.ts.map +0 -1
  108. package/dist/core/report.js +0 -260
  109. package/dist/core/report.js.map +0 -1
  110. package/dist/core/scenarioModel.d.ts +0 -33
  111. package/dist/core/scenarioModel.d.ts.map +0 -1
  112. package/dist/core/scenarioModel.js +0 -130
  113. package/dist/core/scenarioModel.js.map +0 -1
  114. package/dist/core/specLayout.d.ts +0 -8
  115. package/dist/core/specLayout.d.ts.map +0 -1
  116. package/dist/core/specLayout.js +0 -36
  117. package/dist/core/specLayout.js.map +0 -1
  118. package/dist/core/traceability.d.ts +0 -12
  119. package/dist/core/traceability.d.ts.map +0 -1
  120. package/dist/core/traceability.js +0 -70
  121. package/dist/core/traceability.js.map +0 -1
  122. package/dist/core/types.d.ts +0 -25
  123. package/dist/core/types.d.ts.map +0 -1
  124. package/dist/core/types.js +0 -2
  125. package/dist/core/types.js.map +0 -1
  126. package/dist/core/validate.d.ts +0 -4
  127. package/dist/core/validate.d.ts.map +0 -1
  128. package/dist/core/validate.js +0 -34
  129. package/dist/core/validate.js.map +0 -1
  130. package/dist/core/validators/contracts.d.ts +0 -5
  131. package/dist/core/validators/contracts.d.ts.map +0 -1
  132. package/dist/core/validators/contracts.js +0 -162
  133. package/dist/core/validators/contracts.js.map +0 -1
  134. package/dist/core/validators/delta.d.ts +0 -4
  135. package/dist/core/validators/delta.d.ts.map +0 -1
  136. package/dist/core/validators/delta.js +0 -68
  137. package/dist/core/validators/delta.js.map +0 -1
  138. package/dist/core/validators/ids.d.ts +0 -4
  139. package/dist/core/validators/ids.d.ts.map +0 -1
  140. package/dist/core/validators/ids.js +0 -88
  141. package/dist/core/validators/ids.js.map +0 -1
  142. package/dist/core/validators/scenario.d.ts +0 -5
  143. package/dist/core/validators/scenario.d.ts.map +0 -1
  144. package/dist/core/validators/scenario.js +0 -140
  145. package/dist/core/validators/scenario.js.map +0 -1
  146. package/dist/core/validators/spec.d.ts +0 -5
  147. package/dist/core/validators/spec.d.ts.map +0 -1
  148. package/dist/core/validators/spec.js +0 -94
  149. package/dist/core/validators/spec.js.map +0 -1
  150. package/dist/core/validators/traceability.d.ts +0 -4
  151. package/dist/core/validators/traceability.d.ts.map +0 -1
  152. package/dist/core/validators/traceability.js +0 -190
  153. package/dist/core/validators/traceability.js.map +0 -1
  154. package/dist/core/version.d.ts +0 -2
  155. package/dist/core/version.d.ts.map +0 -1
  156. package/dist/core/version.js +0 -25
  157. package/dist/core/version.js.map +0 -1
  158. package/dist/index.d.ts.map +0 -1
  159. package/dist/index.js +0 -2
  160. package/dist/index.js.map +0 -1
  161. package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/index.d.cts CHANGED
@@ -1,3 +1,16 @@
1
+ type ScCoverage = {
2
+ total: number;
3
+ covered: number;
4
+ missing: number;
5
+ missingIds: string[];
6
+ refs: Record<string, string[]>;
7
+ };
8
+ type TestFileScan = {
9
+ globs: string[];
10
+ excludeGlobs: string[];
11
+ matchedFileCount: number;
12
+ };
13
+
1
14
  type IssueSeverity = "info" | "warning" | "error";
2
15
  type IssueLocation = {
3
16
  line: number;
@@ -17,10 +30,15 @@ type ValidationCounts = {
17
30
  warning: number;
18
31
  error: number;
19
32
  };
33
+ type ValidationTraceability = {
34
+ sc: ScCoverage;
35
+ testFiles: TestFileScan;
36
+ };
20
37
  type ValidationResult = {
21
38
  toolVersion: string;
22
39
  issues: Issue[];
23
40
  counts: ValidationCounts;
41
+ traceability?: ValidationTraceability;
24
42
  };
25
43
 
26
44
  type FailOn = "never" | "warning" | "error";
@@ -44,6 +62,8 @@ type QfaiValidationConfig = {
44
62
  brMustHaveSc: boolean;
45
63
  scMustTouchContracts: boolean;
46
64
  scMustHaveTest: boolean;
65
+ testFileGlobs: string[];
66
+ testFileExcludeGlobs: string[];
47
67
  scNoTestSeverity: TraceabilitySeverity;
48
68
  allowOrphanContracts: boolean;
49
69
  unknownContractIdSeverity: TraceabilitySeverity;
@@ -74,14 +94,6 @@ declare function extractIds(text: string, prefix: IdPrefix): string[];
74
94
  declare function extractAllIds(text: string): string[];
75
95
  declare function extractInvalidIds(text: string, prefixes: IdFormatPrefix[]): string[];
76
96
 
77
- type ScCoverage = {
78
- total: number;
79
- covered: number;
80
- missing: number;
81
- missingIds: string[];
82
- refs: Record<string, string[]>;
83
- };
84
-
85
97
  type ReportSummary = {
86
98
  specs: number;
87
99
  scenarios: number;
@@ -104,6 +116,8 @@ type ReportTraceability = {
104
116
  upstreamIdsFound: number;
105
117
  referencedInCodeOrTests: boolean;
106
118
  sc: ScCoverage;
119
+ scSources: Record<string, string[]>;
120
+ testFiles: TestFileScan;
107
121
  };
108
122
  type ReportData = {
109
123
  tool: "qfai";
@@ -139,4 +153,4 @@ declare function validateSpecContent(text: string, file: string, requiredSection
139
153
 
140
154
  declare function validateTraceability(root: string, config: QfaiConfig): Promise<Issue[]>;
141
155
 
142
- export { type ConfigLoadResult, type ConfigPathKey, type FailOn, type IdFormatPrefix, type IdPrefix, type Issue, type IssueLocation, type IssueSeverity, type OutputFormat, type QfaiConfig, type QfaiOutputConfig, type QfaiPaths, type QfaiValidationConfig, type ReportData, type ReportIds, type ReportSummary, type ReportTraceability, type TraceabilitySeverity, type ValidationCounts, type ValidationResult, createReportData, defaultConfig, extractAllIds, extractIds, extractInvalidIds, formatReportJson, formatReportMarkdown, getConfigPath, lintSql, loadConfig, resolvePath, resolveToolVersion, validateContracts, validateDefinedIds, validateDeltas, validateProject, validateScenarioContent, validateScenarios, validateSpecContent, validateSpecs, validateTraceability };
156
+ export { type ConfigLoadResult, type ConfigPathKey, type FailOn, type IdFormatPrefix, type IdPrefix, type Issue, type IssueLocation, type IssueSeverity, type OutputFormat, type QfaiConfig, type QfaiOutputConfig, type QfaiPaths, type QfaiValidationConfig, type ReportData, type ReportIds, type ReportSummary, type ReportTraceability, type TraceabilitySeverity, type ValidationCounts, type ValidationResult, type ValidationTraceability, createReportData, defaultConfig, extractAllIds, extractIds, extractInvalidIds, formatReportJson, formatReportMarkdown, getConfigPath, lintSql, loadConfig, resolvePath, resolveToolVersion, validateContracts, validateDefinedIds, validateDeltas, validateProject, validateScenarioContent, validateScenarios, validateSpecContent, validateSpecs, validateTraceability };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,156 @@
1
- export * from "./core/index.js";
2
- //# sourceMappingURL=index.d.ts.map
1
+ type ScCoverage = {
2
+ total: number;
3
+ covered: number;
4
+ missing: number;
5
+ missingIds: string[];
6
+ refs: Record<string, string[]>;
7
+ };
8
+ type TestFileScan = {
9
+ globs: string[];
10
+ excludeGlobs: string[];
11
+ matchedFileCount: number;
12
+ };
13
+
14
+ type IssueSeverity = "info" | "warning" | "error";
15
+ type IssueLocation = {
16
+ line: number;
17
+ column?: number;
18
+ };
19
+ type Issue = {
20
+ code: string;
21
+ severity: IssueSeverity;
22
+ message: string;
23
+ file?: string;
24
+ refs?: string[];
25
+ rule?: string;
26
+ loc?: IssueLocation;
27
+ };
28
+ type ValidationCounts = {
29
+ info: number;
30
+ warning: number;
31
+ error: number;
32
+ };
33
+ type ValidationTraceability = {
34
+ sc: ScCoverage;
35
+ testFiles: TestFileScan;
36
+ };
37
+ type ValidationResult = {
38
+ toolVersion: string;
39
+ issues: Issue[];
40
+ counts: ValidationCounts;
41
+ traceability?: ValidationTraceability;
42
+ };
43
+
44
+ type FailOn = "never" | "warning" | "error";
45
+ type OutputFormat = "text" | "github";
46
+ type TraceabilitySeverity = "warning" | "error";
47
+ type QfaiPaths = {
48
+ contractsDir: string;
49
+ specsDir: string;
50
+ rulesDir: string;
51
+ outDir: string;
52
+ promptsDir: string;
53
+ srcDir: string;
54
+ testsDir: string;
55
+ };
56
+ type QfaiValidationConfig = {
57
+ failOn: FailOn;
58
+ require: {
59
+ specSections: string[];
60
+ };
61
+ traceability: {
62
+ brMustHaveSc: boolean;
63
+ scMustTouchContracts: boolean;
64
+ scMustHaveTest: boolean;
65
+ testFileGlobs: string[];
66
+ testFileExcludeGlobs: string[];
67
+ scNoTestSeverity: TraceabilitySeverity;
68
+ allowOrphanContracts: boolean;
69
+ unknownContractIdSeverity: TraceabilitySeverity;
70
+ };
71
+ };
72
+ type QfaiOutputConfig = {
73
+ validateJsonPath: string;
74
+ };
75
+ type QfaiConfig = {
76
+ paths: QfaiPaths;
77
+ validation: QfaiValidationConfig;
78
+ output: QfaiOutputConfig;
79
+ };
80
+ type ConfigPathKey = keyof QfaiPaths;
81
+ type ConfigLoadResult = {
82
+ config: QfaiConfig;
83
+ issues: Issue[];
84
+ configPath: string;
85
+ };
86
+ declare const defaultConfig: QfaiConfig;
87
+ declare function getConfigPath(root: string): string;
88
+ declare function loadConfig(root: string): Promise<ConfigLoadResult>;
89
+ declare function resolvePath(root: string, config: QfaiConfig, key: ConfigPathKey): string;
90
+
91
+ type IdPrefix = "SPEC" | "BR" | "SC" | "UI" | "API" | "DATA";
92
+ type IdFormatPrefix = IdPrefix | "ADR";
93
+ declare function extractIds(text: string, prefix: IdPrefix): string[];
94
+ declare function extractAllIds(text: string): string[];
95
+ declare function extractInvalidIds(text: string, prefixes: IdFormatPrefix[]): string[];
96
+
97
+ type ReportSummary = {
98
+ specs: number;
99
+ scenarios: number;
100
+ contracts: {
101
+ api: number;
102
+ ui: number;
103
+ db: number;
104
+ };
105
+ counts: ValidationCounts;
106
+ };
107
+ type ReportIds = {
108
+ spec: string[];
109
+ br: string[];
110
+ sc: string[];
111
+ ui: string[];
112
+ api: string[];
113
+ data: string[];
114
+ };
115
+ type ReportTraceability = {
116
+ upstreamIdsFound: number;
117
+ referencedInCodeOrTests: boolean;
118
+ sc: ScCoverage;
119
+ scSources: Record<string, string[]>;
120
+ testFiles: TestFileScan;
121
+ };
122
+ type ReportData = {
123
+ tool: "qfai";
124
+ version: string;
125
+ generatedAt: string;
126
+ root: string;
127
+ configPath: string;
128
+ summary: ReportSummary;
129
+ ids: ReportIds;
130
+ traceability: ReportTraceability;
131
+ issues: Issue[];
132
+ };
133
+ declare function createReportData(root: string, validation?: ValidationResult, configResult?: ConfigLoadResult): Promise<ReportData>;
134
+ declare function formatReportMarkdown(data: ReportData): string;
135
+ declare function formatReportJson(data: ReportData): string;
136
+
137
+ declare function validateProject(root: string, configResult?: ConfigLoadResult): Promise<ValidationResult>;
138
+
139
+ declare function resolveToolVersion(): Promise<string>;
140
+
141
+ declare function validateContracts(root: string, config: QfaiConfig): Promise<Issue[]>;
142
+ declare function lintSql(text: string, file: string): Issue[];
143
+
144
+ declare function validateDeltas(root: string, config: QfaiConfig): Promise<Issue[]>;
145
+
146
+ declare function validateDefinedIds(root: string, config: QfaiConfig): Promise<Issue[]>;
147
+
148
+ declare function validateScenarios(root: string, config: QfaiConfig): Promise<Issue[]>;
149
+ declare function validateScenarioContent(text: string, file: string): Issue[];
150
+
151
+ declare function validateSpecs(root: string, config: QfaiConfig): Promise<Issue[]>;
152
+ declare function validateSpecContent(text: string, file: string, requiredSections: string[]): Issue[];
153
+
154
+ declare function validateTraceability(root: string, config: QfaiConfig): Promise<Issue[]>;
155
+
156
+ export { type ConfigLoadResult, type ConfigPathKey, type FailOn, type IdFormatPrefix, type IdPrefix, type Issue, type IssueLocation, type IssueSeverity, type OutputFormat, type QfaiConfig, type QfaiOutputConfig, type QfaiPaths, type QfaiValidationConfig, type ReportData, type ReportIds, type ReportSummary, type ReportTraceability, type TraceabilitySeverity, type ValidationCounts, type ValidationResult, type ValidationTraceability, createReportData, defaultConfig, extractAllIds, extractIds, extractInvalidIds, formatReportJson, formatReportMarkdown, getConfigPath, lintSql, loadConfig, resolvePath, resolveToolVersion, validateContracts, validateDefinedIds, validateDeltas, validateProject, validateScenarioContent, validateScenarios, validateSpecContent, validateSpecs, validateTraceability };