@vibecheckai/cli 2.5.1

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 (415) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +532 -0
  3. package/dist/autopatch/verified-autopatch.d.ts +111 -0
  4. package/dist/autopatch/verified-autopatch.d.ts.map +1 -0
  5. package/dist/autopatch/verified-autopatch.js +503 -0
  6. package/dist/autopatch/verified-autopatch.js.map +1 -0
  7. package/dist/bundles/guardrail-core.js +25799 -0
  8. package/dist/bundles/guardrail-security.js +208687 -0
  9. package/dist/bundles/guardrail-ship.js +2318 -0
  10. package/dist/bundles/index.js +8 -0
  11. package/dist/commands/autopilot-decision.d.ts +24 -0
  12. package/dist/commands/autopilot-decision.d.ts.map +1 -0
  13. package/dist/commands/autopilot-decision.js +304 -0
  14. package/dist/commands/autopilot-decision.js.map +1 -0
  15. package/dist/commands/autopilot.d.ts +33 -0
  16. package/dist/commands/autopilot.d.ts.map +1 -0
  17. package/dist/commands/autopilot.js +1539 -0
  18. package/dist/commands/autopilot.js.map +1 -0
  19. package/dist/commands/baseline.d.ts +7 -0
  20. package/dist/commands/baseline.d.ts.map +1 -0
  21. package/dist/commands/baseline.js +79 -0
  22. package/dist/commands/baseline.js.map +1 -0
  23. package/dist/commands/cache.d.ts +13 -0
  24. package/dist/commands/cache.d.ts.map +1 -0
  25. package/dist/commands/cache.js +165 -0
  26. package/dist/commands/cache.js.map +1 -0
  27. package/dist/commands/checkpoint.d.ts +8 -0
  28. package/dist/commands/checkpoint.d.ts.map +1 -0
  29. package/dist/commands/checkpoint.js +35 -0
  30. package/dist/commands/checkpoint.js.map +1 -0
  31. package/dist/commands/context.d.ts +8 -0
  32. package/dist/commands/context.d.ts.map +1 -0
  33. package/dist/commands/context.js +340 -0
  34. package/dist/commands/context.js.map +1 -0
  35. package/dist/commands/debug.d.ts +78 -0
  36. package/dist/commands/debug.d.ts.map +1 -0
  37. package/dist/commands/debug.js +381 -0
  38. package/dist/commands/debug.js.map +1 -0
  39. package/dist/commands/doctor.d.ts +17 -0
  40. package/dist/commands/doctor.d.ts.map +1 -0
  41. package/dist/commands/doctor.js +226 -0
  42. package/dist/commands/doctor.js.map +1 -0
  43. package/dist/commands/evidence.d.ts +45 -0
  44. package/dist/commands/evidence.d.ts.map +1 -0
  45. package/dist/commands/evidence.js +197 -0
  46. package/dist/commands/evidence.js.map +1 -0
  47. package/dist/commands/explain.d.ts +8 -0
  48. package/dist/commands/explain.d.ts.map +1 -0
  49. package/dist/commands/explain.js +52 -0
  50. package/dist/commands/explain.js.map +1 -0
  51. package/dist/commands/fix-consolidated.d.ts +19 -0
  52. package/dist/commands/fix-consolidated.d.ts.map +1 -0
  53. package/dist/commands/fix-consolidated.js +165 -0
  54. package/dist/commands/fix-consolidated.js.map +1 -0
  55. package/dist/commands/index.d.ts +8 -0
  56. package/dist/commands/index.d.ts.map +1 -0
  57. package/dist/commands/index.js +15 -0
  58. package/dist/commands/index.js.map +1 -0
  59. package/dist/commands/init.d.ts +8 -0
  60. package/dist/commands/init.d.ts.map +1 -0
  61. package/dist/commands/init.js +125 -0
  62. package/dist/commands/init.js.map +1 -0
  63. package/dist/commands/launcher.d.ts +10 -0
  64. package/dist/commands/launcher.d.ts.map +1 -0
  65. package/dist/commands/launcher.js +174 -0
  66. package/dist/commands/launcher.js.map +1 -0
  67. package/dist/commands/on.d.ts +8 -0
  68. package/dist/commands/on.d.ts.map +1 -0
  69. package/dist/commands/on.js +123 -0
  70. package/dist/commands/on.js.map +1 -0
  71. package/dist/commands/preview.d.ts +54 -0
  72. package/dist/commands/preview.d.ts.map +1 -0
  73. package/dist/commands/preview.js +352 -0
  74. package/dist/commands/preview.js.map +1 -0
  75. package/dist/commands/quality/check.d.ts +31 -0
  76. package/dist/commands/quality/check.d.ts.map +1 -0
  77. package/dist/commands/quality/check.js +242 -0
  78. package/dist/commands/quality/check.js.map +1 -0
  79. package/dist/commands/quality/index.d.ts +8 -0
  80. package/dist/commands/quality/index.d.ts.map +1 -0
  81. package/dist/commands/quality/index.js +14 -0
  82. package/dist/commands/quality/index.js.map +1 -0
  83. package/dist/commands/quality/setup-quality.d.ts +23 -0
  84. package/dist/commands/quality/setup-quality.d.ts.map +1 -0
  85. package/dist/commands/quality/setup-quality.js +452 -0
  86. package/dist/commands/quality/setup-quality.js.map +1 -0
  87. package/dist/commands/quality/tidy.d.ts +41 -0
  88. package/dist/commands/quality/tidy.d.ts.map +1 -0
  89. package/dist/commands/quality/tidy.js +466 -0
  90. package/dist/commands/quality/tidy.js.map +1 -0
  91. package/dist/commands/quality/utils.d.ts +73 -0
  92. package/dist/commands/quality/utils.d.ts.map +1 -0
  93. package/dist/commands/quality/utils.js +158 -0
  94. package/dist/commands/quality/utils.js.map +1 -0
  95. package/dist/commands/replay.d.ts +8 -0
  96. package/dist/commands/replay.d.ts.map +1 -0
  97. package/dist/commands/replay.js +52 -0
  98. package/dist/commands/replay.js.map +1 -0
  99. package/dist/commands/scan-consolidated.d.ts +61 -0
  100. package/dist/commands/scan-consolidated.d.ts.map +1 -0
  101. package/dist/commands/scan-consolidated.js +243 -0
  102. package/dist/commands/scan-consolidated.js.map +1 -0
  103. package/dist/commands/scan-secrets.d.ts +47 -0
  104. package/dist/commands/scan-secrets.d.ts.map +1 -0
  105. package/dist/commands/scan-secrets.js +225 -0
  106. package/dist/commands/scan-secrets.js.map +1 -0
  107. package/dist/commands/scan-vulnerabilities-enhanced.d.ts +41 -0
  108. package/dist/commands/scan-vulnerabilities-enhanced.d.ts.map +1 -0
  109. package/dist/commands/scan-vulnerabilities-enhanced.js +368 -0
  110. package/dist/commands/scan-vulnerabilities-enhanced.js.map +1 -0
  111. package/dist/commands/scan-vulnerabilities-osv.d.ts +58 -0
  112. package/dist/commands/scan-vulnerabilities-osv.d.ts.map +1 -0
  113. package/dist/commands/scan-vulnerabilities-osv.js +716 -0
  114. package/dist/commands/scan-vulnerabilities-osv.js.map +1 -0
  115. package/dist/commands/scan-vulnerabilities.d.ts +32 -0
  116. package/dist/commands/scan-vulnerabilities.d.ts.map +1 -0
  117. package/dist/commands/scan-vulnerabilities.js +283 -0
  118. package/dist/commands/scan-vulnerabilities.js.map +1 -0
  119. package/dist/commands/secrets-allowlist.d.ts +7 -0
  120. package/dist/commands/secrets-allowlist.d.ts.map +1 -0
  121. package/dist/commands/secrets-allowlist.js +85 -0
  122. package/dist/commands/secrets-allowlist.js.map +1 -0
  123. package/dist/commands/ship-consolidated.d.ts +58 -0
  124. package/dist/commands/ship-consolidated.d.ts.map +1 -0
  125. package/dist/commands/ship-consolidated.js +515 -0
  126. package/dist/commands/ship-consolidated.js.map +1 -0
  127. package/dist/commands/stats.d.ts +8 -0
  128. package/dist/commands/stats.d.ts.map +1 -0
  129. package/dist/commands/stats.js +134 -0
  130. package/dist/commands/stats.js.map +1 -0
  131. package/dist/commands/upgrade.d.ts +8 -0
  132. package/dist/commands/upgrade.d.ts.map +1 -0
  133. package/dist/commands/upgrade.js +30 -0
  134. package/dist/commands/upgrade.js.map +1 -0
  135. package/dist/fix/analytics.d.ts +121 -0
  136. package/dist/fix/analytics.d.ts.map +1 -0
  137. package/dist/fix/analytics.js +289 -0
  138. package/dist/fix/analytics.js.map +1 -0
  139. package/dist/fix/applicator.d.ts +44 -0
  140. package/dist/fix/applicator.d.ts.map +1 -0
  141. package/dist/fix/applicator.js +144 -0
  142. package/dist/fix/applicator.js.map +1 -0
  143. package/dist/fix/audit.d.ts +61 -0
  144. package/dist/fix/audit.d.ts.map +1 -0
  145. package/dist/fix/audit.js +149 -0
  146. package/dist/fix/audit.js.map +1 -0
  147. package/dist/fix/backup.d.ts +38 -0
  148. package/dist/fix/backup.d.ts.map +1 -0
  149. package/dist/fix/backup.js +154 -0
  150. package/dist/fix/backup.js.map +1 -0
  151. package/dist/fix/config.d.ts +78 -0
  152. package/dist/fix/config.d.ts.map +1 -0
  153. package/dist/fix/config.js +200 -0
  154. package/dist/fix/config.js.map +1 -0
  155. package/dist/fix/engine.d.ts +55 -0
  156. package/dist/fix/engine.d.ts.map +1 -0
  157. package/dist/fix/engine.js +285 -0
  158. package/dist/fix/engine.js.map +1 -0
  159. package/dist/fix/impact.d.ts +74 -0
  160. package/dist/fix/impact.d.ts.map +1 -0
  161. package/dist/fix/impact.js +281 -0
  162. package/dist/fix/impact.js.map +1 -0
  163. package/dist/fix/index.d.ts +5 -0
  164. package/dist/fix/index.d.ts.map +1 -0
  165. package/dist/fix/index.js +12 -0
  166. package/dist/fix/index.js.map +1 -0
  167. package/dist/fix/interactive.d.ts +22 -0
  168. package/dist/fix/interactive.d.ts.map +1 -0
  169. package/dist/fix/interactive.js +172 -0
  170. package/dist/fix/interactive.js.map +1 -0
  171. package/dist/fix/learning.d.ts +109 -0
  172. package/dist/fix/learning.d.ts.map +1 -0
  173. package/dist/fix/learning.js +296 -0
  174. package/dist/fix/learning.js.map +1 -0
  175. package/dist/fix/metrics.d.ts +106 -0
  176. package/dist/fix/metrics.d.ts.map +1 -0
  177. package/dist/fix/metrics.js +138 -0
  178. package/dist/fix/metrics.js.map +1 -0
  179. package/dist/fix/parallel.d.ts +69 -0
  180. package/dist/fix/parallel.d.ts.map +1 -0
  181. package/dist/fix/parallel.js +203 -0
  182. package/dist/fix/parallel.js.map +1 -0
  183. package/dist/fix/report.d.ts +40 -0
  184. package/dist/fix/report.d.ts.map +1 -0
  185. package/dist/fix/report.js +212 -0
  186. package/dist/fix/report.js.map +1 -0
  187. package/dist/fix/strategy.d.ts +53 -0
  188. package/dist/fix/strategy.d.ts.map +1 -0
  189. package/dist/fix/strategy.js +143 -0
  190. package/dist/fix/strategy.js.map +1 -0
  191. package/dist/fix/templates.d.ts +58 -0
  192. package/dist/fix/templates.d.ts.map +1 -0
  193. package/dist/fix/templates.js +259 -0
  194. package/dist/fix/templates.js.map +1 -0
  195. package/dist/fix/testing.d.ts +68 -0
  196. package/dist/fix/testing.d.ts.map +1 -0
  197. package/dist/fix/testing.js +245 -0
  198. package/dist/fix/testing.js.map +1 -0
  199. package/dist/fix/validation.d.ts +71 -0
  200. package/dist/fix/validation.d.ts.map +1 -0
  201. package/dist/fix/validation.js +267 -0
  202. package/dist/fix/validation.js.map +1 -0
  203. package/dist/fix/visualization.d.ts +73 -0
  204. package/dist/fix/visualization.d.ts.map +1 -0
  205. package/dist/fix/visualization.js +243 -0
  206. package/dist/fix/visualization.js.map +1 -0
  207. package/dist/formatters/index.d.ts +6 -0
  208. package/dist/formatters/index.d.ts.map +1 -0
  209. package/dist/formatters/index.js +11 -0
  210. package/dist/formatters/index.js.map +1 -0
  211. package/dist/formatters/sarif-enhanced.d.ts +78 -0
  212. package/dist/formatters/sarif-enhanced.d.ts.map +1 -0
  213. package/dist/formatters/sarif-enhanced.js +144 -0
  214. package/dist/formatters/sarif-enhanced.js.map +1 -0
  215. package/dist/formatters/sarif-v2.d.ts +121 -0
  216. package/dist/formatters/sarif-v2.d.ts.map +1 -0
  217. package/dist/formatters/sarif-v2.js +356 -0
  218. package/dist/formatters/sarif-v2.js.map +1 -0
  219. package/dist/formatters/sarif.d.ts +72 -0
  220. package/dist/formatters/sarif.d.ts.map +1 -0
  221. package/dist/formatters/sarif.js +146 -0
  222. package/dist/formatters/sarif.js.map +1 -0
  223. package/dist/index.d.ts +61 -0
  224. package/dist/index.d.ts.map +1 -0
  225. package/dist/index.js +4455 -0
  226. package/dist/index.js.map +1 -0
  227. package/dist/init/ci-generator.d.ts +18 -0
  228. package/dist/init/ci-generator.d.ts.map +1 -0
  229. package/dist/init/ci-generator.js +317 -0
  230. package/dist/init/ci-generator.js.map +1 -0
  231. package/dist/init/detect-framework.d.ts +15 -0
  232. package/dist/init/detect-framework.d.ts.map +1 -0
  233. package/dist/init/detect-framework.js +301 -0
  234. package/dist/init/detect-framework.js.map +1 -0
  235. package/dist/init/hooks-installer.d.ts +22 -0
  236. package/dist/init/hooks-installer.d.ts.map +1 -0
  237. package/dist/init/hooks-installer.js +310 -0
  238. package/dist/init/hooks-installer.js.map +1 -0
  239. package/dist/init/index.d.ts +8 -0
  240. package/dist/init/index.d.ts.map +1 -0
  241. package/dist/init/index.js +22 -0
  242. package/dist/init/index.js.map +1 -0
  243. package/dist/init/templates.d.ts +401 -0
  244. package/dist/init/templates.d.ts.map +1 -0
  245. package/dist/init/templates.js +240 -0
  246. package/dist/init/templates.js.map +1 -0
  247. package/dist/mcp/server.d.ts +12 -0
  248. package/dist/mcp/server.d.ts.map +1 -0
  249. package/dist/mcp/server.js +42 -0
  250. package/dist/mcp/server.js.map +1 -0
  251. package/dist/mcp/telemetry.d.ts +40 -0
  252. package/dist/mcp/telemetry.d.ts.map +1 -0
  253. package/dist/mcp/telemetry.js +98 -0
  254. package/dist/mcp/telemetry.js.map +1 -0
  255. package/dist/reality/no-dead-buttons/button-sweep-generator.d.ts +32 -0
  256. package/dist/reality/no-dead-buttons/button-sweep-generator.d.ts.map +1 -0
  257. package/dist/reality/no-dead-buttons/button-sweep-generator.js +236 -0
  258. package/dist/reality/no-dead-buttons/button-sweep-generator.js.map +1 -0
  259. package/dist/reality/no-dead-buttons/index.d.ts +11 -0
  260. package/dist/reality/no-dead-buttons/index.d.ts.map +1 -0
  261. package/dist/reality/no-dead-buttons/index.js +18 -0
  262. package/dist/reality/no-dead-buttons/index.js.map +1 -0
  263. package/dist/reality/no-dead-buttons/static-scanner.d.ts +34 -0
  264. package/dist/reality/no-dead-buttons/static-scanner.d.ts.map +1 -0
  265. package/dist/reality/no-dead-buttons/static-scanner.js +230 -0
  266. package/dist/reality/no-dead-buttons/static-scanner.js.map +1 -0
  267. package/dist/reality/reality-graph.d.ts +192 -0
  268. package/dist/reality/reality-graph.d.ts.map +1 -0
  269. package/dist/reality/reality-graph.js +600 -0
  270. package/dist/reality/reality-graph.js.map +1 -0
  271. package/dist/reality/reality-runner.d.ts +89 -0
  272. package/dist/reality/reality-runner.d.ts.map +1 -0
  273. package/dist/reality/reality-runner.js +540 -0
  274. package/dist/reality/reality-runner.js.map +1 -0
  275. package/dist/reality/receipt-generator.d.ts +152 -0
  276. package/dist/reality/receipt-generator.d.ts.map +1 -0
  277. package/dist/reality/receipt-generator.js +495 -0
  278. package/dist/reality/receipt-generator.js.map +1 -0
  279. package/dist/reality/runtime-tracer.d.ts +75 -0
  280. package/dist/reality/runtime-tracer.d.ts.map +1 -0
  281. package/dist/reality/runtime-tracer.js +109 -0
  282. package/dist/reality/runtime-tracer.js.map +1 -0
  283. package/dist/runtime/auth-utils.d.ts +43 -0
  284. package/dist/runtime/auth-utils.d.ts.map +1 -0
  285. package/dist/runtime/auth-utils.js +130 -0
  286. package/dist/runtime/auth-utils.js.map +1 -0
  287. package/dist/runtime/cli-errors.d.ts +38 -0
  288. package/dist/runtime/cli-errors.d.ts.map +1 -0
  289. package/dist/runtime/cli-errors.js +354 -0
  290. package/dist/runtime/cli-errors.js.map +1 -0
  291. package/dist/runtime/client.d.ts +74 -0
  292. package/dist/runtime/client.d.ts.map +1 -0
  293. package/dist/runtime/client.js +222 -0
  294. package/dist/runtime/client.js.map +1 -0
  295. package/dist/runtime/creds.d.ts +48 -0
  296. package/dist/runtime/creds.d.ts.map +1 -0
  297. package/dist/runtime/creds.js +245 -0
  298. package/dist/runtime/creds.js.map +1 -0
  299. package/dist/runtime/exit-codes.d.ts +49 -0
  300. package/dist/runtime/exit-codes.d.ts.map +1 -0
  301. package/dist/runtime/exit-codes.js +93 -0
  302. package/dist/runtime/exit-codes.js.map +1 -0
  303. package/dist/runtime/index.d.ts +9 -0
  304. package/dist/runtime/index.d.ts.map +1 -0
  305. package/dist/runtime/index.js +25 -0
  306. package/dist/runtime/index.js.map +1 -0
  307. package/dist/runtime/json-output.d.ts +42 -0
  308. package/dist/runtime/json-output.d.ts.map +1 -0
  309. package/dist/runtime/json-output.js +59 -0
  310. package/dist/runtime/json-output.js.map +1 -0
  311. package/dist/runtime/owner-mode.d.ts +48 -0
  312. package/dist/runtime/owner-mode.d.ts.map +1 -0
  313. package/dist/runtime/owner-mode.js +284 -0
  314. package/dist/runtime/owner-mode.js.map +1 -0
  315. package/dist/runtime/semver.d.ts +37 -0
  316. package/dist/runtime/semver.d.ts.map +1 -0
  317. package/dist/runtime/semver.js +110 -0
  318. package/dist/runtime/semver.js.map +1 -0
  319. package/dist/scan/dead-ui-detector.d.ts +48 -0
  320. package/dist/scan/dead-ui-detector.d.ts.map +1 -0
  321. package/dist/scan/dead-ui-detector.js +170 -0
  322. package/dist/scan/dead-ui-detector.js.map +1 -0
  323. package/dist/scan/playwright-sweep.d.ts +40 -0
  324. package/dist/scan/playwright-sweep.d.ts.map +1 -0
  325. package/dist/scan/playwright-sweep.js +216 -0
  326. package/dist/scan/playwright-sweep.js.map +1 -0
  327. package/dist/scan/proof-bundle.d.ts +25 -0
  328. package/dist/scan/proof-bundle.d.ts.map +1 -0
  329. package/dist/scan/proof-bundle.js +203 -0
  330. package/dist/scan/proof-bundle.js.map +1 -0
  331. package/dist/scan/proof-graph.d.ts +59 -0
  332. package/dist/scan/proof-graph.d.ts.map +1 -0
  333. package/dist/scan/proof-graph.js +64 -0
  334. package/dist/scan/proof-graph.js.map +1 -0
  335. package/dist/scan/reality-sniff.d.ts +56 -0
  336. package/dist/scan/reality-sniff.d.ts.map +1 -0
  337. package/dist/scan/reality-sniff.js +200 -0
  338. package/dist/scan/reality-sniff.js.map +1 -0
  339. package/dist/scan/structural-verifier.d.ts +20 -0
  340. package/dist/scan/structural-verifier.d.ts.map +1 -0
  341. package/dist/scan/structural-verifier.js +112 -0
  342. package/dist/scan/structural-verifier.js.map +1 -0
  343. package/dist/scan/verification-engine.d.ts +47 -0
  344. package/dist/scan/verification-engine.d.ts.map +1 -0
  345. package/dist/scan/verification-engine.js +141 -0
  346. package/dist/scan/verification-engine.js.map +1 -0
  347. package/dist/scanner/baseline.d.ts +52 -0
  348. package/dist/scanner/baseline.d.ts.map +1 -0
  349. package/dist/scanner/baseline.js +85 -0
  350. package/dist/scanner/baseline.js.map +1 -0
  351. package/dist/scanner/incremental.d.ts +30 -0
  352. package/dist/scanner/incremental.d.ts.map +1 -0
  353. package/dist/scanner/incremental.js +82 -0
  354. package/dist/scanner/incremental.js.map +1 -0
  355. package/dist/scanner/index.d.ts +8 -0
  356. package/dist/scanner/index.d.ts.map +1 -0
  357. package/dist/scanner/index.js +15 -0
  358. package/dist/scanner/index.js.map +1 -0
  359. package/dist/scanner/parallel.d.ts +43 -0
  360. package/dist/scanner/parallel.d.ts.map +1 -0
  361. package/dist/scanner/parallel.js +99 -0
  362. package/dist/scanner/parallel.js.map +1 -0
  363. package/dist/scanner/placeholder-detector.d.ts +56 -0
  364. package/dist/scanner/placeholder-detector.d.ts.map +1 -0
  365. package/dist/scanner/placeholder-detector.js +220 -0
  366. package/dist/scanner/placeholder-detector.js.map +1 -0
  367. package/dist/scanner/route-detector.d.ts +100 -0
  368. package/dist/scanner/route-detector.d.ts.map +1 -0
  369. package/dist/scanner/route-detector.js +455 -0
  370. package/dist/scanner/route-detector.js.map +1 -0
  371. package/dist/scanner/scoring.d.ts +67 -0
  372. package/dist/scanner/scoring.d.ts.map +1 -0
  373. package/dist/scanner/scoring.js +284 -0
  374. package/dist/scanner/scoring.js.map +1 -0
  375. package/dist/ship-baseline.d.ts +56 -0
  376. package/dist/ship-baseline.d.ts.map +1 -0
  377. package/dist/ship-baseline.js +194 -0
  378. package/dist/ship-baseline.js.map +1 -0
  379. package/dist/ship-config.d.ts +91 -0
  380. package/dist/ship-config.d.ts.map +1 -0
  381. package/dist/ship-config.js +133 -0
  382. package/dist/ship-config.js.map +1 -0
  383. package/dist/ship-data-loader.d.ts +70 -0
  384. package/dist/ship-data-loader.d.ts.map +1 -0
  385. package/dist/ship-data-loader.js +301 -0
  386. package/dist/ship-data-loader.js.map +1 -0
  387. package/dist/standalone.d.ts +1 -0
  388. package/dist/standalone.d.ts.map +1 -0
  389. package/dist/standalone.js +1 -0
  390. package/dist/standalone.js.map +1 -0
  391. package/dist/truth-pack/index.d.ts +102 -0
  392. package/dist/truth-pack/index.d.ts.map +1 -0
  393. package/dist/truth-pack/index.js +694 -0
  394. package/dist/truth-pack/index.js.map +1 -0
  395. package/dist/ui/frame.d.ts +68 -0
  396. package/dist/ui/frame.d.ts.map +1 -0
  397. package/dist/ui/frame.js +165 -0
  398. package/dist/ui/frame.js.map +1 -0
  399. package/dist/ui/index.d.ts +5 -0
  400. package/dist/ui/index.d.ts.map +1 -0
  401. package/dist/ui/index.js +16 -0
  402. package/dist/ui/index.js.map +1 -0
  403. package/dist/ui.d.ts +36 -0
  404. package/dist/ui.d.ts.map +1 -0
  405. package/dist/ui.js +45 -0
  406. package/dist/ui.js.map +1 -0
  407. package/dist/utils/ai-helpers.d.ts +72 -0
  408. package/dist/utils/ai-helpers.d.ts.map +1 -0
  409. package/dist/utils/ai-helpers.js +339 -0
  410. package/dist/utils/ai-helpers.js.map +1 -0
  411. package/dist/utils/validation.d.ts +34 -0
  412. package/dist/utils/validation.d.ts.map +1 -0
  413. package/dist/utils/validation.js +160 -0
  414. package/dist/utils/validation.js.map +1 -0
  415. package/package.json +66 -0
@@ -0,0 +1,694 @@
1
+ "use strict";
2
+ /**
3
+ * Truth Pack Generator
4
+ *
5
+ * Creates the relationship infrastructure that makes AI dependent on repo-truth.
6
+ * This is the moat - installed once, used 500x/day.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.TruthPackGenerator = void 0;
10
+ const fs_1 = require("fs");
11
+ const path_1 = require("path");
12
+ const child_process_1 = require("child_process");
13
+ const TRUTH_PACK_DIR = '.guardrail-context';
14
+ class TruthPackGenerator {
15
+ constructor(projectPath) {
16
+ this.projectPath = (0, path_1.resolve)(projectPath);
17
+ this.truthPackPath = (0, path_1.join)(this.projectPath, TRUTH_PACK_DIR);
18
+ }
19
+ /**
20
+ * Generate complete Truth Pack
21
+ */
22
+ async generate() {
23
+ // Ensure directory exists
24
+ if (!(0, fs_1.existsSync)(this.truthPackPath)) {
25
+ (0, fs_1.mkdirSync)(this.truthPackPath, { recursive: true });
26
+ }
27
+ // Detect stack
28
+ const stack = this.detectStack();
29
+ // Generate all components
30
+ const [symbols, deps, graph, routes, risk, importance, patterns, antipatterns, vulnerabilities] = await Promise.all([
31
+ this.generateSymbols(),
32
+ this.generateDependencies(),
33
+ this.generateImportGraph(),
34
+ this.generateRoutes(),
35
+ this.generateRiskTags(),
36
+ this.generateImportance(),
37
+ this.generatePatterns(),
38
+ this.generateAntipatterns(),
39
+ this.generateVulnerabilities(),
40
+ ]);
41
+ // Generate metadata
42
+ const metadata = this.generateMetadata();
43
+ // Create Truth Pack
44
+ const truthPack = {
45
+ version: '1.0.0',
46
+ generatedAt: new Date().toISOString(),
47
+ projectPath: this.projectPath,
48
+ stack,
49
+ metadata,
50
+ };
51
+ // Write all files
52
+ (0, fs_1.writeFileSync)((0, path_1.join)(this.truthPackPath, 'truthpack.json'), JSON.stringify(truthPack, null, 2));
53
+ (0, fs_1.writeFileSync)((0, path_1.join)(this.truthPackPath, 'symbols.json'), JSON.stringify(symbols, null, 2));
54
+ (0, fs_1.writeFileSync)((0, path_1.join)(this.truthPackPath, 'deps.json'), JSON.stringify(deps, null, 2));
55
+ (0, fs_1.writeFileSync)((0, path_1.join)(this.truthPackPath, 'graph.json'), JSON.stringify(graph, null, 2));
56
+ (0, fs_1.writeFileSync)((0, path_1.join)(this.truthPackPath, 'routes.json'), JSON.stringify(routes, null, 2));
57
+ (0, fs_1.writeFileSync)((0, path_1.join)(this.truthPackPath, 'risk.json'), JSON.stringify(risk, null, 2));
58
+ (0, fs_1.writeFileSync)((0, path_1.join)(this.truthPackPath, 'importance.json'), JSON.stringify(importance, null, 2));
59
+ (0, fs_1.writeFileSync)((0, path_1.join)(this.truthPackPath, 'patterns.json'), JSON.stringify(patterns, null, 2));
60
+ (0, fs_1.writeFileSync)((0, path_1.join)(this.truthPackPath, 'antipatterns.json'), JSON.stringify(antipatterns, null, 2));
61
+ (0, fs_1.writeFileSync)((0, path_1.join)(this.truthPackPath, 'vulnerabilities.json'), JSON.stringify(vulnerabilities, null, 2));
62
+ return truthPack;
63
+ }
64
+ /**
65
+ * Check if Truth Pack exists and is fresh
66
+ */
67
+ isFresh(maxAgeHours = 24) {
68
+ const truthPackFile = (0, path_1.join)(this.truthPackPath, 'truthpack.json');
69
+ if (!(0, fs_1.existsSync)(truthPackFile)) {
70
+ return false;
71
+ }
72
+ try {
73
+ const content = JSON.parse((0, fs_1.readFileSync)(truthPackFile, 'utf-8'));
74
+ const generatedAt = new Date(content.generatedAt);
75
+ const ageHours = (Date.now() - generatedAt.getTime()) / (1000 * 60 * 60);
76
+ return ageHours < maxAgeHours;
77
+ }
78
+ catch {
79
+ return false;
80
+ }
81
+ }
82
+ /**
83
+ * Get Truth Pack path
84
+ */
85
+ getPath() {
86
+ return this.truthPackPath;
87
+ }
88
+ detectStack() {
89
+ const packageJsonPath = (0, path_1.join)(this.projectPath, 'package.json');
90
+ const hasPackageJson = (0, fs_1.existsSync)(packageJsonPath);
91
+ let framework = 'unknown';
92
+ let language = 'unknown';
93
+ let packageManager = 'unknown';
94
+ let runtime;
95
+ if (hasPackageJson) {
96
+ try {
97
+ const pkg = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, 'utf-8'));
98
+ // Detect framework
99
+ if (pkg.dependencies?.['next'])
100
+ framework = 'nextjs';
101
+ else if (pkg.dependencies?.['react'])
102
+ framework = 'react';
103
+ else if (pkg.dependencies?.['vue'])
104
+ framework = 'vue';
105
+ else if (pkg.dependencies?.['@nestjs/core'])
106
+ framework = 'nestjs';
107
+ else if (pkg.dependencies?.['express'])
108
+ framework = 'express';
109
+ else if (pkg.dependencies?.['fastify'])
110
+ framework = 'fastify';
111
+ else if (pkg.dependencies?.['@angular/core'])
112
+ framework = 'angular';
113
+ // Detect package manager
114
+ if ((0, fs_1.existsSync)((0, path_1.join)(this.projectPath, 'pnpm-lock.yaml')))
115
+ packageManager = 'pnpm';
116
+ else if ((0, fs_1.existsSync)((0, path_1.join)(this.projectPath, 'yarn.lock')))
117
+ packageManager = 'yarn';
118
+ else if ((0, fs_1.existsSync)((0, path_1.join)(this.projectPath, 'package-lock.json')))
119
+ packageManager = 'npm';
120
+ // Detect runtime
121
+ if (pkg.engines?.node)
122
+ runtime = `node ${pkg.engines.node}`;
123
+ }
124
+ catch {
125
+ // Ignore
126
+ }
127
+ }
128
+ // Detect language from files
129
+ const tsConfigPath = (0, path_1.join)(this.projectPath, 'tsconfig.json');
130
+ if ((0, fs_1.existsSync)(tsConfigPath)) {
131
+ language = 'typescript';
132
+ }
133
+ else {
134
+ // Check for .js files
135
+ try {
136
+ const result = (0, child_process_1.execSync)('find . -name "*.js" -type f | head -1', { cwd: this.projectPath, encoding: 'utf-8' });
137
+ if (result.trim())
138
+ language = 'javascript';
139
+ }
140
+ catch {
141
+ // Ignore
142
+ }
143
+ }
144
+ return { framework, language, packageManager, runtime };
145
+ }
146
+ async generateSymbols() {
147
+ const symbols = [];
148
+ const codeFiles = await this.findCodeFiles(['.ts', '.tsx', '.js', '.jsx']);
149
+ for (const file of codeFiles) {
150
+ try {
151
+ const content = (0, fs_1.readFileSync)(file, 'utf-8');
152
+ const relativePath = file.replace(this.projectPath + '/', '');
153
+ // Extract exports using regex (fallback if TypeScript API not available)
154
+ const exportPatterns = [
155
+ /export\s+(?:async\s+)?function\s+(\w+)/g,
156
+ /export\s+(?:default\s+)?class\s+(\w+)/g,
157
+ /export\s+(?:default\s+)?(?:const|let|var)\s+(\w+)/g,
158
+ /export\s+interface\s+(\w+)/g,
159
+ /export\s+type\s+(\w+)/g,
160
+ /export\s+enum\s+(\w+)/g,
161
+ ];
162
+ const lines = content.split('\n');
163
+ lines.forEach((line, index) => {
164
+ for (const pattern of exportPatterns) {
165
+ const match = pattern.exec(line);
166
+ if (match) {
167
+ const name = match[1];
168
+ let type = 'function';
169
+ if (line.includes('class'))
170
+ type = 'class';
171
+ else if (line.includes('interface'))
172
+ type = 'interface';
173
+ else if (line.includes('type'))
174
+ type = 'type';
175
+ else if (line.includes('enum'))
176
+ type = 'enum';
177
+ else if (line.includes('const') || line.includes('let') || line.includes('var'))
178
+ type = 'variable';
179
+ symbols.push({
180
+ name,
181
+ type,
182
+ file: relativePath,
183
+ line: index + 1,
184
+ exported: true,
185
+ signature: this.extractSignature(line, content, index),
186
+ doc: this.extractDoc(content, index),
187
+ });
188
+ }
189
+ }
190
+ });
191
+ }
192
+ catch {
193
+ // Ignore files we can't read
194
+ }
195
+ }
196
+ return symbols;
197
+ }
198
+ extractSignature(line, content, lineIndex) {
199
+ // Extract function/class signature
200
+ const lines = content.split('\n');
201
+ let signature = line.trim();
202
+ // If line ends with {, get more lines
203
+ if (signature.endsWith('{') || signature.includes('=>')) {
204
+ let i = lineIndex;
205
+ while (i < lines.length - 1 && !signature.includes('{') && !signature.includes('=>')) {
206
+ i++;
207
+ signature += ' ' + lines[i].trim();
208
+ if (signature.length > 200)
209
+ break; // Limit length
210
+ }
211
+ }
212
+ return signature.length > 200 ? signature.substring(0, 200) + '...' : signature;
213
+ }
214
+ extractDoc(content, lineIndex) {
215
+ const lines = content.split('\n');
216
+ const docLines = [];
217
+ // Look backwards for JSDoc comments
218
+ for (let i = lineIndex - 1; i >= 0 && i >= lineIndex - 10; i--) {
219
+ const line = lines[i].trim();
220
+ if (line.startsWith('*') || line.startsWith('/**') || line.startsWith('//')) {
221
+ docLines.unshift(line.replace(/^\s*[*\/]+\s*/, ''));
222
+ }
223
+ else if (line.length > 0 && !line.startsWith('*')) {
224
+ break;
225
+ }
226
+ }
227
+ return docLines.length > 0 ? docLines.join(' ').substring(0, 200) : undefined;
228
+ }
229
+ async findCodeFiles(extensions) {
230
+ const files = [];
231
+ const exclude = ['node_modules', '.git', 'dist', 'build', '.next'];
232
+ const walk = (dir, depth = 0) => {
233
+ if (depth > 10)
234
+ return; // Limit depth
235
+ try {
236
+ const entries = (0, fs_1.readdirSync)(dir);
237
+ for (const entry of entries) {
238
+ const fullPath = (0, path_1.join)(dir, entry);
239
+ const stat = (0, fs_1.statSync)(fullPath);
240
+ if (stat.isDirectory()) {
241
+ if (!exclude.some(e => entry.includes(e))) {
242
+ walk(fullPath, depth + 1);
243
+ }
244
+ }
245
+ else if (stat.isFile()) {
246
+ const ext = (0, path_1.extname)(entry);
247
+ if (extensions.includes(ext)) {
248
+ files.push(fullPath);
249
+ }
250
+ }
251
+ }
252
+ }
253
+ catch {
254
+ // Ignore errors
255
+ }
256
+ };
257
+ walk(this.projectPath);
258
+ return files;
259
+ }
260
+ async generateDependencies() {
261
+ const packageJsonPath = (0, path_1.join)(this.projectPath, 'package.json');
262
+ if (!(0, fs_1.existsSync)(packageJsonPath)) {
263
+ return [];
264
+ }
265
+ try {
266
+ const pkg = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, 'utf-8'));
267
+ const deps = [];
268
+ // Production dependencies
269
+ if (pkg.dependencies) {
270
+ for (const [name, version] of Object.entries(pkg.dependencies)) {
271
+ deps.push({
272
+ name,
273
+ version: version,
274
+ type: 'production',
275
+ registry: 'npm',
276
+ });
277
+ }
278
+ }
279
+ // Dev dependencies
280
+ if (pkg.devDependencies) {
281
+ for (const [name, version] of Object.entries(pkg.devDependencies)) {
282
+ deps.push({
283
+ name,
284
+ version: version,
285
+ type: 'dev',
286
+ registry: 'npm',
287
+ });
288
+ }
289
+ }
290
+ return deps;
291
+ }
292
+ catch {
293
+ return [];
294
+ }
295
+ }
296
+ async generateImportGraph() {
297
+ const graph = {};
298
+ const codeFiles = await this.findCodeFiles(['.ts', '.tsx', '.js', '.jsx']);
299
+ for (const file of codeFiles) {
300
+ try {
301
+ const content = (0, fs_1.readFileSync)(file, 'utf-8');
302
+ const relativePath = file.replace(this.projectPath + '/', '');
303
+ const imports = [];
304
+ // Extract imports
305
+ const importPatterns = [
306
+ /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g,
307
+ /require\s*\(['"]([^'"]+)['"]\)/g,
308
+ ];
309
+ for (const pattern of importPatterns) {
310
+ let match;
311
+ while ((match = pattern.exec(content)) !== null) {
312
+ const importPath = match[1];
313
+ // Only track internal imports (relative paths)
314
+ if (importPath.startsWith('.') || importPath.startsWith('/')) {
315
+ imports.push(importPath);
316
+ }
317
+ }
318
+ }
319
+ if (imports.length > 0) {
320
+ graph[relativePath] = imports;
321
+ }
322
+ }
323
+ catch {
324
+ // Ignore files we can't read
325
+ }
326
+ }
327
+ return graph;
328
+ }
329
+ async generateRoutes() {
330
+ const routes = [];
331
+ const codeFiles = await this.findCodeFiles(['.ts', '.tsx', '.js', '.jsx']);
332
+ for (const file of codeFiles) {
333
+ try {
334
+ const content = (0, fs_1.readFileSync)(file, 'utf-8');
335
+ const relativePath = file.replace(this.projectPath + '/', '');
336
+ const lines = content.split('\n');
337
+ // Express/Fastify routes: app.get('/path', handler) or fastify.get('/path', handler)
338
+ const expressPattern = /(?:app|router|fastify)\.(get|post|put|delete|patch|options|head)\s*\(\s*['"`]([^'"`]+)['"`]/gi;
339
+ let match;
340
+ while ((match = expressPattern.exec(content)) !== null) {
341
+ const lineNum = content.substring(0, match.index).split('\n').length;
342
+ routes.push({
343
+ path: match[2],
344
+ method: match[1].toUpperCase(),
345
+ file: relativePath,
346
+ line: lineNum,
347
+ handler: this.extractHandlerName(content, match.index),
348
+ auth: this.hasAuth(content, lineNum),
349
+ middleware: this.extractMiddleware(content, lineNum),
350
+ params: this.extractParams(match[2]),
351
+ });
352
+ }
353
+ // Next.js API routes: export async function GET/POST/etc
354
+ if (file.includes('/api/') || file.includes('/route.')) {
355
+ const nextPattern = /export\s+(?:async\s+)?function\s+(GET|POST|PUT|DELETE|PATCH|OPTIONS|HEAD)\s*\(/gi;
356
+ while ((match = nextPattern.exec(content)) !== null) {
357
+ const lineNum = content.substring(0, match.index).split('\n').length;
358
+ const routePath = this.extractNextJSRoutePath(file);
359
+ routes.push({
360
+ path: routePath,
361
+ method: match[1],
362
+ file: relativePath,
363
+ line: lineNum,
364
+ handler: match[1],
365
+ auth: this.hasAuth(content, lineNum),
366
+ middleware: [],
367
+ params: this.extractParams(routePath),
368
+ });
369
+ }
370
+ }
371
+ }
372
+ catch {
373
+ // Ignore files we can't read
374
+ }
375
+ }
376
+ return routes;
377
+ }
378
+ extractHandlerName(content, index) {
379
+ // Extract handler function name from route definition
380
+ const afterMatch = content.substring(index);
381
+ const handlerMatch = afterMatch.match(/,\s*(\w+)\s*\)/);
382
+ return handlerMatch ? handlerMatch[1] : 'anonymous';
383
+ }
384
+ hasAuth(content, lineNum) {
385
+ const lines = content.split('\n');
386
+ const context = lines.slice(Math.max(0, lineNum - 10), lineNum + 5).join('\n');
387
+ return /auth|authenticate|requireAuth|isAuthenticated|middleware.*auth/i.test(context);
388
+ }
389
+ extractMiddleware(content, lineNum) {
390
+ const lines = content.split('\n');
391
+ const context = lines.slice(Math.max(0, lineNum - 10), lineNum + 5).join('\n');
392
+ const middleware = [];
393
+ if (/cors/i.test(context))
394
+ middleware.push('cors');
395
+ if (/helmet/i.test(context))
396
+ middleware.push('helmet');
397
+ if (/rateLimit/i.test(context))
398
+ middleware.push('rateLimit');
399
+ if (/validate|zod/i.test(context))
400
+ middleware.push('validation');
401
+ return middleware;
402
+ }
403
+ extractParams(path) {
404
+ // Extract path parameters like :id or [id]
405
+ const params = [];
406
+ const paramPattern = /[:[](\w+)[\]}]/g;
407
+ let match;
408
+ while ((match = paramPattern.exec(path)) !== null) {
409
+ params.push(match[1]);
410
+ }
411
+ return params;
412
+ }
413
+ extractNextJSRoutePath(filePath) {
414
+ // Convert /app/api/users/route.ts to /api/users
415
+ const apiMatch = filePath.match(/\/api\/(.+?)\/route\.(ts|tsx|js|jsx)$/);
416
+ if (apiMatch) {
417
+ return `/api/${apiMatch[1]}`;
418
+ }
419
+ // Convert /pages/api/users.ts to /api/users
420
+ const pagesMatch = filePath.match(/\/pages\/api\/(.+?)\.(ts|tsx|js|jsx)$/);
421
+ if (pagesMatch) {
422
+ return `/api/${pagesMatch[1]}`;
423
+ }
424
+ return '/api/unknown';
425
+ }
426
+ async generateRiskTags() {
427
+ const riskTags = [];
428
+ const codeFiles = await this.findCodeFiles(['.ts', '.tsx', '.js', '.jsx']);
429
+ for (const file of codeFiles) {
430
+ try {
431
+ const content = (0, fs_1.readFileSync)(file, 'utf-8');
432
+ const relativePath = file.replace(this.projectPath + '/', '');
433
+ const lines = content.split('\n');
434
+ lines.forEach((line, index) => {
435
+ const lineNum = index + 1;
436
+ // Auth risk
437
+ if (/password|token|jwt|session|auth|login|signin/i.test(line) &&
438
+ /process\.env|hardcoded|secret|key/i.test(line)) {
439
+ riskTags.push({
440
+ file: relativePath,
441
+ line: lineNum,
442
+ category: 'auth',
443
+ severity: 'critical',
444
+ description: 'Potential auth credential exposure',
445
+ });
446
+ }
447
+ // Payment risk
448
+ if (/stripe|payment|billing|charge|subscription|card|credit/i.test(line) &&
449
+ !line.includes('//') && !line.includes('test')) {
450
+ riskTags.push({
451
+ file: relativePath,
452
+ line: lineNum,
453
+ category: 'payment',
454
+ severity: 'high',
455
+ description: 'Payment processing detected',
456
+ });
457
+ }
458
+ // Database risk
459
+ if (/sql|query|database|db\.|prisma\.|mongoose\.|sequelize/i.test(line) &&
460
+ /SELECT|INSERT|UPDATE|DELETE|DROP/i.test(line.toUpperCase())) {
461
+ riskTags.push({
462
+ file: relativePath,
463
+ line: lineNum,
464
+ category: 'database',
465
+ severity: 'high',
466
+ description: 'Database operation detected',
467
+ });
468
+ }
469
+ // Security risk
470
+ if (/eval|exec|dangerouslySetInnerHTML|innerHTML|document\.write/i.test(line)) {
471
+ riskTags.push({
472
+ file: relativePath,
473
+ line: lineNum,
474
+ category: 'security',
475
+ severity: 'critical',
476
+ description: 'Potentially dangerous operation',
477
+ });
478
+ }
479
+ // Sensitive data
480
+ if (/ssn|social.*security|credit.*card|bank.*account|routing/i.test(line)) {
481
+ riskTags.push({
482
+ file: relativePath,
483
+ line: lineNum,
484
+ category: 'sensitive',
485
+ severity: 'critical',
486
+ description: 'Sensitive data handling detected',
487
+ });
488
+ }
489
+ });
490
+ }
491
+ catch {
492
+ // Ignore files we can't read
493
+ }
494
+ }
495
+ return riskTags;
496
+ }
497
+ async generateImportance() {
498
+ const importance = {};
499
+ // Get risk tags and import graph
500
+ const [riskTags, importGraph] = await Promise.all([
501
+ this.generateRiskTags(),
502
+ this.generateImportGraph(),
503
+ ]);
504
+ // Calculate centrality (how many files import this file)
505
+ const centrality = {};
506
+ for (const [file, imports] of Object.entries(importGraph)) {
507
+ centrality[file] = imports.length;
508
+ }
509
+ // Count how many files import each file
510
+ for (const imports of Object.values(importGraph)) {
511
+ for (const imp of imports) {
512
+ // Resolve import path to actual file
513
+ const resolvedFile = this.resolveImportPath(imp);
514
+ if (resolvedFile) {
515
+ centrality[resolvedFile] = (centrality[resolvedFile] || 0) + 1;
516
+ }
517
+ }
518
+ }
519
+ // Calculate importance = risk score × centrality
520
+ const riskByFile = {};
521
+ riskTags.forEach(tag => {
522
+ const riskScore = tag.severity === 'critical' ? 10 : tag.severity === 'high' ? 5 : tag.severity === 'medium' ? 2 : 1;
523
+ riskByFile[tag.file] = (riskByFile[tag.file] || 0) + riskScore;
524
+ });
525
+ // Combine risk and centrality
526
+ const allFiles = new Set([...Object.keys(centrality), ...Object.keys(riskByFile)]);
527
+ allFiles.forEach(file => {
528
+ const risk = riskByFile[file] || 1;
529
+ const cent = centrality[file] || 1;
530
+ importance[file] = risk * Math.log(cent + 1); // Log scale for centrality
531
+ });
532
+ return importance;
533
+ }
534
+ resolveImportPath(importPath) {
535
+ // Simple resolution - in production, would need proper module resolution
536
+ if (importPath.startsWith('.')) {
537
+ // Relative import - would need to resolve from importing file
538
+ return null;
539
+ }
540
+ return null; // External imports don't count
541
+ }
542
+ async generatePatterns() {
543
+ const patterns = [];
544
+ const codeFiles = await this.findCodeFiles(['.ts', '.tsx', '.js', '.jsx']);
545
+ // Look for common patterns (error handling, API structure, etc.)
546
+ for (const file of codeFiles) {
547
+ try {
548
+ const content = (0, fs_1.readFileSync)(file, 'utf-8');
549
+ const relativePath = file.replace(this.projectPath + '/', '');
550
+ // Error handling pattern
551
+ if (/try\s*\{[\s\S]*catch\s*\([\s\S]*\)\s*\{[\s\S]*\}/.test(content) &&
552
+ !content.includes('catch () {}') && // Not empty catch
553
+ content.includes('throw') || content.includes('error')) {
554
+ patterns.push({
555
+ name: 'Proper Error Handling',
556
+ type: 'golden',
557
+ file: relativePath,
558
+ line: 1,
559
+ description: 'Uses try-catch with proper error propagation',
560
+ });
561
+ }
562
+ // Type safety pattern
563
+ if (file.endsWith('.ts') && /:\s*\w+[\[\]<>]/.test(content)) {
564
+ patterns.push({
565
+ name: 'Type Safety',
566
+ type: 'golden',
567
+ file: relativePath,
568
+ line: 1,
569
+ description: 'Uses TypeScript type annotations',
570
+ });
571
+ }
572
+ }
573
+ catch {
574
+ // Ignore
575
+ }
576
+ }
577
+ return patterns;
578
+ }
579
+ async generateAntipatterns() {
580
+ const antipatterns = [];
581
+ const codeFiles = await this.findCodeFiles(['.ts', '.tsx', '.js', '.jsx']);
582
+ for (const file of codeFiles) {
583
+ try {
584
+ const content = (0, fs_1.readFileSync)(file, 'utf-8');
585
+ const relativePath = file.replace(this.projectPath + '/', '');
586
+ const lines = content.split('\n');
587
+ lines.forEach((line, index) => {
588
+ // Empty catch
589
+ if (/catch\s*\([^)]*\)\s*\{\s*\}/.test(line)) {
590
+ antipatterns.push({
591
+ name: 'Empty Catch Block',
592
+ type: 'antipattern',
593
+ file: relativePath,
594
+ line: index + 1,
595
+ description: 'Swallows errors silently',
596
+ });
597
+ }
598
+ // Console.log in production
599
+ if (/console\.(log|error|warn)/.test(line) && !file.includes('test')) {
600
+ antipatterns.push({
601
+ name: 'Console in Production',
602
+ type: 'antipattern',
603
+ file: relativePath,
604
+ line: index + 1,
605
+ description: 'Console statements should use proper logging',
606
+ });
607
+ }
608
+ // Any types
609
+ if (/: any/.test(line)) {
610
+ antipatterns.push({
611
+ name: 'Any Type Usage',
612
+ type: 'antipattern',
613
+ file: relativePath,
614
+ line: index + 1,
615
+ description: 'Avoid any types for type safety',
616
+ });
617
+ }
618
+ });
619
+ }
620
+ catch {
621
+ // Ignore
622
+ }
623
+ }
624
+ return antipatterns;
625
+ }
626
+ async generateVulnerabilities() {
627
+ const vulnerabilities = [];
628
+ // Check dependencies for known vulnerabilities
629
+ const deps = await this.generateDependencies();
630
+ // TODO: Integrate with OSV API or vulnerability database
631
+ // For now, check for known vulnerable packages
632
+ const knownVulnerable = [
633
+ 'lodash@4.17.20', // Example
634
+ ];
635
+ deps.forEach(dep => {
636
+ const depKey = `${dep.name}@${dep.version}`;
637
+ if (knownVulnerable.some(v => depKey.includes(v))) {
638
+ vulnerabilities.push({
639
+ package: dep.name,
640
+ version: dep.version,
641
+ severity: 'high',
642
+ description: 'Known vulnerability',
643
+ });
644
+ }
645
+ });
646
+ return vulnerabilities;
647
+ }
648
+ generateMetadata() {
649
+ let fileCount = 0;
650
+ let lineCount = 0;
651
+ let totalSize = 0;
652
+ const countFiles = (dir, depth = 0) => {
653
+ if (depth > 10)
654
+ return;
655
+ try {
656
+ const entries = (0, fs_1.readdirSync)(dir);
657
+ for (const entry of entries) {
658
+ const fullPath = (0, path_1.join)(dir, entry);
659
+ const stat = (0, fs_1.statSync)(fullPath);
660
+ if (stat.isDirectory()) {
661
+ if (!['node_modules', '.git', 'dist', 'build', '.next'].some(e => entry.includes(e))) {
662
+ countFiles(fullPath, depth + 1);
663
+ }
664
+ }
665
+ else if (stat.isFile()) {
666
+ fileCount++;
667
+ totalSize += stat.size;
668
+ // Count lines for code files
669
+ if (['.ts', '.tsx', '.js', '.jsx', '.py', '.java'].includes((0, path_1.extname)(entry))) {
670
+ try {
671
+ const content = (0, fs_1.readFileSync)(fullPath, 'utf-8');
672
+ lineCount += content.split('\n').length;
673
+ }
674
+ catch {
675
+ // Ignore
676
+ }
677
+ }
678
+ }
679
+ }
680
+ }
681
+ catch {
682
+ // Ignore errors
683
+ }
684
+ };
685
+ countFiles(this.projectPath);
686
+ return {
687
+ fileCount,
688
+ lineCount,
689
+ totalSize,
690
+ };
691
+ }
692
+ }
693
+ exports.TruthPackGenerator = TruthPackGenerator;
694
+ //# sourceMappingURL=index.js.map