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,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import Resolver
|
|
3
|
+
*
|
|
4
|
+
* Resolves and validates import statements in JavaScript/TypeScript code.
|
|
5
|
+
* Used by the diff simulator to detect broken imports.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
const fs = require("fs");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Extract imports from source code
|
|
15
|
+
* @param {string} content - File content
|
|
16
|
+
* @returns {Array} Array of import objects
|
|
17
|
+
*/
|
|
18
|
+
function extractImports(content) {
|
|
19
|
+
const imports = [];
|
|
20
|
+
|
|
21
|
+
// ES6 imports: import X from 'Y', import { X } from 'Y', import 'Y'
|
|
22
|
+
const importRegex = /import\s+(?:(?:(\w+)(?:\s*,\s*)?)?(?:\{([^}]+)\})?\s+from\s+)?['"]([^'"]+)['"]/g;
|
|
23
|
+
let match;
|
|
24
|
+
|
|
25
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
26
|
+
const [, defaultImport, namedImports, source] = match;
|
|
27
|
+
imports.push({
|
|
28
|
+
type: "esm",
|
|
29
|
+
source,
|
|
30
|
+
defaultImport: defaultImport || null,
|
|
31
|
+
namedImports: namedImports ? namedImports.split(",").map(s => s.trim()) : [],
|
|
32
|
+
line: content.substring(0, match.index).split("\n").length,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Dynamic imports: import('X'), await import('X')
|
|
37
|
+
const dynamicRegex = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
38
|
+
while ((match = dynamicRegex.exec(content)) !== null) {
|
|
39
|
+
imports.push({
|
|
40
|
+
type: "dynamic",
|
|
41
|
+
source: match[1],
|
|
42
|
+
defaultImport: null,
|
|
43
|
+
namedImports: [],
|
|
44
|
+
line: content.substring(0, match.index).split("\n").length,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// CommonJS requires: require('X'), require("X")
|
|
49
|
+
const requireRegex = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
50
|
+
while ((match = requireRegex.exec(content)) !== null) {
|
|
51
|
+
imports.push({
|
|
52
|
+
type: "commonjs",
|
|
53
|
+
source: match[1],
|
|
54
|
+
defaultImport: null,
|
|
55
|
+
namedImports: [],
|
|
56
|
+
line: content.substring(0, match.index).split("\n").length,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return imports;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Extract exports from source code
|
|
65
|
+
* @param {string} content - File content
|
|
66
|
+
* @returns {Array} Array of export objects
|
|
67
|
+
*/
|
|
68
|
+
function extractExports(content) {
|
|
69
|
+
const exports = [];
|
|
70
|
+
|
|
71
|
+
// Named exports: export const X, export function X, export class X
|
|
72
|
+
const namedRegex = /export\s+(?:const|let|var|function|class|interface|type|enum)\s+(\w+)/g;
|
|
73
|
+
let match;
|
|
74
|
+
|
|
75
|
+
while ((match = namedRegex.exec(content)) !== null) {
|
|
76
|
+
exports.push({
|
|
77
|
+
type: "named",
|
|
78
|
+
name: match[1],
|
|
79
|
+
line: content.substring(0, match.index).split("\n").length,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Export list: export { X, Y as Z }
|
|
84
|
+
const listRegex = /export\s+\{([^}]+)\}/g;
|
|
85
|
+
while ((match = listRegex.exec(content)) !== null) {
|
|
86
|
+
const names = match[1].split(",").map(s => {
|
|
87
|
+
const parts = s.trim().split(/\s+as\s+/);
|
|
88
|
+
return { original: parts[0].trim(), alias: parts[1]?.trim() || parts[0].trim() };
|
|
89
|
+
});
|
|
90
|
+
for (const name of names) {
|
|
91
|
+
exports.push({
|
|
92
|
+
type: "named",
|
|
93
|
+
name: name.alias,
|
|
94
|
+
originalName: name.original,
|
|
95
|
+
line: content.substring(0, match.index).split("\n").length,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Default export: export default X
|
|
101
|
+
const defaultRegex = /export\s+default\s+(?:class\s+(\w+)|function\s+(\w+)|(\w+))/g;
|
|
102
|
+
while ((match = defaultRegex.exec(content)) !== null) {
|
|
103
|
+
const name = match[1] || match[2] || match[3];
|
|
104
|
+
exports.push({
|
|
105
|
+
type: "default",
|
|
106
|
+
name: name || "default",
|
|
107
|
+
line: content.substring(0, match.index).split("\n").length,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Re-exports: export * from 'X', export { X } from 'X'
|
|
112
|
+
const reExportRegex = /export\s+(?:\*|{[^}]+})\s+from\s+['"]([^'"]+)['"]/g;
|
|
113
|
+
while ((match = reExportRegex.exec(content)) !== null) {
|
|
114
|
+
exports.push({
|
|
115
|
+
type: "reexport",
|
|
116
|
+
source: match[1],
|
|
117
|
+
line: content.substring(0, match.index).split("\n").length,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// module.exports
|
|
122
|
+
if (content.includes("module.exports")) {
|
|
123
|
+
exports.push({
|
|
124
|
+
type: "commonjs",
|
|
125
|
+
name: "module.exports",
|
|
126
|
+
line: content.indexOf("module.exports"),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return exports;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Resolve import path to actual file
|
|
135
|
+
* @param {string} importPath - Import path
|
|
136
|
+
* @param {string} fromFile - File containing the import
|
|
137
|
+
* @param {string} projectRoot - Project root directory
|
|
138
|
+
* @param {Map} virtualFiles - Virtual file system (for simulation)
|
|
139
|
+
* @returns {Object} Resolution result
|
|
140
|
+
*/
|
|
141
|
+
function resolveImportPath(importPath, fromFile, projectRoot, virtualFiles = new Map()) {
|
|
142
|
+
// Node built-ins
|
|
143
|
+
const builtins = [
|
|
144
|
+
"fs", "path", "os", "http", "https", "crypto", "util", "events",
|
|
145
|
+
"stream", "buffer", "url", "querystring", "child_process", "net",
|
|
146
|
+
"assert", "zlib", "readline", "cluster", "dns", "tls", "dgram",
|
|
147
|
+
];
|
|
148
|
+
|
|
149
|
+
if (builtins.includes(importPath) || importPath.startsWith("node:")) {
|
|
150
|
+
return { resolved: true, type: "builtin", path: importPath };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// External packages (don't start with . or /)
|
|
154
|
+
if (!importPath.startsWith(".") && !importPath.startsWith("/") && !importPath.startsWith("@/")) {
|
|
155
|
+
// Check if it looks like a scoped package
|
|
156
|
+
const isScoped = importPath.startsWith("@") && !importPath.startsWith("@/");
|
|
157
|
+
return { resolved: true, type: "external", path: importPath, isScoped };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Resolve relative imports
|
|
161
|
+
const fromDir = path.dirname(fromFile);
|
|
162
|
+
let resolvedPath;
|
|
163
|
+
|
|
164
|
+
// Handle alias imports (@/)
|
|
165
|
+
if (importPath.startsWith("@/")) {
|
|
166
|
+
resolvedPath = path.join(projectRoot, "src", importPath.slice(2));
|
|
167
|
+
} else if (importPath.startsWith("~/")) {
|
|
168
|
+
resolvedPath = path.join(projectRoot, importPath.slice(2));
|
|
169
|
+
} else {
|
|
170
|
+
resolvedPath = path.resolve(fromDir, importPath);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Try different extensions
|
|
174
|
+
const extensions = ["", ".ts", ".tsx", ".js", ".jsx", ".json", "/index.ts", "/index.tsx", "/index.js", "/index.jsx"];
|
|
175
|
+
|
|
176
|
+
for (const ext of extensions) {
|
|
177
|
+
const fullPath = resolvedPath + ext;
|
|
178
|
+
const relativePath = path.relative(projectRoot, fullPath).replace(/\\/g, "/");
|
|
179
|
+
|
|
180
|
+
// Check virtual files first
|
|
181
|
+
if (virtualFiles.has(relativePath)) {
|
|
182
|
+
return { resolved: true, type: "internal", path: relativePath, virtual: true };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Check real file system
|
|
186
|
+
if (fs.existsSync(fullPath)) {
|
|
187
|
+
return { resolved: true, type: "internal", path: relativePath };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Unresolved
|
|
192
|
+
return {
|
|
193
|
+
resolved: false,
|
|
194
|
+
type: "unresolved",
|
|
195
|
+
path: importPath,
|
|
196
|
+
attemptedPaths: extensions.map(ext => resolvedPath + ext),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Check if an import can be resolved with changes applied
|
|
202
|
+
* @param {Object} importObj - Import object
|
|
203
|
+
* @param {string} fromFile - Source file
|
|
204
|
+
* @param {string} projectRoot - Project root
|
|
205
|
+
* @param {Map} virtualFiles - Virtual file system state
|
|
206
|
+
* @param {Set} deletedFiles - Deleted files
|
|
207
|
+
* @returns {Object} Validation result
|
|
208
|
+
*/
|
|
209
|
+
function validateImport(importObj, fromFile, projectRoot, virtualFiles, deletedFiles) {
|
|
210
|
+
const resolution = resolveImportPath(importObj.source, fromFile, projectRoot, virtualFiles);
|
|
211
|
+
|
|
212
|
+
// Check if resolved file is deleted
|
|
213
|
+
if (resolution.resolved && resolution.type === "internal") {
|
|
214
|
+
if (deletedFiles.has(resolution.path)) {
|
|
215
|
+
return {
|
|
216
|
+
valid: false,
|
|
217
|
+
import: importObj,
|
|
218
|
+
resolution,
|
|
219
|
+
error: `Import '${importObj.source}' resolves to deleted file '${resolution.path}'`,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Check if import is unresolved
|
|
225
|
+
if (!resolution.resolved) {
|
|
226
|
+
return {
|
|
227
|
+
valid: false,
|
|
228
|
+
import: importObj,
|
|
229
|
+
resolution,
|
|
230
|
+
error: `Cannot resolve import '${importObj.source}' from '${fromFile}'`,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return {
|
|
235
|
+
valid: true,
|
|
236
|
+
import: importObj,
|
|
237
|
+
resolution,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Build import graph from files
|
|
243
|
+
* @param {Map} files - Map of file path to content
|
|
244
|
+
* @param {string} projectRoot - Project root
|
|
245
|
+
* @returns {Object} Import graph
|
|
246
|
+
*/
|
|
247
|
+
function buildImportGraph(files, projectRoot) {
|
|
248
|
+
const graph = {
|
|
249
|
+
nodes: new Map(),
|
|
250
|
+
edges: [],
|
|
251
|
+
circularDeps: [],
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// Build nodes and edges
|
|
255
|
+
for (const [filePath, content] of files) {
|
|
256
|
+
const imports = extractImports(content);
|
|
257
|
+
const exports = extractExports(content);
|
|
258
|
+
|
|
259
|
+
graph.nodes.set(filePath, {
|
|
260
|
+
path: filePath,
|
|
261
|
+
imports,
|
|
262
|
+
exports,
|
|
263
|
+
importCount: imports.length,
|
|
264
|
+
exportCount: exports.length,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Add edges
|
|
268
|
+
for (const imp of imports) {
|
|
269
|
+
const resolution = resolveImportPath(imp.source, filePath, projectRoot, files);
|
|
270
|
+
if (resolution.type === "internal") {
|
|
271
|
+
graph.edges.push({
|
|
272
|
+
from: filePath,
|
|
273
|
+
to: resolution.path,
|
|
274
|
+
import: imp,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Detect circular dependencies
|
|
281
|
+
graph.circularDeps = detectCircularDeps(graph.edges);
|
|
282
|
+
|
|
283
|
+
return graph;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Detect circular dependencies in import graph
|
|
288
|
+
* @param {Array} edges - Graph edges
|
|
289
|
+
* @returns {Array} Array of circular dependency chains
|
|
290
|
+
*/
|
|
291
|
+
function detectCircularDeps(edges) {
|
|
292
|
+
const graph = new Map();
|
|
293
|
+
|
|
294
|
+
// Build adjacency list
|
|
295
|
+
for (const edge of edges) {
|
|
296
|
+
if (!graph.has(edge.from)) {
|
|
297
|
+
graph.set(edge.from, []);
|
|
298
|
+
}
|
|
299
|
+
graph.get(edge.from).push(edge.to);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const visited = new Set();
|
|
303
|
+
const inStack = new Set();
|
|
304
|
+
const cycles = [];
|
|
305
|
+
|
|
306
|
+
function dfs(node, path) {
|
|
307
|
+
if (inStack.has(node)) {
|
|
308
|
+
// Found cycle
|
|
309
|
+
const cycleStart = path.indexOf(node);
|
|
310
|
+
const cycle = path.slice(cycleStart);
|
|
311
|
+
cycle.push(node);
|
|
312
|
+
cycles.push(cycle);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (visited.has(node)) return;
|
|
317
|
+
|
|
318
|
+
visited.add(node);
|
|
319
|
+
inStack.add(node);
|
|
320
|
+
path.push(node);
|
|
321
|
+
|
|
322
|
+
const neighbors = graph.get(node) || [];
|
|
323
|
+
for (const neighbor of neighbors) {
|
|
324
|
+
dfs(neighbor, [...path]);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
inStack.delete(node);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
for (const node of graph.keys()) {
|
|
331
|
+
if (!visited.has(node)) {
|
|
332
|
+
dfs(node, []);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return cycles;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
module.exports = {
|
|
340
|
+
extractImports,
|
|
341
|
+
extractExports,
|
|
342
|
+
resolveImportPath,
|
|
343
|
+
validateImport,
|
|
344
|
+
buildImportGraph,
|
|
345
|
+
detectCircularDeps,
|
|
346
|
+
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diff Simulator Module
|
|
3
|
+
*
|
|
4
|
+
* Entry point for the diff simulation engine.
|
|
5
|
+
* Validates changes in memory before applying to disk.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const { simulator } = require('./simulator');
|
|
9
|
+
*
|
|
10
|
+
* const result = simulator.simulate(projectRoot, [
|
|
11
|
+
* { type: 'create', path: 'src/new.ts', content: '...' },
|
|
12
|
+
* { type: 'modify', path: 'src/existing.ts', content: '...' },
|
|
13
|
+
* { type: 'delete', path: 'src/old.ts' },
|
|
14
|
+
* ]);
|
|
15
|
+
*
|
|
16
|
+
* if (!result.passed) {
|
|
17
|
+
* console.log('Simulation failed:', result.errors);
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
"use strict";
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
simulate,
|
|
25
|
+
quickSimulate,
|
|
26
|
+
buildVirtualFS,
|
|
27
|
+
validateImportsAfterChanges,
|
|
28
|
+
detectOrphanedFiles,
|
|
29
|
+
formatResult,
|
|
30
|
+
} = require("./diff-simulator");
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
extractImports,
|
|
34
|
+
extractExports,
|
|
35
|
+
resolveImportPath,
|
|
36
|
+
validateImport,
|
|
37
|
+
buildImportGraph,
|
|
38
|
+
detectCircularDeps,
|
|
39
|
+
} = require("./import-resolver");
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
extractRoutes,
|
|
43
|
+
validateRoutes,
|
|
44
|
+
findRouteReferences,
|
|
45
|
+
} = require("./route-validator");
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Simulator singleton
|
|
49
|
+
*/
|
|
50
|
+
const simulator = {
|
|
51
|
+
/**
|
|
52
|
+
* Run full simulation
|
|
53
|
+
* @param {string} projectRoot - Project root directory
|
|
54
|
+
* @param {Array} changes - Array of change operations
|
|
55
|
+
* @param {Object} options - Simulation options
|
|
56
|
+
* @returns {Object} Simulation result
|
|
57
|
+
*/
|
|
58
|
+
simulate(projectRoot, changes, options = {}) {
|
|
59
|
+
return simulate(projectRoot, changes, options);
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Quick simulation for single file
|
|
64
|
+
* @param {string} projectRoot - Project root
|
|
65
|
+
* @param {string} filePath - File path
|
|
66
|
+
* @param {string} newContent - New content
|
|
67
|
+
* @param {string} oldContent - Old content (optional)
|
|
68
|
+
* @returns {Object} Simulation result
|
|
69
|
+
*/
|
|
70
|
+
quick(projectRoot, filePath, newContent, oldContent = null) {
|
|
71
|
+
return quickSimulate(projectRoot, filePath, newContent, oldContent);
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Validate imports only
|
|
76
|
+
* @param {string} projectRoot - Project root
|
|
77
|
+
* @param {Array} changes - Change operations
|
|
78
|
+
* @returns {Object} Import validation result
|
|
79
|
+
*/
|
|
80
|
+
validateImports(projectRoot, changes) {
|
|
81
|
+
const vfs = buildVirtualFS(projectRoot, changes);
|
|
82
|
+
return validateImportsAfterChanges(projectRoot, vfs);
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Validate routes only
|
|
87
|
+
* @param {Array} existingRoutes - Current routes
|
|
88
|
+
* @param {Map} changedFiles - Changed files
|
|
89
|
+
* @param {Set} deletedFiles - Deleted files
|
|
90
|
+
* @returns {Object} Route validation result
|
|
91
|
+
*/
|
|
92
|
+
validateRoutes(existingRoutes, changedFiles, deletedFiles) {
|
|
93
|
+
return validateRoutes(existingRoutes, changedFiles, deletedFiles);
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Extract imports from content
|
|
98
|
+
* @param {string} content - File content
|
|
99
|
+
* @returns {Array} Imports
|
|
100
|
+
*/
|
|
101
|
+
extractImports(content) {
|
|
102
|
+
return extractImports(content);
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Extract exports from content
|
|
107
|
+
* @param {string} content - File content
|
|
108
|
+
* @returns {Array} Exports
|
|
109
|
+
*/
|
|
110
|
+
extractExports(content) {
|
|
111
|
+
return extractExports(content);
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Extract routes from content
|
|
116
|
+
* @param {string} content - File content
|
|
117
|
+
* @param {string} filePath - File path
|
|
118
|
+
* @returns {Array} Routes
|
|
119
|
+
*/
|
|
120
|
+
extractRoutes(content, filePath) {
|
|
121
|
+
return extractRoutes(content, filePath);
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Build import graph
|
|
126
|
+
* @param {Map} files - File map
|
|
127
|
+
* @param {string} projectRoot - Project root
|
|
128
|
+
* @returns {Object} Import graph
|
|
129
|
+
*/
|
|
130
|
+
buildImportGraph(files, projectRoot) {
|
|
131
|
+
return buildImportGraph(files, projectRoot);
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Detect circular dependencies
|
|
136
|
+
* @param {Array} edges - Graph edges
|
|
137
|
+
* @returns {Array} Cycles found
|
|
138
|
+
*/
|
|
139
|
+
detectCircularDeps(edges) {
|
|
140
|
+
return detectCircularDeps(edges);
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Format result for display
|
|
145
|
+
* @param {Object} result - Simulation result
|
|
146
|
+
* @returns {string} Formatted output
|
|
147
|
+
*/
|
|
148
|
+
format(result) {
|
|
149
|
+
return formatResult(result);
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Build virtual file system from changes
|
|
154
|
+
* @param {string} projectRoot - Project root
|
|
155
|
+
* @param {Array} changes - Changes
|
|
156
|
+
* @returns {Object} Virtual FS state
|
|
157
|
+
*/
|
|
158
|
+
buildVirtualFS(projectRoot, changes) {
|
|
159
|
+
return buildVirtualFS(projectRoot, changes);
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
module.exports = {
|
|
164
|
+
simulator,
|
|
165
|
+
// Direct exports
|
|
166
|
+
simulate,
|
|
167
|
+
quickSimulate,
|
|
168
|
+
buildVirtualFS,
|
|
169
|
+
validateImportsAfterChanges,
|
|
170
|
+
detectOrphanedFiles,
|
|
171
|
+
formatResult,
|
|
172
|
+
extractImports,
|
|
173
|
+
extractExports,
|
|
174
|
+
resolveImportPath,
|
|
175
|
+
validateImport,
|
|
176
|
+
buildImportGraph,
|
|
177
|
+
detectCircularDeps,
|
|
178
|
+
extractRoutes,
|
|
179
|
+
validateRoutes,
|
|
180
|
+
findRouteReferences,
|
|
181
|
+
};
|