@vibecheckai/cli 3.5.0 → 3.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 (326) hide show
  1. package/bin/registry.js +174 -449
  2. package/bin/runners/cli-utils.js +33 -2
  3. package/bin/runners/context/generators/cursor.js +2 -49
  4. package/bin/runners/context/generators/mcp.js +13 -15
  5. package/bin/runners/context/proof-context.js +1 -248
  6. package/bin/runners/lib/analysis-core.js +180 -198
  7. package/bin/runners/lib/analyzers.js +241 -2212
  8. package/bin/runners/lib/cli-output.js +210 -242
  9. package/bin/runners/lib/detectors-v2.js +785 -547
  10. package/bin/runners/lib/entitlements-v2.js +431 -161
  11. package/bin/runners/lib/error-handler.js +9 -16
  12. package/bin/runners/lib/global-flags.js +0 -37
  13. package/bin/runners/lib/html-proof-report.js +700 -350
  14. package/bin/runners/lib/missions/plan.js +6 -46
  15. package/bin/runners/lib/missions/templates.js +0 -232
  16. package/bin/runners/lib/route-truth.js +322 -1167
  17. package/bin/runners/lib/scan-output.js +467 -493
  18. package/bin/runners/lib/ship-output.js +27 -280
  19. package/bin/runners/lib/terminal-ui.js +700 -310
  20. package/bin/runners/lib/truth.js +321 -1004
  21. package/bin/runners/lib/unified-output.js +158 -162
  22. package/bin/runners/lib/upsell.js +204 -104
  23. package/bin/runners/runAIAgent.js +10 -5
  24. package/bin/runners/runAllowlist.js +324 -0
  25. package/bin/runners/runAuth.js +94 -344
  26. package/bin/runners/runCheckpoint.js +45 -43
  27. package/bin/runners/runContext.js +24 -139
  28. package/bin/runners/runDoctor.js +101 -136
  29. package/bin/runners/runEvidencePack.js +219 -0
  30. package/bin/runners/runFix.js +71 -82
  31. package/bin/runners/runGuard.js +119 -606
  32. package/bin/runners/runInit.js +60 -22
  33. package/bin/runners/runInstall.js +281 -0
  34. package/bin/runners/runLabs.js +341 -0
  35. package/bin/runners/runMcp.js +62 -139
  36. package/bin/runners/runPolish.js +83 -282
  37. package/bin/runners/runPromptFirewall.js +12 -5
  38. package/bin/runners/runProve.js +58 -33
  39. package/bin/runners/runReality.js +58 -81
  40. package/bin/runners/runReport.js +7 -34
  41. package/bin/runners/runRuntime.js +8 -5
  42. package/bin/runners/runScan.js +844 -219
  43. package/bin/runners/runShip.js +59 -721
  44. package/bin/runners/runValidate.js +11 -24
  45. package/bin/runners/runWatch.js +76 -131
  46. package/bin/vibecheck.js +69 -295
  47. package/mcp-server/ARCHITECTURE.md +339 -0
  48. package/mcp-server/__tests__/cache.test.ts +313 -0
  49. package/mcp-server/__tests__/executor.test.ts +239 -0
  50. package/mcp-server/__tests__/fixtures/exclusion-test/.cache/webpack/cache.pack +1 -0
  51. package/mcp-server/__tests__/fixtures/exclusion-test/.next/server/chunk.js +3 -0
  52. package/mcp-server/__tests__/fixtures/exclusion-test/.turbo/cache.json +3 -0
  53. package/mcp-server/__tests__/fixtures/exclusion-test/.venv/lib/env.py +3 -0
  54. package/mcp-server/__tests__/fixtures/exclusion-test/dist/bundle.js +3 -0
  55. package/mcp-server/__tests__/fixtures/exclusion-test/package.json +5 -0
  56. package/mcp-server/__tests__/fixtures/exclusion-test/src/app.ts +5 -0
  57. package/mcp-server/__tests__/fixtures/exclusion-test/venv/lib/config.py +4 -0
  58. package/mcp-server/__tests__/ids.test.ts +345 -0
  59. package/mcp-server/__tests__/integration/tools.test.ts +410 -0
  60. package/mcp-server/__tests__/registry.test.ts +365 -0
  61. package/mcp-server/__tests__/sandbox.test.ts +323 -0
  62. package/mcp-server/__tests__/schemas.test.ts +372 -0
  63. package/mcp-server/benchmarks/run-benchmarks.ts +304 -0
  64. package/mcp-server/examples/doctor.request.json +14 -0
  65. package/mcp-server/examples/doctor.response.json +53 -0
  66. package/mcp-server/examples/error.response.json +15 -0
  67. package/mcp-server/examples/scan.request.json +14 -0
  68. package/mcp-server/examples/scan.response.json +108 -0
  69. package/mcp-server/handlers/tool-handler.ts +671 -0
  70. package/mcp-server/index-v1.js +698 -0
  71. package/mcp-server/index-v3.ts +293 -0
  72. package/mcp-server/index.js +1080 -1757
  73. package/mcp-server/index.old.js +4137 -0
  74. package/mcp-server/lib/cache.ts +341 -0
  75. package/mcp-server/lib/errors.ts +346 -0
  76. package/mcp-server/lib/executor.ts +792 -0
  77. package/mcp-server/lib/ids.ts +238 -0
  78. package/mcp-server/lib/logger.ts +368 -0
  79. package/mcp-server/lib/metrics.ts +365 -0
  80. package/mcp-server/lib/sandbox.ts +337 -0
  81. package/mcp-server/lib/validator.ts +229 -0
  82. package/mcp-server/package-lock.json +165 -0
  83. package/mcp-server/package.json +32 -7
  84. package/mcp-server/premium-tools.js +2 -2
  85. package/mcp-server/registry/tools.json +476 -0
  86. package/mcp-server/schemas/error-envelope.schema.json +125 -0
  87. package/mcp-server/schemas/finding.schema.json +167 -0
  88. package/mcp-server/schemas/report-artifact.schema.json +88 -0
  89. package/mcp-server/schemas/run-request.schema.json +75 -0
  90. package/mcp-server/schemas/verdict.schema.json +168 -0
  91. package/mcp-server/tier-auth.d.ts +71 -0
  92. package/mcp-server/tier-auth.js +371 -183
  93. package/mcp-server/truth-context.js +90 -131
  94. package/mcp-server/truth-firewall-tools.js +1000 -1611
  95. package/mcp-server/tsconfig.json +34 -0
  96. package/mcp-server/vibecheck-tools.js +2 -2
  97. package/mcp-server/vitest.config.ts +16 -0
  98. package/package.json +3 -4
  99. package/bin/runners/lib/agent-firewall/ai/false-positive-analyzer.js +0 -474
  100. package/bin/runners/lib/agent-firewall/change-packet/builder.js +0 -488
  101. package/bin/runners/lib/agent-firewall/change-packet/schema.json +0 -228
  102. package/bin/runners/lib/agent-firewall/change-packet/store.js +0 -200
  103. package/bin/runners/lib/agent-firewall/claims/claim-types.js +0 -21
  104. package/bin/runners/lib/agent-firewall/claims/extractor.js +0 -303
  105. package/bin/runners/lib/agent-firewall/claims/patterns.js +0 -24
  106. package/bin/runners/lib/agent-firewall/critic/index.js +0 -151
  107. package/bin/runners/lib/agent-firewall/critic/judge.js +0 -432
  108. package/bin/runners/lib/agent-firewall/critic/prompts.js +0 -305
  109. package/bin/runners/lib/agent-firewall/evidence/auth-evidence.js +0 -88
  110. package/bin/runners/lib/agent-firewall/evidence/contract-evidence.js +0 -75
  111. package/bin/runners/lib/agent-firewall/evidence/env-evidence.js +0 -127
  112. package/bin/runners/lib/agent-firewall/evidence/resolver.js +0 -102
  113. package/bin/runners/lib/agent-firewall/evidence/route-evidence.js +0 -213
  114. package/bin/runners/lib/agent-firewall/evidence/side-effect-evidence.js +0 -145
  115. package/bin/runners/lib/agent-firewall/fs-hook/daemon.js +0 -19
  116. package/bin/runners/lib/agent-firewall/fs-hook/installer.js +0 -87
  117. package/bin/runners/lib/agent-firewall/fs-hook/watcher.js +0 -184
  118. package/bin/runners/lib/agent-firewall/git-hook/pre-commit.js +0 -163
  119. package/bin/runners/lib/agent-firewall/ide-extension/cursor.js +0 -107
  120. package/bin/runners/lib/agent-firewall/ide-extension/vscode.js +0 -68
  121. package/bin/runners/lib/agent-firewall/ide-extension/windsurf.js +0 -66
  122. package/bin/runners/lib/agent-firewall/interceptor/base.js +0 -304
  123. package/bin/runners/lib/agent-firewall/interceptor/cursor.js +0 -35
  124. package/bin/runners/lib/agent-firewall/interceptor/vscode.js +0 -35
  125. package/bin/runners/lib/agent-firewall/interceptor/windsurf.js +0 -34
  126. package/bin/runners/lib/agent-firewall/lawbook/distributor.js +0 -465
  127. package/bin/runners/lib/agent-firewall/lawbook/evaluator.js +0 -604
  128. package/bin/runners/lib/agent-firewall/lawbook/index.js +0 -304
  129. package/bin/runners/lib/agent-firewall/lawbook/registry.js +0 -514
  130. package/bin/runners/lib/agent-firewall/lawbook/schema.js +0 -420
  131. package/bin/runners/lib/agent-firewall/learning/learning-engine.js +0 -849
  132. package/bin/runners/lib/agent-firewall/logger.js +0 -141
  133. package/bin/runners/lib/agent-firewall/policy/default-policy.json +0 -90
  134. package/bin/runners/lib/agent-firewall/policy/engine.js +0 -103
  135. package/bin/runners/lib/agent-firewall/policy/loader.js +0 -451
  136. package/bin/runners/lib/agent-firewall/policy/rules/auth-drift.js +0 -50
  137. package/bin/runners/lib/agent-firewall/policy/rules/contract-drift.js +0 -50
  138. package/bin/runners/lib/agent-firewall/policy/rules/fake-success.js +0 -86
  139. package/bin/runners/lib/agent-firewall/policy/rules/ghost-env.js +0 -162
  140. package/bin/runners/lib/agent-firewall/policy/rules/ghost-route.js +0 -189
  141. package/bin/runners/lib/agent-firewall/policy/rules/scope.js +0 -93
  142. package/bin/runners/lib/agent-firewall/policy/rules/unsafe-side-effect.js +0 -57
  143. package/bin/runners/lib/agent-firewall/policy/schema.json +0 -183
  144. package/bin/runners/lib/agent-firewall/policy/verdict.js +0 -54
  145. package/bin/runners/lib/agent-firewall/proposal/extractor.js +0 -394
  146. package/bin/runners/lib/agent-firewall/proposal/index.js +0 -212
  147. package/bin/runners/lib/agent-firewall/proposal/schema.js +0 -251
  148. package/bin/runners/lib/agent-firewall/proposal/validator.js +0 -386
  149. package/bin/runners/lib/agent-firewall/reality/index.js +0 -332
  150. package/bin/runners/lib/agent-firewall/reality/state.js +0 -625
  151. package/bin/runners/lib/agent-firewall/reality/watcher.js +0 -322
  152. package/bin/runners/lib/agent-firewall/risk/index.js +0 -173
  153. package/bin/runners/lib/agent-firewall/risk/scorer.js +0 -328
  154. package/bin/runners/lib/agent-firewall/risk/thresholds.js +0 -321
  155. package/bin/runners/lib/agent-firewall/risk/vectors.js +0 -421
  156. package/bin/runners/lib/agent-firewall/simulator/diff-simulator.js +0 -472
  157. package/bin/runners/lib/agent-firewall/simulator/import-resolver.js +0 -346
  158. package/bin/runners/lib/agent-firewall/simulator/index.js +0 -181
  159. package/bin/runners/lib/agent-firewall/simulator/route-validator.js +0 -380
  160. package/bin/runners/lib/agent-firewall/time-machine/incident-correlator.js +0 -661
  161. package/bin/runners/lib/agent-firewall/time-machine/index.js +0 -267
  162. package/bin/runners/lib/agent-firewall/time-machine/replay-engine.js +0 -436
  163. package/bin/runners/lib/agent-firewall/time-machine/state-reconstructor.js +0 -490
  164. package/bin/runners/lib/agent-firewall/time-machine/timeline-builder.js +0 -530
  165. package/bin/runners/lib/agent-firewall/truthpack/index.js +0 -67
  166. package/bin/runners/lib/agent-firewall/truthpack/loader.js +0 -137
  167. package/bin/runners/lib/agent-firewall/unblock/planner.js +0 -337
  168. package/bin/runners/lib/agent-firewall/utils/ignore-checker.js +0 -118
  169. package/bin/runners/lib/api-client.js +0 -269
  170. package/bin/runners/lib/audit-logger.js +0 -532
  171. package/bin/runners/lib/authority/authorities/architecture.js +0 -364
  172. package/bin/runners/lib/authority/authorities/compliance.js +0 -341
  173. package/bin/runners/lib/authority/authorities/human.js +0 -343
  174. package/bin/runners/lib/authority/authorities/quality.js +0 -420
  175. package/bin/runners/lib/authority/authorities/security.js +0 -228
  176. package/bin/runners/lib/authority/index.js +0 -293
  177. package/bin/runners/lib/authority-badge.js +0 -425
  178. package/bin/runners/lib/bundle/bundle-intelligence.js +0 -846
  179. package/bin/runners/lib/cli-charts.js +0 -368
  180. package/bin/runners/lib/cli-config-display.js +0 -405
  181. package/bin/runners/lib/cli-demo.js +0 -275
  182. package/bin/runners/lib/cli-errors.js +0 -438
  183. package/bin/runners/lib/cli-help-formatter.js +0 -439
  184. package/bin/runners/lib/cli-interactive-menu.js +0 -509
  185. package/bin/runners/lib/cli-prompts.js +0 -441
  186. package/bin/runners/lib/cli-scan-cards.js +0 -362
  187. package/bin/runners/lib/compliance-reporter.js +0 -710
  188. package/bin/runners/lib/conductor/index.js +0 -671
  189. package/bin/runners/lib/easy/README.md +0 -123
  190. package/bin/runners/lib/easy/index.js +0 -140
  191. package/bin/runners/lib/easy/interactive-wizard.js +0 -788
  192. package/bin/runners/lib/easy/one-click-firewall.js +0 -564
  193. package/bin/runners/lib/easy/zero-config-reality.js +0 -714
  194. package/bin/runners/lib/engines/accessibility-engine.js +0 -390
  195. package/bin/runners/lib/engines/api-consistency-engine.js +0 -467
  196. package/bin/runners/lib/engines/ast-cache.js +0 -99
  197. package/bin/runners/lib/engines/async-patterns-engine.js +0 -444
  198. package/bin/runners/lib/engines/bundle-size-engine.js +0 -433
  199. package/bin/runners/lib/engines/code-quality-engine.js +0 -255
  200. package/bin/runners/lib/engines/confidence-scoring.js +0 -276
  201. package/bin/runners/lib/engines/console-logs-engine.js +0 -115
  202. package/bin/runners/lib/engines/context-detection.js +0 -264
  203. package/bin/runners/lib/engines/cross-file-analysis-engine.js +0 -533
  204. package/bin/runners/lib/engines/database-patterns-engine.js +0 -429
  205. package/bin/runners/lib/engines/dead-code-engine.js +0 -198
  206. package/bin/runners/lib/engines/deprecated-api-engine.js +0 -226
  207. package/bin/runners/lib/engines/duplicate-code-engine.js +0 -354
  208. package/bin/runners/lib/engines/empty-catch-engine.js +0 -260
  209. package/bin/runners/lib/engines/env-variables-engine.js +0 -458
  210. package/bin/runners/lib/engines/error-handling-engine.js +0 -437
  211. package/bin/runners/lib/engines/false-positive-prevention.js +0 -630
  212. package/bin/runners/lib/engines/file-filter.js +0 -131
  213. package/bin/runners/lib/engines/framework-adapters/index.js +0 -607
  214. package/bin/runners/lib/engines/framework-detection.js +0 -508
  215. package/bin/runners/lib/engines/hardcoded-secrets-engine.js +0 -251
  216. package/bin/runners/lib/engines/import-order-engine.js +0 -429
  217. package/bin/runners/lib/engines/mock-data-engine.js +0 -315
  218. package/bin/runners/lib/engines/naming-conventions-engine.js +0 -544
  219. package/bin/runners/lib/engines/noise-reduction-engine.js +0 -452
  220. package/bin/runners/lib/engines/orchestrator.js +0 -334
  221. package/bin/runners/lib/engines/parallel-processor.js +0 -71
  222. package/bin/runners/lib/engines/performance-issues-engine.js +0 -405
  223. package/bin/runners/lib/engines/react-patterns-engine.js +0 -457
  224. package/bin/runners/lib/engines/security-vulnerabilities-engine.js +0 -571
  225. package/bin/runners/lib/engines/todo-fixme-engine.js +0 -115
  226. package/bin/runners/lib/engines/type-aware-engine.js +0 -376
  227. package/bin/runners/lib/engines/unsafe-regex-engine.js +0 -225
  228. package/bin/runners/lib/engines/vibecheck-engines/README.md +0 -53
  229. package/bin/runners/lib/engines/vibecheck-engines/index.js +0 -124
  230. package/bin/runners/lib/engines/vibecheck-engines/lib/ai-hallucination-engine.js +0 -806
  231. package/bin/runners/lib/engines/vibecheck-engines/lib/hardcoded-secrets-engine.js +0 -439
  232. package/bin/runners/lib/engines/vibecheck-engines/lib/smart-fix-engine.js +0 -577
  233. package/bin/runners/lib/engines/vibecheck-engines/lib/vibe-score-engine.js +0 -543
  234. package/bin/runners/lib/engines/vibecheck-engines/package.json +0 -13
  235. package/bin/runners/lib/engines/vibecheck-engines.js +0 -514
  236. package/bin/runners/lib/enhanced-features/index.js +0 -305
  237. package/bin/runners/lib/enhanced-output.js +0 -631
  238. package/bin/runners/lib/enterprise.js +0 -300
  239. package/bin/runners/lib/exit-codes.js +0 -275
  240. package/bin/runners/lib/fingerprint.js +0 -377
  241. package/bin/runners/lib/firewall/command-validator.js +0 -351
  242. package/bin/runners/lib/firewall/config.js +0 -341
  243. package/bin/runners/lib/firewall/content-validator.js +0 -519
  244. package/bin/runners/lib/firewall/index.js +0 -101
  245. package/bin/runners/lib/firewall/path-validator.js +0 -256
  246. package/bin/runners/lib/help-formatter.js +0 -413
  247. package/bin/runners/lib/intelligence/cross-repo-intelligence.js +0 -817
  248. package/bin/runners/lib/logger.js +0 -38
  249. package/bin/runners/lib/mcp-utils.js +0 -425
  250. package/bin/runners/lib/output/index.js +0 -1022
  251. package/bin/runners/lib/policy-engine.js +0 -652
  252. package/bin/runners/lib/polish/autofix/accessibility-fixes.js +0 -333
  253. package/bin/runners/lib/polish/autofix/async-handlers.js +0 -273
  254. package/bin/runners/lib/polish/autofix/dead-code.js +0 -280
  255. package/bin/runners/lib/polish/autofix/imports-optimizer.js +0 -344
  256. package/bin/runners/lib/polish/autofix/index.js +0 -200
  257. package/bin/runners/lib/polish/autofix/remove-consoles.js +0 -209
  258. package/bin/runners/lib/polish/autofix/strengthen-types.js +0 -245
  259. package/bin/runners/lib/polish/backend-checks.js +0 -148
  260. package/bin/runners/lib/polish/documentation-checks.js +0 -111
  261. package/bin/runners/lib/polish/frontend-checks.js +0 -168
  262. package/bin/runners/lib/polish/index.js +0 -71
  263. package/bin/runners/lib/polish/infrastructure-checks.js +0 -131
  264. package/bin/runners/lib/polish/library-detection.js +0 -175
  265. package/bin/runners/lib/polish/performance-checks.js +0 -100
  266. package/bin/runners/lib/polish/security-checks.js +0 -148
  267. package/bin/runners/lib/polish/utils.js +0 -203
  268. package/bin/runners/lib/prompt-builder.js +0 -540
  269. package/bin/runners/lib/proof-certificate.js +0 -634
  270. package/bin/runners/lib/reality/accessibility-audit.js +0 -946
  271. package/bin/runners/lib/reality/api-contract-validator.js +0 -1012
  272. package/bin/runners/lib/reality/chaos-engineering.js +0 -1084
  273. package/bin/runners/lib/reality/performance-tracker.js +0 -1077
  274. package/bin/runners/lib/reality/scenario-generator.js +0 -1404
  275. package/bin/runners/lib/reality/visual-regression.js +0 -852
  276. package/bin/runners/lib/reality-profiler.js +0 -717
  277. package/bin/runners/lib/replay/flight-recorder-viewer.js +0 -1160
  278. package/bin/runners/lib/review/ai-code-review.js +0 -832
  279. package/bin/runners/lib/rules/custom-rule-engine.js +0 -985
  280. package/bin/runners/lib/sbom-generator.js +0 -641
  281. package/bin/runners/lib/scan-output-enhanced.js +0 -512
  282. package/bin/runners/lib/security/owasp-scanner.js +0 -939
  283. package/bin/runners/lib/ship-output-enterprise.js +0 -239
  284. package/bin/runners/lib/unified-cli-output.js +0 -777
  285. package/bin/runners/lib/validators/contract-validator.js +0 -283
  286. package/bin/runners/lib/validators/dead-export-detector.js +0 -279
  287. package/bin/runners/lib/validators/dep-audit.js +0 -245
  288. package/bin/runners/lib/validators/env-validator.js +0 -319
  289. package/bin/runners/lib/validators/index.js +0 -120
  290. package/bin/runners/lib/validators/license-checker.js +0 -252
  291. package/bin/runners/lib/validators/route-validator.js +0 -290
  292. package/bin/runners/runAgent.d.ts +0 -5
  293. package/bin/runners/runAgent.js +0 -164
  294. package/bin/runners/runApprove.js +0 -1233
  295. package/bin/runners/runAuthority.js +0 -528
  296. package/bin/runners/runClassify.js +0 -862
  297. package/bin/runners/runConductor.js +0 -772
  298. package/bin/runners/runContainer.js +0 -366
  299. package/bin/runners/runContext.d.ts +0 -4
  300. package/bin/runners/runEasy.js +0 -410
  301. package/bin/runners/runFirewall.d.ts +0 -5
  302. package/bin/runners/runFirewall.js +0 -137
  303. package/bin/runners/runFirewallHook.d.ts +0 -5
  304. package/bin/runners/runFirewallHook.js +0 -59
  305. package/bin/runners/runIaC.js +0 -372
  306. package/bin/runners/runPolish.d.ts +0 -4
  307. package/bin/runners/runProof.zip +0 -0
  308. package/bin/runners/runTruth.d.ts +0 -5
  309. package/bin/runners/runTruth.js +0 -104
  310. package/bin/runners/runVibe.js +0 -791
  311. package/mcp-server/HARDENING_SUMMARY.md +0 -299
  312. package/mcp-server/agent-firewall-interceptor.js +0 -500
  313. package/mcp-server/authority-tools.js +0 -569
  314. package/mcp-server/conductor/conflict-resolver.js +0 -588
  315. package/mcp-server/conductor/execution-planner.js +0 -544
  316. package/mcp-server/conductor/index.js +0 -377
  317. package/mcp-server/conductor/lock-manager.js +0 -615
  318. package/mcp-server/conductor/request-queue.js +0 -550
  319. package/mcp-server/conductor/session-manager.js +0 -500
  320. package/mcp-server/conductor/tools.js +0 -510
  321. package/mcp-server/lib/api-client.cjs +0 -13
  322. package/mcp-server/lib/logger.cjs +0 -30
  323. package/mcp-server/logger.js +0 -173
  324. package/mcp-server/tools-v3.js +0 -1039
  325. package/mcp-server/tools.js +0 -495
  326. package/mcp-server/vibecheck-mcp-server-3.2.0.tgz +0 -0
@@ -1,16 +1,15 @@
1
1
  /**
2
- * Truth Context MCP Tools for EvidenceBacked AI
3
- *
4
- * Core context-engine tools that surface **truth-backed** context for AI agents.
5
- * Every response is grounded in concrete evidence with file/line citations
6
- * and explicit confidence scores.
7
- *
8
- * This is the "Truth Firewall", exposed to agents as an "Evidence Pack" / "Truth Pack". [web:3]
9
- *
2
+ * Truth Context - MCP Tools for Evidence-Backed AI
3
+ *
4
+ * Core Context Engine tools that provide truth-backed context for AI agents.
5
+ * All responses include citations (file/line) and confidence levels.
6
+ *
7
+ * This is the "Truth Firewall" made visible as "Evidence Pack" / "Truth Pack".
8
+ *
10
9
  * Tools:
11
- * - vibecheck.ctx Build a repo-level Truth Pack (routes, auth, billing, env, schema)
12
- * - vibecheck.verify_claim Check whether a claim is backed by real evidence
13
- * - vibecheck.evidence Pull code-level evidence for a specific file/function
10
+ * vibecheck.ctx - Get repo truth bundle (routes, auth, billing, env, schema)
11
+ * vibecheck.verify_claim - Verify a claim has evidence
12
+ * vibecheck.evidence - Get evidence for a specific file/function
14
13
  */
15
14
 
16
15
  import fs from "fs/promises";
@@ -24,72 +23,60 @@ import { execSync } from "child_process";
24
23
  export const TRUTH_CONTEXT_TOOLS = [
25
24
  {
26
25
  name: "vibecheck.ctx",
27
- description: `📋 Build a repo Truth Pack: routes, auth, billing, env vars, schema.
28
-
29
- Generates an evidence-backed context bundle with file/line citations.
30
- Use this before the agent makes any architectural or behavioral claims
31
- about the codebase.
26
+ description: `📋 Get repo Truth Pack routes, auth, billing, env vars, schema.
27
+
28
+ Returns evidence-backed context with file/line citations.
29
+ Use this before making any claims about the codebase.
32
30
 
33
31
  Returns:
34
- - routes: All detected routes with handlers and middleware
35
- - auth: Auth guards, protected routes, auth flow indicators
36
- - billing: Payment gates, subscription checks, paid feature indicators
37
- - env: Environment variables (declared vs used, mismatches)
38
- - schema: Database schema and TypeScript contracts
39
- - confidence: Aggregate confidence score (01) for the extracted view`,
32
+ - routes: All defined routes with handlers and middleware
33
+ - auth: Auth guards, protected routes, auth flow
34
+ - billing: Payment gates, subscription checks, paid features
35
+ - env: Environment variables (declared vs used)
36
+ - schema: Database schema, API contracts
37
+ - confidence: Overall confidence score (0-1)`,
40
38
  inputSchema: {
41
39
  type: "object",
42
40
  properties: {
43
41
  scope: {
44
42
  type: "string",
45
43
  enum: ["all", "routes", "auth", "billing", "env", "schema"],
46
- description: "Which slice of context to extract (default: all)",
44
+ description: "What context to extract (default: all)",
47
45
  default: "all",
48
46
  },
49
47
  path: {
50
48
  type: "string",
51
- description: "Project root path (default: current working directory)",
49
+ description: "Project path (default: current directory)",
52
50
  },
53
51
  },
54
52
  },
55
53
  },
56
54
  {
57
55
  name: "vibecheck.verify_claim",
58
- description: `🔍 Truth Firewall check verify that a claim is backed by code.
59
-
60
- Run this before asserting that something exists, is configured, or is enforced.
61
- Returns concrete evidence (file/line) when the claim is supported,
62
- or a structured rejection with an explanation when it is not.
56
+ description: `🔍 Verify a claim has evidence Truth Firewall check.
57
+
58
+ Before claiming something exists or works, verify it.
59
+ Returns evidence (file/line) or rejection with reason.
63
60
 
64
61
  Examples:
65
- - "Route /api/users exists" VERIFIED with handler at src/routes/users.ts:45
66
- - "Auth is required for /admin" VERIFIED via middleware at src/middleware/auth.ts:12
67
- - "Stripe is configured" → REJECTED: No evidence of Stripe integration found`,
62
+ - "Route /api/users exists" Verified with handler at src/routes/users.ts:45
63
+ - "Auth is required for /admin" Verified with middleware at src/middleware/auth.ts:12
64
+ - "Stripe is configured" → REJECTED: No evidence of Stripe integration found`,
68
65
  inputSchema: {
69
66
  type: "object",
70
67
  properties: {
71
68
  claim_type: {
72
69
  type: "string",
73
- enum: [
74
- "route",
75
- "endpoint",
76
- "env_var",
77
- "middleware",
78
- "auth_guard",
79
- "billing_gate",
80
- "file",
81
- "function",
82
- ],
83
- description: "Category of claim to verify",
70
+ enum: ["route", "endpoint", "env_var", "middleware", "auth_guard", "billing_gate", "file", "function"],
71
+ description: "Type of claim to verify",
84
72
  },
85
73
  claim: {
86
74
  type: "string",
87
- description:
88
- "The claim subject (e.g. '/api/users', 'AUTH_SECRET', 'authMiddleware')",
75
+ description: "The claim to verify (e.g., '/api/users', 'AUTH_SECRET', 'authMiddleware')",
89
76
  },
90
77
  path: {
91
78
  type: "string",
92
- description: "Project root path (default: current working directory)",
79
+ description: "Project path (default: current directory)",
93
80
  },
94
81
  },
95
82
  required: ["claim_type", "claim"],
@@ -97,35 +84,33 @@ Examples:
97
84
  },
98
85
  {
99
86
  name: "vibecheck.evidence",
100
- description: `📎 Retrieve code evidence for a file or symbol.
101
-
102
- Returns an annotated code snippet with line numbers for precise citation.
103
- Use this when the agent needs to quote or reason about specific code blocks
104
- in its response.`,
87
+ description: `📎 Get evidence for a file/function citations with context.
88
+
89
+ Returns the actual code with line numbers for citation.
90
+ Use this when you need to reference specific code in your response.`,
105
91
  inputSchema: {
106
92
  type: "object",
107
93
  properties: {
108
94
  file: {
109
95
  type: "string",
110
- description: "File path relative to the project root",
96
+ description: "File path relative to project root",
111
97
  },
112
98
  function_name: {
113
99
  type: "string",
114
- description: "Optional function/class name to locate within the file",
100
+ description: "Optional function/class name to find",
115
101
  },
116
102
  line: {
117
103
  type: "number",
118
- description: "Optional 1-based line number to center the snippet on",
104
+ description: "Optional specific line number",
119
105
  },
120
106
  context_lines: {
121
107
  type: "number",
122
- description:
123
- "Number of lines of context before/after the target (default: 10)",
108
+ description: "Lines of context around target (default: 10)",
124
109
  default: 10,
125
110
  },
126
111
  path: {
127
112
  type: "string",
128
- description: "Project root path (default: current working directory)",
113
+ description: "Project path (default: current directory)",
129
114
  },
130
115
  },
131
116
  required: ["file"],
@@ -134,7 +119,7 @@ in its response.`,
134
119
  ];
135
120
 
136
121
  // ============================================================================
137
- // TOOL DISPATCH
122
+ // TOOL HANDLERS
138
123
  // ============================================================================
139
124
 
140
125
  export async function handleTruthContextTool(toolName, args) {
@@ -183,11 +168,10 @@ async function getTruthPack(projectPath, scope) {
183
168
  truthPack.sections.schema = await extractSchema(projectPath);
184
169
  }
185
170
 
171
+ // Calculate overall confidence
186
172
  const sections = Object.values(truthPack.sections);
187
173
  if (sections.length > 0) {
188
- truthPack.confidence =
189
- sections.reduce((sum, section) => sum + (section.confidence || 0), 0) /
190
- sections.length;
174
+ truthPack.confidence = sections.reduce((sum, s) => sum + (s.confidence || 0), 0) / sections.length;
191
175
  }
192
176
 
193
177
  return truthPack;
@@ -195,7 +179,7 @@ async function getTruthPack(projectPath, scope) {
195
179
  return {
196
180
  error: error.message,
197
181
  projectPath,
198
- suggestion: "Run `vibecheck init` to set up the project",
182
+ suggestion: "Run 'vibecheck init' to set up the project",
199
183
  };
200
184
  }
201
185
  }
@@ -209,12 +193,12 @@ async function extractRoutes(projectPath) {
209
193
  ];
210
194
 
211
195
  const files = await findSourceFiles(projectPath, [".ts", ".js", ".tsx", ".jsx"]);
212
-
213
- for (const file of files.slice(0, 50)) {
196
+
197
+ for (const file of files.slice(0, 50)) { // Limit for performance
214
198
  try {
215
199
  const content = await fs.readFile(file, "utf8");
216
200
  const relPath = path.relative(projectPath, file);
217
-
201
+
218
202
  for (const pattern of routePatterns) {
219
203
  let match;
220
204
  pattern.lastIndex = 0;
@@ -239,7 +223,7 @@ async function extractRoutes(projectPath) {
239
223
 
240
224
  return {
241
225
  count: routes.length,
242
- routes: routes.slice(0, 100),
226
+ routes: routes.slice(0, 100), // Limit output
243
227
  confidence: routes.length > 0 ? 0.8 : 0.2,
244
228
  };
245
229
  }
@@ -254,12 +238,12 @@ async function extractAuth(projectPath) {
254
238
  ];
255
239
 
256
240
  const files = await findSourceFiles(projectPath, [".ts", ".js"]);
257
-
241
+
258
242
  for (const file of files.slice(0, 50)) {
259
243
  try {
260
244
  const content = await fs.readFile(file, "utf8");
261
245
  const relPath = path.relative(projectPath, file);
262
-
246
+
263
247
  for (const pattern of authPatterns) {
264
248
  let match;
265
249
  pattern.lastIndex = 0;
@@ -281,12 +265,7 @@ async function extractAuth(projectPath) {
281
265
  return {
282
266
  count: authIndicators.length,
283
267
  indicators: authIndicators.slice(0, 50),
284
- confidence:
285
- authIndicators.length > 5
286
- ? 0.8
287
- : authIndicators.length > 0
288
- ? 0.5
289
- : 0.1,
268
+ confidence: authIndicators.length > 5 ? 0.8 : authIndicators.length > 0 ? 0.5 : 0.1,
290
269
  };
291
270
  }
292
271
 
@@ -300,12 +279,12 @@ async function extractBilling(projectPath) {
300
279
  ];
301
280
 
302
281
  const files = await findSourceFiles(projectPath, [".ts", ".js"]);
303
-
282
+
304
283
  for (const file of files.slice(0, 30)) {
305
284
  try {
306
285
  const content = await fs.readFile(file, "utf8");
307
286
  const relPath = path.relative(projectPath, file);
308
-
287
+
309
288
  for (const pattern of billingPatterns) {
310
289
  let match;
311
290
  pattern.lastIndex = 0;
@@ -327,12 +306,7 @@ async function extractBilling(projectPath) {
327
306
  return {
328
307
  count: billingIndicators.length,
329
308
  indicators: billingIndicators.slice(0, 30),
330
- confidence:
331
- billingIndicators.length > 3
332
- ? 0.7
333
- : billingIndicators.length > 0
334
- ? 0.4
335
- : 0.1,
309
+ confidence: billingIndicators.length > 3 ? 0.7 : billingIndicators.length > 0 ? 0.4 : 0.1,
336
310
  };
337
311
  }
338
312
 
@@ -340,6 +314,7 @@ async function extractEnvVars(projectPath) {
340
314
  const declared = [];
341
315
  const used = [];
342
316
 
317
+ // Check .env.example, .env.local.example, etc.
343
318
  const envFiles = [".env.example", ".env.local.example", ".env.sample"];
344
319
  for (const envFile of envFiles) {
345
320
  try {
@@ -356,10 +331,11 @@ async function extractEnvVars(projectPath) {
356
331
  }
357
332
  }
358
333
  } catch {
359
- // File does not exist
334
+ // File doesn't exist
360
335
  }
361
336
  }
362
337
 
338
+ // Find process.env usage in code
363
339
  const files = await findSourceFiles(projectPath, [".ts", ".js"]);
364
340
  for (const file of files.slice(0, 30)) {
365
341
  try {
@@ -380,10 +356,11 @@ async function extractEnvVars(projectPath) {
380
356
  }
381
357
  }
382
358
 
383
- const declaredNames = new Set(declared.map((d) => d.name));
384
- const usedNames = new Set(used.map((u) => u.name));
385
- const undeclared = [...usedNames].filter((name) => !declaredNames.has(name));
386
- const unused = [...declaredNames].filter((name) => !usedNames.has(name));
359
+ // Find mismatches
360
+ const declaredNames = new Set(declared.map(d => d.name));
361
+ const usedNames = new Set(used.map(u => u.name));
362
+ const undeclared = [...usedNames].filter(n => !declaredNames.has(n));
363
+ const unused = [...declaredNames].filter(n => !usedNames.has(n));
387
364
 
388
365
  return {
389
366
  declared: declared.slice(0, 50),
@@ -399,6 +376,7 @@ async function extractEnvVars(projectPath) {
399
376
  async function extractSchema(projectPath) {
400
377
  const schemas = [];
401
378
 
379
+ // Check for Prisma schema
402
380
  try {
403
381
  const prismaPath = path.join(projectPath, "prisma", "schema.prisma");
404
382
  const content = await fs.readFile(prismaPath, "utf8");
@@ -411,15 +389,16 @@ async function extractSchema(projectPath) {
411
389
  });
412
390
  }
413
391
  } catch {
414
- // No Prisma schema
392
+ // No Prisma
415
393
  }
416
394
 
395
+ // Check for TypeScript types/interfaces
417
396
  const files = await findSourceFiles(projectPath, [".ts", ".tsx"]);
418
397
  for (const file of files.slice(0, 20)) {
419
398
  try {
420
399
  const content = await fs.readFile(file, "utf8");
421
400
  const relPath = path.relative(projectPath, file);
422
-
401
+
423
402
  const typeMatches = content.matchAll(/(?:interface|type)\s+(\w+)/g);
424
403
  for (const match of typeMatches) {
425
404
  const line = content.substring(0, match.index).split("\n").length;
@@ -438,8 +417,7 @@ async function extractSchema(projectPath) {
438
417
  return {
439
418
  count: schemas.length,
440
419
  schemas: schemas.slice(0, 50),
441
- confidence:
442
- schemas.length > 5 ? 0.7 : schemas.length > 0 ? 0.4 : 0.2,
420
+ confidence: schemas.length > 5 ? 0.7 : schemas.length > 0 ? 0.4 : 0.2,
443
421
  };
444
422
  }
445
423
 
@@ -458,7 +436,7 @@ async function verifyClaim(projectPath, claimType, claim) {
458
436
 
459
437
  try {
460
438
  switch (claimType) {
461
- case "file": {
439
+ case "file":
462
440
  const filePath = path.join(projectPath, claim);
463
441
  try {
464
442
  await fs.access(filePath);
@@ -475,14 +453,11 @@ async function verifyClaim(projectPath, claimType, claim) {
475
453
  result.rejection = `File does not exist: ${claim}`;
476
454
  }
477
455
  break;
478
- }
479
456
 
480
457
  case "route":
481
- case "endpoint": {
458
+ case "endpoint":
482
459
  const routes = await extractRoutes(projectPath);
483
- const matchingRoute = routes.routes.find(
484
- (route) => route.path === claim || route.path.includes(claim),
485
- );
460
+ const matchingRoute = routes.routes.find(r => r.path === claim || r.path.includes(claim));
486
461
  if (matchingRoute) {
487
462
  result.verified = true;
488
463
  result.confidence = 0.9;
@@ -491,31 +466,26 @@ async function verifyClaim(projectPath, claimType, claim) {
491
466
  result.rejection = `No route matching "${claim}" found in codebase`;
492
467
  }
493
468
  break;
494
- }
495
469
 
496
- case "env_var": {
470
+ case "env_var":
497
471
  const envData = await extractEnvVars(projectPath);
498
- const isDeclared = envData.declared.some((env) => env.name === claim);
499
- const isUsed = envData.used.some((env) => env.name === claim);
472
+ const isDeclared = envData.declared.some(d => d.name === claim);
473
+ const isUsed = envData.used.some(u => u.name === claim);
500
474
  if (isDeclared || isUsed) {
501
475
  result.verified = true;
502
476
  result.confidence = isDeclared && isUsed ? 1.0 : 0.7;
503
477
  result.evidence = {
504
478
  declared: isDeclared,
505
479
  used: isUsed,
506
- locations: [
507
- ...envData.declared.filter((env) => env.name === claim),
508
- ...envData.used.filter((env) => env.name === claim),
509
- ],
480
+ locations: [...envData.declared.filter(d => d.name === claim), ...envData.used.filter(u => u.name === claim)],
510
481
  };
511
482
  } else {
512
483
  result.rejection = `Environment variable "${claim}" not found`;
513
484
  }
514
485
  break;
515
- }
516
486
 
517
487
  default:
518
- result.rejection = `Claim type "${claimType}" verification is not implemented yet`;
488
+ result.rejection = `Claim type "${claimType}" verification not yet implemented`;
519
489
  }
520
490
  } catch (error) {
521
491
  result.rejection = `Verification error: ${error.message}`;
@@ -530,19 +500,17 @@ async function verifyClaim(projectPath, claimType, claim) {
530
500
 
531
501
  async function getEvidence(projectPath, file, options) {
532
502
  const filePath = path.join(projectPath, file);
533
-
503
+
534
504
  try {
535
505
  const content = await fs.readFile(filePath, "utf8");
536
506
  const lines = content.split("\n");
537
-
507
+
538
508
  let targetLine = options.line || 1;
539
509
  const contextLines = options.context_lines || 10;
540
-
510
+
511
+ // If function_name provided, find it
541
512
  if (options.function_name) {
542
- const pattern = new RegExp(
543
- `(function|const|let|var|class)\\s+${options.function_name}`,
544
- "i",
545
- );
513
+ const pattern = new RegExp(`(function|const|let|var|class)\\s+${options.function_name}`, "i");
546
514
  for (let i = 0; i < lines.length; i++) {
547
515
  if (pattern.test(lines[i])) {
548
516
  targetLine = i + 1;
@@ -550,18 +518,14 @@ async function getEvidence(projectPath, file, options) {
550
518
  }
551
519
  }
552
520
  }
553
-
521
+
554
522
  const startLine = Math.max(1, targetLine - contextLines);
555
523
  const endLine = Math.min(lines.length, targetLine + contextLines);
556
-
557
- const snippet = lines
558
- .slice(startLine - 1, endLine)
559
- .map(
560
- (line, index) =>
561
- `${String(startLine + index).padStart(4, " ")} | ${line}`,
562
- )
524
+
525
+ const snippet = lines.slice(startLine - 1, endLine)
526
+ .map((line, i) => `${String(startLine + i).padStart(4, " ")} | ${line}`)
563
527
  .join("\n");
564
-
528
+
565
529
  return {
566
530
  file,
567
531
  targetLine,
@@ -585,19 +549,14 @@ async function getEvidence(projectPath, file, options) {
585
549
 
586
550
  async function findSourceFiles(projectPath, extensions) {
587
551
  const files = [];
588
-
552
+
589
553
  async function walk(dir) {
590
554
  try {
591
555
  const entries = await fs.readdir(dir, { withFileTypes: true });
592
556
  for (const entry of entries) {
593
557
  const fullPath = path.join(dir, entry.name);
594
558
  if (entry.isDirectory()) {
595
- if (
596
- !entry.name.startsWith(".") &&
597
- entry.name !== "node_modules" &&
598
- entry.name !== "dist" &&
599
- entry.name !== "build"
600
- ) {
559
+ if (!entry.name.startsWith(".") && entry.name !== "node_modules" && entry.name !== "dist" && entry.name !== "build") {
601
560
  await walk(fullPath);
602
561
  }
603
562
  } else if (entry.isFile()) {
@@ -611,7 +570,7 @@ async function findSourceFiles(projectPath, extensions) {
611
570
  // Skip inaccessible directories
612
571
  }
613
572
  }
614
-
573
+
615
574
  await walk(projectPath);
616
575
  return files;
617
576
  }