vibecheck-ai 2.0.1 → 5.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/bin/.generated +25 -0
- package/bin/_deprecations.js +463 -0
- package/bin/_router.js +46 -0
- package/bin/cli-hygiene.js +241 -0
- package/bin/dev/run-v2-torture.js +30 -0
- package/bin/registry.js +656 -0
- package/bin/runners/CLI_REFACTOR_SUMMARY.md +229 -0
- package/bin/runners/ENHANCEMENT_GUIDE.md +121 -0
- package/bin/runners/REPORT_AUDIT.md +64 -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 +513 -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-enhanced.js +2525 -0
- package/bin/runners/context/generators/cursor.js +514 -0
- package/bin/runners/context/generators/mcp.js +169 -0
- package/bin/runners/context/generators/windsurf.js +180 -0
- package/bin/runners/context/git-context.js +304 -0
- package/bin/runners/context/index.js +1110 -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 +1264 -0
- package/bin/runners/context/security-scanner.js +541 -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 +336 -0
- package/bin/runners/lib/__tests__/entitlements-v2.test.js +295 -0
- package/bin/runners/lib/agent-firewall/ai/false-positive-analyzer.js +474 -0
- package/bin/runners/lib/agent-firewall/change-packet/builder.js +488 -0
- package/bin/runners/lib/agent-firewall/change-packet/schema.json +228 -0
- package/bin/runners/lib/agent-firewall/change-packet/store.js +200 -0
- package/bin/runners/lib/agent-firewall/claims/claim-types.js +21 -0
- package/bin/runners/lib/agent-firewall/claims/extractor.js +303 -0
- package/bin/runners/lib/agent-firewall/claims/patterns.js +24 -0
- package/bin/runners/lib/agent-firewall/critic/index.js +151 -0
- package/bin/runners/lib/agent-firewall/critic/judge.js +432 -0
- package/bin/runners/lib/agent-firewall/critic/prompts.js +305 -0
- package/bin/runners/lib/agent-firewall/enforcement/gateway.js +1059 -0
- package/bin/runners/lib/agent-firewall/enforcement/index.js +98 -0
- package/bin/runners/lib/agent-firewall/enforcement/mode.js +318 -0
- package/bin/runners/lib/agent-firewall/enforcement/orchestrator.js +484 -0
- package/bin/runners/lib/agent-firewall/enforcement/proof-artifact.js +418 -0
- package/bin/runners/lib/agent-firewall/enforcement/schemas/change-event.schema.json +173 -0
- package/bin/runners/lib/agent-firewall/enforcement/schemas/intent.schema.json +181 -0
- package/bin/runners/lib/agent-firewall/enforcement/schemas/verdict.schema.json +222 -0
- package/bin/runners/lib/agent-firewall/enforcement/verdict-v2.js +333 -0
- package/bin/runners/lib/agent-firewall/evidence/auth-evidence.js +88 -0
- package/bin/runners/lib/agent-firewall/evidence/contract-evidence.js +75 -0
- package/bin/runners/lib/agent-firewall/evidence/env-evidence.js +127 -0
- package/bin/runners/lib/agent-firewall/evidence/resolver.js +102 -0
- package/bin/runners/lib/agent-firewall/evidence/route-evidence.js +213 -0
- package/bin/runners/lib/agent-firewall/evidence/side-effect-evidence.js +145 -0
- package/bin/runners/lib/agent-firewall/fs-hook/daemon.js +19 -0
- package/bin/runners/lib/agent-firewall/fs-hook/installer.js +87 -0
- package/bin/runners/lib/agent-firewall/fs-hook/watcher.js +184 -0
- package/bin/runners/lib/agent-firewall/git-hook/pre-commit.js +163 -0
- package/bin/runners/lib/agent-firewall/ide-extension/cursor.js +107 -0
- package/bin/runners/lib/agent-firewall/ide-extension/vscode.js +68 -0
- package/bin/runners/lib/agent-firewall/ide-extension/windsurf.js +66 -0
- package/bin/runners/lib/agent-firewall/index.js +200 -0
- package/bin/runners/lib/agent-firewall/integration/index.js +20 -0
- package/bin/runners/lib/agent-firewall/integration/ship-gate.js +437 -0
- package/bin/runners/lib/agent-firewall/intent/alignment-engine.js +634 -0
- package/bin/runners/lib/agent-firewall/intent/auto-detect.js +426 -0
- package/bin/runners/lib/agent-firewall/intent/index.js +102 -0
- package/bin/runners/lib/agent-firewall/intent/schema.js +352 -0
- package/bin/runners/lib/agent-firewall/intent/store.js +283 -0
- package/bin/runners/lib/agent-firewall/interception/fs-interceptor.js +502 -0
- package/bin/runners/lib/agent-firewall/interception/index.js +23 -0
- package/bin/runners/lib/agent-firewall/interceptor/base.js +308 -0
- package/bin/runners/lib/agent-firewall/interceptor/cursor.js +35 -0
- package/bin/runners/lib/agent-firewall/interceptor/vscode.js +35 -0
- package/bin/runners/lib/agent-firewall/interceptor/windsurf.js +34 -0
- package/bin/runners/lib/agent-firewall/lawbook/distributor.js +465 -0
- package/bin/runners/lib/agent-firewall/lawbook/evaluator.js +604 -0
- package/bin/runners/lib/agent-firewall/lawbook/index.js +304 -0
- package/bin/runners/lib/agent-firewall/lawbook/registry.js +514 -0
- package/bin/runners/lib/agent-firewall/lawbook/schema.js +420 -0
- package/bin/runners/lib/agent-firewall/logger.js +141 -0
- package/bin/runners/lib/agent-firewall/policy/default-policy.json +90 -0
- package/bin/runners/lib/agent-firewall/policy/engine.js +103 -0
- package/bin/runners/lib/agent-firewall/policy/loader.js +451 -0
- package/bin/runners/lib/agent-firewall/policy/rules/auth-drift.js +50 -0
- package/bin/runners/lib/agent-firewall/policy/rules/contract-drift.js +50 -0
- package/bin/runners/lib/agent-firewall/policy/rules/fake-success.js +79 -0
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-env.js +227 -0
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-route.js +191 -0
- package/bin/runners/lib/agent-firewall/policy/rules/scope.js +93 -0
- package/bin/runners/lib/agent-firewall/policy/rules/unsafe-side-effect.js +57 -0
- package/bin/runners/lib/agent-firewall/policy/schema.json +183 -0
- package/bin/runners/lib/agent-firewall/policy/verdict.js +54 -0
- package/bin/runners/lib/agent-firewall/proposal/extractor.js +394 -0
- package/bin/runners/lib/agent-firewall/proposal/index.js +212 -0
- package/bin/runners/lib/agent-firewall/proposal/schema.js +251 -0
- package/bin/runners/lib/agent-firewall/proposal/validator.js +386 -0
- package/bin/runners/lib/agent-firewall/reality/index.js +332 -0
- package/bin/runners/lib/agent-firewall/reality/state.js +625 -0
- package/bin/runners/lib/agent-firewall/reality/watcher.js +322 -0
- package/bin/runners/lib/agent-firewall/risk/index.js +173 -0
- package/bin/runners/lib/agent-firewall/risk/scorer.js +328 -0
- package/bin/runners/lib/agent-firewall/risk/thresholds.js +322 -0
- package/bin/runners/lib/agent-firewall/risk/vectors.js +421 -0
- package/bin/runners/lib/agent-firewall/session/collector.js +451 -0
- package/bin/runners/lib/agent-firewall/session/index.js +26 -0
- package/bin/runners/lib/agent-firewall/simulator/diff-simulator.js +472 -0
- package/bin/runners/lib/agent-firewall/simulator/import-resolver.js +346 -0
- package/bin/runners/lib/agent-firewall/simulator/index.js +181 -0
- package/bin/runners/lib/agent-firewall/simulator/route-validator.js +380 -0
- package/bin/runners/lib/agent-firewall/time-machine/incident-correlator.js +661 -0
- package/bin/runners/lib/agent-firewall/time-machine/index.js +267 -0
- package/bin/runners/lib/agent-firewall/time-machine/replay-engine.js +436 -0
- package/bin/runners/lib/agent-firewall/time-machine/state-reconstructor.js +490 -0
- package/bin/runners/lib/agent-firewall/time-machine/timeline-builder.js +530 -0
- package/bin/runners/lib/agent-firewall/truthpack/index.js +67 -0
- package/bin/runners/lib/agent-firewall/truthpack/loader.js +137 -0
- package/bin/runners/lib/agent-firewall/unblock/planner.js +337 -0
- package/bin/runners/lib/agent-firewall/utils/ignore-checker.js +118 -0
- package/bin/runners/lib/ai-bridge.js +416 -0
- package/bin/runners/lib/analysis-core.js +309 -0
- package/bin/runners/lib/analyzers.js +2500 -0
- package/bin/runners/lib/api-client.js +269 -0
- package/bin/runners/lib/approve-output.js +235 -0
- package/bin/runners/lib/artifact-envelope.js +540 -0
- package/bin/runners/lib/assets/vibecheck-logo.png +0 -0
- package/bin/runners/lib/audit-bridge.js +391 -0
- package/bin/runners/lib/auth-shared.js +977 -0
- package/bin/runners/lib/auth-truth.js +193 -0
- package/bin/runners/lib/auth.js +215 -0
- package/bin/runners/lib/authority-badge.js +425 -0
- package/bin/runners/lib/backup.js +62 -0
- package/bin/runners/lib/billing.js +107 -0
- package/bin/runners/lib/checkpoint.js +941 -0
- package/bin/runners/lib/claims.js +118 -0
- package/bin/runners/lib/classify-output.js +204 -0
- package/bin/runners/lib/cleanup/engine.js +571 -0
- package/bin/runners/lib/cleanup/index.js +53 -0
- package/bin/runners/lib/cleanup/output.js +375 -0
- package/bin/runners/lib/cleanup/rules.js +1060 -0
- package/bin/runners/lib/cli-output.js +400 -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 +202 -0
- package/bin/runners/lib/contracts/env-contract.js +181 -0
- package/bin/runners/lib/contracts/external-contract.js +206 -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 +199 -0
- package/bin/runners/lib/contracts.js +804 -0
- package/bin/runners/lib/default-config.js +127 -0
- package/bin/runners/lib/detect.js +89 -0
- package/bin/runners/lib/detectors-v2.js +622 -0
- package/bin/runners/lib/doctor/autofix.js +254 -0
- package/bin/runners/lib/doctor/diagnosis-receipt.js +454 -0
- package/bin/runners/lib/doctor/failure-signatures.js +526 -0
- package/bin/runners/lib/doctor/fix-script.js +336 -0
- package/bin/runners/lib/doctor/index.js +37 -0
- package/bin/runners/lib/doctor/modules/build-tools.js +453 -0
- package/bin/runners/lib/doctor/modules/dependencies.js +325 -0
- package/bin/runners/lib/doctor/modules/index.js +105 -0
- package/bin/runners/lib/doctor/modules/network.js +250 -0
- package/bin/runners/lib/doctor/modules/os-quirks.js +706 -0
- package/bin/runners/lib/doctor/modules/project.js +312 -0
- package/bin/runners/lib/doctor/modules/repo-integrity.js +485 -0
- package/bin/runners/lib/doctor/modules/runtime.js +224 -0
- package/bin/runners/lib/doctor/modules/security.js +350 -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/safe-repair.js +384 -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-output.js +226 -0
- package/bin/runners/lib/doctor-v2.js +608 -0
- package/bin/runners/lib/drift.js +425 -0
- package/bin/runners/lib/enforcement.js +72 -0
- package/bin/runners/lib/engine/ast-cache.js +210 -0
- package/bin/runners/lib/engine/auth-extractor.js +211 -0
- package/bin/runners/lib/engine/billing-extractor.js +112 -0
- package/bin/runners/lib/engine/enforcement-extractor.js +100 -0
- package/bin/runners/lib/engine/env-extractor.js +207 -0
- package/bin/runners/lib/engine/express-extractor.js +208 -0
- package/bin/runners/lib/engine/extractors.js +849 -0
- package/bin/runners/lib/engine/index.js +207 -0
- package/bin/runners/lib/engine/repo-index.js +514 -0
- package/bin/runners/lib/engine/types.js +124 -0
- package/bin/runners/lib/engines/accessibility-engine.js +190 -0
- package/bin/runners/lib/engines/api-consistency-engine.js +162 -0
- package/bin/runners/lib/engines/ast-cache.js +99 -0
- package/bin/runners/lib/engines/attack-detector.js +1192 -0
- package/bin/runners/lib/engines/code-quality-engine.js +255 -0
- package/bin/runners/lib/engines/console-logs-engine.js +115 -0
- package/bin/runners/lib/engines/cross-file-analysis-engine.js +268 -0
- package/bin/runners/lib/engines/dead-code-engine.js +198 -0
- package/bin/runners/lib/engines/deprecated-api-engine.js +226 -0
- package/bin/runners/lib/engines/empty-catch-engine.js +150 -0
- package/bin/runners/lib/engines/file-filter.js +131 -0
- package/bin/runners/lib/engines/hardcoded-secrets-engine.js +251 -0
- package/bin/runners/lib/engines/mock-data-engine.js +272 -0
- package/bin/runners/lib/engines/parallel-processor.js +71 -0
- package/bin/runners/lib/engines/performance-issues-engine.js +265 -0
- package/bin/runners/lib/engines/security-vulnerabilities-engine.js +243 -0
- package/bin/runners/lib/engines/todo-fixme-engine.js +115 -0
- package/bin/runners/lib/engines/type-aware-engine.js +152 -0
- package/bin/runners/lib/engines/unsafe-regex-engine.js +225 -0
- package/bin/runners/lib/engines/vibecheck-engines/README.md +53 -0
- package/bin/runners/lib/engines/vibecheck-engines/index.js +15 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/ast-cache.js +164 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/code-quality-engine.js +291 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/console-logs-engine.js +83 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/dead-code-engine.js +198 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/deprecated-api-engine.js +275 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/empty-catch-engine.js +167 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/file-filter.js +217 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/hardcoded-secrets-engine.js +139 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/mock-data-engine.js +140 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/parallel-processor.js +164 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/performance-issues-engine.js +234 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/type-aware-engine.js +217 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/unsafe-regex-engine.js +78 -0
- package/bin/runners/lib/engines/vibecheck-engines/package.json +13 -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 +265 -0
- package/bin/runners/lib/entitlements.generated.js +0 -0
- package/bin/runners/lib/entitlements.js +340 -0
- package/bin/runners/lib/env-resolver.js +417 -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 +368 -0
- package/bin/runners/lib/error-messages.js +289 -0
- package/bin/runners/lib/evidence-pack.js +684 -0
- package/bin/runners/lib/exit-codes.js +275 -0
- package/bin/runners/lib/extractors/client-calls.js +990 -0
- package/bin/runners/lib/extractors/fastify-route-dump.js +573 -0
- package/bin/runners/lib/extractors/fastify-routes.js +426 -0
- package/bin/runners/lib/extractors/index.js +363 -0
- package/bin/runners/lib/extractors/next-routes.js +524 -0
- package/bin/runners/lib/extractors/proof-graph.js +431 -0
- package/bin/runners/lib/extractors/route-matcher.js +451 -0
- package/bin/runners/lib/extractors/truthpack-v2.js +377 -0
- package/bin/runners/lib/extractors/ui-bindings.js +547 -0
- package/bin/runners/lib/finding-id.js +69 -0
- package/bin/runners/lib/finding-sorter.js +89 -0
- package/bin/runners/lib/findings-schema.js +281 -0
- package/bin/runners/lib/fingerprint.js +377 -0
- package/bin/runners/lib/firewall-prompt.js +50 -0
- package/bin/runners/lib/fix-output.js +228 -0
- package/bin/runners/lib/global-flags.js +250 -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/help-formatter.js +413 -0
- package/bin/runners/lib/html-proof-report.js +913 -0
- package/bin/runners/lib/html-report.js +650 -0
- package/bin/runners/lib/init-wizard.js +601 -0
- package/bin/runners/lib/interactive-menu.js +1496 -0
- package/bin/runners/lib/json-output.js +76 -0
- package/bin/runners/lib/llm.js +75 -0
- package/bin/runners/lib/logger.js +38 -0
- package/bin/runners/lib/meter.js +61 -0
- package/bin/runners/lib/missions/briefing.js +427 -0
- package/bin/runners/lib/missions/checkpoint.js +753 -0
- package/bin/runners/lib/missions/evidence.js +126 -0
- package/bin/runners/lib/missions/hardening.js +851 -0
- package/bin/runners/lib/missions/plan.js +648 -0
- package/bin/runners/lib/missions/safety-gates.js +645 -0
- package/bin/runners/lib/missions/schema.js +478 -0
- package/bin/runners/lib/missions/templates.js +317 -0
- package/bin/runners/lib/next-action.js +560 -0
- package/bin/runners/lib/packs/bundle.js +675 -0
- package/bin/runners/lib/packs/evidence-pack.js +671 -0
- package/bin/runners/lib/packs/pack-factory.js +837 -0
- package/bin/runners/lib/packs/permissions-pack.js +686 -0
- package/bin/runners/lib/packs/proof-graph-pack.js +779 -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/policy.js +295 -0
- package/bin/runners/lib/polish/accessibility.js +62 -0
- package/bin/runners/lib/polish/analyzer.js +93 -0
- package/bin/runners/lib/polish/backend.js +87 -0
- package/bin/runners/lib/polish/configuration.js +83 -0
- package/bin/runners/lib/polish/documentation.js +83 -0
- package/bin/runners/lib/polish/frontend.js +817 -0
- package/bin/runners/lib/polish/index.js +27 -0
- package/bin/runners/lib/polish/infrastructure.js +80 -0
- package/bin/runners/lib/polish/internationalization.js +85 -0
- package/bin/runners/lib/polish/libraries.js +180 -0
- package/bin/runners/lib/polish/observability.js +75 -0
- package/bin/runners/lib/polish/performance.js +64 -0
- package/bin/runners/lib/polish/privacy.js +110 -0
- package/bin/runners/lib/polish/resilience.js +92 -0
- package/bin/runners/lib/polish/security.js +78 -0
- package/bin/runners/lib/polish/seo.js +71 -0
- package/bin/runners/lib/polish/styles.js +62 -0
- package/bin/runners/lib/polish/utils.js +104 -0
- package/bin/runners/lib/preflight.js +142 -0
- package/bin/runners/lib/prerequisites.js +149 -0
- package/bin/runners/lib/prove-output.js +220 -0
- package/bin/runners/lib/reality/correlation-detectors.js +359 -0
- package/bin/runners/lib/reality/index.js +318 -0
- package/bin/runners/lib/reality/request-hashing.js +416 -0
- package/bin/runners/lib/reality/request-mapper.js +453 -0
- package/bin/runners/lib/reality/safety-rails.js +463 -0
- package/bin/runners/lib/reality/semantic-snapshot.js +408 -0
- package/bin/runners/lib/reality/toast-detector.js +393 -0
- package/bin/runners/lib/reality-findings.js +84 -0
- package/bin/runners/lib/reality-output.js +231 -0
- package/bin/runners/lib/receipts.js +179 -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 +626 -0
- package/bin/runners/lib/report-html.js +1233 -0
- package/bin/runners/lib/report-output.js +366 -0
- package/bin/runners/lib/report-templates.js +967 -0
- package/bin/runners/lib/report.js +135 -0
- package/bin/runners/lib/route-detection.js +1209 -0
- package/bin/runners/lib/route-truth.js +1322 -0
- package/bin/runners/lib/safelist/index.js +96 -0
- package/bin/runners/lib/safelist/integration.js +334 -0
- package/bin/runners/lib/safelist/matcher.js +696 -0
- package/bin/runners/lib/safelist/schema.js +948 -0
- package/bin/runners/lib/safelist/store.js +438 -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/scan-output.js +631 -0
- package/bin/runners/lib/scan-runner.js +135 -0
- package/bin/runners/lib/schema-validator.js +350 -0
- package/bin/runners/lib/schemas/ajv-validator.js +464 -0
- package/bin/runners/lib/schemas/contracts.schema.json +160 -0
- package/bin/runners/lib/schemas/error-envelope.schema.json +105 -0
- package/bin/runners/lib/schemas/finding-v3.schema.json +151 -0
- package/bin/runners/lib/schemas/finding.schema.json +100 -0
- package/bin/runners/lib/schemas/mission-pack.schema.json +206 -0
- package/bin/runners/lib/schemas/proof-graph.schema.json +176 -0
- package/bin/runners/lib/schemas/reality-report.schema.json +162 -0
- package/bin/runners/lib/schemas/report-artifact.schema.json +120 -0
- package/bin/runners/lib/schemas/run-request.schema.json +108 -0
- package/bin/runners/lib/schemas/share-pack.schema.json +180 -0
- package/bin/runners/lib/schemas/ship-manifest.schema.json +251 -0
- package/bin/runners/lib/schemas/ship-report.schema.json +117 -0
- package/bin/runners/lib/schemas/truthpack-v2.schema.json +303 -0
- package/bin/runners/lib/schemas/validator.js +465 -0
- package/bin/runners/lib/schemas/verdict.schema.json +140 -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/ship-gate.js +832 -0
- package/bin/runners/lib/ship-manifest.js +1153 -0
- package/bin/runners/lib/ship-output-enterprise.js +239 -0
- package/bin/runners/lib/ship-output.js +1128 -0
- package/bin/runners/lib/snippets.js +67 -0
- package/bin/runners/lib/status-output.js +340 -0
- package/bin/runners/lib/terminal-ui.js +356 -0
- package/bin/runners/lib/truth.js +1691 -0
- package/bin/runners/lib/ui.js +562 -0
- package/bin/runners/lib/unified-cli-output.js +947 -0
- package/bin/runners/lib/unified-output.js +197 -0
- package/bin/runners/lib/upsell.js +410 -0
- package/bin/runners/lib/usage.js +153 -0
- package/bin/runners/lib/validate-patch.js +156 -0
- package/bin/runners/lib/verdict-engine.js +628 -0
- package/bin/runners/lib/verification.js +345 -0
- package/bin/runners/lib/why-tree.js +650 -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 +229 -0
- package/bin/runners/runAgent.d.ts +5 -0
- package/bin/runners/runAgent.js +161 -0
- package/bin/runners/runAllowlist.js +418 -0
- package/bin/runners/runApprove.js +320 -0
- package/bin/runners/runAudit.js +692 -0
- package/bin/runners/runAuth.js +731 -0
- package/bin/runners/runCI.js +353 -0
- package/bin/runners/runCheckpoint.js +530 -0
- package/bin/runners/runClassify.js +928 -0
- package/bin/runners/runCleanup.js +343 -0
- package/bin/runners/runContext.d.ts +4 -0
- package/bin/runners/runContext.js +175 -0
- package/bin/runners/runDoctor.js +877 -0
- package/bin/runners/runEvidencePack.js +362 -0
- package/bin/runners/runFirewall.d.ts +5 -0
- package/bin/runners/runFirewall.js +134 -0
- package/bin/runners/runFirewallHook.d.ts +5 -0
- package/bin/runners/runFirewallHook.js +56 -0
- package/bin/runners/runFix.js +1355 -0
- package/bin/runners/runForge.js +451 -0
- package/bin/runners/runGuard.js +262 -0
- package/bin/runners/runInit.js +1927 -0
- package/bin/runners/runIntent.js +906 -0
- package/bin/runners/runKickoff.js +878 -0
- package/bin/runners/runLabs.js +424 -0
- package/bin/runners/runLaunch.js +2000 -0
- package/bin/runners/runLink.js +785 -0
- package/bin/runners/runMcp.js +1875 -0
- package/bin/runners/runPacks.js +2089 -0
- package/bin/runners/runPolish.d.ts +4 -0
- package/bin/runners/runPolish.js +390 -0
- package/bin/runners/runPromptFirewall.js +211 -0
- package/bin/runners/runProve.js +1411 -0
- package/bin/runners/runQuickstart.js +531 -0
- package/bin/runners/runReality.js +2260 -0
- package/bin/runners/runReport.js +726 -0
- package/bin/runners/runRuntime.js +110 -0
- package/bin/runners/runSafelist.js +1190 -0
- package/bin/runners/runScan.js +688 -0
- package/bin/runners/runShield.js +1282 -0
- package/bin/runners/runShip.js +1660 -0
- package/bin/runners/runTruth.d.ts +5 -0
- package/bin/runners/runTruth.js +101 -0
- package/bin/runners/runValidate.js +179 -0
- package/bin/runners/runWatch.js +478 -0
- package/bin/runners/utils.js +360 -0
- package/bin/scan.js +617 -0
- package/bin/vibecheck.js +1617 -0
- package/dist/guardrail/index.d.ts +2405 -0
- package/dist/guardrail/index.js +9747 -0
- package/dist/guardrail/index.js.map +1 -0
- package/dist/scanner/index.d.ts +282 -0
- package/dist/scanner/index.js +3395 -0
- package/dist/scanner/index.js.map +1 -0
- package/package.json +123 -104
- package/README.md +0 -491
- package/dist/index.js +0 -99711
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe Repair Mode
|
|
3
|
+
*
|
|
4
|
+
* Executes only safe, non-destructive repair actions.
|
|
5
|
+
* Actions that can cause data loss or require elevated permissions are excluded.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { execSync, spawnSync } = require('child_process');
|
|
11
|
+
const { SEVERITY, FIX_TYPE } = require('./types');
|
|
12
|
+
|
|
13
|
+
const REPAIR_RESULT = {
|
|
14
|
+
SUCCESS: 'success',
|
|
15
|
+
FAILED: 'failed',
|
|
16
|
+
SKIPPED: 'skipped',
|
|
17
|
+
NOT_APPLICABLE: 'not_applicable',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Safe repair actions that can be automatically executed
|
|
22
|
+
*/
|
|
23
|
+
const SAFE_REPAIR_ACTIONS = [
|
|
24
|
+
{
|
|
25
|
+
id: 'clear-npm-cache',
|
|
26
|
+
name: 'Clear npm cache',
|
|
27
|
+
description: 'Removes npm cache to fix integrity issues',
|
|
28
|
+
applicableTo: ['npm-cache-corrupt', 'npm-permission-error'],
|
|
29
|
+
check: () => true, // Always applicable
|
|
30
|
+
execute: async (projectPath, options) => {
|
|
31
|
+
try {
|
|
32
|
+
execSync('npm cache clean --force', {
|
|
33
|
+
cwd: projectPath,
|
|
34
|
+
encoding: 'utf8',
|
|
35
|
+
timeout: 60000,
|
|
36
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
37
|
+
});
|
|
38
|
+
return { status: REPAIR_RESULT.SUCCESS, message: 'npm cache cleared' };
|
|
39
|
+
} catch (err) {
|
|
40
|
+
return { status: REPAIR_RESULT.FAILED, message: err.message };
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'clear-node-modules-cache',
|
|
46
|
+
name: 'Clear node_modules cache directories',
|
|
47
|
+
description: 'Removes .cache directories inside node_modules',
|
|
48
|
+
applicableTo: ['cache-large', 'build-cache-corrupt'],
|
|
49
|
+
check: (projectPath) => {
|
|
50
|
+
const cachePath = path.join(projectPath, 'node_modules', '.cache');
|
|
51
|
+
return fs.existsSync(cachePath);
|
|
52
|
+
},
|
|
53
|
+
execute: async (projectPath, options) => {
|
|
54
|
+
const cachePath = path.join(projectPath, 'node_modules', '.cache');
|
|
55
|
+
try {
|
|
56
|
+
fs.rmSync(cachePath, { recursive: true, force: true });
|
|
57
|
+
return { status: REPAIR_RESULT.SUCCESS, message: 'node_modules/.cache cleared' };
|
|
58
|
+
} catch (err) {
|
|
59
|
+
return { status: REPAIR_RESULT.FAILED, message: err.message };
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'remove-eslint-cache',
|
|
65
|
+
name: 'Remove ESLint cache',
|
|
66
|
+
description: 'Removes .eslintcache file',
|
|
67
|
+
applicableTo: ['eslint-error', 'cache-large'],
|
|
68
|
+
check: (projectPath) => fs.existsSync(path.join(projectPath, '.eslintcache')),
|
|
69
|
+
execute: async (projectPath, options) => {
|
|
70
|
+
try {
|
|
71
|
+
fs.unlinkSync(path.join(projectPath, '.eslintcache'));
|
|
72
|
+
return { status: REPAIR_RESULT.SUCCESS, message: '.eslintcache removed' };
|
|
73
|
+
} catch (err) {
|
|
74
|
+
return { status: REPAIR_RESULT.FAILED, message: err.message };
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'remove-tsbuildinfo',
|
|
80
|
+
name: 'Remove TypeScript build info',
|
|
81
|
+
description: 'Removes tsconfig.tsbuildinfo for clean TypeScript rebuild',
|
|
82
|
+
applicableTo: ['typescript-error', 'build-error'],
|
|
83
|
+
check: (projectPath) => {
|
|
84
|
+
// Check for any .tsbuildinfo file
|
|
85
|
+
return fs.existsSync(path.join(projectPath, 'tsconfig.tsbuildinfo')) ||
|
|
86
|
+
fs.existsSync(path.join(projectPath, '.tsbuildinfo'));
|
|
87
|
+
},
|
|
88
|
+
execute: async (projectPath, options) => {
|
|
89
|
+
const removed = [];
|
|
90
|
+
const files = ['tsconfig.tsbuildinfo', '.tsbuildinfo'];
|
|
91
|
+
|
|
92
|
+
for (const file of files) {
|
|
93
|
+
const fullPath = path.join(projectPath, file);
|
|
94
|
+
if (fs.existsSync(fullPath)) {
|
|
95
|
+
try {
|
|
96
|
+
fs.unlinkSync(fullPath);
|
|
97
|
+
removed.push(file);
|
|
98
|
+
} catch {}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (removed.length > 0) {
|
|
103
|
+
return { status: REPAIR_RESULT.SUCCESS, message: `Removed: ${removed.join(', ')}` };
|
|
104
|
+
}
|
|
105
|
+
return { status: REPAIR_RESULT.NOT_APPLICABLE, message: 'No build info files found' };
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: 'remove-git-lock',
|
|
110
|
+
name: 'Remove git lock files',
|
|
111
|
+
description: 'Removes stale .git/*.lock files',
|
|
112
|
+
applicableTo: ['git-lock-file'],
|
|
113
|
+
check: (projectPath) => {
|
|
114
|
+
const gitDir = path.join(projectPath, '.git');
|
|
115
|
+
if (!fs.existsSync(gitDir)) return false;
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
const files = fs.readdirSync(gitDir);
|
|
119
|
+
return files.some(f => f.endsWith('.lock'));
|
|
120
|
+
} catch {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
execute: async (projectPath, options) => {
|
|
125
|
+
const gitDir = path.join(projectPath, '.git');
|
|
126
|
+
const removed = [];
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
const files = fs.readdirSync(gitDir);
|
|
130
|
+
for (const file of files) {
|
|
131
|
+
if (file.endsWith('.lock')) {
|
|
132
|
+
fs.unlinkSync(path.join(gitDir, file));
|
|
133
|
+
removed.push(file);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
} catch (err) {
|
|
137
|
+
return { status: REPAIR_RESULT.FAILED, message: err.message };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (removed.length > 0) {
|
|
141
|
+
return { status: REPAIR_RESULT.SUCCESS, message: `Removed: ${removed.join(', ')}` };
|
|
142
|
+
}
|
|
143
|
+
return { status: REPAIR_RESULT.NOT_APPLICABLE, message: 'No lock files found' };
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: 'create-vibecheck-dir',
|
|
148
|
+
name: 'Create .vibecheck directory',
|
|
149
|
+
description: 'Creates missing .vibecheck output directory',
|
|
150
|
+
applicableTo: ['vibecheck-dir-missing'],
|
|
151
|
+
check: (projectPath) => !fs.existsSync(path.join(projectPath, '.vibecheck')),
|
|
152
|
+
execute: async (projectPath, options) => {
|
|
153
|
+
try {
|
|
154
|
+
fs.mkdirSync(path.join(projectPath, '.vibecheck'), { recursive: true });
|
|
155
|
+
return { status: REPAIR_RESULT.SUCCESS, message: '.vibecheck directory created' };
|
|
156
|
+
} catch (err) {
|
|
157
|
+
return { status: REPAIR_RESULT.FAILED, message: err.message };
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
id: 'fix-npm-registry',
|
|
163
|
+
name: 'Reset npm registry URL',
|
|
164
|
+
description: 'Sets npm registry to default npmjs.org',
|
|
165
|
+
applicableTo: ['npm-network-error'],
|
|
166
|
+
check: () => true,
|
|
167
|
+
execute: async (projectPath, options) => {
|
|
168
|
+
try {
|
|
169
|
+
execSync('npm config set registry https://registry.npmjs.org/', {
|
|
170
|
+
encoding: 'utf8',
|
|
171
|
+
timeout: 10000,
|
|
172
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
173
|
+
});
|
|
174
|
+
return { status: REPAIR_RESULT.SUCCESS, message: 'npm registry reset to default' };
|
|
175
|
+
} catch (err) {
|
|
176
|
+
return { status: REPAIR_RESULT.FAILED, message: err.message };
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
id: 'npm-dedupe',
|
|
182
|
+
name: 'Deduplicate npm packages',
|
|
183
|
+
description: 'Runs npm dedupe to reduce duplicate packages',
|
|
184
|
+
applicableTo: ['dependencies-large', 'peer-deps'],
|
|
185
|
+
check: (projectPath) => fs.existsSync(path.join(projectPath, 'node_modules')),
|
|
186
|
+
execute: async (projectPath, options) => {
|
|
187
|
+
try {
|
|
188
|
+
execSync('npm dedupe', {
|
|
189
|
+
cwd: projectPath,
|
|
190
|
+
encoding: 'utf8',
|
|
191
|
+
timeout: 120000, // 2 minutes
|
|
192
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
193
|
+
});
|
|
194
|
+
return { status: REPAIR_RESULT.SUCCESS, message: 'npm dedupe completed' };
|
|
195
|
+
} catch (err) {
|
|
196
|
+
return { status: REPAIR_RESULT.FAILED, message: err.message };
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: 'rebuild-native-modules',
|
|
202
|
+
name: 'Rebuild native modules',
|
|
203
|
+
description: 'Runs npm rebuild for native module issues',
|
|
204
|
+
applicableTo: ['native-module-build', 'node-version-mismatch'],
|
|
205
|
+
check: (projectPath) => fs.existsSync(path.join(projectPath, 'node_modules')),
|
|
206
|
+
execute: async (projectPath, options) => {
|
|
207
|
+
try {
|
|
208
|
+
execSync('npm rebuild', {
|
|
209
|
+
cwd: projectPath,
|
|
210
|
+
encoding: 'utf8',
|
|
211
|
+
timeout: 300000, // 5 minutes
|
|
212
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
213
|
+
});
|
|
214
|
+
return { status: REPAIR_RESULT.SUCCESS, message: 'npm rebuild completed' };
|
|
215
|
+
} catch (err) {
|
|
216
|
+
return { status: REPAIR_RESULT.FAILED, message: err.message };
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
id: 'prune-dev-dependencies',
|
|
222
|
+
name: 'Prune development dependencies',
|
|
223
|
+
description: 'Removes extraneous packages',
|
|
224
|
+
applicableTo: ['dependencies-large'],
|
|
225
|
+
check: (projectPath) => fs.existsSync(path.join(projectPath, 'node_modules')),
|
|
226
|
+
execute: async (projectPath, options) => {
|
|
227
|
+
try {
|
|
228
|
+
execSync('npm prune', {
|
|
229
|
+
cwd: projectPath,
|
|
230
|
+
encoding: 'utf8',
|
|
231
|
+
timeout: 60000,
|
|
232
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
233
|
+
});
|
|
234
|
+
return { status: REPAIR_RESULT.SUCCESS, message: 'npm prune completed' };
|
|
235
|
+
} catch (err) {
|
|
236
|
+
return { status: REPAIR_RESULT.FAILED, message: err.message };
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
];
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Run safe repair on a project
|
|
244
|
+
* @param {object[]} diagnostics - Diagnostic results
|
|
245
|
+
* @param {string} projectPath - Project path
|
|
246
|
+
* @param {object} options - Repair options
|
|
247
|
+
* @returns {object} Repair results
|
|
248
|
+
*/
|
|
249
|
+
async function runSafeRepair(diagnostics, projectPath, options = {}) {
|
|
250
|
+
const {
|
|
251
|
+
dryRun = false,
|
|
252
|
+
verbose = false,
|
|
253
|
+
maxActions = 10,
|
|
254
|
+
} = options;
|
|
255
|
+
|
|
256
|
+
const results = [];
|
|
257
|
+
let actionsRun = 0;
|
|
258
|
+
|
|
259
|
+
// Identify which repairs are applicable
|
|
260
|
+
const applicableRepairs = [];
|
|
261
|
+
|
|
262
|
+
for (const action of SAFE_REPAIR_ACTIONS) {
|
|
263
|
+
// Check if this repair applies to any diagnostics
|
|
264
|
+
const relevantDiag = diagnostics.find(d =>
|
|
265
|
+
(d.severity === SEVERITY.ERROR || d.severity === SEVERITY.WARNING) &&
|
|
266
|
+
action.applicableTo.some(pattern => d.id.includes(pattern) || d.message?.toLowerCase().includes(pattern))
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
if (relevantDiag && action.check(projectPath)) {
|
|
270
|
+
applicableRepairs.push({
|
|
271
|
+
action,
|
|
272
|
+
diagnostic: relevantDiag,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Execute repairs
|
|
278
|
+
for (const { action, diagnostic } of applicableRepairs) {
|
|
279
|
+
if (actionsRun >= maxActions) break;
|
|
280
|
+
|
|
281
|
+
const result = {
|
|
282
|
+
actionId: action.id,
|
|
283
|
+
actionName: action.name,
|
|
284
|
+
description: action.description,
|
|
285
|
+
relatedDiagnostic: diagnostic.id,
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
if (dryRun) {
|
|
289
|
+
result.status = REPAIR_RESULT.SKIPPED;
|
|
290
|
+
result.message = 'Dry run - would execute';
|
|
291
|
+
results.push(result);
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
try {
|
|
296
|
+
const execResult = await action.execute(projectPath, options);
|
|
297
|
+
result.status = execResult.status;
|
|
298
|
+
result.message = execResult.message;
|
|
299
|
+
|
|
300
|
+
if (execResult.status === REPAIR_RESULT.SUCCESS) {
|
|
301
|
+
actionsRun++;
|
|
302
|
+
}
|
|
303
|
+
} catch (err) {
|
|
304
|
+
result.status = REPAIR_RESULT.FAILED;
|
|
305
|
+
result.message = err.message;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
results.push(result);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Summary
|
|
312
|
+
const summary = {
|
|
313
|
+
total: results.length,
|
|
314
|
+
succeeded: results.filter(r => r.status === REPAIR_RESULT.SUCCESS).length,
|
|
315
|
+
failed: results.filter(r => r.status === REPAIR_RESULT.FAILED).length,
|
|
316
|
+
skipped: results.filter(r => r.status === REPAIR_RESULT.SKIPPED).length,
|
|
317
|
+
notApplicable: results.filter(r => r.status === REPAIR_RESULT.NOT_APPLICABLE).length,
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
return {
|
|
321
|
+
projectPath,
|
|
322
|
+
timestamp: new Date().toISOString(),
|
|
323
|
+
dryRun,
|
|
324
|
+
results,
|
|
325
|
+
summary,
|
|
326
|
+
needsRecheck: summary.succeeded > 0,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Get list of all available safe repair actions
|
|
332
|
+
* @returns {object[]} Safe repair actions
|
|
333
|
+
*/
|
|
334
|
+
function listSafeRepairActions() {
|
|
335
|
+
return SAFE_REPAIR_ACTIONS.map(a => ({
|
|
336
|
+
id: a.id,
|
|
337
|
+
name: a.name,
|
|
338
|
+
description: a.description,
|
|
339
|
+
applicableTo: a.applicableTo,
|
|
340
|
+
}));
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Run a specific repair action by ID
|
|
345
|
+
* @param {string} actionId - Action ID to run
|
|
346
|
+
* @param {string} projectPath - Project path
|
|
347
|
+
* @param {object} options - Options
|
|
348
|
+
* @returns {object} Result
|
|
349
|
+
*/
|
|
350
|
+
async function runRepairAction(actionId, projectPath, options = {}) {
|
|
351
|
+
const action = SAFE_REPAIR_ACTIONS.find(a => a.id === actionId);
|
|
352
|
+
|
|
353
|
+
if (!action) {
|
|
354
|
+
return {
|
|
355
|
+
status: REPAIR_RESULT.FAILED,
|
|
356
|
+
message: `Unknown repair action: ${actionId}`,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (!action.check(projectPath)) {
|
|
361
|
+
return {
|
|
362
|
+
status: REPAIR_RESULT.NOT_APPLICABLE,
|
|
363
|
+
message: 'Repair action not applicable to current project state',
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (options.dryRun) {
|
|
368
|
+
return {
|
|
369
|
+
status: REPAIR_RESULT.SKIPPED,
|
|
370
|
+
message: 'Dry run - would execute',
|
|
371
|
+
action: action.name,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return action.execute(projectPath, options);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
module.exports = {
|
|
379
|
+
REPAIR_RESULT,
|
|
380
|
+
SAFE_REPAIR_ACTIONS,
|
|
381
|
+
runSafeRepair,
|
|
382
|
+
listSafeRepairActions,
|
|
383
|
+
runRepairAction,
|
|
384
|
+
};
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DoctorService — Enterprise-Grade Environment Diagnostics
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Pluggable diagnostic modules
|
|
6
|
+
* - Parallel execution for independent checks
|
|
7
|
+
* - Dependency resolution between checks
|
|
8
|
+
* - Auto-fix capability
|
|
9
|
+
* - JSON/Markdown report generation
|
|
10
|
+
* - Health scoring with weighted categories
|
|
11
|
+
* - CI-friendly exit codes
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const { SEVERITY, CATEGORY, CATEGORY_META } = require('./types');
|
|
16
|
+
const { getAllDiagnostics } = require('./modules');
|
|
17
|
+
const { createSummary, saveReports, generateJsonReport } = require('./reporter');
|
|
18
|
+
const { autoFixAll, getFixCommands } = require('./autofix');
|
|
19
|
+
const ui = require('./ui');
|
|
20
|
+
|
|
21
|
+
class DoctorService {
|
|
22
|
+
constructor(projectPath, options = {}) {
|
|
23
|
+
this.projectPath = path.resolve(projectPath);
|
|
24
|
+
this.options = {
|
|
25
|
+
json: false,
|
|
26
|
+
markdown: false,
|
|
27
|
+
fix: false,
|
|
28
|
+
fixDryRun: false,
|
|
29
|
+
quiet: false,
|
|
30
|
+
verbose: false,
|
|
31
|
+
categories: null, // null = all categories
|
|
32
|
+
skipNetwork: false,
|
|
33
|
+
saveReport: true,
|
|
34
|
+
...options,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
this.diagnostics = [];
|
|
38
|
+
this.results = [];
|
|
39
|
+
this.startTime = null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async run() {
|
|
43
|
+
this.startTime = Date.now();
|
|
44
|
+
|
|
45
|
+
// Load diagnostics
|
|
46
|
+
this.diagnostics = this.loadDiagnostics();
|
|
47
|
+
|
|
48
|
+
// Filter by category if specified
|
|
49
|
+
if (this.options.categories) {
|
|
50
|
+
this.diagnostics = this.diagnostics.filter(d =>
|
|
51
|
+
this.options.categories.includes(d.category)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Skip network if requested
|
|
56
|
+
if (this.options.skipNetwork) {
|
|
57
|
+
this.diagnostics = this.diagnostics.filter(d => d.category !== CATEGORY.NETWORK);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Print header (unless quiet or json)
|
|
61
|
+
if (!this.options.quiet && !this.options.json) {
|
|
62
|
+
ui.printHeader();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Run diagnostics
|
|
66
|
+
await this.runDiagnostics();
|
|
67
|
+
|
|
68
|
+
// Calculate summary
|
|
69
|
+
const durationMs = Date.now() - this.startTime;
|
|
70
|
+
const summary = createSummary(this.results);
|
|
71
|
+
|
|
72
|
+
// Output results
|
|
73
|
+
if (this.options.json) {
|
|
74
|
+
// JSON output only
|
|
75
|
+
const report = generateJsonReport(this.results, this.projectPath, durationMs);
|
|
76
|
+
console.log(JSON.stringify(report, null, 2));
|
|
77
|
+
} else if (!this.options.quiet) {
|
|
78
|
+
// Print issues and summary
|
|
79
|
+
ui.printIssuesSummary(this.results);
|
|
80
|
+
ui.printFinalSummary(summary, durationMs);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Save reports
|
|
84
|
+
if (this.options.saveReport && !this.options.json) {
|
|
85
|
+
const outputDir = path.join(this.projectPath, '.vibecheck');
|
|
86
|
+
try {
|
|
87
|
+
const paths = saveReports(this.results, this.projectPath, durationMs, outputDir);
|
|
88
|
+
if (this.options.verbose) {
|
|
89
|
+
console.log(`${ui.c.dim}Reports saved to:${ui.c.reset}`);
|
|
90
|
+
console.log(` ${ui.c.dim}${paths.lastJson}${ui.c.reset}`);
|
|
91
|
+
console.log(` ${ui.c.dim}${paths.lastMd}${ui.c.reset}`);
|
|
92
|
+
}
|
|
93
|
+
} catch (err) {
|
|
94
|
+
if (this.options.verbose) {
|
|
95
|
+
console.log(`${ui.c.dim}Could not save reports: ${err.message}${ui.c.reset}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Auto-fix if requested
|
|
101
|
+
if (this.options.fix) {
|
|
102
|
+
const fixResults = await autoFixAll(this.results, this.projectPath, {
|
|
103
|
+
dryRun: this.options.fixDryRun,
|
|
104
|
+
severity: [SEVERITY.CRITICAL, SEVERITY.ERROR],
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
if (!this.options.quiet && !this.options.json) {
|
|
108
|
+
ui.printAutoFixResults(fixResults);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Re-run affected checks after fixing
|
|
112
|
+
if (fixResults.succeeded > 0 && !this.options.fixDryRun) {
|
|
113
|
+
if (!this.options.quiet && !this.options.json) {
|
|
114
|
+
console.log(`${ui.c.cyan}Re-running diagnostics after fixes...${ui.c.reset}\n`);
|
|
115
|
+
}
|
|
116
|
+
return this.run();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Return exit code
|
|
121
|
+
if (summary.critical > 0) return 3;
|
|
122
|
+
if (summary.errors > 0) return 1;
|
|
123
|
+
if (summary.warnings > 0 && this.options.failOnWarn) return 2;
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
loadDiagnostics() {
|
|
128
|
+
return getAllDiagnostics(this.projectPath);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async runDiagnostics() {
|
|
132
|
+
// Group by category for display
|
|
133
|
+
const byCategory = {};
|
|
134
|
+
for (const d of this.diagnostics) {
|
|
135
|
+
if (!byCategory[d.category]) byCategory[d.category] = [];
|
|
136
|
+
byCategory[d.category].push(d);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Sort categories
|
|
140
|
+
const sortedCategories = Object.keys(byCategory).sort((a, b) => {
|
|
141
|
+
const orderA = CATEGORY_META[a]?.order || 99;
|
|
142
|
+
const orderB = CATEGORY_META[b]?.order || 99;
|
|
143
|
+
return orderA - orderB;
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Track completed diagnostic IDs for dependency resolution
|
|
147
|
+
const completed = new Set();
|
|
148
|
+
const resultMap = new Map();
|
|
149
|
+
|
|
150
|
+
for (const category of sortedCategories) {
|
|
151
|
+
const categoryDiagnostics = byCategory[category];
|
|
152
|
+
|
|
153
|
+
if (!this.options.quiet && !this.options.json) {
|
|
154
|
+
ui.printCategoryHeader(category);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Separate parallel and sequential diagnostics
|
|
158
|
+
const parallel = categoryDiagnostics.filter(d => d.parallel && !d.dependsOn?.length);
|
|
159
|
+
const sequential = categoryDiagnostics.filter(d => !d.parallel || d.dependsOn?.length);
|
|
160
|
+
|
|
161
|
+
// Run parallel diagnostics
|
|
162
|
+
if (parallel.length > 0) {
|
|
163
|
+
const parallelPromises = parallel.map(d => this.runSingleDiagnostic(d));
|
|
164
|
+
const parallelResults = await Promise.all(parallelPromises);
|
|
165
|
+
|
|
166
|
+
for (let i = 0; i < parallel.length; i++) {
|
|
167
|
+
const diagnostic = parallel[i];
|
|
168
|
+
const result = parallelResults[i];
|
|
169
|
+
|
|
170
|
+
this.results.push(result);
|
|
171
|
+
completed.add(diagnostic.id);
|
|
172
|
+
resultMap.set(diagnostic.id, result);
|
|
173
|
+
|
|
174
|
+
if (!this.options.quiet && !this.options.json) {
|
|
175
|
+
ui.printDiagnostic(result, { showFixes: this.options.verbose });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Run sequential diagnostics (respecting dependencies)
|
|
181
|
+
for (const diagnostic of sequential) {
|
|
182
|
+
// Check dependencies
|
|
183
|
+
if (diagnostic.dependsOn) {
|
|
184
|
+
const unmetDeps = diagnostic.dependsOn.filter(dep => !completed.has(dep));
|
|
185
|
+
if (unmetDeps.length > 0) {
|
|
186
|
+
// Skip if dependencies not met
|
|
187
|
+
const skipResult = {
|
|
188
|
+
...diagnostic,
|
|
189
|
+
severity: SEVERITY.INFO,
|
|
190
|
+
message: `Skipped (depends on: ${unmetDeps.join(', ')})`,
|
|
191
|
+
durationMs: 0,
|
|
192
|
+
};
|
|
193
|
+
this.results.push(skipResult);
|
|
194
|
+
if (!this.options.quiet && !this.options.json) {
|
|
195
|
+
ui.printDiagnostic(skipResult);
|
|
196
|
+
}
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const result = await this.runSingleDiagnostic(diagnostic);
|
|
202
|
+
this.results.push(result);
|
|
203
|
+
completed.add(diagnostic.id);
|
|
204
|
+
resultMap.set(diagnostic.id, result);
|
|
205
|
+
|
|
206
|
+
if (!this.options.quiet && !this.options.json) {
|
|
207
|
+
ui.printDiagnostic(result, { showFixes: this.options.verbose });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (!this.options.quiet && !this.options.json) {
|
|
212
|
+
console.log('');
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async runSingleDiagnostic(diagnostic) {
|
|
218
|
+
const startTime = Date.now();
|
|
219
|
+
|
|
220
|
+
try {
|
|
221
|
+
const checkResult = await diagnostic.check();
|
|
222
|
+
const durationMs = Date.now() - startTime;
|
|
223
|
+
|
|
224
|
+
return {
|
|
225
|
+
id: diagnostic.id,
|
|
226
|
+
name: diagnostic.name,
|
|
227
|
+
category: diagnostic.category,
|
|
228
|
+
severity: checkResult.severity || SEVERITY.PASS,
|
|
229
|
+
message: checkResult.message || 'OK',
|
|
230
|
+
detail: checkResult.detail,
|
|
231
|
+
durationMs,
|
|
232
|
+
fixes: checkResult.fixes,
|
|
233
|
+
metadata: checkResult.metadata,
|
|
234
|
+
};
|
|
235
|
+
} catch (err) {
|
|
236
|
+
const durationMs = Date.now() - startTime;
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
id: diagnostic.id,
|
|
240
|
+
name: diagnostic.name,
|
|
241
|
+
category: diagnostic.category,
|
|
242
|
+
severity: SEVERITY.ERROR,
|
|
243
|
+
message: `Check failed: ${err.message}`,
|
|
244
|
+
durationMs,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
getFixCommands() {
|
|
250
|
+
return getFixCommands(this.results);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
async function diagnose(projectPath, options = {}) {
|
|
255
|
+
const service = new DoctorService(projectPath, options);
|
|
256
|
+
return service.run();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
module.exports = {
|
|
260
|
+
DoctorService,
|
|
261
|
+
diagnose,
|
|
262
|
+
};
|