qfai 0.4.0 → 0.4.4

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 (77) hide show
  1. package/README.md +20 -1
  2. package/assets/init/.qfai/README.md +3 -1
  3. package/assets/init/.qfai/contracts/README.md +17 -8
  4. package/assets/init/.qfai/contracts/api/api-0001-sample.yaml +3 -2
  5. package/assets/init/.qfai/contracts/db/db-0001-sample.sql +2 -1
  6. package/assets/init/.qfai/contracts/ui/ui-0001-sample.yaml +3 -1
  7. package/assets/init/.qfai/promptpack/modes/change.md +3 -2
  8. package/assets/init/.qfai/promptpack/modes/compatibility.md +2 -0
  9. package/assets/init/.qfai/prompts/README.md +1 -0
  10. package/assets/init/.qfai/prompts/qfai-generate-test-globs.md +29 -0
  11. package/assets/init/.qfai/prompts/require-to-spec.md +4 -2
  12. package/assets/init/.qfai/specs/README.md +9 -2
  13. package/assets/init/.qfai/specs/spec-0001/spec.md +2 -0
  14. package/assets/init/root/qfai.config.yaml +6 -1
  15. package/assets/init/root/tests/qfai-traceability.sample.test.ts +2 -2
  16. package/dist/cli/index.cjs +885 -489
  17. package/dist/cli/index.cjs.map +1 -1
  18. package/dist/cli/index.mjs +885 -489
  19. package/dist/cli/index.mjs.map +1 -1
  20. package/dist/core/config.d.ts +2 -1
  21. package/dist/core/config.d.ts.map +1 -1
  22. package/dist/core/config.js +4 -2
  23. package/dist/core/config.js.map +1 -1
  24. package/dist/core/contractIndex.d.ts +1 -2
  25. package/dist/core/contractIndex.d.ts.map +1 -1
  26. package/dist/core/contractIndex.js +10 -38
  27. package/dist/core/contractIndex.js.map +1 -1
  28. package/dist/core/contractsDecl.d.ts +3 -0
  29. package/dist/core/contractsDecl.d.ts.map +1 -0
  30. package/dist/core/contractsDecl.js +19 -0
  31. package/dist/core/contractsDecl.js.map +1 -0
  32. package/dist/core/fs.d.ts +5 -0
  33. package/dist/core/fs.d.ts.map +1 -1
  34. package/dist/core/fs.js +13 -0
  35. package/dist/core/fs.js.map +1 -1
  36. package/dist/core/ids.d.ts +1 -1
  37. package/dist/core/ids.d.ts.map +1 -1
  38. package/dist/core/ids.js +3 -3
  39. package/dist/core/ids.js.map +1 -1
  40. package/dist/core/parse/spec.d.ts +8 -0
  41. package/dist/core/parse/spec.d.ts.map +1 -1
  42. package/dist/core/parse/spec.js +43 -0
  43. package/dist/core/parse/spec.js.map +1 -1
  44. package/dist/core/report.d.ts +16 -2
  45. package/dist/core/report.d.ts.map +1 -1
  46. package/dist/core/report.js +144 -11
  47. package/dist/core/report.js.map +1 -1
  48. package/dist/core/scenarioModel.d.ts.map +1 -1
  49. package/dist/core/scenarioModel.js +3 -5
  50. package/dist/core/scenarioModel.js.map +1 -1
  51. package/dist/core/traceability.d.ts +15 -1
  52. package/dist/core/traceability.d.ts.map +1 -1
  53. package/dist/core/traceability.js +96 -9
  54. package/dist/core/traceability.js.map +1 -1
  55. package/dist/core/types.d.ts +6 -0
  56. package/dist/core/types.d.ts.map +1 -1
  57. package/dist/core/validate.d.ts.map +1 -1
  58. package/dist/core/validate.js +12 -1
  59. package/dist/core/validate.js.map +1 -1
  60. package/dist/core/validators/contracts.d.ts.map +1 -1
  61. package/dist/core/validators/contracts.js +45 -18
  62. package/dist/core/validators/contracts.js.map +1 -1
  63. package/dist/core/validators/scenario.d.ts.map +1 -1
  64. package/dist/core/validators/scenario.js +2 -15
  65. package/dist/core/validators/scenario.js.map +1 -1
  66. package/dist/core/validators/spec.js +1 -1
  67. package/dist/core/validators/spec.js.map +1 -1
  68. package/dist/core/validators/traceability.d.ts.map +1 -1
  69. package/dist/core/validators/traceability.js +66 -34
  70. package/dist/core/validators/traceability.js.map +1 -1
  71. package/dist/index.cjs +869 -473
  72. package/dist/index.cjs.map +1 -1
  73. package/dist/index.d.cts +37 -12
  74. package/dist/index.mjs +869 -473
  75. package/dist/index.mjs.map +1 -1
  76. package/dist/tsconfig.tsbuildinfo +1 -1
  77. package/package.json +2 -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";
@@ -42,8 +60,9 @@ type QfaiValidationConfig = {
42
60
  };
43
61
  traceability: {
44
62
  brMustHaveSc: boolean;
45
- scMustTouchContracts: boolean;
46
63
  scMustHaveTest: boolean;
64
+ testFileGlobs: string[];
65
+ testFileExcludeGlobs: string[];
47
66
  scNoTestSeverity: TraceabilitySeverity;
48
67
  allowOrphanContracts: boolean;
49
68
  unknownContractIdSeverity: TraceabilitySeverity;
@@ -68,20 +87,12 @@ declare function getConfigPath(root: string): string;
68
87
  declare function loadConfig(root: string): Promise<ConfigLoadResult>;
69
88
  declare function resolvePath(root: string, config: QfaiConfig, key: ConfigPathKey): string;
70
89
 
71
- type IdPrefix = "SPEC" | "BR" | "SC" | "UI" | "API" | "DATA";
90
+ type IdPrefix = "SPEC" | "BR" | "SC" | "UI" | "API" | "DB";
72
91
  type IdFormatPrefix = IdPrefix | "ADR";
73
92
  declare function extractIds(text: string, prefix: IdPrefix): string[];
74
93
  declare function extractAllIds(text: string): string[];
75
94
  declare function extractInvalidIds(text: string, prefixes: IdFormatPrefix[]): string[];
76
95
 
77
- type ScCoverage = {
78
- total: number;
79
- covered: number;
80
- missing: number;
81
- missingIds: string[];
82
- refs: Record<string, string[]>;
83
- };
84
-
85
96
  type ReportSummary = {
86
97
  specs: number;
87
98
  scenarios: number;
@@ -98,12 +109,26 @@ type ReportIds = {
98
109
  sc: string[];
99
110
  ui: string[];
100
111
  api: string[];
101
- data: string[];
112
+ db: string[];
113
+ };
114
+ type ReportContractCoverage = {
115
+ total: number;
116
+ referenced: number;
117
+ orphan: number;
118
+ idToSpecs: Record<string, string[]>;
119
+ };
120
+ type ReportSpecCoverage = {
121
+ contractRefMissing: number;
122
+ specToContractIds: Record<string, string[]>;
102
123
  };
103
124
  type ReportTraceability = {
104
125
  upstreamIdsFound: number;
105
126
  referencedInCodeOrTests: boolean;
106
127
  sc: ScCoverage;
128
+ scSources: Record<string, string[]>;
129
+ testFiles: TestFileScan;
130
+ contracts: ReportContractCoverage;
131
+ specs: ReportSpecCoverage;
107
132
  };
108
133
  type ReportData = {
109
134
  tool: "qfai";
@@ -139,4 +164,4 @@ declare function validateSpecContent(text: string, file: string, requiredSection
139
164
 
140
165
  declare function validateTraceability(root: string, config: QfaiConfig): Promise<Issue[]>;
141
166
 
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 };
167
+ 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 ReportContractCoverage, type ReportData, type ReportIds, type ReportSpecCoverage, 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 };