@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,385 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Context Compiler v1
|
|
4
|
+
*
|
|
5
|
+
* Generates task-targeted context slices from the Truth Pack.
|
|
6
|
+
* Big context = noise. Small context = missing facts.
|
|
7
|
+
* This compiles exactly what you need for the task.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* compileContext({ task: 'Fix dead login button', focus: { files: [...], routes: [...] } })
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import fs from 'fs/promises';
|
|
14
|
+
import path from 'path';
|
|
15
|
+
import crypto from 'crypto';
|
|
16
|
+
import yaml from 'js-yaml';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Load the truth pack from disk
|
|
20
|
+
*/
|
|
21
|
+
async function loadTruthpack(projectPath) {
|
|
22
|
+
const truthpackPath = path.join(projectPath, '.vibecheck', 'truth', 'truthpack.json');
|
|
23
|
+
try {
|
|
24
|
+
const content = await fs.readFile(truthpackPath, 'utf8');
|
|
25
|
+
return JSON.parse(content);
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Load invariants from disk
|
|
33
|
+
*/
|
|
34
|
+
async function loadInvariants(projectPath) {
|
|
35
|
+
const invariantsPath = path.join(projectPath, '.vibecheck', 'invariants.yml');
|
|
36
|
+
try {
|
|
37
|
+
const content = await fs.readFile(invariantsPath, 'utf8');
|
|
38
|
+
return yaml.load(content);
|
|
39
|
+
} catch {
|
|
40
|
+
return { invariants: [] };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Compile context for a specific task
|
|
46
|
+
*
|
|
47
|
+
* @param {Object} request - Context compilation request
|
|
48
|
+
* @param {string} request.task - What you're trying to do
|
|
49
|
+
* @param {Object} request.focus - Optional focus areas
|
|
50
|
+
* @param {string[]} request.focus.files - Specific files to include
|
|
51
|
+
* @param {string[]} request.focus.routes - Specific routes to include
|
|
52
|
+
* @param {string[]} request.constraints - Constraints to apply
|
|
53
|
+
* @param {number} request.maxTokensHint - Max tokens hint
|
|
54
|
+
* @param {string} projectPath - Project root path
|
|
55
|
+
* @returns {Object} Compiled context slice
|
|
56
|
+
*/
|
|
57
|
+
export async function compileContext(request, projectPath = process.cwd()) {
|
|
58
|
+
const contextId = `ctxslice_${crypto.randomBytes(4).toString('hex')}`;
|
|
59
|
+
const { task, focus = {}, constraints = [], maxTokensHint = 4000 } = request;
|
|
60
|
+
|
|
61
|
+
const truthpack = await loadTruthpack(projectPath);
|
|
62
|
+
if (!truthpack) {
|
|
63
|
+
return {
|
|
64
|
+
contextId,
|
|
65
|
+
error: 'No truth pack found. Run `vibecheck ctx` first.',
|
|
66
|
+
summary: null,
|
|
67
|
+
truthSlice: null,
|
|
68
|
+
evidence: [],
|
|
69
|
+
invariants: [],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const invariantsData = await loadInvariants(projectPath);
|
|
74
|
+
|
|
75
|
+
// Analyze task to determine relevant domains
|
|
76
|
+
const analysis = analyzeTask(task);
|
|
77
|
+
|
|
78
|
+
// Filter truth pack to relevant content
|
|
79
|
+
const truthSlice = buildTruthSlice(truthpack, analysis, focus);
|
|
80
|
+
|
|
81
|
+
// Gather evidence for the slice
|
|
82
|
+
const evidence = gatherEvidence(truthSlice);
|
|
83
|
+
|
|
84
|
+
// Select applicable invariants
|
|
85
|
+
const applicableInvariants = selectInvariants(invariantsData, analysis);
|
|
86
|
+
|
|
87
|
+
// Generate summary
|
|
88
|
+
const summary = generateSummary(task, truthSlice, analysis);
|
|
89
|
+
|
|
90
|
+
// Apply constraints
|
|
91
|
+
const appliedConstraints = applyConstraints(truthSlice, constraints);
|
|
92
|
+
|
|
93
|
+
// Estimate token count
|
|
94
|
+
const tokenEstimate = estimateTokens(truthSlice, evidence);
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
contextId,
|
|
98
|
+
summary,
|
|
99
|
+
task,
|
|
100
|
+
analysis: {
|
|
101
|
+
domains: analysis.domains,
|
|
102
|
+
keywords: analysis.keywords,
|
|
103
|
+
action: analysis.action,
|
|
104
|
+
},
|
|
105
|
+
truthSlice,
|
|
106
|
+
evidence: evidence.slice(0, 50), // Limit evidence
|
|
107
|
+
invariants: applicableInvariants.map(i => i.id),
|
|
108
|
+
constraints: appliedConstraints,
|
|
109
|
+
tokenEstimate,
|
|
110
|
+
warnings: generateWarnings(analysis, tokenEstimate, maxTokensHint),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Analyze task to determine domains, keywords, and action
|
|
116
|
+
*/
|
|
117
|
+
function analyzeTask(task) {
|
|
118
|
+
const taskLower = task.toLowerCase();
|
|
119
|
+
|
|
120
|
+
// Detect domains
|
|
121
|
+
const domains = [];
|
|
122
|
+
if (/auth|login|logout|session|password|jwt|token/i.test(task)) domains.push('auth');
|
|
123
|
+
if (/billing|payment|stripe|subscription|checkout|tier|pro|enterprise/i.test(task)) domains.push('billing');
|
|
124
|
+
if (/route|endpoint|api|handler|fetch|axios/i.test(task)) domains.push('api');
|
|
125
|
+
if (/component|button|form|ui|page|modal|dialog/i.test(task)) domains.push('ui');
|
|
126
|
+
if (/database|prisma|model|schema|query|db/i.test(task)) domains.push('data');
|
|
127
|
+
if (/test|spec|jest|vitest/i.test(task)) domains.push('testing');
|
|
128
|
+
if (/security|xss|csrf|injection|sanitize/i.test(task)) domains.push('security');
|
|
129
|
+
if (/env|environment|config|secret/i.test(task)) domains.push('env');
|
|
130
|
+
|
|
131
|
+
if (domains.length === 0) domains.push('general');
|
|
132
|
+
|
|
133
|
+
// Detect action type
|
|
134
|
+
let action = 'unknown';
|
|
135
|
+
if (/fix|bug|broken|error|issue|problem|dead/i.test(task)) action = 'fix';
|
|
136
|
+
else if (/add|create|implement|build|new/i.test(task)) action = 'create';
|
|
137
|
+
else if (/update|change|modify|refactor/i.test(task)) action = 'update';
|
|
138
|
+
else if (/delete|remove|drop/i.test(task)) action = 'delete';
|
|
139
|
+
else if (/wire|connect|integrate|link/i.test(task)) action = 'integrate';
|
|
140
|
+
else if (/verify|check|validate|test/i.test(task)) action = 'verify';
|
|
141
|
+
|
|
142
|
+
// Extract keywords
|
|
143
|
+
const stopWords = new Set(['the', 'a', 'an', 'is', 'are', 'was', 'were', 'be', 'been', 'have', 'has', 'do', 'does', 'did', 'will', 'would', 'could', 'should', 'may', 'might', 'must', 'to', 'of', 'in', 'for', 'on', 'with', 'at', 'by', 'from', 'as', 'into', 'through', 'this', 'that', 'these', 'those', 'i', 'me', 'my', 'we', 'our', 'you', 'your', 'it', 'its', 'they', 'them', 'their', 'what', 'which', 'who', 'and', 'but', 'if', 'or', 'because', 'fix', 'add', 'update', 'create', 'make', 'build']);
|
|
144
|
+
|
|
145
|
+
const keywords = task
|
|
146
|
+
.toLowerCase()
|
|
147
|
+
.replace(/[^a-z0-9\s]/g, ' ')
|
|
148
|
+
.split(/\s+/)
|
|
149
|
+
.filter(word => word.length > 2 && !stopWords.has(word));
|
|
150
|
+
|
|
151
|
+
return { domains, action, keywords };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Build a filtered truth slice based on analysis and focus
|
|
156
|
+
*/
|
|
157
|
+
function buildTruthSlice(truthpack, analysis, focus) {
|
|
158
|
+
const slice = {
|
|
159
|
+
routes: { server: [], clientRefs: [] },
|
|
160
|
+
env: { vars: [] },
|
|
161
|
+
auth: null,
|
|
162
|
+
billing: null,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// Filter routes
|
|
166
|
+
if (focus.routes && focus.routes.length > 0) {
|
|
167
|
+
slice.routes.server = truthpack.routes.server.filter(r =>
|
|
168
|
+
focus.routes.some(fr => r.path.includes(fr) || fr.includes(r.path))
|
|
169
|
+
);
|
|
170
|
+
slice.routes.clientRefs = truthpack.routes.clientRefs.filter(r =>
|
|
171
|
+
focus.routes.some(fr => r.path.includes(fr) || fr.includes(r.path))
|
|
172
|
+
);
|
|
173
|
+
} else if (analysis.keywords.length > 0) {
|
|
174
|
+
slice.routes.server = truthpack.routes.server.filter(r =>
|
|
175
|
+
analysis.keywords.some(k => r.path.includes(k) || r.handler.includes(k))
|
|
176
|
+
);
|
|
177
|
+
slice.routes.clientRefs = truthpack.routes.clientRefs.filter(r =>
|
|
178
|
+
analysis.keywords.some(k => r.path.includes(k) || r.source.includes(k))
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Include routes from focused files
|
|
183
|
+
if (focus.files && focus.files.length > 0) {
|
|
184
|
+
const fileRoutes = truthpack.routes.server.filter(r =>
|
|
185
|
+
focus.files.some(f => r.handler.includes(f))
|
|
186
|
+
);
|
|
187
|
+
const fileClientRefs = truthpack.routes.clientRefs.filter(r =>
|
|
188
|
+
focus.files.some(f => r.source.includes(f))
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
slice.routes.server.push(...fileRoutes.filter(r => !slice.routes.server.includes(r)));
|
|
192
|
+
slice.routes.clientRefs.push(...fileClientRefs.filter(r => !slice.routes.clientRefs.includes(r)));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Filter env vars based on keywords
|
|
196
|
+
if (analysis.keywords.length > 0) {
|
|
197
|
+
slice.env.vars = truthpack.env.vars.filter(v =>
|
|
198
|
+
analysis.keywords.some(k => v.name.toLowerCase().includes(k))
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Include auth if relevant
|
|
203
|
+
if (analysis.domains.includes('auth')) {
|
|
204
|
+
slice.auth = truthpack.auth;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Include billing if relevant
|
|
208
|
+
if (analysis.domains.includes('billing')) {
|
|
209
|
+
slice.billing = truthpack.billing;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return slice;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Gather evidence from the truth slice
|
|
217
|
+
*/
|
|
218
|
+
function gatherEvidence(truthSlice) {
|
|
219
|
+
const evidence = [];
|
|
220
|
+
|
|
221
|
+
for (const route of truthSlice.routes.server) {
|
|
222
|
+
if (route.evidence) evidence.push(...route.evidence);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
for (const ref of truthSlice.routes.clientRefs) {
|
|
226
|
+
if (ref.evidence) evidence.push(...ref.evidence);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
for (const v of truthSlice.env.vars) {
|
|
230
|
+
if (v.references) evidence.push(...v.references);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (truthSlice.auth?.model?.signals) {
|
|
234
|
+
for (const s of truthSlice.auth.model.signals) {
|
|
235
|
+
if (s.evidence) evidence.push(...s.evidence);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return evidence;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Select applicable invariants based on task analysis
|
|
244
|
+
*/
|
|
245
|
+
function selectInvariants(invariantsData, analysis) {
|
|
246
|
+
const invariants = invariantsData.invariants || [];
|
|
247
|
+
|
|
248
|
+
const domainToApplies = {
|
|
249
|
+
auth: ['server', 'middleware', 'api'],
|
|
250
|
+
billing: ['server', 'ui'],
|
|
251
|
+
api: ['api', 'server'],
|
|
252
|
+
ui: ['ui'],
|
|
253
|
+
security: ['all', 'server'],
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const relevantApplies = new Set();
|
|
257
|
+
for (const domain of analysis.domains) {
|
|
258
|
+
const applies = domainToApplies[domain] || [];
|
|
259
|
+
applies.forEach(a => relevantApplies.add(a));
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Always include security-related invariants for fix/integrate actions
|
|
263
|
+
if (analysis.action === 'fix' || analysis.action === 'integrate') {
|
|
264
|
+
relevantApplies.add('server');
|
|
265
|
+
relevantApplies.add('middleware');
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return invariants.filter(inv => {
|
|
269
|
+
if (!inv.appliesTo) return true;
|
|
270
|
+
return inv.appliesTo.some(a => relevantApplies.has(a) || a === 'all');
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Generate a summary of the context
|
|
276
|
+
*/
|
|
277
|
+
function generateSummary(task, truthSlice, analysis) {
|
|
278
|
+
const parts = [];
|
|
279
|
+
|
|
280
|
+
parts.push(`Task: ${task}`);
|
|
281
|
+
parts.push(`Domains: ${analysis.domains.join(', ')}`);
|
|
282
|
+
parts.push(`Action: ${analysis.action}`);
|
|
283
|
+
|
|
284
|
+
if (truthSlice.routes.server.length > 0) {
|
|
285
|
+
parts.push(`Server routes: ${truthSlice.routes.server.length}`);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (truthSlice.routes.clientRefs.length > 0) {
|
|
289
|
+
parts.push(`Client refs: ${truthSlice.routes.clientRefs.length}`);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Check for mismatches (gaps)
|
|
293
|
+
const serverPaths = new Set(truthSlice.routes.server.map(r => r.path));
|
|
294
|
+
const clientPaths = truthSlice.routes.clientRefs.map(r => r.path);
|
|
295
|
+
const mismatches = clientPaths.filter(p => !serverPaths.has(p));
|
|
296
|
+
|
|
297
|
+
if (mismatches.length > 0) {
|
|
298
|
+
parts.push(`⚠️ Route mismatches: ${mismatches.join(', ')}`);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return parts.join(' | ');
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Apply constraints to the truth slice
|
|
306
|
+
*/
|
|
307
|
+
function applyConstraints(truthSlice, constraints) {
|
|
308
|
+
const applied = [];
|
|
309
|
+
|
|
310
|
+
for (const constraint of constraints) {
|
|
311
|
+
switch (constraint) {
|
|
312
|
+
case 'do_not_invent_routes':
|
|
313
|
+
applied.push({
|
|
314
|
+
id: 'do_not_invent_routes',
|
|
315
|
+
description: 'Only use routes that exist in the truth pack',
|
|
316
|
+
enforced: true,
|
|
317
|
+
});
|
|
318
|
+
break;
|
|
319
|
+
|
|
320
|
+
case 'no_new_env_vars_without_proof':
|
|
321
|
+
applied.push({
|
|
322
|
+
id: 'no_new_env_vars_without_proof',
|
|
323
|
+
description: 'Do not add env vars that are not declared in .env.example',
|
|
324
|
+
enforced: true,
|
|
325
|
+
});
|
|
326
|
+
break;
|
|
327
|
+
|
|
328
|
+
case 'require_auth_verification':
|
|
329
|
+
applied.push({
|
|
330
|
+
id: 'require_auth_verification',
|
|
331
|
+
description: 'Verify auth is enforced on protected routes',
|
|
332
|
+
enforced: true,
|
|
333
|
+
});
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return applied;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Estimate token count for the context
|
|
343
|
+
*/
|
|
344
|
+
function estimateTokens(truthSlice, evidence) {
|
|
345
|
+
let tokens = 0;
|
|
346
|
+
|
|
347
|
+
// Routes: ~50 tokens each
|
|
348
|
+
tokens += truthSlice.routes.server.length * 50;
|
|
349
|
+
tokens += truthSlice.routes.clientRefs.length * 30;
|
|
350
|
+
|
|
351
|
+
// Env vars: ~20 tokens each
|
|
352
|
+
tokens += truthSlice.env.vars.length * 20;
|
|
353
|
+
|
|
354
|
+
// Auth/billing: ~200 tokens each if present
|
|
355
|
+
if (truthSlice.auth) tokens += 200;
|
|
356
|
+
if (truthSlice.billing) tokens += 200;
|
|
357
|
+
|
|
358
|
+
// Evidence: ~100 tokens each
|
|
359
|
+
tokens += evidence.length * 100;
|
|
360
|
+
|
|
361
|
+
return tokens;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Generate warnings based on context
|
|
366
|
+
*/
|
|
367
|
+
function generateWarnings(analysis, tokenEstimate, maxTokensHint) {
|
|
368
|
+
const warnings = [];
|
|
369
|
+
|
|
370
|
+
if (analysis.domains.includes('auth') || analysis.domains.includes('billing')) {
|
|
371
|
+
warnings.push('High-stakes domain detected - verify all claims before making changes');
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (tokenEstimate > maxTokensHint) {
|
|
375
|
+
warnings.push(`Context exceeds ${maxTokensHint} token hint (est: ${tokenEstimate}). Consider narrowing focus.`);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (analysis.action === 'fix' && analysis.domains.includes('auth')) {
|
|
379
|
+
warnings.push('Auth fix - ensure changes do not weaken security');
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return warnings;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export default { compileContext };
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// bin/runners/runCtx.js
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const { buildTruthpack, writeTruthpack, detectFastifyEntry } = require("./lib/truth");
|
|
5
|
+
|
|
6
|
+
const c = {
|
|
7
|
+
reset: '\x1b[0m',
|
|
8
|
+
bold: '\x1b[1m',
|
|
9
|
+
dim: '\x1b[2m',
|
|
10
|
+
red: '\x1b[31m',
|
|
11
|
+
green: '\x1b[32m',
|
|
12
|
+
yellow: '\x1b[33m',
|
|
13
|
+
blue: '\x1b[34m',
|
|
14
|
+
cyan: '\x1b[36m',
|
|
15
|
+
magenta: '\x1b[35m',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function parseArgs(args) {
|
|
19
|
+
const opts = {
|
|
20
|
+
path: process.cwd(),
|
|
21
|
+
fastifyEntry: null,
|
|
22
|
+
json: false,
|
|
23
|
+
snapshot: false,
|
|
24
|
+
help: false,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
for (let i = 0; i < args.length; i++) {
|
|
28
|
+
const arg = args[i];
|
|
29
|
+
if (arg === '--json' || arg === '-j') opts.json = true;
|
|
30
|
+
else if (arg === '--snapshot' || arg === '-s') opts.snapshot = true;
|
|
31
|
+
else if (arg === '--fastify-entry') opts.fastifyEntry = args[++i];
|
|
32
|
+
else if (arg === '--path' || arg === '-p') opts.path = args[++i];
|
|
33
|
+
else if (arg === '--help' || arg === '-h') opts.help = true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return opts;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function printHelp() {
|
|
40
|
+
console.log(`
|
|
41
|
+
${c.cyan}${c.bold}📦 vibecheck ctx${c.reset} — Truth Pack Generator
|
|
42
|
+
|
|
43
|
+
${c.dim}Build a comprehensive truth pack of your codebase for AI agents.${c.reset}
|
|
44
|
+
|
|
45
|
+
${c.bold}USAGE${c.reset}
|
|
46
|
+
vibecheck ctx Generate truth pack
|
|
47
|
+
vibecheck ctx --snapshot Save timestamped snapshot
|
|
48
|
+
vibecheck ctx --json Output as JSON
|
|
49
|
+
|
|
50
|
+
${c.bold}OPTIONS${c.reset}
|
|
51
|
+
--json, -j Output raw JSON
|
|
52
|
+
--snapshot, -s Save to snapshots/ with timestamp
|
|
53
|
+
--fastify-entry Fastify entry file (e.g. src/server.ts)
|
|
54
|
+
--path, -p Project path (default: current directory)
|
|
55
|
+
--help, -h Show this help
|
|
56
|
+
|
|
57
|
+
${c.bold}TRUTH PACK CONTENTS${c.reset}
|
|
58
|
+
• ${c.cyan}routes${c.reset} Server routes + client refs + gaps
|
|
59
|
+
• ${c.cyan}env${c.reset} Used vars + declared vars + sources
|
|
60
|
+
• ${c.cyan}auth${c.reset} Middleware + patterns + signals
|
|
61
|
+
• ${c.cyan}billing${c.reset} Stripe usage + webhooks + gates
|
|
62
|
+
• ${c.cyan}enforcement${c.reset} Paid surface checks
|
|
63
|
+
|
|
64
|
+
${c.bold}OUTPUT${c.reset}
|
|
65
|
+
.vibecheck/truth/truthpack.json Main truth pack
|
|
66
|
+
.vibecheck/truth/truthpack.md Human-readable summary
|
|
67
|
+
|
|
68
|
+
${c.bold}EXAMPLES${c.reset}
|
|
69
|
+
vibecheck ctx # Generate truth pack
|
|
70
|
+
vibecheck ctx --snapshot # Save snapshot
|
|
71
|
+
vibecheck ctx --json > truthpack.json # Export as JSON
|
|
72
|
+
`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function runCtx(args) {
|
|
76
|
+
const opts = typeof args === 'object' && !Array.isArray(args)
|
|
77
|
+
? args // Legacy object format
|
|
78
|
+
: parseArgs(args || []);
|
|
79
|
+
|
|
80
|
+
if (opts.help) {
|
|
81
|
+
printHelp();
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const root = opts.repoRoot || opts.path || process.cwd();
|
|
86
|
+
const entry = opts.fastifyEntry || detectFastifyEntry(root);
|
|
87
|
+
|
|
88
|
+
// Print header
|
|
89
|
+
if (!opts.json && !opts.print) {
|
|
90
|
+
console.log('');
|
|
91
|
+
console.log(`${c.cyan}╔══════════════════════════════════════════════════════════════════════╗${c.reset}`);
|
|
92
|
+
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
93
|
+
console.log(`${c.cyan}║${c.reset} ${c.bold}📦 TRUTH PACK GENERATOR${c.reset} ${c.cyan}║${c.reset}`);
|
|
94
|
+
console.log(`${c.cyan}║${c.reset} ${c.dim}Building ground truth for AI agents${c.reset} ${c.cyan}║${c.reset}`);
|
|
95
|
+
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
96
|
+
console.log(`${c.cyan}╚══════════════════════════════════════════════════════════════════════╝${c.reset}`);
|
|
97
|
+
console.log('');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Build truthpack with progress
|
|
101
|
+
if (!opts.json && !opts.print) {
|
|
102
|
+
process.stdout.write(`${c.dim}○${c.reset} Building truth pack...`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const truthpack = await buildTruthpack({ repoRoot: root, fastifyEntry: entry });
|
|
106
|
+
writeTruthpack(root, truthpack);
|
|
107
|
+
|
|
108
|
+
if (!opts.json && !opts.print) {
|
|
109
|
+
process.stdout.write(`\r${c.green}✓${c.reset} Truth pack built \n`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Handle snapshot
|
|
113
|
+
if (opts.snapshot) {
|
|
114
|
+
const snapshotsDir = path.join(root, ".vibecheck", "truth", "snapshots");
|
|
115
|
+
fs.mkdirSync(snapshotsDir, { recursive: true });
|
|
116
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
117
|
+
const snapshotPath = path.join(snapshotsDir, `truthpack-${timestamp}.json`);
|
|
118
|
+
fs.writeFileSync(snapshotPath, JSON.stringify(truthpack, null, 2));
|
|
119
|
+
if (!opts.json) {
|
|
120
|
+
console.log(`${c.green}✓${c.reset} Snapshot saved: ${c.dim}${path.relative(root, snapshotPath)}${c.reset}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// JSON output
|
|
125
|
+
if (opts.json || opts.print) {
|
|
126
|
+
console.log(JSON.stringify(truthpack, null, 2));
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Beautiful summary
|
|
131
|
+
const nextRoutes = (truthpack.routes?.server || []).filter(r =>
|
|
132
|
+
r.handler?.includes("app/api") || r.handler?.includes("pages/api")
|
|
133
|
+
).length;
|
|
134
|
+
const fastifyRoutes = (truthpack.routes?.server || []).filter(r =>
|
|
135
|
+
!r.handler?.includes("app/api") && !r.handler?.includes("pages/api")
|
|
136
|
+
).length;
|
|
137
|
+
const clientRefs = truthpack.routes?.clientRefs?.length || 0;
|
|
138
|
+
const gaps = truthpack.routes?.gaps?.length || 0;
|
|
139
|
+
|
|
140
|
+
const envUsed = truthpack.env?.vars?.length || 0;
|
|
141
|
+
const envDeclared = truthpack.env?.declared?.length || 0;
|
|
142
|
+
const envSources = (truthpack.env?.declaredSources || []).join(", ") || "none";
|
|
143
|
+
|
|
144
|
+
const nextMiddleware = truthpack.auth?.nextMiddleware?.length || 0;
|
|
145
|
+
const fastifySignals = truthpack.auth?.fastify?.signalTypes?.length || 0;
|
|
146
|
+
|
|
147
|
+
const hasStripe = truthpack.billing?.hasStripe;
|
|
148
|
+
const webhooks = truthpack.billing?.summary?.webhookHandlersFound || 0;
|
|
149
|
+
|
|
150
|
+
const enforced = truthpack.enforcement?.enforcedCount || 0;
|
|
151
|
+
const checked = truthpack.enforcement?.checkedCount || 0;
|
|
152
|
+
|
|
153
|
+
console.log('');
|
|
154
|
+
console.log(`${c.cyan}┌─ Routes ──────────────────────────────────────────────────────────────┐${c.reset}`);
|
|
155
|
+
console.log(`${c.cyan}│${c.reset} ${c.bold}▲ Next.js:${c.reset} ${nextRoutes} routes`);
|
|
156
|
+
console.log(`${c.cyan}│${c.reset} ${c.bold}⚡ Fastify:${c.reset} ${fastifyRoutes} routes`);
|
|
157
|
+
console.log(`${c.cyan}│${c.reset} ${c.dim}Client refs:${c.reset} ${clientRefs} ${gaps > 0 ? `${c.yellow}⚠ ${gaps} gaps${c.reset}` : `${c.green}✓ no gaps${c.reset}`}`);
|
|
158
|
+
console.log(`${c.cyan}└───────────────────────────────────────────────────────────────────────┘${c.reset}`);
|
|
159
|
+
|
|
160
|
+
console.log(`${c.magenta}┌─ Environment ─────────────────────────────────────────────────────────┐${c.reset}`);
|
|
161
|
+
console.log(`${c.magenta}│${c.reset} ${c.bold}Used:${c.reset} ${envUsed} env vars`);
|
|
162
|
+
console.log(`${c.magenta}│${c.reset} ${c.bold}Declared:${c.reset} ${envDeclared} (${envSources})`);
|
|
163
|
+
console.log(`${c.magenta}└───────────────────────────────────────────────────────────────────────┘${c.reset}`);
|
|
164
|
+
|
|
165
|
+
console.log(`${c.blue}┌─ Auth ─────────────────────────────────────────────────────────────────┐${c.reset}`);
|
|
166
|
+
console.log(`${c.blue}│${c.reset} ${c.bold}Next middleware:${c.reset} ${nextMiddleware}`);
|
|
167
|
+
console.log(`${c.blue}│${c.reset} ${c.bold}Fastify signals:${c.reset} ${fastifySignals}`);
|
|
168
|
+
console.log(`${c.blue}└───────────────────────────────────────────────────────────────────────┘${c.reset}`);
|
|
169
|
+
|
|
170
|
+
console.log(`${c.yellow}┌─ Billing ──────────────────────────────────────────────────────────────┐${c.reset}`);
|
|
171
|
+
console.log(`${c.yellow}│${c.reset} ${c.bold}Stripe:${c.reset} ${hasStripe ? `${c.green}✓ detected${c.reset}` : `${c.dim}not detected${c.reset}`}`);
|
|
172
|
+
console.log(`${c.yellow}│${c.reset} ${c.bold}Webhooks:${c.reset} ${webhooks} handlers`);
|
|
173
|
+
console.log(`${c.yellow}│${c.reset} ${c.bold}Enforced:${c.reset} ${enforced}/${checked} paid routes`);
|
|
174
|
+
console.log(`${c.yellow}└───────────────────────────────────────────────────────────────────────┘${c.reset}`);
|
|
175
|
+
|
|
176
|
+
console.log('');
|
|
177
|
+
console.log(`${c.green}${c.bold}✓ Truth pack saved${c.reset}`);
|
|
178
|
+
console.log(` ${c.dim}→${c.reset} ${path.join(root, ".vibecheck", "truth", "truthpack.json")}`);
|
|
179
|
+
if (entry) {
|
|
180
|
+
console.log(` ${c.dim}Fastify entry:${c.reset} ${entry}`);
|
|
181
|
+
}
|
|
182
|
+
console.log('');
|
|
183
|
+
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
module.exports = { runCtx };
|