@opensip-tools/fitness 1.0.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 (461) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/.turbo/turbo-typecheck.log +4 -0
  3. package/LICENSE +21 -0
  4. package/dist/__tests__/gate.test.d.ts +13 -0
  5. package/dist/__tests__/gate.test.d.ts.map +1 -0
  6. package/dist/__tests__/gate.test.js +422 -0
  7. package/dist/__tests__/gate.test.js.map +1 -0
  8. package/dist/__tests__/sarif.test.d.ts +2 -0
  9. package/dist/__tests__/sarif.test.d.ts.map +1 -0
  10. package/dist/__tests__/sarif.test.js +169 -0
  11. package/dist/__tests__/sarif.test.js.map +1 -0
  12. package/dist/cli/dashboard.d.ts +6 -0
  13. package/dist/cli/dashboard.d.ts.map +1 -0
  14. package/dist/cli/dashboard.js +77 -0
  15. package/dist/cli/dashboard.js.map +1 -0
  16. package/dist/cli/fit.d.ts +37 -0
  17. package/dist/cli/fit.d.ts.map +1 -0
  18. package/dist/cli/fit.js +539 -0
  19. package/dist/cli/fit.js.map +1 -0
  20. package/dist/cli/list-checks.d.ts +6 -0
  21. package/dist/cli/list-checks.d.ts.map +1 -0
  22. package/dist/cli/list-checks.js +23 -0
  23. package/dist/cli/list-checks.js.map +1 -0
  24. package/dist/cli/list-recipes.d.ts +6 -0
  25. package/dist/cli/list-recipes.d.ts.map +1 -0
  26. package/dist/cli/list-recipes.js +31 -0
  27. package/dist/cli/list-recipes.js.map +1 -0
  28. package/dist/framework/__tests__/ast-utilities.test.d.ts +2 -0
  29. package/dist/framework/__tests__/ast-utilities.test.d.ts.map +1 -0
  30. package/dist/framework/__tests__/ast-utilities.test.js +153 -0
  31. package/dist/framework/__tests__/ast-utilities.test.js.map +1 -0
  32. package/dist/framework/__tests__/check-config.test.d.ts +2 -0
  33. package/dist/framework/__tests__/check-config.test.d.ts.map +1 -0
  34. package/dist/framework/__tests__/check-config.test.js +56 -0
  35. package/dist/framework/__tests__/check-config.test.js.map +1 -0
  36. package/dist/framework/__tests__/command-executor.test.d.ts +2 -0
  37. package/dist/framework/__tests__/command-executor.test.d.ts.map +1 -0
  38. package/dist/framework/__tests__/command-executor.test.js +71 -0
  39. package/dist/framework/__tests__/command-executor.test.js.map +1 -0
  40. package/dist/framework/__tests__/content-filter-dispatch.test.d.ts +2 -0
  41. package/dist/framework/__tests__/content-filter-dispatch.test.d.ts.map +1 -0
  42. package/dist/framework/__tests__/content-filter-dispatch.test.js +104 -0
  43. package/dist/framework/__tests__/content-filter-dispatch.test.js.map +1 -0
  44. package/dist/framework/__tests__/content-filter.test.d.ts +2 -0
  45. package/dist/framework/__tests__/content-filter.test.d.ts.map +1 -0
  46. package/dist/framework/__tests__/content-filter.test.js +126 -0
  47. package/dist/framework/__tests__/content-filter.test.js.map +1 -0
  48. package/dist/framework/__tests__/define-check.test.d.ts +2 -0
  49. package/dist/framework/__tests__/define-check.test.d.ts.map +1 -0
  50. package/dist/framework/__tests__/define-check.test.js +155 -0
  51. package/dist/framework/__tests__/define-check.test.js.map +1 -0
  52. package/dist/framework/__tests__/directive-inventory.test.d.ts +2 -0
  53. package/dist/framework/__tests__/directive-inventory.test.d.ts.map +1 -0
  54. package/dist/framework/__tests__/directive-inventory.test.js +44 -0
  55. package/dist/framework/__tests__/directive-inventory.test.js.map +1 -0
  56. package/dist/framework/__tests__/execution-context.test.d.ts +2 -0
  57. package/dist/framework/__tests__/execution-context.test.d.ts.map +1 -0
  58. package/dist/framework/__tests__/execution-context.test.js +62 -0
  59. package/dist/framework/__tests__/execution-context.test.js.map +1 -0
  60. package/dist/framework/__tests__/file-accessor.test.d.ts +2 -0
  61. package/dist/framework/__tests__/file-accessor.test.d.ts.map +1 -0
  62. package/dist/framework/__tests__/file-accessor.test.js +106 -0
  63. package/dist/framework/__tests__/file-accessor.test.js.map +1 -0
  64. package/dist/framework/__tests__/file-cache.test.d.ts +2 -0
  65. package/dist/framework/__tests__/file-cache.test.d.ts.map +1 -0
  66. package/dist/framework/__tests__/file-cache.test.js +122 -0
  67. package/dist/framework/__tests__/file-cache.test.js.map +1 -0
  68. package/dist/framework/__tests__/import-graph.test.d.ts +15 -0
  69. package/dist/framework/__tests__/import-graph.test.d.ts.map +1 -0
  70. package/dist/framework/__tests__/import-graph.test.js +164 -0
  71. package/dist/framework/__tests__/import-graph.test.js.map +1 -0
  72. package/dist/framework/__tests__/path-matcher.test.d.ts +2 -0
  73. package/dist/framework/__tests__/path-matcher.test.d.ts.map +1 -0
  74. package/dist/framework/__tests__/path-matcher.test.js +113 -0
  75. package/dist/framework/__tests__/path-matcher.test.js.map +1 -0
  76. package/dist/framework/__tests__/register-helpers.test.d.ts +2 -0
  77. package/dist/framework/__tests__/register-helpers.test.d.ts.map +1 -0
  78. package/dist/framework/__tests__/register-helpers.test.js +42 -0
  79. package/dist/framework/__tests__/register-helpers.test.js.map +1 -0
  80. package/dist/framework/__tests__/registry.test.d.ts +2 -0
  81. package/dist/framework/__tests__/registry.test.d.ts.map +1 -0
  82. package/dist/framework/__tests__/registry.test.js +208 -0
  83. package/dist/framework/__tests__/registry.test.js.map +1 -0
  84. package/dist/framework/__tests__/result-builder.test.d.ts +2 -0
  85. package/dist/framework/__tests__/result-builder.test.d.ts.map +1 -0
  86. package/dist/framework/__tests__/result-builder.test.js +153 -0
  87. package/dist/framework/__tests__/result-builder.test.js.map +1 -0
  88. package/dist/framework/__tests__/scope-resolver.test.d.ts +2 -0
  89. package/dist/framework/__tests__/scope-resolver.test.d.ts.map +1 -0
  90. package/dist/framework/__tests__/scope-resolver.test.js +140 -0
  91. package/dist/framework/__tests__/scope-resolver.test.js.map +1 -0
  92. package/dist/framework/__tests__/severity-mapping.test.d.ts +2 -0
  93. package/dist/framework/__tests__/severity-mapping.test.d.ts.map +1 -0
  94. package/dist/framework/__tests__/severity-mapping.test.js +42 -0
  95. package/dist/framework/__tests__/severity-mapping.test.js.map +1 -0
  96. package/dist/framework/__tests__/strip-literals.test.d.ts +2 -0
  97. package/dist/framework/__tests__/strip-literals.test.d.ts.map +1 -0
  98. package/dist/framework/__tests__/strip-literals.test.js +87 -0
  99. package/dist/framework/__tests__/strip-literals.test.js.map +1 -0
  100. package/dist/framework/abortable-exec.d.ts +34 -0
  101. package/dist/framework/abortable-exec.d.ts.map +1 -0
  102. package/dist/framework/abortable-exec.js +136 -0
  103. package/dist/framework/abortable-exec.js.map +1 -0
  104. package/dist/framework/ast-utilities.d.ts +41 -0
  105. package/dist/framework/ast-utilities.d.ts.map +1 -0
  106. package/dist/framework/ast-utilities.js +106 -0
  107. package/dist/framework/ast-utilities.js.map +1 -0
  108. package/dist/framework/check-config.d.ts +171 -0
  109. package/dist/framework/check-config.d.ts.map +1 -0
  110. package/dist/framework/check-config.js +114 -0
  111. package/dist/framework/check-config.js.map +1 -0
  112. package/dist/framework/check-types.d.ts +57 -0
  113. package/dist/framework/check-types.d.ts.map +1 -0
  114. package/dist/framework/check-types.js +35 -0
  115. package/dist/framework/check-types.js.map +1 -0
  116. package/dist/framework/command-executor.d.ts +25 -0
  117. package/dist/framework/command-executor.d.ts.map +1 -0
  118. package/dist/framework/command-executor.js +63 -0
  119. package/dist/framework/command-executor.js.map +1 -0
  120. package/dist/framework/constants.d.ts +9 -0
  121. package/dist/framework/constants.d.ts.map +1 -0
  122. package/dist/framework/constants.js +16 -0
  123. package/dist/framework/constants.js.map +1 -0
  124. package/dist/framework/content-filter.d.ts +33 -0
  125. package/dist/framework/content-filter.d.ts.map +1 -0
  126. package/dist/framework/content-filter.js +236 -0
  127. package/dist/framework/content-filter.js.map +1 -0
  128. package/dist/framework/define-check.d.ts +38 -0
  129. package/dist/framework/define-check.d.ts.map +1 -0
  130. package/dist/framework/define-check.js +252 -0
  131. package/dist/framework/define-check.js.map +1 -0
  132. package/dist/framework/directive-inventory.d.ts +34 -0
  133. package/dist/framework/directive-inventory.d.ts.map +1 -0
  134. package/dist/framework/directive-inventory.js +77 -0
  135. package/dist/framework/directive-inventory.js.map +1 -0
  136. package/dist/framework/directive-parsing.d.ts +20 -0
  137. package/dist/framework/directive-parsing.d.ts.map +1 -0
  138. package/dist/framework/directive-parsing.js +121 -0
  139. package/dist/framework/directive-parsing.js.map +1 -0
  140. package/dist/framework/execution-context.d.ts +95 -0
  141. package/dist/framework/execution-context.d.ts.map +1 -0
  142. package/dist/framework/execution-context.js +122 -0
  143. package/dist/framework/execution-context.js.map +1 -0
  144. package/dist/framework/file-accessor.d.ts +20 -0
  145. package/dist/framework/file-accessor.d.ts.map +1 -0
  146. package/dist/framework/file-accessor.js +122 -0
  147. package/dist/framework/file-accessor.js.map +1 -0
  148. package/dist/framework/file-cache.d.ts +70 -0
  149. package/dist/framework/file-cache.d.ts.map +1 -0
  150. package/dist/framework/file-cache.js +178 -0
  151. package/dist/framework/file-cache.js.map +1 -0
  152. package/dist/framework/file-type-filter.d.ts +11 -0
  153. package/dist/framework/file-type-filter.d.ts.map +1 -0
  154. package/dist/framework/file-type-filter.js +21 -0
  155. package/dist/framework/file-type-filter.js.map +1 -0
  156. package/dist/framework/ignore-processing.d.ts +22 -0
  157. package/dist/framework/ignore-processing.d.ts.map +1 -0
  158. package/dist/framework/ignore-processing.js +241 -0
  159. package/dist/framework/ignore-processing.js.map +1 -0
  160. package/dist/framework/import-graph.d.ts +51 -0
  161. package/dist/framework/import-graph.d.ts.map +1 -0
  162. package/dist/framework/import-graph.js +216 -0
  163. package/dist/framework/import-graph.js.map +1 -0
  164. package/dist/framework/memory-profiler.d.ts +53 -0
  165. package/dist/framework/memory-profiler.d.ts.map +1 -0
  166. package/dist/framework/memory-profiler.js +92 -0
  167. package/dist/framework/memory-profiler.js.map +1 -0
  168. package/dist/framework/parse-cache.d.ts +23 -0
  169. package/dist/framework/parse-cache.d.ts.map +1 -0
  170. package/dist/framework/parse-cache.js +37 -0
  171. package/dist/framework/parse-cache.js.map +1 -0
  172. package/dist/framework/path-matcher.d.ts +86 -0
  173. package/dist/framework/path-matcher.d.ts.map +1 -0
  174. package/dist/framework/path-matcher.js +138 -0
  175. package/dist/framework/path-matcher.js.map +1 -0
  176. package/dist/framework/register-helpers.d.ts +10 -0
  177. package/dist/framework/register-helpers.d.ts.map +1 -0
  178. package/dist/framework/register-helpers.js +17 -0
  179. package/dist/framework/register-helpers.js.map +1 -0
  180. package/dist/framework/registry.d.ts +41 -0
  181. package/dist/framework/registry.d.ts.map +1 -0
  182. package/dist/framework/registry.js +103 -0
  183. package/dist/framework/registry.js.map +1 -0
  184. package/dist/framework/result-builder.d.ts +74 -0
  185. package/dist/framework/result-builder.d.ts.map +1 -0
  186. package/dist/framework/result-builder.js +154 -0
  187. package/dist/framework/result-builder.js.map +1 -0
  188. package/dist/framework/scope-resolver.d.ts +23 -0
  189. package/dist/framework/scope-resolver.d.ts.map +1 -0
  190. package/dist/framework/scope-resolver.js +201 -0
  191. package/dist/framework/scope-resolver.js.map +1 -0
  192. package/dist/framework/severity-mapping.d.ts +13 -0
  193. package/dist/framework/severity-mapping.d.ts.map +1 -0
  194. package/dist/framework/severity-mapping.js +51 -0
  195. package/dist/framework/severity-mapping.js.map +1 -0
  196. package/dist/framework/strip-literals.d.ts +48 -0
  197. package/dist/framework/strip-literals.d.ts.map +1 -0
  198. package/dist/framework/strip-literals.js +188 -0
  199. package/dist/framework/strip-literals.js.map +1 -0
  200. package/dist/gate.d.ts +74 -0
  201. package/dist/gate.d.ts.map +1 -0
  202. package/dist/gate.js +257 -0
  203. package/dist/gate.js.map +1 -0
  204. package/dist/index.d.ts +47 -0
  205. package/dist/index.d.ts.map +1 -0
  206. package/dist/index.js +51 -0
  207. package/dist/index.js.map +1 -0
  208. package/dist/plugins/__tests__/check-package-discovery.test.d.ts +2 -0
  209. package/dist/plugins/__tests__/check-package-discovery.test.d.ts.map +1 -0
  210. package/dist/plugins/__tests__/check-package-discovery.test.js +170 -0
  211. package/dist/plugins/__tests__/check-package-discovery.test.js.map +1 -0
  212. package/dist/plugins/__tests__/lang-domain.test.d.ts +2 -0
  213. package/dist/plugins/__tests__/lang-domain.test.d.ts.map +1 -0
  214. package/dist/plugins/__tests__/lang-domain.test.js +171 -0
  215. package/dist/plugins/__tests__/lang-domain.test.js.map +1 -0
  216. package/dist/plugins/__tests__/loader.test.d.ts +2 -0
  217. package/dist/plugins/__tests__/loader.test.d.ts.map +1 -0
  218. package/dist/plugins/__tests__/loader.test.js +194 -0
  219. package/dist/plugins/__tests__/loader.test.js.map +1 -0
  220. package/dist/plugins/check-package-discovery.d.ts +73 -0
  221. package/dist/plugins/check-package-discovery.d.ts.map +1 -0
  222. package/dist/plugins/check-package-discovery.js +212 -0
  223. package/dist/plugins/check-package-discovery.js.map +1 -0
  224. package/dist/plugins/loader.d.ts +31 -0
  225. package/dist/plugins/loader.d.ts.map +1 -0
  226. package/dist/plugins/loader.js +290 -0
  227. package/dist/plugins/loader.js.map +1 -0
  228. package/dist/plugins/types.d.ts +23 -0
  229. package/dist/plugins/types.d.ts.map +1 -0
  230. package/dist/plugins/types.js +9 -0
  231. package/dist/plugins/types.js.map +1 -0
  232. package/dist/recipes/__tests__/built-in-recipes.test.d.ts +2 -0
  233. package/dist/recipes/__tests__/built-in-recipes.test.d.ts.map +1 -0
  234. package/dist/recipes/__tests__/built-in-recipes.test.js +93 -0
  235. package/dist/recipes/__tests__/built-in-recipes.test.js.map +1 -0
  236. package/dist/recipes/__tests__/check-config.test.d.ts +5 -0
  237. package/dist/recipes/__tests__/check-config.test.d.ts.map +1 -0
  238. package/dist/recipes/__tests__/check-config.test.js +37 -0
  239. package/dist/recipes/__tests__/check-config.test.js.map +1 -0
  240. package/dist/recipes/__tests__/check-resolution.test.d.ts +2 -0
  241. package/dist/recipes/__tests__/check-resolution.test.d.ts.map +1 -0
  242. package/dist/recipes/__tests__/check-resolution.test.js +135 -0
  243. package/dist/recipes/__tests__/check-resolution.test.js.map +1 -0
  244. package/dist/recipes/__tests__/registry.test.d.ts +2 -0
  245. package/dist/recipes/__tests__/registry.test.d.ts.map +1 -0
  246. package/dist/recipes/__tests__/registry.test.js +97 -0
  247. package/dist/recipes/__tests__/registry.test.js.map +1 -0
  248. package/dist/recipes/__tests__/retry.test.d.ts +2 -0
  249. package/dist/recipes/__tests__/retry.test.d.ts.map +1 -0
  250. package/dist/recipes/__tests__/retry.test.js +75 -0
  251. package/dist/recipes/__tests__/retry.test.js.map +1 -0
  252. package/dist/recipes/__tests__/service.test.d.ts +11 -0
  253. package/dist/recipes/__tests__/service.test.d.ts.map +1 -0
  254. package/dist/recipes/__tests__/service.test.js +482 -0
  255. package/dist/recipes/__tests__/service.test.js.map +1 -0
  256. package/dist/recipes/built-in-recipes.d.ts +14 -0
  257. package/dist/recipes/built-in-recipes.d.ts.map +1 -0
  258. package/dist/recipes/built-in-recipes.js +247 -0
  259. package/dist/recipes/built-in-recipes.js.map +1 -0
  260. package/dist/recipes/check-config.d.ts +40 -0
  261. package/dist/recipes/check-config.d.ts.map +1 -0
  262. package/dist/recipes/check-config.js +61 -0
  263. package/dist/recipes/check-config.js.map +1 -0
  264. package/dist/recipes/check-resolution.d.ts +21 -0
  265. package/dist/recipes/check-resolution.d.ts.map +1 -0
  266. package/dist/recipes/check-resolution.js +121 -0
  267. package/dist/recipes/check-resolution.js.map +1 -0
  268. package/dist/recipes/check-result-processor.d.ts +51 -0
  269. package/dist/recipes/check-result-processor.d.ts.map +1 -0
  270. package/dist/recipes/check-result-processor.js +158 -0
  271. package/dist/recipes/check-result-processor.js.map +1 -0
  272. package/dist/recipes/parallel-execution.d.ts +33 -0
  273. package/dist/recipes/parallel-execution.d.ts.map +1 -0
  274. package/dist/recipes/parallel-execution.js +142 -0
  275. package/dist/recipes/parallel-execution.js.map +1 -0
  276. package/dist/recipes/registry.d.ts +81 -0
  277. package/dist/recipes/registry.d.ts.map +1 -0
  278. package/dist/recipes/registry.js +131 -0
  279. package/dist/recipes/registry.js.map +1 -0
  280. package/dist/recipes/retry.d.ts +25 -0
  281. package/dist/recipes/retry.d.ts.map +1 -0
  282. package/dist/recipes/retry.js +44 -0
  283. package/dist/recipes/retry.js.map +1 -0
  284. package/dist/recipes/sequential-execution.d.ts +10 -0
  285. package/dist/recipes/sequential-execution.d.ts.map +1 -0
  286. package/dist/recipes/sequential-execution.js +122 -0
  287. package/dist/recipes/sequential-execution.js.map +1 -0
  288. package/dist/recipes/service-types.d.ts +84 -0
  289. package/dist/recipes/service-types.d.ts.map +1 -0
  290. package/dist/recipes/service-types.js +8 -0
  291. package/dist/recipes/service-types.js.map +1 -0
  292. package/dist/recipes/service.d.ts +71 -0
  293. package/dist/recipes/service.d.ts.map +1 -0
  294. package/dist/recipes/service.js +331 -0
  295. package/dist/recipes/service.js.map +1 -0
  296. package/dist/recipes/types.d.ts +154 -0
  297. package/dist/recipes/types.d.ts.map +1 -0
  298. package/dist/recipes/types.js +54 -0
  299. package/dist/recipes/types.js.map +1 -0
  300. package/dist/sarif.d.ts +34 -0
  301. package/dist/sarif.d.ts.map +1 -0
  302. package/dist/sarif.js +192 -0
  303. package/dist/sarif.js.map +1 -0
  304. package/dist/signalers/__tests__/loader.test.d.ts +2 -0
  305. package/dist/signalers/__tests__/loader.test.d.ts.map +1 -0
  306. package/dist/signalers/__tests__/loader.test.js +74 -0
  307. package/dist/signalers/__tests__/loader.test.js.map +1 -0
  308. package/dist/signalers/index.d.ts +8 -0
  309. package/dist/signalers/index.d.ts.map +1 -0
  310. package/dist/signalers/index.js +9 -0
  311. package/dist/signalers/index.js.map +1 -0
  312. package/dist/signalers/loader.d.ts +24 -0
  313. package/dist/signalers/loader.d.ts.map +1 -0
  314. package/dist/signalers/loader.js +108 -0
  315. package/dist/signalers/loader.js.map +1 -0
  316. package/dist/signalers/schema.d.ts +288 -0
  317. package/dist/signalers/schema.d.ts.map +1 -0
  318. package/dist/signalers/schema.js +99 -0
  319. package/dist/signalers/schema.js.map +1 -0
  320. package/dist/signalers/types.d.ts +13 -0
  321. package/dist/signalers/types.d.ts.map +1 -0
  322. package/dist/signalers/types.js +5 -0
  323. package/dist/signalers/types.js.map +1 -0
  324. package/dist/targets/__tests__/loader.test.d.ts +2 -0
  325. package/dist/targets/__tests__/loader.test.d.ts.map +1 -0
  326. package/dist/targets/__tests__/loader.test.js +127 -0
  327. package/dist/targets/__tests__/loader.test.js.map +1 -0
  328. package/dist/targets/__tests__/resolver.test.d.ts +2 -0
  329. package/dist/targets/__tests__/resolver.test.d.ts.map +1 -0
  330. package/dist/targets/__tests__/resolver.test.js +54 -0
  331. package/dist/targets/__tests__/resolver.test.js.map +1 -0
  332. package/dist/targets/__tests__/target-registry.test.d.ts +2 -0
  333. package/dist/targets/__tests__/target-registry.test.d.ts.map +1 -0
  334. package/dist/targets/__tests__/target-registry.test.js +89 -0
  335. package/dist/targets/__tests__/target-registry.test.js.map +1 -0
  336. package/dist/targets/index.d.ts +10 -0
  337. package/dist/targets/index.d.ts.map +1 -0
  338. package/dist/targets/index.js +12 -0
  339. package/dist/targets/index.js.map +1 -0
  340. package/dist/targets/loader.d.ts +19 -0
  341. package/dist/targets/loader.d.ts.map +1 -0
  342. package/dist/targets/loader.js +159 -0
  343. package/dist/targets/loader.js.map +1 -0
  344. package/dist/targets/resolver.d.ts +19 -0
  345. package/dist/targets/resolver.d.ts.map +1 -0
  346. package/dist/targets/resolver.js +37 -0
  347. package/dist/targets/resolver.js.map +1 -0
  348. package/dist/targets/target-registry.d.ts +61 -0
  349. package/dist/targets/target-registry.d.ts.map +1 -0
  350. package/dist/targets/target-registry.js +93 -0
  351. package/dist/targets/target-registry.js.map +1 -0
  352. package/dist/targets/types.d.ts +85 -0
  353. package/dist/targets/types.d.ts.map +1 -0
  354. package/dist/targets/types.js +5 -0
  355. package/dist/targets/types.js.map +1 -0
  356. package/dist/tool.d.ts +17 -0
  357. package/dist/tool.d.ts.map +1 -0
  358. package/dist/tool.js +282 -0
  359. package/dist/tool.js.map +1 -0
  360. package/dist/types/findings.d.ts +117 -0
  361. package/dist/types/findings.d.ts.map +1 -0
  362. package/dist/types/findings.js +93 -0
  363. package/dist/types/findings.js.map +1 -0
  364. package/dist/types/severity.d.ts +15 -0
  365. package/dist/types/severity.d.ts.map +1 -0
  366. package/dist/types/severity.js +36 -0
  367. package/dist/types/severity.js.map +1 -0
  368. package/package.json +45 -0
  369. package/src/__tests__/gate.test.ts +537 -0
  370. package/src/__tests__/sarif.test.ts +201 -0
  371. package/src/cli/dashboard.ts +93 -0
  372. package/src/cli/fit.ts +612 -0
  373. package/src/cli/list-checks.ts +32 -0
  374. package/src/cli/list-recipes.ts +38 -0
  375. package/src/framework/__tests__/ast-utilities.test.ts +157 -0
  376. package/src/framework/__tests__/check-config.test.ts +65 -0
  377. package/src/framework/__tests__/command-executor.test.ts +79 -0
  378. package/src/framework/__tests__/content-filter-dispatch.test.ts +132 -0
  379. package/src/framework/__tests__/content-filter.test.ts +136 -0
  380. package/src/framework/__tests__/define-check.test.ts +180 -0
  381. package/src/framework/__tests__/directive-inventory.test.ts +53 -0
  382. package/src/framework/__tests__/execution-context.test.ts +80 -0
  383. package/src/framework/__tests__/file-accessor.test.ts +121 -0
  384. package/src/framework/__tests__/file-cache.test.ts +142 -0
  385. package/src/framework/__tests__/import-graph.test.ts +282 -0
  386. package/src/framework/__tests__/path-matcher.test.ts +130 -0
  387. package/src/framework/__tests__/register-helpers.test.ts +51 -0
  388. package/src/framework/__tests__/registry.test.ts +243 -0
  389. package/src/framework/__tests__/result-builder.test.ts +178 -0
  390. package/src/framework/__tests__/scope-resolver.test.ts +208 -0
  391. package/src/framework/__tests__/severity-mapping.test.ts +50 -0
  392. package/src/framework/__tests__/strip-literals.test.ts +109 -0
  393. package/src/framework/abortable-exec.ts +177 -0
  394. package/src/framework/ast-utilities.ts +112 -0
  395. package/src/framework/check-config.ts +339 -0
  396. package/src/framework/check-types.ts +77 -0
  397. package/src/framework/command-executor.ts +100 -0
  398. package/src/framework/constants.ts +16 -0
  399. package/src/framework/content-filter.ts +288 -0
  400. package/src/framework/define-check.ts +336 -0
  401. package/src/framework/directive-inventory.ts +110 -0
  402. package/src/framework/directive-parsing.ts +152 -0
  403. package/src/framework/execution-context.ts +247 -0
  404. package/src/framework/file-accessor.ts +171 -0
  405. package/src/framework/file-cache.ts +220 -0
  406. package/src/framework/file-type-filter.ts +25 -0
  407. package/src/framework/ignore-processing.ts +350 -0
  408. package/src/framework/import-graph.ts +280 -0
  409. package/src/framework/memory-profiler.ts +145 -0
  410. package/src/framework/parse-cache.ts +38 -0
  411. package/src/framework/path-matcher.ts +191 -0
  412. package/src/framework/register-helpers.ts +20 -0
  413. package/src/framework/registry.ts +125 -0
  414. package/src/framework/result-builder.ts +225 -0
  415. package/src/framework/scope-resolver.ts +262 -0
  416. package/src/framework/severity-mapping.ts +56 -0
  417. package/src/framework/strip-literals.ts +200 -0
  418. package/src/gate.ts +337 -0
  419. package/src/index.ts +110 -0
  420. package/src/plugins/__tests__/check-package-discovery.test.ts +204 -0
  421. package/src/plugins/__tests__/lang-domain.test.ts +198 -0
  422. package/src/plugins/__tests__/loader.test.ts +226 -0
  423. package/src/plugins/check-package-discovery.ts +242 -0
  424. package/src/plugins/loader.ts +327 -0
  425. package/src/plugins/types.ts +25 -0
  426. package/src/recipes/__tests__/built-in-recipes.test.ts +107 -0
  427. package/src/recipes/__tests__/check-config.test.ts +51 -0
  428. package/src/recipes/__tests__/check-resolution.test.ts +185 -0
  429. package/src/recipes/__tests__/registry.test.ts +115 -0
  430. package/src/recipes/__tests__/retry.test.ts +83 -0
  431. package/src/recipes/__tests__/service.test.ts +572 -0
  432. package/src/recipes/built-in-recipes.ts +273 -0
  433. package/src/recipes/check-config.ts +64 -0
  434. package/src/recipes/check-resolution.ts +169 -0
  435. package/src/recipes/check-result-processor.ts +258 -0
  436. package/src/recipes/parallel-execution.ts +220 -0
  437. package/src/recipes/registry.ts +192 -0
  438. package/src/recipes/retry.ts +69 -0
  439. package/src/recipes/sequential-execution.ts +139 -0
  440. package/src/recipes/service-types.ts +105 -0
  441. package/src/recipes/service.ts +400 -0
  442. package/src/recipes/types.ts +247 -0
  443. package/src/sarif.ts +232 -0
  444. package/src/signalers/__tests__/loader.test.ts +99 -0
  445. package/src/signalers/index.ts +9 -0
  446. package/src/signalers/loader.ts +141 -0
  447. package/src/signalers/schema.ts +117 -0
  448. package/src/signalers/types.ts +15 -0
  449. package/src/targets/__tests__/loader.test.ts +170 -0
  450. package/src/targets/__tests__/resolver.test.ts +74 -0
  451. package/src/targets/__tests__/target-registry.test.ts +103 -0
  452. package/src/targets/index.ts +13 -0
  453. package/src/targets/loader.ts +214 -0
  454. package/src/targets/resolver.ts +44 -0
  455. package/src/targets/target-registry.ts +111 -0
  456. package/src/targets/types.ts +89 -0
  457. package/src/tool.ts +302 -0
  458. package/src/types/findings.ts +239 -0
  459. package/src/types/severity.ts +39 -0
  460. package/tsconfig.json +8 -0
  461. package/vitest.config.ts +33 -0
@@ -0,0 +1,136 @@
1
+ // @fitness-ignore-file semgrep-scan -- reviewed: pattern justified for this module
2
+ // @fitness-ignore-file error-handling-suite -- catch blocks delegate errors through established patterns
3
+ /**
4
+ * @fileoverview Abortable command execution for fitness checks
5
+ *
6
+ * Provides shell command execution with abort signal and timeout support.
7
+ * Child processes are properly cleaned up on abort.
8
+ */
9
+ import { spawn } from 'node:child_process';
10
+ import { SystemError } from '@opensip-tools/core';
11
+ /**
12
+ * Error thrown when command execution fails
13
+ */
14
+ class ExecError extends SystemError {
15
+ stdout;
16
+ stderr;
17
+ exitCode;
18
+ aborted;
19
+ constructor(message, stdout, stderr, exitCode, aborted) {
20
+ super(message, { code: 'SYSTEM.FITNESS.EXEC_FAILED' });
21
+ this.stdout = stdout;
22
+ this.stderr = stderr;
23
+ this.exitCode = exitCode;
24
+ this.aborted = aborted;
25
+ this.name = 'ExecError';
26
+ }
27
+ }
28
+ const DEFAULT_MAX_BUFFER_BYTES = 10 * 1024 * 1024; // 10 MB
29
+ /**
30
+ * Execute a command with abort support.
31
+ *
32
+ * @param command - Either a shell command string or an array of [bin, ...args] (no shell).
33
+ * @throws {SystemError} When the command array is empty
34
+ * @throws {ExecError} When the child process fails to spawn
35
+ */
36
+ export function execAbortable(command, options = {}) {
37
+ const { cwd = process.cwd(), signal, maxBuffer = DEFAULT_MAX_BUFFER_BYTES, env = process.env, timeout, } = options;
38
+ return new Promise((resolve, reject) => {
39
+ if (signal?.aborted) {
40
+ resolve({ stdout: '', stderr: '', exitCode: null, aborted: true });
41
+ return;
42
+ }
43
+ let child;
44
+ if (typeof command === 'string') {
45
+ // Shell mode (string command) — callers pass hardcoded commands (e.g., lint/test runners).
46
+ // Array overload is preferred for untrusted input (no shell, no injection risk).
47
+ // nosemgrep: javascript.lang.security.audit.spawn-shell-true.spawn-shell-true -- shell=true required for string commands; input is developer-defined check commands, not user input
48
+ // eslint-disable-next-line sonarjs/os-command -- developer-supplied check command; not user-controllable
49
+ child = spawn(command, [], {
50
+ cwd,
51
+ env,
52
+ shell: true,
53
+ stdio: ['pipe', 'pipe', 'pipe'],
54
+ detached: true,
55
+ });
56
+ }
57
+ else {
58
+ // Array mode (no shell, safer)
59
+ if (command.length === 0) {
60
+ reject(new SystemError('Command array must not be empty', { code: 'SYSTEM.FITNESS.EXEC_EMPTY_COMMAND' }));
61
+ return;
62
+ }
63
+ const [bin, ...args] = command;
64
+ // @fitness-ignore-next-line no-non-null-assertions -- command length validated above
65
+ child = spawn(bin ?? '', args, {
66
+ cwd,
67
+ env,
68
+ stdio: ['pipe', 'pipe', 'pipe'],
69
+ detached: true,
70
+ });
71
+ }
72
+ let stdout = '';
73
+ let stderr = '';
74
+ let aborted = false;
75
+ let timeoutId;
76
+ child.stdout?.on('data', (data) => {
77
+ const chunk = data.toString();
78
+ if (stdout.length + chunk.length <= maxBuffer) {
79
+ stdout += chunk;
80
+ }
81
+ });
82
+ child.stderr?.on('data', (data) => {
83
+ const chunk = data.toString();
84
+ if (stderr.length + chunk.length <= maxBuffer) {
85
+ stderr += chunk;
86
+ }
87
+ });
88
+ const abortHandler = () => {
89
+ if (!aborted) {
90
+ aborted = true;
91
+ killProcess(child);
92
+ }
93
+ };
94
+ signal?.addEventListener('abort', abortHandler);
95
+ if (timeout && timeout > 0) {
96
+ timeoutId = setTimeout(() => {
97
+ if (!aborted) {
98
+ aborted = true;
99
+ killProcess(child);
100
+ }
101
+ }, timeout);
102
+ }
103
+ child.on('close', (code) => {
104
+ signal?.removeEventListener('abort', abortHandler);
105
+ if (timeoutId)
106
+ clearTimeout(timeoutId);
107
+ resolve({ stdout, stderr, exitCode: code, aborted });
108
+ });
109
+ child.on('error', (err) => {
110
+ signal?.removeEventListener('abort', abortHandler);
111
+ if (timeoutId)
112
+ clearTimeout(timeoutId);
113
+ reject(new ExecError(`Failed to spawn process: ${err.message}`, stdout, stderr, null, aborted));
114
+ });
115
+ });
116
+ }
117
+ /**
118
+ * Kill a child process and all its descendants.
119
+ */
120
+ function killProcess(child) {
121
+ if (child.pid) {
122
+ try {
123
+ process.kill(-child.pid, 'SIGKILL');
124
+ }
125
+ catch {
126
+ // @swallow-ok Process group kill failed, try direct kill
127
+ try {
128
+ child.kill('SIGKILL');
129
+ }
130
+ catch {
131
+ // @swallow-ok Process already exited
132
+ }
133
+ }
134
+ }
135
+ }
136
+ //# sourceMappingURL=abortable-exec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abortable-exec.js","sourceRoot":"","sources":["../../src/framework/abortable-exec.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,yGAAyG;AACzG;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAA;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAuBjD;;GAEG;AACH,MAAM,SAAU,SAAQ,WAAW;IAGf;IACA;IACA;IACA;IALlB,YACE,OAAe,EACC,MAAc,EACd,MAAc,EACd,QAAuB,EACvB,OAAgB;QAEhC,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,4BAA4B,EAAE,CAAC,CAAA;QALtC,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,C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S,CAAC,CAAA;YACvB,CAAC;YAAC,MAAM,CAAC;gBACP,qCAAqC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @fileoverview Shared AST utilities for fitness checks
3
+ *
4
+ * Common TypeScript AST operations for source parsing, tree walking,
5
+ * and node inspection. Used by AST-based fitness checks.
6
+ */
7
+ import * as ts from 'typescript';
8
+ /**
9
+ * Parse TypeScript/JavaScript source into an AST SourceFile.
10
+ * Returns null on parse failure.
11
+ */
12
+ export declare function parseSource(content: string, filePath: string): ts.SourceFile | null;
13
+ /**
14
+ * Depth-first walk of all nodes in a SourceFile or subtree.
15
+ */
16
+ export declare function walkNodes(root: ts.Node, visitor: (node: ts.Node) => void): void;
17
+ /**
18
+ * Get the leaf identifier text from an expression node.
19
+ */
20
+ export declare function getIdentifierName(node: ts.Node): string;
21
+ /**
22
+ * Get the full dotted path of a property access chain.
23
+ */
24
+ export declare function getPropertyChain(node: ts.Node): string;
25
+ /**
26
+ * Get the 1-indexed line number for a node.
27
+ */
28
+ export declare function getLineNumber(node: ts.Node, sourceFile: ts.SourceFile): number;
29
+ /**
30
+ * Check if a node is a property access matching a specific property name.
31
+ */
32
+ export declare function isPropertyAccess(node: ts.Node, propertyName: string): boolean;
33
+ /**
34
+ * Check if a node is a literal value.
35
+ */
36
+ export declare function isLiteral(node: ts.Node): boolean;
37
+ /**
38
+ * Check if a node is inside a string literal or template literal.
39
+ */
40
+ export declare function isInStringLiteral(node: ts.Node): boolean;
41
+ //# sourceMappingURL=ast-utilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-utilities.d.ts","sourceRoot":"","sources":["../../src/framework/ast-utilities.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAA;AAMhC;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,GAAG,IAAI,CAOnF;AAMD;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,GAAG,IAAI,CAM/E;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,CAIvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,CAMtD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,MAAM,CAG9E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAE7E;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAQhD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAaxD"}
@@ -0,0 +1,106 @@
1
+ // @fitness-ignore-file batch-operation-limits -- iterates bounded collections (config entries, registry items, or small analysis results)
2
+ /**
3
+ * @fileoverview Shared AST utilities for fitness checks
4
+ *
5
+ * Common TypeScript AST operations for source parsing, tree walking,
6
+ * and node inspection. Used by AST-based fitness checks.
7
+ */
8
+ import * as ts from 'typescript';
9
+ // =============================================================================
10
+ // SOURCE PARSING
11
+ // =============================================================================
12
+ /**
13
+ * Parse TypeScript/JavaScript source into an AST SourceFile.
14
+ * Returns null on parse failure.
15
+ */
16
+ export function parseSource(content, filePath) {
17
+ try {
18
+ return ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
19
+ }
20
+ catch {
21
+ // @swallow-ok Parse failure returns null for graceful degradation
22
+ return null;
23
+ }
24
+ }
25
+ // =============================================================================
26
+ // TREE WALKING
27
+ // =============================================================================
28
+ /**
29
+ * Depth-first walk of all nodes in a SourceFile or subtree.
30
+ */
31
+ export function walkNodes(root, visitor) {
32
+ function visit(node) {
33
+ visitor(node);
34
+ ts.forEachChild(node, visit);
35
+ }
36
+ ts.forEachChild(root, visit);
37
+ }
38
+ // =============================================================================
39
+ // NODE INSPECTION
40
+ // =============================================================================
41
+ /**
42
+ * Get the leaf identifier text from an expression node.
43
+ */
44
+ export function getIdentifierName(node) {
45
+ if (ts.isIdentifier(node))
46
+ return node.text;
47
+ if (ts.isPropertyAccessExpression(node))
48
+ return node.name.text;
49
+ return '';
50
+ }
51
+ /**
52
+ * Get the full dotted path of a property access chain.
53
+ */
54
+ export function getPropertyChain(node) {
55
+ if (ts.isIdentifier(node))
56
+ return node.text;
57
+ if (ts.isPropertyAccessExpression(node)) {
58
+ return `${getPropertyChain(node.expression)}.${node.name.text}`;
59
+ }
60
+ return '';
61
+ }
62
+ /**
63
+ * Get the 1-indexed line number for a node.
64
+ */
65
+ export function getLineNumber(node, sourceFile) {
66
+ const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
67
+ return line + 1;
68
+ }
69
+ /**
70
+ * Check if a node is a property access matching a specific property name.
71
+ */
72
+ export function isPropertyAccess(node, propertyName) {
73
+ return ts.isPropertyAccessExpression(node) && node.name.text === propertyName;
74
+ }
75
+ /**
76
+ * Check if a node is a literal value.
77
+ */
78
+ export function isLiteral(node) {
79
+ if (ts.isStringLiteral(node) || ts.isNumericLiteral(node))
80
+ return true;
81
+ if (ts.isNoSubstitutionTemplateLiteral(node))
82
+ return true;
83
+ if (node.kind === ts.SyntaxKind.TrueKeyword || node.kind === ts.SyntaxKind.FalseKeyword)
84
+ return true;
85
+ if (node.kind === ts.SyntaxKind.NullKeyword)
86
+ return true;
87
+ if (ts.isIdentifier(node) && node.text === 'undefined')
88
+ return true;
89
+ return false;
90
+ }
91
+ /**
92
+ * Check if a node is inside a string literal or template literal.
93
+ */
94
+ export function isInStringLiteral(node) {
95
+ let current = node.parent;
96
+ while (!ts.isSourceFile(current)) {
97
+ if (ts.isStringLiteral(current) ||
98
+ ts.isNoSubstitutionTemplateLiteral(current) ||
99
+ ts.isTemplateExpression(current)) {
100
+ return true;
101
+ }
102
+ current = current.parent;
103
+ }
104
+ return false;
105
+ }
106
+ //# sourceMappingURL=ast-utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-utilities.js","sourceRoot":"","sources":["../../src/framework/ast-utilities.ts"],"names":[],"mappings":"AAAA,0IAA0I;AAC1I;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAA;AAEhC,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,QAAgB;IAC3D,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC7E,CAAC;IAAC,MAAM,CAAC;QACP,kEAAkE;QAClE,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,IAAa,EAAE,OAAgC;IACvE,SAAS,KAAK,CAAC,IAAa;QAC1B,OAAO,CAAC,IAAI,CAAC,CAAA;QACb,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAC9B,CAAC;IACD,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AAC9B,CAAC;AAED,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAa;IAC7C,IAAI,EAAE,CAAC,YAA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AW,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,YAAY;QACrF,OAAO,IAAI,CAAA;IACb,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,WAAW;QAAE,OAAO,IAAI,CAAA;IACxD,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW;QAAE,OAAO,IAAI,CAAA;IACnE,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAa;IAC7C,IAAI,OAAO,GAAG,IAAI,CAAC,MAAM,CAAA;IACzB,OAAO,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,IACE,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC;YAC3B,EAAE,CAAC,+BAA+B,CAAC,OAAO,CAAC;YAC3C,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAChC,CAAC;YACD,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAA;IAC1B,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * @fileoverview Unified check configuration schema
3
+ *
4
+ * Defines the configuration types for fitness checks with three analysis modes:
5
+ * - analyze: Per-file analysis with content and path
6
+ * - analyzeAll: Multi-file analysis with lazy loading FileAccessor
7
+ * - command: External tool execution with output parsing
8
+ */
9
+ import type { ItemType } from '../types/findings.js';
10
+ /** Type alias for a kebab-case check slug string. */
11
+ type CheckSlug = string;
12
+ /**
13
+ * Resolved scope with concrete glob patterns for file matching.
14
+ * Produced by resolving a CheckScope against targets configuration.
15
+ */
16
+ export interface ResolvedScope {
17
+ readonly include: readonly string[];
18
+ readonly exclude: readonly string[];
19
+ readonly description: string;
20
+ }
21
+ /**
22
+ * Semantic concern describing what kind of code a check targets.
23
+ * Used for automatic target matching: a check with `concerns: ['backend']`
24
+ * matches any target that declares `concerns: ['backend', ...]`.
25
+ */
26
+ export type CheckConcern = string;
27
+ /**
28
+ * Language a check is designed for. Used for automatic target matching:
29
+ * a check with `languages: ['typescript']` matches any target with
30
+ * `languages: ['typescript', ...]`.
31
+ */
32
+ export type CheckLanguage = string;
33
+ /**
34
+ * Portable scope declaration for a fitness check.
35
+ *
36
+ * Instead of referencing project-specific target names, checks declare
37
+ * what kind of code they analyze. The platform matches this intent
38
+ * against project targets automatically.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * scope: {
43
+ * languages: ['typescript'],
44
+ * concerns: ['backend', 'server'],
45
+ * }
46
+ * ```
47
+ */
48
+ export interface CheckScope {
49
+ /** File type affinity — which languages this check analyzes. */
50
+ readonly languages: readonly CheckLanguage[];
51
+ /** Semantic hints — what kind of code this check targets. */
52
+ readonly concerns: readonly CheckConcern[];
53
+ }
54
+ /**
55
+ * Violation returned by check authors.
56
+ * This is the simplified shape - the framework converts it to a Signal.
57
+ */
58
+ export interface CheckViolation {
59
+ readonly line: number;
60
+ readonly column?: number;
61
+ readonly message: string;
62
+ readonly severity: 'error' | 'warning';
63
+ readonly suggestion?: string;
64
+ readonly match?: string;
65
+ readonly type?: string;
66
+ readonly filePath?: string;
67
+ readonly fix?: {
68
+ readonly action: 'replace' | 'insert' | 'delete' | 'refactor' | 'configure' | 'investigate';
69
+ readonly replacement?: string;
70
+ readonly confidence: number;
71
+ };
72
+ }
73
+ /**
74
+ * Lazy-loading file accessor for analyzeAll mode.
75
+ */
76
+ export interface FileAccessor {
77
+ /** List of matched file paths */
78
+ readonly paths: readonly string[];
79
+ /** Read a single file on demand (cached after first read) */
80
+ read(filePath: string): Promise<string>;
81
+ /** Read multiple files in batch */
82
+ readMany(filePaths: readonly string[]): Promise<Map<string, string>>;
83
+ /** Read all matched files */
84
+ readAll(): Promise<Map<string, string>>;
85
+ }
86
+ /** Configuration for an external command-based check. */
87
+ export interface CommandConfig {
88
+ readonly bin: string;
89
+ readonly args: readonly string[] | ((files: readonly string[]) => readonly string[]);
90
+ parseOutput(stdout: string, stderr: string, exitCode: number, files: readonly string[], cwd: string): CheckViolation[];
91
+ readonly expectedExitCodes?: readonly number[];
92
+ }
93
+ /** Common configuration fields shared by all check types. */
94
+ interface BaseCheckConfig {
95
+ readonly id: string;
96
+ readonly slug: CheckSlug;
97
+ readonly description: string;
98
+ readonly longDescription?: string;
99
+ readonly tags: readonly string[];
100
+ readonly docs?: string;
101
+ readonly timeout?: number;
102
+ readonly disabled?: boolean;
103
+ readonly fileTypes?: readonly string[];
104
+ /** Signal provider name for external tool checks (default: 'opensip') */
105
+ readonly provider?: string;
106
+ /** The type of items this check validates (default: 'files'). Used for display in results table. */
107
+ readonly itemType?: ItemType;
108
+ /** Portable scope declaration for marketplace-ready target matching. */
109
+ readonly scope?: CheckScope;
110
+ /**
111
+ * Content filtering mode for the analyze() function. Names describe
112
+ * what the filter strips so rule authors don't have to guess at intent.
113
+ *
114
+ * - 'raw' (default): Full file content, unchanged. Use for checks that
115
+ * need to analyze string content (e.g., hardcoded secrets, PII detection).
116
+ * - 'strip-strings': String literals replaced with whitespace,
117
+ * preserving line/column positions. COMMENTS PRESERVED — use when
118
+ * the check reads comment-based directives like the deprecation
119
+ * marker, the swallow-ok marker, or `// @fitness-ignore-...` (we
120
+ * don't reference those tag names verbatim in this JSDoc to avoid
121
+ * confusing static analyzers).
122
+ * - 'strip-strings-and-comments': BOTH string literals and comments
123
+ * replaced with whitespace, preserving line/column positions. Use
124
+ * for checks that pattern-match identifiers via regex and would
125
+ * false-positive on the same banned phrase appearing in JSDoc /
126
+ * line / block comments documenting the rule itself.
127
+ *
128
+ * The legacy `'code-only'` / `'no-strings-no-comments'` aliases were
129
+ * retained through 0.4.x for backwards-compat and removed in 0.5.0.
130
+ * Migrate any remaining call sites to the strip-* names.
131
+ */
132
+ readonly contentFilter?: 'raw' | 'strip-strings' | 'strip-strings-and-comments';
133
+ /**
134
+ * Confidence level of this check's findings. Consumers of opensip-tools
135
+ * signals (via --report-to) use this to decide how aggressively to act
136
+ * on findings; this package treats it as pure metadata.
137
+ *
138
+ * - 'high': AST-based or structurally guaranteed no false positives.
139
+ * - 'medium': Regex with context filtering — some false positives expected.
140
+ * - 'low': Naive regex or heuristic — surfaced in reports but easily noisy.
141
+ *
142
+ * Default: 'medium' (applied at runtime, not in schema).
143
+ */
144
+ readonly confidence?: 'high' | 'medium' | 'low';
145
+ }
146
+ /** Check config with per-file analysis mode. */
147
+ export interface AnalyzeCheckConfig extends BaseCheckConfig {
148
+ analyze(content: string, filePath: string): CheckViolation[];
149
+ }
150
+ /** Check config with multi-file analysis mode using FileAccessor. */
151
+ export interface AnalyzeAllCheckConfig extends BaseCheckConfig {
152
+ analyzeAll(files: FileAccessor): Promise<CheckViolation[]>;
153
+ }
154
+ /** Check config with external command execution mode. */
155
+ export interface CommandCheckConfig extends BaseCheckConfig {
156
+ command: CommandConfig;
157
+ }
158
+ /** Union of all check configuration types (analyze, analyzeAll, command). */
159
+ export type UnifiedCheckConfig = AnalyzeCheckConfig | AnalyzeAllCheckConfig | CommandCheckConfig;
160
+ /** Validate and parse a check configuration, throwing on invalid input. */
161
+ export declare function validateCheckConfig(config: unknown): UnifiedCheckConfig;
162
+ /** Type guard for per-file analyze mode checks. */
163
+ export declare function isAnalyzeConfig(config: UnifiedCheckConfig): config is AnalyzeCheckConfig;
164
+ /** Type guard for multi-file analyzeAll mode checks. */
165
+ export declare function isAnalyzeAllConfig(config: UnifiedCheckConfig): config is AnalyzeAllCheckConfig;
166
+ /** Type guard for external command mode checks. */
167
+ export declare function isCommandConfig(config: UnifiedCheckConfig): config is CommandCheckConfig;
168
+ /** Determine which analysis mode a check config uses. */
169
+ export declare function getAnalysisMode(config: UnifiedCheckConfig): 'analyze' | 'analyzeAll' | 'command';
170
+ export {};
171
+ //# sourceMappingURL=check-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-config.d.ts","sourceRo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CAEvE;AAED,mDAAmD;AACnD,wBAAgB,eAAe,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,IAAI,kBAAkB,CAExF;AAED,wDAAwD;AACxD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,IAAI,qBAAqB,CAE9F;AAED,mDAAmD;AACnD,wBAAgB,eAAe,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,IAAI,kBAAkB,CAExF;AAED,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAIhG"}
@@ -0,0 +1,114 @@
1
+ // @fitness-ignore-file zod-schema-strictness -- flexible schema for external data
2
+ // @fitness-ignore-file null-safety -- Zod schema builder chains (z.string().regex(), z.object().passthrough().superRefine().pipe()) always return valid schema objects
3
+ /**
4
+ * @fileoverview Unified check configuration schema
5
+ *
6
+ * Defines the configuration types for fitness checks with three analysis modes:
7
+ * - analyze: Per-file analysis with content and path
8
+ * - analyzeAll: Multi-file analysis with lazy loading FileAccessor
9
+ * - command: External tool execution with output parsing
10
+ */
11
+ import { z } from 'zod';
12
+ // =============================================================================
13
+ // CHECK SLUGS AND IDS
14
+ // =============================================================================
15
+ /** Zod schema for validating kebab-case check slugs. */
16
+ const CheckSlugSchema = z
17
+ .string()
18
+ .regex(/^[a-z][a-z0-9-]*(?:-[a-z0-9]+)*$/, 'Check slug must be kebab-case (e.g., no-console-log)');
19
+ /** Zod schema for validating UUID-format check IDs. */
20
+ const CheckIdSchema = z
21
+ .string()
22
+ .regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/, 'Check ID must be plain UUID format');
23
+ const CommandArgsSchema = z.union([z.array(z.string()), z.function()]);
24
+ /** Zod schema for validating command configurations. */
25
+ const CommandConfigSchema = z.object({
26
+ bin: z.string().min(1),
27
+ args: CommandArgsSchema,
28
+ parseOutput: z.function(),
29
+ expectedExitCodes: z.array(z.number().int()).optional(),
30
+ });
31
+ // =============================================================================
32
+ // ANALYSIS MODE SCHEMAS
33
+ // =============================================================================
34
+ const AnalyzeModeSchema = z.object({ analyze: z.function() });
35
+ const AnalyzeAllModeSchema = z.object({ analyzeAll: z.function() });
36
+ const CommandModeSchema = z.object({ command: CommandConfigSchema });
37
+ /**
38
+ * Zod schema for validating check scope declarations.
39
+ *
40
+ * Empty `languages` and empty `concerns` are both valid and mean
41
+ * "matches any". This is how cross-language ("universal") checks
42
+ * declare themselves — see @opensip-tools/checks-universal.
43
+ *
44
+ * findByScope() in TargetRegistry treats empty arrays as match-any
45
+ * already; the schema mirrors that behavior so callers can author
46
+ * universal checks without inventing a wildcard sentinel.
47
+ */
48
+ const CheckScopeSchema = z.object({
49
+ languages: z.array(z.string()),
50
+ concerns: z.array(z.string()),
51
+ });
52
+ const BaseCheckConfigSchema = z.object({
53
+ id: CheckIdSchema,
54
+ slug: CheckSlugSchema,
55
+ description: z.string().min(1, 'Description is required'),
56
+ longDescription: z.string().optional(),
57
+ tags: z.array(z.string()).min(1, 'At least one tag is required'),
58
+ docs: z.string().optional(),
59
+ timeout: z.number().positive().optional(),
60
+ disabled: z.boolean().optional(),
61
+ fileTypes: z.array(z.string()).optional(),
62
+ provider: z.string().optional(),
63
+ scope: CheckScopeSchema.optional(),
64
+ contentFilter: z.enum(['raw', 'strip-strings', 'strip-strings-and-comments']).optional(),
65
+ confidence: z.enum(['high', 'medium', 'low']).optional(),
66
+ });
67
+ // =============================================================================
68
+ // VALIDATION
69
+ // =============================================================================
70
+ /** Zod schema for validating unified check configurations (exactly one analysis mode required). */
71
+ const UnifiedCheckConfigSchema = z
72
+ .object({})
73
+ .passthrough()
74
+ .superRefine((config, ctx) => {
75
+ const modes = ['analyze' in config, 'analyzeAll' in config, 'command' in config].filter(Boolean).length;
76
+ if (modes === 0) {
77
+ ctx.addIssue({
78
+ code: z.ZodIssueCode.custom,
79
+ message: 'Check config must specify an analysis mode: analyze, analyzeAll, or command',
80
+ });
81
+ }
82
+ else if (modes > 1) {
83
+ ctx.addIssue({
84
+ code: z.ZodIssueCode.custom,
85
+ message: 'Check config must specify exactly one analysis mode (found multiple)',
86
+ });
87
+ }
88
+ })
89
+ .pipe(BaseCheckConfigSchema.and(z.union([AnalyzeModeSchema, AnalyzeAllModeSchema, CommandModeSchema])));
90
+ /** Validate and parse a check configuration, throwing on invalid input. */
91
+ export function validateCheckConfig(config) {
92
+ return UnifiedCheckConfigSchema.parse(config);
93
+ }
94
+ /** Type guard for per-file analyze mode checks. */
95
+ export function isAnalyzeConfig(config) {
96
+ return 'analyze' in config && typeof config.analyze === 'function';
97
+ }
98
+ /** Type guard for multi-file analyzeAll mode checks. */
99
+ export function isAnalyzeAllConfig(config) {
100
+ return 'analyzeAll' in config && typeof config.analyzeAll === 'function';
101
+ }
102
+ /** Type guard for external command mode checks. */
103
+ export function isCommandConfig(config) {
104
+ return 'command' in config && typeof config.command === 'object';
105
+ }
106
+ /** Determine which analysis mode a check config uses. */
107
+ export function getAnalysisMode(config) {
108
+ if (isAnalyzeConfig(config))
109
+ return 'analyze';
110
+ if (isAnalyzeAllConfig(config))
111
+ return 'analyzeAll';
112
+ return 'command';
113
+ }
114
+ //# sourceMappingURL=check-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-config.js","sourceRoot":"","sources":["../../src/framework/check-config.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,uKAAuK;AACvK;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,gFAAgF;AAChF,sBAAsB;AACtB,gFAAgF;AAEhF,wDAAwD;AACxD,MAAM,eAAe,GAAG,CAAC;KACtB,MAAM,EAAE;KACR,KAAK,CAAC,kCAAkC,EAAE,sDAAsD,CAAC,CAAA;AAEpG,uDAAuD;AACvD,MAAM,aAAa,GAAG,CAAC;KACpB,MAAM,EAAE;KACR,KAAK,CACJ,gEAA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C;QAAE,OAAO,YAAY,CAAA;IACnD,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @fileoverview Core type definitions for fitness checks
3
+ *
4
+ * Check interface is the return type of defineCheck.
5
+ * CheckConfig represents the internal configuration structure.
6
+ * CheckResult carries Signal[].
7
+ */
8
+ import type { CheckScope, ResolvedScope } from './check-config.js';
9
+ import type { ExecutionContext, RunOptions } from './execution-context.js';
10
+ import type { PathMatcher } from './path-matcher.js';
11
+ import type { CheckResult, ItemType } from '../types/findings.js';
12
+ /**
13
+ * Check configuration options.
14
+ */
15
+ export interface CheckConfig {
16
+ readonly id: string;
17
+ readonly slug: string;
18
+ readonly tags: readonly string[];
19
+ readonly description: string;
20
+ readonly longDescription?: string | undefined;
21
+ readonly analysisMode: 'analyze' | 'analyzeAll' | 'command';
22
+ readonly scope: ResolvedScope;
23
+ readonly itemType: ItemType;
24
+ readonly unit?: string | undefined;
25
+ readonly additionalExcludes?: readonly string[] | undefined;
26
+ readonly docs?: string | undefined;
27
+ readonly disabled?: boolean | undefined;
28
+ readonly confidence?: 'high' | 'medium' | 'low' | undefined;
29
+ readonly timeout?: number | undefined;
30
+ readonly scansFiles?: boolean | undefined;
31
+ readonly fileTypes?: readonly string[] | undefined;
32
+ /** Portable scope declaration for marketplace-ready target matching. */
33
+ readonly checkScope?: CheckScope | undefined;
34
+ readonly execute: (ctx: ExecutionContext) => Promise<CheckResult>;
35
+ }
36
+ /**
37
+ * A defined check, ready to run.
38
+ */
39
+ export interface Check {
40
+ readonly config: CheckConfig;
41
+ readonly run: (cwd: string, options?: RunOptions) => Promise<CheckResult>;
42
+ readonly getScope: () => ResolvedScope;
43
+ readonly getMatcher: (cwd: string) => PathMatcher;
44
+ }
45
+ /**
46
+ * Type guard: is this value a Check object?
47
+ *
48
+ * Checks for the shape of a Check object:
49
+ * - Has a `config` property that is an object
50
+ * - config has an `id` property that is a string
51
+ * - config has a `slug` property that is a string
52
+ * - config has an `execute` property that is a function
53
+ * - Has a `run` property that is a function
54
+ */
55
+ export declare function isCheck(value: unknown): value is Check;
56
+ export { type ResolvedScope } from './check-config.js';
57
+ //# sourceMappingURL=check-types.d.ts.map