@vibecheckai/cli 2.8.2 → 3.0.0
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/README.md +8 -8
- package/bin/_deprecations.js +35 -0
- package/bin/_router.js +46 -0
- package/bin/cli-hygiene.js +241 -0
- package/bin/guardrail.js +834 -0
- package/bin/runners/cli-utils.js +1070 -0
- package/bin/runners/context/ai-task-decomposer.js +337 -0
- package/bin/runners/context/analyzer.js +462 -0
- package/bin/runners/context/api-contracts.js +427 -0
- package/bin/runners/context/context-diff.js +342 -0
- package/bin/runners/context/context-pruner.js +291 -0
- package/bin/runners/context/dependency-graph.js +414 -0
- package/bin/runners/context/generators/claude.js +107 -0
- package/bin/runners/context/generators/codex.js +108 -0
- package/bin/runners/context/generators/copilot.js +119 -0
- package/bin/runners/context/generators/cursor.js +514 -0
- package/bin/runners/context/generators/mcp.js +151 -0
- package/bin/runners/context/generators/windsurf.js +180 -0
- package/bin/runners/context/git-context.js +302 -0
- package/bin/runners/context/index.js +1042 -0
- package/bin/runners/context/insights.js +173 -0
- package/bin/runners/context/mcp-server/generate-rules.js +337 -0
- package/bin/runners/context/mcp-server/index.js +1176 -0
- package/bin/runners/context/mcp-server/package.json +24 -0
- package/bin/runners/context/memory.js +200 -0
- package/bin/runners/context/monorepo.js +215 -0
- package/bin/runners/context/multi-repo-federation.js +404 -0
- package/bin/runners/context/patterns.js +253 -0
- package/bin/runners/context/proof-context.js +972 -0
- package/bin/runners/context/security-scanner.js +303 -0
- package/bin/runners/context/semantic-search.js +350 -0
- package/bin/runners/context/shared.js +264 -0
- package/bin/runners/context/team-conventions.js +310 -0
- package/bin/runners/lib/ai-bridge.js +416 -0
- package/bin/runners/lib/analysis-core.js +271 -0
- package/bin/runners/lib/analyzers.js +541 -0
- package/bin/runners/lib/audit-bridge.js +391 -0
- package/bin/runners/lib/auth-truth.js +193 -0
- package/bin/runners/lib/auth.js +215 -0
- package/bin/runners/lib/backup.js +62 -0
- package/bin/runners/lib/billing.js +107 -0
- package/bin/runners/lib/claims.js +118 -0
- package/bin/runners/lib/cli-ui.js +540 -0
- package/bin/runners/lib/compliance-bridge-new.js +0 -0
- package/bin/runners/lib/compliance-bridge.js +165 -0
- package/bin/runners/lib/contracts/auth-contract.js +194 -0
- package/bin/runners/lib/contracts/env-contract.js +178 -0
- package/bin/runners/lib/contracts/external-contract.js +198 -0
- package/bin/runners/lib/contracts/guard.js +168 -0
- package/bin/runners/lib/contracts/index.js +89 -0
- package/bin/runners/lib/contracts/plan-validator.js +311 -0
- package/bin/runners/lib/contracts/route-contract.js +192 -0
- package/bin/runners/lib/detect.js +89 -0
- package/bin/runners/lib/doctor/autofix.js +254 -0
- package/bin/runners/lib/doctor/index.js +37 -0
- package/bin/runners/lib/doctor/modules/dependencies.js +325 -0
- package/bin/runners/lib/doctor/modules/index.js +46 -0
- package/bin/runners/lib/doctor/modules/network.js +250 -0
- package/bin/runners/lib/doctor/modules/project.js +312 -0
- package/bin/runners/lib/doctor/modules/runtime.js +224 -0
- package/bin/runners/lib/doctor/modules/security.js +348 -0
- package/bin/runners/lib/doctor/modules/system.js +213 -0
- package/bin/runners/lib/doctor/modules/vibecheck.js +394 -0
- package/bin/runners/lib/doctor/reporter.js +262 -0
- package/bin/runners/lib/doctor/service.js +262 -0
- package/bin/runners/lib/doctor/types.js +113 -0
- package/bin/runners/lib/doctor/ui.js +263 -0
- package/bin/runners/lib/doctor-enhanced.js +233 -0
- package/bin/runners/lib/doctor-v2.js +608 -0
- package/bin/runners/lib/enforcement.js +72 -0
- package/bin/runners/lib/enterprise-detect.js +603 -0
- package/bin/runners/lib/enterprise-init.js +942 -0
- package/bin/runners/lib/entitlements-v2.js +381 -0
- package/bin/runners/lib/entitlements.generated.js +0 -0
- package/bin/runners/lib/entitlements.js +332 -0
- package/bin/runners/lib/env-template.js +66 -0
- package/bin/runners/lib/env.js +189 -0
- package/bin/runners/lib/error-handler.js +320 -0
- package/bin/runners/lib/firewall-prompt.js +50 -0
- package/bin/runners/lib/graph/graph-builder.js +265 -0
- package/bin/runners/lib/graph/html-renderer.js +413 -0
- package/bin/runners/lib/graph/index.js +32 -0
- package/bin/runners/lib/graph/runtime-collector.js +215 -0
- package/bin/runners/lib/graph/static-extractor.js +518 -0
- package/bin/runners/lib/init-wizard.js +308 -0
- package/bin/runners/lib/json-output.js +76 -0
- package/bin/runners/lib/llm.js +75 -0
- package/bin/runners/lib/meter.js +61 -0
- package/bin/runners/lib/missions/evidence.js +126 -0
- package/bin/runners/lib/missions/plan.js +69 -0
- package/bin/runners/lib/missions/templates.js +147 -0
- package/bin/runners/lib/patch.js +40 -0
- package/bin/runners/lib/permissions/auth-model.js +213 -0
- package/bin/runners/lib/permissions/idor-prover.js +205 -0
- package/bin/runners/lib/permissions/index.js +45 -0
- package/bin/runners/lib/permissions/matrix-builder.js +198 -0
- package/bin/runners/lib/pkgjson.js +28 -0
- package/bin/runners/lib/preflight.js +142 -0
- package/bin/runners/lib/reality-findings.js +84 -0
- package/bin/runners/lib/redact.js +29 -0
- package/bin/runners/lib/replay/capsule-manager.js +154 -0
- package/bin/runners/lib/replay/index.js +263 -0
- package/bin/runners/lib/replay/player.js +348 -0
- package/bin/runners/lib/replay/recorder.js +331 -0
- package/bin/runners/lib/report-engine.js +447 -0
- package/bin/runners/lib/report-html.js +1117 -0
- package/bin/runners/lib/report-templates.js +964 -0
- package/bin/runners/lib/route-detection.js +1140 -0
- package/bin/runners/lib/route-truth.js +477 -0
- package/bin/runners/lib/sandbox/index.js +59 -0
- package/bin/runners/lib/sandbox/proof-chain.js +399 -0
- package/bin/runners/lib/sandbox/sandbox-runner.js +205 -0
- package/bin/runners/lib/sandbox/worktree.js +174 -0
- package/bin/runners/lib/scan-cache.js +330 -0
- package/bin/runners/lib/scan-output-schema.js +344 -0
- package/bin/runners/lib/score-history.js +282 -0
- package/bin/runners/lib/security-bridge.js +249 -0
- package/bin/runners/lib/server-usage.js +513 -0
- package/bin/runners/lib/share-pack.js +239 -0
- package/bin/runners/lib/snippets.js +67 -0
- package/bin/runners/lib/truth.js +667 -0
- package/bin/runners/lib/unified-output.js +189 -0
- package/bin/runners/lib/validate-patch.js +156 -0
- package/bin/runners/lib/verification.js +345 -0
- package/bin/runners/reality/engine.js +917 -0
- package/bin/runners/reality/flows.js +122 -0
- package/bin/runners/reality/report.js +378 -0
- package/bin/runners/reality/session.js +193 -0
- package/bin/runners/runAIAgent.js +2 -0
- package/bin/runners/runAudit.js +2 -0
- package/bin/runners/runAuth.js +106 -0
- package/bin/runners/runAutopilot.js +2 -0
- package/bin/runners/runBadge.js +2 -0
- package/bin/runners/runCertify.js +2 -0
- package/bin/runners/runClaimVerifier.js +483 -0
- package/bin/runners/runContext.js +56 -0
- package/bin/runners/runContextCompiler.js +385 -0
- package/bin/runners/runCtx.js +187 -0
- package/bin/runners/runCtxGuard.js +176 -0
- package/bin/runners/runCtxSync.js +116 -0
- package/bin/runners/runDashboard.js +10 -0
- package/bin/runners/runDoctor.js +245 -0
- package/bin/runners/runEnhancedShip.js +2 -0
- package/bin/runners/runFix.js +735 -0
- package/bin/runners/runFixPacks.js +2 -0
- package/bin/runners/runGate.js +17 -0
- package/bin/runners/runGraph.js +283 -0
- package/bin/runners/runInit.js +260 -0
- package/bin/runners/runInitGha.js +101 -0
- package/bin/runners/runInstall.js +76 -0
- package/bin/runners/runInteractive.js +388 -0
- package/bin/runners/runLaunch.js +2 -0
- package/bin/runners/runMcp.js +19 -0
- package/bin/runners/runMdc.js +2 -0
- package/bin/runners/runMissionGenerator.js +282 -0
- package/bin/runners/runNaturalLanguage.js +3 -0
- package/bin/runners/runPR.js +96 -0
- package/bin/runners/runPermissions.js +290 -0
- package/bin/runners/runPromptFirewall.js +211 -0
- package/bin/runners/runProof.js +2 -0
- package/bin/runners/runProve.js +392 -0
- package/bin/runners/runReality.js +489 -0
- package/bin/runners/runRealitySniff.js +2 -0
- package/bin/runners/runReplay.js +469 -0
- package/bin/runners/runReport.js +478 -0
- package/bin/runners/runScan.js +835 -0
- package/bin/runners/runShare.js +34 -0
- package/bin/runners/runShip.js +1062 -0
- package/bin/runners/runStatus.js +136 -0
- package/bin/runners/runTruthpack.js +634 -0
- package/bin/runners/runUpgrade.js +2 -0
- package/bin/runners/runValidate.js +2 -0
- package/bin/runners/runVerifyAgentOutput.js +2 -0
- package/bin/runners/runWatch.js +230 -0
- package/bin/runners/utils.js +360 -0
- package/bin/scan.js +612 -0
- package/bin/vibecheck.js +834 -0
- package/package.json +11 -11
- package/dist/autopatch/verified-autopatch.d.ts +0 -111
- package/dist/autopatch/verified-autopatch.d.ts.map +0 -1
- package/dist/autopatch/verified-autopatch.js +0 -503
- package/dist/autopatch/verified-autopatch.js.map +0 -1
- package/dist/bundles/index.js +0 -8
- package/dist/bundles/vibecheck-core.js +0 -25799
- package/dist/bundles/vibecheck-security.js +0 -208693
- package/dist/bundles/vibecheck-ship.js +0 -2318
- package/dist/commands/baseline.d.ts +0 -7
- package/dist/commands/baseline.d.ts.map +0 -1
- package/dist/commands/baseline.js +0 -79
- package/dist/commands/baseline.js.map +0 -1
- package/dist/commands/cache.d.ts +0 -13
- package/dist/commands/cache.d.ts.map +0 -1
- package/dist/commands/cache.js +0 -165
- package/dist/commands/cache.js.map +0 -1
- package/dist/commands/checkpoint.d.ts +0 -8
- package/dist/commands/checkpoint.d.ts.map +0 -1
- package/dist/commands/checkpoint.js +0 -35
- package/dist/commands/checkpoint.js.map +0 -1
- package/dist/commands/doctor.d.ts +0 -17
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -226
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/evidence.d.ts +0 -45
- package/dist/commands/evidence.d.ts.map +0 -1
- package/dist/commands/evidence.js +0 -197
- package/dist/commands/evidence.js.map +0 -1
- package/dist/commands/explain.d.ts +0 -8
- package/dist/commands/explain.d.ts.map +0 -1
- package/dist/commands/explain.js +0 -52
- package/dist/commands/explain.js.map +0 -1
- package/dist/commands/fix-consolidated.d.ts +0 -19
- package/dist/commands/fix-consolidated.d.ts.map +0 -1
- package/dist/commands/fix-consolidated.js +0 -165
- package/dist/commands/fix-consolidated.js.map +0 -1
- package/dist/commands/index.d.ts +0 -8
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js +0 -15
- package/dist/commands/index.js.map +0 -1
- package/dist/commands/init.d.ts +0 -8
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -125
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/launcher.d.ts +0 -10
- package/dist/commands/launcher.d.ts.map +0 -1
- package/dist/commands/launcher.js +0 -174
- package/dist/commands/launcher.js.map +0 -1
- package/dist/commands/on.d.ts +0 -8
- package/dist/commands/on.d.ts.map +0 -1
- package/dist/commands/on.js +0 -123
- package/dist/commands/on.js.map +0 -1
- package/dist/commands/replay.d.ts +0 -8
- package/dist/commands/replay.d.ts.map +0 -1
- package/dist/commands/replay.js +0 -52
- package/dist/commands/replay.js.map +0 -1
- package/dist/commands/scan-consolidated.d.ts +0 -61
- package/dist/commands/scan-consolidated.d.ts.map +0 -1
- package/dist/commands/scan-consolidated.js +0 -243
- package/dist/commands/scan-consolidated.js.map +0 -1
- package/dist/commands/scan-secrets.d.ts +0 -47
- package/dist/commands/scan-secrets.d.ts.map +0 -1
- package/dist/commands/scan-secrets.js +0 -225
- package/dist/commands/scan-secrets.js.map +0 -1
- package/dist/commands/scan-vulnerabilities-enhanced.d.ts +0 -41
- package/dist/commands/scan-vulnerabilities-enhanced.d.ts.map +0 -1
- package/dist/commands/scan-vulnerabilities-enhanced.js +0 -368
- package/dist/commands/scan-vulnerabilities-enhanced.js.map +0 -1
- package/dist/commands/scan-vulnerabilities-osv.d.ts +0 -58
- package/dist/commands/scan-vulnerabilities-osv.d.ts.map +0 -1
- package/dist/commands/scan-vulnerabilities-osv.js +0 -722
- package/dist/commands/scan-vulnerabilities-osv.js.map +0 -1
- package/dist/commands/scan-vulnerabilities.d.ts +0 -32
- package/dist/commands/scan-vulnerabilities.d.ts.map +0 -1
- package/dist/commands/scan-vulnerabilities.js +0 -283
- package/dist/commands/scan-vulnerabilities.js.map +0 -1
- package/dist/commands/secrets-allowlist.d.ts +0 -7
- package/dist/commands/secrets-allowlist.d.ts.map +0 -1
- package/dist/commands/secrets-allowlist.js +0 -85
- package/dist/commands/secrets-allowlist.js.map +0 -1
- package/dist/commands/ship-consolidated.d.ts +0 -58
- package/dist/commands/ship-consolidated.d.ts.map +0 -1
- package/dist/commands/ship-consolidated.js +0 -515
- package/dist/commands/ship-consolidated.js.map +0 -1
- package/dist/commands/stats.d.ts +0 -8
- package/dist/commands/stats.d.ts.map +0 -1
- package/dist/commands/stats.js +0 -134
- package/dist/commands/stats.js.map +0 -1
- package/dist/commands/upgrade.d.ts +0 -8
- package/dist/commands/upgrade.d.ts.map +0 -1
- package/dist/commands/upgrade.js +0 -30
- package/dist/commands/upgrade.js.map +0 -1
- package/dist/fix/applicator.d.ts +0 -44
- package/dist/fix/applicator.d.ts.map +0 -1
- package/dist/fix/applicator.js +0 -144
- package/dist/fix/applicator.js.map +0 -1
- package/dist/fix/backup.d.ts +0 -38
- package/dist/fix/backup.d.ts.map +0 -1
- package/dist/fix/backup.js +0 -154
- package/dist/fix/backup.js.map +0 -1
- package/dist/fix/engine.d.ts +0 -55
- package/dist/fix/engine.d.ts.map +0 -1
- package/dist/fix/engine.js +0 -285
- package/dist/fix/engine.js.map +0 -1
- package/dist/fix/index.d.ts +0 -5
- package/dist/fix/index.d.ts.map +0 -1
- package/dist/fix/index.js +0 -12
- package/dist/fix/index.js.map +0 -1
- package/dist/fix/interactive.d.ts +0 -22
- package/dist/fix/interactive.d.ts.map +0 -1
- package/dist/fix/interactive.js +0 -172
- package/dist/fix/interactive.js.map +0 -1
- package/dist/formatters/index.d.ts +0 -6
- package/dist/formatters/index.d.ts.map +0 -1
- package/dist/formatters/index.js +0 -11
- package/dist/formatters/index.js.map +0 -1
- package/dist/formatters/sarif-enhanced.d.ts +0 -78
- package/dist/formatters/sarif-enhanced.d.ts.map +0 -1
- package/dist/formatters/sarif-enhanced.js +0 -144
- package/dist/formatters/sarif-enhanced.js.map +0 -1
- package/dist/formatters/sarif-v2.d.ts +0 -121
- package/dist/formatters/sarif-v2.d.ts.map +0 -1
- package/dist/formatters/sarif-v2.js +0 -356
- package/dist/formatters/sarif-v2.js.map +0 -1
- package/dist/formatters/sarif.d.ts +0 -72
- package/dist/formatters/sarif.d.ts.map +0 -1
- package/dist/formatters/sarif.js +0 -146
- package/dist/formatters/sarif.js.map +0 -1
- package/dist/index.d.ts +0 -61
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4388
- package/dist/index.js.map +0 -1
- package/dist/init/ci-generator.d.ts +0 -18
- package/dist/init/ci-generator.d.ts.map +0 -1
- package/dist/init/ci-generator.js +0 -317
- package/dist/init/ci-generator.js.map +0 -1
- package/dist/init/detect-framework.d.ts +0 -15
- package/dist/init/detect-framework.d.ts.map +0 -1
- package/dist/init/detect-framework.js +0 -301
- package/dist/init/detect-framework.js.map +0 -1
- package/dist/init/hooks-installer.d.ts +0 -22
- package/dist/init/hooks-installer.d.ts.map +0 -1
- package/dist/init/hooks-installer.js +0 -310
- package/dist/init/hooks-installer.js.map +0 -1
- package/dist/init/index.d.ts +0 -8
- package/dist/init/index.d.ts.map +0 -1
- package/dist/init/index.js +0 -22
- package/dist/init/index.js.map +0 -1
- package/dist/init/templates.d.ts +0 -402
- package/dist/init/templates.d.ts.map +0 -1
- package/dist/init/templates.js +0 -240
- package/dist/init/templates.js.map +0 -1
- package/dist/mcp/server.d.ts +0 -12
- package/dist/mcp/server.d.ts.map +0 -1
- package/dist/mcp/server.js +0 -42
- package/dist/mcp/server.js.map +0 -1
- package/dist/mcp/telemetry.d.ts +0 -40
- package/dist/mcp/telemetry.d.ts.map +0 -1
- package/dist/mcp/telemetry.js +0 -98
- package/dist/mcp/telemetry.js.map +0 -1
- package/dist/reality/no-dead-buttons/button-sweep-generator.d.ts +0 -32
- package/dist/reality/no-dead-buttons/button-sweep-generator.d.ts.map +0 -1
- package/dist/reality/no-dead-buttons/button-sweep-generator.js +0 -236
- package/dist/reality/no-dead-buttons/button-sweep-generator.js.map +0 -1
- package/dist/reality/no-dead-buttons/index.d.ts +0 -11
- package/dist/reality/no-dead-buttons/index.d.ts.map +0 -1
- package/dist/reality/no-dead-buttons/index.js +0 -18
- package/dist/reality/no-dead-buttons/index.js.map +0 -1
- package/dist/reality/no-dead-buttons/static-scanner.d.ts +0 -34
- package/dist/reality/no-dead-buttons/static-scanner.d.ts.map +0 -1
- package/dist/reality/no-dead-buttons/static-scanner.js +0 -230
- package/dist/reality/no-dead-buttons/static-scanner.js.map +0 -1
- package/dist/reality/reality-graph.d.ts +0 -192
- package/dist/reality/reality-graph.d.ts.map +0 -1
- package/dist/reality/reality-graph.js +0 -600
- package/dist/reality/reality-graph.js.map +0 -1
- package/dist/reality/reality-runner.d.ts +0 -89
- package/dist/reality/reality-runner.d.ts.map +0 -1
- package/dist/reality/reality-runner.js +0 -540
- package/dist/reality/reality-runner.js.map +0 -1
- package/dist/reality/receipt-generator.d.ts +0 -152
- package/dist/reality/receipt-generator.d.ts.map +0 -1
- package/dist/reality/receipt-generator.js +0 -495
- package/dist/reality/receipt-generator.js.map +0 -1
- package/dist/reality/runtime-tracer.d.ts +0 -75
- package/dist/reality/runtime-tracer.d.ts.map +0 -1
- package/dist/reality/runtime-tracer.js +0 -109
- package/dist/reality/runtime-tracer.js.map +0 -1
- package/dist/runtime/auth-utils.d.ts +0 -43
- package/dist/runtime/auth-utils.d.ts.map +0 -1
- package/dist/runtime/auth-utils.js +0 -130
- package/dist/runtime/auth-utils.js.map +0 -1
- package/dist/runtime/client.d.ts +0 -74
- package/dist/runtime/client.d.ts.map +0 -1
- package/dist/runtime/client.js +0 -222
- package/dist/runtime/client.js.map +0 -1
- package/dist/runtime/creds.d.ts +0 -48
- package/dist/runtime/creds.d.ts.map +0 -1
- package/dist/runtime/creds.js +0 -245
- package/dist/runtime/creds.js.map +0 -1
- package/dist/runtime/exit-codes.d.ts +0 -49
- package/dist/runtime/exit-codes.d.ts.map +0 -1
- package/dist/runtime/exit-codes.js +0 -93
- package/dist/runtime/exit-codes.js.map +0 -1
- package/dist/runtime/index.d.ts +0 -9
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js +0 -25
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/json-output.d.ts +0 -42
- package/dist/runtime/json-output.d.ts.map +0 -1
- package/dist/runtime/json-output.js +0 -59
- package/dist/runtime/json-output.js.map +0 -1
- package/dist/runtime/semver.d.ts +0 -37
- package/dist/runtime/semver.d.ts.map +0 -1
- package/dist/runtime/semver.js +0 -110
- package/dist/runtime/semver.js.map +0 -1
- package/dist/scan/dead-ui-detector.d.ts +0 -48
- package/dist/scan/dead-ui-detector.d.ts.map +0 -1
- package/dist/scan/dead-ui-detector.js +0 -170
- package/dist/scan/dead-ui-detector.js.map +0 -1
- package/dist/scan/playwright-sweep.d.ts +0 -40
- package/dist/scan/playwright-sweep.d.ts.map +0 -1
- package/dist/scan/playwright-sweep.js +0 -216
- package/dist/scan/playwright-sweep.js.map +0 -1
- package/dist/scan/proof-bundle.d.ts +0 -25
- package/dist/scan/proof-bundle.d.ts.map +0 -1
- package/dist/scan/proof-bundle.js +0 -203
- package/dist/scan/proof-bundle.js.map +0 -1
- package/dist/scan/proof-graph.d.ts +0 -59
- package/dist/scan/proof-graph.d.ts.map +0 -1
- package/dist/scan/proof-graph.js +0 -64
- package/dist/scan/proof-graph.js.map +0 -1
- package/dist/scan/reality-sniff.d.ts +0 -56
- package/dist/scan/reality-sniff.d.ts.map +0 -1
- package/dist/scan/reality-sniff.js +0 -200
- package/dist/scan/reality-sniff.js.map +0 -1
- package/dist/scan/structural-verifier.d.ts +0 -20
- package/dist/scan/structural-verifier.d.ts.map +0 -1
- package/dist/scan/structural-verifier.js +0 -112
- package/dist/scan/structural-verifier.js.map +0 -1
- package/dist/scan/verification-engine.d.ts +0 -47
- package/dist/scan/verification-engine.d.ts.map +0 -1
- package/dist/scan/verification-engine.js +0 -141
- package/dist/scan/verification-engine.js.map +0 -1
- package/dist/scanner/baseline.d.ts +0 -52
- package/dist/scanner/baseline.d.ts.map +0 -1
- package/dist/scanner/baseline.js +0 -85
- package/dist/scanner/baseline.js.map +0 -1
- package/dist/scanner/incremental.d.ts +0 -30
- package/dist/scanner/incremental.d.ts.map +0 -1
- package/dist/scanner/incremental.js +0 -82
- package/dist/scanner/incremental.js.map +0 -1
- package/dist/scanner/parallel.d.ts +0 -43
- package/dist/scanner/parallel.d.ts.map +0 -1
- package/dist/scanner/parallel.js +0 -99
- package/dist/scanner/parallel.js.map +0 -1
- package/dist/standalone.d.ts +0 -1
- package/dist/standalone.d.ts.map +0 -1
- package/dist/standalone.js +0 -1
- package/dist/standalone.js.map +0 -1
- package/dist/truth-pack/index.d.ts +0 -102
- package/dist/truth-pack/index.d.ts.map +0 -1
- package/dist/truth-pack/index.js +0 -694
- package/dist/truth-pack/index.js.map +0 -1
- package/dist/ui/frame.d.ts +0 -68
- package/dist/ui/frame.d.ts.map +0 -1
- package/dist/ui/frame.js +0 -165
- package/dist/ui/frame.js.map +0 -1
- package/dist/ui/index.d.ts +0 -5
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/index.js +0 -16
- package/dist/ui/index.js.map +0 -1
- package/dist/ui.d.ts +0 -36
- package/dist/ui.d.ts.map +0 -1
- package/dist/ui.js +0 -45
- package/dist/ui.js.map +0 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// bin/runners/lib/env-template.js
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
function ensureDir(p) {
|
|
6
|
+
fs.mkdirSync(p, { recursive: true });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function pickEnvTemplatePath(root) {
|
|
10
|
+
const candidates = [".env.template", ".env.example", ".env.sample"];
|
|
11
|
+
for (const c of candidates) {
|
|
12
|
+
const abs = path.join(root, c);
|
|
13
|
+
if (fs.existsSync(abs)) return c;
|
|
14
|
+
}
|
|
15
|
+
return ".env.template";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function normalizeEnvName(n) {
|
|
19
|
+
return String(n || "").trim();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function parseDeclaredEnvFromText(text) {
|
|
23
|
+
const declared = new Set();
|
|
24
|
+
const lines = String(text || "").split(/\r?\n/);
|
|
25
|
+
for (const l of lines) {
|
|
26
|
+
if (!l || l.trim().startsWith("#")) continue;
|
|
27
|
+
const m = l.match(/^([A-Z0-9_]+)\s*=/);
|
|
28
|
+
if (m) declared.add(m[1]);
|
|
29
|
+
}
|
|
30
|
+
return declared;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function writeEnvTemplateFromTruthpack(root, truthpack) {
|
|
34
|
+
const outRel = pickEnvTemplatePath(root);
|
|
35
|
+
const outAbs = path.join(root, outRel);
|
|
36
|
+
|
|
37
|
+
const used = new Set((truthpack?.env?.vars || []).map(normalizeEnvName).filter(Boolean));
|
|
38
|
+
|
|
39
|
+
let existingText = "";
|
|
40
|
+
if (fs.existsSync(outAbs)) existingText = fs.readFileSync(outAbs, "utf8");
|
|
41
|
+
|
|
42
|
+
const declared = parseDeclaredEnvFromText(existingText);
|
|
43
|
+
const missing = Array.from(used).filter((x) => !declared.has(x)).sort();
|
|
44
|
+
|
|
45
|
+
if (!missing.length && fs.existsSync(outAbs)) {
|
|
46
|
+
return { outRel, wrote: false, added: [] };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const header =
|
|
50
|
+
`# vibecheck env template
|
|
51
|
+
# This file is generated/extended from REAL env usage found in your code.
|
|
52
|
+
# Fill values in your real .env (never commit secrets).
|
|
53
|
+
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const additions = missing.map((k) => `${k}=\n`).join("");
|
|
57
|
+
|
|
58
|
+
const nextText = (existingText.trim().length ? existingText.trimEnd() + "\n\n" : header) + additions;
|
|
59
|
+
|
|
60
|
+
ensureDir(path.dirname(outAbs));
|
|
61
|
+
fs.writeFileSync(outAbs, nextText, "utf8");
|
|
62
|
+
|
|
63
|
+
return { outRel, wrote: true, added: missing };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = { writeEnvTemplateFromTruthpack };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// bin/runners/lib/env.js
|
|
2
|
+
const fg = require("fast-glob");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const parser = require("@babel/parser");
|
|
6
|
+
const traverse = require("@babel/traverse").default;
|
|
7
|
+
const t = require("@babel/types");
|
|
8
|
+
const crypto = require("crypto");
|
|
9
|
+
|
|
10
|
+
function sha256(text) {
|
|
11
|
+
return "sha256:" + crypto.createHash("sha256").update(text).digest("hex");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function parseFile(code) {
|
|
15
|
+
return parser.parse(code, { sourceType: "unambiguous", plugins: ["typescript", "jsx"] });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function safeRead(fileAbs) {
|
|
19
|
+
return fs.readFileSync(fileAbs, "utf8");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function evidenceFromLoc({ fileAbs, fileRel, loc, reason }) {
|
|
23
|
+
if (!loc) return null;
|
|
24
|
+
const lines = safeRead(fileAbs).split(/\r?\n/);
|
|
25
|
+
const start = Math.max(1, loc.start?.line || 1);
|
|
26
|
+
const end = Math.max(start, loc.end?.line || start);
|
|
27
|
+
const snippet = lines.slice(start - 1, end).join("\n");
|
|
28
|
+
return {
|
|
29
|
+
id: `ev_${crypto.randomBytes(4).toString("hex")}`,
|
|
30
|
+
file: fileRel,
|
|
31
|
+
lines: `${start}-${end}`,
|
|
32
|
+
snippetHash: sha256(snippet),
|
|
33
|
+
reason
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function mergeEvidenceMap(map, name, ev) {
|
|
38
|
+
map[name] = map[name] || { name, references: [], signals: { hasDefault: false } };
|
|
39
|
+
if (ev) map[name].references.push(ev);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function isEnvName(s) {
|
|
43
|
+
return typeof s === "string" && /^[A-Z0-9_]+$/.test(s);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function extractEnvFromMemberExpr(node) {
|
|
47
|
+
if (!t.isMemberExpression(node)) return null;
|
|
48
|
+
|
|
49
|
+
// process.env.NAME
|
|
50
|
+
if (t.isMemberExpression(node.object) &&
|
|
51
|
+
t.isIdentifier(node.object.object, { name: "process" }) &&
|
|
52
|
+
t.isIdentifier(node.object.property, { name: "env" }) &&
|
|
53
|
+
t.isIdentifier(node.property)) {
|
|
54
|
+
return node.property.name;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// process.env["NAME"]
|
|
58
|
+
if (t.isMemberExpression(node.object) &&
|
|
59
|
+
t.isIdentifier(node.object.object, { name: "process" }) &&
|
|
60
|
+
t.isIdentifier(node.object.property, { name: "env" }) &&
|
|
61
|
+
t.isStringLiteral(node.property)) {
|
|
62
|
+
return node.property.value;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// import.meta.env.NAME
|
|
66
|
+
if (t.isMemberExpression(node.object) &&
|
|
67
|
+
t.isMemberExpression(node.object.object) &&
|
|
68
|
+
t.isIdentifier(node.object.object.object, { name: "import" }) &&
|
|
69
|
+
t.isIdentifier(node.object.object.property, { name: "meta" }) &&
|
|
70
|
+
t.isIdentifier(node.object.property, { name: "env" }) &&
|
|
71
|
+
t.isIdentifier(node.property)) {
|
|
72
|
+
return node.property.name;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function detectDefaultSignals(parentPath) {
|
|
79
|
+
const p = parentPath?.parentPath;
|
|
80
|
+
if (!p) return { hasDefault: false };
|
|
81
|
+
|
|
82
|
+
if (p.isLogicalExpression() && (p.node.operator === "||" || p.node.operator === "??")) {
|
|
83
|
+
return { hasDefault: true };
|
|
84
|
+
}
|
|
85
|
+
if (p.isConditionalExpression()) return { hasDefault: true };
|
|
86
|
+
if (p.isAssignmentExpression() && p.node.operator === "||=") return { hasDefault: true };
|
|
87
|
+
return { hasDefault: false };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function resolveEnvUsage(repoRoot) {
|
|
91
|
+
const files = await fg(["**/*.{ts,tsx,js,jsx}"], {
|
|
92
|
+
cwd: repoRoot,
|
|
93
|
+
absolute: true,
|
|
94
|
+
ignore: ["**/node_modules/**","**/.next/**","**/dist/**","**/build/**"]
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const usageMap = {};
|
|
98
|
+
|
|
99
|
+
for (const fileAbs of files) {
|
|
100
|
+
const fileRel = path.relative(repoRoot, fileAbs).replace(/\\/g, "/");
|
|
101
|
+
const code = safeRead(fileAbs);
|
|
102
|
+
|
|
103
|
+
let ast;
|
|
104
|
+
try { ast = parseFile(code); } catch { continue; }
|
|
105
|
+
|
|
106
|
+
traverse(ast, {
|
|
107
|
+
MemberExpression(p) {
|
|
108
|
+
const name = extractEnvFromMemberExpr(p.node);
|
|
109
|
+
if (!name || !isEnvName(name)) return;
|
|
110
|
+
|
|
111
|
+
const ev = evidenceFromLoc({
|
|
112
|
+
fileAbs,
|
|
113
|
+
fileRel,
|
|
114
|
+
loc: p.node.loc,
|
|
115
|
+
reason: `Env usage: ${name}`
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
mergeEvidenceMap(usageMap, name, ev);
|
|
119
|
+
|
|
120
|
+
const sig = detectDefaultSignals(p);
|
|
121
|
+
if (sig.hasDefault) usageMap[name].signals.hasDefault = true;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return usageMap;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function parseDotEnvLike(content) {
|
|
130
|
+
const out = new Set();
|
|
131
|
+
const lines = content.split(/\r?\n/);
|
|
132
|
+
for (const raw of lines) {
|
|
133
|
+
const line = raw.trim();
|
|
134
|
+
if (!line || line.startsWith("#")) continue;
|
|
135
|
+
const l = line.startsWith("export ") ? line.slice(7).trim() : line;
|
|
136
|
+
const eq = l.indexOf("=");
|
|
137
|
+
if (eq <= 0) continue;
|
|
138
|
+
const key = l.slice(0, eq).trim();
|
|
139
|
+
if (isEnvName(key)) out.add(key);
|
|
140
|
+
}
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async function resolveEnvDeclared(repoRoot) {
|
|
145
|
+
const candidates = [
|
|
146
|
+
".env.example", ".env.template", ".env.sample",
|
|
147
|
+
".env.local.example", ".env.development.example",
|
|
148
|
+
".env"
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
const declared = new Set();
|
|
152
|
+
const sources = [];
|
|
153
|
+
|
|
154
|
+
for (const rel of candidates) {
|
|
155
|
+
const abs = path.join(repoRoot, rel);
|
|
156
|
+
if (!fs.existsSync(abs)) continue;
|
|
157
|
+
|
|
158
|
+
const content = safeRead(abs);
|
|
159
|
+
const keys = parseDotEnvLike(content);
|
|
160
|
+
if (keys.size) {
|
|
161
|
+
for (const k of keys) declared.add(k);
|
|
162
|
+
sources.push(rel);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return { declared: Array.from(declared).sort(), sources };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async function buildEnvTruth(repoRoot) {
|
|
170
|
+
const usageMap = await resolveEnvUsage(repoRoot);
|
|
171
|
+
const declared = await resolveEnvDeclared(repoRoot);
|
|
172
|
+
|
|
173
|
+
const used = Object.values(usageMap).sort((a, b) => a.name.localeCompare(b.name));
|
|
174
|
+
|
|
175
|
+
const vars = used.map(u => ({
|
|
176
|
+
name: u.name,
|
|
177
|
+
required: !u.signals?.hasDefault,
|
|
178
|
+
references: u.references || [],
|
|
179
|
+
notes: u.signals?.hasDefault ? "Has default/fallback usage signal" : ""
|
|
180
|
+
}));
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
vars,
|
|
184
|
+
declared: declared.declared,
|
|
185
|
+
declaredSources: declared.sources
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
module.exports = { buildEnvTruth };
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standardized error handling for CLI runners
|
|
3
|
+
*
|
|
4
|
+
* Design principles:
|
|
5
|
+
* - Every error has a human-readable message
|
|
6
|
+
* - Every error suggests a next step
|
|
7
|
+
* - Exit codes are consistent and documented
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const colors = {
|
|
11
|
+
reset: "\x1b[0m",
|
|
12
|
+
red: "\x1b[31m",
|
|
13
|
+
yellow: "\x1b[33m",
|
|
14
|
+
cyan: "\x1b[36m",
|
|
15
|
+
green: "\x1b[32m",
|
|
16
|
+
bold: "\x1b[1m",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const c = {
|
|
20
|
+
error: (text) => `${colors.red}${colors.bold}${text}${colors.reset}`,
|
|
21
|
+
warning: (text) => `${colors.yellow}${text}${colors.reset}`,
|
|
22
|
+
info: (text) => `${colors.cyan}${text}${colors.reset}`,
|
|
23
|
+
success: (text) => `${colors.green}${text}${colors.reset}`,
|
|
24
|
+
dim: (text) => `\x1b[2m${text}${colors.reset}`,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Standard exit codes for CI/CD integration
|
|
28
|
+
// Unified with packages/cli/src/runtime/exit-codes.ts
|
|
29
|
+
// IMPORTANT: These codes are part of the CLI contract - do not change without migration guide
|
|
30
|
+
const EXIT_CODES = {
|
|
31
|
+
SUCCESS: 0, // Scan passed, no policy violations
|
|
32
|
+
POLICY_FAIL: 1, // Findings above threshold (policy fail) - actionable by user
|
|
33
|
+
USER_ERROR: 2, // User error: invalid args, bad config, missing required options
|
|
34
|
+
SYSTEM_ERROR: 3, // System error: crash, filesystem issues, unexpected exceptions
|
|
35
|
+
AUTH_FAILURE: 4, // Auth/entitlement failure: invalid key, expired token, insufficient tier
|
|
36
|
+
NETWORK_FAILURE: 5, // Network/backend failure: API unreachable, timeout
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Error-specific guidance
|
|
40
|
+
const ERROR_GUIDANCE = {
|
|
41
|
+
ENOENT: {
|
|
42
|
+
title: "File or directory not found",
|
|
43
|
+
nextSteps: [
|
|
44
|
+
"Verify the path exists and is spelled correctly",
|
|
45
|
+
"Run from the project root directory",
|
|
46
|
+
"Check if the file was deleted or moved",
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
EACCES: {
|
|
50
|
+
title: "Permission denied",
|
|
51
|
+
nextSteps: [
|
|
52
|
+
"Check file/directory permissions",
|
|
53
|
+
"Try running with appropriate permissions",
|
|
54
|
+
"Ensure you own the files or have read access",
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
ECONNREFUSED: {
|
|
58
|
+
title: "Connection refused",
|
|
59
|
+
nextSteps: [
|
|
60
|
+
"Check if the API server is running",
|
|
61
|
+
"Verify VIBECHECK_API_URL is correct",
|
|
62
|
+
"Check firewall/network settings",
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
ETIMEDOUT: {
|
|
66
|
+
title: "Connection timed out",
|
|
67
|
+
nextSteps: [
|
|
68
|
+
"Check your internet connection",
|
|
69
|
+
"The server may be overloaded, try again later",
|
|
70
|
+
"Increase timeout with --timeout flag if available",
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
INVALID_API_KEY: {
|
|
74
|
+
title: "Invalid API key",
|
|
75
|
+
nextSteps: [
|
|
76
|
+
'Run "vibecheck login" to authenticate',
|
|
77
|
+
"Get a new API key at https://vibecheckai.dev/settings/keys",
|
|
78
|
+
"Check VIBECHECK_API_KEY environment variable",
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
PLAN_REQUIRED: {
|
|
82
|
+
title: "Feature requires a paid plan",
|
|
83
|
+
nextSteps: [
|
|
84
|
+
"Upgrade at https://vibecheckai.dev/pricing",
|
|
85
|
+
'Run "vibecheck upgrade" to manage your subscription',
|
|
86
|
+
"Some features have free tier limits",
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
RATE_LIMITED: {
|
|
90
|
+
title: "Rate limit exceeded",
|
|
91
|
+
nextSteps: [
|
|
92
|
+
"Wait a moment and try again",
|
|
93
|
+
"Upgrade your plan for higher limits",
|
|
94
|
+
"Batch operations to reduce API calls",
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get guidance for an error
|
|
101
|
+
*/
|
|
102
|
+
function getErrorGuidance(error) {
|
|
103
|
+
const code = error.code || error.name;
|
|
104
|
+
|
|
105
|
+
// Check for known error types
|
|
106
|
+
if (ERROR_GUIDANCE[code]) {
|
|
107
|
+
return ERROR_GUIDANCE[code];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Infer from error message
|
|
111
|
+
if (error.message?.includes("API key")) {
|
|
112
|
+
return ERROR_GUIDANCE.INVALID_API_KEY;
|
|
113
|
+
}
|
|
114
|
+
if (error.message?.includes("rate limit")) {
|
|
115
|
+
return ERROR_GUIDANCE.RATE_LIMITED;
|
|
116
|
+
}
|
|
117
|
+
if (error.message?.includes("plan") || error.message?.includes("upgrade")) {
|
|
118
|
+
return ERROR_GUIDANCE.PLAN_REQUIRED;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Handle CLI errors with consistent formatting and guidance
|
|
126
|
+
* @param {Error|string} error - The error to handle
|
|
127
|
+
* @param {string} context - Additional context (command name, file path, etc.)
|
|
128
|
+
* @param {Object} metadata - Additional metadata (command, file, line, receipt, verifyCommand, etc.)
|
|
129
|
+
*/
|
|
130
|
+
function handleError(error, context = "", metadata = {}) {
|
|
131
|
+
// Ensure error is an Error object
|
|
132
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
133
|
+
|
|
134
|
+
// Build receipt string (file:line or evidence)
|
|
135
|
+
let receipt = "";
|
|
136
|
+
if (metadata.file && metadata.line) {
|
|
137
|
+
receipt = `${metadata.file}:${metadata.line}`;
|
|
138
|
+
} else if (metadata.file) {
|
|
139
|
+
receipt = metadata.file;
|
|
140
|
+
} else if (metadata.receipt) {
|
|
141
|
+
receipt = metadata.receipt;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Build enriched context message
|
|
145
|
+
const contextParts = [context];
|
|
146
|
+
if (receipt) contextParts.push(`Receipt: ${receipt}`);
|
|
147
|
+
if (metadata.command && !context.includes(metadata.command)) contextParts.push(`Command: ${metadata.command}`);
|
|
148
|
+
const enrichedContext = contextParts.filter(Boolean).join(' | ');
|
|
149
|
+
|
|
150
|
+
// Add context to error message if provided
|
|
151
|
+
const message = enrichedContext ? `${enrichedContext}: ${err.message}` : err.message;
|
|
152
|
+
|
|
153
|
+
// Get specific guidance
|
|
154
|
+
const guidance = getErrorGuidance(err);
|
|
155
|
+
|
|
156
|
+
// Print error header
|
|
157
|
+
if (guidance) {
|
|
158
|
+
console.error(`\n${c.error("✗")} ${c.error(guidance.title)}`);
|
|
159
|
+
console.error(` ${message}`);
|
|
160
|
+
|
|
161
|
+
// Print next steps
|
|
162
|
+
console.error(`\n${c.info("Next steps:")}`);
|
|
163
|
+
for (const step of guidance.nextSteps) {
|
|
164
|
+
console.error(` ${c.dim("•")} ${step}`);
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
// Generic error handling with specific type detection
|
|
168
|
+
if (err.code === "ENOENT") {
|
|
169
|
+
console.error(`\n${c.error("✗")} File or directory not found`);
|
|
170
|
+
console.error(` ${err.path || message}`);
|
|
171
|
+
// Print receipt if available
|
|
172
|
+
if (receipt) {
|
|
173
|
+
console.error(`\n${c.dim("Receipt:")} ${receipt}`);
|
|
174
|
+
}
|
|
175
|
+
console.error(`\n${c.info("Next steps:")}`);
|
|
176
|
+
console.error(` ${c.dim("•")} Verify the path exists`);
|
|
177
|
+
console.error(` ${c.dim("•")} Run from the correct directory`);
|
|
178
|
+
if (metadata.verifyCommand) {
|
|
179
|
+
console.error(`\n${c.info("Verify it's fixed:")}`);
|
|
180
|
+
console.error(` ${c.dim("•")} ${metadata.verifyCommand}`);
|
|
181
|
+
}
|
|
182
|
+
} else if (err.code === "EACCES") {
|
|
183
|
+
console.error(`\n${c.error("✗")} Permission denied`);
|
|
184
|
+
console.error(` ${message}`);
|
|
185
|
+
// Print receipt if available
|
|
186
|
+
if (receipt) {
|
|
187
|
+
console.error(`\n${c.dim("Receipt:")} ${receipt}`);
|
|
188
|
+
}
|
|
189
|
+
console.error(`\n${c.info("Next steps:")}`);
|
|
190
|
+
console.error(` ${c.dim("•")} Check file permissions`);
|
|
191
|
+
if (metadata.verifyCommand) {
|
|
192
|
+
console.error(`\n${c.info("Verify it's fixed:")}`);
|
|
193
|
+
console.error(` ${c.dim("•")} ${metadata.verifyCommand}`);
|
|
194
|
+
}
|
|
195
|
+
} else if (err.name === "AuthenticationError") {
|
|
196
|
+
console.error(`\n${c.error("✗")} Authentication required`);
|
|
197
|
+
console.error(` ${message}`);
|
|
198
|
+
console.error(`\n${c.info("Next steps:")}`);
|
|
199
|
+
console.error(` ${c.dim("•")} Run "vibecheck login" to authenticate`);
|
|
200
|
+
console.error(` ${c.dim("•")} Get your API key at https://vibecheckai.dev/settings/keys`);
|
|
201
|
+
} else if (err.name === "NetworkError" || err.code === "ECONNREFUSED" || err.code === "ETIMEDOUT") {
|
|
202
|
+
console.error(`\n${c.error("✗")} Network error`);
|
|
203
|
+
console.error(` ${message}`);
|
|
204
|
+
console.error(`\n${c.info("Next steps:")}`);
|
|
205
|
+
console.error(` ${c.dim("•")} Check your internet connection`);
|
|
206
|
+
console.error(` ${c.dim("•")} Verify VIBECHECK_API_URL is correct`);
|
|
207
|
+
} else {
|
|
208
|
+
// Generic error
|
|
209
|
+
console.error(`\n${c.error("✗")} Error`);
|
|
210
|
+
console.error(` ${message}`);
|
|
211
|
+
// Print receipt if available
|
|
212
|
+
if (receipt) {
|
|
213
|
+
console.error(`\n${c.dim("Receipt:")} ${receipt}`);
|
|
214
|
+
}
|
|
215
|
+
console.error(`\n${c.info("Need help?")}`);
|
|
216
|
+
console.error(` ${c.dim("•")} Run "vibecheck doctor" for diagnostics`);
|
|
217
|
+
console.error(` ${c.dim("•")} Visit https://docs.vibecheckai.dev/troubleshooting`);
|
|
218
|
+
if (metadata.verifyCommand) {
|
|
219
|
+
console.error(`\n${c.info("Verify it's fixed:")}`);
|
|
220
|
+
console.error(` ${c.dim("•")} ${metadata.verifyCommand}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Show stack trace in debug mode
|
|
226
|
+
if (process.env.DEBUG || process.env.VIBECHECK_DEBUG) {
|
|
227
|
+
console.error(`\n${c.dim("Stack trace:")}`);
|
|
228
|
+
console.error(c.dim(err.stack));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
console.error(""); // Empty line for readability
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Wrap an async function with error handling
|
|
236
|
+
*/
|
|
237
|
+
function withErrorHandling(fn, context = "") {
|
|
238
|
+
return async (...args) => {
|
|
239
|
+
try {
|
|
240
|
+
return await fn(...args);
|
|
241
|
+
} catch (error) {
|
|
242
|
+
handleError(error, context);
|
|
243
|
+
return 1; // Return error exit code
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Create a user-friendly error for specific scenarios
|
|
250
|
+
*/
|
|
251
|
+
function createUserError(message, type = "Error") {
|
|
252
|
+
const error = new Error(message);
|
|
253
|
+
error.name = type;
|
|
254
|
+
error.isUserError = true;
|
|
255
|
+
return error;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Check if an error should be retried
|
|
260
|
+
*/
|
|
261
|
+
function shouldRetry(error) {
|
|
262
|
+
// Retry on network errors
|
|
263
|
+
if (
|
|
264
|
+
error.code === "ECONNRESET" ||
|
|
265
|
+
error.code === "ECONNREFUSED" ||
|
|
266
|
+
error.code === "ETIMEDOUT" ||
|
|
267
|
+
error.name === "NetworkError"
|
|
268
|
+
) {
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Don't retry on user errors
|
|
273
|
+
if (
|
|
274
|
+
error.isUserError ||
|
|
275
|
+
error.name === "ValidationError" ||
|
|
276
|
+
error.name === "AuthenticationError"
|
|
277
|
+
) {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Default: don't retry
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Retry a function with exponential backoff
|
|
287
|
+
*/
|
|
288
|
+
async function retry(fn, maxAttempts = 3, context = "") {
|
|
289
|
+
let lastError;
|
|
290
|
+
|
|
291
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
292
|
+
try {
|
|
293
|
+
return await fn();
|
|
294
|
+
} catch (error) {
|
|
295
|
+
lastError = error;
|
|
296
|
+
|
|
297
|
+
if (!shouldRetry(error) || attempt === maxAttempts) {
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const delay = Math.pow(2, attempt) * 1000; // Exponential backoff
|
|
302
|
+
console.warn(
|
|
303
|
+
c.warning(`Attempt ${attempt} failed, retrying in ${delay / 1000}s...`),
|
|
304
|
+
);
|
|
305
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
throw lastError;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
module.exports = {
|
|
313
|
+
handleError,
|
|
314
|
+
withErrorHandling,
|
|
315
|
+
createUserError,
|
|
316
|
+
shouldRetry,
|
|
317
|
+
retry,
|
|
318
|
+
EXIT_CODES,
|
|
319
|
+
getErrorGuidance,
|
|
320
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// bin/runners/lib/firewall-prompt.js
|
|
2
|
+
function buildRealityFirewall({ truthpackSummary, mission, template, findings, fileSnippets, allowedFiles }) {
|
|
3
|
+
return `
|
|
4
|
+
You are Guardrail Fix Engine.
|
|
5
|
+
|
|
6
|
+
REALITY RULES (non-negotiable):
|
|
7
|
+
- Do NOT invent files, routes, env vars, middleware, or functions.
|
|
8
|
+
- You may ONLY edit files in ALLOWED_FILES.
|
|
9
|
+
- Use ONLY the provided evidence/snippets.
|
|
10
|
+
- If evidence is insufficient, return {"status":"needs_info","questions":[...]} and STOP.
|
|
11
|
+
- Output MUST be valid JSON only. No markdown. No commentary.
|
|
12
|
+
|
|
13
|
+
ALLOWED_FILES:
|
|
14
|
+
${JSON.stringify(allowedFiles || [], null, 2)}
|
|
15
|
+
|
|
16
|
+
MISSION TEMPLATE (how to fix):
|
|
17
|
+
${JSON.stringify(template || {}, null, 2)}
|
|
18
|
+
|
|
19
|
+
OUTPUT SCHEMA (strict):
|
|
20
|
+
{
|
|
21
|
+
"status": "ok" | "needs_info" | "cannot_fix",
|
|
22
|
+
"summary": "one sentence",
|
|
23
|
+
"edits": [
|
|
24
|
+
{
|
|
25
|
+
"path": "relative/file/path (must be in ALLOWED_FILES)",
|
|
26
|
+
"diff": "unified diff starting with ---/+++",
|
|
27
|
+
"reason": "why this edit fixes the mission"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"notes": ["optional"],
|
|
31
|
+
"questions": ["only when needs_info"]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
TRUTHPACK SUMMARY:
|
|
35
|
+
${JSON.stringify(truthpackSummary, null, 2)}
|
|
36
|
+
|
|
37
|
+
MISSION:
|
|
38
|
+
${JSON.stringify(mission, null, 2)}
|
|
39
|
+
|
|
40
|
+
TARGET FINDINGS:
|
|
41
|
+
${JSON.stringify(findings, null, 2)}
|
|
42
|
+
|
|
43
|
+
EVIDENCE SNIPPETS:
|
|
44
|
+
${JSON.stringify(fileSnippets, null, 2)}
|
|
45
|
+
|
|
46
|
+
TASK:
|
|
47
|
+
Produce the smallest correct patch(es) to satisfy the mission success criteria.`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = { buildRealityFirewall };
|