@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.
- package/bin/registry.js +174 -449
- package/bin/runners/cli-utils.js +33 -2
- package/bin/runners/context/generators/cursor.js +2 -49
- package/bin/runners/context/generators/mcp.js +13 -15
- package/bin/runners/context/proof-context.js +1 -248
- package/bin/runners/lib/analysis-core.js +180 -198
- package/bin/runners/lib/analyzers.js +241 -2212
- package/bin/runners/lib/cli-output.js +210 -242
- package/bin/runners/lib/detectors-v2.js +785 -547
- package/bin/runners/lib/entitlements-v2.js +431 -161
- package/bin/runners/lib/error-handler.js +9 -16
- package/bin/runners/lib/global-flags.js +0 -37
- package/bin/runners/lib/html-proof-report.js +700 -350
- package/bin/runners/lib/missions/plan.js +6 -46
- package/bin/runners/lib/missions/templates.js +0 -232
- package/bin/runners/lib/route-truth.js +322 -1167
- package/bin/runners/lib/scan-output.js +467 -493
- package/bin/runners/lib/ship-output.js +27 -280
- package/bin/runners/lib/terminal-ui.js +700 -310
- package/bin/runners/lib/truth.js +321 -1004
- package/bin/runners/lib/unified-output.js +158 -162
- package/bin/runners/lib/upsell.js +204 -104
- package/bin/runners/runAIAgent.js +10 -5
- package/bin/runners/runAllowlist.js +324 -0
- package/bin/runners/runAuth.js +94 -344
- package/bin/runners/runCheckpoint.js +45 -43
- package/bin/runners/runContext.js +24 -139
- package/bin/runners/runDoctor.js +101 -136
- package/bin/runners/runEvidencePack.js +219 -0
- package/bin/runners/runFix.js +71 -82
- package/bin/runners/runGuard.js +119 -606
- package/bin/runners/runInit.js +60 -22
- package/bin/runners/runInstall.js +281 -0
- package/bin/runners/runLabs.js +341 -0
- package/bin/runners/runMcp.js +62 -139
- package/bin/runners/runPolish.js +83 -282
- package/bin/runners/runPromptFirewall.js +12 -5
- package/bin/runners/runProve.js +58 -33
- package/bin/runners/runReality.js +58 -81
- package/bin/runners/runReport.js +7 -34
- package/bin/runners/runRuntime.js +8 -5
- package/bin/runners/runScan.js +844 -219
- package/bin/runners/runShip.js +59 -721
- package/bin/runners/runValidate.js +11 -24
- package/bin/runners/runWatch.js +76 -131
- package/bin/vibecheck.js +69 -295
- package/mcp-server/ARCHITECTURE.md +339 -0
- package/mcp-server/__tests__/cache.test.ts +313 -0
- package/mcp-server/__tests__/executor.test.ts +239 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.cache/webpack/cache.pack +1 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.next/server/chunk.js +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.turbo/cache.json +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.venv/lib/env.py +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/dist/bundle.js +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/package.json +5 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/src/app.ts +5 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/venv/lib/config.py +4 -0
- package/mcp-server/__tests__/ids.test.ts +345 -0
- package/mcp-server/__tests__/integration/tools.test.ts +410 -0
- package/mcp-server/__tests__/registry.test.ts +365 -0
- package/mcp-server/__tests__/sandbox.test.ts +323 -0
- package/mcp-server/__tests__/schemas.test.ts +372 -0
- package/mcp-server/benchmarks/run-benchmarks.ts +304 -0
- package/mcp-server/examples/doctor.request.json +14 -0
- package/mcp-server/examples/doctor.response.json +53 -0
- package/mcp-server/examples/error.response.json +15 -0
- package/mcp-server/examples/scan.request.json +14 -0
- package/mcp-server/examples/scan.response.json +108 -0
- package/mcp-server/handlers/tool-handler.ts +671 -0
- package/mcp-server/index-v1.js +698 -0
- package/mcp-server/index-v3.ts +293 -0
- package/mcp-server/index.js +1080 -1757
- package/mcp-server/index.old.js +4137 -0
- package/mcp-server/lib/cache.ts +341 -0
- package/mcp-server/lib/errors.ts +346 -0
- package/mcp-server/lib/executor.ts +792 -0
- package/mcp-server/lib/ids.ts +238 -0
- package/mcp-server/lib/logger.ts +368 -0
- package/mcp-server/lib/metrics.ts +365 -0
- package/mcp-server/lib/sandbox.ts +337 -0
- package/mcp-server/lib/validator.ts +229 -0
- package/mcp-server/package-lock.json +165 -0
- package/mcp-server/package.json +32 -7
- package/mcp-server/premium-tools.js +2 -2
- package/mcp-server/registry/tools.json +476 -0
- package/mcp-server/schemas/error-envelope.schema.json +125 -0
- package/mcp-server/schemas/finding.schema.json +167 -0
- package/mcp-server/schemas/report-artifact.schema.json +88 -0
- package/mcp-server/schemas/run-request.schema.json +75 -0
- package/mcp-server/schemas/verdict.schema.json +168 -0
- package/mcp-server/tier-auth.d.ts +71 -0
- package/mcp-server/tier-auth.js +371 -183
- package/mcp-server/truth-context.js +90 -131
- package/mcp-server/truth-firewall-tools.js +1000 -1611
- package/mcp-server/tsconfig.json +34 -0
- package/mcp-server/vibecheck-tools.js +2 -2
- package/mcp-server/vitest.config.ts +16 -0
- package/package.json +3 -4
- package/bin/runners/lib/agent-firewall/ai/false-positive-analyzer.js +0 -474
- package/bin/runners/lib/agent-firewall/change-packet/builder.js +0 -488
- package/bin/runners/lib/agent-firewall/change-packet/schema.json +0 -228
- package/bin/runners/lib/agent-firewall/change-packet/store.js +0 -200
- package/bin/runners/lib/agent-firewall/claims/claim-types.js +0 -21
- package/bin/runners/lib/agent-firewall/claims/extractor.js +0 -303
- package/bin/runners/lib/agent-firewall/claims/patterns.js +0 -24
- package/bin/runners/lib/agent-firewall/critic/index.js +0 -151
- package/bin/runners/lib/agent-firewall/critic/judge.js +0 -432
- package/bin/runners/lib/agent-firewall/critic/prompts.js +0 -305
- package/bin/runners/lib/agent-firewall/evidence/auth-evidence.js +0 -88
- package/bin/runners/lib/agent-firewall/evidence/contract-evidence.js +0 -75
- package/bin/runners/lib/agent-firewall/evidence/env-evidence.js +0 -127
- package/bin/runners/lib/agent-firewall/evidence/resolver.js +0 -102
- package/bin/runners/lib/agent-firewall/evidence/route-evidence.js +0 -213
- package/bin/runners/lib/agent-firewall/evidence/side-effect-evidence.js +0 -145
- package/bin/runners/lib/agent-firewall/fs-hook/daemon.js +0 -19
- package/bin/runners/lib/agent-firewall/fs-hook/installer.js +0 -87
- package/bin/runners/lib/agent-firewall/fs-hook/watcher.js +0 -184
- package/bin/runners/lib/agent-firewall/git-hook/pre-commit.js +0 -163
- package/bin/runners/lib/agent-firewall/ide-extension/cursor.js +0 -107
- package/bin/runners/lib/agent-firewall/ide-extension/vscode.js +0 -68
- package/bin/runners/lib/agent-firewall/ide-extension/windsurf.js +0 -66
- package/bin/runners/lib/agent-firewall/interceptor/base.js +0 -304
- package/bin/runners/lib/agent-firewall/interceptor/cursor.js +0 -35
- package/bin/runners/lib/agent-firewall/interceptor/vscode.js +0 -35
- package/bin/runners/lib/agent-firewall/interceptor/windsurf.js +0 -34
- package/bin/runners/lib/agent-firewall/lawbook/distributor.js +0 -465
- package/bin/runners/lib/agent-firewall/lawbook/evaluator.js +0 -604
- package/bin/runners/lib/agent-firewall/lawbook/index.js +0 -304
- package/bin/runners/lib/agent-firewall/lawbook/registry.js +0 -514
- package/bin/runners/lib/agent-firewall/lawbook/schema.js +0 -420
- package/bin/runners/lib/agent-firewall/learning/learning-engine.js +0 -849
- package/bin/runners/lib/agent-firewall/logger.js +0 -141
- package/bin/runners/lib/agent-firewall/policy/default-policy.json +0 -90
- package/bin/runners/lib/agent-firewall/policy/engine.js +0 -103
- package/bin/runners/lib/agent-firewall/policy/loader.js +0 -451
- package/bin/runners/lib/agent-firewall/policy/rules/auth-drift.js +0 -50
- package/bin/runners/lib/agent-firewall/policy/rules/contract-drift.js +0 -50
- package/bin/runners/lib/agent-firewall/policy/rules/fake-success.js +0 -86
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-env.js +0 -162
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-route.js +0 -189
- package/bin/runners/lib/agent-firewall/policy/rules/scope.js +0 -93
- package/bin/runners/lib/agent-firewall/policy/rules/unsafe-side-effect.js +0 -57
- package/bin/runners/lib/agent-firewall/policy/schema.json +0 -183
- package/bin/runners/lib/agent-firewall/policy/verdict.js +0 -54
- package/bin/runners/lib/agent-firewall/proposal/extractor.js +0 -394
- package/bin/runners/lib/agent-firewall/proposal/index.js +0 -212
- package/bin/runners/lib/agent-firewall/proposal/schema.js +0 -251
- package/bin/runners/lib/agent-firewall/proposal/validator.js +0 -386
- package/bin/runners/lib/agent-firewall/reality/index.js +0 -332
- package/bin/runners/lib/agent-firewall/reality/state.js +0 -625
- package/bin/runners/lib/agent-firewall/reality/watcher.js +0 -322
- package/bin/runners/lib/agent-firewall/risk/index.js +0 -173
- package/bin/runners/lib/agent-firewall/risk/scorer.js +0 -328
- package/bin/runners/lib/agent-firewall/risk/thresholds.js +0 -321
- package/bin/runners/lib/agent-firewall/risk/vectors.js +0 -421
- package/bin/runners/lib/agent-firewall/simulator/diff-simulator.js +0 -472
- package/bin/runners/lib/agent-firewall/simulator/import-resolver.js +0 -346
- package/bin/runners/lib/agent-firewall/simulator/index.js +0 -181
- package/bin/runners/lib/agent-firewall/simulator/route-validator.js +0 -380
- package/bin/runners/lib/agent-firewall/time-machine/incident-correlator.js +0 -661
- package/bin/runners/lib/agent-firewall/time-machine/index.js +0 -267
- package/bin/runners/lib/agent-firewall/time-machine/replay-engine.js +0 -436
- package/bin/runners/lib/agent-firewall/time-machine/state-reconstructor.js +0 -490
- package/bin/runners/lib/agent-firewall/time-machine/timeline-builder.js +0 -530
- package/bin/runners/lib/agent-firewall/truthpack/index.js +0 -67
- package/bin/runners/lib/agent-firewall/truthpack/loader.js +0 -137
- package/bin/runners/lib/agent-firewall/unblock/planner.js +0 -337
- package/bin/runners/lib/agent-firewall/utils/ignore-checker.js +0 -118
- package/bin/runners/lib/api-client.js +0 -269
- package/bin/runners/lib/audit-logger.js +0 -532
- package/bin/runners/lib/authority/authorities/architecture.js +0 -364
- package/bin/runners/lib/authority/authorities/compliance.js +0 -341
- package/bin/runners/lib/authority/authorities/human.js +0 -343
- package/bin/runners/lib/authority/authorities/quality.js +0 -420
- package/bin/runners/lib/authority/authorities/security.js +0 -228
- package/bin/runners/lib/authority/index.js +0 -293
- package/bin/runners/lib/authority-badge.js +0 -425
- package/bin/runners/lib/bundle/bundle-intelligence.js +0 -846
- package/bin/runners/lib/cli-charts.js +0 -368
- package/bin/runners/lib/cli-config-display.js +0 -405
- package/bin/runners/lib/cli-demo.js +0 -275
- package/bin/runners/lib/cli-errors.js +0 -438
- package/bin/runners/lib/cli-help-formatter.js +0 -439
- package/bin/runners/lib/cli-interactive-menu.js +0 -509
- package/bin/runners/lib/cli-prompts.js +0 -441
- package/bin/runners/lib/cli-scan-cards.js +0 -362
- package/bin/runners/lib/compliance-reporter.js +0 -710
- package/bin/runners/lib/conductor/index.js +0 -671
- package/bin/runners/lib/easy/README.md +0 -123
- package/bin/runners/lib/easy/index.js +0 -140
- package/bin/runners/lib/easy/interactive-wizard.js +0 -788
- package/bin/runners/lib/easy/one-click-firewall.js +0 -564
- package/bin/runners/lib/easy/zero-config-reality.js +0 -714
- package/bin/runners/lib/engines/accessibility-engine.js +0 -390
- package/bin/runners/lib/engines/api-consistency-engine.js +0 -467
- package/bin/runners/lib/engines/ast-cache.js +0 -99
- package/bin/runners/lib/engines/async-patterns-engine.js +0 -444
- package/bin/runners/lib/engines/bundle-size-engine.js +0 -433
- package/bin/runners/lib/engines/code-quality-engine.js +0 -255
- package/bin/runners/lib/engines/confidence-scoring.js +0 -276
- package/bin/runners/lib/engines/console-logs-engine.js +0 -115
- package/bin/runners/lib/engines/context-detection.js +0 -264
- package/bin/runners/lib/engines/cross-file-analysis-engine.js +0 -533
- package/bin/runners/lib/engines/database-patterns-engine.js +0 -429
- package/bin/runners/lib/engines/dead-code-engine.js +0 -198
- package/bin/runners/lib/engines/deprecated-api-engine.js +0 -226
- package/bin/runners/lib/engines/duplicate-code-engine.js +0 -354
- package/bin/runners/lib/engines/empty-catch-engine.js +0 -260
- package/bin/runners/lib/engines/env-variables-engine.js +0 -458
- package/bin/runners/lib/engines/error-handling-engine.js +0 -437
- package/bin/runners/lib/engines/false-positive-prevention.js +0 -630
- package/bin/runners/lib/engines/file-filter.js +0 -131
- package/bin/runners/lib/engines/framework-adapters/index.js +0 -607
- package/bin/runners/lib/engines/framework-detection.js +0 -508
- package/bin/runners/lib/engines/hardcoded-secrets-engine.js +0 -251
- package/bin/runners/lib/engines/import-order-engine.js +0 -429
- package/bin/runners/lib/engines/mock-data-engine.js +0 -315
- package/bin/runners/lib/engines/naming-conventions-engine.js +0 -544
- package/bin/runners/lib/engines/noise-reduction-engine.js +0 -452
- package/bin/runners/lib/engines/orchestrator.js +0 -334
- package/bin/runners/lib/engines/parallel-processor.js +0 -71
- package/bin/runners/lib/engines/performance-issues-engine.js +0 -405
- package/bin/runners/lib/engines/react-patterns-engine.js +0 -457
- package/bin/runners/lib/engines/security-vulnerabilities-engine.js +0 -571
- package/bin/runners/lib/engines/todo-fixme-engine.js +0 -115
- package/bin/runners/lib/engines/type-aware-engine.js +0 -376
- package/bin/runners/lib/engines/unsafe-regex-engine.js +0 -225
- package/bin/runners/lib/engines/vibecheck-engines/README.md +0 -53
- package/bin/runners/lib/engines/vibecheck-engines/index.js +0 -124
- package/bin/runners/lib/engines/vibecheck-engines/lib/ai-hallucination-engine.js +0 -806
- package/bin/runners/lib/engines/vibecheck-engines/lib/hardcoded-secrets-engine.js +0 -439
- package/bin/runners/lib/engines/vibecheck-engines/lib/smart-fix-engine.js +0 -577
- package/bin/runners/lib/engines/vibecheck-engines/lib/vibe-score-engine.js +0 -543
- package/bin/runners/lib/engines/vibecheck-engines/package.json +0 -13
- package/bin/runners/lib/engines/vibecheck-engines.js +0 -514
- package/bin/runners/lib/enhanced-features/index.js +0 -305
- package/bin/runners/lib/enhanced-output.js +0 -631
- package/bin/runners/lib/enterprise.js +0 -300
- package/bin/runners/lib/exit-codes.js +0 -275
- package/bin/runners/lib/fingerprint.js +0 -377
- package/bin/runners/lib/firewall/command-validator.js +0 -351
- package/bin/runners/lib/firewall/config.js +0 -341
- package/bin/runners/lib/firewall/content-validator.js +0 -519
- package/bin/runners/lib/firewall/index.js +0 -101
- package/bin/runners/lib/firewall/path-validator.js +0 -256
- package/bin/runners/lib/help-formatter.js +0 -413
- package/bin/runners/lib/intelligence/cross-repo-intelligence.js +0 -817
- package/bin/runners/lib/logger.js +0 -38
- package/bin/runners/lib/mcp-utils.js +0 -425
- package/bin/runners/lib/output/index.js +0 -1022
- package/bin/runners/lib/policy-engine.js +0 -652
- package/bin/runners/lib/polish/autofix/accessibility-fixes.js +0 -333
- package/bin/runners/lib/polish/autofix/async-handlers.js +0 -273
- package/bin/runners/lib/polish/autofix/dead-code.js +0 -280
- package/bin/runners/lib/polish/autofix/imports-optimizer.js +0 -344
- package/bin/runners/lib/polish/autofix/index.js +0 -200
- package/bin/runners/lib/polish/autofix/remove-consoles.js +0 -209
- package/bin/runners/lib/polish/autofix/strengthen-types.js +0 -245
- package/bin/runners/lib/polish/backend-checks.js +0 -148
- package/bin/runners/lib/polish/documentation-checks.js +0 -111
- package/bin/runners/lib/polish/frontend-checks.js +0 -168
- package/bin/runners/lib/polish/index.js +0 -71
- package/bin/runners/lib/polish/infrastructure-checks.js +0 -131
- package/bin/runners/lib/polish/library-detection.js +0 -175
- package/bin/runners/lib/polish/performance-checks.js +0 -100
- package/bin/runners/lib/polish/security-checks.js +0 -148
- package/bin/runners/lib/polish/utils.js +0 -203
- package/bin/runners/lib/prompt-builder.js +0 -540
- package/bin/runners/lib/proof-certificate.js +0 -634
- package/bin/runners/lib/reality/accessibility-audit.js +0 -946
- package/bin/runners/lib/reality/api-contract-validator.js +0 -1012
- package/bin/runners/lib/reality/chaos-engineering.js +0 -1084
- package/bin/runners/lib/reality/performance-tracker.js +0 -1077
- package/bin/runners/lib/reality/scenario-generator.js +0 -1404
- package/bin/runners/lib/reality/visual-regression.js +0 -852
- package/bin/runners/lib/reality-profiler.js +0 -717
- package/bin/runners/lib/replay/flight-recorder-viewer.js +0 -1160
- package/bin/runners/lib/review/ai-code-review.js +0 -832
- package/bin/runners/lib/rules/custom-rule-engine.js +0 -985
- package/bin/runners/lib/sbom-generator.js +0 -641
- package/bin/runners/lib/scan-output-enhanced.js +0 -512
- package/bin/runners/lib/security/owasp-scanner.js +0 -939
- package/bin/runners/lib/ship-output-enterprise.js +0 -239
- package/bin/runners/lib/unified-cli-output.js +0 -777
- package/bin/runners/lib/validators/contract-validator.js +0 -283
- package/bin/runners/lib/validators/dead-export-detector.js +0 -279
- package/bin/runners/lib/validators/dep-audit.js +0 -245
- package/bin/runners/lib/validators/env-validator.js +0 -319
- package/bin/runners/lib/validators/index.js +0 -120
- package/bin/runners/lib/validators/license-checker.js +0 -252
- package/bin/runners/lib/validators/route-validator.js +0 -290
- package/bin/runners/runAgent.d.ts +0 -5
- package/bin/runners/runAgent.js +0 -164
- package/bin/runners/runApprove.js +0 -1233
- package/bin/runners/runAuthority.js +0 -528
- package/bin/runners/runClassify.js +0 -862
- package/bin/runners/runConductor.js +0 -772
- package/bin/runners/runContainer.js +0 -366
- package/bin/runners/runContext.d.ts +0 -4
- package/bin/runners/runEasy.js +0 -410
- package/bin/runners/runFirewall.d.ts +0 -5
- package/bin/runners/runFirewall.js +0 -137
- package/bin/runners/runFirewallHook.d.ts +0 -5
- package/bin/runners/runFirewallHook.js +0 -59
- package/bin/runners/runIaC.js +0 -372
- package/bin/runners/runPolish.d.ts +0 -4
- package/bin/runners/runProof.zip +0 -0
- package/bin/runners/runTruth.d.ts +0 -5
- package/bin/runners/runTruth.js +0 -104
- package/bin/runners/runVibe.js +0 -791
- package/mcp-server/HARDENING_SUMMARY.md +0 -299
- package/mcp-server/agent-firewall-interceptor.js +0 -500
- package/mcp-server/authority-tools.js +0 -569
- package/mcp-server/conductor/conflict-resolver.js +0 -588
- package/mcp-server/conductor/execution-planner.js +0 -544
- package/mcp-server/conductor/index.js +0 -377
- package/mcp-server/conductor/lock-manager.js +0 -615
- package/mcp-server/conductor/request-queue.js +0 -550
- package/mcp-server/conductor/session-manager.js +0 -500
- package/mcp-server/conductor/tools.js +0 -510
- package/mcp-server/lib/api-client.cjs +0 -13
- package/mcp-server/lib/logger.cjs +0 -30
- package/mcp-server/logger.js +0 -173
- package/mcp-server/tools-v3.js +0 -1039
- package/mcp-server/tools.js +0 -495
- package/mcp-server/vibecheck-mcp-server-3.2.0.tgz +0 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Analysis Core
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
2
|
+
* Analysis Core - Shared analysis engine for Ship and Scan
|
|
3
|
+
*
|
|
4
|
+
* Consolidates common logic:
|
|
5
|
+
* - Truthpack generation
|
|
6
|
+
* - Finding collection
|
|
7
|
+
* - Verdict calculation
|
|
8
|
+
* - Output formatting
|
|
9
|
+
*
|
|
10
|
+
* Ship = Fast path (core analyzers only)
|
|
11
|
+
* Scan = Deep path (core + extended analyzers + optional layers)
|
|
9
12
|
*/
|
|
10
13
|
|
|
11
14
|
const path = require("path");
|
|
@@ -23,108 +26,32 @@ const {
|
|
|
23
26
|
const { findingsFromReality } = require("./reality-findings");
|
|
24
27
|
|
|
25
28
|
// ============================================================================
|
|
26
|
-
//
|
|
27
|
-
// ============================================================================
|
|
28
|
-
|
|
29
|
-
/** @typedef {('BLOCK'|'WARN'|'INFO')} FindingSeverity */
|
|
30
|
-
/* ... (Existing typedefs omitted for brevity, assume they are present) ... */
|
|
31
|
-
|
|
32
|
-
// ============================================================================
|
|
33
|
-
// ANALYZER REGISTRY
|
|
34
|
-
// ============================================================================
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Core analyzers run on every 'ship' check.
|
|
38
|
-
* They must be fast (static analysis only, no network).
|
|
39
|
-
*/
|
|
40
|
-
const CORE_ANALYZERS = [
|
|
41
|
-
{ name: "missing-routes", fn: (r, t) => findMissingRoutes(t) },
|
|
42
|
-
{ name: "env-gaps", fn: (r, t) => findEnvGaps(t) },
|
|
43
|
-
{ name: "fake-success", fn: (r, t) => findFakeSuccess(r) }, // Uses root, not truthpack
|
|
44
|
-
{ name: "ghost-auth", fn: (r, t) => findGhostAuth(t, r) },
|
|
45
|
-
{ name: "stripe-safety", fn: (r, t) => findStripeWebhookViolations(t) },
|
|
46
|
-
{ name: "paid-surface", fn: (r, t) => findPaidSurfaceNotEnforced(t) },
|
|
47
|
-
{ name: "owner-bypass", fn: (r, t) => findOwnerModeBypass(r) },
|
|
48
|
-
{ name: "reality-check", fn: (r, t) => findingsFromReality(r) }
|
|
49
|
-
];
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Extended analyzers run only on 'scan' checks.
|
|
53
|
-
* Can include deeper/slower checks.
|
|
54
|
-
*/
|
|
55
|
-
const EXTENDED_ANALYZERS = [
|
|
56
|
-
// Example placeholder: { name: "deep-secret-scan", fn: ... }
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
// ============================================================================
|
|
60
|
-
// EXECUTION ENGINE
|
|
29
|
+
// CORE ANALYSIS (Used by both Ship and Scan)
|
|
61
30
|
// ============================================================================
|
|
62
31
|
|
|
63
32
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* @param {
|
|
67
|
-
* @
|
|
68
|
-
* @param {object} truthpack
|
|
69
|
-
* @returns {Promise<{findings: Finding[], timings: Record<string, number>}>}
|
|
33
|
+
* Run core analyzers that apply to all projects
|
|
34
|
+
* @param {string} root - Project root path
|
|
35
|
+
* @param {object} truthpack - Generated truthpack
|
|
36
|
+
* @returns {Array} - Array of findings
|
|
70
37
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (Array.isArray(result)) {
|
|
83
|
-
allFindings.push(...result);
|
|
84
|
-
}
|
|
85
|
-
} catch (err) {
|
|
86
|
-
// 🛡️ Safe Runner: Don't crash the whole scan if one rule fails
|
|
87
|
-
console.error(`[vibecheck] Analyzer '${tool.name}' crashed:`, err.message);
|
|
88
|
-
|
|
89
|
-
allFindings.push({
|
|
90
|
-
category: "SystemError",
|
|
91
|
-
severity: "WARN",
|
|
92
|
-
title: `Analyzer Failed: ${tool.name}`,
|
|
93
|
-
message: err.message,
|
|
94
|
-
why: "Internal analyzer error. This may hide issues.",
|
|
95
|
-
fixHints: ["Update vibecheck to the latest version", "Report this issue to support"]
|
|
96
|
-
});
|
|
97
|
-
} finally {
|
|
98
|
-
const end = process.hrtime(start);
|
|
99
|
-
// Convert [seconds, nanoseconds] to milliseconds
|
|
100
|
-
timings[tool.name] = (end[0] * 1000 + end[1] / 1e6).toFixed(2);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return { findings: dedupeFindings(allFindings), timings };
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Removes duplicate findings based on a content hash.
|
|
109
|
-
* * @param {Finding[]} findings
|
|
110
|
-
* @returns {Finding[]}
|
|
111
|
-
*/
|
|
112
|
-
function dedupeFindings(findings) {
|
|
113
|
-
const seen = new Set();
|
|
114
|
-
return findings.filter(f => {
|
|
115
|
-
// create a stable signature for the finding
|
|
116
|
-
const sig = `${f.category}|${f.title}|${f.evidence?.[0]?.file}|${f.evidence?.[0]?.line}`;
|
|
117
|
-
if (seen.has(sig)) return false;
|
|
118
|
-
seen.add(sig);
|
|
119
|
-
return true;
|
|
120
|
-
});
|
|
38
|
+
function runCoreAnalyzers(root, truthpack) {
|
|
39
|
+
return [
|
|
40
|
+
...findMissingRoutes(truthpack),
|
|
41
|
+
...findEnvGaps(truthpack),
|
|
42
|
+
...findFakeSuccess(root),
|
|
43
|
+
...findGhostAuth(truthpack, root),
|
|
44
|
+
...findStripeWebhookViolations(truthpack),
|
|
45
|
+
...findPaidSurfaceNotEnforced(truthpack),
|
|
46
|
+
...findOwnerModeBypass(root),
|
|
47
|
+
...findingsFromReality(root)
|
|
48
|
+
];
|
|
121
49
|
}
|
|
122
50
|
|
|
123
51
|
/**
|
|
124
|
-
* Calculate verdict from findings
|
|
125
|
-
*
|
|
126
|
-
* @
|
|
127
|
-
* @returns {('SHIP'|'WARN'|'BLOCK')}
|
|
52
|
+
* Calculate verdict from findings
|
|
53
|
+
* @param {Array} findings - Array of findings
|
|
54
|
+
* @returns {string} - SHIP | WARN | BLOCK
|
|
128
55
|
*/
|
|
129
56
|
function calculateVerdict(findings) {
|
|
130
57
|
if (findings.some(f => f.severity === "BLOCK")) return "BLOCK";
|
|
@@ -132,158 +59,213 @@ function calculateVerdict(findings) {
|
|
|
132
59
|
return "SHIP";
|
|
133
60
|
}
|
|
134
61
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Build proof graph from findings
|
|
64
|
+
* @param {Array} findings - Array of findings
|
|
65
|
+
* @param {object} truthpack - Truthpack data
|
|
66
|
+
* @param {string} root - Project root path
|
|
67
|
+
* @returns {object} - Proof graph
|
|
68
|
+
*/
|
|
141
69
|
function buildProofGraph(findings, truthpack, root) {
|
|
142
|
-
// ... (Keep existing logic, it was solid) ...
|
|
143
|
-
// Ensure we map over deduped findings
|
|
144
|
-
|
|
145
|
-
/** @type {ProofClaim[]} */
|
|
146
70
|
const claims = [];
|
|
147
71
|
let claimId = 0;
|
|
148
|
-
|
|
149
|
-
// Re-implementing just the loop to ensure variables are in scope
|
|
72
|
+
|
|
150
73
|
for (const finding of findings) {
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
74
|
+
const claim = {
|
|
75
|
+
id: `claim-${++claimId}`,
|
|
76
|
+
type: getClaimType(finding.category),
|
|
77
|
+
assertion: finding.title || finding.message,
|
|
78
|
+
verified: finding.severity !== 'BLOCK',
|
|
79
|
+
confidence: finding.confidence === 'high' ? 0.9 : finding.confidence === 'medium' ? 0.7 : 0.5,
|
|
80
|
+
evidence: (finding.evidence || []).map((e, i) => ({
|
|
81
|
+
id: `evidence-${claimId}-${i}`,
|
|
82
|
+
type: 'file_citation',
|
|
83
|
+
file: e.file,
|
|
84
|
+
line: parseInt(e.lines?.split('-')[0]) || e.line || 1,
|
|
85
|
+
snippet: e.snippetHash || '',
|
|
86
|
+
strength: 0.8,
|
|
87
|
+
verifiedAt: new Date().toISOString(),
|
|
88
|
+
method: 'static'
|
|
89
|
+
})),
|
|
90
|
+
gaps: [{
|
|
91
|
+
id: `gap-${claimId}`,
|
|
92
|
+
type: getGapType(finding.category),
|
|
93
|
+
description: finding.why || finding.title,
|
|
94
|
+
severity: finding.severity === 'BLOCK' ? 'critical' : finding.severity === 'WARN' ? 'medium' : 'low',
|
|
95
|
+
suggestion: (finding.fixHints || [])[0] || ''
|
|
96
|
+
}],
|
|
97
|
+
severity: finding.severity === 'BLOCK' ? 'critical' : finding.severity === 'WARN' ? 'medium' : 'low',
|
|
98
|
+
file: finding.evidence?.[0]?.file || '',
|
|
99
|
+
line: parseInt(finding.evidence?.[0]?.lines?.split('-')[0]) || 1
|
|
100
|
+
};
|
|
101
|
+
claims.push(claim);
|
|
174
102
|
}
|
|
175
|
-
|
|
176
|
-
|
|
103
|
+
|
|
104
|
+
const verifiedClaims = claims.filter(c => c.verified);
|
|
177
105
|
const failedClaims = claims.filter(c => !c.verified);
|
|
106
|
+
const allGaps = claims.flatMap(c => c.gaps);
|
|
107
|
+
|
|
108
|
+
const riskScore = Math.min(100, failedClaims.reduce((sum, c) => {
|
|
109
|
+
if (c.severity === 'critical') return sum + 30;
|
|
110
|
+
if (c.severity === 'high') return sum + 20;
|
|
111
|
+
if (c.severity === 'medium') return sum + 10;
|
|
112
|
+
return sum + 5;
|
|
113
|
+
}, 0));
|
|
114
|
+
|
|
115
|
+
const confidence = claims.length > 0
|
|
116
|
+
? claims.reduce((sum, c) => sum + c.confidence, 0) / claims.length
|
|
117
|
+
: 1.0;
|
|
178
118
|
|
|
179
119
|
return {
|
|
180
|
-
version:
|
|
120
|
+
version: '1.0.0',
|
|
181
121
|
generatedAt: new Date().toISOString(),
|
|
182
122
|
projectPath: root,
|
|
183
123
|
claims,
|
|
184
124
|
summary: {
|
|
185
125
|
totalClaims: claims.length,
|
|
186
|
-
verifiedClaims:
|
|
126
|
+
verifiedClaims: verifiedClaims.length,
|
|
187
127
|
failedClaims: failedClaims.length,
|
|
188
|
-
gaps:
|
|
189
|
-
riskScore
|
|
190
|
-
confidence
|
|
128
|
+
gaps: allGaps.length,
|
|
129
|
+
riskScore,
|
|
130
|
+
confidence
|
|
191
131
|
},
|
|
192
132
|
verdict: calculateVerdict(findings),
|
|
193
|
-
topBlockers: failedClaims.slice(0, 5),
|
|
194
|
-
topGaps:
|
|
133
|
+
topBlockers: failedClaims.filter(c => c.severity === 'critical' || c.severity === 'high').slice(0, 5),
|
|
134
|
+
topGaps: allGaps.filter(g => g.severity === 'critical' || g.severity === 'high').slice(0, 5)
|
|
195
135
|
};
|
|
196
136
|
}
|
|
197
137
|
|
|
138
|
+
function getClaimType(category) {
|
|
139
|
+
const map = {
|
|
140
|
+
'MissingRoute': 'route_exists',
|
|
141
|
+
'EnvContract': 'env_declared',
|
|
142
|
+
'FakeSuccess': 'success_verified',
|
|
143
|
+
'GhostAuth': 'auth_protected',
|
|
144
|
+
'StripeWebhook': 'billing_enforced',
|
|
145
|
+
'PaidSurface': 'billing_enforced',
|
|
146
|
+
'OwnerModeBypass': 'billing_enforced',
|
|
147
|
+
'DeadUI': 'ui_wired'
|
|
148
|
+
};
|
|
149
|
+
return map[category] || 'ui_wired';
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function getGapType(category) {
|
|
153
|
+
const map = {
|
|
154
|
+
'MissingRoute': 'missing_handler',
|
|
155
|
+
'EnvContract': 'missing_verification',
|
|
156
|
+
'FakeSuccess': 'missing_verification',
|
|
157
|
+
'GhostAuth': 'missing_gate',
|
|
158
|
+
'StripeWebhook': 'missing_verification',
|
|
159
|
+
'PaidSurface': 'missing_gate',
|
|
160
|
+
'OwnerModeBypass': 'missing_gate',
|
|
161
|
+
'DeadUI': 'missing_handler'
|
|
162
|
+
};
|
|
163
|
+
return map[category] || 'untested_path';
|
|
164
|
+
}
|
|
165
|
+
|
|
198
166
|
// ============================================================================
|
|
199
167
|
// UNIFIED ANALYSIS RUNNER
|
|
200
168
|
// ============================================================================
|
|
201
169
|
|
|
202
170
|
/**
|
|
203
|
-
* Run unified analysis (used by both ship and scan)
|
|
171
|
+
* Run unified analysis (used by both ship and scan)
|
|
172
|
+
* @param {object} options - Analysis options
|
|
173
|
+
* @returns {object} - Analysis result with findings, verdict, proofGraph
|
|
204
174
|
*/
|
|
205
|
-
async function runAnalysis({
|
|
206
|
-
repoRoot = process.cwd(),
|
|
175
|
+
async function runAnalysis({
|
|
176
|
+
repoRoot = process.cwd(),
|
|
207
177
|
fastifyEntry = null,
|
|
208
|
-
extended = false,
|
|
209
|
-
noWrite = false
|
|
178
|
+
extended = false, // If true, run extended analyzers (scan mode)
|
|
179
|
+
noWrite = false
|
|
210
180
|
} = {}) {
|
|
211
|
-
const root =
|
|
181
|
+
const root = repoRoot;
|
|
212
182
|
const fastEntry = fastifyEntry || detectFastifyEntry(root);
|
|
213
183
|
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
const truthpack = await buildTruthpack({
|
|
217
|
-
repoRoot: root,
|
|
218
|
-
fastifyEntry: fastEntry
|
|
219
|
-
});
|
|
220
|
-
|
|
184
|
+
// Build truthpack
|
|
185
|
+
const truthpack = await buildTruthpack({ repoRoot: root, fastifyEntry: fastEntry });
|
|
221
186
|
if (!noWrite) {
|
|
222
187
|
writeTruthpack(root, truthpack);
|
|
223
188
|
}
|
|
224
189
|
|
|
225
|
-
//
|
|
226
|
-
const
|
|
227
|
-
? [...CORE_ANALYZERS, ...EXTENDED_ANALYZERS]
|
|
228
|
-
: CORE_ANALYZERS;
|
|
229
|
-
|
|
230
|
-
// 3. Run Suite (Safe Mode)
|
|
231
|
-
const { findings, timings } = await runAnalyzerSuite(activeAnalyzers, root, truthpack);
|
|
190
|
+
// Run core analyzers
|
|
191
|
+
const findings = runCoreAnalyzers(root, truthpack);
|
|
232
192
|
|
|
233
|
-
//
|
|
193
|
+
// Calculate verdict
|
|
234
194
|
const verdict = calculateVerdict(findings);
|
|
235
|
-
// We pass original logic helpers here or keep buildProofGraph logic
|
|
236
|
-
const proofGraph = buildProofGraph(findings, truthpack, root);
|
|
237
195
|
|
|
238
|
-
//
|
|
196
|
+
// Build proof graph
|
|
197
|
+
const proofGraph = buildProofGraph(findings, truthpack, root);
|
|
198
|
+
|
|
199
|
+
// Build report
|
|
239
200
|
const report = {
|
|
240
|
-
meta: {
|
|
241
|
-
generatedAt: new Date().toISOString(),
|
|
201
|
+
meta: {
|
|
202
|
+
generatedAt: new Date().toISOString(),
|
|
242
203
|
verdict,
|
|
243
|
-
mode: extended ?
|
|
244
|
-
timings // ⏱️ New: Expose perf metrics
|
|
204
|
+
mode: extended ? 'scan' : 'ship'
|
|
245
205
|
},
|
|
246
206
|
truthpackHash: truthpack.index?.hashes?.truthpackHash,
|
|
247
207
|
findings,
|
|
248
208
|
proofGraph: {
|
|
249
209
|
summary: proofGraph.summary,
|
|
250
|
-
topBlockers: proofGraph.topBlockers,
|
|
251
|
-
topGaps: proofGraph.topGaps
|
|
210
|
+
topBlockers: proofGraph.topBlockers.slice(0, 5),
|
|
211
|
+
topGaps: proofGraph.topGaps.slice(0, 5)
|
|
252
212
|
}
|
|
253
213
|
};
|
|
254
214
|
|
|
255
|
-
//
|
|
215
|
+
// Write outputs
|
|
256
216
|
if (!noWrite) {
|
|
257
217
|
const outDir = path.join(root, ".vibecheck");
|
|
258
218
|
fs.mkdirSync(outDir, { recursive: true });
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
fs.writeFileSync(
|
|
263
|
-
path.join(outDir, reportName),
|
|
264
|
-
JSON.stringify(report, null, 2),
|
|
265
|
-
"utf8"
|
|
266
|
-
);
|
|
267
|
-
|
|
268
|
-
// Also write proof graph separately for UI consumption
|
|
269
|
-
fs.writeFileSync(
|
|
270
|
-
path.join(outDir, "proof-graph.json"),
|
|
271
|
-
JSON.stringify(proofGraph, null, 2),
|
|
272
|
-
"utf8"
|
|
273
|
-
);
|
|
219
|
+
fs.writeFileSync(path.join(outDir, "last_ship.json"), JSON.stringify(report, null, 2));
|
|
220
|
+
fs.writeFileSync(path.join(outDir, "proof-graph.json"), JSON.stringify(proofGraph, null, 2));
|
|
274
221
|
}
|
|
275
222
|
|
|
276
223
|
return { report, truthpack, verdict, proofGraph, findings };
|
|
277
224
|
}
|
|
278
225
|
|
|
279
226
|
// ============================================================================
|
|
280
|
-
//
|
|
227
|
+
// FINDING UTILITIES
|
|
281
228
|
// ============================================================================
|
|
282
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Group findings by category
|
|
232
|
+
*/
|
|
233
|
+
function groupFindings(findings) {
|
|
234
|
+
const groups = {};
|
|
235
|
+
for (const f of findings) {
|
|
236
|
+
const cat = f.category || 'Other';
|
|
237
|
+
if (!groups[cat]) groups[cat] = [];
|
|
238
|
+
groups[cat].push(f);
|
|
239
|
+
}
|
|
240
|
+
return groups;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Count findings by severity
|
|
245
|
+
*/
|
|
246
|
+
function countBySeverity(findings) {
|
|
247
|
+
return {
|
|
248
|
+
block: findings.filter(f => f.severity === 'BLOCK').length,
|
|
249
|
+
warn: findings.filter(f => f.severity === 'WARN').length,
|
|
250
|
+
info: findings.filter(f => f.severity === 'INFO').length
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Get top N blockers
|
|
256
|
+
*/
|
|
257
|
+
function getTopBlockers(findings, n = 5) {
|
|
258
|
+
return findings
|
|
259
|
+
.filter(f => f.severity === 'BLOCK')
|
|
260
|
+
.slice(0, n);
|
|
261
|
+
}
|
|
262
|
+
|
|
283
263
|
module.exports = {
|
|
284
|
-
|
|
285
|
-
// Export helpers for testing
|
|
264
|
+
runCoreAnalyzers,
|
|
286
265
|
calculateVerdict,
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
266
|
+
buildProofGraph,
|
|
267
|
+
runAnalysis,
|
|
268
|
+
groupFindings,
|
|
269
|
+
countBySeverity,
|
|
270
|
+
getTopBlockers
|
|
271
|
+
};
|